aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
Diffstat (limited to 'sources')
-rw-r--r--sources/pyside2/.gitattributes2
-rw-r--r--sources/pyside2/.gitignore6
-rw-r--r--sources/pyside2/CMakeLists.txt391
-rw-r--r--sources/pyside2/COPYING501
-rw-r--r--sources/pyside2/LICENSE.FDL450
-rw-r--r--sources/pyside2/LICENSE.GPL2339
-rw-r--r--sources/pyside2/LICENSE.GPL3674
-rw-r--r--sources/pyside2/LICENSE.GPL3-EXCEPT704
-rw-r--r--sources/pyside2/LICENSE.GPLv3686
-rw-r--r--sources/pyside2/LICENSE.LGPL3165
-rw-r--r--sources/pyside2/LICENSE.LGPLv21514
-rw-r--r--sources/pyside2/LICENSE.LGPLv3175
-rw-r--r--sources/pyside2/LICENSE.PREVIEW.COMMERCIAL626
-rw-r--r--sources/pyside2/PySide2/CMakeLists.txt33
-rw-r--r--sources/pyside2/PySide2/QtConcurrent/CMakeLists.txt35
-rw-r--r--sources/pyside2/PySide2/QtConcurrent/curr_errors.txt21
-rw-r--r--sources/pyside2/PySide2/QtConcurrent/typesystem_concurrent.xml57
-rw-r--r--sources/pyside2/PySide2/QtCore/CMakeLists.txt185
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp73
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp63
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp159
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h66
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp228
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp78
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core.xml.in45
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_common.xml4225
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_mac.xml57
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_win.xml90
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_x11.xml61
-rw-r--r--sources/pyside2/PySide2/QtGui/CMakeLists.txt206
-rw-r--r--sources/pyside2/PySide2/QtGui/glue/qguiapplication_init.cpp70
-rw-r--r--sources/pyside2/PySide2/QtGui/typesystem_gui.xml.in46
-rw-r--r--sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml3313
-rw-r--r--sources/pyside2/PySide2/QtGui/typesystem_gui_mac.xml50
-rw-r--r--sources/pyside2/PySide2/QtGui/typesystem_gui_win.xml42
-rw-r--r--sources/pyside2/PySide2/QtGui/typesystem_gui_x11.xml42
-rw-r--r--sources/pyside2/PySide2/QtHelp/CMakeLists.txt51
-rw-r--r--sources/pyside2/PySide2/QtHelp/typesystem_help.xml65
-rw-r--r--sources/pyside2/PySide2/QtMacExtras/CMakeLists.txt43
-rw-r--r--sources/pyside2/PySide2/QtMacExtras/typesystem_macextras.xml55
-rw-r--r--sources/pyside2/PySide2/QtMultimedia/CMakeLists.txt118
-rw-r--r--sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia.xml45
-rw-r--r--sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml365
-rw-r--r--sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_forward_declarations.xml45
-rw-r--r--sources/pyside2/PySide2/QtMultimediaWidgets/CMakeLists.txt52
-rw-r--r--sources/pyside2/PySide2/QtMultimediaWidgets/typesystem_multimediawidgets.xml52
-rw-r--r--sources/pyside2/PySide2/QtNetwork/CMakeLists.txt72
-rw-r--r--sources/pyside2/PySide2/QtNetwork/typesystem_network.xml307
-rw-r--r--sources/pyside2/PySide2/QtOpenGL/CMakeLists.txt50
-rw-r--r--sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml758
-rw-r--r--sources/pyside2/PySide2/QtPrintSupport/CMakeLists.txt48
-rw-r--r--sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml118
-rw-r--r--sources/pyside2/PySide2/QtQml/CMakeLists.txt69
-rw-r--r--sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp545
-rw-r--r--sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h85
-rw-r--r--sources/pyside2/PySide2/QtQml/typesystem_qml.xml216
-rw-r--r--sources/pyside2/PySide2/QtQuick/CMakeLists.txt100
-rw-r--r--sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp253
-rw-r--r--sources/pyside2/PySide2/QtQuick/pysidequickregistertype.h52
-rw-r--r--sources/pyside2/PySide2/QtQuick/typesystem_quick.xml174
-rw-r--r--sources/pyside2/PySide2/QtQuickWidgets/CMakeLists.txt53
-rw-r--r--sources/pyside2/PySide2/QtQuickWidgets/typesystem_quickwidgets.xml54
-rw-r--r--sources/pyside2/PySide2/QtScript/CMakeLists.txt44
-rw-r--r--sources/pyside2/PySide2/QtScript/typesystem_script.xml136
-rw-r--r--sources/pyside2/PySide2/QtScriptTools/CMakeLists.txt46
-rw-r--r--sources/pyside2/PySide2/QtScriptTools/typesystem_scripttools.xml55
-rw-r--r--sources/pyside2/PySide2/QtSql/CMakeLists.txt55
-rw-r--r--sources/pyside2/PySide2/QtSql/typesystem_sql.xml197
-rw-r--r--sources/pyside2/PySide2/QtSvg/CMakeLists.txt45
-rw-r--r--sources/pyside2/PySide2/QtSvg/typesystem_svg.xml74
-rw-r--r--sources/pyside2/PySide2/QtTest/CMakeLists.txt43
-rw-r--r--sources/pyside2/PySide2/QtTest/typesystem_test.xml166
-rw-r--r--sources/pyside2/PySide2/QtUiTools/CMakeLists.txt46
-rw-r--r--sources/pyside2/PySide2/QtUiTools/glue/plugins.h64
-rw-r--r--sources/pyside2/PySide2/QtUiTools/glue/uitools_loadui.cpp91
-rw-r--r--sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml150
-rw-r--r--sources/pyside2/PySide2/QtWebChannel/CMakeLists.txt35
-rw-r--r--sources/pyside2/PySide2/QtWebChannel/typesystem_webchannel.xml55
-rw-r--r--sources/pyside2/PySide2/QtWebEngineWidgets/CMakeLists.txt62
-rw-r--r--sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml96
-rw-r--r--sources/pyside2/PySide2/QtWebKit/CMakeLists.txt43
-rw-r--r--sources/pyside2/PySide2/QtWebKit/typesystem_webkit.xml49
-rw-r--r--sources/pyside2/PySide2/QtWebKitWidgets/CMakeLists.txt77
-rw-r--r--sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml266
-rw-r--r--sources/pyside2/PySide2/QtWebSockets/CMakeLists.txt44
-rw-r--r--sources/pyside2/PySide2/QtWebSockets/typesystem_websockets.xml78
-rw-r--r--sources/pyside2/PySide2/QtWidgets/CMakeLists.txt260
-rw-r--r--sources/pyside2/PySide2/QtWidgets/glue/qapplication_init.cpp80
-rw-r--r--sources/pyside2/PySide2/QtWidgets/glue/qlayout_help_functions.cpp161
-rw-r--r--sources/pyside2/PySide2/QtWidgets/glue/qmenu_glue.cpp60
-rw-r--r--sources/pyside2/PySide2/QtWidgets/glue/qmenubar_glue.cpp59
-rw-r--r--sources/pyside2/PySide2/QtWidgets/glue/qtwidgets_qapp.cpp49
-rw-r--r--sources/pyside2/PySide2/QtWidgets/glue/qwidget_glue.cpp104
-rw-r--r--sources/pyside2/PySide2/QtWidgets/typesystem_widgets.xml.in46
-rw-r--r--sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml3695
-rw-r--r--sources/pyside2/PySide2/QtWidgets/typesystem_widgets_mac.xml55
-rw-r--r--sources/pyside2/PySide2/QtWidgets/typesystem_widgets_win.xml42
-rw-r--r--sources/pyside2/PySide2/QtWidgets/typesystem_widgets_x11.xml42
-rw-r--r--sources/pyside2/PySide2/QtWinExtras/CMakeLists.txt51
-rw-r--r--sources/pyside2/PySide2/QtWinExtras/typesystem_winextras.xml61
-rw-r--r--sources/pyside2/PySide2/QtX11Extras/CMakeLists.txt40
-rw-r--r--sources/pyside2/PySide2/QtX11Extras/typesystem_x11extras.xml47
-rw-r--r--sources/pyside2/PySide2/QtXml/CMakeLists.txt64
-rw-r--r--sources/pyside2/PySide2/QtXml/typesystem_xml.xml438
-rw-r--r--sources/pyside2/PySide2/QtXmlPatterns/CMakeLists.txt48
-rw-r--r--sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml125
-rw-r--r--sources/pyside2/PySide2/__init__.py.in41
-rw-r--r--sources/pyside2/PySide2/_utils.py.in289
-rw-r--r--sources/pyside2/PySide2/global.h.in428
-rw-r--r--sources/pyside2/PySide2/licensecomment.txt38
-rw-r--r--sources/pyside2/PySide2/pysideqtesttouch.h227
-rw-r--r--sources/pyside2/PySide2/pysidewtypes.h66
-rw-r--r--sources/pyside2/PySide2/qpytextobject.cpp50
-rw-r--r--sources/pyside2/PySide2/qpytextobject.h63
-rw-r--r--sources/pyside2/PySide2/typesystem_templates.xml474
-rw-r--r--sources/pyside2/README.md10
-rw-r--r--sources/pyside2/cmake/Macros/FindQt5Extra.cmake25
-rw-r--r--sources/pyside2/cmake/Macros/PySideModules.cmake196
-rw-r--r--sources/pyside2/cmake/Macros/icecc.cmake11
-rw-r--r--sources/pyside2/cmake_uninstall.cmake21
-rw-r--r--sources/pyside2/doc/CMakeLists.txt59
-rw-r--r--sources/pyside2/doc/_templates/index.html70
-rw-r--r--sources/pyside2/doc/_templates/layout.html41
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/domainindex.html57
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/searchbox.html12
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/bg_header.pngbin0 -> 36012 bytes
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/bg_topo.jpgbin0 -> 14237 bytes
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/fakebar.pngbin0 -> 101 bytes
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/logo_indt.jpgbin0 -> 3138 bytes
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/logo_openbossa.pngbin0 -> 4702 bytes
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/logo_python.jpgbin0 -> 2660 bytes
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/logo_qt.pngbin0 -> 1936 bytes
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/minus.pngbin0 -> 199 bytes
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/plus.pngbin0 -> 199 bytes
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/pysidedocs.css477
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/pysidelogo.pngbin0 -> 12969 bytes
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/static/relbar_bg.pngbin0 -> 130 bytes
-rw-r--r--sources/pyside2/doc/_themes/pysidedocs/theme.conf7
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilityfactorysnippet.cpp77
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilitypluginsnippet.cpp84
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilityslidersnippet.cpp271
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/alphachannel.cpp64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/audio/main.cpp104
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/brush/brush.cpp96
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/brush/gradientcreationsnippet.cpp72
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/qt-logo.pngbin0 -> 15518 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.cpp88
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.h71
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.cpp154
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.h108
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/buffer/buffer.cpp133
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.cpp106
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.h82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/doc_src_qnamespace.qdoc67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp55
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.scripttools.qscriptenginedebugger.cpp59
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp85
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp181
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp194
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp110
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp59
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_global_qglobal.cpp514
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp112
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdatastream.cpp135
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp179
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdiriterator.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfile.cpp82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp148
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qiodevice.cpp98
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp132
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qsettings.cpp330
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtextstream.cpp140
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qurl.cpp96
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp98
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp128
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp132
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp119
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp107
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qobject.cpp369
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp71
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qtimer.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp94
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_quuid.cpp54
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp65
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qatomic.cpp108
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutex.cpp165
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp111
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp83
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qthread.cpp59
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp95
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbitarray.cpp239
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp402
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qdatetime.cpp156
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qhash.cpp309
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp214
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp277
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlocale.cpp101
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qmap.cpp323
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qpoint.cpp161
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qqueue.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qrect.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qregexp.cpp225
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qsize.cpp146
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qstring.cpp95
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qtimeline.cpp65
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qvector.cpp193
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp77
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp55
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp136
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp90
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp152
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qwizard.cpp81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp87
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp249
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp96
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp125
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp55
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp136
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qbitmap.cpp54
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qicon.cpp82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimage.cpp86
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagereader.cpp75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagewriter.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qmovie.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmap.cpp68
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapcache.cpp66
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp72
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp86
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp55
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qaction.cpp59
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication.cpp177
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp55
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qclipboard.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qevent.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qformlayout.cpp86
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayout.cpp75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcut.cpp65
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qsound.cpp59
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qwidget.cpp150
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qbrush.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qcolor.cpp59
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qdrawutil.cpp108
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qmatrix.cpp72
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainter.cpp261
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainterpath.cpp160
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpen.cpp85
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion_unix.cpp68
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qtransform.cpp88
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyle.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyleoption.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfont.cpp77
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfontmetrics.cpp64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp124
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextcursor.cpp90
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextdocument.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextlayout.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qcompleter.cpp74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp65
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qundostack.cpp120
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp83
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp89
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qframe.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlabel.cpp74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlineedit.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp65
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenu.cpp87
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenubar.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qrubberband.cpp67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp59
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qspinbox.cpp90
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp65
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplitter.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp54
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextedit.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qvalidator.cpp155
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qftp.cpp109
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qhttp.cpp132
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp86
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp92
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp78
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp71
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qtcpserver.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qudpsocket.cpp67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp54
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp55
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp100
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qgl.cpp168
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglcolormap.cpp74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp103
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_qtestlib_qtestcase.cpp237
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptable.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptclass.cpp59
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptcontext.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengine.cpp320
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengineagent.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalue.cpp91
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalueiterator.cpp78
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp146
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp56
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp55
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp88
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp88
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_svg_qgraphicssvgitem.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xml_dom_qdom.cpp230
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xml_sax_qxml.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstracturiresolver.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlforwarditerator.cpp3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlnodemodel.cpp72
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlreceiver.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qsimplexmlnodemodel.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlformatter.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlname.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp202
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp66
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlserializer.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_assistant_compat_lib_qassistantclient.cpp75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp85
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp65
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_qextensionmanager.cpp67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformeditor.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindow.cpp75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowcursor.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowmanager.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractobjectinspector.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp80
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_abstractformbuilder.cpp67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp76
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_patternist_qapplicationargumentparser.cpp55
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp94
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp97
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp66
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qttoolbardialog_qttoolbardialog.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/console/dbus_pingpong.txt3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/coordsys/coordsys.cpp86
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/customstyle.cpp98
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/customstyle.h69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/main.cpp64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/customviewstyle.cpp79
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.cpp79
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.h69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.ui389
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.ui389
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/imagedialog/main.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.h64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.ui389
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.cpp86
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.h69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.ui389
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.h67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.ui389
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dialogs/dialogs.cpp129
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/modules.html28
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtcore.html122
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtgui.html276
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtnetwork.html35
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtopengl.html27
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtsql.html39
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtxml.html53
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/titles.txt7
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.qrc12
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.cpp131
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.h80
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.cpp163
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.h89
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/main.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.cpp94
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.h81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/images.qrc5
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/images/file.pngbin0 -> 313 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/mainwindow.cpp72
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/mainwindow.h81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/window.cpp115
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/window.h81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/droparea.cpp147
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/window.cpp97
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/window.h81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/window.cpp106
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/window.h81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.cpp84
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.h69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/main.cpp64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/events/events.cpp107
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.cpp119
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.h84
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/main.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/file/file.cpp130
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/filedialogurls.cpp71
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/fileinfo/main.cpp102
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/graphicssceneadditemsnippet.cpp90
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/main.cpp64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.h69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.ts12
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/resources.qrc6
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_en.ts12
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_fr.ts13
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/image/image.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/image/supportedformat.cpp56
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/button.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/button.h69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/main.cpp76
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/itemselection/main.cpp125
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/itemselection/model.h84
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/javastyle.cpp2755
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/layouts/layouts.cpp126
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/mainwindowsnippet.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/matrix/matrix.cpp112
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/mdiareasnippets.cpp66
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/moc/main.cpp75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass1.h75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass2.h76
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass3.h69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/main.cpp78
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.cpp162
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.h80
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.cpp324
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.h100
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.cpp122
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.h78
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/myscrollarea.cpp112
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/network/tcpwait.cpp71
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/ntfsp.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/painterpath/painterpath.cpp86
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/anyHTMLElement.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/anyXLinkAttribute.xq2
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesIncluded.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesIncludedResult.xml1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesOmitted.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesOmittedResult.xml2
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/computedTreeFragment.xq14
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/copyAttribute.xq9
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/copyID.xq3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/directTreeFragment.xq7
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/doc.txt35
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML2.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML.xq10
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML2.xq10
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/emptyParagraphs.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeCurlyBraces.xq4
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xml2
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xq7
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/expressionInsideAttribute.xq2
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/filterOnPath.xq2
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/filterOnStep.xq2
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/firstParagraph.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/fnStringOnAttribute.xq9
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClause.xq3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClause2.xq3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClauseOnFeed.xq6
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/indented.xml5
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introAcneRemover.xq8
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introExample2.xq5
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introFileHierarchy.xml14
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introNavigateFS.xq12
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introductionExample.xq3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/invalidLetOrderBy.xq3
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/items.xq5
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/letOrderBy.xq4
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/literalsAndOperators.xq2
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/mobeyDick.xml4
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nextLastParagraph.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsAreExpressions.xq4
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsInPaths.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeTestChildElement.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/notIndented.xml1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/oneElementConstructor.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/paragraphsExceptTheFiveFirst.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/paragraphsWithTables.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/pathAB.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/pathsAllParagraphs.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/simpleHTML.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/simpleXHTML.xq2
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/svgDocumentElement.xml1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/tablesInParagraphs.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/twoSVGElements.xq5
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xmlStylesheet.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xsBooleanTrue.xq1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xsvgDocumentElement.xml1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.cpp130
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.h80
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/model.h81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/picture/picture.cpp121
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/window.cpp118
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/window.h71
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/pointer/pointer.cpp70
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/polygon/polygon.cpp96
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.cpp134
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.h82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/errors.cpp68
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/main.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/object.cpp81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/object.h62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/process/process.cpp86
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qabstractsliderisnippet.cpp519
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qcalendarwidget/main.cpp74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qcolumnview/main.cpp89
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qdebug/qdebugsnippet.cpp83
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-filepaths/main.cpp64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-listfiles/main.cpp64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-namefilters/main.cpp68
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qelapsedtimer/main.cpp119
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qfontdatabase/main.cpp74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qgl-namespace/main.cpp56
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlabel/main.cpp98
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/main.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.cpp77
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.h69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.cpp93
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.h71
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.cpp161
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.h73
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.cpp147
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.h82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/model.h82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.cpp97
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.h72
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.cpp168
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.h82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qmacnativewidget/main.mm144
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/delegate.h50
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/main.cpp50
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/model.cpp50
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/model.h50
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/paintwidget_unix.cpp54
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/view.h50
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.cpp67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.h68
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qprocess-environment/main.cpp88
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qprocess/qprocess-simpleexecution.cpp75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.cpp77
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.h70
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/main.cpp71
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/mainwindow.h69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/main.cpp79
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/main.cpp87
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/main.cpp66
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.h64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.qrc5
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/splash.pngbin0 -> 27926 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsql-namespace/main.cpp56
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qstack/main.cpp65
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qstackedlayout/main.cpp99
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qstackedwidget/main.cpp78
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qstandarditemmodel/main.cpp81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qstatustipevent/main.cpp74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qstringlistmodel/main.cpp78
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qstyleoption/main.cpp105
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qstyleplugin/main.cpp107
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/main.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.qrc5
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/spheres.svg79
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/sunflower.svg188
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qt-namespace/main.cpp56
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/cubed.pngbin0 -> 437 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/squared.pngbin0 -> 440 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/images.qrc6
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.cpp153
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.h78
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.cpp124
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.h77
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/cubed.pngbin0 -> 437 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/squared.pngbin0 -> 440 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/images.qrc6
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.cpp159
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.h80
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtcast/qtcast.cpp89
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtcast/qtcast.h64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtest-namespace/main.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.h72
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.cpp100
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.h71
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.cpp135
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.h81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.cpp272
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.h89
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.cpp111
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.h87
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp59
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.h87
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/evaluation/main.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/main.cpp66
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.h67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/main.cpp82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/object.js18
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.qrc5
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/main.cpp77
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/myform.ui130
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.h62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.qrc5
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedcontainer/main.cpp77
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.cpp76
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.h75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/main.cpp71
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlquery/bindingExample.cpp59
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlschema/main.cpp124
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlschemavalidator/main.cpp112
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlstreamwriter/main.cpp86
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/main.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/model.h84
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/window.cpp130
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/window.h77
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/scribe-overview/main.cpp81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/scriptdebugger.cpp113
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/separations/finalwidget.cpp136
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/separations/finalwidget.h87
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/separations/main.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/separations/screenwidget.cpp227
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/separations/screenwidget.h96
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/separations/viewer.cpp338
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/separations/viewer.h99
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/settings/settings.cpp188
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/shareddirmodel/main.cpp90
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/employee.cpp51
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/employee.h104
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/main.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/sharedtablemodel/main.cpp99
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/sharedtablemodel/model.h84
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/accountsfile.txt1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/filereader.cpp109
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/filereader.h78
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/main.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/reportfile.txt2
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/taxfile.txt1
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.cpp87
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.h98
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.cpp94
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.h99
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/simplemodel-use/main.cpp103
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/splitter/splitter.cpp76
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/main.cpp67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.cpp88
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.h61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.cpp489
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/streaming/main.cpp118
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/main.cpp89
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/model.cpp170
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/model.h82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/styles/styles.cpp80
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/stylesheet/common-mistakes.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-formats/main.cpp128
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.cpp158
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.h75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.cpp128
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.h74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.cpp166
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.h75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.cpp94
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.h71
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-charformats/main.cpp102
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-css/main.cpp58
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-cursors/main.cpp89
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-find/main.cpp101
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/main.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.cpp171
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.h74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.cpp126
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.h74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.cpp81
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.h66
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images.qrc6
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/advert.pngbin0 -> 16291 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/newimage.pngbin0 -> 5490 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/main.cpp108
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/images.qrc5
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/images/advert.pngbin0 -> 16291 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/main.cpp82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.cpp207
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.h85
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.cpp201
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.h89
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.cpp134
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.h82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.cpp213
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.h89
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/main.cpp62
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.cpp125
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.h75
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.cpp163
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.h74
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-texttable/main.cpp56
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/textdocumentendsnippet.cpp68
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/threads/threads.cpp130
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/threads/threads.h61
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/timeline/main.cpp82
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/timers/timers.cpp88
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/transform/main.cpp110
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.ui303
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/uitools/calculatorform/main.cpp67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/main.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/model.h84
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/window.cpp119
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/window.h77
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/webkit/webpage/main.cpp93
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.cpp57
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/main.cpp64
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/mask.qrc5
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/tux.pngbin0 -> 12191 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/widgetdelegate.cpp72
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/main.cpp67
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/main.cpp98
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/main.cpp63
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/main.cpp69
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.cpp188
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.h84
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/main.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.cpp255
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.h96
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.cpp148
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.h77
-rw-r--r--sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/main.cpp97
-rwxr-xr-xsources/pyside2/doc/codesnippets/examples/dbus/example-client.py100
-rwxr-xr-xsources/pyside2/doc/codesnippets/examples/dbus/example-server.py119
-rw-r--r--sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml59
-rw-r--r--sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/imageprovider/imageprovider.cpp83
-rw-r--r--sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugin.cpp68
-rw-r--r--sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugins.qml62
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.cpp259
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.qrc11
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/background.pngbin0 -> 22578 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/banner.pngbin0 -> 3947 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo1.pngbin0 -> 1619 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo2.pngbin0 -> 1619 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo3.pngbin0 -> 1619 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark1.pngbin0 -> 14516 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark2.pngbin0 -> 14912 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/main.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/extension/finddialog.cpp119
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/logo.pngbin0 -> 1810 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/watermark.pngbin0 -> 34998 bytes
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp358
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.h173
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.qrc6
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/main.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp80
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/tabdialog/tabdialog.cpp193
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp143
-rw-r--r--sources/pyside2/doc/codesnippets/examples/graphicsview/simpleanchorlayout/main.cpp72
-rw-r--r--sources/pyside2/doc/codesnippets/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp109
-rw-r--r--sources/pyside2/doc/codesnippets/examples/itemviews/pixelator/pixeldelegate.cpp103
-rw-r--r--sources/pyside2/doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp197
-rw-r--r--sources/pyside2/doc/codesnippets/examples/linguist/hellotr/main.cpp78
-rw-r--r--sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.cpp359
-rw-r--r--sources/pyside2/doc/codesnippets/examples/mainwindows/dockwidgets/mainwindow.cpp255
-rw-r--r--sources/pyside2/doc/codesnippets/examples/mainwindows/mainwindow.cpp367
-rw-r--r--sources/pyside2/doc/codesnippets/examples/mainwindows/mdi/mainwindow.cpp381
-rw-r--r--sources/pyside2/doc/codesnippets/examples/mainwindows/menus/mainwindow.cpp367
-rw-r--r--sources/pyside2/doc/codesnippets/examples/mainwindows/sdi/mainwindow.cpp60
-rw-r--r--sources/pyside2/doc/codesnippets/examples/painting/svggenerator/window.cpp107
-rw-r--r--sources/pyside2/doc/codesnippets/examples/richtext/textobject/svgtextobject.h79
-rw-r--r--sources/pyside2/doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp112
-rw-r--r--sources/pyside2/doc/codesnippets/examples/sql/relationaltablemodel/relationaltablemodel.cpp120
-rw-r--r--sources/pyside2/doc/codesnippets/examples/uitools/textfinder/textfinder.cpp141
-rw-r--r--sources/pyside2/doc/codesnippets/examples/widgets/analogclock/analogclock.cpp155
-rw-r--r--sources/pyside2/doc/codesnippets/examples/widgets/groupbox/window.cpp187
-rw-r--r--sources/pyside2/doc/codesnippets/examples/widgets/icons/iconsizespinbox.cpp72
-rw-r--r--sources/pyside2/doc/codesnippets/examples/widgets/spinboxes/window.cpp249
-rw-r--r--sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp210
-rw-r--r--sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.h90
-rw-r--r--sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp100
-rw-r--r--sources/pyside2/doc/codesnippets/snippets/customstyle/main.cpp61
-rw-r--r--sources/pyside2/doc/codesnippets/snippets/textdocument-resources/main.cpp93
-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/conf.py.in169
-rw-r--r--sources/pyside2/doc/contents.rst30
-rw-r--r--sources/pyside2/doc/extras/PySide.QtCore.ClassInfo.rst23
-rw-r--r--sources/pyside2/doc/extras/PySide.QtCore.Signal.rst39
-rw-r--r--sources/pyside2/doc/extras/PySide.QtCore.Slot.rst39
-rw-r--r--sources/pyside2/doc/extras/PySide.QtCore.rst5
-rw-r--r--sources/pyside2/doc/extras/PySide.QtGui.rst7
-rw-r--r--sources/pyside2/doc/extras/PySide.QtHelp.rst24
-rw-r--r--sources/pyside2/doc/extras/PySide.QtMultimedia.rst7
-rw-r--r--sources/pyside2/doc/extras/PySide.QtNetwork.rst5
-rw-r--r--sources/pyside2/doc/extras/PySide.QtOpenGL.rst14
-rw-r--r--sources/pyside2/doc/extras/PySide.QtScript.rst21
-rw-r--r--sources/pyside2/doc/extras/PySide.QtScriptTools.rst5
-rw-r--r--sources/pyside2/doc/extras/PySide.QtSql.rst5
-rw-r--r--sources/pyside2/doc/extras/PySide.QtSvg.rst16
-rw-r--r--sources/pyside2/doc/extras/PySide.QtTest.rst7
-rw-r--r--sources/pyside2/doc/extras/PySide.QtUiTools.rst9
-rw-r--r--sources/pyside2/doc/extras/PySide.QtWebKit.rst94
-rw-r--r--sources/pyside2/doc/extras/PySide.QtXml.rst5
-rw-r--r--sources/pyside2/doc/extras/PySide.QtXmlPatterns.rst35
-rw-r--r--sources/pyside2/doc/inheritance_diagram.py374
-rw-r--r--sources/pyside2/doc/modules.rst21
-rw-r--r--sources/pyside2/doc/pyhtml2devhelp.py256
-rw-r--r--sources/pyside2/doc/pyside.qdocconf.in269
-rw-r--r--sources/pyside2/doc/pysideapi2.rst91
-rw-r--r--sources/pyside2/doc/pysideinclude.py147
-rw-r--r--sources/pyside2/doc/pysideversion.rst31
-rw-r--r--sources/pyside2/doc/tutorials/index.rst10
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial1.pngbin0 -> 203229 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial2.pngbin0 -> 249451 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial3.pngbin0 -> 283378 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial4.gifbin0 -> 1687445 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-samegame.pngbin0 -> 124904 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/index.rst34
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame.tar.bz2bin0 -> 60105 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/Block.qml63
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/Button.qml93
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/samegame.qml92
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/samegame1.qmlproject16
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/Block.qml61
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/Button.qml91
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame.js63
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame.qml95
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame2.qmlproject16
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Block.qml73
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Button.qml91
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Dialog.qml81
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame.js174
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame.qml119
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame3.qmlproject16
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/BoomBlock.qml132
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/Button.qml91
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/Dialog.qml117
-rwxr-xr-xsources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/samegame.js225
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/README1
-rwxr-xr-xsources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_data.xml2
-rwxr-xr-xsources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_style.xsl28
-rwxr-xr-xsources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/scores.php31
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/samegame.qml125
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/samegame4.qmlproject16
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/background.jpgbin0 -> 36473 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/blueStar.pngbin0 -> 278 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/blueStone.pngbin0 -> 3054 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/greenStar.pngbin0 -> 273 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/greenStone.pngbin0 -> 2932 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/redStar.pngbin0 -> 274 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/redStone.pngbin0 -> 2902 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/star.pngbin0 -> 262 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/yellowStone.pngbin0 -> 3056 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame1.rst70
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame2.rst71
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame3.rst95
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame4.rst187
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial1.pngbin0 -> 3577 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial2.pngbin0 -> 3913 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial3_animation.gifbin0 -> 301974 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/helloworld.tar.bz2bin0 -> 2401 bytes
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/helloworld/Cell.qml82
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial1.qml73
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial2.qml82
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial3.qml101
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/index.rst25
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/step1.rst66
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/step2.rst81
-rw-r--r--sources/pyside2/doc/tutorials/qmltutorial/step3.rst47
-rw-r--r--sources/pyside2/doc/typesystem_doc.xml.in125
-rw-r--r--sources/pyside2/header.BSD50
-rw-r--r--sources/pyside2/header.BSD-OLD40
-rw-r--r--sources/pyside2/header.COMM20
-rw-r--r--sources/pyside2/header.FDL27
-rw-r--r--sources/pyside2/header.FDL-OLD27
-rw-r--r--sources/pyside2/header.GPL29
-rw-r--r--sources/pyside2/header.GPL-EXCEPT28
-rw-r--r--sources/pyside2/header.LGPL-NOGPL237
-rw-r--r--sources/pyside2/header.LGPL-ONLY22
-rw-r--r--sources/pyside2/header.LGPL2133
-rw-r--r--sources/pyside2/header.LGPL336
-rw-r--r--sources/pyside2/header.LGPL3-COMM28
-rw-r--r--sources/pyside2/libpyside/CMakeLists.txt166
-rw-r--r--sources/pyside2/libpyside/PySide2Config-spec.cmake.in18
-rw-r--r--sources/pyside2/libpyside/PySide2Config.cmake.in5
-rw-r--r--sources/pyside2/libpyside/PySide2ConfigVersion.cmake.in10
-rw-r--r--sources/pyside2/libpyside/destroylistener.cpp106
-rw-r--r--sources/pyside2/libpyside/destroylistener.h72
-rw-r--r--sources/pyside2/libpyside/dynamicqmetaobject.cpp901
-rw-r--r--sources/pyside2/libpyside/dynamicqmetaobject.h82
-rw-r--r--sources/pyside2/libpyside/dynamicqmetaobject_p.h108
-rw-r--r--sources/pyside2/libpyside/globalreceiver.cpp330
-rw-r--r--sources/pyside2/libpyside/globalreceiver.h80
-rw-r--r--sources/pyside2/libpyside/globalreceiverv2.cpp358
-rw-r--r--sources/pyside2/libpyside/globalreceiverv2.h149
-rw-r--r--sources/pyside2/libpyside/pyside.cpp387
-rw-r--r--sources/pyside2/libpyside/pyside.h157
-rw-r--r--sources/pyside2/libpyside/pyside2.pc.in14
-rw-r--r--sources/pyside2/libpyside/pysideclassinfo.cpp229
-rw-r--r--sources/pyside2/libpyside/pysideclassinfo.h68
-rw-r--r--sources/pyside2/libpyside/pysideclassinfo_p.h72
-rw-r--r--sources/pyside2/libpyside/pysideconversions.h275
-rw-r--r--sources/pyside2/libpyside/pysidemacros.h64
-rw-r--r--sources/pyside2/libpyside/pysidemetafunction.cpp253
-rw-r--r--sources/pyside2/libpyside/pysidemetafunction.h76
-rw-r--r--sources/pyside2/libpyside/pysidemetafunction_p.h62
-rw-r--r--sources/pyside2/libpyside/pysideproperty.cpp519
-rw-r--r--sources/pyside2/libpyside/pysideproperty.h117
-rw-r--r--sources/pyside2/libpyside/pysideproperty_p.h184
-rw-r--r--sources/pyside2/libpyside/pysideqflags.cpp167
-rw-r--r--sources/pyside2/libpyside/pysideqflags.h79
-rw-r--r--sources/pyside2/libpyside/pysidesignal.cpp1070
-rw-r--r--sources/pyside2/libpyside/pysidesignal.h173
-rw-r--r--sources/pyside2/libpyside/pysidesignal_p.h82
-rw-r--r--sources/pyside2/libpyside/pysideslot.cpp220
-rw-r--r--sources/pyside2/libpyside/pysideslot_p.h49
-rw-r--r--sources/pyside2/libpyside/pysideweakref.cpp141
-rw-r--r--sources/pyside2/libpyside/pysideweakref.h56
-rw-r--r--sources/pyside2/libpyside/signalmanager.cpp.in726
-rw-r--r--sources/pyside2/libpyside/signalmanager.h123
-rw-r--r--sources/pyside2/plugins/CMakeLists.txt36
-rw-r--r--sources/pyside2/plugins/customwidget.cpp148
-rw-r--r--sources/pyside2/plugins/customwidget.h81
-rw-r--r--sources/pyside2/plugins/customwidgets.cpp84
-rw-r--r--sources/pyside2/plugins/customwidgets.h71
-rw-r--r--sources/pyside2/tests/CMakeLists.txt61
-rw-r--r--sources/pyside2/tests/QtConcurrent/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtConcurrent/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtCore/CMakeLists.txt121
-rw-r--r--sources/pyside2/tests/QtCore/blocking_signals_test.py134
-rw-r--r--sources/pyside2/tests/QtCore/bug_1019.py60
-rw-r--r--sources/pyside2/tests/QtCore/bug_1031.py33
-rw-r--r--sources/pyside2/tests/QtCore/bug_1063.py58
-rw-r--r--sources/pyside2/tests/QtCore/bug_1069.py50
-rw-r--r--sources/pyside2/tests/QtCore/bug_278_test.py52
-rw-r--r--sources/pyside2/tests/QtCore/bug_332.py46
-rw-r--r--sources/pyside2/tests/QtCore/bug_408.py56
-rw-r--r--sources/pyside2/tests/QtCore/bug_428.py46
-rw-r--r--sources/pyside2/tests/QtCore/bug_462.py74
-rw-r--r--sources/pyside2/tests/QtCore/bug_505.py50
-rw-r--r--sources/pyside2/tests/QtCore/bug_515.py46
-rw-r--r--sources/pyside2/tests/QtCore/bug_606.py62
-rw-r--r--sources/pyside2/tests/QtCore/bug_656.py37
-rw-r--r--sources/pyside2/tests/QtCore/bug_686.py116
-rw-r--r--sources/pyside2/tests/QtCore/bug_699.py45
-rw-r--r--sources/pyside2/tests/QtCore/bug_706.py55
-rw-r--r--sources/pyside2/tests/QtCore/bug_820.py97
-rw-r--r--sources/pyside2/tests/QtCore/bug_826.py57
-rw-r--r--sources/pyside2/tests/QtCore/bug_829.py50
-rw-r--r--sources/pyside2/tests/QtCore/bug_835.py93
-rw-r--r--sources/pyside2/tests/QtCore/bug_920.py53
-rw-r--r--sources/pyside2/tests/QtCore/bug_927.py52
-rw-r--r--sources/pyside2/tests/QtCore/bug_931.py49
-rw-r--r--sources/pyside2/tests/QtCore/bug_938.py42
-rw-r--r--sources/pyside2/tests/QtCore/bug_953.py46
-rw-r--r--sources/pyside2/tests/QtCore/bug_987.py43
-rw-r--r--sources/pyside2/tests/QtCore/bug_994.py54
-rw-r--r--sources/pyside2/tests/QtCore/bug_PYSIDE-164.py69
-rw-r--r--sources/pyside2/tests/QtCore/bug_PYSIDE-42.py44
-rw-r--r--sources/pyside2/tests/QtCore/child_event_test.py81
-rw-r--r--sources/pyside2/tests/QtCore/classinfo_test.py110
-rw-r--r--sources/pyside2/tests/QtCore/deepcopy_test.py111
-rw-r--r--sources/pyside2/tests/QtCore/deletelater_test.py50
-rw-r--r--sources/pyside2/tests/QtCore/destroysignal_test.py55
-rw-r--r--sources/pyside2/tests/QtCore/duck_punching_test.py102
-rw-r--r--sources/pyside2/tests/QtCore/hash_test.py86
-rw-r--r--sources/pyside2/tests/QtCore/inherits_test.py44
-rw-r--r--sources/pyside2/tests/QtCore/max_signals.py62
-rw-r--r--sources/pyside2/tests/QtCore/missing_symbols_test.py43
-rw-r--r--sources/pyside2/tests/QtCore/mockclass_test.py55
-rw-r--r--sources/pyside2/tests/QtCore/python_conversion.py93
-rw-r--r--sources/pyside2/tests/QtCore/qabs_test.py48
-rw-r--r--sources/pyside2/tests/QtCore/qabstractitemmodel_test.py56
-rw-r--r--sources/pyside2/tests/QtCore/qabstracttransition_test.py184
-rw-r--r--sources/pyside2/tests/QtCore/qanimationgroup_test.py53
-rw-r--r--sources/pyside2/tests/QtCore/qbitarray_test.py148
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_buffer_protocol_test.py53
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py72
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py92
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_operator_test.py116
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_test.py194
-rw-r--r--sources/pyside2/tests/QtCore/qcollator_test.py61
-rw-r--r--sources/pyside2/tests/QtCore/qcommandlineparser_test.py56
-rw-r--r--sources/pyside2/tests/QtCore/qcoreapplication_instance_test.py49
-rw-r--r--sources/pyside2/tests/QtCore/qdatastream_test.py355
-rw-r--r--sources/pyside2/tests/QtCore/qdate_test.py62
-rw-r--r--sources/pyside2/tests/QtCore/qdatetime_test.py51
-rw-r--r--sources/pyside2/tests/QtCore/qeasingcurve_test.py54
-rw-r--r--sources/pyside2/tests/QtCore/qenum_test.py74
-rw-r--r--sources/pyside2/tests/QtCore/qevent_test.py53
-rw-r--r--sources/pyside2/tests/QtCore/qfile_test.py88
-rw-r--r--sources/pyside2/tests/QtCore/qfileinfo_test.py44
-rw-r--r--sources/pyside2/tests/QtCore/qflags_test.py121
-rw-r--r--sources/pyside2/tests/QtCore/qhandle_test.py45
-rw-r--r--sources/pyside2/tests/QtCore/qinstallmsghandler_test.py80
-rw-r--r--sources/pyside2/tests/QtCore/qlinef_test.py49
-rw-r--r--sources/pyside2/tests/QtCore/qlocale_test.py69
-rw-r--r--sources/pyside2/tests/QtCore/qmetaobject_test.py84
-rw-r--r--sources/pyside2/tests/QtCore/qmimedatabase_test.py78
-rw-r--r--sources/pyside2/tests/QtCore/qmodelindex_internalpointer_test.py78
-rw-r--r--sources/pyside2/tests/QtCore/qobject_children_segfault_test.py56
-rw-r--r--sources/pyside2/tests/QtCore/qobject_connect_notify_test.py104
-rw-r--r--sources/pyside2/tests/QtCore/qobject_destructor.py47
-rw-r--r--sources/pyside2/tests/QtCore/qobject_event_filter_test.py143
-rw-r--r--sources/pyside2/tests/QtCore/qobject_inherits_test.py91
-rw-r--r--sources/pyside2/tests/QtCore/qobject_objectproperty_test.py58
-rw-r--r--sources/pyside2/tests/QtCore/qobject_parent_test.py287
-rw-r--r--sources/pyside2/tests/QtCore/qobject_property_test.py69
-rw-r--r--sources/pyside2/tests/QtCore/qobject_protected_methods_test.py67
-rw-r--r--sources/pyside2/tests/QtCore/qobject_test.py72
-rw-r--r--sources/pyside2/tests/QtCore/qobject_timer_event_test.py73
-rw-r--r--sources/pyside2/tests/QtCore/qobject_tr_as_instance_test.py67
-rw-r--r--sources/pyside2/tests/QtCore/qpoint_test.py48
-rw-r--r--sources/pyside2/tests/QtCore/qprocess_test.py58
-rw-r--r--sources/pyside2/tests/QtCore/qproperty_decorator.py63
-rw-r--r--sources/pyside2/tests/QtCore/qrect_test.py141
-rw-r--r--sources/pyside2/tests/QtCore/qregexp_test.py48
-rw-r--r--sources/pyside2/tests/QtCore/qresource_test.py70
-rw-r--r--sources/pyside2/tests/QtCore/qsize_test.py55
-rw-r--r--sources/pyside2/tests/QtCore/qslot_object_test.py76
-rw-r--r--sources/pyside2/tests/QtCore/qsrand_test.py44
-rw-r--r--sources/pyside2/tests/QtCore/qstandardpaths_test.py50
-rw-r--r--sources/pyside2/tests/QtCore/qstate_test.py64
-rw-r--r--sources/pyside2/tests/QtCore/qstatemachine_test.py97
-rw-r--r--sources/pyside2/tests/QtCore/qstorageinfo_test.py43
-rw-r--r--sources/pyside2/tests/QtCore/qstring_test.py51
-rw-r--r--sources/pyside2/tests/QtCore/qsysinfo_test.py42
-rw-r--r--sources/pyside2/tests/QtCore/qtext_codec_test.py48
-rw-r--r--sources/pyside2/tests/QtCore/qtextstream_test.py115
-rw-r--r--sources/pyside2/tests/QtCore/qthread_prod_cons_test.py136
-rw-r--r--sources/pyside2/tests/QtCore/qthread_signal_test.py91
-rw-r--r--sources/pyside2/tests/QtCore/qthread_test.py108
-rw-r--r--sources/pyside2/tests/QtCore/qtimer_singleshot_test.py106
-rw-r--r--sources/pyside2/tests/QtCore/qtimer_timeout_test.py87
-rw-r--r--sources/pyside2/tests/QtCore/qtnamespace_test.py48
-rw-r--r--sources/pyside2/tests/QtCore/quoteEnUS.txt1
-rw-r--r--sources/pyside2/tests/QtCore/qurl_test.py125
-rw-r--r--sources/pyside2/tests/QtCore/repr_test.py105
-rw-r--r--sources/pyside2/tests/QtCore/resources.qrc7
-rw-r--r--sources/pyside2/tests/QtCore/resources_mc.py3571
-rw-r--r--sources/pyside2/tests/QtCore/sample.pngbin0 -> 55944 bytes
-rw-r--r--sources/pyside2/tests/QtCore/setprop_on_ctor_test.py41
-rw-r--r--sources/pyside2/tests/QtCore/staticMetaObject_test.py51
-rw-r--r--sources/pyside2/tests/QtCore/static_method_test.py84
-rw-r--r--sources/pyside2/tests/QtCore/static_protected_methods_test.py59
-rw-r--r--sources/pyside2/tests/QtCore/thread_signals_test.py61
-rw-r--r--sources/pyside2/tests/QtCore/tr_noop_test.py76
-rw-r--r--sources/pyside2/tests/QtCore/translation_test.py85
-rw-r--r--sources/pyside2/tests/QtCore/translations/trans_latin.qmbin0 -> 125 bytes
-rw-r--r--sources/pyside2/tests/QtCore/translations/trans_latin.ts11
-rw-r--r--sources/pyside2/tests/QtCore/translations/trans_russian.qmbin0 -> 114 bytes
-rw-r--r--sources/pyside2/tests/QtCore/translations/trans_russian.ts11
-rw-r--r--sources/pyside2/tests/QtCore/unaryoperator_test.py67
-rw-r--r--sources/pyside2/tests/QtCore/unicode_test.py62
-rw-r--r--sources/pyside2/tests/QtCore/versioninfo_test.py48
-rw-r--r--sources/pyside2/tests/QtDesigner/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtDesigner/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtGui/CMakeLists.txt47
-rw-r--r--sources/pyside2/tests/QtGui/bug_1091.py40
-rw-r--r--sources/pyside2/tests/QtGui/bug_300_test.py45
-rw-r--r--sources/pyside2/tests/QtGui/bug_367.py50
-rw-r--r--sources/pyside2/tests/QtGui/bug_480.py53
-rw-r--r--sources/pyside2/tests/QtGui/bug_500.py43
-rw-r--r--sources/pyside2/tests/QtGui/bug_606.py54
-rw-r--r--sources/pyside2/tests/QtGui/bug_617.py49
-rw-r--r--sources/pyside2/tests/QtGui/bug_652.py58
-rw-r--r--sources/pyside2/tests/QtGui/bug_660.py55
-rw-r--r--sources/pyside2/tests/QtGui/bug_716.py37
-rw-r--r--sources/pyside2/tests/QtGui/bug_740.py41
-rw-r--r--sources/pyside2/tests/QtGui/bug_743.py43
-rw-r--r--sources/pyside2/tests/QtGui/bug_991.py43
-rw-r--r--sources/pyside2/tests/QtGui/bug_PYSIDE-344.py64
-rw-r--r--sources/pyside2/tests/QtGui/bug_PYSIDE-41.py72
-rw-r--r--sources/pyside2/tests/QtGui/deepcopy_test.py150
-rw-r--r--sources/pyside2/tests/QtGui/float_to_int_implicit_conversion_test.py59
-rw-r--r--sources/pyside2/tests/QtGui/pyside_reload_test.py84
-rw-r--r--sources/pyside2/tests/QtGui/qcolor_reduce_test.py59
-rw-r--r--sources/pyside2/tests/QtGui/qcolor_test.py122
-rw-r--r--sources/pyside2/tests/QtGui/qcursor_test.py44
-rw-r--r--sources/pyside2/tests/QtGui/qdatastream_gui_operators_test.py63
-rw-r--r--sources/pyside2/tests/QtGui/qdesktopservices_test.py43
-rw-r--r--sources/pyside2/tests/QtGui/qfontmetrics_test.py226
-rw-r--r--sources/pyside2/tests/QtGui/qicon_test.py44
-rw-r--r--sources/pyside2/tests/QtGui/qitemselection_test.py47
-rw-r--r--sources/pyside2/tests/QtGui/qkeysequence_test.py48
-rw-r--r--sources/pyside2/tests/QtGui/qmatrix_test.py86
-rw-r--r--sources/pyside2/tests/QtGui/qopenglbuffer_test.py93
-rw-r--r--sources/pyside2/tests/QtGui/qpainter_test.py111
-rw-r--r--sources/pyside2/tests/QtGui/qpdfwriter_test.py47
-rw-r--r--sources/pyside2/tests/QtGui/qpixelformat_test.py50
-rw-r--r--sources/pyside2/tests/QtGui/qpixmap_test.py85
-rw-r--r--sources/pyside2/tests/QtGui/qpixmapcache_test.py72
-rw-r--r--sources/pyside2/tests/QtGui/qpolygonf_test.py55
-rw-r--r--sources/pyside2/tests/QtGui/qradialgradient_test.py57
-rw-r--r--sources/pyside2/tests/QtGui/qrasterwindow_test.py86
-rw-r--r--sources/pyside2/tests/QtGui/qregion_test.py49
-rw-r--r--sources/pyside2/tests/QtGui/qstylehints_test.py42
-rw-r--r--sources/pyside2/tests/QtGui/qtextdocument_undoredo_test.py58
-rw-r--r--sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py47
-rw-r--r--sources/pyside2/tests/QtGui/qtextline_test.py50
-rw-r--r--sources/pyside2/tests/QtGui/qtransform_test.py101
-rw-r--r--sources/pyside2/tests/QtGui/repr_test.py117
-rw-r--r--sources/pyside2/tests/QtGui/sample.pngbin0 -> 55944 bytes
-rw-r--r--sources/pyside2/tests/QtGui/timed_app_test.py41
-rw-r--r--sources/pyside2/tests/QtHelp/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtHelp/help_test.py41
-rw-r--r--sources/pyside2/tests/QtMacExtras/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtMacExtras/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtMultimedia/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtMultimedia/audio_test.py71
-rw-r--r--sources/pyside2/tests/QtMultimediaWidgets/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtMultimediaWidgets/qmultimediawidgets.py59
-rw-r--r--sources/pyside2/tests/QtNetwork/CMakeLists.txt7
-rw-r--r--sources/pyside2/tests/QtNetwork/accessManager_test.py71
-rw-r--r--sources/pyside2/tests/QtNetwork/bug_1084.py44
-rw-r--r--sources/pyside2/tests/QtNetwork/bug_446.py76
-rw-r--r--sources/pyside2/tests/QtNetwork/qipv6address_test.py50
-rw-r--r--sources/pyside2/tests/QtNetwork/tcpserver_test.py52
-rw-r--r--sources/pyside2/tests/QtNetwork/udpsocket_test.py78
-rw-r--r--sources/pyside2/tests/QtOpenGL/CMakeLists.txt2
-rw-r--r--sources/pyside2/tests/QtOpenGL/qglbuffer_test.py72
-rw-r--r--sources/pyside2/tests/QtOpenGL/qglwidget_test.py47
-rw-r--r--sources/pyside2/tests/QtPrintSupport/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtPrintSupport/this_module_loads_test.py39
-rwxr-xr-xsources/pyside2/tests/QtQml/CMakeLists.txt20
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_1029.py58
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_1029.qml43
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_451.py100
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_451.qml54
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_456.py70
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_456.qml59
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_557.py43
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_726.py71
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_726.qml59
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_814.py73
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_814.qml36
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_825.py82
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_825.qml38
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_847.py79
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_847.qml62
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_915.py58
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_926.py69
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_926.qml45
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_951.py61
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_951.qml35
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_995.py43
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_995.qml40
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_997.py52
-rwxr-xr-xsources/pyside2/tests/QtQml/bug_997.qml34
-rw-r--r--sources/pyside2/tests/QtQml/connect_python_qml.py65
-rwxr-xr-xsources/pyside2/tests/QtQml/connect_python_qml.qml48
-rwxr-xr-xsources/pyside2/tests/QtQml/hw.qml48
-rw-r--r--sources/pyside2/tests/QtQml/javascript_exceptions.py103
-rw-r--r--sources/pyside2/tests/QtQml/javascript_exceptions.qml53
-rw-r--r--sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile.py96
-rw-r--r--sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile.qml67
-rw-r--r--sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile_component.qml35
-rwxr-xr-xsources/pyside2/tests/QtQml/qqmlnetwork_test.py70
-rw-r--r--sources/pyside2/tests/QtQml/qquickitem_grabToImage.py79
-rw-r--r--sources/pyside2/tests/QtQml/qquickitem_grabToImage.qml69
-rwxr-xr-xsources/pyside2/tests/QtQml/qquickview_test.py86
-rwxr-xr-xsources/pyside2/tests/QtQml/registertype.py118
-rwxr-xr-xsources/pyside2/tests/QtQml/registertype.qml57
-rwxr-xr-xsources/pyside2/tests/QtQml/view.qml43
-rwxr-xr-xsources/pyside2/tests/QtQml/viewmodel.qml42
-rw-r--r--sources/pyside2/tests/QtQuick/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtQuick/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtQuickWidgets/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtQuickWidgets/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtScript/CMakeLists.txt5
-rw-r--r--sources/pyside2/tests/QtScript/base_test.py32
-rw-r--r--sources/pyside2/tests/QtScript/bug_1022.py41
-rw-r--r--sources/pyside2/tests/QtScript/engine_test.py41
-rw-r--r--sources/pyside2/tests/QtScript/property_test.py90
-rw-r--r--sources/pyside2/tests/QtScript/qscriptvalue_test.py72
-rw-r--r--sources/pyside2/tests/QtScriptTools/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtScriptTools/debugger_test.py75
-rw-r--r--sources/pyside2/tests/QtSql/CMakeLists.txt3
-rw-r--r--sources/pyside2/tests/QtSql/bug_1013.py58
-rw-r--r--sources/pyside2/tests/QtSql/qsqldatabaseandqueries_test.py99
-rw-r--r--sources/pyside2/tests/QtSql/qvarianttype_test.py62
-rw-r--r--sources/pyside2/tests/QtSvg/CMakeLists.txt3
-rw-r--r--sources/pyside2/tests/QtSvg/qsvggenerator_test.py63
-rw-r--r--sources/pyside2/tests/QtSvg/qsvgrenderer_test.py53
-rw-r--r--sources/pyside2/tests/QtSvg/qsvgwidget_test.py55
-rw-r--r--sources/pyside2/tests/QtSvg/tiger.svg730
-rw-r--r--sources/pyside2/tests/QtTest/CMakeLists.txt3
-rw-r--r--sources/pyside2/tests/QtTest/click_test.py55
-rw-r--r--sources/pyside2/tests/QtTest/eventfilter_test.py75
-rw-r--r--sources/pyside2/tests/QtTest/touchevent_test.py77
-rw-r--r--sources/pyside2/tests/QtUiTools/CMakeLists.txt13
-rw-r--r--sources/pyside2/tests/QtUiTools/action.ui16
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_1060.py46
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_1060.ui19
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_360.py64
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_376.py47
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_392.py75
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_426.py46
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_426.ui19
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_552.py49
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_552.ui42
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_797.py39
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_909.py52
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_909.ui31
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_913.py51
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_913.ui57
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_958.py52
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_958.ui48
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_965.py48
-rw-r--r--sources/pyside2/tests/QtUiTools/bug_965.ui27
-rw-r--r--sources/pyside2/tests/QtUiTools/minimal.ui6
-rw-r--r--sources/pyside2/tests/QtUiTools/pycustomwidget.ui36
-rw-r--r--sources/pyside2/tests/QtUiTools/pycustomwidget2.ui48
-rw-r--r--sources/pyside2/tests/QtUiTools/test.ui48
-rw-r--r--sources/pyside2/tests/QtUiTools/ui_test.py41
-rw-r--r--sources/pyside2/tests/QtUiTools/uiloader_test.py71
-rw-r--r--sources/pyside2/tests/QtWebChannel/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtWebChannel/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtWebEngine/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtWebEngine/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtWebEngineWidgets/CMakeLists.txt29
-rw-r--r--sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py49
-rw-r--r--sources/pyside2/tests/QtWebEngineWidgets/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtWebKit/CMakeLists.txt11
-rw-r--r--sources/pyside2/tests/QtWebKit/bug_448.py47
-rw-r--r--sources/pyside2/tests/QtWebKit/bug_694.py78
-rw-r--r--sources/pyside2/tests/QtWebKit/bug_803.py46
-rw-r--r--sources/pyside2/tests/QtWebKit/bug_899.py64
-rw-r--r--sources/pyside2/tests/QtWebKit/bug_959.py128
-rw-r--r--sources/pyside2/tests/QtWebKit/fox.html7
-rw-r--r--sources/pyside2/tests/QtWebKit/qml_plugin_test.py88
-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.py71
-rw-r--r--sources/pyside2/tests/QtWebKit/shouldInterruptjavascript_test.py56
-rw-r--r--sources/pyside2/tests/QtWebKit/webframe_test.py62
-rw-r--r--sources/pyside2/tests/QtWebKit/webpage_test.py88
-rw-r--r--sources/pyside2/tests/QtWebKit/webview_test.py94
-rw-r--r--sources/pyside2/tests/QtWebKitWidgets/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtWebKitWidgets/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtWebSockets/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtWebSockets/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtWidgets/CMakeLists.txt134
-rw-r--r--sources/pyside2/tests/QtWidgets/action_clear.py74
-rw-r--r--sources/pyside2/tests/QtWidgets/add_action_test.py71
-rw-r--r--sources/pyside2/tests/QtWidgets/api2_test.py89
-rw-r--r--sources/pyside2/tests/QtWidgets/application_test.py51
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_1002.py47
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_1006.py111
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_1048.py36
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_1077.py45
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_172.py41
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_243.py45
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_307.py54
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_324.py60
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_338.py55
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_363.py54
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_389.py43
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_400.py54
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_416.py71
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_429.py38
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_430.py42
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_433.py43
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_467.py47
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_493.py51
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_512.py50
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_525.py49
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_546.py42
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_547.py85
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_549.py44
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_569.py47
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_575.py48
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_576.py62
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_585.py54
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_589.py47
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_632.py48
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_635.py57
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_640.py39
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_653.py45
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_662.py57
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_667.py53
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_668.py50
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_674.py51
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_675.py43
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_688.py116
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_693.py58
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_696.py55
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_711.py53
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_714.py50
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_722.py52
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_728.py36
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_736.py47
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_750.py54
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_778.py50
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_785.py58
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_793.py58
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_811.py61
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_834.py46
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_836.py56
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_844.py46
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_854.py68
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_860.py63
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_862.py67
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_871.py70
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_879.py58
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_919.py66
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_921.py79
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_941.py45
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_964.py47
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_967.py46
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_972.py67
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_979.py37
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_988.py46
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_998.py38
-rw-r--r--sources/pyside2/tests/QtWidgets/customproxywidget_test.py62
-rw-r--r--sources/pyside2/tests/QtWidgets/event_filter_test.py67
-rw-r--r--sources/pyside2/tests/QtWidgets/grandparent_method_test.py50
-rw-r--r--sources/pyside2/tests/QtWidgets/hashabletype_test.py46
-rw-r--r--sources/pyside2/tests/QtWidgets/import_test.py2
-rw-r--r--sources/pyside2/tests/QtWidgets/keep_reference_test.py103
-rw-r--r--sources/pyside2/tests/QtWidgets/missing_symbols_test.py57
-rw-r--r--sources/pyside2/tests/QtWidgets/paint_event_test.py98
-rw-r--r--sources/pyside2/tests/QtWidgets/parent_method_test.py52
-rw-r--r--sources/pyside2/tests/QtWidgets/python_properties_test.py44
-rw-r--r--sources/pyside2/tests/QtWidgets/qabstracttextdocumentlayout_test.py75
-rw-r--r--sources/pyside2/tests/QtWidgets/qaction_test.py69
-rw-r--r--sources/pyside2/tests/QtWidgets/qapp_test.py46
-rw-r--r--sources/pyside2/tests/QtWidgets/qapplication_exit_segfault_test.py44
-rw-r--r--sources/pyside2/tests/QtWidgets/qapplication_singleton_test.py39
-rw-r--r--sources/pyside2/tests/QtWidgets/qbrush_test.py52
-rw-r--r--sources/pyside2/tests/QtWidgets/qdynamic_signal.py55
-rw-r--r--sources/pyside2/tests/QtWidgets/qfontdialog_test.py51
-rw-r--r--sources/pyside2/tests/QtWidgets/qformlayout_test.py84
-rw-r--r--sources/pyside2/tests/QtWidgets/qgraphicsitem_isblocked_test.py58
-rw-r--r--sources/pyside2/tests/QtWidgets/qgraphicsitem_test.py63
-rw-r--r--sources/pyside2/tests/QtWidgets/qgraphicsproxywidget_test.py58
-rw-r--r--sources/pyside2/tests/QtWidgets/qgraphicsscene_test.py197
-rw-r--r--sources/pyside2/tests/QtWidgets/qimage_test.py308
-rw-r--r--sources/pyside2/tests/QtWidgets/qinputdialog_get_test.py52
-rw-r--r--sources/pyside2/tests/QtWidgets/qkeysequenceedit_test.py46
-rw-r--r--sources/pyside2/tests/QtWidgets/qlayout_ref_test.py179
-rw-r--r--sources/pyside2/tests/QtWidgets/qlayout_test.py140
-rw-r--r--sources/pyside2/tests/QtWidgets/qlcdnumber_test.py44
-rw-r--r--sources/pyside2/tests/QtWidgets/qlistwidget_test.py82
-rw-r--r--sources/pyside2/tests/QtWidgets/qlistwidgetitem_test.py56
-rw-r--r--sources/pyside2/tests/QtWidgets/qmainwindow_test.py113
-rw-r--r--sources/pyside2/tests/QtWidgets/qmenu_test.py86
-rw-r--r--sources/pyside2/tests/QtWidgets/qmenuadd_test.py53
-rw-r--r--sources/pyside2/tests/QtWidgets/qobject_mi_test.py70
-rw-r--r--sources/pyside2/tests/QtWidgets/qpen_test.py72
-rw-r--r--sources/pyside2/tests/QtWidgets/qpicture_test.py66
-rw-r--r--sources/pyside2/tests/QtWidgets/qpixmap_constructor.py279
-rw-r--r--sources/pyside2/tests/QtWidgets/qpushbutton_test.py69
-rw-r--r--sources/pyside2/tests/QtWidgets/qshortcut_test.py76
-rw-r--r--sources/pyside2/tests/QtWidgets/qsplitter_test.py44
-rw-r--r--sources/pyside2/tests/QtWidgets/qstandarditemmodel_test.py112
-rw-r--r--sources/pyside2/tests/QtWidgets/qstring_qkeysequence_test.py61
-rw-r--r--sources/pyside2/tests/QtWidgets/qstyle_test.py59
-rw-r--r--sources/pyside2/tests/QtWidgets/qtableview_test.py44
-rw-r--r--sources/pyside2/tests/QtWidgets/qtabwidget_test.py56
-rw-r--r--sources/pyside2/tests/QtWidgets/qtextedit_signal_test.py65
-rw-r--r--sources/pyside2/tests/QtWidgets/qtextedit_test.py60
-rw-r--r--sources/pyside2/tests/QtWidgets/qtoolbar_test.py62
-rw-r--r--sources/pyside2/tests/QtWidgets/qtoolbox_test.py59
-rw-r--r--sources/pyside2/tests/QtWidgets/qvalidator_test.py114
-rw-r--r--sources/pyside2/tests/QtWidgets/qvariant_test.py50
-rw-r--r--sources/pyside2/tests/QtWidgets/qwidget_setlayout_test.py61
-rw-r--r--sources/pyside2/tests/QtWidgets/qwidget_test.py55
-rw-r--r--sources/pyside2/tests/QtWidgets/reference_count_test.py99
-rw-r--r--sources/pyside2/tests/QtWidgets/returnquadruplesofnumbers_test.py95
-rw-r--r--sources/pyside2/tests/QtWidgets/sample.pngbin0 -> 55944 bytes
-rw-r--r--sources/pyside2/tests/QtWidgets/standardpixmap_test.py43
-rw-r--r--sources/pyside2/tests/QtWidgets/test_module_template.py40
-rw-r--r--sources/pyside2/tests/QtWidgets/virtual_protected_inheritance_test.py97
-rw-r--r--sources/pyside2/tests/QtWidgets/virtual_pure_override_test.py77
-rw-r--r--sources/pyside2/tests/QtWidgets/wrong_return_test.py58
-rw-r--r--sources/pyside2/tests/QtWinExtras/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtWinExtras/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtX11Extras/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtX11Extras/this_module_loads_test.py39
-rw-r--r--sources/pyside2/tests/QtXml/CMakeLists.txt2
-rw-r--r--sources/pyside2/tests/QtXml/qdomdocument_test.py96
-rw-r--r--sources/pyside2/tests/QtXml/qxmlsimplereader_test.py64
-rw-r--r--sources/pyside2/tests/QtXmlPatterns/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtXmlPatterns/import_test.py58
-rw-r--r--sources/pyside2/tests/mac/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/mac/qmacstyle_test.py45
-rw-r--r--sources/pyside2/tests/manually/README.txt5
-rw-r--r--sources/pyside2/tests/manually/bug_841.py79
-rw-r--r--sources/pyside2/tests/pysidetest/CMakeLists.txt120
-rw-r--r--sources/pyside2/tests/pysidetest/bug_1016.py40
-rw-r--r--sources/pyside2/tests/pysidetest/curr_errors.txt12
-rw-r--r--sources/pyside2/tests/pysidetest/decoratedslot_test.py67
-rw-r--r--sources/pyside2/tests/pysidetest/delegatecreateseditor_test.py83
-rw-r--r--sources/pyside2/tests/pysidetest/enum_test.py44
-rw-r--r--sources/pyside2/tests/pysidetest/hiddenobject.cpp44
-rw-r--r--sources/pyside2/tests/pysidetest/hiddenobject.h55
-rw-r--r--sources/pyside2/tests/pysidetest/homonymoussignalandmethod_test.py81
-rw-r--r--sources/pyside2/tests/pysidetest/list_signal_test.py51
-rw-r--r--sources/pyside2/tests/pysidetest/mixin_signal_slots_test.py216
-rw-r--r--sources/pyside2/tests/pysidetest/modelview_test.py99
-rw-r--r--sources/pyside2/tests/pysidetest/new_inherited_functions_test.py215
-rw-r--r--sources/pyside2/tests/pysidetest/notify_id.py76
-rw-r--r--sources/pyside2/tests/pysidetest/pysidetest_global.h34
-rw-r--r--sources/pyside2/tests/pysidetest/qvariant_test.py45
-rw-r--r--sources/pyside2/tests/pysidetest/signal_slot_warning.py70
-rw-r--r--sources/pyside2/tests/pysidetest/signalandnamespace_test.py120
-rw-r--r--sources/pyside2/tests/pysidetest/signalemissionfrompython_test.py107
-rw-r--r--sources/pyside2/tests/pysidetest/signalwithdefaultvalue_test.py95
-rw-r--r--sources/pyside2/tests/pysidetest/symbols.filter7
-rw-r--r--sources/pyside2/tests/pysidetest/testobject.cpp54
-rw-r--r--sources/pyside2/tests/pysidetest/testobject.h140
-rw-r--r--sources/pyside2/tests/pysidetest/testview.cpp52
-rw-r--r--sources/pyside2/tests/pysidetest/testview.h61
-rw-r--r--sources/pyside2/tests/pysidetest/typedef_signal_test.py54
-rw-r--r--sources/pyside2/tests/pysidetest/typesystem_pysidetest.xml64
-rw-r--r--sources/pyside2/tests/pysidetest/utils_test.py51
-rw-r--r--sources/pyside2/tests/pysidetest/version_test.py45
-rwxr-xr-xsources/pyside2/tests/run_test.sh41
-rw-r--r--sources/pyside2/tests/signals/CMakeLists.txt40
-rw-r--r--sources/pyside2/tests/signals/args_dont_match_test.py50
-rw-r--r--sources/pyside2/tests/signals/bug_189.py54
-rw-r--r--sources/pyside2/tests/signals/bug_311.py70
-rw-r--r--sources/pyside2/tests/signals/bug_312.py79
-rw-r--r--sources/pyside2/tests/signals/bug_319.py63
-rw-r--r--sources/pyside2/tests/signals/bug_79.py69
-rw-r--r--sources/pyside2/tests/signals/decorators_test.py105
-rw-r--r--sources/pyside2/tests/signals/disconnect_test.py88
-rw-r--r--sources/pyside2/tests/signals/invalid_callback_test.py56
-rw-r--r--sources/pyside2/tests/signals/lambda_gui_test.py73
-rw-r--r--sources/pyside2/tests/signals/lambda_test.py93
-rw-r--r--sources/pyside2/tests/signals/leaking_signal_test.py43
-rw-r--r--sources/pyside2/tests/signals/multiple_connections_gui_test.py88
-rw-r--r--sources/pyside2/tests/signals/multiple_connections_test.py103
-rw-r--r--sources/pyside2/tests/signals/pysignal_test.py214
-rw-r--r--sources/pyside2/tests/signals/qobject_destroyed_test.py50
-rw-r--r--sources/pyside2/tests/signals/qobject_receivers_test.py76
-rw-r--r--sources/pyside2/tests/signals/qobject_sender_test.py120
-rw-r--r--sources/pyside2/tests/signals/ref01_test.py55
-rw-r--r--sources/pyside2/tests/signals/ref02_test.py75
-rw-r--r--sources/pyside2/tests/signals/ref03_test.py57
-rw-r--r--sources/pyside2/tests/signals/ref04_test.py84
-rw-r--r--sources/pyside2/tests/signals/ref05_test.py74
-rw-r--r--sources/pyside2/tests/signals/ref06_test.py77
-rw-r--r--sources/pyside2/tests/signals/segfault_proxyparent_test.py86
-rw-r--r--sources/pyside2/tests/signals/self_connect_test.py65
-rw-r--r--sources/pyside2/tests/signals/short_circuit_test.py91
-rw-r--r--sources/pyside2/tests/signals/signal2signal_connect_test.py135
-rw-r--r--sources/pyside2/tests/signals/signal_autoconnect_test.py59
-rw-r--r--sources/pyside2/tests/signals/signal_connectiontype_support_test.py55
-rw-r--r--sources/pyside2/tests/signals/signal_emission_gui_test.py141
-rw-r--r--sources/pyside2/tests/signals/signal_emission_test.py152
-rw-r--r--sources/pyside2/tests/signals/signal_func_test.py49
-rw-r--r--sources/pyside2/tests/signals/signal_manager_refcount_test.py51
-rw-r--r--sources/pyside2/tests/signals/signal_number_limit_test.py90
-rw-r--r--sources/pyside2/tests/signals/signal_object_test.py115
-rw-r--r--sources/pyside2/tests/signals/signal_signature_test.py76
-rw-r--r--sources/pyside2/tests/signals/signal_with_primitive_type_test.py58
-rw-r--r--sources/pyside2/tests/signals/slot_reference_count_test.py81
-rw-r--r--sources/pyside2/tests/signals/static_metaobject_test.py86
-rwxr-xr-xsources/pyside2/tests/tools/list-class-hierarchy.py117
-rw-r--r--sources/pyside2/tests/util/color.py41
-rw-r--r--sources/pyside2/tests/util/helper/__init__.py160
-rw-r--r--sources/pyside2/tests/util/helper/docmodifier.py116
-rw-r--r--sources/pyside2/tests/util/httpd.py177
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtAssistant.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtCore.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtDesigner.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtGui.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtHelp.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtNetwork.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtScript.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtSql.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtSvg.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtTest.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtWebKit.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtXml.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/QtXmlPatterns.py2
-rw-r--r--sources/pyside2/tests/util/module_wrapper/PySide/__init__.py0
-rw-r--r--sources/pyside2/tests/util/processtimer.py77
-rw-r--r--sources/pyside2/tests/util/py2xfunctions.py46
-rw-r--r--sources/pyside2/tests/util/py3kcompat.py38
-rw-r--r--sources/pyside2/tests/util/py3xfunctions.py54
-rw-r--r--sources/pyside2/tests/util/pyqt_diff.py64
-rw-r--r--sources/pyside2/tests/util/pyqtcheck.py74
-rwxr-xr-xsources/pyside2/tests/util/rename_imports.sh42
-rw-r--r--sources/pyside2/tests/util/test_processtimer.py93
-rw-r--r--sources/pyside2/tests/util/use_pyqt4.sh3
-rw-r--r--sources/pyside2/tests/util/use_pyside.sh3
-rw-r--r--sources/pyside2/tests/util/valgrind-python.supp349
-rw-r--r--sources/shiboken2/.gitattributes2
-rw-r--r--sources/shiboken2/.gitignore8
-rw-r--r--sources/shiboken2/AUTHORS12
-rw-r--r--sources/shiboken2/ApiExtractor/AUTHORS8
-rw-r--r--sources/shiboken2/ApiExtractor/CMakeLists.txt102
-rw-r--r--sources/shiboken2/ApiExtractor/COPYING342
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp3381
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.h106
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h194
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp2786
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.h1983
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h49
-rw-r--r--sources/shiboken2/ApiExtractor/apiextractor.cpp356
-rw-r--r--sources/shiboken2/ApiExtractor/apiextractor.h109
-rw-r--r--sources/shiboken2/ApiExtractor/apiextractormacros.h41
-rw-r--r--sources/shiboken2/ApiExtractor/asttoxml.cpp160
-rw-r--r--sources/shiboken2/ApiExtractor/asttoxml.h46
-rw-r--r--sources/shiboken2/ApiExtractor/cmake_uninstall.cmake21
-rw-r--r--sources/shiboken2/ApiExtractor/dependency.h43
-rw-r--r--sources/shiboken2/ApiExtractor/doc/CMakeLists.txt10
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_templates/index.html27
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_templates/layout.html41
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/searchbox.html12
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/bg_header.pngbin0 -> 36012 bytes
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/bg_topo.jpgbin0 -> 14237 bytes
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/fakebar.pngbin0 -> 101 bytes
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_indt.jpgbin0 -> 3138 bytes
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_openbossa.pngbin0 -> 4702 bytes
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_python.jpgbin0 -> 2660 bytes
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_qt.pngbin0 -> 4618 bytes
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/pysidedocs.css409
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/pysidelogo.pngbin0 -> 12969 bytes
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/relbar_bg.pngbin0 -> 130 bytes
-rw-r--r--sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/theme.conf7
-rw-r--r--sources/shiboken2/ApiExtractor/doc/conf.py.in163
-rw-r--r--sources/shiboken2/ApiExtractor/doc/contents.rst9
-rw-r--r--sources/shiboken2/ApiExtractor/doc/dependency-apiextractor.svg360
-rw-r--r--sources/shiboken2/ApiExtractor/doc/overview.rst15
-rw-r--r--sources/shiboken2/ApiExtractor/doc/ownership.rst85
-rw-r--r--sources/shiboken2/ApiExtractor/doc/typesystem.rst29
-rw-r--r--sources/shiboken2/ApiExtractor/doc/typesystem_arguments.rst192
-rw-r--r--sources/shiboken2/ApiExtractor/doc/typesystem_conversionrule.rst113
-rw-r--r--sources/shiboken2/ApiExtractor/doc/typesystem_documentation.rst43
-rw-r--r--sources/shiboken2/ApiExtractor/doc/typesystem_manipulating_objects.rst132
-rw-r--r--sources/shiboken2/ApiExtractor/doc/typesystem_modify_function.rst78
-rw-r--r--sources/shiboken2/ApiExtractor/doc/typesystem_solving_compilation.rst70
-rw-r--r--sources/shiboken2/ApiExtractor/doc/typesystem_specifying_types.rst371
-rw-r--r--sources/shiboken2/ApiExtractor/doc/typesystem_templates.rst55
-rw-r--r--sources/shiboken2/ApiExtractor/docparser.cpp174
-rw-r--r--sources/shiboken2/ApiExtractor/docparser.h127
-rw-r--r--sources/shiboken2/ApiExtractor/doxygenparser.cpp198
-rw-r--r--sources/shiboken2/ApiExtractor/doxygenparser.h43
-rw-r--r--sources/shiboken2/ApiExtractor/fileout.cpp231
-rw-r--r--sources/shiboken2/ApiExtractor/fileout.h62
-rw-r--r--sources/shiboken2/ApiExtractor/generator.qrc5
-rw-r--r--sources/shiboken2/ApiExtractor/graph.cpp135
-rw-r--r--sources/shiboken2/ApiExtractor/graph.h72
-rw-r--r--sources/shiboken2/ApiExtractor/icecc.cmake11
-rw-r--r--sources/shiboken2/ApiExtractor/include.cpp71
-rw-r--r--sources/shiboken2/ApiExtractor/include.h92
-rw-r--r--sources/shiboken2/ApiExtractor/merge.xsl82
-rw-r--r--sources/shiboken2/ApiExtractor/parser/ast.cpp38
-rw-r--r--sources/shiboken2/ApiExtractor/parser/ast.h884
-rw-r--r--sources/shiboken2/ApiExtractor/parser/binder.cpp866
-rw-r--r--sources/shiboken2/ApiExtractor/parser/binder.h133
-rw-r--r--sources/shiboken2/ApiExtractor/parser/class_compiler.cpp71
-rw-r--r--sources/shiboken2/ApiExtractor/parser/class_compiler.h77
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel.cpp1199
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel.h691
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel_enums.h38
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel_finder.cpp103
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel_finder.h75
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel_fwd.h82
-rw-r--r--sources/shiboken2/ApiExtractor/parser/compiler_utils.cpp55
-rw-r--r--sources/shiboken2/ApiExtractor/parser/compiler_utils.h50
-rw-r--r--sources/shiboken2/ApiExtractor/parser/control.cpp135
-rw-r--r--sources/shiboken2/ApiExtractor/parser/control.h165
-rw-r--r--sources/shiboken2/ApiExtractor/parser/declarator_compiler.cpp167
-rw-r--r--sources/shiboken2/ApiExtractor/parser/declarator_compiler.h101
-rw-r--r--sources/shiboken2/ApiExtractor/parser/default_visitor.cpp464
-rw-r--r--sources/shiboken2/ApiExtractor/parser/default_visitor.h123
-rw-r--r--sources/shiboken2/ApiExtractor/parser/dumptree.cpp131
-rw-r--r--sources/shiboken2/ApiExtractor/parser/dumptree.h51
-rw-r--r--sources/shiboken2/ApiExtractor/parser/lexer.cpp1726
-rw-r--r--sources/shiboken2/ApiExtractor/parser/lexer.h295
-rw-r--r--sources/shiboken2/ApiExtractor/parser/list.cpp33
-rw-r--r--sources/shiboken2/ApiExtractor/parser/list.h105
-rw-r--r--sources/shiboken2/ApiExtractor/parser/name_compiler.cpp139
-rw-r--r--sources/shiboken2/ApiExtractor/parser/name_compiler.h74
-rw-r--r--sources/shiboken2/ApiExtractor/parser/parser.cpp4075
-rw-r--r--sources/shiboken2/ApiExtractor/parser/parser.h204
-rw-r--r--sources/shiboken2/ApiExtractor/parser/r++.macros28
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp-allocator.h29
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/builtin-macros.cpp28
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-cctype.h62
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-configuration86
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-engine-bits.h1300
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-engine.h288
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-environment.h144
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-fwd.h44
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-internal.h122
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-iterator.h99
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-macro-expander.h356
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-macro.h77
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-qt-configuration24
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-scanner.h318
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-string.h112
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp-symbol.h97
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/pp.h96
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/preprocessor.cpp164
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rpp/preprocessor.h70
-rw-r--r--sources/shiboken2/ApiExtractor/parser/rxx_allocator.h146
-rw-r--r--sources/shiboken2/ApiExtractor/parser/smallobject.cpp33
-rw-r--r--sources/shiboken2/ApiExtractor/parser/smallobject.h58
-rw-r--r--sources/shiboken2/ApiExtractor/parser/symbol.h127
-rw-r--r--sources/shiboken2/ApiExtractor/parser/tokens.cpp256
-rw-r--r--sources/shiboken2/ApiExtractor/parser/tokens.h152
-rw-r--r--sources/shiboken2/ApiExtractor/parser/type_compiler.cpp134
-rw-r--r--sources/shiboken2/ApiExtractor/parser/type_compiler.h76
-rw-r--r--sources/shiboken2/ApiExtractor/parser/visitor.cpp127
-rw-r--r--sources/shiboken2/ApiExtractor/parser/visitor.h145
-rw-r--r--sources/shiboken2/ApiExtractor/qtdocparser.cpp188
-rw-r--r--sources/shiboken2/ApiExtractor/qtdocparser.h44
-rw-r--r--sources/shiboken2/ApiExtractor/reporthandler.cpp149
-rw-r--r--sources/shiboken2/ApiExtractor/reporthandler.h71
-rw-r--r--sources/shiboken2/ApiExtractor/symbols.filter7
-rw-r--r--sources/shiboken2/ApiExtractor/tests/CMakeLists.txt73
-rw-r--r--sources/shiboken2/ApiExtractor/tests/a.xml13
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp527
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.h55
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testabstractmetatype.cpp216
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testabstractmetatype.h47
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp453
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testaddfunction.h54
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp129
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testarrayargument.h42
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testcodeinjection.cpp106
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testcodeinjection.h45
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testcontainer.cpp105
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testcontainer.h41
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testconversionoperator.cpp188
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testconversionoperator.h44
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testconversionruletag.cpp250
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testconversionruletag.h43
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testctorinformation.cpp76
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testctorinformation.h44
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testdroptypeentries.cpp145
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testdroptypeentries.h44
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testdtorinformation.cpp86
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testdtorinformation.h46
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testenum.cpp416
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testenum.h47
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testextrainclude.cpp85
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testextrainclude.h42
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testfunctiontag.cpp97
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testfunctiontag.h42
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp163
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testimplicitconversions.h46
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testinserttemplate.cpp130
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testinserttemplate.h44
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.cpp80
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.h41
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp249
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testmodifyfunction.h45
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testmultipleinheritance.cpp74
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testmultipleinheritance.h43
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testnamespace.cpp96
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testnamespace.h44
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testnestedtypes.cpp128
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testnestedtypes.h41
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.cpp119
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.h42
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testprimitivetypetag.cpp60
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testprimitivetypetag.h41
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testrefcounttag.cpp100
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testrefcounttag.h42
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testreferencetopointer.cpp59
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testreferencetopointer.h41
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testremovefield.cpp62
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testremovefield.h41
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testremoveimplconv.cpp69
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testremoveimplconv.h41
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testremoveoperatormethod.cpp116
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testremoveoperatormethod.h41
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testresolvetype.cpp64
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testresolvetype.h41
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testreverseoperators.cpp138
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testreverseoperators.h41
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testtemplates.cpp438
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testtemplates.h51
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testtoposort.cpp69
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testtoposort.h42
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testtyperevision.cpp71
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testtyperevision.h42
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testutil.h66
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testvaluetypedefaultctortag.cpp64
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testvaluetypedefaultctortag.h41
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testvoidarg.cpp87
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testvoidarg.h42
-rw-r--r--sources/shiboken2/ApiExtractor/tests/utf8code.txt1
-rw-r--r--sources/shiboken2/ApiExtractor/typedatabase.cpp699
-rw-r--r--sources/shiboken2/ApiExtractor/typedatabase.h179
-rw-r--r--sources/shiboken2/ApiExtractor/typeparser.cpp318
-rw-r--r--sources/shiboken2/ApiExtractor/typeparser.h59
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.cpp2667
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.h1947
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem_enums.h86
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem_p.h176
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem_typedefs.h58
-rw-r--r--sources/shiboken2/CMakeLists.txt244
-rw-r--r--sources/shiboken2/COPYING342
-rw-r--r--sources/shiboken2/COPYING.libsample501
-rw-r--r--sources/shiboken2/COPYING.libshiboken501
-rw-r--r--sources/shiboken2/Doxyfile311
-rw-r--r--sources/shiboken2/LICENSE.GPLv3686
-rw-r--r--sources/shiboken2/LICENSE.LGPLv21514
-rw-r--r--sources/shiboken2/LICENSE.LGPLv3175
-rw-r--r--sources/shiboken2/LICENSE.PREVIEW.COMMERCIAL630
-rw-r--r--sources/shiboken2/README.md19
-rw-r--r--sources/shiboken2/cmake_uninstall.cmake21
-rw-r--r--sources/shiboken2/data/CMakeLists.txt28
-rw-r--r--sources/shiboken2/data/GeneratorRunnerConfig.cmake.in17
-rw-r--r--sources/shiboken2/data/GeneratorRunnerConfigVersion.cmake.in10
-rw-r--r--sources/shiboken2/data/Shiboken2Config-spec.cmake.in29
-rw-r--r--sources/shiboken2/data/Shiboken2Config.cmake.in5
-rw-r--r--sources/shiboken2/data/Shiboken2ConfigVersion.cmake.in10
l---------sources/shiboken2/data/docgenerator.11
-rw-r--r--sources/shiboken2/data/generatorrunner.176
-rw-r--r--sources/shiboken2/data/generatorrunner.pc.in13
-rw-r--r--sources/shiboken2/data/shiboken2.pc.in13
-rw-r--r--sources/shiboken2/doc/CMakeLists.txt24
-rw-r--r--sources/shiboken2/doc/_templates/index.html35
-rw-r--r--sources/shiboken2/doc/_templates/layout.html29
-rw-r--r--sources/shiboken2/doc/_themes/pysidedocs/searchbox.html12
-rw-r--r--sources/shiboken2/doc/_themes/pysidedocs/static/bg_header.pngbin0 -> 36012 bytes
-rw-r--r--sources/shiboken2/doc/_themes/pysidedocs/static/bg_topo.jpgbin0 -> 14237 bytes
-rw-r--r--sources/shiboken2/doc/_themes/pysidedocs/static/fakebar.pngbin0 -> 101 bytes
-rw-r--r--sources/shiboken2/doc/_themes/pysidedocs/static/logo_python.jpgbin0 -> 2660 bytes
-rw-r--r--sources/shiboken2/doc/_themes/pysidedocs/static/logo_qt.pngbin0 -> 1032 bytes
-rw-r--r--sources/shiboken2/doc/_themes/pysidedocs/static/pysidedocs.css475
-rw-r--r--sources/shiboken2/doc/_themes/pysidedocs/static/pysidelogo.pngbin0 -> 12969 bytes
-rw-r--r--sources/shiboken2/doc/_themes/pysidedocs/static/relbar_bg.pngbin0 -> 130 bytes
-rw-r--r--sources/shiboken2/doc/_themes/pysidedocs/theme.conf7
-rw-r--r--sources/shiboken2/doc/codeinjectionsemantics.rst397
-rw-r--r--sources/shiboken2/doc/commandlineoptions.rst105
-rw-r--r--sources/shiboken2/doc/conf.py.in166
-rw-r--r--sources/shiboken2/doc/contents.rst17
-rw-r--r--sources/shiboken2/doc/dependency-pyqtb.svg600
-rw-r--r--sources/shiboken2/doc/dependency-pyside.svg527
-rw-r--r--sources/shiboken2/doc/faq.rst67
-rw-r--r--sources/shiboken2/doc/images/.directory3
-rw-r--r--sources/shiboken2/doc/images/bindinggen-development.pngbin0 -> 34333 bytes
-rw-r--r--sources/shiboken2/doc/images/bindinggen-development.svg543
-rw-r--r--sources/shiboken2/doc/images/boostgen.pngbin0 -> 153473 bytes
-rw-r--r--sources/shiboken2/doc/images/boostqtarch.pngbin0 -> 34257 bytes
-rw-r--r--sources/shiboken2/doc/images/boostqtarch.svg226
-rw-r--r--sources/shiboken2/doc/images/converter.dot14
-rw-r--r--sources/shiboken2/doc/images/converter.pngbin0 -> 37485 bytes
-rw-r--r--sources/shiboken2/doc/images/genrunnerarch.pngbin0 -> 68761 bytes
-rw-r--r--sources/shiboken2/doc/images/genrunnerarch.svg654
-rw-r--r--sources/shiboken2/doc/overview.rst46
-rw-r--r--sources/shiboken2/doc/ownership.rst153
-rw-r--r--sources/shiboken2/doc/projectfile.rst65
-rw-r--r--sources/shiboken2/doc/sequenceprotocol.rst23
-rw-r--r--sources/shiboken2/doc/shiboken2.173
-rw-r--r--sources/shiboken2/doc/shibokenmodule.rst79
-rw-r--r--sources/shiboken2/doc/typeconverters.rst288
-rw-r--r--sources/shiboken2/doc/typesystemvariables.rst336
-rw-r--r--sources/shiboken2/doc/wordsofadvice.rst109
-rw-r--r--sources/shiboken2/ext/sparsehash/AUTHORS2
-rw-r--r--sources/shiboken2/ext/sparsehash/COPYING28
-rw-r--r--sources/shiboken2/ext/sparsehash/google/dense_hash_map310
-rw-r--r--sources/shiboken2/ext/sparsehash/google/dense_hash_set287
-rw-r--r--sources/shiboken2/ext/sparsehash/google/sparsehash/densehashtable.h1062
-rw-r--r--sources/shiboken2/ext/sparsehash/google/sparsehash/sparseconfig.h45
-rw-r--r--sources/shiboken2/ext/sparsehash/google/type_traits.h250
-rw-r--r--sources/shiboken2/generator/CMakeLists.txt40
-rw-r--r--sources/shiboken2/generator/generator.cpp854
-rw-r--r--sources/shiboken2/generator/generator.h447
-rw-r--r--sources/shiboken2/generator/main.cpp529
-rw-r--r--sources/shiboken2/generator/qtdoc/CMakeLists.txt21
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp1704
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.h235
-rw-r--r--sources/shiboken2/generator/shiboken2/CMakeLists.txt28
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp5689
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.h370
-rw-r--r--sources/shiboken2/generator/shiboken2/headergenerator.cpp558
-rw-r--r--sources/shiboken2/generator/shiboken2/headergenerator.h67
-rw-r--r--sources/shiboken2/generator/shiboken2/overloaddata.cpp1079
-rw-r--r--sources/shiboken2/generator/shiboken2/overloaddata.h161
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp2674
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.h554
-rw-r--r--sources/shiboken2/generator/shibokenconfig.h.in6
-rw-r--r--sources/shiboken2/generatorrunnerconfig.h.in13
-rw-r--r--sources/shiboken2/generatorrunnermacros.h48
-rw-r--r--sources/shiboken2/generators/shiboken/shiboken.cpp32
-rw-r--r--sources/shiboken2/header.COMM20
-rw-r--r--sources/shiboken2/header.LGPL-ONLY22
-rw-r--r--sources/shiboken2/header.LGPL2133
-rw-r--r--sources/shiboken2/header.LGPL336
-rw-r--r--sources/shiboken2/header.LGPL3-COMM28
-rw-r--r--sources/shiboken2/icecc.cmake11
-rw-r--r--sources/shiboken2/libshiboken/CMakeLists.txt77
-rw-r--r--sources/shiboken2/libshiboken/autodecref.h115
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.cpp1518
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.h451
-rw-r--r--sources/shiboken2/libshiboken/basewrapper_p.h287
-rw-r--r--sources/shiboken2/libshiboken/bindingmanager.cpp344
-rw-r--r--sources/shiboken2/libshiboken/bindingmanager.h109
-rw-r--r--sources/shiboken2/libshiboken/conversions.h731
-rw-r--r--sources/shiboken2/libshiboken/debugfreehook.cpp194
-rw-r--r--sources/shiboken2/libshiboken/debugfreehook.h61
-rw-r--r--sources/shiboken2/libshiboken/gilstate.cpp68
-rw-r--r--sources/shiboken2/libshiboken/gilstate.h63
-rw-r--r--sources/shiboken2/libshiboken/helper.cpp142
-rw-r--r--sources/shiboken2/libshiboken/helper.h136
-rw-r--r--sources/shiboken2/libshiboken/python25compat.h104
-rw-r--r--sources/shiboken2/libshiboken/sbkconverter.cpp572
-rw-r--r--sources/shiboken2/libshiboken/sbkconverter.h367
-rw-r--r--sources/shiboken2/libshiboken/sbkconverter_p.h574
-rw-r--r--sources/shiboken2/libshiboken/sbkdbg.h124
-rw-r--r--sources/shiboken2/libshiboken/sbkenum.cpp623
-rw-r--r--sources/shiboken2/libshiboken/sbkenum.h118
-rw-r--r--sources/shiboken2/libshiboken/sbkmodule.cpp124
-rw-r--r--sources/shiboken2/libshiboken/sbkmodule.h115
-rw-r--r--sources/shiboken2/libshiboken/sbkpython.h74
-rw-r--r--sources/shiboken2/libshiboken/sbkstring.cpp202
-rw-r--r--sources/shiboken2/libshiboken/sbkstring.h75
-rw-r--r--sources/shiboken2/libshiboken/sbkversion.h.in50
-rw-r--r--sources/shiboken2/libshiboken/shiboken.h60
-rw-r--r--sources/shiboken2/libshiboken/shibokenbuffer.cpp96
-rw-r--r--sources/shiboken2/libshiboken/shibokenbuffer.h85
-rw-r--r--sources/shiboken2/libshiboken/shibokenmacros.h63
-rw-r--r--sources/shiboken2/libshiboken/threadstatesaver.cpp69
-rw-r--r--sources/shiboken2/libshiboken/threadstatesaver.h66
-rw-r--r--sources/shiboken2/libshiboken/tmp-referencetopython/sbkconverter.cpp213
-rw-r--r--sources/shiboken2/libshiboken/tmp-referencetopython/sbkconverter.h191
-rw-r--r--sources/shiboken2/libshiboken/typeresolver.cpp162
-rw-r--r--sources/shiboken2/libshiboken/typeresolver.h139
-rw-r--r--sources/shiboken2/shibokenmodule/CMakeLists.txt40
-rw-r--r--sources/shiboken2/shibokenmodule/nothing.h0
-rw-r--r--sources/shiboken2/shibokenmodule/shibokenmodule.txt.in16
-rw-r--r--sources/shiboken2/shibokenmodule/typesystem_shiboken.xml120
-rw-r--r--sources/shiboken2/tests/CMakeLists.txt102
-rw-r--r--sources/shiboken2/tests/dumpcodemodel/CMakeLists.txt5
-rw-r--r--sources/shiboken2/tests/dumpcodemodel/main.cpp83
-rw-r--r--sources/shiboken2/tests/libminimal/CMakeLists.txt13
-rw-r--r--sources/shiboken2/tests/libminimal/libminimalmacros.h46
-rw-r--r--sources/shiboken2/tests/libminimal/listuser.cpp124
-rw-r--r--sources/shiboken2/tests/libminimal/listuser.h75
-rw-r--r--sources/shiboken2/tests/libminimal/minbool.h68
-rw-r--r--sources/shiboken2/tests/libminimal/obj.cpp44
-rw-r--r--sources/shiboken2/tests/libminimal/obj.h59
-rw-r--r--sources/shiboken2/tests/libminimal/typedef.cpp75
-rw-r--r--sources/shiboken2/tests/libminimal/typedef.h54
-rw-r--r--sources/shiboken2/tests/libminimal/val.h59
-rw-r--r--sources/shiboken2/tests/libother/CMakeLists.txt18
-rw-r--r--sources/shiboken2/tests/libother/extendsnoimplicitconversion.h45
-rw-r--r--sources/shiboken2/tests/libother/libothermacros.h46
-rw-r--r--sources/shiboken2/tests/libother/number.cpp59
-rw-r--r--sources/shiboken2/tests/libother/number.h57
-rw-r--r--sources/shiboken2/tests/libother/otherderived.cpp61
-rw-r--r--sources/shiboken2/tests/libother/otherderived.h65
-rw-r--r--sources/shiboken2/tests/libother/othermultiplederived.cpp50
-rw-r--r--sources/shiboken2/tests/libother/othermultiplederived.h46
-rw-r--r--sources/shiboken2/tests/libother/otherobjecttype.cpp36
-rw-r--r--sources/shiboken2/tests/libother/otherobjecttype.h49
-rw-r--r--sources/shiboken2/tests/libsample/CMakeLists.txt57
-rw-r--r--sources/shiboken2/tests/libsample/abstract.cpp97
-rw-r--r--sources/shiboken2/tests/libsample/abstract.h107
-rw-r--r--sources/shiboken2/tests/libsample/blackbox.cpp131
-rw-r--r--sources/shiboken2/tests/libsample/blackbox.h67
-rw-r--r--sources/shiboken2/tests/libsample/bucket.cpp86
-rw-r--r--sources/shiboken2/tests/libsample/bucket.h59
-rw-r--r--sources/shiboken2/tests/libsample/bytearray.cpp214
-rw-r--r--sources/shiboken2/tests/libsample/bytearray.h89
-rw-r--r--sources/shiboken2/tests/libsample/collector.cpp62
-rw-r--r--sources/shiboken2/tests/libsample/collector.h71
-rw-r--r--sources/shiboken2/tests/libsample/complex.cpp54
-rw-r--r--sources/shiboken2/tests/libsample/complex.h55
-rw-r--r--sources/shiboken2/tests/libsample/ctorconvrule.h45
-rw-r--r--sources/shiboken2/tests/libsample/cvlist.h53
-rw-r--r--sources/shiboken2/tests/libsample/derived.cpp119
-rw-r--r--sources/shiboken2/tests/libsample/derived.h92
-rw-r--r--sources/shiboken2/tests/libsample/echo.cpp29
-rw-r--r--sources/shiboken2/tests/libsample/echo.h55
-rw-r--r--sources/shiboken2/tests/libsample/expression.cpp137
-rw-r--r--sources/shiboken2/tests/libsample/expression.h64
-rw-r--r--sources/shiboken2/tests/libsample/filter.cpp73
-rw-r--r--sources/shiboken2/tests/libsample/filter.h99
-rw-r--r--sources/shiboken2/tests/libsample/functions.cpp214
-rw-r--r--sources/shiboken2/tests/libsample/functions.h93
-rw-r--r--sources/shiboken2/tests/libsample/handle.cpp44
-rw-r--r--sources/shiboken2/tests/libsample/handle.h72
-rw-r--r--sources/shiboken2/tests/libsample/implicitconv.cpp66
-rw-r--r--sources/shiboken2/tests/libsample/implicitconv.h83
-rw-r--r--sources/shiboken2/tests/libsample/injectcode.cpp108
-rw-r--r--sources/shiboken2/tests/libsample/injectcode.h65
-rw-r--r--sources/shiboken2/tests/libsample/libsamplemacros.h46
-rw-r--r--sources/shiboken2/tests/libsample/list.h106
-rw-r--r--sources/shiboken2/tests/libsample/listuser.cpp91
-rw-r--r--sources/shiboken2/tests/libsample/listuser.h74
-rw-r--r--sources/shiboken2/tests/libsample/main.cpp244
-rw-r--r--sources/shiboken2/tests/libsample/mapuser.cpp69
-rw-r--r--sources/shiboken2/tests/libsample/mapuser.h65
-rw-r--r--sources/shiboken2/tests/libsample/modelindex.h72
-rw-r--r--sources/shiboken2/tests/libsample/modifications.cpp151
-rw-r--r--sources/shiboken2/tests/libsample/modifications.h142
-rw-r--r--sources/shiboken2/tests/libsample/modified_constructor.cpp42
-rw-r--r--sources/shiboken2/tests/libsample/modified_constructor.h46
-rw-r--r--sources/shiboken2/tests/libsample/multiple_derived.cpp64
-rw-r--r--sources/shiboken2/tests/libsample/multiple_derived.h195
-rw-r--r--sources/shiboken2/tests/libsample/noimplicitconversion.h49
-rw-r--r--sources/shiboken2/tests/libsample/nondefaultctor.h75
-rw-r--r--sources/shiboken2/tests/libsample/null.h44
-rw-r--r--sources/shiboken2/tests/libsample/objectmodel.cpp42
-rw-r--r--sources/shiboken2/tests/libsample/objectmodel.h58
-rw-r--r--sources/shiboken2/tests/libsample/objecttype.cpp311
-rw-r--r--sources/shiboken2/tests/libsample/objecttype.h176
-rw-r--r--sources/shiboken2/tests/libsample/objecttypebyvalue.h46
-rw-r--r--sources/shiboken2/tests/libsample/objecttypeholder.cpp52
-rw-r--r--sources/shiboken2/tests/libsample/objecttypeholder.h51
-rw-r--r--sources/shiboken2/tests/libsample/objecttypelayout.cpp68
-rw-r--r--sources/shiboken2/tests/libsample/objecttypelayout.h56
-rw-r--r--sources/shiboken2/tests/libsample/objecttypeoperators.cpp63
-rw-r--r--sources/shiboken2/tests/libsample/objecttypeoperators.h61
-rw-r--r--sources/shiboken2/tests/libsample/objectview.cpp54
-rw-r--r--sources/shiboken2/tests/libsample/objectview.h58
-rw-r--r--sources/shiboken2/tests/libsample/oddbool.h83
-rw-r--r--sources/shiboken2/tests/libsample/onlycopy.cpp57
-rw-r--r--sources/shiboken2/tests/libsample/onlycopy.h59
-rw-r--r--sources/shiboken2/tests/libsample/overload.cpp50
-rw-r--r--sources/shiboken2/tests/libsample/overload.h143
-rw-r--r--sources/shiboken2/tests/libsample/overloadsort.cpp30
-rw-r--r--sources/shiboken2/tests/libsample/overloadsort.h88
-rw-r--r--sources/shiboken2/tests/libsample/pairuser.cpp57
-rw-r--r--sources/shiboken2/tests/libsample/pairuser.h55
-rw-r--r--sources/shiboken2/tests/libsample/pen.cpp67
-rw-r--r--sources/shiboken2/tests/libsample/pen.h62
-rw-r--r--sources/shiboken2/tests/libsample/photon.cpp50
-rw-r--r--sources/shiboken2/tests/libsample/photon.h140
-rw-r--r--sources/shiboken2/tests/libsample/point.cpp155
-rw-r--r--sources/shiboken2/tests/libsample/point.h99
-rw-r--r--sources/shiboken2/tests/libsample/pointerholder.h45
-rw-r--r--sources/shiboken2/tests/libsample/pointf.cpp126
-rw-r--r--sources/shiboken2/tests/libsample/pointf.h88
-rw-r--r--sources/shiboken2/tests/libsample/polygon.cpp75
-rw-r--r--sources/shiboken2/tests/libsample/polygon.h66
-rw-r--r--sources/shiboken2/tests/libsample/privatector.h55
-rw-r--r--sources/shiboken2/tests/libsample/privatedtor.h60
-rw-r--r--sources/shiboken2/tests/libsample/protected.cpp32
-rw-r--r--sources/shiboken2/tests/libsample/protected.h151
-rw-r--r--sources/shiboken2/tests/libsample/rect.h86
-rw-r--r--sources/shiboken2/tests/libsample/reference.cpp78
-rw-r--r--sources/shiboken2/tests/libsample/reference.h81
-rw-r--r--sources/shiboken2/tests/libsample/removednamespaces.h68
-rw-r--r--sources/shiboken2/tests/libsample/sample.cpp39
-rw-r--r--sources/shiboken2/tests/libsample/sample.h48
-rw-r--r--sources/shiboken2/tests/libsample/samplenamespace.cpp128
-rw-r--r--sources/shiboken2/tests/libsample/samplenamespace.h162
-rw-r--r--sources/shiboken2/tests/libsample/sbkdate.cpp48
-rw-r--r--sources/shiboken2/tests/libsample/sbkdate.h50
-rw-r--r--sources/shiboken2/tests/libsample/simplefile.cpp108
-rw-r--r--sources/shiboken2/tests/libsample/simplefile.h56
-rw-r--r--sources/shiboken2/tests/libsample/size.cpp39
-rw-r--r--sources/shiboken2/tests/libsample/size.h206
-rw-r--r--sources/shiboken2/tests/libsample/sometime.cpp99
-rw-r--r--sources/shiboken2/tests/libsample/sometime.h92
-rw-r--r--sources/shiboken2/tests/libsample/str.cpp185
-rw-r--r--sources/shiboken2/tests/libsample/str.h78
-rw-r--r--sources/shiboken2/tests/libsample/strlist.cpp57
-rw-r--r--sources/shiboken2/tests/libsample/strlist.h65
-rw-r--r--sources/shiboken2/tests/libsample/templateptr.cpp33
-rw-r--r--sources/shiboken2/tests/libsample/templateptr.h43
-rw-r--r--sources/shiboken2/tests/libsample/transform.cpp65
-rw-r--r--sources/shiboken2/tests/libsample/transform.h45
-rw-r--r--sources/shiboken2/tests/libsample/valueandvirtual.h47
-rw-r--r--sources/shiboken2/tests/libsample/virtualmethods.cpp59
-rw-r--r--sources/shiboken2/tests/libsample/virtualmethods.h139
-rw-r--r--sources/shiboken2/tests/libsample/voidholder.h50
-rw-r--r--sources/shiboken2/tests/libsmart/CMakeLists.txt11
-rw-r--r--sources/shiboken2/tests/libsmart/libsmartmacros.h46
-rw-r--r--sources/shiboken2/tests/libsmart/smart.cpp174
-rw-r--r--sources/shiboken2/tests/libsmart/smart.h210
-rw-r--r--sources/shiboken2/tests/minimalbinding/CMakeLists.txt38
-rw-r--r--sources/shiboken2/tests/minimalbinding/global.h33
-rw-r--r--sources/shiboken2/tests/minimalbinding/listuser_test.py323
-rw-r--r--sources/shiboken2/tests/minimalbinding/minbool_test.py64
-rw-r--r--sources/shiboken2/tests/minimalbinding/minimal-binding.txt.in15
-rw-r--r--sources/shiboken2/tests/minimalbinding/obj_test.py114
-rw-r--r--sources/shiboken2/tests/minimalbinding/typedef_test.py116
-rw-r--r--sources/shiboken2/tests/minimalbinding/typesystem_minimal.xml93
-rw-r--r--sources/shiboken2/tests/minimalbinding/val_test.py115
-rw-r--r--sources/shiboken2/tests/otherbinding/CMakeLists.txt48
-rw-r--r--sources/shiboken2/tests/otherbinding/collector_external_operator_test.py58
-rwxr-xr-xsources/shiboken2/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py73
-rwxr-xr-xsources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py64
-rw-r--r--sources/shiboken2/tests/otherbinding/global.h35
-rw-r--r--sources/shiboken2/tests/otherbinding/module_reload_test.py61
-rwxr-xr-xsources/shiboken2/tests/otherbinding/new_ctor_operator_test.py56
-rw-r--r--sources/shiboken2/tests/otherbinding/objtypehashes_test.py53
-rw-r--r--sources/shiboken2/tests/otherbinding/other-binding.txt.in18
-rw-r--r--sources/shiboken2/tests/otherbinding/otherderived_test.py120
-rw-r--r--sources/shiboken2/tests/otherbinding/test_module_template.py40
-rw-r--r--sources/shiboken2/tests/otherbinding/typediscovery_test.py64
-rw-r--r--sources/shiboken2/tests/otherbinding/typesystem_other.xml15
-rwxr-xr-xsources/shiboken2/tests/otherbinding/usersprimitivefromothermodule_test.py52
-rw-r--r--sources/shiboken2/tests/otherbinding/wrongctor_test.py53
-rw-r--r--sources/shiboken2/tests/py3k.py2
-rw-r--r--sources/shiboken2/tests/py3kcompat.py54
-rw-r--r--sources/shiboken2/tests/samplebinding/CMakeLists.txt145
-rw-r--r--sources/shiboken2/tests/samplebinding/__del___test.py50
-rw-r--r--sources/shiboken2/tests/samplebinding/abstract_test.py111
-rw-r--r--sources/shiboken2/tests/samplebinding/addedfunction_test.py62
-rw-r--r--sources/shiboken2/tests/samplebinding/addedfunction_with_container_args_test.py51
-rw-r--r--sources/shiboken2/tests/samplebinding/argumentmodifications_test.py111
-rw-r--r--sources/shiboken2/tests/samplebinding/bug_554_test.py45
-rw-r--r--sources/shiboken2/tests/samplebinding/bug_704_test.py68
-rw-r--r--sources/shiboken2/tests/samplebinding/bytearray_bufferprotocol.cpp55
-rw-r--r--sources/shiboken2/tests/samplebinding/bytearray_test.py151
-rw-r--r--sources/shiboken2/tests/samplebinding/child_return_test.py58
-rw-r--r--sources/shiboken2/tests/samplebinding/class_fields_test.py168
-rw-r--r--sources/shiboken2/tests/samplebinding/collector_test.py81
-rw-r--r--sources/shiboken2/tests/samplebinding/complex_test.py84
-rw-r--r--sources/shiboken2/tests/samplebinding/conversion_operator_test.py55
-rw-r--r--sources/shiboken2/tests/samplebinding/copy_test.py86
-rw-r--r--sources/shiboken2/tests/samplebinding/ctorconvrule_test.py49
-rw-r--r--sources/shiboken2/tests/samplebinding/cyclic_test.py109
-rw-r--r--sources/shiboken2/tests/samplebinding/date_test.py58
-rw-r--r--sources/shiboken2/tests/samplebinding/decisor_test.py65
-rw-r--r--sources/shiboken2/tests/samplebinding/delete_test.py47
-rw-r--r--sources/shiboken2/tests/samplebinding/deprecated_test.py44
-rw-r--r--sources/shiboken2/tests/samplebinding/derived_test.py153
-rw-r--r--sources/shiboken2/tests/samplebinding/duck_punching_test.py176
-rw-r--r--sources/shiboken2/tests/samplebinding/echo_test.py52
-rw-r--r--sources/shiboken2/tests/samplebinding/enum_test.py168
-rw-r--r--sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py53
-rw-r--r--sources/shiboken2/tests/samplebinding/event_loop_call_virtual_test.py70
-rw-r--r--sources/shiboken2/tests/samplebinding/event_loop_thread_test.py96
-rw-r--r--sources/shiboken2/tests/samplebinding/filter_test.py45
-rw-r--r--sources/shiboken2/tests/samplebinding/global.h90
-rw-r--r--sources/shiboken2/tests/samplebinding/handleholder_test.py57
-rw-r--r--sources/shiboken2/tests/samplebinding/hashabletype_test.py54
-rw-r--r--sources/shiboken2/tests/samplebinding/ignorederefop_test.py38
-rw-r--r--sources/shiboken2/tests/samplebinding/implicitconv_numerical_test.py151
-rw-r--r--sources/shiboken2/tests/samplebinding/implicitconv_test.py66
-rwxr-xr-xsources/shiboken2/tests/samplebinding/inheritanceandscope_test.py48
-rw-r--r--sources/shiboken2/tests/samplebinding/injectcode_test.py132
-rw-r--r--sources/shiboken2/tests/samplebinding/innerclass_test.py42
-rw-r--r--sources/shiboken2/tests/samplebinding/intlist_test.py98
-rw-r--r--sources/shiboken2/tests/samplebinding/invalid_virtual_return_test.py65
-rw-r--r--sources/shiboken2/tests/samplebinding/keep_reference_test.py81
-rw-r--r--sources/shiboken2/tests/samplebinding/list_test.py121
-rw-r--r--sources/shiboken2/tests/samplebinding/lock_test.py95
-rw-r--r--sources/shiboken2/tests/samplebinding/map_test.py80
-rw-r--r--sources/shiboken2/tests/samplebinding/metaclass_test.py61
-rw-r--r--sources/shiboken2/tests/samplebinding/mi_virtual_methods_test.py88
-rw-r--r--sources/shiboken2/tests/samplebinding/mixed_mi_test.py76
-rw-r--r--sources/shiboken2/tests/samplebinding/modelindex_test.py53
-rw-r--r--sources/shiboken2/tests/samplebinding/modelview_test.py78
-rw-r--r--sources/shiboken2/tests/samplebinding/modifications_test.py224
-rw-r--r--sources/shiboken2/tests/samplebinding/modified_constructor_test.py49
-rw-r--r--sources/shiboken2/tests/samplebinding/modifiedvirtualmethods_test.py248
-rw-r--r--sources/shiboken2/tests/samplebinding/multi_cpp_inheritance_test.py105
-rw-r--r--sources/shiboken2/tests/samplebinding/multiple_derived_test.py221
-rw-r--r--sources/shiboken2/tests/samplebinding/namespace_test.py69
-rw-r--r--sources/shiboken2/tests/samplebinding/newdivision_test.py42
-rw-r--r--sources/shiboken2/tests/samplebinding/nondefaultctor_test.py71
-rw-r--r--sources/shiboken2/tests/samplebinding/nonzero_test.py43
-rw-r--r--sources/shiboken2/tests/samplebinding/numericaltypedef_test.py56
-rw-r--r--sources/shiboken2/tests/samplebinding/numpy_test.py58
-rw-r--r--sources/shiboken2/tests/samplebinding/objecttype_test.py122
-rwxr-xr-xsources/shiboken2/tests/samplebinding/objecttype_with_named_args_test.py72
-rw-r--r--sources/shiboken2/tests/samplebinding/objecttypebyvalue_test.py42
-rw-r--r--sources/shiboken2/tests/samplebinding/objecttypelayout_test.py302
-rw-r--r--sources/shiboken2/tests/samplebinding/objecttypeoperators_test.py60
-rw-r--r--sources/shiboken2/tests/samplebinding/objecttypereferenceasvirtualmethodargument_test.py49
-rw-r--r--sources/shiboken2/tests/samplebinding/oddbool_test.py78
-rw-r--r--sources/shiboken2/tests/samplebinding/oldstyleclass_as_number_test.py82
-rw-r--r--sources/shiboken2/tests/samplebinding/onlycopyclass_test.py57
-rw-r--r--sources/shiboken2/tests/samplebinding/overflow_test.py87
-rw-r--r--sources/shiboken2/tests/samplebinding/overload_sorting_test.py92
-rw-r--r--sources/shiboken2/tests/samplebinding/overload_test.py209
-rw-r--r--sources/shiboken2/tests/samplebinding/overloadwithdefault_test.py64
-rw-r--r--sources/shiboken2/tests/samplebinding/ownership_argument_invalidation_test.py62
-rw-r--r--sources/shiboken2/tests/samplebinding/ownership_delete_child_in_cpp_test.py54
-rw-r--r--sources/shiboken2/tests/samplebinding/ownership_delete_child_in_python_test.py60
-rw-r--r--sources/shiboken2/tests/samplebinding/ownership_delete_parent_test.py82
-rw-r--r--sources/shiboken2/tests/samplebinding/ownership_invalidate_after_use_test.py110
-rw-r--r--sources/shiboken2/tests/samplebinding/ownership_invalidate_child_test.py69
-rw-r--r--sources/shiboken2/tests/samplebinding/ownership_invalidate_nonpolymorphic_test.py53
-rw-r--r--sources/shiboken2/tests/samplebinding/ownership_invalidate_parent_test.py68
-rw-r--r--sources/shiboken2/tests/samplebinding/ownership_reparenting_test.py130
-rw-r--r--sources/shiboken2/tests/samplebinding/ownership_transference_test.py85
-rw-r--r--sources/shiboken2/tests/samplebinding/pair_test.py105
-rw-r--r--sources/shiboken2/tests/samplebinding/pen_test.py63
-rw-r--r--sources/shiboken2/tests/samplebinding/point_test.py109
-rw-r--r--sources/shiboken2/tests/samplebinding/pointerholder_test.py59
-rw-r--r--sources/shiboken2/tests/samplebinding/pointf_test.py69
-rw-r--r--sources/shiboken2/tests/samplebinding/primitivereferenceargument_test.py49
-rw-r--r--sources/shiboken2/tests/samplebinding/privatector_test.py84
-rw-r--r--sources/shiboken2/tests/samplebinding/privatedtor_test.py99
-rw-r--r--sources/shiboken2/tests/samplebinding/protected_test.py357
-rw-r--r--sources/shiboken2/tests/samplebinding/pstrlist_test.py50
-rw-r--r--sources/shiboken2/tests/samplebinding/pystr_test.py49
-rw-r--r--sources/shiboken2/tests/samplebinding/python_thread_test.py116
-rw-r--r--sources/shiboken2/tests/samplebinding/receive_null_cstring_test.py54
-rw-r--r--sources/shiboken2/tests/samplebinding/reference_test.py122
-rw-r--r--sources/shiboken2/tests/samplebinding/referencetopointer_test.py97
-rw-r--r--sources/shiboken2/tests/samplebinding/return_null_test.py59
-rw-r--r--sources/shiboken2/tests/samplebinding/richcompare_test.py46
-rw-r--r--sources/shiboken2/tests/samplebinding/sample-binding.txt.in15
-rw-r--r--sources/shiboken2/tests/samplebinding/sample_test.py78
-rw-r--r--sources/shiboken2/tests/samplebinding/simplefile_glue.cpp34
-rw-r--r--sources/shiboken2/tests/samplebinding/simplefile_test.py81
-rw-r--r--sources/shiboken2/tests/samplebinding/size_test.py119
-rw-r--r--sources/shiboken2/tests/samplebinding/static_nonstatic_methods_test.py109
-rw-r--r--sources/shiboken2/tests/samplebinding/str_test.py115
-rw-r--r--sources/shiboken2/tests/samplebinding/strlist_test.py112
-rw-r--r--sources/shiboken2/tests/samplebinding/templateinheritingclass_test.py80
-rw-r--r--sources/shiboken2/tests/samplebinding/time_test.py139
-rw-r--r--sources/shiboken2/tests/samplebinding/transform_test.py56
-rw-r--r--sources/shiboken2/tests/samplebinding/typeconverters_test.py189
-rw-r--r--sources/shiboken2/tests/samplebinding/typedealloc_test.py75
-rw-r--r--sources/shiboken2/tests/samplebinding/typedtordoublefree_test.py54
-rw-r--r--sources/shiboken2/tests/samplebinding/typesystem_sample.xml2426
-rw-r--r--sources/shiboken2/tests/samplebinding/unsafe_parent_test.py54
-rw-r--r--sources/shiboken2/tests/samplebinding/useraddedctor_test.py45
-rw-r--r--sources/shiboken2/tests/samplebinding/virtualdtor_test.py76
-rw-r--r--sources/shiboken2/tests/samplebinding/virtualmethods_test.py138
-rw-r--r--sources/shiboken2/tests/samplebinding/visibilitychange_test.py47
-rw-r--r--sources/shiboken2/tests/samplebinding/voidholder_test.py69
-rw-r--r--sources/shiboken2/tests/samplebinding/weakref_test.py65
-rw-r--r--sources/shiboken2/tests/samplebinding/writableclassdict_test.py52
-rw-r--r--sources/shiboken2/tests/shibokenmodule/module_test.py116
-rw-r--r--sources/shiboken2/tests/smartbinding/CMakeLists.txt39
-rw-r--r--sources/shiboken2/tests/smartbinding/global.h29
-rw-r--r--sources/shiboken2/tests/smartbinding/smart-binding.txt.in15
-rw-r--r--sources/shiboken2/tests/smartbinding/smart_pointer_test.py147
-rw-r--r--sources/shiboken2/tests/smartbinding/typesystem_smart.xml23
-rw-r--r--sources/shiboken2/tests/sphinxtabletest.cpp332
-rw-r--r--sources/shiboken2/tests/sphinxtabletest.h54
-rw-r--r--sources/shiboken2/tests/test_generator/CMakeLists.txt68
-rw-r--r--sources/shiboken2/tests/test_generator/dummygenerator.cpp69
-rw-r--r--sources/shiboken2/tests/test_generator/dummygenerator.h49
-rw-r--r--sources/shiboken2/tests/test_generator/dummygentest-project.txt.in20
-rw-r--r--sources/shiboken2/tests/test_generator/dummygentest.cpp138
-rw-r--r--sources/shiboken2/tests/test_generator/dummygentest.h56
-rw-r--r--sources/shiboken2/tests/test_generator/dummygentestconfig.h.in15
-rw-r--r--sources/shiboken2/tests/test_generator/main.cpp39
-rw-r--r--sources/shiboken2/tests/test_generator/run_test.cmake11
-rw-r--r--sources/shiboken2/tests/test_generator/test_global.h1
-rw-r--r--sources/shiboken2/tests/test_generator/test_typesystem.xml3
2207 files changed, 251698 insertions, 0 deletions
diff --git a/sources/pyside2/.gitattributes b/sources/pyside2/.gitattributes
new file mode 100644
index 000000000..adbe833c1
--- /dev/null
+++ b/sources/pyside2/.gitattributes
@@ -0,0 +1,2 @@
+.gitignore export-ignore
+.gitattributes export-ignore
diff --git a/sources/pyside2/.gitignore b/sources/pyside2/.gitignore
new file mode 100644
index 000000000..b2e7c9d7d
--- /dev/null
+++ b/sources/pyside2/.gitignore
@@ -0,0 +1,6 @@
+build
+*.kdev4
+.kdev4
+*~
+*.log
+*.pyc
diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt
new file mode 100644
index 000000000..6c5691d01
--- /dev/null
+++ b/sources/pyside2/CMakeLists.txt
@@ -0,0 +1,391 @@
+include(cmake/Macros/icecc.cmake) # this must be the first line!
+
+cmake_minimum_required(VERSION 3.0)
+cmake_policy(VERSION 3.0)
+
+project(pysidebindings)
+
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Macros/
+ ${CMAKE_MODULE_PATH})
+
+option(USE_PYTHON_VERSION "Use specific python version to build pyside2." "")
+
+if (USE_PYTHON_VERSION)
+ find_package(PythonInterp ${USE_PYTHON_VERSION} REQUIRED)
+ find_package(PythonLibs ${USE_PYTHON_VERSION} REQUIRED)
+else()
+ find_package(PythonInterp 2.6)
+ find_package(PythonLibs 2.6)
+endif()
+
+# Queries the python sysconfig for the abi flags which need to be inserted into extension suffixes.
+# Only present starting with Python 3.2.
+# Corresponding configure switches to single letter flags:
+# --with-pymalloc -> m
+# --with-pydebug -> d
+# --with-unicode -> u (rare)
+macro(get_python3_abi_flags)
+ if (NOT PYTHON_ABI_FLAGS)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ import sysconfig
+ print(sysconfig.get_config_var('abiflags'))
+ "
+ OUTPUT_VARIABLE PYTHON_ABI_FLAGS
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ endif()
+ message("PYTHON_ABI_FLAGS: " ${PYTHON_ABI_FLAGS})
+endmacro()
+
+macro(get_python_multi_arch_suffix)
+ # TODO: This part needs testing to check if it is available on Windows.
+ # It is present on macOS, but is not used yet.
+ # Result is something like 'x86_64-linux-gnu'.
+ if (NOT PYTHON_MULTIARCH_SUFFIX)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ import sysconfig
+ print(sysconfig.get_config_var('MULTIARCH'))
+ "
+ OUTPUT_VARIABLE PYTHON_MULTIARCH_SUFFIX
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ endif()
+ message("PYTHON_MULTIARCH_SUFFIX: " ${PYTHON_MULTIARCH_SUFFIX})
+endmacro()
+
+macro(get_python2_release_suffix)
+ # Result of imp.get_suffixes() is something like:
+ # [('_d.so', 'rb', 3), ('module_d.so', 'rb', 3), ('.x86_64-linux-gnu_d.so', 'rb', 3)]
+ # or alternatively the same but withut the '_d' part.
+ # The list comprehension is used to choose which suffix to include in library names.
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ import imp
+ print('_d' if any([tup[0].endswith('_d.so') for tup in imp.get_suffixes()]) else '')
+ "
+ OUTPUT_VARIABLE PYTHON_MODULE_RELEASE_SUFFIX
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message("PYTHON_MODULE_RELEASE_SUFFIX: " ${PYTHON_MODULE_RELEASE_SUFFIX})
+endmacro()
+
+if (UNIX AND NOT APPLE)
+ if (NOT PYTHON_EXTENSION_SUFFIX)
+ get_python_multi_arch_suffix()
+ # The suffix added to .so libraries should be differenet between Python 2 and 3.
+ # The position of the multiarch suffix is different, and the way the debug flag is set
+ # computed differently.
+ # In Python 2 there is no standard way to query if the python interpeter was built in debug or
+ # release build (sysconfig.get_config_var('Py_Debug') can have a different value than you would
+ # expect if you do a custom Python build). The solution to query for the import
+ # suffixes and check if _d is present there. It is present on Linux distribution
+ # packages of Python, but not in custom built Python builds, because the distros apply their
+ # custom patches too append the '_d's.
+ # In Python 3 (starting with 3.2) there is a standard way to check if '_d' needs to be added,
+ # as well as any other letters, by querying the abiflags sysconfig variable.
+ if (PYTHON_VERSION_MAJOR EQUAL 2)
+ get_python2_release_suffix()
+ # The suffix of Python module files (e.g. QtCore.x86_64-linux-gnu_d.so) as well as library
+ # libraries (e.g. libpyside2.x86_64-linux-gnu.so).
+ if(PYTHON_MULTIARCH_SUFFIX)
+ set(PYTHON_EXTENSION_SUFFIX ".${PYTHON_MULTIARCH_SUFFIX}")
+ endif()
+ set(PYTHON_EXTENSION_SUFFIX "${PYTHON_EXTENSION_SUFFIX}${PYTHON_MODULE_RELEASE_SUFFIX}")
+ elseif (PYTHON_VERSION_MAJOR EQUAL 3)
+ get_python3_abi_flags()
+ set(PYTHON_EXTENSION_SUFFIX ".cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}${PYTHON_ABI_FLAGS}")
+ if(PYTHON_MULTIARCH_SUFFIX)
+ set(PYTHON_EXTENSION_SUFFIX "${PYTHON_EXTENSION_SUFFIX}-${PYTHON_MULTIARCH_SUFFIX}")
+ endif()
+ else()
+ message(FATAL_ERROR "Unsupported PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}!")
+ endif()
+ endif()
+ message("PYTHON_EXTENSION_SUFFIX: " ${PYTHON_EXTENSION_SUFFIX})
+endif ()
+
+find_package(Shiboken2 2.0.0 REQUIRED)
+find_package(Qt5 5.6.0 REQUIRED COMPONENTS Core)
+add_definitions(${Qt5Core_DEFINITIONS})
+
+find_file(GL_H "gl.h" PATH_SUFFIXES "GL")
+message("result:" "${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)" )
+set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE)
+if(CMAKE_HOST_APPLE)
+ set(ALTERNATIVE_QT_INCLUDE_DIR "" CACHE PATH "The Alternative value to QT_INCLUDE_DIR. Necessary to fix bug on cmake 2.8 MACOS users")
+ set(OSX_USE_LIBCPP "OFF" CACHE BOOL "Explicitly link the libc++ standard library (useful for osx deployment targets lower than 10.9.")
+ if(OSX_USE_LIBCPP)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+ endif()
+endif()
+
+if(NOT CMAKE_HOST_APPLE)
+ # Qt5: QT_INCLUDE_DIR does no longer exist.
+ # On Windows and Linux, it can be computed from Qt5Core_INCLUDE_DIRS
+ message("Qt5Core_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS}")
+ list(GET Qt5Core_INCLUDE_DIRS 0 QT_INCLUDE_DIR)
+ message(STATUS "*** computed QT_INCLUDE_DIR as ${QT_INCLUDE_DIR}")
+endif()
+
+if(MSVC)
+ # Qt5: this flag has changed from /Zc:wchar_t- in Qt4.X
+ set(CMAKE_CXX_FLAGS "/Zc:wchar_t /GR /EHsc /DNOCOLOR /DWIN32 /D_WINDOWS /D_SCL_SECURE_NO_WARNINGS") # XXX
+else()
+ if(CMAKE_HOST_UNIX AND NOT CYGWIN)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden -Wno-strict-aliasing")
+ endif()
+ set(CMAKE_CXX_FLAGS_DEBUG "-g")
+ option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0)
+ if(ENABLE_GCC_OPTIMIZATION)
+ set(CMAKE_BUILD_TYPE Release)
+ set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -Os -Wl,-O1")
+ if(NOT CMAKE_HOST_APPLE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--hash-style=gnu")
+ endif()
+ endif()
+
+ if(CMAKE_HOST_APPLE)
+ if (NOT QT_INCLUDE_DIR)
+ set(QT_INCLUDE_DIR "/Library/Frameworks")
+ endif()
+ if(ALTERNATIVE_QT_INCLUDE_DIR)
+ set(QT_INCLUDE_DIR ${ALTERNATIVE_QT_INCLUDE_DIR})
+ endif()
+ string(REPLACE " " ":" QT_INCLUDE_DIR ${QT_INCLUDE_DIR})
+ endif()
+endif()
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE ${SHIBOKEN_BUILD_TYPE})
+endif()
+
+set(BINDING_NAME PySide2)
+set(BINDING_API_MAJOR_VERSION "2")
+set(BINDING_API_MINOR_VERSION "0")
+set(BINDING_API_MICRO_VERSION "0")
+set(BINDING_API_RELEASE_LEVEL "alpha") # alpha, beta, rc, or final
+set(BINDING_API_SERIAL 0) # leave as 0 when release level is final
+set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}" CACHE STRING "PySide version" FORCE)
+if (BINDING_API_RELEASE_LEVEL STREQUAL "final")
+ set(BINDING_API_VERSION_FULL "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}"
+ CACHE STRING "PySide version [full]" FORCE)
+else()
+ set(BINDING_API_VERSION_FULL "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}~${BINDING_API_RELEASE_LEVEL}${BINDING_API_SERIAL}"
+ CACHE STRING "PySide version [full]" FORCE)
+endif()
+
+include(PySideModules)
+
+macro(COLLECT_MODULE_IF_FOUND shortname)
+ set(name "Qt5${shortname}")
+ find_package(${name})
+ set(_name_found "${name}_FOUND")
+ if(${_name_found})
+ message(STATUS "module ${name} found (${ARGN})")
+
+ # Put the module at the end of pyside2_global.h
+ file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/PySide2/pyside2_global.h.add"
+ "#include \"Qt${shortname}/Qt${shortname}\"\n")
+ # record the shortnames for the tests
+ list(APPEND all_module_shortnames ${shortname})
+ else()
+ if("${ARGN}" STREQUAL "opt")
+ message(STATUS "optional module ${name} skipped")
+ elseif("${ARGN}" STREQUAL "essential")
+ message(STATUS "skipped module ${name} is essential!\n"
+ " We do not guarantee that all tests are working.")
+ else()
+ message(FATAL_ERROR "module ${name} MISSING")
+ endif()
+ endif()
+endmacro()
+
+# note: the order of this list is relevant for dependencies.
+# For instance: Qt5Printsupport must come before Qt5WebKitWidgets.
+COLLECT_MODULE_IF_FOUND(Core)
+COLLECT_MODULE_IF_FOUND(Gui essential)
+COLLECT_MODULE_IF_FOUND(Widgets essential)
+COLLECT_MODULE_IF_FOUND(PrintSupport essential)
+COLLECT_MODULE_IF_FOUND(Sql essential)
+COLLECT_MODULE_IF_FOUND(Network essential)
+COLLECT_MODULE_IF_FOUND(Test essential)
+if(NOT MSVC)
+ # right now this does not build on windows
+ COLLECT_MODULE_IF_FOUND(Concurrent essential)
+else()
+ set(DISABLE_QtConcurrent 1)
+ENDIF()
+if(UNIX AND NOT APPLE)
+ COLLECT_MODULE_IF_FOUND(X11Extras essential)
+endif()
+if(WIN32)
+ COLLECT_MODULE_IF_FOUND(WinExtras essential)
+endif()
+if(APPLE)
+ COLLECT_MODULE_IF_FOUND(MacExtras essential)
+endif()
+COLLECT_MODULE_IF_FOUND(Xml)
+COLLECT_MODULE_IF_FOUND(XmlPatterns opt)
+COLLECT_MODULE_IF_FOUND(Help opt)
+COLLECT_MODULE_IF_FOUND(Multimedia opt)
+COLLECT_MODULE_IF_FOUND(MultimediaWidgets opt)
+COLLECT_MODULE_IF_FOUND(OpenGL opt)
+COLLECT_MODULE_IF_FOUND(Qml opt)
+COLLECT_MODULE_IF_FOUND(Quick opt)
+COLLECT_MODULE_IF_FOUND(QuickWidgets opt)
+COLLECT_MODULE_IF_FOUND(Script opt)
+if(NOT MSVC)
+ # right now this does not build on windows
+ COLLECT_MODULE_IF_FOUND(ScriptTools opt)
+else()
+ set(DISABLE_QtScriptTools 1)
+ENDIF()
+COLLECT_MODULE_IF_FOUND(Svg opt)
+if(Qt5Designer_FOUND)
+ COLLECT_MODULE_IF_FOUND(UiTools opt)
+else()
+ set(DISABLE_QtUiTools 1)
+endif()
+COLLECT_MODULE_IF_FOUND(WebChannel opt)
+# still forgotten:
+#COLLECT_MODULE_IF_FOUND(WebEngineCore opt)
+#COLLECT_MODULE_IF_FOUND(WebEngine opt)
+COLLECT_MODULE_IF_FOUND(WebEngineWidgets opt)
+COLLECT_MODULE_IF_FOUND(WebKit opt)
+if(NOT MSVC)
+ # right now this does not build on windows
+ COLLECT_MODULE_IF_FOUND(WebKitWidgets opt)
+else()
+ set(DISABLE_QtWebKitWidgets 1)
+ENDIF()
+COLLECT_MODULE_IF_FOUND(WebSockets opt)
+
+string(REGEX MATCHALL "[0-9]+" qt_version_helper "${Qt5Core_VERSION}")
+
+list(GET qt_version_helper 0 QT_VERSION_MAJOR)
+list(GET qt_version_helper 1 QT_VERSION_MINOR)
+unset(qt_version_helper)
+
+set(PYSIDE_QT_VERSION "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" CACHE STRING "Qt version used to compile PySide" FORCE)
+if(ENABLE_VERSION_SUFFIX)
+ set(pyside_SUFFIX "-${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}")
+endif()
+
+# no more supported: include(${QT_USE_FILE})
+
+# Configure OS support
+set(ENABLE_X11 "0")
+set(ENABLE_MAC "0")
+set(ENABLE_WIN "0")
+set(ENABLE_SIMULATOR "0")
+
+# no more Maemo, no more simulator
+if(CMAKE_HOST_APPLE)
+ set(ENABLE_MAC "1")
+ set(AUTO_OS "mac")
+elseif(CMAKE_HOST_WIN32)
+ set(ENABLE_WIN "1")
+ set(AUTO_OS "win")
+elseif(CMAKE_HOST_UNIX)
+ set(ENABLE_X11 "1")
+ set(AUTO_OS "x11")
+else()
+ message(FATAL_ERROR "OS not supported")
+endif()
+message(STATUS "Detected OS: ${AUTO_OS}")
+
+if (WIN32)
+ set(PATH_SEP "\;")
+else()
+ set(PATH_SEP ":")
+endif()
+
+# Define supported Qt Version
+set(SUPPORTED_QT_VERSION "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}")
+
+set(BINDING_VERSION ${BINDING_API_VERSION}.${QT_VERSION_MAJOR}.${QT_VERSION_MINOR})
+
+# uninstall target
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ IMMEDIATE @ONLY)
+add_custom_target(uninstall "${CMAKE_COMMAND}"
+ -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
+
+
+set(ARCHIVE_NAME pyside-qt${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}+${BINDING_API_VERSION_FULL})
+add_custom_target(dist
+ COMMAND mkdir -p "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}" &&
+ git log > "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}/ChangeLog" &&
+ git archive --prefix=${ARCHIVE_NAME}/ HEAD --format=tar --output="${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" &&
+ tar -C "${CMAKE_BINARY_DIR}" --owner=root --group=root -r "${ARCHIVE_NAME}/ChangeLog" -f "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" &&
+ bzip2 -f9 "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" &&
+ echo "Source package created at ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2.\n"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+if (NOT SITE_PACKAGE)
+ execute_process(
+ COMMAND ${SHIBOKEN_PYTHON_INTERPRETER} -c "if True:
+ from distutils import sysconfig
+ from os.path import sep
+ print(sysconfig.get_python_lib(1, 0, prefix='${CMAKE_INSTALL_PREFIX}').replace(sep, '/'))
+ "
+ OUTPUT_VARIABLE SITE_PACKAGE
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (NOT SITE_PACKAGE)
+ message(FATAL_ERROR "Could not detect Python module installation directory.")
+ elseif (APPLE)
+ message(STATUS "!!! The generated bindings will be installed on ${SITE_PACKAGE}, is it right!?")
+ endif()
+endif()
+
+set(GENERATOR_EXTRA_FLAGS --generator-set=shiboken
+ --enable-parent-ctor-heuristic
+ --enable-pyside-extensions
+ --enable-return-value-heuristic
+ --use-isnull-as-nb_nonzero)
+# 2017-04-24 The protected hack can unfortunately not be disabled, because
+# Clang does produce linker errors when we disable the hack.
+# But the ugly workaround in Python is replaced by a shiboken change.
+if(WIN32 OR DEFINED AVOID_PROTECTED_HACK)
+ message(STATUS "PySide2 will be generated avoiding the protected hack!")
+ set(GENERATOR_EXTRA_FLAGS ${GENERATOR_EXTRA_FLAGS} --avoid-protected-hack)
+ add_definitions(-DAVOID_PROTECTED_HACK)
+else()
+ message(STATUS "PySide will be generated using the protected hack!")
+endif()
+
+add_subdirectory(libpyside)
+find_package(Qt5UiTools)
+find_package(Qt5Designer)
+if(Qt5UiTools_FOUND AND Qt5Designer_FOUND)
+ add_subdirectory(plugins)
+endif()
+
+# project directories
+add_subdirectory(PySide2)
+if (BUILD_TESTS)
+ enable_testing()
+ add_subdirectory(tests)
+endif ()
+
+find_program(DOT_EXEC dot)
+if (QT_SRC_DIR AND DOT_EXEC)
+ add_subdirectory(doc)
+else ()
+ message(STATUS "QT_SRC_DIR variable not set or graphviz not found, apidoc generation targets disabled.")
+endif()
diff --git a/sources/pyside2/COPYING b/sources/pyside2/COPYING
new file mode 100644
index 000000000..9315102f7
--- /dev/null
+++ b/sources/pyside2/COPYING
@@ -0,0 +1,501 @@
+GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
diff --git a/sources/pyside2/LICENSE.FDL b/sources/pyside2/LICENSE.FDL
new file mode 100644
index 000000000..938bb8da9
--- /dev/null
+++ b/sources/pyside2/LICENSE.FDL
@@ -0,0 +1,450 @@
+ GNU Free Documentation License
+ Version 1.3, 3 November 2008
+
+
+ Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
+ <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+0. PREAMBLE
+
+The purpose of this License is to make a manual, textbook, or other
+functional and useful document "free" in the sense of freedom: to
+assure everyone the effective freedom to copy and redistribute it,
+with or without modifying it, either commercially or noncommercially.
+Secondarily, this License preserves for the author and publisher a way
+to get credit for their work, while not being considered responsible
+for modifications made by others.
+
+This License is a kind of "copyleft", which means that derivative
+works of the document must themselves be free in the same sense. It
+complements the GNU General Public License, which is a copyleft
+license designed for free software.
+
+We have designed this License in order to use it for manuals for free
+software, because free software needs free documentation: a free
+program should come with manuals providing the same freedoms that the
+software does. But this License is not limited to software manuals;
+it can be used for any textual work, regardless of subject matter or
+whether it is published as a printed book. We recommend this License
+principally for works whose purpose is instruction or reference.
+
+
+1. APPLICABILITY AND DEFINITIONS
+
+This License applies to any manual or other work, in any medium, that
+contains a notice placed by the copyright holder saying it can be
+distributed under the terms of this License. Such a notice grants a
+world-wide, royalty-free license, unlimited in duration, to use that
+work under the conditions stated herein. The "Document", below,
+refers to any such manual or work. Any member of the public is a
+licensee, and is addressed as "you". You accept the license if you
+copy, modify or distribute the work in a way requiring permission
+under copyright law.
+
+A "Modified Version" of the Document means any work containing the
+Document or a portion of it, either copied verbatim, or with
+modifications and/or translated into another language.
+
+A "Secondary Section" is a named appendix or a front-matter section of
+the Document that deals exclusively with the relationship of the
+publishers or authors of the Document to the Document's overall
+subject (or to related matters) and contains nothing that could fall
+directly within that overall subject. (Thus, if the Document is in
+part a textbook of mathematics, a Secondary Section may not explain
+any mathematics.) The relationship could be a matter of historical
+connection with the subject or with related matters, or of legal,
+commercial, philosophical, ethical or political position regarding
+them.
+
+The "Invariant Sections" are certain Secondary Sections whose titles
+are designated, as being those of Invariant Sections, in the notice
+that says that the Document is released under this License. If a
+section does not fit the above definition of Secondary then it is not
+allowed to be designated as Invariant. The Document may contain zero
+Invariant Sections. If the Document does not identify any Invariant
+Sections then there are none.
+
+The "Cover Texts" are certain short passages of text that are listed,
+as Front-Cover Texts or Back-Cover Texts, in the notice that says that
+the Document is released under this License. A Front-Cover Text may
+be at most 5 words, and a Back-Cover Text may be at most 25 words.
+
+A "Transparent" copy of the Document means a machine-readable copy,
+represented in a format whose specification is available to the
+general public, that is suitable for revising the document
+straightforwardly with generic text editors or (for images composed of
+pixels) generic paint programs or (for drawings) some widely available
+drawing editor, and that is suitable for input to text formatters or
+for automatic translation to a variety of formats suitable for input
+to text formatters. A copy made in an otherwise Transparent file
+format whose markup, or absence of markup, has been arranged to thwart
+or discourage subsequent modification by readers is not Transparent.
+An image format is not Transparent if used for any substantial amount
+of text. A copy that is not "Transparent" is called "Opaque".
+
+Examples of suitable formats for Transparent copies include plain
+ASCII without markup, Texinfo input format, LaTeX input format, SGML
+or XML using a publicly available DTD, and standard-conforming simple
+HTML, PostScript or PDF designed for human modification. Examples of
+transparent image formats include PNG, XCF and JPG. Opaque formats
+include proprietary formats that can be read and edited only by
+proprietary word processors, SGML or XML for which the DTD and/or
+processing tools are not generally available, and the
+machine-generated HTML, PostScript or PDF produced by some word
+processors for output purposes only.
+
+The "Title Page" means, for a printed book, the title page itself,
+plus such following pages as are needed to hold, legibly, the material
+this License requires to appear in the title page. For works in
+formats which do not have any title page as such, "Title Page" means
+the text near the most prominent appearance of the work's title,
+preceding the beginning of the body of the text.
+
+The "publisher" means any person or entity that distributes copies of
+the Document to the public.
+
+A section "Entitled XYZ" means a named subunit of the Document whose
+title either is precisely XYZ or contains XYZ in parentheses following
+text that translates XYZ in another language. (Here XYZ stands for a
+specific section name mentioned below, such as "Acknowledgements",
+"Dedications", "Endorsements", or "History".) To "Preserve the Title"
+of such a section when you modify the Document means that it remains a
+section "Entitled XYZ" according to this definition.
+
+The Document may include Warranty Disclaimers next to the notice which
+states that this License applies to the Document. These Warranty
+Disclaimers are considered to be included by reference in this
+License, but only as regards disclaiming warranties: any other
+implication that these Warranty Disclaimers may have is void and has
+no effect on the meaning of this License.
+
+2. VERBATIM COPYING
+
+You may copy and distribute the Document in any medium, either
+commercially or noncommercially, provided that this License, the
+copyright notices, and the license notice saying this License applies
+to the Document are reproduced in all copies, and that you add no
+other conditions whatsoever to those of this License. You may not use
+technical measures to obstruct or control the reading or further
+copying of the copies you make or distribute. However, you may accept
+compensation in exchange for copies. If you distribute a large enough
+number of copies you must also follow the conditions in section 3.
+
+You may also lend copies, under the same conditions stated above, and
+you may publicly display copies.
+
+
+3. COPYING IN QUANTITY
+
+If you publish printed copies (or copies in media that commonly have
+printed covers) of the Document, numbering more than 100, and the
+Document's license notice requires Cover Texts, you must enclose the
+copies in covers that carry, clearly and legibly, all these Cover
+Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
+the back cover. Both covers must also clearly and legibly identify
+you as the publisher of these copies. The front cover must present
+the full title with all words of the title equally prominent and
+visible. You may add other material on the covers in addition.
+Copying with changes limited to the covers, as long as they preserve
+the title of the Document and satisfy these conditions, can be treated
+as verbatim copying in other respects.
+
+If the required texts for either cover are too voluminous to fit
+legibly, you should put the first ones listed (as many as fit
+reasonably) on the actual cover, and continue the rest onto adjacent
+pages.
+
+If you publish or distribute Opaque copies of the Document numbering
+more than 100, you must either include a machine-readable Transparent
+copy along with each Opaque copy, or state in or with each Opaque copy
+a computer-network location from which the general network-using
+public has access to download using public-standard network protocols
+a complete Transparent copy of the Document, free of added material.
+If you use the latter option, you must take reasonably prudent steps,
+when you begin distribution of Opaque copies in quantity, to ensure
+that this Transparent copy will remain thus accessible at the stated
+location until at least one year after the last time you distribute an
+Opaque copy (directly or through your agents or retailers) of that
+edition to the public.
+
+It is requested, but not required, that you contact the authors of the
+Document well before redistributing any large number of copies, to
+give them a chance to provide you with an updated version of the
+Document.
+
+
+4. MODIFICATIONS
+
+You may copy and distribute a Modified Version of the Document under
+the conditions of sections 2 and 3 above, provided that you release
+the Modified Version under precisely this License, with the Modified
+Version filling the role of the Document, thus licensing distribution
+and modification of the Modified Version to whoever possesses a copy
+of it. In addition, you must do these things in the Modified Version:
+
+A. Use in the Title Page (and on the covers, if any) a title distinct
+ from that of the Document, and from those of previous versions
+ (which should, if there were any, be listed in the History section
+ of the Document). You may use the same title as a previous version
+ if the original publisher of that version gives permission.
+B. List on the Title Page, as authors, one or more persons or entities
+ responsible for authorship of the modifications in the Modified
+ Version, together with at least five of the principal authors of the
+ Document (all of its principal authors, if it has fewer than five),
+ unless they release you from this requirement.
+C. State on the Title page the name of the publisher of the
+ Modified Version, as the publisher.
+D. Preserve all the copyright notices of the Document.
+E. Add an appropriate copyright notice for your modifications
+ adjacent to the other copyright notices.
+F. Include, immediately after the copyright notices, a license notice
+ giving the public permission to use the Modified Version under the
+ terms of this License, in the form shown in the Addendum below.
+G. Preserve in that license notice the full lists of Invariant Sections
+ and required Cover Texts given in the Document's license notice.
+H. Include an unaltered copy of this License.
+I. Preserve the section Entitled "History", Preserve its Title, and add
+ to it an item stating at least the title, year, new authors, and
+ publisher of the Modified Version as given on the Title Page. If
+ there is no section Entitled "History" in the Document, create one
+ stating the title, year, authors, and publisher of the Document as
+ given on its Title Page, then add an item describing the Modified
+ Version as stated in the previous sentence.
+J. Preserve the network location, if any, given in the Document for
+ public access to a Transparent copy of the Document, and likewise
+ the network locations given in the Document for previous versions
+ it was based on. These may be placed in the "History" section.
+ You may omit a network location for a work that was published at
+ least four years before the Document itself, or if the original
+ publisher of the version it refers to gives permission.
+K. For any section Entitled "Acknowledgements" or "Dedications",
+ Preserve the Title of the section, and preserve in the section all
+ the substance and tone of each of the contributor acknowledgements
+ and/or dedications given therein.
+L. Preserve all the Invariant Sections of the Document,
+ unaltered in their text and in their titles. Section numbers
+ or the equivalent are not considered part of the section titles.
+M. Delete any section Entitled "Endorsements". Such a section
+ may not be included in the Modified Version.
+N. Do not retitle any existing section to be Entitled "Endorsements"
+ or to conflict in title with any Invariant Section.
+O. Preserve any Warranty Disclaimers.
+
+If the Modified Version includes new front-matter sections or
+appendices that qualify as Secondary Sections and contain no material
+copied from the Document, you may at your option designate some or all
+of these sections as invariant. To do this, add their titles to the
+list of Invariant Sections in the Modified Version's license notice.
+These titles must be distinct from any other section titles.
+
+You may add a section Entitled "Endorsements", provided it contains
+nothing but endorsements of your Modified Version by various
+parties--for example, statements of peer review or that the text has
+been approved by an organization as the authoritative definition of a
+standard.
+
+You may add a passage of up to five words as a Front-Cover Text, and a
+passage of up to 25 words as a Back-Cover Text, to the end of the list
+of Cover Texts in the Modified Version. Only one passage of
+Front-Cover Text and one of Back-Cover Text may be added by (or
+through arrangements made by) any one entity. If the Document already
+includes a cover text for the same cover, previously added by you or
+by arrangement made by the same entity you are acting on behalf of,
+you may not add another; but you may replace the old one, on explicit
+permission from the previous publisher that added the old one.
+
+The author(s) and publisher(s) of the Document do not by this License
+give permission to use their names for publicity for or to assert or
+imply endorsement of any Modified Version.
+
+
+5. COMBINING DOCUMENTS
+
+You may combine the Document with other documents released under this
+License, under the terms defined in section 4 above for modified
+versions, provided that you include in the combination all of the
+Invariant Sections of all of the original documents, unmodified, and
+list them all as Invariant Sections of your combined work in its
+license notice, and that you preserve all their Warranty Disclaimers.
+
+The combined work need only contain one copy of this License, and
+multiple identical Invariant Sections may be replaced with a single
+copy. If there are multiple Invariant Sections with the same name but
+different contents, make the title of each such section unique by
+adding at the end of it, in parentheses, the name of the original
+author or publisher of that section if known, or else a unique number.
+Make the same adjustment to the section titles in the list of
+Invariant Sections in the license notice of the combined work.
+
+In the combination, you must combine any sections Entitled "History"
+in the various original documents, forming one section Entitled
+"History"; likewise combine any sections Entitled "Acknowledgements",
+and any sections Entitled "Dedications". You must delete all sections
+Entitled "Endorsements".
+
+
+6. COLLECTIONS OF DOCUMENTS
+
+You may make a collection consisting of the Document and other
+documents released under this License, and replace the individual
+copies of this License in the various documents with a single copy
+that is included in the collection, provided that you follow the rules
+of this License for verbatim copying of each of the documents in all
+other respects.
+
+You may extract a single document from such a collection, and
+distribute it individually under this License, provided you insert a
+copy of this License into the extracted document, and follow this
+License in all other respects regarding verbatim copying of that
+document.
+
+
+7. AGGREGATION WITH INDEPENDENT WORKS
+
+A compilation of the Document or its derivatives with other separate
+and independent documents or works, in or on a volume of a storage or
+distribution medium, is called an "aggregate" if the copyright
+resulting from the compilation is not used to limit the legal rights
+of the compilation's users beyond what the individual works permit.
+When the Document is included in an aggregate, this License does not
+apply to the other works in the aggregate which are not themselves
+derivative works of the Document.
+
+If the Cover Text requirement of section 3 is applicable to these
+copies of the Document, then if the Document is less than one half of
+the entire aggregate, the Document's Cover Texts may be placed on
+covers that bracket the Document within the aggregate, or the
+electronic equivalent of covers if the Document is in electronic form.
+Otherwise they must appear on printed covers that bracket the whole
+aggregate.
+
+
+8. TRANSLATION
+
+Translation is considered a kind of modification, so you may
+distribute translations of the Document under the terms of section 4.
+Replacing Invariant Sections with translations requires special
+permission from their copyright holders, but you may include
+translations of some or all Invariant Sections in addition to the
+original versions of these Invariant Sections. You may include a
+translation of this License, and all the license notices in the
+Document, and any Warranty Disclaimers, provided that you also include
+the original English version of this License and the original versions
+of those notices and disclaimers. In case of a disagreement between
+the translation and the original version of this License or a notice
+or disclaimer, the original version will prevail.
+
+If a section in the Document is Entitled "Acknowledgements",
+"Dedications", or "History", the requirement (section 4) to Preserve
+its Title (section 1) will typically require changing the actual
+title.
+
+
+9. TERMINATION
+
+You may not copy, modify, sublicense, or distribute the Document
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense, or distribute it is void, and
+will automatically terminate your rights under this License.
+
+However, if you cease all violation of this License, then your license
+from a particular copyright holder is reinstated (a) provisionally,
+unless and until the copyright holder explicitly and finally
+terminates your license, and (b) permanently, if the copyright holder
+fails to notify you of the violation by some reasonable means prior to
+60 days after the cessation.
+
+Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, receipt of a copy of some or all of the same material does
+not give you any rights to use it.
+
+
+10. FUTURE REVISIONS OF THIS LICENSE
+
+The Free Software Foundation may publish new, revised versions of the
+GNU Free Documentation License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in
+detail to address new problems or concerns. See
+http://www.gnu.org/copyleft/.
+
+Each version of the License is given a distinguishing version number.
+If the Document specifies that a particular numbered version of this
+License "or any later version" applies to it, you have the option of
+following the terms and conditions either of that specified version or
+of any later version that has been published (not as a draft) by the
+Free Software Foundation. If the Document does not specify a version
+number of this License, you may choose any version ever published (not
+as a draft) by the Free Software Foundation. If the Document
+specifies that a proxy can decide which future versions of this
+License can be used, that proxy's public statement of acceptance of a
+version permanently authorizes you to choose that version for the
+Document.
+
+11. RELICENSING
+
+"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
+World Wide Web server that publishes copyrightable works and also
+provides prominent facilities for anybody to edit those works. A
+public wiki that anybody can edit is an example of such a server. A
+"Massive Multiauthor Collaboration" (or "MMC") contained in the site
+means any set of copyrightable works thus published on the MMC site.
+
+"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
+license published by Creative Commons Corporation, a not-for-profit
+corporation with a principal place of business in San Francisco,
+California, as well as future copyleft versions of that license
+published by that same organization.
+
+"Incorporate" means to publish or republish a Document, in whole or in
+part, as part of another Document.
+
+An MMC is "eligible for relicensing" if it is licensed under this
+License, and if all works that were first published under this License
+somewhere other than this MMC, and subsequently incorporated in whole or
+in part into the MMC, (1) had no cover texts or invariant sections, and
+(2) were thus incorporated prior to November 1, 2008.
+
+The operator of an MMC Site may republish an MMC contained in the site
+under CC-BY-SA on the same site at any time before August 1, 2009,
+provided the MMC is eligible for relicensing.
+
+
+ADDENDUM: How to use this License for your documents
+
+To use this License in a document you have written, include a copy of
+the License in the document and put the following copyright and
+license notices just after the title page:
+
+ Copyright (c) YEAR YOUR NAME.
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.3
+ or any later version published by the Free Software Foundation;
+ with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+ A copy of the license is included in the section entitled "GNU
+ Free Documentation License".
+
+If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
+replace the "with...Texts." line with this:
+
+ with the Invariant Sections being LIST THEIR TITLES, with the
+ Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
+
+If you have Invariant Sections without Cover Texts, or some other
+combination of the three, merge those two alternatives to suit the
+situation.
+
+If your document contains nontrivial examples of program code, we
+recommend releasing these examples in parallel under your choice of
+free software license, such as the GNU General Public License,
+to permit their use in free software.
diff --git a/sources/pyside2/LICENSE.GPL2 b/sources/pyside2/LICENSE.GPL2
new file mode 100644
index 000000000..d159169d1
--- /dev/null
+++ b/sources/pyside2/LICENSE.GPL2
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/sources/pyside2/LICENSE.GPL3 b/sources/pyside2/LICENSE.GPL3
new file mode 100644
index 000000000..94a9ed024
--- /dev/null
+++ b/sources/pyside2/LICENSE.GPL3
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/sources/pyside2/LICENSE.GPL3-EXCEPT b/sources/pyside2/LICENSE.GPL3-EXCEPT
new file mode 100644
index 000000000..b1cb1bec7
--- /dev/null
+++ b/sources/pyside2/LICENSE.GPL3-EXCEPT
@@ -0,0 +1,704 @@
+This is the GNU General Public License version 3, annotated with The
+Qt Company GPL Exception 1.0:
+
+-------------------------------------------------------------------------
+
+The Qt Company GPL Exception 1.0
+
+Exception 1:
+
+As a special exception you may create a larger work which contains the
+output of this application and distribute that work under terms of your
+choice, so long as the work is not otherwise derived from or based on
+this application and so long as the work does not in itself generate
+output that contains the output from this application in its original
+or modified form.
+
+Exception 2:
+
+As a special exception, you have permission to combine this application
+with Plugins licensed under the terms of your choice, to produce an
+executable, and to copy and distribute the resulting executable under
+the terms of your choice. However, the executable must be accompanied
+by a prominent notice offering all users of the executable the entire
+source code to this application, excluding the source code of the
+independent modules, but including any changes you have made to this
+application, under the terms of this license.
+
+
+-------------------------------------------------------------------------
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/sources/pyside2/LICENSE.GPLv3 b/sources/pyside2/LICENSE.GPLv3
new file mode 100644
index 000000000..71c4ad49c
--- /dev/null
+++ b/sources/pyside2/LICENSE.GPLv3
@@ -0,0 +1,686 @@
+ GNU GENERAL PUBLIC LICENSE
+
+ The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
+ Contact: http://www.qt.io/licensing/
+
+ You may use, distribute and copy the Qt Toolkit under the terms of
+ GNU Lesser General Public License version 3. That license references
+ the General Public License version 3, that is displayed below. Other
+ portions of the Qt Toolkit may be licensed directly under this license.
+
+-------------------------------------------------------------------------
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/sources/pyside2/LICENSE.LGPL3 b/sources/pyside2/LICENSE.LGPL3
new file mode 100644
index 000000000..65c5ca88a
--- /dev/null
+++ b/sources/pyside2/LICENSE.LGPL3
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/sources/pyside2/LICENSE.LGPLv21 b/sources/pyside2/LICENSE.LGPLv21
new file mode 100644
index 000000000..15a208b48
--- /dev/null
+++ b/sources/pyside2/LICENSE.LGPLv21
@@ -0,0 +1,514 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+
+ The Qt Toolkit is Copyright (C) 2016 The Qt Company Ltd.
+ Contact: http://www.qt.io/licensing/
+
+ You may use, distribute and copy the Qt Toolkit under the terms of
+ GNU Lesser General Public License version 2.1, which is displayed below.
+
+-------------------------------------------------------------------------
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/sources/pyside2/LICENSE.LGPLv3 b/sources/pyside2/LICENSE.LGPLv3
new file mode 100644
index 000000000..849103ad9
--- /dev/null
+++ b/sources/pyside2/LICENSE.LGPLv3
@@ -0,0 +1,175 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+
+ The Qt Toolkit is Copyright (C) 2016 The Qt Company Ltd.
+ Contact: http://www.qt.io/licensing/
+
+ You may use, distribute and copy the Qt Toolkit under the terms of
+ GNU Lesser General Public License version 3, which is displayed below.
+ This license makes reference to the version 3 of the GNU General
+ Public License, which you can find in the LICENSE.GPLv3 file.
+
+-------------------------------------------------------------------------
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
+Everyone is permitted to copy and distribute verbatim copies of this
+licensedocument, but changing it is not allowed.
+
+This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+0. Additional Definitions.
+
+ As used herein, “this License” refers to version 3 of the GNU Lesser
+General Public License, and the “GNU GPL” refers to version 3 of the
+GNU General Public License.
+
+ “The Library” refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An “Application” is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A “Combined Work” is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the “Linked
+Version”.
+
+ The “Minimal Corresponding Source” for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The “Corresponding Application Code” for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort
+ to ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this
+ license document.
+
+4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that, taken
+together, effectively do not restrict modification of the portions of
+the Library contained in the Combined Work and reverse engineering for
+debugging such modifications, if you also do each of the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this
+ license document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of
+ this License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with
+ the Library. A suitable mechanism is one that (a) uses at run
+ time a copy of the Library already present on the user's
+ computer system, and (b) will operate properly with a modified
+ version of the Library that is interface-compatible with the
+ Linked Version.
+
+ e) Provide Installation Information, but only if you would
+ otherwise be required to provide such information under section 6
+ of the GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the Application
+ with a modified version of the Linked Version. (If you use option
+ 4d0, the Installation Information must accompany the Minimal
+ Corresponding Source and Corresponding Application Code. If you
+ use option 4d1, you must provide the Installation Information in
+ the manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.)
+
+5. Combined Libraries.
+
+ You may place library facilities that are a work based on the Library
+side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities, conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of
+ it is a work based on the Library, and explaining where to find
+ the accompanying uncombined form of the same work.
+
+6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+as you received it specifies that a certain numbered version of the
+GNU Lesser General Public License “or any later version” applies to
+it, you have the option of following the terms and conditions either
+of that published version or of any later version published by the
+Free Software Foundation. If the Library as you received it does not
+specify a version number of the GNU Lesser General Public License,
+you may choose any version of the GNU Lesser General Public License
+ever published by the Free Software Foundation.
+
+If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the Library.
+
diff --git a/sources/pyside2/LICENSE.PREVIEW.COMMERCIAL b/sources/pyside2/LICENSE.PREVIEW.COMMERCIAL
new file mode 100644
index 000000000..5e5aeb691
--- /dev/null
+++ b/sources/pyside2/LICENSE.PREVIEW.COMMERCIAL
@@ -0,0 +1,626 @@
+TECHNOLOGY PREVIEW LICENSE AGREEMENT
+
+For individuals and/or legal entities resident in the Americas (North
+America, Central America and South America), the applicable licensing
+terms are specified under the heading "Technology Preview License
+Agreement: The Americas".
+
+For individuals and/or legal entities not resident in The Americas, the
+applicable licensing terms are specified under the heading "Technology
+Preview License Agreement: Rest of the World".
+
+
+TECHNOLOGY PREVIEW LICENSE AGREEMENT: The Americas
+Agreement version 2.4
+
+This Technology Preview License Agreement ("Agreement")is a legal agreement
+between The Qt Company USA, Inc. ("The Qt Company"), with its registered
+office at 2350 Mission College Blvd., Suite 1020, Santa Clara, California
+95054, U.S.A. and you (either an individual or a legal entity) ("Licensee")
+for the Licensed Software (as defined below).
+
+1. DEFINITIONS
+
+"Affiliate" of a Party shall mean an entity (i) which is directly or
+indirectly controlling such Party; (ii) which is under the same direct
+or indirect ownership or control as such Party; or (iii) which is
+directly or indirectly owned or controlled by such Party. For these
+purposes, an entity shall be treated as being controlled by another if
+that other entity has fifty percent (50 %) or more of the votes in such
+entity, is able to direct its affairs and/or to control the composition
+of its board of directors or equivalent body.
+
+"Applications" shall mean Licensee's software products created using the
+Licensed Software which may include portions of the Licensed Software.
+
+"Term" shall mean the period of time six (6) months from the later of
+(a) the Effective Date; or (b) the date the Licensed Software was
+initially delivered to Licensee by The Qt Company. If no specific Effective
+Date is set forth in the Agreement, the Effective Date shall be deemed to be
+the date the Licensed Software was initially delivered to Licensee.
+
+"Licensed Software" shall mean the computer software, "online" or
+electronic documentation, associated media and printed materials,
+including the source code, example programs and the documentation
+delivered by The Qt Company to Licensee in conjunction with this Agreement.
+
+"Party" or "Parties" shall mean Licensee and/or The Qt Company.
+
+
+2. OWNERSHIP
+
+The Licensed Software is protected by copyright laws and international
+copyright treaties, as well as other intellectual property laws and
+treaties. The Licensed Software is licensed, not sold.
+
+If Licensee provides any findings, proposals, suggestions or other
+feedback ("Feedback") to The Qt Company regarding the Licensed Software,
+The Qt Company shall own all right, title and interest including the
+intellectual property rights in and to such Feedback, excluding however any
+existing patent rights of Licensee. To the extent Licensee owns or controls
+any patents for such Feedback Licensee hereby grants to The Qt Company and its
+Affiliates, a worldwide, perpetual, non-transferable, sublicensable,
+royalty-free license to (i) use, copy and modify Feedback and to create
+derivative works thereof, (ii) to make (and have made), use, import,
+sell, offer for sale, lease, dispose, offer for disposal or otherwise
+exploit any products or services of The Qt Company containing Feedback, and
+(iii) sublicense all the foregoing rights to third party licensees and
+customers of The Qt Company and/or its Affiliates.
+
+
+3. VALIDITY OF THE AGREEMENT
+
+By installing, copying, or otherwise using the Licensed Software,
+Licensee agrees to be bound by the terms of this Agreement. If Licensee
+does not agree to the terms of this Agreement, Licensee may not install,
+copy, or otherwise use the Licensed Software. Upon Licensee's acceptance
+of the terms and conditions of this Agreement, The Qt Company grants Licensee
+the right to use the Licensed Software in the manner provided below.
+
+
+4. LICENSES
+
+4.1. Using and Copying
+
+The Qt Company grants to Licensee a non-exclusive, non-transferable,
+time-limited license to use and copy the Licensed Software for sole purpose
+of designing, developing and testing Applications, and evaluating and the
+Licensed Software during the Term.
+
+Licensee may install copies of the Licensed Software on an unlimited
+number of computers provided that (a) if an individual, only such
+individual; or (b) if a legal entity only its employees; use the
+Licensed Software for the authorized purposes.
+
+4.2 No Distribution or Modifications
+
+Licensee may not disclose, modify, sell, market, commercialise,
+distribute, loan, rent, lease, or license the Licensed Software or any
+copy of it or use the Licensed Software for any purpose that is not
+expressly granted in this Section 4. Licensee may not alter or remove
+any details of ownership, copyright, trademark or other property right
+connected with the Licensed Software. Licensee may not distribute any
+software statically or dynamically linked with the Licensed Software.
+
+4.3 No Technical Support
+
+The Qt Company has no obligation to furnish Licensee with any technical
+support whatsoever. Any such support is subject to separate agreement between
+the Parties.
+
+
+5. PRE-RELEASE CODE
+The Licensed Software contains pre-release code that is not at the level
+of performance and compatibility of a final, generally available,
+product offering. The Licensed Software may not operate correctly and
+may be substantially modified prior to the first commercial product
+release, if any. The Qt Company is not obligated to make this or any later
+version of the Licensed Software commercially available. The License
+Software is "Not for Commercial Use" and may only be used for the
+purposes described in Section 4. The Licensed Software may not be used
+in a live operating environment where it may be relied upon to perform
+in the same manner as a commercially released product or with data that
+has not been sufficiently backed up.
+
+6. THIRD PARTY SOFTWARE
+
+The Licensed Software may provide links to third party libraries or code
+(collectively "Third Party Software") to implement various functions.
+Third Party Software does not comprise part of the Licensed Software. In
+some cases, access to Third Party Software may be included along with
+the Licensed Software delivery as a convenience for development and
+testing only. Such source code and libraries may be listed in the
+".../src/3rdparty" source tree delivered with the Licensed Software or
+documented in the Licensed Software where the Third Party Software is
+used, as may be amended from time to time, do not comprise the Licensed
+Software. Licensee acknowledges (1) that some part of Third Party
+Software may require additional licensing of copyright and patents from
+the owners of such, and (2) that distribution of any of the Licensed
+Software referencing any portion of a Third Party Software may require
+appropriate licensing from such third parties.
+
+
+7. LIMITED WARRANTY AND WARRANTY DISCLAIMER
+
+The Licensed Software is licensed to Licensee "as is". To the maximum
+extent permitted by applicable law, The Qt Company on behalf of itself and
+its suppliers, disclaims all warranties and conditions, either express or
+implied, including, but not limited to, implied warranties of
+merchantability, fitness for a particular purpose, title and
+non-infringement with regard to the Licensed Software.
+
+
+8. LIMITATION OF LIABILITY
+
+If, The Qt Company's warranty disclaimer notwithstanding, The Qt Company is
+held liable to Licensee, whether in contract, tort or any other legal theory,
+based on the Licensed Software, The Qt Company's entire liability to Licensee
+and Licensee's exclusive remedy shall be, at The Qt Company's option, either
+(A) return of the price Licensee paid for the Licensed Software, or (B)
+repair or replacement of the Licensed Software, provided Licensee
+returns to The Qt Company all copies of the Licensed Software as originally
+delivered to Licensee. The Qt Company shall not under any circumstances be
+liable to Licensee based on failure of the Licensed Software if the failure
+resulted from accident, abuse or misapplication, nor shall The Qt Company
+under any circumstances be liable for special damages, punitive or exemplary
+damages, damages for loss of profits or interruption of business or for
+loss or corruption of data. Any award of damages from The Qt Company to
+Licensee shall not exceed the total amount Licensee has paid to The Qt
+Company in connection with this Agreement.
+
+
+9. CONFIDENTIALITY
+
+Each party acknowledges that during the Term of this Agreement it shall
+have access to information about the other party's business, business
+methods, business plans, customers, business relations, technology, and
+other information, including the terms of this Agreement, that is
+confidential and of great value to the other party, and the value of
+which would be significantly reduced if disclosed to third parties (the
+"Confidential Information"). Accordingly, when a party (the "Receiving
+Party") receives Confidential Information from another party (the
+"Disclosing Party"), the Receiving Party shall, and shall obligate its
+employees and agents and employees and agents of its Affiliates to: (i)
+maintain the Confidential Information in strict confidence; (ii) not
+disclose the Confidential Information to a third party without the
+Disclosing Party's prior written approval; and (iii) not, directly or
+indirectly, use the Confidential Information for any purpose other than
+for exercising its rights and fulfilling its responsibilities pursuant
+to this Agreement. Each party shall take reasonable measures to protect
+the Confidential Information of the other party, which measures shall
+not be less than the measures taken by such party to protect its own
+confidential and proprietary information.
+
+"Confidential Information" shall not include information that (a) is or
+becomes generally known to the public through no act or omission of the
+Receiving Party; (b) was in the Receiving Party's lawful possession
+prior to the disclosure hereunder and was not subject to limitations on
+disclosure or use; (c) is developed by the Receiving Party without
+access to the Confidential Information of the Disclosing Party or by
+persons who have not had access to the Confidential Information of the
+Disclosing Party as proven by the written records of the Receiving
+Party; (d) is lawfully disclosed to the Receiving Party without
+restrictions, by a third party not under an obligation of
+confidentiality; or (e) the Receiving Party is legally compelled to
+disclose the information, in which case the Receiving Party shall assert
+the privileged and confidential nature of the information and cooperate
+fully with the Disclosing Party to protect against and prevent
+disclosure of any Confidential Information and to limit the scope of
+disclosure and the dissemination of disclosed Confidential Information
+by all legally available means.
+
+The obligations of the Receiving Party under this Section shall continue
+during the Initial Term and for a period of five (5) years after
+expiration or termination of this Agreement. To the extent that the
+terms of the Non-Disclosure Agreement between The Qt Company and Licensee
+conflict with the terms of this Section 9, this Section 9 shall be
+controlling over the terms of the Non-Disclosure Agreement.
+
+
+10. GENERAL PROVISIONS
+
+10.1 No Assignment
+
+Licensee shall not be entitled to assign or transfer all or any of its
+rights, benefits and obligations under this Agreement without the prior
+written consent of The Qt Company, which shall not be unreasonably withheld.
+
+10.2 Termination
+
+The Qt Company may terminate the Agreement at any time immediately upon
+written notice by The Qt Company to Licensee if Licensee breaches this
+Agreement.
+
+Upon termination of this Agreement, Licensee shall return to The Qt Company
+all copies of Licensed Software that were supplied by The Qt Company. All
+other copies of Licensed Software in the possession or control of Licensee
+must be erased or destroyed. An officer of Licensee must promptly
+deliver to The Qt Company a written confirmation that this has occurred.
+
+10.3 Surviving Sections
+
+Any terms and conditions that by their nature or otherwise reasonably
+should survive a cancellation or termination of this Agreement shall
+also be deemed to survive. Such terms and conditions include, but are
+not limited to the following Sections: 2, 5, 6, 7, 8, 9, 10.2, 10.3, 10.4,
+10.5, 10.6, 10.7, and 10.8 of this Agreement.
+
+10.4 Entire Agreement
+
+This Agreement constitutes the complete agreement between the parties
+and supersedes all prior or contemporaneous discussions,
+representations, and proposals, written or oral, with respect to the
+subject matters discussed herein, with the exception of the
+non-disclosure agreement executed by the parties in connection with this
+Agreement ("Non-Disclosure Agreement"), if any, shall be subject to
+Section 9. No modification of this Agreement shall be effective unless
+contained in a writing executed by an authorized representative of each
+party. No term or condition contained in Licensee's purchase order shall
+apply unless expressly accepted by The Qt Company in writing. If any
+provision of the Agreement is found void or unenforceable, the remainder
+shall remain valid and enforceable according to its terms. If any remedy
+provided is determined to have failed for its essential purpose, all
+limitations of liability and exclusions of damages set forth in this
+Agreement shall remain in effect.
+
+10.5 Export Control
+
+Licensee acknowledges that the Licensed Software may be subject to
+export control restrictions of various countries. Licensee shall fully
+comply with all applicable export license restrictions and requirements
+as well as with all laws and regulations relating to the importation of
+the Licensed Software and shall procure all necessary governmental
+authorizations, including without limitation, all necessary licenses,
+approvals, permissions or consents, where necessary for the
+re-exportation of the Licensed Software.,
+
+10.6 Governing Law and Legal Venue
+
+This Agreement shall be governed by and construed in accordance with the
+federal laws of the United States of America and the internal laws of
+the State of New York without given effect to any choice of law rule
+that would result in the application of the laws of any other
+jurisdiction. The United Nations Convention on Contracts for the
+International Sale of Goods (CISG) shall not apply. Each Party (a)
+hereby irrevocably submits itself to and consents to the jurisdiction of
+the United States District Court for the Southern District of New York
+(or if such court lacks jurisdiction, the state courts of the State of
+New York) for the purposes of any action, claim, suit or proceeding
+between the Parties in connection with any controversy, claim, or
+dispute arising out of or relating to this Agreement; and (b) hereby
+waives, and agrees not to assert by way of motion, as a defense or
+otherwise, in any such action, claim, suit or proceeding, any claim that
+is not personally subject to the jurisdiction of such court(s), that the
+action, claim, suit or proceeding is brought in an inconvenient forum or
+that the venue of the action, claim, suit or proceeding is improper.
+Notwithstanding the foregoing, nothing in this Section 9.6 is intended
+to, or shall be deemed to, constitute a submission or consent to, or
+selection of, jurisdiction, forum or venue for any action for patent
+infringement, whether or not such action relates to this Agreement.
+
+10.7 No Implied License
+
+There are no implied licenses or other implied rights granted under this
+Agreement, and all rights, save for those expressly granted hereunder,
+shall remain with The Qt Company and its licensors. In addition, no licenses
+or immunities are granted to the combination of the Licensed Software with
+any other software or hardware not delivered by The Qt Company under this
+Agreement.
+
+10.8 Government End Users
+
+A "U.S. Government End User" shall mean any agency or entity of the
+government of the United States. The following shall apply if Licensee
+is a U.S. Government End User. The Licensed Software is a "commercial
+item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995),
+consisting of "commercial computer software" and "commercial computer
+software documentation," as such terms are used in 48 C.F.R. 12.212
+(Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+through 227.7202-4 (June 1995), all U.S. Government End Users acquire
+the Licensed Software with only those rights set forth herein. The
+Licensed Software (including related documentation) is provided to U.S.
+Government End Users: (a) only as a commercial end item; and (b) only
+pursuant to this Agreement.
+
+
+
+
+
+TECHNOLOGY PREVIEW LICENSE AGREEMENT: Rest of the World
+Agreement version 2.4
+
+This Technology Preview License Agreement ("Agreement") is a legal
+agreement between The Qt Company Ltd ("The Qt Company"), with its registered
+office at Valimotie 21,FI-00380 Helsinki, Finland and you (either an
+individual or a legal entity) ("Licensee") for the Licensed Software.
+
+1. DEFINITIONS
+
+"Affiliate" of a Party shall mean an entity (i) which is directly or
+indirectly controlling such Party; (ii) which is under the same direct
+or indirect ownership or control as such Party; or (iii) which is
+directly or indirectly owned or controlled by such Party. For these
+purposes, an entity shall be treated as being controlled by another if
+that other entity has fifty percent (50 %) or more of the votes in such
+entity, is able to direct its affairs and/or to control the composition
+of its board of directors or equivalent body.
+
+"Applications" shall mean Licensee's software products created using the
+Licensed Software which may include portions of the Licensed Software.
+
+"Term" shall mean the period of time six (6) months from the later of
+(a) the Effective Date; or (b) the date the Licensed Software was
+initially delivered to Licensee by The Qt Company. If no specific Effective
+Date is set forth in the Agreement, the Effective Date shall be deemed to be
+the date the Licensed Software was initially delivered to Licensee.
+
+"Licensed Software" shall mean the computer software, "online" or
+electronic documentation, associated media and printed materials,
+including the source code, example programs and the documentation
+delivered by The Qt Company to Licensee in conjunction with this Agreement.
+
+"Party" or "Parties" shall mean Licensee and/or The Qt Company.
+
+
+2. OWNERSHIP
+
+The Licensed Software is protected by copyright laws and international
+copyright treaties, as well as other intellectual property laws and
+treaties. The Licensed Software is licensed, not sold.
+
+If Licensee provides any findings, proposals, suggestions or other
+feedback ("Feedback") to The Qt Company regarding the Licensed Software,
+The Qt Companyshall own all right, title and interest including the
+intellectual property rights in and to such Feedback, excluding however any
+existing patent rights of Licensee. To the extent Licensee owns or controls
+any patents for such Feedback Licensee hereby grants to The Qt Company and
+its Affiliates, a worldwide, perpetual, non-transferable, sublicensable,
+royalty-free license to (i) use, copy and modify Feedback and to create
+derivative works thereof, (ii) to make (and have made), use, import,
+sell, offer for sale, lease, dispose, offer for disposal or otherwise
+exploit any products or services of The Qt Company containing Feedback, and
+(iii) sublicense all the foregoing rights to third party licensees and
+customers of The Qt Company and/or its Affiliates.
+
+3. VALIDITY OF THE AGREEMENT
+
+By installing, copying, or otherwise using the Licensed Software,
+Licensee agrees to be bound by the terms of this Agreement. If Licensee
+does not agree to the terms of this Agreement, Licensee may not install,
+copy, or otherwise use the Licensed Software. Upon Licensee's acceptance
+of the terms and conditions of this Agreement, The Qt Company grants Licensee
+the right to use the Licensed Software in the manner provided below.
+
+
+4. LICENSES
+
+4.1. Using and Copying
+
+The Qt Company grants to Licensee a non-exclusive, non-transferable,
+time-limited license to use and copy the Licensed Software for sole purpose
+of designing, developing and testing Applications, and evaluating and the
+Licensed Software during the Term.
+
+Licensee may install copies of the Licensed Software on an unlimited
+number of computers provided that (a) if an individual, only such
+individual; or (b) if a legal entity only its employees; use the
+Licensed Software for the authorized purposes.
+
+4.2 No Distribution or Modifications
+
+Licensee may not disclose, modify, sell, market, commercialise,
+distribute, loan, rent, lease, or license the Licensed Software or any
+copy of it or use the Licensed Software for any purpose that is not
+expressly granted in this Section 4. Licensee may not alter or remove
+any details of ownership, copyright, trademark or other property right
+connected with the Licensed Software. Licensee may not distribute any
+software statically or dynamically linked with the Licensed Software.
+
+4.3 No Technical Support
+
+The Qt Company has no obligation to furnish Licensee with any technical
+support whatsoever. Any such support is subject to separate agreement
+between the Parties.
+
+
+5. PRE-RELEASE CODE
+
+The Licensed Software contains pre-release code that is not at the level
+of performance and compatibility of a final, generally available,
+product offering. The Licensed Software may not operate correctly and
+may be substantially modified prior to the first commercial product
+release, if any. The Qt Company is not obligated to make this or any later
+version of the Licensed Software commercially available. The License
+Software is "Not for Commercial Use" and may only be used for the
+purposes described in Section 4. The Licensed Software may not be used
+in a live operating environment where it may be relied upon to perform
+in the same manner as a commercially released product or with data that
+has not been sufficiently backed up.
+
+6. THIRD PARTY SOFTWARE
+
+The Licensed Software may provide links to third party libraries or code
+(collectively "Third Party Software") to implement various functions.
+Third Party Software does not comprise part of the Licensed Software. In
+some cases, access to Third Party Software may be included along with
+the Licensed Software delivery as a convenience for development and
+testing only. Such source code and libraries may be listed in the
+".../src/3rdparty" source tree delivered with the Licensed Software or
+documented in the Licensed Software where the Third Party Software is
+used, as may be amended from time to time, do not comprise the Licensed
+Software. Licensee acknowledges (1) that some part of Third Party
+Software may require additional licensing of copyright and patents from
+the owners of such, and (2) that distribution of any of the Licensed
+Software referencing any portion of a Third Party Software may require
+appropriate licensing from such third parties.
+
+
+7. LIMITED WARRANTY AND WARRANTY DISCLAIMER
+
+The Licensed Software is licensed to Licensee "as is". To the maximum
+extent permitted by applicable law, The Qt Company on behalf of itself and
+its suppliers, disclaims all warranties and conditions, either express or
+implied, including, but not limited to, implied warranties of
+merchantability, fitness for a particular purpose, title and
+non-infringement with regard to the Licensed Software.
+
+
+8. LIMITATION OF LIABILITY
+
+If, The Qt Company's warranty disclaimer notwithstanding, The Qt Company is
+held liable to Licensee, whether in contract, tort or any other legal theory,
+based on the Licensed Software, The Qt Company's entire liability to Licensee
+and Licensee's exclusive remedy shall be, at The Qt Company's option, either
+(A) return of the price Licensee paid for the Licensed Software, or (B)
+repair or replacement of the Licensed Software, provided Licensee
+returns to The Qt Company all copies of the Licensed Software as originally
+delivered to Licensee. The Qt Company shall not under any circumstances be
+liable to Licensee based on failure of the Licensed Software if the failure
+resulted from accident, abuse or misapplication, nor shall The Qt Company
+under any circumstances be liable for special damages, punitive or exemplary
+damages, damages for loss of profits or interruption of business or for
+loss or corruption of data. Any award of damages from The Qt Company to
+Licensee shall not exceed the total amount Licensee has paid to
+The Qt Company in connection with this Agreement.
+
+
+9. CONFIDENTIALITY
+
+Each party acknowledges that during the Term of this Agreement it shall
+have access to information about the other party's business, business
+methods, business plans, customers, business relations, technology, and
+other information, including the terms of this Agreement, that is
+confidential and of great value to the other party, and the value of
+which would be significantly reduced if disclosed to third parties (the
+"Confidential Information"). Accordingly, when a party (the "Receiving
+Party") receives Confidential Information from another party (the
+"Disclosing Party"), the Receiving Party shall, and shall obligate its
+employees and agents and employees and agents of its Affiliates to: (i)
+maintain the Confidential Information in strict confidence; (ii) not
+disclose the Confidential Information to a third party without the
+Disclosing Party's prior written approval; and (iii) not, directly or
+indirectly, use the Confidential Information for any purpose other than
+for exercising its rights and fulfilling its responsibilities pursuant
+to this Agreement. Each party shall take reasonable measures to protect
+the Confidential Information of the other party, which measures shall
+not be less than the measures taken by such party to protect its own
+confidential and proprietary information.
+
+"Confidential Information" shall not include information that (a) is or
+becomes generally known to the public through no act or omission of the
+Receiving Party; (b) was in the Receiving Party's lawful possession
+prior to the disclosure hereunder and was not subject to limitations on
+disclosure or use; (c) is developed by the Receiving Party without
+access to the Confidential Information of the Disclosing Party or by
+persons who have not had access to the Confidential Information of the
+Disclosing Party as proven by the written records of the Receiving
+Party; (d) is lawfully disclosed to the Receiving Party without
+restrictions, by a third party not under an obligation of
+confidentiality; or (e) the Receiving Party is legally compelled to
+disclose the information, in which case the Receiving Party shall assert
+the privileged and confidential nature of the information and cooperate
+fully with the Disclosing Party to protect against and prevent
+disclosure of any Confidential Information and to limit the scope of
+disclosure and the dissemination of disclosed Confidential Information
+by all legally available means.
+
+The obligations of the Receiving Party under this Section shall continue
+during the Initial Term and for a period of five (5) years after
+expiration or termination of this Agreement. To the extent that the
+terms of the Non-Disclosure Agreement between The Qt Company and Licensee
+conflict with the terms of this Section 9, this Section 9 shall be
+controlling over the terms of the Non-Disclosure Agreement.
+
+
+10. GENERAL PROVISIONS
+
+10.1 No Assignment
+
+Licensee shall not be entitled to assign or transfer all or any of its
+rights, benefits and obligations under this Agreement without the prior
+written consent of The Qt Company, which shall not be unreasonably withheld.
+
+10.2 Termination
+
+The Qt Company may terminate the Agreement at any time immediately upon
+written notice by The Qt Company to Licensee if Licensee breaches this
+Agreement.
+
+Upon termination of this Agreement, Licensee shall return to The Qt Company
+all copies of Licensed Software that were supplied by The Qt Company. All
+other copies of Licensed Software in the possession or control of Licensee
+must be erased or destroyed. An officer of Licensee must promptly
+deliver to The Qt Company a written confirmation that this has occurred.
+
+10.3 Surviving Sections
+
+Any terms and conditions that by their nature or otherwise reasonably
+should survive a cancellation or termination of this Agreement shall
+also be deemed to survive. Such terms and conditions include, but are
+not limited to the following Sections: 2, 5, 6, 7, 8, 9, 10.2, 10.3, 10.4,
+10.5, 10.6, 10.7, and 10.8 of this Agreement.
+
+10.4 Entire Agreement
+
+This Agreement constitutes the complete agreement between the parties
+and supersedes all prior or contemporaneous discussions,
+representations, and proposals, written or oral, with respect to the
+subject matters discussed herein, with the exception of the
+non-disclosure agreement executed by the parties in connection with this
+Agreement ("Non-Disclosure Agreement"), if any, shall be subject to
+Section 9. No modification of this Agreement shall be effective unless
+contained in a writing executed by an authorized representative of each
+party. No term or condition contained in Licensee's purchase order shall
+apply unless expressly accepted by The Qt Company in writing. If any provision
+of the Agreement is found void or unenforceable, the remainder shall remain
+valid and enforceable according to its terms. If any remedy provided is
+determined to have failed for its essential purpose, all limitations of
+liability and exclusions of damages set forth in this Agreement shall
+remain in effect.
+
+10.5 Export Control
+
+Licensee acknowledges that the Licensed Software may be subject to
+export control restrictions of various countries. Licensee shall fully
+comply with all applicable export license restrictions and requirements
+as well as with all laws and regulations relating to the importation of
+the Licensed Software and shall procure all necessary governmental
+authorizations, including without limitation, all necessary licenses,
+approvals, permissions or consents, where necessary for the
+re-exportation of the Licensed Software.,
+
+10.6 Governing Law and Legal Venue
+
+This Agreement shall be construed and interpreted in accordance with the laws
+of Finland, excluding its choice of law provisions. Any disputes arising out
+of or relating to this Agreement shall be resolved in arbitration in accordance
+with the Arbitration Rules of the Finland Chamber of Commerce. The arbitration
+tribunal shall consist of one (1), or if either Party so requires, of three
+(3), arbitrators. The award shall be final and binding and enforceable in any
+court of competent jurisdiction. The arbitration shall be held in Helsinki,
+Finland and the process shall be conducted in the English language.
+
+10.7 No Implied License
+
+There are no implied licenses or other implied rights granted under this
+Agreement, and all rights, save for those expressly granted hereunder,
+shall remain with The Qt Company and its licensors. In addition, no licenses
+or immunities are granted to the combination of the Licensed Software with
+any other software or hardware not delivered by The Qt Company under this
+Agreement.
+
+10.8 Government End Users
+
+A "U.S. Government End User" shall mean any agency or entity of the
+government of the United States. The following shall apply if Licensee
+is a U.S. Government End User. The Licensed Software is a "commercial
+item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995),
+consisting of "commercial computer software" and "commercial computer
+software documentation," as such terms are used in 48 C.F.R. 12.212
+(Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+through 227.7202-4 (June 1995), all U.S. Government End Users acquire
+the Licensed Software with only those rights set forth herein. The
+Licensed Software (including related documentation) is provided to U.S.
+Government End Users: (a) only as a commercial end item; and (b) only
+pursuant to this Agreement.
+
diff --git a/sources/pyside2/PySide2/CMakeLists.txt b/sources/pyside2/PySide2/CMakeLists.txt
new file mode 100644
index 000000000..01d9f64c2
--- /dev/null
+++ b/sources/pyside2/PySide2/CMakeLists.txt
@@ -0,0 +1,33 @@
+project(pyside2)
+
+# Configure include based on platform
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/global.h.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/pyside2_global.h" @ONLY)
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" @ONLY)
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/_utils.py.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/_utils.py" @ONLY)
+
+# Add the collected includes to the global include
+file(READ "${CMAKE_CURRENT_BINARY_DIR}/pyside2_global.h.add" GLOBAL_APPEND)
+file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/pyside2_global.h" "${GLOBAL_APPEND}")
+file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/pyside2_global.h.add")
+
+# now compile all modules.
+foreach(shortname IN LISTS all_module_shortnames)
+ set(name "Qt5${shortname}")
+ HAS_QT_MODULE(${name}_FOUND Qt${shortname})
+endforeach()
+
+# install
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/__init__.py"
+ DESTINATION "${SITE_PACKAGE}/${BINDING_NAME}${pyside2_SUFFIX}")
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/_utils.py
+ DESTINATION "${SITE_PACKAGE}/${BINDING_NAME}${pyside2_SUFFIX}")
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_templates.xml
+ DESTINATION share/PySide2${pyside_SUFFIX}/typesystems)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pyside2_global.h
+ DESTINATION include/${BINDING_NAME}${pyside2_SUFFIX})
+
diff --git a/sources/pyside2/PySide2/QtConcurrent/CMakeLists.txt b/sources/pyside2/PySide2/QtConcurrent/CMakeLists.txt
new file mode 100644
index 000000000..4a7fd53ff
--- /dev/null
+++ b/sources/pyside2/PySide2/QtConcurrent/CMakeLists.txt
@@ -0,0 +1,35 @@
+project(QtConcurrent)
+
+set(QtConcurrent_SRC
+${QtConcurrent_GEN_DIR}/qtconcurrent_wrapper.cpp
+# module is always needed
+${QtConcurrent_GEN_DIR}/qtconcurrent_module_wrapper.cpp
+)
+
+make_path(QtConcurrent_typesystem_path ${QtCore_SOURCE_DIR}
+ ${QtCore_BINARY_DIR}
+ ${QtConcurrent_SOURCE_DIR})
+
+set(QtConcurrent_include_dirs ${QtConcurrent_SOURCE_DIR}
+ ${QtConcurrent_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Concurrent_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ )
+set(QtConcurrent_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${QtConcurrent_LIBRARIES}
+ )
+set(QtConcurrent_deps QtCore)
+
+create_pyside_module(QtConcurrent
+ QtConcurrent_include_dirs
+ QtConcurrent_libraries
+ QtConcurrent_deps
+ QtConcurrent_typesystem_path
+ QtConcurrent_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtConcurrent/curr_errors.txt b/sources/pyside2/PySide2/QtConcurrent/curr_errors.txt
new file mode 100644
index 000000000..827ebea5c
--- /dev/null
+++ b/sources/pyside2/PySide2/QtConcurrent/curr_errors.txt
@@ -0,0 +1,21 @@
+Generating class model... [OK]
+Generating enum model... [OK]
+Generating namespace model... [WARNING]
+ enum 'QtConcurrent::ThreadFunctionResult' does not have a type entry or is not an enum
+ enum 'QtConcurrent::ReduceQueueThrottleLimit' does not have a type entry or is not an enum
+
+
+Resolving typedefs... [OK]
+Fixing class inheritance... [OK]
+Detecting inconsistencies in class model... [OK]
+[OK]
+
+Done, 2 warnings (506 known issues)
+Scanning dependencies of target QtConcurrent
+[ 21%] Building CXX object PySide/QtConcurrent/CMakeFiles/QtConcurrent.dir/PySide/QtConcurrent/qtconcurrent_module_wrapper.cpp.o
+In file included from /Users/tismer/src/pyside-setup2/pyside_build/py3.4-qt5.4.2-64bit-debug/pyside/PySide/QtConcurrent/PySide/QtConcurrent/qtconcurrent_module_wrapper.cpp:30:
+/Users/tismer/src/pyside-setup2/pyside_build/py3.4-qt5.4.2-64bit-debug/pyside/PySide/QtConcurrent/PySide/QtConcurrent/pyside_qtconcurrent_python.h:44:10: fatal error:
+ 'qtconcurrentexception.h' file not found
+#include <qtconcurrentexception.h>
+ ^
+1 error generated.
diff --git a/sources/pyside2/PySide2/QtConcurrent/typesystem_concurrent.xml b/sources/pyside2/PySide2/QtConcurrent/typesystem_concurrent.xml
new file mode 100644
index 000000000..692e744a1
--- /dev/null
+++ b/sources/pyside2/PySide2/QtConcurrent/typesystem_concurrent.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtConcurrent">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+
+ <!-- Qt5: this is currently the minimum possible QtConcurrent support, by just extracting
+ the name space from QtCore -->
+ <namespace-type name="QtConcurrent" target-type="class">
+ <rejection class="QtConcurrent" enum-name="enum_1"/>
+ <enum-type name="ReduceOption" flags="ReduceOptions"/>
+ <enum-type name="ThreadFunctionResult" />
+ <extra-includes>
+ <include file-name="qtconcurrentreducekernel.h" location="global"/>
+ <include file-name="qtconcurrentthreadengine.h" location="global"/>
+ </extra-includes>
+ </namespace-type>
+
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtCore/CMakeLists.txt b/sources/pyside2/PySide2/QtCore/CMakeLists.txt
new file mode 100644
index 000000000..4e833f584
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/CMakeLists.txt
@@ -0,0 +1,185 @@
+project(QtCore)
+
+set(QtCore_gluecode "${QtCore_SOURCE_DIR}/glue/qeasingcurve_glue.cpp")
+
+if(ENABLE_WIN)
+ set(SPECIFIC_OS_FILES
+ ${QtCore_GEN_DIR}/qwineventnotifier_wrapper.cpp
+ )
+else()
+ set(SPECIFIC_OS_FILES "")
+endif()
+
+# TODO: Fix cycling dependency when generating QDataStream operator<< for QUuid
+set (QtCore_SRC_FIXED_ME ${QtCore_GEN_DIR}/quuid_wrapper.cpp)
+
+set(QtCore_SRC
+${QtCore_GEN_DIR}/qabstractanimation_wrapper.cpp
+${QtCore_GEN_DIR}/qabstracteventdispatcher_timerinfo_wrapper.cpp
+${QtCore_GEN_DIR}/qabstracteventdispatcher_wrapper.cpp
+${QtCore_GEN_DIR}/qabstractitemmodel_wrapper.cpp
+${QtCore_GEN_DIR}/qabstractlistmodel_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_wrapper.cpp
+${QtCore_GEN_DIR}/qbytearraymatcher_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}/qcoreapplication_wrapper.cpp
+${QtCore_GEN_DIR}/qcryptographichash_wrapper.cpp
+${QtCore_GEN_DIR}/qdatastream_wrapper.cpp
+${QtCore_GEN_DIR}/qdate_wrapper.cpp
+${QtCore_GEN_DIR}/qdatetime_wrapper.cpp
+${QtCore_GEN_DIR}/qdir_wrapper.cpp
+${QtCore_GEN_DIR}/qdiriterator_wrapper.cpp
+${QtCore_GEN_DIR}/qdynamicpropertychangeevent_wrapper.cpp
+${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}/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}/qiodevice_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
+${QtCore_GEN_DIR}/qlocale_wrapper.cpp
+${QtCore_GEN_DIR}/qmargins_wrapper.cpp
+${QtCore_GEN_DIR}/qmarginsf_wrapper.cpp
+${QtCore_GEN_DIR}/qmessagelogcontext_wrapper.cpp
+${QtCore_GEN_DIR}/qmetaclassinfo_wrapper.cpp
+${QtCore_GEN_DIR}/qmetaenum_wrapper.cpp
+${QtCore_GEN_DIR}/qmetamethod_wrapper.cpp
+${QtCore_GEN_DIR}/qmetaobject_connection_wrapper.cpp
+${QtCore_GEN_DIR}/qmetaobject_wrapper.cpp
+${QtCore_GEN_DIR}/qmetaproperty_wrapper.cpp
+${QtCore_GEN_DIR}/qmimedata_wrapper.cpp
+${QtCore_GEN_DIR}/qmimedatabase_wrapper.cpp
+${QtCore_GEN_DIR}/qmimetype_wrapper.cpp
+${QtCore_GEN_DIR}/qmodelindex_wrapper.cpp
+${QtCore_GEN_DIR}/qmutex_wrapper.cpp
+${QtCore_GEN_DIR}/qmutexlocker_wrapper.cpp
+${QtCore_GEN_DIR}/qobject_wrapper.cpp
+${QtCore_GEN_DIR}/qparallelanimationgroup_wrapper.cpp
+${QtCore_GEN_DIR}/qpauseanimation_wrapper.cpp
+${QtCore_GEN_DIR}/qpersistentmodelindex_wrapper.cpp
+${QtCore_GEN_DIR}/qpluginloader_wrapper.cpp
+${QtCore_GEN_DIR}/qpoint_wrapper.cpp
+${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}/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}/qresource_wrapper.cpp
+${QtCore_GEN_DIR}/qrunnable_wrapper.cpp
+${QtCore_GEN_DIR}/qsavefile_wrapper.cpp
+${QtCore_GEN_DIR}/qsemaphore_wrapper.cpp
+${QtCore_GEN_DIR}/qsequentialanimationgroup_wrapper.cpp
+${QtCore_GEN_DIR}/qsettings_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}/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}/qsysinfo_wrapper.cpp
+${QtCore_GEN_DIR}/qsystemsemaphore_wrapper.cpp
+${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
+${QtCore_GEN_DIR}/qthreadpool_wrapper.cpp
+${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}/qtranslator_wrapper.cpp
+${QtCore_GEN_DIR}/qurl_wrapper.cpp
+${QtCore_GEN_DIR}/qvariantanimation_wrapper.cpp
+${QtCore_GEN_DIR}/qwaitcondition_wrapper.cpp
+${QtCore_GEN_DIR}/qwritelocker_wrapper.cpp
+${QtCore_GEN_DIR}/qxmlstreamattribute_wrapper.cpp
+${QtCore_GEN_DIR}/qxmlstreamattributes_wrapper.cpp
+${QtCore_GEN_DIR}/qxmlstreamentitydeclaration_wrapper.cpp
+${QtCore_GEN_DIR}/qxmlstreamentityresolver_wrapper.cpp
+${QtCore_GEN_DIR}/qxmlstreamnamespacedeclaration_wrapper.cpp
+${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
+)
+
+configure_file("${QtCore_SOURCE_DIR}/typesystem_core.xml.in"
+ "${QtCore_BINARY_DIR}/typesystem_core.xml" @ONLY)
+
+make_path(QtCore_typesystem_path ${QtCore_SOURCE_DIR})
+
+
+set(QtCore_include_dirs ${QtCore_SOURCE_DIR}
+ ${QtCore_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ )
+set(QtCore_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Core_LIBRARIES}
+ )
+create_pyside_module(QtCore
+ QtCore_include_dirs
+ QtCore_libraries
+ ""
+ QtCore_typesystem_path
+ QtCore_SRC
+ QtCore_gluecode
+ ${QtCore_BINARY_DIR}/typesystem_core.xml)
+
diff --git a/sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp b/sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp
new file mode 100644
index 000000000..593b4bfba
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#if PY_VERSION_HEX < 0x03000000
+
+// QByteArray buffer protocol functions
+// see: http://www.python.org/dev/peps/pep-3118/
+
+extern "C" {
+
+static Py_ssize_t SbkQByteArray_segcountproc(PyObject* self, Py_ssize_t* lenp)
+{
+ if (lenp)
+ *lenp = self->ob_type->tp_as_sequence->sq_length(self);
+ return 1;
+}
+
+static Py_ssize_t SbkQByteArray_readbufferproc(PyObject* self, Py_ssize_t segment, void** ptrptr)
+{
+ if (segment || !Shiboken::Object::isValid(self))
+ return -1;
+
+ QByteArray* cppSelf = %CONVERTTOCPP[QByteArray*](self);
+ *ptrptr = reinterpret_cast<void*>(cppSelf->data());
+ return cppSelf->size();
+}
+
+PyBufferProcs SbkQByteArrayBufferProc = {
+ /*bf_getreadbuffer*/ &SbkQByteArray_readbufferproc,
+ /*bf_getwritebuffer*/ (writebufferproc) &SbkQByteArray_readbufferproc,
+ /*bf_getsegcount*/ &SbkQByteArray_segcountproc,
+ /*bf_getcharbuffer*/ (charbufferproc) &SbkQByteArray_readbufferproc
+};
+
+}
+
+#endif
diff --git a/sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp b/sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp
new file mode 100644
index 000000000..20e9c4464
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+// Global variables used to store argc and argv values
+static int QCoreApplicationArgCount;
+static char** QCoreApplicationArgValues;
+
+void QCoreApplication_constructor(PyObject* self, PyObject* args, QCoreApplicationWrapper** cptr)
+{
+ if (QCoreApplication::instance()) {
+ PyErr_SetString(PyExc_RuntimeError, "A QCoreApplication instance already exists.");
+ return;
+ }
+
+ int numArgs = PyTuple_GET_SIZE(args);
+ if (numArgs != 1
+ || !Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QCoreApplicationArgCount, &QCoreApplicationArgValues, "PySideApp")) {
+ PyErr_BadArgument();
+ return;
+ }
+
+ *cptr = new QCoreApplicationWrapper(QCoreApplicationArgCount, QCoreApplicationArgValues);
+
+ Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self));
+ PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
+ Py_INCREF(self);
+}
diff --git a/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp
new file mode 100644
index 000000000..6955b1149
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 <Python.h>
+#include <shiboken.h>
+#include <pysideweakref.h>
+#include <QEasingCurve>
+
+#include "glue/qeasingcurve_glue.h"
+
+#define __ECF_ATT_NAME__ "__ecf__"
+#define MAX_CUSTOM_FUNCTIONS 10
+
+static void deleteData(void* data);
+
+struct CustomFunctionsData
+{
+ static CustomFunctionsData m_list[MAX_CUSTOM_FUNCTIONS];
+
+ PySideEasingCurveFunctor* m_obj;
+ QEasingCurve::EasingFunction m_func;
+};
+
+CustomFunctionsData CustomFunctionsData::m_list[MAX_CUSTOM_FUNCTIONS];
+
+template<int N>
+struct CustomFunctions
+{
+ static void init()
+ {
+ CustomFunctionsData data;
+ data.m_obj = 0;
+ data.m_func = &CustomFunctions<N>::callback;
+ CustomFunctionsData::m_list[N] = data;
+
+ CustomFunctions<N-1>::init();
+ }
+
+ static qreal callback(qreal v)
+ {
+ return (*CustomFunctionsData::m_list[N].m_obj)(v);
+ }
+};
+
+template<>
+struct CustomFunctions<0>
+{
+ static void init()
+ {
+ CustomFunctionsData data;
+ data.m_obj = 0;
+ data.m_func = &CustomFunctions<0>::callback;
+ CustomFunctionsData::m_list[0] = data;
+ }
+
+ static qreal callback(qreal v)
+ {
+ return (*CustomFunctionsData::m_list[0].m_obj)(v);
+ }
+};
+
+void deleteData(void* data)
+{
+ delete (PySideEasingCurveFunctor*)(data);
+}
+
+void PySideEasingCurveFunctor::init()
+{
+ CustomFunctions<MAX_CUSTOM_FUNCTIONS-1>::init();
+}
+
+QEasingCurve::EasingFunction PySideEasingCurveFunctor::createCustomFuntion(PyObject* parent, PyObject* pyFunc)
+{
+ for(int i=0; i < MAX_CUSTOM_FUNCTIONS; i++) {
+ CustomFunctionsData& data = CustomFunctionsData::m_list[i];
+ if (data.m_obj == 0) {
+ data.m_obj = new PySideEasingCurveFunctor(i, parent, pyFunc);
+ return data.m_func;
+ }
+ }
+ //PyErr_Format(PyExc_RuntimeError, "PySide only supports %d custom functions simultaneously.", MAX_CUSTOM_FUNCTIONS);
+ return 0;
+}
+
+PySideEasingCurveFunctor::~PySideEasingCurveFunctor()
+{
+
+ CustomFunctionsData::m_list[m_index].m_obj = 0;
+ PyObject_SetAttrString(m_parent, __ECF_ATT_NAME__, Py_None);
+}
+
+qreal PySideEasingCurveFunctor::operator()(qreal progress)
+{
+ Shiboken::GilState state;
+ PyObject* args = Py_BuildValue("(f)", progress);
+ PyObject* result = PyObject_CallObject(m_func, args);
+ qreal cppResult = 0.0;
+ if (result) {
+ Shiboken::Conversions::pythonToCppCopy(Shiboken::Conversions::PrimitiveTypeConverter<qreal>(), result, &cppResult);
+ Py_DECREF(result);
+ }
+ Py_DECREF(args);
+ return cppResult;
+}
+
+PyObject* PySideEasingCurveFunctor::callable()
+{
+ Py_INCREF(m_func);
+ return m_func;
+}
+
+PyObject* PySideEasingCurveFunctor::callable(PyObject* parent)
+{
+ return PyObject_GetAttrString(parent, __ECF_ATT_NAME__);
+}
+
+PySideEasingCurveFunctor::PySideEasingCurveFunctor(int index, PyObject* parent, PyObject* pyFunc)
+ : m_parent(parent), m_func(pyFunc), m_index(index)
+{
+ PyObject_SetAttrString(m_parent, __ECF_ATT_NAME__, m_func);
+ PySide::WeakRef::create(m_parent, deleteData, this);
+}
+
diff --git a/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h
new file mode 100644
index 000000000..39acac5d5
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 __QEASINGCURVE_GLUE__
+#define __QEASINGCURVE_GLUE__
+
+#include <Python.h>
+#include <QEasingCurve>
+
+class PySideEasingCurveFunctor
+{
+ public:
+ static void init();
+ static QEasingCurve::EasingFunction createCustomFuntion(PyObject* parent, PyObject* pyFunc);
+
+ qreal operator()(qreal progress);
+
+ PyObject* callable(); //Return New reference
+ static PyObject* callable(PyObject* parent); //Return New reference
+
+ ~PySideEasingCurveFunctor();
+ private:
+ PyObject* m_parent;
+ PyObject* m_func;
+ int m_index;
+
+ PySideEasingCurveFunctor(int index, PyObject* parent, PyObject *pyFunc);
+};
+
+#endif
diff --git a/sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp b/sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp
new file mode 100644
index 000000000..5690112ca
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp
@@ -0,0 +1,228 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+static bool isDecorator(PyObject* method, PyObject* self)
+{
+ Shiboken::AutoDecRef methodName(PyObject_GetAttrString(method, "__name__"));
+ if (!PyObject_HasAttr(self, methodName))
+ return true;
+ Shiboken::AutoDecRef otherMethod(PyObject_GetAttr(self, methodName));
+ return reinterpret_cast<PyMethodObject*>(otherMethod.object())->im_func != \
+ reinterpret_cast<PyMethodObject*>(method)->im_func;
+}
+
+static bool getReceiver(QObject *source, const char* signal, PyObject* callback, QObject** receiver, PyObject** self, QByteArray* callbackSig)
+{
+ bool forceGlobalReceiver = false;
+ if (PyMethod_Check(callback)) {
+ *self = PyMethod_GET_SELF(callback);
+ if (%CHECKTYPE[QObject*](*self))
+ *receiver = %CONVERTTOCPP[QObject*](*self);
+ forceGlobalReceiver = isDecorator(callback, *self);
+ } else if (PyCFunction_Check(callback)) {
+ *self = PyCFunction_GET_SELF(callback);
+ if (*self && %CHECKTYPE[QObject*](*self))
+ *receiver = %CONVERTTOCPP[QObject*](*self);
+ } else if (PyCallable_Check(callback)) {
+ // Ok, just a callable object
+ *receiver = 0;
+ *self = 0;
+ }
+
+ bool usingGlobalReceiver = !*receiver || forceGlobalReceiver;
+
+ // Check if this callback is a overwrite of a non-virtual Qt slot.
+ if (!usingGlobalReceiver && receiver && self) {
+ *callbackSig = PySide::Signal::getCallbackSignature(signal, *receiver, callback, usingGlobalReceiver).toLatin1();
+ const QMetaObject* metaObject = (*receiver)->metaObject();
+ int slotIndex = metaObject->indexOfSlot(callbackSig->constData());
+ if (slotIndex != -1 && slotIndex < metaObject->methodOffset() && PyMethod_Check(callback))
+ usingGlobalReceiver = true;
+ }
+
+ if (usingGlobalReceiver) {
+ PySide::SignalManager& signalManager = PySide::SignalManager::instance();
+ *receiver = signalManager.globalReceiver(source, callback);
+ *callbackSig = PySide::Signal::getCallbackSignature(signal, *receiver, callback, usingGlobalReceiver).toLatin1();
+ }
+
+ return usingGlobalReceiver;
+}
+
+static bool qobjectConnect(QObject* source, const char* signal, QObject* receiver, const char* slot, Qt::ConnectionType type)
+{
+ if (!signal || !slot)
+ return false;
+
+ if (!PySide::Signal::checkQtSignal(signal))
+ return false;
+ signal++;
+
+ if (!PySide::SignalManager::registerMetaMethod(source, signal, QMetaMethod::Signal))
+ return false;
+
+ bool isSignal = PySide::Signal::isQtSignal(slot);
+ slot++;
+ PySide::SignalManager::registerMetaMethod(receiver, slot, isSignal ? QMetaMethod::Signal : QMetaMethod::Slot);
+ bool connection;
+ Py_BEGIN_ALLOW_THREADS
+ connection = QObject::connect(source, signal - 1, receiver, slot - 1, type);
+ Py_END_ALLOW_THREADS
+ return connection;
+}
+
+static bool qobjectConnect(QObject* source, QMetaMethod signal, QObject* receiver, QMetaMethod slot, Qt::ConnectionType type)
+{
+ return qobjectConnect(source, signal.methodSignature(), receiver, slot.methodSignature(), type);
+}
+
+static bool qobjectConnectCallback(QObject* source, const char* signal, PyObject* callback, Qt::ConnectionType type)
+{
+ if (!signal || !PySide::Signal::checkQtSignal(signal))
+ return false;
+ signal++;
+
+ int signalIndex = PySide::SignalManager::registerMetaMethodGetIndex(source, signal, QMetaMethod::Signal);
+ if (signalIndex == -1)
+ return false;
+
+ PySide::SignalManager& signalManager = PySide::SignalManager::instance();
+
+ // Extract receiver from callback
+ QObject* receiver = 0;
+ PyObject* self = 0;
+ QByteArray callbackSig;
+ bool usingGlobalReceiver = getReceiver(source, signal, callback, &receiver, &self, &callbackSig);
+ if (receiver == 0 && self == 0)
+ return false;
+
+ const QMetaObject* metaObject = receiver->metaObject();
+ const char* slot = callbackSig.constData();
+ int slotIndex = metaObject->indexOfSlot(slot);
+ QMetaMethod signalMethod = metaObject->method(signalIndex);
+
+ if (slotIndex == -1) {
+ if (!usingGlobalReceiver && self && !Shiboken::Object::hasCppWrapper((SbkObject*)self)) {
+ qWarning() << "You can't add dynamic slots on an object originated from C++.";
+ if (usingGlobalReceiver)
+ signalManager.releaseGlobalReceiver(source, receiver);
+
+ return false;
+ }
+
+ if (usingGlobalReceiver)
+ slotIndex = signalManager.globalReceiverSlotIndex(receiver, slot);
+ else
+ slotIndex = PySide::SignalManager::registerMetaMethodGetIndex(receiver, slot, QMetaMethod::Slot);
+
+ if (slotIndex == -1) {
+ if (usingGlobalReceiver)
+ signalManager.releaseGlobalReceiver(source, receiver);
+
+ return false;
+ }
+ }
+ bool connection;
+ Py_BEGIN_ALLOW_THREADS
+ connection = QMetaObject::connect(source, signalIndex, receiver, slotIndex, type);
+ Py_END_ALLOW_THREADS
+ if (connection) {
+ if (usingGlobalReceiver)
+ signalManager.notifyGlobalReceiver(receiver);
+ #ifndef AVOID_PROTECTED_HACK
+ source->connectNotify(signalMethod); //Qt5: QMetaMethod instead of char*
+ #else
+ // Need to cast to QObjectWrapper* and call the public version of
+ // connectNotify when avoiding the protected hack.
+ reinterpret_cast<QObjectWrapper*>(source)->connectNotify(signalMethod); //Qt5: QMetaMethod instead of char*
+ #endif
+
+ return connection;
+ }
+
+ if (usingGlobalReceiver)
+ signalManager.releaseGlobalReceiver(source, receiver);
+
+ return false;
+}
+
+
+static bool qobjectDisconnectCallback(QObject* source, const char* signal, PyObject* callback)
+{
+ if (!PySide::Signal::checkQtSignal(signal))
+ return false;
+
+ PySide::SignalManager& signalManager = PySide::SignalManager::instance();
+
+ // Extract receiver from callback
+ QObject* receiver = 0;
+ PyObject* self = 0;
+ QByteArray callbackSig;
+ QMetaMethod slotMethod;
+ bool usingGlobalReceiver = getReceiver(NULL, signal, callback, &receiver, &self, &callbackSig);
+ if (receiver == 0 && self == 0)
+ return false;
+
+ const QMetaObject* metaObject = receiver->metaObject();
+ int signalIndex = source->metaObject()->indexOfSignal(++signal);
+ int slotIndex = -1;
+
+ slotIndex = metaObject->indexOfSlot(callbackSig);
+ slotMethod = metaObject->method(slotIndex);
+
+ bool disconnected;
+ Py_BEGIN_ALLOW_THREADS
+ disconnected = QMetaObject::disconnectOne(source, signalIndex, receiver, slotIndex);
+ Py_END_ALLOW_THREADS
+
+ if (disconnected) {
+ if (usingGlobalReceiver)
+ signalManager.releaseGlobalReceiver(source, receiver);
+
+ #ifndef AVOID_PROTECTED_HACK
+ source->disconnectNotify(slotMethod); //Qt5: QMetaMethod instead of char*
+ #else
+ // Need to cast to QObjectWrapper* and call the public version of
+ // connectNotify when avoiding the protected hack.
+ reinterpret_cast<QObjectWrapper*>(source)->disconnectNotify(slotMethod); //Qt5: QMetaMethod instead of char*
+ #endif
+ return true;
+ }
+ return false;
+}
diff --git a/sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp b/sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp
new file mode 100644
index 000000000..5aa75566e
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+static QObject* _findChildHelper(const QObject* parent, const QString& name, PyTypeObject* desiredType)
+{
+ foreach(QObject* child, parent->children()) {
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child));
+ if (PyType_IsSubtype(pyChild->ob_type, desiredType)
+ && (name.isNull() || name == child->objectName())) {
+ return child;
+ }
+ }
+
+ QObject* obj;
+ foreach(QObject* child, parent->children()) {
+ obj = _findChildHelper(child, name, desiredType);
+ if (obj)
+ return obj;
+ }
+ return 0;
+}
+
+static inline bool _findChildrenComparator(const QObject*& child, const QRegExp& name)
+{
+ return name.indexIn(child->objectName()) != -1;
+}
+
+static inline bool _findChildrenComparator(const QObject*& child, const QString& name)
+{
+ return name.isNull() || name == child->objectName();
+}
+
+template<typename T>
+static void _findChildrenHelper(const QObject* parent, const T& name, PyTypeObject* desiredType, PyObject* result)
+{
+ foreach(const QObject* child, parent->children()) {
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child));
+ if (PyType_IsSubtype(pyChild->ob_type, desiredType) && _findChildrenComparator(child, name))
+ PyList_Append(result, pyChild);
+ _findChildrenHelper(child, name, desiredType, result);
+ }
+}
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core.xml.in b/sources/pyside2/PySide2/QtCore/typesystem_core.xml.in
new file mode 100644
index 000000000..4ccf6423f
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/typesystem_core.xml.in
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtCore">
+ <load-typesystem name="typesystem_core_@AUTO_OS@.xml" generate="yes"/>
+ <load-typesystem name="typesystem_core_common.xml" generate="yes"/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
new file mode 100644
index 000000000..e81eb7e21
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
@@ -0,0 +1,4225 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtCore">
+ <load-typesystem name="typesystem_templates.xml" generate="no"/>
+
+ <custom-type name="str" />
+ <custom-type name="PyBytes" />
+ <custom-type name="PyCallable" />
+ <custom-type name="PyObject" />
+ <custom-type name="PySequence" />
+ <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="qFastCos(qreal)" since="4.6"/>
+ <function signature="qFastSin(qreal)" since="4.6" />
+ <function signature="qFuzzyCompare(double,double)" />
+ <function signature="qFuzzyIsNull(double)" since="4.6" />
+ <function signature="qIsFinite(double)" />
+ <function signature="qIsInf(double)" />
+ <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)" />
+
+ <template name="use_stream_for_format_security">
+ // Uses the stream version for security reasons
+ // see gcc man page at -Wformat-security
+ %FUNCTION_NAME() &lt;&lt; %1;
+ </template>
+
+ <add-function signature="qDebug(const char*)">
+ <inject-code>
+ <insert-template name="use_stream_for_format_security" />
+ </inject-code>
+ </add-function>
+ <add-function signature="qCritical(const char*)">
+ <inject-code>
+ <insert-template name="use_stream_for_format_security" />
+ </inject-code>
+ </add-function>
+ <add-function signature="qFatal(const char*)">
+ <inject-code>
+ // qFatal doesn't have a stream version, so we do a
+ // qWarning call followed by a qFatal() call using a
+ // literal.
+ qWarning() &lt;&lt; %1;
+ qFatal("[A qFatal() call was made from Python code]");
+ </inject-code>
+ </add-function>
+ <add-function signature="qWarning(const char*)">
+ <inject-code>
+ <insert-template name="use_stream_for_format_security" />
+ </inject-code>
+ </add-function>
+
+ <!-- TODO: We do not support void* or const void* as arg -->
+ <rejection class="QMetaObject" function-name="activate"/>
+ <rejection class="QMetaObject" function-name="metacall"/>
+ <rejection class="QMetaObject" function-name="static_metacall"/>
+ <!-- TODO: Support to addGuard(QObject**) -->
+ <rejection class="QMetaObject" function-name="addGuard"/>
+ <rejection class="QMetaObject" function-name="changeGuard"/>
+ <rejection class="QMetaObject" function-name="removeGuard"/>
+
+ <rejection class="QByteArray" field-name="MaxSize"/>
+ <rejection class="QChildEvent" field-name="c"/>
+ <rejection class="QTimerEvent" field-name="id"/>
+ <rejection class="QEvent" field-name="t"/>
+ <rejection class="*" function-name="tr" />
+ <rejection class="*" function-name="trUtf8" />
+ <rejection class="*" function-name="qt_metacast" />
+ <!-- From Qt4.6 -->
+ <rejection class="*" field-name="d_ptr"/>
+ <rejection class="*" field-name="staticQtMetaObject"/>
+ <rejection class="*" function-name="qobject_interface_iid"/>
+ <rejection class="*" function-name="qGetPtrHelper"/>
+ <rejection class="*" function-name="q_check_ptr"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QTextCodecFactoryInterface*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QFactoryInterface*&gt;"/>
+ <rejection class="*" function-name="qRegisterAnimationInterpolator"/>
+ <rejection class="*" function-name="qvariant_cast&lt;QVariant&gt;"/>
+ <rejection class="*" function-name="qVariantSetValue&lt;QVariant&gt;"/>
+ <rejection class="*" function-name="qReallocAligned"/>
+ <rejection class="*" function-name="qMallocAligned"/>
+ <rejection class="*" function-name="qFreeAligned"/>
+ <rejection class="QMetaMethod" enum-name="Attributes" />
+
+ <!-- From Qt4.6 ^^^ -->
+
+
+ <enum-type name="QtMsgType"/>
+
+
+ <primitive-type name="qint8"/>
+ <primitive-type name="qint16"/>
+ <primitive-type name="qint32"/>
+ <primitive-type name="quint8"/>
+ <primitive-type name="quint16"/>
+ <primitive-type name="quint32"/>
+ <primitive-type name="quint64"/>
+ <primitive-type name="bool"/>
+ <primitive-type name="double"/>
+ <primitive-type name="qreal"/>
+ <primitive-type name="float"/>
+ <primitive-type name="qint64"/>
+ <primitive-type name="unsigned long long"/>
+ <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="short"/>
+ <primitive-type name="signed short"/>
+ <primitive-type name="signed short int"/>
+ <primitive-type name="ushort" target-lang-api-name="PyInt" />
+ <primitive-type name="unsigned short int" />
+ <primitive-type name="unsigned short"/>
+ <primitive-type name="char"/>
+ <primitive-type name="signed char"/>
+ <primitive-type name="uchar"/>
+ <primitive-type name="unsigned char"/>
+ <primitive-type name="int"/>
+ <primitive-type name="signed int"/>
+ <primitive-type name="uint"/>
+ <primitive-type name="ulong"/>
+ <primitive-type name="unsigned int"/>
+ <primitive-type name="signed long"/>
+ <primitive-type name="signed long int"/>
+ <primitive-type name="long"/>
+ <primitive-type name="unsigned long int" />
+ <primitive-type name="unsigned long">
+ <!-- FIXME APIExtractor or shiboken do not support multiple includes by primitive type -->
+ <include file-name="signalmanager.h" location="global"/>
+ </primitive-type>
+ <primitive-type name="bool" target-lang-api-name="PyBool">
+ <conversion-rule>
+ <native-to-target>
+ return PyBool_FromLong((bool)%in);
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyBool">
+ %out = %OUTTYPE(%in == Py_True);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <!-- Qt5: add the new pointer-ish types -->
+ <primitive-type name="qintptr" target-lang-api-name="PyLong">
+ <conversion-rule>
+ <native-to-target>
+ return PyLong_FromLong(%in);
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyLong">
+ %out = %OUTTYPE(PyLong_AsLong(%in));
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+ <primitive-type name="quintptr" target-lang-api-name="PyLong">
+ <conversion-rule>
+ <native-to-target>
+ return PyLong_FromUnsignedLong(%in);
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyLong">
+ %out = %OUTTYPE(PyLong_AsUnsignedLong(%in));
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+ <primitive-type name="qptrdiff" target-lang-api-name="PyLong">
+ <conversion-rule>
+ <native-to-target>
+ return PyLong_FromLong(%in);
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyLong">
+ %out = %OUTTYPE(PyLong_AsLong(%in));
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <inject-code class="native" position="beginning">
+ bool py2kStrCheck(PyObject* obj)
+ {
+ #ifdef IS_PY3K
+ return false;
+ #else
+ return PyString_Check(obj);
+ #endif
+ }
+ </inject-code>
+
+ <primitive-type name="QString" target-lang-api-name="PyUnicode">
+ <include file-name="QString" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ const int N = %in.length();
+ wchar_t* str = new wchar_t[N];
+ %in.toWCharArray(str);
+ PyObject* %out = PyUnicode_FromWideChar(str, N);
+ delete[] str;
+ return %out;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyUnicode">
+ Py_UNICODE* unicode = PyUnicode_AS_UNICODE(%in);
+ #if defined(Py_UNICODE_WIDE)
+ // cast as Py_UNICODE can be a different type
+ %out = QString::fromUcs4((const uint*)unicode);
+ #else
+ %out = QString::fromUtf16((const ushort*)unicode, PyUnicode_GET_SIZE(%in));
+ #endif
+ </add-conversion>
+ <add-conversion type="PyString" check="py2kStrCheck(%in)">
+ #ifndef IS_PY3K
+ const char* str = %CONVERTTOCPP[const char*](%in);
+ %out = %OUTTYPE(str);
+ #endif
+ </add-conversion>
+ <add-conversion type="Py_None">
+ %out = %OUTTYPE();
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <primitive-type name="QStringRef">
+ <conversion-rule>
+ <native-to-target>
+ const int N = %in.toString().length();
+ wchar_t* str = new wchar_t[N];
+ %in.toString().toWCharArray(str);
+ PyObject* %out = PyUnicode_FromWideChar(str, N);
+ delete[] str;
+ return %out;
+ </native-to-target>
+ </conversion-rule>
+ </primitive-type>
+ <primitive-type name="QChar">
+ <conversion-rule>
+ <native-to-target>
+ wchar_t c = (wchar_t)%in.unicode();
+ return PyUnicode_FromWideChar(&amp;c, 1);
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyString" check="Shiboken::String::checkChar(%in)">
+ char c = %CONVERTTOCPP[char](%in);
+ %out = %OUTTYPE(c);
+ </add-conversion>
+ <add-conversion type="PyInt">
+ int i = %CONVERTTOCPP[int](%in);
+ %out = %OUTTYPE(i);
+ </add-conversion>
+ <add-conversion type="Py_None">
+ %out = %OUTTYPE();
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <primitive-type name="QVariant" target-lang-api-name="PyObject">
+ <include file-name="typeresolver.h" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ if (!%in.isValid())
+ Py_RETURN_NONE;
+
+ if (qstrcmp(%in.typeName(), "QVariantList") == 0) {
+ QList&lt;QVariant&gt; var = %in.value&lt;QVariantList&gt;();
+ return %CONVERTTOPYTHON[QList&lt;QVariant&gt;](var);
+ }
+
+ if (qstrcmp(%in.typeName(), "QStringList") == 0) {
+ QStringList var = %in.value&lt;QStringList&gt;();
+ return %CONVERTTOPYTHON[QList&lt;QString&gt;](var);
+ }
+
+ if (qstrcmp(%in.typeName(), "QVariantMap") == 0) {
+ QMap&lt;QString, QVariant&gt; var = %in.value&lt;QVariantMap&gt;();
+ return %CONVERTTOPYTHON[QMap&lt;QString, QVariant&gt;](var);
+ }
+
+ Shiboken::Conversions::SpecificConverter converter(cppInRef.typeName());
+ if (converter) {
+ void* ptr = cppInRef.data();
+ return converter.toPython(ptr);
+ }
+ PyErr_Format(PyExc_RuntimeError, "Can't find converter for '%s'.", %in.typeName());
+ return 0;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyBool">
+ %out = %OUTTYPE(%in == Py_True);
+ </add-conversion>
+ <add-conversion type="Py_None">
+ %out = %OUTTYPE();
+ </add-conversion>
+ <add-conversion type="QString" check="Shiboken::String::check(%in)">
+ QString in = %CONVERTTOCPP[QString](%in);
+ %out = %OUTTYPE(in);
+ </add-conversion>
+ <add-conversion type="QByteArray">
+ QByteArray in = %CONVERTTOCPP[QByteArray](%in);
+ %out = %OUTTYPE(in);
+ </add-conversion>
+ <add-conversion type="PyFloat" check="PyFloat_CheckExact(%in)">
+ double in = %CONVERTTOCPP[double](%in);
+ %out = %OUTTYPE(in);
+ </add-conversion>
+ <add-conversion type="PyInt">
+ int in = %CONVERTTOCPP[int](%in);
+ %out = %OUTTYPE(in);
+ </add-conversion>
+ <add-conversion type="PyLong" check="PyLong_CheckExact(%in)">
+ qlonglong in = %CONVERTTOCPP[qlonglong](%in);
+ %out = %OUTTYPE(in);
+ </add-conversion>
+ <add-conversion type="SbkEnumType">
+ int in = %CONVERTTOCPP[int](%in);
+ %out = %OUTTYPE(in);
+ </add-conversion>
+ <add-conversion type="SbkObject">
+ // a class supported by QVariant?
+ int typeCode;
+ const char* typeName = QVariant_resolveMetaType(%in->ob_type, &amp;typeCode);
+ if (!typeCode || !typeName)
+ return;
+ QVariant var(typeCode, (void*)0);
+ Shiboken::Conversions::SpecificConverter converter(typeName);
+ converter.toCpp(pyIn, var.data());
+ %out = var;
+ </add-conversion>
+ <add-conversion type="PyDict">
+ QVariant ret = QVariant_convertToVariantMap(%in);
+ %out = ret.isValid() ? ret : QVariant::fromValue&lt;PySide::PyObjectWrapper&gt;(%in);
+ </add-conversion>
+ <add-conversion type="PySequence">
+ %out = QVariant_convertToVariantList(%in);
+ </add-conversion>
+ <add-conversion type="PyObject">
+ // Is a shiboken type not known by Qt
+ %out = QVariant::fromValue&lt;PySide::PyObjectWrapper&gt;(%in);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+ <inject-code class="native" position="beginning">
+ static const char* QVariant_resolveMetaType(PyTypeObject* type, int* typeId)
+ {
+ if (PyObject_TypeCheck(type, &amp;SbkObjectType_Type)) {
+ SbkObjectType* sbkType = (SbkObjectType*)type;
+ const char* typeName = Shiboken::ObjectType::getOriginalName(sbkType);
+ if (!typeName)
+ return 0;
+ bool valueType = '*' != typeName[qstrlen(typeName) - 1];
+ // Do not convert user type of value
+ if (valueType &amp;&amp; Shiboken::ObjectType::isUserType(type))
+ return 0;
+ int obTypeId = QMetaType::type(typeName);
+ if (obTypeId) {
+ *typeId = obTypeId;
+ return typeName;
+ }
+ // Do not resolve types to value type
+ if (valueType)
+ return 0;
+ // Find in base types. First check tp_bases, and only after check tp_base, because
+ // tp_base does not always point to the first base class, but rather to the first
+ // that has added any python fields or slots to its object layout.
+ // See https://mail.python.org/pipermail/python-list/2009-January/520733.html
+ if (type->tp_bases) {
+ for(int i = 0; i &lt; PyTuple_GET_SIZE(type->tp_bases); ++i) {
+ const char* derivedName = QVariant_resolveMetaType((PyTypeObject*)PyTuple_GET_ITEM(type->tp_bases, i), typeId);
+ if (derivedName)
+ return derivedName;
+ }
+ }
+ else if (type->tp_base) {
+ return QVariant_resolveMetaType(type->tp_base, typeId);
+ }
+ }
+ *typeId = 0;
+ return 0;
+ }
+ static QVariant QVariant_convertToValueList(PyObject* list)
+ {
+ if (PySequence_Size(list) &lt; 1)
+ return QVariant();
+ Shiboken::AutoDecRef element(PySequence_GetItem(list, 0));
+ int typeId;
+ const char* typeName = QVariant_resolveMetaType(element.cast&lt;PyTypeObject*&gt;(), &amp;typeId);
+ if (typeName) {
+ QByteArray listTypeName("QList&lt;");
+ listTypeName += typeName;
+ listTypeName += '>';
+ typeId = QMetaType::type(listTypeName);
+ if (typeId &gt; 0) {
+ Shiboken::Conversions::SpecificConverter converter(listTypeName);
+ if (converter) {
+ QVariant var(typeId, (void*)0);
+ converter.toCpp(list, &amp;var);
+ return var;
+ }
+ qWarning() &lt;&lt; "Type converter for :" &lt;&lt; listTypeName &lt;&lt; "not registered.";
+ }
+ }
+ return QVariant();
+ }
+ static bool QVariant_isStringList(PyObject *list)
+ {
+ bool allString = true;
+ Shiboken::AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList"));
+ Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object());
+ for(int i = 0; i &lt; size; ++i) {
+ PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i);
+ if (!%CHECKTYPE[QString](item)) {
+ allString = false;
+ break;
+ }
+ }
+ return allString;
+ }
+ static QVariant QVariant_convertToVariantMap(PyObject* map)
+ {
+ Py_ssize_t pos = 0;
+ Shiboken::AutoDecRef keys(PyDict_Keys(map));
+ if (!QVariant_isStringList(keys))
+ return QVariant();
+ PyObject* key;
+ PyObject* value;
+ QMap&lt;QString,QVariant&gt; ret;
+ while (PyDict_Next(map, &amp;pos, &amp;key, &amp;value)) {
+ QString cppKey = %CONVERTTOCPP[QString](key);
+ QVariant cppValue = %CONVERTTOCPP[QVariant](value);
+ ret.insert(cppKey, cppValue);
+ }
+ return QVariant(ret);
+ }
+ static QVariant QVariant_convertToVariantList(PyObject* list)
+ {
+ if (QVariant_isStringList(list)) {
+ QList&lt;QString &gt; lst = %CONVERTTOCPP[QList&lt;QString&gt;](list);
+ return QVariant(QStringList(lst));
+ }
+ QVariant valueList = QVariant_convertToValueList(list);
+ if (valueList.isValid())
+ return valueList;
+ QList&lt;QVariant&gt; lst;
+ Shiboken::AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList"));
+ Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object());
+ for (int i = 0; i &lt; size; ++i) {
+ PyObject* pyItem = PySequence_Fast_GET_ITEM(fast.object(), i);
+ QVariant item = %CONVERTTOCPP[QVariant](pyItem);
+ lst.append(item);
+ }
+ return QVariant(lst);
+ }
+ </inject-code>
+
+ <primitive-type name="QVariant::Type" default-constructor="QVariant::Invalid">
+ <conversion-rule>
+ <native-to-target>
+ const char* typeName = QVariant::typeToName(%in);
+ PyObject* %out;
+ PyTypeObject* pyType = 0;
+ if (typeName)
+ pyType = Shiboken::Conversions::getPythonTypeObject(typeName);
+ %out = pyType ? ((PyObject*)pyType) : Py_None;
+ Py_INCREF(%out);
+ return %out;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="Py_None">
+ %out = QVariant::Invalid;
+ </add-conversion>
+ <add-conversion type="PyTypeObject">
+ const char* typeName;
+ if (Shiboken::String::checkType((PyTypeObject*)%in))
+ typeName = "QString";
+ else if (%in == (PyObject*)&amp;PyFloat_Type)
+ typeName = "double"; // float is a UserType in QVariant.
+ else if (%in == (PyObject*)&amp;PyLong_Type)
+ typeName = "int"; // long is a UserType in QVariant.
+ else if (%in->ob_type == &amp;SbkObjectType_Type)
+ typeName = Shiboken::ObjectType::getOriginalName((SbkObjectType*)%in);
+ else
+ typeName = ((PyTypeObject*)%in)->tp_name;
+ %out = QVariant::nameToType(typeName);
+ </add-conversion>
+ <add-conversion type="PyString" check="Shiboken::String::check(%in)">
+ %out = QVariant::nameToType(Shiboken::String::toCString(%in));
+ </add-conversion>
+ <add-conversion type="PyDict" check="PyDict_Check(%in) &amp;&amp; QVariantType_checkAllStringKeys(%in)">
+ %out = QVariant::nameToType("QVariantMap");
+ </add-conversion>
+ <add-conversion type="PySequence">
+ const char* typeName;
+ if (QVariantType_isStringList(%in))
+ typeName = "QStringList";
+ else
+ typeName = "QVariantList";
+ %out = QVariant::nameToType(typeName);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <primitive-type name="QVariantMap" target-lang-api-name="PyDict"/>
+ <inject-code class="target" position="end">
+ Shiboken::Conversions::registerConverterName(SbkPySide2_QtCoreTypeConverters[SBK_QTCORE_QMAP_QSTRING_QVARIANT_IDX], "QVariantMap");
+ </inject-code>
+
+ <inject-code class="native" position="beginning">
+ static bool QVariantType_isStringList(PyObject* list)
+ {
+ bool allString = true;
+ Shiboken::AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList"));
+ Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object());
+ for(int i=0; i &lt; size; i++) {
+ PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i);
+ if (!%CHECKTYPE[QString](item)) {
+ allString = false;
+ break;
+ }
+ }
+ return allString;
+ }
+ static bool QVariantType_checkAllStringKeys(PyObject* dict)
+ {
+ Shiboken::AutoDecRef keys(PyDict_Keys(dict));
+ return QVariantType_isStringList(keys);
+ }
+ </inject-code>
+
+ <primitive-type name="QStringList">
+ <include file-name="QStringList" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ <insert-template name="cpplist_to_pylist_conversion">
+ <replace from="%INTYPE_0" to="QString" />
+ </insert-template>
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PySequence">
+ <insert-template name="pyseq_to_cpplist_conversion">
+ <replace from="%OUTTYPE_0" to="QString" />
+ </insert-template>
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <primitive-type name="QJsonObject">
+ <conversion-rule>
+ <native-to-target>
+ // The QVariantMap returned by QJsonObject seems to cause a segfault, so
+ // using QJsonObject.toVariantMap() won't work.
+ // Wrapping it in a QJsonValue first allows it to work
+ QJsonValue val(%in);
+ QVariant ret = val.toVariant();
+
+ return %CONVERTTOPYTHON[QVariant](ret);
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyDict">
+ QVariant dict = QVariant_convertToVariantMap(%in);
+ QJsonValue val = QJsonValue::fromVariant(dict);
+
+ %out = val.toObject();
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <primitive-type name="QModelIndexList">
+ <include file-name="qabstractitemmodel.h" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ <insert-template name="cpplist_to_pylist_conversion">
+ <replace from="%INTYPE_0" to="QModelIndex" />
+ </insert-template>
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PySequence">
+ <insert-template name="pyseq_to_cpplist_conversion">
+ <replace from="%OUTTYPE_0" to="QModelIndex" />
+ </insert-template>
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <container-type name="QSet" type="set">
+ <include file-name="QSet" 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="QList" type="list">
+ <include file-name="QList" 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="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>
+ <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="QQueue" type="queue">
+ <include file-name="QQueue" 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="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>
+
+ <template name="cppmap_to_pymap_conversion">
+ PyObject* %out = PyDict_New();
+ %INTYPE::const_iterator it = %in.begin();
+ for (; it != %in.end(); ++it) {
+ %INTYPE_0 key = it.key();
+ %INTYPE_1 value = it.value();
+ PyObject* pyKey = %CONVERTTOPYTHON[%INTYPE_0](key);
+ PyObject* pyValue = %CONVERTTOPYTHON[%INTYPE_1](value);
+ PyDict_SetItem(%out, pyKey, pyValue);
+ Py_DECREF(pyKey);
+ Py_DECREF(pyValue);
+ }
+ return %out;
+ </template>
+ <template name="pydict_to_cppmap_conversion">
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+ while (PyDict_Next(%in, &amp;pos, &amp;key, &amp;value)) {
+ %OUTTYPE_0 cppKey = %CONVERTTOCPP[%OUTTYPE_0](key);
+ %OUTTYPE_1 cppValue = %CONVERTTOCPP[%OUTTYPE_1](value);
+ %out.insert(cppKey, cppValue);
+ }
+ </template>
+
+ <container-type name="QHash" type="hash">
+ <include file-name="QHash" location="global"/>
+ <include file-name="pysideconversions.h" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ <insert-template name="cppmap_to_pymap_conversion"/>
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyDict">
+ <insert-template name="pydict_to_cppmap_conversion"/>
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+ <container-type name="QMap" type="map">
+ <include file-name="QMap" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ <insert-template name="cppmap_to_pymap_conversion"/>
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyDict">
+ <insert-template name="pydict_to_cppmap_conversion"/>
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+ <container-type name="QMultiMap" type="multi-map">
+ <include file-name="QMultiMap" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ <insert-template name="cppmap_to_pymap_conversion"/>
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyDict">
+ <insert-template name="pydict_to_cppmap_conversion"/>
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+
+ <container-type name="QPair" type="pair">
+ <include file-name="QPair" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ PyObject* %out = PyTuple_New(2);
+ PyTuple_SET_ITEM(%out, 0, %CONVERTTOPYTHON[%INTYPE_0](%in.first));
+ PyTuple_SET_ITEM(%out, 1, %CONVERTTOPYTHON[%INTYPE_1](%in.second));
+ return %out;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PySequence">
+ %out.first = %CONVERTTOCPP[%OUTTYPE_0](PySequence_Fast_GET_ITEM(%in, 0));
+ %out.second = %CONVERTTOCPP[%OUTTYPE_1](PySequence_Fast_GET_ITEM(%in, 1));
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+
+ <rejection class="*" function-name="d_func"/>
+ <rejection class="*" function-name="data_ptr"/>
+ <rejection class="*" function-name="detach"/>
+ <rejection class="*" function-name="isDetached"/>
+ <rejection class="*" field-name="d_ptr"/>
+ <rejection class="*" field-name="d"/>
+ <rejection class="*" field-name="staticMetaObject"/>
+ <!-- not support array in property -->
+ <rejection class="QTextCodec::ConverterState" field-name="state_data"/>
+ <rejection class="QUuid" field-name="data1"/>
+ <rejection class="QUuid" field-name="data2"/>
+ <rejection class="QUuid" field-name="data3"/>
+ <rejection class="QUuid" field-name="data4"/>
+ <rejection class="" enum-name="QtValidLicenseForTestModule"/>
+ <rejection class="" enum-name="QtValidLicenseForDBusModule"/>
+ <rejection class="" enum-name="QtValidLicenseForSqlModule"/>
+ <rejection class="" enum-name="QtValidLicenseForOpenGLModule"/>
+ <rejection class="" enum-name="QtValidLicenseForScriptToolsModule"/>
+ <rejection class="" enum-name="__codecvt_result"/>
+ <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"/>
+ <rejection class="QAbstractEventDispatcher" function-name="filterEvent"/>
+ <rejection class="QAbstractEventDispatcher" function-name="filterNativeEvent"/>
+ <rejection class="QAbstractEventDispatcher" function-name="setEventFilter"/>
+ <!-- Internal -->
+ <rejection class="QAbstractFileEngine"/> <!--
+ <rejection class="QAbstractFileEngine" function-name="endEntryList"/>
+ <rejection class="QAbstractFileEngine" function-name="extension"/> XXX -->
+ <rejection class="QCoreApplication" function-name="compressEvent"/>
+ <rejection class="QCoreApplication" function-name="eventFilter"/>
+ <rejection class="QCoreApplication" function-name="filterEvent"/>
+ <rejection class="QCoreApplication" function-name="setEventFilter"/>
+ <rejection class="QFile" function-name="setDecodingFunction"/>
+ <rejection class="QFile" function-name="setEncodingFunction"/>
+ <rejection class="QRegion" function-name="cleanUp"/>
+ <rejection class="QSettings" function-name="registerFormat"/>
+
+ <namespace-type name="Qt">
+ <enum-type name="AlignmentFlag" flags="Alignment" />
+ <enum-type name="AnchorPoint" since="4.6" />
+ <enum-type name="ApplicationAttribute"/>
+ <enum-type name="ApplicationState" flags="ApplicationStates" since="5.1"/>
+ <enum-type name="ArrowType"/>
+ <enum-type name="AspectRatioMode"/>
+ <enum-type name="Axis"/>
+ <enum-type name="BGMode"/>
+ <enum-type name="BrushStyle"/>
+ <enum-type name="CaseSensitivity"/>
+ <enum-type name="ChecksumType" since="5.9"/>
+ <enum-type name="CheckState"/>
+ <enum-type name="ClipOperation"/>
+ <enum-type name="ConnectionType"/>
+ <enum-type name="ContextMenuPolicy"/>
+ <enum-type name="CoordinateSystem" since="4.6"/>
+ <enum-type name="Corner"/>
+ <enum-type name="CursorShape" />
+ <enum-type name="DateFormat" />
+ <enum-type name="DayOfWeek"/>
+ <enum-type name="DockWidgetArea" flags="DockWidgetAreas" />
+ <enum-type name="DockWidgetAreaSizes"/>
+ <enum-type name="DropAction" flags="DropActions"/>
+ <enum-type name="Edge" flags="Edges" since="5.1"/>
+ <enum-type name="EventPriority"/>
+ <enum-type name="FillRule"/>
+ <enum-type name="FindChildOption" flags="FindChildOptions" since="5.0"/>
+ <enum-type name="FocusPolicy"/>
+ <enum-type name="FocusReason"/>
+ <enum-type name="GestureFlag" flags="GestureFlags" since="4.6"/>
+ <enum-type name="GestureState" since="4.6"/>
+ <enum-type name="GestureType" since="4.6"/>
+ <enum-type name="GlobalColor"/>
+ <enum-type name="HitTestAccuracy"/>
+ <enum-type name="ImageConversionFlag" flags="ImageConversionFlags" />
+ <enum-type name="InputMethodHint" flags="InputMethodHints" since="4.6"/>
+ <enum-type name="InputMethodQuery" flags="InputMethodQueries" />
+ <enum-type name="EnterKeyType" since="5.6" />
+ <enum-type name="ItemDataRole" force-integer="yes" />
+ <enum-type name="ItemFlag" flags="ItemFlags"/>
+ <enum-type name="ItemSelectionMode"/>
+ <enum-type name="ItemSelectionOperation" since="5.5" />
+ <enum-type name="Key" />
+ <enum-type name="KeyboardModifier" flags="KeyboardModifiers"/>
+ <enum-type name="LayoutDirection"/>
+ <enum-type name="MaskMode"/>
+ <enum-type name="MatchFlag" flags="MatchFlags"/>
+ <enum-type name="Modifier"/>
+ <enum-type name="MouseButton" flags="MouseButtons"/>
+ <enum-type name="MouseEventFlag" flags="MouseEventFlags" since="5.3"/>
+ <enum-type name="MouseEventSource" since="5.3"/>
+ <enum-type name="NativeGestureType" since="5.0"/>
+ <enum-type name="NavigationMode" since="4.6"/>
+ <enum-type name="Orientation" flags="Orientations"/>
+ <enum-type name="PenCapStyle"/>
+ <enum-type name="PenJoinStyle"/>
+ <enum-type name="PenStyle"/>
+ <enum-type name="ScreenOrientation" flags="ScreenOrientations" since="5.0"/>
+ <enum-type name="ScrollBarPolicy"/>
+ <enum-type name="ScrollPhase" since="5.2"/>
+ <enum-type name="ShortcutContext"/>
+ <enum-type name="SizeHint"/>
+ <enum-type name="SizeMode"/>
+ <enum-type name="SortOrder"/>
+ <enum-type name="TabFocusBehavior" since="5.5" />
+ <enum-type name="TextElideMode"/>
+ <enum-type name="TextFlag"/>
+ <enum-type name="TextFormat"/>
+ <enum-type name="TextInteractionFlag" flags="TextInteractionFlags"/>
+ <enum-type name="TileRule" since="4.6"/>
+ <enum-type name="TimerType" since="5.0"/>
+ <enum-type name="TimeSpec"/>
+ <enum-type name="ToolBarArea" flags="ToolBarAreas" />
+ <enum-type name="ToolBarAreaSizes"/>
+ <enum-type name="ToolButtonStyle"/>
+ <enum-type name="TouchPointState" flags="TouchPointStates" since="4.6"/>
+ <enum-type name="TransformationMode"/>
+ <enum-type name="UIEffect"/>
+ <enum-type name="WhiteSpaceMode" />
+ <enum-type name="WidgetAttribute" />
+ <enum-type name="WindowFrameSection"/>
+ <enum-type name="WindowModality"/>
+ <enum-type name="WindowState" flags="WindowStates"/>
+ <enum-type name="WindowType" flags="WindowFlags"/>
+ <enum-type name="CursorMoveStyle" since="4.8" revision="4800"/>
+
+ <!--### These functions are part of QtGui, not QtCore -->
+ <modify-function signature="codecForHtml(const QByteArray &amp;)" remove="all"/>
+ <modify-function signature="mightBeRichText(const QString &amp;)" remove="all"/>
+ <modify-function signature="convertFromPlainText(const QString &amp;, Qt::WhiteSpaceMode)" remove="all"/>
+ <!--### -->
+ </namespace-type>
+
+ <add-function signature="qAbs(double)" return-type="double">
+ <inject-code class="target" position="beginning">
+ double _abs = qAbs(%1);
+ %PYARG_0 = %CONVERTTOPYTHON[double](_abs);
+ </inject-code>
+ </add-function>
+
+ <inject-code class="native" position="beginning">
+ namespace PySide {
+ static QStack&lt;PyObject*&gt; globalPostRoutineFunctions;
+ void globalPostRoutineCallback()
+ {
+ Shiboken::GilState state;
+ foreach(PyObject* callback, globalPostRoutineFunctions) {
+ Shiboken::AutoDecRef result(PyObject_CallObject(callback, NULL));
+ Py_DECREF(callback);
+ }
+ globalPostRoutineFunctions.clear();
+ }
+ void addPostRoutine(PyObject* callback)
+ {
+ if (PyCallable_Check(callback)) {
+ globalPostRoutineFunctions &lt;&lt; callback;
+ Py_INCREF(callback);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "qAddPostRoutine: The argument must be a callable object.");
+ }
+ }
+ } // namespace
+ </inject-code>
+ <add-function signature="qAddPostRoutine(PyObject*)">
+ <inject-code class="target" position="beginning">
+ PySide::addPostRoutine(%1);
+ </inject-code>
+ </add-function>
+ <inject-code class="target" position="end">
+ qAddPostRoutine(PySide::globalPostRoutineCallback);
+ </inject-code>
+
+ <inject-code class="target" position="end">
+ QList&lt;QByteArray&gt; version = QByteArray(qVersion()).split('.');
+ PyObject* pyQtVersion = PyTuple_New(3);
+ for (int i = 0; i &lt; 3; ++i)
+ PyTuple_SET_ITEM(pyQtVersion, i, PyInt_FromLong(version[i].toInt()));
+ PyModule_AddObject(module, "__version_info__", pyQtVersion);
+ PyModule_AddStringConstant(module, "__version__", qVersion());
+ </inject-code>
+
+ <inject-code class="target" position="end">
+ { // Avoid name clash
+ Shiboken::AutoDecRef regFunc((PyObject*)NULL);
+ Shiboken::AutoDecRef atexit(Shiboken::Module::import("atexit"));
+ if (atexit.isNull()) {
+ qWarning() &lt;&lt; "Module atexit not found for registering __moduleShutdown";
+ PyErr_Clear();
+ }else{
+ regFunc = PyObject_GetAttrString(atexit, "register");
+ if (regFunc.isNull()) {
+ qWarning() &lt;&lt; "Function atexit.register not found for registering __moduleShutdown";
+ PyErr_Clear();
+ }
+ }
+ if (!atexit.isNull() &amp;&amp; !regFunc.isNull()){
+ PyObject* shutDownFunc = PyObject_GetAttrString(module, "__moduleShutdown");
+ Shiboken::AutoDecRef args(PyTuple_New(1));
+ PyTuple_SET_ITEM(args, 0, shutDownFunc);
+ Shiboken::AutoDecRef retval(PyObject_Call(regFunc, args, 0));
+ Q_ASSERT(!retval.isNull());
+ }
+ }
+ </inject-code>
+
+ <add-function signature="__moduleShutdown()">
+ <inject-code class="target" position="beginning">
+ PySide::runCleanupFunctions();
+ </inject-code>
+ </add-function>
+
+ <!--signal/slot-->
+ <inject-code class="target" position="end">
+ Shiboken::Conversions::registerConverterName(SbkPySide2_QtCoreTypeConverters[SBK_QSTRING_IDX], "unicode");
+ Shiboken::Conversions::registerConverterName(SbkPySide2_QtCoreTypeConverters[SBK_QSTRING_IDX], "str");
+ Shiboken::Conversions::registerConverterName(SbkPySide2_QtCoreTypeConverters[SBK_QTCORE_QLIST_QVARIANT_IDX], "QVariantList");
+
+ PySide::init(module);
+ Py_AtExit(QtCoreModuleExit);
+ </inject-code>
+ <inject-code class="native" position="beginning">
+ #include &lt;pyside.h&gt;
+ </inject-code>
+
+ <inject-code class="native" position="beginning">
+ // Define a global variable to handle qInstallMessageHandler callback
+ static PyObject* qtmsghandler = 0;
+
+ static void msgHandlerCallback(QtMsgType type, const QMessageLogContext &amp; ctx, const QString &amp;msg)
+ {
+ Shiboken::GilState state;
+ Shiboken::AutoDecRef arglist(PyTuple_New(3));
+ PyTuple_SET_ITEM(arglist, 0, %CONVERTTOPYTHON[QtMsgType](type));
+ PyTuple_SET_ITEM(arglist, 1, %CONVERTTOPYTHON[QMessageLogContext &amp;](ctx));
+ QByteArray array = msg.toLatin1().data();
+ char *data = array.data();
+ PyTuple_SET_ITEM(arglist, 2, %CONVERTTOPYTHON[char *](data));
+ Shiboken::AutoDecRef ret(PyObject_CallObject(qtmsghandler, arglist));
+ }
+ static void QtCoreModuleExit()
+ {
+ PySide::SignalManager::instance().clear();
+ }
+ </inject-code>
+ <add-function signature="qInstallMessageHandler(PyObject)" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ if (%PYARG_1 == Py_None) {
+ qInstallMessageHandler(0);
+ %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None;
+ qtmsghandler = 0;
+ } else if (!PyCallable_Check(%PYARG_1)) {
+ PyErr_SetString(PyExc_TypeError, "parameter must be callable");
+ } else {
+ %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None;
+ Py_INCREF(%PYARG_1);
+ qtmsghandler = %PYARG_1;
+ qInstallMessageHandler(msgHandlerCallback);
+ }
+
+ if (%PYARG_0 == Py_None)
+ Py_INCREF(%PYARG_0);
+
+ </inject-code>
+ </add-function>
+
+ <value-type name="QElapsedTimer" since="4.7">
+ <enum-type name="ClockType" since="4.7"/>
+ </value-type>
+
+ <object-type name="QAbstractTableModel" polymorphic-id-expression="qobject_cast&lt;QAbstractTableModel*&gt;(%1)">
+ <extra-includes>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ </object-type>
+ <value-type name="QLine" hash-function="PySide::hash">
+ <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.x1(), %CPPSELF.y1(), %CPPSELF.x2(), %CPPSELF.y2()" />
+ </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="iiii" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.x1(), %CPPSELF.y1(), %CPPSELF.x2(), %CPPSELF.y2()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <inject-code class="native" position="beginning">
+ namespace PySide {
+ template&lt;&gt; inline uint hash(const QLine&amp; v) {
+ return qHash(qMakePair(qMakePair(v.x1(), v.y1()), qMakePair(v.x2(), v.y2())));
+ }
+ };
+ </inject-code>
+
+ <add-function signature="toTuple" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="to_tuple">
+ <replace from="%TT_FORMAT" to="iiii" />
+ <replace from="%TT_ARGS" to="%CPPSELF.x1(), %CPPSELF.y1(), %CPPSELF.x2(), %CPPSELF.y2()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ </value-type>
+ <value-type name="QLineF">
+ <enum-type name="IntersectType" />
+ <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" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.x1(), %CPPSELF.y1(), %CPPSELF.x2(), %CPPSELF.y2()" />
+ </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="dddd" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.x1(), %CPPSELF.y1(), %CPPSELF.x2(), %CPPSELF.y2()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="toTuple" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="to_tuple">
+ <replace from="%TT_FORMAT" to="dddd" />
+ <replace from="%TT_ARGS" to="%CPPSELF.x1(), %CPPSELF.y1(), %CPPSELF.x2(), %CPPSELF.y2()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <modify-function signature="intersect(QLineF, QPointF*)const">
+ <modify-argument index="2">
+ <remove-argument />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(intersectType, intersectionPoint)" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ QPointF p;
+ %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;p);
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QPointF](p));
+ </inject-code>
+ </modify-function>
+ </value-type>
+ <object-type name="QResource">
+ <modify-function signature="data()const">
+ <inject-documentation format="target">
+ Returns a read only buffer object pointing to the segment of data that this resource represents. If the resource is compressed the data returns is compressed and qUncompress() must be used to access the data. If the resource is a directory None is returned.
+ </inject-documentation>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject" />
+ </modify-argument>
+ <inject-code>
+ const void* d = %CPPSELF.%FUNCTION_NAME();
+ if (d) {
+ %PYARG_0 = Shiboken::Buffer::newObject(d, %CPPSELF.size());
+ } else {
+ Py_INCREF(Py_None);
+ %PYARG_0 = Py_None;
+ }
+ </inject-code>
+ </modify-function>
+ <template name="QResource_registerResource">
+ uchar* ptr = (uchar*) Shiboken::Buffer::getPointer(%PYARG_1);
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(const_cast&lt;const uchar*>(ptr), %2);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </template>
+
+ <modify-function signature="unregisterResource(const uchar*, const QString&amp;)" rename="unregisterResourceData">
+ <modify-argument index="1">
+ <replace-type modified-type="PyBuffer"/>
+ </modify-argument>
+ <inject-code>
+ <insert-template name="QResource_registerResource" />
+ </inject-code>
+ </modify-function>
+ <modify-function signature="registerResource(const uchar*, const QString&amp;)" rename="registerResourceData">
+ <modify-argument index="1">
+ <replace-type modified-type="PyBuffer"/>
+ </modify-argument>
+ <inject-code>
+ <insert-template name="QResource_registerResource" />
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+ <value-type name="QBasicTimer"/>
+ <value-type name="QByteArrayMatcher"/>
+ <value-type name="QDate" hash-function="PySide::hash" >
+ <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;
+ return $DATETIMETYPE_Check(pyIn);
+ }
+ </template>
+ <inject-code class="native" position="beginning">
+ <insert-template name="pydatetime_importandcheck_function">
+ <replace from="$DATETIMETYPE" to="PyDate" />
+ </insert-template>
+ </inject-code>
+ <conversion-rule>
+ <target-to-native>
+ <add-conversion type="Py_None">
+ %out = %OUTTYPE();
+ </add-conversion>
+ <add-conversion type="PyDate" check="PyDateTime_ImportAndCheck(%in)">
+ int day = PyDateTime_GET_DAY(%in);
+ int month = PyDateTime_GET_MONTH(%in);
+ int year = PyDateTime_GET_YEAR(%in);
+ %out = %OUTTYPE(year, month, day);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ <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">
+ <replace from="%REPR_FORMAT" to="%i, %i, %i" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.year(), %CPPSELF.month(), %CPPSELF.day()" />
+ </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="iii" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.year(), %CPPSELF.month(), %CPPSELF.day()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="toPython()" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ if (!PyDateTimeAPI) PySideDateTime_IMPORT;
+ %PYARG_0 = PyDate_FromDate(%CPPSELF.year(), %CPPSELF.month(), %CPPSELF.day());
+ </inject-code>
+ </add-function>
+ <modify-function signature="getDate(int*,int*,int*)" >
+ <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="return">
+ <replace-type modified-type="(year, month, day)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int year, month, day;
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF.%FUNCTION_NAME(&amp;year, &amp;month, &amp;day);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(3);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](year));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](month));
+ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[int](day));
+ </inject-code>
+ </modify-function>
+ <modify-function signature="weekNumber(int*)const" >
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(week, yearNumber)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int yearNumber;
+ %BEGIN_ALLOW_THREADS
+ int week = %CPPSELF.%FUNCTION_NAME(&amp;yearNumber);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](week));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](yearNumber));
+ </inject-code>
+ </modify-function>
+ </value-type>
+ <value-type name="QDateTime" hash-function="PySide::hash">
+ <inject-code class="native" position="beginning">
+ <insert-template name="pydatetime_importandcheck_function">
+ <replace from="$DATETIMETYPE" to="PyDateTime" />
+ </insert-template>
+ </inject-code>
+ <conversion-rule>
+ <target-to-native>
+ <add-conversion type="Py_None">
+ %out = %OUTTYPE();
+ </add-conversion>
+ <add-conversion type="PyDateTime" check="PyDateTime_ImportAndCheck(%in)">
+ int day = PyDateTime_GET_DAY(%in);
+ int month = PyDateTime_GET_MONTH(%in);
+ int year = PyDateTime_GET_YEAR(%in);
+ int hour = PyDateTime_DATE_GET_HOUR(%in);
+ int min = PyDateTime_DATE_GET_MINUTE(%in);
+ int sec = PyDateTime_DATE_GET_SECOND(%in);
+ int usec = PyDateTime_DATE_GET_MICROSECOND(%in);
+ %out = %OUTTYPE(QDate(year, month, day), QTime(hour, min, sec, usec/1000));
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ <extra-includes>
+ <include file-name="datetime.h" location="global"/>
+ </extra-includes>
+ <!-- Somewhat internal constructor used to pickle QDateTime -->
+ <add-function signature="QDateTime(int, int, int, int, int, int, int, int)">
+ <modify-argument index="8">
+ <replace-default-expression with="Qt::LocalTime"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ QDate date(%1, %2, %3);
+ QTime time(%4, %5, %6, %7);
+ %0 = new %TYPE(date, time, Qt::TimeSpec(%8));
+ </inject-code>
+ </add-function>
+ <add-function signature="QDateTime(int, int, int, int, int, int)">
+ <inject-code class="target" position="beginning">
+ QDate date(%1, %2, %3);
+ QTime time(%4, %5, %6);
+ %0 = new %TYPE(date, time);
+ </inject-code>
+ </add-function>
+ <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, %i, %i, %i, %i" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.date().year(), %CPPSELF.date().month(), %CPPSELF.date().day(), %CPPSELF.time().hour(), %CPPSELF.time().minute(), %CPPSELF.time().second(), %CPPSELF.time().msec(), (int)%CPPSELF.timeSpec()" />
+ </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="iiiiiiii" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.date().year(), %CPPSELF.date().month(), %CPPSELF.date().day(), %CPPSELF.time().hour(), %CPPSELF.time().minute(), %CPPSELF.time().second(), %CPPSELF.time().msec(), (int)%CPPSELF.timeSpec()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="toPython()" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ QDate date = %CPPSELF.date();
+ QTime time = %CPPSELF.time();
+ if (!PyDateTimeAPI) PySideDateTime_IMPORT;
+ %PYARG_0 = PyDateTime_FromDateAndTime(date.year(), date.month(), date.day(), time.hour(), time.minute(), time.second(), time.msec()*1000);
+ </inject-code>
+ </add-function>
+ </value-type>
+ <value-type name="QDir">
+ <enum-type name="Filter" flags="Filters"/>
+ <enum-type name="SortFlag" flags="SortFlags" />
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code">
+ <replace from="%REDUCE_FORMAT" to="s" />
+ <replace from="%REDUCE_ARGS" to="qPrintable(%CPPSELF.path())" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ <value-type name="QPoint" hash-function="PySide::hash">
+ <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" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" />
+ </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="ii" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <inject-code class="native" position="beginning">
+ namespace PySide {
+ template&lt;&gt; inline uint hash(const QPoint&amp; v) {
+ return qHash(qMakePair(v.x(), v.y()));
+ }
+ };
+ </inject-code>
+
+ <add-function signature="toTuple" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="to_tuple">
+ <replace from="%TT_FORMAT" to="ii" />
+ <replace from="%TT_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <!--### Functions removed because they return references to Python imutable objects -->
+ <modify-function signature="rx()" remove="all"/>
+ <modify-function signature="ry()" remove="all"/>
+ <!--### -->
+ </value-type>
+ <value-type name="QPointF">
+ <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" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" />
+ </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="dd" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="toTuple" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="to_tuple">
+ <replace from="%TT_FORMAT" to="dd" />
+ <replace from="%TT_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <!--### Functions removed because they return references to Python imutable objects -->
+ <modify-function signature="rx()" remove="all"/>
+ <modify-function signature="ry()" remove="all"/>
+ <!--### -->
+ </value-type>
+ <value-type name="QRect" hash-function="PySide::hash">
+ <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.x(), %CPPSELF.y(), %CPPSELF.width(), %CPPSELF.height()" />
+ </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="iiii" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.width(), %CPPSELF.height()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <inject-code class="native" position="beginning">
+ namespace PySide {
+ template&lt;&gt; inline uint hash(const QRect&amp; v) {
+ return qHash(qMakePair(qMakePair(v.x(), v.y()), qMakePair(v.width(), v.height())));
+ }
+ };
+ </inject-code>
+
+ <modify-function signature="getCoords(int*,int*,int*,int*)const">
+ <modify-argument index="return">
+ <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">
+ <insert-template name="fix_number*,number*,number*,number*">
+ <replace from="$TYPE" to="int" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getRect(int*,int*,int*,int*)const">
+ <modify-argument index="return">
+ <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">
+ <insert-template name="fix_number*,number*,number*,number*">
+ <replace from="$TYPE" to="int" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ </value-type>
+ <value-type name="QRectF">
+ <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" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.width(), %CPPSELF.height()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <!--
+ FIXME These functions return qreal. Will convert to double (format
+ string) mess things up in other architectures?
+ -->
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code">
+ <replace from="%REDUCE_FORMAT" to="dddd" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.width(), %CPPSELF.height()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <modify-function signature="getCoords(qreal*,qreal*,qreal*,qreal*)const">
+ <modify-argument index="return">
+ <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">
+ <insert-template name="fix_number*,number*,number*,number*">
+ <replace from="$TYPE" to="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getRect(qreal*,qreal*,qreal*,qreal*)const">
+ <modify-argument index="return">
+ <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">
+ <insert-template name="fix_number*,number*,number*,number*">
+ <replace from="$TYPE" to="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ </value-type>
+ <value-type name="QSize" hash-function="PySide::hash">
+ <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" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.width(), %CPPSELF.height()" />
+ </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="ii" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.width(), %CPPSELF.height()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <inject-code class="native" position="beginning">
+ namespace PySide {
+ template&lt;&gt; inline uint hash(const QSize&amp; v) {
+ return qHash(qMakePair(v.width(), v.height()));
+ }
+ };
+ </inject-code>
+
+ <add-function signature="toTuple" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="to_tuple">
+ <replace from="%TT_FORMAT" to="ii" />
+ <replace from="%TT_ARGS" to="%CPPSELF.width(), %CPPSELF.height()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <!--### Functions removed because they return references to Python imutable objects -->
+ <modify-function signature="rheight()" remove="all"/>
+ <modify-function signature="rwidth()" remove="all"/>
+ <!--### -->
+ </value-type>
+ <value-type name="QSizeF">
+ <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" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.width(), %CPPSELF.height()" />
+ </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="dd" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.width(), %CPPSELF.height()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="toTuple" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="to_tuple">
+ <replace from="%TT_FORMAT" to="dd" />
+ <replace from="%TT_ARGS" to="%CPPSELF.width(), %CPPSELF.height()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <!--### Functions removed because they return references to Python imutable objects -->
+ <modify-function signature="rheight()" remove="all" />
+ <modify-function signature="rwidth()" remove="all" />
+ <!--### -->
+ </value-type>
+
+ <value-type name="QTime" hash-function="PySide::hash">
+ <inject-code class="native" position="beginning">
+ <insert-template name="pydatetime_importandcheck_function">
+ <replace from="$DATETIMETYPE" to="PyTime" />
+ </insert-template>
+ </inject-code>
+ <conversion-rule>
+ <target-to-native>
+ <add-conversion type="Py_None">
+ %out = %OUTTYPE();
+ </add-conversion>
+ <add-conversion type="PyTime" check="PyDateTime_ImportAndCheck(%in)">
+ int hour = PyDateTime_TIME_GET_HOUR(%in);
+ int min = PyDateTime_TIME_GET_MINUTE(%in);
+ int sec = PyDateTime_TIME_GET_SECOND(%in);
+ int usec = PyDateTime_TIME_GET_MICROSECOND(%in);
+ %out = %OUTTYPE(hour, min, sec, usec/1000);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+
+ <extra-includes>
+ <include file-name="datetime.h" 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="%i, %i, %i, %i" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.hour(), %CPPSELF.minute(), %CPPSELF.second(), %CPPSELF.msec()" />
+ </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="iiii" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.hour(), %CPPSELF.minute(), %CPPSELF.second(), %CPPSELF.msec()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="toPython()" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ if (!PyDateTimeAPI) PySideDateTime_IMPORT;
+ %PYARG_0 = PyTime_FromTime(%CPPSELF.hour(), %CPPSELF.minute(), %CPPSELF.second(), %CPPSELF.msec()*1000);
+ </inject-code>
+ </add-function>
+ </value-type>
+ <value-type name="QPersistentModelIndex" hash-function="qHash">
+ <modify-function signature="internalPointer()const">
+ <inject-code class="target" position="beginning">
+ <insert-template name="return_internal_pointer" />
+ </inject-code>
+ </modify-function>
+ <modify-function signature="operator const QModelIndex&amp;()const">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+
+ <!-- FIXME QT5: Remove QUuid because cyclic dependency found on overloaddata QUuid(),
+ this lead to cyclic dependency in <<(QDataStream &, QUUid) and incorrect QDataStream code generation (Windows only)-->
+ <!-- <value-type name="QUuid">
+ <enum-type name="Variant"/>
+ <enum-type name="Version"/>
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="repr_code">
+ <replace from="%REPR_FORMAT" to="'%s'" />
+ <replace from="%REPR_ARGS" to="qPrintable(%CPPSELF.toString())" />
+ </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="s" />
+ <replace from="%REDUCE_ARGS" to="qPrintable(%CPPSELF.toString())" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ </value-type> -->
+
+ <value-type name="QMimeType" since="5.0" />
+ <object-type name="QMimeDatabase" since="5.0">
+ <enum-type name="MatchMode" />
+ </object-type>
+
+ <value-type name="QLocale">
+ <enum-type name="Country" />
+ <enum-type name="FloatingPointPrecisionOption" since="5.7"/>
+ <enum-type name="FormatType"/>
+ <enum-type name="Language" />
+ <enum-type name="MeasurementSystem"/>
+ <enum-type name="NumberOption" flags="NumberOptions"/>
+ <enum-type name="Script" since="4.8" revision="4800"/>
+ <enum-type name="CurrencySymbolFormat" since="4.8" revision="4800"/>
+ <enum-type name="QuotationStyle" since="4.8" revision="4800"/>
+ <!--### All those C++ number types have the same representation in Python -->
+ <modify-function signature="toString(qulonglong) const" remove="all"/>
+ <modify-function signature="toString(ushort) const" remove="all"/>
+ <modify-function signature="toString(unsigned int) const" remove="all"/>
+ <!--### -->
+ <extra-includes>
+ <include file-name="QDate" location="global"/>
+ </extra-includes>
+ <modify-function signature="toTime(QString, QLocale::FormatType)const">
+ <modify-argument index="2">
+ <rename to="format" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="toDate(QString, QLocale::FormatType)const">
+ <modify-argument index="2">
+ <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 />
+ <remove-default-expression />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(int, bool ok)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <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 />
+ <remove-default-expression />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(int, bool ok)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <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 />
+ <remove-default-expression />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(float, bool ok)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <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 />
+ <remove-default-expression />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(float, bool ok)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <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 />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(int, bool ok)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <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 />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(int, bool ok)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <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 />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(int, bool ok)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <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 />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(int, bool ok)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_args,bool*" />
+ </inject-code>
+ </modify-function>
+ </value-type>
+ <value-type name="QBitArray" hash-function="qHash" >
+ <add-function signature="__len__">
+ <inject-code class="target" position="beginning">
+ return %CPPSELF.size();
+ </inject-code>
+ </add-function>
+ <add-function signature="__getitem__">
+ <inject-code class="target" position="beginning">
+ if (_i &lt; 0 || _i >= %CPPSELF.size()) {
+ PyErr_SetString(PyExc_IndexError, "index out of bounds");
+ return 0;
+ }
+ bool ret = %CPPSELF.at(_i);
+ return %CONVERTTOPYTHON[bool](ret);
+ </inject-code>
+ </add-function>
+ <add-function signature="__setitem__">
+ <inject-code class="target" position="beginning">
+ PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value);
+ PyObject* result = Sbk_QBitArrayFunc_setBit(self, args);
+ Py_DECREF(args);
+ Py_XDECREF(result);
+ return !result ? -1 : 0;
+ </inject-code>
+ </add-function>
+ </value-type>
+ <value-type name="QStorageInfo"/>
+ <!-- QReadWriteLock does not have a copy ctor! -->
+ <object-type name="QReadWriteLock">
+ <enum-type name="RecursionMode"/>
+ <modify-function signature="lockForRead()" allow-thread="yes"/>
+ <modify-function signature="tryLockForRead(int)" allow-thread="yes"/>
+ <modify-function signature="lockForWrite()" allow-thread="yes"/>
+ <modify-function signature="tryLockForWrite(int)" allow-thread="yes"/>
+ </object-type>
+ <object-type name="QReadLocker">
+ <modify-function signature="QReadLocker(QReadWriteLock*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="relock()" allow-thread="yes" />
+ <add-function signature="__enter__()" />
+ <add-function signature="__exit__(PyObject*, PyObject*, PyObject*)">
+ <inject-code>
+ %CPPSELF.unlock();
+ </inject-code>
+ </add-function>
+ </object-type>
+ <object-type name="QWriteLocker">
+ <modify-function signature="QWriteLocker(QReadWriteLock*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="relock()" allow-thread="yes" />
+ <add-function signature="__enter__()" />
+ <add-function signature="__exit__(PyObject*, PyObject*, PyObject*)">
+ <inject-code>
+ %CPPSELF.unlock();
+ </inject-code>
+ </add-function>
+ </object-type>
+ <object-type name="QDirIterator">
+ <enum-type name="IteratorFlag" flags="IteratorFlags"/>
+ </object-type>
+ <object-type name="QThread">
+ <enum-type name="Priority"/>
+ <modify-function signature="run()" thread="yes" />
+ <modify-function signature="exec()" rename="exec_" allow-thread="yes" />
+ <modify-function signature="msleep(unsigned long)" allow-thread="yes" />
+ <modify-function signature="sleep(unsigned long)" allow-thread="yes" />
+ <modify-function signature="usleep(unsigned long)" allow-thread="yes" />
+ <modify-function signature="wait(unsigned long)" allow-thread="yes" />
+ <modify-function signature="start(QThread::Priority)" allow-thread="yes">
+ <modify-argument index="1">
+ <rename to="priority"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="exit(int)" allow-thread="yes" />
+ </object-type>
+
+ <object-type name="QAbstractItemModel">
+ <enum-type name="LayoutChangeHint" />
+ <!-- This function was replaced by a added function -->
+ <modify-function signature="createIndex(int, int, 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">
+ <replace-default-expression with="0" />
+ </modify-argument>
+ </modify-function>
+ <add-function signature="createIndex(int, int, PyObject*)const" return-type="QModelIndex">
+ <modify-argument index="1">
+ <rename to="row"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <rename to="column"/>
+ </modify-argument>
+ <modify-argument index="3">
+ <rename to="ptr"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1, %2, %PYARG_3);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ <inject-documentation mode="append" format="target">
+ Creates a model index for the given row and column with the internal pointer ptr.
+ When using a QSortFilterProxyModel, its indexes have their own internal pointer. It is not advisable to access this internal pointer outside of the model. Use the data() function instead.
+ This function provides a consistent interface that model subclasses must use to create model indexes.
+
+ .. warning:: Because of some Qt/Python itegration rules, the ptr argument do not get the reference incremented during the QModelIndex life time. So it is necessary to keep the object used on ptr argument alive during the whole process. Do not destroy the object if you are not sure about that.
+ </inject-documentation>
+ </add-function>
+ <inject-code class="target" position="end">
+ qRegisterMetaType&lt;QVector&lt;int&gt; &gt;("QVector&lt;int&gt;");
+ </inject-code>
+ <modify-function signature="mimeData(QModelIndexList) const">
+ <modify-argument index="return">
+ <define-ownership class="native" owner="c++"/>
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="data(const QModelIndex&amp;,int) const">
+ <modify-argument index="return">
+ <define-ownership class="native" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <value-type name="QItemSelection">
+ <include file-name="QList" location="global"/>
+ </value-type>
+
+ <object-type name="QItemSelectionModel">
+ <extra-includes>
+ <include file-name="QItemSelection" location="global"/>
+ </extra-includes>
+ <enum-type name="SelectionFlag" flags="SelectionFlags"/>
+ </object-type>
+
+ <value-type name="QItemSelectionRange" hash-function="qHash">
+ </value-type>
+ <primitive-type name="QModelIndexList"/>
+ <object-type name="QAbstractProxyModel" polymorphic-id-expression="qobject_cast&lt;QAbstractProxyModel*&gt;(%1)">
+ <extra-includes>
+ <include file-name="QItemSelection" location="global"/>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ <modify-function signature="setSourceModel(QAbstractItemModel *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QSortFilterProxyModel">
+ <!-- ### This reimplementation of "QObject::parent()" is used in C++ only
+ when "using QObject::parent;" is not available. It's useless in Python. -->
+ <modify-function signature="parent()const" remove="all"/>
+ <extra-includes>
+ <include file-name="QItemSelection" location="global"/>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ <modify-function signature="setSourceModel(QAbstractItemModel *)">
+ <modify-argument index="1">
+ <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>
+ <!-- QObject is created manually -->
+ <object-type name="QObject">
+ <extra-includes>
+ <include file-name="QThread" location="global"/>
+ <include file-name="QCoreApplication" location="global"/>
+ <include file-name="signalmanager.h" location="local" />
+ </extra-includes>
+ <modify-function signature="metaObject() const">
+ <inject-code class="target" position="beginning">
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME();
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ <modify-argument index="return">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="deleteLater()">
+ <modify-argument index="this">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ <!-- Invalidate-after-use stuff -->
+ <modify-function signature="childEvent(QChildEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="customEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="event(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="eventFilter(QObject*,QEvent*)">
+ <modify-argument index="2" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="timerEvent(QTimerEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <!-- End of Invalidate-after-use fix -->
+ <modify-function signature="parent() const">
+ <modify-argument index="this">
+ <parent index="return" action="add"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setParent(QObject*)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="connect(const QObject*, const char*, const char *, Qt::ConnectionType) const">
+ <modify-argument index="4">
+ <rename to="type"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning" file="">
+ // %FUNCTION_NAME() - disable generation of function call.
+ bool %0 = qobjectConnect(%1, %2, %CPPSELF, %3, %4);
+ %PYARG_0 = %CONVERTTOPYTHON[bool](%0);
+ </inject-code>
+ </modify-function>
+ <!-- static version -->
+ <modify-function signature="connect(const QObject*, QMetaMethod, const QObject*, QMetaMethod, Qt::ConnectionType)">
+ <modify-argument index="5">
+ <rename to="type"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning" file="">
+ // %FUNCTION_NAME() - disable generation of function call.
+ bool %0 = qobjectConnect(%1, %2, %3, %4, %5);
+ %PYARG_0 = %CONVERTTOPYTHON[bool](%0);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="connect(const QObject*, const char*, const QObject*, const char *, Qt::ConnectionType)">
+ <modify-argument index="5">
+ <rename to="type"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ // %FUNCTION_NAME() - disable generation of function call.
+ bool %0 = qobjectConnect(%1, %2, %3, %4, %5);
+ %PYARG_0 = %CONVERTTOPYTHON[bool](%0);
+ </inject-code>
+ </modify-function>
+ <inject-code class="native" position="beginning" file="glue/qobject_connect.cpp" />
+ <add-function signature="connect(const QObject*, const char*, PyCallable*, Qt::ConnectionType)" return-type="bool" static="yes">
+ <modify-argument index="4">
+ <rename to="type"/>
+ <replace-default-expression with="Qt::AutoConnection" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ // %FUNCTION_NAME() - disable generation of function call.
+ %RETURN_TYPE %0 = qobjectConnectCallback(%1, %2, %PYARG_3, %4);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ <!-- static version -->
+ <add-function signature="connect(const char*, PyCallable*, Qt::ConnectionType)" return-type="bool">
+ <modify-argument index="3">
+ <rename to="type"/>
+ <replace-default-expression with="Qt::AutoConnection" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ // %FUNCTION_NAME() - disable generation of function call.
+ %RETURN_TYPE %0 = qobjectConnectCallback(%CPPSELF, %1, %PYARG_2, %3);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ <add-function signature="connect(const char*, const QObject*, const char *, Qt::ConnectionType)" return-type="bool">
+ <modify-argument index="4">
+ <rename to="type"/>
+ <replace-default-expression with="Qt::AutoConnection" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ // %FUNCTION_NAME() - disable generation of function call.
+ %RETURN_TYPE %0 = qobjectConnect(%CPPSELF, %1, %2, %3, %4);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+
+ <add-function signature="emit(const char*, ...)" return-type="bool">
+ <inject-code class="target" position="beginning">
+ %RETURN_TYPE %0 = PySide::SignalManager::instance().emitSignal(%CPPSELF, %1, %PYARG_2);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ <add-function signature="disconnect(const char *, PyCallable*)" return-type="bool">
+ <inject-code class="target" position="beginning">
+ // %FUNCTION_NAME() - disable generation of function call.
+ %RETURN_TYPE %0 = qobjectDisconnectCallback(%CPPSELF, %1, %2);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ <add-function signature="disconnect(const QObject*, const char*, PyCallable*)" return-type="bool" static="yes">
+ <inject-code class="target" position="beginning">
+ // %FUNCTION_NAME() - disable generation of function call.
+ %RETURN_TYPE %0 = qobjectDisconnectCallback(%1, %2, %3);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+
+
+ <inject-code class="native" file="glue/qobject_findchild.cpp"/>
+ <add-function signature="findChild(PyTypeObject*, const QString&amp;)" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ QObject* child = _findChildHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1);
+ %PYARG_0 = %CONVERTTOPYTHON[QObject*](child);
+ </inject-code>
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <replace-default-expression with="QString()" />
+ </modify-argument>
+ </add-function>
+ <add-function signature="findChildren(PyTypeObject*, const QString&amp;)" return-type="PySequence*" >
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = PyList_New(0);
+ _findChildrenHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1, %PYARG_0);
+ </inject-code>
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <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">
+ %PYARG_0 = PyList_New(0);
+ _findChildrenHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1, %PYARG_0);
+ </inject-code>
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </add-function>
+
+ <add-function signature="tr(const char *, const char *, int)" return-type="QString">
+ <modify-argument index="2">
+ <replace-default-expression with="0"/>
+ </modify-argument>
+ <modify-argument index="3">
+ <replace-default-expression with="-1"/>
+ </modify-argument>
+
+ <inject-code class="target" position="beginning">
+ QString result;
+ if (QCoreApplication::instance()) {
+ PyObject *klass = PyObject_GetAttrString(%PYSELF, "__class__");
+ PyObject *cname = PyObject_GetAttrString(klass, "__name__");
+ result = QString(QCoreApplication::instance()->translate(Shiboken::String::toCString(cname),
+ /* %1, %2, QCoreApplication::CodecForTr, %3)); */
+ %1, %2, %3));
+
+ Py_DECREF(klass);
+ Py_DECREF(cname);
+ } else {
+ result = QString(QString::fromLatin1(%1));
+ }
+ %PYARG_0 = %CONVERTTOPYTHON[QString](result);
+ </inject-code>
+ </add-function>
+
+ <modify-function signature="receivers(const char*) const">
+ <inject-code class="target" position="beginning">
+ // Avoid return +1 because SignalManager connect to "destroyed()" signal to control object timelife
+ int ret = %CPPSELF.%FUNCTION_NAME(%1);
+ if (ret > 0 &amp;&amp; ((strcmp(%1, SIGNAL(destroyed())) == 0) || (strcmp(%1, SIGNAL(destroyed(QObject*))) == 0)))
+ ret -= PySide::SignalManager::instance().countConnectionsWith(%CPPSELF);
+
+ %PYARG_0 = %CONVERTTOPYTHON[int](ret);
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="destroyed(QObject*)">
+ <modify-argument index="1">
+ <rename to="object"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="sender() const">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+
+ <!-- This is not supported due the lack of information durring the call with no arguments, this can cause a memory leak -->
+ <modify-function signature="disconnect(const char*, const QObject *, const char *)const">
+ <modify-argument index="1">
+ <remove-default-expression />
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-default-expression />
+ </modify-argument>
+ <modify-argument index="3">
+ <remove-default-expression />
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QAbstractListModel" polymorphic-id-expression="qobject_cast&lt;QAbstractListModel*&gt;(%1)">
+ <extra-includes>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ </object-type>
+ <value-type name="QUrl" hash-function="PySide::hash">
+ <!-- Qt5: lots of changes -->
+ <enum-type name="ComponentFormattingOption" flags="ComponentFormattingOptions,FormattingOptions"/>
+ <!-- note: above duplication of attribute is not by default XML compliant! -->
+ <enum-type name="UrlFormattingOption" />
+ <enum-type name="UserInputResolutionOption" flags="UserInputResolutionOptions"/>
+ <enum-type name="ParsingMode"/>
+ <modify-documentation xpath='description/para[3]'>
+ &lt;para>URLs can be represented in two forms: encoded or unencoded. The unencoded representation is suitable for showing to users, but the encoded representation is typically what you would send to a web server. For example, the unencoded URL &quot;http://bühler.example.com&quot; would be sent to the server as &quot;http://xn--bhler-kva.example.com/List%20of%20applicants.xml&quot;.&lt;/para>
+ </modify-documentation>
+ <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'" />
+ <replace from="%REPR_ARGS" to="qPrintable(%CPPSELF.toString())" />
+ </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="s" />
+ <replace from="%REDUCE_ARGS" to="qPrintable(%CPPSELF.toString())" />
+ </insert-template>
+ </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">
+ %1.replace(*%CPPSELF, %2);
+ %PYARG_0 = %CONVERTTOPYTHON[QString](%1);
+ </inject-code>
+ </add-function>
+ </value-type>
+ <value-type name="QFileInfo">
+ <extra-includes>
+ <include file-name="QDateTime" location="global"/>
+ <include file-name="QDir" location="global"/>
+ </extra-includes>
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code">
+ <replace from="%REDUCE_FORMAT" to="s" />
+ <replace from="%REDUCE_ARGS" to="qPrintable(%CPPSELF.filePath())" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ </value-type>
+ <value-type name="QByteArray" hash-function="qHash">
+ <enum-type name="Base64Option" flags="Base64Options" since="5.2"/>
+ <conversion-rule>
+ <target-to-native>
+ <add-conversion type="Py_None">
+ %out = %OUTTYPE();
+ </add-conversion>
+ <add-conversion type="PyString" check="Shiboken::String::check(%in)">
+ %out = %OUTTYPE(Shiboken::String::toCString(%in), Shiboken::String::len(%in));
+ </add-conversion>
+ <add-conversion type="PyBytes">
+ #ifdef IS_PY3K
+ %out = %OUTTYPE(PyBytes_AS_STRING(%in), PyBytes_GET_SIZE(%in));
+ #endif
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+
+ <extra-includes>
+ <!-- qt5: this is a pre-defined macro <include file-name="QNoImplicitBoolCast" location="global"/> -->
+ </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+(PyUnicode)">
+ <inject-code>
+ Shiboken::AutoDecRef str(PyUnicode_AsASCIIString(%PYARG_1));
+ if (!str.isNull()) {
+ QByteArray b(PyBytes_AS_STRING(str.object()), PyBytes_GET_SIZE (str.object()));
+ b.prepend(*%CPPSELF);
+ %PYARG_0 = %CONVERTTOPYTHON[QByteArray](b);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+(PyUnicode, QByteArray)">
+ <inject-code>
+ Shiboken::AutoDecRef str(PyUnicode_AsASCIIString(%PYARG_1));
+ if (!str.isNull()) {
+ QByteArray b(PyBytes_AS_STRING(str.object()), PyBytes_GET_SIZE(str.object()));
+ b.append(*%CPPSELF);
+ %PYARG_0 = %CONVERTTOPYTHON[QByteArray](b);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+(PyBytes, QByteArray)">
+ <inject-code>
+ QByteArray ba = QByteArray(PyBytes_AS_STRING(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1)) + *%CPPSELF;
+ %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba);
+ </inject-code>
+ </add-function>
+ <!-- ### -->
+
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ QByteArray b(((PyObject*)%PYSELF)->ob_type->tp_name);
+ PyObject* aux = Shiboken::String::fromStringAndSize(%CPPSELF.constData(), %CPPSELF.size());
+ if (PyUnicode_CheckExact(aux)) {
+ PyObject* tmp = PyUnicode_AsASCIIString(aux);
+ Py_DECREF(aux);
+ aux = tmp;
+ }
+ b += "('";
+ b += QByteArray(PyBytes_AS_STRING(aux), PyBytes_GET_SIZE(aux));
+ b += "')";
+ %PYARG_0 = Shiboken::String::fromStringAndSize(b.constData(), b.size());
+ </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="N" />
+ <replace from="%REDUCE_ARGS" to="PyBytes_FromStringAndSize(%CPPSELF.constData(), %CPPSELF.size())" />
+ </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">
+ if (PyBytes_Check(%PYARG_1)) {
+ %0 = new QByteArray(PyBytes_AsString(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1));
+ } else if (PyUnicode_CheckExact(%PYARG_1)) {
+ Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1));
+ %0 = new QByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object()));
+ } else if (Shiboken::String::check(%PYARG_1)) {
+ %0 = new QByteArray(Shiboken::String::toCString(%PYARG_1), Shiboken::String::len(%PYARG_1));
+ }
+ </inject-code>
+ </modify-function>
+ <!-- buffer protocol -->
+ <inject-code class="native" position="beginning" file="glue/qbytearray_bufferprotocol.cpp" />
+ <inject-code class="target" position="end">
+ #if PY_VERSION_HEX &lt; 0x03000000
+ Shiboken::SbkType&lt;QByteArray>()->tp_as_buffer = &amp;SbkQByteArrayBufferProc;
+ Shiboken::SbkType&lt;QByteArray>()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER;
+ #endif
+ </inject-code>
+
+ <modify-function signature="data()">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = PyBytes_FromStringAndSize(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.size());
+ </inject-code>
+ </modify-function>
+
+ <!-- removed functions -->
+ <!--### Functions removed because they return STL-like iterators -->
+ <modify-function signature="begin()" remove="all"/>
+ <modify-function signature="begin()const" remove="all"/>
+ <modify-function signature="constBegin()const" remove="all"/>
+ <modify-function signature="constData()const" remove="all"/>
+ <modify-function signature="constEnd()const" remove="all"/>
+ <modify-function signature="end()" remove="all"/>
+ <modify-function signature="end()const" remove="all"/>
+ <!--### -->
+
+ <!--### Functions removed because they provide useless overloads from Python point of view -->
+ <modify-function signature="number(uint,int)" remove="all"/>
+ <modify-function signature="number(qulonglong,int)" remove="all"/>
+ <modify-function signature="operator+=(const char*)" remove="all"/>
+ <modify-function signature="operator==(const char*,QByteArray)" remove="all" />
+ <modify-function signature="operator!=(const char*,QByteArray)" remove="all" />
+ <modify-function signature="operator&lt;(const char*,QByteArray)" remove="all" />
+ <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. -->
+ <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(qulonglong,int)" remove="all"/>
+
+ <!--### -->
+
+ <modify-function signature="operator const char *()const" remove="all"/>
+ <modify-function signature="operator const void *()const" remove="all"/>
+
+ <!--### STL compatibility functions not supported by PySide -->
+ <modify-function signature="push_back(char)" remove="all"/>
+ <modify-function signature="push_back(const QByteArray&amp;)" remove="all"/>
+ <modify-function signature="push_back(const char*)" remove="all"/>
+ <modify-function signature="push_front(char)" remove="all"/>
+ <modify-function signature="push_front(const QByteArray&amp;)" remove="all"/>
+ <modify-function signature="push_front(const char*)" remove="all"/>
+ <!--### -->
+
+ <modify-function signature="toLong(bool*, int) const">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_bool*,arg"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="toLongLong(bool*, int) const">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_bool*,arg"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="toShort(bool*, int) const">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_bool*,arg"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="toUInt(bool*, int) const">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_bool*,arg"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="toULong(bool*, int) const">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_bool*,arg"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="toULongLong(bool*, int) const">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_bool*,arg"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="toInt(bool*,int)const">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_bool*,arg"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="toUShort(bool*,int)const">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_bool*,arg"/>
+ </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">
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(PyBytes_AsString(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1));
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="toDouble(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>
+ <modify-function signature="toFloat(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>
+ <add-function signature="__str__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = Shiboken::String::fromStringAndSize(%CPPSELF.constData(), %CPPSELF.size());
+ </inject-code>
+ </add-function>
+ <add-function signature="__len__">
+ <inject-code class="target" position="beginning">
+ return %CPPSELF.count();
+ </inject-code>
+ </add-function>
+ <add-function signature="__getitem__">
+ <inject-code class="target" position="beginning">
+ if (_i &lt; 0 || _i >= %CPPSELF.size()) {
+ PyErr_SetString(PyExc_IndexError, "index out of bounds");
+ return 0;
+ } else {
+ char res[2];
+ res[0] = %CPPSELF.at(_i);
+ res[1] = 0;
+ return PyBytes_FromStringAndSize(res, 1);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="__setitem__">
+ <inject-code class="target" position="beginning">
+ %CPPSELF.remove(_i, 1);
+ PyObject* args = Py_BuildValue("(nO)", _i, _value);
+ PyObject* result = Sbk_QByteArrayFunc_insert(self, args);
+ Py_DECREF(args);
+ Py_XDECREF(result);
+ return !result ? -1 : 0;
+ </inject-code>
+ </add-function>
+ <add-function signature="__getslice__">
+ <inject-code class="target" position="beginning">
+ Py_ssize_t max = %CPPSELF.count();
+ _i1 = qBound(Py_ssize_t(0), _i1, max);
+ _i2 = qBound(Py_ssize_t(0), _i2, max);
+ QByteArray ba;
+ if (_i1 &lt; _i2)
+ ba = %CPPSELF.mid(_i1, _i2 - _i1);
+ return %CONVERTTOPYTHON[QByteArray](ba);
+ </inject-code>
+ </add-function>
+ </value-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"/>
+ </value-type>
+ <object-type name="QXmlStreamEntityResolver"/>
+
+ <!-- Qt5: had to move QAbstractEventDispatcher into os-specific files because of Windows -->
+
+ <object-type name="QEventLoop">
+ <enum-type name="ProcessEventsFlag" flags="ProcessEventsFlags"/>
+ <modify-function signature="exec(QFlags&lt;QEventLoop::ProcessEventsFlag>)" rename="exec_" allow-thread="yes" />
+ <modify-function signature="processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag>)" allow-thread="yes" />
+ <modify-function signature="processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag>, int)" allow-thread="yes" />
+ </object-type>
+ <object-type name="QFileDevice" since="5.0">
+ <enum-type name="FileError"/>
+ <enum-type name="MemoryMapFlags"/>
+ <enum-type name="Permission" flags="Permissions"/>
+ <enum-type name="FileHandleFlag" flags="FileHandleFlags"/>
+ <extra-includes>
+ <!-- Qt5: private <include file-name="QAbstractFileEngine" location="global"/> -->
+ </extra-includes>
+ <modify-function signature="unmap(uchar*)">
+ <modify-argument index="1">
+ <replace-type modified-type="PyBuffer"/>
+ </modify-argument>
+ <inject-code>
+ uchar* ptr = (uchar*) Shiboken::Buffer::getPointer(%PYARG_1);
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(ptr);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="map(qint64,qint64,QFileDevice::MemoryMapFlags)">
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject"/>
+ </modify-argument>
+ <inject-code>
+ %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(%1, %2, %3), %2, Shiboken::Buffer::ReadWrite);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="flush()" allow-thread="yes"/>
+ </object-type>
+ <object-type name="QFile">
+ <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"/>
+ <modify-function signature="link(const QString&amp;, const QString&amp;)" allow-thread="yes"/>
+ <modify-function signature="remove()" allow-thread="yes"/>
+ <modify-function signature="remove(const QString&amp;)" allow-thread="yes"/>
+ <modify-function signature="rename(const QString&amp;)" allow-thread="yes"/>
+ <modify-function signature="rename(const QString&amp;, const QString&amp;)" allow-thread="yes"/>
+ </object-type>
+ <object-type name="QSaveFile"/>
+ <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="close()" allow-thread="yes"/>
+ <modify-function signature="seek(qint64)" allow-thread="yes"/>
+ <modify-function signature="readAll()" allow-thread="yes"/>
+ <modify-function signature="peek(qint64)" allow-thread="yes"/>
+ <modify-function signature="write(const QByteArray&amp;)" allow-thread="yes"/>
+ <modify-function signature="waitForReadyRead(int)" allow-thread="yes"/>
+ <modify-function signature="waitForBytesWritten(int)" allow-thread="yes"/>
+ <!-- ### peek(qint64) do the job -->
+ <modify-function signature="peek(char*, qint64)" remove="all"/>
+ <!-- ### read(qint64) do the job -->
+ <modify-function signature="read(char*, qint64)" remove="all"/>
+ <!-- ### readLine(qint64) do the job -->
+ <modify-function signature="readLine(char*, qint64)" remove="all"/>
+ <!-- ### write(str) do the job -->
+ <modify-function signature="write(const char*, qint64)" remove="all"/>
+ <modify-function signature="write(const char*)" remove="all"/>
+ <modify-function signature="getChar(char*)">
+ <modify-argument index="1">
+ <remove-argument />
+ <remove-default-expression />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_char*" />
+ </inject-code>
+ </modify-function>
+ <modify-function signature="readData(char*, qint64)">
+ <inject-code class="target">
+ QByteArray ba;
+ ba.resize(%2);
+ %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size());
+ %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba);
+ </inject-code>
+ <modify-argument index="1">
+ <remove-argument />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject"/>
+ <conversion-rule class="native">
+ %RETURN_TYPE %out = 0;
+ if (PyBytes_Check(%PYARG_0)) {
+ %out = PyBytes_GET_SIZE((PyObject*)%PYARG_0);
+ memcpy(%1, PyBytes_AS_STRING((PyObject*)%PYARG_0), %out);
+ } else if (Shiboken::String::check(%PYARG_0)) {
+ %out = Shiboken::String::len((PyObject*)%PYARG_0);
+ memcpy(%1, Shiboken::String::toCString((PyObject*)%PYARG_0), %out);
+ }
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="readLineData(char*, qint64)">
+ <inject-code class="target">
+ QByteArray ba;
+ ba.resize(%2);
+ %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size());
+ %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba);
+ </inject-code>
+ <modify-argument index="1">
+ <remove-argument />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject"/>
+ <conversion-rule class="native">
+ %RETURN_TYPE %out;
+ if (!PyBytes_Check(%PYARG_0)) {
+ %out = -1;
+ } else {
+ %out = PyBytes_GET_SIZE((PyObject*)%PYARG_0);
+ memcpy(%1, PyBytes_AS_STRING((PyObject*)%PYARG_0), %out);
+ }
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QCryptographicHash">
+ <enum-type name="Algorithm"/>
+ <modify-function signature="addData(const char*,int)">
+ <modify-argument index="2">
+ <remove-argument />
+ </modify-argument>
+ <inject-code>
+ %CPPSELF.%FUNCTION_NAME(Shiboken::String::toCString(%PYARG_1), Shiboken::String::len(%PYARG_1));
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QLibraryInfo">
+ <enum-type name="LibraryLocation"/>
+ </object-type>
+ <object-type name="QMutexLocker" copyable="no">
+ <modify-function signature="QMutexLocker(QBasicMutex*)" allow-thread="yes">
+ <modify-argument index="1">
+ <reference-count action="set" variable-name="mutex()const0"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="relock()" allow-thread="yes"/>
+ <modify-function signature="mutex() const">
+ <modify-argument index="return">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ <add-function signature="__enter__()" />
+ <add-function signature="__exit__(PyObject*, PyObject*, PyObject*)">
+ <inject-code>
+ %CPPSELF.unlock();
+ </inject-code>
+ </add-function>
+ </object-type>
+
+ <!-- Qt5 addition -->
+ <object-type name="QBasicMutex">
+ <modify-function signature="lock()" allow-thread="yes"/>
+ <modify-function signature="tryLock()" allow-thread="yes"/>
+ </object-type>
+
+ <object-type name="QMutex">
+ <enum-type name="RecursionMode"/>
+ <modify-function signature="lock()" allow-thread="yes"/>
+ <modify-function signature="tryLock(int)" allow-thread="yes"/>
+ </object-type>
+ <object-type name="QSemaphore">
+ <modify-function signature="acquire(int)" allow-thread="yes"/>
+ <modify-function signature="tryAcquire(int, int)" allow-thread="yes"/>
+ </object-type>
+
+ <object-type name="QSocketNotifier">
+ <enum-type name="Type"/>
+ <add-function signature="QSocketNotifier(PyObject*, QSocketNotifier::Type, QObject*)">
+ <modify-argument index="3">
+ <replace-default-expression with="0" />
+ <rename to="parent" />
+ </modify-argument>
+ <inject-code>
+ Shiboken::AutoDecRef fileNo(PyObject_GetAttrString(%PYARG_1, "fileno"));
+ if (!fileNo.isNull()) {
+ Shiboken::AutoDecRef fileNoValue(PyObject_CallObject(fileNo, 0));
+ if (%CHECKTYPE[int](fileNoValue)) {
+ int cppFileNoValue = %CONVERTTOCPP[int](fileNoValue);
+ /* Qt4 version:
+ * %0 = new %TYPE(cppFileNoValue, %2, %3);
+ * Qt5 has qintptr instead.
+ * XXX check if this means a pointer or just the pointer size cast (what I implemented)
+ */
+ qintptr socket = (qintptr)cppFileNoValue;
+ %0 = new %TYPE(socket, %2, %3);
+ }
+ }
+ </inject-code>
+ </add-function>
+ </object-type>
+
+ <object-type name="QTemporaryFile">
+ <extra-includes>
+ <!-- Qt5: private <include file-name="QAbstractFileEngine" location="global"/> -->
+ </extra-includes>
+ <modify-function signature="createLocalFile(const QString&amp;)" allow-thread="yes"/>
+ </object-type>
+ <object-type name="QTemporaryDir"/>
+ <object-type name="QMimeData">
+ <extra-includes>
+ <include file-name="QStringList" location="global"/>
+ <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>
+ <object-type name="QTranslator">
+ <modify-function signature="load(const uchar*, int, QString)">
+ <modify-argument index="1">
+ <replace-type modified-type="PyBuffer" />
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument />
+ </modify-argument>
+ <inject-code>
+ Py_ssize_t size;
+ uchar* ptr = (uchar*) Shiboken::Buffer::getPointer(%PYARG_1, &amp;size);
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(const_cast&lt;const uchar*>(ptr), size);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QWaitCondition">
+ <modify-function signature="wait(QMutex*, unsigned long)" allow-thread="yes"/>
+ <modify-function signature="wait(QReadWriteLock*, unsigned long)" allow-thread="yes"/>
+ </object-type>
+ <object-type name="QFileSystemWatcher">
+ <extra-includes>
+ <include file-name="QStringList" location="global"/>
+ </extra-includes>
+ </object-type>
+ <object-type name="QBuffer">
+ <!-- ### setData(QByteArray) do the job -->
+ <modify-function signature="setData(const char*,int)" remove="all"/>
+ </object-type>
+ <object-type name="QTimer">
+ <modify-function signature="singleShot(int,const QObject*,const char*)">
+ <inject-code class="target" position="beginning">
+ // %FUNCTION_NAME() - disable generation of c++ function call
+ (void) %2; // remove warning about unused variable
+ Shiboken::AutoDecRef emptyTuple(PyTuple_New(0));
+ PyObject* pyTimer = Shiboken::SbkType&lt;QTimer>()->tp_new(Shiboken::SbkType&lt;QTimer>(), emptyTuple, 0);
+ Shiboken::SbkType&lt;QTimer>()->tp_init(pyTimer, emptyTuple, 0);
+
+ QTimer* timer = %CONVERTTOCPP[QTimer*](pyTimer);
+ Shiboken::AutoDecRef result(
+ PyObject_CallMethod(pyTimer,
+ const_cast&lt;char*>("connect"),
+ const_cast&lt;char*>("OsOs"),
+ pyTimer,
+ SIGNAL(timeout()),
+ %PYARG_2,
+ %3)
+ );
+ Shiboken::Object::releaseOwnership((SbkObject*)pyTimer);
+ Py_XDECREF(pyTimer);
+ timer->setSingleShot(true);
+ timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()));
+ timer->start(%1);
+ </inject-code>
+ </modify-function>
+ <add-function signature="singleShot(int, PyCallable*)" static="yes">
+ <inject-code class="target" position="beginning">
+ // %FUNCTION_NAME() - disable generation of c++ function call
+ Shiboken::AutoDecRef emptyTuple(PyTuple_New(0));
+ PyObject *pyTimer = Shiboken::SbkType&lt;QTimer>()->tp_new(Shiboken::SbkType&lt;QTimer>(), emptyTuple, 0);
+ Shiboken::SbkType&lt;QTimer>()->tp_init(pyTimer, emptyTuple, 0);
+ QTimer* timer = %CONVERTTOCPP[QTimer*](pyTimer);
+ timer->setSingleShot(true);
+
+ if (PyObject_TypeCheck(%2, &amp;PySideSignalInstanceType)) {
+ PySideSignalInstance* signalInstance = reinterpret_cast&lt;PySideSignalInstance*&gt;(%2);
+ Shiboken::AutoDecRef signalSignature(Shiboken::String::fromFormat("2%s", PySide::Signal::getSignature(signalInstance)));
+ Shiboken::AutoDecRef result(
+ PyObject_CallMethod(pyTimer,
+ const_cast&lt;char*>("connect"),
+ const_cast&lt;char*>("OsOO"),
+ pyTimer,
+ SIGNAL(timeout()),
+ PySide::Signal::getObject(signalInstance),
+ signalSignature.object())
+ );
+ } else {
+ Shiboken::AutoDecRef result(
+ PyObject_CallMethod(pyTimer,
+ const_cast&lt;char*>("connect"),
+ const_cast&lt;char*>("OsO"),
+ pyTimer,
+ SIGNAL(timeout()),
+ %PYARG_2)
+ );
+ }
+
+ timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()), Qt::DirectConnection);
+ Shiboken::Object::releaseOwnership((SbkObject*)pyTimer);
+ Py_XDECREF(pyTimer);
+ timer->start(%1);
+ </inject-code>
+ </add-function>
+ </object-type>
+ <object-type name="QProcess">
+ <enum-type name="ExitStatus"/>
+ <enum-type name="InputChannelMode"/>
+ <enum-type name="ProcessChannel"/>
+ <enum-type name="ProcessChannelMode"/>
+ <enum-type name="ProcessError"/>
+ <enum-type name="ProcessState"/>
+
+ <modify-function signature="waitForStarted(int)" allow-thread="yes"/>
+ <modify-function signature="waitForBytesWritten(int)" allow-thread="yes"/>
+ <modify-function signature="waitForFinished(int)" allow-thread="yes"/>
+ <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 />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(retval, pid)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ qint64 pid;
+ %RETURN_TYPE retval = %TYPE::%FUNCTION_NAME(%1, %2, %3, &amp;pid);
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[qint64](pid));
+ </inject-code>
+ </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>
+ 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);
+ </inject-code>
+ </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" />
+
+ <object-type name="QCollatorSortKey" since="5.2" />
+ <object-type name="QCollator" since="5.2" />
+
+ <object-type name="QCommandLineOption" since="5.2">
+ <enum-type name="Flag" flags="Flags" since="5.8"/>
+ </object-type>
+ <object-type name="QCommandLineParser" since="5.2">
+ <enum-type name="OptionsAfterPositionalArgumentsMode" since="5.6"/>
+ <enum-type name="SingleDashWordOptionMode"/>
+ </object-type>
+
+ <object-type name="QCoreApplication">
+ <!--Qt5: gone <enum-type name="Encoding" /> -->
+ <enum-type identified-by-value="ApplicationFlags" since="4.8" revision="4800"/>
+ <extra-includes>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QTranslator" location="global"/>
+ </extra-includes>
+ <!-- constructor documentation -->
+ <inject-documentation format="target" mode="append">
+.. class:: QCoreApplication(args)
+
+ Constructs a Qt kernel application. Kernel applications are applications
+ without a graphical user interface. These type of applications are used
+ at the console or as server processes.
+
+ The *args* argument is processed by the application, and made available
+ in a more convenient form by the :meth:`~QCoreApplication.arguments()`
+ method.
+ </inject-documentation>
+ <add-function signature="QCoreApplication(PySequence)">
+ <inject-code>
+ QCoreApplication_constructor(%PYSELF, args, &amp;%0);
+ </inject-code>
+ </add-function>
+ <!-- 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()">
+ <inject-code class="target">
+ QCoreApplication* app = QCoreApplication::instance();
+ PyObject* pyApp = Py_None;
+ if (app) {
+ pyApp = reinterpret_cast&lt;PyObject*&gt;(Shiboken::BindingManager::instance().retrieveWrapper(app));
+ if (!pyApp)
+ pyApp = %CONVERTTOPYTHON[QCoreApplication*](app); // this will keep app live after python exit (extra ref)
+ }
+ %PYARG_0 = pyApp;
+ Py_XINCREF(%PYARG_0);
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="exec()" rename="exec_" allow-thread="yes"/>
+ <!-- ### Obsolete
+ <modify-function signature="argc()" remove="all"/>
+ <modify-function signature="argv()" remove="all"/>
+ -->
+ <modify-function signature="notify(QObject*,QEvent*)" allow-thread="yes">
+ <modify-argument index="2" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="QCoreApplication(int &amp;, char **)" access="private"/>
+ <inject-code class="native" file="glue/qcoreapplication_init.cpp" position="beginning" />
+ <modify-function signature="postEvent(QObject*,QEvent*, int)">
+ <modify-argument index="2">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="winEventFilter(MSG*, long*)">
+ <modify-argument index="2">
+ <remove-argument />
+ <conversion-rule class="native">
+ long *%out = new long;
+ %out = 0;
+ </conversion-rule>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject"/>
+ <conversion-rule class="native">
+ %RETURN_TYPE %out = false;
+ if (PySequence_Check(%PYARG_0) &amp;&amp; (PySequence_Size(%PYARG_0) == 2)) {
+ Shiboken::AutoDecRef pyResult(PySequence_GetItem(%PYARG_0, 0));
+ %out = %CONVERTTOCPP[bool](pyResult);
+ }
+ </conversion-rule>
+ </modify-argument>
+ <inject-code position="end">
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[long](*result_out));
+ delete result_out;
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QSettings">
+ <enum-type name="Format"/>
+ <enum-type name="Scope"/>
+ <enum-type name="Status"/>
+ <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>
+ <modify-function signature="value(const QString&amp;, const QVariant&amp;)const">
+ <inject-documentation mode="append" format="target">
+ .. warning:: QSettings.value can return different types (QVariant types) depending on the platform it's running on, so the safest way to use it is always casting the result to the desired type, e.g.: int(settings.value("myKey"))
+ </inject-documentation>
+ </modify-function>
+ </object-type>
+ <object-type name="QEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::None">
+ <enum-type name="Type" extensible="yes" />
+ </object-type>
+ <object-type name="QChildEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::ChildAdded || %1-&gt;type() == QEvent::ChildPolished || %1-&gt;type() == QEvent::ChildRemoved">
+ <modify-field name="c" read="false" write="false"/>
+ <modify-function signature="child() const">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QTimerEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::Timer" />
+ <object-type name="QDynamicPropertyChangeEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::DynamicPropertyChange" />
+
+ <template name="stream_read_method">
+ %RETURN_TYPE _cpp_result;
+ (*%CPPSELF) &gt;&gt; _cpp_result;
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](_cpp_result);
+ </template>
+
+ <template name="stream_write_method">
+ (*%CPPSELF) &lt;&lt; %1;
+ </template>
+
+ <object-type name="QDataStream" stream="yes">
+ <enum-type name="FloatingPointPrecision" since="4.6"/>
+ <enum-type name="Status"/>
+ <enum-type name="Version"/>
+ <enum-type name="ByteOrder"/>
+ <extra-includes>
+ <include file-name="QtCore/QtCore" location="global"/>
+ </extra-includes>
+
+ <modify-function signature="setDevice(QIODevice*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <!-- ### Replaced by write<TYPE> methods -->
+ <modify-function signature="operator&gt;&gt;(qint8&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(bool&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(quint8&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(qint16&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(quint16&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(qint32&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(quint32&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(qint64&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(quint64&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(float&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(double&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(char*&amp;)" remove="all"/>
+ <!-- ### -->
+
+ <!-- ### Replaced by read<TYPE> methods -->
+ <modify-function signature="operator&lt;&lt;(qint8)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(bool)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(quint8)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(qint16)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(quint16)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(qint32)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(quint32)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(qint64)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(quint64)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(float)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(double)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(const char*)" remove="all"/>
+ <!-- ### -->
+ <add-function signature="operator&lt;&lt;(const QString&amp;)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeQString(const QString&amp;)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readQString()" return-type="QString">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeQChar(const QChar&amp;)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readQChar()" return-type="QChar">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeQStringList(const QStringList&amp;)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readQStringList()" return-type="QStringList">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeQVariant(const QVariant&amp;)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readQVariant()" return-type="QVariant">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <modify-function signature="readRawData(char*,int)">
+ <modify-argument index="1">
+ <remove-argument />
+ </modify-argument>
+ <inject-code class="target">
+ QByteArray data;
+ data.resize(%2);
+ int result = %CPPSELF.%FUNCTION_NAME(data.data(), data.size());
+ if (result == -1) {
+ Py_INCREF(Py_None);
+ %PYARG_0 = Py_None;
+ } else {
+ %PYARG_0 = PyBytes_FromStringAndSize(data.data(), result);
+ }
+ </inject-code>
+ </modify-function>
+ <modify-function signature="writeRawData(const char*,int)">
+ <modify-argument index="2">
+ <remove-argument />
+ </modify-argument>
+ <inject-code class="target">
+ int r = %CPPSELF.%FUNCTION_NAME(%1, Shiboken::String::len(%PYARG_1));
+ %PYARG_0 = %CONVERTTOPYTHON[int](r);
+ </inject-code>
+ </modify-function>
+
+ <!-- Extra functions for primitive type handling -->
+ <add-function signature="readBool()" return-type="bool">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readInt8()" return-type="qint8">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readUInt8()" return-type="quint8">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readUInt16()" return-type="quint16">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readInt16()" return-type="qint16">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readInt32()" return-type="qint32">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readUInt32()" return-type="quint32">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readInt64()" return-type="qint64">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readUInt64()" return-type="quint64">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readFloat()" return-type="float">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readDouble()" return-type="qreal">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="readString()" return-type="QString">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_read_method"/>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="writeBool(bool)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeInt8(qint8)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeUInt8(quint8)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeUInt16(quint16)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeInt16(qint16)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeInt32(qint32)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeUInt32(quint32)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeInt64(qint64)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeUInt64(quint64)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeFloat(float)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeDouble(qreal)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="writeString(QString)">
+ <inject-code class="target" position="end">
+ <insert-template name="stream_write_method"/>
+ </inject-code>
+ </add-function>
+
+ <!-- ### deprecated method -->
+ <modify-function signature="readBytes(char*&amp;,uint&amp;)" remove="all"/>
+ <modify-function signature="writeBytes(const char*,uint)" remove="all" />
+ </object-type>
+
+ <value-type name="QTextStreamManipulator" default-constructor="QTextStreamManipulator(0, 0)">
+ <modify-function signature="exec(QTextStream &amp;)" rename="exec_"/>
+ </value-type>
+ <object-type name="QTextStream" stream="yes">
+ <enum-type name="FieldAlignment"/>
+ <enum-type name="NumberFlag" flags="NumberFlags"/>
+ <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"/>
+ <!-- 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"/>
+
+ <!-- Removed because it expect QString to be mutable -->
+ <modify-function signature="setString(QString*,QFlags&lt;QIODevice::OpenModeFlag&gt;)" remove="all"/>
+
+ <modify-function signature="operator&lt;&lt;(const void*)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(float)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(qlonglong)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(qulonglong)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(signed short)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(signed int)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(unsigned int)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(unsigned short)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(const char*)" remove="all"/>
+
+ <modify-function signature="operator&gt;&gt;(char*)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(char&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(float&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(double&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(qlonglong&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(qulonglong&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(signed long&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(signed int&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(signed short&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(unsigned long&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(unsigned int&amp;)" remove="all"/>
+ <modify-function signature="operator&gt;&gt;(unsigned short&amp;)" remove="all"/>
+ <!-- Removed because it expect QChar to be mutable -->
+ <modify-function signature="operator&gt;&gt;(QChar&amp;)" remove="all"/>
+ <!-- Removed because it expect QString to be mutable -->
+ <modify-function signature="operator&gt;&gt;(QString&amp;)" remove="all"/>
+
+ <modify-function signature="string()const">
+ <modify-argument index="return">
+ <!--<replace-type modified-type="QString" />-->
+ <conversion-rule class="target">
+ QString&amp; res = *%0;
+ %PYARG_0 = %CONVERTTOPYTHON[QString](res);
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="flush()" allow-thread="yes"/>
+ <modify-function signature="read(qint64)" allow-thread="yes"/>
+ <modify-function signature="readLine(qint64)" allow-thread="yes"/>
+ <modify-function signature="readAll()" allow-thread="yes"/>
+ </object-type>
+ <object-type name="QStandardPaths" since="5.0">
+ <enum-type name="StandardLocation"/>
+ <enum-type name="LocateOption" flags="LocateOptions"/>
+ </object-type>
+ <object-type name="QSystemSemaphore">
+ <enum-type name="AccessMode"/>
+ <enum-type name="SystemSemaphoreError"/>
+ </object-type>
+
+ <object-type name="QThreadPool">
+ <modify-function signature="start(QRunnable*, int)">
+ <modify-argument index="1">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="tryStart(QRunnable*)">
+ <modify-argument index="1">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="globalInstance()" >
+ <inject-code position="end">
+ Shiboken::Object::releaseOwnership(%PYARG_0);
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <value-type name="QXmlStreamAttribute"/>
+ <value-type name="QXmlStreamAttributes">
+ <modify-function signature="push_back(QXmlStreamAttribute)" remove="all"/>
+ <modify-function signature="pop_back()" remove="all"/>
+ <modify-function signature="push_front(QXmlStreamAttribute)" remove="all"/>
+ <modify-function signature="pop_front()" remove="all"/>
+ <modify-function signature="toList() 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" />
+ </value-type>
+ <value-type name="QXmlStreamNamespaceDeclaration"/>
+ <value-type name="QXmlStreamNotationDeclaration"/>
+ <value-type name="QXmlStreamEntityDeclaration"/>
+ <object-type name="QXmlStreamReader">
+ <enum-type name="Error"/>
+ <enum-type name="TokenType"/>
+ <enum-type name="ReadElementTextBehaviour" since="4.6"/>
+ </object-type>
+ <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">
+ <inject-code class="target" position="beginning">
+ <insert-template name="return_internal_pointer" />
+ </inject-code>
+ </modify-function>
+ <modify-function signature="model()const">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+
+ <value-type name="QGenericArgument">
+ <include file-name="qobjectdefs.h" location="global" />
+ </value-type>
+
+ <value-type name="QGenericReturnArgument">
+ <include file-name="qobjectdefs.h" location="global" />
+ </value-type>
+
+ <object-type name="QMessageLogContext">
+ <modify-function signature="copy(const QMessageLogContext &amp;)" remove="all" />
+ </object-type>
+
+ <value-type name="QMetaMethod">
+ <enum-type name="Access"/>
+ <enum-type name="MethodType"/>
+ <!-- This isn't part of Qt public API -->
+ <modify-function signature="attributes()const" remove="all" />
+ <modify-function signature="getParameterTypes(int *) const" remove="all" />
+ </value-type>
+ <object-type name="QMetaObject">
+ <enum-type name="Call"/>
+ <include file-name="qobjectdefs.h" location="global" />
+ <!-- This isn't part of Qt public API -->
+ <modify-function signature="connect(const QObject*, int, const QObject*, int, int, int*)" remove="all" />
+ </object-type>
+ <object-type name="QMetaObject::Connection">
+ <include file-name="qobjectdefs.h" location="global" />
+ </object-type>
+ <value-type name="QMetaProperty" >
+ <!-- This isn't part of Qt public API -->
+ <modify-function signature="enclosingMetaObject()const" remove="all" />
+ </value-type>
+ <value-type name="QMetaClassInfo">
+ <!-- This isn't part of Qt public API -->
+ <modify-function signature="enclosingMetaObject()const" remove="all" />
+ </value-type>
+
+ <value-type name="QMetaEnum">
+ <modify-function signature="keyToValue(const char*, bool*) const" allow-thread="yes">
+ <modify-argument index="2">
+ <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_args,bool*"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="keysToValue(const char*, bool*) const" allow-thread="yes">
+ <modify-argument index="2">
+ <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_args,bool*"/>
+ </inject-code>
+ </modify-function>
+ <!-- This isn't part of Qt public API -->
+ <modify-function signature="enclosingMetaObject()const" remove="all" />
+ <!-- Qt5.5: "template<typename T> static QMetaEnum fromType()" is not understood by the compiler.
+ We therefore ignore this 5.5 addition for now: -->
+ <modify-function signature="fromType()" since="5.5" remove="all" />
+ </value-type>
+
+ <!-- From Qt4.6 -->
+ <object-type name="QAbstractAnimation" since="4.6">
+ <enum-type name="DeletionPolicy"/>
+ <enum-type name="Direction"/>
+ <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">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="insertAnimation(int, QAbstractAnimation*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="removeAnimation(QAbstractAnimation*)">
+ <modify-argument index="1">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="takeAnimation(int)">
+ <modify-argument index="return">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="clear()" >
+ <inject-code class="target" position="beginning">
+ for(int counter = 0; counter &lt; %CPPSELF.animationCount(); ++counter ) {
+ QAbstractAnimation* animation = %CPPSELF.animationAt(counter);
+ PyObject* obj = %CONVERTTOPYTHON[QAbstractAnimation*](animation);
+ Shiboken::Object::setParent(NULL, obj);
+ Py_DECREF(obj);
+ }
+ %CPPSELF.clear();
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+ <!-- We will use inject code to implement the function below -->
+ <rejection class="QEasingCurve" function-name="setCustomType" />
+ <rejection class="QEasingCurve" function-name="customType" />
+ <value-type name="QEasingCurve" since="4.6">
+ <extra-includes>
+ <include file-name="pysideweakref.h" location="global"/>
+ <include file-name="glue/qeasingcurve_glue.h" location="local"/>
+ </extra-includes>
+ <inject-code>
+ PySideEasingCurveFunctor::init();
+ </inject-code>
+ <enum-type name="Type" />
+ <add-function signature="setCustomType(PyObject*)">
+ <inject-code>
+ QEasingCurve::EasingFunction func = PySideEasingCurveFunctor::createCustomFuntion(%PYSELF, %PYARG_1);
+ if (func)
+ %CPPSELF.%FUNCTION_NAME(func);
+ </inject-code>
+ </add-function>
+ <add-function signature="customType()" return-type="PyObject">
+ <inject-code>
+ //%FUNCTION_NAME()
+ %PYARG_0 = PySideEasingCurveFunctor::callable(%PYSELF);
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ <value-type name="QJsonArray">
+ <extra-includes>
+ <include file-name="QStringList" location="global"/>
+ </extra-includes>
+ </value-type>
+
+ <value-type name="QJsonDocument">
+ <enum-type name="DataValidation" />
+ <enum-type name="JsonFormat" />
+ </value-type>
+
+ <rejection class="QJsonDocument" field-name="BinaryFormatTag" />
+
+ <value-type name="QJsonParseError">
+ <enum-type name="ParseError"/>
+ </value-type>
+
+ <value-type name="QJsonValue">
+ <enum-type name="Type"/>
+ <extra-includes>
+ <include file-name="QVariant" location="global"/>
+ <include file-name="QJsonArray" location="global"/>
+ <include file-name="QJsonObject" location="global"/>
+ </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 = new QState()
+s11 = new QState(s1)
+s12 = new 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"/>
+
+ <object-type name="QParallelAnimationGroup" since="4.6"/>
+
+ <object-type name="QPauseAnimation" since="4.6"/>
+
+ <value-type name="QProcessEnvironment" since="4.6"/>
+
+ <object-type name="QPropertyAnimation" since="4.6"/>
+
+ <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>
+ if (PyObject_TypeCheck(%1, &amp;PySideSignalInstanceType)) {
+ PyObject* dataSource = PySide::Signal::getObject((PySideSignalInstance*) %PYARG_1);
+ Shiboken::AutoDecRef obType(PyObject_Type(dataSource));
+ QObject* sender = %CONVERTTOCPP[QObject*](dataSource);
+ if (sender) {
+ const char* dataSignature = PySide::Signal::getSignature((PySideSignalInstance*) %PYARG_1);
+ QByteArray signature(dataSignature); // Append SIGNAL flag (2)
+ %0 = new QSignalTransitionWrapper(sender, "2" + signature, %2);
+ }
+ }
+ </inject-code>
+ </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">
+ QString signalName(%2);
+ if (PySide::SignalManager::registerMetaMethod(%1, signalName.mid(1).toLatin1().data(), QMetaMethod::Signal)) {
+ QSignalTransition* %0 = %CPPSELF->addTransition(%1, %2, %3);
+ %PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%0);
+ } else {
+ Py_INCREF(Py_None);
+ %PYARG_0 = Py_None;
+ }
+ </inject-code>
+ </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">
+ // Obviously the label used by the following goto is a very awkward solution,
+ // since it refers to a name very tied to the generator implementation.
+ // Check bug #362 for more information on this
+ // http://bugs.openbossa.org/show_bug.cgi?id=362
+ if (!PyObject_TypeCheck(%1, &amp;PySideSignalInstanceType))
+ goto Sbk_%TYPEFunc_%FUNCTION_NAME_TypeError;
+ PySideSignalInstance* signalInstance = reinterpret_cast&lt;PySideSignalInstance*&gt;(%1);
+ QObject* sender = %CONVERTTOCPP[QObject*](PySide::Signal::getObject(signalInstance));
+ QSignalTransition* %0 = %CPPSELF->%FUNCTION_NAME(sender, PySide::Signal::getSignature(signalInstance), %2);
+ %PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%0);
+ </inject-code>
+ </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">
+ %PYARG_0 = PySet_New(0);
+ foreach(QAbstractState* abs_state, %CPPSELF.configuration()) {
+ Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractState*](abs_state));
+ Shiboken::Object::setParent(self, obj);
+ PySet_Add(%PYARG_0, obj);
+ }
+ </inject-code>
+ </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">
+ %PYARG_0 = PyList_New(0);
+ foreach(QAbstractAnimation* abs_anim, %CPPSELF.defaultAnimations()) {
+ Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractAnimation*](abs_anim));
+ Shiboken::Object::setParent(self, obj);
+ PyList_Append(%PYARG_0, obj);
+ }
+ </inject-code>
+ </add-function>
+ </object-type>
+
+ <object-type name="QVariantAnimation" since="4.6"/>
+
+ <!-- From Qt4.6 ^^^ -->
+
+ <add-function signature="SIGNAL(const char*)" return-type="str">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = Shiboken::String::fromFormat("2%s", QMetaObject::normalizedSignature(%1).constData());
+ </inject-code>
+ </add-function>
+
+ <add-function signature="SLOT(const char*)" return-type="str">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = Shiboken::String::fromFormat("1%s", QMetaObject::normalizedSignature(%1).constData());
+ </inject-code>
+ </add-function>
+
+ <add-function signature="QT_TR_NOOP(PyObject)" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="return_argument"><replace from="#" to="1" /></insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QT_TR_NOOP_UTF8(PyObject)" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="return_argument"><replace from="#" to="1" /></insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QT_TRANSLATE_NOOP(PyObject, PyObject)" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="return_argument"><replace from="#" to="2" /></insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QT_TRANSLATE_NOOP3(PyObject, PyObject, PyObject)" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="return_argument"><replace from="#" to="2" /></insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QT_TRANSLATE_NOOP_UTF8(PyObject)" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="return_argument"><replace from="#" to="1" /></insert-template>
+ </inject-code>
+ </add-function>
+
+ <inject-code class="native" position="beginning">
+ extern bool
+ qRegisterResourceData(int,
+ const unsigned char *,
+ const unsigned char *,
+ const unsigned char *);
+
+ extern bool
+ qUnregisterResourceData(int,
+ const unsigned char *,
+ const unsigned char *,
+ const unsigned char *);
+ </inject-code>
+ <add-function signature="qRegisterResourceData(int, PyBytes, PyBytes, PyBytes)" return-type="bool">
+ <inject-code class="target" position="beginning">
+ %RETURN_TYPE %0 = %FUNCTION_NAME(%1, (uchar*)PyBytes_AS_STRING(%PYARG_2),
+ (uchar*)PyBytes_AS_STRING(%PYARG_3),
+ (uchar*)PyBytes_AS_STRING(%PYARG_4));
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ <add-function signature="qUnregisterResourceData(int, PyBytes, PyBytes, PyBytes)" return-type="bool">
+ <inject-code class="target" position="beginning">
+ %RETURN_TYPE %0 = %FUNCTION_NAME(%1, (uchar*)PyBytes_AS_STRING(%PYARG_2),
+ (uchar*)PyBytes_AS_STRING(%PYARG_3),
+ (uchar*)PyBytes_AS_STRING(%PYARG_4));
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+
+ <object-type name="QFactoryInterface"/>
+ <object-type name="QRunnable"/>
+
+ <object-type name="QPluginLoader"/>
+
+ <suppress-warning text="Unable to decide type of property: 'QLibrary::LoadHints' in class 'QPluginLoader'" />
+ <suppress-warning text="enum '_ISalnum' does not have a type entry or is not an enum" />
+ <suppress-warning text="enum 'Qt::Initialization' does not have a type entry or is not an enum" />
+ <suppress-warning text="visibility of function '*' modified in class '*'"/>
+ <suppress-warning text="hiding of function '*' in class '*'"/>
+ <suppress-warning text="namespace '*' does not have a type entry"/>
+ <suppress-warning text="Shadowing: QObject::parent() const and QAbstractItemModel::parent() const"/>
+ <suppress-warning text="namespace '*' for enum 'QtMsgType' is not declared"/>
+ <suppress-warning text="horribly broken type 'imaxdiv_t'"/>
+ <suppress-warning text="horribly broken type '__off64_t'"/>
+ <suppress-warning text="horribly broken type 'div_t'"/>
+ <suppress-warning text="horribly broken type 'fd_set*'"/>
+ <suppress-warning text="horribly broken type 'ldiv_t'"/>
+ <suppress-warning text="horribly broken type 'lldiv_t'"/>
+ <suppress-warning text="signal '*' in class '*' is overloaded."/>
+ <suppress-warning text="enum 'enum_3' does not have a type entry or is not an enum"/>
+ <suppress-warning text="Shadowing: QFile::fileName() const and QTemporaryFile::fileName() const"/>
+ <suppress-warning text="unhandled enum value: ~0u in Qt::GestureType"/>
+ <suppress-warning text="unhandled enum value: (sizeof(void*)&lt;&lt;3) in QSysInfo::Sizes"/>
+ <suppress-warning text="unmatched enum ~0u"/>
+ <suppress-warning text="unmatched enum (sizeof(void*)&lt;&lt;3)"/>
+ <suppress-warning text="signature 'setCustomType(float)' for function modification in 'QEasingCurve' not found. Possible candidates: setCustomType(double) in QEasingCurve"/>
+ <suppress-warning text="enum 'enum_4' does not have a type entry or is not an enum" />
+ <suppress-warning text="enum 'enum_5' does not have a type entry or is not an enum" />
+ <suppress-warning text="enum 'FP_NORMAL' does not have a type entry or is not an enum" />
+ <suppress-warning text="Shadowing: *" />
+
+ <!-- this enum is defined on Qt global header but only used in QtGui module -->
+ <suppress-warning text="enum 'PM_MessageBoxHeight' does not have a type entry or is not an enum" />
+
+ <!-- this function only exists on Windows -->
+ <suppress-warning text="signature 'winEventFilter(MSG*,long*)' for function modification in 'QCoreApplication' not found. Possible candidates:*"/>
+
+ <!-- this is necessary to avoid warning on other modules -->
+ <suppress-warning text="signature 'operator*(QByteArray,const char*)' for function modification in 'QByteArray' not found. Possible candidates: *"/>
+ <suppress-warning text="signature 'operator+(QByteArray,QString)' for function modification in 'QByteArray' not found. Possible candidates: *"/>
+
+ <!-- This enum is intenaly used -->
+ <suppress-warning text="enum 'PM_CbaIconHeight' does not have a type entry or is not an enum" />
+
+ <!-- TODO: this need be removed -->
+ <suppress-warning text="skipping function '*', unmatched return type '*'"/>
+ <suppress-warning text="skipping function '*', unmatched parameter type '*'"/>
+
+ <suppress-warning text="enum 'q_static_assert_result39' does not have a type entry or is not an enum"/>
+ <suppress-warning text="horribly broken type ''"/>
+ <suppress-warning text="Pure virtual method 'QTextCodec::convertFromUnicode(const QChar*,int,QTextCodec::ConverterState*)const' must be implement but was completely removed on type system." />
+
+ <!-- Qt5.5: No idea how to get rid of the following five enums, which are moved elsewhere since 5.5: -->
+ <suppress-warning text="enum 'QLocale::MeasurementSystem' is specified in typesystem, but not declared" />
+ <suppress-warning text="enum 'QState::RestorePolicy' is specified in typesystem, but not declared" />
+ <!-- <suppress-warning text="enum 'QLocale::FormatType' is specified in typesystem, but not declared" /> -->
+ <suppress-warning text="enum 'QAbstractAnimation::DeletionPolicy' is specified in typesystem, but not declared" />
+ <!-- <suppress-warning text="enum 'QAbstractAnimation::State' is specified in typesystem, but not declared" /> -->
+ <!-- Qt5.5: we also suppress these warnings, instead of adding wrong enums -->
+ <suppress-warning text="enum 'InterfaceType' does not have a type entry or is not an enum" />
+ <suppress-warning text="enum 'TextBoundaryType' does not have a type entry or is not an enum" />
+ <suppress-warning text="enum 'RelationFlag' does not have a type entry or is not an enum" />
+ <suppress-warning text="enum 'Role' does not have a type entry or is not an enum" />
+
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_mac.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_mac.xml
new file mode 100644
index 000000000..be4832c01
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/typesystem_core_mac.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtCore">
+ <primitive-type name="Qt::HANDLE" target-lang-api-name="PyObject" />
+ <!-- Qt5: had to move QAbstractEventDispatcher into os-specific files because of Windows -->
+ <object-type name="QAbstractEventDispatcher">
+ <modify-function signature="processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag>)" allow-thread="yes"/>
+ <!-- Qt5: had to add this recursive object def. This was crucial to get rid of "pure virtual" -->
+ <object-type name="TimerInfo"/>
+ </object-type>
+ <object-type name="QSysInfo">
+ <enum-type name="Endian"/>
+ <enum-type name="Sizes"/>
+ <enum-type name="MacVersion" since="5.5" />
+ </object-type>
+ <suppress-warning text="skipping field 'QSysInfo::WindowsVersion' with unmatched type 'QSysInfo::WinVersion'" />
+ <suppress-warning text="enum 'QSysInfo::WinVersion' does not have a type entry or is not an enum" />
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_win.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_win.xml
new file mode 100644
index 000000000..c9c9f73c5
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/typesystem_core_win.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtCore">
+ <extra-includes>
+ <include file-name="windows.h" location="global"/>
+ </extra-includes>
+ <primitive-type name="Qt::HANDLE" target-lang-api-name="PyObject" />
+ <primitive-type name="HWND">
+ <!-- Qt5: Add this include there to insert ti in the global qtcore header (needed by qprocess_wrapper) -->
+ <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
+ </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
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+ <inject-code class="native" position="beginning">
+ <insert-template name="checkPyCapsuleOrPyCObject_func"/>
+ </inject-code>
+
+ <!-- Qt5: had to move QAbstractEventDispatcher into os-specific files because of Windows -->
+ <object-type name="QWinEventNotifier" />
+ <object-type name="QAbstractEventDispatcher">
+ <modify-function signature="processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag>)" allow-thread="yes"/>
+ <!-- Qt5: had to add this recursive object def. This was crucial to get rid of "pure virtual" -->
+ <object-type name="TimerInfo"/>
+ </object-type>
+ <object-type name="QSysInfo">
+ <enum-type name="Endian"/>
+ <enum-type name="Sizes"/>
+ <enum-type name="WinVersion" since="5.5" />
+ </object-type>
+ <suppress-warning text="skipping field 'QSysInfo::MacintoshVersion' with unmatched type 'QSysInfo::MacVersion'" />
+ <suppress-warning text="enum 'QSysInfo::MacVersion' does not have a type entry or is not an enum" />
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_x11.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_x11.xml
new file mode 100644
index 000000000..801c52b0f
--- /dev/null
+++ b/sources/pyside2/PySide2/QtCore/typesystem_core_x11.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtCore">
+ <primitive-type name="Qt::HANDLE" target-lang-api-name="PyLong">
+ <!-- FIXME APIExtractor or shiboken do not support multiple includes by primitive type -->
+ <!-- Qt5: XXX move this to QtGui <include file-name="QTextDocument" location="global"/> -->
+ </primitive-type>
+ <!-- Qt5: had to move QAbstractEventDispatcher into os-specific files because of Windows -->
+ <object-type name="QAbstractEventDispatcher">
+ <modify-function signature="processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag>)" allow-thread="yes"/>
+ <!-- Qt5: had to add this recursive object def. This was crucial to get rid of "pure virtual" -->
+ <object-type name="TimerInfo"/>
+ </object-type>
+ <object-type name="QSysInfo">
+ <enum-type name="Endian"/>
+ <enum-type name="Sizes"/>
+ </object-type>
+ <suppress-warning text="skipping field 'QSysInfo::MacintoshVersion' with unmatched type 'QSysInfo::MacVersion'" />
+ <suppress-warning text="skipping field 'QSysInfo::WindowsVersion' with unmatched type 'QSysInfo::MacVersion'" />
+ <suppress-warning text="enum 'QSysInfo::MacVersion' does not have a type entry or is not an enum" />
+ <suppress-warning text="enum 'QSysInfo::WinVersion' does not have a type entry or is not an enum" />
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtGui/CMakeLists.txt b/sources/pyside2/PySide2/QtGui/CMakeLists.txt
new file mode 100644
index 000000000..a6a8c1049
--- /dev/null
+++ b/sources/pyside2/PySide2/QtGui/CMakeLists.txt
@@ -0,0 +1,206 @@
+project(QtGui)
+
+qt5_wrap_cpp(QPYTEXTOBJECT_MOC "${pyside2_SOURCE_DIR}/qpytextobject.h")
+
+set(QtGui_SRC
+${QtGui_GEN_DIR}/qabstracttextdocumentlayout_paintcontext_wrapper.cpp
+${QtGui_GEN_DIR}/qabstracttextdocumentlayout_selection_wrapper.cpp
+${QtGui_GEN_DIR}/qabstracttextdocumentlayout_wrapper.cpp
+${QtGui_GEN_DIR}/qaccessibleevent_wrapper.cpp
+${QtGui_GEN_DIR}/qactionevent_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}/qconicalgradient_wrapper.cpp
+${QtGui_GEN_DIR}/qcontextmenuevent_wrapper.cpp
+${QtGui_GEN_DIR}/qcursor_wrapper.cpp
+${QtGui_GEN_DIR}/qdesktopservices_wrapper.cpp
+${QtGui_GEN_DIR}/qdoublevalidator_wrapper.cpp
+${QtGui_GEN_DIR}/qdrag_wrapper.cpp
+${QtGui_GEN_DIR}/qdragenterevent_wrapper.cpp
+${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}/qexposeevent_wrapper.cpp
+${QtGui_GEN_DIR}/qfileopenevent_wrapper.cpp
+${QtGui_GEN_DIR}/qfocusevent_wrapper.cpp
+${QtGui_GEN_DIR}/qfont_wrapper.cpp
+${QtGui_GEN_DIR}/qfontdatabase_wrapper.cpp
+${QtGui_GEN_DIR}/qfontinfo_wrapper.cpp
+${QtGui_GEN_DIR}/qfontmetrics_wrapper.cpp
+${QtGui_GEN_DIR}/qfontmetricsf_wrapper.cpp
+${QtGui_GEN_DIR}/qgradient_wrapper.cpp
+${QtGui_GEN_DIR}/qguiapplication_wrapper.cpp
+${QtGui_GEN_DIR}/qhelpevent_wrapper.cpp
+${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_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}/qinputevent_wrapper.cpp
+${QtGui_GEN_DIR}/qinputmethodevent_attribute_wrapper.cpp
+${QtGui_GEN_DIR}/qinputmethodevent_wrapper.cpp
+${QtGui_GEN_DIR}/qintvalidator_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
+${QtGui_GEN_DIR}/qmatrix3x2_wrapper.cpp
+${QtGui_GEN_DIR}/qmatrix3x3_wrapper.cpp
+${QtGui_GEN_DIR}/qmatrix3x4_wrapper.cpp
+${QtGui_GEN_DIR}/qmatrix4x2_wrapper.cpp
+${QtGui_GEN_DIR}/qmatrix4x3_wrapper.cpp
+${QtGui_GEN_DIR}/qmatrix4x4_wrapper.cpp
+${QtGui_GEN_DIR}/qmouseevent_wrapper.cpp
+${QtGui_GEN_DIR}/qmoveevent_wrapper.cpp
+${QtGui_GEN_DIR}/qmovie_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
+${QtGui_GEN_DIR}/qpaintdevice_wrapper.cpp
+${QtGui_GEN_DIR}/qpaintdevicewindow_wrapper.cpp
+${QtGui_GEN_DIR}/qpaintengine_wrapper.cpp
+${QtGui_GEN_DIR}/qpaintenginestate_wrapper.cpp
+${QtGui_GEN_DIR}/qpainter_pixmapfragment_wrapper.cpp
+${QtGui_GEN_DIR}/qpainter_wrapper.cpp
+${QtGui_GEN_DIR}/qpainterpath_element_wrapper.cpp
+${QtGui_GEN_DIR}/qpainterpath_wrapper.cpp
+${QtGui_GEN_DIR}/qpainterpathstroker_wrapper.cpp
+${QtGui_GEN_DIR}/qpaintevent_wrapper.cpp
+${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}/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}/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}/qstandarditem_wrapper.cpp
+${QtGui_GEN_DIR}/qstandarditemmodel_wrapper.cpp
+${QtGui_GEN_DIR}/qstatustipevent_wrapper.cpp
+${QtGui_GEN_DIR}/qstringlistmodel_wrapper.cpp
+${QtGui_GEN_DIR}/qopenglbuffer_wrapper.cpp
+${QtGui_GEN_DIR}/qopenglcontext_wrapper.cpp
+${QtGui_GEN_DIR}/qaccessible_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}/qrasterwindow_wrapper.cpp
+${QtGui_GEN_DIR}/qrawfont_wrapper.cpp
+${QtGui_GEN_DIR}/qstatictext_wrapper.cpp
+${QtGui_GEN_DIR}/qstylehints_wrapper.cpp
+${QtGui_GEN_DIR}/qsurface_wrapper.cpp
+${QtGui_GEN_DIR}/qsurfaceformat_wrapper.cpp
+${QtGui_GEN_DIR}/qsyntaxhighlighter_wrapper.cpp
+${QtGui_GEN_DIR}/qtabletevent_wrapper.cpp
+${QtGui_GEN_DIR}/qtextblock_iterator_wrapper.cpp
+${QtGui_GEN_DIR}/qtextblock_wrapper.cpp
+${QtGui_GEN_DIR}/qtextblockformat_wrapper.cpp
+${QtGui_GEN_DIR}/qtextblockgroup_wrapper.cpp
+${QtGui_GEN_DIR}/qtextblockuserdata_wrapper.cpp
+${QtGui_GEN_DIR}/qtextcharformat_wrapper.cpp
+${QtGui_GEN_DIR}/qtextcursor_wrapper.cpp
+${QtGui_GEN_DIR}/qtextdocument_wrapper.cpp
+${QtGui_GEN_DIR}/qtextdocumentfragment_wrapper.cpp
+${QtGui_GEN_DIR}/qtextdocumentwriter_wrapper.cpp
+${QtGui_GEN_DIR}/qtextformat_wrapper.cpp
+${QtGui_GEN_DIR}/qtextfragment_wrapper.cpp
+${QtGui_GEN_DIR}/qtextframe_iterator_wrapper.cpp
+${QtGui_GEN_DIR}/qtextframe_wrapper.cpp
+${QtGui_GEN_DIR}/qtextframeformat_wrapper.cpp
+${QtGui_GEN_DIR}/qtextimageformat_wrapper.cpp
+${QtGui_GEN_DIR}/qtextinlineobject_wrapper.cpp
+${QtGui_GEN_DIR}/qtextitem_wrapper.cpp
+${QtGui_GEN_DIR}/qtextlayout_formatrange_wrapper.cpp
+${QtGui_GEN_DIR}/qtextlayout_wrapper.cpp
+${QtGui_GEN_DIR}/qtextlength_wrapper.cpp
+${QtGui_GEN_DIR}/qtextline_wrapper.cpp
+${QtGui_GEN_DIR}/qtextlist_wrapper.cpp
+${QtGui_GEN_DIR}/qtextlistformat_wrapper.cpp
+${QtGui_GEN_DIR}/qtextobject_wrapper.cpp
+${QtGui_GEN_DIR}/qtextobjectinterface_wrapper.cpp
+${QtGui_GEN_DIR}/qtextoption_tab_wrapper.cpp
+${QtGui_GEN_DIR}/qtextoption_wrapper.cpp
+${QtGui_GEN_DIR}/qtexttable_wrapper.cpp
+${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}/qvalidator_wrapper.cpp
+${QtGui_GEN_DIR}/qvector2d_wrapper.cpp
+${QtGui_GEN_DIR}/qvector3d_wrapper.cpp
+${QtGui_GEN_DIR}/qvector4d_wrapper.cpp
+${QtGui_GEN_DIR}/qwhatsthisclickedevent_wrapper.cpp
+${QtGui_GEN_DIR}/qwheelevent_wrapper.cpp
+${QtGui_GEN_DIR}/qwindow_wrapper.cpp
+${QtGui_GEN_DIR}/qwindowstatechangeevent_wrapper.cpp
+
+# module is always needed
+${QtGui_GEN_DIR}/qtgui_module_wrapper.cpp
+)
+
+configure_file("${QtGui_SOURCE_DIR}/typesystem_gui.xml.in"
+ "${QtGui_BINARY_DIR}/typesystem_gui.xml" @ONLY)
+
+make_path(QtGui_typesystem_path ${QtCore_SOURCE_DIR} ${QtCore_BINARY_DIR}
+ ${QtGui_SOURCE_DIR})
+
+set(QtGui_include_dirs ${QtGui_SOURCE_DIR}
+ ${QtGui_BINARY_DIR}
+ ${pyside2_SOURCE_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ )
+set(QtGui_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Gui_LIBRARIES})
+set(QtGui_deps QtCore)
+
+create_pyside_module(QtGui
+ QtGui_include_dirs
+ QtGui_libraries
+ QtGui_deps
+ QtGui_typesystem_path
+ QtGui_SRC
+ QPYTEXTOBJECT_MOC
+ ${QtGui_BINARY_DIR}/typesystem_gui.xml)
+
+install(FILES ${pyside2_SOURCE_DIR}/qpytextobject.h DESTINATION include/PySide2/QtGui/)
+
diff --git a/sources/pyside2/PySide2/QtGui/glue/qguiapplication_init.cpp b/sources/pyside2/PySide2/QtGui/glue/qguiapplication_init.cpp
new file mode 100644
index 000000000..60507f37a
--- /dev/null
+++ b/sources/pyside2/PySide2/QtGui/glue/qguiapplication_init.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+// Borrowed reference to QtGui module
+extern PyObject* moduleQtGui;
+
+static int QGuiApplicationArgCount;
+static char** QGuiApplicationArgValues;
+
+bool QGuiApplicationConstructorStart(PyObject* argv)
+{
+ if (QGuiApplication::instance()) {
+ PyErr_SetString(PyExc_RuntimeError, "A QGuiApplication instance already exists.");
+ return false;
+ }
+
+ return Shiboken::sequenceToArgcArgv(argv, &QGuiApplicationArgCount, &QGuiApplicationArgValues, "PySideApp");
+}
+
+void QGuiApplicationConstructorEnd(PyObject* self)
+{
+ PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
+ Py_INCREF(self);
+}
+
+static void QGuiApplicationConstructor(PyObject* self, PyObject* argv, QGuiApplicationWrapper** cptr)
+{
+ if (QGuiApplicationConstructorStart(argv)) {
+ // XXX do we need to support the ApplicationFlags parameter, instead of 0?
+ *cptr = new QGuiApplicationWrapper(QGuiApplicationArgCount, QGuiApplicationArgValues, 0);
+ Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self));
+ QGuiApplicationConstructorEnd(self);
+ }
+}
diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui.xml.in b/sources/pyside2/PySide2/QtGui/typesystem_gui.xml.in
new file mode 100644
index 000000000..0de65876a
--- /dev/null
+++ b/sources/pyside2/PySide2/QtGui/typesystem_gui.xml.in
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtGui">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+ <load-typesystem name="typesystem_gui_@AUTO_OS@.xml" generate="yes"/>
+ <load-typesystem name="typesystem_gui_common.xml" generate="yes"/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
new file mode 100644
index 000000000..7a0db8a41
--- /dev/null
+++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
@@ -0,0 +1,3313 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtGui">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+
+ <template name="QFontCharFix">
+ int size = Shiboken::String::len(%PYARG_1);
+ if (size == 1) {
+ const char *str = Shiboken::String::toCString(%PYARG_1);
+ QChar ch(str[0]);
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(ch);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "String must have only one character");
+ }
+ </template>
+
+ <function signature="qAlpha(uint)" />
+ <function signature="qBlue(uint)" />
+ <function signature="qGray(int,int,int)" />
+ <function signature="qGray(uint)" />
+ <function signature="qGreen(uint)" />
+ <function signature="qIsGray(uint)" />
+ <function signature="qRed(uint)" />
+ <function signature="qRgb(int,int,int)" />
+ <function signature="qRgba(int,int,int,int)" />
+ <function signature="qFuzzyCompare(QMatrix,QMatrix)" />
+ <function signature="qFuzzyCompare(QTransform,QTransform)" />
+ <function signature="qFuzzyCompare(QQuaternion,QQuaternion)" />
+ <function signature="qFuzzyCompare(QMatrix4x4,QMatrix4x4)" />
+ <function signature="qFuzzyCompare(QVector2D,QVector2D)" />
+ <function signature="qFuzzyCompare(QVector3D,QVector3D)" />
+ <function signature="qFuzzyCompare(QVector4D,QVector4D)" />
+ <rejection class="*" function-name="qobject_interface_iid&lt;QStyleFactoryInterface*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QAccessibleFactoryInterface*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QInputContextFactoryInterface*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QGraphicsItem*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QGraphicsLayout*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QAccessibleBridgeFactoryInterface*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QImageIOHandlerFactoryInterface*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QAccessibleInterface*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QTextObjectInterface*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QGraphicsLayoutItem*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QIconEngineFactoryInterface*&gt;"/>
+ <rejection class="*" function-name="qobject_interface_iid&lt;QPictureFormatInterface*&gt;"/>
+
+ <rejection class="*" function-name="qobject_cast&lt;QGraphicsLayout*&gt;"/>
+ <rejection class="*" function-name="qobject_cast&lt;QGraphicsItem*&gt;"/>
+ <rejection class="*" function-name="qobject_cast&lt;QGraphicsLayoutItem*&gt;"/>
+ <rejection class="*" function-name="qobject_cast&lt;QGraphicsLayoutItem*&gt;"/>
+
+ <rejection class="*" function-name="qGenericMatrixFromMatrix4x4"/>
+ <rejection class="*" function-name="qDrawBorderPixmap"/>
+ <rejection class="*" function-name="qDrawPixmaps"/>
+ <rejection class="*" function-name="qGenericMatrixToMatrix4x4"/>
+
+ <rejection class="*" function-name="d_func"/>
+ <rejection class="*" field-name="d_ptr"/>
+ <rejection class="*" field-name="d"/>
+
+ <!--
+ Event classes have a lot of non-documented protected fields, those fields
+ are removed from PySide because they are Qt implementation details,
+ besides the fact they are accessible by ordinary event methods.
+ -->
+
+ <rejection class="QAccessibleEvent" field-name="m_type"/>
+
+ <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="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="QAbstractTextDocumentLayout::PaintContext" field-name="selections"/>
+ <rejection class="QBrush" function-name="cleanUp"/>
+ <rejection class="QFont" enum-name="ResolveProperties"/>
+ <rejection class="QMotifStyle" field-name="focus"/>
+ <rejection class="QPictureIO" function-name="defineIOHandler"/>
+ <rejection class="QPolygon" function-name="putPoints"/>
+ <rejection class="QPolygon" function-name="setPoints"/>
+ <rejection class="QPolygon" function-name="setPoint"/>
+ <rejection class="QPolygon" function-name="points"/>
+ <rejection class="QPolygon" function-name="point"/>
+ <rejection class="QActionGroup" function-name="selected"/>
+ <rejection class="QPaintEngine" function-name="fix_neg_rect"/>
+
+ <primitive-type name="WId" target-lang-api-name="PyLong">
+ <conversion-rule>
+ <native-to-target>
+ return PyLong_FromVoidPtr(reinterpret_cast&lt;void *&gt;(%in));
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyLong">
+ %out = reinterpret_cast&lt;%OUTTYPE&gt;(PyLong_AsVoidPtr(%in));
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <value-type name="QTransform">
+ <enum-type name="TransformationType"/>
+ <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, %f, %f, %f" />
+ <replace from="%REPR_ARGS"
+ to="%CPPSELF.m11(), %CPPSELF.m12(), %CPPSELF.m13(), %CPPSELF.m21(), %CPPSELF.m22(), %CPPSELF.m23(), %CPPSELF.m31(), %CPPSELF.m32(), %CPPSELF.m33()" />
+ </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="ddddddddd" />
+ <replace from="%REDUCE_ARGS"
+ to="%CPPSELF.m11(), %CPPSELF.m12(), %CPPSELF.m13(), %CPPSELF.m21(), %CPPSELF.m22(), %CPPSELF.m23(), %CPPSELF.m31(), %CPPSELF.m32(), %CPPSELF.m33()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <modify-function signature="map(qreal,qreal,qreal*,qreal*)const">
+ <modify-argument index="0">
+ <replace-type modified-type="PyObject" />
+ </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_args,number*,number*">
+ <replace from="$TYPE" to="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <!-- ### This is just an overload to "map(qreal,qreal,qreal*,qreal*)const" and can be discarded in Python -->
+ <modify-function signature="map(int,int,int*,int*)const" remove="all"/>
+ <!-- ### -->
+
+ <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>
+ <add-function signature="quadToQuad(QPolygonF&amp;, QPolygonF&amp;)" return-type="PyObject*" static="true">
+ <inject-code>
+ QTransform _result;
+ if (QTransform::quadToQuad(%1, %2, _result)) {
+ %PYARG_0 = %CONVERTTOPYTHON[QTransform](_result);
+ } else {
+ Py_INCREF(Py_None);
+ %PYARG_0 = Py_None;
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="quadToSquare(QPolygonF &amp;)" return-type="PyObject*" static="true">
+ <inject-code>
+ QTransform _result;
+ if (QTransform::quadToSquare(%1, _result)) {
+ %PYARG_0 = %CONVERTTOPYTHON[QTransform](_result);
+ } else {
+ Py_INCREF(Py_None);
+ %PYARG_0 = Py_None;
+ }
+ </inject-code>
+ </add-function>
+
+ <add-function signature="squareToQuad(QPolygonF &amp;)" return-type="PyObject*" static="true">
+ <inject-code>
+ QTransform _result;
+ if (QTransform::squareToQuad(%1, _result)) {
+ %PYARG_0 = %CONVERTTOPYTHON[QTransform](_result);
+ } else {
+ Py_INCREF(Py_None);
+ %PYARG_0 = Py_None;
+ }
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ <value-type name="QStaticText">
+ <enum-type name="PerformanceHint"/>
+ </value-type>
+ <value-type name="QTextFragment" />
+ <value-type name="QBitmap" >
+ <modify-function signature="fromData(QSize,const uchar*,QImage::Format)">
+ <modify-argument index="2">
+ <replace-type modified-type="PyBuffer"/>
+ </modify-argument>
+ <inject-code>
+ uchar* buffer = (uchar*) Shiboken::Buffer::getPointer(%PYARG_2);
+ QBitmap %0 = QBitmap::fromData(%1, buffer, %3);
+ %PYARG_0 = %CONVERTTOPYTHON[QBitmap](%0);
+ </inject-code>
+ </modify-function>
+ </value-type>
+ <value-type name="QTextInlineObject" />
+ <value-type name="QTextDocumentFragment" />
+ <value-type name="QTextOption">
+ <enum-type name="Flag" flags="Flags"/>
+ <enum-type name="TabType"/>
+ <enum-type name="WrapMode"/>
+ <value-type name="Tab"/>
+ </value-type>
+ <value-type name="QTextLine" >
+ <enum-type name="CursorPosition"/>
+ <enum-type name="Edge"/>
+ <modify-function signature="cursorToX(int*,QTextLine::Edge)const" remove="all" />
+ <modify-function signature="cursorToX(int,QTextLine::Edge)const">
+ <modify-argument index="0">
+ <replace-type modified-type="PyObject" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE %0 = %CPPSELF->::%TYPE::%FUNCTION_NAME(&amp;%1, %2);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG1_TYPE](%1));
+ </inject-code>
+ </modify-function>
+ <modify-function signature="xToCursor(qreal,QTextLine::CursorPosition)const">
+ <modify-argument index="2">
+ <rename to="edge"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+ <value-type name="QTextTableFormat" />
+ <value-type name="QTextImageFormat" />
+ <value-type name="QTextFrameFormat" >
+ <enum-type name="BorderStyle"/>
+ <enum-type name="Position"/>
+ <modify-function signature="isValid()const" access="non-final"/>
+ </value-type>
+ <value-type name="QTextLength">
+ <enum-type name="Type"/>
+ </value-type>
+ <value-type name="QPainterPath">
+ <enum-type name="ElementType"/>
+ <value-type name="Element">
+ <modify-field name="x" write="false"/>
+ <modify-field name="y" write="false"/>
+ <modify-field name="type" write="false"/>
+ <include file-name="QPainterPath" location="global"/>
+ </value-type>
+ </value-type>
+ <value-type name="QPalette">
+ <enum-type name="ColorGroup" />
+ <enum-type name="ColorRole" />
+ </value-type>
+ <value-type name="QKeySequence">
+ <enum-type name="SequenceFormat"/>
+ <enum-type name="SequenceMatch"/>
+ <enum-type name="StandardKey"/>
+
+ <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>
+ </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="iiii" />
+ <replace from="%REDUCE_ARGS" to="(*%CPPSELF)[0], (*%CPPSELF)[1], (*%CPPSELF)[2], (*%CPPSELF)[3]" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <modify-function signature="operator[](uint) const" remove="all"/>
+ <add-function signature="__getitem__">
+ <inject-code class="target" position="beginning">
+ if (_i &lt; 0 || _i >= %CPPSELF.count()) {
+ PyErr_SetString(PyExc_IndexError, "index out of bounds");
+ return 0;
+ }
+ int item = (*%CPPSELF)[_i];
+ return %CONVERTTOPYTHON[int](item);
+ </inject-code>
+ </add-function>
+
+ <!-- ### Not necessary due the PySide QVariant conversion rules -->
+ <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"/>
+ <!-- See bug 759 -->
+ <modify-function signature="data() const">
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject"/>
+ </modify-argument>
+ <inject-code>
+ %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.data(), %CPPSELF.size());
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setData(const char*,uint)">
+ <modify-argument index="1">
+ <replace-type modified-type="PyBuffer"/>
+ <conversion-rule class="target">
+ PyObject* %out = Shiboken::Buffer::newObject(%in, size);
+ </conversion-rule>
+ <conversion-rule class="native">
+ Py_ssize_t bufferLen;
+ char* %out = (char*) Shiboken::Buffer::getPointer(%PYARG_1, &amp;bufferLen);
+ </conversion-rule>
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument/>
+ <conversion-rule class="native">
+ uint %out = bufferLen;
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+ <value-type name="QRegion" >
+ <enum-type name="RegionType"/>
+ <!-- ### This operator does not make sense in Python. -->
+ <modify-function signature="operator&amp;=(QRegion)" remove="all"/>
+ <modify-function signature="operator&amp;=(QRect)" remove="all"/>
+ <!-- ### -->
+ </value-type>
+
+ <value-type name="QTextBlock">
+ <value-type name="iterator" >
+ <include file-name="QTextBlock" location="global"/>
+ <!-- ### These operators where removed because they don't make sense in Python.
+ The iterator methods (__iter__, next) replace this functionality. -->
+ <modify-function signature="operator++()" remove="all"/>
+ <modify-function signature="operator--()" remove="all"/>
+ <!-- ### -->
+ <add-function signature="__iter__()" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="__iter__" />
+ </inject-code>
+ </add-function>
+ <add-function signature="__next__()" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="__next__">
+ <replace from="%CPPSELF_TYPE" to="QTextBlock::iterator" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ </value-type>
+ <add-function signature="__iter__()" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="__iter_parent__">
+ <replace from="%CPPSELF_TYPE" to="QTextBlock::iterator" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <modify-function signature="setUserData(QTextBlockUserData*)">
+ <inject-code class="target" position="end">
+ const QTextDocument* doc = %CPPSELF.document();
+ if (doc) {
+ Shiboken::AutoDecRef pyDocument(%CONVERTTOPYTHON[QTextDocument*](doc));
+ Shiboken::Object::setParent(pyDocument, %PYARG_1);
+ }
+ </inject-code>
+ </modify-function>
+ <modify-function signature="userData() const">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ const QTextDocument* doc = %CPPSELF.document();
+ if (doc) {
+ Shiboken::AutoDecRef pyDocument(%CONVERTTOPYTHON[QTextDocument*](doc));
+ Shiboken::Object::setParent(pyDocument, %PYARG_0);
+ }
+ </inject-code>
+ </modify-function>
+ </value-type>
+ <value-type name="QTextBlockFormat">
+ <enum-type name="LineHeightTypes" since="4.8" revision="4800"/>
+ </value-type>
+ <value-type name="QTextTableCellFormat" />
+ <value-type name="QTextCharFormat" >
+ <enum-type name="FontPropertiesInheritanceBehavior"/>
+ <enum-type name="UnderlineStyle"/>
+ <enum-type name="VerticalAlignment"/>
+ <modify-function signature="isValid()const" access="non-final"/>
+ </value-type>
+ <value-type name="QTextFormat" >
+ <enum-type name="FormatType"/>
+ <enum-type name="ObjectTypes"/>
+ <enum-type name="PageBreakFlag" flags="PageBreakFlags"/>
+ <enum-type name="Property" />
+ <modify-function signature="isValid()const" access="non-final"/>
+ </value-type>
+ <value-type name="QTextListFormat">
+ <enum-type name="Style"/>
+ </value-type>
+ <value-type name="QPolygon">
+ <extra-includes>
+ <include file-name="QMatrix" location="global"/>
+ <include file-name="QTransform" location="global"/>
+ </extra-includes>
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ PyObject* points = PyList_New(%CPPSELF.count());
+ for (int i = 0, max = %CPPSELF.count(); i &lt; max; ++i){
+ int x, y;
+ %CPPSELF.point(i, &amp;x, &amp;y);
+ QPoint pt = QPoint(x, y);
+ PyList_SET_ITEM(points, i, %CONVERTTOPYTHON[QPoint](pt));
+ }
+ <insert-template name="reduce_code">
+ <replace from="%REDUCE_FORMAT" to="N" />
+ <replace from="%REDUCE_ARGS" to="points" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <!-- ### "QPolygon(int, const int*)" is an internal constructor. -->
+ <modify-function signature="QPolygon(int, const int *)" remove="all"/>
+ <!-- ### A QVector parameter, for no defined type, will generate wrong code. -->
+ <modify-function signature="operator+=(QVector&lt;QPoint&gt;)" remove="all"/>
+ <modify-function signature="operator&lt;&lt;(QPoint)">
+ <inject-code>
+ // %FUNCTION_NAME()
+ *%CPPSELF &lt;&lt; %1;
+ %PYARG_0 = %CONVERTTOPYTHON[QPolygon*](%CPPSELF);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="operator&lt;&lt;(QVector&lt;QPoint&gt;)">
+ <inject-code>
+ // %FUNCTION_NAME()
+ *%CPPSELF &lt;&lt; %1;
+ %PYARG_0 = %CONVERTTOPYTHON[QPolygon*](%CPPSELF);
+ </inject-code>
+ </modify-function>
+ <!-- ### -->
+ </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. -->
+ <modify-function signature="operator+=(QVector&lt;QPointF&gt;)" remove="all"/>
+ <!-- ### See bug 776 -->
+ <modify-function signature="operator&lt;&lt;(QPointF)" remove="all"/>
+ <!-- ### See bug 777 -->
+ <modify-function signature="operator&lt;&lt;(QVector&lt;QPointF&gt;)" remove="all"/>
+ <!-- ### -->
+ </value-type>
+ <value-type name="QIcon" >
+ <enum-type name="Mode"/>
+ <enum-type name="State"/>
+ <modify-function signature="QIcon(QIconEngine *)">
+ <modify-argument index="1">
+ <no-null-pointer/>
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+
+ <template name="load_xpm">
+ Shiboken::AutoDecRef strList(PySequence_Fast(%PYARG_1, "Invalid sequence."));
+ int lineCount = PySequence_Fast_GET_SIZE(strList.object());
+ for (int line = 0; line &lt; lineCount; ++line) {
+ if (!Shiboken::String::check(PySequence_Fast_GET_ITEM(strList.object(), line))) {
+ PyErr_SetString(PyExc_TypeError, "The argument must be a sequence of strings.");
+ break;
+ }
+ }
+
+ const char** xpm = (const char**) malloc (lineCount * sizeof(const char**));
+ for (int line = 0; line &lt; lineCount; ++line)
+ xpm[line] = Shiboken::String::toCString(PySequence_Fast_GET_ITEM(strList.object(), line));
+
+ %BEGIN_ALLOW_THREADS
+ %0 = new %TYPE(xpm);
+ %END_ALLOW_THREADS
+
+ free(xpm);
+ </template>
+ <value-type name="QPixmap" >
+ <!--<conversion-rule>-->
+ <!--<target-to-native replace="no">-->
+ <!--<add-conversion type="QVariant" check="%CHECKTYPE[QVariant](%in)">-->
+ <!--QVariant in = %CONVERTTOCPP[QVariant](%in);-->
+ <!--%out = in.value&lt;%OUTTYPE&gt;();-->
+ <!--</add-conversion>-->
+ <!--</target-to-native>-->
+ <!--</conversion-rule>-->
+ <add-function signature="QPixmap(const QImage&amp;)">
+ <modify-argument index="1">
+ <rename to="image"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ %0 = new %TYPE(QPixmap::fromImage(%1));
+ </inject-code>
+ </add-function>
+ <modify-function signature="QPixmap(const char **)">
+ <modify-argument index="1">
+ <replace-type modified-type="PySequence" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="load_xpm" />
+ </inject-code>
+ </modify-function>
+
+ <!-- ### Operator ! doesn't make sense in Python. -->
+ <modify-function signature="operator!()const" remove="all"/>
+
+ <modify-function signature="loadFromData(const uchar*,uint,const char*,QFlags&lt;Qt::ImageConversionFlag&gt;)">
+ <modify-argument index="1">
+ <replace-type modified-type="PyBytes"/>
+ <conversion-rule class="native">
+ const uchar* %out = reinterpret_cast&lt;const uchar*>(PyBytes_AS_STRING(%PYARG_1));
+ </conversion-rule>
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument/>
+ <conversion-rule class="native">
+ uint %out = static_cast&lt;uint>(PyBytes_Size(%PYARG_1));
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+ <value-type name="QTextCursor" >
+ <extra-includes>
+ <include file-name="QTextBlock" location="global"/>
+ <include file-name="QTextDocumentFragment" location="global"/>
+ </extra-includes>
+ <enum-type name="MoveMode"/>
+ <enum-type name="MoveOperation"/>
+ <enum-type name="SelectionType"/>
+ <modify-function signature="selectedTableCells(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="currentFrame()const">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertTable(int,int,const QTextTableFormat &amp;)">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertTable(int,int)">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </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>
+ <template name="qmatrix_map">
+ %ARG1_TYPE a, b;
+ %CPPSELF.%FUNCTION_NAME(%1, %2, &amp;a, &amp;b);
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%ARG1_TYPE](a));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG1_TYPE](b));
+ </template>
+ <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="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" />
+ <value-type name="QFont" >
+ <enum-type name="Capitalization"/>
+ <enum-type name="SpacingType"/>
+ <enum-type name="Stretch"/>
+ <enum-type name="Style"/>
+ <enum-type name="StyleHint" />
+ <enum-type name="StyleStrategy"/>
+ <enum-type name="Weight"/>
+ <enum-type name="HintingPreference" since="4.8" revision="4800"/>
+ <extra-includes>
+ <include file-name="QStringList" location="global"/>
+ </extra-includes>
+ <modify-function signature="setStyleHint(QFont::StyleHint, QFont::StyleStrategy)">
+ <modify-argument index="2">
+ <rename to="strategy"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+ <value-type name="QTextTableCell" >
+ <extra-includes>
+ <include file-name="QTextCursor" location="global"/>
+ </extra-includes>
+ </value-type> <!--
+ <function signature="QImageCleanupFunction(void*)">
+ <extra-includes>
+ <include file-name="QImage" location="global"/>
+ </extra-includes>
+ </function> -->
+ <primitive-type name="QImageCleanupFunction" />
+ <value-type name="QImage">
+ <enum-type name="Format"/>
+ <enum-type name="InvertMode"/>
+ <extra-includes>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QMatrix" location="global"/>
+ </extra-includes>
+
+ <template name="qimage_buffer_constructor">
+ uchar* ptr = (uchar*) Shiboken::Buffer::getPointer(%PYARG_1);
+ %0 = new %TYPE(ptr, %ARGS);
+ </template>
+ <modify-function signature="QImage(uchar *,int,int,int,QImage::Format,QImageCleanupFunction, void *)">
+ <modify-argument index="1">
+ <replace-type modified-type="PyBuffer"/>
+ </modify-argument>
+ <inject-code>
+ <insert-template name="qimage_buffer_constructor">
+ <replace from="%ARGS" to="%2, %3, %4, %5" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="QImage(uchar*,int,int,QImage::Format,QImageCleanupFunction, void *)">
+ <modify-argument index="1">
+ <replace-type modified-type="PyBuffer"/>
+ </modify-argument>
+ <inject-code>
+ <insert-template name="qimage_buffer_constructor">
+ <replace from="%ARGS" to="%2, %3, %4" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+
+ <add-function signature="QImage(QString&amp;,int,int,int,QImage::Format)">
+ <inject-code>
+ <insert-template name="qimage_buffer_constructor">
+ <replace from="%ARGS" to="%2, %3, %4, %5" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QImage(QString&amp;,int,int,QImage::Format)">
+ <inject-code>
+ <insert-template name="qimage_buffer_constructor">
+ <replace from="%ARGS" to="%2, %3, %4" />
+ </insert-template>
+ </inject-code>
+ </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,QImage::Format,QImageCleanupFunction, void *)" remove="all" />
+ <!-- ### -->
+
+ <modify-function signature="QImage(const char**)">
+ <modify-argument index="1">
+ <replace-type modified-type="PySequence" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="load_xpm" />
+ </inject-code>
+ </modify-function>
+ <!-- ### There is already an fromData with a QByteArray type (that is convertible from Python's str) as the first type. -->
+ <modify-function signature="fromData(const uchar*,int,const char*)" remove="all"/>
+ <!-- ### There is already an loadFromData with a QByteArray type (that is convertible from Python's str) as the first type. -->
+ <modify-function signature="loadFromData(const uchar*,int,const char*)" remove="all" />
+
+ <modify-function signature="constBits()const" since="4.7">
+ <inject-code>
+ %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.byteCount());
+ </inject-code>
+ </modify-function>
+ <modify-function signature="bits()">
+ <inject-code>
+ // byteCount() is only available on Qt4.7, so we use bytesPerLine * height
+ %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.bytesPerLine() * %CPPSELF.height(), Shiboken::Buffer::ReadWrite);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="constScanLine(int)const" since="4.7">
+ <inject-code>
+ %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(%1), %CPPSELF.bytesPerLine());
+ </inject-code>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="scanLine(int)">
+ <inject-code>
+ %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(%1), %CPPSELF.bytesPerLine(), Shiboken::Buffer::ReadWrite);
+ </inject-code>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject" />
+ </modify-argument>
+ </modify-function>
+ <!--
+ Only the non-const version of bits() and scanLine() is exported to Python
+ If the user don't want to detach the QImage data he must use constBits or constScanLine
+ as Python doesn't have the concept of constness.
+ -->
+ <modify-function signature="bits()const" remove="all"/>
+ <modify-function signature="scanLine(int)const" remove="all"/>
+
+ <modify-function signature="invertPixels(QImage::InvertMode)">
+ <modify-argument index="1">
+ <rename to="mode"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+ <value-type name="QCursor" >
+ <extra-includes>
+ <include file-name="QPixmap" location="global"/>
+ <include file-name="Qt" location="global"/>
+ </extra-includes>
+ </value-type>
+ <value-type name="QFontDatabase" >
+ <extra-includes>
+ <include file-name="QStringList" location="global"/>
+ </extra-includes>
+ <enum-type name="SystemFont" />
+ <enum-type name="WritingSystem" />
+ </value-type>
+ <value-type name="QPen">
+ <extra-includes>
+ <include file-name="QBrush" location="global"/>
+ </extra-includes>
+ </value-type>
+ <value-type name="QBrush">
+ <extra-includes>
+ <include file-name="QPixmap" location="global"/>
+ </extra-includes>
+ </value-type>
+
+ <template name="qcolor_repr">
+ switch(%CPPSELF.spec()) {
+ case QColor::Rgb:
+ {
+ qreal r, g, b, a;
+ %CPPSELF.getRgbF(&amp;r, &amp;g, &amp;b, &amp;a);
+ QString repr = QString().sprintf("PySide2.QtGui.QColor.fromRgbF(%.6f, %.6f, %.6f, %.6f)", r, g, b, a);
+ %PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
+ break;
+ }
+ case QColor::Hsv:
+ {
+ qreal h, s, v, a;
+ %CPPSELF.getHsvF(&amp;h, &amp;s, &amp;v, &amp;a);
+ QString repr = QString().sprintf("PySide2.QtGui.QColor.fromHsvF(%.6f, %.6f, %.6f, %.6f)", h, s, v, a);
+ %PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
+ break;
+ }
+ case QColor::Cmyk:
+ {
+ qreal c, m, y, k, a;
+ %CPPSELF.getCmykF(&amp;c, &amp;m, &amp;y, &amp;k, &amp;a);
+ QString repr = QString().sprintf("PySide2.QtGui.QColor.fromCmykF(%.6f, %.6f, %.6f, %.6f, %.6f)", c, m, y, k, a);
+ %PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
+ break;
+ }
+ #if QT_VERSION >= 0x040600
+ case QColor::Hsl:
+ {
+ qreal h, s, l, a;
+ %CPPSELF.getHslF(&amp;h, &amp;s, &amp;l, &amp;a);
+ QString repr = QString().sprintf("PySide2.QtGui.QColor.fromHslF(%.6f, %.6f, %.6f, %.6f)", h, s, l, a);
+ %PYARG_0 = Shiboken::String::fromCString(qPrintable(repr));
+ break;
+ }
+ #endif
+ default:
+ {
+ %PYARG_0 = Shiboken::String::fromCString("PySide2.QtGui.QColor()");
+ }
+ }
+ </template>
+ <value-type name="QColor">
+ <enum-type name="NameFormat"/>
+ <enum-type name="Spec"/>
+ <extra-includes>
+ <include file-name="QVariant" location="global"/>
+ </extra-includes>
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="qcolor_repr" />
+ </inject-code>
+ </add-function>
+ <add-function signature="__str__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="qcolor_repr" />
+ </inject-code>
+ </add-function>
+ <add-function signature="__setstate__(PyObject*)" return-type="PyObject">
+ <inject-code>
+ Shiboken::AutoDecRef func(PyObject_GetAttr(%PYSELF, PyTuple_GET_ITEM(%1, 0)));
+ PyObject* args = PyTuple_GET_ITEM(%1, 1);
+ %PYARG_0 = PyObject_Call(func, args, NULL);
+ </inject-code>
+ </add-function>
+ <add-function signature="__reduce__" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ switch(%CPPSELF.spec()) {
+ case QColor::Rgb:
+ {
+ qreal r, g, b, a;
+ %CPPSELF.getRgbF(&amp;r, &amp;g, &amp;b, &amp;a);
+ %PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setRgbF", (float)r, (float)g, (float)b, (float)a);
+ break;
+ }
+ case QColor::Hsv:
+ {
+ qreal h, s, v, a;
+ %CPPSELF.getHsvF(&amp;h, &amp;s, &amp;v, &amp;a);
+ %PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setHsvF", (float)h, (float)s, (float)v, (float)a);
+ break;
+ }
+ case QColor::Cmyk:
+ {
+ qreal c, m, y, k, a;
+ %CPPSELF.getCmykF(&amp;c, &amp;m, &amp;y, &amp;k, &amp;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);
+ break;
+ }
+ #if QT_VERSION >= 0x040600
+ case QColor::Hsl:
+ {
+ qreal h, s, l, a;
+ %CPPSELF.getHslF(&amp;h, &amp;s, &amp;l, &amp;a);
+ %PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setHslF", (float)h, (float)s, (float)l, (float)a);
+ break;
+ }
+ #endif
+ default:
+ {
+ %PYARG_0 = Py_BuildValue("(N(O))", PyObject_Type(%PYSELF), Py_None);
+ }
+ }
+ </inject-code>
+ </add-function>
+
+ <add-function signature="toTuple" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ switch(%CPPSELF.spec()) {
+ case QColor::Rgb:
+ {
+ int r, g, b, a;
+ %CPPSELF.getRgb(&amp;r, &amp;g, &amp;b, &amp;a);
+ %PYARG_0 = Py_BuildValue("iiii", r, g, b, a);
+ break;
+ }
+ case QColor::Hsv:
+ {
+ int h, s, v, a;
+ %CPPSELF.getHsv(&amp;h, &amp;s, &amp;v, &amp;a);
+ %PYARG_0 = Py_BuildValue("iiii", h, s, v, a);
+ break;
+ }
+ case QColor::Cmyk:
+ {
+ int c, m, y, k, a;
+ %CPPSELF.getCmyk(&amp;c, &amp;m, &amp;y, &amp;k, &amp;a);
+ %PYARG_0 = Py_BuildValue("iiiii", c, m, y, k, a);
+ break;
+ }
+ case QColor::Hsl:
+ {
+ int h, s, l, a;
+ %CPPSELF.getHsl(&amp;h, &amp;s, &amp;l, &amp;a);
+ %PYARG_0 = Py_BuildValue("iiii", h, s, l, a);
+ break;
+ }
+ default:
+ {
+ %PYARG_0 = 0;
+ }
+ }
+ </inject-code>
+ </add-function>
+ <!-- ### "QColor(QColor::Spec)" is an internal method. -->
+ <modify-function signature="QColor(QColor::Spec)" remove="all"/>
+ <!-- ### Constructor removed because we already have an overload using QString. -->
+ <modify-function signature="QColor(const char*)" remove="all" />
+ <!-- ### -->
+ <add-function signature="QColor(QVariant)">
+ <inject-code class="target" position="beginning">
+ if (%1.type() == QVariant::Color)
+ %0 = new %TYPE(%1.value&lt;QColor>());
+ else
+ PyErr_SetString(PyExc_TypeError, "QVariant must be holding a QColor");
+ </inject-code>
+ </add-function>
+ <!-- get* methods. Inject code -->
+ <modify-function signature="getCmyk(int*,int*,int*,int*,int*)">
+ <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>
+ <modify-argument index="5">
+ <remove-argument/>
+ <remove-default-expression/>
+ </modify-argument>
+
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_number*,number*,number*,number*,number*">
+ <replace from="$TYPE" to="int" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getCmykF(qreal*,qreal*,qreal*,qreal*,qreal*)">
+ <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>
+ <modify-argument index="5">
+ <remove-argument/>
+ <remove-default-expression/>
+ </modify-argument>
+
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_number*,number*,number*,number*,number*">
+ <replace from="$TYPE" to="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getHsl(int*,int*,int*,int*)const" since="4.6">
+ <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/>
+ <remove-default-expression/>
+ </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>
+ <modify-function signature="getHslF(qreal*,qreal*,qreal*,qreal*)const" since="4.6">
+ <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/>
+ <remove-default-expression/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_number*,number*,number*,number*">
+ <replace from="$TYPE" to="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getHsv(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/>
+ <remove-default-expression/>
+ </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>
+ <modify-function signature="getHsvF(qreal*,qreal*,qreal*,qreal*)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/>
+ <remove-default-expression/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_number*,number*,number*,number*">
+ <replace from="$TYPE" to="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getRgb(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/>
+ <remove-default-expression/>
+ </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>
+ <modify-function signature="getRgbF(qreal*,qreal*,qreal*,qreal*)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/>
+ <remove-default-expression/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_number*,number*,number*,number*">
+ <replace from="$TYPE" to="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ </value-type>
+ <value-type name="QFontMetricsF" >
+
+ <modify-function signature="boundingRect(QChar)const" rename="boundingRectChar">
+ <modify-argument index="1">
+ <replace-type modified-type="char"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="QFontCharFix"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="width(QChar)const" rename="widthChar">
+ <modify-argument index="1">
+ <replace-type modified-type="char"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="QFontCharFix"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="boundingRect(QRectF,int,QString,int,int*)const">
+ <modify-argument index="5">
+ <replace-type modified-type="PyObject"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int* array = NULL;
+ bool errorOccurred = false;
+
+ if (numArgs == 5) {
+ array = Shiboken::sequenceToIntArray(%PYARG_5, true);
+ if (PyErr_Occurred()) {
+ if (array)
+ delete []array;
+ errorOccurred = true;
+ }
+ }
+
+ if (!errorOccurred) {
+ %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, array);
+
+ if (array)
+ delete []array;
+
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](retval);
+ }
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="size(int,QString,int,int*)const">
+ <modify-argument index="4">
+ <replace-type modified-type="PyObject"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int* array = NULL;
+ bool errorOccurred = false;
+
+ if (numArgs == 4) {
+ array = Shiboken::sequenceToIntArray(%PYARG_4, true);
+ if (PyErr_Occurred()) {
+ if (array)
+ delete []array;
+ errorOccurred = true;
+ }
+ }
+
+ if (!errorOccurred) {
+ %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, array);
+
+ if (array)
+ delete []array;
+
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](retval);
+ }
+ </inject-code>
+ </modify-function>
+ </value-type>
+ <value-type name="QFontMetrics" >
+
+ <modify-function signature="boundingRect(QChar)const" rename="boundingRectChar">
+ <modify-argument index="1">
+ <replace-type modified-type="char"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="QFontCharFix"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="width(QChar)const" rename="widthChar">
+ <modify-argument index="1">
+ <replace-type modified-type="char"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="QFontCharFix"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="boundingRect(int,int,int,int,int,QString,int,int*)const">
+ <modify-argument index="8">
+ <replace-type modified-type="PyObject"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int* array = NULL;
+ bool errorOccurred = false;
+
+ if (numArgs == 8) {
+ array = Shiboken::sequenceToIntArray(%PYARG_8, true);
+ if (PyErr_Occurred()) {
+ if (array)
+ delete []array;
+ errorOccurred = true;
+ }
+ }
+
+ if (!errorOccurred) {
+ %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, %7, array);
+
+ if (array)
+ delete []array;
+
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](retval);
+ }
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="boundingRect(QRect,int,QString,int,int*)const">
+ <modify-argument index="5">
+ <replace-type modified-type="PyObject"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int* array = NULL;
+ bool errorOccurred = false;
+
+ if (numArgs == 5) {
+ array = Shiboken::sequenceToIntArray(%PYARG_5, true);
+ if (PyErr_Occurred()) {
+ if (array)
+ delete []array;
+ errorOccurred = true;
+ }
+ }
+
+ if (!errorOccurred) {
+ %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, array);
+
+ if (array)
+ delete []array;
+
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](retval);
+ }
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="size(int,QString,int,int*)const">
+ <modify-argument index="4">
+ <replace-type modified-type="PyObject"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int* array = NULL;
+ bool errorOccurred = false;
+
+ if (numArgs == 4) {
+ array = Shiboken::sequenceToIntArray(%PYARG_4, true);
+ if (PyErr_Occurred()) {
+ if (array)
+ delete []array;
+ errorOccurred = true;
+ }
+ }
+
+ if (!errorOccurred) {
+ %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, array);
+
+ if (array)
+ delete []array;
+
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](retval);
+ }
+
+ </inject-code>
+ </modify-function>
+ </value-type>
+ <value-type name="QGradient" force-abstract="yes" polymorphic-id-expression="%1-&gt;type() == QGradient::NoGradient">
+ <enum-type name="CoordinateMode"/>
+ <enum-type name="InterpolationMode"/>
+ <enum-type name="Spread" lower-bound="QGradient.PadSpread" upper-bound="QGradient.RepeatSpread"/>
+ <enum-type name="Type"/>
+ </value-type>
+ <value-type name="QLinearGradient" polymorphic-id-expression="%1-&gt;type() == QGradient::LinearGradient" />
+ <object-type name="QPaintDevice">
+ <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>
+ <object-type name="QAbstractTextDocumentLayout">
+ <value-type name="PaintContext" >
+ <include file-name="QAbstractTextDocumentLayout" location="global"/>
+ </value-type>
+ <value-type name="Selection" />
+ <modify-function signature="setPaintDevice(QPaintDevice*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="draw(QPainter*,QAbstractTextDocumentLayout::PaintContext)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="drawInlineObject(QPainter*,QRectF,QTextInlineObject,int,QTextFormat)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+ <object-type name="QPyTextObject" />
+
+ <object-type name="QDesktopServices" since="4.2" />
+ <object-type name="QDoubleValidator">
+ <enum-type name="Notation"/>
+ </object-type>
+ <object-type name="QIconEngine">
+ <object-type name="AvailableSizesArgument" />
+ <enum-type name="IconEngineHook" />
+ <modify-function signature="paint(QPainter*,QRect,QIcon::Mode,QIcon::State)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="read(QDataStream&amp;)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="write(QDataStream&amp;)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <!-- ### This makes little sense in Python. Could be reassessed later. -->
+ <modify-function signature="virtual_hook(int,void*)" remove="all"/>
+ </object-type>
+ <object-type name="QImageWriter">
+ <enum-type name="ImageWriterError"/>
+ <modify-function signature="setDevice(QIODevice*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="write(const QImage&amp;)" allow-thread="yes"/>
+ </object-type>
+ <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>
+ </object-type>
+ <object-type name="QPixmapCache">
+ <value-type name="Key"/>
+ <add-function signature="find(QPixmapCache::Key&amp;)">
+ <inject-code>
+ QPixmap p;
+ if (%CPPSELF.%FUNCTION_NAME(%1, &amp;p)) {
+ %PYARG_0 = %CONVERTTOPYTHON[QPixmap](p);
+ } else {
+ %PYARG_0 = Py_None;
+ Py_INCREF(%PYARG_0);
+ }
+ </inject-code>
+ </add-function>
+ </object-type>
+
+ <object-type name="QRegExpValidator" />
+
+ <object-type name="QStandardItem">
+ <enum-type name="ItemType"/>
+ <modify-function signature="operator&lt;(QStandardItem)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="read(QDataStream&amp;)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="write(QDataStream&amp;)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+
+ <modify-function signature="appendColumn(const QList&lt;QStandardItem *&gt; &amp;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="appendRow(const QList&lt;QStandardItem *&gt; &amp;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="appendRow(QStandardItem *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="appendRows(const QList&lt;QStandardItem *&gt; &amp;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="insertColumn(int, const QList&lt;QStandardItem *&gt; &amp;)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertRow(int, const QList&lt;QStandardItem *&gt; &amp;)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertRows(int, const QList&lt;QStandardItem *&gt; &amp;)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="setChild(int, int, QStandardItem *)">
+ <inject-code class="target" position="beginning">
+ // Clear parent from the old child
+ QStandardItem* _i = %CPPSELF->child(%1, %2);
+ if (_i) {
+ PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i);
+ Shiboken::Object::setParent(0, _pyI);
+ }
+ </inject-code>
+ <modify-argument index="3">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setChild(int, QStandardItem *)">
+ <inject-code class="target" position="beginning">
+ // Clear parent from the old child
+ QStandardItem* _i = %CPPSELF->child(%1);
+ if (_i) {
+ PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i);
+ Shiboken::Object::setParent(0, _pyI);
+ }
+ </inject-code>
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="takeChild(int, int)">
+ <modify-argument index="return">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="clone() const">
+ <modify-argument index="return">
+ <define-ownership class="native" owner="c++"/>
+ <define-ownership class="target" owner="target"/>
+ </modify-argument>
+ </modify-function>
+
+ <!-- ??? -->
+ <modify-function signature="operator&lt;(QStandardItem)const" remove="all"/>
+ </object-type>
+ <object-type name="QStringListModel"/>
+ <object-type name="QSyntaxHighlighter">
+ <modify-function signature="setCurrentBlockUserData(QTextBlockUserData*)">
+ <modify-argument index="1">
+ <define-ownership class="target" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setDocument(QTextDocument*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="document() const">
+ <modify-argument index="this">
+ <parent index="return" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QTextBlockGroup" />
+ <object-type name="QTextBlockUserData" />
+ <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="QTextObject"/>
+ <object-type name="QTextObjectInterface" >
+ <modify-function signature="drawObject(QPainter*,QRectF,QTextDocument*,int,QTextFormat)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+
+ <template name="validator_conversionrule">
+ QValidator::State %out;
+
+ if (PySequence_Check(%PYARG_0)) {
+ Shiboken::AutoDecRef seq(PySequence_Fast(%PYARG_0, 0));
+ int size = PySequence_Fast_GET_SIZE(seq.object());
+
+ if (size > 1) {
+ if (%ISCONVERTIBLE[QString](PySequence_Fast_GET_ITEM(seq.object(), 1)))
+ %1 = %CONVERTTOCPP[QString](PySequence_Fast_GET_ITEM(seq.object(), 1));
+ else
+ qWarning("%TYPE::%FUNCTION_NAME: Second tuple element is not convertible to unicode.");
+ }
+
+ if (size > 2) {
+ if (%ISCONVERTIBLE[int](PySequence_Fast_GET_ITEM(seq.object(), 2)))
+ %2 = %CONVERTTOCPP[int](PySequence_Fast_GET_ITEM(seq.object(), 2));
+ else
+ qWarning("%TYPE::%FUNCTION_NAME: Second tuple element is not convertible to int.");
+ }
+ %PYARG_0 = PySequence_Fast_GET_ITEM(seq.object(), 0);
+ Py_INCREF(%PYARG_0); // we need to incref, because "%PYARG_0 = ..." will decref the tuple and the tuple will be decrefed again at the end of this scope.
+ }
+
+ // check retrun value
+ if (%ISCONVERTIBLE[QValidator::State](%PYARG_0)) {
+ %out = %CONVERTTOCPP[QValidator::State](%PYARG_0);
+ } else {
+ PyErr_Format(PyExc_TypeError, "Invalid return value in function %s, expected %s, got %s.",
+ "QValidator.validate",
+ "PySide2.QtGui.QValidator.State, (PySide2.QtGui.QValidator.State,), (PySide2.QtGui.QValidator.State, unicode) or (PySide2.QtGui.QValidator.State, unicode, int)",
+ pyResult->ob_type->tp_name);
+ return QValidator::State();
+ }
+ </template>
+
+ <object-type name="QValidator">
+ <enum-type name="State"/>
+ <modify-function signature="fixup(QString &amp;)const">
+ <modify-argument index="return">
+ <replace-type modified-type="QString"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_QString"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="validate(QString &amp;, int &amp;)const">
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject"/>
+ <conversion-rule class="native">
+ <insert-template name="validator_conversionrule"/>
+ </conversion-rule>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_tuple_QValidator_QString_int"/>
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QActionEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::ActionAdded || %1-&gt;type() == QEvent::ActionRemoved || %1-&gt;type() == QEvent::ActionChanged" />
+ <object-type name="QCloseEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::Close"/>
+ <object-type name="QContextMenuEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::ContextMenu">
+ <enum-type name="Reason"/>
+ </object-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" />
+ <object-type name="QDropEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::Drop">
+ <modify-function signature="source() const">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QEnterEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::Enter"/>
+ <object-type name="QExposeEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::Expose" />
+ <object-type name="QFileOpenEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::FileOpen" />
+ <object-type name="QFocusEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::FocusIn || %1-&gt;type() == QEvent::FocusOut" />
+ <object-type name="QHelpEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::ToolTip || %1-&gt;type() == QEvent::WhatsThis"/>
+ <object-type name="QHideEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::Hide"/>
+ <object-type name="QHoverEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::HoverEnter || %1-&gt;type() == QEvent::HoverLeave || %1-&gt;type() == QEvent::HoverMove"/>
+ <object-type name="QIconDragEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::IconDrag"/>
+
+ <object-type name="QInputMethodEvent" copyable="no" polymorphic-id-expression="%1-&gt;type() == QEvent::InputMethod">
+ <!-- only declare this if ndef QT_NO_INPUTMETHOD -->
+ <enum-type name="AttributeType"/>
+ <value-type name="Attribute">
+ <include file-name="QInputMethodEvent" location="global"/>
+ </value-type>
+ <!-- endif ndef QT_NO_INPUTMETHOD -->
+ </object-type>
+
+ <object-type name="QMoveEvent" copyable = "false" polymorphic-id-expression="%1-&gt;type() == QEvent::Move" />
+ <object-type name="QResizeEvent" copyable = "false" polymorphic-id-expression="%1-&gt;type() == QEvent::Resize"/>
+ <object-type name="QShortcutEvent" copyable = "false" polymorphic-id-expression="%1-&gt;type() == QEvent::Shortcut">
+ <!-- All these have const overloads that are used instead -->
+ <modify-function signature="isAmbiguous()const" remove="all"/>
+ <modify-function signature="shortcutId()const" remove="all"/>
+ <modify-function signature="key()const" remove="all"/>
+ <!-- ### -->
+ </object-type>
+ <object-type name="QShowEvent" copyable= "false" polymorphic-id-expression="%1-&gt;type() == QEvent::Show"/>
+ <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="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"/>
+ <!-- Qt5.5: suppress this nameless enum -->
+ <suppress-warning text="enum 'QWheelEvent::DefaultDeltasPerStep' does not have a type entry or is not an enum" />
+
+ <object-type name="QWindowStateChangeEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::WindowStateChange"/>
+ <object-type name="QInputEvent" copyable="false">
+ <modify-function signature="modifiers()const" access="non-final"/>
+ </object-type>
+ <object-type name="QKeyEvent" copyable= "false" polymorphic-id-expression="%1-&gt;type() == QEvent::KeyPress || %1-&gt;type() == QEvent::KeyRelease || %1-&gt;type() == QEvent::ShortcutOverride">
+ <add-function signature="operator!=(QKeySequence::StandardKey)">
+ <inject-code class="target">
+ bool ret = !(&amp;%CPPSELF == %1);
+ %PYARG_0 = %CONVERTTOPYTHON[bool](ret);
+ </inject-code>
+ </add-function>
+ </object-type>
+ <object-type name="QMouseEvent" copyable= "false" polymorphic-id-expression="%1-&gt;type() == QEvent::MouseButtonDblClick || %1-&gt;type() == QEvent::MouseButtonPress || %1-&gt;type() == QEvent::MouseButtonRelease || %1-&gt;type() == QEvent::MouseMove"/>
+ <object-type name="QPaintEvent" copyable= "false" polymorphic-id-expression="%1-&gt;type() == QEvent::Paint"/>
+ <object-type name="QAccessibleEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::AccessibilityDescription || %1-&gt;type() == QEvent::AccessibilityHelp"/>
+
+ <object-type name="QTextFrame" >
+ <extra-includes>
+ <include file-name="QTextCursor" location="global"/>
+ </extra-includes>
+ <value-type name="iterator" >
+ <include file-name="QTextFrame" location="global"/>
+ <!-- ### These operators where removed because they don't make sense in Python.
+ Instead iterator methods (__iter__, next) should be implemented.
+ See bug 688 -->
+ <modify-function signature="operator++()" remove="all"/>
+ <modify-function signature="operator--()" remove="all"/>
+ <!-- ### -->
+ <add-function signature="__iter__()" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="__iter__" />
+ </inject-code>
+ </add-function>
+ <add-function signature="__next__()" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="__next__">
+ <replace from="%CPPSELF_TYPE" to="QTextFrame::iterator" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ </value-type>
+ <add-function signature="__iter__()" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="__iter_parent__">
+ <replace from="%CPPSELF_TYPE" to="QTextFrame::iterator" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ </object-type>
+ <object-type name="QImageIOHandler">
+ <extra-includes>
+ <include file-name="QRect" location="global"/>
+ </extra-includes>
+ <enum-type name="ImageOption"/>
+ <enum-type name="Transformation" flags="Transformations" since="5.5" />
+ <modify-function signature="setDevice(QIODevice*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QImageReader">
+ <extra-includes>
+ <include file-name="QColor" location="global"/>
+ <include file-name="QRect" location="global"/>
+ <include file-name="QSize" location="global"/>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QImage" location="global"/>
+ </extra-includes>
+ <enum-type name="ImageReaderError"/>
+ <!-- ### This method does not make sense in Python.
+ Update: perhaps it does, but no one is missing it. -->
+ <modify-function signature="read(QImage*)" remove="all" />
+ <modify-function signature="setDevice(QIODevice*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QMovie">
+ <extra-includes>
+ <include file-name="QColor" location="global"/>
+ <include file-name="QImage" location="global"/>
+ <include file-name="QPixmap" location="global"/>
+ <include file-name="QRect" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ <enum-type name="CacheMode"/>
+ <enum-type name="MovieState"/>
+ <!-- ### "cacheMode()" is an internal method. -->
+ <modify-function signature="setDevice(QIODevice*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QDrag">
+ <extra-includes>
+ <include file-name="QPoint" location="global"/>
+ <include file-name="QPixmap" location="global"/>
+ </extra-includes>
+ <modify-function signature="QDrag(QObject*)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="source() const">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="target() const">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setMimeData(QMimeData*)">
+ <modify-argument index="1">
+ <!-- TODO: maybe this is not the best solution -->
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="exec(QFlags&lt;Qt::DropAction&gt;)" rename="exec_" allow-thread="yes"/>
+ <modify-function signature="exec(QFlags&lt;Qt::DropAction&gt;, Qt::DropAction)" rename="exec_" allow-thread="yes"/>
+ </object-type>
+
+ <object-type name="QStandardItemModel" polymorphic-id-expression="qobject_cast&lt;QStandardItemModel*&gt;(%1)">
+ <extra-includes>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ <modify-function signature="takeItem(int,int)">
+ <modify-argument index="return">
+ <parent index="this" action="remove" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="takeHorizontalHeaderItem(int)">
+ <modify-argument index="return">
+ <parent index="this" action="remove" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="takeVerticalHeaderItem(int)">
+ <modify-argument index="return">
+ <parent index="this" action="remove" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="verticalHeaderItem(int) const">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="horizontalHeaderItem(int) const">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="invisibleRootItem() const">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="item(int, int) const">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="itemFromIndex(const QModelIndex&amp;) const">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="itemPrototype() const">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="appendRow(const QList&lt;QStandardItem*&gt;&amp;)">
+ <modify-argument index="1">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="appendRow(QStandardItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="insertRow(int, QStandardItem*)">
+ <modify-argument index="2">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setHorizontalHeaderItem(int, QStandardItem*)">
+ <modify-argument index="2">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="setItem(int, int, QStandardItem*)">
+ <inject-code class="target" position="beginning">
+ // Clear parent from the old child
+ QStandardItem* _i = %CPPSELF->item(%1, %2);
+ if (_i) {
+ PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i);
+ Shiboken::Object::setParent(0, _pyI);
+ }
+ </inject-code>
+ <modify-argument index="3">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setItem(int, QStandardItem*)">
+ <inject-code class="target" position="beginning">
+ // Clear parent from the old child
+ QStandardItem* _i = %CPPSELF->item(%1);
+ if (_i) {
+ PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i);
+ Shiboken::Object::setParent(0, _pyI);
+ }
+ </inject-code>
+ <modify-argument index="2">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setItemPrototype(const QStandardItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="setVerticalHeaderItem(int, QStandardItem*)">
+ <inject-code class="target" position="beginning">
+ // Clear parent from the old child
+ QStandardItem* _i = %CPPSELF->verticalHeaderItem(%1);
+ if (_i) {
+ PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i);
+ Shiboken::Object::setParent(0, _pyI);
+ }
+ </inject-code>
+ <modify-argument index="2">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="takeColumn(int)">
+ <modify-argument index="return">
+ <parent index="this" action="remove" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="takeRow(int)">
+ <modify-argument index="return">
+ <parent index="this" action="remove" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="findItems(const QString&amp;, QFlags&lt;Qt::MatchFlag&gt;, int) const">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="insertColumn(int, const QList&lt;QStandardItem*&gt;&amp;)">
+ <modify-argument index="2">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="insertRow(int, const QList&lt;QStandardItem*&gt;&amp;)">
+ <modify-argument index="2">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="appendColumn(const QList&lt;QStandardItem*&gt;&amp;)">
+ <modify-argument index="1">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="clear()">
+ <inject-code class="target" position="beginning">
+ Shiboken::BindingManager&amp; bm = Shiboken::BindingManager::instance();
+ SbkObject* pyRoot = bm.retrieveWrapper(%CPPSELF.invisibleRootItem());
+ if (pyRoot) {
+ Shiboken::Object::destroy(pyRoot, %CPPSELF.invisibleRootItem());
+ }
+
+ for(int r=0, r_max = %CPPSELF.rowCount(); r &lt; r_max; r++) {
+ QList&lt;QStandardItem *&gt; ri = %CPPSELF.takeRow(0);
+
+ PyObject *pyResult = %CONVERTTOPYTHON[QList&lt;QStandardItem * &gt;](ri);
+ Shiboken::Object::setParent(Py_None, pyResult);
+ Py_XDECREF(pyResult);
+ }
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QClipboard">
+ <extra-includes>
+ <include file-name="QImage" location="global"/>
+ <include file-name="QPixmap" location="global"/>
+ </extra-includes>
+ <enum-type name="Mode" />
+ <modify-function signature="setMimeData(QMimeData *, QClipboard::Mode)">
+ <modify-argument index="1">
+ <!-- TODO: maybe this is not the best solution -->
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="text(QString&amp;,QClipboard::Mode)const">
+ <modify-argument index="2">
+ <replace-default-expression with="QClipboard::Clipboard"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(retval, subtype)"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG1_TYPE](%1));
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QPaintEngineState">
+ <extra-includes>
+ <include file-name="QPainterPath" location="global"/>
+ </extra-includes>
+ </object-type>
+ <object-type name="QTextLayout">
+ <extra-includes>
+ <include file-name="QTextOption" location="global"/>
+ </extra-includes>
+ <enum-type name="CursorMode"/>
+ <value-type name="FormatRange">
+ <include file-name="QTextLayout" location="global"/>
+ </value-type>
+ </object-type>
+ <object-type name="QTextDocument">
+ <extra-includes>
+ <include file-name="QTextBlock" location="global"/>
+ <include file-name="QTextFormat" location="global"/>
+ <include file-name="QTextCursor" location="global"/>
+ </extra-includes>
+ <enum-type name="FindFlag" flags="FindFlags"/>
+ <enum-type name="MetaInformation"/>
+ <enum-type name="ResourceType"/>
+ <enum-type name="Stacks" since="4.7"/>
+ <modify-function signature="setDocumentLayout(QAbstractTextDocumentLayout*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="object(int)const">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="objectForFormat(const QTextFormat&amp;)const">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="createObject(const QTextFormat&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="print(QPagedPaintDevice*)const" rename="print_" />
+ </object-type>
+ <object-type name="QTextDocumentWriter" since="4.5" />
+ <object-type name="QTextTable">
+ <extra-includes>
+ <include file-name="QTextCursor" location="global"/>
+ </extra-includes>
+ </object-type>
+ <object-type name="QPaintEngine">
+ <enum-type name="DirtyFlag" flags="DirtyFlags"/>
+ <enum-type name="PaintEngineFeature" flags="PaintEngineFeatures"/>
+ <enum-type name="PolygonDrawMode"/>
+ <enum-type name="Type"/>
+ <modify-function signature="begin(QPaintDevice*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="updateState(QPaintEngineState)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="drawTextItem(QPointF,QTextItem)">
+ <modify-argument index="2" invalidate-after-use="yes"/>
+ </modify-function>
+ <extra-includes>
+ <include file-name="QVarLengthArray" location="global"/>
+ </extra-includes>
+ <!-- ### "setPaintDevice(QPaintDevice*)" is an internal method. -->
+ <modify-function signature="setPaintDevice(QPaintDevice*)" remove="all"/>
+ <modify-field name="state" read="false" write="false"/>
+ </object-type>
+ <object-type name="QPainter">
+ <extra-includes>
+ <include file-name="QPainterPath" location="global"/>
+ <include file-name="QPixmap" location="global"/>
+ </extra-includes>
+ <enum-type name="CompositionMode"/>
+ <enum-type name="PixmapFragmentHint" flags="PixmapFragmentHints" since="4.7"/>
+ <enum-type name="RenderHint" flags="RenderHints"/>
+ <value-type name="PixmapFragment" since="4.7">
+ <include file-name="QPainter" location="global"/>
+ </value-type>
+
+ <!-- ### "drawText(...)" is an internal method. -->
+ <modify-function signature="drawText(const QPointF&amp;, const QString&amp;, int, int)" remove="all"/>
+
+ <template name="qpainter_drawlist">
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF.%FUNCTION_NAME(%1.data(), %1.size());
+ %END_ALLOW_THREADS
+ </template>
+
+ <modify-function signature="drawConvexPolygon(const QPoint*, int)" remove="all" />
+ <add-function signature="drawConvexPolygon(QVector&lt;QPoint>)">
+ <inject-code>
+ <insert-template name="qpainter_drawlist" />
+ </inject-code>
+ </add-function>
+ <modify-function signature="drawConvexPolygon(const QPointF*, int)" remove="all" />
+ <add-function signature="drawConvexPolygon(QVector&lt;QPointF>)">
+ <inject-code>
+ <insert-template name="qpainter_drawlist" />
+ </inject-code>
+ </add-function>
+ <!-- ### Overloads using QVector<T> does the job of these methods -->
+ <modify-function signature="drawLines(const QLine*, int)" remove="all" />
+ <modify-function signature="drawLines(const QLineF*, int)" remove="all" />
+ <modify-function signature="drawLines(const QPoint*, int)" remove="all" />
+ <modify-function signature="drawLines(const QPointF*, int)" remove="all" />
+ <modify-function signature="drawRects(const QRect*, int)" remove="all" />
+ <modify-function signature="drawRects(const QRectF*, int)" remove="all" />
+ <!-- ### -->
+ <modify-function signature="drawPoints(const QPoint*, int)" remove="all" />
+ <add-function signature="drawPoints(QVector&lt;QPoint>)">
+ <inject-code>
+ <insert-template name="qpainter_drawlist" />
+ </inject-code>
+ </add-function>
+ <modify-function signature="drawPoints(const QPointF*, int)" remove="all" />
+ <add-function signature="drawPoints(QVector&lt;QPointF>)">
+ <inject-code>
+ <insert-template name="qpainter_drawlist" />
+ </inject-code>
+ </add-function>
+ <modify-function signature="drawPolygon(const QPoint*, int, Qt::FillRule)" remove="all" />
+ <add-function signature="drawPolygon(QVector&lt;QPoint>, Qt::FillRule)">
+ <inject-code>
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF.%FUNCTION_NAME(%1.data(), %1.size(), %2);
+ %END_ALLOW_THREADS
+ </inject-code>
+ </add-function>
+ <modify-function signature="drawPolygon(const QPointF*, int, Qt::FillRule)" remove="all" />
+ <add-function signature="drawPolygon(QVector&lt;QPointF>, Qt::FillRule)">
+ <inject-code>
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF.%FUNCTION_NAME(%1.data(), %1.size(), %2);
+ %END_ALLOW_THREADS
+ </inject-code>
+ </add-function>
+ <modify-function signature="drawPolyline(const QPoint*, int)" remove="all" />
+ <add-function signature="drawPolyline(QVector&lt;QPoint>)">
+ <inject-code>
+ <insert-template name="qpainter_drawlist" />
+ </inject-code>
+ </add-function>
+ <modify-function signature="drawPolyline(const QPointF*, int)" remove="all" />
+ <add-function signature="drawPolyline(QVector&lt;QPointF>)">
+ <inject-code>
+ <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"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="QPainter(QPaintDevice*)">
+ <modify-argument index="1">
+ <no-null-pointer/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="begin(QPaintDevice*)">
+ <modify-argument index="1">
+ <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/>
+ <remove-default-expression/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="QRectF"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_args,QRectF*"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="drawText(QRect,int,QString,QRect*)">
+ <modify-argument index="4">
+ <remove-argument/>
+ <remove-default-expression/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="QRect"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_args,QRect*"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="drawText(int,int,int,int,int,QString,QRect*)">
+ <modify-argument index="7">
+ <remove-argument/>
+ <remove-default-expression/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_args,QRect*"/>
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+ <value-type name="QMatrix2x2" since="4.6">
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="repr_code_matrix">
+ <replace from="%MATRIX_SIZE" to="4" />
+ <replace from="%MATRIX_TYPE" to="float" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code_matrix">
+ <replace from="%MATRIX_TYPE" to="float" />
+ <replace from="%MATRIX_SIZE" to="4" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QMatrix2x2(PySequence*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_constructor">
+ <replace from="%SIZE" to="4" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="data()" return-type="float">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_data_function">
+ <replace from="%MATRIX_SIZE" to="4" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="fill(PyObject*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_fill_function">
+ <replace from="%MATRIX_SIZE" to="4" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="transposed()" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_transposed_function">
+ <replace from="%TRANSPOSED_TYPE" to="QMatrix2x2" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator!=(const QMatrix2x2&amp;)" return-type="bool" />
+
+ <template name="inplace_add">
+ *%CPPSELF += %1;
+ return %CONVERTTOPYTHON[%RETURN_TYPE](*%CPPSELF);
+ </template>
+ <template name="inplace_sub">
+ *%CPPSELF -= %1;
+ return %CONVERTTOPYTHON[%RETURN_TYPE](*%CPPSELF);
+ </template>
+ <template name="inplace_mult">
+ *%CPPSELF *= %1;
+ return %CONVERTTOPYTHON[%RETURN_TYPE](*%CPPSELF);
+ </template>
+ <template name="inplace_div">
+ *%CPPSELF /= %1;
+ return %CONVERTTOPYTHON[%RETURN_TYPE](*%CPPSELF);
+ </template>
+
+ <add-function signature="operator*=(float)" return-type="QMatrix2x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_mult"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+=(const QMatrix2x2&amp;)" return-type="QMatrix2x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_add"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator-=(const QMatrix2x2&amp;)" return-type="QMatrix2x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_sub"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator/=(float)" return-type="QMatrix2x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_div"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator==(const QMatrix2x2&amp;)" return-type="bool" />
+ </value-type>
+
+ <value-type name="QMatrix2x3" since="4.6">
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="repr_code_matrix">
+ <replace from="%MATRIX_SIZE" to="6" />
+ <replace from="%MATRIX_TYPE" to="float" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code_matrix">
+ <replace from="%MATRIX_TYPE" to="float" />
+ <replace from="%MATRIX_SIZE" to="6" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QMatrix2x3(PySequence*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_constructor">
+ <replace from="%SIZE" to="6" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="data()" return-type="float">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_data_function">
+ <replace from="%MATRIX_SIZE" to="6" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="fill(PyObject*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_fill_function">
+ <replace from="%MATRIX_SIZE" to="6" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="transposed()" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_transposed_function">
+ <replace from="%TRANSPOSED_TYPE" to="QMatrix3x2" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator!=(const QMatrix2x3&amp;)" return-type="bool" />
+ <add-function signature="operator*=(float)" return-type="QMatrix2x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_mult"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+=(const QMatrix2x3&amp;)" return-type="QMatrix2x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_add"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator-=(const QMatrix2x3&amp;)" return-type="QMatrix2x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_sub"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator/=(float)" return-type="QMatrix2x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_div"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator==(const QMatrix2x3&amp;)" return-type="bool" />
+ </value-type>
+
+ <value-type name="QMatrix2x4" since="4.6">
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="repr_code_matrix">
+ <replace from="%MATRIX_SIZE" to="8" />
+ <replace from="%MATRIX_TYPE" to="float" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code_matrix">
+ <replace from="%MATRIX_TYPE" to="float" />
+ <replace from="%MATRIX_SIZE" to="8" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QMatrix2x4(PySequence*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_constructor">
+ <replace from="%SIZE" to="8" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="data()" return-type="float">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_data_function">
+ <replace from="%MATRIX_SIZE" to="8" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="fill(PyObject*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_fill_function">
+ <replace from="%MATRIX_SIZE" to="8" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="transposed()" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_transposed_function">
+ <replace from="%TRANSPOSED_TYPE" to="QMatrix4x2" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator!=(const QMatrix2x4&amp;)" return-type="bool" />
+ <add-function signature="operator*=(float)" return-type="QMatrix2x4" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_mult"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+=(const QMatrix2x4&amp;)" return-type="QMatrix2x4" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_add"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator-=(const QMatrix2x4&amp;)" return-type="QMatrix2x4" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_sub"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator/=(float)" return-type="QMatrix2x4" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_div"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator==(const QMatrix2x4&amp;)" return-type="bool" />
+ </value-type>
+
+ <value-type name="QMatrix3x2" since="4.6">
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="repr_code_matrix">
+ <replace from="%MATRIX_SIZE" to="6" />
+ <replace from="%MATRIX_TYPE" to="float" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code_matrix">
+ <replace from="%MATRIX_TYPE" to="float" />
+ <replace from="%MATRIX_SIZE" to="6" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QMatrix3x2(PySequence*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_constructor">
+ <replace from="%SIZE" to="6" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="data()" return-type="float">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_data_function">
+ <replace from="%MATRIX_SIZE" to="6" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="fill(PyObject*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_fill_function">
+ <replace from="%MATRIX_SIZE" to="6" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="transposed()" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_transposed_function">
+ <replace from="%TRANSPOSED_TYPE" to="QMatrix2x3" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator!=(const QMatrix3x2&amp;)" return-type="bool" />
+ <add-function signature="operator*=(float)" return-type="QMatrix3x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_mult"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+=(const QMatrix3x2&amp;)" return-type="QMatrix3x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_add"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator-=(const QMatrix3x2&amp;)" return-type="QMatrix3x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_sub"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator/=(float)" return-type="QMatrix3x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_div"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator==(const QMatrix3x2&amp;)" return-type="bool" />
+ </value-type>
+
+ <value-type name="QMatrix3x3" since="4.6">
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="repr_code_matrix">
+ <replace from="%MATRIX_SIZE" to="9" />
+ <replace from="%MATRIX_TYPE" to="float" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code_matrix">
+ <replace from="%MATRIX_TYPE" to="float" />
+ <replace from="%MATRIX_SIZE" to="9" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QMatrix3x3(PySequence*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_constructor">
+ <replace from="%SIZE" to="9" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="data()" return-type="float">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_data_function">
+ <replace from="%MATRIX_SIZE" to="9" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="fill(PyObject*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_fill_function">
+ <replace from="%MATRIX_SIZE" to="9" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="transposed()" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_transposed_function">
+ <replace from="%TRANSPOSED_TYPE" to="QMatrix3x3" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator!=(const QMatrix3x3&amp;)" return-type="bool" />
+ <add-function signature="operator*=(float)" return-type="QMatrix3x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_mult"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+=(const QMatrix3x3&amp;)" return-type="QMatrix3x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_add"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator-=(const QMatrix3x3&amp;)" return-type="QMatrix3x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_sub"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator/=(float)" return-type="QMatrix3x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_div"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator==(const QMatrix3x3&amp;)" return-type="bool" />
+ </value-type>
+
+ <value-type name="QMatrix3x4" since="4.6">
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="repr_code_matrix">
+ <replace from="%MATRIX_SIZE" to="12" />
+ <replace from="%MATRIX_TYPE" to="float" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code_matrix">
+ <replace from="%MATRIX_TYPE" to="float" />
+ <replace from="%MATRIX_SIZE" to="12" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QMatrix3x4(PySequence*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_constructor">
+ <replace from="%SIZE" to="12" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="data()" return-type="float">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_data_function">
+ <replace from="%MATRIX_SIZE" to="12" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="fill(PyObject*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_fill_function">
+ <replace from="%MATRIX_SIZE" to="12" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="transposed()" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_transposed_function">
+ <replace from="%TRANSPOSED_TYPE" to="QMatrix4x3" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator!=(const QMatrix3x4&amp;)" return-type="bool" />
+ <add-function signature="operator*=(float)" return-type="QMatrix3x4" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_mult"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+=(const QMatrix3x4&amp;)" return-type="QMatrix3x4" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_add"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator-=(const QMatrix3x4&amp;)" return-type="QMatrix3x4" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_sub"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator/=(float)" return-type="QMatrix3x4" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_div"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator==(const QMatrix3x4&amp;)" return-type="bool" />
+ </value-type>
+
+ <value-type name="QMatrix4x2" since="4.6">
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="repr_code_matrix">
+ <replace from="%MATRIX_SIZE" to="8" />
+ <replace from="%MATRIX_TYPE" to="float" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code_matrix">
+ <replace from="%MATRIX_TYPE" to="float" />
+ <replace from="%MATRIX_SIZE" to="8" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QMatrix4x2(PySequence*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_constructor">
+ <replace from="%SIZE" to="8" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="data()" return-type="float">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_data_function">
+ <replace from="%MATRIX_SIZE" to="8" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="fill(PyObject*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_fill_function">
+ <replace from="%MATRIX_SIZE" to="8" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="transposed()" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_transposed_function">
+ <replace from="%TRANSPOSED_TYPE" to="QMatrix2x4" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator!=(const QMatrix4x2&amp;)" return-type="bool" />
+ <add-function signature="operator*=(float)" return-type="QMatrix4x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_mult"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+=(const QMatrix4x2&amp;)" return-type="QMatrix4x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_add"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator-=(const QMatrix4x2&amp;)" return-type="QMatrix4x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_sub"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator/=(float)" return-type="QMatrix4x2" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_div"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator==(const QMatrix4x2&amp;)" return-type="bool" />
+ </value-type>
+
+ <value-type name="QMatrix4x3" since="4.6">
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="repr_code_matrix">
+ <replace from="%MATRIX_SIZE" to="12" />
+ <replace from="%MATRIX_TYPE" to="float" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code_matrix">
+ <replace from="%MATRIX_TYPE" to="float" />
+ <replace from="%MATRIX_SIZE" to="12" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="QMatrix4x3(PySequence*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_constructor">
+ <replace from="%SIZE" to="12" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="data()" return-type="float">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_data_function">
+ <replace from="%MATRIX_SIZE" to="12" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="fill(PyObject*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_fill_function">
+ <replace from="%MATRIX_SIZE" to="12" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="transposed()" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_transposed_function">
+ <replace from="%TRANSPOSED_TYPE" to="QMatrix3x4" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator!=(const QMatrix4x3&amp;)" return-type="bool" />
+ <add-function signature="operator*=(float)" return-type="QMatrix4x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_mult"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+=(const QMatrix4x3&amp;)" return-type="QMatrix4x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_add"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator-=(const QMatrix4x3&amp;)" return-type="QMatrix4x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_sub"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator/=(float)" return-type="QMatrix4x3" >
+ <inject-code class="target" position="beginning">
+ <insert-template name="inplace_div"/>
+ </inject-code>
+ </add-function>
+ <add-function signature="operator==(const QMatrix4x3&amp;)" return-type="bool" />
+ </value-type>
+
+ <value-type name="QMatrix4x4" since="4.6">
+
+
+ <!-- Qt5: HAIRY TRICK ALERT ahead!
+ Qt5 partially replaced 'qreal' by float.
+ That had the side effect that all matrix types did not work any longer.
+
+ Reason (I guess):
+
+ The signature "QList<qreal>" is needed by the __reduce__ methods,
+ but created by some other object used elsewhere.
+ After the matrix type was changed, "QList<float>" was nowhere created.
+
+ I don't know an explicit way to produce the right conversion function, so what I did
+ was to create a dummy function and immediately dele it again.
+ This has the desired effect of creating the implicitly needed "QList<float>"
+ conversion, although the dummy function goes away.
+
+ Q: Do you know a better solution?
+ -->
+ <add-function signature="__dummy(const QList&lt;float &gt; &amp;)"/>
+ <modify-function signature="__dummy(const QList&lt;float &gt; &amp;)" remove="all"/>
+ <!-- that was the trick ^^^^^^^^^^^^^^^^^^^^^^ -->
+
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="repr_code_matrix">
+ <replace from="%MATRIX_SIZE" to="16" />
+ <replace from="%MATRIX_TYPE" to="float" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="reduce_code_matrix">
+ <replace from="%MATRIX_TYPE" to="float" />
+ <replace from="%MATRIX_SIZE" to="16" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <!-- ### "QMatrix4x4(const float*,int,int)" is an internal constructor. -->
+ <modify-function signature="QMatrix4x4(const float*,int,int)" remove="all"/>
+
+ <modify-function signature="QMatrix4x4(const float*)">
+ <modify-argument index="1">
+ <replace-type modified-type="PySequence" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ if (PySequence_Size(%PYARG_1) == 16) {
+ float values[16];
+ for(int i=0; i &lt; 16; i++) {
+ PyObject *pv = PySequence_Fast_GET_ITEM(%PYARG_1, i);
+ values[i] = PyFloat_AsDouble(pv);
+ }
+
+ %0 = new %TYPE(values[0], values[1], values[2], values[3],
+ values[4], values[5], values[6], values[7],
+ values[8], values[9], values[10], values[11],
+ values[12], values[13], values[14], values[15]);
+ }
+ </inject-code>
+ </modify-function>
+ <modify-function signature="data()">
+ <inject-code class="target" position="beginning">
+ <insert-template name="matrix_data_function">
+ <replace from="%MATRIX_SIZE" to="16" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="copyDataTo(float *) const">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyTupleObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ float values[16];
+ %CPPSELF.%FUNCTION_NAME(values);
+ %PYARG_0 = PyTuple_New(16);
+ for(int i=0; i &lt; 16; i++) {
+ PyObject *v = PyFloat_FromDouble(values[i]);
+ PyTuple_SET_ITEM(%PYARG_0, i, v);
+ }
+ </inject-code>
+ </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>
+
+ <!-- ### "constData() const" and "data() const" are unnecessary in Python and their function is performed by "data()". -->
+ <modify-function signature="data() const" remove="all"/>
+ <modify-function signature="constData() const" remove="all"/>
+ <!-- ### -->
+ <modify-function signature="operator()(int, int) const" remove="all"/>
+ <modify-function signature="operator()(int, int)" remove="all"/>
+ <add-function signature="__mgetitem__" return-type="PyObject*">
+ <inject-code>
+ if (PySequence_Check(_key)) {
+ Shiboken::AutoDecRef key(PySequence_Fast(_key, "Invalid matrix index."));
+ if (PySequence_Fast_GET_SIZE(key.object()) == 2) {
+ PyObject* posx = PySequence_Fast_GET_ITEM(key.object(), 0);
+ PyObject* posy = PySequence_Fast_GET_ITEM(key.object(), 1);
+ Py_ssize_t x = PyInt_AsSsize_t(posx);
+ Py_ssize_t y = PyInt_AsSsize_t(posy);
+ float ret = (*%CPPSELF)(x,y);
+ return %CONVERTTOPYTHON[float](ret);
+ }
+ }
+ PyErr_SetString(PyExc_IndexError, "Invalid matrix index.");
+ return 0;
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ _______ end of matrix block _______ -->
+
+
+ <value-type name="QQuaternion" since="4.6">
+ <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" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.scalar(), %CPPSELF.x(), %CPPSELF.y(), %CPPSELF.z()" />
+ </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="dddd" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.scalar(), %CPPSELF.x(), %CPPSELF.y(), %CPPSELF.z()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <!-- Qt5.5: XXX support the output variables! For now, I just suppressed the new methods. -->
+ <modify-function signature="getAxisAndAngle(float *, float *, float *, float *) const" since="5.5" remove="all" />
+ <modify-function signature="getAxisAndAngle(QVector3D *, float *) const" since="5.5" remove="all" />
+ <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="QTouchDevice">
+ <enum-type name="CapabilityFlag" flags="Capabilities" />
+ <enum-type name="DeviceType" />
+ </object-type>
+
+ <value-type name="QVector2D" since="4.6">
+ <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" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" />
+ </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="dd" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="toTuple" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="to_tuple">
+ <replace from="%TT_FORMAT" to="dd" />
+ <replace from="%TT_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ </value-type>
+ <value-type name="QVector3D" since="4.6">
+ <extra-includes>
+ <include file-name="QMatrix4x4" 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" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.z()" />
+ </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="ddd" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.z()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="toTuple" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="to_tuple">
+ <replace from="%TT_FORMAT" to="ddd" />
+ <replace from="%TT_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.z()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ </value-type>
+ <value-type name="QVector4D" since="4.6">
+ <extra-includes>
+ <include file-name="QMatrix4x4" 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" />
+ <replace from="%REPR_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.z(), %CPPSELF.w()" />
+ </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="dddd" />
+ <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.z(), %CPPSELF.w()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="toTuple" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="to_tuple">
+ <replace from="%TT_FORMAT" to="dddd" />
+ <replace from="%TT_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.z(), %CPPSELF.w()" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ <suppress-warning text="template baseclass 'QListSpecialMethods&lt;T&gt;' of 'QList' is not known"/>
+ <suppress-warning text="template baseclass 'QGenericMatrix&lt;float&gt;' of '*' is not known"/>
+
+ <!-- Qt5: note: the unnamed enum cannot be rejected by
+ <rejection class="QMatrix4x4" enum-name="enum_1"/>
+ Instead, we have to suppress the warning. Why that?
+
+ Compare also the note at the beginning of typesystem_widgets_common.xml .
+ This seems to be a related problem with unnamed structures in shiboken.
+ -->
+ <suppress-warning text="enum 'QMatrix4x4::enum_1' is specified in typesystem, but not declared"/>
+
+ <object-type name="QSessionManager">
+ <extra-includes>
+ </extra-includes>
+ <enum-type name="RestartHint"/>
+ <!-- ### -->
+ </object-type>
+
+ <!-- This enum is present on QtCore -->
+ <suppress-warning text="enum 'QCoreApplication::ApplicationFlags' is specified in typesystem, but not declared" />
+
+ <!-- Qt5: here the new QWindow stuff and what it pulls in -->
+ <object-type name="QBackingStore"/>
+ <object-type name="QSurface">
+ <enum-type name="SurfaceClass"/>
+ <enum-type name="SurfaceType"/>
+ </object-type>
+ <rejection class="QSurface" field-name="m_reserved"/>
+ <value-type name="QSurfaceFormat">
+ <enum-type name="ColorSpace" since="5.10"/>
+ <enum-type name="FormatOption" flags="FormatOptions"/>
+ <enum-type name="OpenGLContextProfile"/>
+ <enum-type name="RenderableType"/>
+ <enum-type name="SwapBehavior"/>
+ </value-type>
+ <primitive-type name="QPlatformSurface">
+ <extra-includes>
+ <include file-name="QtGui/qpa/qplatformsurface.h" location="global"/>
+ </extra-includes>
+ </primitive-type>
+
+ <object-type name="QWindow">
+ <enum-type name="AncestorMode"/>
+ <enum-type name="Visibility"/>
+ </object-type>
+ <!-- Qt5: not sure if this needs support, skipped for now -->
+ <rejection class="QWindow" function-name="nativeEvent"/>"
+
+ <!-- Qt5: here the new QGuiApplication and related things -->
+ <object-type name="QGuiApplication">
+ <!-- Qt5: gone <enum-type name="ColorSpec"/> -->
+ <!-- Qt5: gone <enum-type name="Type"/> -->
+ <extra-includes>
+ <include file-name="QBasicTimer" location="global"/>
+ <include file-name="QFont" location="global"/>
+ <include file-name="QFontMetrics" location="global"/>
+ <include file-name="QPalette" location="global"/>
+ <include file-name="QIcon" location="global"/>
+ <include file-name="QLocale" location="global"/>
+ </extra-includes>
+ <modify-function signature="QGuiApplication(int&amp;,char**,int)" access="private" />
+ <add-function signature="QGuiApplication(PySequence)">
+ <inject-code>
+ QGuiApplicationConstructor(%PYSELF, %1, &amp;%0);
+ </inject-code>
+ </add-function>
+ <modify-function signature="exec()" rename="exec_" allow-thread="yes"/>
+ <inject-code class="native" file="glue/qguiapplication_init.cpp" position="beginning" />
+
+ </object-type>
+
+ <value-type name="QAccessible">
+ <value-type name="State"/>
+ <enum-type name="Role"/>
+ <enum-type name="Text"/>
+ <enum-type name="RelationFlag"/>
+ <enum-type name="InterfaceType"/>
+ <enum-type name="TextBoundaryType"/>
+ <enum-type name="Event"/>
+ </value-type>
+ <object-type name="QAccessibleInterface">
+ </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="QOpenGLFramebufferObject">
+ <enum-type name="Attachment" />
+ <enum-type name="FramebufferRestorePolicy" since="5.7"/>
+ </object-type>
+ <object-type name="QOpenGLShader" >
+ <enum-type name="ShaderTypeBit" flags="ShaderType" />
+ </object-type>
+ <!-- Temporarily disable type, because it causes segfault on Linux due to incorrect parsing
+ of the void setUniformValue(const char *name, const GLfloat value[2][2]); method.
+ The float[][] ends up with an "Array" cpp signature, which obviously can't be found in the
+ typesystem.
+ <object-type name="QOpenGLShaderProgram" />
+ -->
+ <value-type name="QPageLayout">
+ <enum-type name="Mode"/>
+ <enum-type name="Orientation"/>
+ <enum-type name="Unit"/>
+ </value-type>
+ <value-type name="QPageSize">
+ <enum-type name="PageSizeId"/>
+ <enum-type name="Unit"/>
+ <enum-type name="SizeMatchPolicy"/>
+ </value-type>
+ <object-type name="QPaintDeviceWindow"/>
+ <value-type name="QPixelFormat">
+ <enum-type name="AlphaUsage"/>
+ <enum-type name="AlphaPosition"/>
+ <enum-type name="AlphaPremultiplied"/>
+ <enum-type name="ByteOrder"/>
+ <enum-type name="ColorModel"/>
+ <enum-type name="TypeInterpretation"/>
+ <enum-type name="YUVLayout"/>
+ </value-type>
+ <object-type name="QPdfWriter"/>
+ <value-type name="QRawFont">
+ <enum-type name="AntialiasingType"/>
+ <enum-type name="LayoutFlag" flags="LayoutFlags"/>
+ <modify-function signature="advancesForGlyphIndexes(const quint32*,QPointF*,int)const" remove="all"/>
+ <modify-function signature="advancesForGlyphIndexes(const quint32*,QPointF*,int,QFlags&lt;QRawFont::LayoutFlag&gt;)const" remove="all"/>
+ <modify-function signature="glyphIndexesForChars(const QChar*,int,quint32*,int*)const" remove="all"/>
+ </value-type>
+ <object-type name="QRasterWindow"/>
+ <object-type name="QScreen" />
+ <object-type name="QStyleHints"/>
+
+</typesystem>
+
+
diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_mac.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_mac.xml
new file mode 100644
index 000000000..76a092d34
--- /dev/null
+++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_mac.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtGui">
+ <rejection class="*" function-name="qt_mac_set_cursor"/>
+ <rejection class="*" function-name="macMenu"/>
+
+ <primitive-type name="Qt::HANDLE" target-lang-api-name="PyObject"/>
+
+ <suppress-warning text="enum 'QSysInfo::Endian' is specified in typesystem, but not declared" />
+ <suppress-warning text="type 'QGtkStyle' is specified in typesystem, but not defined. This could potentially lead to compilation errors." />
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_win.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_win.xml
new file mode 100644
index 000000000..eb8631cc0
--- /dev/null
+++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_win.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtGui"/>
diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_x11.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_x11.xml
new file mode 100644
index 000000000..eb8631cc0
--- /dev/null
+++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_x11.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtGui"/>
diff --git a/sources/pyside2/PySide2/QtHelp/CMakeLists.txt b/sources/pyside2/PySide2/QtHelp/CMakeLists.txt
new file mode 100644
index 000000000..ba8b419f3
--- /dev/null
+++ b/sources/pyside2/PySide2/QtHelp/CMakeLists.txt
@@ -0,0 +1,51 @@
+project(QtHelp)
+
+set(QtHelp_SRC
+${QtHelp_GEN_DIR}/qhelpcontentitem_wrapper.cpp
+${QtHelp_GEN_DIR}/qhelpcontentmodel_wrapper.cpp
+${QtHelp_GEN_DIR}/qhelpcontentwidget_wrapper.cpp
+${QtHelp_GEN_DIR}/qhelpenginecore_wrapper.cpp
+${QtHelp_GEN_DIR}/qhelpengine_wrapper.cpp
+${QtHelp_GEN_DIR}/qhelpindexmodel_wrapper.cpp
+${QtHelp_GEN_DIR}/qhelpindexwidget_wrapper.cpp
+${QtHelp_GEN_DIR}/qhelpsearchengine_wrapper.cpp
+${QtHelp_GEN_DIR}/qhelpsearchquerywidget_wrapper.cpp
+${QtHelp_GEN_DIR}/qhelpsearchquery_wrapper.cpp
+${QtHelp_GEN_DIR}/qhelpsearchresultwidget_wrapper.cpp
+# module is always needed
+${QtHelp_GEN_DIR}/qthelp_module_wrapper.cpp
+)
+
+make_path(QtHelp_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtWidgets_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtWidgets_BINARY_DIR}
+ ${QtHelp_SOURCE_DIR})
+
+set(QtHelp_include_dirs ${QtHelp_SOURCE_DIR}
+ ${QtHelp_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5Help_INCLUDE_DIRS}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${QtWidgets_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtCore_GEN_DIR}
+ )
+set(QtHelp_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ ${Qt5Help_LIBRARIES})
+
+set(QtHelp_deps QtWidgets)
+
+create_pyside_module(QtHelp
+ QtHelp_include_dirs
+ QtHelp_libraries
+ QtHelp_deps
+ QtHelp_typesystem_path
+ QtHelp_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtHelp/typesystem_help.xml b/sources/pyside2/PySide2/QtHelp/typesystem_help.xml
new file mode 100644
index 000000000..4d42e7fb9
--- /dev/null
+++ b/sources/pyside2/PySide2/QtHelp/typesystem_help.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtHelp">
+ <load-typesystem name="typesystem_widgets.xml" generate="no" />
+
+ <value-type name="QHelpContentItem">
+ <modify-function signature="parent() const">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+ <object-type name="QHelpContentModel" polymorphic-id-expression="qobject_cast&lt;QHelpContentModel*&gt;(%1)"/>
+ <object-type name="QHelpContentWidget"/>
+ <object-type name="QHelpEngine" />
+ <object-type name="QHelpEngineCore"/>
+ <object-type name="QHelpIndexModel"/>
+ <object-type name="QHelpIndexWidget"/>
+ <object-type name="QHelpSearchEngine"/>
+ <value-type name="QHelpSearchQuery">
+ <enum-type name="FieldName"/>
+ </value-type>
+ <object-type name="QHelpSearchQueryWidget"/>
+ <object-type name="QHelpSearchResultWidget"/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtMacExtras/CMakeLists.txt b/sources/pyside2/PySide2/QtMacExtras/CMakeLists.txt
new file mode 100644
index 000000000..a98f18e69
--- /dev/null
+++ b/sources/pyside2/PySide2/QtMacExtras/CMakeLists.txt
@@ -0,0 +1,43 @@
+project(QtMacExtras)
+
+set(QtMacExtras_SRC
+${QtMacExtras_GEN_DIR}/qmacpasteboardmime_wrapper.cpp
+${QtMacExtras_GEN_DIR}/qmactoolbar_wrapper.cpp
+${QtMacExtras_GEN_DIR}/qmactoolbaritem_wrapper.cpp
+
+# module is always needed
+${QtMacExtras_GEN_DIR}/QtMacExtras_module_wrapper.cpp
+)
+
+make_path(QtMacExtras_typesystem_path ${QtMacExtras_SOURCE_DIR}
+ ${QtCore_SOURCE_DIR}
+ ${QtCore_BINARY_DIR}
+ ${QtGui_SOURCE_DIR}
+ ${QtGui_BINARY_DIR})
+
+set(QtMacExtras_include_dirs ${QtMacExtras_SOURCE_DIR}
+ ${QtMacExtras_BINARY_DIR}
+ ${Qt5MacExtras_INCLUDE_DIRS}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR})
+
+set(QtMacExtras_libraries pyside2
+ ${Qt5MacExtras_LIBRARIES}
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES})
+
+set(QtMacExtras_deps QtCore QtGui)
+
+create_pyside_module(QtMacExtras
+ QtMacExtras_include_dirs
+ QtMacExtras_libraries
+ QtMacExtras_deps
+ QtMacExtras_typesystem_path
+ QtMacExtras_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtMacExtras/typesystem_macextras.xml b/sources/pyside2/PySide2/QtMacExtras/typesystem_macextras.xml
new file mode 100644
index 000000000..55c7d0160
--- /dev/null
+++ b/sources/pyside2/PySide2/QtMacExtras/typesystem_macextras.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtMacExtras">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+ <load-typesystem name="typesystem_gui.xml" generate="no"/>
+
+ <function signature="qRegisterDraggedTypes(QStringList)" since="5.2"/>
+
+ <object-type name="QMacPasteboardMime" since="5.2">
+ <enum-type name="QMacPasteboardMimeType"/>
+ </object-type>
+ <object-type name="QMacToolBar" since="5.3"/>
+ <object-type name="QMacToolBarItem" since="5.3">
+ <enum-type name="StandardItem"/>
+ </object-type>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtMultimedia/CMakeLists.txt b/sources/pyside2/PySide2/QtMultimedia/CMakeLists.txt
new file mode 100644
index 000000000..a17455eec
--- /dev/null
+++ b/sources/pyside2/PySide2/QtMultimedia/CMakeLists.txt
@@ -0,0 +1,118 @@
+project(QtMultimedia)
+
+set(QtMultimedia_SRC
+${QtMultimedia_GEN_DIR}/qabstractaudiodeviceinfo_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qabstractaudioinput_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qabstractaudiooutput_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qabstractvideobuffer_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qabstractvideofilter_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qabstractvideosurface_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudiobuffer_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudiodecoder_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudiodecodercontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudiodeviceinfo_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudioencodersettingscontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudioencodersettings_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudioformat_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudioinputselectorcontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudioinput_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudiooutputselectorcontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudiooutput_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudioprobe_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudiorecorder_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudiorolecontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qaudio_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcameracapturebufferformatcontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcameracapturedestinationcontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcameracontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcameraexposurecontrol_wrapper.cpp
+# Private destructor: ${QtMultimedia_GEN_DIR}/qcameraexposure_wrapper.cpp
+# Private destructor: ${${QtMultimedia_GEN_DIR}/qcamerafocus_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcamerafocuszone_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcamera_frameraterange_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcameraimagecapturecontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcameraimagecapture_wrapper.cpp
+# Private destructor: ${QtMultimedia_GEN_DIR}/qcameraimageprocessing_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcameraimageprocessingcontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcamerainfocontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcamerainfo_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcameralockscontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcameraviewfindersettingscontrol2_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcameraviewfindersettingscontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcameraviewfindersettings_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcamera_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qcamerazoomcontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qimageencodercontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qimageencodersettings_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediaaudioprobecontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediaavailabilitycontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediabindableinterface_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediacontainercontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediacontent_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediacontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediagaplessplaybackcontrol_wrapper.cpp
+# Causes compile errors: ${QtMultimedia_GEN_DIR}/qmediametadata_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmedianetworkaccesscontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediaobject_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediaplayercontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediaplayer_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediaplaylist_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediarecordercontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediarecorder_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediaresource_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmediatimerange_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qmultimedia_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qradiodatacontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qradiodata_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qradiotunercontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qradiotuner_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qsoundeffect_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qsound_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qvideodeviceselectorcontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qvideoencodersettingscontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qvideoencodersettings_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qvideofilterrunnable_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qvideoframe_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qvideoprobe_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qvideorenderercontrol_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qvideosurfaceformat_wrapper.cpp
+${QtMultimedia_GEN_DIR}/qvideowindowcontrol_wrapper.cpp
+
+# module is always needed
+${QtMultimedia_GEN_DIR}/qtmultimedia_module_wrapper.cpp
+)
+
+make_path(QtMultimedia_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtNetwork_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtNetwork_BINARY_DIR}
+ ${QtMultimedia_SOURCE_DIR})
+
+set(QtMultimedia_include_dirs ${QtMultimedia_SOURCE_DIR}
+ ${QtMultimedia_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Network_INCLUDE_DIRS}
+ ${Qt5Multimedia_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtNetwork_GEN_DIR})
+
+set(QtMultimedia_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Multimedia_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Network_LIBRARIES}
+ )
+set(QtMultimedia_deps QtCore QtGui QtNetwork)
+
+create_pyside_module(QtMultimedia
+ QtMultimedia_include_dirs
+ QtMultimedia_libraries
+ QtMultimedia_deps
+ QtMultimedia_typesystem_path
+ QtMultimedia_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia.xml b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia.xml
new file mode 100644
index 000000000..275719f59
--- /dev/null
+++ b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtMultimedia">
+ <load-typesystem name="typesystem_multimedia_common.xml" generate="yes"/>
+ <load-typesystem name="typesystem_multimedia_forward_declarations.xml" generate="yes"/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml
new file mode 100644
index 000000000..9565b4334
--- /dev/null
+++ b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml
@@ -0,0 +1,365 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtMultimedia">
+ <load-typesystem name="typesystem_core.xml" generate="no" />
+ <load-typesystem name="typesystem_gui.xml" generate="no" />
+ <load-typesystem name="typesystem_network.xml" generate="no" />
+
+ <namespace-type name="QAudio">
+ <enum-type name="Error"/>
+ <enum-type name="Mode"/>
+ <enum-type name="Role" since="5.6"/>
+ <enum-type name="State"/>
+ <enum-type name="VolumeScale" since="5.8"/>
+ </namespace-type>
+
+ <value-type name="QVideoSurfaceFormat">
+ <enum-type name="Direction"/>
+ <enum-type name="YCbCrColorSpace"/>
+ </value-type>
+ <object-type name="QAbstractVideoBuffer">
+ <enum-type name="HandleType"/>
+ <enum-type name="MapMode"/>
+ <modify-function signature="map(QAbstractVideoBuffer::MapMode, int*, int*)" remove="all"/>
+ <!-- TODO: discuss a way to have this working with the virtual method.
+ <modify-function signature="map(QAbstractVideoBuffer::MapMode, int*, int*)">
+ <modify-argument index="0">
+ <replace-type modified-type="PyObject"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="3">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_arg,int*,int*"/>
+ </inject-code>
+ </modify-function>
+ -->
+ <!-- TODO: PYSIDE-354, arrays are not supported -->
+ <modify-function signature="mapPlanes(QAbstractVideoBuffer::MapMode,int*,Array,Array)" remove="all"/>
+ </object-type>
+ <object-type name="QAbstractVideoSurface">
+ <enum-type name="Error"/>
+ </object-type>
+ <object-type name="QAbstractVideoFilter"/>
+ <value-type name="QVideoFrame">
+ <enum-type name="FieldType"/>
+ <enum-type name="PixelFormat"/>
+ <modify-function signature="bits(int)" remove="all"/>
+ <modify-function signature="bits(int) const" remove="all"/>
+ </value-type>
+
+ <value-type name="QAudioBuffer"/>
+ <object-type name="QAudioDecoder">
+ <enum-type name="Error"/>
+ <enum-type name="State"/>
+ </object-type>
+ <value-type name="QAudioFormat">
+ <enum-type name="Endian"/>
+ <enum-type name="SampleType"/>
+ </value-type>
+ <value-type name="QAudioDeviceInfo"/>
+ <object-type name="QAbstractAudioDeviceInfo"/>
+
+ <object-type name="QAbstractAudioOutput">
+ <modify-function signature="start()">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="start(QIODevice *)">
+ <modify-argument index="1">
+ <define-ownership class="target" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QAbstractAudioInput">
+ <modify-function signature="start()">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="start(QIODevice *)">
+ <modify-argument index="1">
+ <define-ownership class="target" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QAudioDecoderControl"/>
+ <object-type name="QAudioProbe"/>
+ <value-type name="QAudioEncoderSettings"/>
+ <object-type name="QAudioEncoderSettingsControl">
+ <modify-function signature="supportedSampleRates(const QAudioEncoderSettings &amp;, bool *) const" remove="all"/>
+ </object-type>
+
+ <object-type name="QAudioInput">
+ <modify-function signature="start()">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="start(QIODevice*)">
+ <modify-argument index="1">
+ <define-ownership class="target" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QAudioInputSelectorControl"/>
+
+ <object-type name="QAudioOutput">
+ <modify-function signature="start()">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="start(QIODevice*)">
+ <modify-argument index="1">
+ <define-ownership class="target" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QAudioOutputSelectorControl"/>
+ <object-type name="QAudioRecorder"/>
+ <object-type name="QAudioRoleControl"/>
+
+ <object-type name="QCamera">
+ <value-type name="FrameRateRange"/>
+ <enum-type name="CaptureMode" flags="CaptureModes"/>
+ <enum-type name="Error"/>
+ <enum-type name="LockChangeReason"/>
+ <enum-type name="LockStatus"/>
+ <enum-type name="LockType" flags="LockTypes"/>
+ <enum-type name="Position"/>
+ <enum-type name="State"/>
+ <enum-type name="Status"/>
+ <modify-function signature="setViewfinder(QVideoWidget *)">
+ <modify-argument index="1">
+ <replace-type modified-type="QObject *" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ %BEGIN_ALLOW_THREADS
+ QObject* upcastedArg = %CONVERTTOCPP[QObject*](%PYARG_1);
+ %CPPSELF.%FUNCTION_NAME(reinterpret_cast&lt; %ARG1_TYPE &gt;(upcastedArg));
+ %END_ALLOW_THREADS
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setViewfinder(QGraphicsVideoItem *)">
+ <modify-argument index="1">
+ <replace-type modified-type="QObject *" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ %BEGIN_ALLOW_THREADS
+ QObject* upcastedArg = %CONVERTTOCPP[QObject*](%PYARG_1);
+ %CPPSELF.%FUNCTION_NAME(reinterpret_cast&lt; %ARG1_TYPE &gt;(upcastedArg));
+ %END_ALLOW_THREADS
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QCameraCaptureBufferFormatControl"/>
+ <object-type name="QCameraCaptureDestinationControl"/>
+ <object-type name="QCameraControl">
+ <enum-type name="PropertyChangeType"/>
+ </object-type>
+ <!-- Private destructor
+ <object-type name="QCameraExposure">
+ <enum-type name="FlashMode" flags="FlashModes"/>
+ <enum-type name="ExposureMode"/>
+ <enum-type name="MeteringMode"/>
+ <modify-function signature="supportedApertures(bool *) const" remove="all"/>
+ <modify-function signature="supportedIsoSensitivities(bool *) const" remove="all"/>
+ <modify-function signature="supportedShutterSpeeds(bool *) const" remove="all"/>
+ </object-type>
+ -->
+ <object-type name="QCameraExposureControl">
+ <enum-type name="ExposureParameter"/>
+ <modify-function signature="supportedParameterRange(QCameraExposureControl::ExposureParameter, bool *) const" remove="all"/>
+ </object-type>
+ <value-type name="QCameraFocusZone">
+ <enum-type name="FocusZoneStatus"/>
+ </value-type>
+ <!-- Private destructor
+ <object-type name="QCameraFocus">
+ <enum-type name="FocusMode" flags="FocusModes"/>
+ <enum-type name="FocusPointMode"/>
+ </object-type>
+ -->
+ <value-type name="QCameraInfo"/>
+ <object-type name="QCameraInfoControl"/>
+ <object-type name="QCameraImageCapture">
+ <enum-type name="CaptureDestination" flags="CaptureDestinations"/>
+ <enum-type name="DriveMode"/>
+ <enum-type name="Error"/>
+ <modify-function signature="supportedResolutions(const QImageEncoderSettings &amp;, bool *) const" remove="all"/>
+ </object-type>
+ <object-type name="QCameraImageCaptureControl"/>
+ <!-- Private destructor
+ <object-type name="QCameraImageProcessing">
+ <enum-type name="WhiteBalanceMode"/>
+ <enum-type name="ColorFilter"/>
+ </object-type>
+ -->
+ <object-type name="QCameraImageProcessingControl">
+ <enum-type name="ProcessingParameter"/>
+ </object-type>
+ <object-type name="QCameraLocksControl"/>
+ <value-type name="QCameraViewfinderSettings"/>
+ <object-type name="QCameraViewfinderSettingsControl">
+ <enum-type name="ViewfinderParameter"/>
+ </object-type>
+ <object-type name="QCameraViewfinderSettingsControl2"/>
+ <object-type name="QCameraZoomControl"/>
+
+ <value-type name="QImageEncoderSettings"/>
+ <object-type name="QImageEncoderControl">
+ <modify-function signature="supportedResolutions(const QImageEncoderSettings &amp;, bool *) const" remove="all"/>
+ </object-type>
+
+ <object-type name="QMediaAudioProbeControl"/>
+ <object-type name="QMediaAvailabilityControl"/>
+ <object-type name="QMediaBindableInterface"/>
+ <object-type name="QMediaContainerControl"/>
+ <value-type name="QMediaContent"/>
+ <object-type name="QMediaGaplessPlaybackControl"/>
+ <object-type name="QMediaControl"/>
+ <object-type name="QMediaNetworkAccessControl"/>
+ <!-- Causes compile errors
+ <namespace-type name="QMediaMetaData"/>
+ -->
+ <object-type name="QMediaObject"/>
+ <object-type name="QMediaPlayer">
+ <enum-type name="State"/>
+ <enum-type name="MediaStatus"/>
+ <enum-type name="Flag" flags="Flags"/>
+ <enum-type name="Error"/>
+ <modify-function signature="setVideoOutput(QVideoWidget *)">
+ <modify-argument index="1">
+ <replace-type modified-type="QObject *" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ %BEGIN_ALLOW_THREADS
+ QObject* upcastedArg = %CONVERTTOCPP[QObject*](%PYARG_1);
+ %CPPSELF.%FUNCTION_NAME(reinterpret_cast&lt; %ARG1_TYPE &gt;(upcastedArg));
+ %END_ALLOW_THREADS
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setVideoOutput(QGraphicsVideoItem *)">
+ <modify-argument index="1">
+ <replace-type modified-type="QObject *" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ %BEGIN_ALLOW_THREADS
+ QObject* upcastedArg = %CONVERTTOCPP[QObject*](%PYARG_1);
+ %CPPSELF.%FUNCTION_NAME(reinterpret_cast&lt; %ARG1_TYPE &gt;(upcastedArg));
+ %END_ALLOW_THREADS
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QMediaPlayerControl"/>
+ <object-type name="QMediaPlaylist">
+ <enum-type name="PlaybackMode"/>
+ <enum-type name="Error"/>
+ </object-type>
+ <object-type name="QMediaRecorder">
+ <enum-type name="Error"/>
+ <enum-type name="State"/>
+ <enum-type name="Status"/>
+ <modify-function signature="supportedAudioSampleRates(const QAudioEncoderSettings &amp;, bool *) const" remove="all"/>
+ <modify-function signature="supportedFrameRates(const QVideoEncoderSettings &amp;, bool *) const" remove="all"/>
+ <modify-function signature="supportedResolutions(const QVideoEncoderSettings &amp;, bool *) const" remove="all"/>
+ </object-type>
+ <object-type name="QMediaRecorderControl"/>
+ <value-type name="QMediaResource"/>
+ <value-type name="QMediaTimeRange"/>
+
+ <namespace-type name="QMultimedia">
+ <enum-type name="SupportEstimate"/>
+ <enum-type name="EncodingQuality"/>
+ <enum-type name="EncodingMode"/>
+ <enum-type name="AvailabilityStatus"/>
+ </namespace-type>
+
+ <object-type name="QRadioData">
+ <enum-type name="Error"/>
+ <enum-type name="ProgramType"/>
+ </object-type>
+ <object-type name="QRadioDataControl"/>
+ <object-type name="QRadioTuner">
+ <enum-type name="Band"/>
+ <enum-type name="Error"/>
+ <enum-type name="SearchMode"/>
+ <enum-type name="State"/>
+ <enum-type name="StereoMode"/>
+ </object-type>
+ <object-type name="QRadioTunerControl"/>
+ <object-type name="QSound">
+ <enum-type name="Loop"/>
+ </object-type>
+ <object-type name="QSoundEffect">
+ <enum-type name="Loop"/>
+ <enum-type name="Status"/>
+ </object-type>
+
+ <object-type name="QVideoDeviceSelectorControl"/>
+ <value-type name="QVideoEncoderSettings"/>
+ <object-type name="QVideoEncoderSettingsControl">
+ <modify-function signature="supportedFrameRates(const QVideoEncoderSettings &amp;, bool *) const" remove="all"/>
+ <modify-function signature="supportedResolutions(const QVideoEncoderSettings &amp;, bool *) const" remove="all"/>
+ </object-type>
+ <object-type name="QVideoFilterRunnable">
+ <enum-type name="RunFlag" flags="RunFlags"/>
+ </object-type>
+ <object-type name="QVideoProbe"/>
+ <object-type name="QVideoRendererControl"/>
+ <object-type name="QVideoWindowControl"/>
+
+ <suppress-warning text="Final class 'QMediaObject' set to non-final, as it is extended by other classes"/>
+ <suppress-warning text="Pure virtual method 'QAbstractVideoBuffer::map(QAbstractVideoBuffer::MapMode,int*,int*)' must be implement but was completely removed on type system."/>
+ <suppress-warning text="Pure virtual method 'QImageEncoderControl::supportedResolutions(QImageEncoderSettings,bool*)const' must be implement but was completely removed on type system."/>
+ <suppress-warning text="Pure virtual method 'QCameraExposureControl::supportedParameterRange(QCameraExposureControl::ExposureParameter,bool*)const' must be implement but was completely removed on type system."/>
+ <suppress-warning text="Pure virtual method 'QVideoEncoderSettingsControl::supportedFrameRates(QVideoEncoderSettings,bool*)const' must be implement but was completely removed on type system."/>
+ <suppress-warning text="Pure virtual method 'QVideoEncoderSettingsControl::supportedResolutions(QVideoEncoderSettings,bool*)const' must be implement but was completely removed on type system."/>
+ <suppress-warning text="Pure virtual method 'QAudioEncoderSettingsControl::supportedSampleRates(QAudioEncoderSettings,bool*)const' must be implement but was completely removed on type system."/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_forward_declarations.xml b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_forward_declarations.xml
new file mode 100644
index 000000000..df6e28c85
--- /dev/null
+++ b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_forward_declarations.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtMultimedia">
+ <custom-type name="QVideoWidget"/>
+ <custom-type name="QGraphicsVideoItem"/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtMultimediaWidgets/CMakeLists.txt b/sources/pyside2/PySide2/QtMultimediaWidgets/CMakeLists.txt
new file mode 100644
index 000000000..1368fc3aa
--- /dev/null
+++ b/sources/pyside2/PySide2/QtMultimediaWidgets/CMakeLists.txt
@@ -0,0 +1,52 @@
+project(QtMultimediaWidgets)
+
+set(QtMultimediaWidgets_SRC
+${QtMultimediaWidgets_GEN_DIR}/qcameraviewfinder_wrapper.cpp
+${QtMultimediaWidgets_GEN_DIR}/qgraphicsvideoitem_wrapper.cpp
+${QtMultimediaWidgets_GEN_DIR}/qvideowidget_wrapper.cpp
+${QtMultimediaWidgets_GEN_DIR}/qvideowidgetcontrol_wrapper.cpp
+# module is always needed
+${QtMultimediaWidgets_GEN_DIR}/qtmultimediawidgets_module_wrapper.cpp
+)
+
+make_path(QtMultimediaWidgets_typesystem_path
+ ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtNetwork_SOURCE_DIR} ${QtWidgets_SOURCE_DIR} ${QtMultimedia_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtNetwork_BINARY_DIR} ${QtWidgets_BINARY_DIR} ${QtMultimedia_BINARY_DIR}
+ ${QtMultimediaWidgets_SOURCE_DIR})
+
+set(QtMultimediaWidgets_include_dirs ${QtMultimediaWidgets_SOURCE_DIR}
+ ${QtMultimediaWidgets_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Network_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5Multimedia_INCLUDE_DIRS}
+ ${Qt5MultimediaWidgets_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtNetwork_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ ${QtMultimedia_GEN_DIR})
+
+set(QtMultimediaWidgets_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Multimedia_LIBRARIES}
+ ${Qt5MultimediaWidgets_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Network_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES})
+
+set(QtMultimediaWidgets_deps QtCore QtGui QtNetwork QtWidgets QtMultimedia)
+
+create_pyside_module(QtMultimediaWidgets
+ QtMultimediaWidgets_include_dirs
+ QtMultimediaWidgets_libraries
+ QtMultimediaWidgets_deps
+ QtMultimediaWidgets_typesystem_path
+ QtMultimediaWidgets_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtMultimediaWidgets/typesystem_multimediawidgets.xml b/sources/pyside2/PySide2/QtMultimediaWidgets/typesystem_multimediawidgets.xml
new file mode 100644
index 000000000..76214baef
--- /dev/null
+++ b/sources/pyside2/PySide2/QtMultimediaWidgets/typesystem_multimediawidgets.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtMultimediaWidgets">
+ <load-typesystem name="typesystem_core.xml" generate="no" />
+ <load-typesystem name="typesystem_gui.xml" generate="no" />
+ <load-typesystem name="typesystem_multimedia_common.xml" generate="no" />
+ <load-typesystem name="typesystem_widgets.xml" generate="no" />
+
+ <object-type name="QCameraViewfinder"/>
+ <object-type name="QGraphicsVideoItem"/>
+ <object-type name="QVideoWidget"/>
+ <object-type name="QVideoWidgetControl"/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtNetwork/CMakeLists.txt b/sources/pyside2/PySide2/QtNetwork/CMakeLists.txt
new file mode 100644
index 000000000..26518991d
--- /dev/null
+++ b/sources/pyside2/PySide2/QtNetwork/CMakeLists.txt
@@ -0,0 +1,72 @@
+project(QtNetwork)
+
+set(QtNetwork_OPTIONAL_SRC )
+set(QtNetwork_DROPPED_ENTRIES )
+check_qt_class(QtNetwork QSslCertificate QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES)
+check_qt_class(QtNetwork QSslCipher QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES)
+check_qt_class(QtNetwork QSslConfiguration QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES)
+check_qt_class(QtNetwork QSslError QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES)
+check_qt_class(QtNetwork QSslKey QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES)
+check_qt_class(QtNetwork QSslSocket QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES)
+
+set(QtNetwork_SRC
+${QtNetwork_GEN_DIR}/qabstractnetworkcache_wrapper.cpp
+${QtNetwork_GEN_DIR}/qabstractsocket_wrapper.cpp
+${QtNetwork_GEN_DIR}/qauthenticator_wrapper.cpp
+${QtNetwork_GEN_DIR}/qhostaddress_wrapper.cpp
+${QtNetwork_GEN_DIR}/qhostinfo_wrapper.cpp
+${QtNetwork_GEN_DIR}/qipv6address_wrapper.cpp
+${QtNetwork_GEN_DIR}/qlocalserver_wrapper.cpp
+${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}/qnetworkdiskcache_wrapper.cpp
+${QtNetwork_GEN_DIR}/qnetworkinterface_wrapper.cpp
+${QtNetwork_GEN_DIR}/qnetworkproxy_wrapper.cpp
+${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}/qssl_wrapper.cpp
+${QtNetwork_GEN_DIR}/qtcpserver_wrapper.cpp
+${QtNetwork_GEN_DIR}/qtcpsocket_wrapper.cpp
+${QtNetwork_GEN_DIR}/qudpsocket_wrapper.cpp
+# module is always needed
+${QtNetwork_GEN_DIR}/qtnetwork_module_wrapper.cpp
+)
+
+make_path(QtNetwork_typesystem_path ${QtCore_SOURCE_DIR}
+ ${QtCore_BINARY_DIR}
+ ${QtNetwork_SOURCE_DIR})
+
+set(QtNetwork_include_dirs ${QtNetwork_SOURCE_DIR}
+ ${QtNetwork_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Network_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR})
+
+set(QtNetwork_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Network_LIBRARIES})
+
+set(QtNetwork_deps QtCore)
+
+create_pyside_module(QtNetwork
+ QtNetwork_include_dirs
+ QtNetwork_libraries
+ QtNetwork_deps
+ QtNetwork_typesystem_path
+ QtNetwork_SRC
+ ""
+ ""
+ QtNetwork_DROPPED_ENTRIES)
diff --git a/sources/pyside2/PySide2/QtNetwork/typesystem_network.xml b/sources/pyside2/PySide2/QtNetwork/typesystem_network.xml
new file mode 100644
index 000000000..2643f1ca9
--- /dev/null
+++ b/sources/pyside2/PySide2/QtNetwork/typesystem_network.xml
@@ -0,0 +1,307 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtNetwork">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+
+ <namespace-type name="QSsl">
+ <enum-type name="AlternativeNameEntryType"/>
+ <enum-type name="EncodingFormat"/>
+ <enum-type name="KeyAlgorithm"/>
+ <enum-type name="KeyType"/>
+ <enum-type name="SslOption" flags="SslOptions" />
+ <enum-type name="SslProtocol"/>
+ <extra-includes>
+ <include file-name="qssl.h" location="global"/>
+ </extra-includes>
+ </namespace-type>
+
+ <rejection class="QIPv6Address" field-name="c"/>
+
+ <object-type name="QAbstractSocket">
+ <enum-type name="BindFlag" flags="BindMode" />
+ <enum-type name="NetworkLayerProtocol"/>
+ <enum-type name="PauseMode" flags="PauseModes" />
+ <enum-type name="SocketError"/>
+ <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="disconnectFromHost()" allow-thread="yes" />
+ <modify-function signature="waitForConnected(int)" allow-thread="yes" />
+ <modify-function signature="waitForDisconnected(int)" allow-thread="yes" />
+ </object-type>
+
+ <object-type name="QTcpServer">
+ <modify-function signature="waitForNewConnection(int,bool*)" allow-thread="yes">
+ <!-- FIXME removing default expression means user will always have to pass a value, but he wouldn't have to -->
+ <modify-argument index="1">
+ <remove-default-expression/>
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-default-expression/>
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(retval, timeOut)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_args,bool*"/>
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QTcpSocket"/>
+ <object-type name="QUdpSocket">
+ <modify-function signature="readDatagram(char*, qint64, QHostAddress*, quint16*)" allow-thread="yes">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="3">
+ <remove-default-expression/>
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="4">
+ <remove-default-expression/>
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(data, address, port)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ Shiboken::AutoArrayPointer&lt;char&gt; data(%ARGUMENT_NAMES);
+ QHostAddress ha;
+ quint16 port;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(data, %ARGUMENT_NAMES, &amp;ha, &amp;port);
+ %END_ALLOW_THREADS
+ QByteArray ba(data, retval);
+ %PYARG_0 = PyTuple_New(3);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[QByteArray](ba));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QHostAddress](ha));
+ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[quint16](port));
+ </inject-code>
+ </modify-function>
+ <modify-function signature="writeDatagram(const QByteArray&amp;, const QHostAddress&amp;, quint16)" allow-thread="yes"/>
+ <!-- ### writeDatagram(QByteArray, ...) does the trick -->
+ <modify-function signature="writeDatagram(const char*,qint64,const QHostAddress&amp;,quint16)" remove="all"/>
+ <!-- ### -->
+ </object-type>
+
+ <object-type name="QLocalServer">
+ <enum-type name="SocketOption" flags="SocketOptions" />
+ <modify-function signature="waitForNewConnection(int,bool*)" allow-thread="yes">
+ <!-- FIXME -->
+ <modify-argument index="1">
+ <remove-default-expression/>
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-default-expression/>
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_args,bool*"/>
+ </inject-code>
+ <modify-argument index="return">
+ <replace-type modified-type="(retval, timeOut)"/>
+ </modify-argument>
+
+ </modify-function>
+ </object-type>
+ <object-type name="QLocalSocket">
+ <enum-type name="LocalSocketError"/>
+ <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"/>
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="get(const QNetworkRequest&amp;)" allow-thread="yes"/>
+ <modify-function signature="post(const QNetworkRequest &amp;, QIODevice *)" allow-thread="yes"/>
+ <modify-function signature="post(const QNetworkRequest &amp;, const QByteArray &amp;)" allow-thread="yes"/>
+ <modify-function signature="put(const QNetworkRequest &amp;, QIODevice *)" allow-thread="yes"/>
+ <modify-function signature="put(const QNetworkRequest &amp;, const QByteArray &amp;)" allow-thread="yes"/>
+ <modify-function signature="sendCustomRequest(const QNetworkRequest &amp;, const QByteArray &amp;, QIODevice *)" allow-thread="yes" since="4.7" />
+ <modify-function signature="setCookieJar(QNetworkCookieJar*)">
+ <modify-argument index="1">
+ <define-ownership class="target" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QNetworkCookieJar"/>
+ <object-type name="QNetworkReply">
+ <enum-type name="NetworkError"/>
+ </object-type>
+
+ <value-type name="QHostAddress" hash-function="qHash">
+ <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="setAddress(quint8*)" remove="all" />
+ </value-type>
+
+ <value-type name="QHostInfo">
+ <enum-type name="HostInfoError"/>
+ <modify-function signature="lookupHost(QString,QObject*,const char*)" access="private"/>
+ </value-type>
+
+ <value-type name="QNetworkAddressEntry" />
+
+ <value-type name="QNetworkInterface">
+ <enum-type name="InterfaceFlag" flags="InterfaceFlags"/>
+ </value-type>
+
+ <value-type name="QNetworkProxy">
+ <enum-type name="Capability" flags="Capabilities" />
+ <enum-type name="ProxyType"/>
+ </value-type>
+
+ <object-type name="QNetworkProxyFactory" />
+ <value-type name="QNetworkProxyQuery">
+ <enum-type name="QueryType" />
+ </value-type>
+
+ <value-type name="QIPv6Address">
+ <add-function signature="__len__">
+ <inject-code class="target" position="beginning">
+ return 16;
+ </inject-code>
+ </add-function>
+ <add-function signature="__getitem__">
+ <inject-code class="target" position="beginning">
+ if (_i >= 16) {
+ PyErr_SetString(PyExc_IndexError, "index out of bounds");
+ return 0;
+ }
+ if (_i &lt; 0)
+ _i = 16 - qAbs(_i);
+
+ uint item = %CPPSELF.c[_i];
+ return %CONVERTTOPYTHON[uint](item);
+ </inject-code>
+ </add-function>
+ <add-function signature="__len__">
+ <inject-code class="target" position="beginning">
+ return 16;
+ </inject-code>
+ </add-function>
+ <add-function signature="__setitem__">
+ <inject-code class="target" position="beginning">
+ if (_i >= 16) {
+ PyErr_SetString(PyExc_IndexError, "index out of bounds");
+ return -1;
+ }
+ if (_i &lt; 0)
+ _i = 16 - qAbs(_i);
+ quint8 item = %CONVERTTOCPP[quint8](_value);
+ %CPPSELF.c[_i] = item;
+ return 0;
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ <value-type name="QAuthenticator" />
+ <value-type name="QNetworkCookie">
+ <enum-type name="RawForm"/>
+ <extra-includes>
+ <include file-name="QDateTime" location="global"/>
+ </extra-includes>
+ </value-type>
+ <value-type name="QNetworkRequest">
+ <enum-type name="Attribute" extensible="yes"/>
+ <enum-type name="LoadControl" since="4.7"/>
+ <enum-type name="Priority" since="4.7"/>
+ <enum-type name="CacheLoadControl"/>
+ <enum-type name="KnownHeaders"/>
+ <enum-type name="RedirectPolicy" since="5.9"/>
+ </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"/>
+
+ <!-- The following entries may be present in the system or not. Keep this section organized. -->
+ <value-type name="QSslCertificate">
+ <enum-type name="SubjectInfo"/>
+ </value-type>
+
+ <value-type name="QSslCipher"/>
+
+ <value-type name="QSslConfiguration">
+ <enum-type name="NextProtocolNegotiationStatus" />
+ </value-type>
+
+ <value-type name="QSslError">
+ <enum-type name="SslError"/>
+ </value-type>
+
+ <value-type name="QSslKey"/>
+ <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="waitForEncrypted(int)" allow-thread="yes" />
+ </object-type>
+ <!-- The above entries may be present in the system or not. Keep this section organized. -->
+</typesystem>
+
diff --git a/sources/pyside2/PySide2/QtOpenGL/CMakeLists.txt b/sources/pyside2/PySide2/QtOpenGL/CMakeLists.txt
new file mode 100644
index 000000000..ebc08946c
--- /dev/null
+++ b/sources/pyside2/PySide2/QtOpenGL/CMakeLists.txt
@@ -0,0 +1,50 @@
+project(QtOpenGL)
+
+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
+# module is always needed
+${QtOpenGL_GEN_DIR}/qtopengl_module_wrapper.cpp
+)
+
+make_path(QtOpenGL_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtWidgets_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtWidgets_BINARY_DIR}
+ ${QtOpenGL_SOURCE_DIR})
+
+set(QtOpenGL_include_dirs ${QtOpenGL_SOURCE_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5OpenGL_INCLUDE_DIRS}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${QtWidgets_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtOpenGL_GEN_DIR}
+ )
+set(QtOpenGL_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ ${Qt5OpenGL_LIBRARIES})
+set(QtOpenGL_deps QtWidgets)
+
+create_pyside_module(QtOpenGL
+ QtOpenGL_include_dirs
+ QtOpenGL_libraries
+ QtOpenGL_deps
+ QtOpenGL_typesystem_path
+ QtOpenGL_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml b/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml
new file mode 100644
index 000000000..d5c701b6f
--- /dev/null
+++ b/sources/pyside2/PySide2/QtOpenGL/typesystem_opengl.xml
@@ -0,0 +1,758 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtOpenGL">
+ <load-typesystem name="typesystem_widgets.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"/>
+
+ <namespace-type name="QGL">
+ <enum-type name="FormatOption" flags="FormatOptions" force-integer="yes"/>
+ <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" />
+ <!-- ### -->
+ </object-type>
+ <object-type name="QGLFramebufferObject">
+ <enum-type name="Attachment"/>
+ </object-type>
+ <object-type name="QGLPixelBuffer">
+ <extra-includes>
+ <include file-name="QImage" location="global"/>
+ </extra-includes>
+ </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>
+
+ <value-type name="QGLFramebufferObjectFormat" since="4.6"/>
+ <object-type name="QGLShader" since="4.6">
+ <enum-type name="ShaderTypeBit" flags="ShaderType"/>
+ </object-type>
+
+ <template name="callArrayFunction">
+ int _size = PySequence_Size(%PYARG_2);
+ if (_size) {
+ $ATTR_TYPE *_list = new $ATTR_TYPE[_size];
+ if (_size) {
+ Shiboken::AutoDecRef fast(PySequence_Fast(%PYARG_2, "Failed to parse sequence with type %VECTOR_TYPE."));
+ for(int i=0; i &lt; _size; i++) {
+ PyObject* pv = PySequence_Fast_GET_ITEM(fast.object(), i);
+ _list[i] = %CONVERTTOCPP[$ATTR_TYPE](pv);
+ }
+ }
+ %CPPSELF.%FUNCTION_NAME(%1, _list, $ARG0);
+ delete[] _list;
+ } else {
+ %CPPSELF.%FUNCTION_NAME(%1, ($ATTR_TYPE*)NULL, $ARG1);
+ }
+ </template>
+
+ <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" />
+ </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" />
+ </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" />
+ </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" />
+ </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>
+
+ <!-- ### TODO: must evaluate if anything other than removal should be done. -->
+ <modify-function signature="setAttributeArray(int,const GLfloat*,int,int)" remove="all" />
+ <modify-function signature="setAttributeArray(const char*,const GLfloat*,int,int)" remove="all" />
+ <modify-function signature="setUniformValueArray(int,const GLfloat*,int,int)" remove="all" />
+ <modify-function signature="setUniformValueArray(const char*,const GLfloat*,int,int)" remove="all" />
+ <!-- ### -->
+
+ <!-- ### Use QMatrixZxY overloads -->
+ <modify-function signature="setUniformValue(int,Array)" remove="all" />
+ <modify-function signature="setUniformValue(const char*,Array)" remove="all" />
+ <modify-function signature="setAttributeValue(int,const GLfloat*,int,int)" remove="all" />
+ <modify-function signature="setAttributeValue(const char*,const GLfloat*,int,int)" remove="all" />
+ <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>
+
+ <!-- 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">
+ int size = (%2 &lt; 0) ? %1.size() : %2;
+ %CPPSELF.allocate((const void*) %1.data(), size);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="map(QGLBuffer::Access)">
+ <inject-code>
+ Py_ssize_t dataSize = %CPPSELF.size();
+ void* data = %CPPSELF.map(%1);
+
+ if (!data) {
+ Py_INCREF(Py_None);
+ %PYARG_0 = Py_None;
+ } else if (%1 == QGLBuffer::ReadOnly) {
+ %PYARG_0 = Shiboken::Buffer::newObject(data, dataSize, Shiboken::Buffer::ReadOnly);
+ } else {
+ %PYARG_0 = Shiboken::Buffer::newObject(data, dataSize, Shiboken::Buffer::ReadWrite);
+ }
+ </inject-code>
+ </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">
+ char *data = new char[%3];
+ bool result = %CPPSELF.read(%1, data, %3);
+ QByteArray ret;
+ if (result)
+ ret.append((const char*)data, %3);
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[bool](result));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QByteArray](ret));
+ delete[] data;
+ </inject-code>
+ </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">
+ int size = (%3 &lt; 0) ? %2.size() : %3;
+ %CPPSELF.write(%1, (const void*) %2.data(), size);
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtPrintSupport/CMakeLists.txt b/sources/pyside2/PySide2/QtPrintSupport/CMakeLists.txt
new file mode 100644
index 000000000..023a5ac74
--- /dev/null
+++ b/sources/pyside2/PySide2/QtPrintSupport/CMakeLists.txt
@@ -0,0 +1,48 @@
+project(QtPrintSupport)
+
+set(QtPrintSupport_SRC
+${QtPrintSupport_GEN_DIR}/qabstractprintdialog_wrapper.cpp
+${QtPrintSupport_GEN_DIR}/qpagesetupdialog_wrapper.cpp
+${QtPrintSupport_GEN_DIR}/qprintdialog_wrapper.cpp
+${QtPrintSupport_GEN_DIR}/qprintengine_wrapper.cpp
+${QtPrintSupport_GEN_DIR}/qprinter_wrapper.cpp
+${QtPrintSupport_GEN_DIR}/qprinterinfo_wrapper.cpp
+${QtPrintSupport_GEN_DIR}/qprintpreviewdialog_wrapper.cpp
+${QtPrintSupport_GEN_DIR}/qprintpreviewwidget_wrapper.cpp
+# module is always needed
+${QtPrintSupport_GEN_DIR}/qtprintsupport_module_wrapper.cpp
+)
+
+make_path(QtPrintSupport_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtWidgets_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtWidgets_BINARY_DIR}
+ ${QtPrintSupport_SOURCE_DIR})
+
+set(QtPrintSupport_include_dirs ${QtPrintSupport_SOURCE_DIR}
+ ${QtPrintSupport_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5PrintSupport_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ )
+set(QtPrintSupport_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ ${Qt5PrintSupport_LIBRARIES}
+ )
+set(QtPrintSupport_deps QtWidgets)
+create_pyside_module(QtPrintSupport
+ QtPrintSupport_include_dirs
+ QtPrintSupport_libraries
+ QtPrintSupport_deps
+ QtPrintSupport_typesystem_path
+ QtPrintSupport_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml
new file mode 100644
index 000000000..09f151af5
--- /dev/null
+++ b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml
@@ -0,0 +1,118 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtPrintSupport">
+ <load-typesystem name="typesystem_widgets.xml" generate="no" />
+
+ <object-type name="QPageSetupDialog">
+ <modify-function signature="exec()" rename="exec_" allow-thread="yes"/>
+ </object-type>
+
+ <object-type name="QAbstractPrintDialog">
+ <enum-type name="PrintDialogOption" flags="PrintDialogOptions" />
+ <enum-type name="PrintRange" />
+ </object-type>
+
+ <object-type name="QPrintDialog">
+ <modify-function signature="exec()" rename="exec_" allow-thread="yes" />
+ </object-type>
+ <object-type name="QPrintEngine">
+ <enum-type name="PrintEnginePropertyKey" />
+ </object-type>
+ <value-type name="QPrinterInfo" />
+ <rejection class="QPrinter" function-name="printerSelectionOption"/>
+ <rejection class="QPrinter" function-name="setPrinterSelectionOption"/>
+
+ <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"/>
+ <enum-type name="PrintRange"/>
+ <enum-type name="PrinterMode"/>
+ <enum-type name="PrinterState"/>
+ <enum-type name="Unit"/>
+ <modify-function signature="getPageMargins(qreal*,qreal*,qreal*,qreal*,QPrinter::Unit)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*,args">
+ <replace from="$TYPE" to="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setEngines(QPrintEngine*,QPaintEngine*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <extra-includes>
+ <include file-name="QPrinterInfo" location="global"/>
+ </extra-includes>
+ </object-type>
+
+ <object-type name="QPrintPreviewDialog"/>
+ <object-type name="QPrintPreviewWidget">
+ <enum-type name="ViewMode"/>
+ <enum-type name="ZoomMode"/>
+ <modify-function signature="print()" rename="print_" />
+ </object-type>
+
+</typesystem>
+
diff --git a/sources/pyside2/PySide2/QtQml/CMakeLists.txt b/sources/pyside2/PySide2/QtQml/CMakeLists.txt
new file mode 100644
index 000000000..0607e905f
--- /dev/null
+++ b/sources/pyside2/PySide2/QtQml/CMakeLists.txt
@@ -0,0 +1,69 @@
+project(QtQml)
+
+set(QtQml_registerType "${QtQml_SOURCE_DIR}/pysideqmlregistertype.cpp")
+
+set(QtQml_SRC
+${QtQml_GEN_DIR}/qjsengine_wrapper.cpp
+${QtQml_GEN_DIR}/qjsvalue_wrapper.cpp
+${QtQml_GEN_DIR}/qjsvalueiterator_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlabstracturlinterceptor_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlapplicationengine_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlcomponent_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlcontext_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlerror_wrapper.cpp
+${QtQml_GEN_DIR}/qqmldebuggingenabler_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlengine_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlexpression_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlextensioninterface_wrapper.cpp
+${QtQml_GEN_DIR}/qqmltypesextensioninterface_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlextensionplugin_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlfile_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlfileselector_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlimageproviderbase_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlincubator_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlincubationcontroller_wrapper.cpp
+#${QtQml_GEN_DIR}/qqmllistproperty_wrapper.cpp
+${QtQml_GEN_DIR}/qqmllistreference_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlparserstatus_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlproperty_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlpropertymap_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlpropertyvaluesource_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlscriptstring_wrapper.cpp
+${QtQml_GEN_DIR}/qqmlnetworkaccessmanagerfactory_wrapper.cpp
+# module is always needed
+${QtQml_GEN_DIR}/qtqml_module_wrapper.cpp
+)
+
+make_path(QtQml_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtNetwork_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtNetwork_BINARY_DIR}
+ ${QtQml_SOURCE_DIR})
+
+set(QtQml_include_dirs ${QtQml_SOURCE_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Network_INCLUDE_DIRS}
+ ${Qt5Qml_INCLUDE_DIRS}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtNetwork_GEN_DIR}
+ ${QtQml_GEN_DIR})
+
+set(QtQml_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Network_LIBRARIES}
+ ${Qt5Qml_LIBRARIES})
+
+set(QtQml_deps QtGui QtNetwork)
+
+create_pyside_module(QtQml
+ QtQml_include_dirs
+ QtQml_libraries
+ QtQml_deps
+ QtQml_typesystem_path
+ QtQml_SRC
+ QtQml_registerType)
diff --git a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp
new file mode 100644
index 000000000..3e217a707
--- /dev/null
+++ b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp
@@ -0,0 +1,545 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "pysideqmlregistertype.h"
+
+// shiboken
+#include <shiboken.h>
+
+// pyside
+#include <pyside.h>
+#include <pysideproperty.h>
+
+// auto generated headers
+#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
+
+// 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)
+ {
+ 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;
+ }
+};
+
+int PySide::qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor,
+ int versionMinor, const char *qmlName)
+{
+ 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))) {
+ PyErr_Format(PyExc_TypeError, "A type inherited from %s expected, got %s.",
+ qobjectType->tp_name, pyObjType->tp_name);
+ return -1;
+ }
+
+ QMetaObject *metaObject = reinterpret_cast<QMetaObject *>(
+ ObjectType::getTypeUserData(reinterpret_cast<SbkObjectType *>(pyObj)));
+ 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);
+ }
+#endif
+
+ // Register as simple QObject rather than Qt Quick item.
+ if (!registered) {
+ // Incref the type object, don't worry about decref'ing it because
+ // there's no way to unregister a QML type.
+ Py_INCREF(pyObj);
+
+ pyTypes[nextType] = pyObj;
+
+ // FIXME: Fix this to assign new type ids each time.
+ type.typeId = qMetaTypeId<QObject*>();
+ type.listId = qMetaTypeId<QQmlListProperty<QObject> >();
+ type.attachedPropertiesFunction = QQmlPrivate::attachedPropertiesFunc<QObject>();
+ type.attachedPropertiesMetaObject = QQmlPrivate::attachedPropertiesMetaObject<QObject>();
+
+ type.parserStatusCast =
+ QQmlPrivate::StaticCastSelector<QObject, QQmlParserStatus>::cast();
+ type.valueSourceCast =
+ QQmlPrivate::StaticCastSelector<QObject, QQmlPropertyValueSource>::cast();
+ type.valueInterceptorCast =
+ QQmlPrivate::StaticCastSelector<QObject, QQmlPropertyValueInterceptor>::cast();
+
+ int objectSize = static_cast<int>(PySide::getSizeOfQObject(
+ reinterpret_cast<SbkObjectType *>(pyObj)));
+ type.objectSize = objectSize;
+ type.create = createFuncs[nextType];
+ type.uri = uri;
+ type.versionMajor = versionMajor;
+ type.versionMinor = versionMinor;
+ type.elementName = qmlName;
+ type.metaObject = metaObject;
+
+ type.extensionObjectCreate = 0;
+ type.extensionMetaObject = 0;
+ type.customParser = 0;
+ ++nextType;
+ }
+
+ int qmlTypeId = QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
+ if (qmlTypeId == -1) {
+ PyErr_Format(PyExc_TypeError, "QML meta type registration of \"%s\" failed.",
+ qmlName);
+ }
+ return qmlTypeId;
+}
+
+extern "C"
+{
+
+// This is the user data we store in the property.
+struct QmlListProperty
+{
+ PyTypeObject* type;
+ PyObject* append;
+ PyObject* at;
+ PyObject* clear;
+ PyObject* count;
+};
+
+static int propListTpInit(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ static const char *kwlist[] = {"type", "append", "at", "clear", "count", 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,
+ &data->type,
+ &data->append,
+ &data->at,
+ &data->clear,
+ &data->count)) {
+ return 0;
+ }
+ PySide::Property::setMetaCallHandler(pySelf, &propListMetaCall);
+ PySide::Property::setTypeName(pySelf, "QQmlListProperty<QObject>");
+ PySide::Property::setUserData(pySelf, data);
+
+ return 1;
+}
+
+void propListTpFree(void* self)
+{
+ PySideProperty* pySelf = reinterpret_cast<PySideProperty*>(self);
+ delete reinterpret_cast<QmlListProperty*>(PySide::Property::userData(pySelf));
+ // calls base type constructor
+ Py_TYPE(pySelf)->tp_base->tp_free(self);
+}
+
+PyTypeObject PropertyListType = {
+ PyVarObject_HEAD_INIT(0, 0)
+ "ListProperty", /*tp_name*/
+ sizeof(PySideProperty), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ 0, /*tp_iter */
+ 0, /*tp_iternext */
+ 0, /*tp_methods */
+ 0, /*tp_members */
+ 0, /*tp_getset */
+ &PySidePropertyType, /*tp_base */
+ 0, /*tp_dict */
+ 0, /*tp_descr_get */
+ 0, /*tp_descr_set */
+ 0, /*tp_dictoffset */
+ propListTpInit, /*tp_init */
+ 0, /*tp_alloc */
+ 0, /*tp_new */
+ propListTpFree, /*tp_free */
+ 0, /*tp_is_gc */
+ 0, /*tp_bases */
+ 0, /*tp_mro */
+ 0, /*tp_cache */
+ 0, /*tp_subclasses */
+ 0, /*tp_weaklist */
+ 0, /*tp_del */
+};
+
+} // extern "C"
+
+// Implementation of QQmlListProperty<T>::AppendFunction callback
+void propListAppender(QQmlListProperty<QObject> *propList, QObject *item)
+{
+ Shiboken::GilState state;
+
+ Shiboken::AutoDecRef args(PyTuple_New(2));
+ PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], propList->object));
+ PyTuple_SET_ITEM(args, 1, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], item));
+
+ QmlListProperty* data = reinterpret_cast<QmlListProperty*>(propList->data);
+ Shiboken::AutoDecRef retVal(PyObject_CallObject(data->append, args));
+
+ if (PyErr_Occurred())
+ PyErr_Print();
+}
+
+// Implementation of QQmlListProperty<T>::CountFunction callback
+int propListCount(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));
+
+ QmlListProperty* data = reinterpret_cast<QmlListProperty*>(propList->data);
+ Shiboken::AutoDecRef retVal(PyObject_CallObject(data->count, args));
+
+ // Check return type
+ int cppResult = 0;
+ PythonToCppFunc pythonToCpp;
+ if (PyErr_Occurred())
+ PyErr_Print();
+ else if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter<int>(), retVal)))
+ pythonToCpp(retVal, &cppResult);
+ return cppResult;
+}
+
+// Implementation of QQmlListProperty<T>::AtFunction callback
+QObject *propListAt(QQmlListProperty<QObject> *propList, int index)
+{
+ Shiboken::GilState state;
+
+ Shiboken::AutoDecRef args(PyTuple_New(2));
+ 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));
+
+ QmlListProperty* data = reinterpret_cast<QmlListProperty*>(propList->data);
+ Shiboken::AutoDecRef retVal(PyObject_CallObject(data->at, args));
+
+ QObject *result = 0;
+ if (PyErr_Occurred())
+ PyErr_Print();
+ else if (PyType_IsSubtype(Py_TYPE(retVal), data->type))
+ Shiboken::Conversions::pythonToCppPointer((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], retVal, &result);
+ return result;
+}
+
+// Implementation of QQmlListProperty<T>::ClearFunction callback
+void propListClear(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));
+
+ QmlListProperty* data = reinterpret_cast<QmlListProperty*>(propList->data);
+ Shiboken::AutoDecRef retVal(PyObject_CallObject(data->clear, args));
+
+ if (PyErr_Occurred())
+ PyErr_Print();
+}
+
+// qt_metacall specialization for ListProperties
+static void propListMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::Call call, void** args)
+{
+ if (call != QMetaObject::ReadProperty)
+ return;
+
+ QmlListProperty* 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);
+
+ // Copy the data to the memory location requested by the meta call
+ void* v = args[0];
+ *reinterpret_cast<QQmlListProperty<QObject> *>(v) = declProp;
+}
+
+// VolatileBool (volatile bool) type definition.
+
+static PyObject *
+QtQml_VolatileBoolObject_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ static const char *kwlist[] = {"x", 0};
+ PyObject *x = Py_False;
+ long ok;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:bool", const_cast<char **>(kwlist), &x))
+ return Q_NULLPTR;
+ ok = PyObject_IsTrue(x);
+ if (ok < 0)
+ return Q_NULLPTR;
+
+ QtQml_VolatileBoolObject *self
+ = reinterpret_cast<QtQml_VolatileBoolObject *>(type->tp_alloc(type, 0));
+
+ if (self != Q_NULLPTR)
+ self->flag = ok;
+
+ return reinterpret_cast<PyObject *>(self);
+}
+
+static PyObject *
+QtQml_VolatileBoolObject_get(QtQml_VolatileBoolObject *self)
+{
+ if (self->flag)
+ return Py_True;
+ return Py_False;
+}
+
+static PyObject *
+QtQml_VolatileBoolObject_set(QtQml_VolatileBoolObject *self, PyObject *args)
+{
+ PyObject *value = Py_False;
+ long ok;
+
+ if (!PyArg_ParseTuple(args, "O:bool", &value)) {
+ return Q_NULLPTR;
+ }
+
+ ok = PyObject_IsTrue(value);
+ if (ok < 0) {
+ PyErr_SetString(PyExc_TypeError, "Not a boolean value.");
+ return Q_NULLPTR;
+ }
+
+ if (ok > 0)
+ self->flag = true;
+ else
+ self->flag = false;
+
+ Py_RETURN_NONE;
+}
+
+static PyMethodDef QtQml_VolatileBoolObject_methods[] = {
+ {"get", reinterpret_cast<PyCFunction>(QtQml_VolatileBoolObject_get), METH_NOARGS,
+ "B.get() -> Bool. Returns the value of the volatile boolean"
+ },
+ {"set", reinterpret_cast<PyCFunction>(QtQml_VolatileBoolObject_set), METH_VARARGS,
+ "B.set(a) -> None. Sets the value of the volatile boolean"
+ },
+ {Q_NULLPTR} /* Sentinel */
+};
+
+static PyObject *
+QtQml_VolatileBoolObject_repr(QtQml_VolatileBoolObject *self)
+{
+ PyObject *s;
+
+ if (self->flag)
+ s = PyBytes_FromFormat("%s(True)",
+ Py_TYPE(self)->tp_name);
+ else
+ s = PyBytes_FromFormat("%s(False)",
+ Py_TYPE(self)->tp_name);
+ Py_XINCREF(s);
+ return s;
+}
+
+static PyObject *
+QtQml_VolatileBoolObject_str(QtQml_VolatileBoolObject *self)
+{
+ PyObject *s;
+
+ if (self->flag)
+ s = PyBytes_FromFormat("%s(True) -> %p",
+ Py_TYPE(self)->tp_name, &(self->flag));
+ else
+ s = PyBytes_FromFormat("%s(False) -> %p",
+ Py_TYPE(self)->tp_name, &(self->flag));
+ Py_XINCREF(s);
+ return s;
+}
+
+PyTypeObject QtQml_VolatileBoolType = {
+ PyVarObject_HEAD_INIT(Q_NULLPTR, 0) /*ob_size*/
+ "VolatileBool", /*tp_name*/
+ sizeof(QtQml_VolatileBoolObject), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ reinterpret_cast<reprfunc>(QtQml_VolatileBoolObject_repr), /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ reinterpret_cast<reprfunc>(QtQml_VolatileBoolObject_str), /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "VolatileBool objects contain a C++ volatile bool", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ QtQml_VolatileBoolObject_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ QtQml_VolatileBoolObject_new, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+ 0, /* tp_del */
+ 0, /* tp_version_tag */
+#if PY_MAJOR_VERSION > 3 || PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 4
+ 0 /* tp_finalize */
+#endif
+};
+
+void PySide::initQmlSupport(PyObject* module)
+{
+ ElementFactory<PYSIDE_MAX_QML_TYPES - 1>::init();
+
+ // Export QmlListProperty type
+ if (PyType_Ready(&PropertyListType) < 0) {
+ qWarning() << "Error initializing PropertyList type.";
+ return;
+ }
+
+ Py_INCREF(reinterpret_cast<PyObject *>(&PropertyListType));
+ PyModule_AddObject(module, PropertyListType.tp_name,
+ reinterpret_cast<PyObject *>(&PropertyListType));
+
+ if (PyType_Ready(&QtQml_VolatileBoolType) < 0) {
+ qWarning() << "Error initializing VolatileBool type.";
+ return;
+ }
+
+ Py_INCREF(&QtQml_VolatileBoolType);
+ PyModule_AddObject(module, QtQml_VolatileBoolType.tp_name,
+ reinterpret_cast<PyObject *>(&QtQml_VolatileBoolType));
+}
diff --git a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h
new file mode 100644
index 000000000..fba7f8d26
--- /dev/null
+++ b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDEQMLREGISTERTYPE_H
+#define PYSIDEQMLREGISTERTYPE_H
+
+#include <Python.h>
+
+struct SbkObjectType;
+
+namespace PySide
+{
+
+extern void* nextQmlElementMemoryAddr;
+
+/**
+ * Init the QML support doing things like registering QtQml.ListProperty and create the necessary stuff for
+ * qmlRegisterType.
+ *
+ * \param module QtQml python module
+ */
+void initQmlSupport(PyObject* module);
+
+/**
+ * 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
+ * \return the metatype id of the registered type.
+ */
+int qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor, int versionMinor,
+ const char *qmlName);
+}
+
+// Volatile Bool Ptr type definition.
+
+typedef struct {
+ PyObject_HEAD
+ volatile bool flag;
+} QtQml_VolatileBoolObject;
+
+PyAPI_DATA(PyTypeObject) QtQml_VolatileBoolType;
+
+#define VolatileBool_Check(op) (Py_TYPE(op) == &QtQml_VolatileBoolType)
+
+#endif
diff --git a/sources/pyside2/PySide2/QtQml/typesystem_qml.xml b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml
new file mode 100644
index 000000000..427b82d90
--- /dev/null
+++ b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml
@@ -0,0 +1,216 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtQml">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+ <load-typesystem name="typesystem_network.xml" generate="no"/>
+ <load-typesystem name="typesystem_gui.xml" generate="no"/>
+
+ <!-- This is to inform the generator that the VolatileBool python type exists -->
+ <custom-type name="VolatileBool" />
+ <primitive-type name="bool volatile" target-lang-api-name="VolatileBool">
+ <include file-name="pysideqmlregistertype.h" location="local"/>
+ <!-- No conversion rules are specified here, because the generator does not handle
+ pointer to primitive types without function adjustment.
+ See commit ff0b861b59b41387e771d9cd565e13de8b2750d1 or search for changePStr
+ in generator tests folder. -->
+ </primitive-type>
+
+ <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:
+
+ ::
+
+ 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.
+ </inject-documentation>
+
+ <inject-code class="target">
+ int %0 = PySide::qmlRegisterType(%ARGUMENT_NAMES);
+ %PYARG_0 = %CONVERTTOPYTHON[int](%0);
+ </inject-code>
+ </add-function>
+
+ <enum-type identified-by-value="QML_HAS_ATTACHED_PROPERTIES">
+ <extra-includes>
+ <include file-name="QtQml" location="global"/>
+ <include file-name="pysideqmlregistertype.h" location="local"/>
+ </extra-includes>
+ </enum-type>
+
+ <inject-code class="target" position="end">
+ PySide::initQmlSupport(module);
+ </inject-code>
+
+ <object-type name="QJSEngine">
+ <enum-type name="Extension" flags="Extensions" since="5.6" />
+ <add-function signature="toScriptValue(const QVariant&amp;)" return-type="QJSValue">
+ <inject-code class="target" position="end">
+ %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(%1);
+ return %CONVERTTOPYTHON[%RETURN_TYPE](retval);
+ </inject-code>
+ </add-function>
+ </object-type>
+ <value-type name="QJSValue">
+ <enum-type name="SpecialValue" />
+ </value-type>
+ <object-type name="QJSValueIterator" />
+ <object-type name="QQmlAbstractUrlInterceptor">
+ <enum-type name="DataType" />
+ </object-type>
+ <object-type name="QQmlApplicationEngine" />
+ <object-type name="QQmlComponent">
+ <enum-type name="CompilationMode" />
+ <enum-type name="Status" />
+ </object-type>
+ <object-type name="QQmlContext" />
+ <value-type name="QQmlError" />
+ <object-type name="QQmlDebuggingEnabler">
+ <enum-type name="StartMode" />
+ </object-type>
+ <object-type name="QQmlEngine">
+ <enum-type name="ObjectOwnership" />
+ </object-type>
+ <object-type name="QQmlExpression">
+ <modify-function signature="evaluate(bool *)" allow-thread="yes">
+ <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>
+ </object-type>
+ <interface-type name="QQmlTypesExtensionInterface" />
+ <interface-type name="QQmlExtensionInterface" />
+ <object-type name="QQmlExtensionPlugin" />
+ <!-- Possible qRegisterMetaType issues ? -->
+ <object-type name="QQmlFile">
+ <enum-type name="Status" />
+ </object-type>
+ <object-type name="QQmlFileSelector" />
+ <object-type name="QQmlImageProviderBase">
+ <modify-function signature="QQmlImageProviderBase()" remove="all"/>
+ <enum-type name="Flag" flags="Flags" />
+ <enum-type name="ImageType" />
+ </object-type>
+ <object-type name="QQmlIncubator">
+ <enum-type name="IncubationMode" />
+ <enum-type name="Status" />
+ </object-type>
+ <object-type name="QQmlIncubationController">
+ <modify-function signature="incubateWhile(bool volatile*,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. -->
+ <replace-type modified-type="VolatileBool" />
+ <conversion-rule class="native">
+ volatile bool * %out =
+ &amp;((reinterpret_cast&lt;QtQml_VolatileBoolObject *&gt;(%PYARG_1))->flag);
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <!-- TODO: QQmlListProperty is a template class, and thus should probably be treated like a
+ container-type tag, which implies custom code for conversion. Not sure there's a use case to
+ allow instantiating or deriving from the class though, given that a separate custom ListProperty
+ type is provided by the module. Plus meta type registration would have to be taken into account
+ for the QML parts.
+ <value-type name="QQmlListProperty" />-->
+ <value-type name="QQmlListReference" />
+ <interface-type name="QQmlParserStatus" />
+ <value-type name="QQmlProperty">
+ <enum-type name="PropertyTypeCategory" />
+ <enum-type name="Type" />
+ </value-type>
+ <object-type name="QQmlPropertyMap" />
+ <object-type name="QQmlPropertyValueSource" />
+ <value-type name="QQmlScriptString">
+ <modify-function signature="numberLiteral(bool *) const" allow-thread="yes">
+ <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>
+ <modify-function signature="booleanLiteral(bool *) const" allow-thread="yes">
+ <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>
+ <object-type name="QQmlNetworkAccessManagerFactory">
+ <modify-function signature="create(QObject*)">
+ <modify-argument index="return">
+ <define-ownership class="native" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <!-- Suppress anonymous enum warning -->
+ <suppress-warning text="enum 'QmlCurrentSingletonTypeRegistrationVersion' does not have a type entry or is not an enum" />
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtQuick/CMakeLists.txt b/sources/pyside2/PySide2/QtQuick/CMakeLists.txt
new file mode 100644
index 000000000..491fc9d9e
--- /dev/null
+++ b/sources/pyside2/PySide2/QtQuick/CMakeLists.txt
@@ -0,0 +1,100 @@
+project(QtQuick)
+
+set(QtQuick_registerType "${QtQuick_SOURCE_DIR}/pysidequickregistertype.cpp")
+
+set(QtQuick_SRC
+${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}/qquicktransform_wrapper.cpp
+${QtQuick_GEN_DIR}/qquickitem_wrapper.cpp
+${QtQuick_GEN_DIR}/qquickitem_updatepaintnodedata_wrapper.cpp
+${QtQuick_GEN_DIR}/qquickitemgrabresult_wrapper.cpp
+${QtQuick_GEN_DIR}/qsharedpointer_qquickitemgrabresult_wrapper.cpp
+${QtQuick_GEN_DIR}/qquickpainteditem_wrapper.cpp
+${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
+${QtQuick_GEN_DIR}/qsggeometry_coloredpoint2d_wrapper.cpp
+${QtQuick_GEN_DIR}/qsggeometry_point2d_wrapper.cpp
+${QtQuick_GEN_DIR}/qsggeometry_texturedpoint2d_wrapper.cpp
+${QtQuick_GEN_DIR}/qsggeometry_wrapper.cpp
+${QtQuick_GEN_DIR}/qsggeometrynode_wrapper.cpp
+#${QtQuick_GEN_DIR}/qsgmaterial_wrapper.cpp
+#${QtQuick_GEN_DIR}/qsgmaterialshader_renderstate_wrapper.cpp
+# Issue with virtual char const *const *attributeNames()
+#${QtQuick_GEN_DIR}/qsgmaterialshader_wrapper.cpp
+${QtQuick_GEN_DIR}/qsgmaterialtype_wrapper.cpp
+${QtQuick_GEN_DIR}/qsgnode_wrapper.cpp
+${QtQuick_GEN_DIR}/qsgopacitynode_wrapper.cpp
+#${QtQuick_GEN_DIR}/qsgopaquetexturematerial_wrapper.cpp
+#${QtQuick_GEN_DIR}/qsgsimplematerial_wrapper.cpp
+#${QtQuick_GEN_DIR}/qsgsimplematerialshader_wrapper.cpp
+${QtQuick_GEN_DIR}/qsgsimplerectnode_wrapper.cpp
+${QtQuick_GEN_DIR}/qsgsimpletexturenode_wrapper.cpp
+${QtQuick_GEN_DIR}/qsgtexture_wrapper.cpp
+#${QtQuick_GEN_DIR}/qsgtexturematerial_wrapper.cpp
+${QtQuick_GEN_DIR}/qsgtextureprovider_wrapper.cpp
+${QtQuick_GEN_DIR}/qsgtransformnode_wrapper.cpp
+#${QtQuick_GEN_DIR}/qsgvertexcolormaterial_wrapper.cpp
+# module is always needed
+${QtQuick_GEN_DIR}/qtquick_module_wrapper.cpp
+)
+
+if (Qt5Quick_VERSION VERSION_GREATER 5.5.1)
+ set(QtQuick_SRC ${QtQuick_SRC}
+ ${QtQuick_GEN_DIR}/qquickasyncimageprovider_wrapper.cpp
+ ${QtQuick_GEN_DIR}/qquickimageresponse_wrapper.cpp
+ )
+endif()
+
+
+make_path(QtQuick_typesystem_path ${QtCore_SOURCE_DIR} ${QtCore_BINARY_DIR}
+ ${QtGui_SOURCE_DIR} ${QtGui_BINARY_DIR}
+ ${QtNetwork_SOURCE_DIR} ${QtNetwork_BINARY_DIR}
+ ${QtQml_SOURCE_DIR} ${QtQml_BINARY_DIR}
+ ${QtQuick_SOURCE_DIR})
+
+set(QtQuick_include_dirs ${QtQuick_SOURCE_DIR}
+ ${QtQml_SOURCE_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Network_INCLUDE_DIRS}
+ ${Qt5Qml_INCLUDE_DIRS}
+ ${Qt5Quick_INCLUDE_DIRS}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtNetwork_GEN_DIR}
+ ${QtQml_GEN_DIR}
+ ${QtQuick_GEN_DIR})
+
+set(QtQuick_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Network_LIBRARIES}
+ ${Qt5Qml_LIBRARIES}
+ ${Qt5Quick_LIBRARIES})
+
+set(QtQuick_deps QtGui QtNetwork QtQml)
+
+create_pyside_module(QtQuick
+ QtQuick_include_dirs
+ QtQuick_libraries
+ QtQuick_deps
+ QtQuick_typesystem_path
+ QtQuick_SRC
+ QtQuick_registerType)
diff --git a/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp
new file mode 100644
index 000000000..6468068a3
--- /dev/null
+++ b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp
@@ -0,0 +1,253 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "pysidequickregistertype.h"
+
+#include <pyside.h>
+
+// Auto generated headers.
+#include "qquickitem_wrapper.h"
+#include "qquickpainteditem_wrapper.h"
+#include "qquickframebufferobject_wrapper.h"
+#include "pyside2_qtcore_python.h"
+#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 init()
+ {
+ createFuncs[0] = &ElementFactoryBase<0>::createQuickItem;
+ }
+};
+
+#define PY_REGISTER_IF_INHERITS_FROM(className, typeToRegister,typePointerName, \
+ typeListName, typeMetaObject, type, registered) \
+ registerTypeIfInheritsFromClass<className##Wrapper>(#className, typeToRegister, \
+ typePointerName, typeListName, \
+ typeMetaObject, type, registered)
+
+bool pyTypeObjectInheritsFromClass(const PyTypeObject *pyObjType, QByteArray className)
+{
+ className.append('*');
+ PyTypeObject *classPyType = Shiboken::Conversions::getPythonTypeObject(className.constData());
+ bool isDerived = PySequence_Contains(pyObjType->tp_mro,
+ reinterpret_cast<PyObject *>(classPyType));
+ return isDerived;
+}
+
+template <class WrapperClass>
+void registerTypeIfInheritsFromClass(
+ QByteArray className,
+ const PyTypeObject *typeToRegister,
+ const QByteArray &typePointerName,
+ const QByteArray &typeListName,
+ QMetaObject *typeMetaObject,
+ QQmlPrivate::RegisterType *type,
+ bool &registered)
+{
+ 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;
+ }
+
+ 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),
+ static_cast<QMetaObject*>(0));
+ 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->attachedPropertiesFunction = QQmlPrivate::attachedPropertiesFunc<WrapperClass>();
+ type->attachedPropertiesMetaObject =
+ QQmlPrivate::attachedPropertiesMetaObject<WrapperClass>();
+ type->parserStatusCast =
+ QQmlPrivate::StaticCastSelector<WrapperClass, QQmlParserStatus>::cast();
+ type->valueSourceCast =
+ QQmlPrivate::StaticCastSelector<WrapperClass, QQmlPropertyValueSource>::cast();
+ type->valueInterceptorCast =
+ QQmlPrivate::StaticCastSelector<WrapperClass, QQmlPropertyValueInterceptor>::cast();
+ type->objectSize = sizeof(WrapperClass);
+ registered = true;
+ }
+}
+
+bool quickRegisterType(PyObject *pyObj, const char *uri, int versionMajor, int versionMinor,
+ const char *qmlName, 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 =
+ Shiboken::Conversions::getPythonTypeObject("QQuickItem*");
+ bool isQuickItem = PySequence_Contains(pyObjType->tp_mro,
+ reinterpret_cast<PyObject *>(qQuickItemPyType));
+
+ // Register only classes that inherit QQuickItem or its children.
+ if (!isQuickItem)
+ return false;
+
+ // Used inside macros to register the type.
+ QMetaObject *metaObject =
+ reinterpret_cast<QMetaObject *>(
+ ObjectType::getTypeUserData(reinterpret_cast<SbkObjectType *>(pyObj)));
+ Q_ASSERT(metaObject);
+
+
+ // Incref the type object, don't worry about decref'ing it because
+ // there's no way to unregister a QML type.
+ Py_INCREF(pyObj);
+
+ pyTypes[nextType] = pyObj;
+
+ // Used in macro registration.
+ QByteArray pointerName(qmlName);
+ pointerName.append('*');
+ QByteArray listName(qmlName);
+ listName.prepend("QQmlListProperty<");
+ listName.append('>');
+
+ bool registered = false;
+ PY_REGISTER_IF_INHERITS_FROM(QQuickPaintedItem, pyObjType, pointerName, listName, metaObject,
+ type, registered);
+ PY_REGISTER_IF_INHERITS_FROM(QQuickFramebufferObject, pyObjType, pointerName, listName,
+ metaObject, type, registered);
+ PY_REGISTER_IF_INHERITS_FROM(QQuickItem, pyObjType, pointerName, listName, metaObject,
+ type, registered);
+ if (!registered)
+ return false;
+
+ type->create = createFuncs[nextType];
+ type->version = 0;
+ type->uri = uri;
+ type->versionMajor = versionMajor;
+ type->versionMinor = versionMinor;
+ type->elementName = qmlName;
+ type->metaObject = metaObject;
+
+ type->extensionObjectCreate = 0;
+ 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/pysidequickregistertype.h b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.h
new file mode 100644
index 000000000..35a669084
--- /dev/null
+++ b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_QUICK_REGISTER_TYPE_H
+#define PYSIDE_QUICK_REGISTER_TYPE_H
+
+#include <Python.h>
+
+struct SbkObjectType;
+
+namespace PySide
+{
+void initQuickSupport(PyObject *module);
+}
+
+#endif // PYSIDE_QUICK_REGISTER_TYPE_H
diff --git a/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml b/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml
new file mode 100644
index 000000000..4cee02eec
--- /dev/null
+++ b/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml
@@ -0,0 +1,174 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtQuick">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+ <load-typesystem name="typesystem_network.xml" generate="no"/>
+ <load-typesystem name="typesystem_gui.xml" generate="no"/>
+ <load-typesystem name="typesystem_qml.xml" generate="no"/>
+
+ <primitive-type name="GLuint"/>
+ <smart-pointer-type name="QSharedPointer" type="shared" getter="data" />
+
+ <extra-includes>
+ <include file-name="pysidequickregistertype.h" location="local"/>
+ </extra-includes>
+
+ <inject-code class="target" position="end">
+ PySide::initQuickSupport(module);
+ </inject-code>
+
+ <object-type name="QQuickAsyncImageProvider" since="5.6" />
+
+ <object-type name="QQuickFramebufferObject" />
+ <object-type name="QQuickFramebufferObject::Renderer" />
+
+ <object-type name="QQuickTextureFactory" />
+ <object-type name="QQuickImageProvider" />
+ <object-type name="QQuickImageResponse" since="5.6" />
+
+ <object-type name="QQuickTransform" />
+ <object-type name="QQuickItem">
+ <value-type name="UpdatePaintNodeData" />
+ <enum-type name="Flag" flags="Flags" />
+ <enum-type name="ItemChange" />
+ <enum-type name="TransformOrigin" />
+ <modify-function signature="itemTransform(QQuickItem *, bool *) const" allow-thread="yes">
+ <modify-argument index="2">
+ <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_args,bool*" />
+ </inject-code>
+ </modify-function>
+ <!-- TODO: Find a way to wrap `union ItemChangeData {}` -->
+ </object-type>
+
+ <object-type name="QQuickItemGrabResult" />
+
+ <object-type name="QQuickPaintedItem">
+ <enum-type name="RenderTarget" />
+ <enum-type name="PerformanceHint" flags="PerformanceHints" />
+ </object-type>
+
+ <object-type name="QQuickRenderControl" />
+
+ <object-type name="QQuickTextDocument" />
+
+ <object-type name="QQuickView">
+ <enum-type name="ResizeMode" />
+ <enum-type name="Status" />
+ </object-type>
+
+ <object-type name="QQuickWindow">
+ <enum-type name="CreateTextureOption" flags="CreateTextureOptions" />
+ <enum-type name="RenderStage" />
+ <enum-type name="SceneGraphError" />
+ </object-type>
+
+ <object-type name="QSGAbstractRenderer">
+ <enum-type name="ClearModeBit" flags="ClearMode" />
+ </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" />
+ <enum-type name="AttributeType" since="5.8"/>
+ <enum-type name="DrawingMode" since="5.8"/>
+ <enum-type name="Type" since="5.8"/>
+ </object-type>
+ <value-type name="QSGGeometry::Attribute" />
+ <value-type name="QSGGeometry::AttributeSet" />
+ <value-type name="QSGGeometry::ColoredPoint2D" />
+ <value-type name="QSGGeometry::Point2D" />
+ <value-type name="QSGGeometry::TexturedPoint2D" />
+ <object-type name="QSGGeometryNode" />
+
+ <!-- QSGMaterialShader doesn't compile because of const char * char * types not being recognized
+ by the C++ parser, nor the generator.
+ <object-type name="QSGMaterial">
+ <enum-type name="Flag" flags="Flags" />
+ </object-type>
+ <object-type name="QSGMaterialShader" />
+ <value-type name="QSGMaterialShader::RenderState">
+ <enum-type name="DirtyState" flags="DirtyStates" />
+ </value-type>
+ -->
+ <object-type name="QSGMaterialType" />
+ <object-type name="QSGNode">
+ <enum-type name="DirtyStateBit" flags="DirtyState" />
+ <enum-type name="Flag" flags="Flags" />
+ <enum-type name="NodeType" />
+ </object-type>
+ <object-type name="QSGOpacityNode" />
+ <!-- <object-type name="QSGOpaqueTextureMaterial" /> -->
+ <object-type name="QSGSimpleRectNode" />
+ <object-type name="QSGSimpleTextureNode">
+ <enum-type name="TextureCoordinatesTransformFlag" flags="TextureCoordinatesTransformMode" />
+ </object-type>
+ <object-type name="QSGTexture">
+ <enum-type name="AnisotropyLevel" since="5.9"/>
+ <enum-type name="Filtering" />
+ <enum-type name="WrapMode" />
+ </object-type>
+ <!-- <object-type name="QSGTextureMaterial" /> -->
+ <object-type name="QSGTextureProvider" />
+ <object-type name="QSGTransformNode" />
+ <!-- <object-type name="QSGVertexColorMaterial" /> -->
+
+ <!-- These currently don't work because they are template classes, and the generator chokes on
+ them. Making these work properly would require fixing the parsing of template classes,
+ allowing creation of State structures and passing them to the template classes, as well as
+ implementing some mechanism of registration of the custom template classes, kind of how
+ it's done for qt quick items.
+ <object-type name="QSGSimpleMaterial" />
+ <object-type name="QSGSimpleMaterialShader" />
+ -->
+
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtQuickWidgets/CMakeLists.txt b/sources/pyside2/PySide2/QtQuickWidgets/CMakeLists.txt
new file mode 100644
index 000000000..1519d1cfd
--- /dev/null
+++ b/sources/pyside2/PySide2/QtQuickWidgets/CMakeLists.txt
@@ -0,0 +1,53 @@
+project(QtQuickWidgets)
+
+set(QtQuickWidgets_SRC
+${QtQuickWidgets_GEN_DIR}/qquickwidget_wrapper.cpp
+# module is always needed
+${QtQuickWidgets_GEN_DIR}/qtquickwidgets_module_wrapper.cpp
+)
+
+make_path(QtQuickWidgets_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtWidgets_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtWidgets_BINARY_DIR}
+ ${QtNetwork_SOURCE_DIR} ${QtNetwork_BINARY_DIR} ${QtQuick_SOURCE_DIR}
+ ${QtQuick_BINARY_DIR} ${QtQml_SOURCE_DIR} ${QtQml_BINARY_DIR}
+ ${QtQuickWidgets_SOURCE_DIR})
+
+set(QtQuickWidgets_include_dirs ${QtQuickWidgets_SOURCE_DIR}
+ ${QtQml_SOURCE_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5Network_INCLUDE_DIRS}
+ ${Qt5Quick_INCLUDE_DIRS}
+ ${Qt5Qml_INCLUDE_DIRS}
+ ${Qt5QuickWidgets_INCLUDE_DIRS}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ ${QtNetwork_GEN_DIR}
+ ${QtQuick_GEN_DIR}
+ ${QtQml_GEN_DIR}
+ ${QtQuickWidgets_GEN_DIR})
+
+set(QtQuickWidgets_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Network_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ ${Qt5Quick_LIBRARIES}
+ ${Qt5Qml_LIBRARIES}
+ ${Qt5QuickWidgets_LIBRARIES})
+
+set(QtQuickWidgets_deps QtGui QtQml QtQuick QtWidgets QtNetwork)
+
+create_pyside_module(QtQuickWidgets
+ QtQuickWidgets_include_dirs
+ QtQuickWidgets_libraries
+ QtQuickWidgets_deps
+ QtQuickWidgets_typesystem_path
+ QtQuickWidgets_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtQuickWidgets/typesystem_quickwidgets.xml b/sources/pyside2/PySide2/QtQuickWidgets/typesystem_quickwidgets.xml
new file mode 100644
index 000000000..10a269067
--- /dev/null
+++ b/sources/pyside2/PySide2/QtQuickWidgets/typesystem_quickwidgets.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtQuickWidgets">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+ <load-typesystem name="typesystem_gui.xml" generate="no"/>
+ <load-typesystem name="typesystem_quick.xml" generate="no"/>
+ <load-typesystem name="typesystem_qml.xml" generate="no"/>
+ <load-typesystem name="typesystem_widgets.xml" generate="no"/>
+
+
+ <object-type name="QQuickWidget">
+ <enum-type name="ResizeMode" />
+ <enum-type name="Status" />
+ </object-type>
+</typesystem> \ No newline at end of file
diff --git a/sources/pyside2/PySide2/QtScript/CMakeLists.txt b/sources/pyside2/PySide2/QtScript/CMakeLists.txt
new file mode 100644
index 000000000..5b5d08070
--- /dev/null
+++ b/sources/pyside2/PySide2/QtScript/CMakeLists.txt
@@ -0,0 +1,44 @@
+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
+)
+
+make_path(QtScript_typesystem_path ${QtCore_SOURCE_DIR} ${QtCore_BINARY_DIR})
+
+set(QtScript_include_dirs ${QtScript_SOURCE_DIR}
+ ${QtScript_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Script_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ )
+set(QtScript_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Script_LIBRARIES})
+set(QtScript_deps QtCore)
+create_pyside_module(QtScript
+ QtScript_include_dirs
+ QtScript_libraries
+ QtScript_deps
+ QtScript_typesystem_path
+ QtScript_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtScript/typesystem_script.xml b/sources/pyside2/PySide2/QtScript/typesystem_script.xml
new file mode 100644
index 000000000..9dbd107a1
--- /dev/null
+++ b/sources/pyside2/PySide2/QtScript/typesystem_script.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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="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">
+ if (%CPPSELF.isVariant() || %CPPSELF.isString()) {
+ QString format = QString().sprintf("%s(\"%s\")", ((PyObject*)%PYSELF)->ob_type->tp_name, qPrintable(%CPPSELF.toString()));
+ %PYARG_0 = Shiboken::String::fromCString(qPrintable(format));
+ } else {
+ %PYARG_0 = Shiboken::String::fromCString(
+ ((PyObject* )%PYSELF)->ob_type->tp_name);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="__mgetitem__">
+ <inject-code>
+ Shiboken::AutoDecRef key(PyObject_Str(_key));
+ QVariant res = %CPPSELF.property(Shiboken::String::toCString(key.object())).toVariant();
+ if (res.isValid()) {
+ return %CONVERTTOPYTHON[QVariant](res);
+ } else {
+ PyObject* errorType = PyInt_Check(_key) ? PyExc_IndexError : PyExc_KeyError;
+ PyErr_SetString(errorType, "Key not found.");
+ return 0;
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="__iter__()" return-type="PyObject*">
+ <inject-code>
+ %PYARG_0 = Shiboken::createWrapper(new QScriptValueIterator(*%CPPSELF), true, true);
+ </inject-code>
+ </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>
+ if (%CPPSELF.hasNext()) {
+ %CPPSELF.next();
+ QString name = %CPPSELF.name();
+ QVariant value = %CPPSELF.value().toVariant();
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[QString](name));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QVariant](value));
+ } else {
+ PyErr_SetNone(PyExc_StopIteration);
+ }
+ </inject-code>
+ </add-function>
+ </object-type>
+</typesystem>
+
diff --git a/sources/pyside2/PySide2/QtScriptTools/CMakeLists.txt b/sources/pyside2/PySide2/QtScriptTools/CMakeLists.txt
new file mode 100644
index 000000000..436522070
--- /dev/null
+++ b/sources/pyside2/PySide2/QtScriptTools/CMakeLists.txt
@@ -0,0 +1,46 @@
+project(QtScriptTools)
+
+set(QtScriptTools_SRC
+${QtScriptTools_GEN_DIR}/qscriptenginedebugger_wrapper.cpp
+# module is always needed
+${QtScriptTools_GEN_DIR}/qtscripttools_module_wrapper.cpp
+)
+
+make_path(QtScriptTools_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtScript_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtScript_BINARY_DIR}
+ ${QtWidgets_SOURCE_DIR} ${QtWidgets_BINARY_DIR}
+ ${QtScriptTools_SOURCE_DIR})
+
+set(QtScriptTools_include_dirs ${QtScriptTools_SOURCE_DIR}
+ ${QtScriptTools_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5Script_INCLUDE_DIRS}
+ ${Qt5ScriptTools_INCLUDE_DIRS}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ ${QtScript_GEN_DIR}
+ )
+
+set(QtScriptTools_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ ${Qt5Script_LIBRARIES}
+ ${Qt5ScriptTools_LIBRARIES})
+
+set(QtScriptTools_deps QtCore QtScript QtGui QtWidgets)
+
+create_pyside_module(QtScriptTools
+ QtScriptTools_include_dirs
+ QtScriptTools_libraries
+ QtScriptTools_deps
+ QtScriptTools_typesystem_path
+ QtScriptTools_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtScriptTools/typesystem_scripttools.xml b/sources/pyside2/PySide2/QtScriptTools/typesystem_scripttools.xml
new file mode 100644
index 000000000..15bda4059
--- /dev/null
+++ b/sources/pyside2/PySide2/QtScriptTools/typesystem_scripttools.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtScriptTools">
+ <load-typesystem name="typesystem_script.xml" generate="no" />
+ <load-typesystem name="typesystem_gui.xml" generate="no" />
+ <load-typesystem name="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>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtSql/CMakeLists.txt b/sources/pyside2/PySide2/QtSql/CMakeLists.txt
new file mode 100644
index 000000000..fe05d4679
--- /dev/null
+++ b/sources/pyside2/PySide2/QtSql/CMakeLists.txt
@@ -0,0 +1,55 @@
+project(QtSql)
+
+set(QtSql_SRC
+${QtSql_GEN_DIR}/qsql_wrapper.cpp
+${QtSql_GEN_DIR}/qsqldatabase_wrapper.cpp
+${QtSql_GEN_DIR}/qsqldriver_wrapper.cpp
+${QtSql_GEN_DIR}/qsqldrivercreatorbase_wrapper.cpp
+${QtSql_GEN_DIR}/qsqlerror_wrapper.cpp
+${QtSql_GEN_DIR}/qsqlfield_wrapper.cpp
+${QtSql_GEN_DIR}/qsqlindex_wrapper.cpp
+${QtSql_GEN_DIR}/qsqlquery_wrapper.cpp
+${QtSql_GEN_DIR}/qsqlquerymodel_wrapper.cpp
+${QtSql_GEN_DIR}/qsqlrecord_wrapper.cpp
+${QtSql_GEN_DIR}/qsqlrelation_wrapper.cpp
+${QtSql_GEN_DIR}/qsqlrelationaldelegate_wrapper.cpp
+${QtSql_GEN_DIR}/qsqlrelationaltablemodel_wrapper.cpp
+${QtSql_GEN_DIR}/qsqlresult_wrapper.cpp
+${QtSql_GEN_DIR}/qsqltablemodel_wrapper.cpp
+# module is always needed
+${QtSql_GEN_DIR}/qtsql_module_wrapper.cpp
+)
+
+make_path(QtSql_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtWidgets_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtWidgets_BINARY_DIR}
+ ${QtSql_SOURCE_DIR})
+
+set(QtSql_include_dirs ${QtSql_SOURCE_DIR}
+ ${QtSql_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5Sql_INCLUDE_DIRS}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ )
+set(QtSql_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ ${Qt5Sql_LIBRARIES})
+set(QtSql_deps QtWidgets)
+
+create_pyside_module(QtSql
+ QtSql_include_dirs
+ QtSql_libraries
+ QtSql_deps
+ QtSql_typesystem_path
+ QtSql_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtSql/typesystem_sql.xml b/sources/pyside2/PySide2/QtSql/typesystem_sql.xml
new file mode 100644
index 000000000..b3d4f2837
--- /dev/null
+++ b/sources/pyside2/PySide2/QtSql/typesystem_sql.xml
@@ -0,0 +1,197 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtSql">
+ <load-typesystem name="typesystem_widgets.xml" generate="no"/>
+
+ <rejection class="QSqlDriverCreator"/>
+ <rejection class="QSqlDriverPlugin"/>
+ <rejection class="QSqlDriverFactoryInterface"/>
+
+ <namespace-type name="QSql">
+ <enum-type name="Location"/>
+ <enum-type name="ParamTypeFlag" flags="ParamType"/>
+ <enum-type name="TableType"/>
+ <enum-type name="NumericalPrecisionPolicy"/>
+ <extra-includes>
+ <include file-name="QtSql/qsql.h" location="global"/>
+ </extra-includes>
+ </namespace-type>
+
+ <value-type name="QSqlDatabase">
+ <extra-includes>
+ <include file-name="QSqlQuery" location="global"/>
+ <include file-name="QSqlError" location="global"/>
+ <include file-name="QSqlIndex" location="global"/>
+ <include file-name="QSqlRecord" location="global"/>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ <modify-function signature="exec(QString)const" rename="exec_" allow-thread="yes" />
+ <modify-function signature="open()" allow-thread="yes" />
+ <modify-function signature="open(const QString&amp;, const QString&amp;)" allow-thread="yes" />
+ <modify-function signature="commit()" allow-thread="yes" />
+ <modify-function signature="rollback()" allow-thread="yes" />
+ <modify-function signature="transaction()" allow-thread="yes" />
+ <modify-function signature="registerSqlDriver(const QString &amp;, QSqlDriverCreatorBase*)">
+ <modify-argument index="2">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+
+ <value-type name="QSqlQuery">
+ <enum-type name="BatchExecutionMode"/>
+ <extra-includes>
+ <include file-name="QSqlError" location="global"/>
+ <include file-name="QSqlRecord" location="global"/>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ <modify-function signature="exec()" rename="exec_" allow-thread="yes" />
+ <modify-function signature="exec(const QString &amp;)" rename="exec_" allow-thread="yes" />
+ <modify-function signature="prepare(const QString&amp;)" allow-thread="yes" />
+ <modify-function signature="clear()" allow-thread="yes" />
+ <modify-function signature="last()" allow-thread="yes" />
+ <modify-function signature="first()" allow-thread="yes" />
+ <modify-function signature="previous()" allow-thread="yes" />
+ <modify-function signature="next()" allow-thread="yes" />
+ <modify-function signature="seek(int,bool)" allow-thread="yes" />
+ </value-type>
+
+ <value-type name="QSqlRecord">
+ <extra-includes>
+ <include file-name="QSqlField" location="global"/>
+ </extra-includes>
+ <modify-function signature="append(QSqlField)" access="non-final"/>
+ </value-type>
+
+ <value-type name="QSqlError">
+ <enum-type name="ErrorType"/>
+ </value-type>
+
+ <value-type name="QSqlIndex" />
+
+ <value-type name="QSqlRelation"/>
+
+ <object-type name="QSqlRelationalDelegate"/>
+
+ <value-type name="QSqlField">
+ <enum-type name="RequiredStatus"/>
+ </value-type>
+
+ <object-type name="QSqlDriver">
+ <enum-type name="DbmsType" />
+ <enum-type name="DriverFeature"/>
+ <enum-type name="IdentifierType"/>
+ <enum-type name="NotificationSource" />
+ <enum-type name="StatementType"/>
+ <extra-includes>
+ <include file-name="QSqlQuery" location="global"/>
+ <include file-name="QSqlError" location="global"/>
+ <include file-name="QSqlIndex" location="global"/>
+ <include file-name="QSqlRecord" location="global"/>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ <modify-function signature="beginTransaction()" allow-thread="yes" />
+ <modify-function signature="commitTransaction()" allow-thread="yes" />
+ <modify-function signature="rollbackTransaction()" allow-thread="yes" />
+ <modify-function signature="open(const QString &amp;, const QString&amp;, const QString&amp;, const QString&amp;, int, const QString&amp;)" allow-thread="yes" />
+ <!-- ### This is too low level for Python, and pointer would be useless for the Python programmer -->
+ <modify-function signature="handle() const" remove="all"/>
+ <!-- ### -->
+ </object-type>
+
+ <object-type name="QSqlQueryModel">
+ <modify-function signature="indexInQuery(QModelIndex)const" access="non-final"/>
+ <modify-function signature="setQuery(QSqlQuery)" access="non-final"/>
+ <extra-includes>
+ <include file-name="QSqlError" location="global"/>
+ <include file-name="QSqlQuery" location="global"/>
+ <include file-name="QSqlRecord" location="global"/>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ </object-type>
+ <object-type name="QSqlRelationalTableModel">
+ <enum-type name="JoinMode" />
+ <extra-includes>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ </object-type>
+ <object-type name="QSqlResult">
+ <enum-type name="BindingSyntax"/>
+ <enum-type name="VirtualHookOperation"/>
+ <extra-includes>
+ <include file-name="QSqlError" location="global"/>
+ <include file-name="QSqlQuery" location="global"/>
+ <include file-name="QSqlRecord" location="global"/>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ <!-- ### This isn't part of Qt public API -->
+ <modify-function signature="virtual_hook(int,void*)" remove="all" />
+ <!-- ### -->
+ <modify-function signature="exec()" rename="exec_" allow-thread="yes" />
+ <modify-function signature="fetchLast()" allow-thread="yes" />
+ <modify-function signature="fetchFirst()" allow-thread="yes" />
+ <modify-function signature="fetchNext()" allow-thread="yes" />
+ <modify-function signature="fetchPrevious()" allow-thread="yes" />
+ <modify-function signature="fetch(int)" allow-thread="yes" />
+ <modify-function signature="prepare(QString)" allow-thread="yes" />
+ </object-type>
+ <object-type name="QSqlTableModel">
+ <enum-type name="EditStrategy"/>
+ <extra-includes>
+ <include file-name="QSqlIndex" location="global"/>
+ <include file-name="QStringList" location="global"/>
+ <include file-name="QSize" location="global"/>
+ </extra-includes>
+ </object-type>
+ <object-type name="QSqlDriverCreatorBase">
+ <extra-includes>
+ <include file-name="QSqlDriver" location="global"/>
+ </extra-includes>
+ </object-type>
+
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtSvg/CMakeLists.txt b/sources/pyside2/PySide2/QtSvg/CMakeLists.txt
new file mode 100644
index 000000000..62db9e4ce
--- /dev/null
+++ b/sources/pyside2/PySide2/QtSvg/CMakeLists.txt
@@ -0,0 +1,45 @@
+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
+)
+
+make_path(QtSvg_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtWidgets_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtWidgets_BINARY_DIR}
+ ${QtSvg_SOURCE_DIR})
+
+set(QtSvg_include_dirs ${QtSvg_SOURCE_DIR}
+ ${QtSvg_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5Svg_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ )
+set(QtSvg_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ ${Qt5Svg_LIBRARIES}
+ )
+set(QtSvg_deps QtWidgets)
+
+create_pyside_module(QtSvg
+ QtSvg_include_dirs
+ QtSvg_libraries
+ QtSvg_deps
+ QtSvg_typesystem_path
+ QtSvg_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtSvg/typesystem_svg.xml b/sources/pyside2/PySide2/QtSvg/typesystem_svg.xml
new file mode 100644
index 000000000..603fe7897
--- /dev/null
+++ b/sources/pyside2/PySide2/QtSvg/typesystem_svg.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtSvg">
+ <load-typesystem name="typesystem_widgets.xml" generate="no"/>
+
+ <object-type name="QSvgRenderer" />
+ <object-type name="QSvgWidget" />
+
+ <object-type name="QSvgGenerator">
+ <modify-function signature="setOutputDevice(QIODevice*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="outputDevice() const">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </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/QtTest/CMakeLists.txt b/sources/pyside2/PySide2/QtTest/CMakeLists.txt
new file mode 100644
index 000000000..118f803ea
--- /dev/null
+++ b/sources/pyside2/PySide2/QtTest/CMakeLists.txt
@@ -0,0 +1,43 @@
+project(QtTest)
+
+set(QtTest_SRC
+${QtTest_GEN_DIR}/qtest_pysideqtoucheventsequence_wrapper.cpp
+${QtTest_GEN_DIR}/qtest_wrapper.cpp
+# module is always needed
+${QtTest_GEN_DIR}/qttest_module_wrapper.cpp
+)
+
+make_path(QtTest_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtWidgets_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtWidgets_BINARY_DIR}
+ ${QtTest_SOURCE_DIR})
+
+set(QtTest_include_dirs ${QtTest_SOURCE_DIR}
+ ${QtTest_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5Test_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ )
+set(QtTest_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Test_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ )
+set(QtTest_deps QtWidgets)
+
+create_pyside_module(QtTest
+ QtTest_include_dirs
+ QtTest_libraries
+ QtTest_deps
+ QtTest_typesystem_path
+ QtTest_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtTest/typesystem_test.xml b/sources/pyside2/PySide2/QtTest/typesystem_test.xml
new file mode 100644
index 000000000..61a3ee850
--- /dev/null
+++ b/sources/pyside2/PySide2/QtTest/typesystem_test.xml
@@ -0,0 +1,166 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtTest">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+ <load-typesystem name="typesystem_gui.xml" generate="no"/>
+ <load-typesystem name="typesystem_widgets.xml" generate="no"/>
+
+ <rejection class="QTest" function-name="qCompare&lt;char&gt;"/>
+ <rejection class="QTest" function-name="qCompare&lt;char*&gt;"/>
+ <rejection class="QTest" function-name="qCompare&lt;double&gt;"/>
+ <rejection class="QTest" function-name="qCompare&lt;float&gt;"/>
+ <rejection class="QTest" function-name="qCompare&lt;double,qreal&gt;"/>
+ <rejection class="QTest" function-name="qCompare&lt;qreal,double&gt;"/>
+ <rejection class="QTest" function-name="qCompare"/>
+ <rejection class="QTest" function-name="qVerify"/>
+ <rejection class="QTest" function-name="qSleep"/>
+ <rejection class="QTest" function-name="toHexRepresentation"/>
+ <rejection class="QTest" function-name="qWait"/>
+ <rejection class="QTest" function-name="qFail"/>
+ <rejection class="QTest" function-name="qExec"/>
+ <rejection class="QTest" function-name="qData"/>
+ <rejection class="QTest" function-name="qWarn"/>
+ <rejection class="QTest" function-name="toString"/>
+ <rejection class="QTest" function-name="toString&lt;bool>"/>
+ <rejection class="QTest" function-name="toString&lt;char>"/>
+ <rejection class="QTest" function-name="toString&lt;unsigned char>"/>
+ <rejection class="QTest" function-name="toString&lt;signed char>"/>
+ <rejection class="QTest" function-name="toString&lt;double>"/>
+ <rejection class="QTest" function-name="toString&lt;float>"/>
+ <rejection class="QTest" function-name="toString&lt;int>"/>
+ <rejection class="QTest" function-name="toString&lt;long>"/>
+ <rejection class="QTest" function-name="toString&lt;qint64>"/>
+ <rejection class="QTest" function-name="toString&lt;quint64>"/>
+ <rejection class="QTest" function-name="toString&lt;short>"/>
+ <rejection class="QTest" function-name="toString&lt;uint>"/>
+ <rejection class="QTest" function-name="toString&lt;ulong>"/>
+ <rejection class="QTest" function-name="toString&lt;ushort>"/>
+ <rejection class="QTest" function-name="qt_snprintf"/>
+
+ <rejection class="QTest" function-name="compare_helper"/>
+ <rejection class="QTest" function-name="toPrettyUnicode"/>
+
+ <rejection class="QTest" field-name="lastMouseButton"/>
+ <rejection class="QTest" field-name="lastMouseTimestamp"/>
+
+ <!-- Qt5: this new stuff below belongs to QtGui. I keep it here for now, after a long odyssey.
+
+ 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:
+
+ 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">
+ <enum-type name="CapabilityFlag" flags="Capabilities" />
+ <enum-type name="DeviceType" />
+ </object-type>
+ ^^^ this is now moved into QtGui -->
+
+ <namespace-type name="QTest">
+ <!-- Qt5: private <enum-type name="AttributeIndex" since="4.6"/> -->
+ <enum-type name="KeyAction"/>
+ <!-- Qt5: private <enum-type name="LogElementType" since="4.6"/> -->
+ <enum-type name="MouseAction"/>
+ <enum-type name="QBenchmarkMetric" since="4.7"/>
+ <enum-type name="TestFailMode"/>
+ <extra-includes>
+ <include file-name="QtTest" location="global"/>
+ </extra-includes>
+
+ <rejection class="QTouchEventSequence"/>
+ <object-type name="PySideQTouchEventSequence" target-lang-name="QTouchEventSequence" since="4.6" >
+ <modify-function signature="press(int, const QPoint&amp;, QWidget*)">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="press(int, const QPoint&amp;, QWindow*)">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="move(int, const QPoint&amp;, QWidget*)">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="move(int, const QPoint&amp;, QWindow*)">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="release(int, const QPoint&amp;, QWidget*)">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="release(int, const QPoint&amp;, QWindow*)">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="stationary(int)">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <modify-function signature="generateTouchEvent(QWidget*, QTouchDevice*, 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-argument index="return">
+ <define-ownership class="target" owner="target"/>
+ </modify-argument>
+ </modify-function>
+ </namespace-type>
+
+ <rejection class="QSignalSpy"/>
+ <rejection class="QTestEventList"/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtUiTools/CMakeLists.txt b/sources/pyside2/PySide2/QtUiTools/CMakeLists.txt
new file mode 100644
index 000000000..b7ae6974d
--- /dev/null
+++ b/sources/pyside2/PySide2/QtUiTools/CMakeLists.txt
@@ -0,0 +1,46 @@
+project(QtUiTools)
+
+set(QtUiTools_SRC
+${QtUiTools_GEN_DIR}/quiloader_wrapper.cpp
+# module is always needed
+${QtUiTools_GEN_DIR}/qtuitools_module_wrapper.cpp
+)
+
+make_path(QtUiTools_typesystem_path
+ ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtWidgets_SOURCE_DIR} ${QtXml_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtWidgets_BINARY_DIR} ${QtXml_BINARY_DIR}
+ ${QtUiTools_SOURCE_DIR})
+
+set(QtUiTools_include_dirs ${QtUiTools_SOURCE_DIR}
+ ${QtUiTools_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5Xml_INCLUDE_DIRS}
+ ${Qt5Designer_INCLUDE_DIRS}
+ ${Qt5UiTools_INCLUDE_DIRS}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${plugins_SOURCE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtXml_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ )
+set(QtUiTools_libraries pyside2
+ uiplugin
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${Qt5UiTools_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ )
+set(QtUiTools_deps QtWidgets QtXml)
+create_pyside_module(QtUiTools
+ QtUiTools_include_dirs
+ QtUiTools_libraries
+ QtUiTools_deps
+ QtUiTools_typesystem_path
+ QtUiTools_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtUiTools/glue/plugins.h b/sources/pyside2/PySide2/QtUiTools/glue/plugins.h
new file mode 100644
index 000000000..d550c3fc6
--- /dev/null
+++ b/sources/pyside2/PySide2/QtUiTools/glue/plugins.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 _PLUGIN_H_
+#define _PLUGIN_H_
+
+#include <QPluginLoader>
+#include "customwidgets.h"
+
+inline void registerCustomWidget(PyObject* obj)
+{
+ static PyCustomWidgets* plugin = 0;
+
+ if (plugin == 0) {
+ foreach(QObject* o, QPluginLoader::staticInstances()) {
+ plugin = qobject_cast<PyCustomWidgets*>(o);
+ if (plugin)
+ break;
+ }
+ }
+
+ if (!plugin)
+ qDebug() << "Failed to load uiloader plugin.";
+ else
+ plugin->registerWidgetType(obj);
+}
+
+#endif
diff --git a/sources/pyside2/PySide2/QtUiTools/glue/uitools_loadui.cpp b/sources/pyside2/PySide2/QtUiTools/glue/uitools_loadui.cpp
new file mode 100644
index 000000000..9a5d23046
--- /dev/null
+++ b/sources/pyside2/PySide2/QtUiTools/glue/uitools_loadui.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ * Based on code provided by:
+ * Antonio Valentino <antonio.valentino at tiscali.it>
+ * Frédéric <frederic.mantegazza at gbiloba.org>
+ */
+
+#include <shiboken.h>
+#include <QUiLoader>
+#include <QFile>
+#include <QWidget>
+
+static void createChildrenNameAttributes(PyObject* root, QObject* object)
+{
+ foreach (QObject* child, object->children()) {
+ const QByteArray name = child->objectName().toLocal8Bit();
+
+ if (!name.isEmpty() && !name.startsWith("_") && !name.startsWith("qt_")) {
+ bool hasAttr = PyObject_HasAttrString(root, name.constData());
+ if (!hasAttr) {
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child));
+ PyObject_SetAttrString(root, name.constData(), pyChild);
+ }
+ createChildrenNameAttributes(root, child);
+ }
+ createChildrenNameAttributes(root, child);
+ }
+}
+
+static PyObject* QUiLoadedLoadUiFromDevice(QUiLoader* self, QIODevice* dev, QWidget* parent)
+{
+ QWidget* wdg = self->load(dev, parent);
+
+ if (wdg) {
+ PyObject* pyWdg = %CONVERTTOPYTHON[QWidget*](wdg);
+ createChildrenNameAttributes(pyWdg, wdg);
+ if (parent) {
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](parent));
+ Shiboken::Object::setParent(pyParent, pyWdg);
+ }
+ return pyWdg;
+ }
+
+ if (!PyErr_Occurred())
+ PyErr_SetString(PyExc_RuntimeError, "Unable to open/read ui device");
+ return 0;
+}
+
+static PyObject* QUiLoaderLoadUiFromFileName(QUiLoader* self, const QString& uiFile, QWidget* parent)
+{
+ QFile fd(uiFile);
+ return QUiLoadedLoadUiFromDevice(self, &fd, parent);
+}
diff --git a/sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml b/sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml
new file mode 100644
index 000000000..a74af0076
--- /dev/null
+++ b/sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml
@@ -0,0 +1,150 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtUiTools">
+ <load-typesystem name="typesystem_widgets.xml" generate="no" />
+ <load-typesystem name="typesystem_xml.xml" generate="no" />
+
+ <object-type name="QUiLoader">
+ <extra-includes>
+ <include file-name="glue/plugins.h" location="local"/>
+ </extra-includes>
+ <inject-code class="native" position="beginning" file="glue/uitools_loadui.cpp"/>
+ <inject-code>
+ Q_IMPORT_PLUGIN(PyCustomWidgets);
+ </inject-code>
+ <add-function signature="registerCustomWidget(PyObject*)" return-type="void">
+ <modify-argument index="1">
+ <rename to="customWidgetType" />
+ </modify-argument>
+ <inject-documentation format="target" mode="append">
+ Registers a Python created custom widget to QUiLoader, so it can be recognized when
+ loading a `.ui` file. The custom widget type is passed via the ``customWidgetType`` argument.
+ This is needed when you want to override a virtual method of some widget in the interface,
+ since duck punching will not work with widgets created by QUiLoader based on the contents
+ of the `.ui` file.
+
+ (Remember that `duck punching virtual methods is an invitation for your own demise!
+ &lt;http://www.pyside.org/docs/shiboken/wordsofadvice.html#duck-punching-and-virtual-methods>`_)
+
+ Let's see an obvious example. If you want to create a new widget it's probable you'll end up
+ overriding :class:`~PySide2.QtGui.QWidget`'s :meth:`~PySide2.QtGui.QWidget.paintEvent` method.
+
+ .. code-block:: python
+
+ class Circle(QWidget):
+ def paintEvent(self, event):
+ painter = QPainter(self)
+ painter.setPen(self.pen)
+ painter.setBrush(QBrush(self.color))
+ painter.drawEllipse(event.rect().center(), 20, 20)
+
+ # ...
+
+ loader = QUiLoader()
+ loader.registerCustomWidget(Circle)
+ circle = loader.load('circle.ui')
+ circle.show()
+
+ # ...
+ </inject-documentation>
+ <inject-code class="target" position="beginning">
+ registerCustomWidget(%PYARG_1);
+ %CPPSELF.addPluginPath(""); // force reload widgets
+ </inject-code>
+ </add-function>
+ <modify-function signature="createAction(QObject*, const QString&amp;)">
+ <modify-argument index="return">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="createActionGroup(QObject*, const QString&amp;)">
+ <modify-argument index="return">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="createLayout(const QString&amp;, QObject*, const QString&amp;)">
+ <modify-argument index="return">
+ <parent index="2" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="createWidget(const QString&amp;, QWidget*, const QString&amp;)">
+ <modify-argument index="return">
+ <parent index="2" action="add"/>
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="load(QIODevice*, QWidget*)">
+ <modify-argument index="2">
+ <replace-default-expression with="0" />
+ <rename to="parentWidget" />
+ </modify-argument>
+ <modify-argument index="return">
+ <define-ownership class="target" owner="target"/>
+ </modify-argument>
+ <inject-code>
+ // Avoid calling the original function: %CPPSELF.%FUNCTION_NAME()
+ %PYARG_0 = QUiLoadedLoadUiFromDevice(%CPPSELF, %1, %2);
+ </inject-code>
+ </modify-function>
+
+ <!-- Syntax sugar -->
+ <add-function signature="load(QString, QWidget*)" return-type="QWidget*">
+ <modify-argument index="2">
+ <replace-default-expression with="0" />
+ <rename to="parentWidget" />
+ </modify-argument>
+ <modify-argument index="return">
+ <define-ownership class="target" owner="target"/>
+ </modify-argument>
+ <inject-code>
+ // Avoid calling the original function: %CPPSELF.%FUNCTION_NAME()
+ %PYARG_0 = QUiLoaderLoadUiFromFileName(%CPPSELF, %1, %2);
+ </inject-code>
+ </add-function>
+ </object-type>
+
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtWebChannel/CMakeLists.txt b/sources/pyside2/PySide2/QtWebChannel/CMakeLists.txt
new file mode 100644
index 000000000..ae292844f
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWebChannel/CMakeLists.txt
@@ -0,0 +1,35 @@
+project(QtWebChannel)
+
+set(QtWebChannel_SRC
+${QtWebChannel_GEN_DIR}/qwebchannel_wrapper.cpp
+${QtWebChannel_GEN_DIR}/qwebchannelabstracttransport_wrapper.cpp
+# module is always needed
+${QtWebChannel_GEN_DIR}/qtwebchannel_module_wrapper.cpp
+)
+
+make_path(QtWebChannel_typesystem_path ${QtCore_SOURCE_DIR} ${QtCore_BINARY_DIR} ${QtWebChannel_SOURCE_DIR})
+
+set(QtWebChannel_include_dirs ${QtWebChannel_SOURCE_DIR}
+ ${QtWebChannel_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5WebChannel_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ )
+set(QtWebChannel_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5WebChannel_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ )
+set(QtWebChannel_deps QtCore)
+
+create_pyside_module(QtWebChannel
+ QtWebChannel_include_dirs
+ QtWebChannel_libraries
+ QtWebChannel_deps
+ QtWebChannel_typesystem_path
+ QtWebChannel_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtWebChannel/typesystem_webchannel.xml b/sources/pyside2/PySide2/QtWebChannel/typesystem_webchannel.xml
new file mode 100644
index 000000000..c25d3f30a
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWebChannel/typesystem_webchannel.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtWebChannel">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+
+ <object-type name="QWebChannel" />
+ <object-type name="QWebChannelAbstractTransport">
+ <extra-includes>
+ <include file-name="QJsonObject" location="global"/>
+ </extra-includes>
+ </object-type>
+ <!-- Not sure if this will be useful, but commented out for now because
+ the QML module is not yet wrapped.
+ <object-type name="QQmlWebChannel" /> -->
+
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtWebEngineWidgets/CMakeLists.txt b/sources/pyside2/PySide2/QtWebEngineWidgets/CMakeLists.txt
new file mode 100644
index 000000000..1e82819f7
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWebEngineWidgets/CMakeLists.txt
@@ -0,0 +1,62 @@
+project(QtWebEngineWidgets)
+
+set(QtWebEngineWidgets_SRC
+${QtWebEngineWidgets_GEN_DIR}/qwebenginecertificateerror_wrapper.cpp
+${QtWebEngineWidgets_GEN_DIR}/qwebenginedownloaditem_wrapper.cpp
+#${QtWebEngineWidgets_GEN_DIR}/qwebenginehistory_wrapper.cpp
+${QtWebEngineWidgets_GEN_DIR}/qwebenginehistoryitem_wrapper.cpp
+${QtWebEngineWidgets_GEN_DIR}/qwebenginepage_wrapper.cpp
+${QtWebEngineWidgets_GEN_DIR}/qwebengineprofile_wrapper.cpp
+${QtWebEngineWidgets_GEN_DIR}/qwebenginescript_wrapper.cpp
+#${QtWebEngineWidgets_GEN_DIR}/qwebenginescriptcollection_wrapper.cpp
+#${QtWebEngineWidgets_GEN_DIR}/qwebenginesettings_wrapper.cpp
+${QtWebEngineWidgets_GEN_DIR}/qwebengineview_wrapper.cpp
+# module is always needed
+${QtWebEngineWidgets_GEN_DIR}/qtwebenginewidgets_module_wrapper.cpp
+)
+
+make_path(QtWebEngineWidgets_typesystem_path
+ ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtWidgets_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtWidgets_BINARY_DIR}
+ ${QtNetwork_SOURCE_DIR} ${QtNetwork_BINARY_DIR}
+ ${QtWebChannel_SOURCE_DIR} ${QtWebChannel_BINARY_DIR}
+ ${QtWebEngineWidgets_SOURCE_DIR})
+
+set(QtWebEngineWidgets_include_dirs
+ ${QtWebEngineWidgets_SOURCE_DIR}
+ ${QtWebEngineWidgets_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5Network_INCLUDE_DIRS}
+ ${Qt5WebChannel_INCLUDE_DIRS}
+ ${Qt5WebEngineWidgets_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ ${QtWebEngineWidgets_GEN_DIR}
+ ${QtNetwork_GEN_DIR}
+ ${QtWebChannel_GEN_DIR}
+ )
+set(QtWebEngineWidgets_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5WebEngineWidgets_LIBRARIES}
+ ${Qt5Network_LIBRARIES}
+ ${Qt5WebChannel_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ )
+set(QtWebEngineWidgets_deps QtGui QtWidgets QtNetwork QtWebChannel)
+create_pyside_module(QtWebEngineWidgets
+ QtWebEngineWidgets_include_dirs
+ QtWebEngineWidgets_libraries
+ QtWebEngineWidgets_deps
+ QtWebEngineWidgets_typesystem_path
+ QtWebEngineWidgets_SRC
+ "")
+
diff --git a/sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml b/sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml
new file mode 100644
index 000000000..f8255db07
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtWebEngineWidgets">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+ <load-typesystem name="typesystem_gui.xml" generate="no"/>
+ <load-typesystem name="typesystem_widgets.xml" generate="no"/>
+ <load-typesystem name="typesystem_network.xml" generate="no"/>
+ <load-typesystem name="typesystem_webchannel.xml" generate="no"/>
+
+
+ <object-type name="QWebEngineCertificateError">
+ <enum-type name="Error"/>
+ </object-type>
+
+ <object-type name="QWebEngineDownloadItem">
+ <enum-type name="DownloadState" />
+ </object-type>
+
+ <!-- TODO: Deal with private constructor
+ <value-type name="QWebEngineHistory" /> -->
+
+ <value-type name="QWebEngineHistoryItem" />
+
+ <object-type name="QWebEnginePage">
+ <enum-type name="WebAction" />
+ <enum-type name="FindFlag" flags="FindFlags"/>
+ <enum-type name="WebWindowType" />
+ <enum-type name="PermissionPolicy" />
+ <enum-type name="NavigationType" />
+ <enum-type name="Feature" />
+ <enum-type name="FileSelectionMode" />
+ <enum-type name="JavaScriptConsoleMessageLevel" />
+ </object-type>
+
+ <object-type name="QWebEngineProfile">
+ <enum-type name="HttpCacheType" />
+ <enum-type name="PersistentCookiesPolicy" />
+ </object-type>
+
+ <value-type name="QWebEngineScript">
+ <enum-type name="InjectionPoint" />
+ <enum-type name="ScriptWorldId" />
+ </value-type>
+
+ <!-- TODO: Deal with private constructor
+ <value-type name="QWebEngineScriptCollection" /> -->
+
+ <!-- TODO: Deal with private constructor
+ <value-type name="QWebEngineSettings">
+ <enum-type name="FontFamily" />
+ <enum-type name="WebAttribute" />
+ <enum-type name="FontSize" />
+ </value-type> -->
+
+ <object-type name="QWebEngineView" />
+
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtWebKit/CMakeLists.txt b/sources/pyside2/PySide2/QtWebKit/CMakeLists.txt
new file mode 100644
index 000000000..6bbcbfd43
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWebKit/CMakeLists.txt
@@ -0,0 +1,43 @@
+project(QtWebKit)
+
+set(QtWebKit_SRC
+${QtWebKit_GEN_DIR}/webcore_wrapper.cpp
+# module is always needed
+${QtWebKit_GEN_DIR}/qtwebkit_module_wrapper.cpp
+)
+
+make_path(QtWebKit_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtNetwork_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtNetwork_BINARY_DIR}
+ ${QtWebKit_SOURCE_DIR})
+
+set(QtWebKit_include_dirs ${QtWebKit_SOURCE_DIR}
+ ${QtWebKit_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Network_INCLUDE_DIRS}
+ ${Qt5WebKit_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ ${QtNetwork_GEN_DIR}
+ )
+set(QtWebKit_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5WebKit_LIBRARIES}
+ ${Qt5Network_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ )
+set(QtWebKit_deps QtGui QtNetwork)
+create_pyside_module(QtWebKit
+ QtWebKit_include_dirs
+ QtWebKit_libraries
+ QtWebKit_deps
+ QtWebKit_typesystem_path
+ QtWebKit_SRC
+ "")
+
diff --git a/sources/pyside2/PySide2/QtWebKit/typesystem_webkit.xml b/sources/pyside2/PySide2/QtWebKit/typesystem_webkit.xml
new file mode 100644
index 000000000..c559c7c02
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWebKit/typesystem_webkit.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtWebKit">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+ <load-typesystem name="typesystem_gui.xml" generate="no"/>
+ <load-typesystem name="typesystem_network.xml" generate="no"/>
+
+ <namespace-type name="WebCore"/>
+
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtWebKitWidgets/CMakeLists.txt b/sources/pyside2/PySide2/QtWebKitWidgets/CMakeLists.txt
new file mode 100644
index 000000000..fa57c8694
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWebKitWidgets/CMakeLists.txt
@@ -0,0 +1,77 @@
+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
+)
+
+make_path(QtWebKitWidgets_typesystem_path
+ ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtWidgets_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtWidgets_BINARY_DIR}
+ ${QtWebKit_SOURCE_DIR} ${QtPrintSupport_SOURCE_DIR} ${QtNetwork_SOURCE_DIR}
+ ${QtWebKit_BINARY_DIR} ${QtPrintSupport_BINARY_DIR} ${QtNetwork_BINARY_DIR}
+ ${QtWebKitWidgets_SOURCE_DIR})
+
+set(QtWebKitWidgets_include_dirs
+ ${QtWebKitWidgets_SOURCE_DIR}
+ ${QtWebKitWidgets_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${Qt5WebKit_INCLUDE_DIRS}
+ ${Qt5PrintSupport_INCLUDE_DIRS}
+ ${Qt5Network_INCLUDE_DIRS}
+ ${Qt5WebKitWidgets_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ ${QtPrintSupport_GEN_DIR}
+ ${QtWebKit_GEN_DIR}
+ ${QtNetwork_GEN_DIR}
+ )
+set(QtWebKitWidgets_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5WebKit_LIBRARIES}
+ ${Qt5WebKitWidgets_LIBRARIES}
+ ${Qt5Network_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ )
+set(QtWebKitWidgets_deps QtWidgets QtPrintSupport QtNetwork)
+create_pyside_module(QtWebKitWidgets
+ QtWebKitWidgets_include_dirs
+ QtWebKitWidgets_libraries
+ QtWebKitWidgets_deps
+ QtWebKitWidgets_typesystem_path
+ QtWebKitWidgets_SRC
+ "")
+
diff --git a/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml b/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml
new file mode 100644
index 000000000..05061fa6c
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml
@@ -0,0 +1,266 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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="typesystem_core.xml" generate="no"/>
+ <load-typesystem name="typesystem_gui.xml" generate="no"/>
+ <load-typesystem name="typesystem_widgets.xml" generate="no"/>
+ <load-typesystem name="typesystem_webkit.xml" generate="no"/>
+ <load-typesystem name="typesystem_network.xml" generate="no"/>
+ <load-typesystem name="typesystem_printsupport.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">
+ SbkObject* _pyReturn = reinterpret_cast&lt;SbkObject*&gt;(%PYARG_0);
+ if (!Shiboken::Object::hasParentInfo(_pyReturn))
+ Shiboken::Object::setParent(%PYSELF, %PYARG_0);
+ </inject-code>
+ </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>
+ return %CPPSELF.count();
+ </inject-code>
+ </add-function>
+ <add-function signature="__getitem__">
+ <inject-code>
+ if (_i &lt; 0 || _i >= %CPPSELF.count()) {
+ PyErr_SetString(PyExc_IndexError, "index out of bounds");
+ return 0;
+ }
+ QWebElement element = %CPPSELF.at(_i);
+ return %CONVERTTOPYTHON[QWebElement](element);
+ </inject-code>
+ </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">
+ <insert-template name="convertFromMultiMap">
+ <replace from="%MAP_NAME" to="%0"/>
+ <replace from="%RETURN_NAME" to="%PYARG_0"/>
+ <replace from="%KEY_TYPE" to="QString"/>
+ <replace from="%VALUE_TYPE" to="QString"/>
+ </insert-template>
+ </inject-code>
+ </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*)">
+ <template name="qwebpage_extension_argument_conversion">
+ PyObject* %out = 0;
+ // Cast the parameters according to the extension type
+ if (extension == QWebPage::ChooseMultipleFilesExtension) {
+ const ChooseMultipleFilesExtension$TYPE_SUFFIX* _in = reinterpret_cast&lt;const ChooseMultipleFilesExtension$TYPE_SUFFIX*>(%in);
+ %out = %CONVERTTOPYTHON[const QWebPage::ChooseMultipleFilesExtension$TYPE_SUFFIX*](_in);
+ #if QT_VERSION >= 0x040600
+ } else if (extension == QWebPage::ErrorPageExtension) {
+ const ErrorPageExtension$TYPE_SUFFIX* _in = reinterpret_cast&lt;const ErrorPageExtension$TYPE_SUFFIX*>(%in);
+ %out = %CONVERTTOPYTHON[const QWebPage::ErrorPageExtension$TYPE_SUFFIX*](_in);
+ #endif
+ }
+ </template>
+ <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">
+ QString _local;
+ QString* %4 = &amp;_local;
+ </conversion-rule>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PySequence"/>
+ <conversion-rule class="native">
+ Shiboken::AutoDecRef pyRes(PySequence_GetItem(%PYARG_0, 0));
+ Shiboken::AutoDecRef pyStr(PySequence_GetItem(%PYARG_0, 1));
+ %RETURN_TYPE %out = %CONVERTTOCPP[%RETURN_TYPE](pyRes);
+ *%4 = %CONVERTTOCPP[QString](pyStr);
+ </conversion-rule>
+ <conversion-rule class="target">
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QString](*%4));
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+
+ <add-function signature="qt_metacall()">
+ <inject-code class="native">
+ static int _signalIndex = -1;
+ static QMetaMethod _m;
+
+ if (_signalIndex == -1) {
+ _signalIndex = QWebPage::staticMetaObject.indexOfSlot("shouldInterruptJavaScript()");
+ _m = QWebPage::staticMetaObject.method(_signalIndex);
+ }
+
+ if (_signalIndex == id) {
+ Shiboken::GilState gil;
+ PyObject* self = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(this);
+ if (self) {
+ Shiboken::AutoDecRef _pyMethod(PyObject_GetAttrString(self, "shouldInterruptJavaScript"));
+ return PySide::SignalManager::callPythonMetaMethod(_m, args, _pyMethod, false);
+ }
+ }
+ </inject-code>
+ </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/QtWebSockets/CMakeLists.txt b/sources/pyside2/PySide2/QtWebSockets/CMakeLists.txt
new file mode 100644
index 000000000..9eb402644
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWebSockets/CMakeLists.txt
@@ -0,0 +1,44 @@
+project(QtWebSockets)
+
+set(QtWebSockets_SRC
+${QtWebSockets_GEN_DIR}/qmaskgenerator_wrapper.cpp
+${QtWebSockets_GEN_DIR}/qwebsocket_wrapper.cpp
+${QtWebSockets_GEN_DIR}/qwebsocketcorsauthenticator_wrapper.cpp
+${QtWebSockets_GEN_DIR}/qwebsocketprotocol_wrapper.cpp
+${QtWebSockets_GEN_DIR}/qwebsocketserver_wrapper.cpp
+# module is always needed
+${QtWebSockets_GEN_DIR}/qtwebsockets_module_wrapper.cpp
+)
+
+make_path(QtWebSockets_typesystem_path ${QtCore_SOURCE_DIR} ${QtCore_BINARY_DIR} ${QtNetwork_SOURCE_DIR}
+ ${QtNetwork_BINARY_DIR} ${QtWebSockets_SOURCE_DIR})
+
+set(QtWebSockets_include_dirs ${QtWebSockets_SOURCE_DIR}
+ ${QtWebSockets_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Network_INCLUDE_DIRS}
+ ${Qt5WebSockets_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtWebSockets_GEN_DIR}
+ ${QtNetwork_GEN_DIR}
+ )
+set(QtWebSockets_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5WebSockets_LIBRARIES}
+ ${Qt5Network_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ )
+
+set(QtWebSockets_deps QtNetwork)
+
+create_pyside_module(QtWebSockets
+ QtWebSockets_include_dirs
+ QtWebSockets_libraries
+ QtWebSockets_deps
+ QtWebSockets_typesystem_path
+ QtWebSockets_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtWebSockets/typesystem_websockets.xml b/sources/pyside2/PySide2/QtWebSockets/typesystem_websockets.xml
new file mode 100644
index 000000000..8671795c0
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWebSockets/typesystem_websockets.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtWebSockets">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+ <load-typesystem name="typesystem_network.xml" generate="no"/>
+
+ <object-type name="QMaskGenerator" />
+
+ <object-type name="QWebSocket">
+ <extra-includes>
+ <include file-name="QTcpSocket" location="global"/>
+ </extra-includes>
+ </object-type>
+
+ <object-type name="QWebSocketCorsAuthenticator" />
+
+ <namespace-type name="QWebSocketProtocol">
+ <enum-type name="Version"/>
+ <enum-type name="CloseCode"/>
+ </namespace-type>
+
+ <object-type name="QWebSocketServer">
+ <enum-type name="SslMode" />
+ <extra-includes>
+ <include file-name="QWebSocketCorsAuthenticator" location="global" />
+ </extra-includes>
+ </object-type>
+
+ <!-- TODO: Gracefully handle the lack of SSL support -->
+ <rejection class="QWebSocket" function-name="ignoreSslErrors" />
+ <rejection class="QWebSocket" function-name="setSslConfiguration" />
+ <rejection class="QWebSocket" function-name="sslConfiguration" />
+ <rejection class="QWebSocket" function-name="ignoreSslErrors" />
+ <rejection class="QWebSocket" function-name="sslErrors" />
+ <rejection class="QWebSocketServer" function-name="setSslConfiguration" />
+ <rejection class="QWebSocketServer" function-name="sslConfiguration" />
+ <rejection class="QWebSocketServer" function-name="peerVerifyError" />
+ <rejection class="QWebSocketServer" function-name="sslErrors" />
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt b/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt
new file mode 100644
index 000000000..84dec8fa9
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt
@@ -0,0 +1,260 @@
+project(QtWidgets)
+
+
+set(QtWidgets_OPTIONAL_SRC )
+set(QtWidgets_DROPPED_ENTRIES )
+## gone check_qt_class(Qt5Widgets QAbstractPageSetupDialog QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+## actually, all the printer stuff is in QtPrintSupport
+## XXX check if these conditionals need to be done elsewhere
+check_qt_class(Qt5Widgets QAbstractPrintDialog QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QGtkStyle QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QPageSetupDialog QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QPrintDialog QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QPrintEngine QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QPrintPreviewDialog QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QPrintPreviewWidget QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QPrinter QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QPrinterInfo QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QSessionManager QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QSizeGrip QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QSystemTrayIcon QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+check_qt_class(Qt5Widgets QMacStyle QtWidgets_OPTIONAL_SRC QtWidgets_DROPPED_ENTRIES)
+
+set(QtWidgets_SRC
+${QtWidgets_GEN_DIR}/qabstractbutton_wrapper.cpp
+${QtWidgets_GEN_DIR}/qabstractgraphicsshapeitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qabstractitemdelegate_wrapper.cpp
+${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
+${QtWidgets_GEN_DIR}/qcalendarwidget_wrapper.cpp
+${QtWidgets_GEN_DIR}/qcheckbox_wrapper.cpp
+${QtWidgets_GEN_DIR}/qcolordialog_wrapper.cpp
+${QtWidgets_GEN_DIR}/qcolumnview_wrapper.cpp
+${QtWidgets_GEN_DIR}/qcombobox_wrapper.cpp
+${QtWidgets_GEN_DIR}/qcommandlinkbutton_wrapper.cpp
+${QtWidgets_GEN_DIR}/qcommonstyle_wrapper.cpp
+${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
+${QtWidgets_GEN_DIR}/qfiledialog_wrapper.cpp
+${QtWidgets_GEN_DIR}/qfileiconprovider_wrapper.cpp
+${QtWidgets_GEN_DIR}/qfilesystemmodel_wrapper.cpp
+${QtWidgets_GEN_DIR}/qfocusframe_wrapper.cpp
+${QtWidgets_GEN_DIR}/qfontcombobox_wrapper.cpp
+${QtWidgets_GEN_DIR}/qfontdialog_wrapper.cpp
+${QtWidgets_GEN_DIR}/qformlayout_wrapper.cpp
+${QtWidgets_GEN_DIR}/qframe_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgesture_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgestureevent_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgesturerecognizer_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsanchor_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsanchorlayout_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsblureffect_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicscolorizeeffect_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsdropshadoweffect_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicseffect_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsellipseitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsgridlayout_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsitemanimation_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsitemgroup_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicslayout_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicslayoutitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicslinearlayout_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicslineitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsobject_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsopacityeffect_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicspathitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicspixmapitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicspolygonitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsproxywidget_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsrectitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsrotation_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsscale_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsscene_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsscenecontextmenuevent_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsscenedragdropevent_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicssceneevent_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsscenehelpevent_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsscenehoverevent_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsscenemouseevent_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsscenemoveevent_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicssceneresizeevent_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsscenewheelevent_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicssimpletextitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicstextitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicstransform_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicsview_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgraphicswidget_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgridlayout_wrapper.cpp
+${QtWidgets_GEN_DIR}/qgroupbox_wrapper.cpp
+${QtWidgets_GEN_DIR}/qhboxlayout_wrapper.cpp
+${QtWidgets_GEN_DIR}/qheaderview_wrapper.cpp
+${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
+${QtWidgets_GEN_DIR}/qlayoutitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qlcdnumber_wrapper.cpp
+${QtWidgets_GEN_DIR}/qlineedit_wrapper.cpp
+${QtWidgets_GEN_DIR}/qlistview_wrapper.cpp
+${QtWidgets_GEN_DIR}/qlistwidget_wrapper.cpp
+${QtWidgets_GEN_DIR}/qlistwidgetitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qmainwindow_wrapper.cpp
+${QtWidgets_GEN_DIR}/qmdiarea_wrapper.cpp
+${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
+${QtWidgets_GEN_DIR}/qplaintextedit_wrapper.cpp
+${QtWidgets_GEN_DIR}/qprogressbar_wrapper.cpp
+${QtWidgets_GEN_DIR}/qprogressdialog_wrapper.cpp
+${QtWidgets_GEN_DIR}/qpushbutton_wrapper.cpp
+${QtWidgets_GEN_DIR}/qradiobutton_wrapper.cpp
+${QtWidgets_GEN_DIR}/qrubberband_wrapper.cpp
+${QtWidgets_GEN_DIR}/qscrollarea_wrapper.cpp
+${QtWidgets_GEN_DIR}/qscrollbar_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
+${QtWidgets_GEN_DIR}/qspaceritem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qspinbox_wrapper.cpp
+${QtWidgets_GEN_DIR}/qsplashscreen_wrapper.cpp
+${QtWidgets_GEN_DIR}/qsplitter_wrapper.cpp
+${QtWidgets_GEN_DIR}/qsplitterhandle_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstackedlayout_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstackedwidget_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstatusbar_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyle_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleditemdelegate_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstylefactory_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstylehintreturn_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstylehintreturnmask_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstylehintreturnvariant_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoption_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptionbutton_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptioncombobox_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptioncomplex_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptiondockwidget_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptionfocusrect_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptionframe_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptiongraphicsitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptiongroupbox_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptionheader_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptionmenuitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptionprogressbar_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptionrubberband_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptionsizegrip_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptionslider_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptionspinbox_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptiontab_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptiontabbarbase_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptiontabwidgetframe_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptiontitlebar_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptiontoolbar_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptiontoolbox_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptiontoolbutton_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstyleoptionviewitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qstylepainter_wrapper.cpp
+${QtWidgets_GEN_DIR}/qswipegesture_wrapper.cpp
+${QtWidgets_GEN_DIR}/qsystemtrayicon_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtabbar_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtableview_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtablewidget_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtablewidgetitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtablewidgetselectionrange_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtabwidget_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtapandholdgesture_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtapgesture_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtextbrowser_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtextedit_extraselection_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtextedit_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtilerules_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtimeedit_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtoolbar_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtoolbox_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtoolbutton_wrapper.cpp
+${QtWidgets_GEN_DIR}/qtooltip_wrapper.cpp
+${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
+${QtWidgets_GEN_DIR}/qwidget_wrapper.cpp
+${QtWidgets_GEN_DIR}/qwidgetaction_wrapper.cpp
+${QtWidgets_GEN_DIR}/qwidgetitem_wrapper.cpp
+${QtWidgets_GEN_DIR}/qwizard_wrapper.cpp
+${QtWidgets_GEN_DIR}/qwizardpage_wrapper.cpp
+
+${SPECIFIC_OS_FILES}
+# module is always needed
+${QtWidgets_GEN_DIR}/qtwidgets_module_wrapper.cpp
+)
+
+configure_file("${QtWidgets_SOURCE_DIR}/typesystem_widgets.xml.in"
+ "${QtWidgets_BINARY_DIR}/typesystem_widgets.xml" @ONLY)
+
+make_path(QtWidgets_typesystem_path ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR}
+ ${QtWidgets_SOURCE_DIR})
+
+set(QtWidgets_include_dirs ${QtWidgets_SOURCE_DIR}
+ ${QtWidgets_BINARY_DIR}
+ ${pyside2_SOURCE_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ )
+set(QtWidgets_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ )
+set(QtWidgets_deps QtGui)
+
+create_pyside_module(QtWidgets
+ QtWidgets_include_dirs
+ QtWidgets_libraries
+ QtWidgets_deps
+ QtWidgets_typesystem_path
+ QtWidgets_SRC
+ ""
+ ${QtWidgets_BINARY_DIR}/typesystem_widgets.xml)
diff --git a/sources/pyside2/PySide2/QtWidgets/glue/qapplication_init.cpp b/sources/pyside2/PySide2/QtWidgets/glue/qapplication_init.cpp
new file mode 100644
index 000000000..0de34d9c5
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/glue/qapplication_init.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+// Borrowed reference to QtWidgets module
+extern PyObject* moduleQtWidgets;
+
+static int QApplicationArgCount;
+static char** QApplicationArgValues;
+static const char QAPP_MACRO[] = "qApp";
+
+bool QApplicationConstructorStart(PyObject* argv)
+{
+ if (QApplication::instance()) {
+ PyErr_SetString(PyExc_RuntimeError, "A QApplication instance already exists.");
+ return false;
+ }
+
+ return Shiboken::sequenceToArgcArgv(argv, &QApplicationArgCount, &QApplicationArgValues, "PySideApp");
+}
+
+void QApplicationConstructorEnd(PyObject* self)
+{
+ // Verify if qApp is in main module
+ PyObject* globalsDict = PyEval_GetGlobals();
+ if (globalsDict) {
+ PyObject* qAppObj = PyDict_GetItemString(globalsDict, QAPP_MACRO);
+ if (qAppObj)
+ PyDict_SetItemString(globalsDict, QAPP_MACRO, self);
+ }
+
+ PyObject_SetAttrString(moduleQtWidgets, QAPP_MACRO, self);
+ PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
+ Py_INCREF(self);
+}
+
+static void QApplicationConstructor(PyObject* self, PyObject* argv, QApplicationWrapper** cptr)
+{
+ if (QApplicationConstructorStart(argv)) {
+ // XXX do we need to support the ApplicationFlags parameter, instead of 0?
+ *cptr = new QApplicationWrapper(QApplicationArgCount, QApplicationArgValues, 0);
+ Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self));
+ QApplicationConstructorEnd(self);
+ }
+}
diff --git a/sources/pyside2/PySide2/QtWidgets/glue/qlayout_help_functions.cpp b/sources/pyside2/PySide2/QtWidgets/glue/qlayout_help_functions.cpp
new file mode 100644
index 000000000..e1d2ffc4d
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/glue/qlayout_help_functions.cpp
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+void addLayoutOwnership(QLayout* layout, QLayoutItem* item);
+void removeLayoutOwnership(QLayout* layout, QWidget* widget);
+
+inline QByteArray retrieveObjectName(PyObject* obj)
+{
+ Shiboken::AutoDecRef objName(PyObject_Str(obj));
+ return Shiboken::String::toCString(objName);
+}
+
+inline void addLayoutOwnership(QLayout* layout, QWidget* widget)
+{
+ //transfer ownership to parent widget
+ QWidget *lw = layout->parentWidget();
+ QWidget *pw = widget->parentWidget();
+
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget));
+
+ //Transfer parent to layout widget
+ if (pw && lw && pw != lw)
+ Shiboken::Object::setParent(0, pyChild);
+
+ if (!lw && !pw) {
+ //keep the reference while the layout is orphan
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](layout));
+ Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
+ } else {
+ if (!lw)
+ lw = pw;
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](lw));
+ Shiboken::Object::setParent(pyParent, pyChild);
+ }
+}
+
+inline void addLayoutOwnership(QLayout* layout, QLayout* other)
+{
+ //transfer all children widgets from other to layout parent widget
+ QWidget* parent = layout->parentWidget();
+ if (!parent) {
+ //keep the reference while the layout is orphan
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](other));
+ Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
+ return;
+ }
+
+ for (int i=0, i_max=other->count(); i < i_max; i++) {
+ QLayoutItem* item = other->itemAt(i);
+ if (PyErr_Occurred() || !item)
+ return;
+ addLayoutOwnership(layout, item);
+ }
+
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](other));
+ Shiboken::Object::setParent(pyParent, pyChild);
+}
+
+inline void addLayoutOwnership(QLayout* layout, QLayoutItem* item)
+{
+ if (!item)
+ return;
+
+ QWidget* w = item->widget();
+ if (w)
+ addLayoutOwnership(layout, w);
+ else {
+ QLayout* l = item->layout();
+ if (l)
+ addLayoutOwnership(layout, l);
+ }
+
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayoutItem*](item));
+ Shiboken::Object::setParent(pyParent, pyChild);
+}
+
+static void removeWidgetFromLayout(QLayout* layout, QWidget* widget)
+{
+ QWidget* parent = widget->parentWidget();
+
+ if (!parent) {
+ //remove reference on layout
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](layout));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget));
+ Shiboken::Object::removeReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild);
+ } else {
+ //give the ownership to parent
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](parent));
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget));
+ Shiboken::Object::setParent(pyParent, pyChild);
+ }
+}
+
+inline void removeLayoutOwnership(QLayout* layout, QLayoutItem* item)
+{
+ QWidget* w = item->widget();
+ if (w)
+ removeWidgetFromLayout(layout, w);
+ else {
+ QLayout* l = item->layout();
+ if (l && item != l)
+ removeLayoutOwnership(layout, l);
+ }
+
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayoutItem*](item));
+ Shiboken::Object::invalidate(pyChild);
+ Shiboken::Object::setParent(0, pyChild);
+}
+
+inline void removeLayoutOwnership(QLayout* layout, QWidget* widget)
+{
+ if (!widget)
+ return;
+
+ for (int i=0, i_max=layout->count(); i < i_max; i++) {
+ QLayoutItem* item = layout->itemAt(i);
+ if (PyErr_Occurred() || !item)
+ return;
+ if (item->widget() == widget)
+ removeLayoutOwnership(layout, item);
+ }
+}
diff --git a/sources/pyside2/PySide2/QtWidgets/glue/qmenu_glue.cpp b/sources/pyside2/PySide2/QtWidgets/glue/qmenu_glue.cpp
new file mode 100644
index 000000000..68e991ce7
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/glue/qmenu_glue.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+inline PyObject* addActionWithPyObject(QMenu* self, const QIcon& icon, const QString& text, PyObject* callback, const QKeySequence& shortcut)
+{
+ QAction* act = new QAction(text, self);
+
+ if (!icon.isNull())
+ act->setIcon(icon);
+
+ if (!shortcut.isEmpty())
+ act->setShortcut(shortcut);
+
+ self->addAction(act);
+
+ PyObject* pyAct = %CONVERTTOPYTHON[QAction*](act);
+ Shiboken::AutoDecRef result(PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered()), callback));
+ if (result.isNull()) {
+ Py_DECREF(pyAct);
+ return 0;
+ }
+
+ return pyAct;
+}
diff --git a/sources/pyside2/PySide2/QtWidgets/glue/qmenubar_glue.cpp b/sources/pyside2/PySide2/QtWidgets/glue/qmenubar_glue.cpp
new file mode 100644
index 000000000..15ddfb81a
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/glue/qmenubar_glue.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+inline PyObject*
+addActionWithPyObject(QMenuBar* self, const QString& text, PyObject* callback)
+{
+ QAction* act = new QAction(text, self);
+
+ self->addAction(act);
+
+ PyObject* pyAct = %CONVERTTOPYTHON[QAction*](act);
+ PyObject* result = PyObject_CallMethod(pyAct, "connect", "OsO", pyAct,
+ SIGNAL(triggered(bool)), callback);
+
+ if (result == 0 || result == Py_False) {
+ if (result)
+ Py_DECREF(result);
+ Py_DECREF(pyAct);
+ return 0;
+ }
+
+ return pyAct;
+}
diff --git a/sources/pyside2/PySide2/QtWidgets/glue/qtwidgets_qapp.cpp b/sources/pyside2/PySide2/QtWidgets/glue/qtwidgets_qapp.cpp
new file mode 100644
index 000000000..e041c7680
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/glue/qtwidgets_qapp.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+// Init qApp macro to None.
+if (qApp) {
+ PyObject* pyApp = %CONVERTTOPYTHON[QApplication*](qApp);
+ Py_INCREF(pyApp);
+ PyModule_AddObject(module, "qApp", pyApp);
+} else {
+ Py_INCREF(Py_None);
+ PyModule_AddObject(module, "qApp", Py_None);
+}
+moduleQtWidgets = module;
diff --git a/sources/pyside2/PySide2/QtWidgets/glue/qwidget_glue.cpp b/sources/pyside2/PySide2/QtWidgets/glue/qwidget_glue.cpp
new file mode 100644
index 000000000..1dd03a8fc
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/glue/qwidget_glue.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+static QString retrieveObjectName(PyObject *obj)
+{
+ Shiboken::AutoDecRef objName(PyObject_Str(obj));
+ return QString(Shiboken::String::toCString(objName));
+}
+
+
+/**
+ * Tranfer objects ownership from layout to widget
+ **/
+static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout)
+{
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](parent));
+
+ for (int i=0; i < layout->count(); i++) {
+ QLayoutItem* item = layout->itemAt(i);
+ if (PyErr_Occurred() || !item)
+ return;
+
+ QWidget* w = item->widget();
+ if (w) {
+ QWidget* pw = w->parentWidget();
+ if (pw != parent) {
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](w));
+ Shiboken::Object::setParent(pyParent, pyChild);
+ }
+ } else {
+ QLayout* l = item->layout();
+ if (l)
+ qwidgetReparentLayout(parent, l);
+ }
+ }
+
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](layout));
+ Shiboken::Object::setParent(pyParent, pyChild);
+ //remove previous references
+ Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyChild.object()), qPrintable(retrieveObjectName(pyChild)), Py_None);
+}
+
+static inline void qwidgetSetLayout(QWidget *self, QLayout *layout)
+{
+ if (!layout || self->layout())
+ return;
+
+ QObject* oldParent = layout->parent();
+ if (oldParent && oldParent != self) {
+ if (oldParent->isWidgetType()) {
+ // remove old parent policy
+ Shiboken::AutoDecRef pyLayout(%CONVERTTOPYTHON[QLayout*](layout));
+ Shiboken::Object::setParent(Py_None, pyLayout);
+ } else {
+ PyErr_Format(PyExc_RuntimeError, "QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent",
+ qPrintable(layout->objectName()), self->metaObject()->className(), qPrintable(self->objectName()));
+ return;
+ }
+ }
+
+ if (oldParent != self) {
+ qwidgetReparentLayout(self, layout);
+ if (PyErr_Occurred())
+ return;
+
+ self->setLayout(layout);
+ }
+}
diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets.xml.in b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets.xml.in
new file mode 100644
index 000000000..e6952c2fe
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets.xml.in
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtWidgets">
+ <load-typesystem name="typesystem_gui.xml" generate="no"/>
+ <load-typesystem name="typesystem_widgets_@AUTO_OS@.xml" generate="yes"/>
+ <load-typesystem name="typesystem_widgets_common.xml" generate="yes"/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
new file mode 100644
index 000000000..59412699c
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
@@ -0,0 +1,3695 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtWidgets">
+ <load-typesystem name="typesystem_gui.xml" generate="no"/>
+
+
+
+ <!-- Qt5: Beware forgetting the following rejection!
+ There are anonymous enums "enum { Type = 1 }" etc. in these QGraphics classes, but they
+ don't show up as "enum_1", but pretend they were a real enum field, not a value.
+
+ """
+ Generating class model... [WARNING]
+ enum 'QGraphicsItem::UserType' does not have a type entry or is not an enum
+ enum 'QGraphicsWidget::Type' does not have a type entry or is not an enum
+ enum 'QGraphicsProxyWidget::Type' does not have a type entry or is not an enum
+ enum 'QGraphicsEllipseItem::Type' does not have a type entry or is not an enum
+ enum 'QGraphicsPixmapItem::Type' does not have a type entry or is not an enum
+ enum 'QGraphicsSimpleTextItem::Type' does not have a type entry or is not an enum
+ enum 'QGraphicsTextItem::Type' does not have a type entry or is not an enum
+ enum 'QGraphicsItemGroup::Type' does not have a type entry or is not an enum
+ enum 'QGraphicsRectItem::Type' does not have a type entry or is not an enum
+ enum 'QGraphicsLineItem::Type' does not have a type entry or is not an enum
+ enum 'QGraphicsPathItem::Type' does not have a type entry or is not an enum
+ enum 'QGraphicsPolygonItem::Type' does not have a type entry or is not an enum
+ """
+ -->
+ <rejection class="*" enum-name="enum_1"/>
+
+
+ <!--
+ Event classes have a lot of non-documented protected fields, those fields
+ are removed from PySide because they are Qt implementation details,
+ besides the fact they are accessible by ordinary event methods.
+ -->
+
+ <object-type name="QStyleOption" polymorphic-id-expression="%1-&gt;type == QStyleOption::SO_Default">
+ <enum-type name="OptionType" extensible="yes"/>
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionGraphicsItem" polymorphic-id-expression="%1-&gt;type == QStyleOptionGraphicsItem::Type &amp;&amp; %1-&gt;version == QStyleOptionGraphicsItem::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionSizeGrip" polymorphic-id-expression="%1-&gt;type == QStyleOptionSizeGrip::Type &amp;&amp; %1-&gt;version == QStyleOptionSizeGrip::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionButton" polymorphic-id-expression="%1-&gt;type == QStyleOptionButton::Type &amp;&amp; %1-&gt;version == QStyleOptionButton::Version">
+ <enum-type name="ButtonFeature" flags="ButtonFeatures"/>
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionComboBox" polymorphic-id-expression="%1-&gt;type == QStyleOptionComboBox::Type &amp;&amp; %1-&gt;version == QStyleOptionComboBox::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionComplex" polymorphic-id-expression="%1-&gt;type == QStyleOptionComplex::Type &amp;&amp; %1-&gt;version == QStyleOptionComplex::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionDockWidget" polymorphic-id-expression="%1-&gt;type == QStyleOptionDockWidget::Type &amp;&amp; %1-&gt;version == QStyleOptionDockWidget::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionFocusRect" polymorphic-id-expression="%1-&gt;type == QStyleOptionFocusRect::Type &amp;&amp; %1-&gt;version == QStyleOptionFocusRect::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionFrame" polymorphic-id-expression="%1-&gt;type == QStyleOptionFrame::Type &amp;&amp; %1-&gt;version == QStyleOptionFrame::Version">
+ <enum-type name="FrameFeature" flags="FrameFeatures"/>
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionGroupBox" polymorphic-id-expression="%1-&gt;type == QStyleOptionGroupBox::Type &amp;&amp; %1-&gt;version == QStyleOptionGroupBox::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionHeader" polymorphic-id-expression="%1-&gt;type == QStyleOptionHeader::Type &amp;&amp; %1-&gt;version == QStyleOptionHeader::Version">
+ <enum-type name="SectionPosition"/>
+ <enum-type name="SelectedPosition"/>
+ <enum-type name="SortIndicator"/>
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionMenuItem" polymorphic-id-expression="%1-&gt;type == QStyleOptionMenuItem::Type &amp;&amp; %1-&gt;version == QStyleOptionMenuItem::Version">
+ <enum-type name="CheckType"/>
+ <enum-type name="MenuItemType"/>
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionProgressBar" polymorphic-id-expression="%1-&gt;type == QStyleOptionProgressBar::Type &amp;&amp; %1-&gt;version == QStyleOptionProgressBar::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionRubberBand" polymorphic-id-expression="%1-&gt;type == QStyleOptionRubberBand::Type &amp;&amp; %1-&gt;version == QStyleOptionRubberBand::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionSlider" polymorphic-id-expression="%1-&gt;type == QStyleOptionSlider::Type &amp;&amp; %1-&gt;version == QStyleOptionSlider::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionSpinBox" polymorphic-id-expression="%1-&gt;type == QStyleOptionSpinBox::Type &amp;&amp; %1-&gt;version == QStyleOptionSpinBox::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionTab" polymorphic-id-expression="%1-&gt;type == QStyleOptionTab::Type &amp;&amp; %1-&gt;version == QStyleOptionTab::Version">
+ <enum-type name="CornerWidget" flags="CornerWidgets"/>
+ <enum-type name="SelectedPosition"/>
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ <enum-type name="TabFeature" flags="TabFeatures"/>
+ <enum-type name="TabPosition"/>
+ </object-type>
+ <object-type name="QStyleOptionTabBarBase" polymorphic-id-expression="%1-&gt;type == QStyleOptionTabBarBase::Type &amp;&amp; %1-&gt;version == QStyleOptionTabBarBase::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionTabWidgetFrame" polymorphic-id-expression="%1-&gt;type == QStyleOptionTabWidgetFrame::Type &amp;&amp; %1-&gt;version == QStyleOptionTabWidgetFrame::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionTitleBar" polymorphic-id-expression="%1-&gt;type == QStyleOptionTitleBar::Type &amp;&amp; %1-&gt;version == QStyleOptionTitleBar::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleOptionToolBar" polymorphic-id-expression="%1-&gt;type == QStyleOptionToolBar::Type &amp;&amp; %1-&gt;version == QStyleOptionToolBar::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ <enum-type name="ToolBarFeature" flags="ToolBarFeatures"/>
+ <enum-type name="ToolBarPosition"/>
+ </object-type>
+ <object-type name="QStyleOptionToolBox" polymorphic-id-expression="%1-&gt;type == QStyleOptionToolBox::Type &amp;&amp; %1-&gt;version == QStyleOptionToolBox::Version">
+ <enum-type name="SelectedPosition"/>
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ <enum-type name="TabPosition"/>
+ </object-type>
+ <object-type name="QStyleOptionToolButton" polymorphic-id-expression="%1-&gt;type == QStyleOptionToolButton::Type &amp;&amp; %1-&gt;version == QStyleOptionToolButton::Version">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ <enum-type name="ToolButtonFeature" flags="ToolButtonFeatures" />
+ </object-type>
+ <value-type name="QStyleOptionViewItem" polymorphic-id-expression="%1-&gt;type == QStyleOptionViewItem::Type &amp;&amp; %1-&gt;version == QStyleOptionViewItem::Version">
+ <enum-type name="Position"/>
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ <enum-type name="ViewItemFeature" flags="ViewItemFeatures"/>
+ <enum-type name="ViewItemPosition"/>
+ </value-type>
+
+ <value-type name="QSizePolicy">
+ <enum-type name="ControlType" flags="ControlTypes"/>
+ <enum-type name="Policy"/>
+ <enum-type name="PolicyFlag"/>
+ </value-type>
+ <value-type name="QTableWidgetSelectionRange"/>
+
+ <value-type name="QTreeWidgetItemIterator" >
+ <modify-function signature="QTreeWidgetItemIterator(QTreeWidget *, QFlags&lt;QTreeWidgetItemIterator::IteratorFlag&gt;)">
+ <modify-argument index="this">
+ <parent index="1" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <add-function signature="__iter__()" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="__iter__" />
+ </inject-code>
+ </add-function>
+ <add-function signature="__next__()" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ if (**%CPPSELF) {
+ QTreeWidgetItemIterator* %0 = new QTreeWidgetItemIterator((*%CPPSELF)++);
+ %PYARG_0 = %CONVERTTOPYTHON[QTreeWidgetItemIterator*](%0);
+ }
+ </inject-code>
+ </add-function>
+
+ <add-function signature="value()" return-type="QTreeWidgetItem*">
+ <inject-code>
+ QTreeWidgetItem* %0 = %CPPSELF.operator*();
+ %PYARG_0 = %CONVERTTOPYTHON[QTreeWidgetItem*](%0);
+ Shiboken::Object::releaseOwnership(%PYARG_0);
+ </inject-code>
+ </add-function>
+ <enum-type name="IteratorFlag" flags="IteratorFlags"/>
+ <!-- ### See bug 778 -->
+ <modify-function signature="operator++(int)" remove="all"/>
+ <modify-function signature="operator--(int)" remove="all"/>
+ <modify-function signature="operator++()" remove="all"/>
+ <modify-function signature="operator--()" remove="all"/>
+ <!-- ### Operator* doesn't make sense in Python. -->
+ <modify-function signature="operator*()const" remove="all"/>
+ <!-- ### -->
+ </value-type>
+
+ <object-type name="QLayoutItem">
+
+ <modify-function signature="widget()">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="layout()">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="spacerItem()">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QGraphicsItem">
+ <enum-type name="CacheMode"/>
+ <enum-type name="Extension"/>
+ <enum-type name="GraphicsItemChange"/>
+ <enum-type name="GraphicsItemFlag" flags="GraphicsItemFlags"/>
+ <enum-type name="PanelModality" since="4.6"/>
+ <inject-code class="target" position="end">
+ PyObject* userTypeConstant = PyInt_FromLong(QGraphicsItem::UserType);
+ PyDict_SetItemString(Sbk_QGraphicsItem_Type.super.ht_type.tp_dict, "UserType", userTypeConstant);
+ </inject-code>
+ <modify-function signature="setParentItem(QGraphicsItem *)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <template name="scene_return_parenting">
+ if (%0) {
+ QObject* parent = %0->parent();
+ Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QObject*](parent));
+ Shiboken::Object::setParent(pyParent, %PYARG_0);
+ }
+ </template>
+ <modify-function signature="scene() const">
+ <inject-code position="end">
+ <insert-template name="scene_return_parenting"/>
+ </inject-code>
+ <modify-argument index="this">
+ <parent index="return" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="parentItem() const">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ <modify-argument index="this">
+ <parent index="return" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="parentWidget() const">
+ <modify-argument index="this">
+ <parent index="return" action="add"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="paint(QPainter*,const QStyleOptionGraphicsItem*,QWidget*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="collidesWithItem(const QGraphicsItem*,Qt::ItemSelectionMode)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="contextMenuEvent(QGraphicsSceneContextMenuEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="dragEnterEvent(QGraphicsSceneDragDropEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="dragLeaveEvent(QGraphicsSceneDragDropEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="dragMoveEvent(QGraphicsSceneDragDropEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="dropEvent(QGraphicsSceneDragDropEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="focusInEvent(QFocusEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="focusOutEvent(QFocusEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="hoverEnterEvent(QGraphicsSceneHoverEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="hoverLeaveEvent(QGraphicsSceneHoverEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="hoverMoveEvent(QGraphicsSceneHoverEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="inputMethodEvent(QInputMethodEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="isBlockedByModalPanel(QGraphicsItem**)const" since="4.6">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(retval, blockingPanel)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ QGraphicsItem *item_ = NULL;
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;item_);
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QGraphicsItem*](item_));
+ </inject-code>
+ </modify-function>
+ <modify-function signature="itemTransform(const QGraphicsItem*,bool*)const">
+ <modify-argument index="2">
+ <remove-argument />
+ <remove-default-expression />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(QTransform, bool ok)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_args,bool*" />
+ </inject-code>
+ </modify-function>
+ <modify-function signature="isObscuredBy(const QGraphicsItem*)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="keyPressEvent(QKeyEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="keyReleaseEvent(QKeyEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="mouseDoubleClickEvent(QGraphicsSceneMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="mouseMoveEvent(QGraphicsSceneMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="mousePressEvent(QGraphicsSceneMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="mouseReleaseEvent(QGraphicsSceneMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="sceneEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="sceneEventFilter(QGraphicsItem*,QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ <modify-argument index="2" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="wheelEvent(QGraphicsSceneWheelEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <!-- ### These methods are internal on Qt. -->
+ <modify-function signature="supportsExtension(QGraphicsItem::Extension)const" remove="all"/>
+ <modify-function signature="setExtension(QGraphicsItem::Extension,QVariant)" remove="all"/>
+ <!-- ### -->
+ </object-type>
+ <object-type name="QAbstractGraphicsShapeItem"/>
+ <object-type name="QAbstractItemView">
+ <enum-type name="CursorAction"/>
+ <enum-type name="DragDropMode"/>
+ <enum-type name="DropIndicatorPosition"/>
+ <enum-type name="EditTrigger" flags="EditTriggers"/>
+ <enum-type name="ScrollHint"/>
+ <enum-type name="ScrollMode"/>
+ <enum-type name="SelectionBehavior"/>
+ <enum-type name="SelectionMode"/>
+ <enum-type name="State"/>
+ <modify-function signature="setModel(QAbstractItemModel*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setSelectionModel(QItemSelectionModel*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setItemDelegate(QAbstractItemDelegate*)">
+ <modify-argument index="1">
+ <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
+ set as parent of the returned pointer. -->
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="selectionModel() 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="setIndexWidget(const QModelIndex &amp;, QWidget *)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="edit(QModelIndex,QAbstractItemView::EditTrigger,QEvent*)">
+ <modify-argument index="3" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="selectionCommand(QModelIndex,const QEvent*)const">
+ <modify-argument index="2" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+ <object-type name="QAbstractSlider">
+ <enum-type name="SliderAction"/>
+ <enum-type name="SliderChange"/>
+ </object-type>
+ <object-type name="QActionGroup">
+ <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>
+ <object-type name="QDataWidgetMapper">
+ <enum-type name="SubmitPolicy"/>
+ <modify-function signature="addMapping(QWidget*,int)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addMapping(QWidget*,int,QByteArray)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="removeMapping(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setItemDelegate(QAbstractItemDelegate*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setModel(QAbstractItemModel*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QDateEdit"/>
+ <object-type name="QDialog">
+ <enum-type name="DialogCode"/>
+ <modify-function signature="exec()" rename="exec_" allow-thread="yes"/>
+ </object-type>
+ <object-type name="QDialogButtonBox">
+ <enum-type name="ButtonLayout"/>
+ <enum-type name="ButtonRole"/>
+ <enum-type name="StandardButton" flags="StandardButtons" />
+ <modify-function signature="addButton(QAbstractButton*,QDialogButtonBox::ButtonRole)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="removeButton(QAbstractButton*)">
+ <modify-argument index="1">
+ <parent index="this" action="remove"/>
+ </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="QWizard">
+ <enum-type name="WizardButton" />
+ <enum-type name="WizardOption" flags="WizardOptions"/>
+ <enum-type name="WizardPixmap"/>
+ <enum-type name="WizardStyle"/>
+ <modify-function signature="addPage(QWizardPage*)">
+ <modify-argument index="1">
+ <no-null-pointer/>
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setButton(QWizard::WizardButton,QAbstractButton*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QWizardPage">
+ <modify-function signature="wizard()const">
+ <modify-argument index="this">
+ <parent index="return" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QFocusFrame">
+ <modify-function signature="setWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QFontComboBox">
+ <enum-type name="FontFilter" flags="FontFilters"/>
+ </object-type>
+ <object-type name="QFontDialog">
+ <enum-type name="FontDialogOption" flags="FontDialogOptions"/>
+ <modify-function signature="getFont(bool*,QWidget*)" allow-thread="yes">
+ <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*,arg"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getFont(bool*,QFont,QWidget*,QString,QFlags&lt;QFontDialog::FontDialogOption&gt;)">
+ <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*,arg,arg,arg,arg"/>
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QGraphicsEllipseItem">
+ </object-type>
+ <object-type name="QGraphicsItemAnimation">
+ <modify-function signature="setItem(QGraphicsItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setTimeLine(QTimeLine*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <extra-includes>
+ <include file-name="QPair" location="global"/>
+ </extra-includes>
+ </object-type>
+ <object-type name="QGraphicsItemGroup"/>
+ <object-type name="QGraphicsLineItem" />
+ <object-type name="QGraphicsPathItem" />
+ <object-type name="QGraphicsPixmapItem">
+ <enum-type name="ShapeMode"/>
+ </object-type>
+ <object-type name="QGraphicsPolygonItem"/>
+ <object-type name="QGraphicsRectItem" />
+ <object-type name="QGraphicsSimpleTextItem" />
+ <object-type name="QHBoxLayout"/>
+ <object-type name="QHeaderView">
+ <enum-type name="ResizeMode" />
+ <modify-function signature="paintSection(QPainter*,QRect,int)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+ <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"/>
+ </modify-function>
+ <modify-function signature="drawDecoration(QPainter*,QStyleOptionViewItem,QRect,QPixmap)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="drawDisplay(QPainter*,QStyleOptionViewItem,QRect,QString)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="drawFocus(QPainter*,QStyleOptionViewItem,QRect)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="setItemEditorFactory(QItemEditorFactory*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QItemEditorCreatorBase">
+ <modify-function signature="createWidget(QWidget *) const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+ <object-type name="QItemEditorFactory">
+ <modify-function signature="registerEditor(int, QItemEditorCreatorBase *)">
+ <modify-argument index="2">
+ <reference-count action="set"/>
+ </modify-argument>
+ <inject-code>
+ Shiboken::Object::releaseOwnership(%PYARG_2);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setDefaultFactory(QItemEditorFactory *)">
+ <modify-argument index="1">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ <inject-code>
+ //this function is static we need keep ref to default value, to be able to call python virtual functions
+ static PyObject* _defaultValue = 0;
+ %CPPSELF.%FUNCTION_NAME(%1);
+ Py_INCREF(%PYARG_1);
+ if (_defaultValue)
+ Py_DECREF(_defaultValue);
+
+ _defaultValue = %PYARG_1;
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QListView">
+ <enum-type name="Flow"/>
+ <enum-type name="LayoutMode"/>
+ <enum-type name="Movement"/>
+ <enum-type name="ResizeMode"/>
+ <enum-type name="ViewMode"/>
+ </object-type>
+ <object-type name="QColumnView">
+ <modify-function signature="setPreviewWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QMainWindow">
+ <enum-type name="DockOption" flags="DockOptions"/>
+ <modify-function signature="setCentralWidget(QWidget*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="replace_child">
+ <replace from="$FUNCTION_GET_OLD" to="centralWidget" />
+ <replace from="$CHILD_TYPE" to="QWidget" />
+ <replace from="$PYARG" to="%PYARG_1" />
+ <replace from="$CPPARG" to="%1" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="setMenuBar(QMenuBar*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="replace_child">
+ <replace from="$FUNCTION_GET_OLD" to="menuBar" />
+ <replace from="$CHILD_TYPE" to="QMenuBar" />
+ <replace from="$PYARG" to="%PYARG_1" />
+ <replace from="$CPPARG" to="%1" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="setMenuWidget(QWidget*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="replace_child">
+ <replace from="$FUNCTION_GET_OLD" to="menuWidget" />
+ <replace from="$CHILD_TYPE" to="QWidget" />
+ <replace from="$PYARG" to="%PYARG_1" />
+ <replace from="$CPPARG" to="%1" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="setStatusBar(QStatusBar*)">
+ <inject-code class="target" position="beginning">
+ <insert-template name="replace_child">
+ <replace from="$FUNCTION_GET_OLD" to="statusBar" />
+ <replace from="$CHILD_TYPE" to="QStatusBar" />
+ <replace from="$PYARG" to="%PYARG_1" />
+ <replace from="$CPPARG" to="%1" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="addDockWidget(Qt::DockWidgetArea, QDockWidget*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addDockWidget(Qt::DockWidgetArea,QDockWidget*,Qt::Orientation)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <!-- this fuction is declared when not defined QT_NO_TOOLBA -->
+ <modify-function signature="addToolBar(Qt::ToolBarArea, QToolBar*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addToolBar(QToolBar*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addToolBar(const QString&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <!--- END QT_NO_TOOLBAR -->
+ <modify-function signature="removeDockWidget(QDockWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="removeToolBar(QToolBar*)">
+ <modify-argument index="1">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="removeDockWidget(QDockWidget*)">
+ <modify-argument index="2">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+
+ </object-type>
+ <object-type name="QMdiArea">
+ <enum-type name="AreaOption" flags="AreaOptions"/>
+ <enum-type name="ViewMode"/>
+ <enum-type name="WindowOrder"/>
+ <modify-function signature="addSubWindow(QWidget*, QFlags&lt;Qt::WindowType&gt;)" >
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QMdiSubWindow">
+ <enum-type name="SubWindowOption" flags="SubWindowOptions"/>
+ <modify-function signature="setWidget(QWidget*)" >
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setSystemMenu(QMenu*)" >
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QMenu">
+ <inject-code class="native" position="beginning" file="glue/qmenu_glue.cpp"/>
+
+ <modify-function signature="exec()" rename="exec_" allow-thread="yes" />
+ <modify-function signature="exec(const QPoint&amp;, QAction*)" rename="exec_" allow-thread="yes" />
+ <modify-function signature="exec(QList&lt;QAction*>, const QPoint&amp;, QAction*, QWidget*)" rename="exec_" allow-thread="yes" />
+ <modify-function signature="addAction(const QString&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addMenu(QMenu*)">
+ <modify-argument index="return">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addMenu(const QString&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addMenu(const QIcon &amp;, const QString &amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertMenu(QAction*,QMenu*)">
+ <modify-argument index="return">
+ <parent index="2" action="add"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addMenu(const QString&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addMenu(const QIcon &amp;, const QString &amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <!-- ### "setNoReplayFor(QWidget*)" is an internal method. -->
+ <modify-function signature="setNoReplayFor(QWidget*)" remove="all" />
+
+ <add-function signature="addAction(QString&amp;, PyObject*, QKeySequence&amp;)">
+ <modify-argument index="3">
+ <replace-default-expression with="0" />
+ </modify-argument>
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = addActionWithPyObject(%CPPSELF, QIcon(), %1, %2, %3);
+ </inject-code>
+ </add-function>
+
+ <add-function signature="addAction(QIcon&amp;, QString&amp;, PyObject*, QKeySequence&amp;)">
+ <modify-argument index="4">
+ <replace-default-expression with="0" />
+ </modify-argument>
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = addActionWithPyObject(%CPPSELF, %1, %2, %3, %4);
+ </inject-code>
+ </add-function>
+
+ <add-function signature="addAction(QAction*)">
+ <inject-code class="target" position="beginning">
+ %CPPSELF.addAction(%1);
+ </inject-code>
+ </add-function>
+
+ <modify-function signature="clear()">
+ <inject-code>
+ Shiboken::BindingManager&amp; bm = Shiboken::BindingManager::instance();
+ PyObject* pyObj;
+ foreach(QAction* act, %CPPSELF.actions()) {
+ if ((pyObj = (PyObject*)bm.retrieveWrapper(act)) != 0) {
+ Py_INCREF(pyObj);
+ Shiboken::Object::setParent(NULL, pyObj);
+ Shiboken::Object::invalidate(pyObj);
+ Py_DECREF(pyObj);
+ }
+ }
+ </inject-code>
+ </modify-function>
+
+ </object-type>
+
+ <object-type name="QMenuBar">
+ <inject-code class="native" position="beginning" file="glue/qmenubar_glue.cpp"/>
+ <modify-function signature="addAction(const QString&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addAction(QString,const QObject*,const char*)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <add-function signature="addAction(const QString&amp;, PyObject*)">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = addActionWithPyObject(%CPPSELF, %1, %2);
+ </inject-code>
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </add-function>
+ <modify-function signature="addMenu(QMenu*)">
+ <modify-argument index="return">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addSeparator()">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertMenu(QAction*,QMenu*)">
+ <modify-argument index="return">
+ <parent index="2" action="add"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertSeparator(QAction*)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="clear()">
+ <inject-code>
+ foreach(QAction *act, %CPPSELF.actions()) {
+ Shiboken::AutoDecRef pyAct(%CONVERTTOPYTHON[QAction*](act));
+ Shiboken::Object::setParent(NULL, pyAct);
+ Shiboken::Object::invalidate(pyAct);
+ }
+ </inject-code>
+ </modify-function>
+
+ <add-function signature="addAction(QAction*)">
+ <inject-code class="target" position="beginning">
+ %CPPSELF.addAction(%1);
+ </inject-code>
+ </add-function>
+
+ </object-type>
+ <object-type name="QProgressBar">
+ <enum-type name="Direction"/>
+ </object-type>
+ <object-type name="QPushButton" />
+ <object-type name="QScrollArea">
+ <modify-function signature="setWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </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">
+ %0 = new %TYPE(%1, %2);
+ </inject-code>
+ <inject-code class="target" position="end">
+ Shiboken::AutoDecRef result(PyObject_CallMethod(%PYSELF, "connect", "OsO", %PYSELF, SIGNAL(activated()), %PYARG_3));
+ if (!result.isNull())
+ Shiboken::Object::setParent(%PYARG_2, %PYSELF);
+ </inject-code>
+ </add-function>
+ </object-type>
+ <object-type name="QSpacerItem"/>
+ <object-type name="QStatusBar">
+ <modify-function signature="addWidget(QWidget*, int)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addPermanentWidget(QWidget*, int)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertWidget(int, QWidget*, int)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertPermanentWidget(int, QWidget*, int)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QStyleFactory">
+ <modify-function signature="create(const QString&amp;)">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QStyleHintReturn">
+ <enum-type name="HintReturnType"/>
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleHintReturnVariant">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStyleHintReturnMask">
+ <enum-type name="StyleOptionType"/>
+ <enum-type name="StyleOptionVersion"/>
+ </object-type>
+ <object-type name="QStylePainter" />
+ <object-type name="QTableView">
+ <modify-function signature="setHorizontalHeader(QHeaderView*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setVerticalHeader(QHeaderView*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QTimeEdit"/>
+ <object-type name="QToolBox">
+ <modify-function signature="addItem(QWidget*, const QIcon&amp;, const QString&amp;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addItem(QWidget*, const QString&amp;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertItem(int, QWidget*, const QIcon&amp;, const QString&amp;)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertItem(int, QWidget*, const QString&amp;)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="removeItem(int)">
+ <inject-code class="target" position="beginning">
+ QWidget *_widget = %CPPSELF.widget(%1);
+ if (_widget) {
+ Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](_widget));
+ Shiboken::Object::setParent(0, pyWidget);
+ }
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QToolButton">
+ <enum-type name="ToolButtonPopupMode"/>
+ <modify-function signature="setDefaultAction(QAction *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setMenu(QMenu *)">
+ </modify-function>
+ </object-type>
+ <object-type name="QToolTip"/>
+ <object-type name="QTreeView">
+ <modify-function signature="drawBranches(QPainter*,QRect,QModelIndex)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="drawRow(QPainter*,QStyleOptionViewItem,QModelIndex)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </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">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setStack(QUndoStack *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="QUndoView(QUndoGroup *,QWidget *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="QUndoView(QUndoStack *,QWidget *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QVBoxLayout"/>
+
+ <object-type name="QWhatsThis"/>
+ <object-type name="QWidgetAction">
+ <modify-function signature="setDefaultWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="releaseWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="remove" />
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QWidgetItem" polymorphic-id-expression="%1-&gt;widget()" />
+
+ <object-type name="QGraphicsSceneContextMenuEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::GraphicsSceneContextMenu">
+ <enum-type name="Reason"/>
+ </object-type>
+ <object-type name="QGraphicsSceneDragDropEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::GraphicsSceneDragEnter || %1-&gt;type() == QEvent::GraphicsSceneDragLeave || %1-&gt;type() == QEvent::GraphicsSceneDragMove || %1-&gt;type() == QEvent::GraphicsSceneDrop" >
+ <!-- ### "setMimeData(const QMimeData*)" is an internal method. -->
+ <modify-function signature="setMimeData(const QMimeData *)" remove="all"/>
+ <!-- ### "setSource(QWidget*)" is an internal method. -->
+ <modify-function signature="setSource(QWidget *)" remove="all"/>
+ <!-- ### -->
+ </object-type>
+ <object-type name="QGraphicsSceneEvent" copyable="false">
+ <!-- ### "setWidget(QWidget*)" is an internal method. -->
+ <modify-function signature="setWidget(QWidget *)" remove="all"/>
+ </object-type>
+ <object-type name="QGraphicsSceneMoveEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::GraphicsSceneMove" />
+ <object-type name="QGraphicsSceneResizeEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::GraphicsSceneResize" />
+ <object-type name="QGraphicsSceneHelpEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::GraphicsSceneHelp" />
+ <object-type name="QGraphicsSceneHoverEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::GraphicsSceneHoverEnter || %1-&gt;type() == QEvent::GraphicsSceneHoverLeave || %1-&gt;type() == QEvent::GraphicsSceneHoverMove" />
+ <object-type name="QGraphicsSceneMouseEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::GraphicsSceneMouseDoubleClick || %1-&gt;type() == QEvent::GraphicsSceneMouseMove || %1-&gt;type() == QEvent::GraphicsSceneMousePress || %1-&gt;type() == QEvent::GraphicsSceneMouseRelease"/>
+ <object-type name="QGraphicsSceneWheelEvent" copyable="false" polymorphic-id-expression="%1-&gt;type() == QEvent::GraphicsSceneWheel"/>
+
+ <object-type name="QGestureEvent" polymorphic-id-expression="%1-&gt;type() == QEvent::Gesture || %1-&gt;type() == QEvent::GestureOverride" since="4.6">
+ <modify-function signature="activeGestures()const">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="canceledGestures()const">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="gestures()const">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="gesture(Qt::GestureType)const">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="widget()const">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QAbstractButton"/>
+ <object-type name="QStyle">
+ <enum-type name="ComplexControl" extensible="yes"/>
+ <enum-type name="ContentsType" extensible="yes"/>
+ <enum-type name="ControlElement" extensible="yes"/>
+ <enum-type name="PixelMetric" extensible="yes" />
+ <enum-type name="PrimitiveElement" extensible="yes" />
+ <enum-type name="RequestSoftwareInputPanel" since="4.6"/>
+ <enum-type name="StandardPixmap" extensible="yes"/>
+ <enum-type name="StateFlag" flags="State"/>
+ <enum-type name="StyleHint" extensible="yes" />
+ <enum-type name="SubControl" flags="SubControls" extensible="yes" force-integer="yes"/>
+ <enum-type name="SubElement" extensible="yes" />
+ <modify-function signature="drawComplexControl(QStyle::ComplexControl,const QStyleOptionComplex*,QPainter*,const QWidget*)const">
+ <modify-argument index="3" invalidate-after-use="yes"/>
+ <modify-argument index="4">
+ <replace-default-expression with="0"/>
+ <rename to="widget" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="drawControl(QStyle::ControlElement,const QStyleOption*,QPainter*,const QWidget*)const">
+ <modify-argument index="3" invalidate-after-use="yes"/>
+ <modify-argument index="4">
+ <replace-default-expression with="0"/>
+ <rename to="widget" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="drawPrimitive(QStyle::PrimitiveElement,const QStyleOption*,QPainter*,const QWidget*)const">
+ <modify-argument index="3" invalidate-after-use="yes"/>
+ <modify-argument index="4">
+ <replace-default-expression with="0"/>
+ <rename to="widget" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="hitTestComplexControl(QStyle::ComplexControl, const QStyleOptionComplex*, const QPoint&amp;, const QWidget*)const">
+ <modify-argument index="4">
+ <replace-default-expression with="0"/>
+ <rename to="widget" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="styleHint(QStyle::StyleHint,const QStyleOption*,const QWidget*,QStyleHintReturn*)const">
+ <modify-argument index="4" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="drawItemPixmap(QPainter*,QRect,int,QPixmap)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="drawItemText(QPainter*,QRect,int,QPalette,bool,QString,QPalette::ColorRole)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+ <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/qlayout_help_functions.cpp"/>
+
+ <enum-type name="SizeConstraint"/>
+
+ <modify-function signature="itemAt(int)const">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ addLayoutOwnership(%CPPSELF, %0);
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="removeWidget(QWidget*)">
+ <inject-code class="target" position="beginning">
+ removeLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="removeItem(QLayoutItem*)">
+ <inject-code class="target" position="beginning">
+ removeLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="parentWidget()const">
+ <modify-argument index="this">
+ <parent index="return" action="add"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="takeAt(int)">
+ <modify-argument index="return">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="addItem(QLayoutItem*)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="addWidget(QWidget *)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="addChildWidget(QWidget *)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="addChildLayout(QLayout*)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setMenuBar(QWidget*)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </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>
+
+ <add-function signature="setAlignment(QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <inject-code class="target" position="beginning">
+ %CPPSELF.setAlignment(%1);
+ </inject-code>
+ </add-function>
+
+ </object-type>
+
+ <object-type name="QStackedLayout">
+ <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/>
+ <enum-type name="StackingMode"/>
+ <modify-function signature="insertWidget(int,QWidget*)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %2);
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QBoxLayout">
+ <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/>
+
+ <enum-type name="Direction" />
+
+ <modify-function signature="addWidget(QWidget *, int, QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="addLayout(QLayout *, int)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="insertWidget(int, QWidget *, int, QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %2);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="insertLayout(int, QLayout *, int)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %2);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="insertItem(int, QLayoutItem *)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %2);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="addSpacerItem(QSpacerItem*)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="insertSpacerItem(int,QSpacerItem*)">
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %2);
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QGridLayout">
+ <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/>
+ <modify-function signature="itemAtPosition (int, int) const">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ addLayoutOwnership(%CPPSELF, %0);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="addWidget(QWidget *, int, int, QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <modify-argument index="4">
+ <rename to="alignment"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="addWidget(QWidget *, int, int, int, int, QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <modify-argument index="6">
+ <rename to="alignment"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="addLayout(QLayout *, int, int, QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <modify-argument index="4">
+ <rename to="alignment"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="addLayout(QLayout *, int, int, int, int, QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <modify-argument index="6">
+ <rename to="alignment"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="addItem(QLayoutItem *, int, int, int, int, QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <modify-argument index="4">
+ <rename to="rowSpan"/>
+ </modify-argument>
+ <modify-argument index="5">
+ <rename to="columnSpan"/>
+ </modify-argument>
+ <modify-argument index="6">
+ <rename to="alignment"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ addLayoutOwnership(%CPPSELF, %1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getItemPosition(int,int*,int*,int*,int*)const">
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*" />
+ </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>
+ <modify-argument index="5">
+ <remove-argument/>
+ <remove-default-expression/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int a, b, c, d;
+ %CPPSELF.%FUNCTION_NAME(%1, &amp;a, &amp;b, &amp;c, &amp;d);
+ %PYARG_0 = PyTuple_New(4);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](a));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](b));
+ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[int](c));
+ PyTuple_SET_ITEM(%PYARG_0, 3, %CONVERTTOPYTHON[int](d));
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QGraphicsView">
+ <extra-includes>
+ <include file-name="QPainterPath" location="global"/>
+ <include file-name="QVarLengthArray" location="global"/>
+ </extra-includes>
+ <enum-type name="CacheModeFlag" flags="CacheMode"/>
+ <enum-type name="DragMode"/>
+ <enum-type name="OptimizationFlag" flags="OptimizationFlags"/>
+ <enum-type name="ViewportAnchor"/>
+ <enum-type name="ViewportUpdateMode"/>
+ <modify-function signature="setupViewport(QWidget *)" access="non-final"/>
+ <modify-function signature="setScene(QGraphicsScene*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="scene()const">
+ <inject-code position="end">
+ <insert-template name="scene_return_parenting"/>
+ </inject-code>
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="itemAt(int,int)const">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="itemAt(QPoint)const">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="drawBackground(QPainter*,QRectF)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="drawForeground(QPainter*,QRectF)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+
+ <!-- TODO: Support conversions on virtual function -->
+ <modify-function signature="drawItems(QPainter*, int, QGraphicsItem**, const QStyleOptionGraphicsItem*)">
+ <modify-argument index="2">
+ <remove-argument/>
+ <conversion-rule class="native">
+ int %out = PySequence_Size(%PYARG_1);
+ </conversion-rule>
+ </modify-argument>
+
+ <modify-argument index="3">
+ <replace-type modified-type="PySequence"/>
+ <conversion-rule class="native">
+ int numItems = PySequence_Size(%PYARG_1);
+ Shiboken::AutoArrayPointer&lt;QGraphicsItem*&gt; %out(numItems);
+ for (int i=0; i &lt; numItems; i++) {
+ %out[i] = %CONVERTTOCPP[QGraphicsItem*](PySequence_Fast_GET_ITEM(%PYARG_1, i));
+ }
+ </conversion-rule>
+
+ <conversion-rule class="target">
+ Shiboken::AutoDecRef object(PyList_New(0));
+ for (int i=0, max=numItems; i &lt; max; i++) {
+ PyList_Append(object, %CONVERTTOPYTHON[QGraphicsItem*](%in[i]));
+ }
+ PyObject *%out = object.object();
+ </conversion-rule>
+ </modify-argument>
+
+ <modify-argument index="4">
+ <replace-type modified-type="PySequence"/>
+ <conversion-rule class="target">
+ Shiboken::AutoDecRef option_object(PyList_New(0));
+ for (int i=0, max=numItems; i &lt; max; i++) {
+ const QStyleOptionGraphicsItem* item = &amp;%in[i];
+ PyList_Append(option_object, %CONVERTTOPYTHON[QStyleOptionGraphicsItem](item));
+ }
+ PyObject* %out = option_object.object();
+ </conversion-rule>
+
+ <conversion-rule class="native">
+ int numOptions = PySequence_Size(%PYARG_2);
+ Shiboken::AutoArrayPointer&lt;QStyleOptionGraphicsItem&gt; %out(numOptions);
+ for (int i=0; i &lt; numOptions; i++) {
+ %out[i] = %CONVERTTOCPP[QStyleOptionGraphicsItem](PySequence_Fast_GET_ITEM(%PYARG_1, i));
+ }
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QInputDialog">
+ <enum-type name="InputDialogOption"/>
+ <enum-type name="InputMode"/>
+
+ <modify-function signature="getInt(QWidget*, const QString&amp;, const QString&amp;, int, int, int, 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="getItem(QWidget*, const QString&amp;, const QString&amp;, const QStringList&amp;, int, bool, bool*, QFlags&lt;Qt::WindowType&gt;,QFlags&lt;Qt::InputMethodHint&gt;)" allow-thread="yes">
+ <modify-argument index="7">
+ <remove-default-expression/>
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_arg,arg,arg,arg,arg,arg,bool*,arg"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="getMultiLineText(QWidget*, const QString&amp;, const QString&amp;, const QString&amp;, bool*, QFlags&lt;Qt::WindowType&gt;, QFlags&lt;Qt::InputMethodHint&gt;)" allow-thread="yes">
+ <modify-argument index="5">
+ <remove-default-expression/>
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_arg,arg,arg,arg,bool*,arg,arg"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="getText(QWidget*, const QString&amp;, const QString&amp;, QLineEdit::EchoMode, const QString&amp;, bool*, QFlags&lt;Qt::WindowType&gt;,QFlags&lt;Qt::InputMethodHint&gt;)" allow-thread="yes">
+ <modify-argument index="6">
+ <remove-default-expression/>
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_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;)" 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>
+ </object-type>
+
+ <object-type name="QGraphicsScene">
+ <extra-includes>
+ <include file-name="QVarLengthArray" location="global"/>
+ </extra-includes>
+ <enum-type name="ItemIndexMethod"/>
+ <enum-type name="SceneLayer" flags="SceneLayers"/>
+
+ <!-- Qt5: note: this was called 'obsolete'. Is that true? -->
+ <modify-function signature="drawItems(QPainter*,int,QGraphicsItem**,const QStyleOptionGraphicsItem*,QWidget*)" remove="all" />
+
+ <modify-function signature="createItemGroup(const QList&lt;QGraphicsItem*&gt;&amp;)">
+ <modify-argument index="1">
+ <parent index="return" action="add" />
+ </modify-argument>
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="destroyItemGroup(QGraphicsItemGroup*)">
+ <inject-code>
+ QGraphicsItem* parentItem = %1->parentItem();
+ Shiboken::AutoDecRef parent(%CONVERTTOPYTHON[QGraphicsItem*](parentItem));
+ foreach (QGraphicsItem* item, %1->childItems())
+ Shiboken::Object::setParent(parent, %CONVERTTOPYTHON[QGraphicsItem*](item));
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF.%FUNCTION_NAME(%1);
+ %END_ALLOW_THREADS
+ // the arg was destroyed by Qt.
+ Shiboken::Object::invalidate(%PYARG_1);
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="contextMenuEvent(QGraphicsSceneContextMenuEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="dragEnterEvent(QGraphicsSceneDragDropEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="dragLeaveEvent(QGraphicsSceneDragDropEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="dragMoveEvent(QGraphicsSceneDragDropEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="drawBackground(QPainter*,QRectF)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="drawForeground(QPainter*,QRectF)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="dropEvent(QGraphicsSceneDragDropEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="focusInEvent(QFocusEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="focusOutEvent(QFocusEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="helpEvent(QGraphicsSceneHelpEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="inputMethodEvent(QInputMethodEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="keyPressEvent(QKeyEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="keyReleaseEvent(QKeyEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="mouseDoubleClickEvent(QGraphicsSceneMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="mouseMoveEvent(QGraphicsSceneMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="mousePressEvent(QGraphicsSceneMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="mouseReleaseEvent(QGraphicsSceneMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="wheelEvent(QGraphicsSceneWheelEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="addItem(QGraphicsItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="addEllipse(const QRectF&amp;, const QPen&amp;, const QBrush&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addEllipse(qreal, qreal, qreal, qreal, const QPen&amp;, const QBrush&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="addLine(const QLineF&amp;, const QPen&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addLine(qreal, qreal, qreal, qreal, const QPen&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="addPath(const QPainterPath&amp;, const QPen&amp;, const QBrush&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addPixmap(const QPixmap&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addPolygon(const QPolygonF&amp;, const QPen&amp;, const QBrush&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addRect(const QRectF&amp;, const QPen&amp;, const QBrush&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addRect(qreal, qreal, qreal, qreal, const QPen&amp;, const QBrush&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="addText(const QString&amp;, const QFont&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addSimpleText(const QString&amp;, const QFont&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="addWidget(QWidget*,QFlags&lt;Qt::WindowType&gt;)">
+ <!-- TODO: Add a keeper attribute to reference-count tag to do what this inject code do. -->
+ <inject-code>
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1, %2);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ Shiboken::Object::keepReference((SbkObject*)%PYARG_0, "setWidget(QWidget*)1", %PYARG_1);
+ </inject-code>
+ </modify-function>
+
+ <!-- use glue code -->
+ <modify-function signature="drawItems(QPainter*, int, QGraphicsItem**, const QStyleOptionGraphicsItem*, QWidget *)">
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="clear()">
+ <inject-code>
+ const QList&lt;QGraphicsItem*> items = %CPPSELF.items();
+ Shiboken::BindingManager&amp; bm = Shiboken::BindingManager::instance();
+ foreach (QGraphicsItem* item, items) {
+ SbkObject* obj = bm.retrieveWrapper(item);
+ if (obj) {
+ if (reinterpret_cast&lt;PyObject*&gt;(obj)->ob_refcnt > 1) // If the refcnt is 1 the object will vannish anyway.
+ Shiboken::Object::invalidate(obj);
+ Shiboken::Object::removeParent(obj);
+ }
+ }
+ %CPPSELF.%FUNCTION_NAME();
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="removeItem(QGraphicsItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="remove" />
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="setFocusItem(QGraphicsItem*,Qt::FocusReason)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QCalendarWidget">
+ <enum-type name="HorizontalHeaderFormat"/>
+ <enum-type name="SelectionMode"/>
+ <enum-type name="VerticalHeaderFormat"/>
+ <extra-includes>
+ <include file-name="QTextCharFormat" location="global"/>
+ </extra-includes>
+ <modify-function signature="paintCell(QPainter*,QRect,QDate)const">
+ <modify-argument invalidate-after-use="yes" index="1"/>
+ </modify-function>
+ </object-type>
+ <object-type name="QTreeWidget">
+ <modify-function signature="dropMimeData(QTreeWidgetItem*,int,const QMimeData*,Qt::DropAction)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="addTopLevelItem(QTreeWidgetItem *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addTopLevelItems(const QList&lt;QTreeWidgetItem*&gt; &amp;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addTopLevelItem(QTreeWidgetItem*)">
+ <modify-argument index="1">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertTopLevelItem(int, QTreeWidgetItem *)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertTopLevelItems(int, const QList&lt;QTreeWidgetItem*&gt; &amp;)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setHeaderItem(QTreeWidgetItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="takeTopLevelItem(int)">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="clear()">
+ <inject-code>
+ QTreeWidgetItem *rootItem = %CPPSELF.invisibleRootItem();
+ Shiboken::BindingManager &amp;bm = Shiboken::BindingManager::instance();
+ for (int i = 0; i &lt; rootItem->childCount(); ++i) {
+ QTreeWidgetItem *item = rootItem->child(i);
+ SbkObject* wrapper = bm.retrieveWrapper(item);
+ if (wrapper)
+ Shiboken::Object::setParent(0, reinterpret_cast&lt;PyObject*&gt;(wrapper));
+ }
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QAbstractItemDelegate">
+ <enum-type name="EndEditHint"/>
+ <modify-function signature="paint(QPainter*,QStyleOptionViewItem,QModelIndex)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="editorEvent(QEvent*,QAbstractItemModel*,QStyleOptionViewItem,QModelIndex)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="createEditor(QWidget*,QStyleOptionViewItem,QModelIndex)const">
+ <modify-argument index="1">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <define-ownership class="native" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QTableWidgetItem" >
+ <enum-type name="ItemType"/>
+ <modify-function signature="read(QDataStream&amp;)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="write(QDataStream&amp;)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+ <object-type name="QListWidgetItem" >
+ <enum-type name="ItemType"/>
+ <modify-function signature="QListWidgetItem(const QString&amp;, QListWidget*, int)">
+ <modify-argument index="this">
+ <parent index="2" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="QListWidgetItem(const QIcon&amp;, const QString&amp;, QListWidget*, int)">
+ <modify-argument index="this">
+ <parent index="3" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="QListWidgetItem(QListWidget*, int)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="listWidget() const">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="read(QDataStream&amp;)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="write(QDataStream&amp;)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+ <object-type name="QGraphicsTextItem">
+ <!-- a QObject so main-thread delete redundant -->
+ <extra-includes>
+ <include file-name="QTextCursor" location="global"/>
+ </extra-includes>
+ <modify-function signature="setDocument(QTextDocument*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QCompleter">
+ <enum-type name="CompletionMode"/>
+ <enum-type name="ModelSorting"/>
+ <modify-function signature="setModel(QAbstractItemModel*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setPopup(QAbstractItemView*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setWidget(QWidget*)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QTreeWidgetItem" hash-function="qHash">
+ <enum-type name="ChildIndicatorPolicy"/>
+ <enum-type name="ItemType"/>
+ <modify-function signature="read(QDataStream&amp;)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="write(QDataStream&amp;)const">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="QTreeWidgetItem(QTreeWidget*, int)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="QTreeWidgetItem(QTreeWidget*, const QStringList&amp;, int)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="QTreeWidgetItem(QTreeWidget*, QTreeWidgetItem*, int)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="QTreeWidgetItem(QTreeWidgetItem *,int)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="QTreeWidgetItem(QTreeWidgetItem*, const QStringList &amp;, int)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="QTreeWidgetItem(QTreeWidgetItem*, QTreeWidgetItem*, int)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addChild(QTreeWidgetItem *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addChildren(const QList&lt;QTreeWidgetItem*&gt; &amp;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertChild(int, QTreeWidgetItem *)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertChildren(int, const QList&lt;QTreeWidgetItem*&gt; &amp;)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="removeChild(QTreeWidgetItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="takeChild(int)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="takeChildren()">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="parent() const">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ // Only call the parent function if this return some value
+ // the parent can be the TreeWidget
+ if (%0)
+ Shiboken::Object::setParent(%PYARG_0, %PYSELF);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="treeWidget() const">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ // Only call the parent function if this return some value
+ // the parent can be the TreeWidgetItem
+ if (%0)
+ Shiboken::Object::setParent(%PYARG_0, %PYSELF);
+ </inject-code>
+ </modify-function>
+
+ </object-type>
+ <object-type name="QListWidget">
+ <modify-function signature="setItemWidget(QListWidgetItem *, QWidget *)">
+ <modify-argument index="2">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addItem(QListWidgetItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertItem(int, QListWidgetItem*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="takeItem(int)">
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QWidget">
+ <!-- Qt5: remove native event for now -->
+ <modify-function signature="nativeEvent(const QByteArray &amp;, void *, long *)" remove="all" />
+
+ <extra-includes>
+ <include file-name="QIcon" location="global"/>
+ <include file-name="QMessageBox" location="global"/>
+ </extra-includes>
+
+ <inject-code class="native" file="glue/qwidget_glue.cpp" position="beginning" />
+
+ <enum-type name="RenderFlag" flags="RenderFlags"/>
+
+ <modify-function signature="setParent(QWidget*)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="setParent(QWidget*, QFlags&lt;Qt::WindowType&gt;)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="parentWidget()const">
+ <modify-argument index="this">
+ <parent index="return" action="add"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="actionEvent(QActionEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="changeEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="closeEvent(QCloseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="contextMenuEvent(QContextMenuEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="dragEnterEvent(QDragEnterEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="dragLeaveEvent(QDragLeaveEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="dragMoveEvent(QDragMoveEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="dropEvent(QDropEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="enterEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="focusInEvent(QFocusEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="focusOutEvent(QFocusEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="hideEvent(QHideEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="inputMethodEvent(QInputMethodEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="keyPressEvent(QKeyEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="keyReleaseEvent(QKeyEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="leaveEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="mouseDoubleClickEvent(QMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="mouseMoveEvent(QMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="mousePressEvent(QMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="mouseReleaseEvent(QMouseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="moveEvent(QMoveEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="paintEvent(QPaintEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="resizeEvent(QResizeEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="showEvent(QShowEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="tabletEvent(QTabletEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="wheelEvent(QWheelEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes">
+ <rename to="event"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="setStyle(QStyle*)">
+ <inject-code class="target" position="end">
+ Shiboken::Object::keepReference(reinterpret_cast&lt;SbkObject*&gt;(%PYSELF), "__style__", %PYARG_1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="style()const">
+ <inject-code class="target" position="end">
+ QStyle* myStyle = %CPPSELF->style();
+ if (myStyle &amp;&amp; qApp) {
+ %PYARG_0 = %CONVERTTOPYTHON[QStyle*](myStyle);
+ QStyle *appStyle = qApp->style();
+ if (appStyle == myStyle) {
+ Shiboken::AutoDecRef pyApp(%CONVERTTOPYTHON[QApplication*](qApp));
+ Shiboken::Object::setParent(pyApp, %PYARG_0);
+ Shiboken::Object::releaseOwnership(%PYARG_0);
+ } else {
+ Shiboken::Object::keepReference(reinterpret_cast&lt;SbkObject*&gt;(%PYSELF), "__style__", %PYARG_0);
+ }
+ }
+ </inject-code>
+ <modify-argument index="return">
+ <define-ownership owner="default"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="render(QPainter*,QPoint,QRegion,QFlags&lt;QWidget::RenderFlag&gt;)">
+ <modify-argument index="2">
+ <!-- Removed because the render(QPainter*) overload conflicts with the identical function in QGraphicsView -->
+ <remove-default-expression/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setFocusProxy(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </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"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="setLayout(QLayout *)">
+ <inject-code class="target" position="beginning">
+ qwidgetSetLayout(%CPPSELF, %1);
+ // %FUNCTION_NAME() - disable generation of function call.
+ </inject-code>
+ </modify-function>
+ <modify-function signature="raise()" rename="raise_" />
+ <modify-function signature="setParent(QWidget*, QFlags&lt;Qt::WindowType>)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="window()const">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QMessageBox">
+ <enum-type name="ButtonRole"/>
+ <enum-type name="Icon"/>
+ <enum-type name="StandardButton" flags="StandardButtons" />
+ <modify-function signature="removeButton(QAbstractButton*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <extra-includes>
+ <include file-name="QPixmap" location="global"/>
+ </extra-includes>
+
+ <modify-function signature="critical(QWidget*, const QString&amp;, const QString&amp;, QFlags&lt;QMessageBox::StandardButton&gt;, QMessageBox::StandardButton)" allow-thread="yes"/>
+ <modify-function signature="information(QWidget*, const QString&amp;, const QString&amp;, QFlags&lt;QMessageBox::StandardButton&gt;, QMessageBox::StandardButton)" allow-thread="yes"/>
+ <modify-function signature="question(QWidget*, const QString&amp;, const QString&amp;, QFlags&lt;QMessageBox::StandardButton&gt;, QMessageBox::StandardButton)" allow-thread="yes"/>
+ <modify-function signature="warning(QWidget*, const QString&amp;, const QString&amp;, QFlags&lt;QMessageBox::StandardButton&gt;, QMessageBox::StandardButton)" allow-thread="yes"/>
+ <modify-function signature="QMessageBox(const QString&amp;, const QString&amp;, QMessageBox::Icon, int, int, int, QWidget*, QFlags&lt;Qt::WindowType&gt;)" remove="all"/>
+ <modify-function signature="critical(QWidget*, const QString&amp;, const QString&amp;, int, int, int)" remove="all"/>
+ <modify-function signature="critical(QWidget*, const QString&amp;, const QString&amp;, const QString&amp;, const QString&amp;, const QString&amp;, int, int)" remove="all"/>
+ <modify-function signature="information(QWidget*, const QString&amp;, const QString&amp;, int, int, int)" remove="all"/>
+ <modify-function signature="information(QWidget*, const QString&amp;, const QString&amp;, const QString&amp;, const QString&amp;, const QString&amp;, int, int)" remove="all"/>
+ <modify-function signature="question(QWidget*, const QString&amp;, const QString&amp;, int, int, int)" remove="all"/>
+ <modify-function signature="question(QWidget*, const QString&amp;, const QString&amp;, const QString&amp;, const QString&amp;, const QString&amp;, int, int)" remove="all"/>
+ <modify-function signature="warning(QWidget*, const QString&amp;, const QString&amp;, int, int, int)" remove="all"/>
+ <modify-function signature="warning(QWidget*, const QString&amp;, const QString&amp;, const QString&amp;, const QString&amp;, const QString&amp;, int, int)" remove="all"/>
+
+ </object-type>
+ <object-type name="QAbstractSpinBox">
+ <enum-type name="ButtonSymbols"/>
+ <enum-type name="CorrectionMode"/>
+ <enum-type name="StepEnabledFlag" flags="StepEnabled"/>
+ <modify-function signature="setLineEdit(QLineEdit *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="fixup(QString &amp;)const">
+ <modify-argument index="return">
+ <replace-type modified-type="QString"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_QString"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="validate(QString &amp;, int &amp;)const">
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject"/>
+ <conversion-rule class="native">
+ <insert-template name="validator_conversionrule"/>
+ </conversion-rule>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_tuple_QValidator_QString_int"/>
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QTabWidget">
+ <enum-type name="TabPosition"/>
+ <enum-type name="TabShape"/>
+ <modify-function signature="addTab(QWidget*, const QString&amp;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addTab(QWidget*, const QIcon&amp;, const QString&amp;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertTab(int, QWidget*, const QIcon&amp;, const QString&amp;)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertTab(int, QWidget*, const QString&amp;)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setCornerWidget(QWidget*, Qt::Corner)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setTabBar(QTabBar*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <!-- This function need be re-implemented in inject code -->
+ <modify-function signature="removeTab(int)">
+ <inject-code class="target" position="beginning">
+ QWidget* tab = %CPPSELF.widget(%1);
+ if (tab) {
+ Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](tab));
+ %CPPSELF.%FUNCTION_NAME(%1);
+ }
+ </inject-code>
+ </modify-function>
+ <modify-function signature="clear()">
+ <inject-code class="target" position="beginning">
+ for (int i = 0; i &lt; %CPPSELF.count(); i++) {
+ QWidget* widget = %CPPSELF.widget(i);
+ Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](widget));
+ Shiboken::Object::setParent(0, pyWidget);
+ }
+ %CPPSELF.%FUNCTION_NAME();
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QDateTimeEdit">
+ <enum-type name="Section" flags="Sections"/>
+ <modify-function signature="setCalendarWidget(QCalendarWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QSlider">
+ <enum-type name="TickPosition" />
+ </object-type>
+ <object-type name="QProgressDialog">
+ <modify-function signature="setBar(QProgressBar*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setLabel(QLabel*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setCancelButton(QPushButton*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QLabel">
+ <modify-function signature="setBuddy(QWidget *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="setMovie(QMovie *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QFileDialog">
+ <enum-type name="AcceptMode"/>
+ <enum-type name="DialogLabel"/>
+ <enum-type name="FileMode"/>
+ <enum-type name="Option" flags="Options"/>
+ <enum-type name="ViewMode"/>
+ <extra-includes>
+ <include file-name="QUrl" location="global"/>
+ <include file-name="QAbstractProxyModel" location="global"/>
+ </extra-includes>
+ <modify-function signature="setIconProvider(QFileIconProvider*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setItemDelegate(QAbstractItemDelegate*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="getExistingDirectory(QWidget*, const QString&amp;, const QString&amp;, QFlags&lt;QFileDialog::Option>)" allow-thread="yes" />
+ <modify-function signature="getExistingDirectoryUrl(QWidget*, const QString&amp;, const QUrl&amp;, QFlags&lt;QFileDialog::Option>, const QStringList&amp;)" />
+ <modify-function signature="getOpenFileName(QWidget*, const QString&amp;, const QString&amp;, const QString&amp;, QString*, QFlags&lt;QFileDialog::Option&gt;)" allow-thread="yes">
+ <modify-argument index="return">
+ <replace-type modified-type="(fileName, selectedFilter)"/>
+ </modify-argument>
+ <modify-argument index="5">
+ <replace-type modified-type="QString"/>
+ <replace-default-expression with="QString()"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_for_QFileDialog"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getOpenFileNames(QWidget*, const QString&amp;, const QString&amp;, const QString&amp;, QString*, QFlags&lt;QFileDialog::Option&gt;)" allow-thread="yes">
+ <modify-argument index="return">
+ <replace-type modified-type="(fileNames, selectedFilter)"/>
+ </modify-argument>
+ <modify-argument index="5">
+ <replace-type modified-type="QString"/>
+ <replace-default-expression with="QString()"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_for_QFileDialog"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="getOpenFileUrl(QWidget*, const QString&amp;, const QUrl&amp;, const QString&amp;, QString*, QFlags&lt;QFileDialog::Option&gt;, const QStringList&amp;)" allow-thread="yes">
+ <modify-argument index="return">
+ <replace-type modified-type="(fileName, selectedFilter)"/>
+ </modify-argument>
+ <modify-argument index="5">
+ <replace-type modified-type="QString"/>
+ <replace-default-expression with="QString()"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_for_QFileDialog"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="getOpenFileUrls(QWidget*, const QString&amp;, const QUrl&amp;, const QString&amp;, QString *, QFlags&lt;QFileDialog::Option&gt;, const QStringList&amp;)" allow-thread="yes">
+ <modify-argument index="return">
+ <replace-type modified-type="(fileName, selectedFilter)"/>
+ </modify-argument>
+ <modify-argument index="5">
+ <replace-type modified-type="QString"/>
+ <replace-default-expression with="QString()"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_for_QFileDialog"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="getSaveFileName(QWidget*, const QString&amp;, const QString&amp;, const QString&amp;, QString*, QFlags&lt;QFileDialog::Option&gt;)" allow-thread="yes">
+ <modify-argument index="return">
+ <replace-type modified-type="(fileName, selectedFilter)"/>
+ </modify-argument>
+ <modify-argument index="5">
+ <replace-type modified-type="QString"/>
+ <replace-default-expression with="QString()"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_for_QFileDialog"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="getSaveFileUrl(QWidget*, const QString&amp;, const QUrl&amp;, const QString&amp;, QString*, QFlags&lt;QFileDialog::Option&gt;, const QStringList&amp;)" allow-thread="yes">
+ <modify-argument index="return">
+ <replace-type modified-type="(fileName, selectedFilter)"/>
+ </modify-argument>
+ <modify-argument index="5">
+ <replace-type modified-type="QString"/>
+ <replace-default-expression with="QString()"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_for_QFileDialog"/>
+ </inject-code>
+ </modify-function>
+
+ </object-type>
+
+ <object-type name="QErrorMessage"/>
+ <object-type name="QTabBar">
+ <extra-includes>
+ <include file-name="QIcon" location="global"/>
+ </extra-includes>
+ <enum-type name="Shape"/>
+ <enum-type name="SelectionBehavior"/>
+ <enum-type name="ButtonPosition"/>
+ </object-type>
+ <object-type name="QRadioButton" />
+ <object-type name="QScrollBar" />
+ <object-type name="QAbstractScrollArea">
+ <enum-type name="SizeAdjustPolicy"/>
+ <modify-function signature="setViewport(QWidget *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addScrollBarWidget(QWidget*,QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setCornerWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setHorizontalScrollBar(QScrollBar*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setVerticalScrollBar(QScrollBar*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setViewport(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setupViewport(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="viewportEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+ <object-type name="QRubberBand">
+ <enum-type name="Shape"/>
+ <modify-function signature="QRubberBand(QRubberBand::Shape, QWidget*)">
+ <modify-argument index="this">
+ <parent index="2" action="add"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <rename to="parent"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QTableWidget">
+ <modify-function signature="setHorizontalHeaderItem(int, QTableWidgetItem *)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setItem(int, int, QTableWidgetItem *)">
+ <modify-argument index="3">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="takeHorizontalHeaderItem(int)">
+ <modify-argument index="return">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="takeVerticalHeaderItem(int)">
+ <modify-argument index="return">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="takeItem(int,int)">
+ <modify-argument index="return">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setItemPrototype(const QTableWidgetItem *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setVerticalHeaderItem(int, QTableWidgetItem *)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setCellWidget(int,int,QWidget*)">
+ <modify-argument index="3">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setCurrentItem(QTableWidgetItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setCurrentItem(QTableWidgetItem*,QFlags&lt;QItemSelectionModel::SelectionFlag&gt;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QSplitter">
+ <modify-function signature="getRange(int,int*,int*)const">
+ <modify-argument index="0">
+ <replace-type modified-type="PyObject" />
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="3">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_args,number*,number*">
+ <replace from="$TYPE" to="int" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="addWidget(QWidget *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertWidget(int, QWidget *)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QGroupBox" />
+ <object-type name="QStackedWidget">
+ <modify-function signature="addWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertWidget(int,QWidget*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="removeWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setCurrentWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QSplitterHandle"/>
+ <object-type name="QDial" />
+ <object-type name="QKeySequenceEdit"/>
+ <object-type name="QLineEdit">
+ <enum-type name="ActionPosition"/>
+ <enum-type name="EchoMode"/>
+ <modify-function signature="setCompleter(QCompleter*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setValidator(const QValidator*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </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">
+ %CPPSELF.addAction(%1);
+ </inject-code>
+ </add-function>
+
+ </object-type>
+ <object-type name="QLCDNumber">
+ <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"/>
+ <modify-function signature="drawContents(QPainter*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+ <object-type name="QDockWidget">
+ <enum-type name="DockWidgetFeature" flags="DockWidgetFeatures"/>
+ <modify-function signature="setTitleBarWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QDesktopWidget"/>
+ <object-type name="QFrame">
+ <enum-type name="Shadow" extensible="yes"/>
+ <enum-type name="Shape"/>
+ <enum-type name="StyleMask"/>
+ </object-type>
+ <object-type name="QSpinBox">
+ <modify-function signature="valueChanged(int)">
+ <inject-documentation mode="append" format="target">
+::
+
+ def callback_int(value_as_int):
+ print 'int value changed:', repr(value_as_int)
+
+ app = QApplication(sys.argv)
+ spinbox = QSpinBox()
+ spinbox.valueChanged[unicode].connect(callback_unicode)
+ spinbox.show()
+ sys.exit(app.exec_())
+ </inject-documentation>
+ </modify-function>
+ <modify-function signature="valueChanged(QString)">
+ <inject-documentation mode="append" format="target">
+::
+
+ def callback_unicode(value_as_unicode):
+ print 'unicode value changed:', repr(value_as_unicode)
+
+ app = QApplication(sys.argv)
+ spinbox = QSpinBox()
+ spinbox.valueChanged[unicode].connect(callback_unicode)
+ spinbox.show()
+ sys.exit(app.exec_())
+ </inject-documentation>
+ </modify-function>
+ </object-type>
+ <object-type name="QTextBrowser"/>
+ <object-type name="QDoubleSpinBox"/>
+ <object-type name="QButtonGroup">
+ <modify-function signature="addButton(QAbstractButton*, int)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ <no-null-pointer/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="removeButton(QAbstractButton *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ <no-null-pointer/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setId(QAbstractButton *,int)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QToolBar">
+ <modify-function signature="addAction(QIcon,QString,const QObject*,const char*)">
+ <modify-argument index="3">
+ <replace-type modified-type="PyObject" />
+ </modify-argument>
+ <modify-argument index="4">
+ <remove-argument />
+ </modify-argument>
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+
+ <inject-code>
+ QAction* action = %CPPSELF.addAction(%1, %2);
+ %PYARG_0 = %CONVERTTOPYTHON[QAction*](action);
+ Shiboken::AutoDecRef result(PyObject_CallMethod(%PYARG_0, "connect", "OsO", %PYARG_0, SIGNAL(triggered()), %PYARG_3));
+ </inject-code>
+ </modify-function>
+ <modify-function signature="addAction(QString,const QObject*,const char*)">
+ <modify-argument index="2">
+ <replace-type modified-type="PyObject" />
+ </modify-argument>
+ <modify-argument index="3">
+ <remove-argument />
+ </modify-argument>
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <inject-code>
+ QAction* action = %CPPSELF.addAction(%1);
+ %PYARG_0 = %CONVERTTOPYTHON[QAction*](action);
+ Shiboken::AutoDecRef result(PyObject_CallMethod(%PYARG_0, "connect", "OsO", %PYARG_0, SIGNAL(triggered()), %PYARG_2));
+ </inject-code>
+ </modify-function>
+ <modify-function signature="addAction(const QString&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addAction(const QIcon&amp;, const QString&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <add-function signature="addAction(QAction*)">
+ <inject-code class="target" position="beginning">
+ %CPPSELF.addAction(%1);
+ </inject-code>
+ </add-function>
+ <modify-function signature="addSeparator()">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addWidget(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertWidget(QAction*,QWidget*)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertSeparator(QAction*)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="clear()">
+ <inject-code>
+ QList&lt;PyObject* &gt; lst;
+ Shiboken::BindingManager&amp; bm = Shiboken::BindingManager::instance();
+ foreach(QToolButton* child, %CPPSELF.findChildren&lt;QToolButton*&gt;()) {
+ if (bm.hasWrapper(child)) {
+ PyObject* pyChild = %CONVERTTOPYTHON[QToolButton*](child);
+ Shiboken::Object::setParent(0, pyChild);
+ lst &lt;&lt; pyChild;
+ }
+ }
+
+ //Remove actions
+ foreach(QAction *act, %CPPSELF.actions()) {
+ Shiboken::AutoDecRef pyAct(%CONVERTTOPYTHON[QAction*](act));
+ Shiboken::Object::setParent(NULL, pyAct);
+ Shiboken::Object::invalidate(pyAct);
+ }
+
+ %CPPSELF.clear();
+ foreach(PyObject* obj, lst) {
+ Shiboken::Object::invalidate(reinterpret_cast&lt;SbkObject* &gt;(obj));
+ Py_XDECREF(obj);
+ }
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <object-type name="QComboBox">
+ <enum-type name="InsertPolicy"/>
+ <enum-type name="SizeAdjustPolicy"/>
+ <modify-function signature="setCompleter(QCompleter*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setValidator(const QValidator*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setItemDelegate(QAbstractItemDelegate *)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ <no-null-pointer/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setView(QAbstractItemView *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setLineEdit(QLineEdit *)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setModel(QAbstractItemModel *)">
+ <modify-argument index="1">
+ <no-null-pointer/>
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QTextEdit">
+ <enum-type name="AutoFormattingFlag" flags="AutoFormatting"/>
+ <enum-type name="LineWrapMode"/>
+ <value-type name="ExtraSelection" >
+ <include file-name="QTextEdit" location="global"/>
+ </value-type>
+ <extra-includes>
+ <include file-name="QTextCursor" location="global"/>
+ </extra-includes>
+ <modify-function signature="setDocument(QTextDocument*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertFromMimeData(const QMimeData*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </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>
+ </object-type>
+
+ <!-- qApp macro -->
+ <inject-code class="native" position="beginning">
+ PyObject* moduleQtWidgets;
+ </inject-code>
+ <inject-code class="target" file="glue/qtwidgets_qapp.cpp" position="end" />
+ <object-type name="QApplication">
+ <enum-type name="ColorSpec"/>
+ <extra-includes>
+ <include file-name="QBasicTimer" location="global"/>
+ <include file-name="QFont" location="global"/>
+ <include file-name="QFontMetrics" location="global"/>
+ <include file-name="QPalette" location="global"/>
+ <include file-name="QIcon" location="global"/>
+ <include file-name="QLocale" location="global"/>
+ <include file-name="QStyle" location="global"/>
+ </extra-includes>
+ <modify-function signature="QApplication(int&amp;,char**,int)" access="private" />
+ <add-function signature="QApplication(PySequence)">
+ <inject-code>
+ QApplicationConstructor(%PYSELF, %1, &amp;%0);
+ </inject-code>
+ </add-function>
+ <modify-function signature="exec()" rename="exec_" allow-thread="yes"/>
+ <inject-code class="native" file="glue/qapplication_init.cpp" position="beginning" />
+
+ <!-- ownership control transfer to qApp -->
+ <modify-function signature="setStyle(QStyle*)">
+ <inject-code class="target" position="end">
+ Shiboken::Object::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="style()">
+ <inject-code class="target" position="end">
+ <insert-template name="set_qapp_parent_for_orphan"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="desktop()">
+ <inject-code class="target" position="end">
+ <insert-template name="set_qapp_parent_for_orphan"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="focusWidget()">
+ <inject-code class="target" position="end">
+ <insert-template name="set_qapp_parent_for_orphan"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="topLevelAt(const QPoint&amp;)">
+ <inject-code class="target" position="end">
+ <insert-template name="set_qapp_parent_for_orphan"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="topLevelAt(int, int)">
+ <inject-code class="target" position="end">
+ <insert-template name="set_qapp_parent_for_orphan"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="widgetAt(const QPoint&amp;)">
+ <inject-code class="target" position="end">
+ <insert-template name="set_qapp_parent_for_orphan"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="widgetAt(int, int)">
+ <inject-code class="target" position="end">
+ <insert-template name="set_qapp_parent_for_orphan"/>
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QCommandLinkButton"/>
+ <object-type name="QFileSystemModel" polymorphic-id-expression="qobject_cast&lt;QFileSystemModel*&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="QFormLayout">
+ <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/>
+
+ <enum-type name="FieldGrowthPolicy"/>
+ <enum-type name="ItemRole"/>
+ <enum-type name="RowWrapPolicy"/>
+
+ <template name="fix_args,int*,ItemRole*">
+ int _row;
+ QFormLayout::ItemRole _role;
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF->%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;_row, &amp;_role);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](_row));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QFormLayout::ItemRole](_role));
+ </template>
+
+ <modify-function signature="getLayoutPosition(QLayout*,int*,QFormLayout::ItemRole*)const">
+ <modify-argument index="0">
+ <replace-type modified-type="PyObject" />
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="3">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_args,int*,ItemRole*"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getWidgetPosition(QWidget*,int*,QFormLayout::ItemRole*)const">
+ <modify-argument index="0">
+ <replace-type modified-type="PyObject" />
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="3">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_args,int*,ItemRole*"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getItemPosition(int,int*,QFormLayout::ItemRole*)const">
+ <modify-argument index="0">
+ <replace-type modified-type="PyObject" />
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="3">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_args,int*,ItemRole*"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="addRow(QWidget*,QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addRow(QLayout*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addRow(QWidget*,QLayout*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addRow(QWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addRow(QString,QLayout*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addRow(QString,QWidget*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertRow(int,QLayout*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertRow(int,QWidget*,QLayout*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <modify-argument index="3">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertRow(int,QWidget*,QWidget*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <modify-argument index="3">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertRow(int,QWidget*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertRow(int,QString,QLayout*)">
+ <modify-argument index="3">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertRow(int,QString,QWidget*)">
+ <modify-argument index="3">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setLayout(int,QFormLayout::ItemRole,QLayout*)">
+ <modify-argument index="3">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setWidget(int,QFormLayout::ItemRole,QWidget*)">
+ <modify-argument index="3">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setItem(int,QFormLayout::ItemRole,QLayoutItem*)">
+ <modify-argument index="3">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QGraphicsGridLayout" >
+ <modify-function signature="addItem(QGraphicsLayoutItem*,int,int,QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="addItem(QGraphicsLayoutItem*,int,int,int,int,QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setAlignment(QGraphicsLayoutItem*,QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QGraphicsLayout">
+ <modify-function signature="getContentsMargins(qreal*,qreal*,qreal*,qreal*)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="qreal" />
+ </insert-template>
+ </inject-code>
+ <inject-code class="native" position="end">
+ <insert-template name="fix_native_return_number*,number*,number*,number*">
+ <replace from="$TYPE" to="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="widgetEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ </object-type>
+ <object-type name="QGraphicsLayoutItem" copyable="false">
+ <modify-function signature="getContentsMargins(qreal*,qreal*,qreal*,qreal*)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="qreal" />
+ </insert-template>
+ </inject-code>
+ <inject-code class="native" position="end">
+ <insert-template name="fix_native_return_number*,number*,number*,number*">
+ <replace from="$TYPE" to="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setParentLayoutItem(QGraphicsLayoutItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QGraphicsLinearLayout" >
+ <modify-function signature="addItem(QGraphicsLayoutItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertItem(int,QGraphicsLayoutItem*)">
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="removeItem(QGraphicsLayoutItem*)">
+ <modify-argument index="1">
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setAlignment(QGraphicsLayoutItem*,QFlags&lt;Qt::AlignmentFlag&gt;)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setStretchFactor(QGraphicsLayoutItem*,int)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QGraphicsProxyWidget">
+ <modify-function signature="QGraphicsProxyWidget(QGraphicsItem*, QFlags&lt;Qt::WindowType&gt;)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="createProxyForChildWidget(QWidget*)">
+ <modify-argument index="return">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="newProxyWidget(const QWidget*)">
+ <modify-argument index="return">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setWidget(QWidget*)">
+ <inject-code>
+ QWidget* _old = %CPPSELF.widget();
+ if (_old)
+ Shiboken::Object::setParent(NULL, %CONVERTTOPYTHON[QWidget*](_old));
+ %CPPSELF.%FUNCTION_NAME(%1);
+ Shiboken::Object::setParent(%PYSELF, %PYARG_1);
+ </inject-code>
+ </modify-function>
+ </object-type>
+ <!-- a QObject so main-thread delete redundant -->
+ <object-type name="QGraphicsWidget">
+ <modify-function signature="getContentsMargins(qreal*,qreal*,qreal*,qreal*)const">
+ <modify-argument index="return">
+ <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="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="getWindowFrameMargins(qreal*,qreal*,qreal*,qreal*)const">
+ <modify-argument index="return">
+ <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="qreal" />
+ </insert-template>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setLayout(QGraphicsLayout*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="changeEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="closeEvent(QCloseEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="grabKeyboardEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="grabMouseEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="hideEvent(QHideEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="moveEvent(QGraphicsSceneMoveEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="paintWindowFrame(QPainter*,const QStyleOptionGraphicsItem*,QWidget*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="resizeEvent(QGraphicsSceneResizeEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="showEvent(QShowEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="ungrabKeyboardEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="ungrabMouseEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="windowFrameEvent(QEvent*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="setStyle(QStyle*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setTabOrder(QGraphicsWidget*,QGraphicsWidget*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QPlainTextDocumentLayout"/>
+ <object-type name="QPlainTextEdit">
+ <enum-type name="LineWrapMode"/>
+ <modify-function signature="setDocument(QTextDocument*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="insertFromMimeData(const QMimeData*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="print(QPagedPaintDevice*)const" rename="print_" />
+ </object-type>
+ <object-type name="QStyledItemDelegate">
+ <modify-function signature="setItemEditorFactory(QItemEditorFactory*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setEditorData(QWidget*,QModelIndex)const">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setModelData(QWidget*,QAbstractItemModel*,QModelIndex)const">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="QGesture" since="4.6">
+ <enum-type name="GestureCancelPolicy"/>
+ </object-type>
+ <object-type name="QGestureRecognizer" since="4.6">
+ <enum-type name="ResultFlag" flags="Result"/>
+ </object-type>
+ <object-type name="QTapAndHoldGesture" since="4.6"/>
+ <object-type name="QTapGesture" since="4.6"/>
+ <object-type name="QGraphicsAnchor" since="4.6"/>
+ <object-type name="QGraphicsAnchorLayout" since="4.6"/>
+ <object-type name="QGraphicsBlurEffect" since="4.6">
+ <enum-type name="BlurHint" flags="BlurHints"/>
+ </object-type>
+ <object-type name="QGraphicsColorizeEffect" since="4.6"/>
+ <object-type name="QGraphicsDropShadowEffect" since="4.6"/>
+
+ <object-type name="QGraphicsEffect" since="4.6">
+ <enum-type name="ChangeFlag" flags="ChangeFlags"/>
+ <enum-type name="PixmapPadMode"/>
+ </object-type>
+
+ <object-type name="QGraphicsObject" since="4.6" />
+ <object-type name="QGraphicsOpacityEffect" since="4.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"/>
+ </object-type>
+ <object-type name="QSwipeGesture" since="4.6">
+ <enum-type name="SwipeDirection"/>
+ </object-type>
+
+ <value-type name="QTileRules" since="4.6"/>
+
+ <object-type name="QSizeGrip"/>
+
+ <object-type name="QSystemTrayIcon">
+ <enum-type name="ActivationReason"/>
+ <enum-type name="MessageIcon"/>
+ <modify-function signature="setContextMenu(QMenu*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <!-- The above entries may be present in the system or not. Keep this section organized. -->
+
+ <!-- This enum is present on QtCore -->
+ <suppress-warning text="enum 'QCoreApplication::ApplicationFlags' is specified in typesystem, but not declared" />
+ <suppress-warning text="QGraphicsEllipseItem::Type' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsItemGroup::Type' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsItem::UserType' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsLineItem::Type' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsPathItem::Type' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsPixmapItem::Type' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsPolygonItem::Type' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsProxyWidget::Type' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsRectItem::Type' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsSimpleTextItem::Type' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsSvgItem::Type' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsTextItem::Type' does not have a type entry or is not an enum"/>
+ <suppress-warning text="QGraphicsWidget::Type' does not have a type entry or is not an enum"/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_mac.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_mac.xml
new file mode 100644
index 000000000..a2d665b0a
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_mac.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtWidgets">
+ <rejection class="*" function-name="qt_mac_set_cursor"/>
+ <rejection class="*" function-name="macMenu"/>
+
+ <primitive-type name="Qt::HANDLE" target-lang-api-name="PyObject"/>
+ <!-- Qt5: internal
+ <object-type name="QMacStyle" >
+ <enum-type name="FocusRectPolicy"/>
+ <enum-type name="WidgetSizePolicy"/>
+ </object-type>
+ -->
+ <rejection class="QWidget" function-name="macCGHandle"/>
+ <rejection class="QWidget" function-name="macQDHandle"/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_win.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_win.xml
new file mode 100644
index 000000000..d15ec8191
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_win.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtWidgets"/>
diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_x11.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_x11.xml
new file mode 100644
index 000000000..d15ec8191
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_x11.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtWidgets"/>
diff --git a/sources/pyside2/PySide2/QtWinExtras/CMakeLists.txt b/sources/pyside2/PySide2/QtWinExtras/CMakeLists.txt
new file mode 100644
index 000000000..4de437012
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWinExtras/CMakeLists.txt
@@ -0,0 +1,51 @@
+project(QtWinExtras)
+
+set(QtWinExtras_SRC
+${QtWinExtras_GEN_DIR}/qwincolorizationchangeevent_wrapper.cpp
+${QtWinExtras_GEN_DIR}/qwincompositionchangeevent_wrapper.cpp
+${QtWinExtras_GEN_DIR}/qwinevent_wrapper.cpp
+${QtWinExtras_GEN_DIR}/qwinjumplist_wrapper.cpp
+${QtWinExtras_GEN_DIR}/qwinjumplistcategory_wrapper.cpp
+${QtWinExtras_GEN_DIR}/qwinjumplistitem_wrapper.cpp
+#${QtWinExtras_GEN_DIR}/qwinmime_wrapper.cpp
+${QtWinExtras_GEN_DIR}/qwintaskbarbutton_wrapper.cpp
+${QtWinExtras_GEN_DIR}/qwintaskbarprogress_wrapper.cpp
+${QtWinExtras_GEN_DIR}/qwinthumbnailtoolbar_wrapper.cpp
+${QtWinExtras_GEN_DIR}/qwinthumbnailtoolbutton_wrapper.cpp
+
+# module is always needed
+${QtWinExtras_GEN_DIR}/qtwinextras_module_wrapper.cpp
+)
+
+make_path(QtWinExtras_typesystem_path ${QtWinExtras_SOURCE_DIR}
+ ${QtCore_SOURCE_DIR}
+ ${QtCore_BINARY_DIR}
+ ${QtGui_SOURCE_DIR}
+ ${QtGui_BINARY_DIR})
+
+set(QtWinExtras_include_dirs ${QtWinExtras_SOURCE_DIR}
+ ${QtWinExtras_BINARY_DIR}
+ ${Qt5WinExtras_INCLUDE_DIRS}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR})
+
+set(QtWinExtras_libraries pyside2
+ ${Qt5WinExtras_LIBRARIES}
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES})
+
+set(QtWinExtras_deps QtCore QtGui)
+
+create_pyside_module(QtWinExtras
+ QtWinExtras_include_dirs
+ QtWinExtras_libraries
+ QtWinExtras_deps
+ QtWinExtras_typesystem_path
+ QtWinExtras_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtWinExtras/typesystem_winextras.xml b/sources/pyside2/PySide2/QtWinExtras/typesystem_winextras.xml
new file mode 100644
index 000000000..d7d400be9
--- /dev/null
+++ b/sources/pyside2/PySide2/QtWinExtras/typesystem_winextras.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtWinExtras">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+ <load-typesystem name="typesystem_gui.xml" generate="no"/>
+
+ <object-type name="QWinEvent" since="5.2"/>
+ <object-type name="QWinColorizationChangeEvent" since="5.2"/>
+ <object-type name="QWinCompositionChangeEvent" since="5.2"/>
+ <object-type name="QWinJumpList" since="5.2"/>
+ <object-type name="QWinJumpListCategory" since="5.2">
+ <enum-type name="Type"/>
+ </object-type>
+ <object-type name="QWinJumpListItem" since="5.2">
+ <enum-type name="Type"/>
+ </object-type>
+ <!-- <object-type name="QWinMime" since="5.4"/> -->
+ <object-type name="QWinTaskbarButton" since="5.2"/>
+ <object-type name="QWinTaskbarProgress" since="5.2"/>
+ <object-type name="QWinThumbnailToolBar" since="5.2"/>
+ <object-type name="QWinThumbnailToolButton" since="5.2"/>
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtX11Extras/CMakeLists.txt b/sources/pyside2/PySide2/QtX11Extras/CMakeLists.txt
new file mode 100644
index 000000000..0af059ffe
--- /dev/null
+++ b/sources/pyside2/PySide2/QtX11Extras/CMakeLists.txt
@@ -0,0 +1,40 @@
+project(QtX11Extras)
+
+set(QtX11Extras_SRC
+${QtX11Extras_GEN_DIR}/qx11info_wrapper.cpp
+# module is always needed
+${QtX11Extras_GEN_DIR}/qtx11extras_module_wrapper.cpp
+)
+
+make_path(QtX11Extras_typesystem_path ${QtX11Extras_SOURCE_DIR}
+ ${QtCore_SOURCE_DIR}
+ ${QtCore_BINARY_DIR}
+ ${QtGui_SOURCE_DIR}
+ ${QtGui_BINARY_DIR})
+
+set(QtX11Extras_include_dirs ${QtX11Extras_SOURCE_DIR}
+ ${QtX11Extras_BINARY_DIR}
+ ${Qt5X11Extras_INCLUDE_DIRS}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR})
+
+set(QtX11Extras_libraries pyside2
+ ${Qt5X11Extras_LIBRARIES}
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES})
+
+set(QtX11Extras_deps QtCore QtGui)
+
+create_pyside_module(QtX11Extras
+ QtX11Extras_include_dirs
+ QtX11Extras_libraries
+ QtX11Extras_deps
+ QtX11Extras_typesystem_path
+ QtX11Extras_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtX11Extras/typesystem_x11extras.xml b/sources/pyside2/PySide2/QtX11Extras/typesystem_x11extras.xml
new file mode 100644
index 000000000..9aa527951
--- /dev/null
+++ b/sources/pyside2/PySide2/QtX11Extras/typesystem_x11extras.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Mateusz Skowroński <skowri@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtX11Extras">
+ <load-typesystem name="typesystem_core.xml" generate="no"/>
+
+ <object-type name="QX11Info" />
+</typesystem>
diff --git a/sources/pyside2/PySide2/QtXml/CMakeLists.txt b/sources/pyside2/PySide2/QtXml/CMakeLists.txt
new file mode 100644
index 000000000..8dd06cc46
--- /dev/null
+++ b/sources/pyside2/PySide2/QtXml/CMakeLists.txt
@@ -0,0 +1,64 @@
+project(QtXml)
+
+set(QtXml_SRC
+${QtXml_GEN_DIR}/qdomattr_wrapper.cpp
+${QtXml_GEN_DIR}/qdomcdatasection_wrapper.cpp
+${QtXml_GEN_DIR}/qdomcharacterdata_wrapper.cpp
+${QtXml_GEN_DIR}/qdomcomment_wrapper.cpp
+${QtXml_GEN_DIR}/qdomdocument_wrapper.cpp
+${QtXml_GEN_DIR}/qdomdocumentfragment_wrapper.cpp
+${QtXml_GEN_DIR}/qdomdocumenttype_wrapper.cpp
+${QtXml_GEN_DIR}/qdomelement_wrapper.cpp
+${QtXml_GEN_DIR}/qdomentity_wrapper.cpp
+${QtXml_GEN_DIR}/qdomentityreference_wrapper.cpp
+${QtXml_GEN_DIR}/qdomimplementation_wrapper.cpp
+${QtXml_GEN_DIR}/qdomnamednodemap_wrapper.cpp
+${QtXml_GEN_DIR}/qdomnode_wrapper.cpp
+${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
+)
+
+make_path(QtXml_typesystem_path ${QtCore_SOURCE_DIR} ${QtCore_BINARY_DIR}
+ ${QtXml_SOURCE_DIR})
+
+set(QtXml_include_dirs ${QtXml_SOURCE_DIR}
+ ${QtXml_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Xml_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QtCore_GEN_DIR}
+ )
+set(QtXml_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Xml_LIBRARIES})
+set(QtXml_deps QtCore)
+
+create_pyside_module(QtXml
+ QtXml_include_dirs
+ QtXml_libraries
+ QtXml_deps
+ QtXml_typesystem_path
+ QtXml_SRC
+ "")
diff --git a/sources/pyside2/PySide2/QtXml/typesystem_xml.xml b/sources/pyside2/PySide2/QtXml/typesystem_xml.xml
new file mode 100644
index 000000000..ba0248342
--- /dev/null
+++ b/sources/pyside2/PySide2/QtXml/typesystem_xml.xml
@@ -0,0 +1,438 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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.QtXml">
+ <load-typesystem name="typesystem_templates.xml" generate="no" />
+ <load-typesystem name="typesystem_core.xml" generate="no" />
+
+ <rejection class="QXmlAttributes::Attribute"/>
+ <rejection class="QDomNode" field-name="impl"/>
+ <rejection class="QXmlInputSource" field-name="EndOfData"/>
+ <rejection class="QXmlInputSource" field-name="EndOfDocument"/>
+
+ <value-type name="QDomAttr" />
+ <value-type name="QDomCDATASection" />
+ <value-type name="QDomCharacterData" />
+ <value-type name="QDomComment" />
+
+ <template name="qdomdocument_setcontent">
+ QString _errorMsg_;
+ int _errorLine_ = 0;
+ int _errorColumn_ = 0;
+ %BEGIN_ALLOW_THREADS
+ bool _ret_ = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;_errorMsg_, &amp;_errorLine_, &amp;_errorColumn_);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(4);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[bool](_ret_));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QString](_errorMsg_));
+ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[int](_errorLine_));
+ PyTuple_SET_ITEM(%PYARG_0, 3, %CONVERTTOPYTHON[int](_errorColumn_));
+ </template>
+
+ <value-type name="QDomDocument">
+ <!-- will be replaced in inject code -->
+ <modify-function signature="setContent(const QByteArray&amp;, 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">
+ <insert-template name="qdomdocument_setcontent" />
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setContent(const QString&amp;, 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">
+ <insert-template name="qdomdocument_setcontent" />
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setContent(QIODevice*, 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">
+ <insert-template name="qdomdocument_setcontent" />
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setContent(const QByteArray&amp;, QString*, int*, int*)">
+ <modify-argument index="2">
+ <remove-argument/>
+ <remove-default-expression/>
+ </modify-argument>
+ <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="return">
+ <replace-type modified-type="(retval, errorMsg, errorLine, errorColumn)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="qdomdocument_setcontent" />
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setContent(QIODevice*,QString*,int*,int*)">
+ <modify-argument index="2">
+ <remove-argument/>
+ <remove-default-expression/>
+ </modify-argument>
+ <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="return">
+ <replace-type modified-type="(retval, errorMsg, errorLine, errorColumn)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="qdomdocument_setcontent" />
+ </inject-code>
+ </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">
+ <insert-template name="qdomdocument_setcontent" />
+ </inject-code>
+ </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">
+ <insert-template name="qdomdocument_setcontent" />
+ </inject-code>
+ </modify-function>
+ <modify-function signature="setContent(const QString&amp;, QString*,int*,int*)">
+ <modify-argument index="2">
+ <remove-argument/>
+ <remove-default-expression/>
+ </modify-argument>
+ <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="return">
+ <replace-type modified-type="(retval, errorMsg, errorLine, errorColumn)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="qdomdocument_setcontent" />
+ </inject-code>
+ </modify-function>
+ </value-type>
+
+ <value-type name="QDomDocumentFragment" />
+ <value-type name="QDomDocumentType" />
+ <value-type name="QDomEntity" />
+ <value-type name="QDomEntityReference" />
+ <value-type name="QDomImplementation">
+ <enum-type name="InvalidDataPolicy"/>
+ </value-type>
+
+ <value-type name="QDomNamedNodeMap" />
+
+ <value-type name="QDomNode">
+ <enum-type name="EncodingPolicy"/>
+ <enum-type name="NodeType"/>
+ <modify-function signature="save(QTextStream&amp;, int, QDomNode::EncodingPolicy)const" allow-thread="yes"/>
+ </value-type>
+
+ <value-type name="QDomNodeList" />
+ <value-type name="QDomNotation" />
+ <value-type name="QDomProcessingInstruction" />
+
+ <value-type name="QDomText" />
+
+ <object-type name="QXmlParseException"/>
+
+ <value-type name="QXmlAttributes"/>
+
+ <object-type name="QXmlNamespaceSupport"/>
+
+ <value-type name="QDomElement"/>
+
+ <object-type name="QXmlContentHandler">
+ <modify-function signature="setDocumentLocator(QXmlLocator*)">
+ <modify-argument index="1">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <object-type name="QXmlDTDHandler"/>
+ <object-type name="QXmlDeclHandler"/>
+ <object-type name="QXmlErrorHandler"/>
+ <object-type name="QXmlLexicalHandler"/>
+
+ <template name="QXmlEntityResolver_resolveEntity_return_conversion_native">
+ Shiboken::AutoDecRef _py_ok_(PySequence_GetItem(%PYARG_0, 0));
+ Shiboken::AutoDecRef _py_ret_(PySequence_GetItem(%PYARG_0, 1));
+ %RETURN_TYPE %out = %CONVERTTOCPP[%RETURN_TYPE](_py_ok_);
+ %3 = %CONVERTTOCPP[QXmlInputSource*](_py_ret_);
+ </template>
+
+ <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">
+ QXmlInputSource* _qxmlinputsource_arg_ = 0;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1, %2, _qxmlinputsource_arg_);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QXmlInputSource*](_qxmlinputsource_arg_));
+ </inject-code>
+ </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">
+ QXmlInputSource* _qxmlinputsource_arg_ = 0;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE %0 = %CPPSELF.%TYPE::%FUNCTION_NAME(%1, %2, _qxmlinputsource_arg_);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QXmlInputSource*](_qxmlinputsource_arg_));
+ </inject-code>
+ </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
new file mode 100644
index 000000000..a10d40bf0
--- /dev/null
+++ b/sources/pyside2/PySide2/QtXmlPatterns/CMakeLists.txt
@@ -0,0 +1,48 @@
+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
+)
+
+make_path(QtXmlPatterns_typesystem_path ${QtCore_SOURCE_DIR} ${QtCore_BINARY_DIR}
+ ${QtXmlPatterns_SOURCE_DIR})
+
+set(QtXmlPatterns_include_dirs ${QtXmlPatterns_SOURCE_DIR}
+ ${QtXmlPatterns_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5XmlPatterns_INCLUDE_DIRS}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${QtCore_GEN_DIR}
+ )
+set(QtXmlPatterns_libraries pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5XmlPatterns_LIBRARIES})
+set(QtXmlPatterns_deps QtCore)
+
+create_pyside_module(QtXmlPatterns
+ QtXmlPatterns_include_dirs
+ QtXmlPatterns_libraries
+ QtXmlPatterns_deps
+ QtXmlPatterns_typesystem_path
+ QtXmlPatterns_SRC
+ "")
+
diff --git a/sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml b/sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml
new file mode 100644
index 000000000..96970366f
--- /dev/null
+++ b/sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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="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>
+ QXmlSchema* %0 = new QXmlSchema(%CPPSELF.schema());
+ %PYARG_0 = %CONVERTTOPYTHON[QXmlSchema*](%0);
+ </inject-code>
+ </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' does not have a type entry or is not an enum"/>
+ <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" 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/__init__.py.in b/sources/pyside2/PySide2/__init__.py.in
new file mode 100644
index 000000000..5dd82ed9f
--- /dev/null
+++ b/sources/pyside2/PySide2/__init__.py.in
@@ -0,0 +1,41 @@
+__all__ = ['QtCore', 'QtGui', 'QtNetwork', 'QtOpenGL', 'QtSql', 'QtSvg', 'QtTest', 'QtWebKit', 'QtScript']
+__version__ = "@BINDING_API_VERSION_FULL@"
+__version_info__ = (@BINDING_API_MAJOR_VERSION@, @BINDING_API_MINOR_VERSION@, @BINDING_API_MICRO_VERSION@, "@BINDING_API_RELEASE_LEVEL@", @BINDING_API_SERIAL@)
+
+
+def _setupQtDirectories():
+ import sys
+ import os
+ from . import _utils
+
+ pysideDir = _utils.get_pyside_dir()
+
+ # Register PySide qt.conf to override the built-in
+ # configuration variables, if there is no default qt.conf in
+ # executable folder
+ prefix = pysideDir.replace('\\', '/')
+ _utils.register_qt_conf(prefix=prefix,
+ binaries=prefix,
+ plugins=prefix+"/plugins",
+ imports=prefix+"/imports",
+ translations=prefix+"/translations")
+
+ # On Windows add the PySide\openssl folder (if it exists) to the
+ # PATH so the SSL DLLs can be found when Qt tries to dynamically
+ # load them. Tell Qt to load them and then reset the PATH.
+ if sys.platform == 'win32':
+ opensslDir = os.path.join(pysideDir, 'openssl')
+ if os.path.exists(opensslDir):
+ path = os.environ['PATH']
+ try:
+ os.environ['PATH'] = opensslDir + os.pathsep + path
+ try:
+ from . import QtNetwork
+ except ImportError:
+ pass
+ else:
+ QtNetwork.QSslSocket.supportsSsl()
+ finally:
+ os.environ['PATH'] = path
+
+_setupQtDirectories()
diff --git a/sources/pyside2/PySide2/_utils.py.in b/sources/pyside2/PySide2/_utils.py.in
new file mode 100644
index 000000000..64a5a0567
--- /dev/null
+++ b/sources/pyside2/PySide2/_utils.py.in
@@ -0,0 +1,289 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of PySide2.
+##
+## $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 fnmatch
+
+
+if sys.platform == 'win32':
+ # On Windows get the PySide package path in case sensitive format.
+ # Even if the file system on Windows is case insensitive,
+ # some parts in Qt environment such as qml imports path,
+ # requires to be in case sensitive format.
+ import ctypes
+ from ctypes import POINTER, WinError, sizeof, byref, create_unicode_buffer
+ from ctypes.wintypes import MAX_PATH, LPCWSTR, LPWSTR, DWORD
+
+ GetShortPathNameW = ctypes.windll.kernel32.GetShortPathNameW
+ GetShortPathNameW.argtypes = [LPCWSTR, LPWSTR, DWORD]
+ GetShortPathNameW.restype = DWORD
+
+ GetLongPathNameW = ctypes.windll.kernel32.GetLongPathNameW
+ GetLongPathNameW.argtypes = [LPCWSTR, LPWSTR, DWORD]
+ GetLongPathNameW.restype = DWORD
+
+ PY_2 = sys.version_info[0] < 3
+
+ if PY_2:
+ def u(x):
+ return unicode(x)
+ def u_fs(x):
+ return unicode(x, sys.getfilesystemencoding())
+ else:
+ def u(x):
+ return x
+ def u_fs(x):
+ return x
+
+ def _get_win32_short_name(s):
+ """ Returns short name """
+ buf_size = MAX_PATH
+ for i in range(2):
+ buf = create_unicode_buffer(u('\0') * (buf_size + 1))
+ r = GetShortPathNameW(u_fs(s), buf, buf_size)
+ if r == 0:
+ raise WinError()
+ if r < buf_size:
+ if PY_2:
+ return buf.value.encode(sys.getfilesystemencoding())
+ return buf.value
+ buf_size = r
+ raise WinError()
+
+ def _get_win32_long_name(s):
+ """ Returns long name """
+ buf_size = MAX_PATH
+ for i in range(2):
+ buf = create_unicode_buffer(u('\0') * (buf_size + 1))
+ r = GetLongPathNameW(u_fs(s), buf, buf_size)
+ if r == 0:
+ raise WinError()
+ if r < buf_size:
+ if PY_2:
+ return buf.value.encode(sys.getfilesystemencoding())
+ return buf.value
+ buf_size = r
+ raise WinError()
+
+ def _get_win32_case_sensitive_name(s):
+ """ Returns long name in case sensitive format """
+ path = _get_win32_long_name(_get_win32_short_name(s))
+ return path
+
+ def get_pyside_dir():
+ try:
+ from . import QtCore
+ except ImportError:
+ return _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(__file__)))
+ else:
+ return _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(QtCore.__file__)))
+
+else:
+ def get_pyside_dir():
+ try:
+ from . import QtCore
+ except ImportError:
+ return os.path.abspath(os.path.dirname(__file__))
+ else:
+ return os.path.abspath(os.path.dirname(QtCore.__file__))
+
+
+def _filter_match(name, patterns):
+ for pattern in patterns:
+ if pattern is None:
+ continue
+ if fnmatch.fnmatch(name, pattern):
+ return True
+ return False
+
+
+def _dir_contains(dir, filter):
+ names = os.listdir(dir)
+ for name in names:
+ srcname = os.path.join(dir, name)
+ if not os.path.isdir(srcname) and _filter_match(name, filter):
+ return True
+ return False
+
+
+def _rcc_write_number(out, number, width):
+ dividend = 1
+ if width == 2:
+ dividend = 256
+ elif width == 3:
+ dividend = 65536
+ elif width == 4:
+ dividend = 16777216
+ while dividend >= 1:
+ tmp = int(number / dividend)
+ out.append("%02x" % tmp)
+ number -= tmp * dividend
+ dividend = int(dividend / 256)
+
+
+def _rcc_write_data(out, data):
+ _rcc_write_number(out, len(data), 4)
+ for d in data:
+ _rcc_write_number(out, ord(d), 1)
+
+
+def _get_qt_conf_resource(prefix, binaries, plugins, imports, translations):
+ """
+ Generate Qt resource with embedded qt.conf
+ """
+ qt_conf_template = "\
+[Paths]\x0d\x0a\
+Prefix = %(prefix)s\x0d\x0a\
+Binaries = %(binaries)s\x0d\x0a\
+Imports = %(imports)s\x0d\x0a\
+Plugins = %(plugins)s\x0d\x0a\
+Translations = %(translations)s"
+
+ rc_data_input = qt_conf_template % {"prefix": prefix,
+ "binaries": binaries,
+ "plugins": plugins,
+ "imports": imports,
+ "translations": translations}
+ rc_data_ouput = []
+ _rcc_write_data(rc_data_ouput, rc_data_input)
+
+ # The rc_struct and rc_name was pre-generated by pyside-rcc from file:
+ # <!DOCTYPE RCC><RCC version="1.0">
+ # <qresource>
+ # <file>qt/etc/qt.conf</file>
+ # </qresource>
+ # </RCC>
+ PY_2 = sys.version_info[0] < 3
+ if PY_2:
+ rc_struct = "\
+\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\
+\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x0a\x00\x02\x00\x00\
+\x00\x01\x00\x00\x00\x03\x00\x00\x00\x16\x00\x00\x00\x00\x00\x01\x00\x00\
+\x00\x00"
+ rc_name = "\
+\x00\x02\x00\x00\x07\x84\x00q\x00t\x00\x03\x00\x00l\xa3\x00e\x00t\x00c\x00\
+\x07\x08t\xa6\xa6\x00q\x00t\x00.\x00c\x00o\x00n\x00f"
+ rc_data = "".join(rc_data_ouput).decode('hex')
+ else:
+ rc_struct = b"\
+\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\
+\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x0a\x00\x02\x00\x00\
+\x00\x01\x00\x00\x00\x03\x00\x00\x00\x16\x00\x00\x00\x00\x00\x01\x00\x00\
+\x00\x00"
+ rc_name = b"\
+\x00\x02\x00\x00\x07\x84\x00q\x00t\x00\x03\x00\x00l\xa3\x00e\x00t\x00c\x00\
+\x07\x08t\xa6\xa6\x00q\x00t\x00.\x00c\x00o\x00n\x00f"
+ rc_data = bytes.fromhex("".join(rc_data_ouput))
+
+ return rc_struct, rc_name, rc_data
+
+
+def register_qt_conf(prefix, binaries, plugins, imports, translations,
+ force=False):
+ """
+ Register qt.conf in Qt resource system to override the built-in
+ configuration variables, if there is no default qt.conf in
+ executable folder and another qt.conf is not already registered in
+ Qt resource system.
+ """
+ try:
+ from . import QtCore
+ except ImportError:
+ return
+
+ # Check folder structure
+ if not prefix or not os.path.exists(prefix):
+ if force:
+ raise RuntimeError("Invalid prefix path specified: %s" % prefix)
+ else:
+ return
+ if not binaries or not os.path.exists(binaries):
+ if force:
+ raise RuntimeError("Invalid binaries path specified: %s" % binaries)
+ else:
+ return
+ else:
+ # Check if required Qt libs exists in binaries folder
+ if sys.platform == 'win32':
+ pattern = ["Qt5Core*.dll"]
+ else:
+ pattern = ["libQtCore.so.*"]
+ if not _dir_contains(binaries, pattern):
+ if force:
+ raise RuntimeError("QtCore lib not found in folder: %s" % \
+ binaries)
+ else:
+ return
+ if not plugins or not os.path.exists(plugins):
+ if force:
+ raise RuntimeError("Invalid plugins path specified: %s" % plugins)
+ else:
+ return
+ if not imports or not os.path.exists(imports):
+ if force:
+ raise RuntimeError("Invalid imports path specified: %s" % imports)
+ else:
+ return
+ if not translations or not os.path.exists(translations):
+ if force:
+ raise RuntimeError("Invalid translations path specified: %s" \
+ % translations)
+ else:
+ return
+
+ # Check if there is no default qt.conf in executable folder
+ exec_prefix = os.path.dirname(sys.executable)
+ qtconf_path = os.path.join(exec_prefix, 'qt.conf')
+ if os.path.exists(qtconf_path) and not force:
+ return
+
+ # Check if another qt.conf is not already registered in Qt resource system
+ if QtCore.QFile.exists(":/qt/etc/qt.conf") and not force:
+ return
+
+ # Keep these variables alive
+ global rc_struct, rc_name, rc_data
+ rc_struct, rc_name, rc_data = _get_qt_conf_resource(prefix, binaries,
+ plugins, imports,
+ translations)
+ QtCore.qRegisterResourceData(0x01, rc_struct, rc_name, rc_data)
+
+ # Initialize the Qt library by querying the QLibraryInfo
+ prefixPath = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.PrefixPath)
diff --git a/sources/pyside2/PySide2/global.h.in b/sources/pyside2/PySide2/global.h.in
new file mode 100644
index 000000000..6bddcfcce
--- /dev/null
+++ b/sources/pyside2/PySide2/global.h.in
@@ -0,0 +1,428 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#undef QT_NO_STL
+
+#undef QT_NO_STL_WCHAR
+#define Q_BYTE_ORDER // used to enable QSysInfo.Endian detection on MacOSX
+
+#if defined(__OBJC__) && !defined(__cplusplus)
+# warning "File built in Objective-C mode (.m), but using Qt requires Objective-C++ (.mm)"
+#endif
+
+#include <QtCore/qnamespace.h>
+
+QT_BEGIN_NAMESPACE
+
+
+class QByteArray;
+struct QArrayData;
+typedef QArrayData QByteArrayData;
+
+class QString;
+
+#ifndef Q_MOC_OUTPUT_REVISION
+#define Q_MOC_OUTPUT_REVISION 67
+#endif
+
+// The following macros are our "extensions" to C++
+// They are used, strictly speaking, only by the moc.
+
+
+#ifndef QT_NO_META_MACROS
+// macro for onaming members
+#ifdef METHOD
+#undef METHOD
+#endif
+#ifdef SLOT
+#undef SLOT
+#endif
+#ifdef SIGNAL
+#undef SIGNAL
+#endif
+#endif // QT_NO_META_MACROS
+
+Q_CORE_EXPORT const char *qFlagLocation(const char *method);
+
+#ifndef QT_NO_META_MACROS
+#ifndef QT_NO_DEBUG
+# define QLOCATION "\0" __FILE__ ":" QT_STRINGIFY(__LINE__)
+# ifndef QT_NO_KEYWORDS
+# define METHOD(a) qFlagLocation("0"#a QLOCATION)
+# endif
+# define SLOT(a) qFlagLocation("1"#a QLOCATION)
+# define SIGNAL(a) qFlagLocation("2"#a QLOCATION)
+#else
+# ifndef QT_NO_KEYWORDS
+# define METHOD(a) "0"#a
+# endif
+# define SLOT(a) "1"#a
+# define SIGNAL(a) "2"#a
+#endif
+
+#define QMETHOD_CODE 0 // member type codes
+#define QSLOT_CODE 1
+#define QSIGNAL_CODE 2
+#endif // QT_NO_META_MACROS
+
+#define Q_ARG(type, data) QArgument<type >(#type, data)
+#define Q_RETURN_ARG(type, data) QReturnArgument<type >(#type, data)
+
+class QObject;
+class QMetaMethod;
+class QMetaEnum;
+class QMetaProperty;
+class QMetaClassInfo;
+
+
+class Q_CORE_EXPORT QGenericArgument
+{
+public:
+ inline QGenericArgument(const char *aName = 0, const void *aData = 0)
+ : _data(aData), _name(aName) {}
+ inline void *data() const { return const_cast<void *>(_data); }
+ inline const char *name() const { return _name; }
+
+private:
+ const void *_data;
+ const char *_name;
+};
+
+class Q_CORE_EXPORT QGenericReturnArgument: public QGenericArgument
+{
+public:
+ inline QGenericReturnArgument(const char *aName = 0, void *aData = 0)
+ : QGenericArgument(aName, aData)
+ {}
+};
+
+template <class T>
+class QArgument: public QGenericArgument
+{
+public:
+ inline QArgument(const char *aName, const T &aData)
+ : QGenericArgument(aName, static_cast<const void *>(&aData))
+ {}
+};
+template <class T>
+class QArgument<T &>: public QGenericArgument
+{
+public:
+ inline QArgument(const char *aName, T &aData)
+ : QGenericArgument(aName, static_cast<const void *>(&aData))
+ {}
+};
+
+
+template <typename T>
+class QReturnArgument: public QGenericReturnArgument
+{
+public:
+ inline QReturnArgument(const char *aName, T &aData)
+ : QGenericReturnArgument(aName, static_cast<void *>(&aData))
+ {}
+};
+
+struct Q_CORE_EXPORT QMetaObject
+{
+ class Connection;
+ const char *className() const;
+ const QMetaObject *superClass() const;
+
+ QObject *cast(QObject *obj) const;
+ const QObject *cast(const QObject *obj) const;
+
+#ifndef QT_NO_TRANSLATION
+ QString tr(const char *s, const char *c, int n = -1) const;
+#endif // QT_NO_TRANSLATION
+
+ int methodOffset() const;
+ int enumeratorOffset() const;
+ int propertyOffset() const;
+ int classInfoOffset() const;
+
+ int constructorCount() const;
+ int methodCount() const;
+ int enumeratorCount() const;
+ int propertyCount() const;
+ int classInfoCount() const;
+
+ int indexOfConstructor(const char *constructor) const;
+ int indexOfMethod(const char *method) const;
+ int indexOfSignal(const char *signal) const;
+ int indexOfSlot(const char *slot) const;
+ int indexOfEnumerator(const char *name) const;
+ int indexOfProperty(const char *name) const;
+ int indexOfClassInfo(const char *name) const;
+
+ QMetaMethod constructor(int index) const;
+ QMetaMethod method(int index) const;
+ QMetaEnum enumerator(int index) const;
+ QMetaProperty property(int index) const;
+ QMetaClassInfo classInfo(int index) const;
+ QMetaProperty userProperty() const;
+
+ static bool checkConnectArgs(const char *signal, const char *method);
+ static bool checkConnectArgs(const QMetaMethod &signal,
+ const QMetaMethod &method);
+ static QByteArray normalizedSignature(const char *method);
+ static QByteArray normalizedType(const char *type);
+
+ // internal index-based connect
+ static Connection connect(const QObject *sender, int signal_index,
+ const QObject *receiver, int method_index,
+ int type = 0, int *types = 0);
+ // internal index-based disconnect
+ static bool disconnect(const QObject *sender, int signal_index,
+ const QObject *receiver, int method_index);
+ static bool disconnectOne(const QObject *sender, int signal_index,
+ const QObject *receiver, int method_index);
+ // internal slot-name based connect
+ static void connectSlotsByName(QObject *o);
+
+ // internal index-based signal activation
+ static void activate(QObject *sender, int signal_index, void **argv);
+ static void activate(QObject *sender, const QMetaObject *, int local_signal_index, void **argv);
+ static void activate(QObject *sender, int signal_offset, int local_signal_index, void **argv);
+
+ static bool invokeMethod(QObject *obj, const char *member,
+ Qt::ConnectionType,
+ QGenericReturnArgument ret,
+ QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val1 = QGenericArgument(),
+ QGenericArgument val2 = QGenericArgument(),
+ QGenericArgument val3 = QGenericArgument(),
+ QGenericArgument val4 = QGenericArgument(),
+ QGenericArgument val5 = QGenericArgument(),
+ QGenericArgument val6 = QGenericArgument(),
+ QGenericArgument val7 = QGenericArgument(),
+ QGenericArgument val8 = QGenericArgument(),
+ QGenericArgument val9 = QGenericArgument());
+
+ static inline bool invokeMethod(QObject *obj, const char *member,
+ QGenericReturnArgument ret,
+ QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val1 = QGenericArgument(),
+ QGenericArgument val2 = QGenericArgument(),
+ QGenericArgument val3 = QGenericArgument(),
+ QGenericArgument val4 = QGenericArgument(),
+ QGenericArgument val5 = QGenericArgument(),
+ QGenericArgument val6 = QGenericArgument(),
+ QGenericArgument val7 = QGenericArgument(),
+ QGenericArgument val8 = QGenericArgument(),
+ QGenericArgument val9 = QGenericArgument())
+ {
+ return invokeMethod(obj, member, Qt::AutoConnection, ret, val0, val1, val2, val3,
+ val4, val5, val6, val7, val8, val9);
+ }
+
+ static inline bool invokeMethod(QObject *obj, const char *member,
+ Qt::ConnectionType type,
+ QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val1 = QGenericArgument(),
+ QGenericArgument val2 = QGenericArgument(),
+ QGenericArgument val3 = QGenericArgument(),
+ QGenericArgument val4 = QGenericArgument(),
+ QGenericArgument val5 = QGenericArgument(),
+ QGenericArgument val6 = QGenericArgument(),
+ QGenericArgument val7 = QGenericArgument(),
+ QGenericArgument val8 = QGenericArgument(),
+ QGenericArgument val9 = QGenericArgument())
+ {
+ return invokeMethod(obj, member, type, QGenericReturnArgument(), val0, val1, val2,
+ val3, val4, val5, val6, val7, val8, val9);
+ }
+
+ static inline bool invokeMethod(QObject *obj, const char *member,
+ QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val1 = QGenericArgument(),
+ QGenericArgument val2 = QGenericArgument(),
+ QGenericArgument val3 = QGenericArgument(),
+ QGenericArgument val4 = QGenericArgument(),
+ QGenericArgument val5 = QGenericArgument(),
+ QGenericArgument val6 = QGenericArgument(),
+ QGenericArgument val7 = QGenericArgument(),
+ QGenericArgument val8 = QGenericArgument(),
+ QGenericArgument val9 = QGenericArgument())
+ {
+ return invokeMethod(obj, member, Qt::AutoConnection, QGenericReturnArgument(), val0,
+ val1, val2, val3, val4, val5, val6, val7, val8, val9);
+ }
+
+ QObject *newInstance(QGenericArgument val0 = QGenericArgument(0),
+ QGenericArgument val1 = QGenericArgument(),
+ QGenericArgument val2 = QGenericArgument(),
+ QGenericArgument val3 = QGenericArgument(),
+ QGenericArgument val4 = QGenericArgument(),
+ QGenericArgument val5 = QGenericArgument(),
+ QGenericArgument val6 = QGenericArgument(),
+ QGenericArgument val7 = QGenericArgument(),
+ QGenericArgument val8 = QGenericArgument(),
+ QGenericArgument val9 = QGenericArgument()) const;
+
+ enum Call {
+ InvokeMetaMethod,
+ ReadProperty,
+ WriteProperty,
+ ResetProperty,
+ QueryPropertyDesignable,
+ QueryPropertyScriptable,
+ QueryPropertyStored,
+ QueryPropertyEditable,
+ QueryPropertyUser,
+ CreateInstance,
+ IndexOfMethod,
+ RegisterPropertyMetaType,
+ RegisterMethodArgumentMetaType
+ };
+
+ int static_metacall(Call, int, void **) const;
+ static int metacall(QObject *, Call, int, void **);
+
+ struct { // private data
+ const QMetaObject *superdata;
+ const QByteArrayData *stringdata;
+ const uint *data;
+ typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **);
+ StaticMetacallFunction static_metacall;
+ const QMetaObject * const *relatedMetaObjects;
+ void *extradata; //reserved for future use
+ } d;
+};
+
+class Q_CORE_EXPORT QMetaObject::Connection {
+ void *d_ptr; //QObjectPrivate::Connection*
+ explicit Connection(void *data) : d_ptr(data) { }
+ friend class QObject;
+ friend class QObjectPrivate;
+ friend struct QMetaObject;
+public:
+ ~Connection();
+ Connection();
+ Connection(const Connection &other);
+ Connection &operator=(const Connection &other);
+#ifdef Q_QDOC
+ operator bool() const;
+#else
+ typedef void *Connection::*RestrictedBool;
+ operator RestrictedBool() const { return d_ptr ? &Connection::d_ptr : 0; }
+#endif
+
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline Connection(Connection &&o) : d_ptr(o.d_ptr) { o.d_ptr = 0; }
+ inline Connection &operator=(Connection &&other)
+ { qSwap(d_ptr, other.d_ptr); return *this; }
+#endif
+};
+
+inline const QMetaObject *QMetaObject::superClass() const
+{ return d.superdata; }
+
+namespace QtPrivate {
+ /* Trait that tells is a the Object has a Q_OBJECT macro */
+ template <typename Object> struct HasQ_OBJECT_Macro {
+ template <typename T>
+ static char test(int (T::*)(QMetaObject::Call, int, void **));
+ static int test(int (Object::*)(QMetaObject::Call, int, void **));
+ enum { Value = sizeof(test(&Object::qt_metacall)) == sizeof(int) };
+ };
+}
+
+QT_END_NAMESPACE
+
+// This Q_QDOC definition is only a convenience, since the shiboken parser is
+// happier with the simplified constructions. XXX remove this for Qt 5.7.
+#define Q_QDOC
+
+#if @ENABLE_X11@
+ #define Q_OS_X11
+#elif @ENABLE_MAC@
+ #define Q_OS_MAC
+#elif @ENABLE_WIN@
+ #include "pysidewtypes.h"
+ #define Q_OS_WIN
+#endif
+
+// There are symbols in Qt that exist in Debug but
+// not in release
+#define QT_NO_DEBUG
+
+#include <QtCore/QtCore>
+#if @ENABLE_MAC@ || @ENABLE_WIN@ || @ENABLE_X11@
+ // Workaround to parse the QApplication header
+ #define Q_INTERNAL_QAPP_SRC
+ #undef Q_QDOC
+#endif
+#if @Qt5Gui_FOUND@
+# include <QtGui/QtGui>
+#endif
+#if @Qt5Widgets_FOUND@
+# include <QtWidgets/QtWidgets>
+#endif
+#ifndef Q_QDOC
+// Make sure that Q_QDOC is defined for as much modules as possible.
+// This creates more wrappers without extra work.
+// Will disappear when we have a really good parser!
+# define Q_QDOC
+#endif
+
+#include "qpytextobject.h" // PySide class
+
+#if @ENABLE_X11@
+# if @Qt5X11Extras_FOUND@
+# include <QtX11Extras/QX11Info>
+# endif
+#elif @ENABLE_MAC@
+# include <QtGui/qmacstyle_mac.h>
+#endif
+
+// QT_WIDGETS_LIB must be defined to QSqlRelationalDelegate become visible.
+// It also changes code generation in pysideqtesttouch.h
+#define QT_WIDGETS_LIB
+#undef Q_DECLARE_INTERFACE
+
+#if @Qt5Test_FOUND@
+# include "pysideqtesttouch.h"
+#endif
+
+#ifndef QT_NO_OPENGL
+# include <@GL_H@>
+#endif // QT_NO_OPENGL
+
+// Here are now all configured modules appended:
diff --git a/sources/pyside2/PySide2/licensecomment.txt b/sources/pyside2/PySide2/licensecomment.txt
new file mode 100644
index 000000000..83535d9ad
--- /dev/null
+++ b/sources/pyside2/PySide2/licensecomment.txt
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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$
+**
+****************************************************************************/
diff --git a/sources/pyside2/PySide2/pysideqtesttouch.h b/sources/pyside2/PySide2/pysideqtesttouch.h
new file mode 100644
index 000000000..6993f0384
--- /dev/null
+++ b/sources/pyside2/PySide2/pysideqtesttouch.h
@@ -0,0 +1,227 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDEQTESTTOUCH_H
+#define PYSIDEQTESTTOUCH_H
+
+#include <QtTest/qtest_global.h>
+#include <QtTest/qtestassert.h>
+#include <QtTest/qtestsystem.h>
+#include <QtTest/qtestspontaneevent.h>
+#include <QtTest/qtesttouch.h>
+
+#include <QtCore/qmap.h>
+#include <QtGui/qevent.h>
+#include <QtGui/qwindow.h>
+#ifdef QT_WIDGETS_LIB
+#include <QtWidgets/qwidget.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+namespace QTest
+{
+
+ class PySideQTouchEventSequence
+ {
+ public:
+ ~PySideQTouchEventSequence()
+ {
+ if (commitWhenDestroyed)
+ commit();
+ }
+ PySideQTouchEventSequence* press(int touchId, const QPoint &pt, QWindow *window = 0)
+ {
+ QTouchEvent::TouchPoint &p = point(touchId);
+ p.setScreenPos(mapToScreen(window, pt));
+ p.setState(Qt::TouchPointPressed);
+ return this;
+ }
+ PySideQTouchEventSequence* move(int touchId, const QPoint &pt, QWindow *window = 0)
+ {
+ QTouchEvent::TouchPoint &p = point(touchId);
+ p.setScreenPos(mapToScreen(window, pt));
+ p.setState(Qt::TouchPointMoved);
+ return this;
+ }
+ PySideQTouchEventSequence* release(int touchId, const QPoint &pt, QWindow *window = 0)
+ {
+ QTouchEvent::TouchPoint &p = point(touchId);
+ p.setScreenPos(mapToScreen(window, pt));
+ p.setState(Qt::TouchPointReleased);
+ return this;
+ }
+ PySideQTouchEventSequence* stationary(int touchId)
+ {
+ QTouchEvent::TouchPoint &p = pointOrPreviousPoint(touchId);
+ p.setState(Qt::TouchPointStationary);
+ return this;
+ }
+
+#ifdef QT_WIDGETS_LIB
+ PySideQTouchEventSequence* press(int touchId, const QPoint &pt, QWidget *widget = 0)
+ {
+ QTouchEvent::TouchPoint &p = point(touchId);
+ p.setScreenPos(mapToScreen(widget, pt));
+ p.setState(Qt::TouchPointPressed);
+ return this;
+ }
+
+ PySideQTouchEventSequence* move(int touchId, const QPoint &pt, QWidget *widget = 0)
+ {
+ QTouchEvent::TouchPoint &p = point(touchId);
+ p.setScreenPos(mapToScreen(widget, pt));
+ p.setState(Qt::TouchPointMoved);
+ return this;
+ }
+
+ PySideQTouchEventSequence* release(int touchId, const QPoint &pt, QWidget *widget = 0)
+ {
+ QTouchEvent::TouchPoint &p = point(touchId);
+ p.setScreenPos(mapToScreen(widget, pt));
+ p.setState(Qt::TouchPointReleased);
+ return this;
+ }
+#endif
+
+ void commit(bool processEvents = true)
+ {
+ if (!points.isEmpty()) {
+ if (targetWindow)
+ {
+ qt_handleTouchEvent(targetWindow, device, points.values());
+ }
+#ifdef QT_WIDGETS_LIB
+ else if (targetWidget)
+ {
+ qt_handleTouchEvent(targetWidget->windowHandle(), device, points.values());
+ }
+#endif
+ }
+ if (processEvents)
+ QCoreApplication::processEvents();
+ previousPoints = points;
+ points.clear();
+ }
+
+private:
+#ifdef QT_WIDGETS_LIB
+ PySideQTouchEventSequence(QWidget *widget, QTouchDevice *aDevice, bool autoCommit)
+ : targetWidget(widget), targetWindow(0), 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)
+ {
+ }
+
+ 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)
+ {
+ if (widget)
+ return widget->mapToGlobal(pt);
+ return targetWidget ? targetWidget->mapToGlobal(pt) : pt;
+ }
+#endif
+ QPoint mapToScreen(QWindow *window, const QPoint &pt)
+ {
+ if(window)
+ return window->mapToGlobal(pt);
+ return targetWindow ? targetWindow->mapToGlobal(pt) : pt;
+ }
+
+ QMap<int, QTouchEvent::TouchPoint> previousPoints;
+ QMap<int, QTouchEvent::TouchPoint> points;
+#ifdef QT_WIDGETS_LIB
+ QWidget *targetWidget;
+#endif
+ QWindow *targetWindow;
+ QTouchDevice *device;
+ bool commitWhenDestroyed;
+#ifdef QT_WIDGETS_LIB
+ friend PySideQTouchEventSequence* generateTouchEvent(QWidget *, QTouchDevice*, bool);
+#endif
+ friend PySideQTouchEventSequence* generateTouchEvent(QWindow *, QTouchDevice*, bool);
+ };
+
+#ifdef QT_WIDGETS_LIB
+ inline
+ PySideQTouchEventSequence* generateTouchEvent(QWidget *widget,
+ QTouchDevice *device,
+ bool autoCommit = true)
+ {
+ return new PySideQTouchEventSequence(widget, device, autoCommit);
+ }
+#endif
+ inline
+ PySideQTouchEventSequence* generateTouchEvent(QWindow *window,
+ QTouchDevice *device,
+ bool autoCommit = true)
+ {
+ return new PySideQTouchEventSequence(window, device, autoCommit);
+ }
+
+}
+
+QT_END_NAMESPACE
+
+#endif // PYSIDEQTESTTOUCH_H
diff --git a/sources/pyside2/PySide2/pysidewtypes.h b/sources/pyside2/PySide2/pysidewtypes.h
new file mode 100644
index 000000000..056819b8e
--- /dev/null
+++ b/sources/pyside2/PySide2/pysidewtypes.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 __PYSIDEWTYPES__
+#define __PYSIDEWTYPES__
+
+typedef struct HWND__ *HWND;
+typedef unsigned UINT;
+typedef long LONG;
+typedef unsigned long DWORD;
+typedef UINT WPARAM;
+typedef LONG LPARAM;
+
+struct POINT
+{
+ LONG x;
+ LONG y;
+};
+
+struct MSG
+{
+ HWND hwnd;
+ UINT message;
+ WPARAM wParam;
+ LPARAM lParam;
+ DWORD time;
+ POINT pt;
+};
+
+#endif
diff --git a/sources/pyside2/PySide2/qpytextobject.cpp b/sources/pyside2/PySide2/qpytextobject.cpp
new file mode 100644
index 000000000..23d38902a
--- /dev/null
+++ b/sources/pyside2/PySide2/qpytextobject.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "qpytextobject.h"
+
+/*!
+ \class QPyTextObject
+ \brief Workaround to make possible use QTextObjectInterface on PySide.
+ \ingroup richtext-processing
+ Due to the technical details of how to bind C++ classes to Python, you need to use this class when you need to implement
+ your own QTextObjectInterface rather than create a class inheriting from QObject and QTextObjectInterface.
+
+ \sa QTextObjectInterface
+*/
diff --git a/sources/pyside2/PySide2/qpytextobject.h b/sources/pyside2/PySide2/qpytextobject.h
new file mode 100644
index 000000000..1c0383e3c
--- /dev/null
+++ b/sources/pyside2/PySide2/qpytextobject.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 QPYTEXTOBJECT
+#define QPYTEXTOBJECT
+
+#include <QtCore/QObject>
+#include <QtGui/QTextObjectInterface>
+
+// Qt5: no idea why this definition is not found automatically! It should come
+// from <QTextObjectInterface> which resolves to qabstracttextdocumentlayout.h
+#ifdef Q_MOC_RUN
+Q_DECLARE_INTERFACE(QTextObjectInterface, "org.qt-project.Qt.QTextObjectInterface")
+#endif
+
+class QPyTextObject : public QObject, public QTextObjectInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QTextObjectInterface)
+public:
+ QPyTextObject(QObject* parent = 0) : QObject(parent) {}
+ void drawObject(QPainter* painter, const QRectF& rect, QTextDocument* doc, int posInDocument, const QTextFormat& format ) = 0;
+ QSizeF intrinsicSize(QTextDocument* doc, int posInDocument, const QTextFormat& format ) = 0;
+};
+#endif
+
+
diff --git a/sources/pyside2/PySide2/typesystem_templates.xml b/sources/pyside2/PySide2/typesystem_templates.xml
new file mode 100644
index 000000000..d9258ba88
--- /dev/null
+++ b/sources/pyside2/PySide2/typesystem_templates.xml
@@ -0,0 +1,474 @@
+<?xml version="1.0"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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>
+ <template name="replace_child">
+ $CHILD_TYPE* oldChild = %CPPSELF.$FUNCTION_GET_OLD();
+ if (oldChild &amp;&amp; (oldChild != $CPPARG)) {
+ Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[$CHILD_TYPE*](oldChild));
+ Shiboken::Object::setParent(0, pyChild);
+ Shiboken::Object::releaseOwnership(pyChild);
+ }
+ Shiboken::Object::setParent(%PYSELF, $PYARG);
+ </template>
+
+ <!-- Templates to fix bool* parameters -->
+ <template name="tuple_retval_ok">
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[bool](ok_));
+ </template>
+ <template name="fix_bool*">
+ bool ok_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_retval_ok"/>
+ </template>
+ <template name="fix_args,bool*">
+ bool ok_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;ok_);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_retval_ok"/>
+ </template>
+ <template name="fix_arg,bool*,arg">
+ bool ok_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, &amp;ok_, %3);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_retval_ok"/>
+ </template>
+ <template name="fix_bool*,arg">
+ bool ok_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_, %2);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_retval_ok"/>
+ </template>
+ <template name="fix_bool*,arg,arg">
+ bool ok_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_, %2, %3);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_retval_ok"/>
+ </template>
+ <template name="fix_bool*,arg,arg,arg">
+ bool ok_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_, %2, %3, %4);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_retval_ok"/>
+ </template>
+ <template name="fix_bool*,arg,arg,arg,arg">
+ bool ok_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_, %2, %3, %4, %5);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_retval_ok"/>
+ </template>
+ <template name="fix_arg,arg,arg,arg,arg,arg,arg,bool*,arg">
+ bool ok_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, %7, &amp;ok_, %9);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_retval_ok"/>
+ </template>
+ <template name="fix_arg,arg,arg,arg,arg,arg,bool*,arg">
+ bool ok_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, &amp;ok_, %8);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_retval_ok"/>
+ </template>
+ <template name="fix_arg,arg,arg,arg,arg,bool*,arg">
+ bool ok_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, &amp;ok_, %7);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_retval_ok"/>
+ </template>
+ <template name="fix_arg,arg,arg,arg,bool*,arg,arg">
+ bool ok_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, &amp;ok_, %6, %7);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_retval_ok"/>
+ </template>
+ <template name="get_slice">
+ %TYPE* sequence;
+ Py_ssize_t start, end;
+ Py_ssize_t len = %CPPSELF->count();
+
+ if (_i1 &gt; len)
+ start = len;
+ else if (_i1 &lt; 0)
+ start = 0;
+ else
+ start = _i1;
+
+ if (_i2 &gt; len)
+ end = len;
+ else if (_i2 &lt; 0)
+ end = 0;
+ else
+ end = _i2;
+
+ sequence = new %TYPE();
+ for (Py_ssize_t i = start; i &lt; end; i++)
+ sequence->append(%CPPSELF->at(i));
+
+ return %CONVERTTOPYTHON[%TYPE](*sequence);
+ </template>
+
+ <template name="fix_args,QRectF*">
+ QRectF rect_;
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;rect_);
+ %END_ALLOW_THREADS
+ %PYARG_0 = %CONVERTTOPYTHON[QRectF](rect_);
+ </template>
+
+ <template name="fix_args,QRect*">
+ QRect rect_;
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;rect_);
+ %END_ALLOW_THREADS
+ %PYARG_0 = %CONVERTTOPYTHON[QRect](rect_);
+ </template>
+
+ <template name="fix_char*">
+ char val_;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;val_);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[char](val_));
+ </template>
+
+ <template name="tuple_abcd_same_type">
+ %PYARG_0 = PyTuple_New(4);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[$TYPE](a));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[$TYPE](b));
+ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[$TYPE](c));
+ PyTuple_SET_ITEM(%PYARG_0, 3, %CONVERTTOPYTHON[$TYPE](d));
+ </template>
+ <template name="fix_number*,number*,number*,number*">
+ $TYPE a, b, c, d;
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF->::%TYPE::%FUNCTION_NAME(&amp;a, &amp;b, &amp;c, &amp;d);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_abcd_same_type"/>
+ </template>
+ <template name="fix_number*,number*,number*,number*,args">
+ $TYPE a, b, c, d;
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF->::%TYPE::%FUNCTION_NAME(&amp;a, &amp;b, &amp;c, &amp;d, %ARGUMENT_NAMES);
+ %END_ALLOW_THREADS
+ <insert-template name="tuple_abcd_same_type"/>
+ </template>
+
+ <template name="fix_native_return_number*,number*,number*,number*">
+ PyObject* _obj = %PYARG_0.object();
+ if (!PySequence_Check(_obj)
+ || PySequence_Fast_GET_SIZE(_obj) != 4
+ || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 0))
+ || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 1))
+ || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 2))
+ || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 3))) {
+ PyErr_SetString(PyExc_TypeError, "Sequence of 4 numbers expected");
+ } else {
+ *%1 = %CONVERTTOCPP[$TYPE](PySequence_Fast_GET_ITEM(_obj, 0));
+ *%2 = %CONVERTTOCPP[$TYPE](PySequence_Fast_GET_ITEM(_obj, 1));
+ *%3 = %CONVERTTOCPP[$TYPE](PySequence_Fast_GET_ITEM(_obj, 2));
+ *%4 = %CONVERTTOCPP[$TYPE](PySequence_Fast_GET_ITEM(_obj, 3));
+ }
+ </template>
+
+ <template name="fix_number*,number*,number*,number*,number*">
+ $TYPE a, b, c, d, e;
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF.%FUNCTION_NAME(&amp;a, &amp;b, &amp;c, &amp;d, &amp;e);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(5);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[$TYPE](a));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[$TYPE](b));
+ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[$TYPE](c));
+ PyTuple_SET_ITEM(%PYARG_0, 3, %CONVERTTOPYTHON[$TYPE](d));
+ PyTuple_SET_ITEM(%PYARG_0, 4, %CONVERTTOPYTHON[$TYPE](e));
+ </template>
+
+ <template name="read_wrapper">
+ Shiboken::AutoArrayPointer&lt;char&gt; _data(%2);
+ qint64 _size = %CPPSELF.%FUNCTION_NAME(_data, %2);
+ QByteArray ba;
+ if (_size > 0)
+ ba = QByteArray(_data, _size);
+ %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba);
+ </template>
+
+ <template name="fix_args,number*,number*">
+ $TYPE a, b;
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;a, &amp;b);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[$TYPE](a));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[$TYPE](b));
+ </template>
+
+ <template name="fix_virtual_method_return_value_and_bool*">
+ Shiboken::AutoDecRef _py_ret_(PySequence_GetItem(%PYARG_0, 0));
+ Shiboken::AutoDecRef _py_ok_(PySequence_GetItem(%PYARG_0, 1));
+ %RETURN_TYPE %out = %CONVERTTOCPP[%RETURN_TYPE](_py_ret_);
+ *%2 = %CONVERTTOCPP[bool](_py_ok_);
+ </template>
+
+ <template name="fix_arg,int*,int*">
+ %RETURN_TYPE _ret;
+ int a, b;
+ %BEGIN_ALLOW_THREADS
+ _ret = %CPPSELF.%FUNCTION_NAME(%1, &amp;a, &amp;b);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(3);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](_ret));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](a));
+ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[int](b));
+ </template>
+
+ <template name="return_QString">
+ %PYARG_0 = %CONVERTTOPYTHON[QString](%1);
+ </template>
+
+ <template name="return_tuple_QValidator_QString_int">
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %RETURN_TYPE(%CPPSELF.%FUNCTION_NAME(%1, %2));
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(3);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG1_TYPE](%1));
+ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[%ARG2_TYPE](%2));
+ </template>
+
+ <template name="return_for_QFileDialog">
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, &amp;%5, %6);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG5_TYPE](%5));
+ </template>
+ <template name="set_qapp_parent_for_orphan">
+ if (%PYARG_0 &amp;&amp; (%PYARG_0 != Py_None)) {
+ SbkObject* _pySelf = reinterpret_cast&lt;SbkObject*&gt;(%PYARG_0);
+ if (!Shiboken::Object::hasParentInfo(_pySelf))
+ Shiboken::Object::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_0);
+ }
+ </template>
+ <!-- templates for __repr__ -->
+ <template name="repr_code">
+ QString format = QString().sprintf("%s(%REPR_FORMAT)", ((PyObject*)%PYSELF)->ob_type->tp_name, %REPR_ARGS);
+ %PYARG_0 = Shiboken::String::fromCString(qPrintable(format));
+ </template>
+ <template name="repr_code_matrix">
+ QString format= QString("%1((").arg(((PyObject*)%PYSELF)->ob_type->tp_name);
+
+ QList&lt; %MATRIX_TYPE &gt; cppArgs;
+ %MATRIX_TYPE data[%MATRIX_SIZE];
+ %CPPSELF.copyDataTo(data);
+ int matrixSize = %MATRIX_SIZE;
+ for(int size=0; size &lt; matrixSize; size++) {
+ if (size > 0)
+ format += ", ";
+ format += QString::number(data[size]);
+ }
+ format += "))";
+
+ %PYARG_0 = Shiboken::String::fromCString(qPrintable(format));
+ </template>
+
+ <template name="return_internal_pointer">
+ %PYARG_0 = reinterpret_cast&lt;PyObject*>(%CPPSELF.%FUNCTION_NAME());
+ if (!%PYARG_0)
+ %PYARG_0 = Py_None;
+ Py_INCREF(%PYARG_0);
+ </template>
+
+ <!-- templates for __reduce__ -->
+ <template name="reduce_code">
+ %PYARG_0 = Py_BuildValue("(N(%REDUCE_FORMAT))", PyObject_Type(%PYSELF), %REDUCE_ARGS);
+ </template>
+ <template name="reduce_code_matrix">
+ QList&lt; %MATRIX_TYPE &gt; cppArgs;
+ %MATRIX_TYPE data[%MATRIX_SIZE];
+ %CPPSELF.copyDataTo(data);
+ int matrixSize = %MATRIX_SIZE;
+ for(int size=0; size &lt; matrixSize; size++)
+ cppArgs.append(data[size]);
+
+ PyObject *type = PyObject_Type(%PYSELF);
+ PyObject *args = Py_BuildValue("(N)", %CONVERTTOPYTHON[QList&lt;%MATRIX_TYPE&gt; ](cppArgs));
+ %PYARG_0 = Py_BuildValue("(NN)", type, args);
+ </template>
+
+ <!-- Matrix Aux functions -->
+ <template name="matrix_constructor">
+ if (PySequence_Size(%PYARG_1) == %SIZE) {
+ Shiboken::AutoDecRef fast(PySequence_Fast(%PYARG_1, "Failed to parse sequence on %TYPE constructor."));
+ float values[%SIZE];
+ for(int i=0; i &lt; %SIZE; i++) {
+ PyObject *pv = PySequence_Fast_GET_ITEM(fast.object(), i);
+ values[i] = %CONVERTTOCPP[float](pv);
+ }
+ %0 = new %TYPE(values);
+ }
+ </template>
+
+ <template name="matrix_data_function">
+ const float* data = %CPPSELF.constData();
+ PyObject *pyData = PyTuple_New(%MATRIX_SIZE);
+ if (data) {
+ for(int i=0; i &lt; %MATRIX_SIZE; i++)
+ PyTuple_SET_ITEM(pyData, i, %CONVERTTOPYTHON[float](data[i]));
+ }
+ return pyData;
+ </template>
+
+ <template name="matrix_fill_function">
+ float value = %CONVERTTOCPP[float](%PYARG_1);
+ %CPPSELF.fill(value);
+ </template>
+
+ <template name="matrix_transposed_function">
+ %TRANSPOSED_TYPE transp = %CPPSELF.transposed();
+ return %CONVERTTOPYTHON[%TRANSPOSED_TYPE](transp);
+ </template>
+
+ <!-- Replace '#' for the argument number you want. -->
+ <template name="return_argument">
+ Py_INCREF(%PYARG_#);
+ %PYARG_0 = %PYARG_#;
+ </template>
+
+ <!-- Iterator -->
+ <template name="__iter__">
+ Py_INCREF(%PYSELF);
+ %PYARG_0 = %PYSELF;
+ </template>
+
+ <template name="__iter_parent__">
+ %CPPSELF_TYPE _tmp = %CPPSELF.begin();
+ %PYARG_0 = %CONVERTTOPYTHON[%CPPSELF_TYPE](_tmp);
+ </template>
+
+ <template name="__next__">
+ if (!%CPPSELF.atEnd()) {
+ %PYARG_0 = %CONVERTTOPYTHON[%CPPSELF_TYPE](*%CPPSELF);
+ ++(*%CPPSELF);
+ }
+ </template>
+
+ <template name="convertFromMultiMap">
+ %RETURN_NAME = PyDict_New();
+ foreach(%KEY_TYPE _key, %MAP_NAME.keys()) {
+ Shiboken::AutoDecRef _pyValueList(PyList_New(0));
+ foreach(%VALUE_TYPE _value, %MAP_NAME.values(_key)) {
+ Shiboken::AutoDecRef _pyValue(%CONVERTTOPYTHON[%VALUE_TYPE](_value));
+ PyList_Append(_pyValueList, _pyValue);
+ }
+
+ Shiboken::AutoDecRef _pyKey(%CONVERTTOPYTHON[%KEY_TYPE](_key));
+ PyDict_SetItem(%RETURN_NAME, _pyKey, _pyValueList);
+ }
+ </template>
+
+ <template name="to_tuple">
+ %PYARG_0 = Py_BuildValue("%TT_FORMAT", %TT_ARGS);
+ </template>
+
+ <template name="cpplist_to_pylist_conversion">
+ PyObject* %out = PyList_New((int) %in.size());
+ %INTYPE::const_iterator it = %in.begin();
+ for (int idx = 0; it != %in.end(); ++it, ++idx) {
+ %INTYPE_0 cppItem(*it);
+ PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem));
+ }
+ return %out;
+ </template>
+ <template name="pyseq_to_cpplist_conversion">
+ for (int i = 0; i &lt; PySequence_Size(%in); i++) {
+ Shiboken::AutoDecRef pyItem(PySequence_GetItem(%in, i));
+ %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem);
+ %out &lt;&lt; cppItem;
+ }
+ </template>
+ <template name="cppvector_to_pylist_conversion">
+ %INTYPE::size_type vectorSize = %in.size();
+ PyObject* %out = PyList_New((int) vectorSize);
+ for (%INTYPE::size_type idx = 0; idx &lt; vectorSize; ++idx) {
+ %INTYPE_0 cppItem(%in[idx]);
+ PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem));
+ }
+ return %out;
+ </template>
+ <template name="pyseq_to_cppvector_conversion">
+ int vectorSize = PySequence_Size(%in);
+ %out.reserve(vectorSize);
+ for (int idx = 0; idx &lt; vectorSize; ++idx) {
+ Shiboken::AutoDecRef pyItem(PySequence_GetItem(%in, idx));
+ %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem);
+ %out.push_back(cppItem);
+ }
+ </template>
+
+ <template name="checkPyCapsuleOrPyCObject_func">
+ static bool checkPyCapsuleOrPyCObject(PyObject* pyObj)
+ {
+ #ifdef IS_PY3K
+ return PyCapsule_CheckExact(pyObj);
+ #else
+ return PyCObject_Check(pyObj);
+ #endif
+ }
+ </template>
+
+</typesystem>
diff --git a/sources/pyside2/README.md b/sources/pyside2/README.md
new file mode 100644
index 000000000..c1897e859
--- /dev/null
+++ b/sources/pyside2/README.md
@@ -0,0 +1,10 @@
+# pyside2
+
+[![Join the chat at https://gitter.im/PySide/pyside2](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/PySide/pyside2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+
+This repository is the sources for PySide2. If you would like to install PySide2, please go to [pyside2-setup](https://github.com/PySide/pyside2-setup) for instructions.
+
+### Project Status
+
+Have a look at the [Project Test Status](https://github.com/PySide/pyside2/wiki/Project-Test-Status)
+in the [PySide2 Wiki](https://github.com/PySide/pyside2/wiki) \ No newline at end of file
diff --git a/sources/pyside2/cmake/Macros/FindQt5Extra.cmake b/sources/pyside2/cmake/Macros/FindQt5Extra.cmake
new file mode 100644
index 000000000..6bfa5e074
--- /dev/null
+++ b/sources/pyside2/cmake/Macros/FindQt5Extra.cmake
@@ -0,0 +1,25 @@
+#
+# Try to find QtMultimedia
+# TODO: Remove this hack when cmake support QtMultimedia module
+# CT: maybe we can remove this.
+# For now, I just use the mapping to Qt5
+
+find_package(Qt5Multimedia)
+
+if (NOT Qt5Multimedia_FOUND)
+ find_path(QT_QTMULTIMEDIA_INCLUDE_DIR QtMultimedia
+ PATHS ${QT_HEADERS_DIR}/QtMultimedia
+ ${QT_LIBRARY_DIR}/QtMultimedia.framework/Headers
+ NO_DEFAULT_PATH)
+ find_library(QT_QTMULTIMEDIA_LIBRARY QtMultimedia PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
+ if (QT_QTMULTIMEDIA_INCLUDE_DIR AND QT_QTMULTIMEDIA_LIBRARY)
+ set(QT_QTMULTIMEDIA_FOUND ON)
+ else()
+ #Replace this on documentation
+ set(if_QtMultimedia "<!--")
+ set(end_QtMultimedia "-->")
+ endif()
+endif ()
+
+# Maemo is no longer supported
+# QtDeclarative is no longer supported
diff --git a/sources/pyside2/cmake/Macros/PySideModules.cmake b/sources/pyside2/cmake/Macros/PySideModules.cmake
new file mode 100644
index 000000000..f4bfd8858
--- /dev/null
+++ b/sources/pyside2/cmake/Macros/PySideModules.cmake
@@ -0,0 +1,196 @@
+macro(make_path varname)
+ # accepts any number of path variables
+ string(REPLACE ";" "${PATH_SEP}" ${varname} "${ARGN}")
+endmacro()
+
+macro(unmake_path varname)
+ string(REPLACE "${PATH_SEP}" ";" ${varname} "${ARGN}")
+endmacro()
+
+macro(create_pyside_module
+ module_name
+ module_include_dir
+ module_libraries
+ module_deps
+ module_typesystem_path
+ module_sources
+ module_static_sources)
+ string(TOLOWER ${module_name} _module)
+ string(REGEX REPLACE ^qt "" _module ${_module})
+ if(${ARGC} GREATER 7)
+ set (typesystem_name ${ARGV7})
+ else()
+ set (typesystem_name "")
+ endif()
+ if(${ARGC} GREATER 8)
+ string(REPLACE ";" "\\;" dropped_entries "${${ARGV8}}")
+ else()
+ set (dropped_entries "")
+ endif()
+
+ if (NOT EXISTS ${typesystem_name})
+ set(typesystem_path ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_${_module}.xml)
+ else()
+ set(typesystem_path ${typesystem_name})
+ endif()
+
+ # check for class files that were commented away.
+ if(DEFINED ${module_sources}_skipped_files)
+ if(DEFINED PYTHON3_EXECUTABLE)
+ set(_python_interpreter "${PYTHON3_EXECUTABLE}")
+ else()
+ set(_python_interpreter "${PYTHON_EXECUTABLE}")
+ endif()
+ if(NOT _python_interpreter)
+ message(FATAL_ERROR "*** we need a python interpreter for postprocessing!")
+ endif()
+ set(_python_postprocessor "${_python_interpreter}" "${CMAKE_CURRENT_BINARY_DIR}/filter_init.py")
+ else()
+ set(_python_postprocessor "")
+ endif()
+
+ # Create typesystem XML dependencies list, so that whenever they change, shiboken is invoked
+ # automatically.
+ # First add the main file.
+ set(total_type_system_files ${typesystem_path})
+
+ # Transform the path separator list back into a cmake list (so from a:b:c to a;b;c)
+ unmake_path(list_of_paths ${${module_typesystem_path}})
+
+ # Collect all XML files, in each given path, and append them to the final total list.
+ foreach(type_system_files_path ${list_of_paths})
+ set(glob_expression "${type_system_files_path}/*.xml")
+ file(GLOB type_system_files ${glob_expression})
+ set(total_type_system_files ${total_type_system_files} ${type_system_files})
+ endforeach(type_system_files_path)
+
+ # Remove any possible duplicates.
+ list(REMOVE_DUPLICATES total_type_system_files)
+
+ # Contains include directories to pass to shiboken's preprocessor.
+ set(shiboken_include_dirs ${pyside2_SOURCE_DIR}${PATH_SEP}${QT_INCLUDE_DIR})
+ if(CMAKE_HOST_APPLE)
+ # On macOS, provide the framework paths for OpenGL headers.
+ set(shiboken_include_dirs ${shiboken_include_dirs} ${CMAKE_SYSTEM_FRAMEWORK_PATH})
+ endif()
+
+ # Transform the path separators into something shiboken understands.
+ make_path(shiboken_include_dirs ${shiboken_include_dirs})
+
+ add_custom_command(OUTPUT ${${module_sources}}
+ COMMAND "${SHIBOKEN_BINARY}" ${GENERATOR_EXTRA_FLAGS}
+ ${pyside2_BINARY_DIR}/pyside2_global.h
+ --include-paths=${shiboken_include_dirs}
+ --typesystem-paths=${pyside2_SOURCE_DIR}${PATH_SEP}${${module_typesystem_path}}
+ --output-directory=${CMAKE_CURRENT_BINARY_DIR}
+ --license-file=${CMAKE_CURRENT_SOURCE_DIR}/../licensecomment.txt
+ ${typesystem_path}
+ --api-version=${SUPPORTED_QT_VERSION}
+ --drop-type-entries="${dropped_entries}"
+ COMMAND ${_python_postprocessor}
+ DEPENDS ${total_type_system_files}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMENT "Running generator for ${module_name}...")
+
+ include_directories(${module_name} ${${module_include_dir}} ${pyside2_SOURCE_DIR})
+ add_library(${module_name} MODULE ${${module_sources}} ${${module_static_sources}})
+ set_target_properties(${module_name} PROPERTIES
+ PREFIX ""
+ OUTPUT_NAME "${module_name}${PYTHON_EXTENSION_SUFFIX}"
+ LIBRARY_OUTPUT_DIRECTORY ${pyside2_BINARY_DIR})
+ if(WIN32)
+ set_target_properties(${module_name} PROPERTIES SUFFIX ".pyd")
+ set(${module_name}_suffix ".pyd")
+ else()
+ set(${module_name}_suffix ${CMAKE_SHARED_MODULE_SUFFIX})
+ endif()
+
+ target_link_libraries(${module_name} ${${module_libraries}})
+ if(${module_deps})
+ add_dependencies(${module_name} ${${module_deps}})
+ endif()
+
+ # install
+ install(TARGETS ${module_name} LIBRARY DESTINATION ${SITE_PACKAGE}/PySide2)
+ string(TOLOWER ${module_name} lower_module_name)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide2/${module_name}/pyside2_${lower_module_name}_python.h
+ DESTINATION include/PySide2${pyside2_SUFFIX}/${module_name}/)
+ file(GLOB typesystem_files ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_*.xml ${typesystem_path})
+ install(FILES ${typesystem_files} DESTINATION share/PySide2${pyside2_SUFFIX}/typesystems)
+endmacro()
+
+#macro(check_qt_class_with_namespace module namespace class optional_source_files dropped_entries [namespace] [module])
+macro(check_qt_class module class optional_source_files dropped_entries)
+ if (${ARGC} GREATER 4)
+ set (namespace ${ARGV4})
+ string(TOLOWER ${namespace} _namespace)
+ else ()
+ set (namespace "")
+ endif ()
+ if (${ARGC} GREATER 5)
+ set (include_file ${ARGV5})
+ else ()
+ set (include_file ${class})
+ endif ()
+ string(TOLOWER ${class} _class)
+ string(TOUPPER ${module} _module)
+ if (_namespace)
+ set(_cppfile ${CMAKE_CURRENT_BINARY_DIR}/PySide2/${module}/${_namespace}_${_class}_wrapper.cpp)
+ else ()
+ set(_cppfile ${CMAKE_CURRENT_BINARY_DIR}/PySide2/${module}/${_class}_wrapper.cpp)
+ endif ()
+ if (DEFINED PYSIDE_${class})
+ if (PYSIDE_${class})
+ list(APPEND ${optional_source_files} ${_cppfile})
+ else()
+ list(APPEND ${dropped_entries} PySide2.${module}.${class})
+ endif()
+ else()
+ if (NOT ${namespace} STREQUAL "" )
+ set (NAMESPACE_USE "using namespace ${namespace};")
+ else ()
+ set (NAMESPACE_USE "")
+ endif ()
+ set(SRC_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test${class}.cxx)
+ file(WRITE ${SRC_FILE}
+ "#include <${include_file}>\n"
+ "${NAMESPACE_USE}\n"
+ "int main() { sizeof(${class}); }\n"
+ )
+ try_compile(Q_WORKS ${CMAKE_BINARY_DIR}
+ ${SRC_FILE}
+ CMAKE_FLAGS
+ "-DLINK_LIBRARIES=${QT_${_module}_LIBRARY}"
+ "-DLINK_DIRECTORIES=${QT_LIBRARY_DIR}"
+ "-DINCLUDE_DIRECTORIES=${QT_INCLUDE_DIR};${QT_${_module}_INCLUDE_DIR}"
+ OUTPUT_VARIABLE OUTPUT)
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCheckQtClassTest.log ${OUTPUT})
+
+ set("PYSIDE_${class}" ${Q_WORKS} CACHE STRING "Has ${class} class been found?")
+ if(Q_WORKS)
+ message(STATUS "Checking for ${class} in ${module} -- found")
+ list(APPEND ${optional_source_files} ${_cppfile})
+ else()
+ message(STATUS "Checking for ${class} in ${module} -- not found")
+ list(APPEND ${dropped_entries} PySide2.${module}.${class})
+ endif()
+ endif()
+endmacro()
+
+
+# Only add subdirectory if the associated Qt module is found.
+# As a side effect, this macro now also defines the variable ${name}_GEN_DIR
+# and must be called for every subproject.
+macro(HAS_QT_MODULE var name)
+ if (NOT DISABLE_${name} AND ${var})
+ # we keep the PySide name here because this is compiled into shiboken
+ set(${name}_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/${name}/PySide2/${name}
+ CACHE INTERNAL "dir with generated source" FORCE)
+ add_subdirectory(${name})
+ else()
+ # Used on documentation to skip modules
+ set("if_${name}" "<!--" PARENT_SCOPE)
+ set("end_${name}" "-->" PARENT_SCOPE)
+ endif()
+endmacro()
+
diff --git a/sources/pyside2/cmake/Macros/icecc.cmake b/sources/pyside2/cmake/Macros/icecc.cmake
new file mode 100644
index 000000000..b2bf071aa
--- /dev/null
+++ b/sources/pyside2/cmake/Macros/icecc.cmake
@@ -0,0 +1,11 @@
+include (CMakeForceCompiler)
+option(ENABLE_ICECC "Enable icecc checking, for distributed compilation")
+if (ENABLE_ICECC)
+ find_program(ICECC icecc)
+ if (ICECC)
+ message(STATUS "icecc found! Distributed compilation for all!! huhuhu.")
+ cmake_force_cxx_compiler(${ICECC} icecc)
+ else(ICECC)
+ message(FATAL_ERROR "icecc NOT found! re-run cmake without -DENABLE_ICECC")
+ endif(ICECC)
+endif(ENABLE_ICECC)
diff --git a/sources/pyside2/cmake_uninstall.cmake b/sources/pyside2/cmake_uninstall.cmake
new file mode 100644
index 000000000..df95fb9d8
--- /dev/null
+++ b/sources/pyside2/cmake_uninstall.cmake
@@ -0,0 +1,21 @@
+IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
+ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+STRING(REGEX REPLACE "\n" ";" files "${files}")
+FOREACH(file ${files})
+ MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
+ IF(EXISTS "$ENV{DESTDIR}${file}")
+ EXEC_PROGRAM(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ IF(NOT "${rm_retval}" STREQUAL 0)
+ MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
+ ENDIF(NOT "${rm_retval}" STREQUAL 0)
+ ELSE(EXISTS "$ENV{DESTDIR}${file}")
+ MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
+ ENDIF(EXISTS "$ENV{DESTDIR}${file}")
+ENDFOREACH(file)
diff --git a/sources/pyside2/doc/CMakeLists.txt b/sources/pyside2/doc/CMakeLists.txt
new file mode 100644
index 000000000..c5d0169d1
--- /dev/null
+++ b/sources/pyside2/doc/CMakeLists.txt
@@ -0,0 +1,59 @@
+project(doc)
+
+set(DOC_DATA_DIR "${CMAKE_CURRENT_BINARY_DIR}/qdoc3-output")
+configure_file("pyside.qdocconf.in" "pyside.qdocconf" @ONLY)
+
+add_custom_target(qdoc3
+ COMMAND qdoc3 pyside.qdocconf
+ COMMENT "Running qdoc3 against Qt source code..."
+ SOURCE "pyside.qdocconf")
+
+
+find_program(SPHINX_BUILD NAMES sphinx-build)
+if (${SPHINX_BUILD} MATCHES "SPHINX_BUILD-NOTFOUND")
+ message(FATAL_ERROR "sphinx-build command not found.")
+endif()
+add_custom_target(apidoc
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/rst
+ COMMAND ${SHIBOKEN_PYTHON_INTERPRETER} ${SPHINX_BUILD} -b html ${CMAKE_CURRENT_BINARY_DIR}/rst html
+ )
+
+# create conf.py based on conf.py.in
+configure_file("conf.py.in" "rst/conf.py" @ONLY)
+configure_file(typesystem_doc.xml.in typesystem_doc.xml @ONLY)
+
+add_custom_target("docrsts"
+ COMMAND ${SHIBOKEN_BINARY} --generator-set=qtdoc
+ ${pyside2_BINARY_DIR}/pyside_global.h
+ --include-paths="${QT_INCLUDE_DIR}${PATH_SEP}${pyside2_SOURCE_DIR}"
+ --api-version=${SUPPORTED_QT_VERSION}
+ --typesystem-paths="${pyside2_SOURCE_DIR}${PATH_SEP}${QtCore_SOURCE_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}${PATH_SEP}${QtHelp_SOURCE_DIR}${PATH_SEP}${QtMultimedia_SOURCE_DIR}${PATH_SEP}${QtNetwork_SOURCE_DIR}${PATH_SEP}${QtOpenGL_SOURCE_DIR}${PATH_SEP}${QtScript_SOURCE_DIR}${PATH_SEP}${QtScriptTools_SOURCE_DIR}${PATH_SEP}${QtSql_SOURCE_DIR}${PATH_SEP}${QtSvg_SOURCE_DIR}${PATH_SEP}${QtTest_SOURCE_DIR}${PATH_SEP}${QtUiTools_SOURCE_DIR}${PATH_SEP}${QtWebKit_SOURCE_DIR}${PATH_SEP}${QtXml_SOURCE_DIR}${PATH_SEP}${QtXmlPatterns_SOURCE_DIR}"
+ --library-source-dir=${QT_SRC_DIR}
+ --documentation-data-dir=${DOC_DATA_DIR}
+ --output-directory=${CMAKE_CURRENT_BINARY_DIR}/rst
+ --documentation-code-snippets-dir=${CMAKE_CURRENT_SOURCE_DIR}/codesnippets${PATH_SEP}${CMAKE_CURRENT_SOURCE_DIR}/codesnippets/examples
+ --documentation-extra-sections-dir=${CMAKE_CURRENT_SOURCE_DIR}/extras
+ ${CMAKE_CURRENT_BINARY_DIR}/typesystem_doc.xml
+ WORKING_DIRECTORY ${${module}_SOURCE_DIR}
+ COMMENT "Running generator to generate documentation..."
+)
+add_dependencies(apidoc docrsts)
+add_dependencies(docrsts qdoc3)
+
+# #create devhelp file
+# add_custom_target(apidevhelp
+# COMMAND python;${CMAKE_CURRENT_SOURCE_DIR}/pyhtml2devhelp.py;${CMAKE_BINARY_DIR}/apidoc/html;index.html >
+# ${CMAKE_BINARY_DIR}/apidoc/html/PySide.devhelp;${BINDING_API_VERSION}&&;
+# gzip;-9v;-f;${CMAKE_BINARY_DIR}/apidoc/html/PySide.devhelp
+# COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_INSTALL_PREFIX}/share/devhelp/books"
+# COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_INSTALL_PREFIX}/share/doc/${BINDING_NAME}/html" "${CMAKE_INSTALL_PREFIX}/share/devhelp/books/${BINDING_NAME}"
+# )
+
+#install files
+add_custom_target(apidocinstall
+ COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/share/doc/PySide2-${BINDING_API_VERSION} && cp -rv ${CMAKE_CURRENT_BINARY_DIR}/html/* ${CMAKE_INSTALL_PREFIX}/share/doc/PySide-${BINDING_API_VERSION}
+)
+
+add_dependencies(apidocinstall apidoc)
+# add_dependencies(apidocinstall apidevhelp)
+
diff --git a/sources/pyside2/doc/_templates/index.html b/sources/pyside2/doc/_templates/index.html
new file mode 100644
index 000000000..8da417682
--- /dev/null
+++ b/sources/pyside2/doc/_templates/index.html
@@ -0,0 +1,70 @@
+{% extends "layout.html" %}
+{% set title = 'Overview' %}
+{% block body %}
+<div class="section">
+ <h1>PySide {{ version }} Reference</h1>
+
+ <p><a href="http://www.qtsoftware.com/">Qt</a> is a cross-platform application framework from Qt Software (owned by Nokia).
+ It features a large number of libraries providing services like network abstraction and XML handling, along with a very rich
+ GUI package, allowing C++ developers to write their applications once and run them unmodified in different systems.
+ PySide aims to provide Python developers access to the Qt libraries in the most natural way.</p>
+
+ <p>PySide is built using the <a href="http://www.pyside.org/docs/shiboken">Shiboken</a> binding generator.</p>
+
+ <h2>Notes</h2>
+
+ <h3>About 0 vs None</h3>
+
+ <p>The PySide class reference documentation is automatically generated from the original Qt documentation for C++, some parts were tuned to fit the Python world. However, it's not possible to rewrite all Qt docs as it would require a really huge effort, so if the documentation says you can use 0 on an QObject argument, interpret it as None.</p>
+
+ <h3>About keyword arguments</h3>
+
+ <p>Only optional arguments can be used as keyword arguments.</p>
+
+ <h2>Modules</h2>
+
+ <table class="contentstable" align="center" ><tr>
+ <td width="50%">
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtCore/index") }}">QtCore</a><br/>
+ <span class="linkdescr">core non-GUI functionality</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtGui/index") }}">QtGui</a><br/>
+ <span class="linkdescr">extends QtCore with GUI functionality.</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtHelp/index") }}">QtHelp</a><br/>
+ <span class="linkdescr">provides classes for integrating online documentation in applications</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtMultimedia/index") }}">QtMultimedia</a><br/>
+ <span class="linkdescr">provides low-level multimedia functionality</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtNetwork/index") }}">QtNetwork</a><br/>
+ <span class="linkdescr">offers classes that allow you to write TCP/IP clients and servers</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtOpenGL/index") }}">QtOpenGL</a><br/>
+ <span class="linkdescr">offers classes that make it easy to use OpenGL in Qt applications</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtScript/index") }}">QtScript</a><br/>
+ <span class="linkdescr">provides classes for making Qt applications scriptable</span></p>
+ </td>
+ <td width="50%">
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtScriptTools/index") }}">QtScriptTools</a><br/>
+ <span class="linkdescr">provides additional components for applications that use Qt Script</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtSql/index") }}">QtSql</a><br/>
+ <span class="linkdescr">helps you provide seamless database integration to your Qt applications</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtSvg/index") }}">QtSvg</a><br/>
+ <span class="linkdescr">provides classes for displaying the contents of SVG files</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtUiTools/index") }}">QtUiTools</a><br/>
+ <span class="linkdescr">provides classes to handle forms created with Qt Designer</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtXml/index") }}">QtXml</a><br/>
+ <span class="linkdescr">provides a stream reader and writer for XML documents</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("PySide/QtWebKit/index") }}">QtWebkit</a><br/>
+ <span class="linkdescr">provides a Web browser engine</span></p>
+ </td></tr>
+ </table>
+
+ <h2>Tutorials and examples</h2>
+
+ <p>A collection of <a href="{{ pathto("tutorials/index") }}">tutorials</a> and "walkthrough" guides are provided with PySide to help new users get started with PySide development. These documents were ported from C++ to Python and cover a range of topics, from basic use of widgets to step-by-step <a href="{{ pathto("tutorials/index") }}">tutorials</a> that show how an application is put together.</p>
+
+ <h2>Other stuff</h2>
+
+ <ul>
+ <li class="toctree-l1"><a class="reference internal" href="pysideapi2.html">PySide API 2</a></li>
+ <li class="toctree-l1"><a class="reference internal" href="pysideversion.html">Getting PySide and Qt version</a></li>
+ </ul>
+</div>
+{% endblock %}
diff --git a/sources/pyside2/doc/_templates/layout.html b/sources/pyside2/doc/_templates/layout.html
new file mode 100644
index 000000000..9dc53722d
--- /dev/null
+++ b/sources/pyside2/doc/_templates/layout.html
@@ -0,0 +1,41 @@
+{% extends "!layout.html" %}
+
+# Invert sidebars
+{%- block sidebar1 %}{{ sidebar() }}{%- endblock %}
+{%- block sidebar2 %}{%- endblock %}
+
+{%- block header %}
+<div id="container">
+<div class="header">
+ <div class="header_container">
+ <div class="logo"><a href="http://www.pyside.org"><img alt="PySide" src="{{ pathto('_static/pysidelogo.png', 1) }}" width="199" height="102" /></a></div>
+ <div class="related">
+ <ul>
+ {%- block rootrellink %}
+ <li><a href="{{ pathto( 'index' ) }}">{{ shorttitle|e }}</a></li>
+ {%- endblock %}
+ {%- for parent in parents %}
+ <li>{{ reldelim1 }} <a href="{{ parent.link|e }}" {% if loop.last %}{{ accesskey("U") }}{% endif %}>{{ parent.title }}</a></li>
+ {%- endfor %}
+ {%- block relbaritems %} {% endblock %}
+ </ul>
+ </div>
+ </div>
+</div>
+{%- endblock -%}
+
+{%- block footer %}
+ <div class="footer">
+ <a href="http://www.indt.org.br"><img src="{{ pathto('_static/logo_indt.jpg', 1) }}" alt="Indt" border="0" /></a>
+ <a href="http://www.openbossa.org"><img src="{{ pathto('_static/logo_openbossa.png', 1) }}" alt="Openbossa" border="0" /></a>
+ <a href="http://qt.nokia.com/"><img src="{{ pathto('_static/logo_qt.png', 1) }}" alt="Qt" border="0" /></a>
+ <a href="http://www.python.org"><img src="{{ pathto('_static/logo_python.jpg', 1) }}" alt="Python" border="0" /></a>
+ </div>
+</div>
+{%- endblock %}
+
+# No top relbar.
+{%- block relbar1 %}{%- endblock %}
+
+# No bottom relbar.
+{%- block relbar2 %}{%- endblock %}
diff --git a/sources/pyside2/doc/_themes/pysidedocs/domainindex.html b/sources/pyside2/doc/_themes/pysidedocs/domainindex.html
new file mode 100644
index 000000000..c136cdd1c
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/domainindex.html
@@ -0,0 +1,57 @@
+{#
+ basic/domainindex.html
+ ~~~~~~~~~~~~~~~~~~~~~~
+
+ Template for domain indices (module index, ...).
+
+ :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+#}
+{% extends "layout.html" %}
+{% set title = indextitle %}
+{% block extrahead %}
+{{ super() }}
+{% if not embedded and collapse_index %}
+ <script type="text/javascript">
+ DOCUMENTATION_OPTIONS.COLLAPSE_INDEX = true;
+ </script>
+{% endif %}
+{% endblock %}
+{% block body %}
+<div class="section">
+ {%- set curr_group = 0 %}
+
+ <h1>{{ indextitle }}</h1>
+
+ <div class="modindex-jumpbox">
+ {%- for (letter, entries) in content %}
+ <a href="#cap-{{ letter }}"><strong>{{ letter }}</strong></a>
+ {%- if not loop.last %} | {% endif %}
+ {%- endfor %}
+ </div>
+
+ <table class="indextable modindextable" cellspacing="0" cellpadding="2">
+ {%- for letter, entries in content %}
+ <tr class="pcap"><td></td><td>&nbsp;</td><td></td></tr>
+ <tr class="cap"><td></td><td><a name="cap-{{ letter }}">
+ <strong>{{ letter }}</strong></a></td><td></td></tr>
+ {%- for (name, grouptype, page, anchor, extra, qualifier, description)
+ in entries %}
+ {%- if grouptype == 1 %}{% set curr_group = curr_group + 1 %}{% endif %}
+ <tr{% if grouptype == 2 %} class="cg-{{ curr_group }}"{% endif %}>
+ <td>{% if grouptype == 1 -%}
+ <img src="{{ pathto('_static/minus.png', 1) }}" id="toggle-{{ curr_group }}"
+ class="toggler" style="display: none" alt="-" />
+ {%- endif %}</td>
+ <td>{% if grouptype == 2 %}&nbsp;&nbsp;&nbsp;{% endif %}
+ {% if page %}<a href="{{ pathto(page) }}#{{ anchor }}">{% endif -%}
+ <tt class="xref">{{ name|e }}</tt>
+ {%- if page %}</a>{% endif %}
+ {%- if extra %} <em>({{ extra|e }})</em>{% endif -%}
+ </td><td>{% if qualifier %}<strong>{{ qualifier|e }}:</strong>{% endif %}
+ <em>{{ description|e }}</em></td></tr>
+ {%- endfor %}
+ {%- endfor %}
+ </table>
+</div>
+{% endblock %}
diff --git a/sources/pyside2/doc/_themes/pysidedocs/searchbox.html b/sources/pyside2/doc/_themes/pysidedocs/searchbox.html
new file mode 100644
index 000000000..55a972156
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/searchbox.html
@@ -0,0 +1,12 @@
+{%- if pagename != "search" %}
+<div id="searchbox" style="display: none">
+ <h3>{{ _('Quick search') }}</h3>
+ <form class="search" action="{{ pathto('search') }}" method="get">
+ <input type="text" name="q" id="q" size="18" />
+ <input type="submit" value="{{ _('Go') }}" id="search_button" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+{%- endif %}
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/bg_header.png b/sources/pyside2/doc/_themes/pysidedocs/static/bg_header.png
new file mode 100644
index 000000000..843e7e2c5
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/bg_header.png
Binary files differ
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/bg_topo.jpg b/sources/pyside2/doc/_themes/pysidedocs/static/bg_topo.jpg
new file mode 100644
index 000000000..4229ae8db
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/bg_topo.jpg
Binary files differ
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/fakebar.png b/sources/pyside2/doc/_themes/pysidedocs/static/fakebar.png
new file mode 100644
index 000000000..b45830e00
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/fakebar.png
Binary files differ
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/logo_indt.jpg b/sources/pyside2/doc/_themes/pysidedocs/static/logo_indt.jpg
new file mode 100644
index 000000000..2a1fbe7a1
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/logo_indt.jpg
Binary files differ
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/logo_openbossa.png b/sources/pyside2/doc/_themes/pysidedocs/static/logo_openbossa.png
new file mode 100644
index 000000000..51e868d6e
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/logo_openbossa.png
Binary files differ
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/logo_python.jpg b/sources/pyside2/doc/_themes/pysidedocs/static/logo_python.jpg
new file mode 100644
index 000000000..cd474efba
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/logo_python.jpg
Binary files differ
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/logo_qt.png b/sources/pyside2/doc/_themes/pysidedocs/static/logo_qt.png
new file mode 100644
index 000000000..3bc03b7c7
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/logo_qt.png
Binary files differ
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/minus.png b/sources/pyside2/doc/_themes/pysidedocs/static/minus.png
new file mode 100644
index 000000000..da1c5620d
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/minus.png
Binary files differ
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/plus.png b/sources/pyside2/doc/_themes/pysidedocs/static/plus.png
new file mode 100644
index 000000000..b3cb37425
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/plus.png
Binary files differ
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/pysidedocs.css b/sources/pyside2/doc/_themes/pysidedocs/static/pysidedocs.css
new file mode 100644
index 000000000..1692dc3ba
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/pysidedocs.css
@@ -0,0 +1,477 @@
+* {
+ font: 100% Verdana, Arial, Helvetica, sans-serif;
+ font-size:12px;
+}
+
+html {
+ height: 100%;
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ background-color: #EBEBEB;
+ height: 100%;
+ color: #333;
+}
+
+strong {
+ font-weight:bold;
+}
+
+.document {
+ padding-bottom: 90px;
+}
+
+#container {
+ position: relative;
+ min-height: 100%;
+ background-image: url(fakebar.png);
+ background-repeat: repeat-y;
+ background-color: white;
+}
+
+.footer {
+ position: absolute;
+ bottom: 0px;
+ margin-top: 50px;
+ text-align:center;
+ background-color: white;
+ border-top: 2px solid #e0e0e0;
+ white-space: nowrap;
+ height: 90px;
+ width: 100%;
+}
+
+.footer img {
+ margin-left: 8px;
+ margin-right: 8px;
+}
+
+.sphinxsidebar {
+ float: left;
+ width: 250px;
+ padding: 0px 10px 0px 10px;
+ text-align: left;
+}
+
+.sphinxsidebar ul {
+ padding: 0px;
+ margin: 0px;
+ list-style-position: inside;
+}
+
+.sphinxsidebar > ul {
+ padding: 0px;
+ margin: 0px;
+}
+
+.sphinxsidebar ul li {
+ margin-left: 10px;
+ padding: 0px;
+}
+
+.sphinxsidebar h3, .sphinxsidebar h3 a {
+ font-weight: bold;
+ color: #333;
+}
+
+.documentwrapper {
+ margin-left: 270px;
+ text-align: left;
+ background-color: #ffffff;
+ border-left: 1px solid #989898;
+ font-size:18px;
+ padding: 10px 50px 15px 50px;
+ height: 100%;
+}
+
+h1 {
+ font-size:18px;
+ padding-left: 50px;
+ padding-bottom: 15px;
+ padding-top: 15px;
+ border-bottom: 1px solid #c2c2c2;
+/* text-transform:uppercase; */
+ margin-right: -100px;
+ position: relative;
+ left: -50px;
+ top: -10px;
+}
+
+h2 {
+ font-size:12px;
+ font-weight:bold;
+ border-left-width: 1px;
+ border-right-width: 1px;
+ border-top-width: 1px;
+ border-bottom-width: 2px;
+ border-style: solid;
+ border-left-color: #b1b1b1;
+ border-right-color: #b1b1b1;
+ border-top-color: #b1b1b1;
+ border-bottom-color: #009491;
+ background-color: #e0e0e0;
+ padding:5px;
+ margin-top: 20px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ -khtml-border-radius:5px;
+}
+
+h3, h4 {
+ font-weight: bolder;
+}
+
+pre {
+ border-top: 1px solid #e0e0e0;
+ border-bottom: 1px solid #e0e0e0;
+ background-color: #fafafa;
+ padding: 5px;
+ font: 100% monospace;
+ overflow: auto;
+}
+
+pre * {
+ font: 100% monospace;
+}
+
+.pre {
+ font: 100% monospace;
+}
+
+.headerlink {
+ font-size: 100%;
+ color: inherit;
+ float: right;
+ visibility: Hidden
+}
+
+h1 .headerlink {
+ padding-right: 50px;
+}
+
+h1:hover .headerlink, h2:hover .headerlink, h3:hover .headerlink {
+ visibility: Visible;
+}
+
+a, a:visited {
+ color: #009491;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+/* -- admonitions ----------------------------------------------------------- */
+
+div.admonition {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ padding: 7px;
+}
+
+div.admonition dt {
+ font-weight: bold;
+}
+
+div.admonition dl {
+ margin-bottom: 0;
+}
+
+p.admonition-title {
+ margin: 0px 10px 5px 0px;
+ font-weight: bold;
+}
+
+div.body p.centered {
+ text-align: center;
+ margin-top: 25px;
+}
+
+div.warning {
+ background-color: #ffe4e4;
+ border: 1px solid #f66;
+}
+
+div.seealso {
+ background-color: #ffffcc;
+ border: 1px solid #ffff66;
+}
+
+div.note {
+ border: 1px solid #e3e3e3;
+}
+
+table.docutils {
+ margin-left: auto;
+ margin-right: auto;
+ margin-bottom: 10px;
+ border: none;
+}
+
+table.docutils td {
+ border: none;
+}
+
+table.docutils th {
+ border: none;
+ font-weight: bold;
+ vertical-align: top;
+}
+
+h2 em {
+ float: right;
+ font-size: 10px;
+ position: relative;
+ top: -20px;
+}
+
+/* Table of pymaemo components */
+
+#development table.docutils td {
+ border-bottom: 1px solid #EBEBEB;
+}
+
+#development th {
+ background-color: #EBEBEB;
+ color: #FC7E00;
+ padding: 5px;
+}
+
+#development th:first-child {
+ -moz-border-radius: 20px 0px 0px 0px;
+ -webkit-border-radius: 20px 0px 0px 0px;
+ -khtml-border-radius: 20px 0px 0px 0px;
+ padding-left: 10px;
+}
+#development th:last-child {
+ -moz-border-radius: 0px 20px 0px 0px;
+ -webkit-border-radius: 0px 20px 0px 0px;
+ -khtml-border-radius: 0px 20px 0px 0px;
+ padding-right: 10px;
+ width: 100px;
+}
+
+hr {
+ border: none;
+ border-bottom: 1px dashed #EBEBEB;
+ width: 70%
+}
+
+.oldnews {
+ text-align: right;
+}
+
+/******************* TOPO *****************************/
+.header {
+ background-image: url(bg_topo.jpg);
+ background-repeat: repeat-x;
+ height: 147px;
+}
+
+.header_container {
+ background-image: url(bg_header.png);
+ background-repeat: no-repeat;
+ background-position: 100px 0px;
+}
+
+.logo {
+ text-align: left;
+ margin-bottom: 10px;
+}
+
+#searchbox {
+ border-top: 1px solid #989898;
+ padding-top: 10px;
+ margin-left: -10px;
+ margin-right: -10px;
+ padding-left: 10px;
+ padding-right: 10px;
+}
+
+#search_button {
+ border: 1px solid #3A393A;
+ background-color: #3A393A;
+ color: white;
+ cursor: pointer;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -khtml-border-radius: 5px;
+
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+}
+
+/* search field */
+form #q {
+ width: 136px;
+/* height: 22px; */
+ border: none;
+ margin: 0px;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -khtml-border-radius: 5px;
+ margin-top: 2px;
+ padding: 4px;
+ line-height: 22px
+}
+
+#search-results h2 {
+ display: none;
+}
+
+#search-results h2 {
+ display: none;
+}
+
+#search-results ul.search {
+ margin: 0px;
+ padding: 0px;
+}
+
+ul.search div.context {
+ padding-left: 40px;
+}
+
+#installation td {
+ text-align: center;
+ font-weight: bold;
+}
+
+em {
+ color: inherit;
+ font-style:italic;
+}
+
+/******** REL bar *********/
+
+.related {
+ display: inline;
+}
+
+.related ul {
+ padding: 0px 0px 0px 10px;
+ margin: 0px;
+ text-align: left;
+ background-image: url(relbar_bg.png);
+}
+
+.related li {
+ display: inline;
+ color: white;
+ font-weight: bold;
+}
+
+.related li a {
+ color: inherit;
+ line-height: 35px;
+ font-weight: bold;
+ vertical-align: middle;
+}
+
+.related li.right {
+ float: right;
+ margin-right: 5px;
+}
+
+.related h3 {
+ display: none;
+}
+
+.align-center {
+ text-align: center;
+}
+
+.contentstable {
+ width: 100%;
+}
+
+.contentstable td {
+ padding-left: 30px;
+ vertical-align: top;
+}
+
+p.biglink a {
+ font-size: 20px;
+}
+
+dt:target, .highlight {
+ background-color: #fbe54e;
+}
+
+img {
+ border: 0px;
+}
+
+.figure .caption {
+ font-style:italic;
+}
+
+table.footnote {
+ margin: 0px;
+}
+
+#synopsis table, table.field-list {
+ margin: 0px;
+}
+
+tt.descname {
+ font-size: 120%;
+ font-weight: bold;
+}
+
+#functions ul, #virtual-functions ul, #slots ul, #signals ul, #static-functions ul {
+ list-style: none;
+ margin: 0px;
+ padding: 10px;
+ border: 1px solid #ddd;
+ background-color: #f4f4f4;
+ -moz-border-radius:10px;
+ -webkit-border-radius:10px;
+ -khtml-border-radius:10px;
+}
+
+#synopsis span.pre {
+ color: #009491;
+ font-weight: bolder;
+}
+
+#detailed-description .class dt, #detailed-description .method dt, #detailed-description .attribute dt {
+ margin: 0px;
+ padding: 10px;
+ border: 1px solid #ddd;
+ background-color: #f4f4f4;
+ -moz-border-radius:10px;
+ -webkit-border-radius:10px;
+ -khtml-border-radius:10px;
+}
+
+.pysidetoc ul {
+ list-style: none;
+ padding: 0px;
+ margin: 0px;
+}
+
+.pysidetoc em {
+ font-style: normal;
+}
+
+.pysidetoc strong {
+ display: block;
+ padding: 5px;
+ border: 1px solid #ddd;
+ background-color: #f4f4f4;
+ -moz-border-radius:6px;
+ -webkit-border-radius:6px;
+ -khtml-border-radius:6px;
+}
+
+.hide {
+ display: none;
+}
+
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/pysidelogo.png b/sources/pyside2/doc/_themes/pysidedocs/static/pysidelogo.png
new file mode 100644
index 000000000..076c1057c
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/pysidelogo.png
Binary files differ
diff --git a/sources/pyside2/doc/_themes/pysidedocs/static/relbar_bg.png b/sources/pyside2/doc/_themes/pysidedocs/static/relbar_bg.png
new file mode 100644
index 000000000..4036733a7
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/static/relbar_bg.png
Binary files differ
diff --git a/sources/pyside2/doc/_themes/pysidedocs/theme.conf b/sources/pyside2/doc/_themes/pysidedocs/theme.conf
new file mode 100644
index 000000000..e0a652a5d
--- /dev/null
+++ b/sources/pyside2/doc/_themes/pysidedocs/theme.conf
@@ -0,0 +1,7 @@
+[theme]
+inherit = default
+stylesheet = pysidedocs.css
+pygments_style = none
+
+[options]
+nosidebar = false
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilityfactorysnippet.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilityfactorysnippet.cpp
new file mode 100644
index 000000000..1422a8076
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilityfactorysnippet.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+//! [0]
+QAccessibleInterface *sliderFactory(const QString &classname, QObject *object)
+{
+ QAccessibleInterface *interface = 0;
+
+ if (classname == "QSlider" && object && object->isWidgetType())
+ interface = new SliderInterface(classname,
+ static_cast<QWidget *>(object));
+
+ return interface;
+}
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+ QAccessible::installFactory(sliderFactory);
+//! [0]
+
+ QMainWindow mainWindow;
+ mainWindow.show();
+
+ return app.exec();
+//! [1]
+}
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilitypluginsnippet.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilitypluginsnippet.cpp
new file mode 100644
index 000000000..42d4692ba
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilitypluginsnippet.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+class SliderPlugin : public QAccessiblePlugin
+{
+public:
+ SliderPlugin() {}
+
+ QStringList keys() const;
+ QAccessibleInterface *create(const QString &classname, QObject *object);
+};
+
+//! [0]
+QStringList SliderPlugin::keys() const
+{
+ return QStringList() << "QSlider";
+}
+//! [0]
+
+//! [1]
+QAccessibleInterface *SliderPlugin::create(const QString &classname, QObject *object)
+{
+ QAccessibleInterface *interface = 0;
+
+ if (classname == "QSlider" && object && object->isWidgetType())
+ interface = new AccessibleSlider(classname, static_cast<QWidget *>(object));
+
+ return interface;
+}
+//! [1]
+
+//! [2]
+Q_EXPORT_STATIC_PLUGIN(SliderPlugin)
+Q_EXPORT_PLUGIN2(acc_sliderplugin, SliderPlugin)
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilityslidersnippet.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilityslidersnippet.cpp
new file mode 100644
index 000000000..3a6ec771c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/accessibilityslidersnippet.cpp
@@ -0,0 +1,271 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+QAccessibleSlider::QAccessibleSlider(QWidget *w)
+: QAccessibleAbstractSlider(w)
+{
+ Q_ASSERT(slider());
+ addControllingSignal(QLatin1String("valueChanged(int)"));
+}
+//! [0]
+
+QSlider *QAccessibleSlider::slider() const
+{
+ return qobject_cast<QSlider*>(object());
+}
+
+//! [1]
+QRect QAccessibleSlider::rect(int child) const
+{
+//! [1]
+ QRect rect;
+ if (!slider()->isVisible())
+ return rect;
+ const QStyleOptionSlider option = qt_qsliderStyleOption(slider());
+ QRect srect = slider()->style()->subControlRect(QStyle::CC_Slider, &option,
+ QStyle::SC_SliderHandle, slider());
+
+//! [2]
+ switch (child) {
+ case PageLeft:
+ if (slider()->orientation() == Qt::Vertical)
+ rect = QRect(0, 0, slider()->width(), srect.y());
+ else
+ rect = QRect(0, 0, srect.x(), slider()->height());
+ break;
+ case Position:
+ rect = srect;
+ break;
+ case PageRight:
+ if (slider()->orientation() == Qt::Vertical)
+ rect = QRect(0, srect.y() + srect.height(), slider()->width(), slider()->height()- srect.y() - srect.height());
+ else
+ rect = QRect(srect.x() + srect.width(), 0, slider()->width() - srect.x() - srect.width(), slider()->height());
+ break;
+ default:
+ return QAccessibleAbstractSlider::rect(child);
+ }
+//! [2] //! [3]
+
+ QPoint tp = slider()->mapToGlobal(QPoint(0,0));
+ return QRect(tp.x() + rect.x(), tp.y() + rect.y(), rect.width(), rect.height());
+}
+//! [3]
+
+int QAccessibleSlider::childCount() const
+{
+ if (!slider()->isVisible())
+ return 0;
+ return PageRight;
+}
+
+//! [4]
+QString QAccessibleSlider::text(Text t, int child) const
+{
+ if (!slider()->isVisible())
+ return QString();
+ switch (t) {
+ case Value:
+ if (!child || child == 2)
+ return QString::number(slider()->value());
+ return QString();
+ case Name:
+ switch (child) {
+ case PageLeft:
+ return slider()->orientation() == Qt::Horizontal ?
+ QSlider::tr("Page left") : QSlider::tr("Page up");
+ case Position:
+ return QSlider::tr("Position");
+ case PageRight:
+ return slider()->orientation() == Qt::Horizontal ?
+ QSlider::tr("Page right") : QSlider::tr("Page down");
+ }
+ break;
+ default:
+ break;
+ }
+ return QAccessibleAbstractSlider::text(t, child);
+}
+//! [4]
+
+//! [5]
+QAccessible::Role QAccessibleSlider::role(int child) const
+{
+ switch (child) {
+ case PageLeft:
+ case PageRight:
+ return PushButton;
+ case Position:
+ return Indicator;
+ default:
+ return Slider;
+ }
+}
+//! [5]
+
+//! [6]
+QAccessible::State QAccessibleSlider::state(int child) const
+{
+ const State parentState = QAccessibleAbstractSlider::state(0);
+//! [6]
+
+ if (child == 0)
+ return parentState;
+
+ // Inherit the Invisible state from parent.
+ State state = parentState & QAccessible::Invisible;
+
+ // Disable left/right if we are at the minimum/maximum.
+ const QSlider * const slider = QAccessibleSlider::slider();
+//! [7]
+ switch (child) {
+ case PageLeft:
+ if (slider->value() <= slider->minimum())
+ state |= Unavailable;
+ break;
+ case PageRight:
+ if (slider->value() >= slider->maximum())
+ state |= Unavailable;
+ break;
+ case Position:
+ default:
+ break;
+ }
+
+ return state;
+}
+//! [7]
+
+int QAccessibleSlider::defaultAction(int child) const
+{
+ switch (child) {
+ case SliderSelf:
+ return SetFocus;
+ case PageLeft:
+ return Press;
+ case PageRight:
+ return Press;
+ }
+
+ return 0;
+}
+
+// Name, Description, Value, Help, Accelerator
+static const char * const actionTexts[][5] =
+{
+ {"Press", "Decreases the value of the slider", "", "", "Ctrl+L"},
+ {"Press", "Increaces the value of the slider", "", "", "Ctrl+R"}
+};
+
+QString QAccessibleSlider::actionText(int action, Text text, int child) const
+{
+ if (action != Press || child < 1 || child > 2)
+ return QAccessibleAbstractSlider::actionText(action, text, child);
+
+ return actionTexts[child - 1][t];
+}
+
+bool QAccessibleSlider::doAction(int action, int child)
+{
+ if (action != Press || child < 1 || child > 2)
+ return false;
+
+ if (child == PageLeft)
+ slider()->setValue(slider()->value() - slider()->pageStep());
+ else
+ slider()->setValue(slider()->value() + slider()->pageStep());
+}
+
+QAccessibleAbstractSlider::QAccessibleAbstractSlider(QWidget *w, Role r)
+ : QAccessibleWidgetEx(w, r)
+{
+ Q_ASSERT(qobject_cast<QAbstractSlider *>(w));
+}
+
+QVariant QAccessibleAbstractSlider::invokeMethodEx(Method method, int child, const QVariantList &params)
+{
+ switch (method) {
+ case ListSupportedMethods: {
+ QSet<QAccessible::Method> set;
+ set << ListSupportedMethods;
+ return qVariantFromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
+ QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
+ }
+ default:
+ return QAccessibleWidgetEx::invokeMethodEx(method, child, params);
+ }
+}
+
+QVariant QAccessibleAbstractSlider::currentValue()
+{
+ return abstractSlider()->value();
+}
+
+void QAccessibleAbstractSlider::setCurrentValue(const QVariant &value)
+{
+ abstractSlider()->setValue(value.toInt());
+}
+
+QVariant QAccessibleAbstractSlider::maximumValue()
+{
+ return abstractSlider()->maximum();
+}
+
+QVariant QAccessibleAbstractSlider::minimumValue()
+{
+ return abstractSlider()->minimum();
+}
+
+QAbstractSlider *QAccessibleAbstractSlider::abstractSlider() const
+{
+ return static_cast<QAbstractSlider *>(object());
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/alphachannel.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/alphachannel.cpp
new file mode 100644
index 000000000..4606ce7b5
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/alphachannel.cpp
@@ -0,0 +1,64 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ pixmap = QPixmap(100, 100)
+ pixmap.fill(Qt.transparent)
+
+ gradient = QRadialGradient(50, 50, 50, 50, 50)
+ gradient.setColorAt(0, QColor.fromRgbF(1, 0, 0, 1))
+ gradient.setColorAt(1, QColor.fromRgbF(0, 0, 0, 0))
+ painter = QPainter(pixmap)
+ painter.fillRect(0, 0, 100, 100, gradient)
+
+ channelImage = pixmap.alphaChannel()
+ update()
+//! [0]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/audio/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/audio/main.cpp
new file mode 100644
index 000000000..796f9b2df
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/audio/main.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+class Window2 (QWidget):
+//![0]
+ @Slot(QAudio.State)
+ def stateChanged(self, newState):
+ if newState == QAudio.StopState:
+ if self.input.error() != QAudio.NoError:
+ # Error handling
+//![0]
+
+class Window (QWidget):
+ def __init__(self):
+ QWidget.__init__(self)
+ self.output = QAudioOutput()
+ self.output.stateChanged[QAudio.State].connect(self.stateChanged)
+
+ def setupFormat(self):
+//![1]
+ format = QAudioFormat()
+ format.setFrequency(44100)
+//![1]
+ format.setChannels(2)
+ format.setSampleSize(16)
+ format.setCodec("audio/pcm")
+ format.setByteOrder(QAudioFormat.LittleEndian)
+//![2]
+ format.setSampleType(QAudioFormat.SignedInt)
+
+ info = QAudioDeviceInfo(QAudioDeviceInfo.defaultOutputDevice())
+
+ if not info.isFormatSupported(format):
+ format = info.nearestFormat(format)
+//![2]
+
+//![3]
+ @Slot(QAudio.State)
+ def stateChanged(self, newState):
+ if newState == QAudio.StopState:
+ if self.output.error() != QAudio.NoError:
+ # Perform error handling
+ else:
+ # Normal stop
+//![3]
+
+ # Handle
+ elif newState == QAudio.ActiveState:
+ # Handle active state...
+
+app = QApplication(sys.argv)
+
+window = Window()
+window.show()
+sys.exit(app.exec_())
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/brush/brush.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/brush/brush.cpp
new file mode 100644
index 000000000..9ea023f24
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/brush/brush.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+int main()
+{
+ QWidget anyPaintDevice;
+ {
+ // PEN SNIPPET
+ QPainter painter;
+ QPen pen(Qt::red, 2); // red solid line, 2 pixels wide
+ painter.begin(&anyPaintDevice); // paint something
+ painter.setPen(pen); // set the red, wide pen
+ painter.drawRect(40,30, 200,100); // draw a rectangle
+ painter.setPen(Qt::blue); // set blue pen, 0 pixel width
+ painter.drawLine(40,30, 240,130); // draw a diagonal in rectangle
+ painter.end(); // painting done
+ }
+
+ {
+ // BRUSH SNIPPET
+ QPainter painter;
+ QBrush brush(Qt::yellow); // yellow solid pattern
+ painter.begin(&anyPaintDevice); // paint something
+ painter.setBrush(brush); // set the yellow brush
+ painter.setPen(Qt::NoPen); // do not draw outline
+ painter.drawRect(40,30, 200,100); // draw filled rectangle
+ painter.setBrush(Qt::NoBrush); // do not fill
+ painter.setPen(Qt::black); // set black pen, 0 pixel width
+ painter.drawRect(10,10, 30,20); // draw rectangle outline
+ painter.end(); // painting done
+ }
+
+ // LINEAR
+//! [0]
+ linearGrad = QLinearGradient(QPointF(100, 100), QPointF(200, 200))
+ linearGrad.setColorAt(0, Qt.black)
+ linearGrad.setColorAt(1, Qt.white)
+//! [0]
+
+ // RADIAL
+//! [1]
+ radialGrad = QRadialGradient(QPointF(100, 100), 100)
+ radialGrad.setColorAt(0, Qt.red)
+ radialGrad.setColorAt(0.5, Qt.blue)
+ radialGrad.setColorAt(1, Qt.green)
+//! [1]
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/brush/gradientcreationsnippet.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/brush/gradientcreationsnippet.cpp
new file mode 100644
index 000000000..e24a0679b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/brush/gradientcreationsnippet.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+//! [0]
+ gradient = QRadialGradient gradient(50, 50, 50, 50, 50)
+ gradient.setColorAt(0, QColor.fromRgbF(0, 1, 0, 1))
+ gradient.setColorAt(1, QColor.fromRgbF(0, 0, 0, 0))
+
+ brush = QBrush(gradient)
+//! [0]
+
+ QWidget widget;
+ QPalette palette;
+ palette.setBrush(widget.backgroundRole(), brush);
+ widget.setPalette(palette);
+ widget.show();
+
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/main.cpp
new file mode 100644
index 000000000..c50eda786
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "stylewidget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ StyleWidget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/qt-logo.png b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/qt-logo.png
new file mode 100644
index 000000000..d609c1e1e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/qt-logo.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.cpp
new file mode 100644
index 000000000..cd50455ce
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "renderarea.h"
+
+RenderArea::RenderArea(QBrush *brush, QWidget *parent)
+ : QWidget(parent)
+{
+ currentBrush = brush;
+}
+
+QSize RenderArea::minimumSizeHint() const
+{
+ return QSize(120, 60);
+}
+
+void RenderArea::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ painter.setPen(Qt::NoPen);
+ painter.setRenderHint(QPainter::Antialiasing);
+
+
+ if(currentBrush->style() == Qt::LinearGradientPattern) {
+ currentBrush = new QBrush(QLinearGradient(0, 0, width(), 60));
+ } else if(currentBrush->style() == Qt::RadialGradientPattern) {
+ QRadialGradient radial(width() / 2, 30, width() / 2, width() / 2, 30);
+ radial.setColorAt(0, Qt::white);
+ radial.setColorAt(1, Qt::black);
+ currentBrush = new QBrush(radial);
+ } else if(currentBrush->style() == Qt::ConicalGradientPattern) {
+ currentBrush = new QBrush(QConicalGradient(width() / 2, 30, 90));
+ }
+ painter.setBrush(*currentBrush);
+
+ QPainterPath path;
+ path.addRect(0, 0, parentWidget()->width(), 60);
+ painter.drawPath(path);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.h
new file mode 100644
index 000000000..b4bedefe6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/renderarea.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef RENDERAREA_H
+#define RENDERAREA_H
+
+#include <QWidget>
+
+class RenderArea : public QWidget
+{
+ Q_OBJECT
+
+public:
+ RenderArea(QBrush *brush, QWidget *parent = 0);
+ QSize minimumSizeHint() const;
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private:
+ QBrush *currentBrush;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.cpp
new file mode 100644
index 000000000..448598bf3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.cpp
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "stylewidget.h"
+
+StyleWidget::StyleWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ solid = new RenderArea(new QBrush(Qt::SolidPattern));
+ dense1 = new RenderArea(new QBrush(Qt::Dense1Pattern));
+ dense2 = new RenderArea(new QBrush(Qt::Dense2Pattern));
+ dense3 = new RenderArea(new QBrush(Qt::Dense3Pattern));
+ dense4 = new RenderArea(new QBrush(Qt::Dense4Pattern));
+ dense5 = new RenderArea(new QBrush(Qt::Dense5Pattern));
+ dense6 = new RenderArea(new QBrush(Qt::Dense6Pattern));
+ dense7 = new RenderArea(new QBrush(Qt::Dense7Pattern));
+ no = new RenderArea(new QBrush(Qt::NoBrush));
+ hor = new RenderArea(new QBrush(Qt::HorPattern));
+ ver = new RenderArea(new QBrush(Qt::VerPattern));
+ cross = new RenderArea(new QBrush(Qt::CrossPattern));
+ bdiag = new RenderArea(new QBrush(Qt::BDiagPattern));
+ fdiag = new RenderArea(new QBrush(Qt::FDiagPattern));
+ diagCross = new RenderArea(new QBrush(Qt::DiagCrossPattern));
+ linear = new RenderArea(new QBrush(QLinearGradient()));
+ radial = new RenderArea(new QBrush(QRadialGradient()));
+ conical = new RenderArea(new QBrush(QConicalGradient()));
+ texture = new RenderArea(new QBrush(QPixmap("qt-logo.png")));
+
+ solidLabel = new QLabel("Qt::SolidPattern");
+ dense1Label = new QLabel("Qt::Dense1Pattern");
+ dense2Label = new QLabel("Qt::Dense2Pattern");
+ dense3Label = new QLabel("Qt::Dense3Pattern");
+ dense4Label = new QLabel("Qt::Dense4Pattern");
+ dense5Label = new QLabel("Qt::Dense5Pattern");
+ dense6Label = new QLabel("Qt::Dense6Pattern");
+ dense7Label = new QLabel("Qt::Dense7Pattern");
+ noLabel = new QLabel("Qt::NoPattern");
+ horLabel = new QLabel("Qt::HorPattern");
+ verLabel = new QLabel("Qt::VerPattern");
+ crossLabel = new QLabel("Qt::CrossPattern");
+ bdiagLabel = new QLabel("Qt::BDiagPattern");
+ fdiagLabel = new QLabel("Qt::FDiagPattern");
+ diagCrossLabel = new QLabel("Qt::DiagCrossPattern");
+ linearLabel = new QLabel("Qt::LinearGradientPattern");
+ radialLabel = new QLabel("Qt::RadialGradientPattern");
+ conicalLabel = new QLabel("Qt::ConicalGradientPattern");
+ textureLabel = new QLabel("Qt::TexturePattern");
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(solid, 0, 0);
+ layout->addWidget(dense1, 0, 1);
+ layout->addWidget(dense2, 0, 2);
+ layout->addWidget(solidLabel, 1, 0);
+ layout->addWidget(dense1Label, 1, 1);
+ layout->addWidget(dense2Label, 1, 2);
+
+ layout->addWidget(dense3, 2, 0 );
+ layout->addWidget(dense4, 2, 1);
+ layout->addWidget(dense5, 2, 2);
+ layout->addWidget(dense3Label, 3, 0);
+ layout->addWidget(dense4Label, 3, 1);
+ layout->addWidget(dense5Label, 3, 2);
+
+ layout->addWidget(dense6, 4, 0);
+ layout->addWidget(dense7, 4, 1);
+ layout->addWidget(no, 4, 2);
+ layout->addWidget(dense6Label, 5, 0);
+ layout->addWidget(dense7Label, 5, 1);
+ layout->addWidget(noLabel, 5, 2);
+
+ layout->addWidget(hor, 6, 0);
+ layout->addWidget(ver, 6, 1);
+ layout->addWidget(cross, 6, 2);
+ layout->addWidget(horLabel, 7, 0);
+ layout->addWidget(verLabel, 7, 1);
+ layout->addWidget(crossLabel, 7, 2);
+
+ layout->addWidget(bdiag, 8, 0);
+ layout->addWidget(fdiag, 8, 1);
+ layout->addWidget(diagCross, 8, 2);
+ layout->addWidget(bdiagLabel, 9, 0);
+ layout->addWidget(fdiagLabel, 9, 1);
+ layout->addWidget(diagCrossLabel, 9, 2);
+
+ layout->addWidget(linear, 10, 0);
+ layout->addWidget(radial, 10, 1);
+ layout->addWidget(conical, 10, 2);
+ layout->addWidget(linearLabel, 11, 0);
+ layout->addWidget(radialLabel, 11, 1);
+ layout->addWidget(conicalLabel, 11, 2);
+
+ layout->addWidget(texture, 12, 0, 1, 3);
+ layout->addWidget(textureLabel, 13, 0, 1, 3);
+
+ setLayout(layout);
+
+ QPalette newPalette = palette();
+ newPalette.setColor(QPalette::Window, Qt::white);
+ setPalette(newPalette);
+
+ setWindowTitle(tr("Brush Styles"));
+ resize(430, 605);
+}
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.h
new file mode 100644
index 000000000..bc05bba21
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/brushstyles/stylewidget.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef STYLEWIDGET_H
+#define STYLEWIDGET_H
+
+#include <QWidget>
+#include <QPainterPath>
+#include "renderarea.h"
+
+class QLabel;
+
+class StyleWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ StyleWidget(QWidget *parent = 0);
+
+private:
+ RenderArea *solid;
+ RenderArea *dense1;
+ RenderArea *dense2;
+ RenderArea *dense3;
+ RenderArea *dense4;
+ RenderArea *dense5;
+ RenderArea *dense6;
+ RenderArea *dense7;
+ RenderArea *no;
+ RenderArea *hor;
+ RenderArea *ver;
+ RenderArea *cross;
+ RenderArea *bdiag;
+ RenderArea *fdiag;
+ RenderArea *diagCross;
+ RenderArea *linear;
+ RenderArea *radial;
+ RenderArea *conical;
+ RenderArea *texture;
+
+ QLabel *solidLabel;
+ QLabel *dense1Label;
+ QLabel *dense2Label;
+ QLabel *dense3Label;
+ QLabel *dense4Label;
+ QLabel *dense5Label;
+ QLabel *dense6Label;
+ QLabel *dense7Label;
+ QLabel *noLabel;
+ QLabel *horLabel;
+ QLabel *verLabel;
+ QLabel *crossLabel;
+ QLabel *bdiagLabel;
+ QLabel *fdiagLabel;
+ QLabel *diagCrossLabel;
+ QLabel *linearLabel;
+ QLabel *radialLabel;
+ QLabel *conicalLabel;
+ QLabel *textureLabel;
+};
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/buffer/buffer.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/buffer/buffer.cpp
new file mode 100644
index 000000000..dfa4af26d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/buffer/buffer.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QBuffer>
+#include <QPalette>
+
+static void main_snippet()
+{
+//! [0]
+ buffer = QBuffer()
+
+ buffer.open(QBuffer.ReadWrite)
+ buffer.write("Qt rocks!")
+ buffer.seek(0)
+ ch = buffer.getChar() # ch == 'Q'
+ ch = buffer.getChar() # ch == 't'
+ ch = buffer.getChar() # ch == ' '
+ ch = buffer.getChar() # ch == 'r'
+//! [0]
+}
+
+static void write_datastream_snippets()
+{
+//! [1]
+ byteArray = QByteArray()
+ buffer = QBuffer(byteArray)
+ buffer.open(QIODevice.WriteOnly)
+
+ out = QDataStream(buffer)
+ out << QApplication.palette()
+//! [1]
+}
+
+static void read_datastream_snippets()
+{
+ QByteArray byteArray;
+
+//! [2]
+ palette = QPalette()
+ buffer = QBuffer(byteArray)
+ buffer.open(QIODevice.ReadOnly)
+
+ in = QDataStream(buffer)
+ in >> palette
+//! [2]
+}
+
+static void bytearray_ptr_ctor_snippet()
+{
+//! [3]
+ byteArray = QByteArray("abc")
+ buffer = QBuffer(byteArray)
+ buffer.open(QIODevice.WriteOnly)
+ buffer.seek(3)
+ buffer.write("def")
+ buffer.close()
+ # byteArray == "abcdef"
+//! [3]
+}
+
+static void setBuffer_snippet()
+{
+//! [4]
+ byteArray = QByteArray("abc")
+ buffer = QBuffer()
+ buffer.setBuffer(byteArray)
+ buffer.open(QIODevice.WriteOnly)
+ buffer.seek(3)
+ buffer.write("def")
+ buffer.close()
+ # byteArray == "abcdef"
+//! [4]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ main_snippet();
+ bytearray_ptr_ctor_snippet();
+ write_datastream_snippets();
+ read_datastream_snippets();
+ setBuffer_snippet();
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.cpp
new file mode 100644
index 000000000..42ff004ac
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.cpp
@@ -0,0 +1,106 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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$
+##
+############################################################################
+
+form PySide2.QtGui import *
+
+
+def __init__(self, parent):
+ QMainWindow.__init__(self, parent)
+ clipboard = QApplication.clipboard()
+
+ centralWidget = QWidget(self)
+ currentItem = QWidget(centralWidget)
+ mimeTypeLabel = QLabel(tr("MIME types:"), currentItem)
+ mimeTypeCombo = QComboBox(currentItem)
+ dataLabel = QLabel(tr("Data:"), currentItem)
+ dataInfoLabel = QLabel("", currentItem)
+
+ previousItems = QListWidget(centralWidget)
+
+//! [0]
+ connect(clipboard, SIGNAL("dataChanged()"), self, SLOT("updateClipboard()"))
+//! [0]
+ connect(mimeTypeCombo, SIGNAL("activated(const QString &)"),
+ self, SLOT("updateData(const QString &))")
+
+ currentLayout = QVBoxLayout(currentItem)
+ currentLayout.addWidget(mimeTypeLabel)
+ currentLayout.addWidget(mimeTypeCombo)
+ currentLayout.addWidget(dataLabel)
+ currentLayout.addWidget(dataInfoLabel)
+ currentLayout.addStretch(1)
+
+ mainLayout = QHBoxLayout(centralWidget)
+ mainLayout.addWidget(currentItem, 1)
+ mainLayout.addWidget(previousItems)
+
+ setCentralWidget(centralWidget)
+ setWindowTitle(tr("Clipboard"))
+
+//! [1]
+def updateClipboard(self):
+ formats = clipboard.mimeData().formats()
+ data = clipboard.mimeData().data(format)
+//! [1]
+
+ mimeTypeCombo.clear()
+ mimeTypeCombo.insertStringList(formats)
+
+ size = clipboard.mimeData().data(formats[0]).size()
+ Item = QListWidgetItem(previousItems)
+ Item.setText(tr("%1 (%2 bytes)").arg(formats[0]).arg(size))
+
+ updateData(formats[0])
+//! [2]
+//! [2]
+
+def updateData(self, format)
+ data = clipboard.mimeData().data(format)
+ dataInfoLabel.setText(tr("%1 bytes").arg(data.size()))
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.h
new file mode 100644
index 000000000..8543bae80
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/clipwindow.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef CLIPWINDOW_H
+#define CLIPWINDOW_H
+
+#include <QMainWindow>
+
+class QClipboard;
+class QComboBox;
+class QLabel;
+class QListWidget;
+class QMimeData;
+class QWidget;
+
+class ClipWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ ClipWindow(QWidget *parent = 0);
+
+public slots:
+ void updateClipboard();
+ void updateData(const QString &format);
+
+private:
+ int currentItem;
+ QClipboard *clipboard;
+ QComboBox *mimeTypeCombo;
+ QLabel *dataInfoLabel;
+ QListWidget *previousItems;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/main.cpp
new file mode 100644
index 000000000..7aef200bb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/clipboard/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "clipwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ClipWindow *window = new ClipWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/doc_src_qnamespace.qdoc b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/doc_src_qnamespace.qdoc
new file mode 100644
index 000000000..5a9a2f49d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/doc_src_qnamespace.qdoc
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QObject::connect: Cannot queue arguments of type 'MyType'
+//! [0]
+
+
+//! [1]
+# An important event
+ImportantEventPriority = Qt.HighEventPriority
+# A more important event
+MoreImportantEventPriority = ImportantEventPriority + 1
+# A critical event
+CriticalEventPriority = 100 * MoreImportantEventPriority
+# Not that important
+StatusEventPriority = Qt.LowEventPriority
+# These are less important than Status events
+IdleProcessingDoneEventPriority = StatusEventPriority - 1
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp
new file mode 100644
index 000000000..19de66485
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.gui.text.qtextdocumentwriter.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ writer = QTextDocumentWriter()
+ writer.setFormat("odf") # same as writer.setFormat("ODF");
+//! [0]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp
new file mode 100644
index 000000000..f9f12b147
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QDBusPendingCall async = iface->asyncCall("RemoteMethod", value1, value2);
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
+
+ QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));
+//! [0]
+
+}
+
+//! [1]
+void MyClass::callFinishedSlot(QDBusPendingCallWatcher *call)
+{
+ QDBusPendingReply<QString, QByteArray> reply = *call;
+ if (reply.isError()) {
+ showError();
+ } else {
+ QString text = reply.argumentAt<0>();
+ QByteArray data = reply.argumentAt<1>();
+ showReply(text, data);
+ }
+}
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp
new file mode 100644
index 000000000..39afcc8f5
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.qdbus.qdbuspendingreply.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QDBusPendingReply<QString> reply = interface->asyncCall("RemoteMethod");
+ reply.waitForFinished();
+ if (reply.isError())
+ // call failed. Show an error condition.
+ showError(reply.error());
+ else
+ // use the returned value
+ useValue(reply.value());
+//! [0]
+
+//! [2]
+ QDBusPendingReply<bool, QString> reply = interface->asyncCall("RemoteMethod");
+ reply.waitForFinished();
+ if (!reply.isError()) {
+ if (reply.argumentAt<0>())
+ showSuccess(reply.argumentAt<1>());
+ else
+ showFailure(reply.argumentAt<1>());
+ }
+//! [2]
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.scripttools.qscriptenginedebugger.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.scripttools.qscriptenginedebugger.cpp
new file mode 100644
index 000000000..2971f244b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src.scripttools.qscriptenginedebugger.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ engine = QScriptEngine()
+ debugger = QScriptEngineDebugger()
+ debugger.attachTo(engine)
+//! [0]
+
+//! [1]
+ engine.evaluate("debugger")
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp
new file mode 100644
index 000000000..cf6bc2894
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+encodedString = QByteArray("...")
+codec = QTextCodec.codecForName("KOI8-R")
+string = codec.toUnicode(encodedString)
+//! [0]
+
+
+//! [1]
+string = u"..."
+codec = QTextCodec.codecForName("KOI8-R")
+encodedString = codec.fromUnicode(string)
+//! [1]
+
+
+//! [2]
+codec = QTextCodec.codecForName("Shift-JIS")
+decoder = codec.makeDecoder()
+
+string = u''
+while new_data_available():
+ chunk = get_new_data()
+ string += decoder.toUnicode(chunk)
+
+//! [2]
+
+
+//! [3]
+def main():
+ app = QApplication([])
+ QTextCodec.setCodecForTr(QTextCodec.codecForName("eucKR"))
+ ...
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp
new file mode 100644
index 000000000..ce3f07148
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+
+def names(self):
+ return list = ["IBM01140", "hp15-tw"]
+
+def createForName(name):
+ if (name == "IBM01140"):
+ return Ibm01140Codec()
+ else if (name == "hp15-tw"):
+ return Hp15TwCodec()
+ return None
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp
new file mode 100644
index 000000000..72f998f43
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QFuture<QString> future = ...;
+
+QFuture<QString>::const_iterator i;
+for (i = future.constBegin(); i != future.constEnd(); ++i)
+ cout << *i << endl;
+//! [0]
+
+
+//! [1]
+QFuture<QString> future;
+...
+QFutureIterator<QString> i(future);
+while (i.hasNext())
+ qDebug() << i.next();
+//! [1]
+
+
+//! [2]
+QFutureIterator<QString> i(future);
+i.toBack();
+while (i.hasPrevious())
+ qDebug() << i.previous();
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp
new file mode 100644
index 000000000..7bcf8437f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+void someFunction()
+{
+ QFutureSynchronizer<void> synchronizer;
+
+ ...
+
+ synchronizer.addFuture(QtConcurrent::run(anotherFunction));
+ synchronizer.addFuture(QtConcurrent::map(list, mapFunction));
+
+ return; // QFutureSynchronizer waits for all futures to finish
+}
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp
new file mode 100644
index 000000000..c18c98a71
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+// Instantiate the objects and connect to the finished signal.
+MyClass myObject;
+QFutureWatcher<int> watcher;
+connect(&watcher, SIGNAL(finished()), &myObject, SLOT(handleFinished()));
+
+// Start the computation.
+QFuture<int> future = QtConcurrent::run(...);
+watcher.setFuture(future);
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp
new file mode 100644
index 000000000..e813afd58
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 MyException : public QtConcurrent::Exception
+{
+public:
+ void raise() const { throw *this; }
+ Exception *clone() const { return new MyException(*this); }
+};
+
+//! [0]
+
+
+//! [1]
+
+try {
+ QtConcurrent::blockingMap(list, throwFunction); // throwFunction throws MyException
+} catch (MyException &e) {
+ // handle exception
+}
+
+//! [1]
+
+
+//! [2]
+
+void MyException::raise() const { throw *this; }
+
+//! [2]
+
+
+//! [3]
+
+MyException *MyException::clone() const { return new MyException(*this); }
+
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp
new file mode 100644
index 000000000..fbfe131ee
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp
@@ -0,0 +1,181 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+bool function(const T &t);
+//! [0]
+
+
+//! [1]
+bool allLowerCase(const QString &string)
+{
+ return string.lowered() == string;
+}
+
+QStringList strings = ...;
+QFuture<QString> lowerCaseStrings = QtConcurrent::filtered(strings, allLowerCase);
+//! [1]
+
+
+//! [2]
+QStringList strings = ...;
+QFuture<void> future = QtConcurrent::filter(strings, allLowerCase);
+//! [2]
+
+
+//! [3]
+V function(T &result, const U &intermediate)
+//! [3]
+
+
+//! [4]
+void addToDictionary(QSet<QString> &dictionary, const QString &string)
+{
+ dictionary.insert(string);
+}
+
+QStringList strings = ...;
+QFuture<QSet<QString> > dictionary = QtConcurrent::filteredReduced(strings, allLowerCase, addToDictionary);
+//! [4]
+
+
+//! [5]
+QStringList strings = ...;
+QFuture<QString> lowerCaseStrings = QtConcurrent::filtered(strings.constBegin(), strings.constEnd(), allLowerCase);
+
+// filter in-place only works on non-const iterators
+QFuture<void> future = QtConcurrent::filter(strings.begin(), strings.end(), allLowerCase);
+
+QFuture<QSet<QString> > dictionary = QtConcurrent::filteredReduced(strings.constBegin(), strings.constEnd(), allLowerCase, addToDictionary);
+//! [5]
+
+
+//! [6]
+QStringList strings = ...;
+
+// each call blocks until the entire operation is finished
+QStringList lowerCaseStrings = QtConcurrent::blockingFiltered(strings, allLowerCase);
+
+
+QtConcurrent::blockingFilter(strings, allLowerCase);
+
+QSet<QString> dictionary = QtConcurrent::blockingFilteredReduced(strings, allLowerCase, addToDictionary);
+//! [6]
+
+
+//! [7]
+// keep only images with an alpha channel
+QList<QImage> images = ...;
+QFuture<void> alphaImages = QtConcurrent::filter(strings, &QImage::hasAlphaChannel);
+
+// keep only gray scale images
+QList<QImage> images = ...;
+QFuture<QImage> grayscaleImages = QtConcurrent::filtered(images, &QImage::isGrayscale);
+
+// create a set of all printable characters
+QList<QChar> characters = ...;
+QFuture<QSet<QChar> > set = QtConcurrent::filteredReduced(characters, &QChar::isPrint, &QSet<QChar>::insert);
+//! [7]
+
+
+//! [8]
+// can mix normal functions and member functions with QtConcurrent::filteredReduced()
+
+// create a dictionary of all lower cased strings
+extern bool allLowerCase(const QString &string);
+QStringList strings = ...;
+QFuture<QSet<int> > averageWordLength = QtConcurrent::filteredReduced(strings, allLowerCase, QSet<QString>::insert);
+
+// create a collage of all gray scale images
+extern void addToCollage(QImage &collage, const QImage &grayscaleImage);
+QList<QImage> images = ...;
+QFuture<QImage> collage = QtConcurrent::filteredReduced(images, &QImage::isGrayscale, addToCollage);
+//! [8]
+
+
+//! [9]
+bool QString::contains(const QRegExp &regexp) const;
+//! [9]
+
+
+//! [10]
+boost::bind(&QString::contains, QRegExp("^\\S+$")); // matches strings without whitespace
+//! [10]
+
+
+//! [11]
+bool contains(const QString &string)
+//! [11]
+
+
+//! [12]
+QStringList strings = ...;
+boost::bind(static_cast<bool(QString::*)(const QRegExp&)>( &QString::contains ), QRegExp("..." ));
+//! [12]
+
+//! [13]
+struct StartsWith
+{
+ StartsWith(const QString &string)
+ : m_string(string) { }
+
+ typedef bool result_type;
+
+ bool operator()(const QString &testString)
+ {
+ return testString.startsWith(m_string);
+ }
+
+ QString m_string;
+};
+
+QList<QString> strings = ...;
+QFuture<QString> fooString = QtConcurrent::filtered(images, StartsWith(QLatin1String("Foo")));
+//! [13]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp
new file mode 100644
index 000000000..c422d5a9a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp
@@ -0,0 +1,194 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+U function(const T &t);
+//! [0]
+
+
+//! [1]
+QImage scaled(const QImage &image)
+{
+ return image.scaled(100, 100);
+}
+
+QList<QImage> images = ...;
+QFuture<QImage> thumbnails = QtConcurrent::mapped(images, scaled);
+//! [1]
+
+
+//! [2]
+U function(T &t);
+//! [2]
+
+
+//! [3]
+void scale(QImage &image)
+{
+ image = image.scaled(100, 100);
+}
+
+QList<QImage> images = ...;
+QFuture<void> future = QtConcurrent::map(images, scale);
+//! [3]
+
+
+//! [4]
+V function(T &result, const U &intermediate)
+//! [4]
+
+
+//! [5]
+void addToCollage(QImage &collage, const QImage &thumbnail)
+{
+ QPainter p(&collage);
+ static QPoint offset = QPoint(0, 0);
+ p.drawImage(offset, thumbnail);
+ offset += ...;
+}
+
+QList<QImage> images = ...;
+QFuture<QImage> collage = QtConcurrent::mappedReduced(images, scaled, addToCollage);
+//! [5]
+
+
+//! [6]
+QList<QImage> images = ...;
+
+QFuture<QImage> thumbnails = QtConcurrent::mapped(images.constBegin(), images.constEnd(), scaled);
+
+// map in-place only works on non-const iterators
+QFuture<void> future = QtConcurrent::map(images.begin(), images.end(), scale);
+
+QFuture<QImage> collage = QtConcurrent::mappedReduced(images.constBegin(), images.constEnd(), scaled, addToCollage);
+//! [6]
+
+
+//! [7]
+QList<QImage> images = ...;
+
+// each call blocks until the entire operation is finished
+QList<QImage> future = QtConcurrent::blockingMapped(images, scaled);
+
+QtConcurrent::blockingMap(images, scale);
+
+QImage collage = QtConcurrent::blockingMappedReduced(images, scaled, addToCollage);
+//! [7]
+
+
+//! [8]
+// squeeze all strings in a QStringList
+QStringList strings = ...;
+QFuture<void> squeezedStrings = QtConcurrent::map(strings, &QString::squeeze);
+
+// swap the rgb values of all pixels on a list of images
+QList<QImage> images = ...;
+QFuture<QImage> bgrImages = QtConcurrent::mapped(images, &QImage::rgbSwapped);
+
+// create a set of the lengths of all strings in a list
+QStringList strings = ...;
+QFuture<QSet<int> > wordLengths = QtConcurrent::mappedReduced(string, &QString::length, &QSet<int>::insert);
+//! [8]
+
+
+//! [9]
+// can mix normal functions and member functions with QtConcurrent::mappedReduced()
+
+// compute the average length of a list of strings
+extern void computeAverage(int &average, int length);
+QStringList strings = ...;
+QFuture<int> averageWordLength = QtConcurrent::mappedReduced(strings, &QString::length, computeAverage);
+
+// create a set of the color distribution of all images in a list
+extern int colorDistribution(const QImage &string);
+QList<QImage> images = ...;
+QFuture<QSet<int> > totalColorDistribution = QtConcurrent::mappedReduced(images, colorDistribution, QSet<int>::insert);
+//! [9]
+
+
+//! [10]
+QImage QImage::scaledToWidth(int width, Qt::TransformationMode) const;
+//! [10]
+
+
+//! [11]
+boost::bind(&QImage::scaledToWidth, 100, Qt::SmoothTransformation)
+//! [11]
+
+
+//! [12]
+QImage scaledToWith(const QImage &image)
+//! [12]
+
+
+//! [13]
+QList<QImage> images = ...;
+QFuture<QImage> thumbnails = QtConcurrent::mapped(images, boost::bind(&QImage::scaledToWidth, 100 Qt::SmoothTransformation));
+//! [13]
+
+//! [14]
+struct Scaled
+{
+ Scaled(int size)
+ : m_size(size) { }
+
+ typedef QImage result_type;
+
+ QImage operator()(const QImage &image)
+ {
+ return image.scaled(m_size, m_size);
+ }
+
+ int m_size;
+};
+
+QList<QImage> images = ...;
+QFuture<QImage> thumbnails = QtConcurrent::mapped(images, Scaled(100));
+//! [14]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp
new file mode 100644
index 000000000..5dcc8c991
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+extern void aFunction();
+QFuture<void> future = QtConcurrent::run(aFunction);
+//! [0]
+
+
+//! [1]
+extern void aFunctionWithArguments(int arg1, double arg2, const QString &string);
+
+int integer = ...;
+double floatingPoint = ...;
+QString string = ...;
+
+QFuture<void> future = QtConcurrent::run(aFunctionWithArguments, integer, floatingPoint, string);
+//! [1]
+
+
+//! [2]
+extern QString functionReturningAString();
+QFuture<QString> future = QtConcurrent::run(functionReturningAString);
+...
+QString result = future.result();
+//! [2]
+
+
+//! [3]
+extern QString someFunction(const QByteArray &input);
+
+QByteArray bytearray = ...;
+
+QFuture<QString> future = QtConcurrent::run(someFunction, bytearray);
+...
+QString result = future.result();
+//! [3]
+
+
+//! [4]
+// call 'QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const' in a separate thread
+QString string = ...;
+QFuture<QStringList> future = QtConcurrent::run(string, &QString::split, QString(", "), QString::KeepEmptyParts, Qt::CaseSensitive);
+...
+QStringList result = future.result();
+//! [4]
+
+
+//! [5]
+// call 'void QImage::invertPixels(InvertMode mode)' in a separate thread
+QImage image = ...;
+QFuture<void> future = QtConcurrent::run(image, &QImage::invertPixels, QImage::InvertRgba);
+...
+future.waitForFinished();
+// At this point, the pixels in 'image' have been inverted
+//! [5]
+
+
+//! [6]
+void someFunction(int arg1, double arg2);
+QFuture<void> future = QtConcurrent::run(boost::bind(someFunction, 1, 2.0));
+...
+//! [6]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp
new file mode 100644
index 000000000..73b713536
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_concurrent_qthreadpool.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 HelloWorldTask(QRunnable):
+ def run(self):
+ print "Hello world from thread", QThread.currentThread()
+
+hello = HelloWorldTask()
+# QThreadPool takes ownership and deletes 'hello' automatically
+QThreadPool.globalInstance().start(hello)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_global_qglobal.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_global_qglobal.cpp
new file mode 100644
index 000000000..6b39702ac
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_global_qglobal.cpp
@@ -0,0 +1,514 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+label.setAlignment(Qt.AlignLeft | Qt.AlignTop)
+//! [0]
+
+
+//! [1]
+class MyClass
+{
+public:
+ enum Option {
+ NoOptions = 0x0,
+ ShowTabs = 0x1,
+ ShowAll = 0x2,
+ SqueezeBlank = 0x4
+ };
+ Q_DECLARE_FLAGS(Options, Option)
+ ...
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(MyClass::Options)
+//! [1]
+
+//! [meta-object flags]
+Q_FLAGS(Options)
+//! [meta-object flags]
+
+//! [2]
+typedef QFlags<Enum> Flags;
+//! [2]
+
+
+//! [3]
+int myValue = 10;
+int minValue = 2;
+int maxValue = 6;
+
+int boundedValue = qBound(minValue, myValue, maxValue);
+// boundedValue == 6
+//! [3]
+
+
+//! [4]
+if (!driver()->isOpen() || driver()->isOpenError()) {
+ qWarning("QSqlQuery::exec: database not open");
+ return false;
+}
+//! [4]
+
+
+//! [5]
+qint64 value = Q_INT64_C(932838457459459);
+//! [5]
+
+
+//! [6]
+quint64 value = Q_UINT64_C(932838457459459);
+//! [6]
+
+
+//! [7]
+void myMsgHandler(QtMsgType, const char *);
+//! [7]
+
+
+//! [8]
+qint64 value = Q_INT64_C(932838457459459);
+//! [8]
+
+
+//! [9]
+quint64 value = Q_UINT64_C(932838457459459);
+//! [9]
+
+
+//! [10]
+myValue = -4
+absoluteValue = qAbs(myValue)
+// absoluteValue == 4
+//! [10]
+
+
+//! [11]
+valueA = 2.3
+valueB = 2.7
+
+roundedValueA = qRound(valueA)
+// roundedValueA = 2
+roundedValueB = qRound(valueB)
+// roundedValueB = 3
+//! [11]
+
+
+//! [12]
+valueA = 42949672960.3
+valueB = 42949672960.7
+
+roundedValueA = qRound(valueA)
+// roundedValueA = 42949672960
+roundedValueB = qRound(valueB)
+// roundedValueB = 42949672961
+//! [12]
+
+
+//! [13]
+myValue = 6
+yourValue = 4
+
+minValue = qMin(myValue, yourValue)
+// minValue == yourValue
+//! [13]
+
+
+//! [14]
+myValue = 6
+yourValue = 4
+
+maxValue = qMax(myValue, yourValue)
+// maxValue == myValue
+//! [14]
+
+
+//! [15]
+myValue = 10
+minValue = 2
+maxValue = 6
+
+boundedValue = qBound(minValue, myValue, maxValue)
+// boundedValue == 6
+//! [15]
+
+
+//! [16]
+#if QT_VERSION >= 0x040100
+ QIcon icon = style()->standardIcon(QStyle::SP_TrashIcon);
+#else
+ QPixmap pixmap = style()->standardPixmap(QStyle::SP_TrashIcon);
+ QIcon icon(pixmap);
+#endif
+//! [16]
+
+
+//! [17]
+// File: div.cpp
+
+#include <QtGlobal>
+
+int divide(int a, int b)
+{
+ Q_ASSERT(b != 0);
+ return a / b;
+}
+//! [17]
+
+
+//! [18]
+ASSERT: "b == 0" in file div.cpp, line 7
+//! [18]
+
+
+//! [19]
+// File: div.cpp
+
+#include <QtGlobal>
+
+int divide(int a, int b)
+{
+ Q_ASSERT_X(b != 0, "divide", "division by zero");
+ return a / b;
+}
+//! [19]
+
+
+//! [20]
+ASSERT failure in divide: "division by zero", file div.cpp, line 7
+//! [20]
+
+
+//! [21]
+int *a;
+
+Q_CHECK_PTR(a = new int[80]); // WRONG!
+
+a = new (nothrow) int[80]; // Right
+Q_CHECK_PTR(a);
+//! [21]
+
+
+//! [22]
+template<typename TInputType>
+const TInputType &myMin(const TInputType &value1, const TInputType &value2)
+{
+ qDebug() << Q_FUNC_INFO << "was called with value1:" << value1 << "value2:" << value2;
+
+ if(value1 < value2)
+ return value1;
+ else
+ return value2;
+}
+//! [22]
+
+
+//! [23]
+#include <qapplication.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void myMessageOutput(QtMsgType type, const char *msg)
+{
+ switch (type) {
+ case QtDebugMsg:
+ fprintf(stderr, "Debug: %s\n", msg);
+ break;
+ case QtWarningMsg:
+ fprintf(stderr, "Warning: %s\n", msg);
+ break;
+ case QtCriticalMsg:
+ fprintf(stderr, "Critical: %s\n", msg);
+ break;
+ case QtFatalMsg:
+ fprintf(stderr, "Fatal: %s\n", msg);
+ abort();
+ }
+}
+
+int main(int argc, char **argv)
+{
+ qInstallMsgHandler(myMessageOutput);
+ QApplication app(argc, argv);
+ ...
+ return app.exec();
+}
+//! [23]
+
+
+//! [24]
+qDebug("Items in list: %d", myList.size());
+//! [24]
+
+
+//! [25]
+qDebug() << "Brush:" << myQBrush << "Other value:" << i;
+//! [25]
+
+
+//! [26]
+void f(int c)
+{
+ if (c > 200)
+ qWarning("f: bad argument, c == %d", c);
+}
+//! [26]
+
+
+//! [27]
+qWarning() << "Brush:" << myQBrush << "Other value:"
+<< i;
+//! [27]
+
+
+//! [28]
+void load(const QString &fileName)
+{
+ QFile file(fileName);
+ if (!file.exists())
+ qCritical("File '%s' does not exist!", qPrintable(fileName));
+}
+//! [28]
+
+
+//! [29]
+qCritical() << "Brush:" << myQBrush << "Other
+value:" << i;
+//! [29]
+
+
+//! [30]
+int divide(int a, int b)
+{
+ if (b == 0) // program error
+ qFatal("divide: cannot divide by zero");
+ return a / b;
+}
+//! [30]
+
+
+//! [31]
+forever {
+ ...
+}
+//! [31]
+
+
+//! [32]
+CONFIG += no_keywords
+//! [32]
+
+
+//! [33]
+CONFIG += no_keywords
+//! [33]
+
+
+//! [34]
+QString FriendlyConversation::greeting(int type)
+{
+static const char *greeting_strings[] = {
+ QT_TR_NOOP("Hello"),
+ QT_TR_NOOP("Goodbye")
+};
+return tr(greeting_strings[type]);
+}
+//! [34]
+
+
+//! [35]
+static const char *greeting_strings[] = {
+ QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"),
+ QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye")
+};
+
+QString FriendlyConversation::greeting(int type)
+{
+ return tr(greeting_strings[type]);
+}
+
+QString global_greeting(int type)
+{
+ return qApp->translate("FriendlyConversation",
+ greeting_strings[type]);
+}
+//! [35]
+
+
+//! [36]
+
+static { const char *source; const char *comment; } greeting_strings[] =
+{
+ QT_TRANSLATE_NOOP3("FriendlyConversation", "Hello",
+ "A really friendly hello"),
+ QT_TRANSLATE_NOOP3("FriendlyConversation", "Goodbye",
+ "A really friendly goodbye")
+};
+
+QString FriendlyConversation::greeting(int type)
+{
+ return tr(greeting_strings[type].source,
+ greeting_strings[type].comment);
+}
+
+QString global_greeting(int type)
+{
+ return qApp->translate("FriendlyConversation",
+ greeting_strings[type].source,
+ greeting_strings[type].comment);
+}
+//! [36]
+
+
+//! [37]
+qWarning("%s: %s", qPrintable(key), qPrintable(value));
+//! [37]
+
+
+//! [38]
+struct Point2D
+{
+ int x;
+ int y;
+};
+
+Q_DECLARE_TYPEINFO(Point2D, Q_PRIMITIVE_TYPE);
+//! [38]
+
+
+//! [39]
+class Point2D
+{
+public:
+ Point2D() { data = new int[2]; }
+ Point2D(const Point2D &other) { ... }
+ ~Point2D() { delete[] data; }
+
+ Point2D &operator=(const Point2D &other) { ... }
+
+ int x() const { return data[0]; }
+ int y() const { return data[1]; }
+
+private:
+ int *data;
+};
+
+Q_DECLARE_TYPEINFO(Point2D, Q_MOVABLE_TYPE);
+//! [39]
+
+
+//! [40]
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+...
+#endif
+
+or
+
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+...
+#endif
+
+//! [40]
+
+
+//! [41]
+
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+...
+#endif
+
+//! [41]
+
+
+//! [42]
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+...
+#endif
+
+//! [42]
+
+//! [begin namespace macro]
+namespace QT_NAMESPACE {
+//! [begin namespace macro]
+
+//! [end namespace macro]
+}
+//! [end namespace macro]
+
+//! [43]
+class MyClass : public QObject
+{
+
+ private:
+ Q_DISABLE_COPY(MyClass)
+};
+
+//! [43]
+
+//! [44]
+class MyClass : public QObject
+{
+
+ private:
+ MyClass(const MyClass &);
+ MyClass &operator=(const MyClass &);
+};
+//! [44]
+
+//! [45]
+ w = QWidget()
+//! [45]
+
+//! [46]
+ // Instead of comparing with 0.0
+ qFuzzyCompare(0.0,1.0e-200); // This will return false
+ // Compare adding 1 to both values will fix the problem
+ qFuzzyCompare(1 + 0.0, 1 + 1.0e-200); // This will return true
+//! [46]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp
new file mode 100644
index 000000000..6a6d019a1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qabstractfileengine.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 ZipEngineHandler(QAbstractFileEngineHandler):
+ def create(self, fileName):
+ # ZipEngineHandler returns a ZipEngine for all .zip files
+ if fileName.toLower().endsWith(".zip"):
+ return ZipEngine(fileName)
+ else
+ return None
+
+def main():
+ app = QApplication(sys.argv)
+
+ engine = ZipEngineHandler()
+
+ window = MainWindow()
+ window.show()
+
+ return app.exec()
+//! [0]
+
+
+//! [1]
+def create(fileName):
+ # ZipEngineHandler returns a ZipEngine for all .zip files
+ if fileName.lower().endswith(".zip"):
+ return ZipEngine(fileName)
+ else
+ return None
+//! [1]
+
+
+//! [2]
+# @arg filters QDir.Filters
+# @arg filterNames [str, ...]
+# @return QAbstractFileEngineIterator
+def beginEntryList(filters, filterNames):
+ return CustomFileEngineIterator(filters, filterNames)
+//! [2]
+
+
+//! [3]
+class CustomIterator(QAbstractFileEngineIterator):
+ def __init__(self, nameFilters, filters):
+ QAbstractFileEngineIterator.__init__(self, nameFilters, filters)
+
+ self.index = 0
+ # In a real iterator, these entries are fetched from the
+ # file system based on the value of path().
+ self.entries << "entry1" << "entry2" << "entry3"
+
+ def hasNext(self):
+ return self.index < self.entries.size() - 1
+
+ def next(self):
+ if not self.hasNext():
+ return None
+ index += 1
+ return currentFilePath()
+
+ def currentFileName(self):
+ return self.entries.at(index)
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdatastream.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdatastream.cpp
new file mode 100644
index 000000000..dff0b2c7c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdatastream.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+void wrapInFunction()
+{
+
+//! [0]
+file_ = QFile("file.dat")
+file_.open(QIODevice.WriteOnly)
+# we will serialize the data into the file
+out = QDataStream(file_)
+# serialize a string
+out.writeQString("the answer is")
+# serialize an integer
+out.writeInt32(42)
+//! [0]
+
+
+//! [1]
+file_ = QFile("file.dat")
+file_.open(QIODevice.ReadOnly)
+# read the data serialized from the file
+i = QDataStream(file_)
+string = ''
+a = 0
+# extract "the answer is" and 42
+string = i.readQString()
+a = i.readInt32()
+//! [1]
+
+
+//! [2]
+stream.setVersion(QDataStream.Qt_4_0)
+//! [2]
+
+
+//! [3]
+file_ = QFile("file.xxx")
+file_.open(QIODevice.WriteOnly)
+out = QDataStream(file_)
+
+# Write a header with a "magic number" and a version
+out.writeInt32(0xA0B0C0D0)
+out.writeInt32(123)
+
+out.setVersion(QDataStream.Qt_4_0)
+
+// Write the data
+out << lots_of_interesting_data
+//! [3]
+
+
+//! [4]
+file_ = QFile("file.xxx")
+file_.open(QIODevice.ReadOnly)
+i = QDataStream(file_)
+
+// Read and check the header
+magic = i.readInt32()
+if magic != 0xA0B0C0D0:
+ return XXX_BAD_FILE_FORMAT
+
+// Read the version
+version = i.readInt32()
+if version < 100:
+ return XXX_BAD_FILE_TOO_OLD
+if version > 123:
+ return XXX_BAD_FILE_TOO_NEW
+
+if version <= 110:
+ in_.setVersion(QDataStream.Qt_3_2)
+else:
+ in_.setVersion(QDataStream.Qt_4_0)
+
+// Read the data
+in_ >> lots_of_interesting_data
+if version >= 120:
+ in_ >> data_new_in_XXX_version_1_2
+in_ >> other_interesting_data
+//! [4]
+
+
+//! [5]
+out = QDataStream(file_)
+out.setVersion(QDataStream.Qt_4_0)
+//! [5]
+
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp
new file mode 100644
index 000000000..85019de30
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdir.cpp
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+void wrapInFunction()
+{
+
+//! [0]
+QDir("/home/user/Documents")
+QDir("C:/Documents and Settings")
+//! [0]
+
+
+//! [1]
+QDir("images/landscape.png")
+//! [1]
+
+
+//! [2]
+QDir("Documents/Letters/Applications").dirName() # "Applications"
+QDir().dirName() # "."
+//! [2]
+
+
+//! [3]
+directory = QDir("Documents/Letters")
+path = directory.filePath("contents.txt")
+absolutePath = directory.absoluteFilePath("contents.txt")
+//! [3]
+
+
+//! [4]
+dir = QDir("example")
+if not dir.exists():
+ print "Cannot find the example directory"
+//! [4]
+
+
+//! [5]
+dir = QDir.root() # "/"
+if not dir.cd("tmp"): # "/tmp"
+ print "Cannot find the \"/tmp\" directory"
+else:
+ file = QFile(dir.filePath("ex1.txt")) # "/tmp/ex1.txt"
+ if !file.open(QIODevice.ReadWrite):
+ print "Cannot create the file %s" % (file.name())
+//! [5]
+
+
+//! [6]
+bin = "/local/bin" # where /local/bin is a symlink to /usr/bin
+binDir = QDir(bin)
+canonicalBin = binDir.canonicalPath()
+# canonicalBin now equals "/usr/bin"
+
+ls = "/local/bin/ls" # where ls is the executable "ls"
+lsDir = QDir(ls)
+canonicalLs = lsDir.canonicalPath()
+# canonicalLS now equals "/usr/bin/ls".
+//! [6]
+
+
+//! [7]
+dir = QDir("/home/bob")
+
+s = dir.relativeFilePath("images/file.jpg") # s is "images/file.jpg"
+s = dir.relativeFilePath("/home/mary/file.txt") # s is "../mary/file.txt"
+//! [7]
+
+
+//! [8]
+QDir.setSearchPaths("icons", [QDir.homePath() + "/images"])
+QDir.setSearchPaths("docs", [":/embeddedDocuments"])
+...
+pixmap = QPixmap("icons:undo.png") # will look for undo.png in QDir::homePath() + "/images"
+file = QFile("docs:design.odf") # will look in the :/embeddedDocuments resource path
+//! [8]
+
+
+//! [9]
+dir = QDir("/tmp/root_link")
+dir = dir.canonicalPath()
+if dir.isRoot():
+ print "It is a root link"
+//! [9]
+
+
+//! [10]
+# The current directory is "/usr/local"
+d1 = QDir("/usr/local/bin")
+d2 = QDir("bin")
+if d1 == d2:
+ print "They're the same"
+//! [10]
+
+
+//! [11]
+// The current directory is "/usr/local"
+d1 = QDir("/usr/local/bin")
+d1.setFilter(QDir.Executable)
+d2 = QDir("bin")
+if d1 != d2:
+ print "They differ"
+//! [11]
+
+
+//! [12]
+C:/Documents and Settings/Username
+//! [12]
+
+
+//! [13]
+Q_INIT_RESOURCE(myapp);
+//! [13]
+
+
+//! [14]
+def initMyResource():
+ Q_INIT_RESOURCE(myapp)
+
+class MyNamespace
+ ...
+
+ def myFunction(self):
+ initMyResource()
+//! [14]
+
+
+//! [15]
+Q_CLEANUP_RESOURCE(myapp);
+//! [15]
+
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdiriterator.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdiriterator.cpp
new file mode 100644
index 000000000..9d37d9f95
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qdiriterator.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+it = QDirIterator("/etc", QDirIterator.Subdirectories)
+while it.hasNext():
+ print it.next()
+
+ # /etc/.
+ # /etc/..
+ # /etc/X11
+ # /etc/X11/fs
+ # ...
+
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfile.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfile.cpp
new file mode 100644
index 000000000..ea225684c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfile.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+file = QFile()
+QDir.setCurrent("/tmp")
+file.setFileName("readme.txt")
+QDir.setCurrent("/home")
+file.open(QIODevice.ReadOnly) # opens "/home/readme.txt" under Unix
+//! [0]
+
+
+//! [1]
+def myEncoderFunc(fileName):
+//! [1]
+
+
+//! [2]
+def myDecoderFunc(localFileName):
+//! [2]
+
+
+//! [3]
+
+def printError(msg):
+ file = QFile()
+ file.open(sys.stderr.fileno(), QIODevice.WriteOnly)
+ file.write(msg, size(msg)) # write to stderr
+ file.close()
+//! [3]
+
+
+//! [4]
+CONFIG += console
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp
new file mode 100644
index 000000000..5a53e7ac6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+//![newstuff]
+ fi = QFileInfo("c:/temp/foo") => fi.absoluteFilePath() => "C:/temp/foo"
+//![newstuff]
+
+//! [0]
+info1 = QFileInfo("/home/bob/bin/untabify")
+info1.isSymLink() # returns true
+info1.absoluteFilePath() # returns "/home/bob/bin/untabify"
+info1.size() # returns 56201
+info1.symLinkTarget() # returns "/opt/pretty++/bin/untabify"
+
+info2 = QFileInfo(info1.symLinkTarget())
+info1.isSymLink() # returns False
+info1.absoluteFilePath() # returns "/opt/pretty++/bin/untabify"
+info1.size() # returns 56201
+
+//! [0]
+
+
+//! [1]
+info1 = QFileInfo("C:\\Documents and Settings\\Bob\\untabify.lnk")
+info1.isSymLink() # returns True
+info1.absoluteFilePath() # returns "C:/Documents and Settings/Bob/untabify.lnk"
+info1.size() # returns 743
+info1.symLinkTarget() # returns "C:/Pretty++/untabify"
+
+info2 = QFileInfo(info1.symLinkTarget())
+info1.isSymLink() # returns False
+info1.absoluteFilePath() # returns "C:/Pretty++/untabify"
+info1.size() # returns 63942
+//! [1]
+
+
+//! [2]
+absolute = "/local/bin"
+relative = "local/bin"
+absFile = QFileInfo(absolute)
+relFile = QFileInfo(relative)
+
+QDir.setCurrent(QDir.rootPath())
+# absFile and relFile now point to the same file
+
+QDir.setCurrent("/tmp")
+# absFile now points to "/local/bin",
+# while relFile points to "/tmp/local/bin"
+//! [2]
+
+
+//! [3]
+fi = QFileInfo("/tmp/archive.tar.gz")
+name = fi.fileName() # name = "archive.tar.gz"
+//! [3]
+
+
+//! [4]
+fi = QFileInfo("/Applications/Safari.app")
+bundle = fi.bundleName() # name = "Safari"
+//! [4]
+
+
+//! [5]
+fi = QFileInfo("/tmp/archive.tar.gz")
+base = fi.baseName() # base = "archive"
+//! [5]
+
+
+//! [6]
+fi = QFileInfo("/tmp/archive.tar.gz")
+base = fi.completeBaseName() # base = "archive.tar"
+//! [6]
+
+
+//! [7]
+fi = QFileInfo("/tmp/archive.tar.gz")
+ext = fi.completeSuffix() # ext = "tar.gz"
+//! [7]
+
+
+//! [8]
+fi = QFileInfo("/tmp/archive.tar.gz")
+ext = fi.suffix(); # ext = "gz"
+//! [8]
+
+
+//! [9]
+info = QFileInfo(fileName)
+if info.isSymLink():
+ fileName = info.symLinkTarget()
+//! [9]
+
+
+//! [10]
+fi = QFileInfo("/tmp/archive.tar.gz")
+if fi.permission(QFile.WriteUser | QFile.ReadGroup):
+ print "I can change the file; my group can read the file"
+if fi.permission(QFile.WriteGroup | QFile.WriteOther):
+ print "The group or others can change the file"
+//! [10]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qiodevice.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qiodevice.cpp
new file mode 100644
index 000000000..0ad210141
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qiodevice.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+gzip = QProcess()
+gzip.start("gzip", ["-c"])
+if not gzip.waitForStarted():
+ return False
+
+gzip.write("uncompressed data")
+
+compressed = QByteArray()
+while gzip.waitForReadyRead():
+ compressed += gzip.readAll()
+//! [0]
+
+
+//! [1]
+def bytesAvailable(self):
+ return buffer.size() + QIODevice.bytesAvailable()
+//! [1]
+
+
+//! [2]
+file = QFile("box.txt")
+if file.open(QFile.ReadOnly):
+ buf = file.readLine(1024)
+ if buf.size():
+ # the line is available in buf
+//! [2]
+
+
+//! [3]
+def canReadLine(self):
+ return buffer.contains('\n') or QIODevice.canReadLine()
+//! [3]
+
+
+//! [4]
+def isExeFile(file_):
+ buf = file_.peek(2)
+ if buf.size() == 2:
+ return buf[0] == 'M' and buf[1] == 'Z'
+ return False
+//! [4]
+
+
+//! [5]
+def isExeFile(file_):
+ return file_.peek(2) == "MZ"
+//! [5]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp
new file mode 100644
index 000000000..5542c796e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qprocess.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+builder = QProcess()
+builder.setProcessChannelMode(QProcess.MergedChannels)
+builder.start("make", ["-j2"])
+
+import sys
+if not builder.waitForFinished():
+ sys.stderr.write("Make failed:" + builder.errorString())
+else
+ sys.stderr.write("Make output:" + builder.readAll())
+//! [0]
+
+
+//! [1]
+more = QProcess()
+more.start("more")
+more.write("Text to display")
+more.closeWriteChannel()
+#QProcess will emit readyRead() once "more" starts printing
+//! [1]
+
+
+//! [2]
+command1 | command2
+//! [2]
+
+
+//! [3]
+process1 = QProcess()
+process2 = QProcess()
+
+process1.setStandardOutputProcess(process2)
+
+process1.start("command1")
+process2.start("command2")
+//! [3]
+
+
+//! [4]
+class SandboxProcess(QProcess):
+ def setupChildProcess(self)
+ # Drop all privileges in the child process, and enter
+ # a chroot jail.
+ os.setgroups(0, 0)
+ os.chroot("/etc/safe")
+ os.chdir("/")
+ os.setgid(safeGid)
+ os.setuid(safeUid)
+ os.umask(0)
+
+//! [4]
+
+
+//! [5]
+process = QProcess()
+process.start("del /s *.txt")
+# same as process.start("del", ["/s", "*.txt"])
+...
+//! [5]
+
+
+//! [6]
+process = QProcess()
+process.start("dir \"My Documents\"")
+//! [6]
+
+
+//! [7]
+process = QProcess()
+process.start("dir \"\"\"My Documents\"\"\"")
+//! [7]
+
+
+//! [8]
+environment = QProcess.systemEnvironment()
+# environment = [PATH=/usr/bin:/usr/local/bin",
+# "USER=greg", "HOME=/home/greg"]
+//! [8]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qsettings.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qsettings.cpp
new file mode 100644
index 000000000..2297e6894
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qsettings.cpp
@@ -0,0 +1,330 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+settings = QSettings("MySoft", "Star Runner")
+color = QColor(settings.value("DataPump/bgcolor"))
+//! [0]
+
+
+//! [1]
+settings = QSettings("MySoft", "Star Runner")
+color = palette().background().color()
+settings.setValue("DataPump/bgcolor", color)
+//! [1]
+
+
+//! [2]
+settings = QSettings("/home/petra/misc/myapp.ini",
+ QSettings.IniFormat)
+//! [2]
+
+
+//! [3]
+settings = QSettings("/Users/petra/misc/myapp.plist",
+ QSettings.NativeFormat)
+//! [3]
+
+
+//! [4]
+settings = QSettings("HKEY_CURRENT_USER\\Software\\Microsoft\\Office",
+ QSettings.NativeFormat)
+//! [4]
+
+
+//! [5]
+settings.setValue("11.0/Outlook/Security/DontTrustInstalledFiles", 0)
+//! [5]
+
+
+//! [6]
+settings.setValue("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy", "Milkyway")
+settings.setValue("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy\\Sun", "OurStar")
+settings.value("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy\\Default") # returns "Milkyway"
+//! [6]
+
+
+//! [7]
+#ifdef Q_WS_MAC
+ settings = QSettings("grenoullelogique.fr", "Squash")
+#else
+ settings = QSettings("Grenoulle Logique", "Squash")
+#endif
+//! [7]
+
+
+//! [8]
+pos = @Point(100 100)
+//! [8]
+
+
+//! [9]
+windir = C:\Windows
+//! [9]
+
+
+//! [10]
+settings = QSettings("Moose Tech", "Facturo-Pro")
+//! [10]
+
+
+//! [11]
+settings = QSettings("Moose Soft", "Facturo-Pro")
+//! [11]
+
+
+//! [12]
+QCoreApplication.setOrganizationName("Moose Soft")
+QCoreApplication.setApplicationName("Facturo-Pro")
+settings = QSettings()
+//! [12]
+
+
+//! [13]
+settings.beginGroup("mainwindow")
+settings.setValue("size", win.size())
+settings.setValue("fullScreen", win.isFullScreen())
+settings.endGroup()
+
+settings.beginGroup("outputpanel")
+settings.setValue("visible", panel.isVisible())
+settings.endGroup()
+//! [13]
+
+
+//! [14]
+settings.beginGroup("alpha")
+# settings.group() == "alpha"
+
+settings.beginGroup("beta")
+# settings.group() == "alpha/beta"
+
+settings.endGroup()
+# settings.group() == "alpha"
+
+settings.endGroup()
+# settings.group() == ""
+//! [14]
+
+
+//! [15]
+class Login:
+ userName = ''
+ password = ''
+
+ logins = []
+ ...
+
+ settings = QSettings()
+ size = settings.beginReadArray("logins")
+ for i in range(size):
+ settings.setArrayIndex(i)
+ login = Login()
+ login.userName = settings.value("userName")
+ login.password = settings.value("password")
+ logins.append(login)
+
+ settings.endArray()
+//! [15]
+
+
+//! [16]
+class Login:
+ userName = ''
+ password = ''
+
+ logins = []
+ ...
+
+ settings = QSettings()
+ settings.beginWriteArray("logins")
+ for i in range(logins.size()):
+ settings.setArrayIndex(i)
+ settings.setValue("userName", list.at(i).userName)
+ settings.setValue("password", list.at(i).password)
+
+ settings.endArray()
+//! [16]
+
+
+//! [17]
+settings = QSettings()
+settings.setValue("fridge/color", Qt.white)
+settings.setValue("fridge/size", QSize(32, 96))
+settings.setValue("sofa", True)
+settings.setValue("tv", False)
+
+keys = settings.allKeys();
+# keys: ["fridge/color", "fridge/size", "sofa", "tv"]
+//! [17]
+
+
+//! [18]
+settings.beginGroup("fridge")
+keys = settings.allKeys()
+# keys: ["color", "size"]
+//! [18]
+
+
+//! [19]
+settings = QSettings()
+settings.setValue("fridge/color", Qt.white)
+settings.setValue("fridge/size", QSize(32, 96))
+settings.setValue("sofa", True)
+settings.setValue("tv", False)
+
+keys = settings.childKeys()
+# keys: ["sofa", "tv"]
+//! [19]
+
+
+//! [20]
+settings.beginGroup("fridge")
+keys = settings.childKeys()
+# keys: ["color", "size"]
+//! [20]
+
+
+//! [21]
+settings = QSettings()
+settings.setValue("fridge/color", Qt.white)
+settings.setValue("fridge/size", QSize(32, 96));
+settings.setValue("sofa", True)
+settings.setValue("tv", False)
+
+groups = settings.childGroups()
+# group: ["fridge"]
+//! [21]
+
+
+//! [22]
+settings.beginGroup("fridge")
+groups = settings.childGroups()
+# groups: []
+//! [22]
+
+
+//! [23]
+settings = QSettings()
+settings.setValue("interval", 30)
+settings.value("interval") # returns 30
+
+settings.setValue("interval", 6.55)
+settings.value("interval") # returns 6.55
+//! [23]
+
+
+//! [24]
+settings = QSettings()
+settings.setValue("ape")
+settings.setValue("monkey", 1)
+settings.setValue("monkey/sea", 2)
+settings.setValue("monkey/doe", 4)
+
+settings.remove("monkey")
+keys = settings.allKeys()
+# keys: ["ape"]
+//! [24]
+
+
+//! [25]
+settings = QSettings()
+settings.setValue("ape")
+settings.setValue("monkey", 1)
+settings.setValue("monkey/sea", 2)
+settings.setValue("monkey/doe", 4)
+
+settings.beginGroup("monkey")
+settings.remove("")
+settings.endGroup()
+
+keys = settings.allKeys()
+# keys: ["ape"]
+//! [25]
+
+
+//! [26]
+settings = QSettings()
+settings.setValue("animal/snake", 58)
+settings.value("animal/snake", 1024) # returns 58
+settings.value("animal/zebra", 1024) # returns 1024
+settings.value("animal/zebra") # returns 0
+//! [26]
+
+
+//! [27]
+# @arg device QIODevice
+# @arg map QSettings.SettingsMap
+# @return bool
+def myReadFunc(device, map):
+//! [27]
+
+
+//! [28]
+# @arg device QIODevice
+# @arg map QSettings.SettingsMap
+# @return bool
+def myWriteFunc(device, map)
+//! [28]
+
+
+//! [29]
+# @arg device QIODevice
+# @arg map QSettings.SettingsMap
+# @return bool
+def readXmlFile(device, map):
+def writeXmlFile(device, map):
+
+def main():
+ XmlFormat = QSettings::registerFormat("xml", readXmlFile, writeXmlFile)
+ settings = QSettings(XmlFormat, QSettings.UserSettings,
+ "MySoft", "Star Runner")
+ ...
+//! [29]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp
new file mode 100644
index 000000000..067b9a375
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtemporaryfile.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ # Within a function/method...
+
+ file_ = QTemporaryFile()
+ if file_.open():
+ # file_.fileName() returns the unique file name
+
+ # The QTemporaryFile destructor removes the temporary file
+ # as it goes out of scope.
+//! [0]
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtextstream.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtextstream.cpp
new file mode 100644
index 000000000..d9efd55f4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qtextstream.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+data = QFile("output.txt")
+if data.open(QFile.WriteOnly | QFile.Truncate):
+ out = QTextStream(&data)
+ out << "Result: " << qSetFieldWidth(10) << left << 3.14 << 2.7
+ # writes "Result: 3.14 2.7 "
+
+//! [0]
+
+
+//! [1]
+stream = QTextStream(sys.stdin.fileno())
+
+while(True):
+ line = stream.readLine()
+ if line.isNull():
+ break;
+//! [1]
+
+
+//! [2]
+in_ = QTextStream("0x50 0x20")
+firstNumber = 0
+secondNumber = 0
+
+in_ >> firstNumber # firstNumber == 80
+in_ >> dec >> secondNumber # secondNumber == 0
+
+ch = None
+in_ >> ch # ch == 'x'
+//! [2]
+
+
+//! [3]
+def main():
+ # read numeric arguments (123, 0x20, 4.5...)
+ for i in sys.argv():
+ number = None
+ QTextStream in_(i)
+ in_ >> number
+ ...
+//! [3]
+
+
+//! [4]
+str = QString()
+in_ = QTextStream(sys.stdin.fileno())
+in_ >> str
+//! [4]
+
+
+//! [5]
+s = QString()
+out = QTextStream(s)
+out.setFieldWidth(10)
+out.setFieldAlignment(QTextStream::AlignCenter)
+out.setPadChar('-')
+out << "Qt" << "rocks!"
+//! [5]
+
+
+//! [6]
+----Qt------rocks!--
+//! [6]
+
+
+//! [7]
+in_ = QTextStream(file)
+ch1 = QChar()
+ch2 = QChar()
+ch3 = QChar()
+in_ >> ch1 >> ch2 >> ch3;
+//! [7]
+
+
+//! [8]
+out = QTextStream(sys.stdout.fileno())
+out << "Qt rocks!" << endl
+//! [8]
+
+
+//! [9]
+stream << '\n' << flush
+//! [9]
+
+
+//! [10]
+out = QTextStream(file)
+out.setCodec("UTF-8")
+//! [10]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qurl.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qurl.cpp
new file mode 100644
index 000000000..bacee95ff
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qurl.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+url = QUrl("http://www.example.com/List of holidays.xml")
+# url.toEncoded() == "http://www.example.com/List%20of%20holidays.xml"
+//! [0]
+
+
+//! [1]
+url = QUrl.fromEncoded("http://qtsoftware.com/List%20of%20holidays.xml")
+//! [1]
+
+
+//! [2]
+def checkUrl(url):
+ if !url.isValid():
+ print "Invalid URL: %s" % url.toString()
+ return False
+
+ return True
+
+//! [2]
+
+
+//! [3]
+ftp = QFtp()
+ftp.connectToHost(url.host(), url.port(21))
+//! [3]
+
+
+//! [4]
+http://www.example.com/cgi-bin/drawgraph.cgi?type-pie/color-green
+//! [4]
+
+
+//! [5]
+baseUrl = QUrl("http://qtsoftware.com/support")
+relativeUrl = QUrl("../products/solutions")
+print baseUrl.resolved(relativeUrl).toString()
+# prints "http://qtsoftware.com/products/solutions"
+//! [5]
+
+
+//! [6]
+ba = QUrl.toPercentEncoding("{a fishy string?}", "{}", "s")
+print ba
+# prints "{a fi%73hy %73tring%3F}"
+//! [6]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp
new file mode 100644
index 000000000..a531f22fc
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstracteventdispatcher.cpp
@@ -0,0 +1,3 @@
+//! [0]
+bool myEventFilter(void *message);
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
new file mode 100644
index 000000000..a9480e381
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+beginInsertRows(parent, 2, 4)
+//! [0]
+
+
+//! [1]
+beginInsertRows(parent, 4, 5)
+//! [1]
+
+
+//! [2]
+beginRemoveRows(parent, 2, 3)
+//! [2]
+
+
+//! [3]
+beginInsertColumns(parent, 4, 6)
+//! [3]
+
+
+//! [4]
+beginInsertColumns(parent, 6, 8)
+//! [4]
+
+
+//! [5]
+beginRemoveColumns(parent, 4, 6)
+//! [5]
+
+
+//! [6]
+beginMoveRows(sourceParent, 2, 4, destinationParent, 2)
+//! [6]
+
+
+//! [7]
+beginMoveRows(sourceParent, 2, 4, destinationParent, 6)
+//! [7]
+
+
+//! [8]
+beginMoveRows(parent, 2, 2, parent, 0)
+//! [8]
+
+
+//! [9]
+beginMoveRows(parent, 2, 2, parent, 4)
+//! [9]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp
new file mode 100644
index 000000000..e5f664cba
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+event = QMouseEvent(QEvent.MouseButtonPress, pos, 0, 0, 0)
+QApplication.sendEvent(mainWindow, event)
+//! [0]
+
+
+//! [1]
+quitButton = QPushButton("Quit")
+quitButton.clicked.connect(app.quit)
+//! [1]
+
+
+//! [2]
+for path in app.libraryPaths():
+ do_something(path)
+//! [2]
+
+
+//! [3]
+myEventFilter(message, result)
+//! [3]
+
+
+//! [4]
+def cleanup_stuff():
+ # do the cleanup stuff
+
+def init_stuff():
+ qAddPostRoutine(cleanup_stuff)
+//! [4]
+
+
+//! [5]
+class MyPrivateInitStuff : public QObject
+{
+public:
+ static MyPrivateInitStuff *initStuff(QObject *parent)
+ {
+ if (!p)
+ p = new MyPrivateInitStuff(parent);
+ return p;
+ }
+
+ ~MyPrivateInitStuff()
+ {
+ // cleanup goes here
+ }
+
+private:
+ MyPrivateInitStuff(QObject *parent)
+ : QObject(parent)
+ {
+ // initialization goes here
+ }
+
+ MyPrivateInitStuff *p;
+};
+//! [5]
+
+
+//! [6]
+static inline QString tr(const char *sourceText,
+ const char *comment = 0);
+static inline QString trUtf8(const char *sourceText,
+ const char *comment = 0);
+//! [6]
+
+
+//! [7]
+class MyMfcView : public CView
+{
+ Q_DECLARE_TR_FUNCTIONS(MyMfcView)
+
+public:
+ MyMfcView();
+ ...
+};
+//! [7]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp
new file mode 100644
index 000000000..71e264832
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+void wrapInFunction()
+{
+
+//! [0]
+class MyClass:
+
+ Q_CLASSINFO("author", "Sabrina Schweinsteiger")
+ Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")
+
+ ...
+//! [0]
+
+
+//! [1]
+normType = QMetaObject.normalizedType(" int const *")
+# normType is now "const int*"
+//! [1]
+
+
+//! [2]
+QMetaObject.invokeMethod(pushButton, "animateClick",
+ Qt.QueuedConnection)
+//! [2]
+
+
+//! [3]
+QMetaObject.invokeMethod: Unable to handle unregistered datatype 'MyType'
+//! [3]
+
+
+//! [4]
+retVal = QString()
+QMetaObject.invokeMethod(obj, "compute", Qt::DirectConnection,
+ Q_RETURN_ARG(QString, retVal),
+ Q_ARG(QString, "sqrt"),
+ Q_ARG(int, 42),
+ Q_ARG(double, 9.7));
+//! [4]
+
+
+//! [5]
+class MyClass:
+ Q_CLASSINFO("author", "Sabrina Schweinsteiger")
+ Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")
+//! [5]
+
+
+//! [propertyCount]
+metaObject = obj.metaObject()
+properties = [metaObject.property(i).name() for i in range(metaObject.propertyOffset(), metaObject.propertyCount())]
+//! [propertyCount]
+
+
+//! [methodCount]
+metaObject = obj.metaObject()
+methods = [metaObject.method(i).signature() for i in range(metaObject.methodOffset(), metaObject.methodCount())]
+//! [methodCount]
+
+//! [6]
+methodIndex = pushButton.metaObject().indexOfMethod("animateClick()")
+method = metaObject.method(methodIndex)
+method.invoke(pushButton, Qt.QueuedConnection)
+//! [6]
+
+//! [7]
+QMetaMethod.invoke: Unable to handle unregistered datatype 'MyType'
+//! [7]
+
+//! [8]
+retVal = QString()
+normalizedSignature = QMetaObject.normalizedSignature("compute(QString, int, double)")
+methodIndex = obj.metaObject().indexOfMethod(normalizedSignature)
+method = metaObject.method(methodIndex)
+method.invoke(obj,
+ Qt.DirectConnection,
+ Q_RETURN_ARG(QString, retVal),
+ Q_ARG(QString, "sqrt"),
+ Q_ARG(int, 42),
+ Q_ARG(double, 9.7));
+//! [8]
+
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
new file mode 100644
index 000000000..62c9ae327
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+struct MyStruct
+{
+ int i;
+ ...
+};
+
+Q_DECLARE_METATYPE(MyStruct)
+//! [0]
+
+
+//! [1]
+namespace MyNamespace
+{
+ ...
+}
+
+Q_DECLARE_METATYPE(MyNamespace::MyStruct)
+//! [1]
+
+
+//! [2]
+MyStruct s;
+QVariant var;
+var.setValue(s); // copy s into the variant
+
+...
+
+// retrieve the value
+MyStruct s2 = var.value<MyStruct>();
+//! [2]
+
+
+//! [3]
+int id = QMetaType::type("MyClass");
+if (id == 0) {
+ void *myClassPtr = QMetaType::construct(id);
+ ...
+ QMetaType::destroy(id, myClassPtr);
+ myClassPtr = 0;
+}
+//! [3]
+
+
+//! [4]
+qRegisterMetaType<MyClass>("MyClass");
+//! [4]
+
+
+//! [5]
+qRegisterMetaTypeStreamOperators<MyClass>("MyClass");
+//! [5]
+
+
+//! [6]
+QDataStream &operator<<(QDataStream &out, const MyClass &myObj);
+QDataStream &operator>>(QDataStream &in, MyClass &myObj);
+//! [6]
+
+
+//! [7]
+int id = qRegisterMetaType<MyStruct>();
+//! [7]
+
+
+//! [8]
+int id = qMetaTypeId<QString>(); // id is now QMetaType::QString
+id = qMetaTypeId<MyStruct>(); // compile error if MyStruct not declared
+//! [8]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp
new file mode 100644
index 000000000..a2e6547f2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def dragEnterEvent(self, event):
+ if event.mimeData().hasUrls():
+ event.acceptProposedAction()
+
+def dropEvent(self, event):
+ if event->mimeData().hasUrls():
+ for url in event.mimeData().urls():
+ ...
+//! [0]
+
+
+//! [1]
+csvData = QByteArray(...)
+
+mimeData = QMimeData()
+mimeData.setData("text/csv", csvData)
+//! [1]
+
+
+//! [2]
+def dropEvent(self, event):
+ myData = event->mimeData()
+ if myData:
+ # access myData's data directly (not through QMimeData's API)
+}
+//! [2]
+
+
+//! [3]
+application/x-qt-windows-mime;value="<custom type>"
+//! [3]
+
+
+//! [4]
+application/x-qt-windows-mime;value="FileGroupDescriptor"
+application/x-qt-windows-mime;value="FileContents"
+//! [4]
+
+
+//! [5]
+if event.mimeData().hasImage():
+ image = QImage(event.mimeData().imageData())
+ ...
+//! [5]
+
+
+//! [6]
+mimeData.setImageData(QImage("beautifulfjord.png"))
+//! [6]
+
+
+//! [7]
+if event.mimeData().hasColor():
+ color = QColor(event.mimeData().colorData())
+ ...
+//! [7]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qobject.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qobject.cpp
new file mode 100644
index 000000000..bfe6d1d1a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qobject.cpp
@@ -0,0 +1,369 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+lineEdit = qt_find_obj_child(myWidget, "QLineEdit", "my line edit")
+if lineEdit:
+ lineEdit.setText("Default")
+//! [0]
+
+
+//! [1]
+obj = QPushButton()
+obj.metaObject().className() # returns "QPushButton"
+
+QPushButton.staticMetaObject.className() # returns "QPushButton"
+//! [1]
+
+
+//! [2]
+QPushButton.staticMetaObject.className() # returns "QPushButton"
+
+obj = QPushButton()
+obj.metaObject().className() # returns "QPushButton"
+//! [2]
+
+
+//! [3]
+obj = QTimer() # QTimer inherits QObject
+
+timer = obj
+# timer == (QObject *)obj
+
+button = obj
+# button == 0
+//! [3]
+
+
+//! [4]
+timer = QTimer() # QTimer inherits QObject
+timer.inherits("QTimer") # returns true
+timer.inherits("QObject") # returns true
+timer.inherits("QAbstractButton") # returns false
+
+# QLayout inherits QObject and QLayoutItem
+layout = QLayout()
+layout.inherits("QObject") # returns true
+layout.inherits("QLayoutItem") # returns false
+//! [4]
+
+
+//! [5]
+print "MyClass::setPrecision(): (%s) invalid precision %f" % \
+ (qPrintable(objectName()), newPrecision)
+//! [5]
+
+
+//! [6]
+class MainWindow(QMainWindow):
+ def __init__(self):
+ self.textEdit = QTextEdit()
+ setCentralWidget(self.textEdit)
+ textEdit.installEventFilter(self)
+
+ def eventFilter(self, obj, event):
+ if obj == textEdit:
+ if event.type() == QEvent.KeyPress:
+ keyEvent = event
+ print "Ate key press", keyEvent.key()
+ return true
+ else:
+ return false
+ else:
+ # pass the event on to the parent class
+ return QMainWindow.eventFilter(self, obj, event)
+//! [6]
+
+
+//! [7]
+myObject.moveToThread(QApplication.instance().thread())
+//! [7]
+
+
+//! [8]
+class MyObject(QObject):
+ def __init__(self, parent):
+ QObject.__init__(self, parent)
+
+ self.startTimer(50) # 50-millisecond timer
+ self.startTimer(1000) # 1-second timer
+ self.startTimer(60000) # 1-minute timer
+
+
+ def timerEvent(self, event):
+ print "Timer ID:", event.timerId()
+
+//! [8]
+
+
+//! [9]
+list = window().queryList("QAbstractButton")
+for obj in list:
+ obj.setEnabled(false)
+//! [9]
+
+
+//! [10]
+button = parentWidget.findChild(QPushButton, "button1")
+//! [10]
+
+
+//! [11]
+list = parentWidget.findChild(QListWidget)
+//! [11]
+
+
+//! [12]
+widgets = parentWidget.findChildren(QWidget, "widgetname")
+//! [12]
+
+
+//! [13]
+allPButtons = parentWidget.findChildren(QPushButton)
+//! [13]
+
+
+//! [14]
+monitoredObj.installEventFilter(filterObj)
+//! [14]
+
+
+//! [15]
+class KeyPressEater(QObject):
+ def eventFilter(self, obj, event):
+ if event.type() == QEvent.KeyPress:
+ print "Ate key press", event.key()
+ return True
+ else:
+ # standard event processing
+ return QObject.eventFilter(self, obj, event)
+//! [15]
+
+
+//! [16]
+keyPressEater = KeyPressEater(self)
+pushButton = QPushButton(self)
+listView = QListView(self)
+
+pushButton.installEventFilter(keyPressEater)
+listView.installEventFilter(keyPressEater)
+//! [16]
+
+
+//! [17]
+def __init__(self):
+ senderLabel = QLabel(self.tr("Name:"))
+ recipientLabel = QLabel(self.tr("Name:", "recipient"))
+ # ...
+//! [17]
+
+
+//! [18]
+n = messages.count();
+showMessage(self.tr("%n message(s) saved", "", n));
+//! [18]
+
+
+//! [19]
+if n == 1:
+ self.tr("%n message saved")
+else:
+ self.tr("%n messages saved")
+//! [19]
+
+
+//! [20]
+label.setText(self.tr("F\374r \310lise"))
+//! [20]
+
+
+//! [21]
+if receivers(SIGNAL('valueChanged()')) > 0:
+ data = get_the_value() # expensive operation
+ self.valueChanged(data)
+//! [21]
+
+
+//! [22]
+label = QLabel()
+scrollBar = QScrollBar()
+QObject.connect(scrollBar, SIGNAL('valueChanged()'),
+ label, SLOT('setNum()'))
+//! [22]
+
+
+//! [23]
+// WRONG
+QObject.connect(scrollBar, SIGNAL('valueChanged()'),
+ label, SLOT('setNum()'));
+//! [23]
+
+
+//! [24]
+class MyWidget(QWidget):
+ def __init__(self):
+ myButton = QPushButton(self)
+ connect(myButton, SIGNAL('clicked()'),
+ self, SIGNAL('buttonClicked()'))
+//! [24]
+
+
+//! [25]
+QObject.connect: Cannot queue arguments of type 'MyType'
+(Make sure 'MyType' is registered using qRegisterMetaType().)
+//! [25]
+
+
+//! [26]
+disconnect(myObject, 0, 0, 0)
+//! [26]
+
+
+//! [27]
+myObject.disconnect()
+//! [27]
+
+
+//! [28]
+disconnect(myObject, SIGNAL('mySignal()'), 0, 0)
+//! [28]
+
+
+//! [29]
+myObject.disconnect(SIGNAL('mySignal()'))
+//! [29]
+
+
+//! [30]
+disconnect(myObject, 0, myReceiver, 0)
+//! [30]
+
+
+//! [31]
+myObject.disconnect(myReceiver)
+//! [31]
+
+
+//! [32]
+if QLatin1String(signal) == SIGNAL('valueChanged()'):
+ # signal is valueChanged()
+//! [32]
+
+
+//! [33]
+def on_<object name>_<signal name>(<signal parameters>)
+//! [33]
+
+
+//! [34]
+def on_button1_clicked()
+//! [34]
+
+
+//! [35]
+class MyClass(QObject):
+ Q_CLASSINFO("Author", "Pierre Gendron")
+ Q_CLASSINFO("URL", "http://www.my-organization.qc.ca")
+
+//! [35]
+
+
+//! [36]
+Q_PROPERTY(type name
+ READ getFunction
+ [WRITE setFunction]
+ [RESET resetFunction]
+ [DESIGNABLE bool]
+ [SCRIPTABLE bool]
+ [STORED bool]
+ [USER bool])
+//! [36]
+
+
+//! [37]
+Q_PROPERTY(QString title READ title WRITE setTitle USER true)
+//! [37]
+
+
+//! [38]
+#this not apply for Python
+class MyClass(QObject):
+
+ Q_OBJECT
+ Q_ENUMS(Priority)
+
+public:
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+
+ enum Priority { High, Low, VeryHigh, VeryLow };
+ void setPriority(Priority priority);
+ Priority priority() const;
+};
+//! [38]
+
+
+//! [39]
+#this not apply for Python
+Q_FLAGS(Options Alignment)
+//! [39]
+
+
+//! [40]
+//: This name refers to a host name.
+hostNameLabel.setText(self.tr("Name:"))
+
+#: This text refers to a C++ code example.
+example = self.tr("Example")
+//! [40]
+
+//! [explicit tr context]
+text = QScrollBar.tr("Page up")
+//! [explicit tr context]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
new file mode 100644
index 000000000..247d10806
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+sem = QSystemSemaphore("market", 3, QSystemSemaphore.Create)
+# resources available == 3
+sem.acquire() # resources available == 2
+sem.acquire() # resources available == 1
+sem.acquire() # resources available == 0
+sem.release() # resources available == 1
+sem.release(2) # resources available == 3
+//! [0]
+
+
+//! [1]
+sem = QSystemSemaphore("market", 5, QSystemSemaphore.Create)
+sem.acquire(5) # acquire all 5 resources
+sem.release(5) # release the 5 resources
+//! [1]
+
+
+//! [2]
+sem.release(10) # "create" 10 new resources
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qtimer.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qtimer.cpp
new file mode 100644
index 000000000..b34bdd206
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_kernel_qtimer.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+from PySide2.QtCore import QApplication, QTimer
+
+def main():
+
+ app = QApplication([])
+ QTimer.singleShot(600000, app, SLOT('quit()'))
+ ...
+ return app.exec_()
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp
new file mode 100644
index 000000000..6fe5807b9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QLibrary myLib("mylib");
+typedef void (*MyPrototype)();
+MyPrototype myFunction = (MyPrototype) myLib.resolve("mysymbol");
+if (myFunction)
+ myFunction();
+//! [0]
+
+
+//! [1]
+typedef void (*MyPrototype)();
+MyPrototype myFunction =
+ (MyPrototype) QLibrary::resolve("mylib", "mysymbol");
+if (myFunction)
+ myFunction();
+//! [1]
+
+
+//! [2]
+typedef int (*AvgFunction)(int, int);
+
+AvgFunction avg = (AvgFunction) library->resolve("avg");
+if (avg)
+ return avg(5, 8);
+else
+ return -1;
+//! [2]
+
+
+//! [3]
+extern "C" MY_EXPORT int avg(int a, int b)
+{
+ return (a + b) / 2;
+}
+//! [3]
+
+
+//! [4]
+#ifdef Q_WS_WIN
+#define MY_EXPORT __declspec(dllexport)
+#else
+#define MY_EXPORT
+#endif
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_quuid.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_quuid.cpp
new file mode 100644
index 000000000..3d19de0fe
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_quuid.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+# {67C8770B-44F1-410A-AB9A-F9B5446F13EE}
+IID_MyInterface = QUuid(0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
new file mode 100644
index 000000000..d61013239
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+//! [simple state machine]
+button = QPushButton()
+
+machine = QStateMachine()
+s1 = QState()
+s1.assignProperty(button, "text", "Click me")
+
+s2 = QFinalState()
+s1.addTransition(button, SIGNAL('clicked()'), s2)
+
+machine.addState(s1)
+machine.addState(s2)
+machine.setInitialState(s1)
+machine.start()
+//! [simple state machine]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qatomic.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qatomic.cpp
new file mode 100644
index 000000000..8632c8b4f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qatomic.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+MySharedType &MySharedType::operator=(const MySharedType &other)
+{
+ (void) other.data->atomicInt.ref();
+ if (!data->atomicInt.deref()) {
+ // The last reference has been released
+ delete d;
+ }
+ d = other.d;
+ return *this;
+}
+//! [0]
+
+
+//! [1]
+if (currentValue == expectedValue) {
+ currentValue = newValue;
+ return true;
+}
+return false;
+//! [1]
+
+
+//! [2]
+int originalValue = currentValue;
+currentValue = newValue;
+return originalValue;
+//! [2]
+
+
+//! [3]
+int originalValue = currentValue;
+currentValue += valueToAdd;
+return originalValue;
+//! [3]
+
+
+//! [4]
+if (currentValue == expectedValue) {
+ currentValue = newValue;
+ return true;
+}
+return false;
+//! [4]
+
+
+//! [5]
+T *originalValue = currentValue;
+currentValue = newValue;
+return originalValue;
+//! [5]
+
+
+//! [6]
+T *originalValue = currentValue;
+currentValue += valueToAdd;
+return originalValue;
+//! [6]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutex.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutex.cpp
new file mode 100644
index 000000000..b83164d56
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutex.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+number = 6
+
+def method1():
+ number *= 5
+ number /= 4
+
+def method2():
+ number *= 3
+ number /= 2
+//! [0]
+
+
+//! [1]
+# method1()
+number *= 5 # number is now 30
+number /= 4 # number is now 7
+
+# method2()
+number *= 3 # number is now 21
+number /= 2 # number is now 10
+//! [1]
+
+
+//! [2]
+# Thread 1 calls method1()
+number *= 5 # number is now 30
+
+# Thread 2 calls method2().
+#
+# Most likely Thread 1 has been put to sleep by the operating
+# system to allow Thread 2 to run.
+number *= 3 # number is now 90
+number /= 2 # number is now 45
+
+# Thread 1 finishes executing.
+number /= 4 # number is now 11, instead of 10
+//! [2]
+
+
+//! [3]
+mutex = QMutex()
+number = 6
+
+def method1():
+ mutex.lock()
+ number *= 5
+ number /= 4
+ mutex.unlock()
+
+def method2():
+ mutex.lock()
+ number *= 3
+ number /= 2
+ mutex.unlock()
+//! [3]
+
+
+//! [4]
+def complexFunction(flag):
+ mutex.lock()
+
+ retVal = 0
+
+ if flag == 0 or flag == 1:
+ mutex.unlock()
+ return moreComplexFunction(flag)
+ elif flag == 2:
+ status = anotherFunction()
+ if status < 0:
+ mutex.unlock()
+ return -2
+ retVal = status + flag
+ else:
+ if flag > 10:
+ mutex.unlock()
+ return -1
+
+ mutex.unlock()
+ return retVal
+//! [4]
+
+
+//! [5]
+def complexFunction(flag):
+ locker = QMutexLocker(mutex)
+
+ retVal = 0
+
+ if flag == 0 or flag == 1:
+ return moreComplexFunction(flag)
+ elif flag == 2:
+ status = anotherFunction()
+ if status < 0:
+ return -2
+ retVal = status + flag
+ else:
+ if flag > 10:
+ return -1
+
+ return retVal
+//! [5]
+
+
+//! [6]
+class SignalWaiter:
+ def __init__(mutex):
+ self.locker = mutex
+
+ def waitForSignal():
+ # ...
+ while not signalled:
+ waitCondition.wait(self.locker.mutex())
+ # ...
+//! [6]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp
new file mode 100644
index 000000000..a5e3952a8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qmutexpool.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 Number:
+ def __init__(n):
+ self.num = n
+//! [0]
+
+
+//! [1]
+def calcSquare(number):
+ locker = QMutexLocker(mutexpool.get(number))
+ number.num = number.num * number.num
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp
new file mode 100644
index 000000000..015aadfaf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qreadwritelock.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+lock = QReadWriteLock()
+
+class ReaderThread:
+ # ...
+ def run():
+ # ...
+ lock.lockForRead()
+ read_file()
+ lock.unlock()
+ # ...
+
+class WriterThread:
+ #...
+ def run():
+ # ...
+ lock.lockForWrite()
+ write_file()
+ lock.unlock()
+ # ...
+//! [0]
+
+
+//! [1]
+lock = QReadWriteLock()
+
+def readData():
+ locker = QReadLocker(lock)
+ # ...
+ return data
+//! [1]
+
+
+//! [2]
+lock = QReadWriteLock()
+
+def readData():
+ locker.lockForRead()
+ # ...
+ locker.unlock()
+ return data
+//! [2]
+
+
+//! [3]
+lock = QReadWriteLock()
+
+def writeData(data):
+ locker = QWriteLocker(lock)
+ # ...
+//! [3]
+
+
+//! [4]
+lock = QReadWriteLock()
+
+def writeData(data):
+ locker.lockForWrite()
+ # ...
+ locker.unlock()
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp
new file mode 100644
index 000000000..26cfd6a0e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qsemaphore.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+sem = QSemaphore(5) # sem.available() == 5
+
+sem.acquire(3) # sem.available() == 2
+sem.acquire(2) # sem.available() == 0
+sem.release(5) # sem.available() == 5
+sem.release(5) # sem.available() == 10
+
+sem.tryAcquire(1) # sem.available() == 9, returns true
+sem.tryAcquire(250) # sem.available() == 9, returns false
+//! [0]
+
+
+//! [1]
+sem = QSemaphore(5) # a semaphore that guards 5 resources
+sem.acquire(5) # acquire all 5 resources
+sem.release(5) # release the 5 resources
+sem.release(10) # "create" 10 new resources
+//! [1]
+
+
+//! [2]
+sem = QSemaphore(5) # sem.available() == 5
+sem.tryAcquire(250) # sem.available() == 5, returns false
+sem.tryAcquire(3) # sem.available() == 2, returns true
+//! [2]
+
+
+//! [3]
+sem = QSemaphore(5) # sem.available() == 5
+sem.tryAcquire(250, 1000) # sem.available() == 5, waits 1000 milliseconds and returns false
+sem.tryAcquire(3, 30000) # sem.available() == 2, returns true without waiting
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qthread.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qthread.cpp
new file mode 100644
index 000000000..c9c702ae4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qthread.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 MyThread (QThread):
+ def run():
+ socket = QTcpSocket()
+ # connect QTcpSocket's signals somewhere meaningful
+ # ...
+ socket.connectToHost(hostName, portNumber)
+ self.exec_()
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp
new file mode 100644
index 000000000..5ac95c9c0
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+while True:
+ mutex.lock()
+ keyPressed.wait(mutex)
+ do_something()
+ mutex.unlock()
+//! [0]
+
+
+//! [1]
+while True:
+ getchar()
+ keyPressed.wakeAll()
+
+//! [1]
+
+
+//! [2]
+while True:
+ mutex.lock()
+ keyPressed.wait(&mutex)
+ count += 1
+ mutex.unlock()
+
+ do_something()
+
+ mutex.lock()
+ count -= 1
+ mutex.unlock()
+//! [2]
+
+
+//! [3]
+while True:
+ getchar()
+
+ mutex.lock()
+ # Sleep until there are no busy worker threads
+ while count > 0:
+ mutex.unlock()
+ sleep(1)
+ mutex.lock()
+ keyPressed.wakeAll()
+ mutex.unlock()
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbitarray.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbitarray.cpp
new file mode 100644
index 000000000..03d953cd4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbitarray.cpp
@@ -0,0 +1,239 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ba = QBitArray(200)
+//! [0]
+
+
+//! [1]
+ba = QBitArray()
+ba.resize(3)
+ba[0] = True
+ba[1] = False
+ba[2] = True
+//! [1]
+
+
+//! [2]
+ba = QBitArray(3)
+ba.setBit(0, True)
+ba.setBit(1, False)
+ba.setBit(2, True)
+//! [2]
+
+
+//! [3]
+x = QBitArray(5)
+x.setBit(3, True)
+# x: [ 0, 0, 0, 1, 0 ]
+
+y = QBitArray(5)
+y.setBit(4, True)
+# y: [ 0, 0, 0, 0, 1 ]
+
+x |= y
+# x: [ 0, 0, 0, 1, 1 ]
+//! [3]
+
+
+//! [4]
+QBitArray().isNull() # returns True
+QBitArray().isEmpty() # returns True
+
+QBitArray(0).isNull() # returns False
+QBitArray(0).isEmpty() # returns True
+
+QBitArray(3).isNull() # returns False
+QBitArray(3).isEmpty() # returns False
+//! [4]
+
+
+//! [5]
+QBitArray().isNull() # returns True
+QBitArray(0).isNull() # returns False
+QBitArray(3).isNull() # returns False
+//! [5]
+
+
+//! [6]
+ba = QBitArray(8)
+ba.fill(True)
+# ba: [ 1, 1, 1, 1, 1, 1, 1, 1 ]
+
+ba.fill(False, 2)
+# ba: [ 0, 0 ]
+//! [6]
+
+
+//! [7]
+a = QBitArray(3)
+a[0] = False
+a[1] = True
+a[2] = a[0] ^ a[1]
+//! [7]
+
+
+//! [8]
+a = QBitArray(3)
+b = QBitArray(2)
+a[0] = 1
+a[1] = 0
+a[2] = 1
+# a: [ 1, 0, 1 ]
+
+b[0] = 1
+b[1] = 0
+# b: [ 1, 1 ]
+
+a &= b
+# a: [ 1, 0, 0 ]
+//! [8]
+
+
+//! [9]
+a = QBitArray(3)
+b = QBitArray(2)
+a[0] = 1
+a[1] = 0
+a[2] = 1
+# a: [ 1, 0, 1 ]
+
+b[0] = 1
+b[1] = 0
+# b: [ 1, 1 ]
+
+a |= b
+# a: [ 1, 1, 1 ]
+//! [9]
+
+
+//! [10]
+a = QBitArray(3)
+b = QBitArray(2)
+a[0] = 1
+a[1] = 0
+a[2] = 1
+# a: [ 1, 0, 1 ]
+
+b[0] = 1
+b[1] = 0
+# b: [ 1, 1 ]
+
+a ^= b
+# a: [ 0, 1, 1 ]
+//! [10]
+
+
+//! [11]
+a = QBitArray(3)
+b = QBitArray()
+a[0] = 1
+a[1] = 0
+a[2] = 1
+# a: [ 1, 0, 1 ]
+
+b = ~a
+# b: [ 0, 1, 0 ]
+//! [11]
+
+
+//! [12]
+a = QBitArray(3)
+b = QBitArray(2)
+c = QBitArray()
+a[0] = 1
+a[1] = 0
+a[2] = 1
+# a: [ 1, 0, 1 ]
+
+b[0] = 1
+b[1] = 0
+# b: [ 1, 1 ]
+
+c = a & b
+# c: [ 1, 0, 0 ]
+//! [12]
+
+
+//! [13]
+a = QBitArray(3)
+QBitArray b(2)
+QBitArray c
+a[0] = 1
+a[1] = 0
+a[2] = 1
+# a: [ 1, 0, 1 ]
+
+b[0] = 1
+b[1] = 0
+# b: [ 1, 1 ]
+
+c = a | b
+# c: [ 1, 1, 1 ]
+//! [13]
+
+
+//! [14]
+a = QBitArray(3)
+b = QBitArray(2)
+c = QBitArray()
+a[0] = 1
+a[1] = 0
+a[2] = 1
+# a: [ 1, 0, 1 ]
+
+b[0] = 1
+b[1] = 0
+# b: [ 1, 1 ]
+
+c = a ^ b
+# c: [ 0, 1, 1 ]
+//! [14]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp
new file mode 100644
index 000000000..5910bc67b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp
@@ -0,0 +1,402 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+void wrapInFunction()
+{
+
+//! [0]
+ba = QByteArray("Hello")
+//! [0]
+
+
+//! [1]
+ba = QByteArray()
+ba.resize(5)
+ba[0] = 'H'
+ba[1] = 'e'
+ba[2] = 'l'
+ba[3] = 'l'
+ba[4] = 'o'
+//! [1]
+
+
+//! [2]
+for i in range(0, ba.size()):
+ if ba.at(i) >= 'a' and ba.at(i) <= 'f':
+ print "Found character in range [a-f]"
+//! [2]
+
+
+//! [3]
+x = QByteArray("and")
+x.prepend("rock ") # x == "rock and"
+x.append(" roll") # x == "rock and roll"
+x.replace(5, 3, "&") # x == "rock & roll"
+//! [3]
+
+
+//! [4]
+ba = QByteArray("We must be <b>bold</b>, very <b>bold</b>")
+j = 0
+while (j = ba.indexOf("<b>", j)) != -1:
+ print "Found <b> tag at index position %d" % j
+ ++j
+//! [4]
+
+
+//! [5]
+QByteArray().isNull() # returns true
+QByteArray().isEmpty() # returns true
+
+QByteArray("").isNull() # returns false
+QByteArray("").isEmpty() # returns true
+
+QByteArray("abc").isNull() # returns false
+QByteArray("abc").isEmpty() # returns false
+//! [5]
+
+
+//! [6]
+ba = QByteArray("Hello")
+n = ba.size() # n == 5
+ba.data()[0] # returns 'H'
+ba.data()[4] # returns 'o'
+//! [6]
+
+
+//! [7]
+QByteArray().isEmpty() # returns true
+QByteArray("").isEmpty() # returns true
+QByteArray("abc").isEmpty() # returns false
+//! [7]
+
+
+//! [8]
+ba = QByteArray("Hello world");
+print ba.data();
+//! [8]
+
+
+//! [9]
+ba = QByteArray()
+for i in range(0, 10):
+ ba[i] = 'A' + str(i)
+# ba == "ABCDEFGHIJ"
+//! [9]
+
+
+//! [10]
+ba = QByteArray("Stockholm")
+ba.truncate(5) # ba == "Stock"
+//! [10]
+
+
+//! [11]
+ba = QByteArray("STARTTLS\r\n")
+ba.chop(2) # ba == "STARTTLS"
+//! [11]
+
+
+//! [12]
+x = QByteArray("free")
+y = QByteArray("dom");
+x += y
+# x == "freedom"
+//! [12]
+
+
+//! [13]
+QByteArray().isNull() # returns true
+QByteArray("").isNull() # returns false
+QByteArray("abc").isNull() # returns false
+//! [13]
+
+
+//! [14]
+ba = QByteArray("Istambul")
+ba.fill('o')
+# ba == "oooooooo"
+
+ba.fill('X', 2)
+# ba == "XX"
+//! [14]
+
+
+//! [15]
+x = QByteArray("ship")
+y = QByteArray("air")
+x.prepend(y)
+# x == "airship"
+//! [15]
+
+
+//! [16]
+x = QByteArray("free")
+y = QByteArray("dom")
+x.append(y)
+# x == "freedom"
+//! [16]
+
+
+//! [17]
+ba = QByteArray("Meal")
+ba.insert(1, QByteArray("ontr"))
+# ba == "Montreal"
+//! [17]
+
+
+//! [18]
+ba = QByteArray("Montreal")
+ba.remove(1, 4)
+# ba == "Meal"
+//! [18]
+
+
+//! [19]
+x = QByteArray("Say yes!")
+y = QByteArray("no")
+x.replace(4, 3, y)
+# x == "Say no!"
+//! [19]
+
+
+//! [20]
+ba = QByteArray("colour behaviour flavour neighbour")
+ba.replace(QByteArray("ou"), QByteArray("o"))
+# ba == "color behavior flavor neighbor"
+//! [20]
+
+
+//! [21]
+x = QByteArray("sticky question")
+y = QByteArray("sti")
+x.indexOf(y) # returns 0
+x.indexOf(y, 1) # returns 10
+x.indexOf(y, 10) # returns 10
+x.indexOf(y, 11) # returns -1
+//! [21]
+
+
+//! [22]
+ba = QByteArray("ABCBA")
+ba.indexOf("B") # returns 1
+ba.indexOf("B", 1) # returns 1
+ba.indexOf("B", 2) # returns 3
+ba.indexOf("X") # returns -1
+//! [22]
+
+
+//! [23]
+x = QByteArray("crazy azimuths")
+y = QByteArray("azy")
+x.lastIndexOf(y) # returns 6
+x.lastIndexOf(y, 6) # returns 6
+x.lastIndexOf(y, 5) # returns 2
+x.lastIndexOf(y, 1) # returns -1
+//! [23]
+
+
+//! [24]
+ba = QByteArray("ABCBA")
+ba.lastIndexOf("B") # returns 3
+ba.lastIndexOf("B", 3) # returns 3
+ba.lastIndexOf("B", 2) # returns 1
+ba.lastIndexOf("X") # returns -1
+//! [24]
+
+
+//! [25]
+url = QByteArray("ftp://ftp.trolltech.com/")
+if url.startsWith("ftp:"):
+ ...
+//! [25]
+
+
+//! [26]
+url = QByteArray("http://qtsoftware.com/index.html")
+if url.endsWith(".html"):
+ ...
+//! [26]
+
+
+//! [27]
+x = QByteArray("Pineapple")
+y = x.left(4)
+# y == "Pine"
+//! [27]
+
+
+//! [28]
+x = QByteArray("Pineapple")
+y = x.right(5)
+# y == "apple"
+//! [28]
+
+
+//! [29]
+x = QByteArray("Five pineapples")
+y = x.mid(5, 4) # y == "pine"
+z = x.mid(5) # z == "pineapples"
+//! [29]
+
+
+//! [30]
+x = QByteArray("TROlltECH")
+y = x.toLower()
+# y == "trolltech"
+//! [30]
+
+
+//! [31]
+x = QByteArray("TROlltECH")
+y = x.toUpper()
+# y == "TROLLTECH"
+//! [31]
+
+
+//! [32]
+ba = QByteArray(" lots\t of\nwhitespace\r\n ")
+ba = ba.simplified()
+# ba == "lots of whitespace";
+//! [32]
+
+
+//! [33]
+ba = QByteArray(" lots\t of\nwhitespace\r\n ");
+ba = ba.trimmed();
+# ba == "lots\t of\nwhitespace";
+//! [33]
+
+
+//! [34]
+x = QByteArray("apple")
+y = x.leftJustified(8, '.') # y == "apple..."
+//! [34]
+
+
+//! [35]
+x = QByteArray("apple")
+y = x.rightJustified(8, '.') # y == "...apple"
+//! [35]
+
+
+//! [36]
+string = QByteArray("FF")
+(hex, ok) = string.toInt(16) # hex == 255, ok == true
+(dec, ok) = string.toInt(10) # dec == 0, ok == false
+//! [36]
+
+
+//! [37]
+string = QByteArray("FF")
+(hex, ok) = str.toLong(16); # hex == 255, ok == true
+(dec, ok) = str.toLong(10); # dec == 0, ok == false
+//! [37]
+
+
+//! [38]
+string = QByteArray("1234.56")
+(a, ok) = string.toDouble() # a == 1234.56, ok == true
+//! [38]
+
+
+//! [39]
+text = QByteArray("Qt is great!")
+text.toBase64() # returns "UXQgaXMgZ3JlYXQh"
+//! [39]
+
+
+//! [40]
+ba = QByteArray()
+n = 63
+ba.setNum(n) # ba == "63"
+ba.setNum(n, 16) # ba == "3f"
+//! [40]
+
+
+//! [41]
+n = 63;
+QByteArray.number(n) # returns "63"
+QByteArray.number(n, 16) # returns "3f"
+QByteArray.number(n, 16).toUpper() # returns "3F"
+//! [41]
+
+
+//! [42]
+ba = QByteArray.number(12.3456, 'E', 3)
+# ba == 1.235E+01
+//! [42]
+
+
+//! [43]
+mydata = '\x00\x00\x03\x84\x78\x9c\x3b\x76'\
+ '\xec\x18\xc3\x31\x0a\xf1\xcc\x99'\
+ ...
+ '\x6d\x5b'
+
+data = QByteArray.fromRawData(mydata)
+in_ = QDataStream(data, QIODevice.ReadOnly)
+...
+//! [43]
+
+
+//! [44]
+text = QByteArray.fromBase64("UXQgaXMgZ3JlYXQh")
+text.data() # returns "Qt is great!"
+//! [44]
+
+
+//! [45]
+text = QByteArray.fromHex("517420697320677265617421")
+text.data() # returns "Qt is great!"
+//! [45]
+
+}
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qdatetime.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qdatetime.cpp
new file mode 100644
index 000000000..f3a230894
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qdatetime.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+d1 = QDate(1995, 5, 17) # May 17, 1995
+d2 = QDate(1995, 5, 20) # May 20, 1995
+d1.daysTo(d2) # returns 3
+d2.daysTo(d1) # returns -3
+//! [0]
+
+
+//! [1]
+date = QDate.fromString("1MM12car2003", "d'MM'MMcaryyyy")
+# date is 1 December 2003
+//! [1]
+
+
+//! [2]
+date = QDate.fromString("130", "Md") # invalid
+//! [2]
+
+
+//! [3]
+QDate.fromString("1.30", "M.d") # January 30 1900
+QDate.fromString("20000110", "yyyyMMdd") # January 10, 2000
+QDate.fromString("20000110", "yyyyMd") # January 10, 2000
+//! [3]
+
+
+//! [4]
+QDate.isValid(2002, 5, 17) # True
+QDate.isValid(2002, 2, 30) # False (Feb 30 does not exist)
+QDate.isValid(2004, 2, 29) # True (2004 is a leap year)
+QDate.isValid(2000, 2, 29) # True (2000 is a leap year)
+QDate.isValid(2006, 2, 29) # False (2006 is not a leap year)
+QDate.isValid(2100, 2, 29) # False (2100 is not a leap year)
+QDate.isValid(1202, 6, 6) # True (even though 1202 is pre-Gregorian)
+//! [4]
+
+
+//! [5]
+n = QTime(14, 0, 0) # n == 14:00:00
+t = QTime()
+t = n.addSecs(70) # t == 14:01:10
+t = n.addSecs(-70) # t == 13:58:50
+t = n.addSecs(10 * 60 * 60 + 5) # t == 00:00:05
+t = n.addSecs(-15 * 60 * 60) # t == 23:00:00
+//! [5]
+
+
+//! [6]
+time = QTime.fromString("1mm12car00", "m'mm'hcarss")
+# time is 12:01.00
+//! [6]
+
+
+//! [7]
+time = QTime.fromString("00:710", "hh:ms") # invalid
+//! [7]
+
+
+//! [8]
+time = QTime.fromString("1.30", "m.s")
+# time is 00:01:30.000
+//! [8]
+
+
+//! [9]
+QTime.isValid(21, 10, 30) # returns True
+QTime.isValid(22, 5, 62) # returns False
+//! [9]
+
+
+//! [10]
+t = QTime()
+t.start()
+some_lengthy_task()
+print ("Time elapsed: %d ms" % t.elapsed())
+//! [10]
+
+
+//! [11]
+now = QDateTime.currentDateTime()
+xmas(QDate(now.date().year(), 12, 25), QTime(0, 0))
+print("There are %d seconds to Christmas" % now.secsTo(xmas))
+//! [11]
+
+
+//! [12]
+time1 = QTime.fromString("131", "HHh")
+# time1 is 13:00:00
+time1 = QTime.fromString("1apA", "1amAM")
+# time1 is 01:00:00
+
+dateTime2 = QDateTime.fromString("M1d1y9800:01:02",
+ "'M'M'd'd'y'yyhh:mm:ss")
+# dateTime is 1 January 1998 00:01:02
+//! [12]
+
+
+//! [13]
+dateTime = QDateTime.fromString("130", "Mm") # invalid
+//! [13]
+
+
+//! [14]
+dateTime = QDateTime.fromString("1.30.1", "M.d.s")
+# dateTime is January 30 in 1900 at 00:00:01.
+//! [14]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qhash.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qhash.cpp
new file mode 100644
index 000000000..b742a51b3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qhash.cpp
@@ -0,0 +1,309 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QHash<QString, int> hash;
+//! [0]
+
+
+//! [1]
+hash["one"] = 1;
+hash["three"] = 3;
+hash["seven"] = 7;
+//! [1]
+
+
+//! [2]
+hash.insert("twelve", 12);
+//! [2]
+
+
+//! [3]
+int num1 = hash["thirteen"];
+int num2 = hash.value("thirteen");
+//! [3]
+
+
+//! [4]
+int timeout = 30;
+if (hash.contains("TIMEOUT"))
+ timeout = hash.value("TIMEOUT");
+//! [4]
+
+
+//! [5]
+int timeout = hash.value("TIMEOUT", 30);
+//! [5]
+
+
+//! [6]
+// WRONG
+QHash<int, QWidget *> hash;
+...
+for (int i = 0; i < 1000; ++i) {
+ if (hash[i] == okButton)
+ cout << "Found button at index " << i << endl;
+}
+//! [6]
+
+
+//! [7]
+QHashIterator<QString, int> i(hash);
+while (i.hasNext()) {
+ i.next();
+ cout << i.key() << ": " << i.value() << endl;
+}
+//! [7]
+
+
+//! [8]
+QHash<QString, int>::const_iterator i = hash.constBegin();
+while (i != hash.constEnd()) {
+ cout << i.key() << ": " << i.value() << endl;
+ ++i;
+}
+//! [8]
+
+
+//! [9]
+hash.insert("plenty", 100);
+hash.insert("plenty", 2000);
+// hash.value("plenty") == 2000
+//! [9]
+
+
+//! [10]
+QList<int> values = hash.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [10]
+
+
+//! [11]
+QHash<QString, int>::iterator i = hash.find("plenty");
+while (i != hash.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [11]
+
+
+//! [12]
+QHash<QString, int> hash;
+...
+foreach (int value, hash)
+ cout << value << endl;
+//! [12]
+
+
+//! [13]
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+class Employee
+{
+public:
+ Employee() {}
+ Employee(const QString &name, const QDate &dateOfBirth);
+ ...
+
+private:
+ QString myName;
+ QDate myDateOfBirth;
+};
+
+inline bool operator==(const Employee &e1, const Employee &e2)
+{
+ return e1.name() == e2.name()
+ && e1.dateOfBirth() == e2.dateOfBirth();
+}
+
+inline uint qHash(const Employee &key)
+{
+ return qHash(key.name()) ^ key.dateOfBirth().day();
+}
+
+#endif // EMPLOYEE_H
+//! [13]
+
+
+//! [14]
+QHash<QString, int> hash;
+hash.reserve(20000);
+for (int i = 0; i < 20000; ++i)
+ hash.insert(keys[i], values[i]);
+//! [14]
+
+
+//! [15]
+QHash<QObject *, int> objectHash;
+...
+QHash<QObject *, int>::iterator i = objectHash.find(obj);
+while (i != objectHash.end() && i.key() == obj) {
+ if (i.value() == 0) {
+ i = objectHash.erase(i);
+ } else {
+ ++i;
+ }
+}
+//! [15]
+
+
+//! [16]
+QHash<QString, int> hash;
+...
+QHash<QString, int>::const_iterator i = hash.find("HDR");
+while (i != hash.end() && i.key() == "HDR") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [16]
+
+
+//! [17]
+QHash<QString, int> hash;
+hash.insert("January", 1);
+hash.insert("February", 2);
+...
+hash.insert("December", 12);
+
+QHash<QString, int>::iterator i;
+for (i = hash.begin(); i != hash.end(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [17]
+
+
+//! [18]
+QHash<QString, int>::iterator i;
+for (i = hash.begin(); i != hash.end(); ++i)
+ i.value() += 2;
+//! [18]
+
+
+//! [19]
+QHash<QString, int>::iterator i = hash.begin();
+while (i != hash.end()) {
+ if (i.key().startsWith("_"))
+ i = hash.erase(i);
+ else
+ ++i;
+}
+//! [19]
+
+
+//! [20]
+QHash<QString, int>::iterator i = hash.begin();
+while (i != hash.end()) {
+ QHash<QString, int>::iterator prev = i;
+ ++i;
+ if (prev.key().startsWith("_"))
+ hash.erase(prev);
+}
+//! [20]
+
+
+//! [21]
+// WRONG
+while (i != hash.end()) {
+ if (i.key().startsWith("_"))
+ hash.erase(i);
+ ++i;
+}
+//! [21]
+
+
+//! [22]
+if (i.key() == "Hello")
+ i.value() = "Bonjour";
+//! [22]
+
+
+//! [23]
+QHash<QString, int> hash;
+hash.insert("January", 1);
+hash.insert("February", 2);
+...
+hash.insert("December", 12);
+
+QHash<QString, int>::const_iterator i;
+for (i = hash.constBegin(); i != hash.constEnd(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [23]
+
+
+//! [24]
+QMultiHash<QString, int> hash1, hash2, hash3;
+
+hash1.insert("plenty", 100);
+hash1.insert("plenty", 2000);
+// hash1.size() == 2
+
+hash2.insert("plenty", 5000);
+// hash2.size() == 1
+
+hash3 = hash1 + hash2;
+// hash3.size() == 3
+//! [24]
+
+
+//! [25]
+QList<int> values = hash.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [25]
+
+
+//! [26]
+QMultiHash<QString, int>::iterator i = hash.find("plenty");
+while (i != hash.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [26]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp
new file mode 100644
index 000000000..41dc8f848
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QLinkedList<int> integerList;
+QLinkedList<QTime> timeList;
+//! [0]
+
+
+//! [1]
+QLinkedList<QString> list;
+list << "one" << "two" << "three";
+// list: ["one", "two", "three"]
+//! [1]
+
+
+//! [2]
+QLinkedList<QWidget *> list;
+...
+while (!list.isEmpty())
+ delete list.takeFirst();
+//! [2]
+
+
+//! [3]
+QLinkedList<QString> list;
+list.append("one");
+list.append("two");
+list.append("three");
+// list: ["one", "two", "three"]
+//! [3]
+
+
+//! [4]
+QLinkedList<QString> list;
+list.prepend("one");
+list.prepend("two");
+list.prepend("three");
+// list: ["three", "two", "one"]
+//! [4]
+
+
+//! [5]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeAll("sun");
+// list: ["cloud", "rain"]
+//! [5]
+
+
+//! [6]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeOne("sun");
+// list: ["cloud", "sun", "rain"]
+//! [6]
+
+
+//! [7]
+QLinkedList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QLinkedList<QString>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ cout << *i << endl;
+//! [7]
+
+
+//! [8]
+QLinkedList<QString> list;
+...
+QLinkedList<QString>::iterator it = qFind(list.begin(),
+ list.end(), "Joel");
+if (it != list.end())
+ cout << "Found Joel" << endl;
+//! [8]
+
+
+//! [9]
+QLinkedList<int>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ *i += 2;
+//! [9]
+
+
+//! [10]
+QLinkedList<QString> list;
+...
+QLinkedList<QString>::iterator i = list.begin();
+while (i != list.end()) {
+ if ((*i).startsWith("_"))
+ i = list.erase(i);
+ else
+ ++i;
+}
+//! [10]
+
+
+//! [11]
+QLinkedList<QString>::iterator i = list.begin();
+while (i != list.end()) {
+ QLinkedList<QString>::iterator previous = i;
+ ++i;
+ if ((*previous).startsWith("_"))
+ list.erase(previous);
+}
+//! [11]
+
+
+//! [12]
+// WRONG
+while (i != list.end()) {
+ if ((*i).startsWith("_"))
+ list.erase(i);
+ ++i;
+}
+//! [12]
+
+
+//! [13]
+if (*it == "Hello")
+ *it = "Bonjour";
+//! [13]
+
+
+//! [14]
+QLinkedList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QLinkedList<QString>::const_iterator i;
+for (i = list.constBegin(); i != list.constEnd(); ++i)
+ cout << *i << endl;
+//! [14]
+
+
+//! [15]
+QLinkedList<QString> list;
+...
+QLinkedList<QString>::iterator it = qFind(list.constBegin(),
+ list.constEnd(), "Joel");
+if (it != list.constEnd())
+ cout << "Found Joel" << endl;
+//! [15]
+
+
+//! [16]
+std::list<double> stdlist;
+list.push_back(1.2);
+list.push_back(0.5);
+list.push_back(3.14);
+
+QLinkedList<double> list = QLinkedList<double>::fromStdList(stdlist);
+//! [16]
+
+
+//! [17]
+QLinkedList<double> list;
+list << 1.2 << 0.5 << 3.14;
+
+std::list<double> stdlist = list.toStdList();
+//! [17]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp
new file mode 100644
index 000000000..de65c5e6b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlistdata.cpp
@@ -0,0 +1,277 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QList<int> integerList;
+QList<QDate> dateList;
+//! [0]
+
+
+//! [1]
+QList<QString> list;
+list << "one" << "two" << "three";
+// list: ["one", "two", "three"]
+//! [1]
+
+
+//! [2]
+if (list[0] == "Bob")
+ list[0] = "Robert";
+//! [2]
+
+
+//! [3]
+for (int i = 0; i < list.size(); ++i) {
+ if (list.at(i) == "Jane")
+ cout << "Found Jane at position " << i << endl;
+}
+//! [3]
+
+
+//! [4]
+QList<QWidget *> list;
+...
+while (!list.isEmpty())
+ delete list.takeFirst();
+//! [4]
+
+
+//! [5]
+int i = list.indexOf("Jane");
+if (i != -1)
+ cout << "First occurrence of Jane is at position " << i << endl;
+//! [5]
+
+
+//! [6]
+QList<QString> list;
+list.append("one");
+list.append("two");
+list.append("three");
+// list: ["one", "two", "three"]
+//! [6]
+
+
+//! [7]
+QList<QString> list;
+list.prepend("one");
+list.prepend("two");
+list.prepend("three");
+// list: ["three", "two", "one"]
+//! [7]
+
+
+//! [8]
+QList<QString> list;
+list << "alpha" << "beta" << "delta";
+list.insert(2, "gamma");
+// list: ["alpha", "beta", "gamma", "delta"]
+//! [8]
+
+
+//! [9]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeAll("sun");
+// list: ["cloud", "rain"]
+//! [9]
+
+
+//! [10]
+QList<QString> list;
+list << "sun" << "cloud" << "sun" << "rain";
+list.removeOne("sun");
+// list: ["cloud", ,"sun", "rain"]
+//! [10]
+
+
+//! [11]
+QList<QString> list;
+list << "A" << "B" << "C" << "D" << "E" << "F";
+list.move(1, 4);
+// list: ["A", "C", "D", "E", "B", "F"]
+//! [11]
+
+
+//! [12]
+QList<QString> list;
+list << "A" << "B" << "C" << "D" << "E" << "F";
+list.swap(1, 4);
+// list: ["A", "E", "C", "D", "B", "F"]
+//! [12]
+
+
+//! [13]
+QList<QString> list;
+list << "A" << "B" << "C" << "B" << "A";
+list.indexOf("B"); // returns 1
+list.indexOf("B", 1); // returns 1
+list.indexOf("B", 2); // returns 3
+list.indexOf("X"); // returns -1
+//! [13]
+
+
+//! [14]
+QList<QString> list;
+list << "A" << "B" << "C" << "B" << "A";
+list.lastIndexOf("B"); // returns 3
+list.lastIndexOf("B", 3); // returns 3
+list.lastIndexOf("B", 2); // returns 1
+list.lastIndexOf("X"); // returns -1
+//! [14]
+
+
+//! [15]
+QList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QList<QString>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ cout << *i << endl;
+//! [15]
+
+
+//! [16]
+QList<int>::iterator i;
+for (i = list.begin(); i != list.end(); ++i)
+ *i += 2;
+//! [16]
+
+
+//! [17]
+QList<QWidget *> list;
+...
+qDeleteAll(list.begin(), list.end());
+//! [17]
+
+
+//! [18]
+if (*it == "Hello")
+ *it = "Bonjour";
+//! [18]
+
+
+//! [19]
+QList<QString> list;
+list.append("January");
+list.append("February");
+...
+list.append("December");
+
+QList<QString>::const_iterator i;
+for (i = list.constBegin(); i != list.constEnd(); ++i)
+ cout << *i << endl;
+//! [19]
+
+
+//! [20]
+QList<QWidget *> list;
+...
+qDeleteAll(list.constBegin(), list.constEnd());
+//! [20]
+
+
+//! [21]
+QVector<double> vect;
+vect << 20.0 << 30.0 << 40.0 << 50.0;
+
+QList<double> list = QVector<T>::fromVector(vect);
+// list: [20.0, 30.0, 40.0, 50.0]
+//! [21]
+
+
+//! [22]
+QStringList list;
+list << "Sven" << "Kim" << "Ola";
+
+QVector<QString> vect = list.toVector();
+// vect: ["Sven", "Kim", "Ola"]
+//! [22]
+
+
+//! [23]
+QSet<double> set;
+set << 20.0 << 30.0 << 40.0 << ... << 70.0;
+
+QList<double> list = QList<double>::fromSet(set);
+qSort(list);
+//! [23]
+
+
+//! [24]
+QStringList list;
+list << "Julia" << "Mike" << "Mike" << "Julia" << "Julia";
+
+QSet<QString> set = list.toSet();
+set.contains("Julia"); // returns true
+set.contains("Mike"); // returns true
+set.size(); // returns 2
+//! [24]
+
+
+//! [25]
+std::list<double> stdlist;
+list.push_back(1.2);
+list.push_back(0.5);
+list.push_back(3.14);
+
+QList<double> list = QList<double>::fromStdList(stdlist);
+//! [25]
+
+
+//! [26]
+QList<double> list;
+list << 1.2 << 0.5 << 3.14;
+
+std::list<double> stdlist = list.toStdList();
+//! [26]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlocale.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlocale.cpp
new file mode 100644
index 000000000..4a8de1a86
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qlocale.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+egyptian = QLocale(QLocale.Arabic, QLocale.Egypt)
+s1 = egyptian.toString(1.571429E+07, 'e')
+s2 = egyptian.toString(10)
+
+(d, ok) = egyptian.toDouble(s1)
+(i, ok) = egyptian.toInt(s2)
+//! [0]
+
+
+//! [1]
+QLocale.setDefault(QLocale(QLocale.Hebrew, QLocale.Israel))
+hebrew = QLocale() # Constructs a default QLocale
+s1 = hebrew.toString(15714.3, 'e')
+
+QLocale.setDefault(QLocale(QLocale.C))
+c = QLocale()
+(d, ok) = c.toDouble("1234,56") # ok == false
+(d, ok) = c.toDouble("1234.56") # ok == true, d == 1234.56
+
+QLocale.setDefault(QLocale(QLocale.German))
+german = QLocale()
+(d, ok) = german.toDouble("1234,56") # ok == true, d == 1234.56
+(d, ok) = german.toDouble("1234.56") # ok == true, d == 1234.56
+
+QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates))
+english = QLocale()
+string = '%s %s %10x' % (12345, english.toString(12345), 12345)
+# string == "12345 12,345 3039"
+//! [1]
+
+
+//! [2]
+korean = QLocale("ko")
+swiss = QLocale("de_CH")
+//! [2]
+
+
+//! [3]
+c = QLocale(QLocale.C)
+(d, ok) = c.toDouble( "1234.56" ) # ok == true, d == 1234.56
+(d, ok) = c.toDouble( "1,234.56" ) # ok == true, d == 1234.56
+(d, ok) = c.toDouble( "1234,56" ) # ok == false
+
+german = QLocale(QLocale.German)
+(d, ok) = german.toDouble( "1234,56" ) # ok == true, d == 1234.56
+(d, ok) = german.toDouble( "1.234,56" ) # ok == true, d == 1234.56
+(d, ok) = german.toDouble( "1234.56" ) # ok == false
+
+(d, ok) = german.toDouble( "1.234" ) # ok == true, d == 1234.0
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qmap.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qmap.cpp
new file mode 100644
index 000000000..da0b4dad8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qmap.cpp
@@ -0,0 +1,323 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QMap<QString, int> map;
+//! [0]
+
+
+//! [1]
+map["one"] = 1;
+map["three"] = 3;
+map["seven"] = 7;
+//! [1]
+
+
+//! [2]
+map.insert("twelve", 12);
+//! [2]
+
+
+//! [3]
+int num1 = map["thirteen"];
+int num2 = map.value("thirteen");
+//! [3]
+
+
+//! [4]
+int timeout = 30;
+if (map.contains("TIMEOUT"))
+ timeout = map.value("TIMEOUT");
+//! [4]
+
+
+//! [5]
+int timeout = map.value("TIMEOUT", 30);
+//! [5]
+
+
+//! [6]
+// WRONG
+QMap<int, QWidget *> map;
+...
+for (int i = 0; i < 1000; ++i) {
+ if (map[i] == okButton)
+ cout << "Found button at index " << i << endl;
+}
+//! [6]
+
+
+//! [7]
+QMapIterator<QString, int> i(map);
+while (i.hasNext()) {
+ i.next();
+ cout << i.key() << ": " << i.value() << endl;
+}
+//! [7]
+
+
+//! [8]
+QMap<QString, int>::const_iterator i = map.constBegin();
+while (i != map.constEnd()) {
+ cout << i.key() << ": " << i.value() << endl;
+ ++i;
+}
+//! [8]
+
+
+//! [9]
+map.insert("plenty", 100);
+map.insert("plenty", 2000);
+// map.value("plenty") == 2000
+//! [9]
+
+
+//! [10]
+QList<int> values = map.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [10]
+
+
+//! [11]
+QMap<QString, int>::iterator i = map.find("plenty");
+while (i != map.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [11]
+
+
+//! [12]
+QMap<QString, int> map;
+...
+foreach (int value, map)
+ cout << value << endl;
+//! [12]
+
+
+//! [13]
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+class Employee
+{
+public:
+ Employee() {}
+ Employee(const QString &name, const QDate &dateOfBirth);
+ ...
+
+private:
+ QString myName;
+ QDate myDateOfBirth;
+};
+
+inline bool operator<(const Employee &e1, const Employee &e2)
+{
+ if (e1.name() != e2.name())
+ return e1.name() < e2.name();
+ return e1.dateOfBirth() < e2.dateOfBirth();
+}
+
+#endif // EMPLOYEE_H
+//! [13]
+
+
+//! [14]
+QMap<QString, int> map;
+...
+QMap<QString, int>::const_iterator i = map.find("HDR");
+while (i != map.end() && i.key() == "HDR") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [14]
+
+
+//! [15]
+QMap<int, QString> map;
+map.insert(1, "one");
+map.insert(5, "five");
+map.insert(10, "ten");
+
+map.lowerBound(0); // returns iterator to (1, "one")
+map.lowerBound(1); // returns iterator to (1, "one")
+map.lowerBound(2); // returns iterator to (5, "five")
+map.lowerBound(10); // returns iterator to (10, "ten")
+map.lowerBound(999); // returns end()
+//! [15]
+
+
+//! [16]
+QMap<QString, int> map;
+...
+QMap<QString, int>::const_iterator i = map.lowerBound("HDR");
+QMap<QString, int>::const_iterator upperBound = map.upperBound("HDR");
+while (i != upperBound) {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [16]
+
+
+//! [17]
+QMap<int, QString> map;
+map.insert(1, "one");
+map.insert(5, "five");
+map.insert(10, "ten");
+
+map.upperBound(0); // returns iterator to (1, "one")
+map.upperBound(1); // returns iterator to (5, "five")
+map.upperBound(2); // returns iterator to (5, "five")
+map.upperBound(10); // returns end()
+map.upperBound(999); // returns end()
+//! [17]
+
+
+//! [18]
+QMap<QString, int> map;
+map.insert("January", 1);
+map.insert("February", 2);
+...
+map.insert("December", 12);
+
+QMap<QString, int>::iterator i;
+for (i = map.begin(); i != map.end(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [18]
+
+
+//! [19]
+QMap<QString, int>::iterator i;
+for (i = map.begin(); i != map.end(); ++i)
+ i.value() += 2;
+//! [19]
+
+
+//! [20]
+QMap<QString, int>::iterator i = map.begin();
+while (i != map.end()) {
+ if (i.key().startsWith("_"))
+ i = map.erase(i);
+ else
+ ++i;
+}
+//! [20]
+
+
+//! [21]
+QMap<QString, int>::iterator i = map.begin();
+while (i != map.end()) {
+ QMap<QString, int>::iterator prev = i;
+ ++i;
+ if (prev.key().startsWith("_"))
+ map.erase(prev);
+}
+//! [21]
+
+
+//! [22]
+// WRONG
+while (i != map.end()) {
+ if (i.key().startsWith("_"))
+ map.erase(i);
+ ++i;
+}
+//! [22]
+
+
+//! [23]
+if (i.key() == "Hello")
+ i.value() = "Bonjour";
+//! [23]
+
+
+//! [24]
+QMap<QString, int> map;
+map.insert("January", 1);
+map.insert("February", 2);
+...
+map.insert("December", 12);
+
+QMap<QString, int>::const_iterator i;
+for (i = map.constBegin(); i != map.constEnd(); ++i)
+ cout << i.key() << ": " << i.value() << endl;
+//! [24]
+
+
+//! [25]
+QMultiMap<QString, int> map1, map2, map3;
+
+map1.insert("plenty", 100);
+map1.insert("plenty", 2000);
+// map1.size() == 2
+
+map2.insert("plenty", 5000);
+// map2.size() == 1
+
+map3 = map1 + map2;
+// map3.size() == 3
+//! [25]
+
+
+//! [26]
+QList<int> values = map.values("plenty");
+for (int i = 0; i < values.size(); ++i)
+ cout << values.at(i) << endl;
+//! [26]
+
+
+//! [27]
+QMultiMap<QString, int>::iterator i = map.find("plenty");
+while (i != map.end() && i.key() == "plenty") {
+ cout << i.value() << endl;
+ ++i;
+}
+//! [27]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qpoint.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qpoint.cpp
new file mode 100644
index 000000000..3b11b62f0
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qpoint.cpp
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+p = QPoint()
+
+p.setX(p.x() + 1)
+p += QPoint(1, 0)
+//! [0]
+
+
+//! [1]
+p = QPoint(1, 2)
+#p.rx()--; // p becomes (0, 2)
+//! [1]
+
+
+//! [2]
+p = QPoint(1, 2)
+#p.ry()++; // p becomes (1, 3)
+//! [2]
+
+
+//! [3]
+p = QPoint( 3, 7)
+q = QPoint(-1, 4)
+p += q # p becomes (2, 11)
+//! [3]
+
+
+//! [4]
+p = QPoint( 3, 7)
+q = QPoint(-1, 4)
+p -= q # p becomes (4, 3)
+//! [4]
+
+
+//! [5]
+p = QPoint(-1, 4)
+p *= 2.5 # p becomes (-3, 10)
+//! [5]
+
+
+//! [6]
+p = QPoint(-3, 10)
+p /= 2.5 # p becomes (-1, 4)
+//! [6]
+
+
+//! [7]
+
+class MyWidget(QWidget):
+
+ self.oldPosition = QPointer()
+
+ # event : QMouseEvent
+ def mouseMoveEvent(QMouseEvent event):
+ point = event.pos() - self.oldPosition
+ if (point.manhattanLength() > 3):
+ # the mouse has moved more than 3 pixels since the oldPosition
+ pass
+//! [7]
+
+
+//! [8]
+trueLength = sqrt(pow(x(), 2) + pow(y(), 2))
+//! [8]
+
+
+//! [9]
+p = QPointF()
+
+p.setX(p.x() + 1.0)
+p += QPointF(1.0, 0.0)
+#p.rx()++;
+//! [9]
+
+
+//! [10]
+ p = QPointF(1.1, 2.5)
+ #p.rx()--; // p becomes (0.1, 2.5)
+//! [10]
+
+
+//! [11]
+p = QPointF(1.1, 2.5)
+#p.ry()++; // p becomes (1.1, 3.5)
+//! [11]
+
+
+//! [12]
+p = QPointF( 3.1, 7.1)
+q = QPointF(-1.0, 4.1)
+p += q # p becomes (2.1, 11.2)
+//! [12]
+
+
+//! [13]
+p = QPointF( 3.1, 7.1)
+q = QPointF(-1.0, 4.1)
+p -= q # p becomes (4.1, 3.0)
+//! [13]
+
+
+//! [14]
+p = QPointF(-1.1, 4.1)
+p *= 2.5 # p becomes (-2.75, 10.25)
+//! [14]
+
+
+//! [15]
+p = QPointF(-2.75, 10.25)
+p /= 2.5 # p becomes (-1.1, 4.1)
+//! [15]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qqueue.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qqueue.cpp
new file mode 100644
index 000000000..372cb0d5d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qqueue.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QQueue<int> queue;
+queue.enqueue(1);
+queue.enqueue(2);
+queue.enqueue(3);
+while (!queue.isEmpty())
+ cout << queue.dequeue() << endl;
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qrect.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qrect.cpp
new file mode 100644
index 000000000..1154d11a3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qrect.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+r1 = QRect(100, 200, 11, 16)
+r2 = QRect(QPoint(100, 200), QSize(11, 16))
+//! [0]
+
+
+//! [1]
+r1 = QRectF(100, 200, 11, 16)
+r2 = QRectF(QPoint(100, 200), QSize(11, 16))
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qregexp.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qregexp.cpp
new file mode 100644
index 000000000..338582651
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qregexp.cpp
@@ -0,0 +1,225 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+rx = QRegExp("(\\d+)")
+txt = "Offsets: 12 14 99 231 7"
+lst = []
+
+pos = rx.indexIn(txt, 0)
+
+while pos != -1:
+ lst.append(rx.cap(1))
+ pos += rx.matchedLength()
+ pos = rx.indexIn(txt, pos)
+
+# lst: ["12", "14", "99", "231", "7"]
+//! [0]
+
+
+//! [1]
+rx = QRegExp("*.txt")
+rx.setPatternSyntax(QRegExp.Wildcard)
+rx.exactMatch("README.txt") # returns True
+rx.exactMatch("welcome.txt.bak") # returns False
+//! [1]
+
+
+//! [2]
+rx = QRegExp("ro+m")
+rx.setMinimal(True)
+//! [2]
+
+
+//! [3]
+mark = QRegExp("\\b" # word boundary
+ "[Mm]ark" # the word we want to match
+ )
+//! [3]
+
+
+//! [4]
+rx = QRegExp("^\\d\\d?$") # match integers 0 to 99
+rx.indexIn("123") # returns -1 (no match)
+rx.indexIn("-6") # returns -1 (no match)
+rx.indexIn("6") # returns 0 (matched as position 0)
+//! [4]
+
+
+//! [5]
+rx = QRegExp("^\\S+$") # match strings without whitespace
+rx.indexIn("Hello world") # returns -1 (no match)
+rx.indexIn("This_is-OK") # returns 0 (matched at position 0)
+//! [5]
+
+
+//! [6]
+rx = QRegExp("\\b(mail|letter|correspondence)\\b")
+rx.indexIn("I sent you an email") # returns -1 (no match)
+rx.indexIn("Please write the letter") # returns 17
+//! [6]
+
+
+//! [7]
+captured = rx.cap(1) # captured == "letter"
+//! [7]
+
+
+//! [8]
+rx = QRegExp("&(?!amp;)") # match ampersands but not &amp;
+line1 = QString("This & that")
+line1.replace(rx, "&amp;") # line1 == "This &amp; that"
+line2 = QString("His &amp; hers & theirs")
+line2.replace(rx, "&amp;") # line2 == "His &amp; hers &amp; theirs"
+//! [8]
+
+
+//! [9]
+txt = QString("One Eric another Eirik, and an Ericsson. How many Eiriks, Eric?")
+rx = QRegExp("\\b(Eric|Eirik)\\b") # match Eric or Eirik
+pos = 0 # where we are in the string
+count = 0 # how many Eric and Eirik's we've counted
+
+while pos >= 0:
+ pos = rx.indexIn(txt, pos)
+ if pos >= 0:
+ pos += 1 # move along in str
+ count += 1 # count our Eric or Eirik
+//! [9]
+
+
+//! [10]
+txt = "Nokia Corporation and/or its subsidiary(-ies)\tqtsoftware.com\tNorway"
+rx.setPattern("^([^\t]+)\t([^\t]+)\t([^\t]+)$");
+if rx.indexIn(txt) != -1:
+ company = rx.cap(1)
+ web = rx.cap(2)
+ country = rx.cap(3)
+//! [10]
+
+
+//! [11]
+field = txt.split("\t")
+//! [11]
+
+
+//! [12]
+rx = QRegExp("*.html")
+rx.setPatternSyntax(QRegExp.Wildcard)
+rx.exactMatch("index.html") # returns True
+rx.exactMatch("default.htm") # returns False
+rx.exactMatch("readme.txt") # returns False
+//! [12]
+
+
+//! [13]
+txt = QString("offsets: 1.23 .50 71.00 6.00")
+rx = QRegExp("\\d*\\.\\d+") # primitive floating point matching
+count = 0
+pos = rx.indexIn(txt, 0)
+while pos != -1:
+ count += 1
+ pos += rx.matchedLength()
+ pos = rx.indexIn(txt, pos)
+
+# pos will be 9, 14, 18 and finally 24; count will end up as 4
+//! [13]
+
+
+//! [14]
+rx = QRegExp("(\\d+)(\\s*)(cm|inch(es)?)")
+pos = rx.indexIn("Length: 36 inches")
+lst = rx.capturedTexts()
+# lst is now ("36 inches", "36", " ", "inches", "es")
+//! [14]
+
+
+//! [15]
+rx = QRegExp("(\\d+)(?:\\s*)(cm|inch(?:es)?)")
+pos = rx.indexIn("Length: 36 inches")
+lst = rx.capturedTexts()
+# lst is now ("36 inches", "36", "inches")
+//! [15]
+
+
+//! [16]
+for a in rx.capturedTexts():
+ myProcessing(a)
+//! [16]
+
+
+//! [17]
+rxlen = QRegExp("(\\d+)(?:\\s*)(cm|inch)")
+pos = rxlen.indexIn("Length: 189cm")
+if pos > -1:
+ value = rxlen.cap(1) # "189"
+ unit = rxlen.cap(2) # "cm"
+//! [17]
+
+
+//! [18]
+rx = QRegExp("/([a-z]+)/([a-z]+)")
+rx.indexIn("Output /dev/null") # returns 7 (position of /dev/null)
+rx.pos(0) # returns 7 (position of /dev/null)
+rx.pos(1) # returns 8 (position of dev)
+rx.pos(2) # returns 12 (position of null)
+//! [18]
+
+
+//! [19]
+s1 = QRegExp.escape("bingo") # s1 == "bingo"
+s2 = QRegExp.escape("f(x)") # s2 == "f\\(x\\)"
+//! [19]
+
+
+//! [20]
+rx = QRegExp("(" + QRegExp.escape(name) + "|" + QRegExp.escape(alias) + ")")
+//! [20]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qsize.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qsize.cpp
new file mode 100644
index 000000000..7897e141c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qsize.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+t1 = QSize(10, 12)
+t1.scale(60, 60, Qt.IgnoreAspectRatio)
+# t1 is (60, 60)
+
+t2 = QSize(10, 12)
+t2.scale(60, 60, Qt.KeepAspectRatio)
+# t2 is (50, 60)
+
+t3 = QSize(10, 12)
+t3.scale(60, 60, Qt.KeepAspectRatioByExpanding)
+# t3 is (60, 72)
+//! [0]
+
+
+//! [1]
+size = QSize(100, 10)
+size.rwidth() += 20
+
+#size becomes (120,10)
+//! [1]
+
+
+//! [2]
+size = QSize(100, 10)
+size.rheight() += 5
+
+# size becomes (100,15)
+//! [2]
+
+
+//! [3]
+s = QSize( 3, 7)
+r = QSize(-1, 4)
+s += r
+
+# s becomes (2,11)
+//! [3]
+
+
+//! [4]
+s = QSize( 3, 7)
+r = QSize(-1, 4)
+s -= r
+
+# s becomes (4,3)
+//! [4]
+
+
+//! [5]
+t1 = QSizeF(10, 12)
+t1.scale(60, 60, Qt.IgnoreAspectRatio)
+# t1 is (60, 60)
+
+t2 = QSizeF(10, 12)
+t2.scale(60, 60, Qt.KeepAspectRatio)
+# t2 is (50, 60)
+
+t3 = QSizeF(10, 12)
+t3.scale(60, 60, Qt.KeepAspectRatioByExpanding)
+# t3 is (60, 72)
+//! [5]
+
+
+//! [6]
+size = QSizeF(100.3, 10)
+size.rwidth() += 20.5
+
+# size becomes (120.8,10)
+//! [6]
+
+
+//! [7]
+size = QSizeF(100, 10.2)
+size.rheight() += 5.5
+
+# size becomes (100,15.7)
+//! [7]
+
+
+//! [8]
+s = QSizeF( 3, 7)
+r = QSizeF(-1, 4)
+s += r
+
+# s becomes (2,11)
+//! [8]
+
+
+//! [9]
+s = QSizeF( 3, 7)
+r = QSizeF(-1, 4)
+s -= r
+
+# s becomes (4,3)
+//! [9]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qstring.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qstring.cpp
new file mode 100644
index 000000000..17ca6bd8d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qstring.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+DEFINES += QT_NO_CAST_FROM_ASCII \
+ QT_NO_CAST_TO_ASCII
+//! [0]
+
+
+//! [1]
+url = QLatin1String("http://www.unicode.org/")
+//! [1]
+
+
+//! [2]
+d = 12.34;
+str = QString("delta: %1").arg(d, 0, 'E', 3)
+# str == "delta: 1.234E+01"
+//! [2]
+
+
+//! [3]
+if str == "auto" || str == "extern" || str == "static" || str == "register":
+ ...
+//! [3]
+
+
+//! [4]
+if str == QString("auto") ||
+ str == QString("extern") ||
+ str == QString("static") ||
+ str == QString("register"):
+ ...
+//! [4]
+
+
+//! [5]
+if str == QLatin1String("auto") ||
+ str == QLatin1String("extern") ||
+ str == QLatin1String("static") ||
+ str == QLatin1String("register"):
+ ...
+//! [5]
+
+
+//! [6]
+label = QLabel(QLatin1String("MOD"), self)
+//! [6]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qtimeline.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qtimeline.cpp
new file mode 100644
index 000000000..a82785b7f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qtimeline.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+...
+progressBar = QProgressBar(self)
+progressBar.setRange(0, 100)
+
+# Construct a 1-second timeline with a frame range of 0 - 100
+timeLine = QTimeLine(1000, self)
+timeLine.setFrameRange(0, 100)
+timeLine.frameChanged[int].connect(progressBar.setValue)
+
+# Clicking the push button will start the progress bar animation
+pushButton = QPushButton(QObject.tr("Start animation"), self)
+pushButton.clicked.connect(timeLine.start)
+...
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qvector.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qvector.cpp
new file mode 100644
index 000000000..d11a1b4bf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_tools_qvector.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QVector<int> integerVector;
+QVector<QString> stringVector;
+//! [0]
+
+
+//! [1]
+QVector<QString> vector(200);
+//! [1]
+
+
+//! [2]
+QVector<QString> vector(200, "Pass");
+//! [2]
+
+
+//! [3]
+if (vector[0] == "Liz")
+ vector[0] = "Elizabeth";
+//! [3]
+
+
+//! [4]
+for (int i = 0; i < vector.size(); ++i) {
+ if (vector.at(i) == "Alfonso")
+ cout << "Found Alfonso at position " << i << endl;
+}
+//! [4]
+
+
+//! [5]
+int i = vector.indexOf("Harumi");
+if (i != -1)
+ cout << "First occurrence of Harumi is at position " << i << endl;
+//! [5]
+
+
+//! [6]
+QVector<int> vector(10);
+int *data = vector.data();
+for (int i = 0; i < 10; ++i)
+ data[i] = 2 * i;
+//! [6]
+
+
+//! [7]
+QVector<QString> vector(0);
+vector.append("one");
+vector.append("two");
+vector.append("three");
+// vector: ["one", "two", "three"]
+//! [7]
+
+
+//! [8]
+QVector<QString> vector;
+vector.prepend("one");
+vector.prepend("two");
+vector.prepend("three");
+// vector: ["three", "two", "one"]
+//! [8]
+
+
+//! [9]
+QVector<QString> vector;
+vector << "alpha" << "beta" << "delta";
+vector.insert(2, "gamma");
+// vector: ["alpha", "beta", "gamma", "delta"]
+//! [9]
+
+
+//! [10]
+QVector<double> vector;
+vector << 2.718 << 1.442 << 0.4342;
+vector.insert(1, 3, 9.9);
+// vector: [2.718, 9.9, 9.9, 9.9, 1.442, 0.4342]
+//! [10]
+
+
+//! [11]
+QVector<QString> vector(3);
+vector.fill("Yes");
+// vector: ["Yes", "Yes", "Yes"]
+
+vector.fill("oh", 5);
+// vector: ["oh", "oh", "oh", "oh", "oh"]
+//! [11]
+
+
+//! [12]
+QVector<QString> vector;
+vector << "A" << "B" << "C" << "B" << "A";
+vector.indexOf("B"); // returns 1
+vector.indexOf("B", 1); // returns 1
+vector.indexOf("B", 2); // returns 3
+vector.indexOf("X"); // returns -1
+//! [12]
+
+
+//! [13]
+QList<QString> vector;
+vector << "A" << "B" << "C" << "B" << "A";
+vector.lastIndexOf("B"); // returns 3
+vector.lastIndexOf("B", 3); // returns 3
+vector.lastIndexOf("B", 2); // returns 1
+vector.lastIndexOf("X"); // returns -1
+//! [13]
+
+
+//! [14]
+QVector<double> vect;
+vect << "red" << "green" << "blue" << "black";
+
+QList<double> list = vect.toList();
+// list: ["red", "green", "blue", "black"]
+//! [14]
+
+
+//! [15]
+QStringList list;
+list << "Sven" << "Kim" << "Ola";
+
+QVector<QString> vect = QVector<QString>::fromList(list);
+// vect: ["Sven", "Kim", "Ola"]
+//! [15]
+
+
+//! [16]
+std::vector<double> stdvector;
+vector.push_back(1.2);
+vector.push_back(0.5);
+vector.push_back(3.14);
+
+QVector<double> vector = QVector<double>::fromStdVector(stdvector);
+//! [16]
+
+
+//! [17]
+QVector<double> vector;
+vector << 1.2 << 0.5 << 3.14;
+
+std::vector<double> stdvector = vector.toStdVector();
+//! [17]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp
new file mode 100644
index 000000000..591712c1e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_corelib_xml_qxmlstream.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+xml = QXmlStreamReader()
+...
+while not xml.atEnd():
+ xml.readNext();
+ ... # do processing
+
+if xml.hasError():
+ ... # do error handling
+
+//! [0]
+
+
+//! [1]
+writeStartElement(qualifiedName)
+writeCharacters(text)
+writeEndElement()
+//! [1]
+
+
+//! [2]
+writeStartElement(namespaceUri, name)
+writeCharacters(text)
+writeEndElement()
+//! [2]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp
new file mode 100644
index 000000000..95285f91f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+child = QAccessibleInterface()
+targetChild = object.navigate(Accessible.Child, 1, child)
+if child:
+ # ...
+ del child
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp
new file mode 100644
index 000000000..aa1cc23b6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+printDialog = QPrintDialog(printer, parent)
+if printDialog.exec_() == QDialog.Accepted:
+ # print ...
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp
new file mode 100644
index 000000000..f3a472a1c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+fileName = QFileDialog.getOpenFileName(self,
+ tr("Open Image"), "/home/jana", tr("Image Files (*.png *.jpg *.bmp)"))
+//! [0]
+
+
+//! [1]
+"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
+//! [1]
+
+
+//! [2]
+dialog = QFileDialog(self)
+dialog.setFileMode(QFileDialog.AnyFile)
+//! [2]
+
+
+//! [3]
+dialog.setNameFilter(tr("Images (*.png *.xpm *.jpg)"))
+//! [3]
+
+
+//! [4]
+dialog.setViewMode(QFileDialog.Detail)
+//! [4]
+
+
+//! [5]
+if dialog.exec_():
+ fileNames = dialog.selectedFiles()
+//! [5]
+
+
+//! [6]
+dialog.setNameFilter("All C++ files (*.cpp *.cc *.C *.cxx *.c++)")
+dialog.setNameFilter("*.cpp *.cc *.C *.cxx *.c++")
+//! [6]
+
+
+//! [7]
+filters = QStringList()
+filters << "Image files (*.png *.xpm *.jpg)"
+ << "Text files (*.txt)"
+ << "Any files (*)"
+
+dialog = QFileDialog(this)
+dialog.setNameFilters(filters)
+dialog.exec_()
+//! [7]
+
+
+//! [8]
+fileName = QFileDialog.getOpenFileName(self, tr("Open File"),
+ "/home",
+ tr("Images (*.png *.xpm *.jpg)"))
+//! [8]
+
+
+//! [9]
+files = QFileDialog.getOpenFileNames(self,
+ "Select one or more files to open",
+ "/home",
+ "Images (*.png *.xpm *.jpg)")
+//! [9]
+
+
+//! [10]
+for it in list:
+ myProcessing(it)
+ it++
+//! [10]
+
+
+//! [11]
+fileName = QFileDialog.getSaveFileName(self, tr("Save F:xile"),
+ "/home/jana/untitled.png",
+ tr("Images (*.png *.xpm *.jpg)"))
+//! [11]
+
+
+//! [12]
+dir = QFileDialog.getExistingDirectory(self, tr("Open Directory"),
+ "/home",
+ QFileDialog.ShowDirsOnly
+ | QFileDialog.DontResolveSymlinks)
+//! [12]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp
new file mode 100644
index 000000000..d32fe6223
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+
+(ok, font) = QFontDialog.getFont(QFont("Helvetica [Cronyx]", 10), self)
+if ok:
+ # the user clicked OK and font is set to the font the user selected
+else:
+ # the user canceled the dialog; font is set to the initial
+ # value, in this case Helvetica [Cronyx], 10
+//! [0]
+
+
+//! [1]
+myWidget.setFont(QFontDialog.getFont(0, myWidget.font()))
+//! [1]
+
+
+//! [2]
+(ok, font) = QFontDialog.getFont(QFont("Times", 12), self)
+if ok:
+ # font is set to the font the user selected
+else:
+ # the user canceled the dialog; font is set to the initial
+ # value, in this case Times, 12.
+//! [2]
+
+
+//! [3]
+myWidget.setFont(QFontDialog.getFont(0, myWidget.font()))
+//! [3]
+
+
+//! [4]
+
+(ok, font) = QFontDialog.getFont(self)
+if ok:
+ # font is set to the font the user selected
+else:
+ # the user canceled the dialog; font is set to the default
+ # application font, QApplication.font()
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp
new file mode 100644
index 000000000..be4586376
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ret = QMessageBox.warning(self, self.tr("My Application"),
+ self.tr("The document has been modified.\n" + \
+ "Do you want to save your changes?"),
+ QMessageBox.Save | QMessageBox.Discard
+ | QMessageBox.Cancel,
+ QMessageBox.Save)
+//! [0]
+
+
+//! [1]
+msgBox = QMessageBox()
+msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
+result = msgBox.exec_()
+
+if result == QMessageBox.Yes:
+ # yes was clicked
+elif result == QMessageBox.No:
+ # no was clicked
+else:
+ # should never be reached
+//! [1]
+
+
+//! [2]
+msgBox = QMessageBox()
+connectButton = msgBox.addButton(self.tr("Connect"), QMessageBox.ActionRole)
+abortButton = msgBox.addButton(QMessageBox.Abort)
+
+msgBox.exec_()
+
+if msgBox.clickedButton() == connectButton:
+ # connect
+elif msgBox.clickedButton() == abortButton:
+ # abort
+}
+//! [2]
+
+
+//! [3]
+messageBox = QMessageBox(self)
+disconnectButton = messageBox.addButton(self.tr("Disconnect"),
+ QMessageBox.ActionRole)
+...
+messageBox.exec_()
+if messageBox.clickedButton() == disconnectButton:
+ ...
+
+//! [3]
+
+
+//! [4]
+#include <QApplication>
+#include <QMessageBox>
+
+int main(int argc, char *argv[])
+{
+# Not Supported by PySide
+ QT_REQUIRE_VERSION(argc, argv, "4.0.2")
+
+ QApplication app(argc, argv);
+ ...
+ return app.exec();
+}
+//! [4]
+
+//! [5]
+msgBox = QMessageBox()
+msgBox.setText("The document has been modified.")
+msgBox.exec_()
+//! [5]
+
+//! [6]
+msgBox = QMessageBox()
+msgBox.setText("The document has been modified.")
+msgBox.setInformativeText("Do you want to save your changes?")
+msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
+msgBox.setDefaultButton(QMessageBox.Save)
+ret = msgBox.exec_()
+//! [6]
+
+//! [7]
+
+if ret == QMessageBox.Save:
+ # Save was clicked
+elif ret == QMessageBox.Discard:
+ # Don't save was clicked
+elif ret == QMessageBox.Cancel:
+ # cancel was clicked
+else:
+ # should never be reached
+
+//! [7]
+
+//! [9]
+msgBox = QMessageBox(self)
+msgBox.setText(tr("The document has been modified.\n" + \
+ "Do you want to save your changes?"))
+msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard
+ | QMessageBox.Cancel)
+msgBox.setDefaultButton(QMessageBox.Save)
+//! [9]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qwizard.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qwizard.cpp
new file mode 100644
index 000000000..0112271b5
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_dialogs_qwizard.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def nextId(self):
+ id = self.currentId()
+ if id == Page_Intro:
+ if field("intro.evaluate").toBool():
+ return Page_Evaluate
+ else:
+ return Page_Register
+ elif id == Page_Evaluate:
+ return Page_Conclusion
+ elif id == Page_Register:
+ if field("register.upgradeKey").toString().isEmpty():
+ return Page_Details
+ else:
+ return Page_Conclusion
+ elif id == Page_Details:
+ return Page_Conclusion
+ else:
+ return -1
+//! [0]
+
+
+//! [1]
+class MyWizard(QWizard):
+ def __init__(self, parent):
+ QWizard.__ini__(self, parent)
+ ...
+ layout = [QWizard.Stretch, QWizard.BackButton, QWizard.CancelButton, QWizard.NextButton, QWizard.FinishButton]
+ setButtonLayout(layout);
+ ...
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp
new file mode 100644
index 000000000..7a04f492a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def draw(self, painter):
+ # Fully opaque draw directly without going through a pixmap.
+ if qFuzzyCompare(self.opacity, 1):
+ drawSource(painter)
+ return
+ # ...
+//! [0]
+
+//! [1]
+def draw(self, painter):
+ # ...
+ offset = QPoint()
+ if self.sourceIsPixmap():
+ # No point in drawing in device coordinates (pixmap will be scaled anyways).
+ pixmap = sourcePixmap(Qt.LogicalCoordinates, offset)
+ ...
+ painter.drawPixmap(offset, pixmap)
+ else:
+ # Draw pixmap in device coordinates to avoid pixmap scaling
+ pixmap = sourcePixmap(Qt.DeviceCoordinates, offset)
+ painter.setWorldTransform(QTransform())
+ # ...
+ painter.drawPixmap(offset, pixmap)
+ # ...
+//! [1]
+
+//! [2]
+# ...
+alphaGradient = QLinearGradient(rect.topLeft(), rect.bottomLeft())
+alphaGradient.setColorAt(0.0, Qt.transparent)
+alphaGradient.setColorAt(0.5, Qt.black)
+alphaGradient.setColorAt(1.0, Qt.transparent)
+effect = QGraphicsOpacityEffect()
+effect.setOpacityMask(alphaGradient)
+# ...
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp
new file mode 100644
index 000000000..201138e90
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+scene = QGraphicsScene()
+textEdit = scene.addWidget(QTextEdit())
+pushButton = scene.addWidget(QPushButton())
+
+layout = QGraphicsGridLayout()
+layout.addItem(textEdit, 0, 0)
+layout.addItem(pushButton, 0, 1)
+
+form = QGraphicsWidget()
+form.setLayout(layout)
+scene.addItem(form)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp
new file mode 100644
index 000000000..67e588075
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp
@@ -0,0 +1,249 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 SimpleItem(QGraphicsItem):
+
+ def boundingRect(self):
+ penWidth = 1.0
+ return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
+ 20 + penWidth, 20 + penWidth)
+
+ def paint(self, painter, option, widget):
+ painter.drawRoundedRect(-10, -10, 20, 20, 5, 5)
+//! [0]
+
+
+//! [1]
+class CustomItem(QGraphicsItem):
+ ...
+ self.Type = QGraphicsItem.UserType + 1
+
+ def type(self):
+ # Enable the use of qgraphicsitem_cast with this item.
+ return self.Type
+ ...
+
+//! [1]
+
+
+//! [2]
+item.setCursor(Qt.IBeamCursor)
+//! [2]
+
+
+//! [3]
+item.setCursor(Qt.IBeamCursor)
+//! [3]
+
+
+//! [4]
+rect = QGraphicsRectItem()
+rect.setPos(100, 100)
+
+rect.sceneTransform().map(QPointF(0, 0))
+# returns QPointF(100, 100)
+
+rect.sceneTransform().inverted().map(QPointF(100, 100))
+# returns QPointF(0, 0);
+//! [4]
+
+
+//! [5]
+rect = QGraphicsRectItem()
+rect.setPos(100, 100)
+
+rect.deviceTransform(view.viewportTransform()).map(QPointF(0, 0))
+# returns the item's (0, 0) point in view's viewport coordinates
+
+rect.deviceTransform(view.viewportTransform()).inverted().map(QPointF(100, 100))
+# returns view's viewport's (100, 100) coordinate in item coordinates
+//! [5]
+
+
+//! [6]
+# Rotate an item 45 degrees around (0, 0)
+item.rotate(45)
+
+# Rotate an item 45 degrees around (x, y)
+item.setTransform(QTransform().translate(x, y).rotate(45).translate(-x, -y))
+//! [6]
+
+
+//! [7]
+# Scale an item by 3x2 from its origin
+item.scale(3, 2)
+
+# Scale an item by 3x2 from (x, y)
+item.setTransform(QTransform().translate(x, y).scale(3, 2).translate(-x, -y))
+//! [7]
+
+
+//! [8]
+def boundingRect(self):
+ penWidth = 1.0
+ return QRectF(-radius - penWidth / 2, -radius - penWidth / 2,
+ diameter + penWidth, diameter + penWidth)
+//! [8]
+
+
+//! [9]
+def shape(self):
+ path = QPainterPath()
+ path.addEllipse(boundingRect())
+ return path
+//! [9]
+
+
+//! [10]
+def paint(self, painter, option, widget):
+ painter.drawRoundedRect(-10, -10, 20, 20, 5, 5)
+//! [10]
+
+
+//! [11]
+ObjectName = 0;
+
+item = scene.itemAt(100, 50)
+if len(item.data(ObjectName)) == 0:
+ if isinstance(ButtonItem, item):
+ item.setData(ObjectName, "Button")
+//! [11]
+
+
+//! [12]
+scene = QGraphicsScene()
+ellipse = scene.addEllipse(QRectF(-10, -10, 20, 20))
+line = scene.addLine(QLineF(-10, -10, 20, 20))
+
+line.installSceneEventFilter(ellipse)
+# line's events are filtered by ellipse's sceneEventFilter() function.
+
+ellipse.installSceneEventFilter(line)
+# ellipse's events are filtered by line's sceneEventFilter() function.
+//! [12]
+
+
+//! [13]
+def contextMenuEvent(self, event):
+ menu = QMenu()
+ removeAction = menu.addAction("Remove")
+ markAction = menu.addAction("Mark")
+ selectedAction = menu.exec(event.screenPos())
+ // ...
+//! [13]
+
+
+//! [14]
+def __init__(self):
+ self.setAcceptDrops(true)
+ ...
+
+def dragEnterEvent(self, event):
+ event.setAccepted(event.mimeData().hasFormat("text/plain"))
+//! [14]
+
+
+//! [15]
+def itemChange(self, change, value):
+ if change == ItemPositionChange && scene():
+ # value is the new position.
+ rect = scene().sceneRect()
+ if !rect.contains(value):
+ # Keep the item inside the scene rect.
+ value.setX(qMin(rect.right(), qMax(value.x(), rect.left())))
+ value.setY(qMin(rect.bottom(), qMax(value.y(), rect.top())))
+ return value
+ return QGraphicsItem.itemChange(self, change, value)
+//! [15]
+
+
+//! [16]
+def setRadius(self, newRadius):
+ if radius != newRadius:
+ prepareGeometryChange()
+ radius = newRadius
+//! [16]
+
+
+//! [17]
+# Group all selected items together
+group = scene.createItemGroup(scene.selecteditems())
+
+# Destroy the group, and delete the group item
+scene.destroyItemGroup(group)
+//! [17]
+
+
+//! [QGraphicsItem type]
+class CustomItem(QGraphicsItem):
+ ...
+ self.Type = QGraphicsItem.UserType + 1
+
+ def type(self):
+ # Enable the use of qgraphicsitem_cast with this item.
+ return self.Type
+ ...
+//! [QGraphicsItem type]
+
+//! [18]
+class QGraphicsPathItem (QAbstractGraphicsShapeItem):
+ Type = 2
+
+ def type(self):
+ return QGraphicsPathItem.Type
+# ...
+//! [18]
+
+//! [19]
+xform = item.deviceTransform(view.viewportTransform())
+deviceRect = xform.mapRect(rect).toAlignedRect()
+view.viewport().scroll(dx, dy, deviceRect)
+//! [19]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp
new file mode 100644
index 000000000..77e7c0149
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+scene = QGraphicsScene()
+textEdit = scene.addWidget(QTextEdit())
+pushButton = scene.addWidget(QPushButton())
+
+layout = QGraphicsLinearLayout()
+layout.addItem(textEdit)
+layout.addItem(pushButton)
+
+form = QGraphicsWidget()
+form.setLayout(layout)
+scene.addItem(form)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp
new file mode 100644
index 000000000..518af80ce
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+import sys
+
+QApplication app(sys.argv)
+
+tabWidget = QTabWidget()
+
+scene = QGraphicsScene()
+proxy = scene.addWidget(tabWidget)
+
+view = QGraphicsView(scene)
+view.show()
+
+return app.exec_()
+//! [0]
+
+//! [1]
+groupBox = QGroupBox("Contact Details")
+numberLabel = QLabel("Telephone number")
+numberEdit = QLineEdit()
+
+layout = QFormLayout()
+layout.addRow(numberLabel, numberEdit)
+groupBox.setLayout(layout)
+
+scene = QGraphicsScene()
+proxy = scene.addWidget(groupBox)
+
+view = QGraphicsView(scene)
+view.show()
+//! [1]
+
+//! [2]
+scene = QGraphicsScene()
+
+edit = QLineEdit()
+proxy = scene.addWidget(edit)
+
+edit.isVisible() // returns true
+proxy.isVisible() // also returns true
+
+edit.hide()
+
+edit.isVisible() // returns false
+proxy.isVisible() // also returns false
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp
new file mode 100644
index 000000000..0538cbaef
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+scene = QGraphicsScene()
+scene.addText("Hello, world!")
+
+view = QGraphicsView(&scene)
+view.show()
+//! [0]
+
+
+//! [1]
+scene = QGraphicsScene
+scene.addItem(...
+...
+printer = QPrinter(QPrinter.HighResolution)
+printer.setPaperSize(QPrinter.A4)
+
+painter = QPainter(printer)
+scene.render(&painter)
+//! [1]
+
+
+//! [2]
+segmentSize = sceneRect().size() / math.pow(2, depth - 1)
+//! [2]
+
+
+//! [3]
+scene = QGraphicsScene()
+view = QGraphicsView(scene)
+view.show()
+
+# a blue background
+scene.setBackgroundBrush(Qt.blue)
+
+# a gradient background
+gradient = QRadialGradient(0, 0, 10)
+gradient.setSpread(QGradient.RepeatSpread)
+scene.setBackgroundBrush(gradient)
+//! [3]
+
+
+//! [4]
+scene = QGraphicsScene()
+view = QGraphicsView(scene)
+view.show()
+
+# a white semi-transparent foreground
+scene.setForegroundBrush(QColor(255, 255, 255, 127))
+
+# a grid foreground
+scene.setForegroundBrush(QBrush(Qt.lightGray, Qt.CrossPattern))
+//! [4]
+
+
+//! [5]
+class TileScene (QGraphicsScene):
+ # ...
+ def rectForTile(x, y):
+ # Return the rectangle for the tile at position (x, y).
+ return QRectF(x * self.tileWidth, y * self.tileHeight, self.tileWidth, self.tileHeight)
+
+ def setTile(x, y, pixmap):
+ # Sets or replaces the tile at position (x, y) with pixmap.
+ if x >= 0 && x < self.numTilesH && y >= 0 && y < self.numTilesV:
+ self.tiles[y][x] = pixmap
+ invalidate(rectForTile(x, y), BackgroundLayer)
+
+ def drawBackground(painter, exposed):
+ # Draws all tiles that intersect the exposed area.
+ for y in range(0, self.numTilesV:
+ for x in range(0, self.numTilesH:
+ rect = rectForTile(x, y)
+ if exposed.intersects(rect):
+ painter.drawPixmap(rect.topLeft(), tiles[y][x])
+//! [5]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp
new file mode 100644
index 000000000..4cf7d8411
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+
+setDropAction(proposedAction())
+
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
new file mode 100644
index 000000000..5a1c7bb7d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+scene = QGraphicsScene()
+scene.addText("Hello, world!")
+
+view = QGraphicsView(scene)
+view.show()
+//! [0]
+
+
+//! [1]
+scene = QGraphicsScene()
+scene.addRect(QRectF(-10, -10, 20, 20))
+
+view = QGraphicsView(scene)
+view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
+view.show()
+//! [1]
+
+
+//! [2]
+view = QGraphicsView()
+view.setBackgroundBrush(QImage(":/images/backgroundtile.png"))
+view.setCacheMode(QGraphicsView.CacheBackground)
+//! [2]
+
+
+//! [3]
+scene = QGraphicsScene()
+scene.addText("GraphicsView rotated clockwise")
+
+view = QGraphicsView(scene)
+view.rotate(90) # the text is rendered with a 90 degree clockwise rotation
+view.show()
+//! [3]
+
+
+//! [4]
+scene = QGraphicsScene()
+scene.addItem(...
+...
+
+view = QGraphicsView(scene)
+view.show()
+...
+
+printer = QPrinter(QPrinter.HighResolution)
+printer.setPageSize(QPrinter.A4)
+painter = QPainter(printer)
+
+# print, fitting the viewport contents into a full page
+view.render(painter)
+
+# print the upper half of the viewport into the lower.
+# half of the page.
+viewport = view.viewport()->rect()
+view.render(painter,
+ QRectF(0, printer.height() / 2,
+ printer.width(), printer.height() / 2),
+ viewport.adjusted(0, 0, 0, -viewport.height() / 2))
+
+//! [4]
+
+
+//! [5]
+def mousePressEvent(self, event):
+ print "There are", items(event->pos()).size(), "items at position", mapToScene(event->pos())
+//! [5]
+
+
+//! [6]
+def mousePressEvent(self, event):
+ if (item = itemAt(event.pos()):
+ print "You clicked on item", item
+ else:
+ print "You didn't click on an item."
+//! [6]
+
+
+//! [7]
+scene = QGraphicsScene()
+scene.addText("GraphicsView rotated clockwise")
+
+view = QGraphicsView(scene)
+view.rotate(90) # the text is rendered with a 90 degree clockwise rotation
+view.show()
+//! [7]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp
new file mode 100644
index 000000000..f23f6e176
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 MyGroupBoxWidget (QStyleOptionGroupBox):
+ # ...
+ def initStyleOption(option):
+ QGraphicsWidget.initStyleOption(self, option)
+ if isinstance(option, QStyleOptionGroupBox):
+ # Add group box specific state.
+ box.flat = isFlat()
+ # ...
+//! [0]
+
+
+//! [1]
+setTabOrder(a, b) # a to b
+setTabOrder(b, c) # a to b to c
+setTabOrder(c, d) # a to b to c to d
+//! [1]
+
+
+//! [2]
+# WRONG
+setTabOrder(c, d) # c to d
+setTabOrder(a, b) # a to b AND c to d
+setTabOrder(b, c) # a to b to c, but not c to d
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qbitmap.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qbitmap.cpp
new file mode 100644
index 000000000..92af1464e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qbitmap.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+uchar arrow_bits[] = { 0x3f, 0x1f, 0x0f, 0x1f, 0x3b, 0x71, 0xe0, 0xc0 };
+QBitmap bm(8, 8, arrow_bits, true);
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qicon.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qicon.cpp
new file mode 100644
index 000000000..37c6a1baa
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qicon.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+button = QToolButton()
+button.setIcon(QIcon("open.xpm"))
+//! [0]
+
+
+//! [1]
+button.setIcon(QIcon())
+//! [1]
+
+
+//! [2]
+def drawIcon(self, painter, pos):
+ enabledStatus = QIcon.Normal
+ if not isEnabled():
+ enabledStatus = QIcon::Disabled
+
+ onOff = QIcon.On
+ if not isOn():
+ onOff = QIcon.Off
+
+ pixmap = self.icon.pixmap(QSize(22, 22), enabledStatus, onOff)
+ painter.drawPixmap(pos, pixmap)
+//! [2]
+
+//! [3]
+ undoicon = QIcon.fromTheme("edit-undo")
+//! [3]
+
+//! [4]
+ undoicon = QIcon.fromTheme("edit-undo", QIcon(":/undo.png"))
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimage.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimage.cpp
new file mode 100644
index 000000000..3a3083697
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimage.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+image = QImage(3, 3, QImage.Format_RGB32)
+
+value = qRgb(189, 149, 39) # 0xffbd9527
+image.setPixel(1, 1, value)
+
+value = qRgb(122, 163, 39) # 0xff7aa327
+image.setPixel(0, 1, value)
+image.setPixel(1, 0, value)
+
+value = qRgb(237, 187, 51) # 0xffedba31
+image.setPixel(2, 1, value)
+//! [0]
+
+
+//! [1]
+image = QImage(3, 3, QImage.Format_Indexed8)
+value = qRgb(122, 163, 39) # 0xff7aa327
+image.setColor(0, value)
+
+value = qRgb(237, 187, 51) # 0xffedba31
+image.setColor(1, value)
+
+value = qRgb(189, 149, 39) # 0xffbd9527
+image.setColor(2, value)
+
+image.setPixel(0, 1, 0)
+image.setPixel(1, 0, 0)
+image.setPixel(1, 1, 2)
+image.setPixel(2, 1, 1)
+//! [1]
+
+
+//! [2]
+start_xpm = ["16 15 8 1", "a c #cec6bd", ....
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagereader.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagereader.cpp
new file mode 100644
index 000000000..bf760794e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagereader.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+reader = QImageReader()
+reader.setFormat("png") # same as reader.setFormat("PNG")
+//! [0]
+
+
+//! [1]
+reader = QImageReader("image.png")
+# reader.format() == "png"
+//! [1]
+
+
+//! [2]
+icon = QImage(64, 64, QImage.Format_RGB32)
+reader = QImageReader("icon_64x64.bmp")
+if reader.read(icon):
+ # Display icon
+//! [2]
+
+
+//! [3]
+reader = QImageReader(":/image.png")
+if reader.supportsOption(QImageIOHandler.Size):
+ print "Size:", str(reader.size())
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagewriter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagewriter.cpp
new file mode 100644
index 000000000..3e5561329
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qimagewriter.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+writer = QImageWriter()
+writer.setFormat("png") # same as writer.setFormat("PNG")
+//! [0]
+
+
+//! [1]
+image = QImage("some/image.jpeg")
+writer = QImageWriter("images/outimage.png", "png")
+writer.setText("Author", "John Smith")
+writer.write(image)
+//! [1]
+
+
+//! [2]
+writer = QImageWriter(fileName)
+if writer.supportsOption(QImageIOHandler.Description):
+ writer.setText("Author", "John Smith")
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qmovie.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qmovie.cpp
new file mode 100644
index 000000000..03fec9076
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qmovie.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+label = QLabel()
+movie = QMovie("animations/fire.gif")
+
+label.setMovie(movie)
+movie.start()
+//! [0]
+
+
+//! [1]
+movie = QMovie("racecar.gif")
+movie.setSpeed(200) // 2x speed
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmap.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmap.cpp
new file mode 100644
index 000000000..7acb620cb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmap.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+static const char * const start_xpm[]={
+ "16 15 8 1",
+ "a c #cec6bd",
+....
+//! [0]
+
+
+//! [1]
+myPixmap = QPixmap()
+myPixmap.setMask(myPixmap.createHeuristicMask())
+//! [1]
+
+//! [2]
+pixmap = QPixmap("background.png")
+exposed = QRegion()
+pixmap.scroll(10, 10, pixmap.rect(), exposed)
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapcache.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapcache.cpp
new file mode 100644
index 000000000..6952941f9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapcache.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+pm = QPixmap()
+if not QPixmapCache.find("my_big_image", pm):
+ pm.load("bigimage.png")
+ QPixmapCache.insert("my_big_image", pm)
+painter.drawPixmap(0, 0, pm)
+//! [0]
+
+
+//! [1]
+pm = QPixmap()
+if not QPixmapCache.find("my_big_image", pm):
+ pm.load("bigimage.png")
+ QPixmapCache.insert("my_big_image", pm)
+painter.drawPixmap(0, 0, pm)
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp
new file mode 100644
index 000000000..95b9a866c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+myFilter = QPixmapColorFilter()
+myFilter.setColor(QColor(128, 0, 0))
+myFilter.draw(painter, QPoint(0, 0), originalPixmap)
+//! [0]
+
+//! [1]
+myFilter = QPixmapConvolutionFilter()
+kernel = [
+ 0.0,-1.0, 0.0,
+ -1.0, 5.0,-1.0,
+ 0.0,-1.0, 0.0
+ ]
+myFilter.setConvolutionKernel(kernel, 3, 3)
+myFilter.sdraw(painter, QPoint(0, 0), originalPixmap)
+//! [1]
+
+//! [2]
+myFilter = QPixmapDropShadowFilter()
+myFilter.draw(painter, QPoint(0, 0), originalPixmap)
+//! [2]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp
new file mode 100644
index 000000000..9408be93c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def resizeEvent(self, event):
+ horizontalScrollBar().setRange(0, realWidth - width())
+ ...
+//! [0]
+
+//! [1]
+setIndexWidget(index, QLineEdit())
+...
+setIndexWidget(index, QTextEdit())
+//! [1]
+
+//! [2]
+m = view->selectionModel()
+view->setModel(model())
+del m
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp
new file mode 100644
index 000000000..ba0e31c71
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+mapper = QDataWidgetMapper
+mapper.setModel(model)
+mapper.addMapping(mySpinBox, 0)
+mapper.addMapping(myLineEdit, 1)
+mapper.addMapping(myCountryChooser, 2)
+mapper.toFirst()
+//! [0]
+
+
+//! [1]
+mapper = QDataWidgetMapper()
+mapper.setModel(myModel)
+mapper.addMapping(nameLineEdit, 0)
+mapper.addMapping(ageSpinBox, 1)
+//! [1]
+
+
+//! [2]
+mapper = QDataWidgetMapper()
+connect(myTableView.selectionModel(), SIGNAL("currentRowChanged(QModelIndex,QModelIndex)"),
+ mapper, SLOT(setCurrentModelIndex(QModelIndex)))
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp
new file mode 100644
index 000000000..22efc1979
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+Q_PROPERTY(QColor color READ color WRITE setColor USER true)
+//! [0]
+
+
+//! [1]
+QItemEditorCreator<MyEditor> *itemCreator =
+ new QItemEditorCreator<MyEditor>("myProperty");
+
+QItemEditorFactory *factory = new QItemEditorFactory;
+//! [1]
+
+
+//! [2]
+QItemEditorFactory *editorFactory = new QItemEditorFactory;
+QItemEditorCreatorBase *creator = new QStandardItemEditorCreator<MyFancyDateTimeEdit>();
+editorFactory->registerEditor(QVariant::DateType, creator);
+//! [2]
+
+
+//! [3]
+Q_PROPERTY(QColor color READ color WRITE setColor USER true)
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp
new file mode 100644
index 000000000..5ab02333f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+selection = QItemSelection(topLeft, bottomRight)
+//! [0]
+
+
+//! [1]
+selection = QItemSelection()
+...
+selection.select(topLeft, bottomRight)
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
new file mode 100644
index 000000000..47cb1d9d1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+model = QStandardItemModel (4, 4)
+for row in range(4):
+ for column in range(4):
+ item = QStandardItem("row %d, column %d" % (row, column))
+ model.setItem(row, column, item)
+//! [0]
+
+
+//! [1]
+model = QStandardItemModel()
+parentItem = model.invisibleRootItem()
+for i in range(4):
+ item = QStandardItem("item %d" % i)
+ parentItem.appendRow(item)
+ parentItem = item
+//! [1]
+
+
+//! [2]
+treeView = QTreeView(self)
+treeView.setModel(myStandardItemModel)
+treeView.clicked[QModelIndex].connect(self.clicked)
+//! [2]
+
+
+//! [3]
+def clicked(self, index):
+ item = myStandardItemModel.itemFromIndex(index)
+ # Do stuff with the item ...
+//! [3]
+
+
+//! [4]
+treeView.scrollTo(item.index())
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp
new file mode 100644
index 000000000..cd0ee658c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+setCellWidget(index, QLineEdit())
+...
+setCellWidget(index, QTextEdit())
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp
new file mode 100644
index 000000000..cc5130949
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+treeWidget = QTreeWidget()
+treeWidget.setColumnCount(1)
+items = []
+for i in range(10):
+ items.append(QTreeWidgetItem(None, QStringList(QString("item: %1").arg(i))))
+treeWidget.insertTopLevelItems(None, items)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qaction.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qaction.cpp
new file mode 100644
index 000000000..5828a9624
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qaction.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+app = QApplication(argv)
+app.setAttribute(Qt.AA_DontShowIconsInMenus) # Icons are *no longer shown* in menus
+// ...
+myAction = QAction()
+// ...
+myAction.setIcon(SomeIcon)
+myAction.setIconVisibleInMenu(True) # Icon *will* be shown in menus for *this* action.
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication.cpp
new file mode 100644
index 000000000..d3e371b1e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication.cpp
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def main():
+ if Qt.Q_WS_X11
+ useGUI = getenv("DISPLAY") != 0
+ else:
+ useGUI = True
+
+ app = QApplication(sys.argv, useGUI)
+
+ if useGUI:
+ # start GUI version
+ ...
+ else:
+ # start non-GUI version
+ ...
+ return app.exec_()
+//! [0]
+
+
+//! [1]
+QApplication.setStyle(QWindowsStyle())
+//! [1]
+
+
+//! [2]
+def main():
+ QApplication.setColorSpec(QApplication.ManyColor)
+ QApplication app(sys.argv)
+ ...
+ return app.exec_()
+
+//! [2]
+
+
+//! [3]
+class MyWidget (QWidget):
+ # ...
+ def sizeHint(self):
+ return QSize(80, 25).expandedTo(QApplication.globalStrut())
+//! [3]
+
+
+//! [4]
+def showAllHiddenTopLevelWidgets():
+ for widget in QApplication.topLevelWidgets():
+ if widget.isHidden():
+ widget.show()
+//! [4]
+
+
+//! [5]
+def updateAllWidgets():
+ for widget in QApplication.allWidgets()
+ widget.update()
+//! [5]
+
+
+//! [6]
+if __name__ == '__main__':
+ QApplication.setDesktopSettingsAware(False)
+ app = QApplication(sys.argv)
+ # ...
+ return app.exec_()
+//! [6]
+
+
+//! [7]
+if (startPos - currentPos).manhattanLength() >= QApplication.startDragDistance():
+ startTheDrag()
+//! [7]
+
+
+//! [8]
+class MyApplication (QApplication):
+# ...
+ def commitData(QSessionManager& manager)
+ if manager.allowsInteraction():
+ ret = QMessageBox.warning(
+ mainWindow,
+ QObject.tr("My Application"),
+ QObject.tr("Save changes to document?"),
+ QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
+
+ if ret == QMessageBox.Save:
+ manager.release()
+ if not saveDocument():
+ manager.cancel()
+ elif ret == QMessageBox.Discard:
+ pass
+ else:
+ manager.cancel()
+ else:
+ # we did not get permission to interact, then
+ # do something reasonable instead
+ pass
+//! [8]
+
+
+//! [9]
+appname -session id
+//! [9]
+
+
+//! [10]
+for command in mySession.restartCommand():
+ do_something(command)
+//! [10]
+
+
+//! [11]
+for command in mySession.discardCommand():
+ do_something(command)
+//! [11]
+
+
+//! [12]
+widget = qApp.widgetAt(x, y)
+if widget:
+ widget = widget.window()
+//! [12]
+
+
+//! [13]
+widget = qApp.widgetAt(point)
+if widget:
+ widget = widget.window()
+//! [13]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp
new file mode 100644
index 000000000..c0cfeef50
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+calculateHugeMandelbrot() # lunch time...
+QApplication.restoreOverrideCursor()
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qclipboard.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qclipboard.cpp
new file mode 100644
index 000000000..e69152401
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qclipboard.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+clipboard = QApplication.clipboard()
+originalText = clipboard.text()
+...
+clipboard.setText(newText)
+//! [0]
+
+
+//! [1]
+data = QMimeData()
+data.setImageData(image)
+clipboard.setMimeData(data, mode)
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qevent.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qevent.cpp
new file mode 100644
index 000000000..a52c02c3b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qevent.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def wheelEvent(self, event):
+ numDegrees = event.delta() / 8
+ numSteps = numDegrees / 15
+
+ if event->orientation() == Qt.Horizontal:
+ scrollHorizontally(numSteps)
+ else:
+ scrollVertically(numSteps)
+ event.accept()
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qformlayout.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qformlayout.cpp
new file mode 100644
index 000000000..629f74936
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qformlayout.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+formLayout = QFormLayout()
+formLayout.addRow(self.tr("&Name:"), nameLineEdit)
+formLayout.addRow(self.tr("&Email:"), emailLineEdit)
+formLayout.addRow(self.tr("&Age:"), ageSpinBox)
+setLayout(formLayout)
+//! [0]
+
+
+//! [1]
+nameLabel = QLabel(self.tr("&Name:"))
+nameLabel.setBuddy(nameLineEdit)
+
+emailLabel = QLabel(self.tr("&Name:"))
+emailLabel.setBuddy(emailLineEdit)
+
+ageLabel = QLabel(self.tr("&Name:"))
+ageLabel.setBuddy(ageSpinBox)
+
+gridLayout = QGridLayout()
+gridLayout.addWidget(nameLabel, 0, 0)
+gridLayout.addWidget(nameLineEdit, 0, 1)
+gridLayout.addWidget(emailLabel, 1, 0)
+gridLayout.addWidget(emailLineEdit, 1, 1)
+gridLayout.addWidget(ageLabel, 2, 0)
+gridLayout.addWidget(ageSpinBox, 2, 1)
+setLayout(gridLayout)
+//! [1]
+
+
+//! [2]
+formLayout.trowWrapPolicy(QFormLayout.DontWrapRows)
+formLayout.setFieldGrowthPolicy(QFormLayout.FieldsStayAtSizeHint)
+formLayout.setFormAlignment(Qt.AlignHCenter | Qt.AlignTop)
+formLayout.setLabelAlignment(Qt.AlignLeft)
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp
new file mode 100644
index 000000000..3e07cb3c0
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QKeySequence(QKeySequence.Print)
+QKeySequence(tr("Ctrl+P"))
+QKeySequence(tr("Ctrl+p"))
+QKeySequence(Qt.CTRL + Qt.Key_P)
+//! [0]
+
+
+//! [1]
+QKeySequence(tr("Ctrl+X, Ctrl+C"))
+QKeySequence(Qt.CTRL + Qt.Key_X, Qt.CTRL + Qt.Key_C)
+//! [1]
+
+
+//! [2]
+file = QMenu(self)
+file.addAction(tr("&Open..."), self, SLOT("open()"),
+ QKeySequence(tr("Ctrl+O", "File|Open")))
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayout.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayout.cpp
new file mode 100644
index 000000000..7b5e9bad9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayout.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+
+def paintLayout(self, painter, item):
+ layout = item.layout()
+
+ if layout:
+ for layout_item in layout:
+ self.paintLayout(painter, layout_item)
+
+ painter.drawRect(item.geometry())
+
+def paintEvent(self, event):
+ painter = QPainter(self)
+ if self.layout():
+ self.paintLayout(painter, self.layout())
+
+//! [0]
+
+
+//! [1]
+child = layout.takeAt(0)
+while child:
+ ...
+ del child
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp
new file mode 100644
index 000000000..5b6488ff6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def heightForWidth(self, w):
+ if cache_dirty or cached_width != w:
+ h = calculateHeightForWidth(w)
+ self.cached_hfw = h
+ return h
+ return cached_hfw
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcut.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcut.cpp
new file mode 100644
index 000000000..b954f3cd3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcut.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+shortcut = QShortcut(QKeySequence(self.tr("Ctrl+O", "File|Open")),
+ parent)
+//! [0]
+
+
+//! [1]
+setKey(0) # no signal emitted
+setKey(QKeySequence()) # no signal emitted
+setKey(0x3b1) # Greek letter alpha
+setKey(Qt.Key_D) # 'd', e.g. to delete
+setKey('q') # 'q', e.g. to quit
+setKey(Qt.CTRL + Qt.Key_P) # Ctrl+P, e.g. to print document
+setKey("Ctrl+P") # Ctrl+P, e.g. to print document
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp
new file mode 100644
index 000000000..48f63f6e9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp
@@ -0,0 +1,3 @@
+//! [0]
+key = QKeySequence()
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qsound.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qsound.cpp
new file mode 100644
index 000000000..ca5842070
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qsound.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QSound.play("mysounds/bells.wav")
+//! [0]
+
+
+//! [1]
+bells = QSound("mysounds/bells.wav")
+bells.play()
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qwidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qwidget.cpp
new file mode 100644
index 000000000..98ff665ea
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_kernel_qwidget.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+w.setWindowState(w.windowState() ^ Qt.WindowFullScreen)
+//! [0]
+
+
+//! [1]
+w.setWindowState(w.windowState() & ~Qt.WindowMinimized | Qt.WindowActive)
+//! [1]
+
+
+//! [2]
+width = widget.baseSize().width() + i * widget.sizeIncrement().width()
+height = widget.baseSize().height() + j * widget.sizeIncrement().height()
+//! [2]
+
+
+//! [3]
+aWidget.window().setWindowTitle("New Window Title")
+//! [3]
+
+
+//! [4]
+font = QFont("Helvetica", 12, QFont.Bold)
+widget.setFont(font)
+//! [4]
+
+
+//! [5]
+font = QFont()
+font.setBold(false)
+widget.setFont(font)
+//! [5]
+
+
+//! [6]
+widget.setCursor(Qt.IBeamCursor)
+//! [6]
+
+
+//! [7]
+pixmap = QPixmap(widget.size())
+widget.render(&pixmap)
+//! [7]
+
+
+//! [8]
+painter = QPainter(self)
+...
+painter.end()
+myWidget.render(self)
+//! [8]
+
+
+//! [9]
+widget.setTabOrder(a, b) # a to b
+widget.setTabOrder(b, c) # a to b to c
+widge.tsetTabOrder(c, d) # a to b to c to d
+//! [9]
+
+
+//! [10]
+# WRONG
+widget.setTabOrder(c, d) # c to d
+widget.setTabOrder(a, b) # a to b AND c to d
+widget.setTabOrder(b, c) # a to b to c, but not c to d
+//! [10]
+
+
+//! [11]
+class MyWidget(QWidget):
+
+ self.settings = None
+
+ def closeEvent(event):
+ # event is a QCloseEvent
+ self.settings = QSettings("MyCompany", "MyApp")
+ self.settings.setValue("geometry", self.saveGeometry())
+ QWidget.closeEvent(self, event)
+//! [11]
+
+
+//! [12]
+settings = QSettings("MyCompany", "MyApp")
+myWidget.restoreGeometry(settings.value("myWidget/geometry").toByteArray())
+//! [12]
+
+
+//! [13]
+widget.setUpdatesEnabled(False)
+widget.bigVisualChanges()
+widget.setUpdatesEnabled(True)
+//! [13]
+
+
+//! [14]
+...
+extern void qt_x11_set_global_double_buffer(bool);
+qt_x11_set_global_double_buffer(false);
+...
+//! [14]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qbrush.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qbrush.cpp
new file mode 100644
index 000000000..aef402ffa
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qbrush.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+painter = QPainter(self)
+
+painter.setBrush(Qt.cyan)
+painter.setPen(Qt.darkCyan)
+painter.drawRect(0, 0, 100,100)
+
+painter.setBrush(Qt.NoBrush)
+painter.setPen(Qt.darkGreen)
+painter.drawRect(40, 40, 100, 100)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qcolor.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qcolor.cpp
new file mode 100644
index 000000000..f44597c40
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qcolor.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+# Specify semi-transparent red
+painter.setBrush(QColor(255, 0, 0, 127))
+painter.drawRect(0, 0, self.width()/2, self.height())
+
+# Specify semi-transparent blue
+painter.setBrush(QColor(0, 0, 255, 127))
+painter.drawRect(0, 0, self.width(), self.height()/2)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qdrawutil.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qdrawutil.cpp
new file mode 100644
index 000000000..57f8300dd
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qdrawutil.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+frame = QFrame()
+frame.setFrameStyle(QFrame.HLine | QFrame.Sunken)
+//! [0]
+
+
+//! [1]
+frame = QFrame()
+frame.setFrameStyle(QFrame.Box | QFrame.Raised)
+//! [1]
+
+
+//! [2]
+frame = QFrame()
+frame.setFrameStyle( QFrame.Panel | QFrame.Sunken)
+//! [2]
+
+
+//! [3]
+frame = QFrame()
+frame.setFrameStyle(QFrame.WinPanel | QFrame.Raised)
+//! [3]
+
+
+//! [4]
+frame = QFrame()
+frame.setFrameStyle(QFrame.Box | QFrame.Plain)
+//! [4]
+
+
+//! [5]
+frame = QFrame()
+frame.setFrameStyle(QFrame.HLine | QFrame.Sunken)
+//! [5]
+
+
+//! [6]
+frame = QFrame()
+frame.setFrameStyle(QFrame.Box | QFrame.Raised)
+//! [6]
+
+
+//! [7]
+frame = QFrame()
+frame.setFrameStyle( QFrame.Panel | QFrame.Sunken)
+//! [7]
+
+
+//! [8]
+frame = QFrame()
+frame.setFrameStyle(QFrame.WinPanel | QFrame.Raised)
+//! [8]
+
+
+//! [9]
+frame = QFrame()
+frame.setFrameStyle(QFrame.Box | QFrame.Plain)
+//! [9]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qmatrix.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qmatrix.cpp
new file mode 100644
index 000000000..15a7f7d04
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qmatrix.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+x' = m11*x + m21*y + dx
+y' = m22*y + m12*x + dy
+//! [0]
+
+
+//! [1]
+x' = m11*x + m21*y + dx
+y' = m22*y + m12*x + dy
+//! [1]
+
+
+//! [2]
+x' = m11*x + m21*y + dx
+y' = m22*y + m12*x + dy
+//! [2]
+
+
+//! [3]
+x' = m11*x + m21*y + dx
+y' = m22*y + m12*x + dy
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainter.cpp
new file mode 100644
index 000000000..e702214f7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainter.cpp
@@ -0,0 +1,261 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def paintEvent(self, paintEvent):
+ painter = QPainter(self)
+ painter.setPen(Qt.blue)
+ painter.setFont(QFont("Arial", 30))
+ painter.drawText(rect(), Qt.AlignCenter, "Qt")
+//! [0]
+
+
+//! [1]
+def paintEvent(self, paintEvent):
+ p = QPainter()
+ p.begin(self)
+ p.drawLine(...) # drawing code
+ p.end()
+//! [1]
+
+
+//! [2]
+self paintEvent(self, paintEvent):
+ p = QPainter(self)
+ p.drawLine(...) # drawing code
+
+//! [2]
+
+
+//! [3]
+painter.begin(0) # impossible - paint device cannot be 0
+
+image = QPixmap(0, 0)
+painter.begin(&image) # impossible - image.isNull() == true
+
+painter.begin(myWidget)
+painter2.begin(myWidget) # impossible - only one painter at a time
+//! [3]
+
+
+//! [4]
+def rotate(self, angle):
+ matrix = QMatrix()
+ matrix.rotate(angle)
+ setWorldMatrix(matrix, true)
+//! [4]
+
+
+//! [5]
+path = QPainterPath()
+path.moveTo(20, 80)
+path.lineTo(20, 30)
+path.cubicTo(80, 0, 50, 50, 80, 80)
+
+painter = QPainter(self)
+painter.drawPath(path)
+//! [5]
+
+
+//! [6]
+line = QLineF(10.0, 80.0, 90.0, 20.0)
+
+painter = QPainter(self)
+painter.drawLine(line)
+//! [6]
+
+
+//! [7]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+
+painter = QPainter(self)
+painter.drawRect(rectangle)
+//! [7]
+
+
+//! [8]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+
+painter = QPainter(self)
+painter.drawRoundedRect(rectangle, 20.0, 15.0)
+//! [8]
+
+
+//! [9]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+
+painter = QPainter(self)
+painter.drawEllipse(rectangle)
+//! [9]
+
+
+//! [10]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+startAngle = 30 * 16
+spanAngle = 120 * 16
+
+painter = QPainter(self)
+painter.drawArc(rectangle, startAngle, spanAngle)
+//! [10]
+
+
+//! [11]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+startAngle = 30 * 16
+spanAngle = 120 * 16
+
+painter = QPainter(self)
+painter.drawPie(rectangle, startAngle, spanAngle)
+//! [11]
+
+
+//! [12]
+rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
+startAngle = 30 * 16
+spanAngle = 120 * 16
+
+painter = QPainter(self)
+painter.drawChord(rect, startAngle, spanAngle)
+//! [12]
+
+
+//! [13]
+points = [
+ QPointF(10.0, 80.0),
+ QPointF(20.0, 10.0),
+ QPointF(80.0, 30.0),
+]
+
+painter = QPainter(self)
+painter.drawPolyline(points, 3)
+//! [13]
+
+
+//! [14]
+points = [
+ QPointF(10.0, 80.0),
+ QPointF(20.0, 10.0),
+ QPointF(80.0, 30.0),
+ QPointF(90.0, 70.0)
+]
+
+painter = QPainter(self)
+painter.drawPolygon(points, 4)
+//! [14]
+
+
+//! [15]
+points = [
+ QPointF(10.0, 80.0),
+ QPointF(20.0, 10.0),
+ QPointF(80.0, 30.0),
+ QPointF(90.0, 70.0)
+]
+
+painter = QPainter(self)
+painter.drawConvexPolygon(points, 4)
+//! [15]
+
+
+//! [16]
+target = QRectF(10.0, 20.0, 80.0, 60.0)
+source = QRectF(0.0, 0.0, 70.0, 40.0)
+pixmap = QPixmap(":myPixmap.png")
+
+painter = QPainter(self)
+painter.drawPixmap(target, image, source)
+//! [16]
+
+
+//! [17]
+painter = QPainter(self)
+painter.drawText(rect, Qt.AlignCenter, tr("Qt by\nTrolltech"))
+//! [17]
+
+
+//! [18]
+picture = QPicture()
+point = QPointF(10.0, 20.0)
+picture.load("drawing.pic")
+
+painter = QPainter(self)
+painter.drawPicture(0, 0, picture)
+//! [18]
+
+
+//! [19]
+fillRect(rectangle, background())
+//! [19]
+
+
+//! [20]
+target = QRectF(10.0, 20.0, 80.0, 60.0)
+source = QRectF(0.0, 0.0, 70.0, 40.0)
+image = QImage(":/images/myImage.png")
+
+painter = QPainter(self)
+painter.drawImage(target, image, source)
+//! [20]
+
+//! [21]
+painter = QPainter(self)
+painter.fillRect(0, 0, 128, 128, Qt.green)
+painter.beginNativePainting()
+
+glEnable(GL_SCISSOR_TEST)
+glScissor(0, 0, 64, 64)
+
+glClearColor(1, 0, 0, 1)
+glClear(GL_COLOR_BUFFER_BIT)
+
+glDisable(GL_SCISSOR_TEST)
+
+painter.endNativePainting()
+//! [21]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainterpath.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainterpath.cpp
new file mode 100644
index 000000000..5ebbefcec
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpainterpath.cpp
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+path = QPainterPath()
+path.addRect(20, 20, 60, 60)
+
+path.moveTo(0, 0)
+path.cubicTo(99, 0, 50, 50, 99, 99)
+path.cubicTo(0, 99, 50, 50, 0, 0)
+
+QPainter painter(self)
+painter.fillRect(0, 0, 100, 100, Qt.white)
+painter.setPen(QPen(QColor(79, 106, 25), 1, Qt.SolidLine,
+ Qt.FlatCap, Qt.MiterJoin))
+painter.setBrush(QColor(122, 163, 39))
+
+painter.drawPath(path)
+//! [0]
+
+
+//! [1]
+myGradient = QLinearGradient()
+myPen = QPen()
+
+myPath = QPainterPath()
+myPath.cubicTo(c1, c2, endPoint)
+
+painter = QPainter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [1]
+
+
+//! [2]
+myGradient = QLinearGradient()
+myPen = QPen()
+
+startPoint = QPointF()
+center = QPointF()
+
+myPath = QPainterPath()
+myPath.moveTo(center)
+myPath.arcTo(boundingRect, startAngle,
+ sweepLength)
+
+painter = QPainter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [2]
+
+
+//! [3]
+myGradient = QLinearGradient()
+myPen = QPen()
+myRectangle = QRectF()
+
+myPath = QPainterPath()
+myPath.addRect(myRectangle)
+
+painter = QPainter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [3]
+
+
+//! [4]
+myGradient = QLinearGradient()
+myPen = QPen()
+myPolygon = QPolygonF()
+
+myPath = QPainterPath()
+myPath.addPolygon(myPolygon)
+
+QPainter painter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [4]
+
+
+//! [5]
+myGradient = QLinearGradient()
+myPen = QPen()
+boundingRectangle = QRectF()
+
+myPath = QPainterPath()
+myPath.addEllipse(boundingRectangle)
+
+QPainter painter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [5]
+
+
+//! [6]
+myGradient = QLinearGradient()
+myPen = QPen()
+myFont = QFont()
+QPointF baseline(x, y)
+
+myPath = QPainterPath()
+myPath.addText(baseline, myFont, tr("Qt"))
+
+painter QPainter(self)
+painter.setBrush(myGradient)
+painter.setPen(myPen)
+painter.drawPath(myPath)
+//! [6]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpen.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpen.cpp
new file mode 100644
index 000000000..7f063971d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qpen.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+painter = QPainter(self)
+pen = QPen(Qt.green, 3, Qt.DashDotLine, Qt.RoundCap, Qt.RoundJoin)
+painter.setPen(pen)
+//! [0]
+
+
+//! [1]
+painter = QPainter(self)
+pen = QPen() # creates a default pen
+
+pen.setStyle(Qt.DashDotLine)
+pen.setWidth(3)
+pen.setBrush(Qt.green)
+pen.setCapStyle(Qt.RoundCap)
+pen.setJoinStyle(Qt.RoundJoin)
+
+painter.setPen(pen)
+//! [1]
+
+
+//! [2]
+pen = QPen()
+space = 4;
+dashes = [1, space, 3, space, 9, space, 27, space, 9, space]
+pen.setDashPattern(dashes)
+//! [2]
+
+
+//! [3]
+pen = QPen()
+space = 4;
+dashes = [1, space, 3, space, 9, space, 27, space, 9, space]
+pen.setDashPattern(dashes)
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion.cpp
new file mode 100644
index 000000000..301f19499
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 MyWidget (QWidget):
+ # ...
+ def paintEvent(self):
+ r1 = QRegion(QRect(100, 100, 200, 80), QRegion.Ellipse) # r1: elliptic region
+ )
+ r2 = QRect(100, 120, 90, 30) # r2: rectangular region
+ r3 = r1.intersected(r2) # r3: intersection
+
+ painter = QPainter(self)
+ painter.setClipRegion(r3)
+ ... # paint clipped graphics
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion_unix.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion_unix.cpp
new file mode 100644
index 000000000..76f08b156
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qregion_unix.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+r1 = QRegion(10, 10, 20, 20)
+r1.isNull() // false
+r1.isEmpty() // false
+
+r2 = QRegion(40, 40, 20, 20)
+r3 = QRegion()
+r3.isNull() // true
+r3.isEmpty() // true
+
+r3 = r1.intersected(r2) // r3: intersection of r1 and r2
+r3.isNull() // false
+r3.isEmpty() // true
+
+r3 = r1.united(r2) // r3: union of r1 and r2
+r3.isNull() // false
+r3.isEmpty() // false
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qtransform.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qtransform.cpp
new file mode 100644
index 000000000..dd063e1f9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_painting_qtransform.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+x' = m11*x + m21*y + dx
+y' = m22*y + m12*x + dy
+if is not affine:
+ w' = m13*x + m23*y + m33
+ x' /= w'
+ y' /= w'
+//! [0]
+
+
+//! [1]
+x' = m11*x + m21*y + dx
+y' = m22*y + m12*x + dy
+if is not affine:
+ w' = m13*x + m23*y + m33
+ x' /= w'
+ y' /= w'
+//! [1]
+
+
+//! [2]
+x' = m11*x + m21*y + dx
+y' = m22*y + m12*x + dy
+if is not affine:
+ w' = m13*x + m23*y + m33
+ x' /= w'
+ y' /= w'
+//! [2]
+
+
+//! [3]
+x' = m11*x + m21*y + dx
+y' = m22*y + m12*x + dy
+if is not affine:
+ w' = m13*x + m23*y + m33
+ x' /= w'
+ y' /= w'
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyle.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyle.cpp
new file mode 100644
index 000000000..ba8719dc3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyle.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+python myapplication.py -style motif
+//! [0]
+
+
+//! [1]
+python myapplication.py -style custom
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyleoption.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyleoption.cpp
new file mode 100644
index 000000000..a4354c671
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_styles_qstyleoption.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def styleHint(self, stylehint, opt, widget, returnData):
+ if stylehint == SH_RubberBand_Mask:
+ if isinstance(QStyleHintReturnMask, hint):
+ ...
+ ...
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfont.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfont.cpp
new file mode 100644
index 000000000..0e221a1fe
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfont.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+serifFont = QFont("Times", 10, QFont.Bold)
+sansFont = QFont("Helvetica [Cronyx]", 12)
+//! [0]
+
+
+//! [1]
+f = QFont("Helvetica")
+//! [1]
+
+
+//! [2]
+f = QFont("Helvetica [Cronyx]")
+//! [2]
+
+
+//! [3]
+info = QFontInfo(f1)
+family = info.family()
+//! [3]
+
+
+//! [4]
+fm = QFontMetrics(f1)
+textWidthInPixels = fm.width("How many pixels wide is this text?")
+textHeightInPixels = fm.height()
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfontmetrics.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfontmetrics.cpp
new file mode 100644
index 000000000..ef89f1d7f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qfontmetrics.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+font = QFont("times", 24)
+fm = QFontMetrics(font)
+pixelsWide = fm.width("What's the width of this text?")
+pixelsHigh = fm.height()
+//! [0]
+
+
+//! [1]
+font = QFont("times", 24)
+fm = QFontMetricsF(font)
+pixelsWide = fm.width("What's the width of this text?")
+pixelsHigh = fm.height()
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp
new file mode 100644
index 000000000..05300479a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qsyntaxhighlighter.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+editor = QTextEdit()
+highlighter = MyHighlighter(editor.document())
+//! [0]
+
+
+//! [1]
+class MyHighlighter(QSyntaxHighlighter):
+ def highlightBlock(self, text):
+ myClassFormat = QTextCharFormat()
+ myClassFormat.setFontWeight(QFont.Bold)
+ myClassFormat.setForeground(Qt.darkMagenta)
+ pattern = QString("\\bMy[A-Za-z]+\\b")
+
+ expression = QRegExp(pattern)
+ index = text.indexOf(expression)
+ while index >= 0:
+ length = expression.matchedLength()
+ setFormat(index, length, myClassFormat)
+ index = text.indexOf(expression, index + length)
+//! [1]
+
+
+//! [2]
+multiLineCommentFormat = QTextCharFormat()
+multiLineCommentFormat.setForeground(Qt.red)
+
+startExpression = QRegExp("/\\*")
+endExpression = QRegExp("\\*/")
+
+setCurrentBlockState(0)
+
+startIndex = 0
+if previousBlockState() != 1:
+ startIndex = text.indexOf(startExpression)
+
+while startIndex >= 0:
+ endIndex = text.indexOf(endExpression, startIndex)
+ if endIndex == -1:
+ setCurrentBlockState(1)
+ commentLength = text.length() - startIndex
+ else:
+ commentLength = endIndex - startIndex
+ + endExpression.matchedLength()
+
+ setFormat(startIndex, commentLength, multiLineCommentFormat)
+ startIndex = text.indexOf(startExpression,
+ startIndex + commentLength)
+//! [2]
+
+
+//! [3]
+class MyHighlighter(QSyntaxHighlighter):
+ def highlightBlock(self, text):
+ myClassFormat = QTextCharFormat()
+ myClassFormat.setFontWeight(QFont.Bold)
+ myClassFormat.setForeground(Qt.darkMagenta)
+ pattern = QString("\\bMy[A-Za-z]+\\b")
+
+ expression = QRegExp(pattern)
+ index = text.indexOf(expression)
+ while index >= 0:
+ length = expression.matchedLength()
+ setFormat(index, length, myClassFormat)
+ index = text.indexOf(expression, index + length)
+//! [3]
+
+
+//! [4]
+class BlockData(QTextBlockUserData):
+ def __init__(self):
+ # ...
+ self.parentheses = []
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextcursor.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextcursor.cpp
new file mode 100644
index 000000000..4e3ec2f99
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextcursor.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+cursor.clearSelection()
+cursor.movePosition(QTextCursor.NextWord, QTextCursor.KeepAnchor)
+cursor.insertText("Hello World")
+//! [0]
+
+
+//! [1]
+img = ... # A QImage
+textDocument.addResource(QTextDocument.ImageResource, QUrl("myimage"), img)
+cursor.insertImage("myimage")
+//! [1]
+
+
+//! [2]
+cursor = QTextCursor(textDocument)
+cursor.beginEditBlock()
+cursor.insertText("Hello")
+cursor.insertText("World")
+cursor.endEditBlock()
+
+textDocument.undo()
+//! [2]
+
+
+//! [3]
+cursor = QTextCursor(textDocument)
+cursor.beginEditBlock()
+cursor.insertText("Hello")
+cursor.insertText("World")
+cursor.endEditBlock()
+
+...
+
+cursor.joinPreviousEditBlock()
+cursor.insertText("Hey")
+cursor.endEditBlock()
+
+textDocument.undo()
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextdocument.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextdocument.cpp
new file mode 100644
index 000000000..626436fea
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextdocument.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+plain = QString("#include <QtCore>")
+html = Qt::escape(plain)
+# html == "#include &lt;QtCore&gt;"
+//! [0]
+
+
+//! [1]
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>...
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextlayout.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextlayout.cpp
new file mode 100644
index 000000000..2f01083ca
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_text_qtextlayout.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+leading = fontMetrics.leading()
+height = 0
+widthUsed = 0
+textLayout.beginLayout()
+while True:
+ line = textLayout.createLine()
+ if not line.isValid():
+ break
+
+ line.setLineWidth(lineWidth)
+ height += leading
+ line.setPosition(QPointF(0, height))
+ height += line.height()
+ widthUsed = qMax(widthUsed, line.naturalTextWidth())
+textLayout.endLayout()
+//! [0]
+
+
+//! [1]
+painter = QPainter(self)
+textLayout.draw(painter, QPoint(0, 0))
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qcompleter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qcompleter.cpp
new file mode 100644
index 000000000..4010efc95
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qcompleter.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+wordList = ["alpha", "omega", "omicron", "zeta"]
+
+lineEdit = QLineEdit(self)
+
+completer = QCompleter(wordList, self)
+completer.setCaseSensitivity(Qt.CaseInsensitive)
+lineEdit.setCompleter(completer)
+//! [0]
+
+
+//! [1]
+completer = QCompleter(self)
+completer.setModel(QDirModel(completer))
+lineEdit.setCompleter(completer)
+//! [1]
+
+
+//! [2]
+i = 0
+while completer.setCurrentRow(i):
+ print "%s is match number %d" % (completer.currentCompletion(), i)
+ i += 1
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp
new file mode 100644
index 000000000..b4622a8a9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def showHelp(url):
+ # ...
+ pass
+
+QDesktopServices.setUrlHandler("help", showHelp);
+//! [0]
+
+//! [1]
+mailto:user@foo.com?subject=Test&body=Just a test
+//! [1]
+
+//! [2]
+QDesktopServices.openUrl(QUrl("file:///C:/Documents and Settings/All Users/Desktop", QUrl.TolerantMode))
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qundostack.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qundostack.cpp
new file mode 100644
index 000000000..9d1196790
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_util_qundostack.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 AppendText(QUndoCommand):
+ self.m_document = ''
+ self.m_text = ''
+
+ def AppendText(self, doc, text):
+ self.m_document = doc
+ self.m_text = text
+ self.setText("append text")
+
+ def undo(self):
+ self.m_document.chop(self.m_text.length())
+
+ def redo(self):
+ self.m_document->append(self.m_text)
+//! [0]
+
+
+//! [1]
+command1 = MyCommand()
+stack.push(command1)
+command2 = MyCommand()
+stack.push(command2)
+
+stack.undo()
+
+command3 = MyCommand()
+stack.push(command3) # command2 gets deleted
+//! [1]
+
+
+//! [2]
+insertRed = QUndoCommand() # an empty command
+insertRed.setText("insert red text")
+
+InsertText(document, idx, text, insertRed) # becomes child of insertRed
+SetColor(document, idx, text.length(), Qt.red, insertRed)
+
+stack.push(insertRed)
+//! [2]
+
+
+//! [3]
+class AppendText(QUndoCommand):
+ ...
+ def mergeWith(self, other):
+ if other.id() != self.id(): # make sure other is also an AppendText command
+ return False
+ m_text += other.m_text
+ return True
+//! [3]
+
+
+//! [4]
+stack.beginMacro("insert red text")
+stack.push(InsertText(document, idx, text))
+stack.push(SetColor(document, idx, text.length(), Qt.red))
+stack.endMacro() # indexChanged() is emitted
+//! [4]
+
+
+//! [5]
+insertRed = QUndoCommand() # an empty command
+insertRed.setText("insert red text")
+
+InsertText(document, idx, text, insertRed) # becomes child of insertRed
+SetColor(document, idx, text.length(), Qt.red, insertRed)
+
+stack.push(insertRed)
+//! [5]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp
new file mode 100644
index 000000000..d84336a89
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+button = QPushButton(QObject.tr("Ro&ck && Roll"), self)
+//! [0]
+
+
+//! [1]
+button.setIcon(QIcon(":/images/print.png"))
+button.setShortcut(tr("Alt+F7"))
+//! [1]
+
+
+//! [2]
+class MyWidget (QWidget):
+ #...
+ def reactToToggle(checked):
+ if checked:
+ // Examine the button states.
+ ...
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp
new file mode 100644
index 000000000..b2b49698e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+spinBox = QSpinBox(self)
+spinBox.setRange(0, 100)
+spinBox.setWrapping(True)
+spinBox.setValue(100)
+spinBox.stepBy(1)
+// value is 0
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp
new file mode 100644
index 000000000..c2d6f4c18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+calendar.setGridVisible(True)
+//! [0]
+
+
+//! [1]
+calendar.setGridVisible(True)
+calendar.setMinimumDate(QDate(2006, 6, 19))
+//! [1]
+
+
+//! [2]
+calendar.setGridVisible(True)
+calendar.setMaximumDate(QDate(2006, 7, 3))
+//! [2]
+
+
+//! [3]
+
+calendar.setDateRange(min, max)
+//! [3]
+
+
+//! [4]
+
+calendar.setMinimumDate(min)
+calendar.setMaximumDate(max)
+//! [4]
+
+
+//! [5]
+calendar.setGridVisible(True)
+//! [5]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp
new file mode 100644
index 000000000..c8aa50aa2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp
@@ -0,0 +1,3 @@
+//! [0]
+checkbox = QCheckBox("C&ase sensitive", self)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp
new file mode 100644
index 000000000..c11b58961
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+dateEdit = QDateTimeEdit(QDate.currentDate())
+dateEdit.setMinimumDate(QDate.currentDate().addDays(-365))
+dateEdit.setMaximumDate(QDate.currentDate().addDays(365))
+dateEdit.setDisplayFormat("yyyy.MM.dd")
+//! [0]
+
+
+//! [1]
+setDateTimeRange(min, max)
+//! [1]
+
+
+//! [2]
+setMinimumDateTime(min)
+setMaximumDateTime(max)
+//! [2]
+
+
+//! [3]
+setDateRange(min, max)
+//! [3]
+
+
+//! [4]
+setMinimumDate(min)
+setMaximumDate(max)
+//! [4]
+
+
+//! [5]
+setTimeRange(min, max)
+//! [5]
+
+
+//! [6]
+setMinimumTime(min)
+setMaximumTime(max)
+//! [6]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp
new file mode 100644
index 000000000..04a9d9df4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+dockWidget = parentWidget()
+if dockWidget.features() & QDockWidget.DockWidgetVerticalTitleBar:
+ # I need to be vertical
+else:
+ # I need to be horizontal
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qframe.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qframe.cpp
new file mode 100644
index 000000000..951f9ec01
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qframe.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+label = QLabel()
+label.setFrameStyle(QFrame.Panel | QFrame.Raised)
+label.setLineWidth(2)
+
+pbar = QProgressBar()
+label.setFrameStyle(QFrame.NoFrame)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp
new file mode 100644
index 000000000..d236d91dd
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp
@@ -0,0 +1,3 @@
+//! [0]
+g.setTitle("&User information")
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlabel.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlabel.cpp
new file mode 100644
index 000000000..0d2c80015
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlabel.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+label = QLabel(self)
+label.setFrameStyle(QFrame.Panel | QFrame.Sunken)
+label.setText("first line\nsecond line")
+label.setAlignment(Qt.AlignBottom | Qt.AlignRight)
+//! [0]
+
+
+//! [1]
+phoneEdit = QLineEdit(self)
+phoneLabel = QLabel("&Phone:", self)
+phoneLabel.setBuddy(phoneEdit)
+//! [1]
+
+
+//! [2]
+nameEd = QLineEdit(self)
+nameLb = QLabel("&Name:", self)
+nameLb.setBuddy(nameEd)
+phoneEd = QLineEdit(self)
+phoneLb = QLabel("&Phone:", self)
+phoneLb.setBuddy(phoneEd)
+# (layout setup not shown)
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlineedit.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlineedit.cpp
new file mode 100644
index 000000000..9418f5ea5
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qlineedit.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def contextMenuEvent(event):
+ menu = createStandardContextMenu()
+ menu.addAction(QObject.tr("My Menu Item"))
+ #...
+ menu.exec_(event.globalPos())
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp
new file mode 100644
index 000000000..dfc7e6902
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def closeEvent(self, event):
+ settings = QSettings("MyCompany", "MyApp")
+ settings.setValue("geometry", self.saveGeometry())
+ settings.setValue("windowState", self.saveState())
+ QMainWindow.closeEvent(self, event)
+//! [0]
+
+
+//! [1]
+def readSettings(self):
+ settings = QSettings("MyCompany", "MyApp")
+ restoreGeometry(settings.value("myWidget/geometry"))
+ restoreState(settings.value("myWidget/windowState"))
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenu.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenu.cpp
new file mode 100644
index 000000000..f5fcc8ca3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenu.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+exec_(QCursor.pos())
+//! [0]
+
+
+//! [1]
+exec_(somewidget.mapToGlobal(QPoint(0,0)))
+//! [1]
+
+
+//! [2]
+exec_(e.globalPos())
+//! [2]
+
+
+//! [3]
+exec_(QCursor.pos())
+//! [3]
+
+
+//! [4]
+exec_(somewidget.mapToGlobal(QPoint(0, 0)))
+//! [4]
+
+
+//! [5]
+exec_(e.globalPos())
+//! [5]
+
+
+//! [6]
+menu = QMenu()
+at = actions[0] // Assumes actions is not empty
+for a in actions:
+ menu.addAction(a)
+menu.exec_(pos, at)
+//! [6]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenubar.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenubar.cpp
new file mode 100644
index 000000000..e3e974fe2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qmenubar.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+menubar.addMenu(fileMenu)
+//! [0]
+
+
+//! [1]
+menuBar = QMenuBar()
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp
new file mode 100644
index 000000000..dd3d0e3b7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 MyQPlainTextEdit(QPlainTextEdit):
+ def contextMenuEvent(self, event):
+ menu = createStandardContextMenu()
+ menu.addAction(tr("My Menu Item"))
+ # ...
+ menu.exec_(event.globalPos())
+ del menu
+//! [0]
+
+
+//! [1]
+edit.textCursor().insertText(text)
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp
new file mode 100644
index 000000000..74b4cf884
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp
@@ -0,0 +1,3 @@
+//! [0]
+button = QPushButton("&Download", self)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp
new file mode 100644
index 000000000..dbee86850
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp
@@ -0,0 +1,3 @@
+//! [0]
+button = QRadioButton("Search from the &cursor", self)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qrubberband.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qrubberband.cpp
new file mode 100644
index 000000000..8a689fc74
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qrubberband.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 Widget:
+ def mousePressEvent(self, event):
+ origin = event.pos()
+ if not self.rubberBand:
+ self.rubberBand = QRubberBand(QRubberBand.Rectangle, self)
+ rubberBand.setGeometry(QRect(origin, QSize()))
+ rubberBand.show()
+
+ def mouseMoveEvent(self, event):
+ rubberBand.setGeometry(QRect(origin, event.pos()).normalized())
+
+ def mouseReleaseEvent(self, event):
+ rubberBand.hide()
+ # determine selection, for example using QRect.intersects()
+ # and QRect.contains().
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp
new file mode 100644
index 000000000..3ff390b35
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+imageLabel = QLabel()
+image = QImage("happyguy.png")
+imageLabel.setPixmap(QPixmap.fromImage(image))
+
+scrollArea = QScrollArea()
+scrollArea.setBackgroundRole(QPalette.Dark)
+scrollArea.setWidget(imageLabel)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qspinbox.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qspinbox.cpp
new file mode 100644
index 000000000..8df536bf2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qspinbox.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+sb.setPrefix("$")
+//! [0]
+
+
+//! [1]
+sb.setSuffix(" km")
+//! [1]
+
+
+//! [2]
+setRange(minimum, maximum)
+//! [2]
+
+
+//! [3]
+setMinimum(minimum)
+setMaximum(maximum)
+//! [3]
+
+
+//! [4]
+spinbox.setPrefix("$")
+//! [4]
+
+
+//! [5]
+spinbox.setSuffix(" km")
+//! [5]
+
+
+//! [6]
+setRange(minimum, maximum)
+//! [6]
+
+
+//! [7]
+setMinimum(minimum)
+setMaximum(maximum)
+//! [7]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp
new file mode 100644
index 000000000..6d6ec7ba5
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+pixmap = QPixmap(":/splash.png")
+splash = QSplashScreen(pixmap)
+splash.show()
+
+... # Loading some items
+splash.showMessage("Loaded modules")
+
+qApp.processEvents()
+
+... # Establishing connections
+splash.showMessage("Established connections")
+
+qApp.processEvents()
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplitter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplitter.cpp
new file mode 100644
index 000000000..b6cf932d8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qsplitter.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+widget = splitter.widget(index)
+policy = widget.sizePolicy()
+policy.setHorizontalStretch(stretch)
+policy.setVerticalStretch(stretch)
+widget.setSizePolicy(policy)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp
new file mode 100644
index 000000000..8b972b6f2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp
@@ -0,0 +1,3 @@
+//! [0]
+statusBar().addWidget(MyReadWriteIndication())
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp
new file mode 100644
index 000000000..cf9382dbc
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+backaction.setToolTip(browser.historyTitle(-1))
+forwardaction.setToolTip(browser.historyTitle(+1))
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextedit.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextedit.cpp
new file mode 100644
index 000000000..fef8b8e34
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qtextedit.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 MyTextEdit(QTextEdit):
+ def contextMenuEvent(self, event):
+ menu = createStandardContextMenu()
+ menu.addAction(tr("My Menu Item"))
+ #...
+ menu.exec_(event->globalPos())
+ del menu
+//! [0]
+
+
+//! [1]
+edit.textCursor().insertText(text)
+//! [1]
+
+
+//! [2]
+edit.textCursor().insertHtml(fragment)
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qvalidator.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qvalidator.cpp
new file mode 100644
index 000000000..b366dc2ab
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qvalidator.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+validator = QIntValidator(100, 999, self)
+edit = QLineEdit(self)
+
+# the edit lineedit will only accept integers between 100 and 999
+edit.setValidator(validator)
+//! [0]
+
+
+//! [1]
+pos = 0
+v = QIntValidator(100, 900, self)
+
+str = "1"
+v.validate(str, pos) # returns Intermediate
+str = "012"
+v.validate(str, pos) # returns Intermediate
+
+str = "123"
+v.validate(str, pos) # returns Acceptable
+str = "678"
+v.validate(str, pos) # returns Acceptable
+
+str = "999"
+v.validate(str, pos) # returns Intermediate
+
+str = "1234"
+v.validate(str, pos) # returns Invalid
+str = "-123"
+v.validate(str, pos) # returns Invalid
+str = "abc"
+v.validate(str, pos) # returns Invalid
+str = "12cm"
+v.validate(str, pos) # returns Invalid
+//! [1]
+
+
+//! [2]
+pos = 0
+
+s = "abc"
+v.validate(s, pos) # returns Invalid
+
+s = "5"
+v.validate(s, pos) # returns Intermediate
+
+s = "50"
+v.validate(s, pos) # returns Acceptable
+//! [2]
+
+
+//! [3]
+# regexp: optional '-' followed by between 1 and 3 digits
+rx = QRegExp("-?\\d{1,3}")
+validator = QRegExpValidator(rx, self)
+
+edit = QLineEdit(self)
+edit.setValidator(validator)
+//! [3]
+
+
+//! [4]
+# integers 1 to 9999
+rx = QRegExp("[1-9]\\d{0,3}")
+# the validator treats the regexp as "^[1-9]\\d{0,3}$"
+v = QRegExpValidator(rx, 0)
+pos = 0
+
+s = "0"
+v.validate(s, pos) # returns Invalid
+s = "12345"
+v.validate(s, pos) # returns Invalid
+s = "1"
+v.validate(s, pos) # returns Acceptable
+
+rx.setPattern("\\S+") # one or more non-whitespace characters
+v.setRegExp(rx)
+s = "myfile.txt"
+v.validate(s, pos) # Returns Acceptable
+s = "my file.txt"
+v.validate(s, pos) # Returns Invalid
+
+# A, B or C followed by exactly five digits followed by W, X, Y or Z
+rx.setPattern("[A-C]\\d{5}[W-Z]")
+v.setRegExp(rx)
+s = "a12345Z"
+v.validate(s, pos) # Returns Invalid
+s = "A12345Z"
+v.validate(s, pos) # Returns Acceptable
+s = "B12"
+v.validate(s, pos) # Returns Intermediate
+
+# match most 'readme' files
+rx.setPattern("read\\S?me(\.(txt|asc|1st))?")
+rx.setCaseSensitive(false)
+v.setRegExp(rx)
+s = "readme"
+v.validate(s, pos) # Returns Acceptable
+s = "README.1ST"
+v.validate(s, pos) # Returns Acceptable
+s = "read me.txt"
+v.validate(s, pos) # Returns Invalid
+s = "readm"
+v.validate(s, pos) # Returns Intermediate
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp
new file mode 100644
index 000000000..f26999148
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_gui_widgets_qworkspace.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 MainWindow(...):
+ def __init__(self):
+ self.workspace = QWorkspace()
+ self.setCentralWidget(workspace)
+ ...
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qftp.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qftp.cpp
new file mode 100644
index 000000000..b227b5797
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qftp.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ftp = QFtp(parent)
+ftp.connectToHost("ftp.trolltech.com")
+ftp.login()
+//! [0]
+
+
+//! [1]
+ftp.connectToHost("ftp.trolltech.com") # id == 1
+ftp.login() # id == 2
+ftp.cd("qt") # id == 3
+ftp.get("INSTALL") # id == 4
+ftp.close() # id == 5
+//! [1]
+
+
+//! [2]
+start(1)
+stateChanged(HostLookup)
+stateChanged(Connecting)
+stateChanged(Connected)
+finished(1, false)
+
+start(2)
+stateChanged(LoggedIn)
+finished(2, false)
+
+start(3)
+finished(3, false)
+
+start(4)
+dataTransferProgress(0, 3798)
+dataTransferProgress(2896, 3798)
+readyRead()
+dataTransferProgress(3798, 3798)
+readyRead()
+finished(4, false)
+
+start(5)
+stateChanged(Closing)
+stateChanged(Unconnected)
+finished(5, false)
+
+done(false)
+//! [2]
+
+
+//! [3]
+start(1)
+stateChanged(HostLookup)
+stateChanged(Connecting)
+stateChanged(Connected)
+finished(1, false)
+
+start(2)
+finished(2, true)
+
+done(true)
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qhttp.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qhttp.cpp
new file mode 100644
index 000000000..31216fd7f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qhttp.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+content-type: text/html
+//! [0]
+
+
+//! [1]
+header.setValue("content-type", "text/html")
+contentType = header.value("content-type")
+//! [1]
+
+
+//! [2]
+header = QHttpRequestHeader("GET", QUrl.toPercentEncoding("/index.html"))
+header.setValue("Host", "qtsoftware.com")
+http.setHost("qtsoftware.com")
+http.request(header)
+//! [2]
+
+
+//! [3]
+http.setHost("qtsoftware.com") # id == 1
+http.get(QUrl.toPercentEncoding("/index.html")) # id == 2
+//! [3]
+
+
+//! [4]
+requestStarted(1)
+requestFinished(1, False)
+
+requestStarted(2)
+stateChanged(Connecting)
+stateChanged(Sending)
+dataSendProgress(77, 77)
+stateChanged(Reading)
+responseHeaderReceived(responseheader)
+dataReadProgress(5388, 0)
+readyRead(responseheader)
+dataReadProgress(18300, 0)
+readyRead(responseheader)
+stateChanged(Connected)
+requestFinished(2, False)
+
+done(False)
+
+stateChanged(Closing)
+stateChanged(Unconnected)
+//! [4]
+
+
+//! [5]
+http.setHost("www.foo.bar") # id == 1
+http.get("/index.html") # id == 2
+http.post("register.html", data) # id == 3
+//! [5]
+
+
+//! [6]
+requestStarted(1)
+requestFinished(1, False)
+
+requestStarted(2)
+stateChanged(HostLookup)
+requestFinished(2, True)
+
+done(True)
+
+stateChanged(Unconnected)
+//! [6]
+
+
+//! [7]
+def getTicks(self):
+ http = QHttp(self)
+ self.connect(http, SIGNAL('done(bool)'), self, SLOT('showPage()'))
+ http.setProxy("proxy.example.com", 3128)
+ http.setHost("ticker.example.com")
+ http.get("/ticks.asp")
+
+def showPage(self):
+ self.display(http.readAll())
+
+//! [7]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp
new file mode 100644
index 000000000..0c7afec10
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+manager = QNetworkAccessManager(self)
+manager.finished[QNetworkReply].connect(self.replyFinished)
+
+manager.get(QNetworkRequest(QUrl("http://qt.nokia.com")))
+//! [0]
+
+
+//! [1]
+request = QNetworkRequest()
+request.setUrl(QUrl("http://qt.nokia.com"))
+request.setRawHeader("User-Agent", "MyOwnBrowser 1.0")
+
+reply = manager.get(request)
+reply.readyRead.connect(self.slotReadyRead)
+reply.error[QNetworkReply.NetworkError].connect(self..slotError)
+reply.sslErrors.connect(self.slotSslErrors)
+//! [1]
+
+//! [2]
+manager = QNetworkConfigurationManager()
+networkAccessManager.setConfiguration(manager.defaultConfiguration())
+//! [2]
+
+//! [3]
+networkAccessManager.setConfiguration(QNetworkConfiguration())
+//! [3]
+
+//! [4]
+networkAccessManager.setNetworkAccessible(QNetworkAccessManager.NotAccessible)
+//! [4]
+
+//! [5]
+networkAccessManager.setNetworkAccessible(QNetworkAccessManager.Accessible)
+//! [5]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp
new file mode 100644
index 000000000..7e2aea326
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+manager = QNetworkAccessManager(self)
+diskCache = QNetworkDiskCache(self)
+diskCache.setCacheDirectory("cacheDir")
+manager.setCache(diskCache)
+//! [0]
+
+//! [1]
+# do a normal request (preferred from network, as this is the default)
+request = QNetworkRequest(QUrl("http://qt.nokia.com"))
+manager.get(request)
+
+# do a request preferred from cache
+request2 = QNetworkRequest(QUrl("http://qt.nokia.com"))
+request2.setAttribute(QNetworkRequest.CacheLoadControlAttribute, QNetworkRequest.PreferCache)
+manager.get(request2)
+//! [1]
+
+//! [2]
+@Slot(QNetworkReply)
+def replyFinished(reply):
+ fromCache = reply.attribute(QNetworkRequest.SourceIsFromCacheAttribute)
+ print("page from cache? %d" % fromCache)
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp
new file mode 100644
index 000000000..9156597b1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp
@@ -0,0 +1,3 @@
+//! [0]
+request.setRawHeader("Last-Modified", "Sun, 06 Nov 1994 08:49:37 GMT")
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp
new file mode 100644
index 000000000..951446fbb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+mgr = QNetworkConfigurationManager()
+activeConfigs = mgr.allConfigurations(QNetworkConfiguration.Active)
+if activeConfigs:
+ assert(mgr.isOnline())
+else:
+ assert(not mgr.isOnline())
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp
new file mode 100644
index 000000000..e6de7bf36
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+addr = hostAddr.toIPv6Address()
+# addr contains 16 unsigned characters
+
+for i in range(0, 16):
+ # process addr[i]
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp
new file mode 100644
index 000000000..c1971b0ba
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+# To find the IP address of qtsoftware.com
+QHostInfo.lookupHost("qtsoftware.com", self, SLOT("printResults(QHostInfo)"))
+
+# To find the host name for 4.2.2.1
+QHostInfo.lookupHost("4.2.2.1", self, SLOT("printResults(QHostInfo)"))
+//! [0]
+
+
+//! [1]
+info = QHostInfo.fromName("qtsoftware.com")
+//! [1]
+
+
+//! [2]
+QHostInfo.lookupHost("www.kde.org", self.lookedUp)
+//! [2]
+
+
+//! [3]
+def lookedUp(host):
+ if host.error() != QHostInfo.NoError:
+ print "Lookup failed: %s" % host.errorString()
+ return
+
+ for address in host.addresses():
+ print "Found address: %s" % address.toString()
+//! [3]
+
+
+//! [4]
+QHostInfo.lookupHost("4.2.2.1", self.lookedUp)
+//! [4]
+
+
+//! [5]
+info = QHostInfo()
+...
+if not info.addresses().isEmpty():
+ address = info.addresses().first()
+ # use the first IP address
+//! [5]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp
new file mode 100644
index 000000000..681534045
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+proxy = QNetworkProxy()
+proxy.setType(QNetworkProxy.Socks5Proxy)
+proxy.setHostName("proxy.example.com")
+proxy.setPort(1080)
+proxy.setUser("username")
+proxy.setPassword("password")
+QNetworkProxy.setApplicationProxy(proxy)
+//! [0]
+
+
+//! [1]
+serverSocket.setProxy(QNetworkProxy.NoProxy)
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp
new file mode 100644
index 000000000..f1e271eaf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+socket.connectToHost("imap", 143)
+if socket.waitForConnected(1000):
+ print "Connected!"
+//! [0]
+
+
+//! [1]
+socket.disconnectFromHost()
+ if socket.state() == QAbstractSocket.UnconnectedState or \
+ socket.waitForDisconnected(1000):
+ print "Disconnected!"
+//! [1]
+
+
+//! [2]
+class SocketClass(...):
+ def readyReadSlot(self):
+ # This slot is connected to QAbstractSocket::readyRead()
+ while not socket.atEnd():
+ data = socket.read(100)
+ ...
+//! [2]
+
+
+//! [3]
+socket.setProxy(QNetworkProxy.NoProxy)
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp
new file mode 100644
index 000000000..f7815a631
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+socket.connectToServer("market")
+if (socket.waitForConnected(1000))
+ print("Connected!")
+//! [0]
+
+
+//! [1]
+socket.disconnectFromServer()
+if (socket.waitForDisconnected(1000))
+ print("Disconnected!")
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp
new file mode 100644
index 000000000..02c4e5032
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+socketLayer = QNativeSocketEngine()
+socketLayer.initialize(QAbstractSocket.TcpSocket, QAbstractSocket.IPv4Protocol)
+socketLayer.connectToHost(QHostAddress.LocalHost, 22)
+# returns False
+
+socketLayer.waitForWrite()
+socketLayer.connectToHost(QHostAddress.LocalHost, 22)
+# returns True
+//! [0]
+
+
+//! [1]
+socketLayer = QNativeSocketEngine()
+socketLayer.bind(QHostAddress.Any, 4000)
+socketLayer.listen()
+if socketLayer.waitForRead():
+ clientSocket = socketLayer.accept()
+ # a client is connected
+
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qtcpserver.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qtcpserver.cpp
new file mode 100644
index 000000000..b685462bc
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qtcpserver.cpp
@@ -0,0 +1,3 @@
+//! [0]
+server.setProxy(QNetworkProxy.NoProxy)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qudpsocket.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qudpsocket.cpp
new file mode 100644
index 000000000..d1ecc6754
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_socket_qudpsocket.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def initSocket(self):
+ udpSocket = QUdpSocket(self)
+ udpSocket.bind(QHostAddress.LocalHost, 7755)
+
+ self.connect(udpSocket, SIGNAL('readyRead()'),
+ self, SLOT('readPendingDatagrams()'))
+
+def readPendingDatagrams(self):
+ while udpSocket.hasPendingDatagrams():
+ datagram = QByteArray()
+ datagram.resize(udpSocket.pendingDatagramSize())
+
+ (sender, senderPort) = udpSocket.readDatagram(datagram.data(), datagram.size())
+
+ processTheDatagram(datagram)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp
new file mode 100644
index 000000000..234502ec6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+for cert in QSslCertificate.fromPath('C:/ssl/certificate.*.pem', QSsL.Pem, QRegExp.Wildcard):
+ print cert.issuerInfo(QSslCertificate.Organization)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp
new file mode 100644
index 000000000..0d95b3bbb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+config = sslSocket.sslConfiguration()
+config.setProtocol(QSsl.TlsV1)
+sslSocket.setSslConfiguration(config)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp
new file mode 100644
index 000000000..865b8ce50
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+socket = QSslSocket(self)
+QObject.connect(socket, SIGNAL("encrypted()"), self, SLOT("ready()"))
+
+socket.connectToHostEncrypted("imap.example.com", 993)
+//! [0]
+
+
+//! [1]
+def incomingConnection(socketDescriptor):
+ serverSocket = QSslSocket()
+ if serverSocket.setSocketDescriptor(socketDescriptor):
+ QObject.connect(serverSocket, SIGNAL("encrypted()"), self, SLOT("ready()"))
+ serverSocket.startServerEncryption()
+//! [1]
+
+
+//! [2]
+socket = QSslSocket()
+socket.connectToHostEncrypted("http.example.com", 443)
+if not socket.waitForEncrypted():
+ print socket.errorString()
+ return false
+
+socket.write("GET / HTTP/1.0\r\n\r\n")
+while socket.waitForReadyRead():
+ print socket.readAll().data()
+//! [2]
+
+
+//! [3]
+socket = QSslSocket()
+QObject.connect(socket, SIGNAL("encrypted()"), receiver, SLOT("socketEncrypted()"))
+
+socket.connectToHostEncrypted("imap", 993)
+socket.write("1 CAPABILITY\r\n")
+//! [3]
+
+
+//! [4]
+socket = QSslSocket()
+socket.setCiphers("DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA")
+//! [4]
+
+
+//! [5]
+socket.connectToHostEncrypted("imap", 993)
+if socket.waitForEncrypted(1000):
+ print "Encrypted!"
+//! [5]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qgl.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qgl.cpp
new file mode 100644
index 000000000..64c69aee9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qgl.cpp
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+fmt = QGLFormat()
+fmt.setAlpha(True)
+fmt.setStereo(True)
+QGLFormat.setDefaultFormat(fmt)
+//! [0]
+
+
+//! [1]
+fmt = QGLFormat()
+fmt.setDoubleBuffer(False) # single buffer
+fmt.setDirectRendering(False) # software rendering
+myWidget = MyGLWidget(fmt, ...)
+//! [1]
+
+
+//! [2]
+fmt = QGLFormat()
+fmt.setOverlay(True)
+fmt.setStereo(True)
+myWidget = MyGLWidget(fmt, ...)
+if !myWidget.format().stereo():
+ # ok, goggles off
+ if !myWidget.format().hasOverlay():
+ print "Cool hardware required"
+//! [2]
+
+
+//! [3]
+# The rendering in MyGLWidget depends on using
+# stencil buffer and alpha channel
+
+class MyGLWidget(QGLWidget):
+ def __init__(self, parent):
+ QGLWidget.__init__(self, QGLFormat(QGL.StencilBuffer | QGL.AlphaChannel), parent)
+
+ if !format().stencil():
+ print "Could not get stencil buffer results will be suboptimal"
+ if !format().alpha():
+ print "Could not get alpha channel results will be suboptimal"
+ ...
+//! [3]
+
+
+//! [4]
+a = QApplication([])
+f = QGLFormat()
+f.setDoubleBuffer(False)
+QGLFormat.setDefaultFormat(f)
+//! [4]
+
+
+//! [5]
+f = QGLFormat.defaultOverlayFormat()
+f.setDoubleBuffer(True)
+QGLFormat.setDefaultOverlayFormat(f)
+//! [5]
+
+
+//! [6]
+# ...continued from above
+myWidget = MyGLWidget(QGLFormat(QGL.HasOverlay), ...)
+if myWidget.format().hasOverlay():
+ # Yes, we got an overlay, let's check _its_ format:
+ olContext = myWidget.overlayContext()
+ if olContext.format().doubleBuffer():
+ # yes, we got a double buffered overlay
+ else:
+ # no, only single buffered overlays are available
+//! [6]
+
+
+//! [7]
+cx = QGLContext()
+# ...
+f = QGLFormat()
+f.setStereo(True)
+cx.setFormat(f)
+if !cx.create():
+ exit() # no OpenGL support, or cannot render on the specified paintdevice
+if !cx.format().stereo():
+ exit() # could not create stereo context
+//! [7]
+
+
+//! [8]
+class MyGLDrawer(QGLWidget):
+
+ def __init__(self, parent):
+ QGLWidget.__init__(self, parent)
+ pass
+
+ def initializeGL(self):
+ # Set up the rendering context, define display lists etc.:
+ ...
+ glClearColor(0.0, 0.0, 0.0, 0.0)
+ glEnable(GL_DEPTH_TEST)
+ ...
+
+ def resizeGL(self, w, h):
+ # setup viewport, projection etc.:
+ glViewport(0, 0, w, h)
+ ...
+ glFrustum(...)
+ ...
+
+ def paintGL(self):
+ # draw the scene:
+ ...
+ glRotatef(...)
+ glMaterialfv(...)
+ glBegin(GL_QUADS)
+ glVertex3f(...)
+ glVertex3f(...)
+ ...
+ glEnd()
+ ...
+//! [8]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglcolormap.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglcolormap.cpp
new file mode 100644
index 000000000..6a087c3a8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglcolormap.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+import sys
+
+from PySide2.QtGui import QApplication, qRgb
+from PySide2.QtOpenGL import QGLColormap
+
+def main(argv):
+ app = QApplication(argv)
+
+ widget = MySuperGLWidget() # a QGLWidget in color-index mode
+ colormap = QGLColormap()
+
+ # This will fill the colormap with colors ranging from
+ # black to white.
+ for i in range(0, colormap.size()):
+ colormap.setEntry(i, qRgb(i, i, i))
+
+ widget.setColormap(colormap)
+ widget.show()
+ return app.exec_()
+
+if __name__ == "__main__":
+ main(sys.argv)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp
new file mode 100644
index 000000000..20c1d7431
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglpixelbuffer.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+pbuffer QGLPixelBuffer(...)
+...
+pbuffer.makeCurrent()
+dynamicTexture = pbuffer.generateDynamicTexture()
+pbuffer.bindToDynamicTexture(dynamicTexture)
+...
+pbuffer.releaseFromDynamicTexture()
+//! [0]
+
+
+//! [1]
+pbuffer QGLPixelBuffer(...)
+...
+pbuffer.makeCurrent()
+dynamicTexture = pbuffer.generateDynamicTexture()
+...
+pbuffer.updateDynamicTexture(dynamicTexture)
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp
new file mode 100644
index 000000000..2633705df
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+shader = QGLShader(QGLShader.Vertex)
+shader.compileSourceCode(code)
+
+program = QGLShaderProgram(context)
+program.addShader(shader)
+program.link()
+
+program.bind()
+//! [0]
+
+//! [1]
+program.addShaderFromSourceCode(QGLShader.Vertex,
+ "attribute highp vec4 vertex\n" \
+ "attribute mediump mat4 matrix\n" \
+ "void main(void)\n" \
+ "{\n" \
+ " gl_Position = matrix * vertex\n" \
+ "}")
+program.addShaderFromSourceCode(QGLShader.Fragment,
+ "uniform mediump vec4 color\n" \
+ "void main(void)\n" \
+ "{\n" \
+ " gl_FragColor = color\n" \
+ "}")
+program.link()
+program.bind()
+
+vertexLocation = program.attributeLocation("vertex")
+matrixLocation = program.attributeLocation("matrix")
+colorLocation = program.uniformLocation("color")
+//! [1]
+
+//! [2]
+triangleVertices = (
+ 60.0f, 10.0f, 0.0f,
+ 110.0f, 110.0f, 0.0f,
+ 10.0f, 110.0f, 0.0f)
+
+color = QColor(0, 255, 0, 255)
+
+pmvMatrix = QMatrix4x4()
+pmvMatrix.ortho(self.rect())
+
+program.enableAttributeArray(vertexLocation)
+program.setAttributeArray(vertexLocation, triangleVertices, 3)
+program.setUniformValue(matrixLocation, pmvMatrix)
+program.setUniformValue(colorLocation, color)
+
+glDrawArrays(GL_TRIANGLES, 0, 3)
+
+program.disableAttributeArray(vertexLocation)
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_qtestlib_qtestcase.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_qtestlib_qtestcase.cpp
new file mode 100644
index 000000000..fbc97b416
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_qtestlib_qtestcase.cpp
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QVERIFY(1 + 1 == 2)
+//! [0]
+
+
+//! [1]
+QVERIFY2(1 + 1 == 2, "A breach in basic arithmetic occured.")
+//! [1]
+
+
+//! [2]
+QCOMPARE(QString("hello").toUpper(), QString("HELLO"))
+//! [2]
+
+
+//! [3]
+void TestQString.toInt_data()
+{
+ QTest.addColumn<QString>("aString")
+ QTest.addColumn<int>("expected")
+
+ QTest.newRow("positive value") << "42" << 42
+ QTest.newRow("negative value") << "-42" << -42
+ QTest.newRow("zero") << "0" << 0
+}
+//! [3]
+
+
+//! [4]
+void TestQString.toInt()
+{
+ QFETCH(QString, aString)
+ QFETCH(int, expected)
+
+ QCOMPARE(aString.toInt(), expected)
+}
+//! [4]
+
+
+//! [5]
+if (sizeof(int) != 4)
+ QFAIL("This test has not been ported to this platform yet.")
+//! [5]
+
+
+//! [6]
+QFETCH(QString, myString)
+QCOMPARE(QString("hello").toUpper(), myString)
+//! [6]
+
+
+//! [7]
+QTEST(QString("hello").toUpper(), "myString")
+//! [7]
+
+
+//! [8]
+if (!QSqlDatabase.drivers().contains("SQLITE"))
+ QSKIP("This test requires the SQLITE database driver", SkipAll)
+//! [8]
+
+
+//! [9]
+QEXPECT_FAIL("", "Will fix in the next release", Continue)
+QCOMPARE(i, 42)
+QCOMPARE(j, 43)
+//! [9]
+
+
+//! [10]
+QEXPECT_FAIL("data27", "Oh my, this is soooo broken", Abort)
+QCOMPARE(i, 42)
+//! [10]
+
+
+//! [11]
+class TestQString: public QObject { ... }
+QTEST_MAIN(TestQString)
+//! [11]
+
+
+//! [12]
+#ifdef Q_WS_X11
+ QTEST_MAIN(MyX11Test)
+#else
+ // do nothing on non-X11 platforms
+ QTEST_NOOP_MAIN
+#endif
+//! [12]
+
+
+//! [13]
+QTest.keyClick(myWidget, 'a')
+//! [13]
+
+
+//! [14]
+QTest.keyClick(myWidget, Qt.Key_Escape)
+
+QTest.keyClick(myWidget, Qt.Key_Escape, Qt.ShiftModifier, 200)
+//! [14]
+
+
+//! [15]
+QTest.keyClicks(myWidget, "hello world")
+//! [15]
+
+
+//! [16]
+namespace QTest {
+ template<>
+ char *toString(const MyPoint &point)
+ {
+ QByteArray ba = "MyPoint("
+ ba += QByteArray.number(point.x()) + ", " + QByteArray.number(point.y())
+ ba += ")"
+ return qstrdup(ba.data())
+ }
+}
+//! [16]
+
+
+//! [17]
+int i = 0
+while (myNetworkServerNotResponding() && i++ < 50)
+ QTest.qWait(250)
+//! [17]
+
+
+//! [18]
+MyFirstTestObject test1
+QTest.qExec(&test1)
+
+MySecondTestObject test2
+QTest.qExec(&test2)
+//! [18]
+
+
+//! [19]
+QDir dir
+
+QTest.ignoreMessage(QtWarningMsg, "QDir.mkdir: Empty or null file name(s)")
+dir.mkdir("")
+//! [19]
+
+
+//! [20]
+void myTestFunction_data()
+{
+ QTest.addColumn<QString>("aString")
+ QTest.newRow("just hello") << QString("hello")
+ QTest.newRow("a null string") << QString()
+}
+//! [20]
+
+
+//! [21]
+void myTestFunction_data() {
+ QTest.addColumn<int>("intval")
+ QTest.addColumn<QString>("str")
+ QTest.addColumn<double>("dbl")
+
+ QTest.newRow("row1") << 1 << "hello" << 1.5
+}
+//! [21]
+
+
+//! [22]
+void MyTestClass.cleanup()
+{
+ if (qstrcmp(currentTestFunction(), "myDatabaseTest") == 0) {
+ // clean up all database connections
+ closeAllDatabases()
+ }
+}
+//! [22]
+
+
+//! [23]
+QTest.qSleep(250)
+//! [23]
+
+//! [24]
+widget = QWidget()
+widget.show()
+QTest.qWaitForWindowShown(widget)
+//! [24]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptable.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptable.cpp
new file mode 100644
index 000000000..86ac79c8f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptable.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 MyScriptableObject(QObject, QScriptable):
+...
+ def doSomething(self):
+ ...
+ def doSomethingElse(self):
+ ...
+//! [0]
+
+
+//! [1]
+
+def doSomething(self):
+ self.context().throwError('Threw an error from a slot')
+
+def doSomethingElse(self):
+ return self.thisObject()
+
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptclass.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptclass.cpp
new file mode 100644
index 000000000..41df2baea
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptclass.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+if extension == Callable:
+ context = argument
+ engine = context.engine()
+ sum = 0
+ for i in range(0, context.argumentCount()):
+ sum += context.argument(i).toNumber()
+ return sum
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptcontext.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptcontext.cpp
new file mode 100644
index 000000000..393c9cd4e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptcontext.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+foo(20.5, "hello", Object())
+//! [0]
+
+
+//! [1]
+def Person_prototype_fullName(context, engine):
+ self = context.selfObject()
+ result = self.property("firstName").toString()
+ result += QLatin1String(" ")
+ result += self.property("lastName").toString()
+ return result
+//! [1]
+
+
+//! [2]
+def myInclude(ctx, eng):
+ fileName = ctx.argument(0).toString()
+ contents = readTheFile(fileName)
+ ctx.setActivationObject(ctx.parentContext().activationObject())
+ ctx.setThisObject(ctx.parentContext().selfObject())
+ return eng.evaluate(contents, fileName)
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengine.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengine.cpp
new file mode 100644
index 000000000..2f27b446e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengine.cpp
@@ -0,0 +1,320 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+myEngine = QScriptEngine()
+three = myEngine.evaluate("1 + 2")
+//! [0]
+
+
+//! [1]
+fun = myEngine.evaluate("function(a, b) { return a + b }");
+args = QScriptValueList()
+args << 1 << 2
+threeAgain = fun.call(QScriptValue(), args)
+//! [1]
+
+
+//! [2]
+fileName = "helloworld.qs"
+scriptFile = QFile(fileName)
+if !scriptFile.open(QIODevice.ReadOnly):
+ # handle error
+stream = QTextStream(scriptFile)
+contents = stream.readAll()
+scriptFile.close()
+myEngine.evaluate(contents, fileName)
+//! [2]
+
+
+//! [3]
+myEngine.globalObject().setProperty("myNumber", 123)
+...
+myNumberPlusOne = myEngine.evaluate("myNumber + 1")
+//! [3]
+
+
+//! [4]
+result = myEngine.evaluate(...)
+if myEngine.hasUncaughtException():
+ line = myEngine.uncaughtExceptionLineNumber()
+ print "uncaught exception at line", line, ":", result.toString()
+//! [4]
+
+
+//! [5]
+button = QPushButton()
+QScriptValue scriptButton = myEngine.QObject(button)
+myEngine.globalObject().setProperty("button", scriptButton)
+
+myEngine.evaluate("button.checkable = True")
+
+print scriptButton.property("checkable").toBoolean()
+scriptButton.property("show").call() # call the show() slot
+//! [5]
+
+
+//! [6]
+def myAdd(context, engine):
+ a = context.argument(0)
+ b = context.argument(1)
+ return a.toNumber() + b.toNumber()
+//! [6]
+
+
+//! [7]
+fun = myEngine.Function(myAdd)
+myEngine.globalObject().setProperty("myAdd", fun)
+//! [7]
+
+
+//! [8]
+result = myEngine.evaluate("myAdd(myNumber, 1)")
+//! [8]
+
+
+//! [9]
+def Foo(context, engine):
+ if context.calledAsConstructor():
+ # initialize the object
+ context.selfObject().setProperty("bar", ...)
+ # ...
+ # return a non-object value to indicate that the
+ # selfObject() should be the result of the " Foo()" expression
+ return engine.undefinedValue()
+ else:
+ # not called as " Foo()", just "Foo()"
+ # create our own object and return that one
+ object = engine.Object()
+ object.setPrototype(context.callee().property("prototype"))
+ object.setProperty("baz", ...)
+ return object
+...
+
+fooProto = engine.Object()
+fooProto.setProperty("whatever", ...)
+engine.globalObject().setProperty("Foo", engine->Function(Foo, fooProto))
+//! [9]
+
+
+//! [10]
+class Bar:
+ ...
+
+def constructBar(context, engine):
+ bar = Bar()
+ # initialize from arguments in context, if desired
+ ...
+ return engine.toScriptValue(bar)
+
+class BarPrototype(QObject, QScriptable):
+# provide the scriptable interface of self type using slots and properties
+...
+
+...
+
+# create and register the Bar prototype and constructor in the engine
+barPrototypeObject = BarPrototype(...)
+barProto = engine.QObject(barPrototypeObject)
+engine.setDefaultPrototype(qMetaTypeId(Bar), barProto)
+barCtor = engine.Function(constructBar, barProto)
+engine.globalObject().setProperty("Bar", barCtor)
+//! [10]
+
+
+//! [11]
+def getSetFoo(context,engine):
+ callee = context.callee()
+ if context.argumentCount() == 1: # writing?
+ callee.setProperty("value", context.argument(0))
+ return callee.property("value")
+}
+
+....
+
+object = engine.Object()
+object.setProperty("foo", engine.Function(getSetFoo),
+ QScriptValue.PropertyGetter | QScriptValue::PropertySetter)
+//! [11]
+
+
+//! [12]
+object = engine.Object()
+object.setProperty("foo", engine.Function(getFoo), QScriptValue.PropertyGetter)
+object.setProperty("foo", engine.Function(setFoo), QScriptValue.PropertySetter)
+//! [12]
+
+
+//! [13]
+Q_SCRIPT_DECLARE_QMETAOBJECT(QLineEdit, QWidget*)
+
+...
+
+lineEditClass = engine.scriptValueFromQMetaObject(QLineEdit)
+engine.globalObject().setProperty("QLineEdit", lineEditClass)
+//! [13]
+
+
+//! [14]
+if hello && world:
+ print("hello world")
+//! [14]
+
+
+//! [15]
+if hello &&
+//! [15]
+
+
+//! [16]
+0 = 0
+//! [16]
+
+
+//! [17]
+./test.js
+//! [17]
+
+
+//! [18]
+foo["bar"]
+//! [18]
+
+
+//! [19]
+engine = QScriptEngine()
+context = engine.pushContext()
+context.activationObject().setProperty("myArg", 123)
+engine.evaluate("var tmp = myArg + 42")
+...
+engine.popContext()
+//! [19]
+
+
+//! [20]
+class MyStruct:
+ x = 0
+ y = 0
+//! [20]
+
+
+//! [21]
+Q_DECLARE_METATYPE(MyStruct)
+//! [21]
+
+
+//! [22]
+def toScriptValue(engine, s):
+ obj = engine.Object()
+ obj.setProperty("x", s.x)
+ obj.setProperty("y", s.y)
+ return obj
+
+def fromScriptValue(obj, s):
+ s.x = obj.property("x").toInt32()
+ s.y = obj.property("y").toInt32()
+//! [22]
+
+
+//! [23]
+qScriptRegisterMetaType(engine, toScriptValue, fromScriptValue)
+//! [23]
+
+
+//! [24]
+s = context.argument(0)
+...
+s2 = MyStruct()
+s2.x = s.x + 10
+s2.y = s.y + 20
+v = engine.toScriptValue(s2)
+//! [24]
+
+
+//! [25]
+def createMyStruct(cx, engine):
+ s = MyStruct()
+ s.x = 123
+ s.y = 456
+ return engine.toScriptValue(s)
+...
+
+ctor = engine.Function(createMyStruct)
+engine.globalObject().setProperty("MyStruct", ctor)
+//! [25]
+
+
+//! [26]
+Q_DECLARE_METATYPE(QVector<int>)
+
+...
+
+qScriptRegisterSequenceMetaType<QVector<int> >(engine)
+...
+v = engine.evaluate("[5, 1, 3, 2]")
+v.sort()
+a = engine.toScriptValue(v)
+print a.toString() # outputs "[1, 2, 3, 5]"
+//! [26]
+
+//! [27]
+def mySpecialQObjectConstructor(context, engine):
+ parent = context.argument(0).toQObject()
+ object = QObject(parent)
+ return engine.QObject(object, QScriptEngine.ScriptOwnership)
+
+...
+
+ctor = engine.Function(mySpecialQObjectConstructor)
+metaObject = engine.QMetaObject(QObject.staticMetaObject, ctor)
+engine.globalObject().setProperty("QObject", metaObject)
+
+result = engine.evaluate(" QObject()")
+//! [27]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengineagent.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengineagent.cpp
new file mode 100644
index 000000000..c8041d80e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptengineagent.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+var a = Math.random() + 2;
+//! [0]
+
+
+//! [1]
+function cube(a) {
+ return a * a * a;
+}
+
+var a = cube(3);
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalue.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalue.cpp
new file mode 100644
index 000000000..a2a780b91
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalue.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+myEngine = QScriptEngine()
+myObject = myEngine.newObject()
+myOtherObject = myEngine.newObject()
+myObject.setProperty("myChild", myOtherObject)
+myObject.setProperty("name", "John Doe")
+//! [0]
+
+
+//! [1]
+val = QScriptValue(myEngine, 123)
+myObject.setProperty("myReadOnlyProperty", val, QScriptValue.ReadOnly)
+//! [1]
+
+
+//! [2]
+engine = QScriptEngine()
+engine.evaluate("function fullName() { return this.firstName + ' ' + this.lastName; }")
+engine.evaluate("somePerson = { firstName: 'John', lastName: 'Doe' }")
+
+global_ = engine.globalObject()
+fullName = global_.property("fullName")
+who = global_.property("somePerson")
+print fullName.call(who).toString() # "John Doe"
+
+engine.evaluate("function cube(x) { return x * x * x; }")
+QScriptValue cube = global_.property("cube")
+args = QScriptValueList()
+args << 3
+print cube.call(QScriptValue(), args).toNumber() # 27
+//! [2]
+
+
+//! [3]
+
+def myNativeFunction(context, engine):
+ otherFunction = ...
+
+ return otherFunction.call(context.thisObject(), context.argumentsObject())
+
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalueiterator.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalueiterator.cpp
new file mode 100644
index 000000000..9b899385d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_script_qscriptvalueiterator.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+object = QScriptValue()
+...
+it = QScriptValueIterator(object)
+while it.hasNext():
+ it.next()
+ print "%s:%s" % (it.name(), it.value().toString())
+//! [0]
+
+
+//! [1]
+QScriptValue obj = ... // the object to iterate over
+while obj.isObject():
+ it = QScriptValueIterator(obj)
+ while it.hasNext():
+ it.next()
+ print it.name()
+ obj = obj.prototype()
+//! [1]
+
+
+//! [2]
+while it.hasNext():
+ it.next()
+ if it.flags() & QScriptValue::SkipInEnumeration:
+ continue
+ print "found enumerated property: %s" % it.name()
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp
new file mode 100644
index 000000000..632011812
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldatabase.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+# WRONG
+db = QSqlDatabase.database("sales")
+query = QSqlQuery("SELECT NAME, DOB FROM EMPLOYEES", db)
+QSqlDatabase.removeDatabase("sales") # will output a warning
+
+# "db" is now a dangling invalid database connection,
+# "query" contains an invalid result set
+//! [0]
+
+
+//! [1]
+db = QSqlDatabase.database("sales")
+query = QSqlQuery("SELECT NAME, DOB FROM EMPLOYEES", db)
+# Both "db" and "query" are destroyed because they are out of scope
+QSqlDatabase.removeDatabase("sales") # correct
+//! [1]
+
+
+//! [2]
+class MyDatabaseDriverCreatorBase(QtSql.QSqlDriverCreatorBase):
+ ...
+ def createObject(self):
+ return MyDatabaseDriver()
+
+mydriver = MyDatabaseDriverCreatorBase()
+QtSql.QSqlDatabase.registerSqlDriver("MYDRIVER", mydriver)
+db = QtSql.QSqlDatabase.addDatabase("MYDRIVER")
+//! [2]
+
+
+//! [3]
+...
+db = QSqlDatabase.addDatabase("QODBC")
+db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=myaccessfile.mdb")
+if db.open():
+ # success!
+ pass
+...
+//! [3]
+
+
+//! [4]
+...
+# MySQL connection
+db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1") # use an SSL connection to the server
+if not db.open():
+ db.setConnectOptions() # clears the connect option string
+ ...
+...
+# PostgreSQL connection
+db.setConnectOptions("requiressl=1") # enable PostgreSQL SSL connections
+if not db.open():
+ db.setConnectOptions() # clear options
+ ...
+...
+# ODBC connection
+# set ODBC options
+db.setConnectOptions("SQL_ATTR_ACCESS_MODE=SQL_MODE_READ_ONLY;SQL_ATTR_TRACE=SQL_OPT_TRACE_ON")
+if not db.open():
+ db.setConnectOptions() # don't try to set this option
+ ...
+//! [4]
+
+
+//! [5]
+#include "qtdir/src/sql/drivers/psql/qsql_psql.cpp"
+//! [5]
+
+
+//! [6]
+con = PQconnectdb("host=server user=bart password=simpson dbname=springfield")
+drv = QPSQLDriver(con)
+db = QSqlDatabase.addDatabase(drv) # becomes the new default connection
+query = QSqlQuery()
+query.exec_("SELECT NAME, ID FROM STAFF")
+...
+//! [6]
+
+
+//! [7]
+unix:LIBS += -lpq
+win32:LIBS += libpqdll.lib
+//! [7]
+
+
+//! [8]
+db = QSqlDatabase()
+print(db.isValid()) # Returns False
+
+db = QSqlDatabase.database("sales")
+print(db.isValid()) # Returns True if "sales" connection exists
+
+QSqlDatabase.removeDatabase("sales")
+print(db.isValid()) # Returns False
+//! [8]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp
new file mode 100644
index 000000000..89c68465f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+db = QSqlDatabase.addDatabase("SQLITE3")
+v = QVariant(db.driver().handle())
+if v.isValid() && v.typeName() == "sqlite3*":
+ # v.data() returns a pointer to the handle
+ sqlite3 *handle = *static_cast<sqlite3 **>(v.data())
+ if handle != 0: # check that it is not NULL
+ doSomething()
+//! [0]
+
+
+//! [1]
+# Impossible to translate to python
+if (v.typeName() == "PGconn*") {
+ PGconn *handle = *static_cast<PGconn **>(v.data())
+ if (handle != 0) ...
+}
+
+if (v.typeName() == "MYSQL*") {
+ MYSQL *handle = *static_cast<MYSQL **>(v.data())
+ if (handle != 0) ...
+}
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp
new file mode 100644
index 000000000..9911add09
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlerror.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+model = QSqlQueryModel()
+model.setQuery("select * from myTable")
+if model.lastError().isValid():
+ print model.lastError()
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp
new file mode 100644
index 000000000..b2bdd454a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlindex.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+strlist = myIndex.toStringList()
+for i in strlist:
+ myProcessing(i)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp
new file mode 100644
index 000000000..9ffac81b8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlquery.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+SELECT forename, surname FROM people
+//! [0]
+
+
+//! [1]
+q = QSqlQuery("select * from employees")
+rec = q.record()
+
+print "Number of columns: %d" % rec.count()
+
+nameCol = rec.indexOf("name") # index of the field "name"
+while q.next():
+ print q.value(nameCol) # output all names
+//! [1]
+
+
+//! [2]
+q = QSqlQuery()
+q.prepare("insert into myTable values (?, ?)")
+
+ints = [1, 2, 3, 4]
+q.addBindValue(ints)
+
+names = ["Harald", "Boris", "Trond", ""]
+q.addBindValue(names)
+
+if not q.execBatch():
+ print q.lastError()
+//! [2]
+
+
+//! [3]
+1 Harald
+2 Boris
+3 Trond
+4 NULL
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp
new file mode 100644
index 000000000..65bbc41e9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqlresult.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+q = QSqlQuery()
+q.prepare("insert into test (i1, i2, s) values (?, ?, ?)")
+
+col1 = [1, 3]
+col2 = [2, 4]
+col3 = ["hello", "world"]
+
+q.bindValue(0, col1)
+q.bindValue(1, col2)
+q.bindValue(2, col3)
+
+if not q.execBatch():
+ print q.lastError()
+//! [0]
+
+
+//! [1]
+query = QSqlQuery ...
+v = query.result().handle()
+if v.isValid() and (v.typeName() == "sqlite3_stmt*"):
+ # v.data() returns a pointer to the handle
+ handle = v.data()
+ if handle != 0: # check that it is not NULL
+ ...
+//! [1]
+
+
+//! [2]
+if v.typeName() == "PGresult*":
+ handle = v.data()
+ if handle != 0 ...
+
+if v.typeName() == "MYSQL_STMT*":
+ handle = v.data()
+ if handle != 0 ...
+}
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp
new file mode 100644
index 000000000..b037221bb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_sql_models_qsqlquerymodel.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+while myModel.canFetchMore():
+ myModel.fetchMore()
+//! [0]
+
+
+//! [1]
+model = QSqlQueryModel()
+model.setQuery("select * from MyTable")
+if model.lastError().isValid():
+ print model.lastError()
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_svg_qgraphicssvgitem.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_svg_qgraphicssvgitem.cpp
new file mode 100644
index 000000000..df2dcbd94
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_svg_qgraphicssvgitem.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+renderer = QSvgRenderer(QLatin1String("SvgCardDeck.svg"))
+black = QGraphicsSvgItem()
+red = QGraphicsSvgItem()
+
+black.setSharedRenderer(renderer)
+black.setElementId(QLatin1String("black_joker"))
+
+red.setSharedRenderer(renderer)
+red.setElementId(QLatin1String("red_joker"))
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xml_dom_qdom.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xml_dom_qdom.cpp
new file mode 100644
index 000000000..741a75245
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xml_dom_qdom.cpp
@@ -0,0 +1,230 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+doc = QDomDocument()
+impl = QDomImplementation()
+
+# This will create the element, but the resulting XML document will
+# be invalid, because '~' is not a valid character in a tag name.
+impl.setInvalidDataPolicy(QDomImplementation.AcceptInvalidData)
+elt1 = doc.createElement("foo~bar")
+
+# This will create an element with the tag name "foobar".
+impl.setInvalidDataPolicy(QDomImplementation.DropInvalidData)
+elt2 = doc.createElement("foo~bar")
+
+# This will create a null element.
+impl.setInvalidDataPolicy(QDomImplementation::ReturnNullNode)
+elt3 = doc.createElement("foo~bar")
+//! [0]
+
+
+//! [1]
+d = QDomDocument()
+d.setContent(someXML)
+n = d.firstChild()
+while !n.isNull():
+ if n.isElement():
+ e = n.toElement()
+ print "Element name: %s" % e.tagName()
+ break
+ n = n.nextSibling()
+//! [1]
+
+
+//! [2]
+QDomDocument document
+QDomElement element1 = document.documentElement()
+QDomElement element2 = element1
+//! [2]
+
+
+//! [3]
+QDomElement element3 = document.createElement("MyElement")
+QDomElement element4 = document.createElement("MyElement")
+//! [3]
+
+
+//! [4]
+<body>
+<h1>Heading</h1>
+<p>Hello <b>you</b></p>
+</body>
+//! [4]
+
+
+//! [5]
+<h1>Heading</h1>
+<p>The text...</p>
+<h2>Next heading</h2>
+//! [5]
+
+
+//! [6]
+<h1>Heading</h1>
+<p>The text...</p>
+<h2>Next heading</h2>
+//! [6]
+
+
+//! [7]
+<link href="http://qtsoftware.com" color="red" />
+//! [7]
+
+
+//! [8]
+e = # some QDomElement...
+#...
+a = e.attributeNode("href")
+print a.value() # prints "http://qtsoftware.com"
+a.setValue("http://doc.trolltech.com") # change the node's attribute
+a2 = e.attributeNode("href")
+print a2.value() # prints "http://doc.trolltech.com"
+//! [8]
+
+
+//! [9]
+e = # some QDomElement...
+#...
+s = e.text()
+//! [9]
+
+
+//! [10]
+text = QString()
+element = doc.documentElement()
+
+n = element.firstChild()
+while True:
+ if not n.isNull()
+ break
+ t = n.toText()
+ if !t.isNull():
+ text += t.data()
+
+ n = n.nextSibling()
+//! [10]
+
+
+//! [11]
+doc = # some QDomDocument ...
+root = doc.firstChildElement("database")
+elt = root.firstChildElement("entry")
+while True:
+ if not elt.isNull():
+ break
+ # ...
+ elt = elt.nextSiblingElement("entry")
+//! [11]
+
+
+//! [12]
+<img src="myimg.png">
+//! [12]
+
+
+//! [13]
+<h1>Hello <b>Qt</b> <![CDATA[<xml is cool>]]></h1>
+//! [13]
+
+
+//! [14]
+Hello Qt <xml is cool>
+//! [14]
+
+
+//! [15]
+<!-- this is a comment -->
+//! [15]
+
+
+//! [16]
+doc = QDomDocument("mydocument")
+file = QFile("mydocument.xml")
+if not file.open(QIODevice::ReadOnly):
+ return
+if not doc.setContent(&file):
+ file.close()
+ return
+file.close()
+
+# print out the element names of all elements that are direct children
+# of the outermost element.
+docElem = doc.documentElement()
+
+n = docElem.firstChild()
+while not n.isNull():
+ e = n.toElement() # try to convert the node to an element.
+ if not e.isNull():
+ print e.tagName() # the node really is an element.
+ n = n.nextSibling()
+}
+
+# Here we append a new element to the end of the document
+elem = doc.createElement("img")
+elem.setAttribute("src", "myimage.png")
+docElem.appendChild(elem)
+//! [16]
+
+
+//! [17]
+doc = QDomDocument("MyML")
+root = doc.createElement("MyML")
+doc.appendChild(root)
+
+tag = doc.createElement("Greeting")
+root.appendChild(tag)
+
+t = doc.createTextNode("Hello World")
+tag.appendChild(t)
+
+xml = doc.toString()
+//! [17]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xml_sax_qxml.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xml_sax_qxml.cpp
new file mode 100644
index 000000000..9df91ab39
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xml_sax_qxml.cpp
@@ -0,0 +1,3 @@
+//! [0]
+xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", True)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstracturiresolver.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstracturiresolver.cpp
new file mode 100644
index 000000000..990a84968
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstracturiresolver.cpp
@@ -0,0 +1,3 @@
+//! [0]
+return baseURI.resolved(relative);
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlforwarditerator.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlforwarditerator.cpp
new file mode 100644
index 000000000..f31ea3f5c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlforwarditerator.cpp
@@ -0,0 +1,3 @@
+//! [0]
+OutputType inputToOutputItem(const InputType &inputType) const;
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlnodemodel.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlnodemodel.cpp
new file mode 100644
index 000000000..6adda1721
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlnodemodel.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+myInstance = QXmlNodeModelIndex();
+//! [0]
+
+//! [1]
+QFile queryFile(argv[1]);
+QFile chemistryData(argv[2]);
+QString moleculeName = argv[3];
+
+QXmlQuery query;
+query.setQuery(&queryFile, QUrl::fromLocalFile(queryFile.fileName()));
+
+ChemistryNodeModel myNodeModel(query.namePool(), chemistryData);
+QXmlNodeModelIndex startNode = myNodeModel.nodeFor(moleculeName);
+query.bindVariable("queryRoot", startNode);
+
+QFile out;
+out.open(stdout, QIODevice::WriteOnly);
+
+QXmlSerializer serializer(query, &out);
+query.evaluateTo(&serializer);
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlreceiver.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlreceiver.cpp
new file mode 100644
index 000000000..e8df709c8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qabstractxmlreceiver.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QXmlQuery query;
+query.setQuery("doc('index.html')/html/body/p[1]");
+
+QXmlSerializer serializer(query, myOutputDevice);
+query.evaluateTo(&serializer);
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qsimplexmlnodemodel.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qsimplexmlnodemodel.cpp
new file mode 100644
index 000000000..3007057d1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qsimplexmlnodemodel.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QXmlNodeModelIndex MyTreeModel::nextFromSimpleAxis(SimpleAxis axis, const QXmlNodeModelIndex &ni) const
+{
+ // Convert the QXmlNodeModelIndex to a value that is specific to what we represent.
+ const MyValue value = toMyValue(ni);
+
+ switch(axis)
+ {
+ case Parent:
+ return toNodeIndex(value.parent());
+ case FirstChild:
+ case PreviousSibling:
+ case NextSibling:
+ // and so on
+ ;
+ }
+ return QXmlNodeModelIndex();
+}
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlformatter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlformatter.cpp
new file mode 100644
index 000000000..5df7d059b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlformatter.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QXmlQuery query;
+query.setQuery("doc('index.html')/html/body/p[1]");
+
+QXmlFormatter formatter(query, myOutputDevice);
+formatter.setIndentationDepth(2);
+query.evaluateTo(&formatter);
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlname.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlname.cpp
new file mode 100644
index 000000000..60bd6b9c6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlname.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+// Fills the bits from begin to end with 1s and leaves the rest as 0.
+
+template<typename IntegralT>
+inline IntegralT bitmask(IntegralT begin, IntegralT end)
+{
+ IntegralT filled_bits = (1 << (end - begin + 1)) - 1;
+ return filled_bits << begin;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp
new file mode 100644
index 000000000..b29136eea
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp
@@ -0,0 +1,202 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QXmlNamePool namePool(query.namePool());
+ query.bindVariable(QXmlName(namePool, localName), value);
+//! [0]
+
+
+{
+//! [1]
+ QByteArray myDocument;
+ QBuffer buffer(&myDocument); // This is a QIODevice.
+ buffer.open(QIODevice::ReadOnly);
+ QXmlQuery query;
+ query.bindVariable("myDocument", &buffer);
+ query.setQuery("doc($myDocument)");
+//! [1]
+}
+
+
+{
+ QIODevice *device = 0;
+//! [2]
+ QXmlNamePool namePool(query.namePool());
+ query.bindVariable(QXmlName(namePool, localName), device);
+//! [2]
+
+}
+
+{
+ QIODevice *myOutputDevice = 0;
+//! [3]
+ QFile xq("myquery.xq");
+
+ QXmlQuery query;
+ query.setQuery(&xq, QUrl::fromLocalFile(xq.fileName()));
+
+ QXmlSerializer serializer(query, myOutputDevice);
+ query.evaluateTo(&serializer);
+//! [3]
+}
+
+{
+ QIODevice *myOutputDevice = 0;
+//! [4]
+ QFile xq("myquery.xq");
+ QString fileName("the filename");
+ QString publisherName("the publisher");
+ qlonglong year = 1234;
+
+ QXmlQuery query;
+
+ query.bindVariable("file", QVariant(fileName));
+ query.bindVariable("publisher", QVariant(publisherName));
+ query.bindVariable("year", QVariant(year));
+
+ query.setQuery(&xq, QUrl::fromLocalFile(xq.fileName()));
+
+ QXmlSerializer serializer(query, myOutputDevice);
+ query.evaluateTo(&serializer);
+//! [4]
+}
+
+{
+//! [5]
+ QFile xq("myquery.xq");
+ QString fileName("the filename");
+ QString publisherName("the publisher");
+ qlonglong year = 1234;
+
+ QXmlQuery query;
+
+ query.bindVariable("file", QVariant(fileName));
+ query.bindVariable("publisher", QVariant(publisherName));
+ query.bindVariable("year", QVariant(year));
+
+ query.setQuery(&xq, QUrl::fromLocalFile(xq.fileName()));
+
+ QXmlResultItems result;
+ query.evaluateTo(&result);
+ QXmlItem item(result.next());
+ while (!item.isNull()) {
+ if (item.isAtomicValue()) {
+ QVariant v = item.toAtomicValue();
+ switch (v.type()) {
+ case QVariant::LongLong:
+ // xs:integer
+ break;
+ case QVariant::String:
+ // xs:string
+ break;
+ default:
+ // error
+ break;
+ }
+ }
+ else if (item.isNode()) {
+ QXmlNodeModelIndex i = item.toNodeModelIndex();
+ // process node
+ }
+ item = result.next();
+ }
+//! [5]
+}
+
+{
+//! [6]
+ QFile xq("myquery.xq");
+
+ QXmlQuery query;
+ query.setQuery(&xq, QUrl::fromLocalFile(xq.fileName()));
+
+ QXmlResultItems result;
+ query.evaluateTo(&result);
+ QXmlItem item(result.next());
+ while (!item.isNull()) {
+ if (item.isAtomicValue()) {
+ QVariant v = item.toAtomicValue();
+ switch (v.type()) {
+ case QVariant::LongLong:
+ // xs:integer
+ break;
+ case QVariant::String:
+ // xs:string
+ break;
+ default:
+ if (v.userType() == qMetaTypeId<QXmlName>()) {
+ QXmlName n = qVariantValue<QXmlName>(v);
+ // process QXmlName n...
+ }
+ else {
+ // error
+ }
+ break;
+ }
+ }
+ else if (item.isNode()) {
+ QXmlNodeModelIndex i = item.toNodeModelIndex();
+ // process node
+ }
+ item = result.next();
+ }
+//! [6]
+}
+
+{
+ QIODevice *out = 0;
+//! [7]
+ QXmlQuery query(QXmlQuery::XSLT20);
+ query.setFocus(QUrl("myInput.xml"));
+ query.setQuery(QUrl("myStylesheet.xsl"));
+ query.evaluateTo(out);
+//! [7]
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp
new file mode 100644
index 000000000..733d5c2c7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QXmlQuery query;
+query.setQuery("<e/>, 1, 'two'");
+QXmlResultItems result;
+
+if (query.isValid()) {
+ query.evaluateTo(&result);
+ QXmlItem item(result.next());
+ while (!item.isNull()) {
+ // use item
+ item = result.next();
+ }
+ if (result.hasError())
+ /* Runtime error! */;
+}
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlserializer.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlserializer.cpp
new file mode 100644
index 000000000..e8df709c8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/src_xmlpatterns_api_qxmlserializer.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+QXmlQuery query;
+query.setQuery("doc('index.html')/html/body/p[1]");
+
+QXmlSerializer serializer(query, myOutputDevice);
+query.evaluateTo(&serializer);
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_assistant_compat_lib_qassistantclient.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_assistant_compat_lib_qassistantclient.cpp
new file mode 100644
index 000000000..34554d99e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_assistant_compat_lib_qassistantclient.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QProcess *process = new QProcess(this);
+ QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath)
+ + QLatin1String("/assistant");
+
+ process->start(app, QStringList() << QLatin1String("-enableRemoteControl"));
+ if (!process->waitForStarted()) {
+ QMessageBox::critical(this, tr("Remote Control"),
+ tr("Could not start Qt Assistant from %1.").arg(app));
+ return;
+ }
+
+ // show index page
+ QTextStream str(process);
+ str << QLatin1String("SetSource qthelp://mycompany.com/doc/index.html")
+ << QLatin1Char('\0') << endl;
+ }
+//! [0]
+
+
+//! [1]
+ CONFIG += assistant
+//! [1]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp
new file mode 100644
index 000000000..7bd0e9a08
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QObject *ANewExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+ {
+ if (iid != Q_TYPEID(QDesignerContainerExtension))
+ return 0;
+
+ if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
+ (object))
+ return new MyContainerExtension(widget, parent);
+
+ return 0;
+ }
+//! [0]
+
+
+//! [1]
+ QObject *AGeneralExtensionFactory::createExtension(QObject *object,
+ const QString &iid, QObject *parent) const
+ {
+ MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
+
+ if (widget && (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
+ return new MyTaskMenuExtension(widget, parent);
+
+ } else if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) {
+ return new MyContainerExtension(widget, parent);
+
+ } else {
+ return 0;
+ }
+ }
+//! [1]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp
new file mode 100644
index 000000000..0896b7590
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QDesignerPropertySheetExtension *propertySheet;
+ QExtensionManager manager = formEditor->extensionManager();
+
+ propertySheet = qt_extension<QDesignerPropertySheetExtension*>(manager, widget);
+
+ if(propertySheet) {...}
+//! [0]
+
+
+//! [1]
+ Q_DECLARE_EXTENSION_INTERFACE(MyExtension, "com.mycompany.myproduct.myextension")
+//! [1]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_qextensionmanager.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_qextensionmanager.cpp
new file mode 100644
index 000000000..a03482d56
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_extension_qextensionmanager.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ void MyPlugin::initialize(QDesignerFormEditorInterface *formEditor)
+ {
+ if (initialized)
+ return;
+
+ QExtensionManager *manager = formEditor->extensionManager();
+ Q_ASSERT(manager != 0);
+
+ manager->registerExtensions(new MyExtensionFactory(manager),
+ Q_TYPEID(QDesignerTaskMenuExtension));
+
+ initialized = true;
+ }
+//! [0]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformeditor.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformeditor.cpp
new file mode 100644
index 000000000..d81e7fb0b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformeditor.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QDesignerObjectInspectorInterface *objectInspector = 0;
+ objectInspector = formEditor->objectInspector();
+
+ QDesignerFormWindowManagerInterface *manager = 0;
+ manager = formEditor->formWindowManager();
+
+ objectInspector->setFormWindow(manager->formWindow(0));
+//! [0]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindow.cpp
new file mode 100644
index 000000000..291f839b1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindow.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QDesignerFormWindowInterface *formWindow;
+ formWindow = QDesignerFormWindowInterface::findFormWindow(myWidget);
+//! [0]
+
+
+//! [1]
+ QList<QDesignerFormWindowInterface *> forms;
+ QDesignerFormWindowInterface *formWindow;
+
+ QDesignerFormWindowManagerInterface *manager = formEditor->formWindowManager();
+
+ for (int i = 0; i < manager->formWindowCount(); i++) {
+ formWindow = manager->formWindow(i);
+ forms.append(formWindow);
+ }
+//! [1]
+
+
+//! [2]
+ if (formWindow->isManaged(myWidget))
+ formWindow->manageWidget(myWidget->childWidget);
+//! [2]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowcursor.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowcursor.cpp
new file mode 100644
index 000000000..2b59b22b0
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowcursor.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QDesignerFormWindowInterface *formWindow = 0;
+ formWindow = QDesignerFormWindowInterface::findFormWindow(myWidget);
+
+ formWindow->cursor()->setProperty(myWidget, myProperty, newValue);
+//! [0]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowmanager.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowmanager.cpp
new file mode 100644
index 000000000..2bdf62cde
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowmanager.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QDesignerFormWindowManagerInterface *manager = 0;
+ QDesignerFormWindowInterface *formWindow = 0;
+
+ manager = formEditor->formWindowManager();
+ formWindow = manager->formWindow(0);
+
+ manager->setActiveFormWindow(formWindow);
+//! [0]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractobjectinspector.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractobjectinspector.cpp
new file mode 100644
index 000000000..d81e7fb0b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractobjectinspector.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QDesignerObjectInspectorInterface *objectInspector = 0;
+ objectInspector = formEditor->objectInspector();
+
+ QDesignerFormWindowManagerInterface *manager = 0;
+ manager = formEditor->formWindowManager();
+
+ objectInspector->setFormWindow(manager->formWindow(0));
+//! [0]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp
new file mode 100644
index 000000000..cec019625
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QDesignerPropertyEditorInterface *propertyEditor = 0;
+ propertyEditor = formEditor->propertyEditor();
+
+ connect(propertyEditor, SIGNAL(propertyChanged(QString, QVariant)),
+ this, SLOT(checkProperty(QString, QVariant)));
+//! [0]
+
+
+//! [1]
+ void checkProperty(QString property, QVariant value) {
+ QDesignerPropertyEditorInterface *propertyEditor = 0;
+ propertyEditor = formEditor->propertyEditor();
+
+ QObject *object = propertyeditor->object();
+ MyCustomWidget *widget = qobject_cast<MyCustomWidget>(object);
+
+ if (widget && property == aProperty && value != expectedValue)
+ {...}
+ }
+//! [1]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp
new file mode 100644
index 000000000..2093c8e5a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QDesignerWidgetBoxInterface *widgetBox = 0:
+ widgetBox = formEditor->widgetBox();
+
+ widgetBox->load();
+//! [0]
+
+
+//! [1]
+ QString originalFile = widgetBox->fileName();
+
+ widgetBox->setFileName("myWidgetBox.xml");
+ widgetBox->save();
+//! [1]
+
+
+//! [2]
+ widgetBox->setFileName(originalFile);
+ widgetBox->load();
+//! [2]
+
+
+//! [3]
+ if (widgetBox->filename() != "myWidgetBox.xml") {
+ widgetBox->setFileName("myWidgetBox.xml");
+ widgetBox->load();
+ }
+//! [3]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_abstractformbuilder.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_abstractformbuilder.cpp
new file mode 100644
index 000000000..ba832d63d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_abstractformbuilder.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ MyForm::MyForm(QWidget *parent)
+ : QWidget(parent)
+ {
+ QFormBuilder builder;
+ QFile file(":/forms/myWidget.ui");
+ file.open(QFile::ReadOnly);
+ QWidget *myWidget = builder.load(&file, this);
+ file.close();
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(myWidget);
+ setLayout(layout);
+ }
+//! [0]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp
new file mode 100644
index 000000000..7282bb545
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ MyForm::MyForm(QWidget *parent)
+ : QWidget(parent)
+ {
+ QFormBuilder builder;
+ QFile file(":/forms/myWidget.ui");
+ file.open(QFile::ReadOnly);
+ QWidget *myWidget = builder.load(&file, this);
+ file.close();
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(myWidget);
+ setLayout(layout);
+ }
+//! [0]
+
+
+//! [1]
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/forms">
+ <file>mywidget.ui</file>
+ </qresource>
+ </RCC>
+//! [1]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_patternist_qapplicationargumentparser.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_patternist_qapplicationargumentparser.cpp
new file mode 100644
index 000000000..fb39b23ea
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_patternist_qapplicationargumentparser.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ \include main.cpp
+//! [0]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp
new file mode 100644
index 000000000..6a7045f57
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ bool ok;
+ QGradient gradient = QtGradientDialog::getGradient(&ok, QRadialGradient(), this);
+ if (ok) {
+ // the user clicked OK and gradient is set to the gradient the user selected
+ } else {
+ // the user canceled the dialog; gradient is set to the initial
+ // value, in this case radial gradient
+ }
+//! [0]
+
+
+//! [1]
+ bool detailsVisible;
+ QColor::Spec spec;
+ QGradient gradient;
+
+ QtGradientDialog dlg(this);
+ dlg.setDetailsVisible(detailsVisible);
+ dlg.setSpec(spec);
+ dlg.setGradient(gradient);
+ if (dlg.exec() != QDialog::Accepted)
+ return;
+
+ gradient = dlg.gradient();
+ // detailsVisible and spec properties can be changed interactively by the user too,
+ // we store the values of these properties for the next time QtGradientDialog is executed.
+ detailsVisible = dlg.detailsVisible();
+ spec = dlg.spec();
+//! [1]
+
+
+//! [2]
+ QtGradientDialog dlg;
+ dlg.setBackgroundCheckered(true);
+//! [2]
+
+
+//! [3]
+ QtGradientDialog dlg;
+ dlg.setBackgroundCheckered(false);
+//! [3]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp
new file mode 100644
index 000000000..31bd49818
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QtSpinBoxFactory *factory;
+ QSet<QtIntPropertyManager *> managers = factory->propertyManagers();
+//! [0]
+
+
+//! [1]
+ QtBrowserItem *item;
+ QList<QtBrowserItem *> childrenItems = item->children();
+
+ QList<QtProperty *> childrenProperties = item->property()->subProperties();
+//! [1]
+
+
+//! [2]
+ QtProperty *property1, *property2, *property3;
+
+ property2->addSubProperty(property1);
+ property3->addSubProperty(property2);
+
+ QtAbstractPropertyBrowser *editor;
+
+ editor->addProperty(property1);
+ editor->addProperty(property2);
+ editor->addProperty(property3);
+//! [2]
+
+
+//! [3]
+ QtIntPropertyManager *intManager;
+ QtDoublePropertyManager *doubleManager;
+
+ QtProperty *myInteger = intManager->addProperty();
+ QtProperty *myDouble = doubleManager->addProperty();
+
+ QtSpinBoxFactory *spinBoxFactory;
+ QtDoubleSpinBoxFactory *doubleSpinBoxFactory;
+
+ QtAbstractPropertyBrowser *editor;
+ editor->setFactoryForManager(intManager, spinBoxFactory);
+ editor->setFactoryForManager(doubleManager, doubleSpinBoxFactory);
+
+ editor->addProperty(myInteger);
+ editor->addProperty(myDouble);
+//! [3]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp
new file mode 100644
index 000000000..d908e315e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QtVariantPropertyManager *variantPropertyManager;
+ QtProperty *property;
+
+ variantPropertyManager->setValue(property, 10);
+//! [0]
+
+
+//! [1]
+ QtVariantPropertyManager *variantPropertyManager;
+ QtVariantProperty *property;
+
+ property->setValue(10);
+//! [1]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qttoolbardialog_qttoolbardialog.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qttoolbardialog_qttoolbardialog.cpp
new file mode 100644
index 000000000..808a9f35f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/code/tools_shared_qttoolbardialog_qttoolbardialog.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QtToolBarManager *toolBarManager;
+
+ void MyMainWindow::customize()
+ {
+ QtToolBarDialog dialog(this);
+ dialog.setToolBarManager(toolBarManager);
+ dialog.exec();
+ }
+//! [0]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/console/dbus_pingpong.txt b/sources/pyside2/doc/codesnippets/doc/src/snippets/console/dbus_pingpong.txt
new file mode 100644
index 000000000..3c700db5c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/console/dbus_pingpong.txt
@@ -0,0 +1,3 @@
+[qtuser@workstation:~/dev/qt-4.4/examples/dbus/pingpong]$ ./pong &
+[qtuser@workstation:~/dev/qt-4.4/examples/dbus/pingpong]$ ./ping Hello
+Reply was: ping("Hello") got called
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/coordsys/coordsys.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/coordsys/coordsys.cpp
new file mode 100644
index 000000000..3d7b2a372
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/coordsys/coordsys.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+class MyWidget : public QWidget
+{
+public:
+ MyWidget();
+
+protected:
+ void paintEvent(QPaintEvent *);
+};
+
+MyWidget::MyWidget()
+{
+ QPalette palette(MyWidget::palette());
+ palette.setColor(backgroundRole(), Qt::white);
+ setPalette(palette);
+}
+
+void MyWidget::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setPen(Qt::darkGreen);
+ painter.drawRect(1, 2, 6, 4);
+
+ //painter.setPen(Qt::darkGray);
+ //painter.drawLine(2, 8, 6, 2);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MyWidget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/customstyle.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/customstyle.cpp
new file mode 100644
index 000000000..c0c14512f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/customstyle.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "customstyle.h"
+
+CustomStyle::CustomStyle()
+{
+//! [0]
+ if widget:
+//! [0] //! [1]
+//! [1]
+}
+
+//! [2]
+def drawPrimitive(element, option, painter, widget):
+ if element == PE_IndicatorSpinUp or element == PE_IndicatorSpinDown:
+ points = QPolygon(3)
+ x = option->rect.x()
+ y = option->rect.y()
+ w = option->rect.width() / 2
+ h = option->rect.height() / 2
+ x += (option->rect.width() - w) / 2
+ y += (option->rect.height() - h) / 2
+
+ if element == PE_IndicatorSpinUp:
+ points[0] = QPoint(x, y + h)
+ points[1] = QPoint(x + w, y + h)
+ points[2] = QPoint(x + w / 2, y)
+ else: # PE_SpinBoxDown
+ points[0] = QPoint(x, y)
+ points[1] = QPoint(x + w, y)
+ points[2] = QPoint(x + w / 2, y + h)
+
+ if option.state & State_Enabled:
+ painter.setPen(option.palette.mid().color())
+ painter.setBrush(option.palette.buttonText())
+ else:
+ painter.setPen(option.palette.buttonText().color())
+ painter.setBrush(option.palette.mid())
+
+ painter.drawPolygon(points)
+
+ else:
+ QWindowsStyle.drawPrimitive(element, option, painter, widget)
+//! [2] //! [3]
+
+//! [3] //! [4]
+}
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/customstyle.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/customstyle.h
new file mode 100644
index 000000000..a89c621a1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/customstyle.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef CUSTOMSTYLE_H
+#define CUSTOMSTYLE_H
+
+#include <QWindowsStyle>
+
+//! [0]
+class CustomStyle(QWindowsStyle):
+ ...
+
+ def drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ # element : PrimitiveElement
+ # option : QStyleOption
+ # painter : QPainter
+ # widget : QWidget
+ ...
+//! [0]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/main.cpp
new file mode 100644
index 000000000..abdfdf5a1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/customstyle/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+//! [using a custom style]
+#include <QtWidgets>
+
+#include "customstyle.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication::setStyle(new CustomStyle);
+ QApplication app(argc, argv);
+ QSpinBox spinBox;
+ spinBox.show();
+ return app.exec();
+}
+//! [using a custom style]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/customviewstyle.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/customviewstyle.cpp
new file mode 100644
index 000000000..240f9ab88
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/customviewstyle.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "customviewstyle.h"
+
+
+
+void CustomViewStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
+{
+
+//![0]
+ switch (element) {
+ case (PE_PanelItemViewItem): {
+ painter->save();
+
+ QPoint topLeft = option->rect.topLeft();
+ QPoint bottomRight = option->rect.topRight();
+ QLinearGradient backgroundGradient(topLeft, bottomRight);
+ backgroundGradient.setColorAt(0.0, QColor(Qt::yellow).lighter(190));
+ backgroundGradient.setColorAt(1.0, Qt::white);
+ painter->fillRect(option->rect, QBrush(backgroundGradient));
+
+ painter->restore();
+ break;
+ }
+ default:
+ QWindowsStyle::drawPrimitive(element, option, painter, widget);
+ }
+//![0]
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.cpp
new file mode 100644
index 000000000..42f2d81a7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "imagedialog.h"
+
+ImageDialog::ImageDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+ okButton->setAutoDefault(false);
+ cancelButton->setAutoDefault(false);
+
+ colorDepthCombo->addItem(tr("2 colors (1 bit per pixel)"));
+ colorDepthCombo->addItem(tr("4 colors (2 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 colors (4 bits per pixel)"));
+ colorDepthCombo->addItem(tr("256 colors (8 bits per pixel)"));
+ colorDepthCombo->addItem(tr("65536 colors (16 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 million colors (24 bits per pixel)"));
+
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+}
+
+void ImageDialog::on_okButton_clicked()
+{
+ if (nameLineEdit->text().isEmpty())
+ (void) QMessageBox::information(this, tr("No Image Name"),
+ tr("Please supply a name for the image."), QMessageBox::Cancel);
+ else
+ accept();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.h
new file mode 100644
index 000000000..b0140d24f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef IMAGEDIALOG_H
+#define IMAGEDIALOG_H
+
+#include "ui_imagedialog.h"
+
+//! [0]
+class ImageDialog : public QDialog, private Ui::ImageDialog
+{
+ Q_OBJECT
+
+public:
+ ImageDialog(QWidget *parent = 0);
+
+private slots:
+ void on_okButton_clicked();
+};
+//! [0]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.ui b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.ui
new file mode 100644
index 000000000..1c5e546f2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/imagedialog.ui
@@ -0,0 +1,389 @@
+<ui version="4.0" >
+ <comment></comment>
+ <class>ImageDialog</class>
+ <widget class="QDialog" >
+ <property name="objectName" >
+ <string notr="true" >ImageDialog</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>180</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Create Image</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="widthLabel" >
+ <property name="objectName" >
+ <string notr="true" >widthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>27</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Width:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="heightLabel" >
+ <property name="objectName" >
+ <string notr="true" >heightLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>55</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Height:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="colorDepthCombo" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthCombo</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="insertPolicy" >
+ <enum>QComboBox::InsertAtBottom</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="nameLineEdit" >
+ <property name="objectName" >
+ <string notr="true" >nameLineEdit</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Untitled image</string>
+ </property>
+ <property name="echoMode" >
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QSpinBox" name="spinBox" >
+ <property name="objectName" >
+ <string notr="true" >spinBox</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>1</y>
+ <width>227</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QSpinBox" name="spinBox_2" >
+ <property name="objectName" >
+ <string notr="true" >spinBox_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>27</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="nameLabel" >
+ <property name="objectName" >
+ <string notr="true" >nameLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>67</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Name:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="colorDepthLabel" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>83</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Color depth:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>9</x>
+ <y>121</y>
+ <width>302</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>128</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton" >
+ <property name="objectName" >
+ <string notr="true" >okButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>135</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="objectName" >
+ <string notr="true" >cancelButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>221</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <tabstops>
+ <tabstop>nameLineEdit</tabstop>
+ <tabstop>spinBox</tabstop>
+ <tabstop>spinBox_2</tabstop>
+ <tabstop>colorDepthCombo</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <connections>
+ <connection>
+ <sender>nameLineEdit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>okButton</receiver>
+ <slot>animateClick()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/main.cpp
new file mode 100644
index 000000000..98ed0b868
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/autoconnection/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "imagedialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ImageDialog *dialog = new ImageDialog;
+ dialog->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.ui b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.ui
new file mode 100644
index 000000000..1c5e546f2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/imagedialog/imagedialog.ui
@@ -0,0 +1,389 @@
+<ui version="4.0" >
+ <comment></comment>
+ <class>ImageDialog</class>
+ <widget class="QDialog" >
+ <property name="objectName" >
+ <string notr="true" >ImageDialog</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>180</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Create Image</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="widthLabel" >
+ <property name="objectName" >
+ <string notr="true" >widthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>27</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Width:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="heightLabel" >
+ <property name="objectName" >
+ <string notr="true" >heightLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>55</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Height:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="colorDepthCombo" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthCombo</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="insertPolicy" >
+ <enum>QComboBox::InsertAtBottom</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="nameLineEdit" >
+ <property name="objectName" >
+ <string notr="true" >nameLineEdit</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Untitled image</string>
+ </property>
+ <property name="echoMode" >
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QSpinBox" name="spinBox" >
+ <property name="objectName" >
+ <string notr="true" >spinBox</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>1</y>
+ <width>227</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QSpinBox" name="spinBox_2" >
+ <property name="objectName" >
+ <string notr="true" >spinBox_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>27</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="nameLabel" >
+ <property name="objectName" >
+ <string notr="true" >nameLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>67</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Name:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="colorDepthLabel" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>83</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Color depth:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>9</x>
+ <y>121</y>
+ <width>302</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>128</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton" >
+ <property name="objectName" >
+ <string notr="true" >okButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>135</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="objectName" >
+ <string notr="true" >cancelButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>221</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <tabstops>
+ <tabstop>nameLineEdit</tabstop>
+ <tabstop>spinBox</tabstop>
+ <tabstop>spinBox_2</tabstop>
+ <tabstop>colorDepthCombo</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <connections>
+ <connection>
+ <sender>nameLineEdit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>okButton</receiver>
+ <slot>animateClick()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/imagedialog/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/imagedialog/main.cpp
new file mode 100644
index 000000000..b89c5abd0
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/imagedialog/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "ui_imagedialog.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QDialog *window = new QDialog;
+ Ui::ImageDialog ui;
+ ui.setupUi(window);
+
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.cpp
new file mode 100644
index 000000000..f2e861f40
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "imagedialog.h"
+
+ImageDialog::ImageDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+
+ colorDepthCombo->addItem(tr("2 colors (1 bit per pixel)"));
+ colorDepthCombo->addItem(tr("4 colors (2 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 colors (4 bits per pixel)"));
+ colorDepthCombo->addItem(tr("256 colors (8 bits per pixel)"));
+ colorDepthCombo->addItem(tr("65536 colors (16 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 million colors (24 bits per pixel)"));
+
+ connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.h
new file mode 100644
index 000000000..b9cf4492e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef IMAGEDIALOG_H
+#define IMAGEDIALOG_H
+
+#include "ui_imagedialog.h"
+
+class ImageDialog : public QDialog, private Ui::ImageDialog
+{
+ Q_OBJECT
+
+public:
+ ImageDialog(QWidget *parent = 0);
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.ui b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.ui
new file mode 100644
index 000000000..1c5e546f2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/imagedialog.ui
@@ -0,0 +1,389 @@
+<ui version="4.0" >
+ <comment></comment>
+ <class>ImageDialog</class>
+ <widget class="QDialog" >
+ <property name="objectName" >
+ <string notr="true" >ImageDialog</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>180</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Create Image</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="widthLabel" >
+ <property name="objectName" >
+ <string notr="true" >widthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>27</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Width:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="heightLabel" >
+ <property name="objectName" >
+ <string notr="true" >heightLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>55</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Height:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="colorDepthCombo" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthCombo</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="insertPolicy" >
+ <enum>QComboBox::InsertAtBottom</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="nameLineEdit" >
+ <property name="objectName" >
+ <string notr="true" >nameLineEdit</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Untitled image</string>
+ </property>
+ <property name="echoMode" >
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QSpinBox" name="spinBox" >
+ <property name="objectName" >
+ <string notr="true" >spinBox</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>1</y>
+ <width>227</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QSpinBox" name="spinBox_2" >
+ <property name="objectName" >
+ <string notr="true" >spinBox_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>27</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="nameLabel" >
+ <property name="objectName" >
+ <string notr="true" >nameLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>67</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Name:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="colorDepthLabel" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>83</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Color depth:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>9</x>
+ <y>121</y>
+ <width>302</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>128</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton" >
+ <property name="objectName" >
+ <string notr="true" >okButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>135</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="objectName" >
+ <string notr="true" >cancelButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>221</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <tabstops>
+ <tabstop>nameLineEdit</tabstop>
+ <tabstop>spinBox</tabstop>
+ <tabstop>spinBox_2</tabstop>
+ <tabstop>colorDepthCombo</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <connections>
+ <connection>
+ <sender>nameLineEdit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>okButton</receiver>
+ <slot>animateClick()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/main.cpp
new file mode 100644
index 000000000..98ed0b868
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/multipleinheritance/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "imagedialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ImageDialog *dialog = new ImageDialog;
+ dialog->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.cpp
new file mode 100644
index 000000000..eef9acb66
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "imagedialog.h"
+
+//! [0]
+ImageDialog::ImageDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+ okButton->setAutoDefault(false);
+ cancelButton->setAutoDefault(false);
+//! [0]
+
+ colorDepthCombo->addItem(tr("2 colors (1 bit per pixel)"));
+ colorDepthCombo->addItem(tr("4 colors (2 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 colors (4 bits per pixel)"));
+ colorDepthCombo->addItem(tr("256 colors (8 bits per pixel)"));
+ colorDepthCombo->addItem(tr("65536 colors (16 bits per pixel)"));
+ colorDepthCombo->addItem(tr("16 million colors (24 bits per pixel)"));
+
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+//! [1]
+ connect(okButton, SIGNAL(clicked()), this, SLOT(checkValues()));
+}
+//! [1]
+
+//! [2]
+void ImageDialog::checkValues()
+{
+ if (nameLineEdit->text().isEmpty())
+ (void) QMessageBox::information(this, tr("No Image Name"),
+ tr("Please supply a name for the image."), QMessageBox::Cancel);
+ else
+ accept();
+}
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.h
new file mode 100644
index 000000000..5760f24b2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef IMAGEDIALOG_H
+#define IMAGEDIALOG_H
+
+#include "ui_imagedialog.h"
+
+//! [0]
+class ImageDialog : public QDialog, private Ui::ImageDialog
+{
+ Q_OBJECT
+
+public:
+ ImageDialog(QWidget *parent = 0);
+
+private slots:
+ void checkValues();
+};
+//! [0]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.ui b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.ui
new file mode 100644
index 000000000..1c5e546f2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/imagedialog.ui
@@ -0,0 +1,389 @@
+<ui version="4.0" >
+ <comment></comment>
+ <class>ImageDialog</class>
+ <widget class="QDialog" >
+ <property name="objectName" >
+ <string notr="true" >ImageDialog</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>180</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Create Image</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="widthLabel" >
+ <property name="objectName" >
+ <string notr="true" >widthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>27</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Width:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="heightLabel" >
+ <property name="objectName" >
+ <string notr="true" >heightLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>55</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Height:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="colorDepthCombo" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthCombo</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="insertPolicy" >
+ <enum>QComboBox::InsertAtBottom</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="nameLineEdit" >
+ <property name="objectName" >
+ <string notr="true" >nameLineEdit</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Untitled image</string>
+ </property>
+ <property name="echoMode" >
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QSpinBox" name="spinBox" >
+ <property name="objectName" >
+ <string notr="true" >spinBox</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>1</y>
+ <width>227</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QSpinBox" name="spinBox_2" >
+ <property name="objectName" >
+ <string notr="true" >spinBox_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>27</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="nameLabel" >
+ <property name="objectName" >
+ <string notr="true" >nameLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>67</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Name:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="colorDepthLabel" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>83</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Color depth:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>9</x>
+ <y>121</y>
+ <width>302</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>128</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton" >
+ <property name="objectName" >
+ <string notr="true" >okButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>135</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="objectName" >
+ <string notr="true" >cancelButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>221</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <tabstops>
+ <tabstop>nameLineEdit</tabstop>
+ <tabstop>spinBox</tabstop>
+ <tabstop>spinBox_2</tabstop>
+ <tabstop>colorDepthCombo</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <connections>
+ <connection>
+ <sender>nameLineEdit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>okButton</receiver>
+ <slot>animateClick()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/main.cpp
new file mode 100644
index 000000000..98ed0b868
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/noautoconnection/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "imagedialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ImageDialog *dialog = new ImageDialog;
+ dialog->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.cpp
new file mode 100644
index 000000000..ec66252f5
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "imagedialog.h"
+
+ImageDialog::ImageDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ ui.setupUi(this);
+
+ ui.colorDepthCombo->addItem(tr("2 colors (1 bit per pixel)"));
+ ui.colorDepthCombo->addItem(tr("4 colors (2 bits per pixel)"));
+ ui.colorDepthCombo->addItem(tr("16 colors (4 bits per pixel)"));
+ ui.colorDepthCombo->addItem(tr("256 colors (8 bits per pixel)"));
+ ui.colorDepthCombo->addItem(tr("65536 colors (16 bits per pixel)"));
+ ui.colorDepthCombo->addItem(tr("16 million colors (24 bits per pixel)"));
+
+ connect(ui.okButton, SIGNAL(clicked()), this, SLOT(accept()));
+ connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.h
new file mode 100644
index 000000000..a6b332287
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef IMAGEDIALOG_H
+#define IMAGEDIALOG_H
+
+#include "ui_imagedialog.h"
+
+class ImageDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ImageDialog(QWidget *parent = 0);
+
+private:
+ Ui::ImageDialog ui;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.ui b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.ui
new file mode 100644
index 000000000..1c5e546f2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/imagedialog.ui
@@ -0,0 +1,389 @@
+<ui version="4.0" >
+ <comment></comment>
+ <class>ImageDialog</class>
+ <widget class="QDialog" >
+ <property name="objectName" >
+ <string notr="true" >ImageDialog</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>180</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Create Image</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="widthLabel" >
+ <property name="objectName" >
+ <string notr="true" >widthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>27</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Width:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="heightLabel" >
+ <property name="objectName" >
+ <string notr="true" >heightLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>55</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Height:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="colorDepthCombo" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthCombo</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="insertPolicy" >
+ <enum>QComboBox::InsertAtBottom</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="nameLineEdit" >
+ <property name="objectName" >
+ <string notr="true" >nameLineEdit</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>83</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Untitled image</string>
+ </property>
+ <property name="echoMode" >
+ <enum>QLineEdit::Normal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QSpinBox" name="spinBox" >
+ <property name="objectName" >
+ <string notr="true" >spinBox</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>1</y>
+ <width>227</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QSpinBox" name="spinBox_2" >
+ <property name="objectName" >
+ <string notr="true" >spinBox_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>74</x>
+ <y>27</y>
+ <width>227</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols" >
+ <enum>QAbstractSpinBox::UpDownArrows</enum>
+ </property>
+ <property name="value" >
+ <number>32</number>
+ </property>
+ <property name="maximum" >
+ <number>1024</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="nameLabel" >
+ <property name="objectName" >
+ <string notr="true" >nameLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>67</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Name:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="colorDepthLabel" >
+ <property name="objectName" >
+ <string notr="true" >colorDepthLabel</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>83</y>
+ <width>67</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text" >
+ <string>Color depth:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>9</x>
+ <y>121</y>
+ <width>302</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>128</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton" >
+ <property name="objectName" >
+ <string notr="true" >okButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>135</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="objectName" >
+ <string notr="true" >cancelButton</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>221</x>
+ <y>1</y>
+ <width>80</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <tabstops>
+ <tabstop>nameLineEdit</tabstop>
+ <tabstop>spinBox</tabstop>
+ <tabstop>spinBox_2</tabstop>
+ <tabstop>colorDepthCombo</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <connections>
+ <connection>
+ <sender>nameLineEdit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>okButton</receiver>
+ <slot>animateClick()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>-1</x>
+ <y>7</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/main.cpp
new file mode 100644
index 000000000..98ed0b868
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/designer/singleinheritance/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "imagedialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ImageDialog *dialog = new ImageDialog;
+ dialog->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dialogs/dialogs.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/dialogs/dialogs.cpp
new file mode 100644
index 000000000..f926bbc03
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dialogs/dialogs.cpp
@@ -0,0 +1,129 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+def find(self)
+
+ if !self.findDialog:
+ self.findDialog = FindDialog(self)
+ connect(findDialog, SIGNAL("findNext()"), self, SLOT("findNext()"))
+
+
+ self.findDialog.show()
+ self.findDialog.raise()
+ self.findDialog.activateWindow()
+
+//! [0]
+
+//! [1]
+def countWords(self):
+ dialog = WordCountDialog(self)
+ dialog.setWordCount(document().wordCount())
+ dialog.exec_()
+
+//! [1]
+
+//! [2]
+ mb = QMessageBox("Application Name",
+ "Hardware failure.\n\nDisk error detected\nDo you want to stop?",
+ QMessageBox.Question,
+ QMessageBox.Yes | QMessageBox.Default,
+ QMessageBox.No | QMessageBox.Escape,
+ QMessageBox.NoButton)
+ if mb.exec() == QMessageBox.No:
+ # try again
+//! [2]
+
+//! [3]
+ progress = QProgressDialog("Copying files...", "Abort Copy", 0, numFiles, self)
+ progress.setWindowModality(Qt.WindowModal)
+
+ for i in rang(numFiles):
+ progress.setValue(i)
+
+ if progress.wasCanceled():
+ break
+ #... copy one file
+
+ progress.setValue(numFiles)
+//! [3]
+
+//! [4]
+# Operation constructor
+def __init__(self, parent):
+ QObject.__init__(self, parent)
+
+ pd = QProgressDialog("Operation in progress.", "Cancel", 0, 100)
+ connect(pd, SIGNAL("canceled()"), self, SLOT("cancel()"))
+ t = QTimer(self)
+ connect(t, SIGNAL("timeout()"), self, SLOT("perform()"))
+ t.start(0)
+
+//! [4] //! [5]
+
+def perform(self):
+
+ pd.setValue(steps)
+ #... perform one percent of the operation
+ steps++
+ if steps > pd.maximum():
+ t.stop()
+
+//! [5] //! [6]
+
+def cancel(self):
+
+ t.stop()
+ #... cleanup
+
+//! [6]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/modules.html b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/modules.html
new file mode 100644
index 000000000..9c67393da
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/modules.html
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: Qt Classes by Module</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="next" href="qtcore.html" />
+ <link rel="start" href="index.html" />
+</head>
+<body>
+<h1 align="center">Qt Classes by Module</h1>
+<table align="center" cellpadding="2" cellspacing="1" border="0">
+<tr valign="top" bgcolor="#f0f0f0"><td>QtCore</td><td>Core classes used by other modules.</td></tr>
+<tr valign="top" bgcolor="#e0e0e0"><td>QtGui</td><td>Graphical User Interface components</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td>QtNetwork</td><td>Classes for network programming.</td></tr>
+<tr valign="top" bgcolor="#e0e0e0"><td>QtOpenGL</td><td>OpenGL support classes.</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td>QtSql</td><td>Classes for database integration using SQL.</td></tr>
+<tr valign="top" bgcolor="#e0e0e0"><td>QtXml</td><td>Classes for handling XML.</td></tr>
+</table>
+</body>
+</html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtcore.html b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtcore.html
new file mode 100644
index 000000000..947ad4038
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtcore.html
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtCore Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="modules.html" />
+ <link rel="contents" href="modules.html" />
+ <link rel="next" href="qtgui.html" />
+</head>
+<body>
+<h1 align="center">QtCore Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractEventDispatcher</b></td><td>Manages Qt's event queue, excluding GUI-related events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractItemModel</b></td><td>The abstract interface for item model classes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractListModel</b></td><td>Abstract model that can be subclassed to create one-dimensional list models</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractTableModel</b></td><td>Abstract model that can be subclassed to create table models</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBasicTimer</b></td><td>Timer events for </td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBitArray</b></td><td>Array of bits</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBuffer</b></td><td>QIODevice interface for a QByteArray</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QByteArray</b></td><td>Array of bytes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QByteArrayMatcher</b></td><td>Holds a sequence of bytes that can be quickly matched in a byte array</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCache</b></td><td>Template class that provides a cache</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QChar</b></td><td>16-bit Unicode character</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QChildEvent</b></td><td>Event parameters for child object events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCoreApplication</b></td><td>Event loop for Qt applications</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCustomEvent</b></td><td>Support for custom events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDataStream</b></td><td>Serialization of binary data to a QIODevice</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDate</b></td><td>Date functions</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDateTime</b></td><td>Date and time functions</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDir</b></td><td>Access to directory structures and their contents</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QEvent</b></td><td>The base class of all event classes. Event objects contain event parameters</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFile</b></td><td>Interface for reading from and writing to files</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileEngine</b></td><td>Abstraction for accessing the filesystem</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileEngineHandler</b></td><td>Allows custom QFileEngines to be plugged into Qt</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileInfo</b></td><td>System-independent file information</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHash</b></td><td>Template class that provides a hash-table-based dictionary</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIODevice</b></td><td>The base interface class of all I/O devices in Qt</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLatin1Char</b></td><td>8-bit ASCII/Latin-1 character</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLatin1String</b></td><td>Thin wrapper around an ASCII/Latin-1 encoded string literal</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLibrary</b></td><td>Loads shared libraries at runtime</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLibraryInfo</b></td><td>Information about the Qt library</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLine</b></td><td>Two-dimensional vector that uses integer point coordinates for accuracy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLineF</b></td><td>Two-dimensional vector that uses floating point coordinates for accuracy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLinkedList</b></td><td>Template class that provides linked lists</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QList</b></td><td>Template class that provides lists</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLocale</b></td><td>Converts between numbers and their string representations in various languages</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMap</b></td><td>Template class that provides a skip-list-based dictionary</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaClassInfo</b></td><td>Additional information about a class</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaEnum</b></td><td>Meta data about an enumerator</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaMember</b></td><td>Meta data about a member function</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaObject</b></td><td>Meta information about Qt objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaProperty</b></td><td>Meta data about a property</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMetaType</b></td><td>Manages named types in the meta object system</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMimeData</b></td><td>Container for data that records information about its MIME type</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QModelIndex</b></td><td>Used to locate data in a data model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMultiHash</b></td><td>Convenience QHash subclass that provides multi-valued hashes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMultiMap</b></td><td>Convenience QMap subclass that provides multi-valued maps</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMutex</b></td><td>Access serialization between threads</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMutexLocker</b></td><td>Convenience class that simplifies locking and unlocking mutexes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QObject</b></td><td>The base class of all Qt objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QObjectCleanupHandler</b></td><td>Watches the lifetime of multiple QObjects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPair</b></td><td>Template class that stores a pair of items</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPersistentModelIndex</b></td><td>Used to locate data in a data model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPluginLoader</b></td><td>Loads a plugin at runtime</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPoint</b></td><td>Defines a point in the plane</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPointF</b></td><td>Point object that uses floating point coordinates for accuracy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPointer</b></td><td>Template class that provides guarded pointers to QObjects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QProcess</b></td><td>Used to start external programs and to communicate with them</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QQueue</b></td><td>Generic container that provides a queue</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QReadLocker</b></td><td>Convenience class that simplifies locking and unlocking read-write locks for read access</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QReadWriteLock</b></td><td>Read-write locking</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRect</b></td><td>Defines a rectangle in the plane</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRectF</b></td><td>Defines a rectangle in the plane using floating point coordinates for accuracy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRegExp</b></td><td>Pattern matching using regular expressions</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QResource</b></td><td>Access to application resource data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSemaphore</b></td><td>General counting semaphore</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSet</b></td><td>Template class that provides a hash-table-based set</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSettings</b></td><td>Persistent platform-independent application settings</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSharedData</b></td><td>Base class for shared data objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSharedDataPointer</b></td><td>Pointer to a shared data object</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSignal</b></td><td>Can be used to send signals for classes that do not inherit QObject</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSignalMapper</b></td><td>Bundles signals from identifiable senders</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSize</b></td><td>Defines the size of a two-dimensional object</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSizeF</b></td><td>Defines the size of a two-dimensional object using floating point values for accuracy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSocketNotifier</b></td><td>Support for monitoring activity on a file descriptor</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStack</b></td><td>Template class that provides a stack</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QString</b></td><td>Unicode character string</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStringList</b></td><td>List of strings</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTemporaryFile</b></td><td>I/O device that operates on temporary files</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextCodec</b></td><td>Conversions between text encodings</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextCodecPlugin</b></td><td>Abstract base for custom QTextCodec plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextDecoder</b></td><td>State-based decoder</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextEncoder</b></td><td>State-based encoder</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextIStream</b></td><td>Convenience class for input streams</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextOStream</b></td><td>Convenience class for output streams</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextStream</b></td><td>Convenient interface for reading and writing text</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QThread</b></td><td>Platform-independent threads</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QThreadStorage</b></td><td>Per-thread data storage</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTime</b></td><td>Clock time functions</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTimer</b></td><td>Repetitive and single-shot timers</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTimerEvent</b></td><td>Parameters that describe a timer event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTranslator</b></td><td>Internationalization support for text output</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTranslatorMessage</b></td><td>Translator message and its properties</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTsciiCodec</b></td><td>Conversion to and from the Tamil TSCII encoding</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QUrl</b></td><td>Convenient interface for working with URLs</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QUuid</b></td><td>Defines a Universally Unique Identifier (UUID)</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QVarLengthArray</b></td><td>Low-level variable-length array</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QVariant</b></td><td>Acts like a union for the most common Qt data types</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QVector</b></td><td>Template class that provides a dynamic array</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWaitCondition</b></td><td>Condition variable for synchronizing threads</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWriteLocker</b></td><td>Convenience class that simplifies locking and unlocking read-write locks for write access</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtgui.html b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtgui.html
new file mode 100644
index 000000000..9182b4cb4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtgui.html
@@ -0,0 +1,276 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtGui Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="qtcore.html" />
+ <link rel="contents" href="modules.html" />
+ <link rel="next" href="qtnetwork.html" />
+</head>
+<body>
+<h1 align="center">QtGui Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractButton</b></td><td>The abstract base class of button widgets, providing functionality common to buttons</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractItemDelegate</b></td><td>Used to display and edit data items from a model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractItemView</b></td><td>The basic functionality for item view classes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractScrollArea</b></td><td>Scrolling area with on-demand scroll bars</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractSlider</b></td><td>Integer value within a range</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractSpinBox</b></td><td>Spinwidget and a line edit to display values</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractTextDocumentLayout</b></td><td>Abstract base class used to implement custom layouts for QTextDocuments</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAccessible</b></td><td>Enums and static functions relating to accessibility</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAccessibleInterface</b></td><td>Defines an interface that exposes information about accessible objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAccessibleObject</b></td><td>Implements parts of the QAccessibleInterface for QObjects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAccessiblePlugin</b></td><td>Abstract base for accessibility plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAccessibleWidget</b></td><td>Implements the QAccessibleInterface for QWidgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAction</b></td><td>Abstract user interface action that can be inserted into widgets with QWidget::addAction()</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QActionGroup</b></td><td>Groups actions together</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QApplication</b></td><td>Manages the GUI application's control flow and main settings</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBitmap</b></td><td>Monochrome (1-bit depth) pixmaps</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBoxLayout</b></td><td>Lines up child widgets horizontally or vertically</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QBrush</b></td><td>Defines the fill pattern of shapes drawn by a QPainter</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QButtonGroup</b></td><td>Container to organize groups of button widgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCDEStyle</b></td><td>CDE look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCheckBox</b></td><td>Checkbox with a text label</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QClipboard</b></td><td>Access to the window system clipboard</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCloseEvent</b></td><td>Parameters that describe a close event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QColor</b></td><td>Colors based on RGB or HSV values</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QColorDialog</b></td><td>Dialog widget for specifying colors</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QColorGroup</b></td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QComboBox</b></td><td>Combined button and popup list</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCommonStyle</b></td><td>Encapsulates the common Look and Feel of a GUI</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QConicalGradient</b></td><td>Used in combination with QBrush to specify a conical gradient brush</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QContextMenuEvent</b></td><td>Parameters that describe a context menu event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCopChannel</b></td><td>Communication capabilities between several clients</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QCursor</b></td><td>Mouse cursor with an arbitrary shape</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDateTimeEdit</b></td><td>Widget for editing dates and times</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDecoration</b></td><td>Allows the appearance of the Qtopia Core Window Manager to be customized</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDecorationFactory</b></td><td>Creates QDecoration objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDecorationPlugin</b></td><td>Abstract base for custom QDecoration plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDesktopWidget</b></td><td>Access to screen information on multi-head systems</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDial</b></td><td>Rounded range control (like a speedometer or potentiometer)</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDialog</b></td><td>The base class of dialog windows</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDirModel</b></td><td>Data model for the local filesystem</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDirectPainter</b></td><td>Direct access to the video hardware</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDockWidget</b></td><td>Widget that can be docked inside a QMainWindow or floated as a top-level window on the desktop</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDoubleSpinBox</b></td><td>Spin box widget that takes doubles</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDoubleValidator</b></td><td>Range checking of floating-point numbers</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDrag</b></td><td>Support for MIME-based drag and drop data transfer</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDragEnterEvent</b></td><td>Event which is sent to a widget when a drag and drop action enters it</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDragLeaveEvent</b></td><td>Event that is sent to a widget when a drag and drop action leaves it</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDragMoveEvent</b></td><td>Event which is sent while a drag and drop action is in progress</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDropEvent</b></td><td>Event which is sent when a drag and drop action is completed</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QErrorMessage</b></td><td>Error message display dialog</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileDialog</b></td><td>Dialog that allow users to select files or directories</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileIconProvider</b></td><td>File icon for the QDirModel class</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFileOpenEvent</b></td><td>Event that will be sent when there is a request to open a file</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFocusEvent</b></td><td>Event parameters for widget focus events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFocusFrame</b></td><td>Focus frame which can be outside of a widget's normal paintable area</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFont</b></td><td>Font used for drawing text</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFontDatabase</b></td><td>Information about the fonts available in the underlying window system</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFontDialog</b></td><td>Dialog widget for selecting a font</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFontInfo</b></td><td>General information about fonts</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFontMetrics</b></td><td>Font metrics information</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFontMetricsF</b></td><td>Font metrics information</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFrame</b></td><td>The base class of widgets that can have a frame</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGfxDriverFactory</b></td><td>Creates QScreen objects for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGfxDriverPlugin</b></td><td>Abstract base for Qtopia Core graphics driver plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGradient</b></td><td>Used in combination with QBrush to specify gradient fills</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGridLayout</b></td><td>Lays out widgets in a grid</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGridWidget</b></td><td>Simple geometry management of its children</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGroupBox</b></td><td>Group box frame with a title</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHBoxLayout</b></td><td>Lines up widgets horizontally</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHBoxWidget</b></td><td>Horizontal geometry management for its child widgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHeaderView</b></td><td>Header row or header column for item views</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHideEvent</b></td><td>Event which is sent after a widget is hidden</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHoverEvent</b></td><td>Parameters that describe a mouse event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIcon</b></td><td>Scalable icons in different modes and states</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIconDragEvent</b></td><td>Indicates that a main icon drag has begun</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIconEngine</b></td><td>Abstract base class for QIcon renderers</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIconEnginePlugin</b></td><td>Abstract base for custom QIconEngine plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImage</b></td><td>Hardware-independent pixmap that allows direct access to the pixel data, and can be used as a paint device</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImageIOHandler</b></td><td>Defines the common image I/O interface for all image formats in Qt</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImageIOHandlerFactoryInterface</b></td><td>The factory interface for QImageIOPlugin</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImageIOPlugin</b></td><td>Defines an interface for writing an image format plugin</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImageReader</b></td><td>Format independent interface for reading images from files or other devices</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QImageWriter</b></td><td>Format independent interface for writing images to files or other devices</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QInputContext</b></td><td>Abstracts the input method dependent data and composing state</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QInputContextPlugin</b></td><td>Abstract base for custom QInputContext plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QInputDialog</b></td><td>Simple convenience dialog to get a single value from the user</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QInputEvent</b></td><td>The base class for events that describe user input</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QInputMethodEvent</b></td><td>Parameters for input method events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QIntValidator</b></td><td>Validator that ensures a string contains a valid integer within a specified range</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QItemDelegate</b></td><td>Display and editing facilities for data items from a model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QItemSelection</b></td><td>Manages information about selected items in a model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QItemSelectionModel</b></td><td>Keeps track of a view's selected items</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QItemSelectionRange</b></td><td>Manages information about a range of selected items in a model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QKbdDriverFactory</b></td><td>Creates QWSKeyboardHandler objects for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QKbdDriverPlugin</b></td><td>Abstract base for Qtopia Core keyboard driver plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QKeyEvent</b></td><td>Describes a key event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QKeySequence</b></td><td>Encapsulates a key sequence as used by shortcuts</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLCDNumber</b></td><td>Displays a number with LCD-like digits</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLabel</b></td><td>Text or image display</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLayout</b></td><td>The base class of geometry managers</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLayoutItem</b></td><td>Abstract item that a QLayout manipulates</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLineEdit</b></td><td>One-line text editor</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QLinearGradient</b></td><td>Used in combination with QBrush to specify a linear gradient brush</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QListView</b></td><td>Default model/view implementation of a list, and of an icon view</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QListWidget</b></td><td>Item-based list widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QListWidgetItem</b></td><td>Item for use with the QListWidget item view class</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMacMime</b></td><td>Maps open-standard MIME to Mac flavors</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMacStyle</b></td><td>Implements an Appearance Manager style</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMainWindow</b></td><td>Main application window</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMatrix</b></td><td>2D transformations of a coordinate system</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMenu</b></td><td>Menu widget for use in menu bars, context menus, and other popup menus</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMenuBar</b></td><td>Horizontal menu bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMenuItem</b></td><td>Represents an item in a menu</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMessageBox</b></td><td>Modal dialog with a short message, an icon, and some buttons</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMotifPlusStyle</b></td><td>More sophisticated Motif-ish look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMotifStyle</b></td><td>Motif look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMouseDriverFactory</b></td><td>Creates QWSMouseHandler objects for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMouseDriverPlugin</b></td><td>Abstract base for Qtopia Core mouse driver plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMouseEvent</b></td><td>Parameters that describe a mouse event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMoveEvent</b></td><td>Event parameters for move events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QMovie</b></td><td>Convenience class for playing movies with QImageReader</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPaintDevice</b></td><td>The base class of objects that can be painted</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPaintEngine</b></td><td>Abstract definition of how QPainter draws to a given device on a given platform</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPaintEvent</b></td><td>Event parameters for paint events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPainter</b></td><td>Does low-level painting e.g. on widgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPainterPath</b></td><td>Container for painting operations, enabling graphical shapes to be constructed and reused</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPalette</b></td><td>Color groups for each widget state</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPen</b></td><td>Defines how a QPainter should draw lines and outlines of shapes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPicture</b></td><td>Paint device that records and replays QPainter commands</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPictureFormatPlugin</b></td><td>Abstract base for custom picture format plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPictureIO</b></td><td>Parameters for loading and saving pictures</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPixmap</b></td><td>Off-screen, pixel-based paint device</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPixmapCache</b></td><td>Application-wide cache for pixmaps</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPlatinumStyle</b></td><td>Mac/Platinum look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPolygon</b></td><td>Vector of points</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPolygonF</b></td><td>Vector of points</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPrintEngine</b></td><td>Defines an interface for how QPrinter interacts with a given printing subsystem</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPrinter</b></td><td>Paint device that paints on a printer</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QProgressBar</b></td><td>Horizontal progress bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QProgressDialog</b></td><td>Feedback on the progress of a slow operation</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QProxyModel</b></td><td>Support for filtering and sorting data that is passed between another model and a view</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QPushButton</b></td><td>Command button</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRadialGradient</b></td><td>Used in combination with QBrush to specify a radial gradient brush</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRadioButton</b></td><td>Radio button with a text label</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRegExpValidator</b></td><td>Used to check a string against a regular expression</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRegion</b></td><td>Clip region for a painter</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QResizeEvent</b></td><td>Event parameters for resize events</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QRubberBand</b></td><td>Rectangle or line that can indicate a selection or a boundary</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSGIStyle</b></td><td>SGI/Irix look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QScreen</b></td><td>And its descendants manage the framebuffer and palette</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QScrollArea</b></td><td>Scrolling view onto another widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QScrollBar</b></td><td>Vertical or horizontal scroll bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSessionManager</b></td><td>Access to the session manager</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QShortcut</b></td><td>Used to create keyboard shortcuts</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QShowEvent</b></td><td>Event that is sent when a widget is shown</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSizeGrip</b></td><td>Corner-grip for resizing a top-level window</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSizePolicy</b></td><td>Layout attribute describing horizontal and vertical resizing policy</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSlider</b></td><td>Vertical or horizontal slider</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSound</b></td><td>Access to the platform audio facilities</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSpacerItem</b></td><td>Blank space in a layout</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSpinBox</b></td><td>Spin box widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSplashScreen</b></td><td>Splash screen that can be shown during application startup</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSplitter</b></td><td>Implements a splitter widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSplitterHandle</b></td><td>Handle functionality of the splitter</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStackedLayout</b></td><td>Stack of widgets where only one widget is visible at a time</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStackedWidget</b></td><td>Stack of widgets where only one widget is visible at a time</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStandardItemModel</b></td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStatusBar</b></td><td>Horizontal bar suitable for presenting status information</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyle</b></td><td>Abstract base class that encapsulates the look and feel of a GUI</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleFactory</b></td><td>Creates QStyle objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleHintReturn</b></td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOption</b></td><td>Stores the parameters used by QStyle functions</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionButton</b></td><td>Used to describe the parameters for drawing buttons</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionComboBox</b></td><td>Used to describe the parameter for drawing a combobox</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionComplex</b></td><td>Used to hold parameters that are common to all complex controls</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionDockWidget</b></td><td>Used to describe the parameters for drawing a dock window</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionFocusRect</b></td><td>Used to describe the parameters for drawing a focus rectangle with QStyle</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionFrame</b></td><td>Used to describe the parameters for drawing a frame</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionHeader</b></td><td>Used to describe the parameters for drawing a header</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionMenuItem</b></td><td>Used to describe the parameter necessary for drawing a menu item</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionProgressBar</b></td><td>Used to describe the parameters necessary for drawing a progress bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionQ3DockWindow</b></td><td>Used to describe the parameters for drawing various parts of a </td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionQ3ListView</b></td><td>Used to describe the parameters for drawing a Q3ListView</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionQ3ListViewItem</b></td><td>Used to describe an item drawn in a Q3ListView</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionSlider</b></td><td>Used to describe the parameters needed for drawing a slider</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionSpinBox</b></td><td>Used to describe the parameters necessary for drawing a spin box</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionTab</b></td><td>Used to describe the parameters for drawing a tab bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionTitleBar</b></td><td>Used to describe the parameters for drawing a title bar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionToolBox</b></td><td>Used to describe the parameters needed for drawing a tool box</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionToolButton</b></td><td>Used to describe the parameters for drawing a tool button</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStyleOptionViewItem</b></td><td>Used to describe the parameters used to draw an item in a view widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStylePainter</b></td><td>Convenience class for drawing QStyle elements inside a widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QStylePlugin</b></td><td>Abstract base for custom QStyle plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTabBar</b></td><td>Tab bar, e.g. for use in tabbed dialogs</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTabWidget</b></td><td>Stack of tabbed widgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTableView</b></td><td>Default model/view implementation of a table view</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTableWidget</b></td><td>Item-based table view with a default model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTableWidgetItem</b></td><td>Item for use with the QTableWidget class</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTableWidgetSelectionRange</b></td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTabletEvent</b></td><td>Parameters that describe a Tablet event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextBlock</b></td><td>Container for text fragments in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextBlockFormat</b></td><td>Formatting information for blocks of text in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextBlockGroup</b></td><td>Container for text blocks within a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextBrowser</b></td><td>Rich text browser with hypertext navigation</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextCharFormat</b></td><td>Formatting information for characters in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextCursor</b></td><td>Offers an API to access and modify QTextDocuments</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextDocument</b></td><td>Holds formatted text that can be viewed and edited using a QTextEdit</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextDocumentFragment</b></td><td>Represents a piece of formatted text from a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextEdit</b></td><td>Widget that is used to edit and display both plain and rich text</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextFormat</b></td><td>Formatting information for a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextFragment</b></td><td>Holds a piece of text in a QTextDocument with a single QTextCharFormat</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextFrame</b></td><td>Represents a frame in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextFrameFormat</b></td><td>Formatting information for frames in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextImageFormat</b></td><td>Formatting information for images in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextInlineObject</b></td><td>Represents an inline object in a QTextLayout</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextLayout</b></td><td>Used to lay out and paint a single paragraph of text</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextLength</b></td><td>Encapsulates the different types of length used in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextLine</b></td><td>Represents a line of text inside a QTextLayout</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextList</b></td><td>Decorated list of items in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextListFormat</b></td><td>Formatting information for lists in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextObject</b></td><td>Base class for different kinds of objects that can group parts of a QTextDocument together</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextOption</b></td><td>Description of general rich text properties</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextTable</b></td><td>Represents a table in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextTableCell</b></td><td>Represents the properties of a cell in a QTextTable</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTextTableFormat</b></td><td>Formatting information for tables in a QTextDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QToolBar</b></td><td>Movable panel that contains a set of controls</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QToolBarChangeEvent</b></td><td>Event that is sent whenever a the toolbar button is clicked on Mac OS X</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QToolBox</b></td><td>Column of tabbed widget items</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QToolButton</b></td><td>Quick-access button to commands or options, usually used inside a QToolBar</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QToolTip</b></td><td>Tool tips (balloon help) for any widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTreeView</b></td><td>Default model/view implementation of a tree view</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTreeWidget</b></td><td>Tree view that uses a predefined tree model</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTreeWidgetItem</b></td><td>Item for use with the QTreeWidget convenience class</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QVBoxLayout</b></td><td>Lines up widgets vertically</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QVBoxWidget</b></td><td>Vertical geometry management of its child widgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QValidator</b></td><td>Validation of input text</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWSInputMethod</b></td><td>International input methods for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWSKeyboardHandler</b></td><td>Implements the keyboard driver for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWSMouseHandler</b></td><td>Mouse driver for Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWSServer</b></td><td>Server-specific functionality in Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWSWindow</b></td><td>Server-specific functionality in Qtopia Core</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWhatsThis</b></td><td>Simple description of any widget, i.e. answering the question &quot;What's this?&quot;</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWhatsThisAction</b></td><td>Ready-made action to invoke &quot;What's This&quot; context help</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWheelEvent</b></td><td>Parameters that describe a wheel event</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWidget</b></td><td>The base class of all user interface objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWidgetContainerPlugin</b></td><td>Abstract base for complex custom container QWidget plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWidgetItem</b></td><td>Layout item that represents a widget</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWidgetPlugin</b></td><td>Abstract base for custom QWidget plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWindowsMime</b></td><td>Maps open-standard MIME to Window Clipboard formats</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWindowsStyle</b></td><td>Microsoft Windows-like look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWindowsXPStyle</b></td><td>Microsoft WindowsXP-like look and feel</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QWorkspace</b></td><td>Workspace window that be used in an MDI application</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QX11Info</b></td><td>Information about the X display configuration</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtnetwork.html b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtnetwork.html
new file mode 100644
index 000000000..01e1fa48b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtnetwork.html
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtNetwork Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="qtgui.html" />
+ <link rel="contents" href="modules.html" />
+ <link rel="next" href="qtopengl.html" />
+</head>
+<body>
+<h1 align="center">QtNetwork Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QAbstractSocket</b></td><td>The base functionality common to all socket types</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QFtp</b></td><td>Implementation of the FTP protocol</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHostAddress</b></td><td>IP address</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHostInfo</b></td><td>Static functions for host name lookups</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHttp</b></td><td>Implementation of the HTTP protocol</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHttpHeader</b></td><td>Header information for HTTP</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHttpRequestHeader</b></td><td>Request header information for HTTP</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QHttpResponseHeader</b></td><td>Response header information for HTTP</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTcpServer</b></td><td>TCP-based server</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QTcpSocket</b></td><td>TCP socket</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QUdpSocket</b></td><td>UDP socket</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QUrlInfo</b></td><td>Stores information about URLs</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtopengl.html b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtopengl.html
new file mode 100644
index 000000000..c42c4ae26
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtopengl.html
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtOpenGL Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="qtnetwork.html" />
+ <link rel="contents" href="modules.html" />
+ <link rel="next" href="qtsql.html" />
+</head>
+<body>
+<h1 align="center">QtOpenGL Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGLColormap</b></td><td>Used for installing custom colormaps into QGLWidgets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGLContext</b></td><td>Encapsulates an OpenGL rendering context</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGLFormat</b></td><td>The display format of an OpenGL rendering context</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QGLWidget</b></td><td>Widget for rendering OpenGL graphics</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtsql.html b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtsql.html
new file mode 100644
index 000000000..db44d6d36
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtsql.html
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtSql Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="qtopengl.html" />
+ <link rel="contents" href="modules.html" />
+ <link rel="next" href="qtxml.html" />
+</head>
+<body>
+<h1 align="center">QtSql Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlDatabase</b></td><td>Represents a connection to a database</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlDriver</b></td><td>Abstract base class for accessing specific SQL databases</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlDriverCreator</b></td><td>Template class that provides a SQL driver factory for a specific driver type</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlDriverCreatorBase</b></td><td>The base class for SQL driver factories</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlDriverPlugin</b></td><td>Abstract base for custom QSqlDriver plugins</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlError</b></td><td>SQL database error information</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlField</b></td><td>Manipulates the fields in SQL database tables and views</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlIndex</b></td><td>Functions to manipulate and describe database indexes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlQuery</b></td><td>Means of executing and manipulating SQL statements</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlQueryModel</b></td><td>Read-only data model for SQL result sets</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlRecord</b></td><td>Encapsulates a database record</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlRelation</b></td><td>Stores information about an SQL foreign key</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlRelationalDelegate</b></td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlRelationalTableModel</b></td><td>Editable data model for a single database table, with foreign key support</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlResult</b></td><td>Abstract interface for accessing data from specific SQL databases</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QSqlTableModel</b></td><td>Editable data model for a single database table</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtxml.html b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtxml.html
new file mode 100644
index 000000000..d10d54237
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/qtxml.html
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- /home/dboddie/dev/qt-4.0/doc/src/classes.qdoc -->
+<head>
+ <title>Qt 4.0: QtXml Classes</title>
+ <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+td.postheader { font-family: sans-serif }
+tr.address { font-family: sans-serif }
+body { background: #ffffff; color: black; }</style>
+ <link rel="prev" href="qtsql.html" />
+ <link rel="contents" href="modules.html" />
+</head>
+<body>
+<h1 align="center">QtXml Classes</h1>
+<p><table width="100%">
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomAttr</b></td><td>Represents one attribute of a QDomElement</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomCDATASection</b></td><td>Represents an XML CDATA section</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomCharacterData</b></td><td>Represents a generic string in the DOM</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomComment</b></td><td>Represents an XML comment</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomDocument</b></td><td>Represents an XML document</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomDocumentFragment</b></td><td>Tree of QDomNodes which is not usually a complete QDomDocument</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomDocumentType</b></td><td>The representation of the DTD in the document tree</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomElement</b></td><td>Represents one element in the DOM tree</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomEntity</b></td><td>Represents an XML entity</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomEntityReference</b></td><td>Represents an XML entity reference</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomImplementation</b></td><td>Information about the features of the DOM implementation</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomNamedNodeMap</b></td><td>Collection of nodes that can be accessed by name</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomNode</b></td><td>The base class for all the nodes in a DOM tree</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomNodeList</b></td><td>List of QDomNode objects</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomNotation</b></td><td>Represents an XML notation</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomProcessingInstruction</b></td><td>Represents an XML processing instruction</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QDomText</b></td><td>Represents text data in the parsed XML document</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlAttributes</b></td><td>XML attributes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlContentHandler</b></td><td>Interface to report the logical content of XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlDTDHandler</b></td><td>Interface to report DTD content of XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlDeclHandler</b></td><td>Interface to report declaration content of XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlDefaultHandler</b></td><td>Default implementation of all the XML handler classes</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlEntityResolver</b></td><td>Interface to resolve external entities contained in XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlErrorHandler</b></td><td>Interface to report errors in XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlInputSource</b></td><td>The input data for the QXmlReader subclasses</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlLexicalHandler</b></td><td>Interface to report the lexical content of XML data</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlLocator</b></td><td>The XML handler classes with information about the parsing position within a file</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlNamespaceSupport</b></td><td>Helper class for XML readers which want to include namespace support</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlParseException</b></td><td>Used to report errors with the QXmlErrorHandler interface</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlReader</b></td><td>Interface for XML readers (i.e. parsers)</td></tr>
+<tr valign="top" bgcolor="#f0f0f0"><td><b>QXmlSimpleReader</b></td><td>Implementation of a simple XML parser</td></tr>
+</table></p>
+</body>
+</html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/titles.txt b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/titles.txt
new file mode 100644
index 000000000..016825d87
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/Resources/titles.txt
@@ -0,0 +1,7 @@
+Qt Classes by Module :/Resources/modules.html
+QtCore :/Resources/qtcore.html
+QtGui :/Resources/qtgui.html
+QtNetwork :/Resources/qtnetwork.html
+QtOpenGL :/Resources/qtopengl.html
+QtSql :/Resources/qtsql.html
+QtXml :/Resources/qtxml.html
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.qrc
new file mode 100644
index 000000000..8c462a517
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/dockwidgets.qrc
@@ -0,0 +1,12 @@
+<RCC>
+ <qresource>
+ <file>Resources/titles.txt</file>
+ <file>Resources/modules.html</file>
+ <file>Resources/qtcore.html</file>
+ <file>Resources/qtgui.html</file>
+ <file>Resources/qtnetwork.html</file>
+ <file>Resources/qtopengl.html</file>
+ <file>Resources/qtsql.html</file>
+ <file>Resources/qtxml.html</file>
+ </qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/main.cpp
new file mode 100644
index 000000000..97c2aacd1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QMainWindow *window = new MainWindow;
+ window->show();
+ window->resize(640, 480);
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.cpp
new file mode 100644
index 000000000..6e1753611
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ setWindowTitle("Dock Widgets");
+
+ setupDockWindow();
+ setupContents();
+ setupMenus();
+
+ textBrowser = new QTextBrowser(this);
+
+ connect(headingList, SIGNAL(itemClicked(QListWidgetItem *)),
+ this, SLOT(updateText(QListWidgetItem *)));
+
+ updateText(headingList->item(0));
+ headingList->setCurrentRow(0);
+ setCentralWidget(textBrowser);
+}
+
+void MainWindow::setupContents()
+{
+ QFile titlesFile(":/Resources/titles.txt");
+ titlesFile.open(QFile::ReadOnly);
+ int chapter = 0;
+
+ do {
+ QString line = titlesFile.readLine().trimmed();
+ QStringList parts = line.split("\t", QString::SkipEmptyParts);
+ if (parts.size() != 2)
+ break;
+
+ QString chapterTitle = parts[0];
+ QString fileName = parts[1];
+
+ QFile chapterFile(fileName);
+
+ chapterFile.open(QFile::ReadOnly);
+ QListWidgetItem *item = new QListWidgetItem(chapterTitle, headingList);
+ item->setData(Qt::DisplayRole, chapterTitle);
+ item->setData(Qt::UserRole, chapterFile.readAll());
+ item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+ chapterFile.close();
+
+ chapter++;
+ } while (titlesFile.isOpen());
+
+ titlesFile.close();
+}
+
+void MainWindow::setupDockWindow()
+{
+//! [0]
+ contentsWindow = QDockWidget(tr("Table of Contents"), self)
+ contentsWindow.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
+ addDockWidget(Qt.LeftDockWidgetArea, contentsWindow)
+
+ headingList = QListWidget(contentsWindow)
+ contentsWindow.setWidget(headingList)
+//! [0]
+}
+
+void MainWindow::setupMenus()
+{
+ QAction *exitAct = new QAction(tr("E&xit"), this);
+ exitAct->setShortcut(tr("Ctrl+Q"));
+ exitAct->setStatusTip(tr("Exit the application"));
+ connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
+
+ QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
+ fileMenu->addAction(exitAct);
+}
+
+void MainWindow::updateText(QListWidgetItem *item)
+{
+ QString text = item->data(Qt::UserRole).toString();
+ textBrowser->setHtml(text);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.h
new file mode 100644
index 000000000..29163b607
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dockwidgets/mainwindow.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+class QDockWidget;
+class QListWidget;
+class QListWidgetItem;
+class QTextBrowser;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow(QWidget *parent = 0);
+
+private slots:
+ void updateText(QListWidgetItem *item);
+
+private:
+ void setupContents();
+ void setupDockWindow();
+ void setupMenus();
+
+ QDockWidget *contentsWindow;
+ QListWidget *headingList;
+ QTextBrowser *textBrowser;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.cpp
new file mode 100644
index 000000000..4d31bf612
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.cpp
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "dragwidget.h"
+
+DragWidget::DragWidget(QWidget *parent)
+ : QFrame(parent)
+{
+ setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
+ dragDropLabel = new QLabel("", this);
+ dragDropLabel->setAlignment(Qt::AlignHCenter);
+
+ QHBoxLayout *layout = new QHBoxLayout(this);
+ layout->addStretch(0);
+ layout->addWidget(dragDropLabel);
+ layout->addStretch(0);
+
+ setAcceptDrops(true);
+}
+
+// Accept all actions, but deal with them separately later.
+//! [0]
+void DragWidget::dragEnterEvent(QDragEnterEvent *event)
+{
+ event->acceptProposedAction();
+}
+//! [0]
+
+//! [1]
+void DragWidget::dropEvent(QDropEvent *event)
+{
+ if (event->source() == this && event->possibleActions() & Qt::MoveAction)
+ return;
+//! [1]
+
+//! [2]
+ if (event->proposedAction() == Qt::MoveAction) {
+ event->acceptProposedAction();
+ // Process the data from the event.
+//! [2]
+ emit dragResult(tr("The data was moved here."));
+//! [3]
+ } else if (event->proposedAction() == Qt::CopyAction) {
+ event->acceptProposedAction();
+ // Process the data from the event.
+//! [3]
+ emit dragResult(tr("The data was copied here."));
+//! [4]
+ } else {
+ // Ignore the drop.
+ return;
+ }
+//! [4]
+ // End of quote
+
+ emit mimeTypes(event->mimeData()->formats());
+ setData(event->mimeData()->formats()[0],
+ event->mimeData()->data(event->mimeData()->formats()[0]));
+//! [5]
+}
+//! [5]
+
+//! [6]
+void DragWidget::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton)
+ dragStartPosition = event->pos();
+}
+//! [6]
+
+//! [7]
+void DragWidget::mouseMoveEvent(QMouseEvent *event)
+{
+ if (!(event->buttons() & Qt::LeftButton))
+ return;
+ if ((event->pos() - dragStartPosition).manhattanLength()
+ < QApplication::startDragDistance())
+ return;
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setData(mimeType, data);
+ drag->setMimeData(mimeData);
+
+ Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
+//! [7]
+
+ switch (dropAction) {
+ case Qt::CopyAction:
+ emit dragResult(tr("The text was copied."));
+ break;
+ case Qt::MoveAction:
+ emit dragResult(tr("The text was moved."));
+ break;
+ default:
+ emit dragResult(tr("Unknown action."));
+ break;
+ }
+//! [8]
+}
+//! [8]
+
+void DragWidget::setData(const QString &mimetype, const QByteArray &newData)
+{
+ mimeType = mimetype;
+ data = QByteArray(newData);
+
+ dragDropLabel->setText(tr("%1 bytes").arg(data.size()));
+
+ QStringList formats;
+ formats << mimetype;
+ emit mimeTypes(formats);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.h
new file mode 100644
index 000000000..0e20d53f1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/dragwidget.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef DRAGWIDGET_H
+#define DRAGWIDGET_H
+
+#include <QByteArray>
+#include <QFrame>
+#include <QString>
+#include <QStringList>
+
+class QComboBox;
+class QFrame;
+class QLabel;
+class QTextBrowser;
+
+class DragWidget : public QFrame
+{
+ Q_OBJECT
+
+public:
+ DragWidget(QWidget *parent);
+ void setData(const QString &mimetype, const QByteArray &newData);
+
+signals:
+ void dragResult(const QString &actionText);
+ void mimeTypes(const QStringList &types);
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+
+private:
+ QByteArray data;
+ QLabel *dragDropLabel;
+ QPoint dragStartPosition;
+ QString mimeType;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/main.cpp
new file mode 100644
index 000000000..b25cc33b9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window1 = new MainWindow;
+ MainWindow *window2 = new MainWindow;
+ window1->show();
+ window2->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.cpp
new file mode 100644
index 000000000..4dc3b8bfb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "dragwidget.h"
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ QFrame *centralWidget = new QFrame(this);
+
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), centralWidget);
+ mimeTypeCombo = new QComboBox(centralWidget);
+
+ QLabel *dataLabel = new QLabel(tr("Amount of data (bytes):"), centralWidget);
+ dragWidget = new DragWidget(centralWidget);
+
+ connect(dragWidget, SIGNAL(mimeTypes(const QStringList &)),
+ this, SLOT(setMimeTypes(const QStringList &)));
+ connect(dragWidget, SIGNAL(dragResult(const QString &)),
+ this, SLOT(setDragResult(const QString &)));
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(centralWidget);
+ mainLayout->addWidget(mimeTypeLabel);
+ mainLayout->addWidget(mimeTypeCombo);
+ mainLayout->addSpacing(32);
+ mainLayout->addWidget(dataLabel);
+ mainLayout->addWidget(dragWidget);
+
+ statusBar();
+ dragWidget->setData(QString("text/plain"), QByteArray("Hello world"));
+ setCentralWidget(centralWidget);
+ setWindowTitle(tr("Drag and Drop"));
+}
+
+void MainWindow::setDragResult(const QString &actionText)
+{
+ statusBar()->showMessage(actionText);
+}
+
+void MainWindow::setMimeTypes(const QStringList &types)
+{
+ mimeTypeCombo->clear();
+ mimeTypeCombo->addItems(types);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.h
new file mode 100644
index 000000000..e07519341
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/draganddrop/mainwindow.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QPixmap>
+#include <QPoint>
+
+class QComboBox;
+class QLabel;
+class QLineEdit;
+class QMouseEvent;
+class QTextEdit;
+class DragWidget;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+
+public slots:
+ void setDragResult(const QString &actionText);
+ void setMimeTypes(const QStringList &types);
+
+private:
+ QComboBox *mimeTypeCombo;
+ DragWidget *dragWidget;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/images.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/images.qrc
new file mode 100644
index 000000000..30b8a2986
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/images.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/file.png</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/images/file.png b/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/images/file.png
new file mode 100644
index 000000000..9520080ed
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/images/file.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/main.cpp
new file mode 100644
index 000000000..08343ac18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/mainwindow.cpp
new file mode 100644
index 000000000..739e70799
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/mainwindow.cpp
@@ -0,0 +1,72 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+def mousePressEvent(self, event):
+ if event.button() == Qt.LeftButton
+ && iconLabel.geometry().contains(event.pos()):
+
+//! [1]
+ drag = QDrag(self)
+ mimeData = QMimeData()
+
+ mimeData.setText(commentEdit.toPlainText())
+ drag.setMimeData(mimeData)
+//! [1]
+ drag.setPixmap(iconPixmap)
+
+ dropAction = drag.exec_()
+//! [0]
+
+//! [2]
+
+
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/mainwindow.h
new file mode 100644
index 000000000..ffbe5ce35
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dragging/mainwindow.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QPixmap>
+#include <QPoint>
+
+class QLabel;
+class QLineEdit;
+class QMouseEvent;
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+
+protected:
+ void mousePressEvent(QMouseEvent *event);
+
+private:
+ QLabel *iconLabel;
+ QLineEdit *nameEdit;
+ QPixmap iconPixmap;
+ QPoint dragStartPosition;
+ QTextEdit *commentEdit;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/main.cpp
new file mode 100644
index 000000000..e0a65868b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window *window = new Window;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/window.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/window.cpp
new file mode 100644
index 000000000..ed5fbd39c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/window.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "window.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ QLabel *textLabel = new QLabel(tr("Data:"), this);
+ textBrowser = new QTextBrowser(this);
+
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), this);
+ mimeTypeCombo = new QComboBox(this);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(textLabel);
+ layout->addWidget(textBrowser);
+ layout->addWidget(mimeTypeLabel);
+ layout->addWidget(mimeTypeCombo);
+/*
+ ...
+ setAcceptDrops(true);
+*/
+ setAcceptDrops(true);
+ setWindowTitle(tr("Drop Actions"));
+}
+
+void Window::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasFormat("text/plain"))
+ event->acceptProposedAction();
+}
+
+void Window::dropEvent(QDropEvent *event)
+{
+ QMenu actionMenu(this);
+ QAction *copyAction = 0;
+ QAction *moveAction = 0;
+ QAction *linkAction = 0;
+ QAction *ignoreAction = 0;
+ if (event->possibleActions() & Qt::CopyAction)
+ copyAction = actionMenu.addAction(tr("Copy"));
+ if (event->possibleActions() & Qt::MoveAction)
+ moveAction = actionMenu.addAction(tr("Move"));
+ if (event->possibleActions() & Qt::LinkAction)
+ linkAction = actionMenu.addAction(tr("Link"));
+ if (event->possibleActions() & Qt::IgnoreAction)
+ ignoreAction = actionMenu.addAction(tr("Ignore"));
+
+ QAction *result = actionMenu.exec(QCursor::pos());
+
+ if (copyAction && result == copyAction)
+ event->setDropAction(Qt::CopyAction);
+ else if (moveAction && result == moveAction)
+ event->setDropAction(Qt::MoveAction);
+ else if (linkAction && result == linkAction)
+ event->setDropAction(Qt::LinkAction);
+ else {
+ event->setDropAction(Qt::IgnoreAction);
+ return;
+ }
+
+ textBrowser->setPlainText(event->mimeData()->text());
+ mimeTypeCombo->clear();
+ mimeTypeCombo->addItems(event->mimeData()->formats());
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/window.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/window.h
new file mode 100644
index 000000000..8eae5e588
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropactions/window.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QString>
+#include <QStringList>
+#include <QWidget>
+
+class QComboBox;
+class QFrame;
+class QTextBrowser;
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window(QWidget *parent = 0);
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
+
+private:
+ QComboBox *mimeTypeCombo;
+ QFrame *dropFrame;
+ QTextBrowser *textBrowser;
+ QString oldText;
+ QStringList oldMimeTypes;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/droparea.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/droparea.cpp
new file mode 100644
index 000000000..ce25fd693
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/droparea.cpp
@@ -0,0 +1,147 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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.QtGui import *
+
+
+DropArea.DropArea(QWidget *parent)
+ : QLabel(parent)
+{
+ setMinimumSize(200, 200)
+ setFrameStyle(QFrame.Sunken | QFrame::StyledPanel)
+ setAlignment(Qt.AlignCenter)
+ setAcceptDrops(True)
+ setAutoFillBackground(True)
+ clear()
+}
+
+void DropArea.dragEnterEvent(QDragEnterEvent *event)
+{
+ setText(tr("<drop content>"))
+ setBackgroundRole(QPalette.Highlight)
+
+ event.acceptProposedAction()
+ emit changed(event.mimeData())
+}
+
+void DropArea.dragMoveEvent(QDragMoveEvent *event)
+{
+ event.acceptProposedAction()
+}
+
+void DropArea.dropEvent(QDropEvent *event)
+{
+ const QMimeData *mimeData = event.mimeData()
+
+ if (mimeData.hasImage()) {
+ setPixmap(qvariant_cast<QPixmap>(mimeData.imageData()))
+ } else if (mimeData.hasHtml()) {
+ setText(mimeData.html())
+ setTextFormat(Qt.RichText)
+ } else if (mimeData.hasText()) {
+ setText(mimeData.text())
+ setTextFormat(Qt.PlainText)
+ } else {
+ setText(tr("Cannot display data"))
+ }
+
+ setBackgroundRole(QPalette.Dark)
+ event.acceptProposedAction()
+}
+
+//![0]
+def paste(self):
+ clipboard = QApplication.clipboard()
+ mimeData = clipboard.mimeData()
+
+ if mimeData.hasImage():
+ setPixmap(mimeData.imageData())
+ elif mimeData.hasHtml():
+ setText(mimeData.html())
+ setTextFormat(Qt.RichText)
+ elif (mimeData.hasText():
+ setText(mimeData.text())
+ setTextFormat(Qt.PlainText)
+ else:
+ setText(tr("Cannot display data"))
+//![0]
+
+ emit changed(mimeData)
+ setBackgroundRole(QPalette.Dark)
+ //event.acceptProposedAction()
+}
+
+void DropArea.dragLeaveEvent(QDragLeaveEvent *event)
+{
+ clear()
+ event.accept()
+}
+
+void DropArea.clear()
+{
+ setText(tr("<drop content>"))
+ setBackgroundRole(QPalette.Dark)
+
+ emit changed()
+}
+
+QPixmap DropArea.extractPixmap(const QByteArray &data, const QString &format)
+{
+ QList<QByteArray> imageFormats = QImageReader.supportedImageFormats()
+ QPixmap pixmap
+
+ foreach (QByteArray imageFormat, imageFormats) {
+ if (format.mid(6) == QString(imageFormat)) {
+ pixmap.loadFromData(data, imageFormat)
+ break
+ }
+ }
+ return pixmap
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/main.cpp
new file mode 100644
index 000000000..6916f51b4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Window *window = new Window;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/window.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/window.cpp
new file mode 100644
index 000000000..023aa1522
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/window.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "window.h"
+
+//! [0]
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ QLabel *textLabel = new QLabel(tr("Data:"), this);
+ textBrowser = new QTextBrowser(this);
+
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), this);
+ mimeTypeCombo = new QComboBox(this);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(textLabel);
+ layout->addWidget(textBrowser);
+ layout->addWidget(mimeTypeLabel);
+ layout->addWidget(mimeTypeCombo);
+
+//! [1]
+ setAcceptDrops(true);
+//! [1]
+ setWindowTitle(tr("Drop Events"));
+//! [2]
+}
+//! [2]
+
+//! [3]
+void Window::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasFormat("text/plain"))
+ event->acceptProposedAction();
+}
+//! [3]
+
+//! [4]
+void Window::dropEvent(QDropEvent *event)
+{
+ textBrowser->setPlainText(event->mimeData()->text());
+ mimeTypeCombo->clear();
+ mimeTypeCombo->addItems(event->mimeData()->formats());
+
+ event->acceptProposedAction();
+}
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/window.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/window.h
new file mode 100644
index 000000000..8eae5e588
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/dropevents/window.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QString>
+#include <QStringList>
+#include <QWidget>
+
+class QComboBox;
+class QFrame;
+class QTextBrowser;
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window(QWidget *parent = 0);
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
+
+private:
+ QComboBox *mimeTypeCombo;
+ QFrame *dropFrame;
+ QTextBrowser *textBrowser;
+ QString oldText;
+ QStringList oldMimeTypes;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/main.cpp
new file mode 100644
index 000000000..e0a65868b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window *window = new Window;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/window.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/window.cpp
new file mode 100644
index 000000000..932d8d436
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/window.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "window.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ QLabel *textLabel = new QLabel(tr("Data:"), this);
+ textBrowser = new QTextBrowser(this);
+
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), this);
+ mimeTypeCombo = new QComboBox(this);
+
+ dropFrame = new QFrame(this);
+ dropFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
+ QLabel *dropLabel = new QLabel(tr("Drop items here"), dropFrame);
+ dropLabel->setAlignment(Qt::AlignHCenter);
+
+ QVBoxLayout *dropFrameLayout = new QVBoxLayout(dropFrame);
+ dropFrameLayout->addWidget(dropLabel);
+
+ QHBoxLayout *dropLayout = new QHBoxLayout;
+ dropLayout->addStretch(0);
+ dropLayout->addWidget(dropFrame);
+ dropLayout->addStretch(0);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ mainLayout->addWidget(textLabel);
+ mainLayout->addWidget(textBrowser);
+ mainLayout->addWidget(mimeTypeLabel);
+ mainLayout->addWidget(mimeTypeCombo);
+ mainLayout->addSpacing(32);
+ mainLayout->addLayout(dropLayout);
+
+ setAcceptDrops(true);
+ setWindowTitle(tr("Drop Rectangle"));
+}
+
+//! [0]
+void Window::dragMoveEvent(QDragMoveEvent *event)
+{
+ if (event->mimeData()->hasFormat("text/plain")
+ && event->answerRect().intersects(dropFrame->geometry()))
+
+ event->acceptProposedAction();
+}
+//! [0]
+
+void Window::dropEvent(QDropEvent *event)
+{
+ textBrowser->setPlainText(event->mimeData()->text());
+ mimeTypeCombo->clear();
+ mimeTypeCombo->addItems(event->mimeData()->formats());
+
+ event->acceptProposedAction();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/window.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/window.h
new file mode 100644
index 000000000..6e0e30ee0
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/droprectangle/window.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QString>
+#include <QStringList>
+#include <QWidget>
+
+class QComboBox;
+class QFrame;
+class QTextBrowser;
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window(QWidget *parent = 0);
+
+protected:
+ void dragMoveEvent(QDragMoveEvent *event);
+ void dropEvent(QDropEvent *event);
+
+private:
+ QComboBox *mimeTypeCombo;
+ QFrame *dropFrame;
+ QTextBrowser *textBrowser;
+ QString oldText;
+ QStringList oldMimeTypes;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.cpp
new file mode 100644
index 000000000..808aaa762
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "filterobject.h"
+
+FilterObject::FilterObject(QObject *parent)
+ : QObject(parent), target(0)
+{
+}
+
+//! [0]
+bool FilterObject::eventFilter(QObject *object, QEvent *event)
+{
+ if (object == target && event->type() == QEvent::KeyPress) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ if (keyEvent->key() == Qt::Key_Tab) {
+ // Special tab handling
+ return true;
+ } else
+ return false;
+ }
+ return false;
+}
+//! [0]
+
+void FilterObject::setFilteredObject(QObject *object)
+{
+ if (target)
+ target->removeEventFilter(this);
+
+ target = object;
+
+ if (target)
+ target->installEventFilter(this);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.h
new file mode 100644
index 000000000..55ce51d6d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/filterobject.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef FILTEROBJECT_H
+#define FILTEROBJECT_H
+
+#include <QObject>
+
+class FilterObject : public QObject
+{
+ Q_OBJECT
+
+public:
+ FilterObject(QObject *parent = 0);
+ bool eventFilter(QObject *object, QEvent *event);
+ void setFilteredObject(QObject *object);
+
+private:
+ QObject *target;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/main.cpp
new file mode 100644
index 000000000..6fa7e00cb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/eventfilters/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QTextEdit>
+
+#include "filterobject.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit editor;
+ FilterObject filter;
+ filter.setFilteredObject(&editor);
+ editor.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/events/events.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/events/events.cpp
new file mode 100644
index 000000000..e3dc8ef7e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/events/events.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QCheckBox>
+#include <QMouseEvent>
+
+class MyCheckBox : public QCheckBox
+{
+public:
+ void mousePressEvent(QMouseEvent *event);
+};
+
+//! [0]
+void MyCheckBox::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+ // handle left mouse button here
+ } else {
+ // pass on other buttons to base class
+ QCheckBox::mousePressEvent(event);
+ }
+}
+//! [0]
+
+class MyWidget : public QWidget
+{
+public:
+ bool event(QEvent *event);
+};
+
+static const int MyCustomEventType = 1099;
+
+class MyCustomEvent : public QEvent
+{
+public:
+ MyCustomEvent() : QEvent((QEvent::Type)MyCustomEventType) {}
+};
+
+//! [1]
+bool MyWidget::event(QEvent *event)
+{
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *ke = static_cast<QKeyEvent *>(event);
+ if (ke->key() == Qt::Key_Tab) {
+ // special tab handling here
+ return true;
+ }
+ } else if (event->type() == MyCustomEventType) {
+ MyCustomEvent *myEvent = static_cast<MyCustomEvent *>(event);
+ // custom event handling here
+ return true;
+ }
+
+ return QWidget::event(event);
+}
+//! [1]
+
+int main()
+{
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.cpp
new file mode 100644
index 000000000..79950ded7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "employee.h"
+
+//! [0]
+EmployeeData::EmployeeData()
+{
+ id = -1;
+ name = 0;
+}
+//! [0]
+
+//! [1]
+EmployeeData::EmployeeData(const EmployeeData &other)
+//! [1] //! [2]
+ : QSharedData(other)
+{
+ id = other.id;
+ if (other.name) {
+ name = new QString(*other.name);
+ } else {
+ name = 0;
+ }
+}
+//! [2]
+
+//! [3]
+EmployeeData::~EmployeeData()
+//! [3] //! [4]
+{
+ delete name;
+}
+//! [4]
+
+//! [5]
+Employee::Employee()
+//! [5] //! [6]
+{
+ d = new EmployeeData;
+}
+//! [6]
+
+//! [7]
+Employee::Employee(int id, const QString &name)
+//! [7] //! [8]
+{
+ d = new EmployeeData;
+ setId(id);
+ setName(name);
+}
+//! [8]
+
+//! [9]
+void Employee::setName(const QString &name)
+//! [9] //! [10]
+{
+ if (!d->name)
+ d->name = new QString;
+ *d->name = name;
+}
+//! [10]
+
+//! [11]
+QString Employee::name() const
+//! [11] //! [12]
+{
+ if (!d->name)
+ return QString();
+ return *d->name;
+}
+//! [12]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.h
new file mode 100644
index 000000000..9a50889ed
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/employee.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+#include <QSharedData>
+#include <QString>
+
+class EmployeeData : public QSharedData
+{
+public:
+ EmployeeData();
+ EmployeeData(const EmployeeData &other);
+ ~EmployeeData();
+
+ int id;
+ QString *name;
+};
+
+class Employee
+{
+public:
+ Employee();
+ Employee(int id, const QString &name);
+
+ void setId(int id) { d->id = id; }
+ void setName(const QString &name);
+
+ int id() const { return d->id; }
+ QString name() const;
+
+private:
+ QExplicitlySharedDataPointer<EmployeeData> d;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/main.cpp
new file mode 100644
index 000000000..80eac22d4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/explicitlysharedemployee/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "employee.h"
+
+int main()
+{
+ {
+ Employee e1(10, "Albrecht Durer");
+ Employee e2 = e1;
+ e1.setName("Hans Holbein");
+ }
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/file/file.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/file/file.cpp
new file mode 100644
index 000000000..e52117f84
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/file/file.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QFile>
+#include <QTextStream>
+
+static void process_line(const QByteArray &)
+{
+}
+
+static void process_line(const QString &)
+{
+}
+
+static void noStream_snippet()
+{
+//! [0]
+ file = QFile("in.txt")
+ if not file.open(QIODevice.ReadOnly | QIODevice.Text):
+ return
+
+ while not file.atEnd():
+ line = file.readLine() # A QByteArray
+ process_line(line)
+//! [0]
+}
+
+static void readTextStream_snippet()
+{
+//! [1]
+ file = QFile("in.txt")
+ if not file.open(QIODevice.ReadOnly | QIODevice.Text):
+ return
+
+ in = QTextStream(file)
+ while not in.atEnd():
+ line = in.readLine() # A QByteArray
+ process_line(line)
+//! [1]
+}
+
+static void writeTextStream_snippet()
+{
+//! [2]
+ file = QFile("out.txt")
+ if not file.open(QIODevice.WriteOnly | QIODevice.Text):
+ return
+
+ out = QTextStream(file)
+ out << "The magic number is: " << 49 << "\n"
+//! [2]
+}
+
+static void writeTextStream_snippet()
+{
+ QFile file("out.dat");
+ if (!file.open(QIODevice.WriteOnly))
+ return;
+
+ QDataStream out(&file);
+ out << "The magic number is: " << 49 << "\n";
+}
+
+static void readRegularEmptyFile_snippet()
+{
+//! [3]
+ file = QFile("/proc/modules")
+ if not file.open(QIODevice.ReadOnly | QIODevice.Text):
+ return
+
+ in = QTextStream(file)
+ line = in.readLine()
+ while not line.isNull():
+ process_line(line)
+ line = in.readLine()
+//! [3]
+}
+
+int main()
+{
+ lineByLine_snippet();
+ writeStream_snippet();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/filedialogurls.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/filedialogurls.cpp
new file mode 100644
index 000000000..4aff915fe
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/filedialogurls.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+//![0]
+ QList<QUrl> urls;
+ urls << QUrl::fromLocalFile("/home/gvatteka/dev/qt-45")
+ << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
+
+ QFileDialog dialog;
+ dialog.setSidebarUrls(urls);
+ dialog.setFileMode(QFileDialog::AnyFile);
+ if(dialog.exec()) {
+ // ...
+ }
+//![0]
+
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/fileinfo/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/fileinfo/main.cpp
new file mode 100644
index 000000000..e1b266df5
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/fileinfo/main.cpp
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QPushButton>
+#include <QFileInfo>
+#include <QDir>
+#include <QGroupBox>
+#include <QVBoxLayout>
+#include <QDebug>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ fileInfo1 = QFileInfo("~/examples/191697/.")
+ fileInfo2 = QFileInfo("~/examples/191697/..")
+ fileInfo3 = QFileInfo("~/examples/191697/main.cpp")
+//! [0]
+//! [1]
+ fileInfo4 = QFileInfo(".")
+ fileInfo5 = QFileInfo("..")
+ fileInfo6 = QFileInfo("main.cpp")
+//! [1]
+
+ qDebug() << fileInfo1.fileName();
+ qDebug() << fileInfo2.fileName();
+ qDebug() << fileInfo3.fileName();
+ qDebug() << fileInfo4.fileName();
+ qDebug() << fileInfo5.fileName();
+ qDebug() << fileInfo6.fileName();
+
+ QPushButton* button1 = new QPushButton(fileInfo1.dir().path());
+ QPushButton* button2 = new QPushButton(fileInfo2.dir().path());
+ QPushButton* button3 = new QPushButton(fileInfo3.dir().path());
+ QPushButton* button4 = new QPushButton(fileInfo4.dir().path());
+ QPushButton* button5 = new QPushButton(fileInfo5.dir().path());
+ QPushButton* button6 = new QPushButton(fileInfo6.dir().path());
+
+ QVBoxLayout* vbox = new QVBoxLayout;
+ vbox->addWidget(button1);
+ vbox->addWidget(button2);
+ vbox->addWidget(button3);
+ vbox->addWidget(button4);
+ vbox->addWidget(button5);
+ vbox->addWidget(button6);
+ vbox->addStretch(1);
+
+ QGroupBox *groupBox = new QGroupBox("QFileInfo::dir() test");
+ groupBox->setLayout(vbox);
+ groupBox->show();
+
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/graphicssceneadditemsnippet.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/graphicssceneadditemsnippet.cpp
new file mode 100644
index 000000000..027bfdc5d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/graphicssceneadditemsnippet.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+class CustomScene : public QGraphicsScene
+{
+public:
+ CustomScene()
+ { addItem(new QGraphicsEllipseItem(QRect(10, 10, 30, 30))); }
+
+ void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[],
+ const QStyleOptionGraphicsItem options[],
+ QWidget *widget = 0);
+};
+
+//! [0]
+void CustomScene::drawItems(QPainter *painter, int numItems,
+ QGraphicsItem *items[],
+ const QStyleOptionGraphicsItem options[],
+ QWidget *widget)
+{
+ for (int i = 0; i < numItems; ++i) {
+ // Draw the item
+ painter->save();
+ painter->setMatrix(items[i]->sceneMatrix(), true);
+ items[i]->paint(painter, &options[i], widget);
+ painter->restore();
+ }
+}
+//! [0]
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ CustomScene scene;
+ QGraphicsView view(&scene);
+
+ view.show();
+
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/main.cpp
new file mode 100644
index 000000000..9e3fbe28e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtCore>
+#include "myclass.h"
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+
+ QTranslator translator;
+ translator.load(":/translations/i18n-non-qt-class_" + QLocale::system().name());
+ app.installTranslator(&translator);
+
+ MyClass instance;
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.cpp
new file mode 100644
index 000000000..be748892e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "myclass.h"
+
+MyClass::MyClass()
+{
+ std::cout << tr("Hello Qt!\n").toLocal8Bit().constData();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.h
new file mode 100644
index 000000000..46aa84eb6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MYCLASS_H
+#define MYCLASS_H
+
+#include <QCoreApplication>
+
+//! [0]
+class MyClass
+{
+ Q_DECLARE_TR_FUNCTIONS(MyClass)
+
+public:
+ MyClass();
+//! [0]
+ /* ... */
+//! [1]
+};
+//! [1]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.ts b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.ts
new file mode 100644
index 000000000..9bd90f244
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/myclass.ts
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1">
+<context>
+ <name>MyClass</name>
+ <message>
+ <location filename="myclass.cpp" line="6"/>
+ <source>Hello Qt!
+</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/resources.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/resources.qrc
new file mode 100644
index 000000000..903ac8578
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/resources.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>translations/i18n-non-qt-class_en.qm</file>
+ <file>translations/i18n-non-qt-class_fr.qm</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_en.ts b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_en.ts
new file mode 100644
index 000000000..54f188694
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_en.ts
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1">
+<context>
+ <name>MyClass</name>
+ <message>
+ <location filename="../myclass.cpp" line="6"/>
+ <source>Hello Qt!
+</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_fr.ts b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_fr.ts
new file mode 100644
index 000000000..3f3cebc23
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/i18n-non-qt-class/translations/i18n-non-qt-class_fr.ts
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1" language="fr">
+<context>
+ <name>MyClass</name>
+ <message>
+ <location filename="../myclass.cpp" line="6"/>
+ <source>Hello Qt!
+</source>
+ <translation>Bonjour Qt!
+</translation>
+ </message>
+</context>
+</TS>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/image/image.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/image/image.cpp
new file mode 100644
index 000000000..e03c67519
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/image/image.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+ image = QImage()
+ ba = QByteArray()
+ buffer(ba)
+ buffer.open(QIODevice.WriteOnly)
+ image.save(buffer, "PNG") # writes image into ba in PNG format
+//! [0]
+//! [1]
+ pixmap = QPixmap()
+ bytes = QByteArray()
+ buffer(bytes)
+ buffer.open(QIODevice.WriteOnly)
+ pixmap.save(buffer, "PNG") # writes pixmap into bytes in PNG format
+//! [1]
+//! [2]
+ alpha = QPixmap("image-with-alpha.png")
+ alphacopy = alpha
+ alphacopy.setMask(alphacopy.mask())
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/image/supportedformat.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/image/supportedformat.cpp
new file mode 100644
index 000000000..4e60b64ef
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/image/supportedformat.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+ writer = QImageWriter()
+ writer.setFormat("png")
+ if writer.supportsOption(QImageIOHandler.Description):
+ print "Png supports embedded text"
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/button.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/button.cpp
new file mode 100644
index 000000000..f8bbe5ede
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/button.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include "button.h"
+
+Button::Button(QWidget *parent)
+ : QPushButton(parent)
+{
+}
+
+void Button::animateClick()
+{
+ qDebug() << "Extra code goes here...";
+ QPushButton::animateClick();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/button.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/button.h
new file mode 100644
index 000000000..7f7ef891e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/button.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QPushButton>
+
+//! [Button class with reimplemented slot]
+class Button : public QPushButton
+{
+ Q_OBJECT
+
+public:
+ Button(QWidget *parent = 0);
+
+public slots:
+ void animateClick();
+};
+//! [Button class with reimplemented slot]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/main.cpp
new file mode 100644
index 000000000..5437a484f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/inherited-slot/main.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QDebug>
+#include <QHBoxLayout>
+#include <QLineEdit>
+#include <QMetaMethod>
+#include <QWidget>
+#include "button.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget window;
+ QHBoxLayout *layout = new QHBoxLayout(&window);
+ QLineEdit *lineEdit = new QLineEdit;
+ Button *button = new Button;
+
+ QObject::connect(lineEdit, SIGNAL(returnPressed()), button, SLOT(animateClick()));
+
+ layout->addWidget(lineEdit);
+ layout->addWidget(button);
+ window.show();
+
+ for (int i = 0; i < button->metaObject()->methodCount(); ++i)
+ qDebug() << i << button->metaObject()->method(i).signature();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/itemselection/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/itemselection/main.cpp
new file mode 100644
index 000000000..55f8def35
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/itemselection/main.cpp
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example that shows how selections can be used directly on a model.
+ It shows the result of some selections made using a table view.
+*/
+
+#include <QApplication>
+#include <QItemSelection>
+#include <QItemSelectionModel>
+#include <QTableView>
+
+#include "model.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ TableModel *model = new TableModel(8, 4, &app);
+
+ QTableView *table = new QTableView(0);
+ table->setModel(model);
+
+ QItemSelectionModel *selectionModel = table->selectionModel();
+//! [0] //! [1]
+ QModelIndex topLeft;
+ QModelIndex bottomRight;
+
+ topLeft = model->index(0, 0, QModelIndex());
+ bottomRight = model->index(5, 2, QModelIndex());
+//! [1]
+
+//! [2]
+ QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, QItemSelectionModel::Select);
+//! [2]
+
+//! [3]
+ QItemSelection toggleSelection;
+
+ topLeft = model->index(2, 1, QModelIndex());
+ bottomRight = model->index(7, 3, QModelIndex());
+ toggleSelection.select(topLeft, bottomRight);
+
+ selectionModel->select(toggleSelection, QItemSelectionModel::Toggle);
+//! [3]
+
+//! [4]
+ QItemSelection columnSelection;
+
+ topLeft = model->index(0, 1, QModelIndex());
+ bottomRight = model->index(0, 2, QModelIndex());
+
+ columnSelection.select(topLeft, bottomRight);
+
+ selectionModel->select(columnSelection,
+ QItemSelectionModel::Select | QItemSelectionModel::Columns);
+
+ QItemSelection rowSelection;
+
+ topLeft = model->index(0, 0, QModelIndex());
+ bottomRight = model->index(1, 0, QModelIndex());
+
+ rowSelection.select(topLeft, bottomRight);
+
+ selectionModel->select(rowSelection,
+ QItemSelectionModel::Select | QItemSelectionModel::Rows);
+//! [4]
+
+ table->setWindowTitle("Selected items in a table model");
+ table->show();
+ table->resize(460, 280);
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/itemselection/model.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/itemselection/model.h
new file mode 100644
index 000000000..886e77852
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/itemselection/model.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QVariant>
+
+class TableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ TableModel(int rows = 1, int columns = 1, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+
+private:
+ QList<QStringList> rowList;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/javastyle.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/javastyle.cpp
new file mode 100644
index 000000000..46e58e8da
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/javastyle.cpp
@@ -0,0 +1,2755 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "javastyle.h"
+#include <math.h>
+
+static const int windowsItemFrame = 2;
+static const int windowsSepHeight = 2;
+static const int windowsItemHMargin = 3;
+static const int windowsItemVMargin = 2;
+static const int windowsArrowHMargin = 6;
+static const int windowsTabSpacing = 12;
+static const int windowsCheckMarkHMargin = 2;
+static const int windowsRightBorder = 15;
+static const int windowsCheckMarkWidth = 12;
+
+JavaStyle::JavaStyle()
+{
+ qApp->setPalette(standardPalette());
+}
+
+
+inline QPoint JavaStyle::adjustScrollPoint(const QPoint &point,
+ Qt::Orientation orientation,
+ bool add) const
+{
+ int adder = add ? -1 : 1;
+ QPoint retPoint;
+
+ if (orientation == Qt::Horizontal) {
+ retPoint = QPoint(point.y() * adder, point.x());
+ } else {
+ retPoint = QPoint(point.x(), point.y() * adder);
+ }
+
+ return retPoint;
+}
+
+QPalette JavaStyle::standardPalette() const
+{
+ QPalette palette = QWindowsStyle::standardPalette();
+
+ palette.setBrush(QPalette::Active, QPalette::Button,
+ QColor(184, 207, 229));
+ palette.setBrush(QPalette::Active, QPalette::WindowText,
+ Qt::black);
+ palette.setBrush(QPalette::Active, QPalette::Background,
+ QColor(238, 238, 238));
+ palette.setBrush(QPalette::Active, QPalette::Window,
+ QColor(238 ,238, 238));
+ palette.setBrush(QPalette::Active, QPalette::Base, Qt::white);
+ palette.setBrush(QPalette::Active, QPalette::AlternateBase, QColor(238, 238, 238));
+ palette.setBrush(QPalette::Active, QPalette::Text, Qt::black);
+ palette.setBrush(QPalette::Active, QPalette::BrightText, Qt::white);
+
+ palette.setBrush(QPalette::Active, QPalette::Light, QColor(163, 184, 204)); // focusFrameColor
+ palette.setBrush(QPalette::Active, QPalette::Midlight, QColor(99, 130, 191)); // tabBarBorderColor
+ palette.setBrush(QPalette::Active, QPalette::Dark, QColor(106, 104, 100));
+ palette.setBrush(QPalette::Active, QPalette::Mid, QColor(122, 138, 153)); //defaultFrameColor
+ palette.setBrush(QPalette::Active, QPalette::Shadow, QColor(122, 138, 153)); // defaultFrame
+
+ palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(184, 207, 229));
+ palette.setBrush(QPalette::Active, QPalette::HighlightedText, Qt::black);
+
+ palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(184, 207, 229));
+ palette.setBrush(QPalette::Inactive, QPalette::HighlightedText, Qt::black);
+
+ palette.setBrush(QPalette::Disabled, QPalette::Button,
+ QColor(238, 238, 238));
+ palette.setBrush(QPalette::Disabled, QPalette::WindowText,
+ QColor(153, 153, 153));
+ palette.setBrush(QPalette::Disabled, QPalette::Background, QColor(238, 238, 238));
+
+ palette.setBrush(QPalette::Inactive, QPalette::Button,
+ QColor(184, 207, 229));
+ palette.setBrush(QPalette::Inactive, QPalette::Background,
+ QColor(238, 238, 238));
+ palette.setBrush(QPalette::Inactive, QPalette::Window,
+ QColor(238 ,238, 238));
+ palette.setBrush(QPalette::Inactive, QPalette::Light, QColor(163, 184, 204)); // focusFrameColor
+ palette.setBrush(QPalette::Inactive, QPalette::Midlight, QColor(99, 130, 191)); // tabBarBorderColor
+ palette.setBrush(QPalette::Inactive, QPalette::Dark,QColor(106, 104, 100));
+ palette.setBrush(QPalette::Inactive, QPalette::Mid, QColor(122, 138, 153)); //defaultFrame
+ palette.setBrush(QPalette::Inactive, QPalette::Shadow, QColor(122, 138, 153)); // defaultFrame
+
+ return palette;
+}
+
+inline void JavaStyle::drawScrollBarArrow(const QRect &rect, QPainter *painter,
+ const QStyleOptionSlider *option,
+ bool add) const
+{
+
+ painter->save();
+
+ Qt::Orientation orient = option->orientation;
+ QPoint offset;
+
+ if (add) {
+ if (orient == Qt::Vertical) {
+ offset = rect.bottomLeft();
+ } else {
+ offset = rect.topRight();
+ }
+ } else {
+ offset = rect.topLeft();
+ }
+
+ QPainterPath arrow;
+ arrow.moveTo(offset + adjustScrollPoint(QPoint(4, 8), orient, add));
+ arrow.lineTo(offset + adjustScrollPoint(QPoint(7, 5), orient, add));
+ arrow.lineTo(offset + adjustScrollPoint(QPoint(8, 5), orient, add));
+ arrow.lineTo(offset + adjustScrollPoint(QPoint(11, 8), orient, add));
+ arrow.lineTo(offset + adjustScrollPoint(QPoint(4, 8), orient, add));
+
+ QColor fillColor;
+ if (option->state & State_Sunken)
+ fillColor = QColor(option->palette.color(QPalette::Button));
+ else
+ fillColor = option->palette.color(QPalette::Background);
+
+ painter->fillRect(rect, fillColor);
+
+ painter->setPen(option->palette.color(QPalette::Base));
+ int adjust = option->state & State_Sunken ? 0 : 1;
+ painter->drawRect(rect.adjusted(adjust, adjust, -1, -1));
+ painter->setPen(option->palette.color(QPalette::Mid));
+ painter->drawRect(rect.adjusted(0, 0, -1, -1));
+
+ painter->setPen(option->palette.color(QPalette::WindowText));
+ painter->setBrush(option->palette.color(QPalette::WindowText));
+ painter->drawPath(arrow);
+
+ painter->restore();
+}
+
+inline QPoint JavaStyle::adjustScrollHandlePoint(Qt::Orientation orig,
+ const QPoint &point) const
+{
+ QPoint retPoint;
+
+ if (orig == Qt::Vertical)
+ retPoint = point;
+ else
+ retPoint = QPoint(point.y(), point.x());
+
+ return retPoint;
+}
+
+void JavaStyle::drawControl(ControlElement control, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+
+ painter->save();
+
+ switch (control) {
+ case CE_ToolBoxTabShape: {
+ const QStyleOptionToolBox *box =
+ qstyleoption_cast<const QStyleOptionToolBox *>(option);
+
+ painter->save();
+
+ if (box->direction == Qt::RightToLeft) {
+ painter->rotate(1);
+ painter->translate(box->rect.width(), -box->rect.height());
+ }
+
+ int textWidth = box->fontMetrics.width(box->text) + 20;
+
+ QPolygon innerLine;
+ innerLine << (box->rect.topLeft() + QPoint(0, 1)) <<
+ (box->rect.topLeft() + QPoint(textWidth, 1)) <<
+ (box->rect.bottomLeft() + QPoint(textWidth + 15, -3)) <<
+ (box->rect.bottomRight() + QPoint(0, -3)) <<
+ box->rect.bottomRight() <<
+ box->rect.bottomLeft() <<
+ box->rect.topLeft();
+
+ painter->setPen(box->palette.color(QPalette::Base));
+ painter->setBrush(QColor(200, 221, 242));
+ painter->drawPolygon(innerLine);
+
+ QPolygon outerLine;
+ outerLine << (box->rect.bottomRight() + QPoint(0, -3)) <<
+ box->rect.bottomRight() <<
+ box->rect.bottomLeft() <<
+ box->rect.topLeft() <<
+ (box->rect.topLeft() + QPoint(textWidth, 0)) <<
+ (box->rect.bottomLeft() + QPoint(textWidth + 15, -4)) <<
+ (box->rect.bottomRight() + QPoint(0, -4));
+
+ painter->setPen(box->palette.color(QPalette::Midlight));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawPolyline(outerLine);
+
+ painter->restore();
+ break;
+ }
+ case CE_DockWidgetTitle: {
+ const QStyleOptionDockWidgetV2 *docker =
+ new QStyleOptionDockWidgetV2(
+ *qstyleoption_cast<const QStyleOptionDockWidget *>(option));
+
+ QRect rect = docker->rect;
+ QRect titleRect = rect;
+ if (docker->verticalTitleBar) {
+ QRect r = rect;
+ QSize s = r.size();
+ s.transpose();
+ r.setSize(s);
+
+ titleRect = QRect(r.left() + rect.bottom()
+ - titleRect.bottom(),
+ r.top() + titleRect.left() - rect.left(),
+ titleRect.height(), titleRect.width());
+
+ painter->translate(r.left(), r.top() + r.width());
+ painter->rotate(-90);
+ painter->translate(-r.left(), -r.top());
+
+ rect = r;
+ }
+
+ QLinearGradient gradient(rect.topLeft(),
+ rect.bottomLeft());
+ gradient.setColorAt(1.0, QColor(191, 212, 231));
+ gradient.setColorAt(0.3, Qt::white);
+ gradient.setColorAt(0.0, QColor(221, 232, 243));
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(gradient);
+ painter->drawRect(rect.adjusted(0, 0, -1, -1));
+
+ if (!docker->title.isEmpty()) {
+ QRect textRect = docker->fontMetrics.boundingRect(docker->title);
+ textRect.moveCenter(rect.center());
+
+ QFont font = painter->font();
+ font.setPointSize(font.pointSize() - 1);
+ painter->setFont(font);
+ painter->setPen(docker->palette.text().color());
+ painter->drawText(textRect, docker->title,
+ QTextOption(Qt::AlignHCenter |
+ Qt::AlignVCenter));
+ }
+ break;
+ }
+ case CE_RubberBand: {
+ painter->setPen(option->palette.color(QPalette::Active,
+ QPalette::WindowText));
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+ break;
+ }
+ case CE_SizeGrip: {
+ break;
+ }
+ case CE_HeaderSection: {
+ const QStyleOptionHeader *header =
+ qstyleoption_cast<const QStyleOptionHeader *>(option);
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(option->palette.color(QPalette::Active,
+ QPalette::Background));
+ painter->drawRect(option->rect);
+
+ painter->setPen(header->palette.color(QPalette::Mid));
+ if (header->orientation == Qt::Horizontal) {
+ if (header->position == QStyleOptionHeader::Beginning ||
+ header->position == QStyleOptionHeader::OnlyOneSection) {
+ painter->drawRect(header->rect.adjusted(0, 0, -1, -1));
+ painter->setPen(header->palette.color(QPalette::Base));
+ painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
+ header->rect.topLeft() + QPoint(1, 1));
+ painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
+ header->rect.topRight() + QPoint(-1, 1));
+ } else {
+ painter->drawLine(header->rect.bottomRight(),
+ header->rect.topRight());
+ painter->drawLine(header->rect.topLeft(),
+ header->rect.topRight());
+ painter->drawLine(header->rect.bottomLeft(),
+ header->rect.bottomRight());
+ painter->setPen(option->palette.color(QPalette::Base));
+ painter->drawLine(header->rect.bottomLeft() + QPoint(0, -1),
+ header->rect.topLeft() + QPoint(0, 1));
+ painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
+ header->rect.topRight() + QPoint(-1, 1));
+ }
+ } else { // Vertical
+ if (header->position == QStyleOptionHeader::Beginning ||
+ header->position == QStyleOptionHeader::OnlyOneSection) {
+ painter->drawRect(header->rect.adjusted(0, 0, -1, -1));
+ painter->setPen(header->palette.color(QPalette::Base));
+ painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
+ header->rect.topLeft() + QPoint(1, 1));
+ painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
+ header->rect.topRight() + QPoint(-1, 1));
+ } else {
+ painter->drawLine(header->rect.bottomLeft(),
+ header->rect.bottomRight());
+ painter->drawLine(header->rect.topLeft(),
+ header->rect.bottomLeft());
+ painter->drawLine(header->rect.topRight(),
+ header->rect.bottomRight());
+ painter->setPen(header->palette.color(QPalette::Base));
+ painter->drawLine(header->rect.topLeft(),
+ header->rect.topRight() + QPoint(-1, 0));
+ painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
+ header->rect.topLeft() + QPoint(1, 0));
+ }
+ }
+ break;
+ }
+ case CE_ToolBar: {
+ QRect rect = option->rect;
+
+ QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
+ gradient.setColorAt(1.0, QColor(221, 221, 221));
+ gradient.setColorAt(0.0, QColor(241, 241, 241));
+
+ if (option->state & State_Horizontal) {
+ painter->setPen(QColor(204, 204, 204));
+ painter->setBrush(gradient);
+ } else {
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(option->palette.color(QPalette::Background));
+ }
+ painter->drawRect(rect.adjusted(0, 0, -1, -1));
+ break;
+ }
+ case CE_ProgressBar: {
+ const QStyleOptionProgressBar *bar1 =
+ qstyleoption_cast<const QStyleOptionProgressBar *>(option);
+
+ QStyleOptionProgressBarV2 *bar = new QStyleOptionProgressBarV2(*bar1);
+
+ QRect rect = bar->rect;
+ if (bar->orientation == Qt::Vertical) {
+ rect = QRect(rect.left(), rect.top(), rect.height(), rect.width());
+ QMatrix m;
+ m.translate(rect.height()-1, 0);
+ m.rotate(90.0);
+ painter->setMatrix(m);
+ }
+
+ painter->setPen(bar->palette.color(QPalette::Mid));
+ painter->drawRect(rect.adjusted(0, 0, -1, -1));
+
+ QRect grooveRect = subElementRect(SE_ProgressBarGroove, bar,
+ widget);
+ if (bar->orientation == Qt::Vertical) {
+ grooveRect = QRect(grooveRect.left(), grooveRect.top(),
+ grooveRect.height(), grooveRect.width());
+ }
+
+ QStyleOptionProgressBar grooveBar = *bar;
+ grooveBar.rect = grooveRect;
+
+ drawControl(CE_ProgressBarGroove, &grooveBar, painter, widget);
+
+ QRect progressRect = subElementRect(SE_ProgressBarContents, bar,
+ widget);
+ if (bar->orientation == Qt::Vertical) {
+ progressRect = QRect(progressRect.left(), progressRect.top(),
+ progressRect.height(), progressRect.width());
+ progressRect.adjust(0, 0, 0, -1);
+ }
+ QStyleOptionProgressBar progressOpt = *bar;
+ progressOpt.rect = progressRect;
+ drawControl(CE_ProgressBarContents, &progressOpt, painter, widget);
+
+ QRect labelRect = subElementRect(SE_ProgressBarLabel, bar, widget);
+ if (bar->orientation == Qt::Vertical) {
+ labelRect = QRect(labelRect.left(), labelRect.top(),
+ labelRect.height(), labelRect.width());
+ }
+ QStyleOptionProgressBar subBar = *bar;
+ subBar.rect = labelRect;
+ if (bar->textVisible)
+ drawControl(CE_ProgressBarLabel, &subBar, painter, widget);
+
+ delete bar;
+ break;
+ }
+ case CE_ProgressBarGroove: {
+ painter->setBrush(option->palette.color(QPalette::Background));
+ painter->setPen(Qt::NoPen);
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+
+ painter->setPen(option->palette.color(QPalette::Button));
+ painter->drawLine(option->rect.topLeft() + QPoint(0, 0),
+ option->rect.topRight() + QPoint(0, 0));
+ break;
+ }
+ case CE_ProgressBarContents: {
+ const QStyleOptionProgressBar *bar =
+ qstyleoption_cast<const QStyleOptionProgressBar *>(option);
+ int progress = int((double(bar->progress) /
+ double(bar->maximum - bar->minimum)) *
+ bar->rect.width());
+
+ painter->setBrush(bar->palette.color(QPalette::Light));
+ painter->setPen(Qt::NoPen);
+ QRect progressRect = QRect(bar->rect.topLeft(), QPoint(progress,
+ bar->rect.bottom()));
+ painter->drawRect(progressRect);
+
+ painter->setPen(bar->palette.color(QPalette::Midlight));
+ painter->setBrush(Qt::NoBrush);
+
+ painter->drawLine(bar->rect.bottomLeft(), bar->rect.topLeft());
+ painter->drawLine(bar->rect.topLeft(), QPoint(progress,
+ bar->rect.top()));
+ break;
+ }
+ case CE_ProgressBarLabel: {
+ painter->save();
+ const QStyleOptionProgressBar *bar =
+ qstyleoption_cast<const QStyleOptionProgressBar *>(option);
+
+ QRect rect = bar->rect;
+ QRect leftRect;
+
+ int progressIndicatorPos = int((double(bar->progress) /
+ double(bar->maximum - bar->minimum)) *
+ bar->rect.width());
+
+ QFont font;
+ font.setBold(true);
+ painter->setFont(font);
+ painter->setPen(bar->palette.color(QPalette::Midlight));
+
+ if (progressIndicatorPos >= 0 &&
+ progressIndicatorPos <= rect.width()) {
+ leftRect = QRect(bar->rect.topLeft(),
+ QPoint(progressIndicatorPos,
+ bar->rect.bottom()));
+ } else if (progressIndicatorPos > rect.width()) {
+ painter->setPen(bar->palette.color(QPalette::Base));
+ } else {
+ painter->setPen(bar->palette.color(QPalette::Midlight));
+ }
+
+ QRect textRect = QFontMetrics(font).boundingRect(bar->text);
+ textRect.moveCenter(option->rect.center());
+ painter->drawText(textRect, bar->text,
+ QTextOption(Qt::AlignCenter));
+ if (!leftRect.isNull()) {
+ painter->setPen(bar->palette.color(QPalette::Base));
+ painter->setClipRect(leftRect, Qt::IntersectClip);
+ painter->drawText(textRect, bar->text,
+ QTextOption(Qt::AlignCenter));
+ }
+
+ painter->restore();
+ break;
+ }
+ case CE_MenuBarEmptyArea: {
+ QRect emptyArea = option->rect.adjusted(0, 0, -1, -1);
+ QLinearGradient gradient(emptyArea.topLeft(), emptyArea.bottomLeft()
+ - QPoint(0, 1));
+ gradient.setColorAt(0.0, option->palette.color(QPalette::Base));
+ gradient.setColorAt(1.0, QColor(223, 223, 223));
+
+ painter->setPen(QColor(238, 238, 238));
+ painter->setBrush(gradient);
+ painter->drawRect(emptyArea.adjusted(0, 0, 0, -1));
+ break;
+ }
+ case CE_MenuBarItem: {
+ if (!(option->state & State_Sunken)) {
+ QLinearGradient gradient(option->rect.topLeft(),
+ option->rect.bottomLeft());
+ gradient.setColorAt(0.0, Qt::white);
+ gradient.setColorAt(1.0, QColor(223, 223, 223));
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(gradient);
+ } else {
+ painter->setBrush(option->palette.color(QPalette::Light));
+ }
+
+ painter->drawRect(option->rect);
+ if (option->state & State_Sunken) {
+ painter->setPen(option->palette.color(QPalette::Mid));
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+ painter->setPen(option->palette.color(QPalette::Base));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawLine(option->rect.bottomRight() + QPoint(0, -1),
+ option->rect.topRight() + QPoint(0, -1));
+ }
+ QCommonStyle::drawControl(control, option, painter, widget);
+ break;
+ }
+ case CE_MenuItem: {
+ const QStyleOptionMenuItem *menuItem =
+ qstyleoption_cast<const QStyleOptionMenuItem *>(option);
+
+ bool selected = menuItem->state & State_Selected;
+ bool checkable = menuItem->checkType !=
+ QStyleOptionMenuItem::NotCheckable;
+ bool checked = menuItem->checked;
+
+ if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
+ QPoint center = menuItem->rect.center();
+
+ painter->setPen(menuItem->palette.color(QPalette::Midlight));
+ painter->drawLine(QPoint(menuItem->rect.left() - 2, center.y()),
+ QPoint(menuItem->rect.right(), center.y()));
+ painter->setPen(menuItem->palette.color(QPalette::Base));
+ painter->drawLine(QPoint(menuItem->rect.left() - 2,
+ center.y() + 1),
+ QPoint(menuItem->rect.right(),
+ center.y() + 1));
+
+ break;
+ }
+
+ if (selected) {
+ painter->setBrush(menuItem->palette.color(QPalette::Light));
+ painter->setPen(Qt::NoPen);
+ painter->drawRect(menuItem->rect);
+ painter->setPen(menuItem->palette.color(QPalette::Midlight));
+ painter->drawLine(menuItem->rect.topLeft(),
+ menuItem->rect.topRight());
+ painter->setPen(menuItem->palette.color(QPalette::Base));
+ painter->drawLine(menuItem->rect.bottomLeft(),
+ menuItem->rect.bottomRight());
+ }
+
+ if (checkable) {
+ QRect checkRect(option->rect.left() + 5,
+ option->rect.center().y() - 5, 10, 10);
+ if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
+ QStyleOptionButton button;
+ button.rect = checkRect;
+ button.state = menuItem->state;
+ if (button.state & State_Sunken)
+ button.state ^= State_Sunken;
+ if (checked)
+ button.state |= State_On;
+ button.palette = menuItem->palette;
+ drawPrimitive(PE_IndicatorRadioButton, &button, painter,
+ widget);
+ } else {
+ QBrush buttonBrush = gradientBrush(option->rect);
+ painter->setBrush(buttonBrush);
+ painter->setPen(option->palette.color(QPalette::Mid));
+
+ painter->drawRect(checkRect);
+
+ if (checked) {
+ QImage image(":/images/checkboxchecked.png");
+ painter->drawImage(QPoint(option->rect.left() + 5,
+ option->rect.center().y() - 8), image);
+ }
+ }
+ }
+
+ bool dis = !(menuItem->state & State_Enabled);
+ bool act = menuItem->state & State_Selected;
+ const QStyleOption *opt = option;
+ const QStyleOptionMenuItem *menuitem = menuItem;
+ int checkcol = qMax(menuitem->maxIconWidth, 20);
+ if (menuItem->icon.isNull())
+ checkcol = 0;
+
+ QPainter *p = painter;
+ QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
+ QRect(menuitem->rect.x(),
+ menuitem->rect.y(),
+ checkcol, menuitem->rect.height()));
+ if (!menuItem->icon.isNull()) {
+ QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
+ if (act && !dis)
+ mode = QIcon::Active;
+ QPixmap pixmap;
+ if (checked)
+ pixmap = menuItem->icon.pixmap(
+ pixelMetric(PM_SmallIconSize), mode, QIcon::On);
+ else
+ pixmap = menuItem->icon.pixmap(
+ pixelMetric(PM_SmallIconSize), mode);
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+
+ int adjustedIcon = checkable ? 15 : 0;
+ QRect pmr(0, 0, pixw, pixh);
+ pmr.moveCenter(vCheckRect.center());
+ painter->setPen(menuItem->palette.text().color());
+ if (checkable && checked)
+ painter->drawPixmap(QPoint(pmr.left() +
+ adjustedIcon, pmr.top() + 1), pixmap);
+ else
+ painter->drawPixmap(pmr.topLeft() +
+ QPoint(adjustedIcon, 0), pixmap);
+ }
+
+ if (selected) {
+ painter->setPen(menuItem->palette.highlightedText().color());
+ } else {
+ painter->setPen(menuItem->palette.text().color());
+ }
+ int x, y, w, h;
+ menuitem->rect.getRect(&x, &y, &w, &h);
+ int tab = menuitem->tabWidth;
+ QColor discol;
+ if (dis) {
+ discol = menuitem->palette.text().color();
+ p->setPen(discol);
+ }
+ int xm = windowsItemFrame + checkcol + windowsItemHMargin;
+ int xpos = menuitem->rect.x() + xm;
+ QRect textRect;
+ if (!menuItem->icon.isNull())
+ textRect.setRect(xpos, y + windowsItemVMargin, w - xm -
+ windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
+ else
+ textRect.setRect(menuItem->rect.left() + 9,
+ y + windowsItemVMargin,
+ w - xm - windowsRightBorder - tab,
+ h - 2 * windowsItemVMargin);
+
+ if (checkable)
+ textRect.adjust(10, 0, 10, 0);
+
+ QRect vTextRect = visualRect(opt->direction, menuitem->rect,
+ textRect);
+ QString s = menuitem->text;
+ if (!s.isEmpty()) {
+ int t = s.indexOf(QLatin1Char('\t'));
+ int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic |
+ Qt::TextDontClip | Qt::TextSingleLine;
+ if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
+ text_flags |= Qt::TextHideMnemonic;
+ text_flags |= Qt::AlignLeft;
+ if (t >= 0) {
+ QRect vShortcutRect = visualRect(opt->direction,
+ menuitem->rect,
+ QRect(textRect.topRight(),
+ QPoint(menuitem->rect.right(), textRect.bottom())));
+ if (dis && !act) {
+ p->setPen(menuitem->palette.light().color());
+ p->drawText(vShortcutRect.adjusted(1, 1, 1, 1),
+ text_flags,
+ s.mid(t + 1));
+ p->setPen(discol);
+ }
+ p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
+ s = s.left(t);
+ }
+ QFont font = menuitem->font;
+ if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
+ font.setBold(true);
+ p->setFont(font);
+ if (dis && !act) {
+ p->setPen(menuitem->palette.light().color());
+ p->drawText(vTextRect.adjusted(1,1,1,1), text_flags,
+ s.left(t));
+ p->setPen(discol);
+ }
+ p->drawText(vTextRect, text_flags, s.left(t));
+ }
+
+ if (menuItem->menuItemType & QStyleOptionMenuItem::SubMenu) {
+ QPoint center = menuItem->rect.center();
+ QPoint drawStart(menuItem->rect.right() - 6, center.y() + 4);
+
+ QPainterPath arrow;
+ arrow.moveTo(drawStart);
+ arrow.lineTo(drawStart + QPoint(0, -8));
+ arrow.lineTo(drawStart + QPoint(4, -5));
+ arrow.lineTo(drawStart + QPoint(4, -4));
+ arrow.lineTo(drawStart + QPoint(0, 0));
+
+ painter->save();
+ painter->setBrush(menuItem->palette.color(QPalette::Text));
+ painter->setPen(Qt::NoPen);
+ painter->drawPath(arrow);
+ painter->restore();
+ }
+
+ break;
+ }
+ case CE_MenuVMargin: {
+ break;
+ }
+ case CE_MenuHMargin: {
+ break;
+ }
+ case CE_Splitter: {
+ drawSplitter(option, painter, option->state & State_Horizontal);
+ break;
+ }
+ case CE_ScrollBarAddPage: {
+ case CE_ScrollBarSubPage:
+ const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ QRect myRect;
+ if (scrollBar->orientation == Qt::Horizontal) {
+ myRect = QRect(option->rect.topLeft(),
+ option->rect.bottomRight()).adjusted(0, 0, 1, -1);
+ } else {
+ myRect = option->rect;
+ }
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(option->palette.color(QPalette::Background));
+ painter->drawRect(myRect);
+
+ painter->setBrush(Qt::NoBrush);
+ painter->setPen(scrollBar->palette.color(QPalette::Mid));
+ painter->drawRect(myRect.adjusted(0, 0, -1, 0));
+ painter->setPen(scrollBar->palette.color(QPalette::Button));
+ painter->drawLine(myRect.bottomLeft() + QPoint(1, 0),
+ myRect.topLeft() + QPoint(1, 1));
+ painter->drawLine(myRect.topLeft() + QPoint(1, 1),
+ myRect.topRight() + QPoint(-1, 1));
+ break;
+ }
+ case CE_ScrollBarSubLine: {
+ const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ int scrollBarExtent = pixelMetric(PM_ScrollBarExtent);
+ QRect scrollBarSubLine = option->rect;
+
+ QRect button1;
+ QRect button2;
+
+ if (scrollBar->orientation == Qt::Horizontal) {
+ button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(),
+ 16, scrollBarExtent);
+ button2.setRect(scrollBarSubLine.right() - 15,
+ scrollBarSubLine.top(), 16, scrollBarExtent);
+ } else {
+ button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(),
+ scrollBarExtent, 16);
+ button2.setRect(scrollBarSubLine.left(),
+ scrollBarSubLine.bottom() - 15, scrollBarExtent, 16);
+ }
+
+ painter->fillRect(button2, Qt::blue);
+
+ drawScrollBarArrow(button1, painter, scrollBar);
+ drawScrollBarArrow(button2, painter, scrollBar);
+ break;
+ }
+ case CE_ScrollBarAddLine: {
+ const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ QRect button(option->rect.left(), option->rect.top(), 16, 16);
+ drawScrollBarArrow(button, painter, scrollBar, true);
+ break;
+ }
+ case CE_ScrollBarSlider: {
+ const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+
+ painter->setPen(scrollBar->palette.color(QPalette::Midlight));
+ painter->drawRect(scrollBar->rect.adjusted(-1, 0, -3, -1));
+
+ QPoint g1, g2;
+ if (scrollBar->orientation == Qt::Horizontal) {
+ g1 = option->rect.topLeft();
+ g2 = option->rect.bottomLeft();
+ } else {
+ g1 = option->rect.topLeft();
+ g2 = option->rect.topRight();
+ }
+
+ if (scrollBar->state & State_Enabled) {
+ QLinearGradient gradient(g1, g2);
+ gradient.setColorAt(1.0, QColor(188, 210, 230));
+ gradient.setColorAt(0.3, Qt::white);
+ gradient.setColorAt(0.0, QColor(223, 233, 243));
+ painter->setBrush(gradient);
+ } else {
+ painter->setPen(scrollBar->palette.buttonText().color());
+ painter->setBrush(scrollBar->palette.button());
+ }
+ painter->drawRect(scrollBar->rect.adjusted(0, 0, -1, -1));
+
+ int sliderLength = option->rect.height();
+ int drawPos = scrollBar->orientation == Qt::Vertical ?
+ (sliderLength / 2) + 1 : 1 - ((option->rect.width() / 2));
+
+ QPoint origin;
+ if (scrollBar->orientation == Qt::Vertical)
+ origin = option->rect.bottomLeft();
+ else
+ origin = option->rect.topLeft();
+
+ painter->setPen(scrollBar->palette.color(QPalette::Base));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(4, -drawPos)),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(13, -drawPos)));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(4, 2 - drawPos)),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(13, 2 - drawPos)));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(4, 4 - drawPos)),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(13, 4 - drawPos)));
+
+ painter->setPen(option->palette.color(QPalette::Midlight));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(3, -(drawPos + 1))),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(12, -(drawPos + 1))));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(3, 1 - drawPos)),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(12, 1 - drawPos)));
+ painter->drawLine(origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(3, 3 - drawPos)),
+ origin + adjustScrollHandlePoint(
+ scrollBar->orientation,
+ QPoint(12, 3 - drawPos)));
+
+ break;
+ }
+ case CE_TabBarTabLabel: {
+ QStyleOptionTab copy =
+ *qstyleoption_cast<const QStyleOptionTab *>(option);
+ if (copy.state & State_HasFocus)
+ copy.state ^= State_HasFocus;
+ painter->setBrush(Qt::NoBrush);
+ QWindowsStyle::drawControl(CE_TabBarTabLabel, &copy, painter,
+ widget);
+ break;
+ }
+ case CE_TabBarTabShape: {
+ const QStyleOptionTab *tab =
+ qstyleoption_cast<const QStyleOptionTab *>(option);
+ QRect myRect = option->rect;
+ QPoint bottomLeft, bottomRight, topLeft, topRight;
+
+ if ((tab->position == QStyleOptionTab::Beginning) ||
+ (tab->position == QStyleOptionTab::OnlyOneTab)) {
+ if (tab->shape == QTabBar::RoundedSouth ||
+ tab->shape == QTabBar::RoundedNorth) {
+ myRect = myRect.adjusted(2, 0, 0, 0);
+ } else {
+ myRect = myRect.adjusted(0, 2, 0, 0);
+ }
+ }
+
+ switch (tab->shape) {
+ case QTabBar::RoundedNorth:
+ topLeft = myRect.topLeft();
+ topRight = myRect.topRight();
+ bottomLeft = myRect.bottomLeft();
+ bottomRight = myRect.bottomRight();
+ break;
+ case QTabBar::RoundedSouth:
+ topLeft = myRect.bottomLeft();
+ topRight = myRect.bottomRight();
+ bottomLeft = myRect.topLeft();
+ bottomRight = myRect.topRight();
+ break;
+ case QTabBar::RoundedWest:
+ topLeft = myRect.topLeft();
+ topRight = myRect.bottomLeft();
+ bottomLeft = myRect.topRight();
+ bottomRight = myRect.bottomRight();
+ break;
+ case QTabBar::RoundedEast:
+ topLeft = myRect.topRight();
+ topRight = myRect.bottomRight();
+ bottomLeft = myRect.topLeft();
+ bottomRight = myRect.bottomLeft();
+ break;
+ default:
+ ;
+ }
+
+ QPainterPath outerPath;
+ outerPath.moveTo(bottomLeft + adjustTabPoint(QPoint(0, -2),
+ tab->shape));
+ outerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(0, -14),
+ tab->shape));
+ outerPath.lineTo(topLeft + adjustTabPoint(QPoint(6 , 0),
+ tab->shape));
+ outerPath.lineTo(topRight + adjustTabPoint(QPoint(0, 0),
+ tab->shape));
+ outerPath.lineTo(bottomRight + adjustTabPoint(QPoint(0, -2),
+ tab->shape));
+
+ if (tab->state & State_Selected ||
+ tab->position == QStyleOptionTab::OnlyOneTab) {
+ QPainterPath innerPath;
+ innerPath.moveTo(topLeft + adjustTabPoint(QPoint(6, 2),
+ tab->shape));
+ innerPath.lineTo(topRight + adjustTabPoint(QPoint(-1, 2),
+ tab->shape));
+ innerPath.lineTo(bottomRight + adjustTabPoint(QPoint(-1 , -2),
+ tab->shape));
+ innerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(2 , -2),
+ tab->shape));
+ innerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(2 , -14),
+ tab->shape));
+ innerPath.lineTo(topLeft + adjustTabPoint(QPoint(6, 2),
+ tab->shape));
+
+ QPainterPath whitePath;
+ whitePath.moveTo(bottomLeft + adjustTabPoint(QPoint(1, -2),
+ tab->shape));
+ whitePath.lineTo(bottomLeft + adjustTabPoint(QPoint(1, -14),
+ tab->shape));
+ whitePath.lineTo(topLeft + adjustTabPoint(QPoint(6, 1),
+ tab->shape));
+ whitePath.lineTo(topRight + adjustTabPoint(QPoint(-1, 1),
+ tab->shape));
+
+ painter->setPen(tab->palette.color(QPalette::Midlight));
+ painter->setBrush(QColor(200, 221, 242));
+ painter->drawPath(outerPath);
+ painter->setPen(QColor(200, 221, 242));
+ painter->drawRect(QRect(bottomLeft + adjustTabPoint(
+ QPoint(2, -3), tab->shape),
+ bottomRight + adjustTabPoint(
+ QPoint(-2, 0), tab->shape)));
+ painter->setPen(tab->palette.color(QPalette::Base));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawPath(whitePath);
+
+ if (option->state & State_HasFocus) {
+ painter->setPen(option->palette.color(QPalette::Mid));
+ painter->drawPath(innerPath);
+ }
+ } else {
+ painter->setPen(tab->palette.color(QPalette::Mid));
+ painter->drawPath(outerPath);
+ }
+ break;
+ }
+ case CE_PushButtonLabel:
+ painter->save();
+
+ if (const QStyleOptionButton *button =
+ qstyleoption_cast<const QStyleOptionButton *>(option)) {
+ QRect ir = button->rect;
+ uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
+ if (!styleHint(SH_UnderlineShortcut, button, widget))
+ tf |= Qt::TextHideMnemonic;
+
+ if (!button->icon.isNull()) {
+ QPoint point;
+
+ QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
+ : QIcon::Disabled;
+ if (mode == QIcon::Normal && button->state & State_HasFocus)
+ mode = QIcon::Active;
+ QIcon::State state = QIcon::Off;
+ if (button->state & State_On)
+ state = QIcon::On;
+
+ QPixmap pixmap = button->icon.pixmap(button->iconSize, mode,
+ state);
+ int w = pixmap.width();
+ int h = pixmap.height();
+
+ if (!button->text.isEmpty())
+ w += button->fontMetrics.width(button->text) + 2;
+
+ point = QPoint(ir.x() + ir.width() / 2 - w / 2,
+ ir.y() + ir.height() / 2 - h / 2);
+
+ if (button->direction == Qt::RightToLeft)
+ point.rx() += pixmap.width();
+
+ painter->drawPixmap(visualPos(button->direction, button->rect,
+ point), pixmap);
+
+ if (button->direction == Qt::RightToLeft)
+ ir.translate(-point.x() - 2, 0);
+ else
+ ir.translate(point.x() + pixmap.width(), 0);
+
+ if (!button->text.isEmpty())
+ tf |= Qt::AlignLeft;
+
+ } else {
+ tf |= Qt::AlignHCenter;
+ }
+
+ if (button->fontMetrics.height() > 14)
+ ir.translate(0, 1);
+
+ drawItemText(painter, ir, tf, button->palette, (button->state &
+ State_Enabled),
+ button->text, QPalette::ButtonText);
+ }
+
+ painter->restore();
+ break;
+
+ default:
+ QWindowsStyle::drawControl(control, option, painter, widget);
+ }
+ painter->restore();
+}
+
+inline QPoint JavaStyle::adjustTabPoint(const QPoint &point,
+ QTabBar::Shape shape) const
+{
+ QPoint rPoint;
+
+ switch (shape) {
+ case QTabBar::RoundedWest:
+ rPoint = QPoint(point.y(), point.x());
+ break;
+ case QTabBar::RoundedSouth:
+ rPoint = QPoint(point.x(), point.y() * -1);
+ break;
+ case QTabBar::RoundedEast:
+ rPoint = QPoint(point.y() * -1, point.x());
+ break;
+ default:
+ rPoint = point;
+ }
+ return rPoint;
+}
+
+QRect JavaStyle::subControlRect(ComplexControl control,
+ const QStyleOptionComplex *option,
+ SubControl subControl,
+ const QWidget *widget) const
+{
+ QRect rect = QWindowsStyle::subControlRect(control, option, subControl,
+ widget);
+
+ switch (control) {
+ case CC_TitleBar: {
+ const QStyleOptionTitleBar *bar =
+ qstyleoption_cast<const QStyleOptionTitleBar *>(option);
+
+ switch (subControl) {
+ case SC_TitleBarMinButton: {
+ rect = QRect(bar->rect.topRight() + QPoint(-68, 2),
+ QSize(15, 15));
+ break;
+ }
+ case SC_TitleBarMaxButton: {
+ rect = QRect(bar->rect.topRight() + QPoint(-43, 3),
+ QSize(15, 15));
+ break;
+ }
+ case SC_TitleBarCloseButton: {
+ rect = QRect(bar->rect.topRight() + QPoint(-18, 3),
+ QSize(15, 15));
+ break;
+ }
+ case SC_TitleBarLabel: {
+ QRect labelRect = bar->fontMetrics.boundingRect(bar->text);
+ rect = labelRect;
+ rect.translate(bar->rect.left() + 30, 0);
+ rect.moveTop(bar->rect.top());
+ rect.adjust(0, 2, 2, 2);
+ break;
+ }
+ case SC_TitleBarSysMenu: {
+ rect = QRect(bar->rect.topLeft() + QPoint(6, 3),
+ QSize(16, 16));
+ break;
+ }
+ default:
+ ;
+ }
+ break;
+ }
+ case CC_GroupBox: {
+ const QStyleOptionGroupBox *box =
+ qstyleoption_cast<const QStyleOptionGroupBox *>(option);
+ bool hasCheckbox = box->subControls & SC_GroupBoxCheckBox;
+ int checkAdjust = 13;
+
+ QRect textRect = box->fontMetrics.boundingRect(box->text);
+
+ switch (subControl) {
+ case SC_GroupBoxFrame: {
+ rect = box->rect;
+ break;
+ }
+ case SC_GroupBoxCheckBox: {
+ if (hasCheckbox) {
+ rect = QRect(box->rect.topLeft() + QPoint(7, 4 +
+ (textRect.height() / 2 - checkAdjust / 2)),
+ QSize(checkAdjust, checkAdjust));
+ }
+ else {
+ rect = QRect();
+ }
+ break;
+ }
+ case SC_GroupBoxLabel: {
+ rect = QRect(box->rect.topLeft() + QPoint(7 + (hasCheckbox ?
+ checkAdjust + 2 : 0), 4), textRect.size());
+ break;
+ }
+ case SC_GroupBoxContents: {
+ rect = box->rect.adjusted(10, 10 + textRect.height(), -10,
+ -10);
+ break;
+ }
+ default:
+ ;
+ }
+ break;
+ }
+ case CC_SpinBox: {
+ const QStyleOptionSpinBox *spinBox =
+ qstyleoption_cast<const QStyleOptionSpinBox *>(option);
+ int spinnerWidth = 16;
+ QRect myRect = spinBox->rect;
+ QPoint center = myRect.center();
+ int frameWidth = pixelMetric(PM_SpinBoxFrameWidth, spinBox, widget);
+
+ switch (subControl) {
+ case SC_SpinBoxUp: {
+ rect = QRect(myRect.topRight() + QPoint(-16, 0),
+ QSize(16, center.y() - myRect.topRight().y()));
+ break;
+ }
+ case SC_SpinBoxDown: {
+ rect = QRect(QPoint(myRect.bottomRight().x() - 16,
+ center.y() + 1),
+ QSize(16, myRect.bottomRight().y() -
+ center.y() - 1));
+ break;
+ }
+ case SC_SpinBoxFrame: {
+ rect = QRect(myRect.topLeft(), myRect.bottomRight() +
+ QPoint(-16, 0));
+ break;
+ }
+ case SC_SpinBoxEditField: {
+ rect = QRect(myRect.topLeft() + QPoint(2, 2),
+ myRect.bottomRight() + QPoint(-15 - frameWidth, -2));
+ break;
+ }
+ default:
+ ;
+ }
+ break;
+ }
+ case CC_ToolButton: {
+ const QStyleOptionToolButton *button =
+ qstyleoption_cast<const QStyleOptionToolButton *>(option);
+
+ switch (subControl) {
+ case SC_ToolButton: {
+ rect = option->rect.adjusted(1, 1, -1, -1);
+ break;
+ }
+ case SC_ToolButtonMenu: {
+ rect = QRect(option->rect.bottomRight() +
+ QPoint(-11, -11), QSize(10, 10));
+ break;
+ }
+ }
+ break;
+ }
+ case CC_ComboBox: {
+ const QStyleOptionComboBox *combo =
+ qstyleoption_cast<const QStyleOptionComboBox *>(option);
+
+ bool reverse = combo->direction == Qt::RightToLeft;
+
+ switch (subControl) {
+ case SC_ComboBoxFrame:
+ rect = combo->rect;
+ break;
+ case SC_ComboBoxArrow:
+ if (reverse) {
+ rect = QRect(combo->rect.topLeft(),
+ combo->rect.bottomLeft() + QPoint(17, 0));
+ } else {
+ rect = QRect(combo->rect.topRight() + QPoint(-17, 0),
+ combo->rect.bottomRight());
+ }
+ break;
+ case SC_ComboBoxEditField:
+ if (reverse) {
+ rect = QRect(combo->rect.topLeft() + QPoint(19, 2),
+ combo->rect.bottomRight() + QPoint(-2, 2));
+ } else {
+ rect = QRect(combo->rect.topLeft() + QPoint(2, 2),
+ combo->rect.bottomRight() + QPoint(-19, -2));
+ }
+ break;
+ case SC_ComboBoxListBoxPopup:
+ rect = combo->rect;
+ break;
+ }
+ break;
+ }
+ case CC_ScrollBar: {
+ const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ int scrollBarExtent = pixelMetric(PM_ScrollBarExtent, scrollBar,
+ widget);
+ int sliderMaxLength = ((scrollBar->orientation == Qt::Horizontal) ?
+ scrollBar->rect.width() :
+ scrollBar->rect.height()) - (16 * 3);
+ int sliderMinLength = pixelMetric(PM_ScrollBarSliderMin, scrollBar,
+ widget);
+ int sliderLength;
+
+ if (scrollBar->maximum != scrollBar->minimum) {
+ uint valueRange = scrollBar->maximum - scrollBar->minimum;
+ sliderLength = (scrollBar->pageStep * sliderMaxLength) /
+ (valueRange + scrollBar->pageStep);
+
+ if (sliderLength < sliderMinLength || valueRange > INT_MAX / 2)
+ sliderLength = sliderMinLength;
+ if (sliderLength > sliderMaxLength)
+ sliderLength = sliderMaxLength;
+ } else {
+ sliderLength = sliderMaxLength;
+ }
+ int sliderStart = 16 + sliderPositionFromValue(scrollBar->minimum,
+ scrollBar->maximum,
+ scrollBar->sliderPosition,
+ sliderMaxLength - sliderLength,
+ scrollBar->upsideDown);
+ QRect scrollBarRect = scrollBar->rect;
+
+ switch (subControl) {
+ case SC_ScrollBarSubLine:
+ if (scrollBar->orientation == Qt::Horizontal) {
+ rect.setRect(scrollBarRect.left(), scrollBarRect.top(),
+ scrollBarRect.width() - 16, scrollBarExtent);
+ } else {
+ rect.setRect(scrollBarRect.left(), scrollBarRect.top(),
+ scrollBarExtent, scrollBarRect.height() - 16);
+ }
+ break;
+ case SC_ScrollBarAddLine:
+ if (scrollBar->orientation == Qt::Horizontal) {
+ rect.setRect(scrollBarRect.right() - 15,
+ scrollBarRect.top(), 16, scrollBarExtent);
+ } else {
+ rect.setRect(scrollBarRect.left(), scrollBarRect.bottom()
+ - 15, scrollBarExtent, 16);
+ }
+ break;
+ case SC_ScrollBarSubPage:
+ if (scrollBar->orientation == Qt::Horizontal) {
+ rect.setRect(scrollBarRect.left() + 16, scrollBarRect.top(),
+ sliderStart - (scrollBarRect.left() + 16),
+ scrollBarExtent);
+ } else {
+ rect.setRect(scrollBarRect.left(), scrollBarRect.top() + 16,
+ scrollBarExtent,
+ sliderStart - (scrollBarRect.left() + 16));
+ }
+ break;
+ case SC_ScrollBarAddPage:
+ if (scrollBar->orientation == Qt::Horizontal)
+ rect.setRect(sliderStart + sliderLength, 0,
+ sliderMaxLength - sliderStart -
+ sliderLength + 16, scrollBarExtent);
+ else
+ rect.setRect(0, sliderStart + sliderLength,
+ scrollBarExtent, sliderMaxLength -
+ sliderStart - sliderLength + 16);
+ break;
+ case SC_ScrollBarGroove:
+ if (scrollBar->orientation == Qt::Horizontal) {
+ rect = scrollBarRect.adjusted(16, 0, -32, 0);
+ } else {
+ rect = scrollBarRect.adjusted(0, 16, 0, -32);
+ }
+ break;
+ case SC_ScrollBarSlider:
+ if (scrollBar->orientation == Qt::Horizontal) {
+ rect.setRect(sliderStart, 0, sliderLength,
+ scrollBarExtent);
+ } else {
+ rect.setRect(0, sliderStart, scrollBarExtent,
+ sliderLength);
+ }
+ break;
+ default:
+ return QWindowsStyle::subControlRect(control, option,
+ subControl, widget);
+ }
+ break;
+ }
+ case CC_Slider: {
+ const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ rect = slider->rect;
+ int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget);
+ int handleSize = pixelMetric(PM_SliderControlThickness, option,
+ widget);
+
+ int dist = slider->orientation == Qt::Vertical ? slider->rect.height() :
+ slider->rect.width();
+ int pos = QStyle::sliderPositionFromValue(slider->minimum,
+ slider->maximum, slider->sliderValue, dist - handleSize);
+
+ switch (subControl) {
+ case SC_SliderGroove: {
+ QPoint center = rect.center();
+
+ if (slider->orientation == Qt::Horizontal) {
+ rect.setHeight(handleSize);
+ if (slider->tickPosition == QSlider::TicksBelow) {
+ center.ry() -= tickSize;
+ }
+ } else {
+ rect.adjust(0, 0, 0, 0);
+ rect.setWidth(handleSize);
+ if (slider->tickPosition == QSlider::TicksBelow) {
+ center.rx() -= tickSize;
+ }
+ }
+ rect.moveCenter(center);
+ break;
+ }
+ case SC_SliderHandle: {
+ QPoint center = rect.center();
+
+ if (slider->orientation == Qt::Horizontal) {
+ rect.setHeight(handleSize);
+ if (slider->tickPosition == QSlider::TicksBelow) {
+ center.ry() -= tickSize;
+ }
+
+ rect.moveCenter(center);
+
+ if (slider->upsideDown)
+ rect.setLeft(slider->rect.right() -
+ pos - (handleSize - 1));
+ else
+ rect.setLeft(pos);
+
+ rect.setWidth(handleSize - 1);
+ } else {
+ rect.setWidth(handleSize);
+ if (slider->tickPosition == QSlider::TicksBelow) {
+ center.rx() -= tickSize;
+ }
+
+ rect.moveCenter(center);
+
+ if (slider->upsideDown)
+ rect.setTop(slider->rect.bottom() -
+ ((pos + handleSize) - 2));
+ else
+ rect.setTop(slider->rect.top() + pos);
+
+ rect.setHeight(handleSize);
+ }
+ break;
+ }
+ case SC_SliderTickmarks: {
+ QPoint center = slider->rect.center();
+
+ if (slider->tickPosition & QSlider::TicksBelow) {
+ if (slider->orientation == Qt::Horizontal) {
+ rect.setHeight(tickSize);
+ center.ry() += tickSize / 2;
+ rect.adjust(6, 0, -10, 0);
+ } else {
+ rect.setWidth(tickSize);
+ center.rx() += tickSize / 2;
+ rect.adjust(0, 6, 0, -10);
+ }
+ } else {
+ rect = QRect();
+ }
+ rect.moveCenter(center);
+ break;
+ }
+ default:
+ ;
+ }
+ break;
+ }
+ default:
+ return QWindowsStyle::subControlRect(control, option, subControl,
+ widget);
+ }
+ return rect;
+}
+
+static const char * const sliderHandleImage[] = {
+ "15 16 7 1",
+ " c None",
+ "+ c #FFFFFF",
+ "@ c #FFFFFF",
+ "$ c #FFFFFF",
+ "( c #E5EDF5",
+ ") c #F2F6FA",
+ "[ c #FFFFFF",
+ " +++++++++++++ ",
+ "+@@@@@@@@@@@@@+",
+ "+@(((((((((((@+",
+ "+@(((((((((((@+",
+ "+@)))))))))))@+",
+ "+@[[[[[[[[[[[@+",
+ "+@[[[[[[[[[[[@+",
+ "+@)))))))))))@+",
+ "+@)))))))))))@+",
+ " +@)))))))))@+ ",
+ " +@(((((((@+ ",
+ " +@(((((@+ ",
+ " +@(((@+ ",
+ " +@(@+ ",
+ " +@+ ",
+ " + "};
+
+
+void JavaStyle::drawComplexControl(ComplexControl control,
+ const QStyleOptionComplex *option,
+ QPainter *painter,
+ const QWidget *widget) const
+{
+ painter->save();
+
+ switch (control) {
+ case CC_TitleBar: {
+ const QStyleOptionTitleBar *bar =
+ qstyleoption_cast<const QStyleOptionTitleBar *>(option);
+
+ bool sunken = bar->state & State_Sunken;
+
+ QLinearGradient gradient(bar->rect.bottomLeft(),
+ bar->rect.topLeft());
+ gradient.setColorAt(0.0, QColor(191, 212, 231));
+ gradient.setColorAt(0.7, Qt::white);
+ gradient.setColorAt(1.0, QColor(221, 232, 243));
+
+ painter->setPen(Qt::NoPen);
+ if (bar->titleBarState & State_Active) {
+ painter->setBrush(gradient);
+ }
+ else
+ painter->setBrush(bar->palette.color(QPalette::Active,
+ QPalette::Background));
+
+ painter->drawRect(bar->rect.adjusted(0, 0, -1, -1));
+
+ painter->setBrush(QColor(233, 233, 233));
+ painter->drawRect(QRect(bar->rect.bottomLeft() + QPoint(0, 1),
+ bar->rect.bottomRight() + QPoint(0, 2)));
+
+ QRect minButtonRect = subControlRect(control, bar,
+ SC_TitleBarMinButton);
+ QRect maxButtonRect = subControlRect(control, bar,
+ SC_TitleBarMaxButton);
+ QRect closeButtonRect = subControlRect(control, bar,
+ SC_TitleBarCloseButton);
+ QRect systemButtonRect = subControlRect(control, bar,
+ SC_TitleBarSysMenu);
+ QRect labelRect = subControlRect(control, bar, SC_TitleBarLabel);
+ QRect gripRect = QRect(QPoint(labelRect.right() + 5, bar->rect.top() + 5),
+ QPoint(minButtonRect.left() - 5,
+ bar->rect.bottom() - 4));
+
+ QColor textColor = option->palette.color(QPalette::Text);
+ painter->setPen(textColor);
+ painter->setBrush(Qt::NoBrush);
+
+ drawItemText(painter, labelRect, Qt::TextShowMnemonic |
+ Qt::AlignHCenter | Qt::AlignCenter,
+ bar->palette, bar->state & State_Enabled, bar->text,
+ textColor.isValid() ? QPalette::NoRole :
+ QPalette::WindowText);
+
+ for (int i = 0; i < gripRect.width(); ++i) {
+ painter->setPen(i % 2 ? bar->palette.color(QPalette::Midlight)
+ : Qt::white);
+
+ for (int j = 0; j < 4; ++j) {
+ painter->drawPoint(i + gripRect.left(),
+ gripRect.top() - 2 + i % 4 + 4 * j);
+ }
+ }
+
+ QPixmap maximizePixmap(":/images/internalmaximize.png");
+ QPixmap minimizePixmap(":/images/internalminimize.png");
+ QPixmap closePixmap(":/images/internalclose.png");
+ QPixmap internalPixmap(":/images/internalsystem.png");
+ QPixmap internalCloseDownPixmap(":/images/internalclosedown.png");
+ QPixmap minimizeDownPixmap(":/images/internalminimizedown.png");
+ QPixmap maximizeDownPixmap(":/images/internalmaximizedown.png");
+
+ if (bar->activeSubControls & SC_TitleBarCloseButton &&
+ bar->state & State_Sunken)
+ painter->drawPixmap(closeButtonRect.topLeft(),
+ internalCloseDownPixmap);
+ else
+ painter->drawPixmap(closeButtonRect.topLeft(), closePixmap);
+
+ if (bar->activeSubControls & SC_TitleBarMinButton &&
+ bar->state & State_Sunken)
+ painter->drawPixmap(minButtonRect.topLeft(),
+ minimizeDownPixmap);
+ else
+ painter->drawPixmap(minButtonRect.topLeft(), minimizePixmap);
+
+ if (bar->activeSubControls & SC_TitleBarMaxButton &&
+ bar->state & State_Sunken)
+ painter->drawPixmap(maxButtonRect.topLeft(),
+ maximizeDownPixmap);
+ else
+ painter->drawPixmap(maxButtonRect.topLeft(), maximizePixmap);
+
+ painter->drawPixmap(systemButtonRect.topLeft(), internalPixmap);
+
+ break;
+ }
+ case CC_GroupBox: {
+ const QStyleOptionGroupBox *box =
+ qstyleoption_cast<const QStyleOptionGroupBox *>(option);
+
+ QRect frameRect = subControlRect(control, box, SC_GroupBoxFrame);
+ QRect labelRect = subControlRect(control, box, SC_GroupBoxLabel);
+ QRect contentsRect = subControlRect(control, box,
+ SC_GroupBoxContents);
+ QRect checkerRect = subControlRect(control, box,
+ SC_GroupBoxCheckBox);
+
+ int y = labelRect.center().y();
+
+ painter->setPen(box->palette.color(QPalette::Button));
+ painter->drawRect(frameRect.adjusted(2, y - frameRect.top(), -2,
+ -2));
+
+ painter->setPen(box->palette.color(QPalette::Background));
+
+ if (box->subControls & SC_GroupBoxCheckBox) {
+ painter->drawLine(checkerRect.left() - 1, y,
+ checkerRect.right() + 2, y);
+ QStyleOptionButton checker;
+ checker.QStyleOption::operator=(*box);
+ checker.rect = checkerRect;
+ drawPrimitive(PE_IndicatorCheckBox, &checker, painter, widget);
+ }
+
+ if (box->subControls & SC_GroupBoxLabel && !box->text.isEmpty()) {
+ painter->drawLine(labelRect.left() - 1, y,
+ labelRect.right() +1, y);
+
+ QColor textColor = box->textColor;
+ if (textColor.isValid())
+ painter->setPen(textColor);
+
+ drawItemText(painter, labelRect, Qt::TextShowMnemonic |
+ Qt::AlignHCenter | int(box->textAlignment),
+ box->palette, box->state & State_Enabled,
+ box->text, textColor.isValid() ? QPalette::NoRole :
+ QPalette::WindowText);
+ }
+ break;
+ }
+ case CC_SpinBox: {
+ const QStyleOptionSpinBox *spinner =
+ qstyleoption_cast<const QStyleOptionSpinBox *>(option);
+
+ QRect frameRect = subControlRect(control, spinner, SC_SpinBoxFrame);
+ QRect upRect = subControlRect(control, spinner, SC_SpinBoxUp);
+ QRect downRect = subControlRect(control, spinner, SC_SpinBoxDown);
+
+ painter->setPen(Qt::white);
+ painter->drawRect(frameRect.adjusted(1, 1, -1, -1));
+ painter->drawPoint(frameRect.bottomLeft());
+
+ painter->setPen(spinner->palette.color(QPalette::Mid));
+ painter->drawRect(frameRect.adjusted(0, 0, -1, -2));
+
+ bool isEnabled = (spinner->state & State_Enabled);
+ bool hover = isEnabled && (spinner->state & State_MouseOver);
+ bool sunken = (spinner->state & State_Sunken);
+ bool upIsActive = (spinner->activeSubControls == SC_SpinBoxUp);
+ bool downIsActive = (spinner->activeSubControls == SC_SpinBoxDown);
+ bool stepUpEnabled = spinner->stepEnabled &
+ QAbstractSpinBox::StepUpEnabled;
+ bool stepDownEnabled = spinner->stepEnabled &
+ QAbstractSpinBox::StepDownEnabled;
+
+ painter->setBrush(spinner->palette.color(QPalette::Background));
+
+ painter->drawRect(upRect);
+ if (upIsActive && stepUpEnabled) {
+ if (sunken) {
+ drawSunkenButtonShadow(painter, upRect,
+ spinner->palette.color(QPalette::Mid));
+ } else if (hover) {
+ drawButtonHoverFrame(painter, upRect,
+ spinner->palette.color(QPalette::Mid),
+ spinner->palette.color(QPalette::Button));
+ }
+ }
+
+ QStyleOptionSpinBox upSpin = *spinner;
+ upSpin.rect = upRect;
+ drawPrimitive(PE_IndicatorSpinUp, &upSpin, painter, widget);
+
+ painter->drawRect(downRect);
+ if (downIsActive && stepDownEnabled) {
+ if (sunken) {
+ drawSunkenButtonShadow(painter, downRect,
+ spinner->palette.color(QPalette::Mid));
+ } else if (hover) {
+ drawButtonHoverFrame(painter, downRect,
+ spinner->palette.color(QPalette::Mid),
+ spinner->palette.color(QPalette::Button));
+ }
+ }
+
+ QStyleOptionSpinBox downSpin = *spinner;
+ downSpin.rect = downRect;
+ drawPrimitive(PE_IndicatorSpinDown, &downSpin, painter, widget);
+
+ break;
+ }
+ case CC_ToolButton: {
+ const QStyleOptionToolButton *button =
+ qstyleoption_cast<const QStyleOptionToolButton *>(option);
+
+ painter->setPen(Qt::white);
+ painter->drawRect(button->rect.adjusted(1, 1, -1, -1));
+
+ QStyleOptionToolButton panelOption = *button;
+ QRect panelRect;
+ if (!(button->state & State_MouseOver) &&
+ !(button->state & State_On)) {
+ painter->setPen(QColor(153, 153, 153));
+ painter->drawRect(button->rect.adjusted(0, 0, -2, -2));
+
+ panelRect = subControlRect(control, option, SC_ToolButton);
+ panelOption.rect = panelRect;
+ } else {
+ panelOption.rect.adjust(0, 0, -1, -1);
+ }
+
+ QRect menuRect = subControlRect(control, option, SC_ToolButtonMenu);
+
+ drawPrimitive(PE_PanelButtonTool, &panelOption, painter, widget);
+
+ QStyleOptionToolButton menuOption = *button;
+ menuOption.rect = menuRect;
+
+ QStyleOptionToolButton label = *button;
+ int fw = 5;
+
+ drawControl(CE_ToolButtonLabel, &label, painter, widget);
+ if (button->subControls & SC_ToolButtonMenu) {
+ painter->setPen(button->palette.color(QPalette::WindowText));
+ drawPrimitive(PE_IndicatorArrowDown, &menuOption, painter, widget);
+ }
+
+ if (button->state & State_HasFocus) {
+ QStyleOptionToolButton focusOption = *button;
+ focusOption.rect = label.rect.adjusted(-1, -1, 1, 1);
+
+ drawPrimitive(PE_FrameFocusRect, &focusOption, painter, widget);
+ }
+
+ break;
+ }
+ case CC_ComboBox: {
+ const QStyleOptionComboBox *combo =
+ qstyleoption_cast<const QStyleOptionComboBox *>(option);
+
+ QRect frameRect = subControlRect(control, option, SC_ComboBoxFrame,
+ widget);
+ painter->setPen(combo->palette.color(QPalette::Mid));
+
+ if (option->state & State_HasFocus)
+ painter->setBrush(option->palette.color(QPalette::Light));
+ else
+ painter->setBrush(combo->palette.color(QPalette::Background));
+
+ painter->drawRect(frameRect.adjusted(0, 0, -1, -1));
+
+ QRect arrowRect = subControlRect(control, option, SC_ComboBoxArrow,
+ widget);
+ painter->setPen(combo->palette.color(QPalette::Button));
+ painter->setBrush(Qt::NoBrush);
+
+ if (combo->direction == Qt::LeftToRight) {
+ painter->drawRect(QRect(frameRect.topLeft() + QPoint(1, 1),
+ arrowRect.bottomLeft() + QPoint(-2, -2)));
+ } else {
+ painter->drawRect(QRect(arrowRect.topLeft() + QPoint(1, 1),
+ frameRect.bottomRight() + QPoint(-2, -2)));
+ }
+
+ QStyleOptionButton button;
+ button.rect = arrowRect;
+ button.state = combo->state;
+ button.palette = combo->palette;
+
+ if (button.state & State_On)
+ button.state ^= State_On;
+
+ painter->save();
+ drawButtonBackground(&button, painter, false);
+ painter->restore();
+
+ QPoint center = arrowRect.center();
+ QPoint offset = QPoint(arrowRect.bottomLeft().x() + 1,
+ center.y() + 7);
+ QPainterPath arrow;
+ arrow.moveTo(offset + QPoint(4, -8));
+ arrow.lineTo(offset + QPoint(7, -5));
+ arrow.lineTo(offset + QPoint(8, -5));
+ arrow.lineTo(offset + QPoint(11, -8));
+ arrow.lineTo(offset + QPoint(4, -8));
+
+ painter->setBrush(combo->palette.color(QPalette::WindowText));
+ painter->setPen(combo->palette.color(QPalette::WindowText));
+
+ painter->drawPath(arrow);
+
+ QRect fieldRect = subControlRect(control, option,
+ SC_ComboBoxEditField, widget);
+
+ break;
+ }
+ case CC_Slider: {
+ const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+
+ bool horizontal = slider->orientation == Qt::Horizontal;
+
+ QRect groove = subControlRect(control, option, SC_SliderGroove,
+ widget);
+ QRect ticks = subControlRect(control, option, SC_SliderTickmarks,
+ widget);
+ QRect handle = subControlRect(control, option, SC_SliderHandle,
+ widget);
+
+ QRect afterHandle = QRect(handle.topLeft() + xySwitch(QPoint(4, 6), horizontal),
+ groove.bottomRight() + xySwitch(QPoint(-4, -6), horizontal));
+ QRect beforeHandle = QRect(groove.topLeft() + xySwitch(QPoint(4, 6), horizontal),
+ handle.bottomRight() + xySwitch(QPoint(-4, -6), horizontal));
+
+ if (slider->upsideDown || !horizontal) {
+ QRect remember;
+ remember = afterHandle;
+ afterHandle = beforeHandle;
+ beforeHandle = remember;
+ }
+
+ painter->setPen(slider->palette.color(QPalette::Mid));
+ painter->setBrush(option->palette.color(QPalette::Background));
+ painter->drawRect(afterHandle);
+ painter->setPen(slider->palette.color(QPalette::Light));
+ painter->drawLine(afterHandle.topLeft() + xySwitch(QPoint(0, 1), horizontal),
+ afterHandle.topRight() + xySwitch(QPoint(0, 1), horizontal));
+ painter->setPen(option->palette.color(QPalette::Midlight));
+
+ if (horizontal) {
+ painter->setBrush(gradientBrush(QRect(QPoint(groove.x(),
+ handle.y() + 1),
+ QSize(groove.width(),
+ handle.height() + 1))));
+ } else {
+ QRect rect = QRect(QPoint(groove.x(),
+ handle.x() - 1),
+ QSize(groove.height(),
+ handle.width() + 1));
+ QLinearGradient gradient(groove.bottomLeft(),
+ groove.bottomRight());
+ gradient.setColorAt(1.0, QColor(188, 210, 230));
+ gradient.setColorAt(0.3, Qt::white);
+ gradient.setColorAt(0.0, QColor(223, 233, 243));
+
+ painter->setBrush(gradient);
+ }
+
+ painter->drawRect(beforeHandle);
+
+ QPainterPath handlePath;
+ QPainterPath innerPath;
+ QPoint topLeft, topRight, bottomLeft;
+ if (horizontal) {
+ topLeft = handle.topLeft();
+ topRight = handle.topRight();
+ bottomLeft = handle.bottomLeft();
+ } else {
+ topLeft = handle.bottomLeft();
+ topRight = handle.topLeft();
+ bottomLeft = handle.topRight();
+ }
+
+ if (horizontal) {
+ QImage image(sliderHandleImage);
+
+ image.setColor(1,
+ option->palette.color(QPalette::Midlight).rgb());
+ image.setColor(2,
+ option->palette.color(QPalette::Button).rgb());
+
+ if (!(slider->state & State_Enabled)) {
+ image.setColor(4, slider->palette.color(QPalette::Background).rgb());
+ image.setColor(5, slider->palette.color(QPalette::Background).rgb());
+ image.setColor(6, slider->palette.color(QPalette::Background).rgb());
+ }
+
+ painter->drawImage(handle.topLeft(), image);
+ } else {
+ QImage image(":/images/verticalsliderhandle.png");
+ painter->drawImage(handle.topLeft(), image);
+ }
+
+ if (slider->tickPosition & QSlider::TicksBelow) {
+ painter->setPen(slider->palette.color(QPalette::Light));
+ int tickInterval = slider->tickInterval ? slider->tickInterval :
+ slider->pageStep;
+
+ for (int i = 0; i <= slider->maximum; i += tickInterval) {
+ if (horizontal) {
+ int pos = int(((i / double(slider->maximum)) *
+ ticks.width()) - 1);
+ painter->drawLine(QPoint(ticks.left() + pos,
+ ticks.top() + 2), QPoint(ticks.left() + pos, ticks.top() + 8));
+ } else {
+ int pos = int(((i / double(slider->maximum)) *
+ ticks.height()) - 1);
+ painter->drawLine(QPoint(ticks.left() + 2, ticks.bottom() - pos),
+ QPoint(ticks.right() - 2, ticks.bottom() - pos));
+ }
+ }
+ if (horizontal) {
+ painter->drawLine(QPoint(ticks.right(), ticks.top() + 2),
+ QPoint(ticks.right(), ticks.top() + 8));
+ } else {
+ painter->drawLine(QPoint(ticks.left() + 2, ticks.top()),
+ QPoint(ticks.right() - 2, ticks.top()));
+ }
+ }
+ break;
+ }
+ default:
+ QWindowsStyle::drawComplexControl(control, option, painter, widget);
+ }
+ painter->restore();
+}
+
+inline void JavaStyle::drawSunkenButtonShadow(QPainter *painter,
+ QRect rect,
+ const QColor &frameColor,
+ bool reverse) const
+{
+ painter->save();
+
+ painter->setPen(frameColor);
+
+ if (!reverse) {
+ painter->drawLine(QLine(QPoint(rect.x() + 1, rect.y() + 1),
+ QPoint(rect.x() + rect.width() - 1, rect.y() + 1)));
+ painter->drawLine(QLine(QPoint(rect.x() + 1, rect.y()),
+ QPoint(rect.x() + 1, rect.y() + rect.height())));
+ } else {
+ painter->drawLine(QLine(QPoint(rect.right(), rect.bottom()),
+ QPoint(rect.right(), rect.top())));
+ painter->drawLine(QLine(QPoint(rect.left(), rect.top() + 1),
+ QPoint(rect.right(), rect.top() + 1)));
+ }
+ painter->restore();
+}
+
+inline void JavaStyle::drawButtonHoverFrame(QPainter *painter, QRect rect,
+ const QColor &frameColor,
+ const QColor &activeFrame) const
+{
+ painter->save();
+
+ painter->setPen(activeFrame);
+ painter->drawRect(rect);
+ rect.adjust(1, 1, -1, -1);
+ painter->setPen(frameColor);
+ painter->drawRect(rect);
+ rect.adjust(1, 1, -1, -1);
+ painter->setPen(activeFrame);
+ painter->drawRect(rect);
+
+ painter->restore();
+}
+
+QStyle::SubControl JavaStyle::hitTestComplexControl(ComplexControl control,
+ const QStyleOptionComplex *option,
+ const QPoint &pos,
+ const QWidget *widget) const
+{
+ SubControl ret = SC_None;
+
+ switch (control) {
+ case CC_TitleBar: {
+ const QStyleOptionTitleBar *bar =
+ qstyleoption_cast<const QStyleOptionTitleBar *>(option);
+
+ QRect maximize = subControlRect(control, bar, SC_TitleBarMaxButton);
+ if (maximize.contains(pos)) {
+ ret = SC_TitleBarMaxButton;
+ break;
+ }
+ QRect minimize = subControlRect(control, bar, SC_TitleBarMinButton);
+ if (minimize.contains(pos)) {
+ ret = SC_TitleBarMinButton;
+ break;
+ }
+ QRect close = subControlRect(control, bar, SC_TitleBarCloseButton);
+ if (close.contains(pos)) {
+ ret = SC_TitleBarCloseButton;
+ break;
+ }
+ QRect system = subControlRect(control, bar, SC_TitleBarSysMenu);
+ if (system.contains(pos)) {
+ ret = SC_TitleBarSysMenu;
+ break;
+ }
+ ret = SC_TitleBarLabel;
+ break;
+ }
+ case CC_ScrollBar:
+ if (const QStyleOptionSlider *scrollBar =
+ qstyleoption_cast<const QStyleOptionSlider *>(option)) {
+ QRect slider = subControlRect(control, scrollBar,
+ SC_ScrollBarSlider, widget);
+ if (slider.contains(pos)) {
+ ret = SC_ScrollBarSlider;
+ break;
+ }
+
+ QRect scrollBarAddLine = subControlRect(control, scrollBar,
+ SC_ScrollBarAddLine, widget);
+ if (scrollBarAddLine.contains(pos)) {
+ ret = SC_ScrollBarAddLine;
+ break;
+ }
+
+ QRect scrollBarSubPage = subControlRect(control, scrollBar,
+ SC_ScrollBarSubPage, widget);
+ if (scrollBarSubPage.contains(pos)) {
+ ret = SC_ScrollBarSubPage;
+ break;
+ }
+
+ QRect scrollBarAddPage = subControlRect(control, scrollBar,
+ SC_ScrollBarAddPage, widget);
+ if (scrollBarAddPage.contains(pos)) {
+ ret = SC_ScrollBarAddPage;
+ break;
+ }
+
+ QRect scrollBarSubLine = subControlRect(control, scrollBar,
+ SC_ScrollBarSubLine, widget);
+ if (scrollBarSubLine.contains(pos)) {
+ ret = SC_ScrollBarSubLine;
+ break;
+ }
+ }
+ break;
+
+ default:
+ ret = QWindowsStyle::hitTestComplexControl(control, option, pos,
+ widget);
+ }
+ return ret;
+}
+
+void JavaStyle::polish(QWidget *widget)
+{
+ if (qobject_cast<QCheckBox *>(widget) ||
+ qobject_cast<QRadioButton *>(widget) ||
+ qobject_cast<QPushButton *>(widget) ||
+ qobject_cast<QToolButton *>(widget) ||
+ qobject_cast<QSpinBox *>(widget) ||
+ qobject_cast<QGroupBox *>(widget))
+ widget->setAttribute(Qt::WA_Hover, true);
+}
+
+void JavaStyle::unpolish(QWidget *widget)
+{
+ if (qobject_cast<QPushButton *>(widget) ||
+ qobject_cast<QCheckBox *>(widget) ||
+ qobject_cast<QRadioButton *>(widget) ||
+ qobject_cast<QToolButton *>(widget) ||
+ qobject_cast<QSpinBox *>(widget) ||
+ qobject_cast<QGroupBox *>(widget))
+ widget->setAttribute(Qt::WA_Hover, false);
+}
+
+void JavaStyle::drawSplitter(const QStyleOption *option, QPainter *painter,
+ bool horizontal) const
+{
+ QRect rect = option->rect;
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(option->palette.color(QPalette::Background));
+
+ painter->drawRect(rect);
+
+ QColor colors[] = { Qt::white, option->palette.color(QPalette::Mid) };
+ int iterations = horizontal ? rect.height() - 1 : rect.width() - 1;
+ for (int i = 0; i < iterations; ++i) {
+ painter->setPen(colors[i % 2]);
+ painter->drawPoint(xySwitch(QPoint(rect.x() + 0 + (i % 4),
+ rect.y() + i), horizontal));
+ }
+}
+
+inline QPoint JavaStyle::xySwitch(const QPoint &point, bool horizontal) const
+{
+ QPoint retPoint = point;
+
+ if (!horizontal) {
+ retPoint = QPoint(point.y(), point.x());
+ }
+
+ return retPoint;
+}
+
+void JavaStyle::drawPrimitive(PrimitiveElement element,
+ const QStyleOption *option,
+ QPainter *painter,
+ const QWidget *widget) const
+{
+ painter->save();
+
+ switch (element) {
+ case PE_PanelButtonBevel:
+ case PE_FrameButtonBevel: {
+ painter->save();
+ painter->setBrush(option->palette.background());
+ painter->setPen(Qt::NoPen);
+ painter->drawRect(option->rect);
+ painter->restore();
+ break;
+ }
+ case PE_IndicatorBranch: {
+ painter->save();
+ QColor lineColor(204, 204, 255);
+ QPixmap openPixmap(":/images/jtreeopen.png");
+ QPixmap closedPixmap(":/images/jtreeclosed.png");
+ QRect pixmapRect(QPoint(0, 0), QSize(12, 12));
+ pixmapRect.moveCenter(option->rect.center());
+ pixmapRect.translate(2, 0);
+ QPoint center = option->rect.center();
+
+ painter->setPen(lineColor);
+ painter->setBrush(Qt::NoBrush);
+
+ if (option->state & State_Item) {
+ painter->drawLine(center,
+ QPoint(option->rect.right(), center.y()));
+
+ painter->drawLine(center, QPoint(center.x(),
+ option->rect.top()));
+
+ if (option->state & State_Sibling) {
+ painter->drawLine(center, QPoint(center.x(),
+ option->rect.bottom()));
+ }
+
+ if (option->state & State_Children)
+ if (option->state & State_Open)
+ painter->drawPixmap(pixmapRect.topLeft(), closedPixmap);
+ else
+ painter->drawPixmap(pixmapRect.topLeft(), openPixmap);
+ } else if (option->state & State_Sibling) {
+ painter->drawLine(center.x(), option->rect.top(), center.x(),
+ option->rect.bottom());
+ }
+
+ painter->restore();
+ break;
+ }
+ case PE_IndicatorViewItemCheck: {
+ break;
+ }
+ case PE_FrameWindow: {
+ painter->save();
+ bool active = option->state & State_Active;
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(active ? option->palette.color(QPalette::Midlight)
+ : option->palette.color(QPalette::Mid));
+
+ painter->drawRect(QRect(option->rect.topLeft(), option->rect.bottomLeft() + QPoint(5, 0)));
+ painter->drawRect(QRect(option->rect.bottomLeft(), option->rect.bottomRight() + QPoint(0, -5)));
+ painter->drawRect(QRect(option->rect.bottomRight() + QPoint(-5, 0), option->rect.topRight()));
+ painter->drawRect(QRect(option->rect.topLeft(), option->rect.topRight() + QPoint(0, 4)));
+
+ painter->setBrush(Qt::NoBrush);
+ painter->setPen(option->palette.color(QPalette::Active, QPalette::WindowText));
+ painter->drawLine(option->rect.topLeft() + QPoint(2, 14),
+ option->rect.bottomLeft() + QPoint(2, -14));
+
+ painter->drawLine(option->rect.topRight() + QPoint(-2, 14),
+ option->rect.bottomRight() + QPoint(-2, -14));
+
+ painter->drawLine(option->rect.topLeft() + QPoint(14, 2),
+ option->rect.topRight() + QPoint(-14, 2));
+
+ painter->drawLine(option->rect.bottomLeft() + QPoint(14, -2),
+ option->rect.bottomRight() + QPoint(-14, -2));
+
+ painter->setPen(active ? option->palette.color(QPalette::Light) :
+ option->palette.color(QPalette::Button));
+ painter->drawLine(option->rect.topLeft() + QPoint(3, 15),
+ option->rect.bottomLeft() + QPoint(3, -13));
+
+ painter->drawLine(option->rect.topRight() + QPoint(-1, 15),
+ option->rect.bottomRight() + QPoint(-1, -13));
+
+ painter->drawLine(option->rect.topLeft() + QPoint(15, 3),
+ option->rect.topRight() + QPoint(-13, 3));
+
+ painter->drawLine(option->rect.bottomLeft() + QPoint(15, -1),
+ option->rect.bottomRight() + QPoint(-13, -1));
+
+ painter->restore();
+ break;
+ }
+ case PE_IndicatorSpinUp: {
+ const QStyleOptionSpinBox *spinner =
+ qstyleoption_cast<const QStyleOptionSpinBox *>(option);
+ int add = spinner->state & State_Sunken &&
+ spinner->activeSubControls & SC_SpinBoxUp ? 1 : 0;
+
+ QPoint center = option->rect.center();
+ painter->drawLine(center.x() + add, center.y() + 1 + add,
+ center.x() + 2 + add, center.y() + 1 + add);
+ painter->drawPoint(center.x() + 1 + add, center.y() + add);
+ break;
+ }
+ case PE_IndicatorSpinDown: {
+ const QStyleOptionSpinBox *spinner =
+ qstyleoption_cast<const QStyleOptionSpinBox *>(option);
+
+ int add = spinner->state & State_Sunken &&
+ spinner->activeSubControls & SC_SpinBoxDown ? 1 : 0;
+ QPoint center = option->rect.center();
+ painter->drawLine(center.x() + add, center.y() + add,
+ center.x() + 2 + add, center.y() + add);
+ painter->drawPoint(center.x() + 1 + add, center.y() + 1 + add);
+ break;
+ }
+ case PE_FrameDockWidget: {
+ drawPrimitive(PE_FrameWindow, option, painter, widget);
+ break;
+ }
+ case PE_IndicatorToolBarHandle: {
+ QPoint offset;
+ bool horizontal = option->state & State_Horizontal;
+
+ if (horizontal)
+ offset = option->rect.topLeft();
+ else
+ offset = option->rect.topLeft();
+
+ int iterations = horizontal ? option->rect.height() :
+ option->rect.width();
+
+ for (int i = 0; i < iterations; ++i) {
+ painter->setPen(i % 2 ? Qt::white :
+ option->palette.color(QPalette::Mid));
+ int add = i % 4;
+ painter->drawPoint(offset + xySwitch(QPoint(add, i),
+ horizontal));
+ painter->drawPoint(offset + xySwitch(QPoint(add + 4, i),
+ horizontal));
+ if (add + 8 < 10)
+ painter->drawPoint(offset + xySwitch(QPoint(add + 8, i),
+ horizontal));
+ }
+
+ break;
+ }
+ case PE_IndicatorToolBarSeparator: {
+ break;
+ }
+ case PE_PanelButtonTool: {
+ const QStyleOptionToolButton *button =
+ qstyleoption_cast<const QStyleOptionToolButton *>(option);
+
+ if (!button) {
+ painter->setPen(Qt::red);
+ if (!(option->state & State_Enabled))
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+ drawButtonBackground(option, painter, false);
+ break;
+ }
+
+ if (button->state & State_MouseOver || button->state & State_On) {
+ QStyleOptionButton bevel;
+ bevel.state = button->state;
+ bevel.rect = button->rect;
+ bevel.palette = button->palette;
+
+ drawButtonBackground(&bevel, painter, false);
+ } else {
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(button->palette.color(QPalette::Background));
+
+ painter->drawRect(button->rect.adjusted(0, 0, -1, -1));
+ }
+ break;
+ }
+ case PE_FrameMenu: {
+ painter->setPen(option->palette.color(QPalette::Midlight));
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+ break;
+ }
+ case PE_PanelButtonCommand: {
+ const QStyleOptionButton *btn =
+ qstyleoption_cast<const QStyleOptionButton *>(option);
+ bool hover = (btn->state & State_Enabled) &&
+ (btn->state & State_MouseOver);
+ bool sunken = btn->state & State_Sunken;
+ bool isDefault = btn->features & QStyleOptionButton::DefaultButton;
+ bool on = option->state & State_On;
+
+ drawButtonBackground(option, painter, false);
+
+ QRect rect = option->rect.adjusted(0, 0, -1, -1);
+ if (hover && !sunken && !isDefault && !on) {
+ drawButtonHoverFrame(painter, rect,
+ btn->palette.color(QPalette::Mid),
+ btn->palette.color(QPalette::Button));
+ } else if (isDefault) {
+ drawPrimitive(PE_FrameDefaultButton, option, painter, widget);
+ }
+ break;
+ }
+ case PE_FrameDefaultButton: {
+ painter->setPen(option->palette.color(QPalette::Mid));
+ QRect rect = option->rect.adjusted(0, 0, -1, -1);
+ painter->drawRect(rect);
+ painter->drawRect(rect.adjusted(1, 1, -1, -1));
+ break;
+ }
+//! [0]
+ case PE_IndicatorCheckBox: {
+ painter->save();
+ drawButtonBackground(option, painter, true);
+
+ if (option->state & State_Enabled &&
+ option->state & State_MouseOver &&
+ !(option->state & State_Sunken)) {
+ painter->setPen(option->palette.color(QPalette::Button));
+ QRect rect = option->rect.adjusted(1, 1, -2, -2);
+ painter->drawRect(rect);
+ rect = rect.adjusted(1, 1, -1, -1);
+ painter->drawRect(rect);
+ }
+
+ if (option->state & State_On) {
+ QImage image(":/images/checkboxchecked.png");
+ painter->drawImage(option->rect.topLeft(), image);
+ }
+ painter->restore();
+ break;
+//! [0]
+ }
+ case PE_IndicatorRadioButton: {
+ painter->save();
+ QBrush radioBrush = option->palette.button();
+
+ if (!(option->state & State_Sunken) &&
+ option->state & State_Enabled)
+ radioBrush = gradientBrush(option->rect);
+
+ painter->setBrush(radioBrush);
+ if (option->state & State_Enabled)
+ painter->setPen(option->palette.color(QPalette::Mid));
+ else
+ painter->setPen(option->palette.color(QPalette::Disabled,
+ QPalette::WindowText));
+ painter->drawEllipse(option->rect.adjusted(0, 0, -1, -1));
+
+ if (option->state & State_MouseOver &&
+ option->state & State_Enabled &&
+ !(option->state & State_Sunken)) {
+ gradientBrush(option->rect);
+ painter->setPen(option->palette.color(QPalette::Button));
+ painter->setBrush(Qt::NoBrush);
+ QRect rect = option->rect.adjusted(1, 1, -2, -2);
+ painter->drawEllipse(rect);
+ rect = rect.adjusted(1, 1, -1, -1);
+ painter->drawEllipse(rect);
+ }
+
+ if (option->state & State_On) {
+ painter->setBrush(option->palette.color(QPalette::Text));
+ painter->setPen(Qt::NoPen);
+ painter->drawEllipse(option->rect.adjusted(3, 3, -3, -3));
+ }
+ if (option->state & State_Sunken &&
+ option->state & State_Enabled) {
+ painter->setPen(option->palette.color(QPalette::Mid));
+ painter->drawArc(option->rect.adjusted(1, 1, -2, -2), 80 * 16,
+ 100 * 16);
+ }
+ painter->restore();
+ break;
+ }
+ case PE_FrameTabWidget: {
+ painter->setPen(option->palette.color(QPalette::Midlight));
+ painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
+ painter->setPen(Qt::white);
+ painter->drawRect(option->rect.adjusted(1, 1, -2, -2));
+ break;
+ }
+ case PE_Frame:
+ case PE_FrameLineEdit: {
+ const QStyleOptionFrame *frame =
+ qstyleoption_cast<const QStyleOptionFrame *>(option);
+ const QStyleOptionFrameV2 frameV2(*frame);
+
+ painter->setPen(frame->palette.color(QPalette::Mid));
+ painter->drawRect(frameV2.rect.adjusted(0, 0, -2, -2));
+ painter->setPen(Qt::white);
+ painter->drawRect(frameV2.rect.adjusted(1, 1, -1, -1));
+ painter->setPen(frameV2.palette.color(QPalette::Active,
+ QPalette::Background));
+ painter->drawLine(frameV2.rect.bottomLeft(),
+ frameV2.rect.bottomLeft() + QPoint(1, -1));
+ painter->drawLine(frameV2.rect.topRight(),
+ frameV2.rect.topRight() + QPoint(-1, 1));
+ break;
+ }
+ case PE_FrameFocusRect: {
+ painter->setPen(option->palette.color(QPalette::Light));
+ painter->setBrush(Qt::NoBrush);
+ QRect rect = option->rect;
+ rect = rect.adjusted(0,0, -1, -1);
+ painter->drawRect(rect);
+ break;
+ }
+ default:
+ QWindowsStyle::drawPrimitive(element, option, painter, widget);
+ }
+ painter->restore();
+}
+
+//! [1]
+void JavaStyle::drawButtonBackground(const QStyleOption *option,
+ QPainter *painter, bool isCheckbox) const
+{
+ QBrush buttonBrush = option->palette.button();
+ bool sunken = option->state & State_Sunken;
+ bool disabled = !(option->state & State_Enabled);
+ bool on = option->state & State_On;
+
+ if (!sunken && !disabled && (!on || isCheckbox))
+ buttonBrush = gradientBrush(option->rect);
+
+ painter->fillRect(option->rect, buttonBrush);
+
+ QRect rect = option->rect.adjusted(0, 0, -1, -1);
+
+ if (disabled)
+ painter->setPen(option->palette.color(QPalette::Disabled,
+ QPalette::WindowText));
+ else
+ painter->setPen(option->palette.color(QPalette::Mid));
+
+ painter->drawRect(rect);
+
+ if (sunken && !disabled) {
+ drawSunkenButtonShadow(painter, rect,
+ option->palette.color(QPalette::Mid),
+ option->direction == Qt::RightToLeft);
+ }
+}
+//! [1]
+
+QBrush JavaStyle::gradientBrush(const QRect &rect) const
+{
+ QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
+ gradient.setColorAt(1.0, QColor(188, 210, 230));
+ gradient.setColorAt(0.3, Qt::white);
+ gradient.setColorAt(0.0, QColor(223, 233, 243));
+
+ return QBrush(gradient);
+}
+
+QRect JavaStyle::subElementRect(SubElement element,
+ const QStyleOption *option,
+ const QWidget *widget) const
+{
+ QRect rect;
+
+ switch (element) {
+ case SE_ToolBoxTabContents: {
+ const QStyleOptionToolBox *box =
+ qstyleoption_cast<const QStyleOptionToolBox *>(option);
+
+ rect.moveTopLeft(box->rect.topLeft() + QPoint(0, 2));
+ rect.setHeight(box->rect.height() - 4);
+ rect.setWidth(box->fontMetrics.width(box->text) + 15);
+ break;
+ }
+ case SE_ProgressBarLabel:
+ case SE_ProgressBarGroove:
+ case SE_ProgressBarContents: {
+ rect = option->rect.adjusted(1, 1, -1, -1);
+ break;
+ }
+ case SE_PushButtonFocusRect: {
+ const QStyleOptionButton *btn =
+ qstyleoption_cast<const QStyleOptionButton *>(option);
+
+ rect = btn->fontMetrics.boundingRect(btn->text);
+ rect = QRect(0, 0, btn->fontMetrics.width(btn->text),
+ rect.height());
+
+ if (!btn->icon.isNull()) {
+ rect.adjust(0, 0, btn->iconSize.width(), btn->iconSize.height()
+ > rect.height() ? btn->iconSize.height() - rect.height() : 0);
+ rect.translate(-btn->iconSize.width(), 0);
+ rect.adjust(-1, -1, 1, 1);
+ }
+ rect = QRect(int(ceil((btn->rect.width() - rect.width()) / 2.0)),
+ int(ceil((btn->rect.height() - rect.height()) / 2.0)),
+ rect.width() - 1, rect.height());
+ rect.adjust(-1, 0, 1, 0);
+
+ break;
+ }
+ default:
+ rect = QWindowsStyle::subElementRect(element, option, widget);
+ }
+ return rect;
+}
+
+int JavaStyle::pixelMetric(PixelMetric metric,
+ const QStyleOption* /* option */,
+ const QWidget* /*widget*/) const
+{
+ int value = 0;
+
+ switch (metric) {
+ case PM_ButtonShiftHorizontal:
+ case PM_ButtonShiftVertical:
+ case PM_TabBarTabShiftHorizontal:
+ case PM_ButtonDefaultIndicator:
+ case PM_TabBarTabShiftVertical:
+ value = 0;
+ break;
+ case PM_TabBarBaseOverlap:
+ case PM_DefaultFrameWidth:
+ value = 2;
+ break;
+ case PM_TabBarTabVSpace:
+ value = 4;
+ break;
+ case PM_ScrollBarExtent:
+ value = 16;
+ break;
+ case PM_ScrollBarSliderMin:
+ value = 26;
+ break;
+ case PM_SplitterWidth:
+ value = 8;
+ break;
+ case PM_SliderThickness:
+ value = 16;
+ break;
+ case PM_SliderControlThickness:
+ value = 16;
+ break;
+ case PM_SliderTickmarkOffset:
+ value = 10;
+ break;
+ case PM_SliderSpaceAvailable:
+ break;
+ case PM_MenuPanelWidth:
+ value = 1;
+ break;
+ case PM_MenuVMargin:
+ value = 2;
+ break;
+ case PM_MenuBarPanelWidth:
+ value = 1;
+ break;
+ case PM_MenuBarItemSpacing:
+ value = 0;
+ break;
+ case PM_MenuBarHMargin:
+ value = 3;
+ break;
+ case PM_MenuBarVMargin:
+ value = 0;
+ break;
+ case PM_ComboBoxFrameWidth:
+ value = 1;
+ break;
+ case PM_MenuButtonIndicator:
+ value = 15;
+ break;
+ case PM_ToolBarItemMargin:
+ value = 3;
+ break;
+ case PM_ToolBarHandleExtent:
+ value = 13;
+ break;
+ case PM_SpinBoxFrameWidth:
+ value = 2;
+ break;
+ case PM_TitleBarHeight: {
+ value = 21;
+ break;
+ case PM_MDIFrameWidth:
+ value = 6;
+ break;
+ }
+ case PM_DockWidgetFrameWidth: {
+ value = 5;
+ break;
+ }
+ default:
+ value = QWindowsStyle::pixelMetric(metric);
+ }
+ return value;
+}
+
+
+int JavaStyle::styleHint(StyleHint hint, const QStyleOption *option,
+ const QWidget *widget,
+ QStyleHintReturn *returnData) const
+{
+ int ret;
+
+ switch (hint) {
+ case SH_Table_GridLineColor: {
+ ret = static_cast<int>(option->palette.color(QPalette::Mid).rgb());
+ break;
+ }
+ case QStyle::SH_Menu_Scrollable:
+ ret = 1;
+ break;
+ default:
+ ret = QWindowsStyle::styleHint(hint, option, widget, returnData);
+ }
+ return ret;
+}
+
+QPixmap JavaStyle::standardPixmap(StandardPixmap standardPixmap,
+ const QStyleOption *option,
+ const QWidget *widget) const
+{
+ QPixmap pixmap = QWindowsStyle::standardPixmap(standardPixmap, option,
+ widget);
+
+ QPixmap maximizePixmap(":/images/internalmaximize.png");
+ QPixmap minimizePixmap(":/images/internalminimize.png");
+ QPixmap closePixmap(":/images/internalclose.png");
+ QPixmap internalPixmap(":/images/internalsystem.png");
+ QPixmap internalCloseDownPixmap(":/images/internalclosedown.png");
+ QPixmap minimizeDownPixmap(":/images/internalminimizedown.png");
+ QPixmap maximizeDownPixmap(":/images/internalmaximizedown.png");
+ QPixmap dirOpenPixmap(":/images/open24.png");
+ QPixmap filePixmap(":/images/file.png");
+
+ switch (standardPixmap) {
+ case SP_DirLinkIcon:
+ case SP_DirClosedIcon:
+ case SP_DirIcon:
+ case SP_DirOpenIcon: {
+ pixmap = closePixmap;
+ break;
+ }
+ case SP_FileIcon: {
+ pixmap = filePixmap;
+ break;
+ }
+ case SP_FileDialogBack: {
+ pixmap = QPixmap(":/images/fileback.png");
+ break;
+ }
+ case SP_FileDialogToParent: {
+ pixmap = QPixmap(":/images/fileparent.png");
+ break;
+ }
+ case SP_FileDialogNewFolder: {
+ pixmap = QPixmap(":/images/open24.png");
+ break;
+ }
+ case SP_FileDialogListView: {
+ pixmap = QPixmap(":/images/filelist.png");
+ break;
+ }
+ case SP_FileDialogDetailedView: {
+ pixmap = QPixmap(":/images/filedetail.png");
+ break;
+ }
+ case SP_MessageBoxInformation: {
+ pixmap = QPixmap(":/images/information.png");
+ break;
+ }
+ case SP_MessageBoxWarning: {
+ pixmap = QPixmap(":/images/warning.png");
+ }
+ case SP_MessageBoxCritical: {
+ pixmap = QPixmap(":/images/critical.png");
+ break;
+ }
+ case SP_MessageBoxQuestion: {
+ pixmap = QPixmap(":/images/question.png");
+ break;
+ }
+ case SP_TitleBarNormalButton:
+ pixmap = maximizePixmap;
+ break;
+ case SP_TitleBarCloseButton:
+ pixmap = closePixmap;
+ break;
+ default:
+ ;
+ }
+
+ return pixmap;
+}
+
+QSize JavaStyle::sizeFromContents(ContentsType type,
+ const QStyleOption *option,
+ const QSize &contentsSize,
+ const QWidget *widget) const
+{
+ switch (type) {
+ case CT_ComboBox: {
+ return QSize(contentsSize.width() + 27, contentsSize.height());
+ }
+ case CT_Slider: {
+ const QStyleOptionSlider *slider =
+ qstyleoption_cast<const QStyleOptionSlider *>(option);
+ if (slider->tickPosition == QSlider::TicksBelow) {
+ return QSize(contentsSize.width(), contentsSize.height() + 15);
+ } else {
+ return contentsSize;
+ }
+ }
+ case CT_MenuBarItem: {
+ const QStyleOptionMenuItem *menuItem =
+ qstyleoption_cast<const QStyleOptionMenuItem *>(option);
+ QFontMetrics metrics(menuItem->font);
+ QRect boundingRect = metrics.boundingRect(menuItem->text);
+ int width = boundingRect.width() + 14;
+ int height = boundingRect.height() + 3;
+ if (height < 20)
+ height = 20;
+
+ return QSize(width, height);
+ }
+ case CT_MenuItem: {
+ const QStyleOptionMenuItem *menuItem =
+ qstyleoption_cast<const QStyleOptionMenuItem *>(option);
+ QSize defaultSize = QWindowsStyle::sizeFromContents(type, option,
+ contentsSize, widget);
+
+ if (menuItem->menuItemType == QStyleOptionMenuItem::Separator)
+ return defaultSize;
+
+ int width = 30;
+ int height = 0;
+
+ if (!menuItem->icon.isNull()) {
+ width += 20;
+ height += 20;
+ }
+ if (!menuItem->text.isEmpty()) {
+ QFontMetrics metrics(menuItem->font);
+ QString text = menuItem->text;
+ text.remove(QLatin1Char('\t'));
+ QRect textRect = metrics.boundingRect(text);
+ width += textRect.width();
+ if (height < textRect.height())
+ height += textRect.height();
+ }
+ if (menuItem->checkType != QStyleOptionMenuItem::NotCheckable) {
+ width += 10;
+ if (height < 10)
+ height = 10;
+ }
+ return QSize(width, height);
+ }
+ default:
+ return QWindowsStyle::sizeFromContents(type, option, contentsSize,
+ widget);
+ }
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/layouts/layouts.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/layouts/layouts.cpp
new file mode 100644
index 000000000..1211ccbc5
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/layouts/layouts.cpp
@@ -0,0 +1,126 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ window = QWidget()
+//! [0] //! [1]
+ button1 = QPushButton("One")
+//! [1] //! [2]
+ button2 = QPushButton("Two")
+ button3 = QPushButton("Three")
+ button4 = QPushButton("Four")
+ button5 = QPushButton("Five")
+//! [2]
+
+//! [3]
+ layout = QHBoxLayout()
+//! [3] //! [4]
+ layout.addWidget(button1)
+ layout.addWidget(button2)
+ layout.addWidget(button3)
+ layout.addWidget(button4)
+ layout.addWidget(button5)
+
+ window.setLayout(layout)
+//! [4] //! [5]
+ window.show()
+//! [5]
+
+//! [6]
+ window = QWidget()
+//! [6] //! [7]
+ button1 = QPushButton("One")
+//! [7] //! [8]
+ button2 = QPushButton("Two")
+ button3 = QPushButton("Three")
+ button4 = QPushButton("Four")
+ button5 = QPushButton("Five")
+//! [8]
+
+//! [9]
+ layout = QVBoxLayout()
+
+//! [9] //! [10]
+ layout.addWidget(button1)
+ layout.addWidget(button2)
+ layout.addWidget(button3)
+ layout.addWidget(button4)
+ layout.addWidget(button5)
+
+ window.setLayout(layout)
+//! [10] //! [11]
+ window.show()
+//! [11]
+
+//! [12]
+ window = QWidget()
+//! [12] //! [13]
+ button1 = QPushButton("One")
+//! [13] //! [14]
+ button2 = QPushButton("Two")
+ button3 = QPushButton("Three")
+ button4 = QPushButton("Four")
+ button5 = QPushButton("Five")
+//! [14]
+
+//! [15]
+ layout = QGridLayout()
+
+//! [15] //! [16]
+ layout.addWidget(button1, 0, 0)
+ layout.addWidget(button2, 0, 1)
+ layout.addWidget(button3, 1, 0, 1, 2)
+ layout.addWidget(button4, 2, 0)
+ layout.addWidget(button5, 2, 1)
+
+ window.setLayout(layout)
+//! [16] //! [17]
+ window.show()
+//! [17]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/mainwindowsnippet.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/mainwindowsnippet.cpp
new file mode 100644
index 000000000..fb2440426
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/mainwindowsnippet.cpp
@@ -0,0 +1,58 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ dockWidget = QDockWidget(tr("Dock Widget"), self)
+ dockWidget.setAllowedAreas(Qt.LeftDockWidgetArea |
+ Qt.RightDockWidgetArea)
+ dockWidget.setWidget(dockWidgetContents)
+ addDockWidget(Qt.LeftDockWidgetArea, dockWidget)
+//! [0]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/matrix/matrix.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/matrix/matrix.cpp
new file mode 100644
index 000000000..0f5b5f441
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/matrix/matrix.cpp
@@ -0,0 +1,112 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+def paintEvent(self, event):
+ painter = QPainter(self)
+ painter.setPen(QPen(Qt.blue, 1, Qt.DashLine))
+ painter.drawRect(0, 0, 100, 100)
+
+ painter.rotate(45)
+
+ painter.setFont(QFont("Helvetica", 24))
+ painter.setPen(QPen(Qt.black, 1))
+ painter.drawText(20, 10, "QMatrix")
+//! [0]
+
+
+//! [1]
+def paintEvent(self, event)
+
+ painter = QPainter(self)
+ painter.setPen(QPen(Qt.blue, 1, Qt.DashLine))
+ painter.drawRect(0, 0, 100, 100)
+
+ matrix = QMatrix()
+ matrix.translate(50, 50)
+ matrix.rotate(45)
+ matrix.scale(0.5, 1.0)
+ painter.setMatrix(matrix)
+
+ painter.setFont(QFont("Helvetica", 24))
+ painter.setPen(QPen(Qt.black, 1))
+ painter.drawText(20, 10, "QMatrix")
+
+//! [1]
+
+
+//! [2]
+def paintEvent(self, event)
+
+ pi = 3.14
+
+ a = pi/180 * 45.0
+ sina = sin(a)
+ cosa = cos(a)
+
+ translationMatrix = QMatrix(1, 0, 0, 1, 50.0, 50.0)
+ rotationMatrix = QMatrix(cosa, sina, -sina, cosa, 0, 0)
+ scalingMatrix = QMatrix(0.5, 0, 0, 1.0, 0, 0)
+
+ matrix = QMatrix()
+ matrix = scalingMatrix * rotationMatrix * translationMatrix
+
+ painter = QPainter(self)
+ painter.setPen(QPen(Qt.blue, 1, Qt::DashLine))
+ painter.drawRect(0, 0, 100, 100)
+
+ painter.setMatrix(matrix)
+
+ painter.setFont(QFont("Helvetica", 24))
+ painter.setPen(QPen(Qt.black, 1))
+ painter.drawText(20, 10, "QMatrix")
+
+//! [2]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/mdiareasnippets.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/mdiareasnippets.cpp
new file mode 100644
index 000000000..a20f70fc2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/mdiareasnippets.cpp
@@ -0,0 +1,66 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ mainWindow = QMainWindow()
+ mainWindow.setCentralWidget(mdiArea)
+//! [0]
+
+//! [1]
+ mdiArea = QMdiArea()
+ subWindow1 = QMdiSubWindow()
+ subWindow1.setWidget(internalWidget1)
+ subWindow1.setAttribute(Qt.WA_DeleteOnClose)
+ mdiArea.addSubWindow(subWindow1)
+
+ subWindow2 = QMdiSubWindow()
+ mdiArea.addSubWindow(internalWidget2)
+//! [1]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/main.cpp
new file mode 100644
index 000000000..5098ac38f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/main.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "myclass1.h"
+
+MyClass::MyClass(QObject *) {}
+MyClass::~MyClass() {}
+void MyClass::mySlot() {}
+#undef MyClass
+
+#include "myclass2.h"
+
+MyClass::MyClass(QObject *) {}
+MyClass::~MyClass() {}
+void MyClass::setPriority(Priority) {}
+MyClass::Priority MyClass::priority() const { return High; }
+#undef MyClass
+
+#include "myclass3.h"
+
+MyClass::MyClass(QObject *) {}
+MyClass::~MyClass() {}
+#undef MyClass
+
+int main()
+{
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass1.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass1.h
new file mode 100644
index 000000000..859ef90a7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass1.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MYCLASS1_H
+#define MYCLASS1_H
+
+#include <QObject>
+
+#define MyClass MyClass1
+
+//! [0]
+class MyClass : public QObject
+{
+ Q_OBJECT
+
+public:
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+
+signals:
+ void mySignal();
+
+public slots:
+ void mySlot();
+};
+//! [0]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass2.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass2.h
new file mode 100644
index 000000000..2bfe4ced6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass2.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MYCLASS2_H
+#define MYCLASS2_H
+
+#include <QObject>
+
+#define MyClass MyClass2
+
+//! [0]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(Priority priority READ priority WRITE setPriority)
+ Q_ENUMS(Priority)
+
+public:
+ enum Priority { High, Low, VeryHigh, VeryLow };
+
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+
+ void setPriority(Priority priority);
+ Priority priority() const;
+};
+//! [0]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass3.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass3.h
new file mode 100644
index 000000000..60834c8e5
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/moc/myclass3.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MYCLASS3_H
+#define MYCLASS3_H
+
+#include <QObject>
+
+//! [0]
+class MyClass : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("Author", "Oscar Peterson")
+ Q_CLASSINFO("Status", "Active")
+
+public:
+ MyClass(QObject *parent = 0);
+ ~MyClass();
+};
+//! [0]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/main.cpp
new file mode 100644
index 000000000..84752a4fd
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/main.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ An example of a main window application that used a subclassed model
+ and view to display data from sound files.
+*/
+
+#include <QApplication>
+
+#include "model.h"
+#include "view.h"
+#include "window.h"
+
+/*!
+ The main function for the linear model example. This creates and
+ populates a model with long integers then displays the contents of the
+ model using a QListView widget.
+*/
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ MainWindow *window = new MainWindow;
+
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.cpp
new file mode 100644
index 000000000..50ba15020
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.cpp
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ A simple model that uses a QVector as its data source.
+*/
+
+#include "model.h"
+
+/*!
+ Returns the number of items in the string list as the number of rows
+ in the model.
+*/
+
+int LinearModel::rowCount(const QModelIndex &parent) const
+{
+ Q_USING(parent);
+
+ return values.count();
+}
+
+/*
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ If a header is requested then we just return the column or row number,
+ depending on the orientation of the header.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned.
+*/
+
+/*!
+ Returns a model index for other component to use when referencing the
+ item specified by the given row, column, and type. The parent index
+ is ignored.
+*/
+
+QModelIndex LinearModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if (parent == QModelIndex() && row >= 0 && row < rowCount()
+ && column == 0)
+ return createIndex(row, column, 0);
+ else
+ return QModelIndex();
+}
+
+QVariant LinearModel::data(const QModelIndex &index, int role) const
+{
+ Q_UNUSED(role);
+
+ if (!index.isValid())
+ return QVariant();
+
+ return values.at(index.row());
+}
+
+/*!
+ Returns Qt::ItemIsEditable so that all items in the vector can be edited.
+*/
+
+Qt::ItemFlags LinearModel::flags(const QModelIndex &index) const
+{
+ // all items in the model are editable
+ return QAbstractListModel::flags(index) | Qt::ItemIsEditable;
+}
+
+/*!
+ Changes an item in the string list, but only if the following conditions
+ are met:
+
+ * The index supplied is valid.
+ * The index corresponds to an item to be shown in a view.
+ * The role associated with editing text is specified.
+
+ The dataChanged() signal is emitted if the item is changed.
+*/
+
+bool LinearModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (!index.isValid() || role != Qt::EditRole)
+ return false;
+ values.replace(index.row(), value.toInt());
+ emit dataChanged(index, index);
+ return true;
+}
+
+/*!
+ Inserts a number of rows into the model at the specified position.
+*/
+
+bool LinearModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ beginInsertRows(parent, position, position + rows - 1);
+
+ values.insert(position, rows, 0);
+
+ endInsertRows();
+ return true;
+}
+
+/*!
+ Removes a number of rows from the model at the specified position.
+*/
+
+bool LinearModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ beginRemoveRows(QModelIndex(), position, position+rows-1);
+
+ values.remove(position, rows);
+
+ endRemoveRows();
+ return true;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.h
new file mode 100644
index 000000000..0c0239046
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/model.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractListModel>
+#include <QObject>
+#include <qvector.h>
+
+class LinearModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ LinearModel(QObject *parent = 0)
+ : QAbstractListModel(parent) {}
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
+
+private:
+ QVector<int> values;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.cpp
new file mode 100644
index 000000000..a2a341bcb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.cpp
@@ -0,0 +1,324 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*!
+ view.cpp
+
+ Provides a view to represent a one-dimensional sequence of integers
+ obtained from a list model as a series of rows.
+*/
+
+#include <QAbstractItemModel>
+#include <QBrush>
+#include <QItemSelection>
+#include <QPainter>
+#include <QPaintEvent>
+#include <QPen>
+#include <QPoint>
+#include <QResizeEvent>
+#include <QScrollBar>
+#include <QSizePolicy>
+
+#include "view.h"
+
+LinearView::LinearView(QWidget *parent)
+ : QAbstractItemView(parent)
+{
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+}
+
+/*!
+ Returns the position of the item in viewport coordinates.
+*/
+
+QRect LinearView::itemViewportRect(const QModelIndex &index) const
+{
+ QRect rect = itemRect(index);
+ QRect result(rect.left() - horizontalScrollBar()->value(),
+ rect.top() - verticalScrollBar()->value(),
+ rect.width(), viewport()->height());
+
+ return result;
+}
+
+/*!
+ Returns the rectangle of the item at position \a index in the
+ model. The rectangle is in contents coordinates.
+*/
+
+QRect LinearView::itemRect(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return QRect();
+ else
+ return QRect(index.row(), 0, 1, 1);
+}
+
+
+void LinearView::ensureVisible(const QModelIndex &index)
+{
+ QRect area = viewport()->rect();
+ QRect rect = itemViewportRect(index);
+
+ if (rect.left() < area.left())
+ horizontalScrollBar()->setValue(
+ horizontalScrollBar()->value() - rect.left());
+ else if (rect.right() > area.right())
+ horizontalScrollBar()->setValue(
+ horizontalScrollBar()->value() + rect.left() - area.width());
+}
+
+/*!
+ Returns the item that covers the coordinate given in the view.
+*/
+
+QModelIndex LinearView::itemAt(int x, int /* y */) const
+{
+ int row = x + horizontalScrollBar()->value();
+
+ return model()->index(row, 0, QModelIndex());
+}
+
+//void LinearView::dataChanged(const QModelIndex &/* topLeft */,
+// const QModelIndex &/* bottomRight */)
+//{
+// updateGeometries();
+// if (isVisible())
+// repaint();
+//}
+
+void LinearView::rowsInserted(const QModelIndex &/* parent */, int /* start */,
+ int /* end */)
+{
+ updateGeometries();
+ if (isVisible())
+ repaint();
+}
+
+void LinearView::rowsRemoved(const QModelIndex &/* parent */, int /* start */,
+ int /* end */)
+{
+ updateGeometries();
+ if (isVisible())
+ repaint();
+}
+/*
+void LinearView::verticalScrollbarAction(int action)
+{
+}
+
+void LinearView::horizontalScrollbarAction(int action)
+{
+}
+*/
+
+/*!
+ Select the items in the model that lie within the rectangle specified by
+ \a rect, using the selection \a command.
+*/
+
+void LinearView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
+{
+ QModelIndex leftIndex = itemAt(rect.left(), 0);
+ QModelIndex rightIndex = itemAt(rect.right(), 0);
+
+ QItemSelection selection(leftIndex, rightIndex);
+
+ selectionModel()->select(selection, command);
+}
+
+QModelIndex LinearView::moveCursor(QAbstractItemView::CursorAction cursorAction,
+ Qt::KeyboardModifiers)
+{
+ QModelIndex current = currentIndex();
+
+ switch (cursorAction) {
+ case MoveLeft:{
+ if (current.row() > 0)
+ return model()->index(current.row() - 1, 0, QModelIndex());
+ else
+ return model()->index(0, 0, QModelIndex());
+ break;}
+ case MoveRight:{
+ if (current.row() < rows(current) - 1)
+ return model()->index(current.row() + 1, 0, QModelIndex());
+ else
+ return model()->index(rows(current) - 1, 0,QModelIndex());
+ break;}
+ case MoveUp:
+ return current;
+ case MoveDown:
+ return current;
+ case MovePageUp:
+ return current;
+ case MovePageDown:
+ return current;
+ case MoveHome:
+ return model()->index(0, 0, QModelIndex());
+ case MoveEnd:
+ return model()->index(rows(current) - 1, 0, QModelIndex());
+ default:
+ return current;
+ }
+}
+
+int LinearView::horizontalOffset() const
+{
+ return horizontalScrollBar()->value();
+}
+
+int LinearView::verticalOffset() const
+{
+ return verticalScrollBar()->value();
+}
+
+/*!
+ Returns a rectangle corresponding to the selection in viewport cooridinates.
+*/
+
+QRect LinearView::selectionViewportRect(const QItemSelection &selection) const
+{
+ int ranges = selection.count();
+
+ if (ranges == 0)
+ return QRect();
+
+ // Note that we use the top and bottom functions of the selection range
+ // since the data is stored in rows.
+
+ int firstRow = selection.at(0).top();
+ int lastRow = selection.at(0).top();
+
+ for (int i = 0; i < ranges; ++i) {
+ firstRow = qMin(firstRow, selection.at(i).top());
+ lastRow = qMax(lastRow, selection.at(i).bottom());
+ }
+
+ QModelIndex firstItem = model()->index(qMin(firstRow, lastRow), 0,
+ QModelIndex());
+ QModelIndex lastItem = model()->index(qMax(firstRow, lastRow), 0,
+ QModelIndex());
+
+ QRect firstRect = itemViewportRect(firstItem);
+ QRect lastRect = itemViewportRect(lastItem);
+
+ return QRect(firstRect.left(), firstRect.top(),
+ lastRect.right() - firstRect.left(), firstRect.height());
+}
+
+void LinearView::paintEvent(QPaintEvent *event)
+{
+ QPainter painter(viewport());
+
+ QRect updateRect = event->rect();
+ QBrush background(Qt::black);
+ QPen foreground(Qt::white);
+
+ painter.fillRect(updateRect, background);
+ painter.setPen(foreground);
+
+ QModelIndex firstItem = itemAt(updateRect.left(), updateRect.top());
+ if (!firstItem.isValid())
+ firstItem = model()->index(0, 0, QModelIndex());
+
+ QModelIndex lastItem = itemAt(updateRect.right(), updateRect.bottom());
+ if (!lastItem.isValid())
+ lastItem = model()->index(rows() - 1, 0, QModelIndex());
+
+ int x = updateRect.left();
+ //int top = updateRect.top();
+ //int bottom = updateRect.bottom();
+
+ int row = firstItem.row();
+ QModelIndex index = model()->index(row, 0, QModelIndex());
+ int value = model()->data(index, Qt::DisplayRole).toInt();
+ int midPoint = viewport()->height()/2;
+ int y2 = midPoint - int(value * midPoint/255.0);
+
+ while (row <= lastItem.row()) {
+
+ QModelIndex index = model()->index(row, 0, QModelIndex());
+ int value = model()->data(index, Qt::DisplayRole).toInt();
+
+ int y1 = y2;
+ y2 = midPoint - int(value * midPoint/255.0);
+
+ painter.drawLine(x-1, y1, x, y2);
+ ++row; ++x;
+ }
+}
+
+void LinearView::resizeEvent(QResizeEvent * /* event */)
+{
+ updateGeometries();
+}
+
+void LinearView::updateGeometries()
+{
+ if (viewport()->width() < rows()) {
+ horizontalScrollBar()->setPageStep(viewport()->width());
+ horizontalScrollBar()->setRange(0, rows() - viewport()->width() - 1);
+ }
+}
+
+QSize LinearView::sizeHint() const
+{
+ return QSize(rows(), 200);
+}
+
+int LinearView::rows(const QModelIndex &index) const
+{
+ return model()->rowCount(model()->parent(index));
+}
+
+bool LinearView::isIndexHidden(const QModelIndex &index) const
+{
+ return false;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.h
new file mode 100644
index 000000000..4a78426de
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/view.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef VIEW_H
+#define VIEW_H
+
+#include <QAbstractItemView>
+#include <QItemSelection>
+#include <QItemSelectionModel>
+#include <QModelIndex>
+#include <QRect>
+#include <QSize>
+#include <QWidget>
+
+class LinearView : public QAbstractItemView
+{
+ Q_OBJECT
+public:
+ LinearView(QWidget *parent = 0);
+
+ QRect itemViewportRect(const QModelIndex &index) const;
+ void ensureVisible(const QModelIndex &index);
+ QModelIndex itemAt(int x, int y) const;
+
+protected slots:
+ /*void dataChanged(const QModelIndex &topLeft, const QModelIndex
+ &bottomRight);*/
+ void rowsInserted(const QModelIndex &parent, int start, int end);
+ void rowsRemoved(const QModelIndex &parent, int start, int end);
+ /*void selectionChanged(const QItemSelection &deselected, const QItemSelection &selected);
+ void verticalScrollbarAction(int action);
+ void horizontalScrollbarAction(int action);*/
+
+protected:
+ void setSelection(const QRect&, QItemSelectionModel::SelectionFlags command);
+ QRect selectionViewportRect(const QItemSelection &selection) const;
+ QRect itemRect(const QModelIndex &item) const;
+ bool isIndexHidden(const QModelIndex &index) const;
+ int horizontalOffset() const;
+ int verticalOffset() const;
+ QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction,
+ Qt::KeyboardModifiers modifiers);
+
+ void paintEvent(QPaintEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ QSize sizeHint() const;
+
+private:
+ int rows(const QModelIndex &index = QModelIndex()) const;
+ void updateGeometries();
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.cpp
new file mode 100644
index 000000000..35af752ae
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QAction>
+#include <QDataStream>
+#include <QMenu>
+#include <QMenuBar>
+#include <QFile>
+#include <QFileDialog>
+#include <QListView>
+
+#include "window.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ setWindowTitle("Model/View example");
+
+ setupModelView();
+
+ QAction *openAction = new QAction(tr("&Open"), this);
+ QAction *quitAction = new QAction(tr("E&xit"), this);
+ QMenu *fileMenu = new QMenu(tr("&File"), this);
+ fileMenu->addAction(openAction);
+ fileMenu->addAction(quitAction);
+ menuBar()->addMenu(fileMenu);
+
+ connect(openAction, SIGNAL(triggered()), this, SLOT(selectOpenFile()));
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+
+ setCentralWidget(view);
+}
+
+void MainWindow::setupModelView()
+{
+ model = new LinearModel(this);
+ view = new LinearView(this);
+ view->setModel(model);
+}
+
+void MainWindow::selectOpenFile()
+{
+ QString fileName = QFileDialog::getOpenFileName(this,
+ tr("Select a file to open"), "", tr("Sound files (*.wav)"));
+
+ if (!fileName.isEmpty())
+ openFile(fileName);
+}
+
+void MainWindow::openFile(const QString &fileName)
+{
+ QFile file(fileName);
+ int length = file.size();
+
+ if (file.open(QFile::ReadOnly)) {
+ model->removeRows(0, model->rowCount());
+
+ int rows = (length - 0x2c)/2;
+ model->insertRows(0, rows);
+
+ // Perform some dodgy tricks to extract the data from the file.
+ QDataStream stream(&file);
+ stream.setByteOrder(QDataStream::LittleEndian);
+
+ Q_INT16 left;
+ Q_INT16 right;
+
+ for (int row = 0; row < rows; ++row) {
+ QModelIndex index = model->index(row);
+
+ stream >> left >> right;
+ model->setData(index, int(left / 256));
+ }
+ }
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.h
new file mode 100644
index 000000000..c9949adf4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/modelview-subclasses/window.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+#include <QString>
+#include <QWidget>
+
+#include "model.h"
+#include "view.h"
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow::MainWindow(QWidget *parent = 0);
+
+public slots:
+ void selectOpenFile();
+
+private:
+ void setupModelView();
+ void openFile(const QString &fileName);
+
+ LinearModel *model;
+ LinearView *view;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/myscrollarea.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/myscrollarea.cpp
new file mode 100644
index 000000000..325f1b317
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/myscrollarea.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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 *
+import sys
+
+class MyScrollArea (QAbstractScrollArea):
+ widget = None
+
+ def __init__(widget):
+ self.setWidget(widget);
+
+ def setWidget(w):
+ self.widget = w;
+ self.widget.setParent(viewport());
+ if not self.widget.testAttribute(Qt.WA_Resized):
+ self.widget.resize(widget.sizeHint())
+
+ self.verticalScrollBar().setValue(0)
+ self.verticalScrollBar().setValue(0)
+
+ self.updateArea()
+
+
+ def updateWidgetPosition():
+//! [0]
+ hvalue = self.horizontalScrollBar().value()
+ vvalue = self.verticalScrollBar().value()
+ topLeft = self.viewport().rect().topLeft()
+
+ self.widget.move(topLeft.x() - hvalue, topLeft.y() - vvalue)
+//! [0]
+
+
+ def scrollContentsBy(dx, dy):
+ self.updateWidgetPosition()
+
+ def updateArea():
+//! [1]
+ areaSize = viewport().size()
+ widgetSize = widget.size()
+
+ self.verticalScrollBar().setPageStep(widgetSize.height())
+ self.horizontalScrollBar().setPageStep(widgetSize.width())
+ self.verticalScrollBar().setRange(0, widgetSize.height() - areaSize.height())
+ self.horizontalScrollBar().setRange(0, widgetSize.width() - areaSize.width())
+ self.updateWidgetPosition()
+//! [1]
+
+ def resizeEvent(QResizeEvent):
+ self.updateArea()
+
+app = QApplication(sys.argv)
+pixmap = QPixmap("mypixmap.png")
+label = QLabel()
+label.setPixmap(pixmap)
+area = MyScrollArea(label)
+area.resize(300, 300)
+area.show()
+
+area.setWidget(label)
+
+app.exec_();
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/network/tcpwait.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/network/tcpwait.cpp
new file mode 100644
index 000000000..f7a0d22bf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/network/tcpwait.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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.QtGui import *
+from PySide2.QtNetwork import QTcpSocket
+
+def main():
+ app = QCoreApplication()
+
+ socket = QTcpSocket()
+ socket.connectToHost("localhost", 1025)
+
+//! [0]
+ numRead = 0
+ numReadTotal = 0
+
+ while(True):
+ buffer = socket.read(50)
+ # do whatever with array
+ numReadTotal += buffer.size()
+ if (buffer.size() == 0 && !socket.waitForReadyRead()):
+ break
+//! [0]
+ return app.exec_()
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/ntfsp.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/ntfsp.cpp
new file mode 100644
index 000000000..1b247884d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/ntfsp.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
+//! [0]
+
+//! [1]
+qt_ntfs_permission_lookup += 1 // turn checking on
+qt_ntfs_permission_lookup += 1 // turn it off again
+//! [1]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/painterpath/painterpath.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/painterpath/painterpath.cpp
new file mode 100644
index 000000000..8073744a3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/painterpath/painterpath.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QImage image(100, 100, QImage::Format_RGB32);
+
+ QPainterPath path;
+ path.addRect(20, 20, 60, 60);
+
+ path.moveTo(0, 0);
+ path.cubicTo(99, 0, 50, 50, 99, 99);
+ path.cubicTo(0, 99, 50, 50, 0, 0);
+
+ QPainter painter(&image);
+ painter.fillRect(0, 0, 100, 100, Qt::white);
+
+ painter.save();
+ painter.translate(0.5, 0.5);
+ painter.setPen(QPen(QColor(79, 106, 25), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ painter.setBrush(QColor(122, 163, 39));
+ painter.setRenderHint(QPainter::Antialiasing);
+
+ painter.drawPath(path);
+
+ painter.restore();
+ painter.end();
+
+ QLabel lab;
+ lab.setPixmap(QPixmap::fromImage(image));
+ lab.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/anyHTMLElement.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/anyHTMLElement.xq
new file mode 100644
index 000000000..9f5ee1275
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/anyHTMLElement.xq
@@ -0,0 +1 @@
+doc('data.xml')/*:body
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/anyXLinkAttribute.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/anyXLinkAttribute.xq
new file mode 100644
index 000000000..059bcc081
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/anyXLinkAttribute.xq
@@ -0,0 +1,2 @@
+declare namespace xlink = "http://www.w3.org/1999/xlink";
+doc('image.svg')//@xlink:*
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesIncluded.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesIncluded.xq
new file mode 100644
index 000000000..3961c2838
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesIncluded.xq
@@ -0,0 +1 @@
+<e>{sum((1, 2, 3))}</e>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesIncludedResult.xml b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesIncludedResult.xml
new file mode 100644
index 000000000..0004c7126
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesIncludedResult.xml
@@ -0,0 +1 @@
+<e>6</e>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesOmitted.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesOmitted.xq
new file mode 100644
index 000000000..ffbadd077
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesOmitted.xq
@@ -0,0 +1 @@
+<e>sum({(1, 2, 3)})</e>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesOmittedResult.xml b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesOmittedResult.xml
new file mode 100644
index 000000000..744fb8fe6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/bracesOmittedResult.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<e>sum(1 2 3)</e> \ No newline at end of file
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/computedTreeFragment.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/computedTreeFragment.xq
new file mode 100644
index 000000000..c5b93ada6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/computedTreeFragment.xq
@@ -0,0 +1,14 @@
+declare default element namespace "http://example.com/Namespace";
+declare variable $documentElementName := "doc";
+
+element {$documentElementName}
+{
+ attribute xml:base {"http://example.com/"},
+ element anotherElement
+ {
+ comment {" a comment "},
+ processing-instruction target {"data"},
+ element anotherElement {()},
+ text {"some text"}
+ }
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/copyAttribute.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/copyAttribute.xq
new file mode 100644
index 000000000..40e44942c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/copyAttribute.xq
@@ -0,0 +1,9 @@
+<html>
+ <body>
+ <p>
+ {
+ doc('feed.rss')/rss/@version
+ }
+ </p>
+ </body>
+</html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/copyID.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/copyID.xq
new file mode 100644
index 000000000..2409cafe6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/copyID.xq
@@ -0,0 +1,3 @@
+(: Copy the value of xml:id attribute from other.html. This is a comment by the way! :)
+<html xmlns="http://www.w3.org/1999/xhtml/"
+ xml:id="{doc("other.html")/html/@xml:id}"/>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/directTreeFragment.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/directTreeFragment.xq
new file mode 100644
index 000000000..96bc963b4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/directTreeFragment.xq
@@ -0,0 +1,7 @@
+<doc xmlns="http://example.com/Namespace" xml:base="http://example.com/">
+
+ <!-- a comment -->
+ <?target data?>
+ <anotherElement/>
+ some text
+</doc>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/doc.txt b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/doc.txt
new file mode 100644
index 000000000..d30b057b2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/doc.txt
@@ -0,0 +1,35 @@
+<doc>
+ <p>
+ <span>1</span>
+ <span>2</span>
+ </p>
+ <p>
+ <span>3</span>
+ <span>4</span>
+ </p>
+ <p>
+ <span>5</span>
+ <span>6</span>
+ </p>
+ <p>
+ <span>7</span>
+ <span>8</span>
+ </p>
+ <p>
+ <span>9</span>
+ <span>a</span>
+ </p>
+ <p>
+ <span>b</span>
+ <span>c</span>
+ </p>
+ <p>
+ <span>d</span>
+ <span>e</span>
+ </p>
+ <p>
+ <span>f</span>
+ <span>0</span>
+ </p>
+</doc>
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML.xq
new file mode 100644
index 000000000..622bec891
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML.xq
@@ -0,0 +1 @@
+doc("myPlainHTML.html")/body
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML2.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML2.xq
new file mode 100644
index 000000000..5e7fbaedc
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/docPlainHTML2.xq
@@ -0,0 +1 @@
+doc("myPlainHTML.html")/html/body
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML.xq
new file mode 100644
index 000000000..b513922a3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML.xq
@@ -0,0 +1,10 @@
+declare default element namespace "http://www.w3.org/1999/xhtml";
+<html>
+ <body>
+ {
+ for $i in doc("testResult.xml")/tests/test[@status = "failure"]
+ order by $i/@name
+ return <p>{$i/@name}</p>
+ }
+ </body>
+</html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML2.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML2.xq
new file mode 100644
index 000000000..754ddba87
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/embedDataInXHTML2.xq
@@ -0,0 +1,10 @@
+declare namespace x = "http://www.w3.org/1998/xhtml";
+<x:html>
+ <x:body>
+ {
+ for $i in doc("testResult.xml")/tests/test[@status = "failure"]
+ order by $i/@name
+ return <x:p>{$i/@name}</x:p>
+ }
+ </x:body>
+</x:html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/emptyParagraphs.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/emptyParagraphs.xq
new file mode 100644
index 000000000..6024d28a8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/emptyParagraphs.xq
@@ -0,0 +1 @@
+doc('index.html')//p[string-length(.) = 0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeCurlyBraces.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeCurlyBraces.xq
new file mode 100644
index 000000000..669e7c197
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeCurlyBraces.xq
@@ -0,0 +1,4 @@
+<doc>
+ This is one left followed by one right curly brace: {{ }}
+ Here they are again, but with character references: &#x7B; &#x7D;
+</doc>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xml b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xml
new file mode 100644
index 000000000..425ccb075
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xml
@@ -0,0 +1,2 @@
+<p>"I hate quotations" -- Ralph Waldo Emerson"
+ '"I hate quotations"" -- Ralph Waldo Emerson"', appeared above</p> \ No newline at end of file
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xq
new file mode 100644
index 000000000..4a6054ba6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/escapeStringLiterals.xq
@@ -0,0 +1,7 @@
+<p>
+{
+ """I hate quotations"" -- Ralph Waldo Emerson""",
+ "&#xA;",
+ '''"I hate quotations"" -- Ralph Waldo Emerson"'', appeared above'
+}
+</p>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/expressionInsideAttribute.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/expressionInsideAttribute.xq
new file mode 100644
index 000000000..97f46b1c4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/expressionInsideAttribute.xq
@@ -0,0 +1,2 @@
+declare variable $additionalClass := "example";
+<p class="important {$additionalClass} obsolete"/>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/filterOnPath.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/filterOnPath.xq
new file mode 100644
index 000000000..d23dfe8c7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/filterOnPath.xq
@@ -0,0 +1,2 @@
+let $doc := doc('doc.txt')
+return ($doc/doc/p/span)[1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/filterOnStep.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/filterOnStep.xq
new file mode 100644
index 000000000..46b77fa3c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/filterOnStep.xq
@@ -0,0 +1,2 @@
+let $doc := doc('doc.txt')
+return $doc/doc/p/span[1] \ No newline at end of file
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/firstParagraph.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/firstParagraph.xq
new file mode 100644
index 000000000..db5e2c720
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/firstParagraph.xq
@@ -0,0 +1 @@
+doc("index.html")/html/body/p[@xml:id = "thatSpecialOne"]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/fnStringOnAttribute.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/fnStringOnAttribute.xq
new file mode 100644
index 000000000..b26e9f2f4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/fnStringOnAttribute.xq
@@ -0,0 +1,9 @@
+<html>
+ <body>
+ <p>
+ {
+ string(doc('feed.rss')/rss/@version)
+ }
+ </p>
+ </body>
+</html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClause.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClause.xq
new file mode 100644
index 000000000..a412dca47
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClause.xq
@@ -0,0 +1,3 @@
+for $i in(reverse(1 to 10)),
+ $d in xs:integer(doc("numbers.xml")/numbers/number)
+return ($i + $d)
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClause2.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClause2.xq
new file mode 100644
index 000000000..4fa505d53
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClause2.xq
@@ -0,0 +1,3 @@
+for $i in(reverse(1 to 10)),
+ $d in xs:integer(doc("numbers.xml")/numbers/number)
+return $i + $d
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClauseOnFeed.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClauseOnFeed.xq
new file mode 100644
index 000000000..9ec33397b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/forClauseOnFeed.xq
@@ -0,0 +1,6 @@
+for $item in doc('feed.rss')//item
+return <p>
+ {
+ $item/description/node()
+ }
+ </p>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/indented.xml b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/indented.xml
new file mode 100644
index 000000000..a312c63f2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/indented.xml
@@ -0,0 +1,5 @@
+<a>
+ <b/>
+ <c/>
+ <p>Some Text</p>
+</a>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introAcneRemover.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introAcneRemover.xq
new file mode 100644
index 000000000..4e6ee8044
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introAcneRemover.xq
@@ -0,0 +1,8 @@
+<result>
+ <para>The following skin care products have shipped, ordered by shipping date(oldest first):</para>
+ {
+ for $i in doc("myOrders.xml")/orders/order[@product = "Acme Skin Care"]
+ order by xs:date($i/@shippingDate) descending
+ return $i
+ }
+</result>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introExample2.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introExample2.xq
new file mode 100644
index 000000000..411cc171f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introExample2.xq
@@ -0,0 +1,5 @@
+<bibliography>
+{
+ doc($file)/bib/book[publisher = $publisher and @year > $year]/<book year="{@year}">{title}</book>
+}
+</bibliography>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introFileHierarchy.xml b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introFileHierarchy.xml
new file mode 100644
index 000000000..cfa6151ce
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introFileHierarchy.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<directory name="home">
+
+ <file name="myNote.txt" mimetype="text/plain" size="8" extension="txt" uri="file:///home/frans/myNote.txt">
+ <content asBase64Binary="TXkgTm90ZSE=" asStringFromUTF-8="My Note!"/>
+ </file>
+
+ <directory name="src">
+ ...
+ </directory>
+
+ ...
+
+</directory>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introNavigateFS.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introNavigateFS.xq
new file mode 100644
index 000000000..1f5a3a73e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introNavigateFS.xq
@@ -0,0 +1,12 @@
+declare variable $myRoot := <e/>; (: This line is a dummy and shouldn't appear in the documentation. :)
+<html>
+ <body>
+ {
+ $myRoot//file[@mimetype = 'text/xml' or @mimetype = 'application/xml']
+ /
+ (if(doc-available(@uri))
+ then ()
+ else <p>Failed to parse file {@uri}.</p>)
+ }
+ </body>
+</html>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introductionExample.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introductionExample.xq
new file mode 100644
index 000000000..1a309dd7f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/introductionExample.xq
@@ -0,0 +1,3 @@
+<bibliography>
+{doc("library.xml")/bib/book[publisher="Addison-Wesley" and @year>1991]/<book year="{@year}">{title}</book>}
+</bibliography>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/invalidLetOrderBy.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/invalidLetOrderBy.xq
new file mode 100644
index 000000000..d65f24066
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/invalidLetOrderBy.xq
@@ -0,0 +1,3 @@
+let $i := (2, 3, 1)
+order by $i[1]
+return $i
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/items.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/items.xq
new file mode 100644
index 000000000..0b46ec14e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/items.xq
@@ -0,0 +1,5 @@
+<aNode/>,
+xs:base64Binary("FFFF"),
+current-date(),
+3e3, (: A floating point value :)
+attribute {"name"} {()}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/letOrderBy.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/letOrderBy.xq
new file mode 100644
index 000000000..f4106d280
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/letOrderBy.xq
@@ -0,0 +1,4 @@
+for $a in (8, -4, 2)
+let $b := ($a * -1, $a)
+order by $a
+return $b
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/literalsAndOperators.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/literalsAndOperators.xq
new file mode 100644
index 000000000..ec4af33ba
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/literalsAndOperators.xq
@@ -0,0 +1,2 @@
+declare variable $date := fn:current-date(); (: This line should not be part of the example. It exists in order to make the query valid. :)
+fn:current-date() - $date > xs:dayTimeDuration("P365D")
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/mobeyDick.xml b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/mobeyDick.xml
new file mode 100644
index 000000000..32d0b6cae
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/mobeyDick.xml
@@ -0,0 +1,4 @@
+<book xmlns:dc='http://purl.org/dc/elements/1.1'
+ xmlns='http://example.com/MyDefault'>
+ <dc:title>Mobey Dick</dc:title> ...
+</book>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nextLastParagraph.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nextLastParagraph.xq
new file mode 100644
index 000000000..9424f792b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nextLastParagraph.xq
@@ -0,0 +1 @@
+doc('index.html')//p[last() - 1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsAreExpressions.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsAreExpressions.xq
new file mode 100644
index 000000000..ce36e843a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsAreExpressions.xq
@@ -0,0 +1,4 @@
+let $docURI := 'maybeNotWellformed.xml'
+return if(doc-available($docURI))
+ then doc($docURI)//p/<para>{./node()}</para>
+ else <para>Failed to load {$docURI}</para>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsInPaths.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsInPaths.xq
new file mode 100644
index 000000000..beb294fba
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeConstructorsInPaths.xq
@@ -0,0 +1 @@
+doc('feed.rss')//item/<p>{description/node()}</p>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeTestChildElement.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeTestChildElement.xq
new file mode 100644
index 000000000..7aa7b3437
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/nodeTestChildElement.xq
@@ -0,0 +1 @@
+doc('index.html')/descendant-or-self::element(p)/child::element(span)
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/notIndented.xml b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/notIndented.xml
new file mode 100644
index 000000000..b3321f286
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/notIndented.xml
@@ -0,0 +1 @@
+<a><b/><c/><p>Some Text</p></a>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/oneElementConstructor.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/oneElementConstructor.xq
new file mode 100644
index 000000000..b7eb615f8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/oneElementConstructor.xq
@@ -0,0 +1 @@
+<myElement/>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/paragraphsExceptTheFiveFirst.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/paragraphsExceptTheFiveFirst.xq
new file mode 100644
index 000000000..16438d188
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/paragraphsExceptTheFiveFirst.xq
@@ -0,0 +1 @@
+doc('index.html')//p[position() > 5]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/paragraphsWithTables.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/paragraphsWithTables.xq
new file mode 100644
index 000000000..dbb9fcf94
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/paragraphsWithTables.xq
@@ -0,0 +1 @@
+doc('index.html')/html/body/p[table]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/pathAB.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/pathAB.xq
new file mode 100644
index 000000000..26fd1e5dc
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/pathAB.xq
@@ -0,0 +1 @@
+doc('index.html')//p/span
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/pathsAllParagraphs.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/pathsAllParagraphs.xq
new file mode 100644
index 000000000..ba47900f9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/pathsAllParagraphs.xq
@@ -0,0 +1 @@
+doc('index.html')//p
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/simpleHTML.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/simpleHTML.xq
new file mode 100644
index 000000000..93ac31ec6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/simpleHTML.xq
@@ -0,0 +1 @@
+doc("index.html")/html/body/p[@class="example"]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/simpleXHTML.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/simpleXHTML.xq
new file mode 100644
index 000000000..fda537167
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/simpleXHTML.xq
@@ -0,0 +1,2 @@
+declare namespace x = "http://www.w3.org/1999/xhtml/";
+doc("index.html")/x:html/x:body/x:p[@class="example"]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/svgDocumentElement.xml b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/svgDocumentElement.xml
new file mode 100644
index 000000000..0c7be4e2d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/svgDocumentElement.xml
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg"/>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/tablesInParagraphs.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/tablesInParagraphs.xq
new file mode 100644
index 000000000..fc92cf003
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/tablesInParagraphs.xq
@@ -0,0 +1 @@
+doc('index.html')/html/body/p/table
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/twoSVGElements.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/twoSVGElements.xq
new file mode 100644
index 000000000..ab4fe3580
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/twoSVGElements.xq
@@ -0,0 +1,5 @@
+declare namespace s = "http://www.w3.org/2000/svg";
+declare default element namespace "http://www.w3.org/2000/svg";
+let $doc := doc('image.svg')
+return ($doc/svg,
+ $doc/s:svg)
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xmlStylesheet.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xmlStylesheet.xq
new file mode 100644
index 000000000..9e022081b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xmlStylesheet.xq
@@ -0,0 +1 @@
+<?xml-stylesheet type="test/xsl" href="formatter.xsl"?>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xsBooleanTrue.xq b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xsBooleanTrue.xq
new file mode 100644
index 000000000..897a99e4d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xsBooleanTrue.xq
@@ -0,0 +1 @@
+xs:boolean("true")
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xsvgDocumentElement.xml b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xsvgDocumentElement.xml
new file mode 100644
index 000000000..fb6a236e7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/patternist/xsvgDocumentElement.xml
@@ -0,0 +1 @@
+<x:svg xmlns:x="http://www.w3.org/2000/svg"/>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/main.cpp
new file mode 100644
index 000000000..da90be7e6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.cpp
new file mode 100644
index 000000000..6d17518fb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+#include "model.h"
+
+/*!
+ The main window constructor creates and populates a model with values
+ from a string list then displays the contents of the model using a
+ QListView widget.
+*/
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ insertAction = itemsMenu->addAction(tr("&Insert Item"));
+ removeAction = itemsMenu->addAction(tr("&Remove Item"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+ QStringList numbers;
+ numbers << tr("One") << tr("Two") << tr("Three") << tr("Four") << tr("Five")
+ << tr("Six") << tr("Seven") << tr("Eight") << tr("Nine") << tr("Ten");
+
+ model = new StringListModel(numbers);
+ QListView *view = new QListView(this);
+ view->setModel(model);
+
+ selectionModel = view->selectionModel();
+
+ connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
+ connect(selectionModel,
+ SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(updateMenus(const QModelIndex &)));
+
+ setCentralWidget(view);
+ setWindowTitle("View onto a string list model");
+}
+
+void MainWindow::insertItem()
+{
+ if (!selectionModel->currentIndex().isValid())
+ return;
+
+ QString itemText = QInputDialog::getText(this, tr("Insert Item"),
+ tr("Input text for the new item:"));
+
+ if (itemText.isNull())
+ return;
+
+ int row = selectionModel->currentIndex().row();
+
+ if (model->insertRows(row, 1))
+ model->setData(model->index(row, 0), itemText, Qt::EditRole);
+}
+
+void MainWindow::removeItem()
+{
+ if (!selectionModel->currentIndex().isValid())
+ return;
+
+ int row = selectionModel->currentIndex().row();
+
+ model->removeRows(row, 1);
+}
+
+void MainWindow::updateMenus(const QModelIndex &currentIndex)
+{
+ insertAction->setEnabled(currentIndex.isValid());
+ removeAction->setEnabled(currentIndex.isValid());
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.h
new file mode 100644
index 000000000..af4fcb202
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/mainwindow.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QModelIndex>
+
+class QAbstractItemModel;
+class QAction;
+class QItemSelectionModel;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+
+private slots:
+ void insertItem();
+ void removeItem();
+ void updateMenus(const QModelIndex &currentIndex);
+
+private:
+ QAbstractItemModel *model;
+ QAction *insertAction;
+ QAction *removeAction;
+ QItemSelectionModel *selectionModel;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/model.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/model.h
new file mode 100644
index 000000000..3d6b27970
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/persistentindexes/model.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractListModel>
+#include <QObject>
+#include <QStringList>
+
+class StringListModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ StringListModel(const QStringList &strings, QObject *parent = 0)
+ : QAbstractListModel(parent), stringList(strings) {}
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
+
+private:
+ QStringList stringList;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/picture/picture.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/picture/picture.cpp
new file mode 100644
index 000000000..1dba7c686
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/picture/picture.cpp
@@ -0,0 +1,121 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ picture = QPicture()
+ painter = QPainter()
+ painter.begin(picture) # paint in picture
+ painter.drawEllipse(10,20, 80,70) # draw an ellipse
+ painter.end() # painting done
+ picture.save("drawing.pic") # save picture
+//! [0]
+
+//! [1]
+ picture = QPicture()
+ picture.load("drawing.pic") # load picture
+ painter = QPainter()
+ painter.begin(myImage) # paint in myImage
+ painter.drawPicture(0, 0, picture) # draw the picture at (0,0)
+ painter.end() # painting done
+//! [1]
+
+//! [2]
+ list = QPicture.inputFormatList()
+ for string in list:
+ myProcessing(string)
+//! [2]
+
+//! [3]
+ list = QPicture.outputFormatList()
+ for string in list:
+ myProcessing(string)
+//! [3]
+
+//! [4]
+ iio = QPictureIO()
+ pixmap = QPixmap()
+ iio.setFileName("vegeburger.pic")
+ if iio.read(): # OK
+ picture = iio.picture()
+ painter = QPainter(pixmap)
+ painter.drawPicture(0, 0, picture)
+
+//! [4]
+
+//! [5]
+ iio = QPictureIO()
+ picture = QPicture()
+ painter = QPainter(picture)
+ painter.drawPixmap(0, 0, pixmap)
+ iio.setPicture(picture)
+ iio.setFileName("vegeburger.pic")
+ iio.setFormat("PIC")
+ if iio.write():
+ return True # returned true if written successfully
+//! [5]
+
+//! [6]
+def readSVG(picture):
+ # read the picture using the picture.ioDevice()
+
+//! [6]
+
+
+//! [7]
+def writeSVG(picture):
+ # write the picture using the picture.ioDevice()
+
+//! [7]
+
+
+//! [8]
+ # add the SVG picture handler
+ # ...
+//! [8]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/main.cpp
new file mode 100644
index 000000000..28c6cda92
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window *window = new Window;
+ window->resize(337, 343);
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/window.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/window.cpp
new file mode 100644
index 000000000..46e919112
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/window.cpp
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <math.h>
+
+#include "window.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ text = QString("Support for text rendering and layout in Qt 4 has been "
+ "redesigned around a system that allows textual content to "
+ "be represented in a more flexible way than was possible "
+ "with Qt 3. Qt 4 also provides a more convenient "
+ "programming interface for editing documents. These "
+ "improvements are made available through a reimplementation "
+ "of the existing text rendering engine, and the "
+ "introduction of several new classes. "
+ "See the relevant module overview for a detailed discussion "
+ "of this framework. The following sections provide a brief "
+ "overview of the main concepts behind Scribe.");
+
+ setWindowTitle(tr("Plain Text Layout"));
+}
+
+void Window::paintEvent(QPaintEvent *event)
+{
+//! [0]
+ QTextLayout textLayout(text, font);
+ qreal margin = 10;
+ qreal radius = qMin(width()/2.0, height()/2.0) - margin;
+ QFontMetrics fm(font);
+
+ qreal lineHeight = fm.height();
+ qreal y = 0;
+
+ textLayout.beginLayout();
+
+ while (1) {
+ // create a new line
+ QTextLine line = textLayout.createLine();
+ if (!line.isValid())
+ break;
+
+ qreal x1 = qMax(0.0, pow(pow(radius,2)-pow(radius-y,2), 0.5));
+ qreal x2 = qMax(0.0, pow(pow(radius,2)-pow(radius-(y+lineHeight),2), 0.5));
+ qreal x = qMax(x1, x2) + margin;
+ qreal lineWidth = (width() - margin) - x;
+
+ line.setLineWidth(lineWidth);
+ line.setPosition(QPointF(x, margin+y));
+ y += line.height();
+ }
+
+ textLayout.endLayout();
+
+ QPainter painter;
+ painter.begin(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.fillRect(rect(), Qt::white);
+ painter.setBrush(QBrush(Qt::black));
+ painter.setPen(QPen(Qt::black));
+ textLayout.draw(&painter, QPoint(0,0));
+
+ painter.setBrush(QBrush(QColor("#a6ce39")));
+ painter.setPen(QPen(Qt::black));
+ painter.drawEllipse(QRectF(-radius, margin, 2*radius, 2*radius));
+ painter.end();
+//! [0]
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/window.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/window.h
new file mode 100644
index 000000000..2a6352058
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/plaintextlayout/window.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QWidget>
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window(QWidget *parent = 0);
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private:
+ QFont font;
+ QString text;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/pointer/pointer.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/pointer/pointer.cpp
new file mode 100644
index 000000000..3272b742c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/pointer/pointer.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QLabel>
+#include <QPointer>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ QPointer<QLabel> label = new QLabel;
+ label->setText("&Status:");
+//! [0]
+
+//! [1]
+ if (label)
+//! [1] //! [2]
+ label->show();
+//! [2]
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/polygon/polygon.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/polygon/polygon.cpp
new file mode 100644
index 000000000..5641dbdbe
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/polygon/polygon.cpp
@@ -0,0 +1,96 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ polygon = QPolygon()
+ polygon << QPoint(10, 20) << QPoint(20, 30)
+//! [0]
+
+//! [1]
+ polygon = QPolygonF()
+ polygon << QPointF(10.4, 20.5) << QPointF(20.2, 30.2)
+//! [1]
+
+//! [2]
+ points = [ 10, 20, 30, 40 ]
+ polygon = QPolygon()
+ polygon.setPoints(2, points)
+//! [2]
+
+//! [3]
+ polygon = QPolygon()
+ polygon.setPoints(2, 10, 20, 30, 40)
+//! [3]
+
+//! [4]
+ polygon = QPolygon(1)
+ polygon[0] = QPoint(4, 5)
+ polygon.putPoints(1, 2, 6,7, 8,9)
+//! [4]
+
+//! [5]
+ polygon = QPolygon(3)
+ polygon.putPoints(0, 3, 4,5, 0,0, 8,9)
+ polygon.putPoints(1, 1, 6,7)
+//! [5]
+
+//! [6]
+ polygon1 = QPolygon()
+ polygon1.putPoints(0, 3, 1,2, 0,0, 5,6)
+ # polygon1 is now the three-point polygon(1,2, 0,0, 5,6)
+
+ polygon2 = QPolygon()
+ polygon2.putPoints(0, 3, 4,4, 5,5, 6,6)
+ # polygon2 is now (4,4, 5,5, 6,6)
+
+ polygon1.putPoints(2, 3, polygon2)
+ # polygon1 is now the five-point polygon(1,2, 0,0, 4,4, 5,5, 6,6)
+//! [6]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/main.cpp
new file mode 100644
index 000000000..990351121
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ MyWidget window;
+ window.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.cpp
new file mode 100644
index 000000000..7d5222182
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "window.h"
+
+MyWidget::MyWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ QLabel *textLabel = new QLabel(tr("Data:"), this);
+ dataLabel = new QLabel(this);
+ dataLabel->setFixedSize(200, 200);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(textLabel);
+ layout->addWidget(dataLabel);
+
+ setAcceptDrops(true);
+ setWindowTitle(tr("Drop Events"));
+}
+
+//! [0]
+void MyWidget::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasText() || event->mimeData()->hasImage())
+ event->acceptProposedAction();
+}
+//! [0]
+
+//! [1]
+void MyWidget::dropEvent(QDropEvent *event)
+{
+ if (event->mimeData()->hasText())
+ dataLabel->setText(event->mimeData()->text());
+ else if (event->mimeData()->hasImage()) {
+ QVariant imageData = event->mimeData()->imageData();
+ dataLabel->setPixmap(qvariant_cast<QPixmap>(imageData));
+ }
+ event->acceptProposedAction();
+}
+//! [1]
+
+//! [2]
+void MyWidget::mousePressEvent(QMouseEvent *event)
+{
+//! [2]
+ QString text = dataLabel->text();
+ QPixmap iconPixmap(32, 32);
+ iconPixmap.fill(qRgba(255, 0, 0, 127));
+ QImage image(100, 100, QImage::Format_RGB32);
+ image.fill(qRgb(0, 0, 255));
+
+//! [3]
+ if (event->button() == Qt::LeftButton) {
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setText(text);
+ mimeData->setImageData(image);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(iconPixmap);
+
+ Qt::DropAction dropAction = drag->exec();
+//! [3]
+ // ...
+//! [4]
+ event->accept();
+ }
+//! [4]
+ else if (event->button() == Qt::MidButton) {
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setImageData(image);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(iconPixmap);
+
+ Qt::DropAction dropAction = drag->exec();
+ // ...
+ event->accept();
+ }
+//! [5]
+}
+//! [5]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.h
new file mode 100644
index 000000000..36e766114
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/porting4-dropevents/window.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QString>
+#include <QStringList>
+#include <QWidget>
+
+class QComboBox;
+class QFrame;
+class QLabel;
+
+class MyWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ MyWidget(QWidget *parent = 0);
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+
+private:
+ QComboBox *mimeTypeCombo;
+ QFrame *dropFrame;
+ QLabel *dataLabel;
+ QString oldText;
+ QStringList oldMimeTypes;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/errors.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/errors.cpp
new file mode 100644
index 000000000..5d42297d3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/errors.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ printer = QPrinter()
+ printer.setOutputFormat(QPrinter.PdfFormat)
+ printer.setOutputFileName("/foobar/nonwritable.pdf")
+ QPainter painter
+ if painter.begin(printer): # failed to open file
+ print "failed to open file, is it writable?"
+ return 1
+
+ painter.drawText(10, 10, "Test")
+ if !printer.Page():
+ print "failed in flushing page to disk, disk full?"
+ return 1
+
+ painter.drawText(10, 10, "Test 2")
+ painter.end()
+//! [0]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/main.cpp
new file mode 100644
index 000000000..553e1d726
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include "object.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Object object;
+ QTimer timer;
+ timer.setSingleShot(true);
+ timer.connect(&timer, SIGNAL(timeout()), &object, SLOT(print()));
+ timer.start(0);
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/object.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/object.cpp
new file mode 100644
index 000000000..fdf135f45
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/object.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include "object.h"
+
+Object::Object(QObject *parent)
+ : QObject(parent)
+{
+}
+
+void Object::print()
+{
+ int numberOfPages = 10;
+ int lastPage = numberOfPages - 1;
+
+//! [0]
+ QPrinter printer(QPrinter::HighResolution);
+ printer.setOutputFileName("print.ps");
+ QPainter painter;
+ painter.begin(&printer);
+
+ for (int page = 0; page < numberOfPages; ++page) {
+
+ // Use the painter to draw on the page.
+
+ if (page != lastPage)
+ printer.newPage();
+ }
+
+ painter.end();
+//! [0]
+ qApp->quit();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/object.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/object.h
new file mode 100644
index 000000000..388001d5f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/printing-qprinter/object.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QObject>
+
+class Object : public QObject
+{
+ Q_OBJECT
+
+public:
+ Object(QObject *parent = 0);
+
+public slots:
+ void print();
+};
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/process/process.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/process/process.cpp
new file mode 100644
index 000000000..43f01f84a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/process/process.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QProcess>
+
+bool zip()
+{
+//! [0]
+ gzip = QProcess()
+ gzip.start("gzip", ["-c"])
+ if not gzip.waitForStarted():
+ return False
+
+ gzip.write("Qt rocks!")
+ gzip.closeWriteChannel()
+
+ if not gzip.waitForFinished():
+ return False
+
+ result = gzip.readAll()
+//! [0]
+
+ gzip.start("gzip", QStringList() << "-d" << "-c");
+ gzip.write(result);
+ gzip.closeWriteChannel();
+
+ if (!gzip.waitForFinished())
+ return false;
+
+ qDebug("Result: %s", gzip.readAll().data());
+ return true;
+}
+
+
+int main()
+{
+ zip();
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qabstractsliderisnippet.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qabstractsliderisnippet.cpp
new file mode 100644
index 000000000..ce32d21d3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qabstractsliderisnippet.cpp
@@ -0,0 +1,519 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+QAbstractSliderPrivate::QAbstractSliderPrivate()
+ : minimum(0), maximum(99), singleStep(1), pageStep(10),
+ value(0), position(0), pressValue(-1), tracking(true), blocktracking(false), pressed(false),
+ invertedAppearance(false), invertedControls(false),
+ orientation(Qt::Horizontal), repeatAction(QAbstractSlider::SliderNoAction)
+{
+}
+
+QAbstractSliderPrivate::~QAbstractSliderPrivate()
+{
+}
+
+oid QAbstractSlider::setRange(int min, int max)
+{
+ Q_D(QAbstractSlider);
+ int oldMin = d->minimum;
+ int oldMax = d->maximum;
+ d->minimum = min;
+ d->maximum = qMax(min, max);
+ if (oldMin != d->minimum || oldMax != d->maximum) {
+ sliderChange(SliderRangeChange);
+ emit rangeChanged(d->minimum, d->maximum);
+ setValue(d->value); // re-bound
+ }
+}
+
+
+void QAbstractSliderPrivate::setSteps(int single, int page)
+{
+ Q_Q(QAbstractSlider);
+ singleStep = qAbs(single);
+ pageStep = qAbs(page);
+ q->sliderChange(QAbstractSlider::SliderStepsChange);
+}
+
+AbstractSlider::QAbstractSlider(QWidget *parent)
+ :QWidget(*new QAbstractSliderPrivate, parent, 0)
+{
+}
+
+QAbstractSlider::QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent)
+ :QWidget(dd, parent, 0)
+{
+}
+
+QAbstractSlider::~QAbstractSlider()
+{
+}
+
+void QAbstractSlider::setOrientation(Qt::Orientation orientation)
+{
+ Q_D(QAbstractSlider);
+ if (d->orientation == orientation)
+ return;
+
+ d->orientation = orientation;
+ if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
+ QSizePolicy sp = sizePolicy();
+ sp.transpose();
+ setSizePolicy(sp);
+ setAttribute(Qt::WA_WState_OwnSizePolicy, false);
+ }
+ update();
+ updateGeometry();
+}
+
+Qt::Orientation QAbstractSlider::orientation() const
+{
+ Q_D(const QAbstractSlider);
+ return d->orientation;
+}
+
+
+void QAbstractSlider::setMinimum(int min)
+{
+ Q_D(QAbstractSlider);
+ setRange(min, qMax(d->maximum, min));
+}
+
+int QAbstractSlider::minimum() const
+{
+ Q_D(const QAbstractSlider);
+ return d->minimum;
+}
+
+
+void QAbstractSlider::setMaximum(int max)
+{
+ Q_D(QAbstractSlider);
+ setRange(qMin(d->minimum, max), max);
+}
+
+int QAbstractSlider::maximum() const
+{
+ Q_D(const QAbstractSlider);
+ return d->maximum;
+}
+
+
+
+void QAbstractSlider::setSingleStep(int step)
+{
+ Q_D(QAbstractSlider);
+ d->setSteps(step, d->pageStep);
+}
+
+int QAbstractSlider::singleStep() const
+{
+ Q_D(const QAbstractSlider);
+ return d->singleStep;
+}
+
+
+void QAbstractSlider::setPageStep(int step)
+{
+ Q_D(QAbstractSlider);
+ d->setSteps(d->singleStep, step);
+}
+
+int QAbstractSlider::pageStep() const
+{
+ Q_D(const QAbstractSlider);
+ return d->pageStep;
+}
+
+oid QAbstractSlider::setTracking(bool enable)
+{
+ Q_D(QAbstractSlider);
+ d->tracking = enable;
+}
+
+bool QAbstractSlider::hasTracking() const
+{
+ Q_D(const QAbstractSlider);
+ return d->tracking;
+}
+
+
+
+void QAbstractSlider::setSliderDown(bool down)
+{
+ Q_D(QAbstractSlider);
+ bool doEmit = d->pressed != down;
+
+ d->pressed = down;
+
+ if (doEmit) {
+ if (down)
+ emit sliderPressed();
+ else
+ emit sliderReleased();
+ }
+
+ if (!down && d->position != d->value)
+ triggerAction(SliderMove);
+}
+
+bool QAbstractSlider::isSliderDown() const
+{
+ Q_D(const QAbstractSlider);
+ return d->pressed;
+}
+
+
+void QAbstractSlider::setSliderPosition(int position)
+{
+ Q_D(QAbstractSlider);
+ position = d->bound(position);
+ if (position == d->position)
+ return;
+ d->position = position;
+ if (!d->tracking)
+ update();
+ if (d->pressed)
+ emit sliderMoved(position);
+ if (d->tracking && !d->blocktracking)
+ triggerAction(SliderMove);
+}
+
+int QAbstractSlider::sliderPosition() const
+{
+ Q_D(const QAbstractSlider);
+ return d->position;
+}
+
+
+
+int QAbstractSlider::value() const
+{
+ Q_D(const QAbstractSlider);
+ return d->value;
+}
+
+//! [0]
+void QAbstractSlider::setValue(int value)
+//! [0]
+{
+ Q_D(QAbstractSlider);
+ value = d->bound(value);
+ if (d->value == value && d->position == value)
+ return;
+ d->value = value;
+ if (d->position != value) {
+ d->position = value;
+ if (d->pressed)
+ emit sliderMoved((d->position = value));
+ }
+#ifndef QT_NO_ACCESSIBILITY
+//! [1]
+ QAccessible::updateAccessibility(this, 0, QAccessible::ValueChanged);
+//! [1]
+#endif
+ sliderChange(SliderValueChange);
+ emit valueChanged(value);
+//! [2]
+}
+//! [2]
+
+bool QAbstractSlider::invertedAppearance() const
+{
+ Q_D(const QAbstractSlider);
+ return d->invertedAppearance;
+}
+
+void QAbstractSlider::setInvertedAppearance(bool invert)
+{
+ Q_D(QAbstractSlider);
+ d->invertedAppearance = invert;
+ update();
+}
+
+
+
+bool QAbstractSlider::invertedControls() const
+{
+ Q_D(const QAbstractSlider);
+ return d->invertedControls;
+}
+
+void QAbstractSlider::setInvertedControls(bool invert)
+{
+ Q_D(QAbstractSlider);
+ d->invertedControls = invert;
+}
+
+void QAbstractSlider::triggerAction(SliderAction action)
+{
+ Q_D(QAbstractSlider);
+ d->blocktracking = true;
+ switch (action) {
+ case SliderSingleStepAdd:
+ setSliderPosition(d->value + d->singleStep);
+ break;
+ case SliderSingleStepSub:
+ setSliderPosition(d->value - d->singleStep);
+ break;
+ case SliderPageStepAdd:
+ setSliderPosition(d->value + d->pageStep);
+ break;
+ case SliderPageStepSub:
+ setSliderPosition(d->value - d->pageStep);
+ break;
+ case SliderToMinimum:
+ setSliderPosition(d->minimum);
+ break;
+ case SliderToMaximum:
+ setSliderPosition(d->maximum);
+ break;
+ case SliderMove:
+ case SliderNoAction:
+ break;
+ };
+ emit actionTriggered(action);
+ d->blocktracking = false;
+ setValue(d->position);
+}
+
+void QAbstractSlider::setRepeatAction(SliderAction action, int thresholdTime, int repeatTime)
+{
+ Q_D(QAbstractSlider);
+ if ((d->repeatAction = action) == SliderNoAction) {
+ d->repeatActionTimer.stop();
+ } else {
+ d->repeatActionTime = repeatTime;
+ d->repeatActionTimer.start(thresholdTime, this);
+ }
+}
+
+QAbstractSlider::SliderAction QAbstractSlider::repeatAction() const
+{
+ Q_D(const QAbstractSlider);
+ return d->repeatAction;
+}
+
+void QAbstractSlider::timerEvent(QTimerEvent *e)
+{
+ Q_D(QAbstractSlider);
+ if (e->timerId() == d->repeatActionTimer.timerId()) {
+ if (d->repeatActionTime) { // was threshold time, use repeat time next time
+ d->repeatActionTimer.start(d->repeatActionTime, this);
+ d->repeatActionTime = 0;
+ }
+ if (d->repeatAction == SliderPageStepAdd)
+ d->setAdjustedSliderPosition(d->value + d->pageStep);
+ else if (d->repeatAction == SliderPageStepSub)
+ d->setAdjustedSliderPosition(d->value - d->pageStep);
+ else
+ triggerAction(d->repeatAction);
+ }
+}
+
+oid QAbstractSlider::sliderChange(SliderChange)
+{
+ update();
+}
+
+
+#ifndef QT_NO_WHEELEVENT
+void QAbstractSlider::wheelEvent(QWheelEvent * e)
+{
+ Q_D(QAbstractSlider);
+ e->ignore();
+ if (e->orientation() != d->orientation && !rect().contains(e->pos()))
+ return;
+
+ static qreal offset = 0;
+ static QAbstractSlider *offset_owner = 0;
+ if (offset_owner != this){
+ offset_owner = this;
+ offset = 0;
+ }
+
+ int step = qMin(QApplication::wheelScrollLines() * d->singleStep, d->pageStep);
+ if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier))
+ step = d->pageStep;
+ offset += e->delta() * step / 120;
+ if (d->invertedControls)
+ offset = -offset;
+
+ if (qAbs(offset) < 1)
+ return;
+
+ int prevValue = d->value;
+ d->position = d->value + int(offset); // value will be updated by triggerAction()
+ triggerAction(SliderMove);
+ if (prevValue == d->value) {
+ offset = 0;
+ } else {
+ offset -= int(offset);
+ e->accept();
+ }
+}
+#endif
+void QAbstractSlider::keyPressEvent(QKeyEvent *ev)
+{
+ Q_D(QAbstractSlider);
+ SliderAction action = SliderNoAction;
+ switch (ev->key()) {
+#ifdef QT_KEYPAD_NAVIGATION
+ case Qt::Key_Select:
+ if (QApplication::keypadNavigationEnabled())
+ setEditFocus(!hasEditFocus());
+ else
+ ev->ignore();
+ break;
+ case Qt::Key_Back:
+ if (QApplication::keypadNavigationEnabled() && hasEditFocus()) {
+ setValue(d->origValue);
+ setEditFocus(false);
+ } else
+ ev->ignore();
+ break;
+#endif
+
+ // It seems we need to use invertedAppearance for Left and right, otherwise, things look weird.
+ case Qt::Key_Left:
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
+ ev->ignore();
+ return;
+ }
+ if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical)
+ action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd;
+ else
+#endif
+ action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd;
+ break;
+ case Qt::Key_Right:
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
+ ev->ignore();
+ return;
+ }
+ if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical)
+ action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub;
+ else
+#endif
+ action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub;
+ break;
+ case Qt::Key_Up:
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled()) {
+ ev->ignore();
+ break;
+ }
+#endif
+ action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd;
+ break;
+ case Qt::Key_Down:
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled()) {
+ ev->ignore();
+ break;
+ }
+#endif
+ action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub;
+ break;
+ case Qt::Key_PageUp:
+ action = d->invertedControls ? SliderPageStepSub : SliderPageStepAdd;
+ break;
+ case Qt::Key_PageDown:
+ action = d->invertedControls ? SliderPageStepAdd : SliderPageStepSub;
+ break;
+ case Qt::Key_Home:
+ action = SliderToMinimum;
+ break;
+ case Qt::Key_End:
+ action = SliderToMaximum;
+ break;
+ default:
+ ev->ignore();
+ break;
+ }
+ if (action)
+ triggerAction(action);
+}
+
+void QAbstractSlider::changeEvent(QEvent *ev)
+{
+ Q_D(QAbstractSlider);
+ switch (ev->type()) {
+ case QEvent::EnabledChange:
+ if (!isEnabled()) {
+ d->repeatActionTimer.stop();
+ setSliderDown(false);
+ }
+ // fall through...
+ default:
+ QWidget::changeEvent(ev);
+ }
+}
+
+bool QAbstractSlider::event(QEvent *e)
+{
+#ifdef QT_KEYPAD_NAVIGATION
+ Q_D(QAbstractSlider);
+ switch (e->type()) {
+ case QEvent::FocusIn:
+ d->origValue = d->value;
+ break;
+ default:
+ break;
+ }
+#endif
+
+ return QWidget::event(e);
+}
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qcalendarwidget/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qcalendarwidget/main.cpp
new file mode 100644
index 000000000..8a1751fa3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qcalendarwidget/main.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QCalendarWidget>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QCalendarWidget calendar;
+ calendar.setSelectedDate(calendar.selectedDate().addDays(3));
+ calendar.setGridVisible(true);
+ calendar.show();
+
+ QCalendarWidget calendarMin;
+ calendarMin.setMinimumDate(calendarMin.selectedDate().addDays(-7));
+ calendarMin.setGridVisible(true);
+ calendarMin.show();
+
+ QCalendarWidget calendarMax;
+ calendarMax.setMaximumDate(calendarMax.selectedDate().addDays(7));
+ calendarMax.setGridVisible(true);
+ calendarMax.show();
+
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qcolumnview/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qcolumnview/main.cpp
new file mode 100644
index 000000000..de61bd13c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qcolumnview/main.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QStandardItemModel model;
+
+ QStandardItem *name = new QStandardItem("Name");
+ QStandardItem *firstName = new QStandardItem("First Name");
+ QStandardItem *lastName = new QStandardItem("Last Name");
+
+ name->appendRow(firstName);
+ name->appendRow(lastName);
+ model.appendRow(name);
+
+ QStandardItem *john = new QStandardItem("John");
+ QStandardItem *smith = new QStandardItem("Smith");
+
+ firstName->appendRow(john);
+ lastName->appendRow(smith);
+
+ QStandardItem *address = new QStandardItem("Address");
+ QStandardItem *street = new QStandardItem("Street");
+ QStandardItem *city = new QStandardItem("City");
+ QStandardItem *state = new QStandardItem("State");
+ QStandardItem *country = new QStandardItem("Country");
+
+ address->appendRow(street);
+ address->appendRow(city);
+ address->appendRow(state);
+ address->appendRow(country);
+ model.appendRow(address);
+
+ QColumnView columnView;
+ columnView.setModel(&model);
+ columnView.show();
+
+ return app.exec();
+} \ No newline at end of file
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qdebug/qdebugsnippet.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qdebug/qdebugsnippet.cpp
new file mode 100644
index 000000000..e4ab7c75c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qdebug/qdebugsnippet.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QtDebug>
+
+class Coordinate : public QObject
+{
+public:
+ int myX, myY;
+
+ int x() const { return myX; };
+ int y() const { return myY; };
+};
+
+//! [0]
+QDebug operator<<(QDebug dbg, const Coordinate &c)
+{
+ dbg.nospace() << "(" << c.x() << ", " << c.y() << ")";
+
+ return dbg.space();
+}
+//! [0]
+
+int main(int argv, char **args)
+{
+ Coordinate coordinate;
+ coordinate.myX = 10;
+ coordinate.myY = 44;
+
+//! [1]
+ qDebug() << "Date:" << QDate::currentDate();
+ qDebug() << "Types:" << QString("String") << QChar('x') << QRect(0, 10, 50, 40);
+ qDebug() << "Custom coordinate type:" << coordinate;
+//! [1]
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-filepaths/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-filepaths/main.cpp
new file mode 100644
index 000000000..75c1fbd99
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-filepaths/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QDir>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+ QDir directory("Documents/Letters");
+ QString path = directory.filePath("contents.txt");
+ QString absolutePath = directory.absoluteFilePath("contents.txt");
+
+ std::cout << qPrintable(directory.dirName()) << std::endl;
+ std::cout << qPrintable(path) << std::endl;
+ std::cout << qPrintable(absolutePath) << std::endl;
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-listfiles/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-listfiles/main.cpp
new file mode 100644
index 000000000..99f8896b3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-listfiles/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+
+from PySide2.QtCore import QDir, QCoreApplication
+import sys
+
+app = QCoreApplication(sys.argv)
+directory = QDir()
+directory.setFilter(QDir.Files | QDir.Hidden | QDir.NoSymLinks)
+directory.setSorting(QDir.Size | QDir.Reversed)
+
+for entry in directory.entryInfoList():
+ print "%s %s" % (entry.size(), entry.fileName())
+
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-namefilters/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-namefilters/main.cpp
new file mode 100644
index 000000000..dc459c8b8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qdir-namefilters/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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 *
+
+def main():
+ dir_ = QDir()
+ dir_.setFilter(QDir.Files | QDir.Hidden | QDir.NoSymLinks)
+ dir_.setSorting(QDir.Size | QDir.Reversed)
+
+//! [0]
+ filters = ["*.cpp", "*.cxx", "*.cc"]
+ dir_.setNameFilters(filters)
+//! [0]
+//
+ lst = d.entryInfoList()
+
+ print " Bytes Filename"
+ for fileInfo in lst:
+ print '%d %s' % (fileInfo.size(), fileInfo.fileName())
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qelapsedtimer/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qelapsedtimer/main.cpp
new file mode 100644
index 000000000..51f3f59dd
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qelapsedtimer/main.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+#include <QtCore>
+
+void slowOperation1()
+{
+ static char buf[256];
+ for (int i = 0; i < (1<<20); ++i)
+ buf[i % sizeof buf] = i;
+}
+
+void slowOperation2(int) { slowOperation1(); }
+
+void startExample()
+{
+//![0]
+ timer = QElapsedTimer()
+ timer.start()
+
+ slowOperation1()
+
+ sys.stderr.write("The slow operation took" + timer.elapsed() + "milliseconds")
+//![0]
+}
+
+//![1]
+def executeSlowOperations(timeout):
+ timer = QElapsedTimer()
+ timer.start()
+ slowOperation1()
+
+ remainingTime = timeout - timer.elapsed()
+ if remainingTime > 0:
+ slowOperation2(remainingTime)
+//![1]
+
+//![2]
+def executeOperationsForTime(ms):
+ timer = QElapsedTimer()
+ timer.start()
+
+ while not timer.hasExpired(ms):
+ slowOperation1()
+//![2]
+
+int restartExample()
+{
+//![3]
+ timer = QElapsedTimer()
+
+ count = 1
+ timer.start()
+
+ while True:
+ count *= 2
+ slowOperation2(count)
+ if timer.restart() < 250:
+ break
+
+ return count
+//![3]
+}
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ startExample();
+ restartExample();
+ executeSlowOperations(5);
+ executeOperationsForTime(5);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qfontdatabase/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qfontdatabase/main.cpp
new file mode 100644
index 000000000..a7abf4584
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qfontdatabase/main.cpp
@@ -0,0 +1,74 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ database = QFontDatabase()
+ fontTree = QTreeWidget()
+ fontTree.setColumnCount(2)
+ fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes")
+
+ for family in database.families():
+ familyItem = QTreeWidgetItem(fontTree)
+ familyItem.setText(0, family)
+
+ for style in database.styles(family):
+ styleItem = QTreeWidgetItem(familyItem)
+ styleItem.setText(0, style)
+
+ sizes = 0
+ for points in database.smoothSizes(family, style):
+ sizes += QString.number(points) + " "
+
+ styleItem.setText(1, sizes.trimmed())
+
+//! [0] //! [1]
+
+//! [1]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qgl-namespace/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qgl-namespace/main.cpp
new file mode 100644
index 000000000..db5d00fbf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qgl-namespace/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QGL>
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlabel/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlabel/main.cpp
new file mode 100644
index 000000000..d8d2c9897
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlabel/main.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+class Updater : public QObject
+{
+ Q_OBJECT
+
+public:
+ Updater(QWidget *widget);
+
+public slots:
+ void adjustSize();
+
+private:
+ QWidget *widget;
+};
+
+Updater::Updater(QWidget *widget)
+ : widget(widget)
+{
+}
+
+void Updater::adjustSize()
+{
+ widget->adjustSize();
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QLabel *label = new QLabel("My label");
+ QLineEdit *editor = new QLineEdit("New text");
+ QWidget window;
+ //Updater updater(&label);
+ QObject::connect(editor, SIGNAL(textChanged(const QString &)),
+ label, SLOT(setText(const QString &)));
+ //QObject::connect(editor, SIGNAL(textChanged(const QString &)),
+ // &updater, SLOT(adjustSize()));
+ //editor.show();
+ //label.show();
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(label);
+ layout->addWidget(editor);
+ window.setLayout(layout);
+ window.show();
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/main.cpp
new file mode 100644
index 000000000..b646ceaff
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include "paintwidget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ PaintWidget window;
+ window.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.cpp
new file mode 100644
index 000000000..ce83d0daa
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include "paintwidget.h"
+
+PaintWidget::PaintWidget(QWidget *parent)
+ : QWidget(parent)
+{
+}
+
+void PaintWidget::paintEvent(QPaintEvent *event)
+{
+ QLinearGradient gradient1(rect().topLeft(), rect().bottomRight());
+ gradient1.setColorAt(0, QColor("#ffffcc"));
+ gradient1.setColorAt(1, QColor("#ccccff"));
+
+ QRectF ellipseRect(width()*0.25, height()*0.25, width()*0.5, height()*0.5);
+ QLinearGradient gradient2(ellipseRect.topLeft(), ellipseRect.bottomRight());
+ gradient2.setColorAt(0, QColor("#ccccff"));
+ gradient2.setColorAt(1, QColor("#ffffcc"));
+
+ QPainter painter;
+ painter.begin(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.fillRect(rect(), QBrush(gradient1));
+ painter.setBrush(QBrush(gradient2));
+ painter.drawEllipse(ellipseRect);
+ painter.end();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.h
new file mode 100644
index 000000000..dbcd38211
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlineargradient/paintwidget.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef PAINTWIDGET_H
+#define PAINTWIDGET_H
+
+#include <QWidget>
+
+class QPaintEvent;
+
+class PaintWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ PaintWidget(QWidget *parent = 0);
+
+protected:
+ void paintEvent(QPaintEvent *event);
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/main.cpp
new file mode 100644
index 000000000..08343ac18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.cpp
new file mode 100644
index 000000000..f26f42eca
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+#include "model.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ menuBar()->addMenu(fileMenu);
+
+// For convenient quoting:
+//! [0]
+QListView *listView = new QListView(this);
+listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+listView->setDragEnabled(true);
+listView->setAcceptDrops(true);
+listView->setDropIndicatorShown(true);
+//! [0]
+
+ this->listView = listView;
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+
+ setupListItems();
+
+ setCentralWidget(listView);
+ setWindowTitle(tr("List View"));
+}
+
+void MainWindow::setupListItems()
+{
+ QStringList items;
+ items << tr("Oak") << tr("Fir") << tr("Pine") << tr("Birch") << tr("Hazel")
+ << tr("Redwood") << tr("Sycamore") << tr("Chestnut")
+ << tr("Mahogany");
+
+ DragDropListModel *model = new DragDropListModel(items, this);
+ listView->setModel(model);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.h
new file mode 100644
index 000000000..eddbe0ab8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/mainwindow.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QListView;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+private:
+ void setupListItems();
+
+ QListView *listView;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.cpp
new file mode 100644
index 000000000..d2ea654d8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.cpp
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ A simple model that uses a QStringList as its data source.
+*/
+
+#include <QtWidgets>
+
+#include "model.h"
+
+DragDropListModel::DragDropListModel(const QStringList &strings,
+ QObject *parent)
+ : QStringListModel(strings, parent)
+{
+}
+
+//! [0]
+bool DragDropListModel::dropMimeData(const QMimeData *data,
+ Qt::DropAction action, int row, int column, const QModelIndex &parent)
+{
+ if (action == Qt::IgnoreAction)
+ return true;
+
+ if (!data->hasFormat("application/vnd.text.list"))
+ return false;
+
+ if (column > 0)
+//! [0] //! [1]
+ return false;
+//! [1]
+
+//! [2]
+ int beginRow;
+
+ if (row != -1)
+ beginRow = row;
+//! [2] //! [3]
+ else if (parent.isValid())
+ beginRow = parent.row();
+//! [3] //! [4]
+ else
+ beginRow = rowCount(QModelIndex());
+//! [4]
+
+//! [5]
+ QByteArray encodedData = data->data("application/vnd.text.list");
+ QDataStream stream(&encodedData, QIODevice::ReadOnly);
+ QStringList newItems;
+ int rows = 0;
+
+ while (!stream.atEnd()) {
+ QString text;
+ stream >> text;
+ newItems << text;
+ ++rows;
+ }
+//! [5]
+
+//! [6]
+ insertRows(beginRow, rows, QModelIndex());
+ foreach (QString text, newItems) {
+ QModelIndex idx = index(beginRow, 0, QModelIndex());
+ setData(idx, text);
+ beginRow++;
+ }
+
+ return true;
+}
+//! [6]
+
+//! [7]
+Qt::ItemFlags DragDropListModel::flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags defaultFlags = QStringListModel::flags(index);
+
+ if (index.isValid())
+ return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
+ else
+ return Qt::ItemIsDropEnabled | defaultFlags;
+}
+//! [7]
+
+//! [8]
+def mimeData(self, indexes):
+ mimeData = QMimeData()
+ encodedData = QByteArray()
+ stream = QDataStream(encodedData, QIODevice.WriteOnly)
+
+ for index in indexes:
+ if index.isValid():
+ stream << data(index, Qt.DisplayRole)
+
+ mimeData.setData("application/vnd.text.list", encodedData)
+ return mimeData;
+//! [8]
+
+//! [9]
+QStringList DragDropListModel::mimeTypes() const
+{
+ QStringList types;
+ types << "application/vnd.text.list";
+ return types;
+}
+//! [9]
+
+//! [10]
+Qt::DropActions DragDropListModel::supportedDropActions() const
+{
+ return Qt::CopyAction | Qt::MoveAction;
+}
+//! [10]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.h
new file mode 100644
index 000000000..cde8c5800
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-dnd/model.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QObject>
+#include <QStringListModel>
+
+class DragDropListModel : public QStringListModel
+{
+ Q_OBJECT
+
+public:
+ DragDropListModel(const QStringList &strings, QObject *parent = 0);
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+ QMimeData *mimeData(const QModelIndexList &indexes) const;
+ QStringList mimeTypes() const;
+ Qt::DropActions supportedDropActions() const;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/main.cpp
new file mode 100644
index 000000000..08343ac18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.cpp
new file mode 100644
index 000000000..9927e4594
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+#include "model.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ insertAction = itemsMenu->addAction(tr("&Insert Item"));
+ removeAction = itemsMenu->addAction(tr("&Remove Item"));
+ QAction *ascendingAction = itemsMenu->addAction(tr("Sort in &Ascending Order"));
+ QAction *descendingAction = itemsMenu->addAction(tr("Sort in &Descending Order"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+ QStringList strings;
+ strings << tr("Oak") << tr("Fir") << tr("Pine") << tr("Birch")
+ << tr("Hazel") << tr("Redwood") << tr("Sycamore") << tr("Chestnut");
+ model = new StringListModel(strings, this);
+/* For convenient quoting:
+ QListView *listView = new QListView(this);
+*/
+ listView = new QListView(this);
+ listView->setModel(model);
+ listView->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
+ connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
+ connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
+ connect(listView->selectionModel(),
+ SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(updateMenus(const QModelIndex &)));
+
+ updateMenus(listView->selectionModel()->currentIndex());
+
+ setCentralWidget(listView);
+ setWindowTitle(tr("List View"));
+}
+
+void MainWindow::sortAscending()
+{
+ model->sort(0, Qt::AscendingOrder);
+}
+
+void MainWindow::sortDescending()
+{
+ model->sort(0, Qt::DescendingOrder);
+}
+
+void MainWindow::insertItem()
+{
+ QModelIndex currentIndex = listView->currentIndex();
+ if (!currentIndex.isValid())
+ return;
+
+ QString itemText = QInputDialog::getText(this, tr("Insert Item"),
+ tr("Input text for the new item:"));
+
+ if (itemText.isNull())
+ return;
+
+ if (model->insertRow(currentIndex.row(), QModelIndex())) {
+ QModelIndex newIndex = model->index(currentIndex.row(), 0, QModelIndex());
+ model->setData(newIndex, itemText, Qt::EditRole);
+
+ QString toolTipText = tr("Tooltip:") + itemText;
+ QString statusTipText = tr("Status tip:") + itemText;
+ QString whatsThisText = tr("What's This?:") + itemText;
+ model->setData(newIndex, toolTipText, Qt::ToolTipRole);
+ model->setData(newIndex, toolTipText, Qt::StatusTipRole);
+ model->setData(newIndex, whatsThisText, Qt::WhatsThisRole);
+ }
+}
+
+void MainWindow::removeItem()
+{
+ QModelIndex currentIndex = listView->currentIndex();
+ if (!currentIndex.isValid())
+ return;
+
+ model->removeRow(currentIndex.row(), QModelIndex());
+}
+
+void MainWindow::updateMenus(const QModelIndex &current)
+{
+ insertAction->setEnabled(current.isValid());
+ removeAction->setEnabled(current.isValid());
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.h
new file mode 100644
index 000000000..936f30856
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/mainwindow.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+#include <QModelIndex>
+
+class QAction;
+class QListView;
+class StringListModel;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void insertItem();
+ void removeItem();
+ void sortAscending();
+ void sortDescending();
+ void updateMenus(const QModelIndex &current);
+
+private:
+ QAction *insertAction;
+ QAction *removeAction;
+ QListView *listView;
+ StringListModel *model;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/model.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/model.h
new file mode 100644
index 000000000..215443270
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistview-using/model.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractListModel>
+#include <QObject>
+#include <QStringList>
+
+class StringListModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ StringListModel(const QStringList &strings, QObject *parent = 0)
+ : QAbstractListModel(parent), stringList(strings) {}
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
+
+private:
+ QStringList stringList;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/main.cpp
new file mode 100644
index 000000000..08343ac18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.cpp
new file mode 100644
index 000000000..806f3ce9b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ menuBar()->addMenu(fileMenu);
+
+// For convenient quoting:
+//! [0]
+QListWidget *listWidget = new QListWidget(this);
+listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+listWidget->setDragEnabled(true);
+listWidget->viewport()->setAcceptDrops(true);
+listWidget->setDropIndicatorShown(true);
+//! [0] //! [1]
+listWidget->setDragDropMode(QAbstractItemView::InternalMove);
+//! [1]
+
+ this->listWidget = listWidget;
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+
+ setupListItems();
+
+ setCentralWidget(listWidget);
+ setWindowTitle(tr("List Widget"));
+}
+
+void MainWindow::setupListItems()
+{
+ QListWidgetItem *item;
+ item = new QListWidgetItem(tr("Oak"), listWidget);
+ item = new QListWidgetItem(tr("Fir"), listWidget);
+ item = new QListWidgetItem(tr("Pine"), listWidget);
+ item = new QListWidgetItem(tr("Birch"), listWidget);
+ item = new QListWidgetItem(tr("Hazel"), listWidget);
+ item = new QListWidgetItem(tr("Redwood"), listWidget);
+ item = new QListWidgetItem(tr("Sycamore"), listWidget);
+ item = new QListWidgetItem(tr("Chestnut"), listWidget);
+ item = new QListWidgetItem(tr("Mahogany"), listWidget);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.h
new file mode 100644
index 000000000..79ed14699
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-dnd/mainwindow.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QListWidget;
+class QListWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+private:
+ void setupListItems();
+
+ QListWidget *listWidget;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/main.cpp
new file mode 100644
index 000000000..08343ac18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.cpp
new file mode 100644
index 000000000..659cfbb98
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.cpp
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ insertAction = itemsMenu->addAction(tr("&Insert Item"));
+ removeAction = itemsMenu->addAction(tr("&Remove Item"));
+ QAction *ascendingAction = itemsMenu->addAction(tr("Sort in &Ascending Order"));
+ QAction *descendingAction = itemsMenu->addAction(tr("Sort in &Descending Order"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+/* For convenient quoting:
+//! [0]
+ listWidget = QListWidget(self)
+//! [0]
+*/
+ listWidget = new QListWidget(this);
+ listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
+ connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
+ connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
+ connect(listWidget,
+ SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
+ this, SLOT(updateMenus(QListWidgetItem *)));
+
+ setupListItems();
+ updateMenus(listWidget->currentItem());
+
+ setCentralWidget(listWidget);
+ setWindowTitle(tr("List Widget"));
+}
+
+void MainWindow::setupListItems()
+{
+//! [1]
+ QListWidgetItem(tr("Oak"), listWidget)
+ QListWidgetItem(tr("Fir"), listWidget)
+ QListWidgetItem(tr("Pine"), listWidget)
+//! [1]
+ new QListWidgetItem(tr("Birch"), listWidget);
+//! [2]
+ QListWidgetItem(tr("Hazel"), listWidget)
+//! [2]
+ new QListWidgetItem(tr("Redwood"), listWidget);
+//! [3]
+ QListWidgetItem(tr("Sycamore"), listWidget)
+ QListWidgetItem(tr("Chestnut"), listWidget)
+ QListWidgetItem(tr("Mahogany"), listWidget)
+//! [3]
+}
+
+void MainWindow::sortAscending()
+{
+//! [4]
+ listWidget.sortItems(Qt.AscendingOrder)
+//! [4]
+}
+
+void MainWindow::sortDescending()
+{
+//! [5]
+ listWidget.sortItems(Qt.DescendingOrder)
+//! [5]
+}
+
+void MainWindow::insertItem()
+{
+ if (!listWidget->currentItem())
+ return;
+
+ QString itemText = QInputDialog::getText(this, tr("Insert Item"),
+ tr("Input text for the new item:"));
+
+ if (itemText.isNull())
+ return;
+
+//! [6]
+ newItem = QListWidgetItem()
+ newItem.setText(itemText)
+//! [6]
+ int row = listWidget->row(listWidget->currentItem());
+//! [7]
+ listWidget.insertItem(row, newItem)
+//! [7]
+
+ QString toolTipText = tr("Tooltip:") + itemText;
+ QString statusTipText = tr("Status tip:") + itemText;
+ QString whatsThisText = tr("What's This?:") + itemText;
+//! [8]
+ newItem.setToolTip(toolTipText)
+ newItem.setStatusTip(toolTipText)
+ newItem.setWhatsThis(whatsThisText)
+//! [8]
+}
+
+void MainWindow::removeItem()
+{
+ listWidget->takeItem(listWidget->row(listWidget->currentItem()));
+}
+
+void MainWindow::updateMenus(QListWidgetItem *current)
+{
+ insertAction->setEnabled(current != 0);
+ removeAction->setEnabled(current != 0);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.h
new file mode 100644
index 000000000..344a429f0
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qlistwidget-using/mainwindow.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QListWidget;
+class QListWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void insertItem();
+ void removeItem();
+ void sortAscending();
+ void sortDescending();
+ void updateMenus(QListWidgetItem *current);
+
+private:
+ void setupListItems();
+
+ QAction *insertAction;
+ QAction *removeAction;
+ QListWidget *listWidget;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qmacnativewidget/main.mm b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmacnativewidget/main.mm
new file mode 100644
index 000000000..36d6927ee
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmacnativewidget/main.mm
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtGui/QtGui>
+#include <QtGui/qmacnativewidget_mac.h>
+#ifdef QT_MAC_USE_COCOA
+#import <Cocoa/Cocoa.h>
+#else
+#include <Carbon/Carbon.h>
+#endif
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+#ifdef QT_MAC_USE_COCOA
+//![0]
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(200, app.desktop()->height() - 200, 239, 200)
+ styleMask:NSTitledWindowMask | NSClosableWindowMask
+ | NSMiniaturizableWindowMask | NSResizableWindowMask
+ backing:NSBackingStoreBuffered defer:NO];
+
+ QMacNativeWidget *nativeWidget = new QMacNativeWidget();
+ nativeWidget->move(0, 0);
+ nativeWidget->setPalette(QPalette(Qt::red));
+ nativeWidget->setAutoFillBackground(true);
+ QVBoxLayout *layout = new QVBoxLayout();
+ QPushButton *pushButton = new QPushButton("An Embedded Qt Button!", nativeWidget);
+ pushButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // Don't use the layout rect calculated from QMacStyle.
+ layout->addWidget(pushButton);
+ nativeWidget->setLayout(layout);
+
+ // Adjust Cocoa layouts
+ NSView *nativeWidgetView = reinterpret_cast<NSView *>(nativeWidget->winId());
+ NSView *contentView = [window contentView];
+ [contentView setAutoresizesSubviews:YES];
+ [nativeWidgetView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+ [nativeWidgetView setAutoresizesSubviews:YES];
+ NSView *pushButtonView = reinterpret_cast<NSView *>(pushButton->winId());
+ [pushButtonView setAutoresizingMask:NSViewWidthSizable];
+
+ // Add the nativeWidget to the window.
+ [contentView addSubview:nativeWidgetView positioned:NSWindowAbove relativeTo:nil];
+ nativeWidget->show();
+ pushButton->show();
+
+ // Show the window.
+ [window makeKeyAndOrderFront:window];
+ [pool release];
+//![0]
+#else
+//![1]
+ Rect contentRect;
+ SetRect(&contentRect, 200, 200, 400, 400);
+ HIWindowRef windowRef;
+ CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowCompositingAttribute | kWindowStandardHandlerAttribute | kWindowLiveResizeAttribute, &contentRect, &windowRef);
+ HIViewRef contentView = 0;
+ GetRootControl(windowRef, &contentView);
+
+ QMacNativeWidget *nativeWidget = new QMacNativeWidget();
+ nativeWidget->move(0, 0);
+ nativeWidget->setPalette(QPalette(Qt::red));
+ nativeWidget->setAutoFillBackground(true);
+ QVBoxLayout *layout = new QVBoxLayout();
+ QPushButton *pushButton = new QPushButton("An Embedded Qt Button!", nativeWidget);
+ pushButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // Don't use the layout rect calculated from QMacStyle.
+ layout->addWidget(pushButton);
+ nativeWidget->setLayout(layout);
+ HIViewRef nativeWidgetView = reinterpret_cast<HIViewRef>(nativeWidget->winId());
+ // Add the nativeWidget to the window.
+ HIViewAddSubview(contentView, nativeWidgetView);
+
+ // Adjust Carbon layouts
+ HILayoutInfo layoutInfo;
+ layoutInfo.version = kHILayoutInfoVersionZero;
+ HIViewGetLayoutInfo(nativeWidgetView, &layoutInfo);
+
+ layoutInfo.binding.top.toView = contentView;
+ layoutInfo.binding.top.kind = kHILayoutBindTop;
+ layoutInfo.binding.left.toView = contentView;
+ layoutInfo.binding.left.kind = kHILayoutBindLeft;
+ layoutInfo.binding.right.toView = contentView;
+ layoutInfo.binding.right.kind = kHILayoutBindRight;
+ layoutInfo.binding.bottom.toView = contentView;
+ layoutInfo.binding.bottom.kind = kHILayoutBindBottom;
+
+ HIViewSetLayoutInfo(nativeWidgetView, &layoutInfo);
+ HIViewApplyLayout(nativeWidgetView);
+
+ pushButton->show();
+ nativeWidget->show();
+ // Show the window.
+ ShowWindow(windowRef);
+//![1]
+#endif
+ return app.exec(); // gives us the same behavior in both
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/delegate.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/delegate.h
new file mode 100644
index 000000000..68ebab9e2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/delegate.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/main.cpp
new file mode 100644
index 000000000..68ebab9e2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/model.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/model.cpp
new file mode 100644
index 000000000..68ebab9e2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/model.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/model.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/model.h
new file mode 100644
index 000000000..68ebab9e2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/model.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/paintwidget_unix.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/paintwidget_unix.cpp
new file mode 100644
index 000000000..cca4a000e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/paintwidget_unix.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/view.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/view.h
new file mode 100644
index 000000000..68ebab9e2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmake/view.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/main.cpp
new file mode 100644
index 000000000..286b53a30
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QDebug>
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window window;
+ qDebug() << window.metaObject()->methodCount();
+ window.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.cpp
new file mode 100644
index 000000000..fa6246e98
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "window.h"
+
+Window::Window()
+{
+}
+
+void Window::normalMethod()
+{
+ // Cannot be called by the meta-object system.
+ show();
+}
+
+void Window::invokableMethod()
+{
+ // Can be called by the meta-object system.
+ show();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.h
new file mode 100644
index 000000000..fe708a150
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qmetaobject-invokable/window.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QWidget>
+
+//! [Window class with invokable method]
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window();
+ void normalMethod();
+ Q_INVOKABLE void invokableMethod();
+};
+//! [Window class with invokable method]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qprocess-environment/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qprocess-environment/main.cpp
new file mode 100644
index 000000000..e1e8f4310
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qprocess-environment/main.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtCore>
+
+void startProcess()
+{
+ {
+//! [0]
+import re
+from PySide2.QtCore import QProcess
+
+process = QProcess()
+
+env = QProcess.systemEnvironment()
+env.append("TMPDIR=C:\\MyApp\\temp") # Add an environment variable
+regex = re.compile(r'^PATH=(.*)', re.IGNORECASE)
+env = [regex.sub(r'PATH=\1;C:\\Bin', var) for var in env]
+process.setEnvironment(env)
+process.start("myapp")
+//! [0]
+ }
+
+ {
+//! [1]
+process = QProcess()
+env = QProcessEnvironment.systemEnvironment()
+env.insert("TMPDIR", "C:\\MyApp\\temp") # Add an environment variable
+env.insert("PATH", env.value("Path") + ";C:\\Bin")
+process.setProcessEnvironment(env)
+process.start("myapp")
+//! [1]
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+ startProcess();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qprocess/qprocess-simpleexecution.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qprocess/qprocess-simpleexecution.cpp
new file mode 100644
index 000000000..03ce62bea
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qprocess/qprocess-simpleexecution.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QtWidgets>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [0]
+ ...
+//! [0]
+ parent = &app;
+
+//! [1]
+ program = "./path/to/Qt/examples/widgets/analogclock"
+//! [1]
+ program = "./../../../../examples/widgets/analogclock/analogclock";
+
+//! [2]
+ arguments = ["-style", "motif"]
+
+ myProcess = QProcess(parent)
+ myProcess.start(program, arguments)
+//! [2]
+
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.cpp
new file mode 100644
index 000000000..2c5496b4c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "buttonwidget.h"
+
+//! [0]
+
+def __init__(self, texts, parent):
+ QWidget.__init__(self, parent)
+
+ self.signalMapper = QSignalMapper(self)
+
+ layout = QGridLayout()
+
+ for text, index in enumerate(texts):
+ button = QPushButton(text)
+ self.connect(SIGNAL("clicked()"), self.signalMapper, SLOT("map()"))
+//! [0] //! [1]
+ self.signalMapper.setMapping(button, text)
+ layout.addWidget(button, index / 3, index % 3)
+
+ self.signalMapper.connect(SIGNAL("mapped(const QString &)"),
+//! [1] //! [2]
+ self, SLOT("clicked(const QString &)"))
+
+ self.setLayout(layout)
+
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.h
new file mode 100644
index 000000000..f2436b493
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/buttonwidget.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef BUTTONWIDGET_H
+#define BUTTONWIDGET_H
+
+#include <qwidget.h>
+
+class QSignalMapper;
+class QString;
+class QStringList;
+
+//! [0]
+
+class ButtonWidget(QWidget):
+ def __init__(self, texts, parent=None):
+ QWidget.__init__(self, parent)
+ ...
+//! [0] //! [1]
+
+//! [1]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/main.cpp
new file mode 100644
index 000000000..4ddabd59e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/main.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "buttonwidget.h"
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QStringList texts;
+ texts << "January" << "February" << "March" << "April"
+ << "May" << "June" << "July" << "August"
+ << "September" << "October" << "November"
+ << "December";
+ MainWindow *mw = new MainWindow;
+ ButtonWidget *buttons = new ButtonWidget(texts, mw);
+ mw->setCentralWidget(buttons);
+ mw->show();
+ QObject::connect(buttons, SIGNAL(clicked(const QString &)),
+ mw, SLOT(buttonPressed(const QString &)));
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/mainwindow.h
new file mode 100644
index 000000000..8274b8f7b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsignalmapper/mainwindow.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QMainWindow>
+#include <QStatusBar>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow()
+ {
+ statusBar()->showMessage(tr("Ready"));
+ }
+
+public slots:
+ void buttonPressed(const QString &text)
+ {
+ statusBar()->showMessage(tr("Chose %1").arg(text));
+ }
+};
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/main.cpp
new file mode 100644
index 000000000..bea97889f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel-details/main.cpp
@@ -0,0 +1,79 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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] //! [1]
+ treeView = QTreeView()
+//! [0]
+ model = MyItemModel(self)
+
+ treeView.setModel(model)
+//! [1]
+
+//! [2]
+ sourceModel = MyItemModel(self)
+ proxyModel = QSortFilterProxyModel(self)
+
+ proxyModel.setSourceModel(sourceModel)
+ treeView.setModel(proxyModel)
+//! [2]
+
+//! [3]
+ treeView.setSortingEnabled(True)
+//! [3]
+
+//! [4]
+ proxyModel.sort(2, Qt.AscendingOrder)
+//! [4] //! [5]
+ proxyModel.setFilterRegExp(QRegExp(".png", Qt.CaseInsensitive,
+ QRegExp.FixedString))
+ proxyModel.setFilterKeyColumn(1)
+//! [5]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/main.cpp
new file mode 100644
index 000000000..1205cb928
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsortfilterproxymodel/main.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QObject *parent = &app;
+
+ QStringList numbers;
+ numbers << "One" << "Two" << "Three" << "Four" << "Five";
+
+ QAbstractItemModel *stringListModel = new QStringListModel(numbers, parent);
+
+//! [0]
+ QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(parent);
+ filterModel->setSourceModel(stringListModel);
+//! [0]
+
+ QWidget *window = new QWidget;
+
+//! [1]
+ QListView *filteredView = new QListView;
+ filteredView->setModel(filterModel);
+//! [1]
+ filteredView->setWindowTitle("Filtered view onto a string list model");
+
+ QLineEdit *patternEditor = new QLineEdit;
+ QObject::
+ connect(patternEditor, SIGNAL(textChanged(const QString &)),
+ filterModel, SLOT(setFilterRegExp(const QString &)));
+
+ QVBoxLayout *layout = new QVBoxLayout(window);
+ layout->addWidget(filteredView);
+ layout->addWidget(patternEditor);
+
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/main.cpp
new file mode 100644
index 000000000..d24d11e11
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/main.cpp
@@ -0,0 +1,66 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+def main():
+ app = QApplication(sys.argv)
+ pixmap = QPixmap(":/splash.png")
+ splash = QSplashScreen(pixmap)
+ splash.show()
+ app.processEvents()
+//! [0]
+
+//! [1]
+ window = QMainWindow()
+ window.show()
+ splash.finish(&window)
+ return app.exec_()
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.cpp
new file mode 100644
index 000000000..4d1a8dda8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QLabel *label = new QLabel(tr("This is the main window."));
+ label->setAlignment(Qt::AlignCenter);
+ setCentralWidget(label);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.h
new file mode 100644
index 000000000..79e9665ec
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/mainwindow.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.qrc
new file mode 100644
index 000000000..330ec7868
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/qsplashscreen.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>splash.png</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/splash.png b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/splash.png
new file mode 100644
index 000000000..d82f6d218
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsplashscreen/splash.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsql-namespace/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsql-namespace/main.cpp
new file mode 100644
index 000000000..6dd6c8934
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsql-namespace/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QSql>
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qstack/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstack/main.cpp
new file mode 100644
index 000000000..18b24aa15
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstack/main.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <iostream>
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+//! [0]
+ QStack<int> stack;
+ stack.push(1);
+ stack.push(2);
+ stack.push(3);
+ while (!stack.isEmpty())
+ cout << stack.pop() << endl;
+//! [0]
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qstackedlayout/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstackedlayout/main.cpp
new file mode 100644
index 000000000..1009119f7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstackedlayout/main.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QApplication>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ QWidget *firstPageWidget = new QWidget;
+ QWidget *secondPageWidget = new QWidget;
+ QWidget *thirdPageWidget = new QWidget;
+
+ QStackedLayout *stackedLayout = new QStackedLayout;
+ stackedLayout->addWidget(firstPageWidget);
+ stackedLayout->addWidget(secondPageWidget);
+ stackedLayout->addWidget(thirdPageWidget);
+
+//! [0] //! [1]
+ QComboBox *pageComboBox = new QComboBox;
+ pageComboBox->addItem(tr("Page 1"));
+ pageComboBox->addItem(tr("Page 2"));
+ pageComboBox->addItem(tr("Page 3"));
+ connect(pageComboBox, SIGNAL(activated(int)),
+ stackedLayout, SLOT(setCurrentIndex(int)));
+//! [1]
+
+//! [2]
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+//! [2]
+ mainLayout->addWidget(pageComboBox);
+//! [3]
+ mainLayout->addLayout(stackedLayout);
+ setLayout(mainLayout);
+//! [3]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qstackedwidget/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstackedwidget/main.cpp
new file mode 100644
index 000000000..b391bcc90
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstackedwidget/main.cpp
@@ -0,0 +1,78 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ firstPageWidget = QWidget()
+ secondPageWidget = QWidget()
+ thirdPageWidget = QWidget()
+
+ stackedWidget = QStackedWidget()
+ stackedWidget.addWidget(firstPageWidget)
+ stackedWidget.addWidget(secondPageWidget)
+ stackedWidget.addWidget(thirdPageWidget)
+
+//! [0] //! [1]
+ pageComboBox = QComboBox()
+ pageComboBox.addItem(tr("Page 1"))
+ pageComboBox.addItem(tr("Page 2"))
+ pageComboBox.addItem(tr("Page 3"))
+ connect(pageComboBox, SIGNAL("activated(int)"),
+ stackedWidget, SLOT("setCurrentIndex(int)"))
+
+//! [1] //! [2]
+ layout = QVBoxLayout()
+//! [2]
+ layout.addWidget(pageComboBox)
+//! [3]
+ layout.addWidget(stackedWidget)
+ setLayout(layout)
+//! [3]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qstandarditemmodel/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstandarditemmodel/main.cpp
new file mode 100644
index 000000000..1c321682c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstandarditemmodel/main.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QApplication>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parentWidget = 0);
+};
+
+Widget::Widget(QWidget *parentWidget)
+ : QWidget(parentWidget)
+{
+ QStandardItemModel *model = new QStandardItemModel();
+ QModelIndex parent;
+ for (int i = 0; i < 4; ++i) {
+ parent = model->index(0, 0, parent);
+ model->insertRows(0, 1, parent);
+ model->insertColumns(0, 1, parent);
+ QModelIndex index = model->index(0, 0, parent);
+ model->setData(index, i);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qstatustipevent/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstatustipevent/main.cpp
new file mode 100644
index 000000000..d62bbdbcf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstatustipevent/main.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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] //! [1]
+def __init__(self, parent):
+ QMainWindow.__init__(self, parent)
+//! [0]
+ myWidget = QWidget()
+ myWidget.setStatusTip(tr("This is my widget."))
+
+ setCentralWidget(myWidget)
+//! [1]
+
+//! [2]
+ fileMenu = menuBar().addMenu(tr("File"))
+
+ Act = QAction(self.tr("&New"), self)
+ Act.setStatusTip(tr("Create a new file."))
+ fileMenu.addAction(Act)
+//! [2]
+
+ statusBar().showMessage(self.tr("Ready"))
+ setWindowTitle(tr("QStatusTipEvent"))
+//! [3]
+
+//! [3]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qstringlistmodel/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstringlistmodel/main.cpp
new file mode 100644
index 000000000..f4ca91d2a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstringlistmodel/main.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ model = QStringListModel()
+ list = QStringList()
+ list.append("a")
+ list.append("b")
+ list.append("c")
+ model.setStringList(list)
+//! [0]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qstyleoption/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstyleoption/main.cpp
new file mode 100644
index 000000000..5f7420acc
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstyleoption/main.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+def paintEvent(self, qpaintevent):
+ option = QStyleOptionButton()
+ option.initFrom(self)
+ if isDown():
+ option.state = QStyle.State_Sunken
+ else:
+ option.state = QStyle.State_Raised
+
+ if self.isDefault():
+ option.features = option.features or QStyleOptionButton.DefaultButton
+ option.text = self.text()
+ option.icon = self.icon()
+
+ painter = QPainter(self)
+ self.style().drawControl(QStyle.CE_PushButton, option, painter, self)
+//! [0]
+//! [1]
+ option = QStyleOptionFrame()
+
+ if isinstance(option, QStyleOptionFrameV2):
+ frameOptionV2 = QStyleOptionFrameV2(option)
+
+ # draw the frame using frameOptionV2
+
+//! [1]
+
+//! [2]
+ if isinstance(option, QStyleOptionProgressBarV2):
+ progressBarV2 = QStyleOptionProgressBarV2(option)
+
+ # draw the progress bar using progressBarV2
+
+//! [2]
+
+//! [3]
+ if isinstance(option, QStyleOptionTabV2):
+ tabV2 = QStyleOptionTabV2(option)
+
+ # draw the tab using tabV2
+
+//! [3]
+
+
+//! [4]
+def drawPrimitive(self, element, option, painter, widget):
+ if element == self.PE_FrameFocusRect:
+ focusRectOption = QStyleOptionFocusRect(option)
+ if focusRectOption:
+ # ...
+
+
+ # ...
+
+//! [4]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qstyleplugin/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstyleplugin/main.cpp
new file mode 100644
index 000000000..9ea182d6d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qstyleplugin/main.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QtWidgets>
+
+class MyStylePlugin : public QStylePlugin
+{
+public:
+ MyStylePlugin(QObject *parent = 0);
+
+ QStyle *create(const QString &key);
+ QStringList keys() const;
+};
+
+class RocketStyle : public QCommonStyle
+{
+public:
+ RocketStyle() {};
+
+};
+
+class StarBusterStyle : public QCommonStyle
+{
+public:
+ StarBusterStyle() {};
+};
+
+MyStylePlugin::MyStylePlugin(QObject *parent)
+ : QStylePlugin(parent)
+{
+}
+
+//! [0]
+QStringList MyStylePlugin::keys() const
+{
+ return QStringList() << "Rocket" << "StarBuster";
+}
+//! [0]
+
+//! [1]
+QStyle *MyStylePlugin::create(const QString &key)
+{
+ QString lcKey = key;
+ if (lcKey == "rocket") {
+ return new RocketStyle;
+ } else if (lcKey == "starbuster") {
+ return new StarBusterStyle;
+ }
+ return 0;
+//! [1] //! [2]
+}
+//! [2]
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MyStylePlugin plugin;
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/main.cpp
new file mode 100644
index 000000000..61ad18a64
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QtSvg>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [0]
+ QSvgWidget window(":/files/spheres.svg");
+ window.show();
+//! [0]
+ QSvgRenderer *renderer = window.renderer();
+ QImage image(150, 150, QImage::Format_RGB32);
+ QPainter painter;
+ painter.begin(&image);
+ renderer->render(&painter);
+ painter.end();
+ image.save("spheres.png", "PNG", 9);
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.qrc
new file mode 100644
index 000000000..13d8b3612
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/qsvgwidget.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/files" >
+ <file>spheres.svg</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/spheres.svg b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/spheres.svg
new file mode 100644
index 000000000..9e3819306
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/spheres.svg
@@ -0,0 +1,79 @@
+<?xml version="1.0" standalone="no"?>
+<svg width="8cm" height="8cm" viewBox="0 0 400 400"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink/"
+ baseProfile="tiny" version="1.2">
+ <title>Spheres</title>
+ <desc>Gradient filled spheres with different colors.</desc>
+ <defs>
+ <!-- Create radial gradients for each circle to make them look like
+ spheres. -->
+ <radialGradient id="blueSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="blue" />
+ <stop offset="100%" stop-color="#222244" />
+ </radialGradient>
+ <radialGradient id="redSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="red" />
+ <stop offset="100%" stop-color="#442222" />
+ </radialGradient>
+ <radialGradient id="greenSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="green" />
+ <stop offset="100%" stop-color="#113311" />
+ </radialGradient>
+ <radialGradient id="yellowSphere" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="-50">
+ <stop offset="0%" stop-color="white" />
+ <stop offset="75%" stop-color="yellow" />
+ <stop offset="100%" stop-color="#444422" />
+ </radialGradient>
+ <radialGradient id="shadow" gradientUnits="userSpaceOnUse"
+ cx="0" cy="0" r="100" fx="-50" fy="50">
+ <stop offset="0%" stop-color="black" stop-opacity="1.0" />
+ <stop offset="100%" stop-color="white" stop-opacity="0.0" />
+ </radialGradient>
+
+ <!-- Define a shadow for each sphere. -->
+ <circle id="shadow" fill="url(#shadow)" cx="0" cy="0" r="100" />
+ </defs>
+ <g fill="#ffee99" stroke="none" >
+ <rect x="0" y="0" width="400" height="400" />
+ </g>
+ <g fill="white" stroke="none" >
+ <rect x="0" y="175" width="400" height="225" />
+ </g>
+ <g transform="translate(200,290) scale(2.0,1.0) rotate(45)" >
+ <rect fill="#a6ce39" x="-69" y="-69" width="138" height="138" />
+ <circle fill="black" cx="0" cy="0" r="50" />
+ <circle fill="#a6ce39" cx="0" cy="0" r="33" />
+ <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
+ L -11,22 L -1,12 Z" />
+ </g>
+ <g transform="translate(200,175)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#blueSphere)" cx="0" cy="0" r="100" />
+ </g>
+ <g transform="translate(315,240)">
+ <g transform="scale(0.5,0.5)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#redSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ <g transform="translate(80,275)">
+ <g transform="scale(0.65,0.65)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#greenSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+ <g transform="translate(255,325)">
+ <g transform="scale(0.3,0.3)">
+ <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+ <circle fill="url(#yellowSphere)" cx="0" cy="0" r="100" />
+ </g>
+ </g>
+</svg>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/sunflower.svg b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/sunflower.svg
new file mode 100644
index 000000000..b60dd11a6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qsvgwidget/sunflower.svg
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
+<svg width="289.619" height="450.482"
+ xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" version="1.1">
+ <defs>
+ <marker id="ArrowEnd" viewBox="0 0 10 10" refX="0" refY="5"
+ markerUnits="strokeWidth"
+ markerWidth="4"
+ markerHeight="3"
+ orient="auto">
+ <path d="M 0 0 L 10 5 L 0 10 z" />
+ </marker>
+ <marker id="ArrowStart" viewBox="0 0 10 10" refX="10" refY="5"
+ markerUnits="strokeWidth"
+ markerWidth="4"
+ markerHeight="3"
+ orient="auto">
+ <path d="M 10 0 L 0 5 L 10 10 z" />
+ </marker> </defs>
+<g>
+<defs><linearGradient id="1" x1="155.352" y1="450.482" x2="155.352" y2="140" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#9ded37"/>
+<stop offset="1" style="stop-color:#f8ff76"/>
+</linearGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#1)" d="M 132.72 145.241C 211.668 237.549 150.166 295.646 148.222 342.665C 146.89 374.889 171.099 410.104 185.352 445.241C 185.352 445.241 185.352 445.241 132.72 352.933C 106.405 306.779 159.036 306.779 159.036 237.549C 159.036 191.395 132.72 145.241 132.72 145.241z"/>
+<defs><radialGradient id="2" cx="145.352" cy="45.2408" r="47.7391" fx="145.352" fy="45.2408" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#2)" d="M 155.352 45.2408C 155.352 67.3199 150.872 85.2408 145.352 85.2408C 139.832 85.2408 135.352 67.3199 135.352 45.2408C 135.352 23.1618 139.832 5.24084 145.352 5.24084C 150.872 5.24084 155.352 23.1618 155.352 45.2408z"/>
+<defs><radialGradient id="3" cx="170.135" cy="48.3609" r="48.0339" fx="170.135" fy="48.3609" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#3)" d="M 179.823 50.8388C 174.351 72.2289 165.569 88.4808 160.221 87.1129C 154.874 85.7448 154.975 67.2728 160.447 45.8828C 165.919 24.4928 174.701 8.24084 180.048 9.60886C 185.396 10.9768 185.295 29.4489 179.823 50.8388z"/>
+<g>
+<defs><radialGradient id="4" cx="192.599" cy="57.0958" r="48.4248" fx="192.599" fy="57.0958" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#4)" d="M 201.476 61.6998C 191.31 81.2998 179.081 95.1448 174.181 92.6039C 169.282 90.0618 173.556 72.0909 183.722 52.4919C 193.888 32.8918 206.116 19.0468 211.016 21.5878C 215.916 24.1299 211.642 42.1008 201.476 61.6998z"/>
+<defs><radialGradient id="5" cx="213.162" cy="71.2758" r="48.6431" fx="213.162" fy="71.2758" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#5)" d="M 220.621 77.9368C 205.915 94.4048 190.636 104.788 186.519 101.112C 182.402 97.4348 190.997 81.0838 205.703 64.6148C 220.409 48.1469 235.688 37.7639 239.805 41.4398C 243.922 45.1169 235.327 61.4678 220.621 77.9368z"/>
+</g>
+<defs><radialGradient id="6" cx="229.082" cy="90.7439" r="48.5357" fx="229.082" fy="90.7439" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#6)" d="M 234.466 99.1708C 215.86 111.058 198.346 116.932 195.374 112.28C 192.403 107.629 205.092 94.2048 223.698 82.3168C 242.303 70.4298 259.817 64.5558 262.789 69.2079C 265.761 73.8589 253.071 87.2838 234.466 99.1708z"/>
+<defs><radialGradient id="7" cx="239.796" cy="113.308" r="48.1584" fx="239.796" fy="113.308" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#7)" d="M 242.923 122.806C 221.952 129.712 203.529 131.061 201.803 125.819C 200.076 120.576 215.697 110.715 236.668 103.81C 257.639 96.9038 276.063 95.5548 277.789 100.797C 279.515 106.04 263.895 115.901 242.923 122.806z"/>
+<g>
+<defs><radialGradient id="8" cx="244.53" cy="136.94" r="47.7879" fx="244.53" fy="136.94" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#8)" d="M 245.429 146.899C 223.44 148.885 205.188 146.035 204.692 140.538C 204.195 135.04 221.641 128.966 243.63 126.981C 265.62 124.995 283.871 127.845 284.368 133.342C 284.864 138.84 267.418 144.914 245.429 146.899z"/>
+<defs><radialGradient id="9" cx="243.651" cy="161.904" r="47.8795" fx="243.651" fy="161.904" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#9)" d="M 242.055 171.776C 220.259 168.25 203.284 160.965 204.165 155.516C 205.047 150.067 223.453 148.506 245.249 152.032C 267.044 155.558 284.02 162.843 283.138 168.292C 282.257 173.741 263.85 175.302 242.055 171.776z"/>
+</g>
+<g>
+<g>
+<g>
+<defs><radialGradient id="10" cx="236.069" cy="186.194" r="48.3388" fx="236.069" fy="186.194" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#10)" d="M 231.976 195.318C 211.831 186.281 197.314 174.858 199.573 169.822C 201.832 164.785 220.017 168.033 240.162 177.07C 260.306 186.107 274.824 197.53 272.565 202.566C 270.305 207.603 252.12 204.355 231.976 195.318z"/>
+<defs><radialGradient id="11" cx="223.077" cy="207.529" r="48.6188" fx="223.077" fy="207.529" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#11)" d="M 216.851 215.354C 199.575 201.606 188.341 186.942 191.778 182.623C 195.215 178.303 212.028 185.956 229.304 199.704C 246.581 213.452 257.814 228.116 254.377 232.435C 250.94 236.755 234.128 229.102 216.851 215.354z"/>
+</g>
+<g>
+<defs><radialGradient id="12" cx="205.914" cy="224.449" r="48.6182" fx="205.914" fy="224.449" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#12)" d="M 198.079 230.664C 184.358 213.366 176.731 196.542 181.055 193.111C 185.379 189.681 200.027 200.937 213.748 218.234C 227.469 235.532 235.097 252.356 230.772 255.787C 226.448 259.217 211.801 247.961 198.079 230.664z"/>
+<defs><radialGradient id="13" cx="184.559" cy="237.407" r="48.3362" fx="184.559" fy="237.407" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#13)" d="M 175.429 241.486C 166.422 221.328 163.203 203.138 168.242 200.886C 173.282 198.635 184.683 213.169 193.689 233.328C 202.695 253.486 205.915 271.676 200.875 273.928C 195.836 276.179 184.435 261.645 175.429 241.486z"/>
+</g>
+</g>
+<g>
+<g>
+<defs><radialGradient id="14" cx="160.281" cy="243.964" r="47.8592" fx="160.281" fy="243.964" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#14)" d="M 150.388 245.427C 147.158 223.586 148.968 205.202 154.428 204.395C 159.888 203.587 166.943 220.66 170.173 242.501C 173.404 264.342 171.594 282.726 166.134 283.534C 160.673 284.341 153.619 267.268 150.388 245.427z"/>
+<defs><radialGradient id="15" cx="135.307" cy="244.504" r="47.8021" fx="135.307" fy="244.504" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#15)" d="M 125.361 243.47C 127.645 221.509 133.954 204.148 139.444 204.719C 144.934 205.289 147.537 223.578 145.254 245.538C 142.971 267.499 136.661 284.86 131.171 284.289C 125.681 283.719 123.078 265.43 125.361 243.47z"/>
+</g>
+<g>
+<defs><radialGradient id="16" cx="111.808" cy="239.15" r="48.183" fx="111.808" fy="239.15" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#16)" d="M 102.353 235.894C 109.541 215.018 119.613 199.532 124.831 201.33C 130.05 203.127 128.452 221.53 121.263 242.406C 114.074 263.282 104.003 278.768 98.784 276.97C 93.5651 275.173 95.1639 256.77 102.353 235.894z"/>
+<defs><radialGradient id="17" cx="89.3906" cy="228.131" r="48.5494" fx="89.3906" fy="228.131" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#17)" d="M 81.0375 222.633C 93.1756 204.19 106.771 191.684 111.381 194.718C 115.992 197.753 109.882 215.186 97.7439 233.629C 85.6057 252.072 72.0108 264.578 67.4001 261.544C 62.7894 258.509 68.8993 241.076 81.0375 222.633z"/>
+</g>
+</g>
+</g>
+<g>
+<g>
+<g>
+<defs><radialGradient id="18" cx="53.7557" cy="185.38" r="48.3405" fx="53.7557" fy="185.38" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#18)" d="M 49.653 176.26C 69.7881 167.202 87.9697 163.935 90.2343 168.969C 92.4989 174.003 77.9935 185.441 57.8584 194.5C 37.7233 203.558 19.5417 206.825 17.2771 201.791C 15.0125 196.757 29.5179 185.319 49.653 176.26z"/>
+<defs><radialGradient id="19" cx="46.4327" cy="161.498" r="47.8981" fx="46.4327" fy="161.498" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#19)" d="M 44.7181 151.646C 66.47 147.861 84.894 149.202 85.8404 154.64C 86.7868 160.078 69.8991 167.564 48.1473 171.35C 26.3954 175.135 7.97139 173.794 7.02501 168.356C 6.07862 162.918 22.9663 155.432 44.7181 151.646z"/>
+</g>
+<g>
+<defs><radialGradient id="20" cx="45.1827" cy="137.429" r="47.7585" fx="45.1827" fy="137.429" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#20)" d="M 45.7397 127.445C 67.7843 128.674 85.4281 134.146 85.1206 139.657C 84.8131 145.168 66.6702 148.643 44.6257 147.413C 22.5811 146.184 4.93733 140.712 5.2448 135.201C 5.55227 129.69 23.6952 126.215 45.7397 127.445z"/>
+<defs><radialGradient id="21" cx="49.6787" cy="112.858" r="48.1368" fx="49.6787" fy="112.858" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#21)" d="M 52.6929 103.323C 73.7448 109.978 89.4821 119.652 87.8184 124.915C 86.1547 130.178 67.7165 129.048 46.6645 122.393C 25.6126 115.738 9.87529 106.064 11.539 100.801C 13.2027 95.5378 31.6409 96.6678 52.6929 103.323z"/>
+</g>
+</g>
+<g>
+<g>
+<defs><radialGradient id="22" cx="60.9007" cy="90.3528" r="48.5468" fx="60.9007" fy="90.3528" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#22)" d="M 66.3768 81.9858C 84.8509 94.0758 97.3927 107.639 94.3701 112.257C 91.3475 116.876 73.8987 110.811 55.4246 98.7198C 36.9505 86.6299 24.4087 73.0668 27.4313 68.4489C 30.4539 63.8298 47.9027 69.8948 66.3768 81.9858z"/>
+<defs><radialGradient id="23" cx="77.0826" cy="71.3239" r="48.6458" fx="77.0826" fy="71.3239" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#23)" d="M 84.4616 64.5748C 99.363 80.8669 108.152 97.1148 104.079 100.84C 100.006 104.565 84.6051 94.3648 69.7038 78.0728C 54.8024 61.7809 46.013 45.5338 50.086 41.8078C 54.1589 38.0829 69.5603 48.2828 84.4616 64.5748z"/>
+</g>
+<g>
+<defs><radialGradient id="24" cx="96.6928" cy="57.3108" r="48.4711" fx="96.6928" fy="57.3108" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#24)" d="M 105.406 52.4048C 116.239 71.6429 121.128 89.4579 116.318 92.1658C 111.508 94.8738 98.8115 81.4558 87.979 62.2168C 77.1465 42.9778 72.2579 25.1638 77.0676 22.4558C 81.8773 19.7478 94.5739 33.1658 105.406 52.4048z"/>
+<defs><radialGradient id="25" cx="119.819" cy="47.8708" r="48.0557" fx="119.819" fy="47.8708" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#25)" d="M 129.477 45.2769C 135.203 66.6008 135.524 85.0708 130.193 86.5018C 124.863 87.9338 115.888 71.7878 110.161 50.4648C 104.434 29.1408 104.113 10.6718 109.444 9.23984C 114.775 7.80783 123.75 23.9538 129.477 45.2769z"/>
+</g>
+</g>
+</g>
+<defs><radialGradient id="26" cx="69.0797" cy="209.914" r="48.6339" fx="69.0797" fy="209.914" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#ffa048"/>
+<stop offset="1" style="stop-color:#ff472e"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#26)" d="M 62.6124 202.287C 79.4523 188.008 96.0187 179.835 99.5885 184.045C 103.158 188.255 92.3869 203.262 75.547 217.541C 58.707 231.82 42.1406 239.993 38.5709 235.783C 35.0011 231.573 45.7725 216.566 62.6124 202.287z"/>
+<defs><radialGradient id="27" cx="145.352" cy="145.241" r="92.2646" fx="145.352" fy="145.241" gradientUnits="userSpaceOnUse">
+<stop offset="0" style="stop-color:#fff82e"/>
+<stop offset="1" style="stop-color:#ffffff"/>
+</radialGradient>
+</defs><path style="stroke:#000000; stroke-width:1; fill:url(#27)" d="M 85.3517 145.241C 85.3517 178.359 112.234 205.241 145.352 205.241C 178.47 205.241 205.352 178.359 205.352 145.241C 205.352 112.123 178.47 85.2408 145.352 85.2408C 112.234 85.2408 85.3517 112.123 85.3517 145.241z"/>
+</g>
+</svg>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qt-namespace/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qt-namespace/main.cpp
new file mode 100644
index 000000000..c362b92f6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qt-namespace/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <Qt>
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/cubed.png b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/cubed.png
new file mode 100644
index 000000000..2cd9048ca
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/cubed.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/squared.png b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/squared.png
new file mode 100644
index 000000000..bfdf99328
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/Images/squared.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/images.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/images.qrc
new file mode 100644
index 000000000..1d49b5286
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/images.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>Images/squared.png</file>
+ <file>Images/cubed.png</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/main.cpp
new file mode 100644
index 000000000..08343ac18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.cpp
new file mode 100644
index 000000000..d9d398e78
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.cpp
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include "math.h"
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ QAction *sumItemsAction = itemsMenu->addAction(tr("&Sum Items"));
+ QAction *averageItemsAction = itemsMenu->addAction(tr("&Average Items"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+ tableWidget = new QTableWidget(12, 3, this);
+ tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ tableWidget->setDragEnabled(true);
+ tableWidget->setAcceptDrops(true);
+ tableWidget->setDropIndicatorShown(true);
+
+ QTableWidgetItem *valuesHeaderItem = new QTableWidgetItem(tr("Values"));
+ tableWidget->setHorizontalHeaderItem(0, valuesHeaderItem);
+ valuesHeaderItem->setTextAlignment(Qt::AlignVCenter);
+ QTableWidgetItem *squaresHeaderItem = new QTableWidgetItem(tr("Squares"));
+ squaresHeaderItem->setIcon(QIcon(QPixmap(":/Images/squared.png")));
+ squaresHeaderItem->setTextAlignment(Qt::AlignVCenter);
+ QTableWidgetItem *cubesHeaderItem = new QTableWidgetItem(tr("Cubes"));
+ cubesHeaderItem->setIcon(QIcon(QPixmap(":/Images/cubed.png")));
+ cubesHeaderItem->setTextAlignment(Qt::AlignVCenter);
+ tableWidget->setHorizontalHeaderItem(1, squaresHeaderItem);
+ tableWidget->setHorizontalHeaderItem(2, cubesHeaderItem);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(sumItemsAction, SIGNAL(triggered()), this, SLOT(sumItems()));
+ connect(averageItemsAction, SIGNAL(triggered()), this, SLOT(averageItems()));
+
+ setupTableItems();
+
+ setCentralWidget(tableWidget);
+ setWindowTitle(tr("Table Widget"));
+}
+
+void MainWindow::setupTableItems()
+{
+ for (int row = 0; row < tableWidget->rowCount()-1; ++row) {
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+ QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(
+ pow((float)row, (float)column+1)));
+ tableWidget->setItem(row, column, newItem);
+ }
+ }
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+ QTableWidgetItem *newItem = new QTableWidgetItem;
+ newItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
+ tableWidget->setItem(tableWidget->rowCount()-1, column, newItem);
+ }
+}
+
+void MainWindow::averageItems()
+{
+ QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
+ QTableWidgetItem *item;
+ int number = 0;
+ double total = 0;
+
+ foreach (item, selected) {
+ bool ok;
+ double value = item->text().toDouble(&ok);
+
+ if (ok && !item->text().isEmpty()) {
+ total += value;
+ number++;
+ }
+ }
+ if (number > 0)
+ tableWidget->currentItem()->setText(QString::number(total/number));
+}
+
+void MainWindow::sumItems()
+{
+ QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
+ QTableWidgetItem *item;
+ int number = 0;
+ double total = 0;
+
+ foreach (item, selected) {
+ bool ok;
+ double value = item->text().toDouble(&ok);
+
+ if (ok && !item->text().isEmpty()) {
+ total += value;
+ number++;
+ }
+ }
+ if (number > 0)
+ tableWidget->currentItem()->setText(QString::number(total));
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.h
new file mode 100644
index 000000000..42ac2740d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-dnd/mainwindow.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QTableWidget;
+class QTableWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void averageItems();
+ void sumItems();
+
+private:
+ void setupTableItems();
+
+ QAction *removeAction;
+ QTableWidget *tableWidget;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/main.cpp
new file mode 100644
index 000000000..08343ac18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.cpp
new file mode 100644
index 000000000..ad76da6b8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *tableMenu = new QMenu(tr("&Table"));
+
+ QAction *tableWidthAction = tableMenu->addAction(tr("Change Table &Width"));
+ QAction *tableHeightAction = tableMenu->addAction(tr("Change Table &Height"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(tableMenu);
+
+//! [0]
+ tableWidget = QTableWidget()
+//! [0]
+ tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(tableWidthAction, SIGNAL(triggered()), this, SLOT(changeWidth()));
+ connect(tableHeightAction, SIGNAL(triggered()), this, SLOT(changeHeight()));
+
+ setupTableItems();
+
+ setCentralWidget(tableWidget);
+ setWindowTitle(tr("Table Widget Resizing"));
+}
+
+void MainWindow::setupTableItems()
+{
+//! [1]
+ tableWidget.setRowCount(10)
+ tableWidget.setColumnCount(5)
+//! [1]
+
+ for (int row = 0; row < tableWidget->rowCount(); ++row) {
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+//! [2]
+ newItem = QTableWidgetItem(tr("%s" % ((row+1)*(column+1))))
+ tableWidget.setItem(row, column, newItem)
+//! [2]
+ }
+ }
+}
+
+void MainWindow::changeWidth()
+{
+ bool ok;
+
+ int newWidth = QInputDialog::getInteger(this, tr("Change table width"),
+ tr("Input the number of columns required (1-20):"),
+ tableWidget->columnCount(), 1, 20, 1, &ok);
+
+ if (ok)
+ tableWidget->setColumnCount(newWidth);
+}
+
+void MainWindow::changeHeight()
+{
+ bool ok;
+
+ int newHeight = QInputDialog::getInteger(this, tr("Change table height"),
+ tr("Input the number of rows required (1-20):"),
+ tableWidget->rowCount(), 1, 20, 1, &ok);
+
+ if (ok)
+ tableWidget->setRowCount(newHeight);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.h
new file mode 100644
index 000000000..e8e06d1be
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-resizing/mainwindow.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QTableWidget;
+class QTableWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void changeHeight();
+ void changeWidth();
+
+private:
+ void setupTableItems();
+
+ QTableWidget *tableWidget;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/cubed.png b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/cubed.png
new file mode 100644
index 000000000..2cd9048ca
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/cubed.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/squared.png b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/squared.png
new file mode 100644
index 000000000..bfdf99328
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/Images/squared.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/images.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/images.qrc
new file mode 100644
index 000000000..1d49b5286
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/images.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>Images/squared.png</file>
+ <file>Images/cubed.png</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/main.cpp
new file mode 100644
index 000000000..08343ac18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.cpp
new file mode 100644
index 000000000..52928b835
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include "math.h"
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ QAction *sumItemsAction = itemsMenu->addAction(tr("&Sum Items"));
+ QAction *averageItemsAction = itemsMenu->addAction(tr("&Average Items"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+//! [0]
+ tableWidget = QTableWidget(12, 3, self)
+//! [0]
+ tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+//! [1]
+ valuesHeaderItem = QTableWidgetItem(tr("Values"))
+ tableWidget.setHorizontalHeaderItem(0, valuesHeaderItem)
+//! [1]
+ valuesHeaderItem->setTextAlignment(Qt::AlignVCenter);
+ QTableWidgetItem *squaresHeaderItem = new QTableWidgetItem(tr("Squares"));
+ squaresHeaderItem->setIcon(QIcon(QPixmap(":/Images/squared.png")));
+ squaresHeaderItem->setTextAlignment(Qt::AlignVCenter);
+//! [2]
+ cubesHeaderItem = QTableWidgetItem(tr("Cubes"))
+ cubesHeaderItem.setIcon(QIcon(QPixmap(":/Images/cubed.png")))
+ cubesHeaderItem.setTextAlignment(Qt::AlignVCenter)
+//! [2]
+ tableWidget->setHorizontalHeaderItem(1, squaresHeaderItem);
+ tableWidget->setHorizontalHeaderItem(2, cubesHeaderItem);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(sumItemsAction, SIGNAL(triggered()), this, SLOT(sumItems()));
+ connect(averageItemsAction, SIGNAL(triggered()), this, SLOT(averageItems()));
+
+ setupTableItems();
+
+ setCentralWidget(tableWidget);
+ setWindowTitle(tr("Table Widget"));
+}
+
+void MainWindow::setupTableItems()
+{
+ for (int row = 0; row < tableWidget->rowCount()-1; ++row) {
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+//! [3]
+ newItem = QTableWidgetItem(tr("%s" % pow(row, column+1)))
+ tableWidget.setItem(row, column, newItem)
+//! [3]
+ }
+ }
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+ QTableWidgetItem *newItem = new QTableWidgetItem;
+ newItem->setFlags(Qt::ItemIsEnabled);
+ tableWidget->setItem(tableWidget->rowCount()-1, column, newItem);
+ }
+}
+
+void MainWindow::averageItems()
+{
+ QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
+ QTableWidgetItem *item;
+ int number = 0;
+ double total = 0;
+
+ foreach (item, selected) {
+ bool ok;
+ double value = item->text().toDouble(&ok);
+
+ if (ok && !item->text().isEmpty()) {
+ total += value;
+ number++;
+ }
+ }
+ if (number > 0)
+ tableWidget->currentItem()->setText(QString::number(total/number));
+}
+
+void MainWindow::sumItems()
+{
+//! [4]
+ QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
+ QTableWidgetItem *item;
+ int number = 0;
+ double total = 0;
+
+ foreach (item, selected) {
+ bool ok;
+ double value = item->text().toDouble(&ok);
+
+ if (ok && !item->text().isEmpty()) {
+ total += value;
+ number++;
+ }
+ }
+//! [4]
+ if (number > 0)
+ tableWidget->currentItem()->setText(QString::number(total));
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.h
new file mode 100644
index 000000000..fa35433c8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtablewidget-using/mainwindow.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QTableWidget;
+class QTableWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void averageItems();
+ void sumItems();
+
+private:
+ void setupTableItems();
+
+ QAction *removeAction;
+//! [0]
+ QTableWidget *tableWidget;
+//! [0]
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtcast/qtcast.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtcast/qtcast.cpp
new file mode 100644
index 000000000..cdc2736b5
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtcast/qtcast.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QLabel>
+#include <QPushButton>
+
+#include "qtcast.h"
+
+MyWidget::MyWidget()
+{
+//! [0]
+ QObject *obj = new MyWidget;
+//! [0]
+
+//! [1]
+ QWidget *widget = qobject_cast<QWidget *>(obj);
+//! [1]
+
+//! [2]
+ MyWidget *myWidget = qobject_cast<MyWidget *>(obj);
+//! [2]
+
+//! [3]
+ QLabel *label = qobject_cast<QLabel *>(obj);
+//! [3] //! [4]
+ // label is 0
+//! [4]
+
+//! [5]
+ if (QLabel *label = qobject_cast<QLabel *>(obj)) {
+//! [5] //! [6]
+ label->setText(tr("Ping"));
+ } else if (QPushButton *button = qobject_cast<QPushButton *>(obj)) {
+ button->setText(tr("Pong!"));
+ }
+//! [6]
+}
+
+int main()
+{
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtcast/qtcast.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtcast/qtcast.h
new file mode 100644
index 000000000..b5507ad9d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtcast/qtcast.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef QTCAST_H
+#define QTCAST_H
+
+#include <QWidget>
+
+class MyWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ MyWidget();
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtest-namespace/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtest-namespace/main.cpp
new file mode 100644
index 000000000..cfd07ca6c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtest-namespace/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QTest>
+
+int main(int argc, char *argv[])
+{
+ QTest::qSleep(10);
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.h
new file mode 100644
index 000000000..d639bb17f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/dragdropmodel.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef DRAGDROPMODEL_H
+#define DRAGDROPMODEL_H
+
+#include "treemodel.h"
+
+class DragDropModel : public TreeModel
+{
+ Q_OBJECT
+
+public:
+ DragDropModel(const QStringList &strings, QObject *parent = 0);
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+ QMimeData *mimeData(const QModelIndexList &indexes) const;
+ QStringList mimeTypes() const;
+ Qt::DropActions supportedDropActions() const;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/main.cpp
new file mode 100644
index 000000000..08343ac18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.cpp
new file mode 100644
index 000000000..373a17ea9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+#include "dragdropmodel.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ menuBar()->addMenu(fileMenu);
+
+// For convenient quoting:
+ QTreeView *treeView = new QTreeView(this);
+ treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ treeView->setDragEnabled(true);
+ treeView->setAcceptDrops(true);
+ treeView->setDropIndicatorShown(true);
+
+ this->treeView = treeView;
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+
+ setupItems();
+
+ setCentralWidget(treeView);
+ setWindowTitle(tr("Tree View"));
+}
+
+void MainWindow::setupItems()
+{
+ QStringList items;
+ items << tr("Widgets\tUser interface objects used to create GUI applications.")
+ << tr(" QWidget\tThe basic building block for all other widgets.")
+ << tr(" QDialog\tThe base class for dialog windows.")
+ << tr("Tools\tUtilities and applications for Qt developers.")
+ << tr(" Qt Designer\tA GUI form designer for Qt applications.")
+ << tr(" Qt Assistant\tA documentation browser for Qt documentation.");
+
+ DragDropModel *model = new DragDropModel(items, this);
+ QModelIndex index = model->index(0, 0, QModelIndex());
+ model->insertRows(2, 3, index);
+ index = model->index(0, 0, QModelIndex());
+ index = model->index(2, 0, index);
+ model->setData(index, QVariant("QFrame"));
+ model->removeRows(3, 2, index.parent());
+ treeView->setModel(model);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.h
new file mode 100644
index 000000000..55d8e2399
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/mainwindow.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QTreeView;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+private:
+ void setupItems();
+
+ QTreeView *treeView;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.cpp
new file mode 100644
index 000000000..0243dc528
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ treeitem.cpp
+
+ A container for items of data supplied by the simple tree model.
+*/
+
+#include <QStringList>
+
+#include "treeitem.h"
+
+TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
+{
+ parentItem = parent;
+ itemData = data;
+}
+
+TreeItem::~TreeItem()
+{
+ qDeleteAll(childItems);
+}
+
+void TreeItem::appendChild(TreeItem *item)
+{
+ childItems.append(item);
+}
+
+TreeItem *TreeItem::child(int row)
+{
+ return childItems.value(row);
+}
+
+int TreeItem::childCount() const
+{
+ return childItems.count();
+}
+
+int TreeItem::columnCount() const
+{
+ return itemData.count();
+}
+
+QVariant TreeItem::data(int column) const
+{
+ return itemData.value(column);
+}
+
+bool TreeItem::insertChild(int row, TreeItem *item)
+{
+ if (row < 0 || row > childItems.count())
+ return false;
+
+ childItems.insert(row, item);
+ return true;
+}
+
+TreeItem *TreeItem::parent()
+{
+ return parentItem;
+}
+
+bool TreeItem::removeChild(int row)
+{
+ if (row < 0 || row >= childItems.count())
+ return false;
+
+ delete childItems.takeAt(row);
+ return true;
+}
+
+int TreeItem::row() const
+{
+ if (parentItem)
+ return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
+
+ return 0;
+}
+
+bool TreeItem::setData(int column, const QVariant &data)
+{
+ if (column < 0 || column >= itemData.count())
+ return false;
+
+ itemData.replace(column, data);
+ return true;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.h
new file mode 100644
index 000000000..b96243b3f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treeitem.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef TREEITEM_H
+#define TREEITEM_H
+
+#include <QList>
+#include <QVariant>
+
+class TreeItem
+{
+public:
+ TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
+ ~TreeItem();
+
+ void appendChild(TreeItem *child);
+
+ TreeItem *child(int row);
+ int childCount() const;
+ int columnCount() const;
+ QVariant data(int column) const;
+ bool insertChild(int row, TreeItem *item);
+ TreeItem *parent();
+ bool removeChild(int row);
+ int row() const;
+ bool setData(int column, const QVariant &data);
+
+private:
+ QList<TreeItem*> childItems;
+ QList<QVariant> itemData;
+ TreeItem *parentItem;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.cpp
new file mode 100644
index 000000000..7b10543eb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.cpp
@@ -0,0 +1,272 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ treemodel.cpp
+
+ Provides a simple tree model to show how to create and use hierarchical
+ models.
+*/
+
+#include <QtWidgets>
+
+#include "treeitem.h"
+#include "treemodel.h"
+
+TreeModel::TreeModel(const QStringList &strings, QObject *parent)
+ : QAbstractItemModel(parent)
+{
+ QList<QVariant> rootData;
+ rootData << "Title" << "Summary";
+ rootItem = new TreeItem(rootData);
+ setupModelData(strings, rootItem);
+}
+
+TreeModel::~TreeModel()
+{
+ delete rootItem;
+}
+
+int TreeModel::columnCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
+ else
+ return rootItem->columnCount();
+}
+
+QVariant TreeModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
+
+ return item->data(index.column());
+}
+
+Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::ItemIsEnabled;
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
+ return rootItem->data(section);
+
+ return QVariant();
+}
+
+QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent)
+ const
+{
+ TreeItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<TreeItem*>(parent.internalPointer());
+
+ TreeItem *childItem = parentItem->child(row);
+ if (childItem)
+ return createIndex(row, column, childItem);
+ else
+ return QModelIndex();
+}
+
+bool TreeModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ TreeItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<TreeItem*>(parent.internalPointer());
+
+ if (position < 0 || position > parentItem->childCount())
+ return false;
+
+ QList<QVariant> blankList;
+ for (int column = 0; column < columnCount(); ++column)
+ blankList << QVariant("");
+
+ beginInsertRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ TreeItem *newItem = new TreeItem(blankList, parentItem);
+ if (!parentItem->insertChild(position, newItem))
+ break;
+ }
+
+ endInsertRows();
+ return true;
+}
+
+QModelIndex TreeModel::parent(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return QModelIndex();
+
+ TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
+ TreeItem *parentItem = childItem->parent();
+
+ if (parentItem == rootItem)
+ return QModelIndex();
+
+ return createIndex(parentItem->row(), 0, parentItem);
+}
+
+bool TreeModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ TreeItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<TreeItem*>(parent.internalPointer());
+
+ if (position < 0 || position > parentItem->childCount())
+ return false;
+
+ beginRemoveRows(parent, position, position + rows - 1);
+
+ for (int row = 0; row < rows; ++row) {
+ if (!parentItem->removeChild(position))
+ break;
+ }
+
+ endRemoveRows();
+ return true;
+}
+
+int TreeModel::rowCount(const QModelIndex &parent) const
+{
+ TreeItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<TreeItem*>(parent.internalPointer());
+
+ return parentItem->childCount();
+}
+
+bool TreeModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (!index.isValid() || role != Qt::EditRole)
+ return false;
+
+ TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
+
+ if (item->setData(index.column(), value))
+ emit dataChanged(index, index);
+ else
+ return false;
+
+ return true;
+}
+
+void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
+{
+ QList<TreeItem*> parents;
+ QList<int> indentations;
+ parents << parent;
+ indentations << 0;
+
+ int number = 0;
+
+ while (number < lines.count()) {
+ int position = 0;
+ while (position < lines[number].length()) {
+ if (lines[number].mid(position, 1) != " ")
+ break;
+ position++;
+ }
+
+ QString lineData = lines[number].mid(position).trimmed();
+
+ if (!lineData.isEmpty()) {
+ // Read the column data from the rest of the line.
+ QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
+ QList<QVariant> columnData;
+ for (int column = 0; column < columnStrings.count(); ++column)
+ columnData << columnStrings[column];
+
+ if (position > indentations.last()) {
+ // The last child of the current parent is now the new parent
+ // unless the current parent has no children.
+
+ if (parents.last()->childCount() > 0) {
+ parents << parents.last()->child(parents.last()->childCount()-1);
+ indentations << position;
+ }
+ } else {
+ while (position < indentations.last() && parents.count() > 0) {
+ parents.pop_back();
+ indentations.pop_back();
+ }
+ }
+
+ // Append a new item to the current parent's list of children.
+ parents.last()->appendChild(new TreeItem(columnData, parents.last()));
+ }
+
+ number++;
+ }
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.h
new file mode 100644
index 000000000..9d02df605
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreeview-dnd/treemodel.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef TREEMODEL_H
+#define TREEMODEL_H
+
+#include <QAbstractItemModel>
+#include <QModelIndex>
+#include <QVariant>
+
+class TreeItem;
+
+class TreeModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ TreeModel(const QStringList &strings, QObject *parent = 0);
+ ~TreeModel();
+
+ QVariant data(const QModelIndex &index, int role) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column,
+ const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex &index) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+private:
+ void setupModelData(const QStringList &lines, TreeItem *parent);
+
+ TreeItem *rootItem;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/main.cpp
new file mode 100644
index 000000000..08343ac18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.cpp
new file mode 100644
index 000000000..1c85cf7cf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.cpp
@@ -0,0 +1,111 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ treeWidget = QTreeWidget(self)
+//! [0]
+
+//! [1]
+ treeWidget.setColumnCount(2)
+//! [1] //! [2]
+ headers = QStringList()
+ headers << tr("Subject") << tr("Default")
+ treeWidget.setHeaderLabels(headers)
+//! [2]
+
+//! [3]
+ cities = QTreeWidgetItem(treeWidget)
+ cities.setText(0, tr("Cities"))
+ osloItem = QTreeWidgetItem(cities)
+ osloItem.setText(0, tr("Oslo"))
+ osloItem.setText(1, tr("Yes"))
+//! [3]
+
+//! [4] //! [5]
+ planets = QTreeWidgetItem(treeWidget, cities)
+//! [4]
+ planets.setText(0, tr("Planets"))
+//! [5]
+
+//! [6]
+ item = QTreeWidgetItem()
+//! [6]
+
+//! [7]
+ found = treeWidget.findItems(itemText, Qt.MatchWildcard)
+
+ for item in found:
+ treeWidget.setItemSelected(item, True)
+ # Show the item.text(0) for each item.
+
+//! [7]
+
+//! [8]
+ parent = currentItem.parent()
+ if parent:
+ Item = QTreeWidgetItem(parent, treeWidget.currentItem())
+ else
+//! [8] //! [9]
+ Item = QTreeWidgetItem(treeWidget, treeWidget.currentItem())
+//! [9]
+
+//! [10]
+ parent = currentItem.parent()
+
+ if parent:
+ index = parent.indexOfChild(treeWidget->currentItem())
+ delete parent.takeChild(index)
+ else:
+ index = treeWidget.indexOfTopLevelItem(treeWidget->currentItem())
+ delete treeWidget.takeTopLevelItem(index)
+//! [10] //! [11]
+
+//! [11]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.h
new file mode 100644
index 000000000..30a6ede95
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidget-using/mainwindow.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QTreeWidget;
+class QTreeWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void findItems();
+ void insertItem();
+ void removeItem();
+ void sortAscending();
+ void sortDescending();
+ void updateMenus(QTreeWidgetItem *current);
+ void updateSortItems();
+
+private:
+ void setupTreeItems();
+
+ QAction *ascendingAction;
+ QAction *autoSortAction;
+ QAction *descendingAction;
+ QAction *insertAction;
+ QAction *removeAction;
+ QTreeWidget *treeWidget;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/main.cpp
new file mode 100644
index 000000000..08343ac18
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp
new file mode 100644
index 000000000..a3579b789
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp
@@ -0,0 +1,59 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ it = QTreeWidgetItemIterator(treeWidget)
+ while it:
+ if it.text(0) == itemText:
+ *it.setSelected(True)
+ ++it
+//! [0]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.h
new file mode 100644
index 000000000..30a6ede95
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class QTreeWidget;
+class QTreeWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void findItems();
+ void insertItem();
+ void removeItem();
+ void sortAscending();
+ void sortDescending();
+ void updateMenus(QTreeWidgetItem *current);
+ void updateSortItems();
+
+private:
+ void setupTreeItems();
+
+ QAction *ascendingAction;
+ QAction *autoSortAction;
+ QAction *descendingAction;
+ QAction *insertAction;
+ QAction *removeAction;
+ QTreeWidget *treeWidget;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/evaluation/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/evaluation/main.cpp
new file mode 100644
index 000000000..45f1788c1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/evaluation/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtScript>
+
+int main(int argc, char *argv[])
+{
+//! [0]
+ QScriptEngine engine;
+ qDebug() << "the magic number is:" << engine.evaluate("1 + 2").toNumber();
+//! [0]
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/main.cpp
new file mode 100644
index 000000000..4406c8298
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QObject>
+#include <QtScript>
+#include "myobject.h"
+
+int main(int argc, char *argv[])
+{
+//! [0]
+ QScriptEngine engine;
+ QObject *someObject = new MyObject;
+ QScriptValue objectValue = engine.newQObject(someObject);
+ engine.globalObject().setProperty("myObject", objectValue);
+//! [0]
+ qDebug() << "myObject's calculate() function returns"
+ << engine.evaluate("myObject.calculate(10)").toNumber();
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.cpp
new file mode 100644
index 000000000..d063540e7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "myobject.h"
+
+MyObject::MyObject()
+{
+}
+
+int MyObject::calculate(int value) const
+{
+ int total = 0;
+ for (int i = 0; i <= value; ++i)
+ total += i;
+ return total;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.h
new file mode 100644
index 000000000..ebc597fcf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringobjects/myobject.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MYOBJECT_H
+#define MYOBJECT_H
+
+#include <QObject>
+
+class MyObject : public QObject
+{
+ Q_OBJECT
+
+public:
+ MyObject();
+
+public slots:
+ int calculate(int value) const;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/main.cpp
new file mode 100644
index 000000000..3b45042cf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/registeringvalues/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtScript>
+
+int main(int argc, char *argv[])
+{
+ QScriptEngine engine;
+//! [0]
+ engine.globalObject().setProperty("foo", 123);
+ qDebug() << "foo times two is:" << engine.evaluate("foo * 2").toNumber();
+//! [0]
+ return 0;
+}
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/main.cpp
new file mode 100644
index 000000000..2ac44fb63
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/main.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QTextEdit>
+#include <QTimer>
+#include <QtScript>
+#include "myobject.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QScriptEngine engine;
+ QFile scriptFile(":/object.js");
+ scriptFile.open(QFile::ReadOnly);
+ engine.evaluate(scriptFile.readAll());
+ scriptFile.close();
+
+ QTextEdit editor;
+ QTimer timer;
+ QScriptValue constructor = engine.evaluate("Object");
+ QScriptValueList arguments;
+ arguments << engine.newQObject(&timer);
+ arguments << engine.newQObject(&editor);
+ QScriptValue object = constructor.construct(arguments);
+ if (engine.hasUncaughtException()) {
+ qDebug() << engine.uncaughtException().toString();
+ }
+
+ editor.show();
+ timer.start(1000);
+
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/object.js b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/object.js
new file mode 100644
index 000000000..44ad0e657
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/object.js
@@ -0,0 +1,18 @@
+function Object(timer, editor)
+{
+ this.editor = editor;
+ this.counter = 0;
+ timer.timeout.connect(notify);
+ timer.timeout.connect(this, this.addLine);
+}
+
+Object.prototype.addLine = function()
+{
+ this.editor.append(this.counter);
+ this.counter += 1;
+}
+
+function notify()
+{
+ print("timeout() received");
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.qrc
new file mode 100644
index 000000000..fc7ff67b9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qtscript/scriptedslot/scriptedslot.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>object.js</file>
+ </qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/main.cpp
new file mode 100644
index 000000000..74299e228
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QtUiTools>
+
+#include "mywidget.h"
+
+//! [0]
+def loadCustomWidget(parent):
+ loader = QUiLoader()
+
+ availableWidgets = loader.availableWidgets()
+
+ if availableWidgets.contains("AnalogClock"):
+ myWidget = loader.createWidget("AnalogClock", parent)
+
+ return myWidget
+//! [0]
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MyWidget widget;
+ widget.show();
+
+ QWidget *customWidget = loadCustomWidget(0);
+ customWidget->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/myform.ui b/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/myform.ui
new file mode 100644
index 000000000..00702e860
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/myform.ui
@@ -0,0 +1,130 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>Form</class>
+ <widget class="QWidget" name="Form" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>258</width>
+ <height>224</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Export Document</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>8</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="groupBox" >
+ <property name="title" >
+ <string>Export Options</string>
+ </property>
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>8</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="0" >
+ <widget class="QRadioButton" name="radioButton_2" >
+ <property name="text" >
+ <string>&amp;DocBook</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QRadioButton" name="radioButton" >
+ <property name="text" >
+ <string>&amp;LaTeX</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QCheckBox" name="checkBox_2" >
+ <property name="text" >
+ <string>Include p&amp;ictures</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QCheckBox" name="checkBox" >
+ <property name="text" >
+ <string>&amp;Compress</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QRadioButton" name="radioButton_2_2" >
+ <property name="text" >
+ <string>&amp;HTML</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QRadioButton" name="radioButton_3" >
+ <property name="text" >
+ <string>&amp;PostScript</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" >
+ <widget class="QRadioButton" name="radioButton_4" >
+ <property name="text" >
+ <string>PD&amp;F</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QCheckBox" name="checkBox_3" >
+ <property name="text" >
+ <string>Include &amp;metadata</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QCheckBox" name="checkBox_4" >
+ <property name="text" >
+ <string>Create inde&amp;x</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.cpp
new file mode 100644
index 000000000..70b136e9c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QtUiTools>
+
+#include "mywidget.h"
+
+//! [0]
+class MyWidget(QWidget):
+ def __init__(self, parent):
+ super(QWidget, self).__init__(parent)
+ loader = QUiLoader()
+ file = QFile(":/forms/myform.ui")
+ file.open(QFile.ReadOnly)
+ myWidget = loader.load(file, self)
+ file.close()
+
+ layout = QVBoxLayout()
+ layout.addWidget(myWidget)
+ self.setLayout(layout)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.h
new file mode 100644
index 000000000..62c38ca0a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MYWIDGET_H
+#define MYWIDGET_H
+
+#include <QWidget>
+
+class MyWidget : public QWidget
+{
+public:
+ MyWidget(QWidget *parent = 0);
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.qrc
new file mode 100644
index 000000000..47684d68b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/quiloader/mywidget.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/forms">
+<file>myform.ui</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedcontainer/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedcontainer/main.cpp
new file mode 100644
index 000000000..b94b2cea9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedcontainer/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QX11EmbedContainer>
+
+//! [0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ if (app.arguments().count() != 2) {
+ qFatal("Error - expected executable path as argument");
+ return 1;
+ }
+
+ QX11EmbedContainer container;
+ container.show();
+
+ QProcess process(&container);
+ QString executable(app.arguments()[1]);
+ QStringList arguments;
+ arguments << QString::number(container.winId());
+ process.start(executable, arguments);
+
+ int status = app.exec();
+ process.close();
+ return status;
+}
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.cpp
new file mode 100644
index 000000000..55fd34b23
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "embedwidget.h"
+
+EmbedWidget::EmbedWidget(QWidget *parent)
+ : QX11EmbedWidget(parent)
+{
+ gradient = QRadialGradient(100, 100, 90, 60, 60);
+ gradient.setColorAt(0.0, Qt::white);
+ gradient.setColorAt(0.9, QColor(192, 192, 255));
+ gradient.setColorAt(1.0, QColor(0, 32, 64));
+}
+
+QSize EmbedWidget::sizeHint() const
+{
+ return QSize(200, 200);
+}
+
+void EmbedWidget::paintEvent(QPaintEvent *event)
+{
+ QPainter painter;
+ painter.begin(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.fillRect(event->rect(), QBrush(gradient));
+ painter.end();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.h
new file mode 100644
index 000000000..cf2fdccff
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/embedwidget.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef EMBEDWIDGET_H
+#define EMBEDWIDGET_H
+
+#include <QRadialGradient>
+#include <QSize>
+#include <QX11EmbedWidget>
+
+class QPaintEvent;
+
+class EmbedWidget : public QX11EmbedWidget
+{
+ Q_OBJECT
+
+public:
+ EmbedWidget(QWidget *parent = 0);
+ QSize sizeHint() const;
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private:
+ QRadialGradient gradient;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/main.cpp
new file mode 100644
index 000000000..b966d1eab
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qx11embedwidget/main.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include "embedwidget.h"
+
+//! [0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ if (app.arguments().count() != 2) {
+ qFatal("Error - expected window id as argument");
+ return 1;
+ }
+
+ QString windowId(app.arguments()[1]);
+ EmbedWidget window;
+ window.embedInto(windowId.toULong());
+ window.show();
+
+ return app.exec();
+}
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlquery/bindingExample.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlquery/bindingExample.cpp
new file mode 100644
index 000000000..103680a7f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlquery/bindingExample.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+ QBuffer device;
+ device.setData(myQString.toUtf8());
+ device.open(QIODevice::ReadOnly);
+
+ QXmlQuery query;
+ query.setQuery("doc($inputDocument)/query[theDocument]");
+ query.bindVariable("inputDocument", &device);
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlschema/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlschema/main.cpp
new file mode 100644
index 000000000..f8e0b07b9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlschema/main.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtCore>
+#include <QtXmlPatterns>
+
+class Schema
+{
+ public:
+ void loadFromUrl() const;
+ void loadFromFile() const;
+ void loadFromData() const;
+};
+
+void Schema::loadFromUrl() const
+{
+//! [0]
+ url = QUrl("http://www.schema-example.org/myschema.xsd")
+
+ schema = QXmlSchema()
+ if schema.load(url):
+ qDebug("schema is valid")
+ else:
+ qDebug("schema is invalid")
+//! [0]
+}
+
+void Schema::loadFromFile() const
+{
+//! [1]
+ file = QFile("myschema.xsd")
+ file.open(QIODevice.ReadOnly)
+
+ schema = QXmlSchema()
+ schema.load(file, QUrl.fromLocalFile(file.fileName()))
+
+ if schema.isValid():
+ qDebug("schema is valid")
+ else:
+ qDebug("schema is invalid")
+//! [1]
+}
+
+void Schema::loadFromData() const
+{
+//! [2]
+ data = QByteArray("<?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>" )
+
+ schema = QXmlSchema()
+ schema.load(data)
+
+ if schema.isValid():
+ qDebug("schema is valid")
+ else:
+ qDebug("schema is invalid")
+//! [2]
+}
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ Schema schema;
+
+ schema.loadFromUrl();
+ schema.loadFromFile();
+ schema.loadFromData();
+
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlschemavalidator/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlschemavalidator/main.cpp
new file mode 100644
index 000000000..1ec0652e9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlschemavalidator/main.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 validateFromUrl():
+//! [0]
+ schema = getSchema()
+
+ url = QUrl("http://www.schema-example.org/test.xml")
+
+ validator = QXmlSchemaValidator(schema)
+ if validator.validate(url):
+ print "instance document is valid"
+ else:
+ print "instance document is invalid"
+//! [0]
+
+def validateFromFile():
+//! [1]
+ schema = getSchema()
+
+ file = QFile("test.xml")
+ file.open(QIODevice.ReadOnly)
+
+ validator = QXmlSchemaValidator(schema)
+ if validator.validate(file, QUrl.fromLocalFile(file.fileName())):
+ print "instance document is valid"
+ else:
+ print "instance document is invalid"
+//! [1]
+}
+
+def validateFromData():
+//! [2]
+ schema = getSchema()
+
+ data = QByteArray("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test></test>")
+
+ buffer = QBuffer(data)
+ buffer.open(QIODevice.ReadOnly)
+
+ QXmlSchemaValidator validator(schema)
+ if validator.validate(buffer):
+ print "instance document is valid"
+ else:
+ print "instance document is invalid"
+//! [2]
+
+def validateComplete():
+//! [3]
+ schemaUrl = QUrl("file:///home/user/schema.xsd")
+
+ schema = QXmlSchema()
+ schema.load(schemaUrl)
+
+ if schema.isValid():
+ file = QFile("test.xml")
+ file.open(QIODevice.ReadOnly)
+
+ validator = QXmlSchemaValidator(schema)
+ if validator.validate(file, QUrl.fromLocalFile(file.fileName())):
+ print "instance document is valid"
+ else:
+ print "instance document is invalid"
+ }
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlstreamwriter/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlstreamwriter/main.cpp
new file mode 100644
index 000000000..9838dab1d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/qxmlstreamwriter/main.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QCoreApplication>
+#include <QFile>
+#include <QXmlStreamWriter>
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+ QFile output;
+ output.open(stdout, QIODevice::WriteOnly);
+//! [write output]
+//! [start stream]
+ QXmlStreamWriter stream(&output);
+ stream.setAutoFormatting(true);
+ stream.writeStartDocument();
+//! [start stream]
+ stream.writeDTD("<!DOCTYPE xbel>");
+ stream.writeStartElement("xbel");
+ stream.writeAttribute("version", "1.0");
+ stream.writeStartElement("folder");
+ stream.writeAttribute("folded", "no");
+//! [write element]
+ stream.writeStartElement("bookmark");
+ stream.writeAttribute("href", "http://www.qtsoftware.com/");
+ stream.writeTextElement("title", "Qt Home");
+ stream.writeEndElement(); // bookmark
+//! [write element]
+ stream.writeEndElement(); // folder
+ stream.writeEndElement(); // xbel
+//! [finish stream]
+ stream.writeEndDocument();
+//! [finish stream]
+//! [write output]
+ output.close();
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/main.cpp
new file mode 100644
index 000000000..48588d081
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example that shows how selections can be used directly on a model.
+ It shows the result of some selections made using a table view.
+*/
+
+#include <QApplication>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QMainWindow *window = new MainWindow;
+ window->show();
+ window->resize(640, 480);
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/model.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/model.h
new file mode 100644
index 000000000..886e77852
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/model.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QVariant>
+
+class TableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ TableModel(int rows = 1, int columns = 1, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+
+private:
+ QList<QStringList> rowList;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/window.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/window.cpp
new file mode 100644
index 000000000..2d86dd951
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/window.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ window.cpp
+
+ A minimal subclass of QTableView with slots to allow the selection model
+ to be monitored.
+*/
+
+#include <QAbstractItemModel>
+#include <QItemSelection>
+#include <QItemSelectionModel>
+#include <QMenu>
+#include <QMenuBar>
+#include <QStatusBar>
+
+#include "model.h"
+#include "window.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ setWindowTitle("Selected Items in a Table Model");
+
+ model = new TableModel(8, 4, this);
+
+ table = new QTableView(this);
+ table->setModel(model);
+
+ QMenu *actionMenu = new QMenu(tr("&Actions"), this);
+ QAction *fillAction = actionMenu->addAction(tr("&Fill Selection"));
+ QAction *clearAction = actionMenu->addAction(tr("&Clear Selection"));
+ QAction *selectAllAction = actionMenu->addAction(tr("&Select All"));
+ menuBar()->addMenu(actionMenu);
+
+ connect(fillAction, SIGNAL(triggered()), this, SLOT(fillSelection()));
+ connect(clearAction, SIGNAL(triggered()), this, SLOT(clearSelection()));
+ connect(selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll()));
+
+ selectionModel = table->selectionModel();
+
+ statusBar();
+ setCentralWidget(table);
+}
+
+void MainWindow::fillSelection()
+{
+//! [0]
+ QModelIndexList indexes = selectionModel->selectedIndexes();
+ QModelIndex index;
+
+ foreach(index, indexes) {
+ QString text = QString("(%1,%2)").arg(index.row()).arg(index.column());
+ model->setData(index, text);
+ }
+//! [0]
+}
+
+void MainWindow::clearSelection()
+{
+ QModelIndexList indexes = selectionModel->selectedIndexes();
+ QModelIndex index;
+
+ foreach(index, indexes)
+ model->setData(index, "");
+}
+
+void MainWindow::selectAll()
+{
+//! [1]
+ QModelIndex parent = QModelIndex();
+//! [1] //! [2]
+ QModelIndex topLeft = model->index(0, 0, parent);
+ QModelIndex bottomRight = model->index(model->rowCount(parent)-1,
+ model->columnCount(parent)-1, parent);
+//! [2]
+
+//! [3]
+ QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, QItemSelectionModel::Select);
+//! [3]
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/window.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/window.h
new file mode 100644
index 000000000..63f566384
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/reading-selections/window.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QItemSelection>
+#include <QMainWindow>
+#include <QAbstractItemModel>
+#include <QWidget>
+#include <QTableView>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow(QWidget *parent = 0);
+
+private slots:
+ void fillSelection();
+ void clearSelection();
+ void selectAll();
+
+private:
+ QAbstractItemModel *model;
+ QItemSelectionModel *selectionModel;
+ QTableView *table;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/scribe-overview/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/scribe-overview/main.cpp
new file mode 100644
index 000000000..49597ecc3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/scribe-overview/main.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+from PySide2.QtGui import *
+
+# edit : QTextEdit
+def mergeFormat(edit):
+//! [0]
+ document = edit.document()
+ cursor = QTextCursor(document)
+
+ cursor.movePosition(QTextCursor.Start)
+ cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor)
+
+ format = QTextCharFormat()
+ format.setFontWeight(QFont.Bold)
+
+ cursor.mergeCharFormat(format)
+//! [0]
+
+def main():
+ aStringContainingHTMLtext QString("<h1>Scribe Overview</h1>")
+
+ app = QApplication(sys.argv)
+
+//! [1]
+ editor = QTextEdit(None)
+ editor.setHtml(aStringContainingHTMLtext)
+ editor.show()
+//! [1]
+
+ return app.exec_()
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/scriptdebugger.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/scriptdebugger.cpp
new file mode 100644
index 000000000..e88a5c032
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/scriptdebugger.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QtScript>
+#include <QtScriptTools>
+
+// Perhaps shpw entire example for getting debugger up with script
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ QString fileName("helloscript.qs");
+ QFile scriptFile(fileName);
+ scriptFile.open(QIODevice::ReadOnly);
+ QTextStream stream(&scriptFile);
+ QString contents = stream.readAll();
+ scriptFile.close();
+
+ QScriptEngine *engine = new QScriptEngine();
+
+ QScriptEngineDebugger *debugger = new QScriptEngineDebugger();
+ debugger->attachTo(engine);
+
+ // Set up configuration with only stack and code
+ QWidget *widget = new QWidget;
+//![0]
+ codeWindow = debugger.widget(QScriptEngineDebugger.CodeWidget)
+ stackWidget = debugger.widget(QScriptEngineDebugger.StackWidget)
+
+ layout = QHBoxLayout()
+ layout.addWidget(codeWindow)
+ layout.addWidget(stackWidget)
+//![0]
+
+//![1]
+ continueAction = debugger.action(QScriptEngineDebugger.ContinueAction)
+ stepOverAction = debugger.action(QScriptEngineDebugger.StepOverAction)
+ stepIntoAction = debugger.action(QScriptEngineDebugger.StepIntoAction)
+
+ toolBar = QToolBar()
+ toolBar.addAction(continueAction)
+//![1]
+ toolBar->addAction(stepOverAction);
+ toolBar->addAction(stepIntoAction);
+
+ layout->addWidget(toolBar);
+ continueAction->setIcon(QIcon("copy.png"));
+
+ debugger->setAutoShowStandardWindow(false);
+
+ widget->setLayout(layout);
+ widget->show();
+
+ QPushButton button;
+ QScriptValue scriptButton = engine->newQObject(&button);
+ engine->globalObject().setProperty("button", scriptButton);
+
+//![2]
+ debugger.action(QScriptEngineDebugger.InterruptAction).trigger()
+ engine.evaluate(contents, fileName)
+//![2]
+
+ return app.exec();
+}
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/finalwidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/finalwidget.cpp
new file mode 100644
index 000000000..3f42a50d3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/finalwidget.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+finalwidget.cpp
+
+A widget to display an image and a label containing a description.
+*/
+
+#include <QtWidgets>
+#include "finalwidget.h"
+
+FinalWidget::FinalWidget(QWidget *parent, const QString &name,
+ const QSize &labelSize)
+ : QFrame(parent)
+{
+ hasImage = false;
+ imageLabel = new QLabel;
+ imageLabel->setFrameShadow(QFrame::Sunken);
+ imageLabel->setFrameShape(QFrame::StyledPanel);
+ imageLabel->setMinimumSize(labelSize);
+ nameLabel = new QLabel(name);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(imageLabel, 1);
+ layout->addWidget(nameLabel, 0);
+ setLayout(layout);
+}
+
+/*!
+ If the mouse moves far enough when the left mouse button is held down,
+ start a drag and drop operation.
+*/
+
+void FinalWidget::mouseMoveEvent(QMouseEvent *event)
+{
+ if (!(event->buttons() & Qt::LeftButton))
+ return;
+ if ((event->pos() - dragStartPosition).manhattanLength()
+ < QApplication::startDragDistance())
+ return;
+ if (!hasImage)
+ return;
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+//! [0]
+ output = QByteArray()
+ outputBuffer = QBuffer(output)
+ outputBuffer.open(QIODevice.WriteOnly)
+ imageLabel.pixmap().toImage().save(outputBuffer, "PNG")
+ mimeData.setData("image/png", output)
+//! [0]
+/*
+//! [1]
+ mimeData.setImageData(QVariant(imageLabel.pixmap()))
+//! [1]
+*/
+ drag.setMimeData(mimeData)
+ drag.setPixmap(imageLabel.pixmap().scaled(64, 64, Qt.KeepAspectRatio))
+//! [2]
+ drag.setHotSpot(QPoint(drag.pixmap().width()/2,
+ drag.pixmap().height()))
+//! [2]
+
+ drag->start();
+}
+
+/*!
+ Check for left mouse button presses in order to enable drag and drop.
+*/
+
+void FinalWidget::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton)
+ dragStartPosition = event->pos();
+}
+
+const QPixmap* FinalWidget::pixmap() const
+{
+ return imageLabel->pixmap();
+}
+
+void FinalWidget::setPixmap(const QPixmap &pixmap)
+{
+ imageLabel->setPixmap(pixmap);
+ hasImage = true;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/finalwidget.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/finalwidget.h
new file mode 100644
index 000000000..90c06712f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/finalwidget.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef FINALWIDGET_H
+#define FINALWIDGET_H
+
+#include <QFrame>
+#include <QImage>
+#include <QPoint>
+#include <QSize>
+
+class QGridLayout;
+class QLabel;
+class QMouseEvent;
+class QWidget;
+
+class FinalWidget : public QFrame
+{
+ Q_OBJECT
+
+public:
+ FinalWidget(QWidget *parent, const QString &name, const QSize &labelSize);
+ void setPixmap(const QPixmap &pixmap);
+ const QPixmap *pixmap() const;
+
+protected:
+ void mouseMoveEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+
+private:
+ void createImage();
+
+ bool hasImage;
+ QImage originalImage;
+ QLabel *imageLabel;
+ QLabel *nameLabel;
+ QPoint dragStartPosition;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/main.cpp
new file mode 100644
index 000000000..8d7109b9a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include "viewer.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Viewer viewer;
+ viewer.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/screenwidget.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/screenwidget.cpp
new file mode 100644
index 000000000..f3cc73327
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/screenwidget.cpp
@@ -0,0 +1,227 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+screenwidget.cpp
+
+A widget to display colour components from an image using independently
+selected colors. Controls are provided to allow the image to be inverted, and
+the color to be selection via a standard dialog. The image is displayed in a
+label widget.
+*/
+
+#include <QApplication>
+#include <QColorDialog>
+#include <QGridLayout>
+#include <QImage>
+#include <QLabel>
+#include <QMenu>
+#include <QMimeData>
+#include <QMouseEvent>
+#include <QPixmap>
+#include <QPushButton>
+#include <QWidget>
+
+#include "screenwidget.h"
+
+/*!
+Initializes the paint color, the mask color (cyan, magenta,
+or yellow), connects the color selector and invert checkbox to functions,
+and creates a two-by-two grid layout.
+*/
+
+ScreenWidget::ScreenWidget(QWidget *parent, QColor initialColor,
+ const QString &name, Separation mask,
+ const QSize &labelSize)
+ : QFrame(parent)
+{
+ paintColor = initialColor;
+ maskColor = mask;
+ inverted = false;
+
+ imageLabel = new QLabel;
+ imageLabel->setFrameShadow(QFrame::Sunken);
+ imageLabel->setFrameShape(QFrame::StyledPanel);
+ imageLabel->setMinimumSize(labelSize);
+
+ nameLabel = new QLabel(name);
+ colorButton = new QPushButton(tr("Modify..."));
+ colorButton->setBackgroundRole(QPalette::Button);
+ colorButton->setMinimumSize(32, 32);
+
+ QPalette palette(colorButton->palette());
+ palette.setColor(QPalette::Button, initialColor);
+ colorButton->setPalette(palette);
+
+ invertButton = new QPushButton(tr("Invert"));
+ //invertButton->setToggleButton(true);
+ //invertButton->setOn(inverted);
+ invertButton->setEnabled(false);
+
+ connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
+ connect(invertButton, SIGNAL(clicked()), this, SLOT(invertImage()));
+
+ QGridLayout *gridLayout = new QGridLayout;
+ gridLayout->addWidget(imageLabel, 0, 0, 1, 2);
+ gridLayout->addWidget(nameLabel, 1, 0);
+ gridLayout->addWidget(colorButton, 1, 1);
+ gridLayout->addWidget(invertButton, 2, 1, 1, 1);
+ setLayout(gridLayout);
+}
+
+/*!
+ Creates a new image by separating out the cyan, magenta, or yellow
+ component, depending on the mask color specified in the constructor.
+
+ The amount of the component found in each pixel of the image is used
+ to determine how much of a user-selected ink is used for each pixel
+ in the new image for the label widget.
+*/
+
+void ScreenWidget::createImage()
+{
+ newImage = originalImage.copy();
+
+ // Create CMY components for the ink being used.
+ float cyanInk = (255 - paintColor.red())/255.0;
+ float magentaInk = (255 - paintColor.green())/255.0;
+ float yellowInk = (255 - paintColor.blue())/255.0;
+
+ int (*convert)(QRgb);
+
+ switch (maskColor) {
+ case Cyan:
+ convert = qRed;
+ break;
+ case Magenta:
+ convert = qGreen;
+ break;
+ case Yellow:
+ convert = qBlue;
+ break;
+ }
+
+ for (int y = 0; y < newImage.height(); ++y) {
+ for (int x = 0; x < newImage.width(); ++x) {
+ QRgb p(originalImage.pixel(x, y));
+
+ // Separate the source pixel into its cyan component.
+ int amount;
+
+ if (inverted)
+ amount = convert(p);
+ else
+ amount = 255 - convert(p);
+
+ QColor newColor(
+ 255 - qMin(int(amount * cyanInk), 255),
+ 255 - qMin(int(amount * magentaInk), 255),
+ 255 - qMin(int(amount * yellowInk), 255));
+
+ newImage.setPixel(x, y, newColor.rgb());
+ }
+ }
+
+ imageLabel->setPixmap(QPixmap::fromImage(newImage));
+}
+
+/*!
+ Returns a pointer to the modified image.
+*/
+
+QImage* ScreenWidget::image()
+{
+ return &newImage;
+}
+
+/*!
+ Sets whether the amount of ink applied to the canvas is to be inverted
+ (subtracted from the maximum value) before the ink is applied.
+*/
+
+void ScreenWidget::invertImage()
+{
+ //inverted = invertButton->isOn();
+ inverted = !inverted;
+ createImage();
+ emit imageChanged();
+}
+
+/*!
+ Separate the current image into cyan, magenta, and yellow components.
+ Create a representation of how each component might appear when applied
+ to a blank white piece of paper.
+*/
+
+void ScreenWidget::setColor()
+{
+ QColor newColor = QColorDialog::getColor(paintColor);
+
+ if (newColor.isValid()) {
+ paintColor = newColor;
+ QPalette palette(colorButton->palette());
+ palette.setColor(QPalette::Button, paintColor);
+ colorButton->setPalette(palette);
+ createImage();
+ emit imageChanged();
+ }
+}
+
+/*!
+ Records the original image selected by the user, creates a color
+ separation, and enables the invert image checkbox.
+*/
+
+void ScreenWidget::setImage(QImage &image)
+{
+ originalImage = image;
+ createImage();
+ invertButton->setEnabled(true);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/screenwidget.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/screenwidget.h
new file mode 100644
index 000000000..ad1c76c84
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/screenwidget.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef SCREENWIDGET_H
+#define SCREENWIDGET_H
+
+#include <QColor>
+#include <QFrame>
+#include <QImage>
+#include <QSize>
+
+class QGridLayout;
+class QLabel;
+class QPushButton;
+class QWidget;
+
+class ScreenWidget : public QFrame
+{
+ Q_OBJECT
+public:
+ enum Separation { Cyan, Magenta, Yellow };
+
+ ScreenWidget(QWidget *parent, QColor initialColor, const QString &name,
+ Separation mask, const QSize &labelSize);
+ void setImage(QImage &image);
+ QImage* image();
+
+signals:
+ void imageChanged();
+
+public slots:
+ void setColor();
+ void invertImage();
+
+private:
+ void createImage();
+
+ bool inverted;
+ QColor paintColor;
+ QImage newImage;
+ QImage originalImage;
+ QLabel *imageLabel;
+ QLabel *nameLabel;
+ QPushButton *colorButton;
+ QPushButton *invertButton;
+ Separation maskColor;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/viewer.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/viewer.cpp
new file mode 100644
index 000000000..65eabb600
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/viewer.cpp
@@ -0,0 +1,338 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+viewer.cpp
+
+Provides a main window for displaying a user-specified original image
+with three color separations in a grid layout.
+
+A main menu provides entries for selecting files, and adjusting the
+brightness of the separations.
+*/
+
+#include <QtWidgets>
+
+#include "finalwidget.h"
+#include "screenwidget.h"
+#include "viewer.h"
+
+/*
+ Constructor: initializes a default value for the brightness, creates
+ the main menu entries, and constructs a central widget that contains
+ enough space for images to be displayed.
+*/
+
+Viewer::Viewer()
+{
+ setWindowTitle(tr("QImage Color Separations"));
+
+ brightness = 255;
+
+ createMenus();
+ setCentralWidget(createCentralWidget());
+}
+
+/*
+ Creates a main menu with two entries: a File menu, to allow the image
+ to be selected, and a Brightness menu to allow the brightness of the
+ separations to be changed.
+
+ Initially, the Brightness menu items are disabled, but the first entry in
+ the menu is checked to reflect the default brightness.
+*/
+
+void Viewer::createMenus()
+{
+ fileMenu = new QMenu(tr("&File"), this);
+ brightnessMenu = new QMenu(tr("&Brightness"), this);
+
+ QAction *openAction = fileMenu->addAction(tr("&Open..."));
+ openAction->setShortcut(QKeySequence("Ctrl+O"));
+ saveAction = fileMenu->addAction(tr("&Save..."));
+ saveAction->setShortcut(QKeySequence("Ctrl+S"));
+ saveAction->setEnabled(false);
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(QKeySequence("Ctrl+Q"));
+
+ QAction *noBrightness = brightnessMenu->addAction(tr("&0%"));
+ noBrightness->setCheckable(true);
+ QAction *quarterBrightness = brightnessMenu->addAction(tr("&25%"));
+ quarterBrightness->setCheckable(true);
+ QAction *halfBrightness = brightnessMenu->addAction(tr("&50%"));
+ halfBrightness->setCheckable(true);
+ QAction *threeQuartersBrightness = brightnessMenu->addAction(tr("&75%"));
+ threeQuartersBrightness->setCheckable(true);
+ QAction *fullBrightness = brightnessMenu->addAction(tr("&100%"));
+ fullBrightness->setCheckable(true);
+
+ menuMap[noBrightness] = None;
+ menuMap[quarterBrightness] = Quarter;
+ menuMap[halfBrightness] = Half;
+ menuMap[threeQuartersBrightness] = ThreeQuarters;
+ menuMap[fullBrightness] = Full;
+
+ currentBrightness = fullBrightness;
+ currentBrightness->setChecked(true);
+ brightnessMenu->setEnabled(false);
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(brightnessMenu);
+
+ connect(openAction, SIGNAL(triggered()), this, SLOT(chooseFile()));
+ connect(saveAction, SIGNAL(triggered()), this, SLOT(saveImage()));
+ connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ connect(brightnessMenu, SIGNAL(triggered(QAction *)), this,
+ SLOT(setBrightness(QAction *)));
+}
+
+/*
+ Constructs a central widget for the window consisting of a two-by-two
+ grid of labels, each of which will contain an image. We restrict the
+ size of the labels to 256 pixels, and ensure that the window cannot
+ be resized.
+*/
+
+QFrame* Viewer::createCentralWidget()
+{
+ QFrame* frame = new QFrame(this);
+ grid = new QGridLayout(frame);
+ grid->setSpacing(8);
+ grid->setMargin(4);
+
+ layout()->setSizeConstraint(QLayout::SetFixedSize);
+
+ QSize labelSize(256, 256);
+
+ finalWidget = new FinalWidget(frame, tr("Final image"), labelSize);
+
+ cyanWidget = new ScreenWidget(frame, Qt::cyan, tr("Cyan"),
+ ScreenWidget::Cyan, labelSize);
+ magentaWidget = new ScreenWidget(frame, Qt::magenta, tr("Magenta"),
+ ScreenWidget::Magenta, labelSize);
+ yellowWidget = new ScreenWidget(frame, Qt::yellow, tr("Yellow"),
+ ScreenWidget::Yellow, labelSize);
+
+ connect(cyanWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
+ connect(magentaWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
+ connect(yellowWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
+
+ grid->addWidget(finalWidget, 0, 0, Qt::AlignTop | Qt::AlignHCenter);
+ grid->addWidget(cyanWidget, 0, 1, Qt::AlignTop | Qt::AlignHCenter);
+ grid->addWidget(magentaWidget, 1, 0, Qt::AlignTop | Qt::AlignHCenter);
+ grid->addWidget(yellowWidget, 1, 1, Qt::AlignTop | Qt::AlignHCenter);
+
+ return frame;
+}
+
+/*
+ Provides a dialog window to allow the user to specify an image file.
+ If a file is selected, the appropriate function is called to process
+ and display it.
+*/
+
+void Viewer::chooseFile()
+{
+ QString imageFile = QFileDialog::getOpenFileName(this,
+ tr("Choose an image file to open"), path, tr("Images (*.*)"));
+
+ if (!imageFile.isEmpty()) {
+ openImageFile(imageFile);
+ path = imageFile;
+ }
+}
+
+/*
+ Changes the value of the brightness according to the entry selected in the
+ Brightness menu. The selected entry is checked, and the previously selected
+ entry is unchecked.
+
+ The color separations are updated to use the new value for the brightness.
+*/
+
+void Viewer::setBrightness(QAction *action)
+{
+ if (!menuMap.contains(action) || scaledImage.isNull())
+ return;
+
+ Brightness amount = menuMap[action];
+
+ switch (amount) {
+ case None:
+ brightness = 0; break;
+ case Quarter:
+ brightness = 64; break;
+ case Half:
+ brightness = 128; break;
+ case ThreeQuarters:
+ brightness = 191; break;
+ case Full:
+ brightness = 255; break;
+ default: return;
+ }
+
+ currentBrightness->setChecked(false);
+ currentBrightness = action;
+ currentBrightness->setChecked(true);
+
+ createImage();
+}
+
+/*
+ Load the image from the file given, and create four pixmaps based
+ on the original image.
+
+ The window caption is set, and the Brightness menu enabled if the image file
+ can be loaded.
+*/
+
+void Viewer::openImageFile(QString &imageFile)
+{
+ QImage originalImage;
+
+ if (originalImage.load(imageFile)) {
+ setWindowTitle(imageFile);
+ //menuBar()->setItemEnabled(brightnessMenuId, true);
+ saveAction->setEnabled(true);
+ brightnessMenu->setEnabled(true);
+
+ /* Note: the ScaleMin value may be different for Qt 4. */
+ scaledImage = originalImage.scaled(256, 256, Qt::KeepAspectRatio);
+
+ cyanWidget->setImage(scaledImage);
+ magentaWidget->setImage(scaledImage);
+ yellowWidget->setImage(scaledImage);
+ createImage();
+ }
+ else
+ (void) QMessageBox::warning(this, tr("Cannot open file"),
+ tr("The selected file could not be opened."),
+ QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton);
+}
+
+/*
+ Creates an image by combining the contents of the three screens
+ to present a page preview.
+
+ The image associated with each screen is separated into cyan,
+ magenta, and yellow components. We add up the values for each
+ component from the three screen images, and subtract the totals
+ from the maximum value for each corresponding primary color.
+*/
+
+void Viewer::createImage()
+{
+ QImage newImage = scaledImage.copy();
+
+ QImage *image1 = cyanWidget->image();
+ QImage *image2 = magentaWidget->image();
+ QImage *image3 = yellowWidget->image();
+ int darkness = 255 - brightness;
+
+ for (int y = 0; y < newImage.height(); ++y) {
+ for (int x = 0; x < newImage.width(); ++x) {
+
+ // Create three screens, using the quantities of the source
+ // CMY components to determine how much of each of the
+ // inks are to be put on each screen.
+ QRgb p1(image1->pixel(x, y));
+ float cyan1 = 255 - qRed(p1);
+ float magenta1 = 255 - qGreen(p1);
+ float yellow1 = 255 - qBlue(p1);
+
+ QRgb p2(image2->pixel(x, y));
+ float cyan2 = 255 - qRed(p2);
+ float magenta2 = 255 - qGreen(p2);
+ float yellow2 = 255 - qBlue(p2);
+
+ QRgb p3(image3->pixel(x, y));
+ float cyan3 = 255 - qRed(p3);
+ float magenta3 = 255 - qGreen(p3);
+ float yellow3 = 255 - qBlue(p3);
+
+ QColor newColor(
+ qMax(255 - int(cyan1+cyan2+cyan3) - darkness, 0),
+ qMax(255 - int(magenta1+magenta2+magenta3) - darkness, 0),
+ qMax(255 - int(yellow1+yellow2+yellow3) - darkness, 0));
+
+ newImage.setPixel(x, y, newColor.rgb());
+ }
+ }
+
+ finalWidget->setPixmap(QPixmap::fromImage(newImage));
+}
+
+/*
+ Provides a dialog window to allow the user to save the image file.
+*/
+
+void Viewer::saveImage()
+{
+ QString imageFile = QFileDialog::getSaveFileName(this,
+ tr("Choose a filename to save the image"), "", tr("Images (*.png)"));
+
+ QFileInfo info(imageFile);
+
+ if (!info.baseName().isEmpty()) {
+ QString newImageFile = QFileInfo(info.absoluteDir(),
+ info.baseName() + ".png").absoluteFilePath();
+
+ if (!finalWidget->pixmap()->save(newImageFile, "PNG"))
+ (void) QMessageBox::warning(this, tr("Cannot save file"),
+ tr("The file could not be saved."),
+ QMessageBox::Cancel, QMessageBox::NoButton,
+ QMessageBox::NoButton);
+ }
+ else
+ (void) QMessageBox::warning(this, tr("Cannot save file"),
+ tr("Please enter a valid filename."),
+ QMessageBox::Cancel, QMessageBox::NoButton,
+ QMessageBox::NoButton);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/viewer.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/viewer.h
new file mode 100644
index 000000000..4e10f1f62
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/separations/viewer.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef VIEWER_H
+#define VIEWER_H
+
+#include <QImage>
+#include <QMainWindow>
+#include <QMap>
+
+class QAction;
+class QFrame;
+class QGridLayout;
+class QLabel;
+class QMenu;
+class FinalWidget;
+class ScreenWidget;
+
+class Viewer : public QMainWindow
+{
+ Q_OBJECT
+public:
+ enum Brightness { None, Quarter, Half, ThreeQuarters, Full };
+ Viewer();
+
+public slots:
+ void chooseFile();
+ void setBrightness(QAction *action);
+ void createImage();
+ void saveImage();
+
+private:
+ void createMenus();
+ QFrame *createCentralWidget();
+ void openImageFile(QString &filePath);
+
+ FinalWidget *finalWidget;
+ int brightness;
+ QAction *currentBrightness;
+ QAction *saveAction;
+ QGridLayout *grid;
+ QImage scaledImage;
+ QMap <QAction*,Brightness> menuMap;
+ QMenu *brightnessMenu;
+ QMenu *fileMenu;
+ QString path;
+ ScreenWidget *cyanWidget;
+ ScreenWidget *magentaWidget;
+ ScreenWidget *yellowWidget;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/settings/settings.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/settings/settings.cpp
new file mode 100644
index 000000000..7eaef2877
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/settings/settings.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+QWidget *win
+QWidget *panel
+
+void snippet_ctor1()
+{
+//! [0]
+ settings = QSettings("MySoft", "Star Runner")
+//! [0]
+}
+
+void snippet_ctor2()
+{
+//! [1]
+ QCoreApplication.setOrganizationName("MySoft")
+//! [1] //! [2]
+ QCoreApplication.setOrganizationDomain("mysoft.com")
+//! [2] //! [3]
+ QCoreApplication.setApplicationName("Star Runner")
+//! [3]
+
+//! [4]
+ settings = QSettings()
+//! [4]
+
+//! [5]
+ settings.setValue("editor/wrapMargin", 68)
+//! [5] //! [6]
+ margin = int(settings.value("editor/wrapMargin"))
+//! [6]
+ {
+//! [7]
+ margin = int(settings.value("editor/wrapMargin", 80))
+//! [7]
+ }
+
+//! [8]
+ settings.setValue("mainwindow/size", win.size())
+//! [8] //! [9]
+ settings.setValue("mainwindow/fullScreen", win.isFullScreen())
+//! [9] //! [10]
+ settings.setValue("outputpanel/visible", panel.isVisible())
+//! [10]
+
+//! [11]
+ settings.beginGroup("mainwindow")
+ settings.setValue("size", win.size())
+ settings.setValue("fullScreen", win.isFullScreen())
+ settings.endGroup()
+//! [11]
+
+//! [12]
+ settings.beginGroup("outputpanel")
+ settings.setValue("visible", panel.isVisible())
+ settings.endGroup()
+//! [12]
+}
+
+void snippet_locations()
+{
+//! [13]
+ obj1 = QSettings("MySoft", "Star Runner")
+//! [13] //! [14]
+ obj2 = QSettings("MySoft")
+ obj3 = QSettings(QSettings.SystemScope, "MySoft", "Star Runner")
+ obj4 = QSettings(QSettings.SystemScope, "MySoft")
+//! [14]
+
+ {
+//! [15]
+ settings = QSettings(QSettings.IniFormat, QSettings.UserScope,
+ "MySoft", "Star Runner")
+//! [15]
+ }
+
+ {
+ QSettings settings("starrunner.ini", QSettings.IniFormat)
+ }
+
+ {
+ QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft",
+ QSettings.NativeFormat)
+ }
+}
+
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow()
+
+ void writeSettings()
+ void readSettings()
+
+protected:
+ void closeEvent(QCloseEvent *event)
+}
+
+//! [16]
+class MainWindow(QMainWindow):
+ ...
+ def writeSettings(self):
+ self.settings = QSettings("Moose Soft", "Clipper")
+ self.settings.beginGroup("MainWindow")
+ self.settings.setValue("size", self.size())
+ self.settings.setValue("pos", self.pos())
+ self.settings.endGroup()
+//! [16]
+
+//! [17]
+ def readSettings(self):
+ self.settings = QSettings("Moose Soft", "Clipper")
+ self.settings.beginGroup("MainWindow")
+ self.resize(settings.value("size", QSize(400, 400)).toSize())
+ self.move(settings.value("pos", QPoint(200, 200)).toPoint())
+ self.settings.endGroup()
+//! [17]
+
+//! [18]
+ def __init__(self):
+ self.settings = None
+//! [18] //! [19]
+ self.readSettings()
+//! [19] //! [20]
+
+//! [20]
+
+bool userReallyWantsToQuit() { return true; }
+
+//! [21]
+ # event : QCloseEvent
+ def closeEvent(self, event):
+ if self.userReallyWantsToQuit():
+ self.writeSettings()
+ event.accept()
+ else:
+ event.ignore()
+//! [21]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/shareddirmodel/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/shareddirmodel/main.cpp
new file mode 100644
index 000000000..187acde31
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/shareddirmodel/main.cpp
@@ -0,0 +1,90 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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$
+##
+############################################################################
+
+"""
+ main.cpp
+
+ A simple example of how to view a model in several views, and share a
+ selection model.
+"""
+
+from PySide2.QtGui import *
+
+
+//! [0] //! [1]
+def main():
+ app = QApplication(sys.argv)
+ splitter = QSplitter()
+
+//! [2] //! [3]
+ model = QFileSystemModel()
+ model.setRootPath(QDir.currentPath())
+//! [0] //! [2] //! [4] //! [5]
+ tree = QTreeView()
+//! [3] //! [6]
+ tree.setModel(model)
+//! [4] //! [6] //! [7]
+ tree.setRootIndex(model.index(QDir.currentPath()))
+//! [7]
+
+ list = QListView(splitter)
+ list.setModel(model)
+ list.setRootIndex(model.index(QDir.currentPath()))
+
+//! [5]
+ selection = QItemSelectionModel(model)
+ tree.setSelectionModel(selection)
+ list.setSelectionModel(selection)
+
+//! [8]
+ splitter.setWindowTitle("Two views onto the same directory model")
+ splitter.show()
+ return app.exec_()
+//! [1] //! [8]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/employee.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/employee.cpp
new file mode 100644
index 000000000..942db372a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/employee.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "employee.h"
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/employee.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/employee.h
new file mode 100644
index 000000000..97209ff33
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/employee.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef EMPLOYEE_H
+#define EMPLOYEE_H
+
+//! [0]
+#include <QSharedData>
+#include <QString>
+
+class EmployeeData : public QSharedData
+{
+ public:
+ EmployeeData() : id(-1) { name.clear(); }
+ EmployeeData(const EmployeeData &other)
+ : QSharedData(other), id(other.id), name(other.name) { }
+ ~EmployeeData() { }
+
+ int id;
+ QString name;
+};
+
+class Employee
+{
+ public:
+//! [1]
+ Employee() { d = new EmployeeData; }
+//! [1] //! [2]
+ Employee(int id, QString name) {
+ d = new EmployeeData;
+ setId(id);
+ setName(name);
+ }
+//! [2] //! [7]
+ Employee(const Employee &other)
+ : d (other.d)
+ {
+ }
+//! [7]
+//! [3]
+ void setId(int id) { d->id = id; }
+//! [3] //! [4]
+ void setName(QString name) { d->name = name; }
+//! [4]
+
+//! [5]
+ int id() const { return d->id; }
+//! [5] //! [6]
+ QString name() const { return d->name; }
+//! [6]
+
+ private:
+ QSharedDataPointer<EmployeeData> d;
+};
+//! [0]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/main.cpp
new file mode 100644
index 000000000..3f36468da
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedemployee/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+#include "employee.h"
+
+int main()
+{
+ Employee e1(1001, "Albrecht Durer");
+ Employee e2 = e1;
+ e1.setName("Hans Holbein");
+}
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedtablemodel/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedtablemodel/main.cpp
new file mode 100644
index 000000000..c0adef6e7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedtablemodel/main.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example that shows how a single model can be shared between
+ multiple views.
+*/
+
+#include <QApplication>
+#include <QHeaderView>
+#include <QItemSelectionModel>
+#include <QTableView>
+
+#include "model.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ TableModel *model = new TableModel(4, 2, &app);
+
+//! [0]
+ QTableView *firstTableView = new QTableView;
+ QTableView *secondTableView = new QTableView;
+//! [0]
+
+//! [1]
+ firstTableView->setModel(model);
+ secondTableView->setModel(model);
+//! [1]
+
+ firstTableView->horizontalHeader()->setModel(model);
+
+ for (int row = 0; row < 4; ++row) {
+ for (int column = 0; column < 2; ++column) {
+ QModelIndex index = model->index(row, column, QModelIndex());
+ model->setData(index, QVariant(QString("(%1, %2)").arg(row).arg(column)));
+ }
+ }
+
+//! [2]
+ secondTableView->setSelectionModel(firstTableView->selectionModel());
+//! [2]
+
+ firstTableView->setWindowTitle("First table view");
+ secondTableView->setWindowTitle("Second table view");
+ firstTableView->show();
+ secondTableView->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedtablemodel/model.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedtablemodel/model.h
new file mode 100644
index 000000000..886e77852
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/sharedtablemodel/model.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QVariant>
+
+class TableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ TableModel(int rows = 1, int columns = 1, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+
+private:
+ QList<QStringList> rowList;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/accountsfile.txt b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/accountsfile.txt
new file mode 100644
index 000000000..2ec5ffbc1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/accountsfile.txt
@@ -0,0 +1 @@
+1 + 1 = 2
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/filereader.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/filereader.cpp
new file mode 100644
index 000000000..efe8a06cd
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/filereader.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include "filereader.h"
+
+
+FileReader::FileReader(QWidget *parent)
+ : QWidget(parent)
+{
+ textEdit = new QTextEdit;
+
+ taxFileButton = new QPushButton("Tax File");
+ accountFileButton = new QPushButton("Accounts File");
+ reportFileButton = new QPushButton("Report File");
+
+//! [0]
+ signalMapper = new QSignalMapper(this);
+ signalMapper->setMapping(taxFileButton, QString("taxfile.txt"));
+ signalMapper->setMapping(accountFileButton, QString("accountsfile.txt"));
+ signalMapper->setMapping(reportFileButton, QString("reportfile.txt"));
+
+ connect(taxFileButton, SIGNAL(clicked()),
+ signalMapper, SLOT (map()));
+ connect(accountFileButton, SIGNAL(clicked()),
+ signalMapper, SLOT (map()));
+ connect(reportFileButton, SIGNAL(clicked()),
+ signalMapper, SLOT (map()));
+//! [0]
+
+//! [1]
+ connect(signalMapper, SIGNAL(mapped(const QString &)),
+ this, SLOT(readFile(const QString &)));
+//! [1]
+
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
+ buttonLayout->addWidget(taxFileButton);
+ buttonLayout->addWidget(accountFileButton);
+ buttonLayout->addWidget(reportFileButton);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(textEdit);
+ mainLayout->addLayout(buttonLayout);
+
+ setLayout(mainLayout);
+}
+
+void FileReader::readFile(const QString &filename)
+{
+ QFile file(filename);
+
+ if (!file.open(QIODevice::ReadOnly)) {
+ QMessageBox::information(this, tr("Unable to open file"),
+ file.errorString());
+ return;
+ }
+
+
+ QTextStream in(&file);
+ textEdit->setPlainText(in.readAll());
+}
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/filereader.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/filereader.h
new file mode 100644
index 000000000..a56e3b83c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/filereader.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef FILEREADER_H
+#define FILEREADER_H
+
+#include <QTextEdit>
+#include <QPushButton>
+#include <QSignalMapper>
+
+class FileReader : public QWidget
+{
+ Q_OBJECT
+
+public:
+ FileReader(QWidget *parent=0);
+ void readFromFile(QString filename);
+
+public slots:
+ void readFile(const QString &);
+
+private:
+ QTextEdit *textEdit;
+ QPushButton *taxFileButton;
+ QPushButton *accountFileButton;
+ QPushButton *reportFileButton;
+ QSignalMapper *signalMapper;
+};
+
+#endif
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/main.cpp
new file mode 100644
index 000000000..7fa593642
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include "filereader.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ FileReader *reader = new FileReader;
+ reader->show();
+
+ return app.exec();
+}
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/reportfile.txt b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/reportfile.txt
new file mode 100644
index 000000000..30123cc60
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/reportfile.txt
@@ -0,0 +1,2 @@
+Tax this year = 50%
+Total profit = 2
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/taxfile.txt b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/taxfile.txt
new file mode 100644
index 000000000..a682e0aaa
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalmapper/taxfile.txt
@@ -0,0 +1 @@
+Tax this year = 50%
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.cpp
new file mode 100644
index 000000000..437d3a674
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "lcdnumber.h"
+
+LcdNumber::LcdNumber(QWidget *parent)
+{
+}
+
+void LcdNumber::display(int)
+{
+}
+
+void LcdNumber::display(double)
+{
+}
+
+void LcdNumber::display(const QString &)
+{
+}
+
+void LcdNumber::setHexMode()
+{
+}
+
+void LcdNumber::setDecMode()
+{
+}
+
+void LcdNumber::setOctMode()
+{
+}
+
+void LcdNumber::setBinMode()
+{
+}
+
+void LcdNumber::setSmallDecimalPoint(bool)
+{
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.h
new file mode 100644
index 000000000..6a0930f6b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/lcdnumber.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+#ifndef LCDNUMBER_H
+//! [0] //! [1]
+#define LCDNUMBER_H
+//! [1]
+
+//! [2]
+#include <QFrame>
+//! [2]
+
+//! [3]
+class LcdNumber : public QFrame
+//! [3] //! [4]
+{
+//! [4] //! [5]
+ Q_OBJECT
+//! [5]
+
+//! [6]
+public:
+//! [6] //! [7]
+ LcdNumber(QWidget *parent = 0);
+//! [7]
+
+//! [8]
+signals:
+//! [8] //! [9]
+ void overflow();
+//! [9]
+
+//! [10]
+public slots:
+//! [10] //! [11]
+ void display(int num);
+ void display(double num);
+ void display(const QString &str);
+ void setHexMode();
+ void setDecMode();
+ void setOctMode();
+ void setBinMode();
+ void setSmallDecimalPoint(bool point);
+//! [11] //! [12]
+};
+//! [12]
+
+//! [13]
+#endif
+//! [13]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.cpp
new file mode 100644
index 000000000..75c691503
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QAbstractButton>
+
+#include "signalsandslots.h"
+
+//! [0]
+void Counter::setValue(int value)
+{
+ if (value != m_value) {
+ m_value = value;
+ emit valueChanged(value);
+ }
+}
+//! [0]
+
+int main()
+{
+//! [1]
+ Counter a, b;
+//! [1] //! [2]
+ QObject::connect(&a, SIGNAL(valueChanged(int)),
+ &b, SLOT(setValue(int)));
+//! [2]
+
+//! [3]
+ a.setValue(12); // a.value() == 12, b.value() == 12
+//! [3] //! [4]
+ b.setValue(48); // a.value() == 12, b.value() == 48
+//! [4]
+
+
+ QWidget *widget = reinterpret_cast<QWidget *>(new QObject(0));
+//! [5]
+ if (widget->inherits("QAbstractButton")) {
+ QAbstractButton *button = static_cast<QAbstractButton *>(widget);
+ button->toggle();
+//! [5] //! [6]
+ }
+//! [6]
+
+//! [7]
+ if (QAbstractButton *button = qobject_cast<QAbstractButton *>(widget))
+ button->toggle();
+//! [7]
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.h
new file mode 100644
index 000000000..2d04faf13
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/signalsandslots/signalsandslots.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef SIGNALSANDSLOTS_H
+#define SIGNALSANDSLOTS_H
+
+#define Counter PlainCounter
+
+//! [0]
+class Counter
+{
+public:
+ Counter() { m_value = 0; }
+
+ int value() const { return m_value; }
+ void setValue(int value);
+
+private:
+ int m_value;
+};
+//! [0]
+
+#undef Counter
+#define Counter ObjectCounter
+
+//! [1]
+#include <QObject>
+//! [1]
+
+//! [2]
+class Counter : public QObject
+//! [2] //! [3]
+{
+ Q_OBJECT
+
+public:
+ Counter() { m_value = 0; }
+
+ int value() const { return m_value; }
+
+public slots:
+ void setValue(int value);
+
+signals:
+ void valueChanged(int newValue);
+
+private:
+ int m_value;
+};
+//! [3]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/simplemodel-use/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/simplemodel-use/main.cpp
new file mode 100644
index 000000000..dfc9669ea
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/simplemodel-use/main.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example of how to access items from an existing model.
+*/
+
+#include <QtWidgets>
+
+/*!
+ Create a default directory model and, using the index-based interface to
+ the model and some QLabel widgets, populate the window's layout with the
+ names of objects in the directory.
+
+ Note that we only want to read the filenames in the highest level of the
+ directory, so we supply a default (invalid) QModelIndex to the model in
+ order to indicate that we want top-level items.
+*/
+
+def main():
+ app = QApplication(sys.argc, sys.argv)
+
+ window = QWidget()
+ layout = QVBoxLayout(window)
+ title = QLabel("Some items from the directory model", window)
+ title.setBackgroundRole(QPalette.Base)
+ title.setMargin(8)
+ layout.addWidget(title)
+
+//! [0]
+ model = QFileSystemModel()
+ parentIndex = model.index(QDir.currentPath())
+ numRows = model.rowCount(parentIndex)
+//! [0]
+
+//! [1]
+ for row in range(numRows):
+ index = model.index(row, 0, parentIndex)
+//! [1]
+
+//! [2]
+ text = model.data(index, Qt.DisplayRole)
+ // Display the text in a widget.
+//! [2]
+
+ label = QLabel(text, window)
+ layout.addWidget(label)
+//! [3]
+//! [3]
+
+ window.setWindowTitle("A simple model example")
+ window.show()
+ return app.exec_()
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/splitter/splitter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/splitter/splitter.cpp
new file mode 100644
index 000000000..269ca02da
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/splitter/splitter.cpp
@@ -0,0 +1,76 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ splitter = QSplitter(parent)
+ listview = QListView()
+ treeview = QTreeView()
+ textedit = QTextEdit()
+ splitter.addWidget(listview)
+ splitter.addWidget(treeview)
+ splitter.addWidget(textedit)
+//! [0]
+
+//! [1]
+ settings = QSettings()
+ settings.setValue("splitterSizes", splitter.saveState())
+//! [1]
+
+//! [2]
+ settings = QSettings()
+ splitter.restoreState(settings.value("splitterSizes").toByteArray())
+//! [2]
+
+//! [3]
+ for it in splitter.sizes():
+ processSize(it.next())
+//! [3]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/main.cpp
new file mode 100644
index 000000000..63446a78a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/main.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QLabel>
+
+#include "splitter.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Splitter splitter(Qt::Horizontal);
+ splitter.addWidget(new QLabel("Hello"));
+ splitter.addWidget(new QLabel("World"));
+ Splitter verticalSplitter(Qt::Vertical, &splitter);
+ verticalSplitter.addWidget(new QLabel("A"));
+ verticalSplitter.addWidget(new QLabel("B"));
+ splitter.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.cpp
new file mode 100644
index 000000000..18699c7e9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "splitter.h"
+
+SplitterHandle::SplitterHandle(Qt::Orientation orientation, QSplitter *parent)
+ : QSplitterHandle(orientation, parent)
+{
+ gradient.setColorAt(0.0, Qt::darkGreen);
+ gradient.setColorAt(0.25, Qt::white);
+ gradient.setColorAt(1.0, Qt::darkGreen);
+}
+
+//! [0]
+void SplitterHandle::paintEvent(QPaintEvent *event)
+{
+ QPainter painter(this);
+ if (orientation() == Qt::Horizontal) {
+ gradient.setStart(rect().left(), rect().height()/2);
+ gradient.setFinalStop(rect().right(), rect().height()/2);
+ } else {
+ gradient.setStart(rect().width()/2, rect().top());
+ gradient.setFinalStop(rect().width()/2, rect().bottom());
+ }
+ painter.fillRect(event->rect(), QBrush(gradient));
+}
+//! [0]
+
+Splitter::Splitter(Qt::Orientation orientation, QWidget *parent)
+ : QSplitter(orientation, parent)
+{
+}
+
+//! [1]
+QSplitterHandle *Splitter::createHandle()
+{
+ return new SplitterHandle(orientation(), this);
+}
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.h
new file mode 100644
index 000000000..f067f2249
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/splitterhandle/splitter.h
@@ -0,0 +1,61 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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 Splitter(QSplitter):
+ def __init__(self, orientation, parent):
+ ...
+
+ def createHandle(self):
+ ...
+}
+//! [0]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.cpp
new file mode 100644
index 000000000..aa026d755
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/sqldatabase/sqldatabase.cpp
@@ -0,0 +1,489 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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.QtGui import *
+from PySide2.QtSql import *
+
+
+def tr(text):
+ return QApplication.translate(text, text)
+
+def QSqlDatabase_snippets():
+//! [0]
+ db = QSqlDatabase.addDatabase("QPSQL")
+ db.setHostName("acidalia")
+ db.setDatabaseName("customdb")
+ db.setUserName("mojito")
+ db.setPassword("J0a1m8")
+ ok = db.open()
+//! [0]
+
+//! [1]
+ db = QSqlDatabase.database()
+//! [1]
+
+def QSqlField_snippets():
+//! [2]
+ field = QSqlField("age", QVariant.Int)
+ field.setValue(QPixmap()) # WRONG
+//! [2]
+
+//! [3]
+ field = QSqlField("age", QVariant.Int)
+ field.setValue(QString("123")) # casts QString to int
+//! [3]
+
+//! [4]
+ query = QSqlQuery()
+//! [4] //! [5]
+ record = query.record()
+//! [5] //! [6]
+ field = record.field("country")
+//! [6]
+
+def doSomething(str):
+ pass
+
+def QSqlQuery_snippets():
+ # typical loop
+//! [7]
+ query = QSqlQuery("SELECT country FROM artist")
+ while query.next():
+ country = query.value(0)
+ doSomething(country)
+//! [7]
+
+
+ # field index lookup
+//! [8]
+ query = QSqlQuery("SELECT * FROM artist")
+ fieldNo = query.record().indexOf("country")
+ while query.next():
+ country = query.value(fieldNo)
+ doSomething(country)
+//! [8]
+
+ # named with named
+//! [9]
+ query = QSqlQuery()
+ query.prepare("INSERT INTO person (id, forename, surname) "
+ "VALUES (:id, :forename, :surname)")
+ query.bindValue(":id", 1001)
+ query.bindValue(":forename", "Bart")
+ query.bindValue(":surname", "Simpson")
+ query.exec_()
+//! [9]
+
+ # positional with named
+//! [10]
+ query = QSqlQuery()
+ query.prepare("INSERT INTO person (id, forename, surname) "
+ "VALUES (:id, :forename, :surname)")
+ query.bindValue(0, 1001)
+ query.bindValue(1, "Bart")
+ query.bindValue(2, "Simpson")
+ query.exec_()
+//! [10]
+
+ # positional 1
+//! [11]
+ query = QSqlQuery()
+ query.prepare("INSERT INTO person (id, forename, surname) "
+ "VALUES (?, ?, ?)")
+ query.bindValue(0, 1001)
+ query.bindValue(1, "Bart")
+ query.bindValue(2, "Simpson")
+ query.exec_()
+//! [11]
+
+ # positional 2
+//! [12]
+ query = QSqlQuery()
+ query.prepare("INSERT INTO person (id, forename, surname) "
+ "VALUES (?, ?, ?)")
+ query.addBindValue(1001)
+ query.addBindValue("Bart")
+ query.addBindValue("Simpson")
+ query.exec_()
+//! [12]
+
+ # stored
+//! [13]
+ query = QSqlQuery()
+ query.prepare("CALL AsciiToInt(?, ?)")
+ query.bindValue(0, "A")
+ query.bindValue(1, 0, QSql.Out)
+ query.exec_()
+ i = query.boundValue(1) # i is 65
+//! [13]
+
+ query = QSqlQuery()
+
+ # examine with named binding
+//! [14]
+ i = query.boundValues()
+ while i.hasNext():
+ i.next()
+ print i.key(), ": ", i.value()
+//! [14]
+
+ # examine with positional binding
+//! [15]
+ list_ = query.boundValues().values()
+ for item in list:
+ print item
+//! [15]
+
+def QSqlQueryModel_snippets():
+
+//! [16]
+ model = QSqlQueryModel()
+ model.setQuery("SELECT name, salary FROM employee")
+ model.setHeaderData(0, Qt.Horizontal, tr("Name"))
+ model.setHeaderData(1, Qt.Horizontal, tr("Salary"))
+
+//! [17]
+ view = QTableView()
+//! [17] //! [18]
+ view.setModel(model)
+//! [18] //! [19]
+ view.show()
+//! [16] //! [19] //! [20]
+ view.setEditTriggers(QAbstractItemView.NoEditTriggers)
+//! [20]
+
+//! [21]
+ model = QSqlQueryModel()
+ model.setQuery("SELECT * FROM employee")
+ salary = model.record(4).value("salary")
+//! [21]
+
+//! [22]
+ salary = model.data(model.index(4, 2))
+//! [22]
+
+ for row in range(model.rowCount()):
+ for (col in range(model.columnCount())):
+ print model.data(model.index(row, col))
+
+
+class MyModel(QSqlQueryModel)
+ m_specialColumnNo = 0
+ def data(item, role):
+//! [23]
+ if item.column() == self.m_specialColumnNo:
+ # handle column separately
+ pass
+
+ return QSqlQueryModel.data(item, role)
+
+//! [23]
+
+
+def QSqlTableModel_snippets():
+
+//! [24]
+ model = QSqlTableModel()
+ model.setTable("employee")
+ model.setEditStrategy(QSqlTableModel.OnManualSubmit)
+ model.select()
+ model.removeColumn(0) # don't show the ID
+ model.setHeaderData(0, Qt.Horizontal, tr("Name"))
+ model.setHeaderData(1, Qt.Horizontal, tr("Salary"))
+
+ view = QTableView()
+ view.setModel(model)
+ view.show()
+//! [24]
+
+
+//! [25]
+ model = QSqlTableModel()
+ model.setTable("employee")
+ QString name = model.record(4).value("name")
+//! [25]
+
+def sql_intro_snippets():
+
+//! [26]
+ db = QSqlDatabase.addDatabase("QMYSQL")
+ db.setHostName("bigblue")
+ db.setDatabaseName("flightdb")
+ db.setUserName("acarlson")
+ db.setPassword("1uTbSbAs")
+ ok = db.open()
+//! [26]
+
+//! [27]
+ firstDB = QSqlDatabase.addDatabase("QMYSQL", "first")
+ secondDB = QSqlDatabase.addDatabase("QMYSQL", "second")
+//! [27]
+
+//! [28]
+ defaultDB = QSqlDatabase.database()
+//! [28] //! [29]
+ firstDB = QSqlDatabase.database("first")
+//! [29] //! [30]
+ secondDB = QSqlDatabase.database("second")
+//! [30]
+
+ # SELECT1
+//! [31]
+ query = QSqlQuery()
+ query.exec_("SELECT name, salary FROM employee WHERE salary > 50000")
+//! [31]
+
+//! [32]
+ while query.next():
+ name = query.value(0)
+ salary = query.value(1)
+ print name, salary
+//! [32]
+
+ # FEATURE
+//! [33]
+ query = QSqlQuery()
+ query.exec_("SELECT name, salary FROM employee WHERE salary > 50000")
+
+ defaultDB = QSqlDatabase.database()
+ if defaultDB.driver().hasFeature(QSqlDriver.QuerySize):
+ numRows = query.size()
+ else:
+ # self can be very slow
+ query.last()
+ numRows = query.at() + 1
+//! [33]
+
+ # INSERT1
+//! [34]
+ query = QSqlQuery()
+ query.exec_("INSERT INTO employee (id, name, salary) "
+ "VALUES (1001, 'Thad Beaumont', 65000)")
+//! [34]
+
+ # NAMED BINDING
+//! [35]
+ query = QSqlQuery()
+ query.prepare("INSERT INTO employee (id, name, salary) "
+ "VALUES (:id, :name, :salary)")
+ query.bindValue(":id", 1001)
+ query.bindValue(":name", "Thad Beaumont")
+ query.bindValue(":salary", 65000)
+ query.exec_()
+//! [35]
+
+ # POSITIONAL BINDING
+//! [36]
+ query = QSqlQuery()
+ query.prepare("INSERT INTO employee (id, name, salary) "
+ "VALUES (?, ?, ?)")
+ query.addBindValue(1001)
+ query.addBindValue("Thad Beaumont")
+ query.addBindValue(65000)
+ query.exec_()
+//! [36]
+
+ # UPDATE1
+//! [37]
+ query = QSqlQuery()
+ query.exec_("UPDATE employee SET salary = 70000 WHERE id = 1003")
+//! [37]
+
+ # DELETE1
+//! [38]
+ query = QSqlQuery()
+ query.exec_("DELETE FROM employee WHERE id = 1007")
+//! [38]
+
+ # TRANSACTION
+//! [39]
+ QSqlDatabase.database().transaction()
+ query = QSqlQuery()
+ query.exec_("SELECT id FROM employee WHERE name = 'Torild Halvorsen'")
+ if query.next():
+ employeeId = query.value(0)
+ query.exec_("INSERT INTO project (id, name, ownerid) "
+ "VALUES (201, 'Manhattan Project', "
+ + QString.number(employeeId) + ')')
+
+ QSqlDatabase.database().commit()
+//! [39]
+
+ # SQLQUERYMODEL1
+//! [40]
+ model = QSqlQueryModel()
+ model.setQuery("SELECT * FROM employee")
+
+ for i in range(model.rowCount()):
+ _id = model.record(i).value("id")
+ name = model.record(i).value("name")
+ print _id, name
+
+//! [40]
+ }
+
+ {
+ # SQLTABLEMODEL1
+//! [41]
+ model = QSqlTableModel()
+ model.setTable("employee")
+ model.setFilter("salary > 50000")
+ model.setSort(2, Qt.DescendingOrder)
+ model.select()
+
+ for i in range(model.rowCount()):
+ name = model.record(i).value("name")
+ salary = model.record(i).value("salary")
+ print "%s: %d" % (name, salary)
+
+//! [41]
+
+ # SQLTABLEMODEL2
+ model = QSqlTableModel()
+ model.setTable("employee")
+
+//! [42]
+ for i in range(model.rowCount()):
+ record = model.record(i)
+ salary = record.value("salary")
+ salary *= 1.1
+ record.setValue("salary", salary)
+ model.setRecord(i, record)
+
+ model.submitAll()
+//! [42]
+
+ # SQLTABLEMODEL3
+ row = 1
+ column = 2
+//! [43]
+ model.setData(model.index(row, column), 75000)
+ model.submitAll()
+//! [43]
+
+ # SQLTABLEMODEL4
+//! [44]
+ model.insertRows(row, 1)
+ model.setData(model.index(row, 0), 1013)
+ model.setData(model.index(row, 1), "Peter Gordon")
+ model.setData(model.index(row, 2), 68500)
+ model.submitAll()
+//! [44]
+
+//! [45]
+ model.removeRows(row, 5)
+//! [45]
+
+//! [46]
+ model.submitAll()
+//! [46]
+
+//! [47]
+class XyzResult(QSqlResult):
+ def __init__(driver):
+ QSqlResult.__init__(self, driver)
+ pass
+
+ def data(self, index):
+ return QVariant()
+
+ def isNull(self, index):
+ return False
+
+ def reset(self, query):
+ return False
+
+ def fetch(self, index):
+ return False
+
+ def fetchFirst(self):
+ return False
+
+ def fetchLast(self):
+ return False
+
+ def size(self):
+ return 0
+
+ def numRowsAffected(self):
+ return 0
+
+ def record(self):
+ return QSqlRecord()
+
+//! [47]
+
+//! [48]
+class XyzDriver(QSqlDriver)
+ def hasFeature(self, feature):
+ return False
+
+ def open(self, db, user, password, host, port, options):
+ return False
+
+ def close(self):
+ pass
+
+ def createResult(self):
+ return XyzResult(self)
+
+//! [48]
+
+def main():
+ app = QApplication([])
+
+ QSqlDatabase_snippets()
+ QSqlField_snippets()
+ QSqlQuery_snippets()
+ QSqlQueryModel_snippets()
+ QSqlTableModel_snippets()
+
+ driver = XyzDriver()
+ result = XyzResult(driver)
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/streaming/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/streaming/main.cpp
new file mode 100644
index 000000000..dd2190242
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/streaming/main.cpp
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QByteArray>
+#include <QDataStream>
+
+//! [0]
+struct Movie
+{
+ int id;
+ QString title;
+ QDate releaseDate;
+};
+//! [0]
+
+//! [1]
+QDataStream &operator<<(QDataStream &out, const Movie &movie)
+{
+ out << (quint32)movie.id << movie.title
+ << movie.releaseDate;
+ return out;
+}
+//! [1]
+
+//! [2]
+QDataStream &operator>>(QDataStream &in, Movie &movie)
+{
+ quint32 id;
+ QDate date;
+
+ in >> id >> movie.title >> date;
+ movie.id = (int)id;
+ movie.releaseDate = date;
+ return in;
+}
+//! [2]
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Movie m;
+ m.id = 0001;
+ m.title = "Happy Meal";
+ m.releaseDate = QDate(1995, 5, 17);
+
+ QByteArray byteArray;
+ QDataStream stream(&byteArray, QIODevice::WriteOnly);
+ stream << m;
+
+ // display
+ qDebug() << m.id << m.releaseDate << m.title;
+
+ Movie m2;
+
+ int id2;
+ QString title2;
+ QDate date2;
+
+ QDataStream stream2(byteArray);
+ stream2 >> id2 >> title2 >> date2;
+
+ m2.id = id2;
+ m2.title = title2;
+ m2.releaseDate = date2;
+
+ qDebug() << id2 << " " << date2 << " " << title2;
+
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/main.cpp
new file mode 100644
index 000000000..7f7eec71b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/main.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*!
+ The main function for the string list model example. This creates and
+ populates a model with values from a string list then displays the
+ contents of the model using a QListView widget.
+*/
+
+#include <QAbstractItemModel>
+#include <QApplication>
+#include <QListView>
+
+#include "model.h"
+
+//! [0]
+
+app = QApplication(sys.argv)
+
+// Unindented for quoting purposes:
+//! [1]
+numbers = ["One", "Two", "Three", "Four", "Five"]
+
+model = StringListModel(numbers)
+//! [0] //! [1] //! [2] //! [3]
+view = QListView()
+//! [2]
+view.setWindowTitle("View onto a string list model")
+//! [4]
+view.setModel(model)
+//! [3] //! [4]
+
+ model.insertRows(5, 7, QModelIndex())
+
+ for row in range(5, 12):
+ index = model.index(row, 0, QModelIndex())
+ model.setData(index, str(row+1))
+
+//! [5]
+ view.show()
+ sys.exit(app.exec_())
+//! [5]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/model.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/model.cpp
new file mode 100644
index 000000000..a63496f21
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/model.cpp
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ A simple model that uses a QStringList as its data source.
+*/
+
+/*!
+ Returns the number of items in the string list as the number of rows
+ in the model.
+*/
+
+//! [0]
+def rowCount(self, parent):
+ return len(self.stringList)
+//! [0]
+
+/*!
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned.
+*/
+
+//! [1]
+def data(self, index, role):
+ if not index.isValid():
+ return None
+
+ if index.row() >= stringList.size():
+ return None
+
+ if role == Qt.DisplayRole:
+ return stringList[index.row()]
+ else
+ return None
+//! [1]
+
+/*!
+ Returns the appropriate header string depending on the orientation of
+ the header and the section. If anything other than the display role is
+ requested, we return an invalid variant.
+*/
+
+//! [2]
+def headerData(self, section, orientation, role):
+ if role != Qt::DisplayRole:
+ return None
+
+ if orientation == Qt::Horizontal:
+ return "Column %s" % section
+ else:
+ return "Row %s" % section
+//! [2]
+
+/*!
+ Returns an appropriate value for the item's flags. Valid items are
+ enabled, selectable, and editable.
+*/
+
+//! [3]
+def flags(self, index):
+ if not index.isValid()
+ return Qt.ItemIsEnabled
+
+ return QAbstractItemModel.flags(index) | Qt.ItemIsEditable
+//! [3]
+
+/*!
+ Changes an item in the string list, but only if the following conditions
+ are met:
+
+ * The index supplied is valid.
+ * The index corresponds to an item to be shown in a view.
+ * The role associated with editing text is specified.
+
+ The dataChanged() signal is emitted if the item is changed.
+*/
+
+//! [4]
+def setData(self, index, value, role):
+ if index.isValid() and role == Qt.EditRole:
+ self.stringList[index.row()] = value
+ self.dataChanged.emit(index, index)
+ return True;
+//! [4] //! [5]
+ return False;
+}
+//! [5]
+
+/*!
+ Inserts a number of rows into the model at the specified position.
+*/
+
+//! [6]
+def insertRows(self, position, rows, parent):
+ self.beginInsertRows(QModelIndex(), position, position+rows-1)
+
+ for row in range(0, rows):
+ self.stringList.insert(position, "")
+
+ self.endInsertRows()
+ return True;
+//! [6] //! [7]
+//! [7]
+
+/*!
+ Removes a number of rows from the model at the specified position.
+*/
+
+//! [8]
+def removeRows(self, position, rows, parent):
+ self.beginRemoveRows(QModelIndex(), position, position+rows-1)
+
+ for row in range(0, rows):
+ del self.stringList[position]
+
+ self.endRemoveRows()
+ return True;
+//! [8] //! [9]
+//! [9]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/model.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/model.h
new file mode 100644
index 000000000..dcf91e389
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/stringlistmodel/model.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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 StringListModel (QAbstractListModel):
+ def __init__(strings, parent = None):
+ QAbstractListModel.__init__(self, parent)
+//! [5]
+ self.stringList = strings
+//! [5]
+
+ def rowCount(self, parent = QModelIndex()):
+ # ...
+ def data(self, index, role):
+ # ...
+ def headerData(self, section, orientation,
+//! [0] //! [1]
+ role = Qt.DisplayRole):
+//! [1]
+
+//! [2]
+ def flags(self, index):
+ # ...
+ def setData(self, index, value,
+//! [2] //! [3]
+ role = Qt.EditRole)
+//! [3]
+
+//! [4]
+ def insertRows(self, position, rows, index = QModelIndex()):
+ # ...
+ def removeRows(self, position, rows, index = QModelIndex()):
+ # ...
+//! [4]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/styles/styles.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/styles/styles.cpp
new file mode 100644
index 000000000..0b004b6b3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/styles/styles.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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] //! [1]
+def paintEvent(self, event):
+//! [0]
+//! [2]
+ painter = QPainter(self)
+//! [2]
+
+ option = QStyleOptionFocusRect()
+ option.initFrom(self)
+ option.backgroundColor = palette().color(QPalette.Background)
+
+//! [3]
+ style().drawPrimitive(QStyle.PE_FrameFocusRect, option, painter, self)
+//! [3]
+//! [1]
+
+def paintEvent2(event):
+//! [4]
+//! [4] //! [5] //! [6]
+ painter = QStylePainter(self)
+//! [5]
+
+ option = QStyleOptionFocusRect()
+ option.initFrom(self)
+ option.backgroundColor = palette().color(QPalette.Background)
+
+//! [7]
+ painter.drawPrimitive(QStyle.PE_FrameFocusRect, option)
+//! [7]
+//! [6]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/stylesheet/common-mistakes.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/stylesheet/common-mistakes.cpp
new file mode 100644
index 000000000..7db78a159
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/stylesheet/common-mistakes.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+//! [1]
+ QPushButton {
+ color: grey;
+ border-image: url(/home/kamlie/code/button.png) 3 10 3 10;
+ border-top: 3px transparent;
+ border-bottom: 3px transparent;
+ border-right: 10px transparent;
+ border-left: 10px transparent;
+ }
+//! [1]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-formats/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-formats/main.cpp
new file mode 100644
index 000000000..404a678d2
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-formats/main.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+//! [0]
+ QTextEdit *editor = new QTextEdit();
+ QTextCursor cursor(editor->textCursor());
+//! [0]
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextBlockFormat blockFormat = cursor.blockFormat();
+ blockFormat.setTopMargin(4);
+ blockFormat.setLeftMargin(4);
+ blockFormat.setRightMargin(4);
+ blockFormat.setBottomMargin(4);
+
+ cursor.setBlockFormat(blockFormat);
+ cursor.insertText(tr("This contains plain text inside a "
+ "text block with margins to keep it separate "
+ "from other parts of the document."));
+
+ cursor.insertBlock();
+
+//! [1]
+ QTextBlockFormat backgroundFormat = blockFormat;
+ backgroundFormat.setBackground(QColor("lightGray"));
+
+ cursor.setBlockFormat(backgroundFormat);
+//! [1]
+ cursor.insertText(tr("The background color of a text block can be "
+ "changed to highlight text."));
+
+ cursor.insertBlock();
+
+ QTextBlockFormat rightAlignedFormat = blockFormat;
+ rightAlignedFormat.setAlignment(Qt::AlignRight);
+
+ cursor.setBlockFormat(rightAlignedFormat);
+ cursor.insertText(tr("The alignment of the text within a block is "
+ "controlled by the alignment properties of "
+ "the block itself. This text block is "
+ "right-aligned."));
+
+ cursor.insertBlock();
+
+ QTextBlockFormat paragraphFormat = blockFormat;
+ paragraphFormat.setAlignment(Qt::AlignJustify);
+ paragraphFormat.setTextIndent(32);
+
+ cursor.setBlockFormat(paragraphFormat);
+ cursor.insertText(tr("Text can be formatted so that the first "
+ "line in a paragraph has its own margin. "
+ "This makes the text more readable."));
+
+ cursor.insertBlock();
+
+ QTextBlockFormat reverseFormat = blockFormat;
+ reverseFormat.setAlignment(Qt::AlignJustify);
+ reverseFormat.setTextIndent(32);
+
+ cursor.setBlockFormat(reverseFormat);
+ cursor.insertText(tr("The direction of the text can be reversed. "
+ "This is useful for right-to-left "
+ "languages."));
+
+ editor->setWindowTitle(tr("Text Block Formats"));
+ editor->resize(480, 480);
+ editor->show();
+
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/main.cpp
new file mode 100644
index 000000000..f6ba623fb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.cpp
new file mode 100644
index 000000000..5a5107824
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.cpp
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+#include "xmlwriter.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *saveAction = fileMenu->addAction(tr("&Save..."));
+ saveAction->setShortcut(tr("Ctrl+S"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *insertMenu = new QMenu(tr("&Insert"));
+
+ QAction *calendarAction = insertMenu->addAction(tr("&Calendar"));
+ calendarAction->setShortcut(tr("Ctrl+I"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(insertMenu);
+
+ editor = new QTextEdit(this);
+
+ connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(calendarAction, SIGNAL(triggered()), this, SLOT(insertCalendar()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+void MainWindow::saveFile()
+{
+ QString fileName = QFileDialog::getSaveFileName(this,
+ tr("Save document as:"), "", tr("XML (*.xml)"));
+
+ if (!fileName.isEmpty()) {
+ if (writeXml(fileName))
+ setWindowTitle(fileName);
+ else
+ QMessageBox::warning(this, tr("Warning"),
+ tr("Failed to save the document."), QMessageBox::Cancel,
+ QMessageBox::NoButton);
+ }
+}
+
+void MainWindow::insertCalendar()
+{
+ QTextCursor cursor(editor->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextCharFormat format(cursor.charFormat());
+ format.setFontFamily("Courier");
+
+ QTextCharFormat boldFormat = format;
+ boldFormat.setFontWeight(QFont::Bold);
+
+ cursor.insertBlock();
+ cursor.insertText(" ", boldFormat);
+
+ QDate date = QDate::currentDate();
+ int year = date.year(), month = date.month();
+
+ for (int weekDay = 1; weekDay <= 7; ++weekDay) {
+ cursor.insertText(QString("%1 ").arg(QDate::shortDayName(weekDay), 3),
+ boldFormat);
+ }
+
+ cursor.insertBlock();
+ cursor.insertText(" ", format);
+
+ for (int column = 1; column < QDate(year, month, 1).dayOfWeek(); ++column) {
+ cursor.insertText(" ", format);
+ }
+
+ for (int day = 1; day <= date.daysInMonth(); ++day) {
+ int weekDay = QDate(year, month, day).dayOfWeek();
+
+ if (QDate(year, month, day) == date)
+ cursor.insertText(QString("%1 ").arg(day, 3), boldFormat);
+ else
+ cursor.insertText(QString("%1 ").arg(day, 3), format);
+
+ if (weekDay == 7) {
+ cursor.insertBlock();
+ cursor.insertText(" ", format);
+ }
+ }
+}
+
+bool MainWindow::writeXml(const QString &fileName)
+{
+ XmlWriter documentWriter(editor->document());
+
+ QDomDocument *domDocument = documentWriter.toXml();
+ QFile file(fileName);
+
+ if (file.open(QFile::WriteOnly)) {
+ QTextStream textStream(&file);
+
+ textStream << domDocument->toByteArray(1);
+ return true;
+ }
+ else
+ return false;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.h
new file mode 100644
index 000000000..7ec5194e0
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/mainwindow.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void insertCalendar();
+ void saveFile();
+
+private:
+ bool writeXml(const QString &fileName);
+
+ QTextEdit *editor;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.cpp
new file mode 100644
index 000000000..d16dffc0c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "xmlwriter.h"
+
+QDomDocument *XmlWriter::toXml()
+{
+ QDomImplementation implementation;
+ QDomDocumentType docType = implementation.createDocumentType(
+ "scribe-document", "scribe", "qtsoftware.com/scribe");
+
+ document = new QDomDocument(docType);
+
+ // ### This processing instruction is required to ensure that any kind
+ // of encoding is given when the document is written.
+ QDomProcessingInstruction process = document->createProcessingInstruction(
+ "xml", "version=\"1.0\" encoding=\"utf-8\"");
+ document->appendChild(process);
+
+ QDomElement documentElement = document->createElement("document");
+ document->appendChild(documentElement);
+
+//! [0]
+ QTextBlock currentBlock = textDocument->begin();
+
+ while (currentBlock.isValid()) {
+//! [0]
+ QDomElement blockElement = document->createElement("block");
+ document->appendChild(blockElement);
+
+ readFragment(currentBlock, blockElement, document);
+
+//! [1]
+ processBlock(currentBlock);
+//! [1]
+
+//! [2]
+ currentBlock = currentBlock.next();
+ }
+//! [2]
+
+ return document;
+}
+
+void XmlWriter::readFragment(const QTextBlock &currentBlock,
+ QDomElement blockElement,
+ QDomDocument *document)
+{
+//! [3] //! [4]
+ QTextBlock::iterator it;
+ for (it = currentBlock.begin(); !(it.atEnd()); ++it) {
+ QTextFragment currentFragment = it.fragment();
+ if (currentFragment.isValid())
+//! [3] //! [5]
+ processFragment(currentFragment);
+//! [4] //! [5]
+
+ if (currentFragment.isValid()) {
+ QDomElement fragmentElement = document->createElement("fragment");
+ blockElement.appendChild(fragmentElement);
+
+ fragmentElement.setAttribute("length", currentFragment.length());
+ QDomText fragmentText = document->createTextNode(currentFragment.text());
+
+ fragmentElement.appendChild(fragmentText);
+//! [6]
+ }
+//! [7]
+ }
+//! [6] //! [7]
+}
+
+void XmlWriter::processBlock(const QTextBlock &currentBlock)
+{
+}
+
+void XmlWriter::processFragment(const QTextFragment &currentFragment)
+{
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.h
new file mode 100644
index 000000000..e0c559a6b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textblock-fragments/xmlwriter.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef XMLWRITER_H
+#define XMLWRITER_H
+
+#include <QDomDocument>
+
+class QTextDocument;
+
+class XmlWriter
+{
+public:
+ XmlWriter(QTextDocument *document) : textDocument(document) {}
+ QDomDocument *toXml();
+
+private:
+ void readFragment(const QTextBlock &currentBlock, QDomElement blockElement,
+ QDomDocument *document);
+ void processBlock(const QTextBlock &currentBlock);
+ void processFragment(const QTextFragment &currentFragment);
+
+ QDomDocument *document;
+ QTextDocument *textDocument;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/main.cpp
new file mode 100644
index 000000000..f6ba623fb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.cpp
new file mode 100644
index 000000000..a0db618cc
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+#include "xmlwriter.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *saveAction = fileMenu->addAction(tr("&Save..."));
+ saveAction->setShortcut(tr("Ctrl+S"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *insertMenu = new QMenu(tr("&Insert"));
+
+ QAction *calendarAction = insertMenu->addAction(tr("&Calendar"));
+ calendarAction->setShortcut(tr("Ctrl+I"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(insertMenu);
+
+//! [0]
+ editor = new QTextEdit(this);
+//! [0]
+
+ connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(calendarAction, SIGNAL(triggered()), this, SLOT(insertCalendar()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+void MainWindow::saveFile()
+{
+ QString fileName = QFileDialog::getSaveFileName(this,
+ tr("Save document as:"), "", tr("XML (*.xml)"));
+
+ if (!fileName.isEmpty()) {
+ if (writeXml(fileName))
+ setWindowTitle(fileName);
+ else
+ QMessageBox::warning(this, tr("Warning"),
+ tr("Failed to save the document."), QMessageBox::Cancel,
+ QMessageBox::NoButton);
+ }
+}
+
+void MainWindow::insertCalendar()
+{
+//! [1]
+ QTextCursor cursor(editor->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextCharFormat format(cursor.charFormat());
+ format.setFontFamily("Courier");
+
+ QTextCharFormat boldFormat = format;
+ boldFormat.setFontWeight(QFont::Bold);
+
+ cursor.insertBlock();
+ cursor.insertText(" ", boldFormat);
+
+ QDate date = QDate::currentDate();
+ int year = date.year(), month = date.month();
+
+ for (int weekDay = 1; weekDay <= 7; ++weekDay) {
+ cursor.insertText(QString("%1 ").arg(QDate::shortDayName(weekDay), 3),
+ boldFormat);
+ }
+
+ cursor.insertBlock();
+ cursor.insertText(" ", format);
+
+ for (int column = 1; column < QDate(year, month, 1).dayOfWeek(); ++column) {
+ cursor.insertText(" ", format);
+ }
+
+ for (int day = 1; day <= date.daysInMonth(); ++day) {
+//! [1] //! [2]
+ int weekDay = QDate(year, month, day).dayOfWeek();
+
+ if (QDate(year, month, day) == date)
+ cursor.insertText(QString("%1 ").arg(day, 3), boldFormat);
+ else
+ cursor.insertText(QString("%1 ").arg(day, 3), format);
+
+ if (weekDay == 7) {
+ cursor.insertBlock();
+ cursor.insertText(" ", format);
+ }
+//! [2] //! [3]
+ }
+//! [3]
+}
+
+bool MainWindow::writeXml(const QString &fileName)
+{
+ XmlWriter documentWriter(editor->document());
+
+ QDomDocument *domDocument = documentWriter.toXml();
+ QFile file(fileName);
+
+ if (file.open(QFile::WriteOnly)) {
+ QTextStream textStream(&file);
+ textStream.setCodec(QTextCodec::codecForName("UTF-8"));
+
+ textStream << domDocument->toString(1).toUtf8();
+ file.close();
+ return true;
+ }
+ else
+ return false;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.h
new file mode 100644
index 000000000..7ec5194e0
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/mainwindow.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void insertCalendar();
+ void saveFile();
+
+private:
+ bool writeXml(const QString &fileName);
+
+ QTextEdit *editor;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.cpp
new file mode 100644
index 000000000..b021dffa6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "xmlwriter.h"
+
+QDomDocument *XmlWriter::toXml()
+{
+ QDomImplementation implementation;
+ QDomDocumentType docType = implementation.createDocumentType(
+ "scribe-document", "scribe", "qtsoftware.com/scribe");
+
+ document = new QDomDocument(docType);
+
+ // ### This processing instruction is required to ensure that any kind
+ // of encoding is given when the document is written.
+ QDomProcessingInstruction process = document->createProcessingInstruction(
+ "xml", "version=\"1.0\" encoding=\"utf-8\"");
+ document->appendChild(process);
+
+ QDomElement documentElement = document->createElement("document");
+ document->appendChild(documentElement);
+
+ QTextBlock firstBlock = textDocument->begin();
+ createItems(documentElement, firstBlock);
+
+ return document;
+}
+
+void XmlWriter::createItems(QDomElement &parent, const QTextBlock &block)
+{
+ QTextBlock currentBlock = block;
+
+ while (currentBlock.isValid()) {
+ QDomElement blockElement = document->createElement("block");
+ blockElement.setAttribute("length", currentBlock.length());
+ parent.appendChild(blockElement);
+
+ if (!(currentBlock.text().isNull())) {
+ QDomText textNode = document->createTextNode(currentBlock.text());
+ blockElement.appendChild(textNode);
+ }
+
+ currentBlock = currentBlock.next();
+ }
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.h
new file mode 100644
index 000000000..a47e34cc8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-blocks/xmlwriter.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef XMLWRITER_H
+#define XMLWRITER_H
+
+#include <QDomDocument>
+
+class QTextDocument;
+
+class XmlWriter
+{
+public:
+ XmlWriter(QTextDocument *document) : textDocument(document) {}
+ QDomDocument *toXml();
+
+private:
+ void createItems(QDomElement &parent, const QTextBlock &block);
+
+ QDomDocument *document;
+ QTextDocument *textDocument;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-charformats/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-charformats/main.cpp
new file mode 100644
index 000000000..776550300
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-charformats/main.cpp
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit();
+
+ QTextCursor cursor(editor->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextCharFormat plainFormat(cursor.charFormat());
+
+ QTextCharFormat headingFormat = plainFormat;
+ headingFormat.setFontWeight(QFont::Bold);
+ headingFormat.setFontPointSize(16);
+
+ QTextCharFormat emphasisFormat = plainFormat;
+ emphasisFormat.setFontItalic(true);
+
+ QTextCharFormat qtFormat = plainFormat;
+ qtFormat.setForeground(QColor("#990000"));
+
+ QTextCharFormat underlineFormat = plainFormat;
+ underlineFormat.setFontUnderline(true);
+
+//! [0]
+ cursor.insertText(tr("Character formats"),
+ headingFormat);
+
+ cursor.insertBlock();
+
+ cursor.insertText(tr("Text can be displayed in a variety of "
+ "different character formats. "), plainFormat);
+ cursor.insertText(tr("We can emphasize text by "));
+ cursor.insertText(tr("making it italic"), emphasisFormat);
+//! [0]
+ cursor.insertText(tr(", give it a "), plainFormat);
+ cursor.insertText(tr("different color "), qtFormat);
+ cursor.insertText(tr("to the default text color, "), plainFormat);
+ cursor.insertText(tr("underline it"), underlineFormat);
+ cursor.insertText(tr(", and use many other effects."), plainFormat);
+
+ editor->setWindowTitle(tr("Text Document Character Formats"));
+ editor->resize(320, 480);
+ editor->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-css/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-css/main.cpp
new file mode 100644
index 000000000..e7d355115
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-css/main.cpp
@@ -0,0 +1,58 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ browser = QTextBrowser()
+ linkColor = QColor(Qt.red)
+ sheet = QString.fromLatin1("a { text-decoration: underline color: %1 }").arg(linkColor.name())
+ browser.document().setDefaultStyleSheet(sheet)
+//! [0]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-cursors/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-cursors/main.cpp
new file mode 100644
index 000000000..756d05488
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-cursors/main.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit;
+
+//! [0]
+ QTextDocument *document = editor->document();
+ QTextCursor redCursor(document);
+//! [0] //! [1]
+ QTextCursor blueCursor(document);
+//! [1]
+
+ QTextCharFormat redFormat(redCursor.charFormat());
+ redFormat.setForeground(Qt::red);
+ QTextCharFormat blueFormat(blueCursor.charFormat());
+ blueFormat.setForeground(Qt::blue);
+
+ redCursor.setCharFormat(redFormat);
+ blueCursor.setCharFormat(blueFormat);
+
+ for (int i = 0; i < 20; ++i) {
+ if (i % 2 == 0)
+ redCursor.insertText(tr("%1 ").arg(i), redFormat);
+ if (i % 5 == 0)
+ blueCursor.insertText(tr("%1 ").arg(i), blueFormat);
+ }
+
+ editor->setWindowTitle(tr("Text Document Cursors"));
+ editor->resize(320, 480);
+ editor->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-find/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-find/main.cpp
new file mode 100644
index 000000000..07ced234f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-find/main.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit();
+
+ QTextCursor cursor(editor->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextCharFormat plainFormat(cursor.charFormat());
+ QTextCharFormat colorFormat = plainFormat;
+ colorFormat.setForeground(Qt::red);
+
+ cursor.insertText(tr("Text can be displayed in a variety of "
+ "different character "
+ "formats. "), plainFormat);
+ cursor.insertText(tr("We can emphasize text by making it "));
+ cursor.insertText(tr("italic, give it a different color "));
+ cursor.insertText(tr("to the default text color, underline it, "));
+ cursor.insertText(tr("and use many other effects."));
+
+ QString searchString = tr("text");
+
+ QTextDocument *document = editor->document();
+//! [0]
+ QTextCursor newCursor(document);
+
+ while (!newCursor.isNull() && !newCursor.atEnd()) {
+ newCursor = document->find(searchString, newCursor);
+
+ if (!newCursor.isNull()) {
+ newCursor.movePosition(QTextCursor::WordRight,
+ QTextCursor::KeepAnchor);
+
+ newCursor.mergeCharFormat(colorFormat);
+ }
+//! [0] //! [1]
+ }
+//! [1]
+
+ editor->setWindowTitle(tr("Text Document Find"));
+ editor->resize(320, 480);
+ editor->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/main.cpp
new file mode 100644
index 000000000..6c675daf4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(480, 480);
+ window->show();
+ return app.exec();
+}
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.cpp
new file mode 100644
index 000000000..fecbf0f0a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+#include "xmlwriter.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *saveAction = fileMenu->addAction(tr("&Save..."));
+ saveAction->setShortcut(tr("Ctrl+S"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ menuBar()->addMenu(fileMenu);
+ editor = new QTextEdit();
+
+ QTextCursor cursor(editor->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextFrame *mainFrame = cursor.currentFrame();
+
+ QTextCharFormat plainCharFormat;
+ QTextCharFormat boldCharFormat;
+ boldCharFormat.setFontWeight(QFont::Bold);
+/* main frame
+//! [0]
+ QTextFrame *mainFrame = cursor.currentFrame();
+ cursor.insertText(...);
+//! [0]
+*/
+ cursor.insertText("Text documents are represented by the "
+ "QTextDocument class, rather than by QString objects. "
+ "Each QTextDocument object contains information about "
+ "the document's internal representation, its structure, "
+ "and keeps track of modifications to provide undo/redo "
+ "facilities. This approach allows features such as the "
+ "layout management to be delegated to specialized "
+ "classes, but also provides a focus for the framework.",
+ plainCharFormat);
+
+//! [1]
+ QTextFrameFormat frameFormat;
+ frameFormat.setMargin(32);
+ frameFormat.setPadding(8);
+ frameFormat.setBorder(4);
+//! [1]
+ cursor.insertFrame(frameFormat);
+
+/* insert frame
+//! [2]
+ cursor.insertFrame(frameFormat);
+ cursor.insertText(...);
+//! [2]
+*/
+ cursor.insertText("Documents are either converted from external sources "
+ "or created from scratch using Qt. The creation process "
+ "can done by an editor widget, such as QTextEdit, or by "
+ "explicit calls to the Scribe API.", boldCharFormat);
+
+ cursor = mainFrame->lastCursorPosition();
+/* last cursor
+//! [3]
+ cursor = mainFrame->lastCursorPosition();
+ cursor.insertText(...);
+//! [3]
+*/
+ cursor.insertText("There are two complementary ways to visualize the "
+ "contents of a document: as a linear buffer that is "
+ "used by editors to modify the contents, and as an "
+ "object hierarchy containing structural information "
+ "that is useful to layout engines. In the hierarchical "
+ "model, the objects generally correspond to visual "
+ "elements such as frames, tables, and lists. At a lower "
+ "level, these elements describe properties such as the "
+ "style of text used and its alignment. The linear "
+ "representation of the document is used for editing and "
+ "manipulation of the document's contents.",
+ plainCharFormat);
+
+
+ connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Frames"));
+}
+
+void MainWindow::saveFile()
+{
+ QString fileName = QFileDialog::getSaveFileName(this,
+ tr("Save document as:"), "", tr("XML (*.xml)"));
+
+ if (!fileName.isEmpty()) {
+ if (writeXml(fileName))
+ setWindowTitle(fileName);
+ else
+ QMessageBox::warning(this, tr("Warning"),
+ tr("Failed to save the document."), QMessageBox::Cancel,
+ QMessageBox::NoButton);
+ }
+}
+bool MainWindow::writeXml(const QString &fileName)
+{
+ XmlWriter documentWriter(editor->document());
+
+ QDomDocument *domDocument = documentWriter.toXml();
+ QFile file(fileName);
+
+ if (file.open(QFile::WriteOnly)) {
+ QTextStream textStream(&file);
+ textStream.setCodec(QTextCodec::codecForName("UTF-8"));
+
+ textStream << domDocument->toString(1).toUtf8();
+ file.close();
+ return true;
+ }
+ else
+ return false;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.h
new file mode 100644
index 000000000..eff212a4a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/mainwindow.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void saveFile();
+
+private:
+ bool writeXml(const QString &fileName);
+
+ QTextEdit *editor;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.cpp
new file mode 100644
index 000000000..4a6cd5d5c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "xmlwriter.h"
+
+QDomDocument *XmlWriter::toXml()
+{
+ QDomImplementation implementation;
+ QDomDocumentType docType = implementation.createDocumentType(
+ "scribe-document", "scribe", "qtsoftware.com/scribe");
+
+ document = new QDomDocument(docType);
+
+ // ### This processing instruction is required to ensure that any kind
+ // of encoding is given when the document is written.
+ QDomProcessingInstruction process = document->createProcessingInstruction(
+ "xml", "version=\"1.0\" encoding=\"utf-8\"");
+ document->appendChild(process);
+
+ QDomElement documentElement = document->createElement("document");
+ document->appendChild(documentElement);
+
+//! [0]
+ QTextFrame *root = textDocument->rootFrame();
+//! [0]
+
+ if (root)
+ processFrame(documentElement, root);
+
+ return document;
+}
+
+void XmlWriter::processBlock(QDomElement &parent, const QTextBlock &block)
+{
+ QDomElement blockElement = document->createElement("block");
+ blockElement.setAttribute("position", block.position());
+ blockElement.setAttribute("length", block.length());
+ parent.appendChild(blockElement);
+
+ QTextBlock::iterator it;
+ for (it = block.begin(); !(it.atEnd()); ++it) {
+ QTextFragment fragment = it.fragment();
+
+ if (fragment.isValid()) {
+ QDomElement fragmentElement = document->createElement("fragment");
+ blockElement.appendChild(fragmentElement);
+
+ fragmentElement.setAttribute("length", fragment.length());
+ QDomText fragmentText = document->createTextNode(fragment.text());
+
+ fragmentElement.appendChild(fragmentText);
+ }
+ }
+}
+
+void XmlWriter::processFrame(QDomElement &parent, QTextFrame *frame)
+{
+ QDomElement frameElement = document->createElement("frame");
+ frameElement.setAttribute("begin", frame->firstPosition());
+ frameElement.setAttribute("end", frame->lastPosition());
+ parent.appendChild(frameElement);
+
+//! [1]
+ QTextFrame::iterator it;
+ for (it = frame->begin(); !(it.atEnd()); ++it) {
+
+ QTextFrame *childFrame = it.currentFrame();
+ QTextBlock childBlock = it.currentBlock();
+
+ if (childFrame)
+//! [1] //! [2]
+ processFrame(frameElement, childFrame);
+ else if (childBlock.isValid())
+ processBlock(frameElement, childBlock);
+ }
+//! [2]
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.h
new file mode 100644
index 000000000..2a0f33322
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-frames/xmlwriter.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef XMLWRITER_H
+#define XMLWRITER_H
+
+#include <QDomDocument>
+
+class QTextDocument;
+
+class XmlWriter
+{
+public:
+ XmlWriter(QTextDocument *document) : textDocument(document) {}
+ QDomDocument *toXml();
+
+private:
+ void processBlock(QDomElement &parent, const QTextBlock &block);
+ void processFrame(QDomElement &parent, QTextFrame *frame);
+
+ QDomDocument *document;
+//! [0]
+ QTextDocument *textDocument;
+//! [0]
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/main.cpp
new file mode 100644
index 000000000..2eda7e7f8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include "textedit.h"
+
+int main(int argc, char * argv[])
+{
+ QApplication app(argc, argv);
+
+ TextEdit *textEdit = new TextEdit;
+ textEdit->show();
+
+ return app.exec();
+} \ No newline at end of file
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.cpp
new file mode 100644
index 000000000..e69e18d4d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "textedit.h"
+#include <QtWidgets>
+
+TextEdit::TextEdit(QWidget *parent)
+ : QTextEdit(parent)
+{
+}
+
+//! [0]
+
+def canInsertFromMimeData(source):
+ if source.hasImage:
+ return True
+ else:
+ return QTextEdit.canInsertFromMimeData(source)
+
+//! [0]
+
+//! [1]
+void TextEdit::insertFromMimeData( const QMimeData *source )
+{
+ if (source->hasImage())
+ {
+ QImage image = qvariant_cast<QImage>(source->imageData());
+ QTextCursor cursor = this->textCursor();
+ QTextDocument *document = this->document();
+ document->addResource(QTextDocument::ImageResource, QUrl("image"), image);
+ cursor.insertImage("image");
+ }
+}
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.h
new file mode 100644
index 000000000..7f8f86df9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imagedrop/textedit.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef TEXTEDIT_H
+#define TEXTEDIT_H
+
+#include <QTextEdit>
+
+class TextEdit : public QTextEdit
+{
+ Q_OBJECT
+
+public:
+ TextEdit(QWidget *parent=0);
+ bool canInsertFromMimeData( const QMimeData *source ) const;
+ void insertFromMimeData( const QMimeData *source );
+};
+
+#endif \ No newline at end of file
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images.qrc
new file mode 100644
index 000000000..6473daf34
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/advert.png</file>
+ <file>images/newimage.png</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/advert.png b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/advert.png
new file mode 100644
index 000000000..40e10d522
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/advert.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/newimage.png b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/newimage.png
new file mode 100644
index 000000000..0eec048a7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/images/newimage.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/main.cpp
new file mode 100644
index 000000000..34ec55125
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-imageformat/main.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit;
+
+ QTextDocument *document = new QTextDocument(editor);
+ QTextCursor cursor(document);
+
+ QTextImageFormat imageFormat;
+ imageFormat.setName(":/images/advert.png");
+ cursor.insertImage(imageFormat);
+
+ QTextBlock block = cursor.block();
+ QTextFragment fragment;
+ QTextBlock::iterator it;
+
+ for (it = block.begin(); !(it.atEnd()); ++it) {
+ fragment = it.fragment();
+
+ if (fragment.contains(cursor.position()))
+ break;
+ }
+
+//! [0]
+ if (fragment.isValid()) {
+ QTextImageFormat newImageFormat = fragment.charFormat().toImageFormat();
+
+ if (newImageFormat.isValid()) {
+ newImageFormat.setName(":/images/newimage.png");
+ QTextCursor helper = cursor;
+
+ helper.setPosition(fragment.position());
+ helper.setPosition(fragment.position() + fragment.length(),
+ QTextCursor::KeepAnchor);
+ helper.setCharFormat(newImageFormat);
+//! [0] //! [1]
+ }
+//! [1] //! [2]
+ }
+//! [2]
+
+ cursor.insertBlock();
+ cursor.insertText("Code less. Create more.");
+
+ editor->setDocument(document);
+ editor->setWindowTitle(tr("Text Document Image Format"));
+ editor->resize(320, 480);
+ editor->show();
+
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/images.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/images.qrc
new file mode 100644
index 000000000..09e305e8f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/images.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/advert.png</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/images/advert.png b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/images/advert.png
new file mode 100644
index 000000000..40e10d522
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/images/advert.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/main.cpp
new file mode 100644
index 000000000..25718f485
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-images/main.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit;
+
+//! [0]
+ QTextDocument *document = new QTextDocument(editor);
+ QTextCursor cursor(document);
+//! [0]
+
+//! [1]
+ QTextImageFormat imageFormat;
+ imageFormat.setName(":/images/advert.png");
+ cursor.insertImage(imageFormat);
+//! [1]
+
+ cursor.insertBlock();
+ cursor.insertText("Code less. Create more.");
+
+ editor->setDocument(document);
+ editor->setWindowTitle(tr("Text Document Images"));
+ editor->resize(320, 480);
+ editor->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/main.cpp
new file mode 100644
index 000000000..f6ba623fb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.cpp
new file mode 100644
index 000000000..45389626d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.cpp
@@ -0,0 +1,207 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
+ QKeySequence(tr("Ctrl+Q", "File|Exit")));
+
+ QMenu *actionsMenu = new QMenu(tr("&Actions"));
+ actionsMenu->addAction(tr("&Highlight List Items"),
+ this, SLOT(highlightListItems()));
+ actionsMenu->addAction(tr("&Show Current List"), this, SLOT(showList()));
+
+ QMenu *insertMenu = new QMenu(tr("&Insert"));
+
+ insertMenu->addAction(tr("&List"), this, SLOT(insertList()),
+ QKeySequence(tr("Ctrl+L", "Insert|List")));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(insertMenu);
+ menuBar()->addMenu(actionsMenu);
+
+ editor = new QTextEdit(this);
+ document = new QTextDocument(this);
+ editor->setDocument(document);
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document List Items"));
+}
+
+void MainWindow::highlightListItems()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextList *list = cursor.currentList();
+
+ if (!list)
+ return;
+
+ cursor.beginEditBlock();
+//! [0]
+ for (int index = 0; index < list->count(); ++index) {
+ QTextBlock listItem = list->item(index);
+//! [0]
+ QTextBlockFormat newBlockFormat = listItem.blockFormat();
+ newBlockFormat.setBackground(Qt::lightGray);
+ QTextCursor itemCursor = cursor;
+ itemCursor.setPosition(listItem.position());
+ //itemCursor.movePosition(QTextCursor::StartOfBlock);
+ itemCursor.movePosition(QTextCursor::EndOfBlock,
+ QTextCursor::KeepAnchor);
+ itemCursor.setBlockFormat(newBlockFormat);
+ /*
+//! [1]
+ processListItem(listItem);
+//! [1]
+ */
+//! [2]
+ }
+//! [2]
+ cursor.endEditBlock();
+}
+
+void MainWindow::showList()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextFrame *frame = cursor.currentFrame();
+
+ if (!frame)
+ return;
+
+ QTreeWidget *treeWidget = new QTreeWidget;
+ treeWidget->setColumnCount(1);
+ QStringList headerLabels;
+ headerLabels << tr("Lists");
+ treeWidget->setHeaderLabels(headerLabels);
+
+ QTreeWidgetItem *parentItem = 0;
+ QTreeWidgetItem *item;
+ QTreeWidgetItem *lastItem = 0;
+ parentItems.clear();
+ previousItems.clear();
+
+//! [3]
+ QTextFrame::iterator it;
+ for (it = frame->begin(); !(it.atEnd()); ++it) {
+
+ QTextBlock block = it.currentBlock();
+
+ if (block.isValid()) {
+
+ QTextList *list = block.textList();
+
+ if (list) {
+ int index = list->itemNumber(block);
+//! [3]
+ if (index == 0) {
+ parentItems.append(parentItem);
+ previousItems.append(lastItem);
+ listStructures.append(list);
+ parentItem = lastItem;
+ lastItem = 0;
+
+ if (parentItem != 0)
+ item = new QTreeWidgetItem(parentItem, lastItem);
+ else
+ item = new QTreeWidgetItem(treeWidget, lastItem);
+
+ } else {
+
+ while (parentItem != 0 && listStructures.last() != list) {
+ listStructures.pop_back();
+ parentItem = parentItems.takeLast();
+ lastItem = previousItems.takeLast();
+ }
+ if (parentItem != 0)
+ item = new QTreeWidgetItem(parentItem, lastItem);
+ else
+ item = new QTreeWidgetItem(treeWidget, lastItem);
+ }
+ item->setText(0, block.text());
+ lastItem = item;
+ /*
+//! [4]
+ processListItem(list, index);
+//! [4]
+ */
+//! [5]
+ }
+//! [5] //! [6]
+ }
+//! [6] //! [7]
+ }
+//! [7]
+
+ treeWidget->setWindowTitle(tr("List Contents"));
+ treeWidget->show();
+}
+
+void MainWindow::insertList()
+{
+ QTextCursor cursor = editor->textCursor();
+ cursor.beginEditBlock();
+
+ QTextList *list = cursor.currentList();
+ QTextListFormat listFormat;
+ if (list)
+ listFormat = list->format();
+
+ listFormat.setStyle(QTextListFormat::ListDisc);
+ listFormat.setIndent(listFormat.indent() + 1);
+ cursor.insertList(listFormat);
+
+ cursor.endEditBlock();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.h
new file mode 100644
index 000000000..4d8dab676
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-listitems/mainwindow.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QList>
+#include <QMainWindow>
+#include <QString>
+
+class QAction;
+class QTextDocument;
+class QTextEdit;
+class QTextList;
+class QTreeWidgetItem;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void insertList();
+ void highlightListItems();
+ void showList();
+
+private:
+ QString currentFile;
+ QTextEdit *editor;
+ QTextDocument *document;
+ QList<QTextList*> listStructures;
+ QList<QTreeWidgetItem*> previousItems;
+ QList<QTreeWidgetItem*> parentItems;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/main.cpp
new file mode 100644
index 000000000..f6ba623fb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.cpp
new file mode 100644
index 000000000..d9707f30c
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.cpp
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
+ QKeySequence(tr("Ctrl+Q", "File|Exit")));
+
+ QMenu *editMenu = new QMenu(tr("&Edit"));
+
+ cutAction = editMenu->addAction(tr("Cu&t"), this, SLOT(cutSelection()),
+ QKeySequence(tr("Ctrl+X", "Edit|Cut")));
+ copyAction = editMenu->addAction(tr("&Copy"), this, SLOT(copySelection()),
+ QKeySequence(tr("Ctrl+C", "Edit|Copy")));
+ pasteAction = editMenu->addAction(tr("&Paste"), this,
+ SLOT(pasteSelection()), QKeySequence(tr("Ctrl+V", "Edit|Paste")));
+
+ QMenu *selectMenu = new QMenu(tr("&Select"));
+ selectMenu->addAction(tr("&Word"), this, SLOT(selectWord()));
+ selectMenu->addAction(tr("&Line"), this, SLOT(selectLine()));
+ selectMenu->addAction(tr("&Block"), this, SLOT(selectBlock()));
+ selectMenu->addAction(tr("&Frame"), this, SLOT(selectFrame()));
+
+ QMenu *insertMenu = new QMenu(tr("&Insert"));
+
+ insertMenu->addAction(tr("&List"), this, SLOT(insertList()),
+ QKeySequence(tr("Ctrl+L", "Insert|List")));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(editMenu);
+ menuBar()->addMenu(selectMenu);
+ menuBar()->addMenu(insertMenu);
+
+ editor = new QTextEdit(this);
+ document = new QTextDocument(this);
+ editor->setDocument(document);
+
+ connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
+
+ updateMenus();
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+void MainWindow::cutSelection()
+{
+ QTextCursor cursor = editor->textCursor();
+ if (cursor.hasSelection()) {
+ selection = cursor.selection();
+ cursor.removeSelectedText();
+ }
+}
+
+void MainWindow::copySelection()
+{
+ QTextCursor cursor = editor->textCursor();
+ if (cursor.hasSelection()) {
+ selection = cursor.selection();
+ cursor.clearSelection();
+ }
+}
+
+void MainWindow::pasteSelection()
+{
+ QTextCursor cursor = editor->textCursor();
+ cursor.insertFragment(selection);
+}
+
+void MainWindow::selectWord()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextBlock block = cursor.block();
+
+ cursor.beginEditBlock();
+ cursor.movePosition(QTextCursor::StartOfWord);
+ cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::selectLine()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextBlock block = cursor.block();
+
+ cursor.beginEditBlock();
+ cursor.movePosition(QTextCursor::StartOfLine);
+ cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::selectBlock()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextBlock block = cursor.block();
+
+ cursor.beginEditBlock();
+ cursor.movePosition(QTextCursor::StartOfBlock);
+ cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::selectFrame()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextFrame *frame = cursor.currentFrame();
+
+ cursor.beginEditBlock();
+ cursor.setPosition(frame->firstPosition());
+ cursor.setPosition(frame->lastPosition(), QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::insertList()
+{
+ QTextCursor cursor = editor->textCursor();
+ cursor.beginEditBlock();
+
+ QTextList *list = cursor.currentList();
+//! [0]
+ listFormat = QTextListFormat()
+ if list:
+ listFormat = list.format()
+ listFormat.setIndent(listFormat.indent() + 1)
+
+ listFormat.setStyle(QTextListFormat.ListDisc)
+ cursor.insertList(listFormat)
+//! [0]
+
+ cursor.endEditBlock();
+}
+
+void MainWindow::updateMenus()
+{
+ QTextCursor cursor = editor->textCursor();
+ cutAction->setEnabled(cursor.hasSelection());
+ copyAction->setEnabled(cursor.hasSelection());
+
+ pasteAction->setEnabled(!selection.isEmpty());
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.h
new file mode 100644
index 000000000..cfbc1d0c4
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-lists/mainwindow.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+#include <QTextDocumentFragment>
+
+class QAction;
+class QTextDocument;
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void cutSelection();
+ void copySelection();
+ void insertList();
+ void pasteSelection();
+ void selectWord();
+ void selectLine();
+ void selectBlock();
+ void selectFrame();
+ void updateMenus();
+
+private:
+ QAction *cutAction;
+ QAction *copyAction;
+ QAction *pasteAction;
+ QString currentFile;
+ QTextEdit *editor;
+ QTextDocument *document;
+ QTextDocumentFragment selection;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/main.cpp
new file mode 100644
index 000000000..f6ba623fb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.cpp
new file mode 100644
index 000000000..a8f8d1b6b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
+ QKeySequence(tr("Ctrl+O", "File|Open")));
+
+ printAction = fileMenu->addAction(tr("&Print..."), this, SLOT(printFile()));
+ printAction->setEnabled(false);
+
+ pdfPrintAction = fileMenu->addAction(tr("Print as P&DF..."), this, SLOT(printPdf()));
+ pdfPrintAction->setEnabled(false);
+
+ fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
+ QKeySequence(tr("Ctrl+Q", "File|Exit")));
+
+ menuBar()->addMenu(fileMenu);
+
+ editor = new QTextEdit(this);
+ document = new QTextDocument(this);
+ editor->setDocument(document);
+
+ connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+void MainWindow::openFile()
+{
+ QString fileName = QFileDialog::getOpenFileName(this,
+ tr("Open file"), currentFile, "HTML files (*.html);;Text files (*.txt)");
+
+ if (!fileName.isEmpty()) {
+ QFileInfo info(fileName);
+ if (info.completeSuffix() == "html") {
+ QFile file(fileName);
+
+ if (file.open(QIODevice::ReadOnly)) {
+ editor->setHtml(file.readAll());
+ file.close();
+ currentFile = fileName;
+ }
+ } else if (info.completeSuffix() == "txt") {
+ QFile file(fileName);
+
+ if (file.open(QIODevice::ReadOnly)) {
+ editor->setPlainText(file.readAll());
+ file.close();
+ currentFile = fileName;
+ }
+ }
+ printAction->setEnabled(true);
+ pdfPrintAction->setEnabled(true);
+ }
+}
+
+void MainWindow::printFile()
+{
+//! [0]
+ QTextDocument *document = editor->document();
+ QPrinter printer;
+
+ QPrintDialog *dlg = new QPrintDialog(&printer, this);
+ if (dlg->exec() != QDialog::Accepted)
+ return;
+
+ document->print(&printer);
+//! [0]
+}
+
+void MainWindow::printPdf()
+{
+ QPrinter printer(QPrinter::HighResolution);
+ printer.setOutputFormat(QPrinter::PdfFormat);
+
+ QPrintDialog *printDialog = new QPrintDialog(&printer, this);
+ if (printDialog->exec() == QDialog::Accepted)
+ editor->document()->print(&printer);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.h
new file mode 100644
index 000000000..133dd5973
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-printing/mainwindow.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QHash>
+#include <QMainWindow>
+#include <QTextDocumentFragment>
+
+class QAction;
+class QTextDocument;
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void openFile();
+ void printFile();
+ void printPdf();
+
+private:
+ QAction *printAction;
+ QAction *pdfPrintAction;
+ QString currentFile;
+ QTextEdit *editor;
+ QTextDocument *document;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/main.cpp
new file mode 100644
index 000000000..f6ba623fb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.cpp
new file mode 100644
index 000000000..bde20edda
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.cpp
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
+ QKeySequence(tr("Ctrl+O", "File|Open")));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"), this, SLOT(close()));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *editMenu = new QMenu(tr("&Edit"));
+
+ cutAction = editMenu->addAction(tr("Cu&t"), this, SLOT(cutSelection()));
+ cutAction->setShortcut(tr("Ctrl+X"));
+ cutAction->setEnabled(false);
+
+ copyAction = editMenu->addAction(tr("&Copy"), this, SLOT(copySelection()));
+ copyAction->setShortcut(tr("Ctrl+C"));
+ copyAction->setEnabled(false);
+
+ pasteAction = editMenu->addAction(tr("&Paste"), this, SLOT(pasteSelection()));
+ pasteAction->setShortcut(tr("Ctrl+V"));
+ pasteAction->setEnabled(false);
+
+ QMenu *selectMenu = new QMenu(tr("&Select"));
+ selectMenu->addAction(tr("&Word"), this, SLOT(selectWord()));
+ selectMenu->addAction(tr("&Line"), this, SLOT(selectLine()));
+ selectMenu->addAction(tr("&Block"), this, SLOT(selectBlock()));
+ selectMenu->addAction(tr("&Frame"), this, SLOT(selectFrame()));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(editMenu);
+ menuBar()->addMenu(selectMenu);
+
+ editor = new QTextEdit(this);
+ document = new QTextDocument(this);
+ editor->setDocument(document);
+
+ connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+void MainWindow::openFile()
+{
+ QString fileName = QFileDialog::getOpenFileName(this,
+ tr("Open file"), currentFile, "HTML files (*.html);;Text files (*.txt)");
+
+ if (!fileName.isEmpty()) {
+ QFileInfo info(fileName);
+ if (info.completeSuffix() == "html") {
+ QFile file(fileName);
+
+ if (file.open(QFile::ReadOnly)) {
+ editor->setHtml(QString(file.readAll()));
+ file.close();
+ currentFile = fileName;
+ }
+ } else if (info.completeSuffix() == "txt") {
+ QFile file(fileName);
+
+ if (file.open(QFile::ReadOnly)) {
+ editor->setPlainText(file.readAll());
+ file.close();
+ currentFile = fileName;
+ }
+ }
+ }
+}
+
+void MainWindow::cutSelection()
+{
+ QTextCursor cursor = editor->textCursor();
+ if (cursor.hasSelection()) {
+ selection = cursor.selection();
+ cursor.removeSelectedText();
+ }
+}
+
+void MainWindow::copySelection()
+{
+ QTextCursor cursor = editor->textCursor();
+ if (cursor.hasSelection()) {
+ selection = cursor.selection();
+ cursor.clearSelection();
+ }
+}
+
+void MainWindow::pasteSelection()
+{
+ QTextCursor cursor = editor->textCursor();
+ cursor.insertFragment(selection);
+}
+
+void MainWindow::selectWord()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextBlock block = cursor.block();
+
+//! [0]
+ cursor.beginEditBlock();
+//! [1]
+ cursor.movePosition(QTextCursor::StartOfWord);
+ cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
+//! [1]
+ cursor.endEditBlock();
+//! [0]
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::selectLine()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextBlock block = cursor.block();
+
+ cursor.beginEditBlock();
+ cursor.movePosition(QTextCursor::StartOfLine);
+ cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::selectBlock()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextBlock block = cursor.block();
+
+ cursor.beginEditBlock();
+ cursor.movePosition(QTextCursor::StartOfBlock);
+ cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::selectFrame()
+{
+ QTextCursor cursor = editor->textCursor();
+ QTextFrame *frame = cursor.currentFrame();
+
+ cursor.beginEditBlock();
+ cursor.setPosition(frame->firstPosition());
+ cursor.setPosition(frame->lastPosition(), QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+
+ editor->setTextCursor(cursor);
+}
+
+void MainWindow::updateMenus()
+{
+ QTextCursor cursor = editor->textCursor();
+ cutAction->setEnabled(cursor.hasSelection());
+ copyAction->setEnabled(cursor.hasSelection());
+
+ pasteAction->setEnabled(!selection.isEmpty());
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.h
new file mode 100644
index 000000000..311fb923a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-selections/mainwindow.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+#include <QTextDocumentFragment>
+
+class QAction;
+class QTextDocument;
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void cutSelection();
+ void copySelection();
+ void openFile();
+ void pasteSelection();
+ void selectWord();
+ void selectLine();
+ void selectBlock();
+ void selectFrame();
+ void updateMenus();
+
+private:
+ QAction *cutAction;
+ QAction *copyAction;
+ QAction *pasteAction;
+ QString currentFile;
+ QTextEdit *editor;
+ QTextDocument *document;
+ QTextDocumentFragment selection;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/main.cpp
new file mode 100644
index 000000000..9ebc95f09
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->resize(480, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.cpp
new file mode 100644
index 000000000..c15d43646
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.cpp
@@ -0,0 +1,125 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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] //! [1]
+ cursor = QTextCursor(editor.textCursor())
+//! [0]
+ cursor.movePosition(QTextCursor.Start)
+//! [1]
+
+//! [2]
+ tableFormat = QTextTableFormat()
+ tableFormat.setBackground(QColor("#e0e0e0"))
+ QVector<QTextLength> constraints
+ constraints << QTextLength(QTextLength.PercentageLength, 16)
+ constraints << QTextLength(QTextLength.PercentageLength, 28)
+ constraints << QTextLength(QTextLength.PercentageLength, 28)
+ constraints << QTextLength(QTextLength.PercentageLength, 28)
+ tableFormat.setColumnWidthConstraints(constraints)
+//! [3]
+ table = cursor.insertTable(rows, columns, tableFormat)
+//! [2] //! [3]
+
+//! [4]
+ cell = table.cellAt(0, 0)
+ cellCursor = cell.firstCursorPosition()
+ cellCursor.insertText(tr("Week"), charFormat)
+//! [4]
+
+//! [5]
+ for column in range(columns):
+ cell = table.cellAt(0, column)
+ cellCursor = cell.firstCursorPosition()
+ cellCursor.insertText(tr("Team %1").arg(column), charFormat)
+
+
+ for row in range(rows):
+ cell = table.cellAt(row, 0)
+ cellCursor = cell.firstCursorPosition()
+ cellCursor.insertText(tr("%1").arg(row), charFormat)
+
+ for column in range(columns)
+ if (row-1) % 3 == column-1:
+//! [5] //! [6]
+ cell = table.cellAt(row, column)
+ cellCursor = cell.firstCursorPosition()
+ cellCursor.insertText(tr("On duty"), charFormat)
+
+//! [6] //! [7]
+
+//! [7] //! [8]
+
+//! [8]
+
+//! [9]
+ for row in range(table.rows()):
+ for column in range(table.columns()):
+ tableCell = table.cellAt(row, column)
+//! [9]
+ QTextFrame.iterator it
+ QString text
+ for (it = tableCell.begin() !(it.atEnd()); ++it):
+ QTextBlock childBlock = it.currentBlock()
+ if (childBlock.isValid())
+ text += childBlock.text()
+
+ Item = QTableWidgetItem(text)
+ tableWidget.setItem(row, column, Item)
+
+//! [10]
+ processTableCell(tableCell)
+//! [10]
+
+//! [11]
+
+//! [11] //! [12]
+
+//! [12]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.h
new file mode 100644
index 000000000..15671417b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/mainwindow.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QMainWindow>
+
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void saveFile();
+ void showTable();
+
+private:
+ bool writeXml(const QString &fileName);
+
+ QTextEdit *editor;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.cpp
new file mode 100644
index 000000000..3f6640aec
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.cpp
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "xmlwriter.h"
+
+QDomDocument *XmlWriter::toXml()
+{
+ QDomImplementation implementation;
+ QDomDocumentType docType = implementation.createDocumentType(
+ "scribe-document", "scribe", "qtsoftware.com/scribe");
+
+ document = new QDomDocument(docType);
+
+ // ### This processing instruction is required to ensure that any kind
+ // of encoding is given when the document is written.
+ QDomProcessingInstruction process = document->createProcessingInstruction(
+ "xml", "version=\"1.0\" encoding=\"utf-8\"");
+ document->appendChild(process);
+
+ QDomElement documentElement = document->createElement("document");
+ document->appendChild(documentElement);
+
+ QTextFrame *root = textDocument->rootFrame();
+
+ if (root)
+ processFrame(documentElement, root);
+
+ return document;
+}
+
+void XmlWriter::processBlock(QDomElement &parent, const QTextBlock &block)
+{
+ QDomElement blockElement = document->createElement("block");
+ blockElement.setAttribute("position", block.position());
+ blockElement.setAttribute("length", block.length());
+ parent.appendChild(blockElement);
+
+ QTextBlock::iterator it;
+ for (it = block.begin(); !(it.atEnd()); ++it) {
+ QTextFragment fragment = it.fragment();
+
+ if (fragment.isValid()) {
+ QDomElement fragmentElement = document->createElement("fragment");
+ blockElement.appendChild(fragmentElement);
+
+ fragmentElement.setAttribute("length", fragment.length());
+ QDomText fragmentText = document->createTextNode(fragment.text());
+
+ fragmentElement.appendChild(fragmentText);
+ }
+ }
+}
+
+void XmlWriter::processFrame(QDomElement &parent, QTextFrame *frame)
+{
+ QDomElement frameElement = document->createElement("frame");
+ frameElement.setAttribute("begin", frame->firstPosition());
+ frameElement.setAttribute("end", frame->lastPosition());
+ parent.appendChild(frameElement);
+
+//! [0]
+ QTextFrame::iterator it;
+ for (it = frame->begin(); !(it.atEnd()); ++it) {
+
+ QTextFrame *childFrame = it.currentFrame();
+ QTextBlock childBlock = it.currentBlock();
+
+ if (childFrame) {
+ QTextTable *childTable = qobject_cast<QTextTable*>(childFrame);
+
+ if (childTable)
+ processTable(frameElement, childTable);
+ else
+ processFrame(frameElement, childFrame);
+
+ } else if (childBlock.isValid())
+//! [0] //! [1]
+ processBlock(frameElement, childBlock);
+ }
+//! [1]
+}
+
+void XmlWriter::processTable(QDomElement &parent, QTextTable *table)
+{
+ QDomElement element = document->createElement("table");
+
+ for (int row = 0; row < table->rows(); ++row) {
+ for (int column = 0; column < table->columns(); ++column) {
+ QTextTableCell cell = table->cellAt(row, column);
+ processTableCell(element, cell);
+ }
+ }
+ parent.appendChild(element);
+}
+
+void XmlWriter::processTableCell(QDomElement &parent, const QTextTableCell &cell)
+{
+ QDomElement element = document->createElement("cell");
+ element.setAttribute("row", cell.row());
+ element.setAttribute("column", cell.column());
+
+ QTextFrame::iterator it;
+ for (it = cell.begin(); !(it.atEnd()); ++it) {
+
+ QTextFrame *childFrame = it.currentFrame();
+ QTextBlock childBlock = it.currentBlock();
+
+ if (childFrame)
+ processFrame(element, childFrame);
+ else if (childBlock.isValid())
+ processBlock(element, childBlock);
+ }
+ parent.appendChild(element);
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.h
new file mode 100644
index 000000000..6cfab3aa0
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-tables/xmlwriter.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef XMLWRITER_H
+#define XMLWRITER_H
+
+#include <QDomDocument>
+
+class QTextDocument;
+
+class XmlWriter
+{
+public:
+ XmlWriter(QTextDocument *document) : textDocument(document) {}
+ QDomDocument *toXml();
+
+private:
+ void processBlock(QDomElement &parent, const QTextBlock &block);
+ void processFrame(QDomElement &parent, QTextFrame *frame);
+ void processTable(QDomElement &parent, QTextTable *table);
+ void processTableCell(QDomElement &parent, const QTextTableCell &cell);
+
+ QDomDocument *document;
+ QTextDocument *textDocument;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-texttable/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-texttable/main.cpp
new file mode 100644
index 000000000..7874764db
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocument-texttable/main.cpp
@@ -0,0 +1,56 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ table.mergeCells(0, 0, 1, 2)
+//! [0] //! [1]
+ table.splitCell(0, 0, 1, 1)
+//! [1]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocumentendsnippet.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocumentendsnippet.cpp
new file mode 100644
index 000000000..3ad7b4785
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/textdocumentendsnippet.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <iostream.h>
+
+int main(int argv, char **args)
+{
+ QString contentString("One\nTwp\nThree");
+
+ QTextDocument *doc = new QTextDocument(contentString);
+
+//! [0]
+ it = doc.begin()
+ while it != doc.end():
+ print it.text()
+ it = it.next()
+//! [0]
+
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/threads/threads.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/threads/threads.cpp
new file mode 100644
index 000000000..6a7f042bd
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/threads/threads.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QCache>
+#include <QMutex>
+#include <QThreadStorage>
+
+#include "threads.h"
+
+//! [0]
+void MyThread::run()
+//! [0] //! [1]
+{
+//! [1] //! [2]
+}
+//! [2]
+
+#define Counter ReentrantCounter
+
+//! [3]
+class Counter
+//! [3] //! [4]
+{
+public:
+ Counter() { n = 0; }
+
+ void increment() { ++n; }
+ void decrement() { --n; }
+ int value() const { return n; }
+
+private:
+ int n;
+};
+//! [4]
+
+#undef Counter
+#define Counter ThreadSafeCounter
+
+//! [5]
+class Counter
+//! [5] //! [6]
+{
+public:
+ Counter() { n = 0; }
+
+ void increment() { QMutexLocker locker(&mutex); ++n; }
+ void decrement() { QMutexLocker locker(&mutex); --n; }
+ int value() const { QMutexLocker locker(&mutex); return n; }
+
+private:
+ mutable QMutex mutex;
+ int n;
+};
+//! [6]
+
+typedef int SomeClass;
+
+//! [7]
+QThreadStorage<QCache<QString, SomeClass> *> caches;
+
+void cacheObject(const QString &key, SomeClass *object)
+//! [7] //! [8]
+{
+ if (!caches.hasLocalData())
+ caches.setLocalData(new QCache<QString, SomeClass>);
+
+ caches.localData()->insert(key, object);
+}
+
+void removeFromCache(const QString &key)
+//! [8] //! [9]
+{
+ if (!caches.hasLocalData())
+ return;
+
+ caches.localData()->remove(key);
+}
+//! [9]
+
+int main()
+{
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/threads/threads.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/threads/threads.h
new file mode 100644
index 000000000..01f03ee62
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/threads/threads.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QThread>
+
+//! [0]
+class MyThread : public QThread
+{
+ Q_OBJECT
+
+protected:
+ void run();
+};
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/timeline/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/timeline/main.cpp
new file mode 100644
index 000000000..70be14a03
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/timeline/main.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <math.h>
+
+int main(int argv, char *args[])
+{
+ QApplication app(argv, args)
+
+//! [0]
+ ball = QGraphicsEllipseItem(0, 0, 20, 20)
+
+ timer = QTimeLine(5000)
+ timer.setFrameRange(0, 100)
+
+ animation = QGraphicsItemAnimation()
+ animation.setItem(ball)
+ animation.setTimeLine(timer)
+
+ for i in range(200):
+ animation.setPosAt(i / 200.0, QPointF(i, i))
+
+ scene = QGraphicsScene()
+ scene.setSceneRect(0, 0, 250, 250)
+ scene.addItem(ball)
+
+ view = QGraphicsView(scene)
+ view.show()
+
+ timer.start()
+//! [0]
+
+ return app.exec()
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/timers/timers.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/timers/timers.cpp
new file mode 100644
index 000000000..c13be4b95
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/timers/timers.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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 QTimer
+
+class Foo : public QObject
+{
+public:
+ Foo()
+}
+
+Foo::Foo()
+{
+//! [0]
+ timer = QTimer(self)
+//! [0] //! [1]
+ timer.timeout.connect(self.updateCaption)
+//! [1] //! [2]
+ timer.start(1000)
+//! [2]
+
+//! [3]
+ QTimer.singleShot(200, self.updateCaption)
+//! [3]
+
+ {
+ // ZERO-CASE
+//! [4]
+ timer = QTimer(self)
+//! [4] //! [5]
+ timer.timeout.connect(self.processOneThing)
+//! [5] //! [6]
+ timer.start()
+//! [6]
+ }
+}
+
+int main()
+{
+
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/transform/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/transform/main.cpp
new file mode 100644
index 000000000..6d84261e9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/transform/main.cpp
@@ -0,0 +1,110 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+def paintEvent(self, event)
+ painter = QPainter(self)
+ painter.setPen(QPen(Qt.blue, 1, Qt.DashLine))
+ painter.drawRect(0, 0, 100, 100)
+
+ painter.rotate(45)
+
+ painter.setFont(QFont("Helvetica", 24))
+ painter.setPen(QPen(Qt.black, 1))
+ painter.drawText(20, 10, "QTransform")
+//! [0]
+
+//! [1]
+def paintEvent(self, event)
+ painter = QPainter(self)
+ painter.setPen(QPen(Qt.blue, 1, Qt.DashLine))
+ painter.drawRect(0, 0, 100, 100)
+
+ transform = QTransform()
+ transform.translate(50, 50)
+ transform.rotate(45)
+ transform.scale(0.5, 1.0)
+ painter.setTransform(transform)
+
+ painter.setFont(QFont("Helvetica", 24))
+ painter.setPen(QPen(Qt.black, 1))
+ painter.drawText(20, 10, "QTransform")
+//! [1]
+
+
+//! [2]
+def paintEvent(self, event)
+ pi = 3.14
+
+ a = pi/180 * 45.0
+ sina = sin(a)
+ cosa = cos(a)
+
+ translationTransform = QTransform(1, 0, 0, 1, 50.0, 50.0)
+ rotationTransform = QTransform(cosa, sina, -sina, cosa, 0, 0)
+ scalingTransform = QTransform(0.5, 0, 0, 1.0, 0, 0)
+
+ transform = QTransform()
+ transform = scalingTransform * rotationTransform * translationTransform
+
+ painter = QPainter(self)
+ painter.setPen(QPen(Qt.blue, 1, Qt.DashLine))
+ painter.drawRect(0, 0, 100, 100)
+
+ painter.setTransform(transform)
+
+ painter.setFont(QFont("Helvetica", 24))
+ painter.setPen(QPen(Qt.black, 1))
+ painter.drawText(20, 10, "QTransform")
+
+//! [2]
+
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.ui b/sources/pyside2/doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.ui
new file mode 100644
index 000000000..dda0e62dd
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/uitools/calculatorform/calculatorform.ui
@@ -0,0 +1,303 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>CalculatorForm</class>
+ <widget class="QWidget" name="CalculatorForm" >
+ <property name="objectName" >
+ <string notr="true" >CalculatorForm</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>276</width>
+ <height>98</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle" >
+ <string>Calculator Builder</string>
+ </property>
+ <layout class="QGridLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="0" column="0" >
+ <layout class="QHBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label" >
+ <property name="objectName" >
+ <string notr="true" >label</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>45</width>
+ <height>19</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Input 1</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="inputSpinBox1" >
+ <property name="objectName" >
+ <string notr="true" >inputSpinBox1</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>26</y>
+ <width>45</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="mouseTracking" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3" >
+ <property name="objectName" >
+ <string notr="true" >label_3</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>54</x>
+ <y>1</y>
+ <width>7</width>
+ <height>52</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>+</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_2" >
+ <property name="objectName" >
+ <string notr="true" >label_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>45</width>
+ <height>19</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Input 2</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="inputSpinBox2" >
+ <property name="objectName" >
+ <string notr="true" >inputSpinBox2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>26</y>
+ <width>45</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="mouseTracking" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3_2" >
+ <property name="objectName" >
+ <string notr="true" >label_3_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>120</x>
+ <y>1</y>
+ <width>7</width>
+ <height>52</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>=</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="objectName" >
+ <string notr="true" />
+ </property>
+ <property name="margin" >
+ <number>1</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_2_2_2" >
+ <property name="objectName" >
+ <string notr="true" >label_2_2_2</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>1</y>
+ <width>37</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Output</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="outputWidget" >
+ <property name="objectName" >
+ <string notr="true" >outputWidget</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>1</x>
+ <y>24</y>
+ <width>37</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <property name="text" >
+ <string>0</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignAbsolute|Qt::AlignBottom|Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignHorizontal_Mask|Qt::AlignJustify|Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing|Qt::AlignVCenter|Qt::AlignVertical_Mask</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0" >
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" >verticalSpacer</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>85</x>
+ <y>69</y>
+ <width>20</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="1" >
+ <spacer>
+ <property name="objectName" >
+ <string notr="true" >horizontalSpacer</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>188</x>
+ <y>26</y>
+ <width>79</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/uitools/calculatorform/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/uitools/calculatorform/main.cpp
new file mode 100644
index 000000000..d89d230c7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/uitools/calculatorform/main.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+#include "ui_calculatorform.h"
+//! [0]
+#include <QApplication>
+
+//! [1]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget *widget = new QWidget;
+ Ui::CalculatorForm ui;
+ ui.setupUi(widget);
+
+ widget->show();
+ return app.exec();
+}
+//! [1]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/main.cpp
new file mode 100644
index 000000000..48588d081
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example that shows how selections can be used directly on a model.
+ It shows the result of some selections made using a table view.
+*/
+
+#include <QApplication>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QMainWindow *window = new MainWindow;
+ window->show();
+ window->resize(640, 480);
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/model.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/model.h
new file mode 100644
index 000000000..886e77852
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/model.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QVariant>
+
+class TableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ TableModel(int rows = 1, int columns = 1, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+
+private:
+ QList<QStringList> rowList;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/window.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/window.cpp
new file mode 100644
index 000000000..0bd7fbfda
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/window.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+ window.cpp
+
+ A minimal subclass of QTableView with slots to allow the selection model
+ to be monitored.
+*/
+
+#include <QAbstractItemModel>
+#include <QItemSelection>
+#include <QItemSelectionModel>
+#include <QStatusBar>
+
+#include "model.h"
+#include "window.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ setWindowTitle("Selected items in a table model");
+
+ model = new TableModel(8, 4, this);
+
+ table = new QTableView(this);
+ table->setModel(model);
+
+ selectionModel = table->selectionModel();
+ connect(selectionModel,
+ SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+ this, SLOT(updateSelection(const QItemSelection &, const QItemSelection &)));
+ connect(selectionModel,
+ SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(changeCurrent(const QModelIndex &, const QModelIndex &)));
+
+ statusBar();
+ setCentralWidget(table);
+}
+
+//! [0]
+void MainWindow::updateSelection(const QItemSelection &selected,
+ const QItemSelection &deselected)
+{
+ QModelIndex index;
+ QModelIndexList items = selected.indexes();
+
+ foreach (index, items) {
+ QString text = QString("(%1,%2)").arg(index.row()).arg(index.column());
+ model->setData(index, text);
+//! [0] //! [1]
+ }
+//! [1]
+
+//! [2]
+ items = deselected.indexes();
+
+ foreach (index, items)
+ model->setData(index, "");
+}
+//! [2]
+
+//! [3]
+void MainWindow::changeCurrent(const QModelIndex &current,
+ const QModelIndex &previous)
+{
+ statusBar()->showMessage(
+ tr("Moved from (%1,%2) to (%3,%4)")
+ .arg(previous.row()).arg(previous.column())
+ .arg(current.row()).arg(current.column()));
+}
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/window.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/window.h
new file mode 100644
index 000000000..032412d40
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/updating-selections/window.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QItemSelection>
+#include <QMainWindow>
+#include <QModelIndex>
+#include <QWidget>
+#include <QTableView>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow(QWidget *parent = 0);
+
+public slots:
+ void updateSelection(const QItemSelection &selected,
+ const QItemSelection &deselected);
+ void changeCurrent(const QModelIndex &current, const QModelIndex &previous);
+
+private:
+ QAbstractItemModel *model;
+ QItemSelectionModel *selectionModel;
+ QTableView *table;
+};
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/webkit/webpage/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/webkit/webpage/main.cpp
new file mode 100644
index 000000000..0a416de58
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/webkit/webpage/main.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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.QtGui import *
+from PySide2.QWebKit import QWebPage
+from PySide2.QWebKit import QWebFrame
+
+
+//! [0]
+class Thumbnailer(QObject):
+ page = QWebPage()
+//! [1]
+ def __init__(self, url):
+ page.mainFrame().load(url)
+ connect(page, SIGNAL("loadFinished(bool)"),
+ self, SLOT("render()"))
+//! [1]
+
+//! [2]
+ def render(self):
+ page.setViewportSize(page.mainFrame().contentsSize())
+ image = QImage(page.viewportSize(), QImage.Format_ARGB32)
+ painter = QPainter(image)
+
+ page.mainFrame().render(painter)
+ painter.end()
+
+ thumbnail = image.scaled(400, 400)
+ thumbnail.save("thumbnail.png")
+
+ self.finished()
+//! [2]
+
+//! [0]
+
+def main():
+ app = QApplication([])
+ thumbnail = Thumbnailer(QUrl("http://qtsoftware.com"))
+ QObject.connect(thumbnail, SIGNAL("finished()"),
+ app, SLOT("quit()"))
+
+ return app.exec_()
+
+
+
+#include "main.moc"
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.cpp
new file mode 100644
index 000000000..d25ce3637
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/whatsthis/whatsthis.cpp
@@ -0,0 +1,57 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+ Act = QAction(tr("&New"), self)
+ Act.setShortcut(tr("Ctrl+N"))
+ Act.setStatusTip(QObject.tr("Create a new file"))
+ Act.setWhatsThis(QObject.tr("Click self option to create a new file."))
+//! [0]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/main.cpp
new file mode 100644
index 000000000..70f073783
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [0]
+ QLabel topLevelLabel;
+ QPixmap pixmap(":/images/tux.png");
+ topLevelLabel.setPixmap(pixmap);
+ topLevelLabel.setMask(pixmap.mask());
+//! [0]
+ topLevelLabel.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/mask.qrc b/sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/mask.qrc
new file mode 100644
index 000000000..92f227253
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/mask.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/images" >
+ <file>tux.png</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/tux.png b/sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/tux.png
new file mode 100644
index 000000000..a95527f3f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/widget-mask/tux.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/widgetdelegate.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/widgetdelegate.cpp
new file mode 100644
index 000000000..660ced865
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/widgetdelegate.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 WidgetDelegate (QStyledItemDelegate):
+ # ...
+
+ def paint(painter, option, index):
+ if index.column() == 1:
+ progress = index.data().toInt()
+
+ progressBarOption = QStyleOptionProgressBar()
+ progressBarOption.rect = option.rect
+ progressBarOption.minimum = 0
+ progressBarOption.maximum = 100
+ progressBarOption.progress = progress
+ progressBarOption.text = QString::number(progress) + "%"
+ progressBarOption.textVisible = True
+
+ QApplication.style().drawControl(QStyle.CE_ProgressBar, progressBarOption, painter)
+ else:
+ QStyledItemDelegate.paint(self, painter, option, index)
+
+//![0]
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/main.cpp
new file mode 100644
index 000000000..751b326c3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/childwidget/main.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget *window = new QWidget();
+ window->resize(320, 240);
+ window->setWindowTitle(tr("Child widget"));
+ window->show();
+
+//! [create, position and show]
+ QPushButton *button = new QPushButton(tr("Press me"), window);
+ button->move(100, 100);
+ button->show();
+//! [create, position and show]
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/main.cpp
new file mode 100644
index 000000000..f4e66193e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/nestedlayouts/main.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget *window = new QWidget();
+//! [create, lay out widgets and show]
+ QLabel *queryLabel = new QLabel(tr("Query:"));
+ QLineEdit *queryEdit = new QLineEdit();
+ QTableView *resultView = new QTableView();
+
+ QHBoxLayout *queryLayout = new QHBoxLayout();
+ queryLayout->addWidget(queryLabel);
+ queryLayout->addWidget(queryEdit);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout();
+ mainLayout->addLayout(queryLayout);
+ mainLayout->addWidget(resultView);
+ window->setLayout(mainLayout);
+//! [create, lay out widgets and show]
+
+ QStandardItemModel model;
+ model.setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Office"));
+ QList<QStringList> rows = QList<QStringList>()
+ << (QStringList() << "Verne Nilsen" << "123")
+ << (QStringList() << "Carlos Tang" << "77")
+ << (QStringList() << "Bronwyn Hawcroft" << "119")
+ << (QStringList() << "Alessandro Hanssen" << "32")
+ << (QStringList() << "Andrew John Bakken" << "54")
+ << (QStringList() << "Vanessa Weatherley" << "85")
+ << (QStringList() << "Rebecca Dickens" << "17")
+ << (QStringList() << "David Bradley" << "42")
+ << (QStringList() << "Knut Walters" << "25")
+ << (QStringList() << "Andrea Jones" << "34");
+ foreach (QStringList row, rows) {
+ QList<QStandardItem *> items;
+ foreach (QString text, row)
+ items.append(new QStandardItem(text));
+ model.appendRow(items);
+ }
+
+ resultView->setModel(&model);
+ resultView->verticalHeader()->hide();
+ resultView->horizontalHeader()->setStretchLastSection(true);
+ window->setWindowTitle(tr("Nested layouts"));
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/main.cpp
new file mode 100644
index 000000000..4d553de4b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/toplevel/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [create, resize and show]
+ QWidget *window = new QWidget();
+ window->resize(320, 240);
+ window->show();
+//! [create, resize and show]
+ window->setWindowTitle(tr("Top-level widget"));
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/main.cpp
new file mode 100644
index 000000000..06e7b3db3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/widgets-tutorial/windowlayout/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget *window = new QWidget();
+//! [create, lay out widgets and show]
+ QLabel *label = new QLabel(tr("Name:"));
+ QLineEdit *lineEdit = new QLineEdit();
+
+ QHBoxLayout *layout = new QHBoxLayout();
+ layout->addWidget(label);
+ layout->addWidget(lineEdit);
+ window->setLayout(layout);
+//! [create, lay out widgets and show]
+ window->setWindowTitle(tr("Window layout"));
+ window->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.cpp
new file mode 100644
index 000000000..4c2d26d7b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+handler.cpp
+
+Provides a handler for processing XML elements found by the reader.
+
+The handler looks for <title> and <link> elements within <item> elements,
+and records the text found within them. Link information stored within
+rdf:about attributes of <item> elements is also recorded when it is
+available.
+
+For each item found, a signal is emitted which specifies its title and
+link information. This may be used by user interfaces for the purpose of
+displaying items as they are read.
+*/
+
+#include <QtWidgets>
+
+#include "handler.h"
+
+/*
+ Reset the state of the handler to ensure that new documents are
+ read correctly.
+
+ We return true to indicate that parsing should continue.
+*/
+
+bool Handler::startDocument()
+{
+ inItem = false;
+ inTitle = false;
+ inLink = false;
+
+ return true;
+}
+
+/*
+ Process each starting element in the XML document.
+
+ Nested item, title, or link elements are not allowed, so we return false
+ if we encounter any of these. We also prohibit multiple definitions of
+ title strings.
+
+ Link destinations are read by this function if they are specified as
+ attributes in item elements.
+
+ For all cases not explicitly checked for, we return true to indicate that
+ the element is acceptable, and that parsing should continue. By doing
+ this, we can ignore elements in which we are not interested.
+*/
+
+bool Handler::startElement(const QString &, const QString &,
+ const QString & qName, const QXmlAttributes &attr)
+{
+ if (qName == "item") {
+
+ if (inItem)
+ return false;
+ else {
+ inItem = true;
+ linkString = attr.value("rdf:about");
+ }
+ }
+ else if (qName == "title") {
+
+ if (inTitle)
+ return false;
+ else if (!titleString.isEmpty())
+ return false;
+ else if (inItem)
+ inTitle = true;
+ }
+ else if (qName == "link") {
+
+ if (inLink)
+ return false;
+ else if (inItem)
+ inLink = true;
+ }
+
+ return true;
+}
+
+/*
+ Process each ending element in the XML document.
+
+ For recognized elements, we reset flags to ensure that we can read new
+ instances of these elements. If we have read an item element, emit a
+ signal to indicate that a new item is available for display.
+
+ We return true to indicate that parsing should continue.
+*/
+
+bool Handler::endElement(const QString &, const QString &,
+ const QString & qName)
+{
+ if (qName == "title" && inTitle)
+ inTitle = false;
+ else if (qName == "link" && inLink)
+ inLink = false;
+ else if (qName == "item") {
+ if (!titleString.isEmpty() && !linkString.isEmpty())
+ emit newItem(titleString, linkString);
+ inItem = false;
+ titleString = "";
+ linkString = "";
+ }
+
+ return true;
+}
+
+/*
+ Collect characters when reading the contents of title or link elements
+ when they occur within an item element.
+
+ We return true to indicate that parsing should continue.
+*/
+
+bool Handler::characters (const QString &chars)
+{
+ if (inTitle)
+ titleString += chars;
+ else if (inLink)
+ linkString += chars;
+
+ return true;
+}
+
+/*
+ Report a fatal parsing error, and return false to indicate to the reader
+ that parsing should stop.
+*/
+
+//! [0]
+def fatalError(self, exception):
+ qWarning("Fatal error on line %d, column %d:%s" % (exception.lineNumber(), exception.columnNumber(), exception.message())
+
+ return False
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.h
new file mode 100644
index 000000000..453b1e4c3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/handler.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef HANDLER_H
+#define HANDLER_H
+
+#include <QObject>
+#include <QString>
+#include <QXmlDefaultHandler>
+
+/* Note that QObject must precede QXmlDefaultHandler in the following list. */
+
+class Handler : public QObject, public QXmlDefaultHandler
+{
+ Q_OBJECT
+public:
+ bool startDocument();
+ bool startElement(const QString &, const QString &, const QString &qName,
+ const QXmlAttributes &attr);
+ bool endElement(const QString &, const QString &, const QString &qName);
+ bool characters(const QString &chars);
+
+ bool fatalError(const QXmlParseException &exception);
+
+signals:
+ void newItem(QString &title, QString &link);
+
+private:
+ QString titleString;
+ QString linkString;
+ bool inItem;
+ bool inTitle;
+ bool inLink;
+};
+
+#endif
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/main.cpp
new file mode 100644
index 000000000..db8a62732
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+main.cpp
+
+Provides the main function for the RSS news reader example.
+*/
+
+#include <QtWidgets>
+
+#include "rsslisting.h"
+
+/*!
+ Create an application and a main widget. Open the main widget for
+ user input, and exit with an appropriate return value when it is
+ closed.
+*/
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ RSSListing *rsslisting = new RSSListing;
+ rsslisting->show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.cpp
new file mode 100644
index 000000000..fb62dbecf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.cpp
@@ -0,0 +1,255 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+rsslisting.cpp
+
+Provides a widget for displaying news items from RDF news sources.
+RDF is an XML-based format for storing items of information (see
+http://www.w3.org/RDF/ for details).
+
+The widget itself provides a simple user interface for specifying
+the URL of a news source, and controlling the downloading of news.
+
+The widget downloads and parses the XML asynchronously, feeding the
+data to an XML reader in pieces. This allows the user to interrupt
+its operation, and also allows very large data sources to be read.
+*/
+
+
+#include <QtCore>
+#include <QtWidgets>
+#include <QtNetwork>
+#include <QtXml>
+
+#include "rsslisting.h"
+
+
+/*
+ Constructs an RSSListing widget with a simple user interface, and sets
+ up the XML reader to use a custom handler class.
+
+ The user interface consists of a line edit, two push buttons, and a
+ list view widget. The line edit is used for entering the URLs of news
+ sources; the push buttons start and abort the process of reading the
+ news.
+*/
+
+RSSListing::RSSListing(QWidget *parent)
+ : QWidget(parent)
+{
+ lineEdit = new QLineEdit(this);
+
+ fetchButton = new QPushButton(tr("Fetch"), this);
+ abortButton = new QPushButton(tr("Abort"), this);
+ abortButton->setEnabled(false);
+
+ treeWidget = new QTreeWidget(this);
+ QStringList headerLabels;
+ headerLabels << tr("Title") << tr("Link");
+ treeWidget->setHeaderLabels(headerLabels);
+
+ handler = 0;
+
+ connect(&http, SIGNAL(readyRead(const QHttpResponseHeader &)),
+ this, SLOT(readData(const QHttpResponseHeader &)));
+
+ connect(&http, SIGNAL(requestFinished(int, bool)),
+ this, SLOT(finished(int, bool)));
+
+ connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(fetch()));
+ connect(fetchButton, SIGNAL(clicked()), this, SLOT(fetch()));
+ connect(abortButton, SIGNAL(clicked()), &http, SLOT(abort()));
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+
+ QHBoxLayout *hboxLayout = new QHBoxLayout;
+
+ hboxLayout->addWidget(lineEdit);
+ hboxLayout->addWidget(fetchButton);
+ hboxLayout->addWidget(abortButton);
+
+ layout->addLayout(hboxLayout);
+ layout->addWidget(treeWidget);
+
+ setWindowTitle(tr("RSS listing example"));
+}
+
+/*
+ Starts fetching data from a news source specified in the line
+ edit widget.
+
+ The line edit is made read only to prevent the user from modifying its
+ contents during the fetch; this is only for cosmetic purposes.
+ The fetch button is disabled, and the abort button is enabled to allow
+ the user to interrupt processing. The list view is cleared, and we
+ define the last list view item to be 0, meaning that there are no
+ existing items in the list.
+
+ We reset the flag used to determine whether parsing should begin again
+ or continue. A new handler is created, if required, and made available
+ to the reader.
+
+ The HTTP handler is supplied with the raw contents of the line edit and
+ a fetch is initiated. We keep the ID value returned by the HTTP handler
+ for future reference.
+*/
+
+void RSSListing::fetch()
+{
+ lineEdit->setReadOnly(true);
+ fetchButton->setEnabled(false);
+ abortButton->setEnabled(true);
+ treeWidget->clear();
+
+ lastItemCreated = 0;
+
+ newInformation = true;
+
+ if (handler != 0)
+ delete handler;
+ handler = new Handler;
+
+//! [0]
+ xmlReader.setContentHandler(handler)
+ xmlReader.setErrorHandler(handler)
+//! [0]
+
+ connect(handler, SIGNAL(newItem(QString &, QString &)),
+ this, SLOT(addItem(QString &, QString &)));
+
+ QUrl url(lineEdit->text());
+
+ http.setHost(url.host());
+ connectionId = http.get(url.path());
+}
+
+/*
+ Reads data received from the RDF source.
+
+ We read all the available data, and pass it to the XML
+ input source. The first time we receive new information,
+ the reader is set up for a new incremental parse;
+ we continue parsing using a different function on
+ subsequent calls involving the same data source.
+
+ If parsing fails for any reason, we abort the fetch.
+*/
+
+//! [1]
+def readData(self, resp):
+ if resp.statusCode() != 200:
+ self.http.abort()
+ else:
+ xmlInput.setData(self.http.readAll())
+
+ if newInformation:
+ ok = xmlReader.parse(xmlInput, True)
+ newInformation = False
+ else:
+ ok = xmlReader.parseContinue()
+
+ if not ok:
+ self.http.abort()
+//! [1]
+
+/*
+ Finishes processing an HTTP request.
+
+ The default behavior is to keep the text edit read only.
+
+ If an error has occurred, the user interface is made available
+ to the user for further input, allowing a new fetch to be
+ started.
+
+ If the HTTP get request has finished, we perform a final
+ parsing operation on the data returned to ensure that it was
+ well-formed. Whether this is successful or not, we make the
+ user interface available to the user for further input.
+*/
+
+void RSSListing::finished(int id, bool error)
+{
+ if (error) {
+ qWarning("Received error during HTTP fetch.");
+ lineEdit->setReadOnly(false);
+ abortButton->setEnabled(false);
+ fetchButton->setEnabled(true);
+ }
+ else if (id == connectionId) {
+
+ bool ok = xmlReader.parseContinue();
+ if (!ok)
+ qWarning("Parse error at the end of input.");
+
+ lineEdit->setReadOnly(false);
+ abortButton->setEnabled(false);
+ fetchButton->setEnabled(true);
+ }
+}
+
+/*
+ Adds an item to the list view as it is reported by the handler.
+
+ We keep a record of the last item created to ensure that the
+ items are created in sequence.
+*/
+
+void RSSListing::addItem(QString &title, QString &link)
+{
+ QTreeWidgetItem *item;
+
+ item = new QTreeWidgetItem(treeWidget, lastItemCreated);
+ item->setText(0, title);
+ item->setText(1, link);
+
+ lastItemCreated = item;
+}
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.h
new file mode 100644
index 000000000..9490a1a3e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/rsslisting/rsslisting.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef RSSLISTING_H
+#define RSSLISTING_H
+
+#include <QHttp>
+#include <QWidget>
+#include <QXmlInputSource>
+#include <QXmlSimpleReader>
+
+#include "handler.h"
+
+class QLineEdit;
+class QTreeWidget;
+class QTreeWidgetItem;
+class QPushButton;
+
+class RSSListing : public QWidget
+{
+ Q_OBJECT
+public:
+ RSSListing(QWidget *widget = 0);
+
+public slots:
+ void addItem(QString &title, QString &link);
+ void fetch();
+ void finished(int id, bool error);
+ void readData(const QHttpResponseHeader &);
+
+private:
+ Handler *handler;
+ QXmlInputSource xmlInput;
+ QXmlSimpleReader xmlReader;
+
+ bool newInformation;
+
+ QHttp http;
+ int connectionId;
+
+ QLineEdit *lineEdit;
+ QTreeWidget *treeWidget;
+ QTreeWidgetItem *lastItemCreated;
+ QPushButton *abortButton;
+ QPushButton *fetchButton;
+};
+
+#endif
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.cpp
new file mode 100644
index 000000000..6f18c7786
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+/*
+handler.cpp
+
+Provides a handler for processing XML elements found by the reader.
+
+The handler stores the names of elements it finds and their indentation
+levels. The indentation level is initially set to zero.
+When a starting element is found, the indentation level is increased;
+when an ending element is found, the indentation level is decreased.
+*/
+
+#include <QDebug>
+#include "handler.h"
+
+/*!
+ Reset the state of the handler to ensure that new documents are
+ read correctly.
+
+ We return true to indicate that parsing should continue.
+*/
+
+bool Handler::startDocument()
+{
+ elementName.clear();
+ elementIndentation.clear();
+ indentationLevel = 0;
+
+ return true;
+}
+
+/*!
+ Process each starting element in the XML document.
+
+ Append the element name to the list of elements found; add its
+ corresponding indentation level to the list of indentation levels.
+
+ Increase the level of indentation by one column.
+
+ We return true to indicate that parsing should continue.
+*/
+
+bool Handler::startElement(const QString &, const QString &,
+ const QString & qName, const QXmlAttributes &)
+{
+ elementName.append(qName);
+ elementIndentation.append(indentationLevel);
+ indentationLevel += 1;
+
+ return true;
+}
+
+/*!
+ Process each ending element in the XML document.
+
+ Decrease the level of indentation by one column.
+
+ We return true to indicate that parsing should continue.
+*/
+
+bool Handler::endElement(const QString &, const QString &,
+ const QString &)
+{
+ indentationLevel -= 1;
+
+ return true;
+}
+
+/*!
+ Report a fatal parsing error, and return false to indicate to the reader
+ that parsing should stop.
+*/
+
+bool Handler::fatalError (const QXmlParseException & exception)
+{
+ qWarning() << QString("Fatal error on line %1, column %2: %3").arg(
+ exception.lineNumber()).arg(exception.columnNumber()).arg(
+ exception.message());
+
+ return false;
+}
+
+/*!
+ Return the list of element names found.
+*/
+
+QStringList& Handler::names ()
+{
+ return elementName;
+}
+
+/*!
+ Return the list of indentations used for each element found.
+*/
+
+QList<int>& Handler::indentations ()
+{
+ return elementIndentation;
+}
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.h b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.h
new file mode 100644
index 000000000..1d3ec1144
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/handler.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef HANDLER_H
+#define HANDLER_H
+
+#include <qstring.h>
+#include <qxml.h>
+
+class Handler : public QXmlDefaultHandler
+{
+public:
+ bool startDocument();
+ bool startElement(const QString &, const QString &, const QString &qName,
+ const QXmlAttributes &);
+ bool endElement(const QString &, const QString &, const QString &);
+
+ bool fatalError(const QXmlParseException &exception);
+
+ QStringList& names();
+ QList<int>& indentations();
+
+private:
+ int indentationLevel;
+ QStringList elementName;
+ QList<int> elementIndentation;
+};
+
+#endif
+
diff --git a/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/main.cpp b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/main.cpp
new file mode 100644
index 000000000..f16891533
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/doc/src/snippets/xml/simpleparse/main.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <qfile.h>
+#include <qxml.h>
+#include "handler.h"
+
+#include <iostream>
+
+int main(int argc, char **argv)
+{
+ if (argc != 2) {
+ std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
+ return 1;
+ }
+
+ QFile *file = new QFile(argv[1]);
+
+//! [0]
+ xmlReader = QXmlSimpleReader()
+ source = QXmlInputSource(filename)
+//! [0]
+
+//! [1]
+ handler = Handler()
+ xmlReader.setContentHandler(handler)
+ xmlReader.setErrorHandler(handler)
+//! [1]
+
+//! [2]
+ ok = xmlReader.parse(source)
+
+ if not ok:
+ print "Parsing failed."
+//! [2]
+ else {
+ QStringList names = handler->names();
+ QList<int> indentations = handler->indentations();
+
+ int items = names.count();
+
+ for (int i = 0; i < items; ++i) {
+ for (int j = 0; j < indentations[i]; ++j)
+ std::cout << " ";
+ std::cout << names[i].toLocal8Bit().constData() << std::endl;
+ }
+ }
+
+ return 0;
+}
diff --git a/sources/pyside2/doc/codesnippets/examples/dbus/example-client.py b/sources/pyside2/doc/codesnippets/examples/dbus/example-client.py
new file mode 100755
index 000000000..a294b6f20
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dbus/example-client.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the documentation of PySide2.
+##
+## $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$
+##
+#############################################################################
+
+# -*- coding: utf-8 -*-
+
+# DBUS Client using PySide integration
+
+import sys
+from traceback import print_exc
+
+# import python dbus module
+import dbus
+# import python dbus GLib mainloop support
+import dbus.mainloop.glib
+# import QtCore
+from PySide2.QtCore import *
+
+# signal handler
+def button_clicked():
+ print "button clicked"
+
+# main function
+if __name__ == '__main__':
+
+ # Enable glib main loop support
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+ # Get the session bus
+ bus = dbus.SessionBus()
+
+ try:
+ # Get the remote object
+ remote_object = bus.get_object("com.example.SampleService",
+ "/DBusWidget")
+ # Get the remote interface for the remote object
+ iface = dbus.Interface(remote_object, "com.example.SampleWidget")
+ except dbus.DBusException:
+ print_exc()
+ sys.exit(1)
+
+ # Start the application
+ app = QCoreApplication([])
+
+ # Call some methods of the remote interface
+ iface.show()
+ iface.setText("Emit signal")
+ # connect the DBus signal clicked to the function button_clicked
+ iface.connect_to_signal("clicked", button_clicked)
+ iface.connect_to_signal("lastWindowClosed", app.quit)
+
+ # enter in the main loop
+ app.exec_()
diff --git a/sources/pyside2/doc/codesnippets/examples/dbus/example-server.py b/sources/pyside2/doc/codesnippets/examples/dbus/example-server.py
new file mode 100755
index 000000000..c4b9ce13e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dbus/example-server.py
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the documentation of PySide2.
+##
+## $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$
+##
+#############################################################################
+
+# -*- coding: utf-8 -*-
+
+# DBUS Server Example of use PySide with PyDBus library
+
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import random
+
+from PySide2.QtCore import *
+from PySide2.QtGui import QPushButton, QApplication
+
+# The adaptor, MUST inherit dbus.service.Object
+class DBusWidget(dbus.service.Object):
+ def __init__(self, name, session):
+ # export this object to dbus
+ dbus.service.Object.__init__(self, name, session)
+
+ # create a simple widget
+ self.widget = QPushButton()
+ self.widget.resize(200, 50)
+
+ # To export a Qt signal as a DBus-signal, you need to connect it to a method in this class.
+ # The method MUST have the signal annotation, so python-dbus will export it as a dbus-signal
+ QObject.connect(self.widget, SIGNAL("clicked()"), self.clicked)
+ QObject.connect(QApplication.instance(), SIGNAL("lastWindowClosed()"), self.lastWindowClosed)
+
+ # You can export methods to dbus like you do in python-dbus.
+ @dbus.service.method("com.example.SampleWidget", in_signature='', out_signature='')
+ def show(self):
+ self.widget.show()
+
+ # Another method... now with a parameter
+ @dbus.service.method("com.example.SampleWidget", in_signature='s', out_signature='')
+ def setText(self, value):
+ self.widget.setText(value)
+
+ # Another one...
+ @dbus.service.method("com.example.SampleWidget", in_signature='', out_signature='')
+ def exit(self):
+ qApp().quit()
+
+ # A signal that will be exported to dbus
+ @dbus.service.signal("com.example.SampleWidget", signature='')
+ def clicked(self):
+ pass
+
+ # Another signal that will be exported to dbus
+ @dbus.service.signal("com.example.SampleWidget", signature='')
+ def lastWindowClosed(self):
+ pass
+
+
+if __name__ == '__main__':
+ app = QApplication([])
+ # Use qt/glib mainloop integration to get dbus mainloop working
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+ session_bus = dbus.SessionBus()
+ # Export the service
+ name = dbus.service.BusName("com.example.SampleService", session_bus)
+ # Export the object
+ widget = DBusWidget(session_bus, '/DBusWidget')
+
+ print "Running example service."
+ app.exec_()
+
diff --git a/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml b/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml
new file mode 100644
index 000000000..ad51f2e7a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import "ImageProviderCore" // import the plugin that registers the color image provider
+
+//![0]
+Column {
+ Image { source: "image://colors/yellow" }
+ Image { source: "image://colors/red" }
+}
+//![0]
diff --git a/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/imageprovider/imageprovider.cpp b/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/imageprovider/imageprovider.cpp
new file mode 100644
index 000000000..ffbe8f564
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/imageprovider/imageprovider.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 ColorImageProvider (QDeclarativeImageProvider):
+ def __init__(self):
+ QDeclarativeImageProvider.__init__(self, QDeclarativeImageProvider.Pixmap)
+
+ def requestPixmap(id, size, requestedSize):
+ width = 100
+ height = 50
+
+ if size:
+ size.setWidth(width)
+ size.setHeight(height)
+
+ if requestedSize.width() > 0:
+ width = requestedSize.width()
+ if requestedSize.height() > 0:
+ height = requestedSize.height()
+
+ pixmap = QPixmap(width, height)
+ pixmap.fill(QColor(id).rgba())
+//![0]
+ # write the color name
+ painter = QPainter(pixmap)
+ f = painter.font()
+ f.setPixelSize(20)
+ painter.setFont(f)
+ painter.setPen(Qt.black)
+ if requestedSize.isValid():
+ painter.scale(requestedSize.width() / width, requestedSize.height() / height)
+ painter.drawText(QRectF(0, 0, width, height), Qt.AlignCenter, id)
+//![1]
+ return pixmap
+//![1]
diff --git a/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugin.cpp b/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugin.cpp
new file mode 100644
index 000000000..822fded38
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugin.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 TimeModel (QObject):
+ hour = Property(int, getHour, notify = timeChanged)
+ minute = Property(int, getMinute, notify = timeChanged)
+//![0]
+
+//![plugin]
+class QExampleQmlPlugin (QDeclarativeExtensionPlugin):
+
+ def registerTypes(self, uri):
+ assert(uri == "com.nokia.TimeExample")
+ qmlRegisterType(TimeModel, uri, 1, 0, "Time")
+//![plugin]
+
+//![export]
+# This isn't supported by PySide yet.
+# Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin);
+//![export]
diff --git a/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugins.qml b/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugins.qml
new file mode 100644
index 000000000..094b81f2e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugins.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+import com.nokia.TimeExample 1.0 // import types from the plugin
+
+Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml)
+
+ Time { // this class is defined in C++ (plugin.cpp)
+ id: time
+ }
+
+ hours: time.hour
+ minutes: time.minute
+}
+//![0]
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.cpp
new file mode 100644
index 000000000..897410ed7
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.cpp
@@ -0,0 +1,259 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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] //! [1]
+def __init__(self, parent):
+ QWizard.__init__(self, parent):
+ self.addPage(IntroPage())
+ self.addPage(ClassInfoPage())
+ self.addPage(CodeStylePage())
+ self.addPage(OutputFilesPage())
+ self.addPage(ConclusionPage())
+//! [0]
+
+ self.setPixmap(QWizard.BannerPixmap, QPixmap(":/images/banner.png"))
+ self.setPixmap(QWizard.BackgroundPixmap, QPixmap(":/images/background.png"))
+
+ self.setWindowTitle(self.tr("Class Wizard"))
+//! [2]
+
+//! [1] //! [2]
+
+//! [3]
+def accept(self):
+//! [3] //! [4]
+ className = self.field("className")
+ baseClass = self.field("baseClass")
+ macroName = self.field("macroName")
+ baseInclude = self.field("baseInclude")
+
+ outputDir = self.field("outputDir")
+ header = self.field("header")
+ implementation = self.field("implementation")
+//! [4]
+
+...
+
+//! [5]
+ QDialog.accept(self)
+//! [5] //! [6]
+}
+//! [6]
+
+//! [7]
+class IntroPage (QWizardPage):
+
+ def __init__(self, parent):
+ QWizardPage.__init__(self, parent)
+
+ self.setTitle(tr("Introduction"))
+ self.setPixmap(QWizard.WatermarkPixmap, QPixmap(":/images/watermark1.png"))
+
+ label = QLabel(self.tr("This wizard will generate a skeleton C++ class " \
+ "definition, including a few functions. You simply " \
+ "need to specify the class name and set a few " \
+ "options to produce a header file and an " \
+ "implementation file for your new C++ class."))
+ label.setWordWrap(True)
+
+ layout = QVBoxLayout()
+ layout.addWidget(label)
+ self.setLayout(layout)
+}
+//! [7]
+
+//! [8] //! [9]
+class ClassInfoPage(QWizardPage):
+
+ def __init__(self, parent):
+ QWizardPage.__init__(self, parent)
+//! [8]
+ self.setTitle(self.tr("Class Information"))
+ self.setSubTitle(self.tr("Specify basic information about the class for which you " \
+ "want to generate skeleton source code files."))
+ self.setPixmap(QWizard.LogoPixmap, QPixmap(":/images/logo1.png"))
+
+//! [10]
+ classNameLabel = QLabel(self.tr("&Class name:"))
+ classNameLineEdit = QLineEdit()
+ classNameLabel.setBuddy(classNameLineEdit)
+
+ baseClassLabel = QLabel(self.tr("B&ase class:"))
+ baseClassLineEdit = QLineEdit()
+ baseClassLabel.setBuddy(baseClassLineEdit)
+
+ qobjectMacroCheckBox = QCheckBox(self.tr("Generate Q_OBJECT &macro"))
+
+//! [10]
+ groupBox = QGroupBox(self.tr("C&onstructor"))
+//! [9]
+
+ qobjectCtorRadioButton = QRadioButton(self.tr("&QObject-style constructor"))
+ qwidgetCtorRadioButton = QRadioButton(self.tr("Q&Widget-style constructor"))
+ defaultCtorRadioButton = QRadioButton(self.tr("&Default constructor"))
+ copyCtorCheckBox = QCheckBox(self.tr("&Generate copy constructor and operator="))
+
+ defaultCtorRadioButton.setChecked(True)
+
+ self.connect(defaultCtorRadioButton, SIGNAL("toggled(bool)"),
+ copyCtorCheckBox, SLOT("setEnabled(bool)"))
+
+//! [11] //! [12]
+ registerField("className*", classNameLineEdit)
+ registerField("baseClass", baseClassLineEdit)
+ registerField("qobjectMacro", qobjectMacroCheckBox)
+//! [11]
+ registerField("qobjectCtor", qobjectCtorRadioButton)
+ registerField("qwidgetCtor", qwidgetCtorRadioButton)
+ registerField("defaultCtor", defaultCtorRadioButton)
+ registerField("copyCtor", copyCtorCheckBox)
+
+ groupBoxLayout = QVBoxLayout()
+//! [12]
+ groupBoxLayout.addWidget(qobjectCtorRadioButton)
+ groupBoxLayout.addWidget(qwidgetCtorRadioButton)
+ groupBoxLayout.addWidget(defaultCtorRadioButton)
+ groupBoxLayout.addWidget(copyCtorCheckBox)
+ groupBox.setLayout(groupBoxLayout)
+
+ layout = QGridLayout()
+ layout.addWidget(classNameLabel, 0, 0)
+ layout.addWidget(classNameLineEdit, 0, 1)
+ layout.addWidget(baseClassLabel, 1, 0)
+ layout.addWidget(baseClassLineEdit, 1, 1)
+ layout.addWidget(qobjectMacroCheckBox, 2, 0, 1, 2)
+ layout.addWidget(groupBox, 3, 0, 1, 2)
+ self.setLayout(layout)
+//! [13]
+
+//! [13]
+
+//! [14]
+class CodeStylePage(QWizardPage):
+
+ def __init__(self, parent):
+ QWizardPage.__init__(self, parent)
+ self.setTitle(tr("Code Style Options"))
+ self.setSubTitle(tr("Choose the formatting of the generated code."))
+ self.setPixmap(QWizard.LogoPixmap, QPixmap(":/images/logo2.png"))
+
+ commentCheckBox = QCheckBox(self.tr("&Start generated files with a comment"))
+//! [14]
+ commentCheckBox.setChecked(True)
+
+ protectCheckBox = QCheckBox(self.tr("&Protect header file against multiple " \
+ "inclusions"))
+ protectCheckBox.setChecked(True)
+
+ macroNameLabel = QLabel(self.tr("&Macro name:"))
+ macroNameLineEdit = QLineEdit()
+ macroNameLabel.setBuddy(macroNameLineEdit)
+
+ includeBaseCheckBox = QCheckBox(self.tr("&Include base class definition"))
+ baseIncludeLabel = QLabel(self.tr("Base class include:"))
+ baseIncludeLineEdit = QLineEdit()
+ baseIncludeLabel.setBuddy(baseIncludeLineEdit)
+
+ self.connect(protectCheckBox, SIGNAL("toggled(bool)"),
+ macroNameLabel, SLOT("setEnabled(bool)"))
+ self.connect(protectCheckBox, SIGNAL("toggled(bool)"),
+ macroNameLineEdit, SLOT("setEnabled(bool)"))
+ self.connect(includeBaseCheckBox, SIGNAL("toggled(bool)"),
+ baseIncludeLabel, SLOT("setEnabled(bool)"))
+ self.connect(includeBaseCheckBox, SIGNAL(toggled(bool)),
+ baseIncludeLineEdit, SLOT("setEnabled(bool)"))
+
+ self.registerField("comment", commentCheckBox)
+ self.registerField("protect", protectCheckBox)
+ self.registerField("macroName", macroNameLineEdit)
+ self.registerField("includeBase", includeBaseCheckBox)
+ self.registerField("baseInclude", baseIncludeLineEdit)
+
+ layout = QGridLayout()
+ layout.setColumnMinimumWidth(0, 20)
+ layout.addWidget(commentCheckBox, 0, 0, 1, 3)
+ layout.addWidget(protectCheckBox, 1, 0, 1, 3)
+ layout.addWidget(macroNameLabel, 2, 1)
+ layout.addWidget(macroNameLineEdit, 2, 2)
+ layout.addWidget(includeBaseCheckBox, 3, 0, 1, 3)
+ layout.addWidget(baseIncludeLabel, 4, 1)
+ layout.addWidget(baseIncludeLineEdit, 4, 2)
+//! [15]
+ self.setLayout(layout)
+}
+//! [15]
+
+//! [16]
+ def initializePage(self):
+ className = self.field("className")
+ self.macroNameLineEdit.setText(className.upper() + "_H")
+
+ baseClass = self.field("baseClass")
+
+ self.includeBaseCheckBox.setChecked(len(baseClass))
+ self.includeBaseCheckBox.setEnabled(len(baseClass))
+ self.baseIncludeLabel.setEnabled(len(baseClass))
+ self.baseIncludeLineEdit.setEnabled(len(baseClass))
+
+ if not baseClass:
+ self.baseIncludeLineEdit.clear()
+ elsif QRegExp("Q[A-Z].*").exactMatch(baseClass):
+ baseIncludeLineEdit.setText("<" + baseClass + ">")
+ else:
+ baseIncludeLineEdit.setText("\"" + baseClass.lower() + ".h\"")
+//! [16]
+
+//! [17]
+ def initializePage(self):
+ className = field("className")
+ self.headerLineEdit.setText(className.lower() + ".h")
+ self.implementationLineEdit.setText(className.lower() + ".cpp")
+ self.outputDirLineEdit.setText(QDir.convertSeparators(QDir.tempPath()))
+//! [17]
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.qrc b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.qrc
new file mode 100644
index 000000000..41a5ddc7d
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.qrc
@@ -0,0 +1,11 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/background.png</file>
+ <file>images/banner.png</file>
+ <file>images/logo1.png</file>
+ <file>images/logo2.png</file>
+ <file>images/logo3.png</file>
+ <file>images/watermark1.png</file>
+ <file>images/watermark2.png</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/background.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/background.png
new file mode 100644
index 000000000..44c7badb8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/background.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/banner.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/banner.png
new file mode 100644
index 000000000..3169152b8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/banner.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo1.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo1.png
new file mode 100644
index 000000000..f9b594aaf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo1.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo2.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo2.png
new file mode 100644
index 000000000..5dcbd4669
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo2.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo3.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo3.png
new file mode 100644
index 000000000..9fd3ea235
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo3.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark1.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark1.png
new file mode 100644
index 000000000..0091f5c17
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark1.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark2.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark2.png
new file mode 100644
index 000000000..3b88f2e36
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark2.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/main.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/main.cpp
new file mode 100644
index 000000000..9e9566d37
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QTranslator>
+#include <QLocale>
+#include <QLibraryInfo>
+
+#include "classwizard.h"
+
+int main(int argc, char *argv[])
+{
+ Q_INIT_RESOURCE(classwizard);
+
+ QApplication app(argc, argv);
+
+ QString translatorFileName = QLatin1String("qt_");
+ translatorFileName += QLocale::system().name();
+ QTranslator *translator = new QTranslator(&app);
+ if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+ app.installTranslator(translator);
+
+ ClassWizard wizard;
+ wizard.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/extension/finddialog.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/extension/finddialog.cpp
new file mode 100644
index 000000000..de99bb3ec
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/extension/finddialog.cpp
@@ -0,0 +1,119 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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.QtGui import *
+
+//! [0]
+def __init__(self, parent):
+ QDialog.__init__(self, parent)
+ label = QLabel(self.tr("Find &what:"))
+ lineEdit = QLineEdit()
+ label.setBuddy(lineEdit)
+
+ caseCheckBox = QCheckBox(self.tr("Match &case"))
+ fromStartCheckBox = QCheckBox(self.tr("Search from &start"))
+ fromStartCheckBox.setChecked(True)
+
+//! [1]
+ findButton = QPushButton(self.tr("&Find"))
+ findButton.setDefault(True)
+
+ moreButton = QPushButton(self.tr("&More"))
+ moreButton.setCheckable(True)
+//! [0]
+ moreButton.setAutoDefault(False)
+
+ buttonBox = QDialogButtonBox(Qt.Vertical)
+ buttonBox.addButton(findButton, QDialogButtonBox.ActionRole)
+ buttonBox.addButton(moreButton, QDialogButtonBox.ActionRole)
+//! [1]
+
+//! [2]
+ extension = QWidget()
+
+ wholeWordsCheckBox = QCheckBox(self.tr("&Whole words"))
+ backwardCheckBox = QCheckBox(self.tr("Search &backward"))
+ searchSelectionCheckBox = QCheckBox(self.tr("Search se&lection"))
+//! [2]
+
+//! [3]
+ connect(moreButton, SIGNAL("toggled(bool)"), extension, SLOT("setVisible(bool)"))
+
+ extensionLayout = QVBoxLayout()
+ extensionLayout.setMargin(0)
+ extensionLayout.addWidget(wholeWordsCheckBox)
+ extensionLayout.addWidget(backwardCheckBox)
+ extensionLayout.addWidget(searchSelectionCheckBox)
+ extension.setLayout(extensionLayout)
+//! [3]
+
+//! [4]
+ topLeftLayout = QHBoxLayout()
+ topLeftLayout.addWidget(label)
+ topLeftLayout.addWidget(lineEdit)
+
+ leftLayout = QVBoxLayout()
+ leftLayout.addLayout(topLeftLayout)
+ leftLayout.addWidget(caseCheckBox)
+ leftLayout.addWidget(fromStartCheckBox)
+ leftLayout.addSself.tretch(1)
+
+ mainLayout = QGridLayout()
+ mainLayout.setSizeConsself.traint(QLayout.SetFixedSize)
+ mainLayout.addLayout(leftLayout, 0, 0)
+ mainLayout.addWidget(buttonBox, 0, 1)
+ mainLayout.addWidget(extension, 1, 0, 1, 2)
+ setLayout(mainLayout)
+
+ setWindowTitle(self.tr("Extension"))
+//! [4] //! [5]
+ extension.hide()
+//! [5]
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/logo.png b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/logo.png
new file mode 100644
index 000000000..56f17a3e5
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/logo.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/watermark.png b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/watermark.png
new file mode 100644
index 000000000..124a05068
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/watermark.png
Binary files differ
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp
new file mode 100644
index 000000000..453dac773
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp
@@ -0,0 +1,358 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "licensewizard.h"
+
+//! [0] //! [1] //! [2]
+# class LicenseWizard
+def __init__(self, parent)
+ QWizard(self, parent)
+//! [0]
+ self.setPage(self.Page_Intro, IntroPage())
+ self.setPage(self.Page_Evaluate, EvaluatePage())
+ self.setPage(self.Page_Register, RegisterPage())
+ self.setPage(self.Page_Details, DetailsPage())
+ self.setPage(self.Page_Conclusion, ConclusionPage())
+//! [1]
+
+ self.setStartId(self.Page_Intro);
+//! [2]
+
+//! [3]
+
+//! [3] //! [4]
+ self.setWizardStyle(QWizard.ModernStyle);
+
+//! [4] //! [5]
+ self.setOption(HaveHelpButton, True);
+//! [5] //! [6]
+ self.setPixmap(QWizard.LogoPixmap, QPixmap(":/images/logo.png"));
+
+//! [7]
+ connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp()));
+//! [7]
+
+ setWindowTitle(tr("License Wizard"));
+//! [8]
+}
+//! [6] //! [8]
+
+//! [9] //! [10]
+void LicenseWizard::showHelp()
+//! [9] //! [11]
+{
+ static QString lastHelpMessage;
+
+ message = ""
+
+ switch (currentId()) {
+ case Page_Intro:
+ message = tr("The decision you make here will affect which page you "
+ "get to see next.");
+ break;
+//! [10] //! [11]
+ case Page_Evaluate:
+ message = tr("Make sure to provide a valid email address, such as "
+ "toni.buddenbrook@example.de.");
+ break;
+ case Page_Register:
+ message = tr("If you don't provide an upgrade key, you will be "
+ "asked to fill in your details.");
+ break;
+ case Page_Details:
+ message = tr("Make sure to provide a valid email address, such as "
+ "thomas.gradgrind@example.co.uk.");
+ break;
+ case Page_Conclusion:
+ message = tr("You must accept the terms and conditions of the "
+ "license to proceed.");
+ break;
+//! [12] //! [13]
+ default:
+ message = tr("This help is likely not to be of any help.");
+ }
+//! [12]
+
+ if (lastHelpMessage == message)
+ message = tr("Sorry, I already gave what help I could. "
+ "Maybe you should try asking a human?");
+
+//! [14]
+ QMessageBox::information(this, tr("License Wizard Help"), message);
+//! [14]
+
+ lastHelpMessage = message;
+//! [15]
+}
+//! [13] //! [15]
+
+//! [16]
+IntroPage::IntroPage(QWidget *parent)
+ : QWizardPage(parent)
+{
+ setTitle(tr("Introduction"));
+ setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png"));
+
+ topLabel = new QLabel(tr("This wizard will help you register your copy of "
+ "<i>Super Product One</i>&trade; or start "
+ "evaluating the product."));
+ topLabel->setWordWrap(true);
+
+ registerRadioButton = new QRadioButton(tr("&Register your copy"));
+ evaluateRadioButton = new QRadioButton(tr("&Evaluate the product for 30 "
+ "days"));
+ registerRadioButton->setChecked(true);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(topLabel);
+ layout->addWidget(registerRadioButton);
+ layout->addWidget(evaluateRadioButton);
+ setLayout(layout);
+}
+//! [16] //! [17]
+
+//! [18]
+# class IntroPage
+def nextId(self):
+//! [17] //! [19]
+ if evaluateRadioButton.isChecked():
+ return LicenseWizard.Page_Evaluate
+ else:
+ return LicenseWizard.Page_Register
+//! [18] //! [19]
+
+//! [20]
+EvaluatePage::EvaluatePage(QWidget *parent)
+ : QWizardPage(parent)
+{
+ setTitle(tr("Evaluate <i>Super Product One</i>&trade;"));
+ setSubTitle(tr("Please fill both fields. Make sure to provide a valid "
+ "email address (e.g., john.smith@example.com)."));
+
+ nameLabel = new QLabel(tr("N&ame:"));
+ nameLineEdit = new QLineEdit;
+//! [20]
+ nameLabel->setBuddy(nameLineEdit);
+
+ emailLabel = new QLabel(tr("&Email address:"));
+ emailLineEdit = new QLineEdit;
+ emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this));
+ emailLabel->setBuddy(emailLineEdit);
+
+//! [21]
+ registerField("evaluate.name*", nameLineEdit);
+ registerField("evaluate.email*", emailLineEdit);
+//! [21]
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(nameLabel, 0, 0);
+ layout->addWidget(nameLineEdit, 0, 1);
+ layout->addWidget(emailLabel, 1, 0);
+ layout->addWidget(emailLineEdit, 1, 1);
+ setLayout(layout);
+//! [22]
+}
+//! [22]
+
+//! [23]
+# class EvaluatePage
+def nextId(self):
+ return LicenseWizard.Page_Conclusion
+//! [23]
+
+RegisterPage::RegisterPage(QWidget *parent)
+ : QWizardPage(parent)
+{
+ setTitle(tr("Register Your Copy of <i>Super Product One</i>&trade;"));
+ setSubTitle(tr("If you have an upgrade key, please fill in "
+ "the appropriate field."));
+
+ nameLabel = new QLabel(tr("N&ame:"));
+ nameLineEdit = new QLineEdit;
+ nameLabel->setBuddy(nameLineEdit);
+
+ upgradeKeyLabel = new QLabel(tr("&Upgrade key:"));
+ upgradeKeyLineEdit = new QLineEdit;
+ upgradeKeyLabel->setBuddy(upgradeKeyLineEdit);
+
+ registerField("register.name*", nameLineEdit);
+ registerField("register.upgradeKey", upgradeKeyLineEdit);
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(nameLabel, 0, 0);
+ layout->addWidget(nameLineEdit, 0, 1);
+ layout->addWidget(upgradeKeyLabel, 1, 0);
+ layout->addWidget(upgradeKeyLineEdit, 1, 1);
+ setLayout(layout);
+}
+
+//! [24]
+# class RegisterPage
+def nextId(self):
+ if self.upgradeKeyLineEdit.text().isEmpty():
+ return LicenseWizard::Page_Details
+ else:
+ return LicenseWizard::Page_Conclusion
+//! [24]
+
+DetailsPage::DetailsPage(QWidget *parent)
+ : QWizardPage(parent)
+{
+ setTitle(tr("Fill In Your Details"));
+ setSubTitle(tr("Please fill all three fields. Make sure to provide a valid "
+ "email address (e.g., tanaka.aya@example.co.jp)."));
+
+ companyLabel = new QLabel(tr("&Company name:"));
+ companyLineEdit = new QLineEdit;
+ companyLabel->setBuddy(companyLineEdit);
+
+ emailLabel = new QLabel(tr("&Email address:"));
+ emailLineEdit = new QLineEdit;
+ emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this));
+ emailLabel->setBuddy(emailLineEdit);
+
+ postalLabel = new QLabel(tr("&Postal address:"));
+ postalLineEdit = new QLineEdit;
+ postalLabel->setBuddy(postalLineEdit);
+
+ registerField("details.company*", companyLineEdit);
+ registerField("details.email*", emailLineEdit);
+ registerField("details.postal*", postalLineEdit);
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(companyLabel, 0, 0);
+ layout->addWidget(companyLineEdit, 0, 1);
+ layout->addWidget(emailLabel, 1, 0);
+ layout->addWidget(emailLineEdit, 1, 1);
+ layout->addWidget(postalLabel, 2, 0);
+ layout->addWidget(postalLineEdit, 2, 1);
+ setLayout(layout);
+}
+
+//! [25]
+# class DetailsPage
+def nextId(self):
+ return LicenseWizard.Page_Conclusion
+//! [25]
+
+ConclusionPage::ConclusionPage(QWidget *parent)
+ : QWizardPage(parent)
+{
+ setTitle(tr("Complete Your Registration"));
+ setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png"));
+
+ bottomLabel = new QLabel;
+ bottomLabel->setWordWrap(true);
+
+ agreeCheckBox = new QCheckBox(tr("I agree to the terms of the license"));
+
+ registerField("conclusion.agree*", agreeCheckBox);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(bottomLabel);
+ layout->addWidget(agreeCheckBox);
+ setLayout(layout);
+}
+
+//! [26]
+#class ConclusionPage
+def nextId(self):
+ return -1
+//! [26]
+
+//! [27]
+# class ConclusionPage
+def initializePage(self):
+ if wizard().hasVisitedPage(LicenseWizard::Page_Evaluate):
+ licenseText = self.tr("<u>Evaluation License Agreement:</u> " \
+ "You can use this software for 30 days and make one " \
+ "backup, but you are not allowed to distribute it.")
+ elsif wizard().hasVisitedPage(LicenseWizard.Page_Details):
+ licenseText = self.tr("<u>First-Time License Agreement:</u> " \
+ "You can use this software subject to the license " \
+ "you will receive by email.")
+ else:
+ licenseText = self.tr("<u>Upgrade License Agreement:</u> " \
+ "This software is licensed under the terms of your " \
+ "current license.")
+ }
+ bottomLabel.setText(licenseText)
+//! [27]
+
+//! [28]
+void ConclusionPage::setVisible(bool visible)
+{
+ QWizardPage::setVisible(visible);
+
+ if (visible) {
+//! [29]
+ self.wizard().setButtonText(QWizard.CustomButton1, self.tr("&Print"))
+ self.wizard().setOption(QWizard.HaveCustomButton1, True)
+ self.connect(wizard(), SIGNAL("customButtonClicked(int)"), self, SLOT("printButtonClicked()"))
+//! [29]
+ } else {
+ wizard()->setOption(QWizard::HaveCustomButton1, false);
+ disconnect(wizard(), SIGNAL(customButtonClicked(int)),
+ this, SLOT(printButtonClicked()));
+ }
+}
+//! [28]
+
+void ConclusionPage::printButtonClicked()
+{
+ QPrinter printer;
+ QPrintDialog dialog(&printer, this);
+ if (dialog.exec())
+ QMessageBox::warning(this, tr("Print License"),
+ tr("As an environmentally friendly measure, the "
+ "license text will not actually be printed."));
+}
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.h b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.h
new file mode 100644
index 000000000..f0be5fa60
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.h
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef LICENSEWIZARD_H
+#define LICENSEWIZARD_H
+
+#include <QWizard>
+
+QT_BEGIN_NAMESPACE
+class QCheckBox;
+class QLabel;
+class QLineEdit;
+class QRadioButton;
+QT_END_NAMESPACE
+
+//! [0] //! [1]
+class LicenseWizard (QWizard):
+//! [0]
+//! [2]
+ Page_Intro = 1
+ Page_Evaluate = 2
+ Page_Register = 3
+ Page_Details = 4
+ Page_Conclusion = 5
+//! [2]
+
+ def __init__(self, parent):
+ ...
+
+ def showHelp(self):
+ ...
+//! [3]
+
+//! [1] //! [3]
+
+//! [4]
+class IntroPage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ IntroPage(QWidget *parent = 0);
+
+ int nextId() const;
+
+private:
+ QLabel *topLabel;
+ QRadioButton *registerRadioButton;
+ QRadioButton *evaluateRadioButton;
+};
+//! [4]
+
+//! [5]
+class EvaluatePage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ EvaluatePage(QWidget *parent = 0);
+
+ int nextId() const;
+
+private:
+ QLabel *nameLabel;
+ QLabel *emailLabel;
+ QLineEdit *nameLineEdit;
+ QLineEdit *emailLineEdit;
+};
+//! [5]
+
+class RegisterPage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ RegisterPage(QWidget *parent = 0);
+
+ int nextId() const;
+
+private:
+ QLabel *nameLabel;
+ QLabel *upgradeKeyLabel;
+ QLineEdit *nameLineEdit;
+ QLineEdit *upgradeKeyLineEdit;
+};
+
+class DetailsPage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ DetailsPage(QWidget *parent = 0);
+
+ int nextId() const;
+
+private:
+ QLabel *companyLabel;
+ QLabel *emailLabel;
+ QLabel *postalLabel;
+ QLineEdit *companyLineEdit;
+ QLineEdit *emailLineEdit;
+ QLineEdit *postalLineEdit;
+};
+
+//! [6]
+class ConclusionPage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ ConclusionPage(QWidget *parent = 0);
+
+ void initializePage();
+ int nextId() const;
+ void setVisible(bool visible);
+
+private slots:
+ void printButtonClicked();
+
+private:
+ QLabel *bottomLabel;
+ QCheckBox *agreeCheckBox;
+};
+//! [6]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.qrc b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.qrc
new file mode 100644
index 000000000..b06993851
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/logo.png</file>
+ <file>images/watermark.png</file>
+</qresource>
+</RCC>
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/main.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/main.cpp
new file mode 100644
index 000000000..e372e9c17
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QTranslator>
+#include <QLocale>
+#include <QLibraryInfo>
+
+#include "licensewizard.h"
+
+int main(int argc, char *argv[])
+{
+ Q_INIT_RESOURCE(licensewizard);
+
+ QApplication app(argc, argv);
+
+ QString translatorFileName = QLatin1String("qt_");
+ translatorFileName += QLocale::system().name();
+ QTranslator *translator = new QTranslator(&app);
+ if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+ app.installTranslator(translator);
+
+ LicenseWizard wizard;
+ wizard.show();
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp
new file mode 100644
index 000000000..ed305196a
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+ i = QInputDialog().getInteger(self, self.tr("QInputDialog().getInteger()"),
+ self.tr("Percentage:"), 25, 0, 100, 1, ok)
+ if ok:
+ self.integerLabel.setText(self.tr("%1%").arg(i))
+//! [0]
+
+//! [1]
+ d = QInputDialog().getDouble(self, self.tr("QInputDialog().getDouble()"),
+ self.tr("Amount:"), 37.56, -10000, 10000, 2, ok)
+ if ok:
+ doubleLabel.setText(QString("$%1").arg(d))
+//! [1]
+
+//! [2]
+ items = [self.tr("Spring"), self.tr("Summer"), self.tr("Fall"), self.tr("Winter")]
+
+ item = QInputDialog().getItem(self, self.tr("QInputDialog().getItem()"),
+ selftr("Season:"), items, 0, False, ok)
+ if ok and not item.isEmpty():
+ itemLabel.setText(item)
+//! [2]
+
+//! [3]
+ text = QInputDialog::getText(self, self.tr("QInputDialog().getText()"),
+ self.tr("User name:"), QLineEdit.Normal,
+ QDir().home().dirName(), ok)
+ if ok and text:
+ textLabel.setText(text)
+//! [3]
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/tabdialog/tabdialog.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/tabdialog/tabdialog.cpp
new file mode 100644
index 000000000..2244c2275
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/tabdialog/tabdialog.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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 TabDialog (QDialog):
+ def __init__(self, fileName, parent = None):
+ QDialog.__init__(self, parent)
+ fileInfo = QFileInfo(fileName)
+
+ self.tabWidget = QTabWidget()
+ self.tabWidget.addTab(GeneralTab(fileInfo), "General")
+ self.tabWidget.addTab(PermissionsTab(fileInfo), "Permissions")
+ self.tabWidget.addTab(ApplicationsTab(fileInfo), "Applications")
+//! [0]
+
+//! [1] //! [2]
+ self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
+//! [1] //! [3]
+ | QDialogButtonBox.Cancel)
+
+ self.buttonBox.accepted.connect(self.accept)
+ self.buttonBox.rejected.connect(self.reject)
+//! [2] //! [3]
+
+//! [4]
+ mainLayout = QVBoxLayout()
+ mainLayout.addWidget(tabWidget)
+ mainLayout.addWidget(buttonBox)
+ self.setLayout(mainLayout)
+//! [4]
+
+//! [5]
+ self.setWindowTitle("Tab Dialog")
+//! [5]
+
+//! [6]
+class GeneralTab (QWidget):
+ def __init__(self, fileInfo, parent = None):
+ QWidget.__init__(self, parent)
+ fileNameLabel = QLabel("File Name:")
+ fileNameEdit = QLineEdit(fileInfo.fileName())
+
+ pathLabel = QLabel("Path:")
+ pathValueLabel = QLabel(fileInfo.absoluteFilePath())
+ pathValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)
+
+ sizeLabel = QLabel("Size:")
+ size = fileInfo.size()/1024
+ sizeValueLabel = QLabel("%d K" % size)
+ sizeValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)
+
+ lastReadLabel = QLabel("Last Read:")
+ lastReadValueLabel = QLabel(fileInfo.lastRead().toString())
+ lastReadValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)
+
+ lastModLabel = QLabel("Last Modified:")
+ lastModValueLabel = QLabel(fileInfo.lastModified().toString())
+ lastModValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)
+
+ mainLayout = QVBoxLayout()
+ mainLayout.addWidget(fileNameLabel)
+ mainLayout.addWidget(fileNameEdit)
+ mainLayout.addWidget(pathLabel)
+ mainLayout.addWidget(pathValueLabel)
+ mainLayout.addWidget(sizeLabel)
+ mainLayout.addWidget(sizeValueLabel)
+ mainLayout.addWidget(lastReadLabel)
+ mainLayout.addWidget(lastReadValueLabel)
+ mainLayout.addWidget(lastModLabel)
+ mainLayout.addWidget(lastModValueLabel)
+ mainLayout.addStretch(1)
+ self.setLayout(mainLayout)
+//! [6]
+
+//! [7]
+class PermissionsTab (QWidget):
+ def __init__(self, fileInfo, parent = None):
+ QWidget.__init__(self, parent)
+ permissionsGroup = QGroupBox("Permissions")
+
+ readable = QCheckBox("Readable")
+ if fileInfo.isReadable():
+ readable.setChecked(True)
+
+ writable = QCheckBox("Writable")
+ if fileInfo.isWritable():
+ writable.setChecked(True)
+
+ executable = QCheckBox("Executable")
+ if fileInfo.isExecutable():
+ executable.setChecked(True)
+
+ ownerGroup = QGroupBox("Ownership")
+
+ ownerLabel = QLabel("Owner")
+ ownerValueLabel = QLabel(fileInfo.owner())
+ ownerValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)
+
+ groupLabel = QLabel("Group")
+ groupValueLabel = QLabel(fileInfo.group())
+ groupValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)
+
+ permissionsLayout = QVBoxLayout()
+ permissionsLayout.addWidget(readable)
+ permissionsLayout.addWidget(writable)
+ permissionsLayout.addWidget(executable)
+ permissionsGroup.setLayout(permissionsLayout)
+
+ ownerLayout = QVBoxLayout()
+ ownerLayout.addWidget(ownerLabel)
+ ownerLayout.addWidget(ownerValueLabel)
+ ownerLayout.addWidget(groupLabel)
+ ownerLayout.addWidget(groupValueLabel)
+ ownerGroup.setLayout(ownerLayout)
+
+ mainLayout = QVBoxLayout()
+ mainLayout.addWidget(permissionsGroup)
+ mainLayout.addWidget(ownerGroup)
+ mainLayout.addStretch(1)
+ self.setLayout(mainLayout)
+//! [7]
+
+//! [8]
+class ApplicationsTab (QWidget):
+ def __init__(self, fileInfo, parent = None):
+ QWidget.__init__(self, parent)
+ topLabel = QLabel("Open with:")
+
+ applicationsListBox = QListWidget()
+ applications = []
+
+ for i in range(30):
+ applications.append("Application %d" %s i)
+ applicationsListBox.insertItems(0, applications)
+
+ if fileInfo.suffix().isEmpty():
+ alwaysCheckBox = QCheckBox("Always use this application to open this type of file")
+ else:
+ alwaysCheckBox = QCheckBox("Always use this application to open files with the extension '%s'" % fileInfo.suffix())
+
+ layout = QVBoxLayout()
+ layout.addWidget(topLabel)
+ layout.addWidget(applicationsListBox)
+ layout.addWidget(alwaysCheckBox)
+ self.setLayout(layout)
+//! [8]
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp
new file mode 100644
index 000000000..6a06c1725
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QTranslator>
+#include <QLocale>
+#include <QLibraryInfo>
+
+//! [0] //! [1]
+def createIntroPage(self):
+ page = QWizardPage()
+ page.setTitle("Introduction")
+
+ label = QLabel("This wizard will help you register your copy of Super Product Two.")
+ label.setWordWrap(True)
+
+ layout = QVBoxLayout()
+ layout.addWidget(label)
+ page.setLayout(layout)
+
+ return page
+//! [0]
+
+//! [2]
+QWizardPage *createRegistrationPage()
+//! [1] //! [3]
+
+//! [3]
+ QWizardPage *page = new QWizardPage;
+ page->setTitle("Registration");
+ page->setSubTitle("Please fill both fields.");
+
+ QLabel *nameLabel = new QLabel("Name:");
+ QLineEdit *nameLineEdit = new QLineEdit;
+
+ QLabel *emailLabel = new QLabel("Email address:");
+ QLineEdit *emailLineEdit = new QLineEdit;
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(nameLabel, 0, 0);
+ layout->addWidget(nameLineEdit, 0, 1);
+ layout->addWidget(emailLabel, 1, 0);
+ layout->addWidget(emailLineEdit, 1, 1);
+ page->setLayout(layout);
+
+ return page;
+//! [4]
+
+//! [2] //! [4]
+
+//! [5] //! [6]
+def createConclusionPage(self):
+//! [5] //! [7]
+
+//! [7]
+ QWizardPage *page = new QWizardPage;
+ page->setTitle("Conclusion");
+
+ QLabel *label = new QLabel("You are now successfully registered. Have a "
+ "nice day!");
+ label->setWordWrap(true);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(label);
+ page->setLayout(layout);
+
+ return page;
+//! [8]
+
+//! [6] //! [8]
+
+//! [9] //! [10]
+
+//! [9] //! [11]
+def main():
+ app = QApplication(sys.argv)
+
+ translatorFileName = "qt_"
+ translatorFileName += QLocale.system().name()
+ translator = QTranslator(app)
+ if translator.load(translatorFileName, QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
+ app.installTranslator(translator)
+
+ wizard = QWizard()
+ wizard.addPage(createIntroPage())
+ wizard.addPage(createRegistrationPage())
+ wizard.addPage(createConclusionPage())
+
+ wizard.setWindowTitle("Trivial Wizard")
+ wizard.show()
+
+ return app.exec_()
+
+if __name__ == "__main__":
+ main()
+//! [10] //! [11]
diff --git a/sources/pyside2/doc/codesnippets/examples/graphicsview/simpleanchorlayout/main.cpp b/sources/pyside2/doc/codesnippets/examples/graphicsview/simpleanchorlayout/main.cpp
new file mode 100644
index 000000000..73e1a40b3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/graphicsview/simpleanchorlayout/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+//! [adding a corner anchor in two steps]
+layout.addAnchor(a, Qt.AnchorTop, layout, Qt.AnchorTop)
+layout.addAnchor(a, Qt.AnchorLeft, layout, Qt.AnchorLeft)
+//! [adding a corner anchor in two steps]
+
+//! [adding a corner anchor]
+layout.addCornerAnchors(a, Qt.TopLeftCorner, layout, Qt.TopLeftCorner)
+//! [adding a corner anchor]
+
+//! [adding anchors]
+layout.addAnchor(b, Qt.AnchorLeft, a, Qt.AnchorRight)
+layout.addAnchor(b, Qt.AnchorTop, a, Qt.AnchorBottom)
+//! [adding anchors]
+
+//! [adding anchors to match sizes in two steps]
+layout.addAnchor(b, Qt.AnchorLeft, c, Qt.AnchorLeft)
+layout.addAnchor(b, Qt.AnchorRight, c, Qt.AnchorRight)
+//! [adding anchors to match sizes in two steps]
+
+//! [adding anchors to match sizes]
+layout.addAnchors(b, c, Qt.Horizontal)
+//! [adding anchors to match sizes]
diff --git a/sources/pyside2/doc/codesnippets/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp b/sources/pyside2/doc/codesnippets/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
new file mode 100644
index 000000000..0ec3b071f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
@@ -0,0 +1,109 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+def __init__(self, parent):
+ QSortFilterProxyModel.__init__(self, parent)
+//! [0]
+
+//! [1]
+def setFilterMinimumDate(self, date):
+ self.minDate = date
+ self.invalidateFilter()
+
+//! [1]
+
+//! [2]
+def setFilterMaximumDate(self, date):
+ self.maxDate = date
+ self.invalidateFilter()
+
+//! [2]
+
+//! [3]
+def filterAcceptsRow(self, sourceRow, sourceParent):
+ index0 = sourceModel().index(sourceRow, 0, sourceParent)
+ index1 = sourceModel().index(sourceRow, 1, sourceParent)
+ index2 = sourceModel().index(sourceRow, 2, sourceParent)
+
+ regex = filterRegExp()
+ return (regex.indexIn(sourceModel().data(index0)) != -1
+ or regex.indexIn(sourceModel().data(index1)) != -1
+ and dateInRange(sourceModel().data(index2))
+//! [3]
+
+//! [4] //! [5]
+def lessThan(self, left, right):
+ leftData = sourceModel().data(left)
+ rightData = sourceModel().data(right)
+//! [4]
+
+//! [6]
+ if isinstance(leftData, QDateTime):
+ return leftData < rightData
+ else:
+ emailPattern = QRegExp("([\\w\\.]*@[\\w\\.]*)")
+
+ if left.column() == 1 && emailPattern.indexIn(leftData) != -1:
+ leftData = emailPattern.cap(1)
+
+ if right.column() == 1 && emailPattern.indexIn(rightData) != -1:
+ rightData = emailPattern.cap(1)
+
+ return leftString < rightString
+
+//! [5] //! [6]
+
+//! [7]
+def dateInRange(self, date):
+ return (!minDate.isValid() || date > minDate)
+ && (!maxDate.isValid() || date < maxDate)
+
+//! [7]
diff --git a/sources/pyside2/doc/codesnippets/examples/itemviews/pixelator/pixeldelegate.cpp b/sources/pyside2/doc/codesnippets/examples/itemviews/pixelator/pixeldelegate.cpp
new file mode 100644
index 000000000..77eaf55e6
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/itemviews/pixelator/pixeldelegate.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+def __init__(self, parent):
+ QAbstractItemDelegate.__init__(self, parent)
+ self.pixelSize = 12
+//! [0]
+
+//! [1]
+def paint(self, painter, option, index):
+//! [2]
+ if option.state and QStyle.State_Selected:
+ painter.fillRect(option.rect, option.palette.highlight())
+//! [1]
+
+//! [3]
+ size = qMin(option.rect.width(), option.rect.height())
+//! [3] //! [4]
+ brightness = index.model().data(index, Qt.DisplayRole).toInt()
+ radius = (size/2.0) - (brightness/255.0 * size/2.0)
+ if radius == 0.0:
+ return
+//! [4]
+
+//! [5]
+ painter.save()
+//! [5] //! [6]
+ painter.setRenderHint(QPainter.Antialiasing, true)
+//! [6] //! [7]
+ painter.setPen(Qt.NoPen)
+//! [7] //! [8]
+ if option.state and QStyle.State_Selected:
+//! [8] //! [9]
+ painter.setBrush(option.palette.highlightedText())
+ else
+//! [2]
+ painter.setBrush(QBrush(Qt.black))
+//! [9]
+
+//! [10]
+ painter.drawEllipse(QRectF(option.rect.x() + option.rect.width()/2 - radius,
+ option.rect.y() + option.rect.height()/2 - radius,
+ 2*radius, 2*radius))
+ painter.restore()
+//! [10]
+
+//! [11]
+def sizeHint(self, option, index):
+ return QSize(self.pixelSize, self.pixelSize)
+//! [11]
+
+//! [12]
+def setPixelSize(self, size):
+ self.pixelSize = size
+//! [12]
diff --git a/sources/pyside2/doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp b/sources/pyside2/doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp
new file mode 100644
index 000000000..b9f582640
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QtXml>
+
+#include "domitem.h"
+#include "dommodel.h"
+
+//! [0]
+DomModel::DomModel(QDomDocument document, QObject *parent)
+ : QAbstractItemModel(parent), domDocument(document)
+{
+ rootItem = new DomItem(domDocument, 0);
+}
+//! [0]
+
+//! [1]
+DomModel::~DomModel()
+{
+ delete rootItem;
+}
+//! [1]
+
+//! [2]
+def columnCount(self, parent):
+ return 3
+//! [2]
+
+//! [3]
+QVariant DomModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ DomItem *item = static_cast<DomItem*>(index.internalPointer());
+
+ QDomNode node = item->node();
+//! [3] //! [4]
+ QStringList attributes;
+ QDomNamedNodeMap attributeMap = node.attributes();
+
+ switch (index.column()) {
+ case 0:
+ return node.nodeName();
+ case 1:
+ for (int i = 0; i < attributeMap.count(); ++i) {
+ QDomNode attribute = attributeMap.item(i);
+ attributes << attribute.nodeName() + "=\""
+ +attribute.nodeValue() + "\"";
+ }
+ return attributes.join(" ");
+ case 2:
+ return node.nodeValue().split("\n").join(" ");
+ default:
+ return QVariant();
+ }
+}
+//! [4]
+
+//! [5]
+Qt::ItemFlags DomModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return 0;
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+//! [5]
+
+//! [6]
+QVariant DomModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) {
+ case 0:
+ return tr("Name");
+ case 1:
+ return tr("Attributes");
+ case 2:
+ return tr("Value");
+ default:
+ return QVariant();
+ }
+ }
+
+ return QVariant();
+}
+//! [6]
+
+//! [7]
+QModelIndex DomModel::index(int row, int column, const QModelIndex &parent)
+ const
+{
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ DomItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<DomItem*>(parent.internalPointer());
+//! [7]
+
+//! [8]
+ DomItem *childItem = parentItem->child(row);
+ if (childItem)
+ return createIndex(row, column, childItem);
+ else
+ return QModelIndex();
+}
+//! [8]
+
+//! [9]
+QModelIndex DomModel::parent(const QModelIndex &child) const
+{
+ if (!child.isValid())
+ return QModelIndex();
+
+ DomItem *childItem = static_cast<DomItem*>(child.internalPointer());
+ DomItem *parentItem = childItem->parent();
+
+ if (!parentItem || parentItem == rootItem)
+ return QModelIndex();
+
+ return createIndex(parentItem->row(), 0, parentItem);
+}
+//! [9]
+
+//! [10]
+int DomModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.column() > 0)
+ return 0;
+
+ DomItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<DomItem*>(parent.internalPointer());
+
+ return parentItem->node().childNodes().count();
+}
+//! [10]
diff --git a/sources/pyside2/doc/codesnippets/examples/linguist/hellotr/main.cpp b/sources/pyside2/doc/codesnippets/examples/linguist/hellotr/main.cpp
new file mode 100644
index 000000000..7125841ef
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/linguist/hellotr/main.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QPushButton>
+//! [0]
+from PySide2.QtCore import QTranslator
+//! [0]
+
+//! [1] //! [2]
+def main(args):
+//! [1] //! [3] //! [4]
+ app = QApplication(args)
+//! [3]
+
+//! [5]
+ translator = QTranslator()
+//! [5] //! [6]
+ translator.load("hellotr_la")
+//! [6] //! [7]
+ app.installTranslator(translator)
+//! [4] //! [7]
+
+//! [8]
+ hello = QPushButton(QPushButton.tr("Hello world!"))
+//! [8]
+ hello.resize(100, 30)
+
+ hello.show()
+ return app.exec_()
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.cpp
new file mode 100644
index 000000000..82c5f891b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.cpp
@@ -0,0 +1,359 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+from PySide2.QtGui import *
+//! [0]
+
+//! [1]
+def __init__(self):
+ QMainWindow.__init__(self)
+//! [1] //! [2]
+ textEdit = QPlainTextEdit()
+ setCentralWidget(textEdit)
+
+ createActions()
+ createMenus()
+ createToolBars()
+ createStatusBar()
+
+ readSettings()
+
+ connect(textEdit.document(), SIGNAL("contentsChanged()"),
+ self, SLOT("documentWasModified()"))
+
+ setCurrentFile("")
+ setUnifiedTitleAndToolBarOnMac(True)
+
+//! [2]
+
+//! [3]
+def closeEvent(self, event):
+//! [3] //! [4]
+ if maybeSave():
+ writeSettings()
+ event.accept()
+ else:
+ event.ignore()
+//! [4]
+
+//! [5]
+def File(self):
+//! [5] //! [6]
+ if maybeSave():
+ textEdit.clear()
+ setCurrentFile("")
+//! [6]
+
+//! [7]
+def open(self):
+//! [7] //! [8]
+ if maybeSave():
+ fileName = QFileDialog.getOpenFileName(self)
+ if !fileName.isEmpty():
+ loadFile(fileName)
+//! [8]
+
+//! [9]
+def save(self):
+//! [9] //! [10]
+ if curFile.isEmpty():
+ return saveAs()
+ else:
+ return saveFile(curFile)
+//! [10]
+
+//! [11]
+def saveAs(self):
+//! [11] //! [12]
+ fileName = QFileDialog.getSaveFileName(self)
+ if fileName.isEmpty():
+ return False
+
+ return saveFile(fileName)
+//! [12]
+
+//! [13]
+def about(self):
+//! [13] //! [14]
+ QMessageBox.about(self, tr("About Application"),
+ tr("The <b>Application</b> example demonstrates how to "
+ "write modern GUI applications using Qt, with a menu bar, "
+ "toolbars, and a status bar."))
+
+//! [14]
+
+//! [15]
+def documentWasModified(self):
+//! [15] //! [16]
+ setWindowModified(textEdit.document().isModified())
+//! [16]
+
+//! [17]
+def MainWindow.createActions(self):
+//! [17] //! [18]
+ Act = QAction(QIcon(":/images/new.png"), tr("&New"), self)
+ Act.setShortcuts(QKeySequence.New)
+ Act.setStatusTip(tr("Create a new file"))
+ connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()"))
+
+//! [19]
+ openAct = QAction(QIcon(":/images/open.png"), tr("&Open..."), self)
+ openAct.setShortcuts(QKeySequence.Open)
+ openAct.setStatusTip(tr("Open an existing file"))
+ connect(openAct, SIGNAL("triggered()"), self, SLOT("open()"))
+//! [18] //! [19]
+
+ saveAct = QAction(QIcon(":/images/save.png"), tr("&Save"), self)
+ saveAct.setShortcuts(QKeySequence.Save)
+ saveAct.setStatusTip(tr("Save the document to disk"))
+ connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()"))
+
+ saveAsAct = QAction(tr("Save &As..."), self)
+ saveAsAct.setShortcuts(QKeySequence.SaveAs)
+ saveAsAct.setStatusTip(tr("Save the document under a name"))
+ connect(saveAsAct, SIGNAL("triggered()"), self, SLOT("saveAs()"))
+
+//! [20]
+ exitAct = QAction(tr("E&xit"), self)
+ exitAct.setShortcut(tr("Ctrl+Q"))
+//! [20]
+ exitAct.setStatusTip(tr("Exit the application"))
+ connect(exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
+
+//! [21]
+ cutAct = QAction(QIcon(":/images/cut.png"), tr("Cu&t"), self)
+//! [21]
+ cutAct.setShortcuts(QKeySequence.Cut)
+ cutAct.setStatusTip(tr("Cut the current selection's contents to the "
+ "clipboard"))
+ connect(cutAct, SIGNAL("triggered()"), textEdit, SLOT("cut()"))
+
+ copyAct = QAction(QIcon(":/images/copy.png"), tr("&Copy"), self)
+ copyAct.setShortcuts(QKeySequence.Copy)
+ copyAct.setStatusTip(tr("Copy the current selection's contents to the "
+ "clipboard"))
+ connect(copyAct, SIGNAL("triggered()"), textEdit, SLOT("copy()"))
+
+ pasteAct = QAction(QIcon(":/images/paste.png"), tr("&Paste"), self)
+ pasteAct.setShortcuts(QKeySequence.Paste)
+ pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current "
+ "selection"))
+ connect(pasteAct, SIGNAL("triggered()"), textEdit, SLOT("paste()"))
+
+ aboutAct = QAction(tr("&About"), self)
+ aboutAct.setStatusTip(tr("Show the application's About box"))
+ connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()"))
+
+//! [22]
+ aboutQtAct = QAction(tr("About &Qt"), self)
+ aboutQtAct.setStatusTip(tr("Show the Qt library's About box"))
+ connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()"))
+//! [22]
+
+//! [23]
+ cutAct.setEnabled(False)
+//! [23] //! [24]
+ copyAct.setEnabled(False)
+ connect(textEdit, SIGNAL("copyAvailable(bool)"),
+ cutAct, SLOT("setEnabled(bool)"))
+ connect(textEdit, SIGNAL("copyAvailable(bool)"),
+ copyAct, SLOT("setEnabled(bool)"))
+}
+//! [24]
+
+//! [25] //! [26]
+def createMenus(self):
+//! [25] //! [27]
+ fileMenu = menuBar().addMenu(tr("&File"))
+ fileMenu.addAction(Act)
+//! [28]
+ fileMenu.addAction(openAct)
+//! [28]
+ fileMenu.addAction(saveAct)
+//! [26]
+ fileMenu.addAction(saveAsAct)
+ fileMenu.addSeparator()
+ fileMenu.addAction(exitAct)
+
+ editMenu = menuBar().addMenu(tr("&Edit"))
+ editMenu.addAction(cutAct)
+ editMenu.addAction(copyAct)
+ editMenu.addAction(pasteAct)
+
+ menuBar().addSeparator()
+
+ helpMenu = menuBar().addMenu(tr("&Help"))
+ helpMenu.addAction(aboutAct)
+ helpMenu.addAction(aboutQtAct)
+
+//! [27]
+
+//! [29] //! [30]
+def createToolBars(self):
+ fileToolBar = addToolBar(tr("File"))
+ fileToolBar.addAction(Act)
+//! [29] //! [31]
+ fileToolBar.addAction(openAct)
+//! [31]
+ fileToolBar.addAction(saveAct)
+
+ editToolBar = addToolBar(tr("Edit"))
+ editToolBar.addAction(cutAct)
+ editToolBar.addAction(copyAct)
+ editToolBar.addAction(pasteAct)
+//! [30]
+
+//! [32]
+def createStatusBar(self):
+//! [32] //! [33]
+ statusBar().showMessage(tr("Ready"))
+
+//! [33]
+
+//! [34] //! [35]
+def readSettings(self):
+//! [34] //! [36]
+ settings("Trolltech", "Application Example")
+ pos = settings.value("pos", QPoint(200, 200)).toPoint()
+ size = settings.value("size", QSize(400, 400)).toSize()
+ resize(size)
+ move(pos)
+
+//! [35] //! [36]
+
+//! [37] //! [38]
+def writeSettings(self):
+//! [37] //! [39]
+ settings = QSettings("Trolltech", "Application Example")
+ settings.setValue("pos", pos())
+ settings.setValue("size", size())
+
+//! [38] //! [39]
+
+//! [40]
+def maybeSave(self):
+//! [40] //! [41]
+ if textEdit.document()->isModified():
+ ret = QMessageBox.warning(self, tr("Application"),
+ tr("The document has been modified.\n"
+ "Do you want to save your changes?"),
+ QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
+ if ret == QMessageBox.Save:
+ return save()
+ elif ret == QMessageBox.Cancel:
+ return False
+ return True
+//! [41]
+
+//! [42]
+def loadFile(self, fileName):
+//! [42] //! [43]
+ file = QFile(fileName)
+ if !file.open(QFile.ReadOnly | QFile.Text):
+ QMessageBox.warning(self, tr("Application"),
+ tr("Cannot read file %1:\n%2.")
+ .arg(fileName)
+ .arg(file.errorString()))
+ return
+
+ in = QTextStream(file)
+ QApplication.setOverrideCursor(Qt::WaitCursor)
+ textEdit.setPlainText(in.readAll())
+ QApplication.restoreOverrideCursor()
+
+ setCurrentFile(fileName)
+ statusBar().showMessage(tr("File loaded"), 2000)
+
+//! [43]
+
+//! [44]
+def saveFile(self, fileName):
+//! [44] //! [45]
+ file = QFile(fileName)
+ if !file.open(QFile.WriteOnly | QFile::Text):
+ QMessageBox.warning(self, tr("Application"),
+ tr("Cannot write file %1:\n%2.")
+ .arg(fileName)
+ .arg(file.errorString()))
+ return False
+
+ out = QTextStream(file)
+ QApplication.setOverrideCursor(Qt.WaitCursor)
+ out << textEdit.toPlainText()
+ QApplication.restoreOverrideCursor()
+
+ setCurrentFile(fileName)
+ statusBar().showMessage(tr("File saved"), 2000)
+ return True
+
+//! [45]
+
+//! [46]
+def setCurrentFile(fileName):
+//! [46] //! [47]
+ curFile = fileName
+ textEdit.document().setModified(False)
+ setWindowModified(False)
+
+ if curFile.isEmpty():
+ shownName = "untitled.txt"
+ else:
+ shownName = strippedName(curFile)
+
+ setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("Application")))
+
+//! [47]
+
+//! [48]
+def strippedName(self, fullFileName):
+//! [48] //! [49]
+ return QFileInfo(fullFileName).fileName()
+//! [49]
diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/dockwidgets/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/dockwidgets/mainwindow.cpp
new file mode 100644
index 000000000..fa125e01f
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/mainwindows/dockwidgets/mainwindow.cpp
@@ -0,0 +1,255 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+from PySide2.QtGui import *
+//! [0]
+
+//! [1]
+def __init__(self):
+ textEdit = QTextEdit()
+ setCentralWidget(textEdit)
+
+ createActions()
+ createMenus()
+ createToolBars()
+ createStatusBar()
+ createDockWindows()
+
+ setWindowTitle(tr("Dock Widgets"))
+
+ Letter()
+ setUnifiedTitleAndToolBarOnMac(True)
+//! [1]
+
+//! [2]
+def Letter(self)
+ textEdit.clear()
+
+ cursor = QTextCursor(textEdit.textCursor())
+ cursor.movePosition(QTextCursor.Start)
+ topFrame = cursor.currentFrame()
+ topFrameFormat = topFrame.frameFormat()
+ topFrameFormat.setPadding(16)
+ topFrame.setFrameFormat(topFrameFormat)
+
+ textFormat = QTextCharFormat()
+ boldFormat = QTextCharFormat()
+ boldFormat.setFontWeight(QFont.Bold)
+ italicFormat = QTextCharFormat()
+ italicFormat.setFontItalic(True)
+
+ tableFormat = QTextTableFormat()
+ tableFormat.setBorder(1)
+ tableFormat.setCellPadding(16)
+ tableFormat.setAlignment(Qt.AlignRight)
+ cursor.insertTable(1, 1, tableFormat)
+ cursor.insertText("The Firm", boldFormat)
+ cursor.insertBlock()
+ cursor.insertText("321 City Street", textFormat)
+ cursor.insertBlock()
+ cursor.insertText("Industry Park")
+ cursor.insertBlock()
+ cursor.insertText("Some Country")
+ cursor.setPosition(topFrame.lastPosition())
+ cursor.insertText(QDate.currentDate().toString("d MMMM yyyy"), textFormat)
+ cursor.insertBlock()
+ cursor.insertBlock()
+ cursor.insertText("Dear ", textFormat)
+ cursor.insertText("NAME", italicFormat)
+ cursor.insertText(",", textFormat)
+ for i in range(3):
+ cursor.insertBlock()
+ cursor.insertText(tr("Yours sincerely,"), textFormat)
+ for i in range(3):
+ cursor.insertBlock()
+ cursor.insertText("The Boss", textFormat)
+ cursor.insertBlock()
+ cursor.insertText("ADDRESS", italicFormat)
+//! [2]
+
+//! [3]
+def print(self)
+ document = textEdit.document()
+ printer = QPrinter()
+
+ dlg = QPrintDialog(&printer, self)
+ if dlg.exec() != QDialog.Accepted:
+ return
+
+ document.print(printer)
+ statusBar().showMessage(tr("Ready"), 2000)
+//! [3]
+
+//! [4]
+def save(self):
+ fileName = QFileDialog.getSaveFileName(self,
+ tr("Choose a file name"), ".",
+ tr("HTML (*.html *.htm)"))
+ if fileName.isEmpty():
+ return
+ file = QFile(fileName)
+ if !file.open(QFile.WriteOnly | QFile::Text):
+ QMessageBox.warning(self, tr("Dock Widgets"),
+ tr("Cannot write file %1:\n%2.")
+ .arg(fileName)
+ .arg(file.errorString()))
+ return
+
+
+ out = QTextStream(file)
+ QApplication.setOverrideCursor(Qt::WaitCursor)
+ out << textEdit.toHtml()
+ QApplication.restoreOverrideCursor()
+
+ statusBar().showMessage(tr("Saved '%1'").arg(fileName), 2000)
+
+//! [4]
+
+//! [5]
+def undo(self):
+ document = textEdit.document()
+ document.undo()
+
+//! [5]
+
+//! [6]
+def insertCustomer(self, customer):
+ if customer.isEmpty():
+ return
+
+ customerList = customer.split(", ")
+ document = textEdit.document()
+ cursor = document.find("NAME")
+ if not cursor.isNull():
+ cursor.beginEditBlock()
+ cursor.insertText(customerList.at(0))
+ oldcursor = cursor
+ cursor = document.find("ADDRESS")
+ if not cursor.isNull():
+ for i in range(customerList.size()):
+ cursor.insertBlock()
+ cursor.insertText(customerList.at(i))
+
+ cursor.endEditBlock()
+ else:
+ oldcursor.endEditBlock()
+//! [6]
+
+//! [7]
+def addParagraph(self, paragraph):
+ if (paragraph.isEmpty())
+ return
+
+ document = textEdit.document()
+ cursor = document.find(tr("Yours sincerely,"))
+ if cursor.isNull():
+ return
+ cursor.beginEditBlock()
+ cursor.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, 2)
+ cursor.insertBlock()
+ cursor.insertText(paragraph)
+ cursor.insertBlock()
+ cursor.endEditBlock()
+
+//! [7]
+
+
+//! [8]
+def createStatusBar(self):
+ statusBar().showMessage(tr("Ready"))
+
+//! [8]
+
+//! [9]
+def createDockWindows(self):
+ dock = QDockWidget(tr("Customers"), self)
+ dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
+ customerList = QListWidget(dock)
+ customerList.addItems(QStringList()
+ << "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton"
+ << "Jane Doe, Memorabilia, 23 Watersedge, Beaton"
+ << "Tammy Shea, Tiblanka, 38 Sea Views, Carlton"
+ << "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal"
+ << "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston"
+ << "Sally Hobart, Tiroli Tea, 67 Long River, Fedula")
+ dock.setWidget(customerList)
+ addDockWidget(Qt.RightDockWidgetArea, dock)
+ viewMenu.addAction(dock.toggleViewAction())
+
+ dock = QDockWidget(tr("Paragraphs"), self)
+ paragraphsList = QListWidget(dock)
+ paragraphsList.addItems(QStringList()
+ << "Thank you for your payment which we have received today."
+ << "Your order has been dispatched and should be with you "
+ "within 28 days."
+ << "We have dispatched those items that were in stock. The "
+ "rest of your order will be dispatched once all the "
+ "remaining items have arrived at our warehouse. No "
+ "additional shipping charges will be made."
+ << "You made a small overpayment (less than $5) which we "
+ "will keep on account for you, or return at your request."
+ << "You made a small underpayment (less than $1), but we have "
+ "sent your order anyway. We'll add self underpayment to "
+ "your next bill."
+ << "Unfortunately you did not send enough money. Please remit "
+ "an additional $. Your order will be dispatched as soon as "
+ "the complete amount has been received."
+ << "You made an overpayment (more than $5). Do you wish to "
+ "buy more items, or should we return the excess to you?")
+ dock.setWidget(paragraphsList)
+ addDockWidget(Qt.RightDockWidgetArea, dock)
+ viewMenu.addAction(dock.toggleViewAction())
+
+ connect(customerList, SIGNAL("currentTextChanged(const QString &)"),
+ self, SLOT("insertCustomer(const QString &)"))
+ connect(paragraphsList, SIGNAL("currentTextChanged(const QString &)"),
+ self, SLOT("addParagraph(const QString &)"))
+//! [9]
diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/mainwindow.cpp
new file mode 100644
index 000000000..8dc283ebf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/mainwindows/mainwindow.cpp
@@ -0,0 +1,367 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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.QtGui import *
+
+//! [0]
+def __init__(self):
+ Q__init__(self)
+
+ widget = QWidget()
+ setCentralWidget(widget)
+//! [0]
+
+//! [1]
+ topFiller = QWidget()
+ topFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+
+ infoLabel = QLabel(tr("<i>Choose a menu option, or right-click to "
+ "invoke a context menu</i>"))
+ infoLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
+ infoLabel.setAlignment(Qt.AlignCenter)
+
+ bottomFiller = QWidget()
+ bottomFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+
+ layout = QVBoxLayout()
+ layout.setMargin(5)
+ layout.addWidget(topFiller)
+ layout.addWidget(infoLabel)
+ layout.addWidget(bottomFiller)
+ widget.setLayout(layout)
+//! [1]
+
+//! [2]
+ createActions()
+ createMenus()
+
+ message = tr("A context menu is available by right-clicking")
+ statusBar().showMessage(message)
+
+ setWindowTitle(tr("Menus"))
+ setMinimumSize(160, 160)
+ resize(480, 320)
+
+//! [2]
+
+//! [3]
+def contextMenuEvent(self, event):
+ menu = QMenu(self)
+ menu.addAction(cutAct)
+ menu.addAction(copyAct)
+ menu.addAction(pasteAct)
+ menu.exec_(event.globalPos()")
+
+//! [3]
+
+def File(self):
+ infoLabel.setText(tr("Invoked <b>File|New</b>"))
+
+
+def open(self):
+ infoLabel.setText(tr("Invoked <b>File|Open</b>"))
+
+
+def save(self):
+ infoLabel.setText(tr("Invoked <b>File|Save</b>"))
+
+def print_(self):
+ infoLabel.setText(tr("Invoked <b>File|Print</b>"))
+
+def undo(self):
+ infoLabel.setText(tr("Invoked <b>Edit|Undo</b>"))
+
+def redo(self):
+ infoLabel.setText(tr("Invoked <b>Edit|Redo</b>"))
+
+def cut(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Cut</b>"))
+
+
+def copy(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Copy</b>"))
+
+
+def paste(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Paste</b>"))
+
+
+def bold(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Bold</b>"))
+
+
+def italic(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Italic</b>"))
+
+
+def leftAlign(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Left Align</b>"))
+
+
+def rightAlign(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Right Align</b>"))
+
+
+def justify(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Justify</b>"))
+
+
+def center(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Center</b>"))
+
+
+def setLineSpacing(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Set Line Spacing</b>"))
+
+
+def setParagraphSpacing(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Set Paragraph Spacing</b>"))
+
+
+def about(self):
+
+ infoLabel.setText(tr("Invoked <b>Help|About</b>"))
+ QMessageBox.about(self, tr("About Menu"),
+ tr("The <b>Menu</b> example shows how to create "
+ "menu-bar menus and context menus."))
+
+
+def aboutQt(self):
+
+ infoLabel.setText(tr("Invoked <b>Help|About Qt</b>"))
+
+
+//! [4]
+def createActions(self):
+
+//! [5]
+ Act = new QAction(tr("&New"), self)
+ Act.setShortcuts(QKeySequence.New)
+ Act.setStatusTip(tr("Create a new file"))
+ connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()"))
+//! [4]
+
+ openAct = QAction(tr("&Open..."), self)
+ openAct.setShortcuts(QKeySequence.Open)
+ openAct.setStatusTip(tr("Open an existing file"))
+ connect(openAct, SIGNAL("triggered()"), self, SLOT("open()"))
+//! [5]
+
+ saveAct = QAction(tr("&Save"), self)
+ saveAct.setShortcuts(QKeySequence.Save)
+ saveAct.setStatusTip(tr("Save the document to disk"))
+ connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()"))
+
+ printAct = QAction(tr("&Print..."), self)
+ printAct.setShortcuts(QKeySequence.Print)
+ printAct.setStatusTip(tr("Print the document"))
+ connect(printAct, SIGNAL("triggered()"), self, SLOT("print_()"))
+
+ exitAct = QAction(tr("E&xit"), self)
+ exitAct.setShortcut(tr("Ctrl+Q"))
+ exitAct.setStatusTip(tr("Exit the application"))
+ connect(exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
+
+ undoAct = QAction(tr("&Undo"), self)
+ undoAct.setShortcuts(QKeySequence.Undo)
+ undoAct.setStatusTip(tr("Undo the last operation"))
+ connect(undoAct, SIGNAL("triggered()"), self, SLOT("undo()"))
+
+ redoAct = QAction(tr("&Redo"), self)
+ redoAct.setShortcuts(QKeySequence.Redo)
+ redoAct.setStatusTip(tr("Redo the last operation"))
+ connect(redoAct, SIGNAL("triggered()"), self, SLOT("redo()"))
+
+ cutAct = QAction(tr("Cu&t"), self)
+ cutAct.setShortcuts(QKeySequence.Cut)
+ cutAct.setStatusTip(tr("Cut the current selection's contents to the "
+ "clipboard"))
+ connect(cutAct, SIGNAL("triggered()"), self, SLOT("cut()"))
+
+ copyAct = QAction(tr("&Copy"), self)
+ copyAct.setShortcut(tr("Ctrl+C"))
+ copyAct.setStatusTip(tr("Copy the current selection's contents to the "
+ "clipboard"))
+ connect(copyAct, SIGNAL("triggered()"), self, SLOT("copy()"))
+
+ pasteAct = QAction(tr("&Paste"), self)
+ pasteAct.setShortcuts(QKeySequence.Paste)
+ pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current "
+ "selection"))
+ connect(pasteAct, SIGNAL("triggered()"), self, SLOT("paste()"))
+
+ boldAct = QAction(tr("&Bold"), self)
+ boldAct.setCheckable(True)
+ boldAct.setShortcut(tr("Ctrl+B"))
+ boldAct.setStatusTip(tr("Make the text bold"))
+ connect(boldAct, SIGNAL("triggered()"), self, SLOT("bold()"))
+
+ QFont boldFont = boldAct.font()
+ boldFont.setBold(True)
+ boldAct.setFont(boldFont)
+
+ italicAct = QAction(tr("&Italic"), self)
+ italicAct.setCheckable(True)
+ italicAct.setShortcut(tr("Ctrl+I"))
+ italicAct.setStatusTip(tr("Make the text italic"))
+ connect(italicAct, SIGNAL("triggered()"), self, SLOT("italic()"))
+
+ QFont italicFont = italicAct.font()
+ italicFont.setItalic(True)
+ italicAct.setFont(italicFont)
+
+ setLineSpacingAct = QAction(tr("Set &Line Spacing..."), self)
+ setLineSpacingAct.setStatusTip(tr("Change the gap between the lines of a "
+ "paragraph"))
+ connect(setLineSpacingAct, SIGNAL("triggered()"), self, SLOT("setLineSpacing()"))
+
+ setParagraphSpacingAct = QAction(tr("Set &Paragraph Spacing..."), self)
+ setLineSpacingAct.setStatusTip(tr("Change the gap between paragraphs"))
+ connect(setParagraphSpacingAct, SIGNAL("triggered()"),
+ self, SLOT("setParagraphSpacing()"))
+
+ aboutAct = QAction(tr("&About"), self)
+ aboutAct.setStatusTip(tr("Show the application's About box"))
+ connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()"))
+
+ aboutQtAct = QAction(tr("About &Qt"), self)
+ aboutQtAct.setStatusTip(tr("Show the Qt library's About box"))
+ connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()"))
+ connect(aboutQtAct, SIGNAL("triggered()"), self, SLOT("aboutQt()"))
+
+ leftAlignAct = QAction(tr("&Left Align"), self)
+ leftAlignAct.setCheckable(True)
+ leftAlignAct.setShortcut(tr("Ctrl+L"))
+ leftAlignAct.setStatusTip(tr("Left align the selected text"))
+ connect(leftAlignAct, SIGNAL("triggered()"), self, SLOT("leftAlign()"))
+
+ rightAlignAct = QAction(tr("&Right Align"), self)
+ rightAlignAct.setCheckable(True)
+ rightAlignAct.setShortcut(tr("Ctrl+R"))
+ rightAlignAct.setStatusTip(tr("Right align the selected text"))
+ connect(rightAlignAct, SIGNAL("triggered()"), self, SLOT("rightAlign()"))
+
+ justifyAct = QAction(tr("&Justify"), self)
+ justifyAct.setCheckable(True)
+ justifyAct.setShortcut(tr("Ctrl+J"))
+ justifyAct.setStatusTip(tr("Justify the selected text"))
+ connect(justifyAct, SIGNAL("triggered()"), self, SLOT("justify()"))
+
+ centerAct = QAction(tr("&Center"), self)
+ centerAct.setCheckable(True)
+ centerAct.setShortcut(tr("Ctrl+E"))
+ centerAct.setStatusTip(tr("Center the selected text"))
+ connect(centerAct, SIGNAL("triggered()"), self, SLOT("center()"))
+
+//! [6] //! [7]
+ alignmentGroup = QActionGroup(self)
+ alignmentGroup.addAction(leftAlignAct)
+ alignmentGroup.addAction(rightAlignAct)
+ alignmentGroup.addAction(justifyAct)
+ alignmentGroup.addAction(centerAct)
+ leftAlignAct.setChecked(True)
+//! [6]
+
+//! [7]
+
+//! [8]
+def createMenus(self):
+
+//! [9] //! [10]
+ fileMenu = menuBar().addMenu(tr("&File"))
+ fileMenu.addAction(Act)
+//! [9]
+ fileMenu.addAction(openAct)
+//! [10]
+ fileMenu.addAction(saveAct)
+ fileMenu.addAction(printAct)
+//! [11]
+ fileMenu.addSeparator()
+//! [11]
+ fileMenu.addAction(exitAct)
+
+ editMenu = menuBar().addMenu(tr("&Edit"))
+ editMenu.addAction(undoAct)
+ editMenu.addAction(redoAct)
+ editMenu.addSeparator()
+ editMenu.addAction(cutAct)
+ editMenu.addAction(copyAct)
+ editMenu.addAction(pasteAct)
+ editMenu.addSeparator()
+
+ helpMenu = menuBar().addMenu(tr("&Help"))
+ helpMenu.addAction(aboutAct)
+ helpMenu.addAction(aboutQtAct)
+//! [8]
+
+//! [12]
+ formatMenu = editMenu.addMenu(tr("&Format"))
+ formatMenu.addAction(boldAct)
+ formatMenu.addAction(italicAct)
+ formatMenu.addSeparator()->setText(tr("Alignment"))
+ formatMenu.addAction(leftAlignAct)
+ formatMenu.addAction(rightAlignAct)
+ formatMenu.addAction(justifyAct)
+ formatMenu.addAction(centerAct)
+ formatMenu.addSeparator()
+ formatMenu.addAction(setLineSpacingAct)
+ formatMenu.addAction(setParagraphSpacingAct)
+//! [12]
diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/mdi/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/mdi/mainwindow.cpp
new file mode 100644
index 000000000..7032ba7da
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/mainwindows/mdi/mainwindow.cpp
@@ -0,0 +1,381 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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.QtGui import *
+
+def __init__(self):
+
+ mdiArea = QMdiArea()
+ mdiArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
+ mdiArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
+ setCentralWidget(mdiArea)
+ connect(mdiArea, SIGNAL("subWindowActivated(QMdiSubWindow *)"),
+ self, SLOT("updateMenus()"))
+ windowMapper = QSignalMapper(self)
+ connect(windowMapper, SIGNAL("mapped(QWidget *)"),
+ self, SLOT("setActiveSubWindow(QWidget *)"))
+
+ createActions()
+ createMenus()
+ createToolBars()
+ createStatusBar()
+ updateMenus()
+
+ readSettings()
+
+ setWindowTitle(tr("MDI"))
+ setUnifiedTitleAndToolBarOnMac(True)
+
+
+def closeEvent(self, event):
+ mdiArea.closeAllSubWindows()
+ if self.activeMdiChild():
+ event.ignore()
+ else:
+ self.writeSettings()
+ event.accept()
+
+def File(self):
+ child = self.createMdiChild()
+ child.File()
+ child.show()
+
+
+def open(self):
+ fileName = QFileDialog.getOpenFileName(self)
+ if !fileName.isEmpty()):
+ existing = self.findMdiChild(fileName)
+ if existing:
+ mdiArea.setActiveSubWindow(existing)
+ return
+
+ child = createMdiChild()
+ if child.loadFile(fileName)):
+ statusBar().showMessage(tr("File loaded"), 2000)
+ child.show()
+ else:
+ child.close()
+
+def save(self):
+ if self.activeMdiChild() && self.activeMdiChild().save():
+ self.statusBar().showMessage(tr("File saved"), 2000)
+
+def saveAs(self):
+ if self.activeMdiChild() && self.activeMdiChild().saveAs():
+ self.statusBar().showMessage(tr("File saved"), 2000)
+
+def cut(self):
+ if self.activeMdiChild():
+ self.activeMdiChild().cut()
+
+def copy(self):
+ if self.activeMdiChild():
+ activeMdiChild().copy()
+
+def paste(self):
+ if self.activeMdiChild():
+ activeMdiChild().paste()
+
+def about(self):
+ QMessageBox.about(self, tr("About MDI"),
+ tr("The <b>MDI</b> example demonstrates how to write multiple "
+ "document interface applications using Qt.")")
+
+def updateMenus(self):
+ hasMdiChild = (activeMdiChild() != 0)
+ self.saveAct.setEnabled(hasMdiChild)
+ self.saveAsAct.setEnabled(hasMdiChild)
+ self.pasteAct.setEnabled(hasMdiChild)
+ self.closeAct.setEnabled(hasMdiChild)
+ self.closeAllAct.setEnabled(hasMdiChild)
+ self.tileAct.setEnabled(hasMdiChild)
+ self.cascadeAct.setEnabled(hasMdiChild)
+ self.nextAct.setEnabled(hasMdiChild)
+ self.previousAct.setEnabled(hasMdiChild)
+ self.separatorAct.setVisible(hasMdiChild)
+
+ hasSelection = (self.activeMdiChild() &&
+ self.activeMdiChild().textCursor().hasSelection()")
+ self.cutAct.setEnabled(hasSelection)
+ self.copyAct.setEnabled(hasSelection)
+
+def updateWindowMenu(self):
+ self.windowMenu.clear()
+ self.windowMenu.addAction(closeAct)
+ self.windowMenu.addAction(closeAllAct)
+ self.windowMenu.addSeparator()
+ self.windowMenu.addAction(tileAct)
+ self.windowMenu.addAction(cascadeAct)
+ self.windowMenu.addSeparator()
+ self.windowMenu.addAction(nextAct)
+ self.windowMenu.addAction(previousAct)
+ self.windowMenu.addAction(separatorAct)
+
+ windows = mdiArea.subWindowList()
+ separatorAct.setVisible(!windows.isEmpty()")
+
+ for i in range((int i = 0 i < windows.size(); ++i)
+ MdiChild *child = qobject_cast<MdiChild *>(windows.at(i).widget()")
+
+ QString text
+ if (i < 9)
+ text = tr("&%1 %2").arg(i + 1)
+ .arg(child.userFriendlyCurrentFile()")
+ else
+ text = tr("%1 %2").arg(i + 1)
+ .arg(child.userFriendlyCurrentFile()")
+
+ QAction *action = windowMenu.addAction(text)
+ action.setCheckable(True)
+ action .setChecked(child == activeMdiChild()")
+ connect(action, SIGNAL("triggered()"), windowMapper, SLOT("map()"))
+ windowMapper.setMapping(action, windows.at(i)")
+
+
+
+MdiChild *createMdiChild()
+
+ MdiChild *child = MdiChild
+ mdiArea.addSubWindow(child)
+
+ connect(child, SIGNAL("copyAvailable(bool)"),
+ cutAct, SLOT("setEnabled(bool)"))
+ connect(child, SIGNAL("copyAvailable(bool)"),
+ copyAct, SLOT("setEnabled(bool)"))
+
+ return child
+
+
+def createActions()
+
+ Act = new QAction(QIcon(":/images/new.png"), tr("&New"), self)
+ Act.setShortcuts(QKeySequence.New)
+ Act.setStatusTip(tr("Create a new file")")
+ connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()"))
+
+ openAct = QAction(QIcon(":/images/open.png"), tr("&Open..."), self)
+ openAct.setShortcuts(QKeySequence.Open)
+ openAct.setStatusTip(tr("Open an existing file")")
+ connect(openAct, SIGNAL("triggered()"), self, SLOT("open()"))
+
+ saveAct = QAction(QIcon(":/images/save.png"), tr("&Save"), self)
+ saveAct.setShortcuts(QKeySequence.Save)
+ saveAct.setStatusTip(tr("Save the document to disk")")
+ connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()"))
+
+ saveAsAct = QAction(tr("Save &As..."), self)
+ saveAsAct.setShortcuts(QKeySequence.SaveAs)
+ saveAsAct.setStatusTip(tr("Save the document under a name")")
+ connect(saveAsAct, SIGNAL("triggered()"), self, SLOT("saveAs()"))
+
+//! [0]
+ exitAct = QAction(tr("E&xit"), self)
+ exitAct.setShortcut(tr("Ctrl+Q")")
+ exitAct.setStatusTip(tr("Exit the application")")
+ connect(exitAct, SIGNAL("triggered()"), qApp, SLOT("closeAllWindows()"))
+//! [0]
+
+ cutAct = QAction(QIcon(":/images/cut.png"), tr("Cu&t"), self)
+ cutAct.setShortcuts(QKeySequence.Cut)
+ cutAct.setStatusTip(tr("Cut the current selection's contents to the "
+ "clipboard")")
+ connect(cutAct, SIGNAL("triggered()"), self, SLOT("cut()"))
+
+ copyAct = QAction(QIcon(":/images/copy.png"), tr("&Copy"), self)
+ copyAct.setShortcuts(QKeySequence.Copy)
+ copyAct.setStatusTip(tr("Copy the current selection's contents to the "
+ "clipboard")")
+ connect(copyAct, SIGNAL("triggered()"), self, SLOT("copy()"))
+
+ pasteAct = QAction(QIcon(":/images/paste.png"), tr("&Paste"), self)
+ pasteAct.setShortcuts(QKeySequence.Paste)
+ pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current "
+ "selection")")
+ connect(pasteAct, SIGNAL("triggered()"), self, SLOT("paste()"))
+
+ closeAct = QAction(tr("Cl&ose"), self)
+ closeAct.setShortcut(tr("Ctrl+F4")")
+ closeAct.setStatusTip(tr("Close the active window")")
+ connect(closeAct, SIGNAL("triggered()"),
+ mdiArea, SLOT("closeActiveSubWindow()"))
+
+ closeAllAct = QAction(tr("Close &All"), self)
+ closeAllAct.setStatusTip(tr("Close all the windows")")
+ connect(closeAllAct, SIGNAL("triggered()"),
+ mdiArea, SLOT("closeAllSubWindows()"))
+
+ tileAct = QAction(tr("&Tile"), self)
+ tileAct.setStatusTip(tr("Tile the windows")")
+ connect(tileAct, SIGNAL("triggered()"), mdiArea, SLOT("tileSubWindows()"))
+
+ cascadeAct = QAction(tr("&Cascade"), self)
+ cascadeAct.setStatusTip(tr("Cascade the windows")")
+ connect(cascadeAct, SIGNAL("triggered()"), mdiArea, SLOT("cascadeSubWindows()"))
+
+ nextAct = QAction(tr("Ne&xt"), self)
+ nextAct.setShortcuts(QKeySequence.NextChild)
+ nextAct.setStatusTip(tr("Move the focus to the next window")")
+ connect(nextAct, SIGNAL("triggered()"),
+ mdiArea, SLOT("activateNextSubWindow()"))
+
+ previousAct = QAction(tr("Pre&vious"), self)
+ previousAct.setShortcuts(QKeySequence.PreviousChild)
+ previousAct.setStatusTip(tr("Move the focus to the previous "
+ "window")")
+ connect(previousAct, SIGNAL("triggered()"),
+ mdiArea, SLOT("activatePreviousSubWindow()"))
+
+ separatorAct = QAction(self)
+ separatorAct.setSeparator(True)
+
+ aboutAct = QAction(tr("&About"), self)
+ aboutAct.setStatusTip(tr("Show the application's About box")")
+ connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()"))
+
+ aboutQtAct = QAction(tr("About &Qt"), self)
+ aboutQtAct.setStatusTip(tr("Show the Qt library's About box")")
+ connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()"))
+
+
+def createMenus()
+
+ fileMenu = menuBar().addMenu(tr("&File")")
+ fileMenu.addAction(Act)
+ fileMenu.addAction(openAct)
+ fileMenu.addAction(saveAct)
+ fileMenu.addAction(saveAsAct)
+ fileMenu.addSeparator()
+ QAction *action = fileMenu.addAction(tr("Switch layout direction")")
+ connect(action, SIGNAL("triggered()"), self, SLOT("switchLayoutDirection()"))
+ fileMenu.addAction(exitAct)
+
+ editMenu = menuBar().addMenu(tr("&Edit")")
+ editMenu.addAction(cutAct)
+ editMenu.addAction(copyAct)
+ editMenu.addAction(pasteAct)
+
+ windowMenu = menuBar().addMenu(tr("&Window")")
+ updateWindowMenu()
+ connect(windowMenu, SIGNAL("aboutToShow()"), self, SLOT("updateWindowMenu()"))
+
+ menuBar().addSeparator()
+
+ helpMenu = menuBar().addMenu(tr("&Help")")
+ helpMenu.addAction(aboutAct)
+ helpMenu.addAction(aboutQtAct)
+
+
+def createToolBars()
+
+ fileToolBar = addToolBar(tr("File")")
+ fileToolBar.addAction(Act)
+ fileToolBar.addAction(openAct)
+ fileToolBar.addAction(saveAct)
+
+ editToolBar = addToolBar(tr("Edit")")
+ editToolBar.addAction(cutAct)
+ editToolBar.addAction(copyAct)
+ editToolBar.addAction(pasteAct)
+
+
+def createStatusBar()
+
+ statusBar().showMessage(tr("Ready")")
+
+
+def readSettings()
+
+ QSettings settings("Trolltech", "MDI Example")
+ QPoint pos = settings.value("pos", QPoint(200, 200)").toPoint()
+ QSize size = settings.value("size", QSize(400, 400)").toSize()
+ move(pos)
+ resize(size)
+
+
+def writeSettings()
+
+ QSettings settings("Trolltech", "MDI Example")
+ settings.setValue("pos", pos()")
+ settings.setValue("size", size()")
+
+
+MdiChild *activeMdiChild()
+
+ if (QMdiSubWindow *activeSubWindow = mdiArea.activeSubWindow()")
+ return qobject_cast<MdiChild *>(activeSubWindow.widget()")
+ return 0
+
+
+QMdiSubWindow *findMdiChild(const QString &fileName)
+
+ QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath()
+
+ foreach (QMdiSubWindow *window, mdiArea.subWindowList()")
+ MdiChild *mdiChild = qobject_cast<MdiChild *>(window.widget()")
+ if (mdiChild.currentFile() == canonicalFilePath)
+ return window
+
+ return 0
+
+
+def switchLayoutDirection()
+
+ if (layoutDirection() == Qt.LeftToRight)
+ qApp.setLayoutDirection(Qt.RightToLeft)
+ else
+ qApp.setLayoutDirection(Qt.LeftToRight)
+
+
+def setActiveSubWindow(QWidget *window)
+
+ if (!window)
+ return
+ mdiArea.setActiveSubWindow(qobject_cast<QMdiSubWindow *>(window)")
+
diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/menus/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/menus/mainwindow.cpp
new file mode 100644
index 000000000..8dc283ebf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/mainwindows/menus/mainwindow.cpp
@@ -0,0 +1,367 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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.QtGui import *
+
+//! [0]
+def __init__(self):
+ Q__init__(self)
+
+ widget = QWidget()
+ setCentralWidget(widget)
+//! [0]
+
+//! [1]
+ topFiller = QWidget()
+ topFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+
+ infoLabel = QLabel(tr("<i>Choose a menu option, or right-click to "
+ "invoke a context menu</i>"))
+ infoLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
+ infoLabel.setAlignment(Qt.AlignCenter)
+
+ bottomFiller = QWidget()
+ bottomFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+
+ layout = QVBoxLayout()
+ layout.setMargin(5)
+ layout.addWidget(topFiller)
+ layout.addWidget(infoLabel)
+ layout.addWidget(bottomFiller)
+ widget.setLayout(layout)
+//! [1]
+
+//! [2]
+ createActions()
+ createMenus()
+
+ message = tr("A context menu is available by right-clicking")
+ statusBar().showMessage(message)
+
+ setWindowTitle(tr("Menus"))
+ setMinimumSize(160, 160)
+ resize(480, 320)
+
+//! [2]
+
+//! [3]
+def contextMenuEvent(self, event):
+ menu = QMenu(self)
+ menu.addAction(cutAct)
+ menu.addAction(copyAct)
+ menu.addAction(pasteAct)
+ menu.exec_(event.globalPos()")
+
+//! [3]
+
+def File(self):
+ infoLabel.setText(tr("Invoked <b>File|New</b>"))
+
+
+def open(self):
+ infoLabel.setText(tr("Invoked <b>File|Open</b>"))
+
+
+def save(self):
+ infoLabel.setText(tr("Invoked <b>File|Save</b>"))
+
+def print_(self):
+ infoLabel.setText(tr("Invoked <b>File|Print</b>"))
+
+def undo(self):
+ infoLabel.setText(tr("Invoked <b>Edit|Undo</b>"))
+
+def redo(self):
+ infoLabel.setText(tr("Invoked <b>Edit|Redo</b>"))
+
+def cut(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Cut</b>"))
+
+
+def copy(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Copy</b>"))
+
+
+def paste(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Paste</b>"))
+
+
+def bold(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Bold</b>"))
+
+
+def italic(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Italic</b>"))
+
+
+def leftAlign(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Left Align</b>"))
+
+
+def rightAlign(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Right Align</b>"))
+
+
+def justify(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Justify</b>"))
+
+
+def center(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Center</b>"))
+
+
+def setLineSpacing(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Set Line Spacing</b>"))
+
+
+def setParagraphSpacing(self):
+
+ infoLabel.setText(tr("Invoked <b>Edit|Format|Set Paragraph Spacing</b>"))
+
+
+def about(self):
+
+ infoLabel.setText(tr("Invoked <b>Help|About</b>"))
+ QMessageBox.about(self, tr("About Menu"),
+ tr("The <b>Menu</b> example shows how to create "
+ "menu-bar menus and context menus."))
+
+
+def aboutQt(self):
+
+ infoLabel.setText(tr("Invoked <b>Help|About Qt</b>"))
+
+
+//! [4]
+def createActions(self):
+
+//! [5]
+ Act = new QAction(tr("&New"), self)
+ Act.setShortcuts(QKeySequence.New)
+ Act.setStatusTip(tr("Create a new file"))
+ connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()"))
+//! [4]
+
+ openAct = QAction(tr("&Open..."), self)
+ openAct.setShortcuts(QKeySequence.Open)
+ openAct.setStatusTip(tr("Open an existing file"))
+ connect(openAct, SIGNAL("triggered()"), self, SLOT("open()"))
+//! [5]
+
+ saveAct = QAction(tr("&Save"), self)
+ saveAct.setShortcuts(QKeySequence.Save)
+ saveAct.setStatusTip(tr("Save the document to disk"))
+ connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()"))
+
+ printAct = QAction(tr("&Print..."), self)
+ printAct.setShortcuts(QKeySequence.Print)
+ printAct.setStatusTip(tr("Print the document"))
+ connect(printAct, SIGNAL("triggered()"), self, SLOT("print_()"))
+
+ exitAct = QAction(tr("E&xit"), self)
+ exitAct.setShortcut(tr("Ctrl+Q"))
+ exitAct.setStatusTip(tr("Exit the application"))
+ connect(exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
+
+ undoAct = QAction(tr("&Undo"), self)
+ undoAct.setShortcuts(QKeySequence.Undo)
+ undoAct.setStatusTip(tr("Undo the last operation"))
+ connect(undoAct, SIGNAL("triggered()"), self, SLOT("undo()"))
+
+ redoAct = QAction(tr("&Redo"), self)
+ redoAct.setShortcuts(QKeySequence.Redo)
+ redoAct.setStatusTip(tr("Redo the last operation"))
+ connect(redoAct, SIGNAL("triggered()"), self, SLOT("redo()"))
+
+ cutAct = QAction(tr("Cu&t"), self)
+ cutAct.setShortcuts(QKeySequence.Cut)
+ cutAct.setStatusTip(tr("Cut the current selection's contents to the "
+ "clipboard"))
+ connect(cutAct, SIGNAL("triggered()"), self, SLOT("cut()"))
+
+ copyAct = QAction(tr("&Copy"), self)
+ copyAct.setShortcut(tr("Ctrl+C"))
+ copyAct.setStatusTip(tr("Copy the current selection's contents to the "
+ "clipboard"))
+ connect(copyAct, SIGNAL("triggered()"), self, SLOT("copy()"))
+
+ pasteAct = QAction(tr("&Paste"), self)
+ pasteAct.setShortcuts(QKeySequence.Paste)
+ pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current "
+ "selection"))
+ connect(pasteAct, SIGNAL("triggered()"), self, SLOT("paste()"))
+
+ boldAct = QAction(tr("&Bold"), self)
+ boldAct.setCheckable(True)
+ boldAct.setShortcut(tr("Ctrl+B"))
+ boldAct.setStatusTip(tr("Make the text bold"))
+ connect(boldAct, SIGNAL("triggered()"), self, SLOT("bold()"))
+
+ QFont boldFont = boldAct.font()
+ boldFont.setBold(True)
+ boldAct.setFont(boldFont)
+
+ italicAct = QAction(tr("&Italic"), self)
+ italicAct.setCheckable(True)
+ italicAct.setShortcut(tr("Ctrl+I"))
+ italicAct.setStatusTip(tr("Make the text italic"))
+ connect(italicAct, SIGNAL("triggered()"), self, SLOT("italic()"))
+
+ QFont italicFont = italicAct.font()
+ italicFont.setItalic(True)
+ italicAct.setFont(italicFont)
+
+ setLineSpacingAct = QAction(tr("Set &Line Spacing..."), self)
+ setLineSpacingAct.setStatusTip(tr("Change the gap between the lines of a "
+ "paragraph"))
+ connect(setLineSpacingAct, SIGNAL("triggered()"), self, SLOT("setLineSpacing()"))
+
+ setParagraphSpacingAct = QAction(tr("Set &Paragraph Spacing..."), self)
+ setLineSpacingAct.setStatusTip(tr("Change the gap between paragraphs"))
+ connect(setParagraphSpacingAct, SIGNAL("triggered()"),
+ self, SLOT("setParagraphSpacing()"))
+
+ aboutAct = QAction(tr("&About"), self)
+ aboutAct.setStatusTip(tr("Show the application's About box"))
+ connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()"))
+
+ aboutQtAct = QAction(tr("About &Qt"), self)
+ aboutQtAct.setStatusTip(tr("Show the Qt library's About box"))
+ connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()"))
+ connect(aboutQtAct, SIGNAL("triggered()"), self, SLOT("aboutQt()"))
+
+ leftAlignAct = QAction(tr("&Left Align"), self)
+ leftAlignAct.setCheckable(True)
+ leftAlignAct.setShortcut(tr("Ctrl+L"))
+ leftAlignAct.setStatusTip(tr("Left align the selected text"))
+ connect(leftAlignAct, SIGNAL("triggered()"), self, SLOT("leftAlign()"))
+
+ rightAlignAct = QAction(tr("&Right Align"), self)
+ rightAlignAct.setCheckable(True)
+ rightAlignAct.setShortcut(tr("Ctrl+R"))
+ rightAlignAct.setStatusTip(tr("Right align the selected text"))
+ connect(rightAlignAct, SIGNAL("triggered()"), self, SLOT("rightAlign()"))
+
+ justifyAct = QAction(tr("&Justify"), self)
+ justifyAct.setCheckable(True)
+ justifyAct.setShortcut(tr("Ctrl+J"))
+ justifyAct.setStatusTip(tr("Justify the selected text"))
+ connect(justifyAct, SIGNAL("triggered()"), self, SLOT("justify()"))
+
+ centerAct = QAction(tr("&Center"), self)
+ centerAct.setCheckable(True)
+ centerAct.setShortcut(tr("Ctrl+E"))
+ centerAct.setStatusTip(tr("Center the selected text"))
+ connect(centerAct, SIGNAL("triggered()"), self, SLOT("center()"))
+
+//! [6] //! [7]
+ alignmentGroup = QActionGroup(self)
+ alignmentGroup.addAction(leftAlignAct)
+ alignmentGroup.addAction(rightAlignAct)
+ alignmentGroup.addAction(justifyAct)
+ alignmentGroup.addAction(centerAct)
+ leftAlignAct.setChecked(True)
+//! [6]
+
+//! [7]
+
+//! [8]
+def createMenus(self):
+
+//! [9] //! [10]
+ fileMenu = menuBar().addMenu(tr("&File"))
+ fileMenu.addAction(Act)
+//! [9]
+ fileMenu.addAction(openAct)
+//! [10]
+ fileMenu.addAction(saveAct)
+ fileMenu.addAction(printAct)
+//! [11]
+ fileMenu.addSeparator()
+//! [11]
+ fileMenu.addAction(exitAct)
+
+ editMenu = menuBar().addMenu(tr("&Edit"))
+ editMenu.addAction(undoAct)
+ editMenu.addAction(redoAct)
+ editMenu.addSeparator()
+ editMenu.addAction(cutAct)
+ editMenu.addAction(copyAct)
+ editMenu.addAction(pasteAct)
+ editMenu.addSeparator()
+
+ helpMenu = menuBar().addMenu(tr("&Help"))
+ helpMenu.addAction(aboutAct)
+ helpMenu.addAction(aboutQtAct)
+//! [8]
+
+//! [12]
+ formatMenu = editMenu.addMenu(tr("&Format"))
+ formatMenu.addAction(boldAct)
+ formatMenu.addAction(italicAct)
+ formatMenu.addSeparator()->setText(tr("Alignment"))
+ formatMenu.addAction(leftAlignAct)
+ formatMenu.addAction(rightAlignAct)
+ formatMenu.addAction(justifyAct)
+ formatMenu.addAction(centerAct)
+ formatMenu.addSeparator()
+ formatMenu.addAction(setLineSpacingAct)
+ formatMenu.addAction(setParagraphSpacingAct)
+//! [12]
diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/sdi/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/sdi/mainwindow.cpp
new file mode 100644
index 000000000..fe52f0fbb
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/mainwindows/sdi/mainwindow.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+//! [implicit tr context]
+def createMenus(self):
+ fileMenu = menuBar().addMenu("&File")
+//! [implicit tr context]
+
+//! [0]
+ fileToolBar = addToolBar("File")
+ fileToolBar.addAction(newAct)
+ fileToolBar.addAction(openAct)
+//! [0]
diff --git a/sources/pyside2/doc/codesnippets/examples/painting/svggenerator/window.cpp b/sources/pyside2/doc/codesnippets/examples/painting/svggenerator/window.cpp
new file mode 100644
index 000000000..60c415949
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/painting/svggenerator/window.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QColorDialog>
+#include <QFileDialog>
+#include <QPainter>
+#include <QSvgGenerator>
+#include "window.h"
+#include "displaywidget.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+}
+
+void Window::updateBackground(int background)
+{
+ displayWidget->setBackground(DisplayWidget::Background(background));
+}
+
+void Window::updateColor()
+{
+ QColor color = QColorDialog::getColor(displayWidget->color());
+ if (color.isValid())
+ displayWidget->setColor(color);
+}
+
+void Window::updateShape(int shape)
+{
+ displayWidget->setShape(DisplayWidget::Shape(shape));
+}
+
+//! [save SVG]
+def saveSvg(self):
+ newPath = QFileDialog.getSaveFileName(self, QObject.tr("Save SVG"), path, QObject.tr("SVG files (*.svg)"))
+
+ if newPath.isEmpty():
+ return
+
+ path = newPath
+
+//![configure SVG generator]
+ generator = QSvgGenerator()
+ generator.setFileName(path)
+ generator.setSize(QSize(200, 200))
+ generator.setViewBox(QRect(0, 0, 200, 200))
+ generator.setTitle(QObject.tr("SVG Generator Example Drawing"))
+ generator.setDescription(QObject.tr("An SVG drawing created by the SVG Generator Example provided with Qt."))
+//![configure SVG generator]
+//![begin painting]
+ painter = QPainter()
+ painter.begin(generator)
+//![begin painting]
+ displayWidget->paint(painter)
+//![end painting]
+ painter.end()
+//![end painting]
+
+//! [save SVG]
diff --git a/sources/pyside2/doc/codesnippets/examples/richtext/textobject/svgtextobject.h b/sources/pyside2/doc/codesnippets/examples/richtext/textobject/svgtextobject.h
new file mode 100644
index 000000000..0c9b7c06e
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/richtext/textobject/svgtextobject.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef SVGTEXTOBJECT_H
+#define SVGTEXTOBJECT_H
+
+#include <QTextObjectInterface>
+
+QT_BEGIN_NAMESPACE
+class QTextDocument;
+class QTextFormat;
+class QPainter;
+class QRectF;
+class QSizeF;
+QT_END_NAMESPACE
+
+//![0] //![1]
+class SvgTextObject(QObject, QTextObjectInterface):
+ def __init__(self,...):
+ super(SvgTextObject, self).__init__(...)
+ ...
+//![1]
+
+public:
+ QSizeF intrinsicSize(QTextDocument *doc, int posInDocument,
+ const QTextFormat &format);
+ void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc,
+ int posInDocument, const QTextFormat &format);
+};
+//![0]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp b/sources/pyside2/doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp
new file mode 100644
index 000000000..844ee7711
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtSql>
+
+#include "editablesqlmodel.h"
+
+EditableSqlModel::EditableSqlModel(QObject *parent)
+ : QSqlQueryModel(parent)
+{
+}
+
+//! [0]
+def flags(self, index):
+ flags = QSqlQueryModel.flags(index)
+ if index.column() == 1 or index.column() == 2:
+ flags |= Qt.ItemIsEditable
+ return flags
+//! [0]
+
+//! [1]
+def setData(self, index, value, role):
+ if index.column() < 1 or index.column() > 2:
+ return False
+
+ primaryKeyIndex = QSqlQueryModel.index(index.row(), 0)
+ id = self.data(primaryKeyIndex).toInt()
+
+ self.clear()
+
+ ok = False
+ if index.column() == 1:
+ ok = self.setFirstName(id, value)
+ else:
+ ok = self.setLastName(id, value)
+ self.refresh()
+ return ok
+}
+//! [1]
+
+void EditableSqlModel::refresh()
+{
+ setQuery("select * from person");
+ setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
+ setHeaderData(1, Qt::Horizontal, QObject::tr("First name"));
+ setHeaderData(2, Qt::Horizontal, QObject::tr("Last name"));
+}
+
+//! [2]
+def setFirstName(self, personId, firstName):
+ query = QSqlQuery()
+ query.prepare("update person set firstname = ? where id = ?")
+ query.addBindValue(firstName)
+ query.addBindValue(personId)
+ return query.exec()
+//! [2]
+
+bool EditableSqlModel::setLastName(int personId, const QString &lastName)
+{
+ QSqlQuery query;
+ query.prepare("update person set lastname = ? where id = ?");
+ query.addBindValue(lastName);
+ query.addBindValue(personId);
+ return query.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/examples/sql/relationaltablemodel/relationaltablemodel.cpp b/sources/pyside2/doc/codesnippets/examples/sql/relationaltablemodel/relationaltablemodel.cpp
new file mode 100644
index 000000000..b34c652d0
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/sql/relationaltablemodel/relationaltablemodel.cpp
@@ -0,0 +1,120 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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.QtGui import *
+from PySide2.QtSql import *
+
+def initializeModel(model):
+//! [0]
+ model.setTable("employee")
+//! [0]
+
+ model.setEditStrategy(QSqlTableModel.OnManualSubmit)
+//! [1]
+ model.setRelation(2, QSqlRelation("city", "id", "name"))
+//! [1] //! [2]
+ model.setRelation(3, QSqlRelation("country", "id", "name"))
+//! [2]
+
+//! [3]
+ model.setHeaderData(0, Qt.Horizontal, QObject::tr("ID"))
+ model.setHeaderData(1, Qt.Horizontal, QObject::tr("Name"))
+ model.setHeaderData(2, Qt.Horizontal, QObject::tr("City"))
+ model.setHeaderData(3, Qt.Horizontal, QObject::tr("Country"))
+//! [3]
+
+ model.select()
+
+
+def createView(title, model):
+//! [4]
+ view = QTableView()
+ view.setModel(model)
+ view.setItemDelegate(QSqlRelationalDelegate(view))
+//! [4]
+ view.setWindowTitle(title)
+ return view
+
+
+def createRelationalTables():
+ query = QSqlQuery()
+ query.exec_("create table employee(id int primary key, name varchar(20), city int, country int)")
+ query.exec_("insert into employee values(1, 'Espen', 5000, 47)")
+ query.exec_("insert into employee values(2, 'Harald', 80000, 49)")
+ query.exec_("insert into employee values(3, 'Sam', 100, 1)")
+
+ query.exec_("create table city(id int, name varchar(20))")
+ query.exec_("insert into city values(100, 'San Jose')")
+ query.exec_("insert into city values(5000, 'Oslo')")
+ query.exec_("insert into city values(80000, 'Munich')")
+
+ query.exec_("create table country(id int, name varchar(20))")
+ query.exec_("insert into country values(1, 'USA')")
+ query.exec_("insert into country values(47, 'Norway')")
+ query.exec_("insert into country values(49, 'Germany')")
+
+
+def main():
+
+ app = QApplication([])
+ if !createConnection():
+ return 1
+
+ createRelationalTables()
+
+ model = QSqlRelationalTableModel()
+
+ initializeModel(model)
+
+ view = createView(QObject.tr("Relational Table Model"), model)
+ view.show()
+
+ return app.exec_()
+
diff --git a/sources/pyside2/doc/codesnippets/examples/uitools/textfinder/textfinder.cpp b/sources/pyside2/doc/codesnippets/examples/uitools/textfinder/textfinder.cpp
new file mode 100644
index 000000000..e493945c9
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/uitools/textfinder/textfinder.cpp
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtUiTools>
+#include <QtWidgets>
+#include "textfinder.h"
+
+//! [0]
+def __init__(self, parent = None):
+ QWidget.__init__(self. parent)
+ formWidget = self.loadUiFile()
+
+//! [1]
+ self.ui_findButton = qFindChild(QPushButton, self, "findButton")
+ self.ui_textEdit = qFindChild(QTextEdit, self, "textEdit")
+ self.ui_lineEdit = qFindChild(QLineEdit, self, "lineEdit")
+//! [0] //! [1]
+
+//! [2]
+ QMetaObject.connectSlotsByName(self)
+//! [2]
+
+//! [3a]
+ self.loadTextFile()
+//! [3a]
+
+//! [3b]
+ layout = QVBoxLayout()
+ layout.addWidget(formWidget)
+ self.setLayout(layout)
+//! [3b]
+
+//! [3c]
+ self.setWindowTitle("Text Finder")
+ self.isFirstTime = True
+//! [3c]
+
+//! [4]
+def loadUiFile(self):
+ loader = QUiLoader()
+ return loader.load(":/forms/textfinder.ui", self)
+//! [4]
+
+//! [5]
+def loadTextFile(self):
+ inputFile = QFile(":/forms/input.txt")
+ inputFile.open(QIODevice.ReadOnly)
+ in = QTextStream(inputFile)
+ line = in.readAll()
+ inputFile.close()
+
+ self.ui_textEdit.append(line)
+ self.ui_textEdit.setUndoRedoEnabled(False)
+ self.ui_textEdit.setUndoRedoEnabled(True)
+//! [5]
+
+//! [6] //! [7]
+@Slot()
+def on_findButton_clicked(self):
+ searchString = self.ui_lineEdit.text()
+ document = self.ui_textEdit.document()
+
+ found = False
+
+ if not self.isFirstTime:
+ document.undo()
+
+ if not searchString:
+ QMessageBox.information(self, "Empty Search Field",
+ "The search field is empty. Please enter a word and click Find.")
+ else:
+ highlightCursor = QTextCursor(document)
+ cursor = QTextCursor(document)
+ cursor.beginEditBlock()
+//! [6]
+ plainFormat = QTextCharFormat(highlightCursor.charFormat())
+ colorFormat = QTextCharFormat(plainFormat)
+ colorFormat.setForeground(Qt.red)
+
+ while not highlightCursor.isNull() and not highlightCursor.atEnd():
+ highlightCursor = document.find(searchString, highlightCursor, QTextDocument.FindWholeWords)
+
+ if not highlightCursor.isNull():
+ found = True
+ highlightCursor.movePosition(QTextCursor.WordRight, QTextCursor.KeepAnchor)
+ highlightCursor.mergeCharFormat(colorFormat)
+//! [8]
+ cursor.endEditBlock()
+//! [7] //! [9]
+ self.isFirstTime = False
+
+ if not found:
+ QMessageBox.information(self, "Word Not Found", "Sorry, the word cannot be found.");
+//! [8] //! [9]
diff --git a/sources/pyside2/doc/codesnippets/examples/widgets/analogclock/analogclock.cpp b/sources/pyside2/doc/codesnippets/examples/widgets/analogclock/analogclock.cpp
new file mode 100644
index 000000000..dcd24b275
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/widgets/analogclock/analogclock.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "analogclock.h"
+
+//! [0] //! [1]
+AnalogClock::AnalogClock(QWidget *parent)
+//! [0] //! [2]
+ : QWidget(parent)
+//! [2] //! [3]
+{
+//! [3] //! [4]
+ timer = QTimer(self)
+//! [4] //! [5]
+ self.connect(timer, SIGNAL("timeout()"), self.update)
+//! [5] //! [6]
+ timer.start(1000)
+//! [6]
+
+ setWindowTitle(tr("Analog Clock"));
+ resize(200, 200);
+//! [7]
+}
+//! [1] //! [7]
+
+//! [8] //! [9]
+void AnalogClock::paintEvent(QPaintEvent *)
+//! [8] //! [10]
+{
+ static const QPoint hourHand[3] = {
+ QPoint(7, 8),
+ QPoint(-7, 8),
+ QPoint(0, -40)
+ };
+ static const QPoint minuteHand[3] = {
+ QPoint(7, 8),
+ QPoint(-7, 8),
+ QPoint(0, -70)
+ };
+
+ QColor hourColor(127, 0, 127);
+ QColor minuteColor(0, 127, 127, 191);
+
+ int side = qMin(width(), height());
+ QTime time = QTime::currentTime();
+//! [10]
+
+//! [11]
+ QPainter painter(this);
+//! [11] //! [12]
+ painter.setRenderHint(QPainter::Antialiasing);
+//! [12] //! [13]
+ painter.translate(width() / 2, height() / 2);
+//! [13] //! [14]
+ painter.scale(side / 200.0, side / 200.0);
+//! [9] //! [14]
+
+//! [15]
+ painter.setPen(Qt::NoPen);
+//! [15] //! [16]
+ painter.setBrush(hourColor);
+//! [16]
+
+//! [17] //! [18]
+ painter.save();
+//! [17] //! [19]
+ painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
+ painter.drawConvexPolygon(hourHand, 3);
+ painter.restore();
+//! [18] //! [19]
+
+//! [20]
+ painter.setPen(hourColor);
+//! [20] //! [21]
+
+ for (int i = 0; i < 12; ++i) {
+ painter.drawLine(88, 0, 96, 0);
+ painter.rotate(30.0);
+ }
+//! [21]
+
+//! [22]
+ painter.setPen(Qt::NoPen);
+//! [22] //! [23]
+ painter.setBrush(minuteColor);
+
+//! [24]
+ painter.save();
+ painter.rotate(6.0 * (time.minute() + time.second() / 60.0));
+ painter.drawConvexPolygon(minuteHand, 3);
+ painter.restore();
+//! [23] //! [24]
+
+//! [25]
+ painter.setPen(minuteColor);
+//! [25] //! [26]
+
+//! [27]
+ for (int j = 0; j < 60; ++j) {
+ if ((j % 5) != 0)
+ painter.drawLine(92, 0, 96, 0);
+ painter.rotate(6.0);
+ }
+//! [27]
+}
+//! [26]
diff --git a/sources/pyside2/doc/codesnippets/examples/widgets/groupbox/window.cpp b/sources/pyside2/doc/codesnippets/examples/widgets/groupbox/window.cpp
new file mode 100644
index 000000000..9203e5ba3
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/widgets/groupbox/window.cpp
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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]
+def __init__(self, parent = None):
+ QWidget.__init__(self, parent)
+
+ grid = QGridLayout()
+ grid.addWidget(createFirstExclusiveGroup(), 0, 0)
+ grid.addWidget(createSecondExclusiveGroup(), 1, 0)
+ grid.addWidget(createNonExclusiveGroup(), 0, 1)
+ grid.addWidget(createPushButtonGroup(), 1, 1)
+ setLayout(grid)
+
+ setWindowTitle("Group Boxes")
+ resize(480, 320)
+
+//! [0]
+
+//! [1]
+def createFirstExclusiveGroup(self):
+//! [2]
+ groupBox = QGroupBox("Exclusive Radio Buttons")
+
+ radio1 = QRadioButton("&Radio button 1")
+ radio2 = QRadioButton("R&adio button 2")
+ radio3 = QRadioButton("Ra&dio button 3")
+
+ radio1.setChecked(True)
+//! [1] //! [3]
+
+ vbox = QVBoxLayout()
+ vbox.addWidget(radio1)
+ vbox.addWidget(radio2)
+ vbox.addWidget(radio3)
+ vbox.addStretch(1)
+ groupBox.setLayout(vbox)
+//! [2]
+ return groupBox
+//! [3]
+
+//! [4]
+def createSecondExclusiveGroup(self):
+ groupBox = QGroupBox("E&xclusive Radio Buttons")
+ groupBox.setCheckable(True)
+ groupBox.setChecked(False)
+//! [4]
+
+//! [5]
+ radio1 = QRadioButton("Rad&io button 1")
+ radio2 = QRadioButton("Radi&o button 2")
+ radio3 = QRadioButton("Radio &button 3")
+ radio1.setChecked(True)
+ checkBox = QCheckBox("Ind&ependent checkbox")
+ checkBox.setChecked(True)
+//! [5]
+
+//! [6]
+ vbox = QVBoxLayout()
+ vbox.addWidget(radio1)
+ vbox.addWidget(radio2)
+ vbox.addWidget(radio3)
+ vbox.addWidget(checkBox)
+ vbox.addStretch(1)
+ groupBox.setLayout(vbox)
+
+ return groupBox
+//! [6]
+
+//! [7]
+def createNonExclusiveGroup(self):
+ groupBox = QGroupBox("Non-Exclusive Checkboxes")
+ groupBox.setFlat(True)
+//! [7]
+
+//! [8]
+ checkBox1 = QCheckBox("&Checkbox 1")
+ checkBox2 = QCheckBox("C&heckbox 2")
+ checkBox2.setChecked(True)
+ tristateBox = QCheckBox("Tri-&state button")
+ tristateBox.setTristate(True)
+//! [8]
+ tristateBox.setCheckState(Qt.PartiallyChecked)
+
+//! [9]
+ vbox = QVBoxLayout()
+ vbox.addWidget(checkBox1)
+ vbox.addWidget(checkBox2)
+ vbox.addWidget(tristateBox)
+ vbox.addStretch(1)
+ groupBox.setLayout(vbox)
+
+ return groupBox
+//! [9]
+
+//! [10]
+def createPushButtonGroup(self):
+ groupBox = QGroupBox("&Push Buttons")
+ groupBox.setCheckable(True)
+ groupBox.setChecked(True)
+//! [10]
+
+//! [11]
+ pushButton = QPushButton("&Normal Button")
+ toggleButton = QPushButton("&Toggle Button")
+ toggleButton.setCheckable(True)
+ toggleButton.setChecked(True)
+ flatButton = QPushButton("&Flat Button")
+ flatButton.setFlat(True)
+//! [11]
+
+//! [12]
+ popupButton = QPushButton("Pop&up Button")
+ menu = QMenu(self)
+ menu.addAction("&First Item")
+ menu.addAction("&Second Item")
+ menu.addAction("&Third Item")
+ menu.addAction("F&ourth Item")
+ popupButton.setMenu(menu)
+//! [12]
+
+ newAction = menu.addAction("Submenu")
+ QMenu *subMenu = QMenu("Popup Submenu")
+ subMenu.addAction("Item 1")
+ subMenu.addAction("Item 2")
+ subMenu.addAction("Item 3")
+ newAction.setMenu(subMenu)
+
+//! [13]
+ vbox = QVBoxLayout()
+ vbox.addWidget(pushButton)
+ vbox.addWidget(toggleButton)
+ vbox.addWidget(flatButton)
+ vbox.addWidget(popupButton)
+ vbox.addStretch(1)
+ groupBox.setLayout(vbox)
+
+ return groupBox
+}
+//! [13]
diff --git a/sources/pyside2/doc/codesnippets/examples/widgets/icons/iconsizespinbox.cpp b/sources/pyside2/doc/codesnippets/examples/widgets/icons/iconsizespinbox.cpp
new file mode 100644
index 000000000..22e5fbc37
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/widgets/icons/iconsizespinbox.cpp
@@ -0,0 +1,72 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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]
+def __init__(self, parent):
+ QSpinBox.__init__(self, parent)
+
+//! [0]
+
+//! [1]
+def valueFromText(self, text):
+ regExp = QRegExp(tr("(\\d+)(\\s*[xx]\\s*\\d+)?"))
+
+ if regExp.exactMatch(text):
+ return regExp.cap(1).toInt()
+ else:
+ return 0
+//! [1]
+
+//! [2]
+def textFromValue(self, value):
+ return self.tr("%1 x %1").arg(value)
+
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/examples/widgets/spinboxes/window.cpp b/sources/pyside2/doc/codesnippets/examples/widgets/spinboxes/window.cpp
new file mode 100644
index 000000000..54a9523ee
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/widgets/spinboxes/window.cpp
@@ -0,0 +1,249 @@
+############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the examples of PySide2.
+##
+## $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.QtGui import *
+
+//! [0]
+def __init__(self):
+ createSpinBoxes()
+ createDateTimeEdits()
+ createDoubleSpinBoxes()
+
+ layout = QHBoxLayout()
+ layout.addWidget(spinBoxesGroup)
+ layout.addWidget(editsGroup)
+ layout.addWidget(doubleSpinBoxesGroup)
+ setLayout(layout)
+
+ setWindowTitle(tr("Spin Boxes"))
+//! [0]
+
+//! [1]
+def createSpinBoxes(self):
+ spinBoxesGroup = QGroupBox(tr("Spinboxes"))
+
+ integerLabel = QLabel(tr("Enter a value between "
+ "%1 and %2:").arg(-20).arg(20))
+ integerSpinBox = QSpinBox()
+ integerSpinBox.setRange(-20, 20)
+ integerSpinBox.setSingleStep(1)
+ integerSpinBox.setValue(0)
+//! [1]
+
+//! [2]
+ zoomLabel = QLabel(tr("Enter a zoom value between "
+ "%1 and %2:").arg(0).arg(1000))
+//! [3]
+ zoomSpinBox = QSpinBox()
+ zoomSpinBox.setRange(0, 1000)
+ zoomSpinBox.setSingleStep(10)
+ zoomSpinBox.setSuffix("%")
+ zoomSpinBox.setSpecialValueText(tr("Automatic"))
+ zoomSpinBox.setValue(100)
+//! [2] //! [3]
+
+//! [4]
+ priceLabel = QLabel(tr("Enter a price between "
+ "%1 and %2:").arg(0).arg(999))
+ priceSpinBox = QSpinBox()
+ priceSpinBox.setRange(0, 999)
+ priceSpinBox.setSingleStep(1)
+ priceSpinBox.setPrefix("$")
+ priceSpinBox.setValue(99)
+//! [4] //! [5]
+
+ spinBoxLayout = QVBoxLayout()
+ spinBoxLayout.addWidget(integerLabel)
+ spinBoxLayout.addWidget(integerSpinBox)
+ spinBoxLayout.addWidget(zoomLabel)
+ spinBoxLayout.addWidget(zoomSpinBox)
+ spinBoxLayout.addWidget(priceLabel)
+ spinBoxLayout.addWidget(priceSpinBox)
+ spinBoxesGroup.setLayout(spinBoxLayout)
+
+//! [5]
+
+//! [6]
+def createDateTimeEdits(self):
+ editsGroup = QGroupBox(tr("Date and time spin boxes"))
+
+ dateLabel = QLabel()
+ dateEdit = QDateEdit(QDate.currentDate())
+ dateEdit.setDateRange(QDate(2005, 1, 1), QDate(2010, 12, 31))
+ dateLabel.setText(tr("Appointment date (between %0 and %1):")
+ .arg(dateEdit.minimumDate().toString(Qt.ISODate))
+ .arg(dateEdit.maximumDate().toString(Qt.ISODate)))
+//! [6]
+
+//! [7]
+ timeLabel = QLabel()
+ timeEdit = QTimeEdit(QTime.currentTime())
+ timeEdit.setTimeRange(QTime(9, 0, 0, 0), QTime(16, 30, 0, 0))
+ timeLabel.setText(tr("Appointment time (between %0 and %1):")
+ .arg(timeEdit.minimumTime().toString(Qt.ISODate))
+ .arg(timeEdit.maximumTime().toString(Qt.ISODate)))
+//! [7]
+
+//! [8]
+ meetingLabel = QLabel()
+ meetingEdit = QDateTimeEdit(QDateTime.currentDateTime())
+//! [8]
+
+//! [9]
+ formatLabel = QLabel(tr("Format string for the meeting date "
+ "and time:"))
+ formatComboBox = QComboBox()
+ formatComboBox.addItem("yyyy-MM-dd hh:mm:ss (zzz 'ms')")
+ formatComboBox.addItem("hh:mm:ss MM/dd/yyyy")
+ formatComboBox.addItem("hh:mm:ss dd/MM/yyyy")
+ formatComboBox.addItem("hh:mm:ss")
+ formatComboBox.addItem("hh:mm ap")
+//! [9] //! [10]
+
+ connect(formatComboBox, SIGNAL("activated(const QString &)"),
+ self, SLOT("setFormatString(const QString &)"))
+//! [10]
+
+ setFormatString(formatComboBox.currentText())
+
+//! [11]
+ editsLayout = QVBoxLayout()
+ editsLayout.addWidget(dateLabel)
+ editsLayout.addWidget(dateEdit)
+ editsLayout.addWidget(timeLabel)
+ editsLayout.addWidget(timeEdit)
+ editsLayout.addWidget(meetingLabel)
+ editsLayout.addWidget(meetingEdit)
+ editsLayout.addWidget(formatLabel)
+ editsLayout.addWidget(formatComboBox)
+ editsGroup.setLayout(editsLayout)
+//! [11]
+
+//! [12]
+def setFormatString(self, formatString):
+ meetingEdit.setDisplayFormat(formatString)
+//! [12] //! [13]
+ if meetingEdit.displayedSections() & QDateTimeEdit.DateSections_Mask:
+ meetingEdit.setDateRange(QDate(2004, 11, 1), QDate(2005, 11, 30))
+ meetingLabel.setText(tr("Meeting date (between %0 and %1):")
+ .arg(meetingEdit.minimumDate().toString(Qt.ISODate))
+ .arg(meetingEdit.maximumDate().toString(Qt.ISODate)))
+ else:
+ meetingEdit.setTimeRange(QTime(0, 7, 20, 0), QTime(21, 0, 0, 0))
+ meetingLabel.setText(tr("Meeting time (between %0 and %1):")
+ .arg(meetingEdit.minimumTime().toString(Qt.ISODate))
+ .arg(meetingEdit.maximumTime().toString(Qt.ISODate)))
+//! [13]
+
+//! [14]
+def createDoubleSpinBoxes():
+ doubleSpinBoxesGroup = QGroupBox(tr("Double precision spinboxes"))
+
+ precisionLabel = QLabel(tr("Number of decimal places "
+ "to show:"))
+ precisionSpinBox = QSpinBox()
+ precisionSpinBox.setRange(0, 100)
+ precisionSpinBox.setValue(2)
+//! [14]
+
+//! [15]
+ doubleLabel = QLabel(tr("Enter a value between "
+ "%1 and %2:").arg(-20).arg(20))
+ doubleSpinBox = QDoubleSpinBox ()
+ doubleSpinBox.setRange(-20.0, 20.0)
+ doubleSpinBox.setSingleStep(1.0)
+ doubleSpinBox.setValue(0.0)
+//! [15]
+
+//! [16]
+ scaleLabel = QLabel(tr("Enter a scale factor between "
+ "%1 and %2:").arg(0).arg(1000.0))
+ scaleSpinBox = QDoubleSpinBox()
+ scaleSpinBox.setRange(0.0, 1000.0)
+ scaleSpinBox.setSingleStep(10.0)
+ scaleSpinBox.setSuffix("%")
+ scaleSpinBox.setSpecialValueText(tr("No scaling"))
+ scaleSpinBox.setValue(100.0)
+//! [16]
+
+//! [17]
+ priceLabel = QLabel(tr("Enter a price between "
+ "%1 and %2:").arg(0).arg(1000))
+ priceSpinBox = QDoubleSpinBox()
+ priceSpinBox.setRange(0.0, 1000.0)
+ priceSpinBox.setSingleStep(1.0)
+ priceSpinBox.setPrefix("$")
+ priceSpinBox.setValue(99.99)
+
+ connect(precisionSpinBox, SIGNAL("valueChanged(int)"),
+//! [17]
+ self, SLOT("changePrecision(int))")
+
+//! [18]
+ spinBoxLayout = QVBoxLayout()
+ spinBoxLayout.addWidget(precisionLabel)
+ spinBoxLayout.addWidget(precisionSpinBox)
+ spinBoxLayout.addWidget(doubleLabel)
+ spinBoxLayout.addWidget(doubleSpinBox)
+ spinBoxLayout.addWidget(scaleLabel)
+ spinBoxLayout.addWidget(scaleSpinBox)
+ spinBoxLayout.addWidget(priceLabel)
+ spinBoxLayout.addWidget(priceSpinBox)
+ doubleSpinBoxesGroup.setLayout(spinBoxLayout)
+}
+//! [18]
+
+//! [19]
+def changePrecision(self, int)
+ doubleSpinBox.setDecimals(decimals)
+ scaleSpinBox.setDecimals(decimals)
+ priceSpinBox.setDecimals(decimals)
+
+//! [19]
diff --git a/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp b/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp
new file mode 100644
index 000000000..c82f02752
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp
@@ -0,0 +1,210 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "xbelreader.h"
+
+//! [0]
+XbelReader::XbelReader(QTreeWidget *treeWidget)
+ : treeWidget(treeWidget)
+{
+ QStyle *style = treeWidget->style();
+
+ folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon),
+ QIcon::Normal, QIcon::Off);
+ folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon),
+ QIcon::Normal, QIcon::On);
+ bookmarkIcon.addPixmap(style->standardPixmap(QStyle::SP_FileIcon));
+}
+//! [0]
+
+//! [1]
+def read(self, device):
+ self.setDevice(device)
+
+ while not atEnd():
+ readNext()
+
+ if isStartElement():
+ if self.name() == "xbel" and self.attributes().value("version") == "1.0":
+ self.readXBEL()
+ else:
+ self.raiseError(QObject.tr("The file is not an XBEL version 1.0 file."));
+
+ return not self.error();
+//! [1]
+
+//! [2]
+void XbelReader::readUnknownElement()
+{
+ Q_ASSERT(isStartElement());
+
+ while (!atEnd()) {
+ readNext();
+
+ if (isEndElement())
+ break;
+
+ if (isStartElement())
+ readUnknownElement();
+ }
+}
+//! [2]
+
+//! [3]
+void XbelReader::readXBEL()
+{
+ Q_ASSERT(isStartElement() && name() == "xbel");
+
+ while (!atEnd()) {
+ readNext();
+
+ if (isEndElement())
+ break;
+
+ if (isStartElement()) {
+ if (name() == "folder")
+ readFolder(0);
+ else if (name() == "bookmark")
+ readBookmark(0);
+ else if (name() == "separator")
+ readSeparator(0);
+ else
+ readUnknownElement();
+ }
+ }
+}
+//! [3]
+
+//! [4]
+void XbelReader::readTitle(QTreeWidgetItem *item)
+{
+ Q_ASSERT(isStartElement() && name() == "title");
+
+ QString title = readElementText();
+ item->setText(0, title);
+}
+//! [4]
+
+//! [5]
+void XbelReader::readSeparator(QTreeWidgetItem *item)
+{
+ QTreeWidgetItem *separator = createChildItem(item);
+ separator->setFlags(item->flags() & ~Qt::ItemIsSelectable);
+ separator->setText(0, QString(30, 0xB7));
+ readElementText();
+}
+//! [5]
+
+void XbelReader::readFolder(QTreeWidgetItem *item)
+{
+ Q_ASSERT(isStartElement() && name() == "folder");
+
+ QTreeWidgetItem *folder = createChildItem(item);
+ bool folded = (attributes().value("folded") != "no");
+ treeWidget->setItemExpanded(folder, !folded);
+
+ while (!atEnd()) {
+ readNext();
+
+ if (isEndElement())
+ break;
+
+ if (isStartElement()) {
+ if (name() == "title")
+ readTitle(folder);
+ else if (name() == "folder")
+ readFolder(folder);
+ else if (name() == "bookmark")
+ readBookmark(folder);
+ else if (name() == "separator")
+ readSeparator(folder);
+ else
+ readUnknownElement();
+ }
+ }
+}
+
+void XbelReader::readBookmark(QTreeWidgetItem *item)
+{
+ Q_ASSERT(isStartElement() && name() == "bookmark");
+
+ QTreeWidgetItem *bookmark = createChildItem(item);
+ bookmark->setFlags(bookmark->flags() | Qt::ItemIsEditable);
+ bookmark->setIcon(0, bookmarkIcon);
+ bookmark->setText(0, QObject::tr("Unknown title"));
+ bookmark->setText(1, attributes().value("href").toString());
+ while (!atEnd()) {
+ readNext();
+
+ if (isEndElement())
+ break;
+
+ if (isStartElement()) {
+ if (name() == "title")
+ readTitle(bookmark);
+ else
+ readUnknownElement();
+ }
+ }
+}
+
+QTreeWidgetItem *XbelReader::createChildItem(QTreeWidgetItem *item)
+{
+ QTreeWidgetItem *childItem;
+ if (item) {
+ childItem = new QTreeWidgetItem(item);
+ } else {
+ childItem = new QTreeWidgetItem(treeWidget);
+ }
+ childItem->setData(0, Qt::UserRole, name().toString());
+ return childItem;
+}
diff --git a/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.h b/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.h
new file mode 100644
index 000000000..cb7207333
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef XBELREADER_H
+#define XBELREADER_H
+
+#include <QIcon>
+#include <QXmlStreamReader>
+
+QT_BEGIN_NAMESPACE
+class QTreeWidget;
+class QTreeWidgetItem;
+QT_END_NAMESPACE
+
+//! [0]
+class XbelReader (QXmlStreamReader):
+//! [1]
+ def __init__(self, treeWidget):
+ ...
+//! [1]
+
+ def read(self, device);
+ ...
+
+//! [2]
+ def readUnknownElement(self):
+ ...
+ def readXBEL(self):
+ ...
+ def readTitle(self, item):
+ ...
+ def readSeparator(self, item):
+ ...
+ def readFolder(self, item):
+ ...
+ def readBookmark(self, item):
+ ...
+ def createChildItem(self, item):
+ ...
+//! [2]
+//! [0]
+
+#endif
diff --git a/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp b/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp
new file mode 100644
index 000000000..372bc53bf
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+#include "xbelwriter.h"
+
+//! [0]
+XbelWriter::XbelWriter(QTreeWidget *treeWidget)
+ : treeWidget(treeWidget)
+{
+ setAutoFormatting(true);
+}
+//! [0]
+
+//! [1]
+def writeFile(self, device):
+ self.setDevice(device)
+
+ self.writeStartDocument()
+ self.writeDTD("<!DOCTYPE xbel>")
+ self.writeStartElement("xbel")
+ self.writeAttribute("version", "1.0")
+ for i in range(0, self.treeWidget.topLevelItemCount()):
+ self.writeItem(self.treeWidget.topLevelItem(i))
+
+ self.writeEndDocument()
+ return True;
+//! [1]
+
+//! [2]
+void XbelWriter::writeItem(QTreeWidgetItem *item)
+{
+ QString tagName = item->data(0, Qt::UserRole).toString();
+ if (tagName == "folder") {
+ bool folded = !treeWidget->isItemExpanded(item);
+ writeStartElement(tagName);
+ writeAttribute("folded", folded ? "yes" : "no");
+ writeTextElement("title", item->text(0));
+ for (int i = 0; i < item->childCount(); ++i)
+ writeItem(item->child(i));
+ writeEndElement();
+ } else if (tagName == "bookmark") {
+ writeStartElement(tagName);
+ if (!item->text(1).isEmpty())
+ writeAttribute("href", item->text(1));
+ writeTextElement("title", item->text(0));
+ writeEndElement();
+ } else if (tagName == "separator") {
+ writeEmptyElement(tagName);
+ }
+}
+//! [2]
diff --git a/sources/pyside2/doc/codesnippets/snippets/customstyle/main.cpp b/sources/pyside2/doc/codesnippets/snippets/customstyle/main.cpp
new file mode 100644
index 000000000..b5963f418
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/snippets/customstyle/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+//! [using a custom style]
+import sys
+from PySide2.QtGui import *
+
+QApplication.setStyle(CustomStyle())
+app = QApplication(sys.argv)
+spinBox = QSpinBox()
+spinBox.show()
+sys.exit(app.exec_())
+
+//! [using a custom style]
diff --git a/sources/pyside2/doc/codesnippets/snippets/textdocument-resources/main.cpp b/sources/pyside2/doc/codesnippets/snippets/textdocument-resources/main.cpp
new file mode 100644
index 000000000..4c8401022
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/snippets/textdocument-resources/main.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QTextEdit *editor = new QTextEdit;
+
+ QTextDocument *document = new QTextDocument(editor);
+ QTextCursor cursor(document);
+
+ QImage image(64, 64, QImage::Format_RGB32);
+ image.fill(qRgb(255, 160, 128));
+
+//! [Adding a resource]
+ document.addResource(QTextDocument.ImageResource,
+ QUrl("mydata://image.png"), image)
+//! [Adding a resource]
+
+//! [Inserting an image with a cursor]
+ imageFormat = QTextImageFormat()
+ imageFormat.setName("mydata://image.png")
+ cursor.insertImage(imageFormat)
+//! [Inserting an image with a cursor]
+
+ cursor.insertBlock();
+ cursor.insertText("Code less. Create more.");
+
+ editor->setDocument(document);
+ editor->setWindowTitle(tr("Text Document Images"));
+ editor->resize(320, 480);
+ editor->show();
+
+//! [Inserting an image using HTML]
+ editor.append("<img src=\"mydata://image.png\" />")
+//! [Inserting an image using HTML]
+
+ return app.exec();
+}
diff --git a/sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp b/sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp
new file mode 100644
index 000000000..0f5495cd1
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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
new file mode 100644
index 000000000..82b84076b
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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
new file mode 100644
index 000000000..231636773
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/webkitsnippets/simple/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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.nokia.com/"))
+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
new file mode 100644
index 000000000..673f045e8
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/webkitsnippets/webelement/main.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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
new file mode 100644
index 000000000..8166a8a49
--- /dev/null
+++ b/sources/pyside2/doc/codesnippets/webkitsnippets/webpage/main.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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.nokia.com"))
+thumbnail.finished.connect(app.quit)
+sys.exit(app.exec_())
diff --git a/sources/pyside2/doc/conf.py.in b/sources/pyside2/doc/conf.py.in
new file mode 100644
index 000000000..3fd1781b5
--- /dev/null
+++ b/sources/pyside2/doc/conf.py.in
@@ -0,0 +1,169 @@
+# -*- coding: utf-8 -*-
+#
+# PySide documentation build configuration file, created by
+# sphinx-quickstart on Wed Apr 22 15:04:20 2009.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+sys.path.append('@CMAKE_CURRENT_SOURCE_DIR@')
+sys.path.append('@pyside_BINARY_DIR@')
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.todo', 'sphinx.ext.graphviz', 'inheritance_diagram', 'pysideinclude']
+
+rst_epilog = """
+.. |project| replace:: PySide
+"""
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'contents'
+
+# General information about the project.
+project = u'PySide'
+copyright = u'2009-2011, Nokia Corporation'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '@BINDING_API_VERSION@'
+# The full version, including alpha/beta/rc tags.
+release = '@BINDING_API_VERSION_FULL@'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_build', 'extras']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'pysidedocs'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {
+#}
+
+# Add any paths that contain custom themes here, relative to this directory.
+html_theme_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_themes']
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+#html_static_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = { '' : ''}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+html_additional_pages = { 'index' : 'index.html'}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+html_use_index = False
+
+# If true, the index is split into individual pages for each letter.
+html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+html_show_sourcelink = False
+
+html_add_permalinks = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+#htmlhelp_basename = 'PySideDoc'
diff --git a/sources/pyside2/doc/contents.rst b/sources/pyside2/doc/contents.rst
new file mode 100644
index 000000000..c2ea806a2
--- /dev/null
+++ b/sources/pyside2/doc/contents.rst
@@ -0,0 +1,30 @@
+PySide Documentation contents
+*****************************
+
+.. toctree::
+ :maxdepth: 2
+
+ modules.rst
+
+Tutorials
+=========
+
+.. toctree::
+ :maxdepth: 2
+
+ tutorials/index.rst
+
+Other stuff
+===========
+
+.. toctree::
+ :maxdepth: 1
+
+ pysideapi2.rst
+ pysideversion.rst
+
+Module Index
+============
+
+* :ref:`modindex`
+
diff --git a/sources/pyside2/doc/extras/PySide.QtCore.ClassInfo.rst b/sources/pyside2/doc/extras/PySide.QtCore.ClassInfo.rst
new file mode 100644
index 000000000..d2267be9c
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtCore.ClassInfo.rst
@@ -0,0 +1,23 @@
+.. module:: PySide2.QtCore
+.. _ClassInfo:
+
+ClassInfo
+*********
+
+This class is used to associates extra information to the class, which is available
+using QObject.metaObject(). Qt and PySide doesn't use this information.
+
+The extra information takes the form of a dictionary with key and value in a literal string.
+
+.. note:: This Class is a implementation of Q_CLASSINFO macro.
+
+
+Example
+-------
+
+::
+
+ @ClassInfo(Author='PySide Team', URL='http://www.pyside.org')
+ class MyObject(QObject):
+ ...
+
diff --git a/sources/pyside2/doc/extras/PySide.QtCore.Signal.rst b/sources/pyside2/doc/extras/PySide.QtCore.Signal.rst
new file mode 100644
index 000000000..16c640831
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtCore.Signal.rst
@@ -0,0 +1,39 @@
+.. module:: PySide2.QtCore
+.. _Signal:
+
+Signal
+******
+
+Synopsis
+--------
+
+Functions
+^^^^^^^^^
+
++---------------------------------------------------------------------------------------------+
+|def :meth:`connect<Signal.connect>` (receiver) |
++---------------------------------------------------------------------------------------------+
+|def :meth:`disconnect<Signal.disconnect>` (receiver) |
++---------------------------------------------------------------------------------------------+
+|def :meth:`emit<Signal.disconnect>` (\*args) |
++---------------------------------------------------------------------------------------------+
+
+Detailed Description
+--------------------
+
+ The :class:`~.Signal` class provides a way to declare and connect Qt signals in a pythonic way.
+
+ PySide adopt PyQt's new signal and slot syntax as-is. The PySide implementation is functionally compatible with the PyQt 4.5 one, with the exceptions listed bellow.
+
+.. method:: Signal.connect(receiver[, type=Qt.AutoConnection])
+
+ Create a connection between this signal and a `receiver`, the `receiver` can be a Python callable, a :class:`Slot` or a :class:`Signal`.
+
+.. method:: Signal.disconnect(receiver)
+
+ Disconnect this signal from a `receiver`, the `receiver` can be a Python callable, a :class:`Slot` or a :class:`Signal`.
+
+.. method:: Signal.emit(*args)
+
+ `args` is the arguments to pass to any connected slots, if any.
+
diff --git a/sources/pyside2/doc/extras/PySide.QtCore.Slot.rst b/sources/pyside2/doc/extras/PySide.QtCore.Slot.rst
new file mode 100644
index 000000000..6b93014cf
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtCore.Slot.rst
@@ -0,0 +1,39 @@
+.. module:: PySide2.QtCore
+.. _Slot:
+
+Slot
+****
+
+Detailed Description
+--------------------
+
+ PySide adopt PyQt's new signal and slot syntax as-is. The PySide
+ implementation is functionally compatible with the PyQt 4.5 one, with the
+ exceptions listed bellow.
+
+ PyQt's new signal and slot style utilizes method and decorator names
+ specific to their implementation. These will be generalized according to
+ the table below:
+
+ ======= ====================== =============
+ Module PyQt factory function PySide class
+ ======= ====================== =============
+ QtCore pyqtSignal Signal
+ QtCore pyqtSlot Slot
+ ======= ====================== =============
+
+Q_INVOKABLE
+-----------
+
+ PySide doesn't offer something identical to Q_INVOKABLE macro of Qt, the
+ reason is simple, PySide slots can have return values, so if you need to
+ create a invokable method that returns some value, declare it as a slot,
+ e.g.:
+
+ ::
+
+ class Foo(QObject):
+
+ @Slot(result=int, float)
+ def getFloatReturnInt(self, f):
+ return int(f)
diff --git a/sources/pyside2/doc/extras/PySide.QtCore.rst b/sources/pyside2/doc/extras/PySide.QtCore.rst
new file mode 100644
index 000000000..d3277a418
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtCore.rst
@@ -0,0 +1,5 @@
+All other Qt modules rely on this module. To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtCore
diff --git a/sources/pyside2/doc/extras/PySide.QtGui.rst b/sources/pyside2/doc/extras/PySide.QtGui.rst
new file mode 100644
index 000000000..e16329c38
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtGui.rst
@@ -0,0 +1,7 @@
+To include the definitions of modules classes, use the following directive:
+
+::
+
+ import PySide2.QtGui
+
+.. seealso:: :mod:`PySide2.QtCore`
diff --git a/sources/pyside2/doc/extras/PySide.QtHelp.rst b/sources/pyside2/doc/extras/PySide.QtHelp.rst
new file mode 100644
index 000000000..5e101a795
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtHelp.rst
@@ -0,0 +1,24 @@
+To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtHelp
+
+License Information
+-------------------
+
+The QtHelp module uses the CLucene indexing library to provide full-text searching capabilities for Qt Assistant and applications that use the features of QtHelp.
+
+Qt Commercial Edition licensees that wish to distribute applications that use these features of the QtHelp module need to be aware of their obligations under the GNU Lesser General Public License (LGPL).
+
+Developers using the Open Source Edition can choose to redistribute the module under the appropriate version of the GNU LGPL; version 2.1 for applications and libraries licensed under the GNU GPL version 2, or version 3 for applications and libraries licensed under the GNU GPL version 3.
+
+Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+
+Changes are Copyright (C) 2016 The Qt Company Ltd.
+
+This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
diff --git a/sources/pyside2/doc/extras/PySide.QtMultimedia.rst b/sources/pyside2/doc/extras/PySide.QtMultimedia.rst
new file mode 100644
index 000000000..5088db4d0
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtMultimedia.rst
@@ -0,0 +1,7 @@
+To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtMultimedia
+
+
diff --git a/sources/pyside2/doc/extras/PySide.QtNetwork.rst b/sources/pyside2/doc/extras/PySide.QtNetwork.rst
new file mode 100644
index 000000000..07303b157
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtNetwork.rst
@@ -0,0 +1,5 @@
+To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtNetwork
diff --git a/sources/pyside2/doc/extras/PySide.QtOpenGL.rst b/sources/pyside2/doc/extras/PySide.QtOpenGL.rst
new file mode 100644
index 000000000..38783d9fd
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtOpenGL.rst
@@ -0,0 +1,14 @@
+OpenGL is a standard API for rendering 3D graphics. OpenGL only deals with 3D rendering and provides little or no support for GUI programming issues. The user interface for an OpenGL application must be created with another toolkit, such as Motif on the X platform, Microsoft Foundation Classes (MFC) under Windows, or Qt on both platforms.
+
+.. note:: OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.
+
+The Qt OpenGL module makes it easy to use OpenGL in Qt applications. It provides an OpenGL widget class that can be used just like any other Qt widget, except that it opens an OpenGL display buffer where you can use the OpenGL API to render the contents.
+To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtOpenGL
+
+The Qt OpenGL module is implemented as a platform-independent wrapper around the platform-dependent GLX (version 1.3 or later), WGL, or AGL C APIs. Although the basic functionality provided is very similar to Mark Kilgard's GLUT library, applications using the Qt OpenGL module can take advantage of the whole Qt API for non-OpenGL-specific GUI functionality.
+
+The QtOpenGL module is available on Windows, X11 and Mac OS X. Qt for Embedded Linux and OpenGL supports OpenGL ES (OpenGL for Embedded Systems). \ No newline at end of file
diff --git a/sources/pyside2/doc/extras/PySide.QtScript.rst b/sources/pyside2/doc/extras/PySide.QtScript.rst
new file mode 100644
index 000000000..8ce7681ec
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtScript.rst
@@ -0,0 +1,21 @@
+The QtScript module only provides core scripting facilities; the QtScriptTools module provides additional Qt Script-related components that application developers may find useful.
+
+To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtScript
+
+License Information
+-------------------
+
+Qt Commercial Edition licensees that wish to distribute applications that use the QtScript 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.
+QtScript 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.
diff --git a/sources/pyside2/doc/extras/PySide.QtScriptTools.rst b/sources/pyside2/doc/extras/PySide.QtScriptTools.rst
new file mode 100644
index 000000000..a54ed914b
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtScriptTools.rst
@@ -0,0 +1,5 @@
+Applications that use the Qt Script Tools classes need to be configured to be built against the QtScriptTools module. To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtScriptTools
diff --git a/sources/pyside2/doc/extras/PySide.QtSql.rst b/sources/pyside2/doc/extras/PySide.QtSql.rst
new file mode 100644
index 000000000..fcdd6ba02
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtSql.rst
@@ -0,0 +1,5 @@
+To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtSql
diff --git a/sources/pyside2/doc/extras/PySide.QtSvg.rst b/sources/pyside2/doc/extras/PySide.QtSvg.rst
new file mode 100644
index 000000000..d77846550
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtSvg.rst
@@ -0,0 +1,16 @@
+To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtSvg
+
+License Information
+-------------------
+
+Some code for arc handling in this module is derived from code with the following license:
+
+Copyright 2002 USC/Information Sciences Institute
+
+Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Information Sciences Institute not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Information Sciences Institute makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
+
+INFORMATION SCIENCES INSTITUTE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL INFORMATION SCIENCES INSTITUTE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/sources/pyside2/doc/extras/PySide.QtTest.rst b/sources/pyside2/doc/extras/PySide.QtTest.rst
new file mode 100644
index 000000000..0b89a22d4
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtTest.rst
@@ -0,0 +1,7 @@
+To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtTest
+
+.. note:: All macros in the C++ version of QtTest were not binded in PySide, this module is useful only for GUI testing and benchmarking, for ordinary unit testing you should use the ``unittest`` Python module.
diff --git a/sources/pyside2/doc/extras/PySide.QtUiTools.rst b/sources/pyside2/doc/extras/PySide.QtUiTools.rst
new file mode 100644
index 000000000..553224527
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtUiTools.rst
@@ -0,0 +1,9 @@
+These forms are processed at run-time to produce dynamically-generated user interfaces. In order to generate a form at run-time, a resource file containing a UI file is needed.
+
+A form loader object, provided by the QUiLoader class, is used to construct the user interface. This user interface can be retrieved from any QIODevice; for example, a QFile object can be used to obtain a form stored in a project's resources. The :meth:`PySide2.QtUiTools.QUiLoader.load` function takes the user interface description contained in the file and constructs the form widget.
+
+To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide..QtUiTools
diff --git a/sources/pyside2/doc/extras/PySide.QtWebKit.rst b/sources/pyside2/doc/extras/PySide.QtWebKit.rst
new file mode 100644
index 000000000..58f9230a7
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtWebKit.rst
@@ -0,0 +1,94 @@
+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/extras/PySide.QtXml.rst b/sources/pyside2/doc/extras/PySide.QtXml.rst
new file mode 100644
index 000000000..4b48ef21e
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtXml.rst
@@ -0,0 +1,5 @@
+To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtXml
diff --git a/sources/pyside2/doc/extras/PySide.QtXmlPatterns.rst b/sources/pyside2/doc/extras/PySide.QtXmlPatterns.rst
new file mode 100644
index 000000000..3830efb4d
--- /dev/null
+++ b/sources/pyside2/doc/extras/PySide.QtXmlPatterns.rst
@@ -0,0 +1,35 @@
+To include the definitions of the module's classes, use the following directive:
+
+::
+
+ import PySide2.QtXmlPatterns
+
+Further Reading
+---------------
+
+General overviews of XQuery and XSchema can be found in the XQuery document.
+
+An introduction to the XQuery language can be found in A Short Path to XQuery.
+
+License Information
+-------------------
+
+The XML Schema implementation provided by this module contains the xml.xsd file (located in src/xmlpatterns/schema/schemas) which is licensed under the terms given below. This module is always built with XML Schema support enabled.
+
+W3C© SOFTWARE NOTICE AND LICENSE
+
+This license came from: http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license. By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
+
+Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
+
+* The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
+* Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
+* Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
+
+THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
diff --git a/sources/pyside2/doc/inheritance_diagram.py b/sources/pyside2/doc/inheritance_diagram.py
new file mode 100644
index 000000000..616b47057
--- /dev/null
+++ b/sources/pyside2/doc/inheritance_diagram.py
@@ -0,0 +1,374 @@
+# -*- coding: utf-8 -*-
+r"""
+ sphinx.ext.inheritance_diagram
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Defines a docutils directive for inserting inheritance diagrams.
+
+ Provide the directive with one or more classes or modules (separated
+ by whitespace). For modules, all of the classes in that module will
+ be used.
+
+ Example::
+
+ Given the following classes:
+
+ class A: pass
+ class B(A): pass
+ class C(A): pass
+ class D(B, C): pass
+ class E(B): pass
+
+ .. inheritance-diagram: D E
+
+ Produces a graph like the following:
+
+ A
+ / \
+ B C
+ / \ /
+ E D
+
+ The graph is inserted as a PNG+image map into HTML and a PDF in
+ LaTeX.
+
+ :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2010-2011 by the PySide team.
+ :license: BSD, see LICENSE for details.
+"""
+
+import os
+import re
+import sys
+import inspect
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5
+
+from docutils import nodes
+from docutils.parsers.rst import directives
+
+from sphinx.ext.graphviz import render_dot_html, render_dot_latex
+from sphinx.util.compat import Directive
+
+
+class_sig_re = re.compile(r'''^([\w.]*\.)? # module names
+ (\w+) \s* $ # class/final module name
+ ''', re.VERBOSE)
+
+
+class InheritanceException(Exception):
+ pass
+
+
+class InheritanceGraph(object):
+ """
+ Given a list of classes, determines the set of classes that they inherit
+ from all the way to the root "object", and then is able to generate a
+ graphviz dot graph from them.
+ """
+ def __init__(self, class_names, currmodule, show_builtins=False, parts=0):
+ """
+ *class_names* is a list of child classes to show bases from.
+
+ If *show_builtins* is True, then Python builtins will be shown
+ in the graph.
+ """
+ self.class_names = class_names
+ classes = self._import_classes(class_names, currmodule)
+ self.class_info = self._class_info(classes, show_builtins, parts)
+ if not self.class_info:
+ raise InheritanceException('No classes found for '
+ 'inheritance diagram')
+
+ def _import_class_or_module(self, name, currmodule):
+ """
+ Import a class using its fully-qualified *name*.
+ """
+ try:
+ path, base = class_sig_re.match(name).groups()
+ except (AttributeError, ValueError):
+ raise InheritanceException('Invalid class or module %r specified '
+ 'for inheritance diagram' % name)
+
+ fullname = (path or '') + base
+ path = (path and path.rstrip('.') or '')
+
+ # two possibilities: either it is a module, then import it
+ try:
+ __import__(fullname)
+ todoc = sys.modules[fullname]
+ except ImportError:
+ # else it is a class, then import the module
+ if not path:
+ if currmodule:
+ # try the current module
+ path = currmodule
+ else:
+ raise InheritanceException(
+ 'Could not import class %r specified for '
+ 'inheritance diagram' % base)
+ try:
+ __import__(path)
+ todoc = getattr(sys.modules[path], base)
+ except (ImportError, AttributeError):
+ raise InheritanceException(
+ 'Could not import class or module %r specified for '
+ 'inheritance diagram' % (path + '.' + base))
+
+ # If a class, just return it
+ if inspect.isclass(todoc):
+ return [todoc]
+ elif inspect.ismodule(todoc):
+ classes = []
+ for cls in todoc.__dict__.values():
+ if inspect.isclass(cls) and cls.__module__ == todoc.__name__:
+ classes.append(cls)
+ return classes
+ raise InheritanceException('%r specified for inheritance diagram is '
+ 'not a class or module' % name)
+
+ def _import_classes(self, class_names, currmodule):
+ """Import a list of classes."""
+ classes = []
+ for name in class_names:
+ classes.extend(self._import_class_or_module(name, currmodule))
+ return classes
+
+ def _class_info(self, classes, show_builtins, parts):
+ """Return name and bases for all classes that are ancestors of
+ *classes*.
+
+ *parts* gives the number of dotted name parts that is removed from the
+ displayed node names.
+ """
+ all_classes = {}
+ builtins = __builtins__.values()
+
+ def recurse(cls):
+ if not show_builtins and cls in builtins:
+ return
+
+ nodename = self.class_name(cls, parts)
+ fullname = self.class_name(cls, 0)
+
+ baselist = []
+ all_classes[cls] = (nodename, fullname, baselist)
+ for base in cls.__bases__:
+ if not show_builtins and base in builtins:
+ continue
+ if base.__name__ == "Object" and base.__module__ == "Shiboken":
+ continue
+ baselist.append(self.class_name(base, parts))
+ if base not in all_classes:
+ recurse(base)
+
+ for cls in classes:
+ recurse(cls)
+
+ return all_classes.values()
+
+ def class_name(self, cls, parts=0):
+ """Given a class object, return a fully-qualified name.
+
+ This works for things I've tested in matplotlib so far, but may not be
+ completely general.
+ """
+ module = cls.__module__
+ if module == '__builtin__':
+ fullname = cls.__name__
+ else:
+ fullname = '%s.%s' % (module, cls.__name__)
+ if parts == 0:
+ return fullname
+ name_parts = fullname.split('.')
+ return '.'.join(name_parts[-parts:])
+
+ def get_all_class_names(self):
+ """
+ Get all of the class names involved in the graph.
+ """
+ return [fullname for (_, fullname, _) in self.class_info]
+
+ # These are the default attrs for graphviz
+ default_graph_attrs = {
+ 'rankdir': 'LR',
+ 'size': '"8.0, 12.0"',
+ }
+ default_node_attrs = {
+ 'shape': 'box',
+ 'fontsize': 10,
+ 'height': 0.25,
+ 'fontname': 'Vera Sans, DejaVu Sans, Liberation Sans, '
+ 'Arial, Helvetica, sans',
+ 'style': '"setlinewidth(0.5)"',
+ }
+ default_edge_attrs = {
+ 'arrowsize': 0.5,
+ 'style': '"setlinewidth(0.5)"',
+ }
+
+ def _format_node_attrs(self, attrs):
+ return ','.join(['%s=%s' % x for x in attrs.items()])
+
+ def _format_graph_attrs(self, attrs):
+ return ''.join(['%s=%s;\n' % x for x in attrs.items()])
+
+ def generate_dot(self, name, urls={}, env=None,
+ graph_attrs={}, node_attrs={}, edge_attrs={}):
+ """
+ Generate a graphviz dot graph from the classes that
+ were passed in to __init__.
+
+ *name* is the name of the graph.
+
+ *urls* is a dictionary mapping class names to HTTP URLs.
+
+ *graph_attrs*, *node_attrs*, *edge_attrs* are dictionaries containing
+ key/value pairs to pass on as graphviz properties.
+ """
+ g_attrs = self.default_graph_attrs.copy()
+ n_attrs = self.default_node_attrs.copy()
+ e_attrs = self.default_edge_attrs.copy()
+ g_attrs.update(graph_attrs)
+ n_attrs.update(node_attrs)
+ e_attrs.update(edge_attrs)
+ if env:
+ g_attrs.update(env.config.inheritance_graph_attrs)
+ n_attrs.update(env.config.inheritance_node_attrs)
+ e_attrs.update(env.config.inheritance_edge_attrs)
+
+ res = []
+ res.append('digraph %s {\n' % name)
+ res.append(self._format_graph_attrs(g_attrs))
+
+ for name, fullname, bases in self.class_info:
+ # Write the node
+ this_node_attrs = n_attrs.copy()
+ url = urls.get(fullname)
+ if url is not None:
+ this_node_attrs['URL'] = '"%s"' % url
+ res.append(' "%s" [%s];\n' %
+ (name, self._format_node_attrs(this_node_attrs)))
+
+ # Write the edges
+ for base_name in bases:
+ res.append(' "%s" -> "%s" [%s];\n' %
+ (base_name, name,
+ self._format_node_attrs(e_attrs)))
+ res.append('}\n')
+ return ''.join(res)
+
+
+class inheritance_diagram(nodes.General, nodes.Element):
+ """
+ A docutils node to use as a placeholder for the inheritance diagram.
+ """
+ pass
+
+
+class InheritanceDiagram(Directive):
+ """
+ Run when the inheritance_diagram directive is first encountered.
+ """
+ has_content = False
+ required_arguments = 1
+ optional_arguments = 0
+ final_argument_whitespace = True
+ option_spec = {
+ 'parts': directives.nonnegative_int,
+ }
+
+ def run(self):
+ node = inheritance_diagram()
+ node.document = self.state.document
+ env = self.state.document.settings.env
+ class_names = self.arguments[0].split()
+ class_role = env.get_domain('py').role('class')
+ # Store the original content for use as a hash
+ node['parts'] = self.options.get('parts', 0)
+ node['content'] = ', '.join(class_names)
+
+ # Create a graph starting with the list of classes
+ try:
+ graph = InheritanceGraph(
+ class_names, env.temp_data.get('py:module'),
+ parts=node['parts'])
+ except InheritanceException, err:
+ return [node.document.reporter.warning(err.args[0],
+ line=self.lineno)]
+
+ # Create xref nodes for each target of the graph's image map and
+ # add them to the doc tree so that Sphinx can resolve the
+ # references to real URLs later. These nodes will eventually be
+ # removed from the doctree after we're done with them.
+ for name in graph.get_all_class_names():
+ refnodes, x = class_role(
+ 'class', ':class:`%s`' % name, name, 0, self.state)
+ node.extend(refnodes)
+ # Store the graph object so we can use it to generate the
+ # dot file later
+ node['graph'] = graph
+ return [node]
+
+
+def get_graph_hash(node):
+ return md5(node['content'] + str(node['parts'])).hexdigest()[-10:]
+
+
+def html_visit_inheritance_diagram(self, node):
+ """
+ Output the graph for HTML. This will insert a PNG with clickable
+ image map.
+ """
+ graph = node['graph']
+
+ graph_hash = get_graph_hash(node)
+ name = 'inheritance%s' % graph_hash
+
+ # Create a mapping from fully-qualified class names to URLs.
+ urls = {}
+ for child in node:
+ if child.get('refuri') is not None:
+ urls[child['reftitle']] = child.get('refuri')
+ elif child.get('refid') is not None:
+ urls[child['reftitle']] = '#' + child.get('refid')
+
+ dotcode = graph.generate_dot(name, urls, env=self.builder.env)
+ render_dot_html(self, node, dotcode, [], 'inheritance', 'inheritance',
+ alt='Inheritance diagram of ' + node['content'])
+ raise nodes.SkipNode
+
+
+def latex_visit_inheritance_diagram(self, node):
+ """
+ Output the graph for LaTeX. This will insert a PDF.
+ """
+ graph = node['graph']
+
+ graph_hash = get_graph_hash(node)
+ name = 'inheritance%s' % graph_hash
+
+ dotcode = graph.generate_dot(name, env=self.builder.env,
+ graph_attrs={'size': '"6.0,6.0"'})
+ render_dot_latex(self, node, dotcode, [], 'inheritance')
+ raise nodes.SkipNode
+
+
+def skip(self, node):
+ raise nodes.SkipNode
+
+
+def setup(app):
+ app.setup_extension('sphinx.ext.graphviz')
+ app.add_node(
+ inheritance_diagram,
+ latex=(latex_visit_inheritance_diagram, None),
+ html=(html_visit_inheritance_diagram, None),
+ text=(skip, None),
+ man=(skip, None))
+ app.add_directive('inheritance-diagram', InheritanceDiagram)
+ app.add_config_value('inheritance_graph_attrs', {}, False),
+ app.add_config_value('inheritance_node_attrs', {}, False),
+ app.add_config_value('inheritance_edge_attrs', {}, False),
diff --git a/sources/pyside2/doc/modules.rst b/sources/pyside2/doc/modules.rst
new file mode 100644
index 000000000..0faa629ad
--- /dev/null
+++ b/sources/pyside2/doc/modules.rst
@@ -0,0 +1,21 @@
+PySide modules
+**************
+
+Qt is splitted in several modules.
+
+.. toctree::
+ :maxdepth: 1
+
+ PySide/QtCore/index.rst
+ PySide/QtGui/index.rst
+ PySide/QtHelp/index.rst
+ PySide/QtMultimedia/index.rst
+ PySide/QtNetwork/index.rst
+ PySide/QtOpenGL/index.rst
+ PySide/QtScript/index.rst
+ PySide/QtScriptTools/index.rst
+ PySide/QtSql/index.rst
+ PySide/QtSvg/index.rst
+ PySide/QtUiTools/index.rst
+ PySide/QtXml/index.rst
+ PySide/QtWebKit/index.rst
diff --git a/sources/pyside2/doc/pyhtml2devhelp.py b/sources/pyside2/doc/pyhtml2devhelp.py
new file mode 100644
index 000000000..29a37bfca
--- /dev/null
+++ b/sources/pyside2/doc/pyhtml2devhelp.py
@@ -0,0 +1,256 @@
+#! /usr/bin/python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Copyright (C) 2009 Matthias Klose <doko@debian.org>
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the tools applications of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+"""
+ This script is based on Python2.6 Ubuntu package script
+"""
+
+import formatter, htmllib
+import os, sys, re
+
+class PyHTMLParser(htmllib.HTMLParser):
+ pages_to_include = set(('index.html', 'PySide/QtHelp/index.html', 'PySide/QtSvg/index.html',
+ 'PySide/QtGui/index.html', 'PySide/QtNetwork/index.html', 'PySide/QtWebKit/index.html',
+ 'PySide/QtUiTools/index.html', 'PySide/QtXml/index.html', 'PySide/QtCore/index.html',
+ 'PySide/QtScriptTools/index.html', 'PySide/QtOpenGL/index.html', 'PySide/QtScript/index.html',
+ 'PySide/QtSql/index.html', 'howto-build/index.html'))
+
+ def __init__(self, formatter, basedir, fn, indent, parents=set()):
+ htmllib.HTMLParser.__init__(self, formatter)
+ self.basedir = basedir
+ self.dir, self.fn = os.path.split(fn)
+ self.data = ''
+ self.parents = parents
+ self.link = {}
+ self.indent = indent
+ self.last_indent = indent - 1
+ self.sub_indent = 0
+ self.sub_count = 0
+ self.next_link = False
+
+ def process_link(self):
+ new_href = os.path.join(self.dir, self.link['href'])
+ text = self.link['text']
+ indent = self.indent + self.sub_indent
+ if self.last_indent == indent:
+ print '%s</sub>' % (' ' * self.last_indent)
+ self.sub_count -= 1
+ print '%s<sub link="%s" name="%s">' % (' ' * indent, new_href, text)
+ self.sub_count += 1
+ self.last_indent = self.indent + self.sub_indent
+
+ def start_li(self, attrs):
+ self.sub_indent += 1
+ self.next_link = True
+
+ def end_li(self):
+ indent = self.indent + self.sub_indent
+ if self.sub_count > 0:
+ print '%s</sub>' % (' ' * self.last_indent)
+ self.sub_count -= 1
+ self.last_indent -= 1
+ self.sub_indent -= 1
+
+ def start_a(self, attrs):
+ self.link = {}
+ for attr in attrs:
+ self.link[attr[0]] = attr[1]
+ self.data = ''
+
+ def end_a(self):
+ process = False
+ text = self.data.replace('\t', '').replace('\n', ' ').replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
+ self.link['text'] = text
+ # handle a tag without href attribute
+ try:
+ href = self.link['href']
+ except KeyError:
+ return
+
+ abs_href = os.path.join(self.basedir, href)
+ if abs_href in self.parents:
+ return
+ if href.startswith('..') or href.startswith('http:') \
+ or href.startswith('mailto:') or href.startswith('news:'):
+ return
+ if href in ('', 'about.html', 'modindex.html', 'genindex.html', 'glossary.html',
+ 'search.html', 'contents.html', 'download.html', 'bugs.html',
+ 'license.html', 'copyright.html'):
+ return
+
+ if self.link.has_key('class'):
+ if self.link['class'] in ('biglink'):
+ process = True
+ if self.link['class'] in ('reference external'):
+ if self.next_link:
+ process = True
+ next_link = False
+
+ if process == True:
+ self.process_link()
+ if href in self.pages_to_include:
+ self.parse_file(os.path.join(self.dir, href))
+
+ def finish(self):
+ if self.sub_count > 0:
+ print '%s</sub>' % (' ' * self.last_indent)
+
+ def handle_data(self, data):
+ self.data += data
+
+ def parse_file(self, href):
+ # TODO basedir bestimmen
+ parent = os.path.join(self.basedir, self.fn)
+ self.parents.add(parent)
+ parser = PyHTMLParser(formatter.NullFormatter(),
+ self.basedir, href, self.indent + 1,
+ self.parents)
+ text = file(self.basedir + '/' + href).read()
+ parser.feed(text)
+ parser.finish()
+ parser.close()
+ if parent in self.parents:
+ self.parents.remove(parent)
+
+class PyIdxHTMLParser(htmllib.HTMLParser):
+ def __init__(self, formatter, basedir, fn, indent):
+ htmllib.HTMLParser.__init__(self, formatter)
+ self.basedir = basedir
+ self.dir, self.fn = os.path.split(fn)
+ self.data = ''
+ self.link = {}
+ self.indent = indent
+ self.active = False
+ self.indented = False
+ self.nolink = False
+ self.header = ''
+ self.last_letter = 'Z'
+ self.last_text = ''
+
+ def process_link(self):
+ new_href = os.path.join(self.dir, self.link['href'])
+ text = self.link['text']
+ if not self.active:
+ return
+ if text.startswith('['):
+ return
+ if self.link.get('rel', None) in ('prev', 'parent', 'next', 'contents', 'index'):
+ return
+ if self.indented:
+ text = self.last_text + ' ' + text
+ else:
+ # Save it in case we need it again
+ self.last_text = re.sub(' \([\w\-\.\s]+\)', '', text)
+ indent = self.indent
+ print '%s<function link="%s" name="%s"/>' % (' ' * indent, new_href, text)
+
+ def start_dl(self, attrs):
+ if self.last_text:
+ # Looks like we found the second part to a command
+ self.indented = True
+
+ def end_dl(self):
+ self.indented = False
+
+ def start_dt(self, attrs):
+ self.data = ''
+ self.nolink = True
+
+ def end_dt(self):
+ if not self.active:
+ return
+ if self.nolink == True:
+ # Looks like we found the first part to a command
+ self.last_text = re.sub(' \([\w\-\.\s]+\)', '', self.data)
+ self.nolink = False
+
+ def start_h2(self, attrs):
+ for k, v in attrs:
+ if k == 'id':
+ self.header = v
+ if v == '_':
+ self.active = True
+
+ def start_td(self, attrs):
+ self.indented = False
+ self.last_text = ''
+
+ def start_table(self, attrs):
+ pass
+
+ def end_table(self):
+ if self.header == self.last_letter:
+ self.active = False
+
+ def start_a(self, attrs):
+ self.nolink = False
+ self.link = {}
+ for attr in attrs:
+ self.link[attr[0]] = attr[1]
+ self.data = ''
+
+ def end_a(self):
+ text = self.data.replace('\t', '').replace('\n', ' ').replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
+ self.link['text'] = text
+ # handle a tag without href attribute
+ try:
+ href = self.link['href']
+ except KeyError:
+ return
+ self.process_link()
+
+ def handle_data(self, data):
+ self.data += data
+
+def main():
+ base = sys.argv[1]
+ fn = sys.argv[2]
+
+ parser = PyHTMLParser(formatter.NullFormatter(), base, fn, indent=0)
+ print '<?xml version="1.0" encoding="iso-8859-1"?>'
+ print '<book title="PySide %s Documentation" name="PySide" version="%s" link="index.html">' % (sys.argv[3], sys.argv[3])
+ print '<chapters>'
+ parser.parse_file(fn)
+ print '</chapters>'
+
+ print '<functions>'
+
+ fn = 'genindex.html'
+ parser = PyIdxHTMLParser(formatter.NullFormatter(), base, fn, indent=1)
+ text = file(base + '/' + fn).read()
+ parser.feed(text)
+ parser.close()
+
+ print '</functions>'
+ print '</book>'
+
+main()
+
diff --git a/sources/pyside2/doc/pyside.qdocconf.in b/sources/pyside2/doc/pyside.qdocconf.in
new file mode 100644
index 000000000..9672d6103
--- /dev/null
+++ b/sources/pyside2/doc/pyside.qdocconf.in
@@ -0,0 +1,269 @@
+######################## compat.qdocconf
+alias.i = e
+alias.include = input
+
+macro.0 = "\\\\0"
+macro.b = "\\\\b"
+macro.n = "\\\\n"
+macro.r = "\\\\r"
+macro.i = "\\o"
+macro.i11 = "\\o{1,1}"
+macro.i12 = "\\o{1,2}"
+macro.i13 = "\\o{1,3}"
+macro.i14 = "\\o{1,4}"
+macro.i15 = "\\o{1,5}"
+macro.i16 = "\\o{1,6}"
+macro.i17 = "\\o{1,7}"
+macro.i18 = "\\o{1,8}"
+macro.i19 = "\\o{1,9}"
+macro.i21 = "\\o{2,1}"
+macro.i31 = "\\o{3,1}"
+macro.i41 = "\\o{4,1}"
+macro.i51 = "\\o{5,1}"
+macro.i61 = "\\o{6,1}"
+macro.i71 = "\\o{7,1}"
+macro.i81 = "\\o{8,1}"
+macro.i91 = "\\o{9,1}"
+macro.img = "\\image"
+macro.endquote = "\\endquotation"
+macro.relatesto = "\\relates"
+
+spurious = "Missing comma in .*" \
+ "Missing pattern .*"
+
+######################## macros.qdocconf
+macro.aacute.HTML = "&aacute;"
+macro.Aring.HTML = "&Aring;"
+macro.aring.HTML = "&aring;"
+macro.Auml.HTML = "&Auml;"
+macro.author = "\\bold{Author:}"
+macro.br.HTML = "<br />"
+macro.BR.HTML = "<br />"
+macro.copyright.HTML = "&copy;"
+macro.eacute.HTML = "&eacute;"
+macro.gui = "\\bold"
+macro.hr.HTML = "<hr />"
+macro.iacute.HTML = "&iacute;"
+macro.key = "\\bold"
+macro.menu = "\\bold"
+macro.note = "\\bold{Note:}"
+macro.oslash.HTML = "&oslash;"
+macro.ouml.HTML = "&ouml;"
+macro.QA = "\\e{Qt Assistant}"
+macro.QD = "\\e{Qt Designer}"
+macro.QL = "\\e{Qt Linguist}"
+macro.QQV = "\\e{Qt QML Viewer}"
+macro.qmlbasictype = "\\e"
+macro.param = "\\e"
+macro.raisedaster.HTML = "<sup>*</sup>"
+macro.rarrow.HTML = "&rarr;"
+macro.reg.HTML = "<sup>&reg;</sup>"
+macro.return = "Returns"
+macro.starslash = "\\c{*/}"
+macro.begincomment = "\\c{/*}"
+macro.endcomment = "\\c{*/}"
+macro.uuml.HTML = "&uuml;"
+macro.mdash.HTML = "&mdash;"
+
+macro.beginfloatleft.HTML = "<div style=\"float: left; margin-right: 2em\">"
+macro.beginfloatright.HTML = "<div style=\"float: right; margin-left: 2em\">"
+macro.endfloat.HTML = "</div>"
+macro.clearfloat.HTML = "<br style=\"clear: both\" />"
+
+######################## qt-cpp-ignore.qdocconf
+Cpp.ignoretokens = QAXFACTORY_EXPORT \
+ QDESIGNER_COMPONENTS_LIBRARY \
+ QDESIGNER_EXTENSION_LIBRARY \
+ QDESIGNER_SDK_LIBRARY \
+ QDESIGNER_SHARED_LIBRARY \
+ QDESIGNER_UILIB_LIBRARY \
+ QM_EXPORT_CANVAS \
+ QM_EXPORT_DNS \
+ QM_EXPORT_DOM \
+ QM_EXPORT_FTP \
+ QM_EXPORT_HTTP \
+ QM_EXPORT_ICONVIEW \
+ QM_EXPORT_NETWORK \
+ QM_EXPORT_OPENGL \
+ QM_EXPORT_OPENVG \
+ QM_EXPORT_SQL \
+ QM_EXPORT_TABLE \
+ QM_EXPORT_WORKSPACE \
+ QM_EXPORT_XML \
+ QT_ASCII_CAST_WARN \
+ QT_ASCII_CAST_WARN_CONSTRUCTOR \
+ QT_BEGIN_HEADER \
+ QT_DESIGNER_STATIC \
+ QT_END_HEADER \
+ QT_FASTCALL \
+ QT_WIDGET_PLUGIN_EXPORT \
+ Q_COMPAT_EXPORT \
+ Q_CORE_EXPORT \
+ Q_CORE_EXPORT_INLINE \
+ Q_EXPLICIT \
+ Q_EXPORT \
+ Q_EXPORT_CODECS_CN \
+ Q_EXPORT_CODECS_JP \
+ Q_EXPORT_CODECS_KR \
+ Q_EXPORT_PLUGIN \
+ Q_GFX_INLINE \
+ Q_AUTOTEST_EXPORT \
+ Q_GUI_EXPORT \
+ Q_GUI_EXPORT_INLINE \
+ Q_GUI_EXPORT_STYLE_CDE \
+ Q_GUI_EXPORT_STYLE_COMPACT \
+ Q_GUI_EXPORT_STYLE_MAC \
+ Q_GUI_EXPORT_STYLE_MOTIF \
+ Q_GUI_EXPORT_STYLE_MOTIFPLUS \
+ Q_GUI_EXPORT_STYLE_PLATINUM \
+ Q_GUI_EXPORT_STYLE_POCKETPC \
+ Q_GUI_EXPORT_STYLE_SGI \
+ Q_GUI_EXPORT_STYLE_WINDOWS \
+ Q_GUI_EXPORT_STYLE_WINDOWSXP \
+ QHELP_EXPORT \
+ Q_INLINE_TEMPLATE \
+ Q_INTERNAL_WIN_NO_THROW \
+ Q_NETWORK_EXPORT \
+ Q_OPENGL_EXPORT \
+ Q_OPENVG_EXPORT \
+ Q_OUTOFLINE_TEMPLATE \
+ Q_SQL_EXPORT \
+ Q_SVG_EXPORT \
+ Q_SCRIPT_EXPORT \
+ Q_SCRIPTTOOLS_EXPORT \
+ Q_TESTLIB_EXPORT \
+ Q_TYPENAME \
+ Q_XML_EXPORT \
+ Q_XMLSTREAM_EXPORT \
+ Q_XMLPATTERNS_EXPORT \
+ QDBUS_EXPORT \
+ QT_BEGIN_NAMESPACE \
+ QT_BEGIN_INCLUDE_NAMESPACE \
+ QT_END_NAMESPACE \
+ QT_END_INCLUDE_NAMESPACE \
+ Q_DECLARATIVE_EXPORT \
+ Q_GADGET \
+ QWEBKIT_EXPORT
+Cpp.ignoredirectives = Q_DECLARE_HANDLE \
+ Q_DECLARE_INTERFACE \
+ Q_DECLARE_METATYPE \
+ Q_DECLARE_OPERATORS_FOR_FLAGS \
+ Q_DECLARE_PRIVATE \
+ Q_DECLARE_PUBLIC \
+ Q_DECLARE_SHARED \
+ Q_DECLARE_TR_FUNCTIONS \
+ Q_DECLARE_TYPEINFO \
+ Q_DISABLE_COPY \
+ QT_FORWARD_DECLARE_CLASS \
+ Q_DUMMY_COMPARISON_OPERATOR \
+ Q_ENUMS \
+ Q_FLAGS \
+ Q_INTERFACES \
+ __attribute__ \
+ K_DECLARE_PRIVATE \
+ Q_PRIVATE_PROPERTY \
+ Q_DECLARE_PRIVATE_D \
+ Q_CLASSINFO
+
+######################## qt-defines.qdocconf
+defines = Q_QDOC \
+ QT_.*_SUPPORT \
+ QT_.*_LIB \
+ QT_COMPAT \
+ QT_KEYPAD_NAVIGATION \
+ QT3_SUPPORT \
+ Q_WS_.* \
+ Q_OS_.* \
+ Q_BYTE_ORDER \
+ QT_DEPRECATED \
+ Q_NO_USING_KEYWORD \
+ __cplusplus
+
+versionsym = QT_VERSION_STR
+
+codeindent = 1
+
+######################## qt.qdocconf
+
+project = Qt
+versionsym =
+version = @PYSIDE_QT_VERSION@
+description = Qt Reference Documentation
+url = http://www.pyside.org/docs/pyside-@PYSIDE_QT_VERSION@
+
+language = Cpp
+
+headerdirs = @QT_SRC_DIR@/src \
+ @QT_SRC_DIR@/extensions/activeqt \
+ @QT_SRC_DIR@/tools/assistant/lib \
+ @QT_SRC_DIR@/tools/assistant/compat/lib \
+ @QT_SRC_DIR@/tools/designer/src/uitools \
+ @QT_SRC_DIR@/tools/designer/src/lib/extension \
+ @QT_SRC_DIR@/tools/designer/src/lib/sdk \
+ @QT_SRC_DIR@/tools/designer/src/lib/uilib \
+ @QT_SRC_DIR@/tools/qtestlib/src \
+ @QT_SRC_DIR@/tools/qdbus/src \
+ @pyside_SOURCE_DIR@
+sourcedirs = @QT_SRC_DIR@/src \
+ @QT_SRC_DIR@/doc/src \
+ @QT_SRC_DIR@/extensions/activeqt \
+ @QT_SRC_DIR@/tools/assistant/lib \
+ @QT_SRC_DIR@/tools/assistant/compat/lib \
+ @QT_SRC_DIR@/tools/designer/src/uitools \
+ @QT_SRC_DIR@/tools/designer/src/lib/extension \
+ @QT_SRC_DIR@/tools/designer/src/lib/sdk \
+ @QT_SRC_DIR@/tools/designer/src/lib/uilib \
+ @QT_SRC_DIR@/tools/qtestlib/src \
+ @QT_SRC_DIR@/tools/qdbus \
+ @pyside_SOURCE_DIR@
+
+excludedirs = @QT_SRC_DIR@/src/3rdparty/clucene \
+ @QT_SRC_DIR@/src/3rdparty/des \
+ @QT_SRC_DIR@/src/3rdparty/freetype \
+ @QT_SRC_DIR@/src/3rdparty/harfbuzz \
+ @QT_SRC_DIR@/src/3rdparty/kdebase \
+ @QT_SRC_DIR@/src/3rdparty/libjpeg \
+ @QT_SRC_DIR@/src/3rdparty/libmng \
+ @QT_SRC_DIR@/src/3rdparty/libpng \
+ @QT_SRC_DIR@/src/3rdparty/libtiff \
+ @QT_SRC_DIR@/src/3rdparty/md4 \
+ @QT_SRC_DIR@/src/3rdparty/md5 \
+ @QT_SRC_DIR@/src/3rdparty/patches \
+ @QT_SRC_DIR@/src/3rdparty/sha1 \
+ @QT_SRC_DIR@/src/3rdparty/sqlite \
+ @QT_SRC_DIR@/src/3rdparty/webkit/JavaScriptCore \
+ @QT_SRC_DIR@/src/3rdparty/webkit/WebCore \
+ @QT_SRC_DIR@/src/3rdparty/wintab \
+ @QT_SRC_DIR@/src/3rdparty/zlib \
+ @QT_SRC_DIR@/doc/src/snippets \
+ @QT_SRC_DIR@/doc/src/ja_JP \
+ @QT_SRC_DIR@/doc/src/zh_CN
+
+sources.fileextensions = "*.cpp *.qdoc *.mm"
+examples.fileextensions = "*.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp"
+examples.imageextensions = "*.png"
+
+tagfile = @QT_SRC_DIR@/doc/html/qt.tags
+base = file:@QT_SRC_DIR@/doc/html
+
+HTML.generatemacrefs = "true"
+
+######################## pyside.qdocconf
+quotinginformation = true
+exampledirs = @QT_SRC_DIR@/doc/src \
+ @QT_SRC_DIR@/examples \
+ @QT_SRC_DIR@/examples/tutorials \
+ @QT_SRC_DIR@ \
+ @QT_SRC_DIR@/qmake/examples \
+ @QT_SRC_DIR@/src/3rdparty/webkit/WebKit/qt/docs
+
+imagedirs = @QT_SRC_DIR@/doc/src/images \
+ @QT_SRC_DIR@/examples \
+ @QT_SRC_DIR@/doc/src/declarative/pics \
+ @QT_SRC_DIR@/doc/src/template/image
+
+outputdir = @DOC_DATA_DIR@
+outputformats = WebXML
+
+generateindex = false
+url = .
diff --git a/sources/pyside2/doc/pysideapi2.rst b/sources/pyside2/doc/pysideapi2.rst
new file mode 100644
index 000000000..e86be05c9
--- /dev/null
+++ b/sources/pyside2/doc/pysideapi2.rst
@@ -0,0 +1,91 @@
+
+.. _pysideapi2:
+
+PySide API 2
+************
+
+Since the beginning one of the PySide goals was to be API compatible with PyQt4,
+but with some (documented) exceptions. For example, PySide will not export to
+Python components marked as deprecated on C++ Qt. All the modifications follow
+the `PSEP101 <http://www.pyside.org/docs/pseps/psep-0101.html>`_ as its guideline.
+
+The release 4.7 of PyQt4 came with improvements on the pythonic front, being
+the extinction of QString a good example. PySide followed this change, except in
+one point: while PyQt4 has conserved the old behavior as optional, PySide
+bindings fully adopted the new API - completely removing QString. No turning
+back. Thus remember to update your source code to the new API, this will ensure
+your code will run on both bindings.
+
+
+__hash__() function return value
+================================
+
+The hash value returned for the classes :class:`PySide2.QtCore.QDate`, :class:`PySide2.QtCore.QDateTime`, :class:`PySide2.QtCore.QTime`, :class:`PySide2.QtCore.QUrl` will be
+based on their string representations, thus objects with the same value will
+produce the same hash.
+
+
+QString
+=======
+
+Methods that change QString arguments
+-------------------------------------
+
+Methods and functions that change the contents of a QString argument were
+modified to receive an immutable Python unicode (or str) and return another
+Python unicode/str as the modified string.
+
+The following methods had their return types modified this way:
+
+**Classes:** QAbstractSpinBox, QDateTimeEdit, QDoubleSpinBox, QSpinBox, QValidator
+
+- *fixup(string)*: string
+- *validate(string, int)*: [QValidator.State, string, int]
+
+
+**Classes:** QDoubleValidator, QIntValidator, QRegExpValidator
+
+- *validate(string, int)*: [QValidator.State, string, int]
+
+**Class:** QClipboard
+
+- *text(string, QClipboard.Mode mode=QClipboard.Clipboard)*: [string, string]
+
+
+**Class:** QFileDialog
+
+Instead of *getOpenFileNameAndFilter()*, *getOpenFileNamesAndFilter()* and *getSaveFileNameAndFilter()* like PyQt4 does,
+PySide has modified the original methods to return a tuple.
+
+- *getOpenFileName(QWidget parent=None, str caption=None, str dir=None, str filter=None, QFileDialog.Options options=0)*: [string, filter]
+- *getOpenFileNames(QWidget parent=None, str caption=None, str dir=None, str filter=None, QFileDialog.Options options=0)*: [list(string), filter]
+- *getSaveFileName(QWidget parent=None, str caption=None, str dir=None, str filter=None, QFileDialog.Options options=0)*: [string, filter]
+
+**Class:** QWebPage
+
+- *javaScriptPrompt(QWebFrame, string, string)*: [bool, string]
+
+Other QString related changes
+-----------------------------
+
+**Classes:** QFontMetrics and QFontMetricsF
+
+They had two new methods added. Both take a string of one character and convert to a QChar (to call the C++ counterpart):
+
+- widthChar(string)
+- boundingRectChar(string)
+
+
+QTextStream
+===========
+
+Inside this class some renames were applied to avoid clashes with native Python functions. They are: *bin_()*, *hex_()* and *oct_()*.
+The only modification was the addition of '_' character.
+
+
+QVariant
+========
+
+As QVariant was removed, any function expecting it can receive any Python object (None is an invalid QVariant). The same rule is valid when returning something: the returned QVariant will be converted to the its original Python object type.
+
+When a method expects a *QVariant::Type* the programmer can use a string (the type name) or the type itself.
diff --git a/sources/pyside2/doc/pysideinclude.py b/sources/pyside2/doc/pysideinclude.py
new file mode 100644
index 000000000..89024f0c0
--- /dev/null
+++ b/sources/pyside2/doc/pysideinclude.py
@@ -0,0 +1,147 @@
+#
+# This code is a modified version of the code found in sphinx distribution
+# the same license of sphinx distribution applies to this file as well.
+#
+
+import os
+import sys
+import codecs
+from os import path
+
+from docutils import nodes
+from docutils.parsers.rst import Directive, directives
+
+from sphinx import addnodes
+from sphinx.util import parselinenos
+
+class PySideInclude(Directive):
+ """
+ Like ``.. include:: :literal:``, but only warns if the include file is
+ not found, and does not raise errors. Also has several options for
+ selecting what to include.
+ """
+
+ has_content = False
+ required_arguments = 1
+ optional_arguments = 0
+ final_argument_whitespace = False
+ option_spec = {
+ 'linenos': directives.flag,
+ 'tab-width': int,
+ 'language': directives.unchanged_required,
+ 'encoding': directives.encoding,
+ 'pyobject': directives.unchanged_required,
+ 'lines': directives.unchanged_required,
+ 'start-after': directives.unchanged_required,
+ 'end-before': directives.unchanged_required,
+ 'prepend': directives.unchanged_required,
+ 'append': directives.unchanged_required,
+ 'snippet': directives.unchanged_required,
+ }
+
+ def run(self):
+ document = self.state.document
+ filename = self.arguments[0]
+ if not document.settings.file_insertion_enabled:
+ return [document.reporter.warning('File insertion disabled',
+ line=self.lineno)]
+ env = document.settings.env
+ if filename.startswith('/') or filename.startswith(os.sep):
+ rel_fn = filename[1:]
+ else:
+ docdir = path.dirname(env.doc2path(env.docname, base=None))
+ rel_fn = path.join(docdir, filename)
+ try:
+ fn = path.join(env.srcdir, rel_fn)
+ except UnicodeDecodeError:
+ # the source directory is a bytestring with non-ASCII characters;
+ # let's try to encode the rel_fn in the file system encoding
+ rel_fn = rel_fn.encode(sys.getfilesystemencoding())
+ fn = path.join(env.srcdir, rel_fn)
+
+ if 'pyobject' in self.options and 'lines' in self.options:
+ return [document.reporter.warning(
+ 'Cannot use both "pyobject" and "lines" options',
+ line=self.lineno)]
+
+ encoding = self.options.get('encoding', env.config.source_encoding)
+ codec_info = codecs.lookup(encoding)
+ try:
+ f = codecs.StreamReaderWriter(open(fn, 'U'),
+ codec_info[2], codec_info[3], 'strict')
+ lines = f.readlines()
+ f.close()
+ except (IOError, OSError):
+ return [document.reporter.warning(
+ 'Include file %r not found or reading it failed' % filename,
+ line=self.lineno)]
+ except UnicodeError:
+ return [document.reporter.warning(
+ 'Encoding %r used for reading included file %r seems to '
+ 'be wrong, try giving an :encoding: option' %
+ (encoding, filename))]
+
+ objectname = self.options.get('pyobject')
+ if objectname is not None:
+ from sphinx.pycode import ModuleAnalyzer
+ analyzer = ModuleAnalyzer.for_file(fn, '')
+ tags = analyzer.find_tags()
+ if objectname not in tags:
+ return [document.reporter.warning(
+ 'Object named %r not found in include file %r' %
+ (objectname, filename), line=self.lineno)]
+ else:
+ lines = lines[tags[objectname][1]-1 : tags[objectname][2]-1]
+
+ linespec = self.options.get('lines')
+ if linespec is not None:
+ try:
+ linelist = parselinenos(linespec, len(lines))
+ except ValueError, err:
+ return [document.reporter.warning(str(err), line=self.lineno)]
+ lines = [lines[i] for i in linelist]
+
+ startafter = self.options.get('start-after')
+ endbefore = self.options.get('end-before')
+ prepend = self.options.get('prepend')
+ append = self.options.get('append')
+ snippet = self.options.get('snippet')
+
+ if snippet:
+ startafter = "//![%s]" % snippet
+ endbefore = "//![%s]" % snippet
+
+ if startafter is not None or endbefore is not None:
+ use = not startafter
+ res = []
+ for line in lines:
+ if not use and startafter and startafter in line:
+ use = True
+ elif use and endbefore and endbefore in line:
+ use = False
+ break
+ elif use:
+ if not line.startswith("//!"):
+ res.append(line)
+ lines = res
+
+ if prepend:
+ lines.insert(0, prepend + '\n')
+ if append:
+ lines.append(append + '\n')
+
+ text = ''.join(lines)
+ if self.options.get('tab-width'):
+ text = text.expandtabs(self.options['tab-width'])
+ retnode = nodes.literal_block(text, text, source=fn)
+ retnode.line = 1
+ retnode.attributes['line_number'] = self.lineno
+ if self.options.get('language', ''):
+ retnode['language'] = self.options['language']
+ if 'linenos' in self.options:
+ retnode['linenos'] = True
+ document.settings.env.note_dependency(rel_fn)
+ return [retnode]
+
+def setup(app):
+ app.add_directive('pysideinclude', PySideInclude)
diff --git a/sources/pyside2/doc/pysideversion.rst b/sources/pyside2/doc/pysideversion.rst
new file mode 100644
index 000000000..3bcebe0da
--- /dev/null
+++ b/sources/pyside2/doc/pysideversion.rst
@@ -0,0 +1,31 @@
+Getting PySide and Qt version
+*****************************
+
+PySide exports their version numbers among the version of Qt used to compile PySide in a pythonnic way, you can check it using the variables:
+
+::
+
+ import PySide
+
+ # Prints PySide version
+ # e.g. 1.0.2
+ print PySide.__version__
+
+ # Gets a tuple with each version component
+ # e.g. (1, 0, 2, 'final', 1)
+ print PySide.__version_info__
+
+ # Prints the Qt version used to compile PySide
+ # e.g. "4.7.2"
+ print PySide2.QtCore.__version__
+
+ # Gets a tuple with each version components of Qt used to compile PySide
+ # e.g. (4, 7, 2)
+ print PySide2.QtCore.__version_info__
+
+
+Note that the Qt version used to compile PySide may differ from the version used to run PySide, to get the current running Qt version you can do:
+
+::
+
+ print PySide2.QtCore.qVersion()
diff --git a/sources/pyside2/doc/tutorials/index.rst b/sources/pyside2/doc/tutorials/index.rst
new file mode 100644
index 000000000..2e97612aa
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/index.rst
@@ -0,0 +1,10 @@
+PySide tutorials
+****************
+
+A collection of tutorials and "walkthrough" guides are provided with PySide to help new users get started with PySide development. These documents were ported from C++ to Python and cover a range of topics, from basic use of widgets to step-by-step tutorials that show how an application is put together.
+
+.. toctree::
+ :maxdepth: 2
+
+ qmltutorial/index.rst
+ qmladvancedtutorial/index.rst
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial1.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial1.png
new file mode 100644
index 000000000..1699ab0e4
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial1.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial2.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial2.png
new file mode 100644
index 000000000..ba27c442c
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial2.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial3.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial3.png
new file mode 100644
index 000000000..d500434d1
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial3.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial4.gif b/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial4.gif
new file mode 100644
index 000000000..827458daa
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-adv-tutorial4.gif
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-samegame.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-samegame.png
new file mode 100644
index 000000000..2232df204
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/declarative-samegame.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/index.rst b/sources/pyside2/doc/tutorials/qmladvancedtutorial/index.rst
new file mode 100644
index 000000000..5b5a367d0
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/index.rst
@@ -0,0 +1,34 @@
+.. _qmladvancedtutorial:
+
+QML Advanced Tutorial
+*********************
+
+This tutorial walks step-by-step through the creation of a full application using QML.
+It assumes that you already know the basics of QML (for example, from reading the
+:ref:`qmltutorial`.
+
+In this tutorial we write a game, *Same Game*, based on the Same Game application
+included in the declarative demos directory, which looks like this:
+
+.. figure:: declarative-samegame.png
+ :align: center
+
+We will cover concepts for producing a fully functioning application, including
+JavaScript integration, using QML States and Behaviors to
+manage components and enhance your interface, and storing persistent application data.
+
+An understanding of JavaScript is helpful to understand parts of this tutorial, but if you don't
+know JavaScript you can still get a feel for how you can integrate backend logic to create and
+control QML elements.
+
+Tutorial chapters:
+
+.. toctree::
+ :maxdepth: 1
+
+ samegame1.rst
+ samegame2.rst
+ samegame3.rst
+ samegame4.rst
+
+All the code in this tutorial can be found :download:`here <samegame.tar.bz2>`.
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame.tar.bz2 b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame.tar.bz2
new file mode 100644
index 000000000..f33983d0a
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame.tar.bz2
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/Block.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/Block.qml
new file mode 100644
index 000000000..b130b2864
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/Block.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+import QtQuick 1.0
+
+Item {
+ id: block
+
+ Image {
+ id: img
+ anchors.fill: parent
+ source: "../shared/pics/redStone.png"
+ }
+}
+//![0]
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/Button.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/Button.qml
new file mode 100644
index 000000000..b419fb562
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/Button.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+import QtQuick 1.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
+//![0]
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/samegame.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/samegame.qml
new file mode 100644
index 000000000..8f71901b7
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/samegame.qml
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+import QtQuick 1.0
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+ }
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: console.log("This doesn't do anything yet...")
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
+//![0]
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/samegame1.qmlproject b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/samegame1.qmlproject
new file mode 100644
index 000000000..d4909f868
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame1/samegame1.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/Block.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/Block.qml
new file mode 100644
index 000000000..3f91bc7cc
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/Block.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+Item {
+ id: block
+
+ Image {
+ id: img
+ anchors.fill: parent
+ source: "../shared/pics/redStone.png"
+ }
+}
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/Button.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/Button.qml
new file mode 100644
index 000000000..2de0d9422
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/Button.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame.js b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame.js
new file mode 100644
index 000000000..c749dc17b
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame.js
@@ -0,0 +1,63 @@
+//![0]
+var blockSize = 40;
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ }
+
+ //Calculate board size
+ maxColumn = Math.floor(background.width / blockSize);
+ maxRow = Math.floor(background.height / blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("Block.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(background);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.x = column * blockSize;
+ dynamicObject.y = row * blockSize;
+ dynamicObject.width = blockSize;
+ dynamicObject.height = blockSize;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+//![0]
+
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame.qml
new file mode 100644
index 000000000..9f5cef44a
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+//![2]
+import "samegame.js" as SameGame
+//![2]
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+ }
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 32
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+//![1]
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+//![1]
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame2.qmlproject b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame2.qmlproject
new file mode 100644
index 000000000..d4909f868
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame2/samegame2.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Block.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Block.qml
new file mode 100644
index 000000000..d0f3d7619
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Block.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+import QtQuick 1.0
+
+Item {
+ id: block
+
+ property int type: 0
+
+ Image {
+ id: img
+
+ anchors.fill: parent
+ source: {
+ if (type == 0)
+ return "../shared/pics/redStone.png";
+ else if (type == 1)
+ return "../shared/pics/blueStone.png";
+ else
+ return "../shared/pics/greenStone.png";
+ }
+ }
+}
+//![0]
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Button.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Button.qml
new file mode 100644
index 000000000..2de0d9422
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Button.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Dialog.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Dialog.qml
new file mode 100644
index 000000000..897c5bf3b
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/Dialog.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+import QtQuick 1.0
+
+Rectangle {
+ id: container
+
+ function show(text) {
+ dialogText.text = text;
+ container.opacity = 1;
+ }
+
+ function hide() {
+ container.opacity = 0;
+ }
+
+ width: dialogText.width + 20
+ height: dialogText.height + 20
+ opacity: 0
+
+ Text {
+ id: dialogText
+ anchors.centerIn: parent
+ text: ""
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: hide();
+ }
+}
+//![0]
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame.js b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame.js
new file mode 100644
index 000000000..df5bdfb04
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame.js
@@ -0,0 +1,174 @@
+/* This script file handles the game logic */
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Calculate board size
+ maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Close dialogs
+ dialog.hide();
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("Block.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(gameCanvas);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.type = Math.floor(Math.random() * 3);
+ dynamicObject.x = column * gameCanvas.blockSize;
+ dynamicObject.y = row * gameCanvas.blockSize;
+ dynamicObject.width = gameCanvas.blockSize;
+ dynamicObject.height = gameCanvas.blockSize;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+var fillFound; //Set after a floodFill call to the number of blocks found
+var floodBoard; //Set to 1 if the floodFill reaches off that node
+
+//![1]
+function handleClick(xPos, yPos) {
+ var column = Math.floor(xPos / gameCanvas.blockSize);
+ var row = Math.floor(yPos / gameCanvas.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ //If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column, row, -1);
+ if (fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+//![1]
+
+function floodFill(column, row, type) {
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column, row)].type;
+
+ //Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; //Can't remove single blocks
+ board[index(column, row)].opacity = 0;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown() {
+ //Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column, row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y += fallDist * gameCanvas.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ //Fall to the left
+ var fallDist = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (var row = 0; row < maxRow; row++) {
+ var obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x -= fallDist * gameCanvas.blockSize;
+ board[index(column - fallDist, row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+//![2]
+function victoryCheck() {
+ //Award bonus points if no blocks left
+ var deservesBonus = true;
+ for (var column = maxColumn - 1; column >= 0; column--)
+ if (board[index(column, maxRow - 1)] != null)
+ deservesBonus = false;
+ if (deservesBonus)
+ gameCanvas.score += 500;
+
+ //Check whether game has finished
+ if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1)))
+ dialog.show("Game Over. Your score is " + gameCanvas.score);
+}
+//![2]
+
+//only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type) {
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type);
+}
+
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame.qml
new file mode 100644
index 000000000..d10a2caa9
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame.qml
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+import QtQuick 1.0
+import "samegame.js" as SameGame
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+//![1]
+ Item {
+ id: gameCanvas
+
+ property int score: 0
+ property int blockSize: 40
+
+ width: parent.width - (parent.width % blockSize)
+ height: parent.height - (parent.height % blockSize)
+ anchors.centerIn: parent
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: SameGame.handleClick(mouse.x, mouse.y)
+ }
+ }
+//![1]
+ }
+
+//![2]
+ Dialog {
+ id: dialog
+ anchors.centerIn: parent
+ z: 100
+ }
+//![2]
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
+//![0]
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame3.qmlproject b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame3.qmlproject
new file mode 100644
index 000000000..d4909f868
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame3/samegame3.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/BoomBlock.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/BoomBlock.qml
new file mode 100644
index 000000000..97f63c2e3
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/BoomBlock.qml
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.particles 1.0
+
+Item {
+ id: block
+
+ property int type: 0
+ property bool dying: false
+
+ //![1]
+ property bool spawned: false
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ //![1]
+
+ //![2]
+ Image {
+ id: img
+
+ anchors.fill: parent
+ source: {
+ if (type == 0)
+ return "../../shared/pics/redStone.png";
+ else if (type == 1)
+ return "../../shared/pics/blueStone.png";
+ else
+ return "../../shared/pics/greenStone.png";
+ }
+ opacity: 0
+
+ Behavior on opacity {
+ NumberAnimation { properties:"opacity"; duration: 200 }
+ }
+ }
+ //![2]
+
+ //![3]
+ Particles {
+ id: particles
+
+ width: 1; height: 1
+ anchors.centerIn: parent
+
+ emissionRate: 0
+ lifeSpan: 700; lifeSpanDeviation: 600
+ angle: 0; angleDeviation: 360;
+ velocity: 100; velocityDeviation: 30
+ source: {
+ if (type == 0)
+ return "../../shared/pics/redStar.png";
+ else if (type == 1)
+ return "../../shared/pics/blueStar.png";
+ else
+ return "../../shared/pics/greenStar.png";
+ }
+ }
+ //![3]
+
+ //![4]
+ states: [
+ State {
+ name: "AliveState"
+ when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"
+ when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+ //![4]
+}
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/Button.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/Button.qml
new file mode 100644
index 000000000..2de0d9422
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/Button.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/Dialog.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/Dialog.qml
new file mode 100644
index 000000000..b9787da1e
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/Dialog.qml
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+//![0]
+Rectangle {
+ id: container
+//![0]
+
+//![1]
+ property string inputText: textInput.text
+ signal closed
+
+ function show(text) {
+ dialogText.text = text;
+ container.opacity = 1;
+ textInput.opacity = 0;
+ }
+
+ function showWithInput(text) {
+ show(text);
+ textInput.opacity = 1;
+ textInput.focus = true;
+ textInput.text = ""
+ }
+
+ function hide() {
+ textInput.focus = false;
+ container.opacity = 0;
+ container.closed();
+ }
+//![1]
+
+ width: dialogText.width + textInput.width + 20
+ height: dialogText.height + 20
+ opacity: 0
+ visible: opacity > 0
+
+ Text {
+ id: dialogText
+ anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: 10 }
+ text: ""
+ }
+
+//![2]
+ TextInput {
+ id: textInput
+ anchors { verticalCenter: parent.verticalCenter; left: dialogText.right }
+ width: 80
+ text: ""
+
+ onAccepted: container.hide() // close dialog when Enter is pressed
+ }
+//![2]
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: {
+ if (textInput.text == "" && textInput.opacity > 0)
+ textInput.openSoftwareInputPanel();
+ else
+ hide();
+ }
+ }
+
+//![3]
+}
+//![3]
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/samegame.js b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/samegame.js
new file mode 100755
index 000000000..79ff0c19b
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/content/samegame.js
@@ -0,0 +1,225 @@
+/* This script file handles the game logic */
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+var scoresURL = "";
+var gameDuration;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ }
+
+ //Calculate board size
+ maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Close dialogs
+ nameInputDialog.hide();
+ dialog.hide();
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+
+ gameDuration = new Date();
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("content/BoomBlock.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(gameCanvas);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.type = Math.floor(Math.random() * 3);
+ dynamicObject.x = column * gameCanvas.blockSize;
+ dynamicObject.y = row * gameCanvas.blockSize;
+ dynamicObject.width = gameCanvas.blockSize;
+ dynamicObject.height = gameCanvas.blockSize;
+ dynamicObject.spawned = true;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+var fillFound; //Set after a floodFill call to the number of blocks found
+var floodBoard; //Set to 1 if the floodFill reaches off that node
+
+function handleClick(xPos, yPos) {
+ var column = Math.floor(xPos / gameCanvas.blockSize);
+ var row = Math.floor(yPos / gameCanvas.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ //If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column, row, -1);
+ if (fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+
+function floodFill(column, row, type) {
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column, row)].type;
+
+ //Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; //Can't remove single blocks
+ board[index(column, row)].dying = true;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown() {
+ //Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column, row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y = (row + fallDist) * gameCanvas.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ //Fall to the left
+ fallDist = 0;
+ for (column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (row = 0; row < maxRow; row++) {
+ obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x = (fallDist - column) * gameCanvas.blockSize;
+ board[index(column - fallDist, row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+//![3]
+function victoryCheck() {
+//![3]
+ //Award bonus points if no blocks left
+ var deservesBonus = true;
+ for (var column = maxColumn - 1; column >= 0; column--)
+ if (board[index(column, maxRow - 1)] != null)
+ deservesBonus = false;
+ if (deservesBonus)
+ gameCanvas.score += 500;
+
+//![4]
+ //Check whether game has finished
+ if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) {
+ gameDuration = new Date() - gameDuration;
+ nameInputDialog.showWithInput("You won! Please enter your name: ");
+ }
+}
+//![4]
+
+//only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type) {
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type);
+}
+
+//![2]
+function saveHighScore(name) {
+ if (scoresURL != "")
+ sendHighScore(name);
+
+ var db = openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores", 100);
+ var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
+ var data = [name, gameCanvas.score, maxColumn + "x" + maxRow, Math.floor(gameDuration / 1000)];
+ db.transaction(function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ tx.executeSql(dataStr, data);
+
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10');
+ var r = "\nHIGH SCORES for a standard sized grid\n\n"
+ for (var i = 0; i < rs.rows.length; i++) {
+ r += (i + 1) + ". " + rs.rows.item(i).name + ' got ' + rs.rows.item(i).score + ' points in ' + rs.rows.item(i).time + ' seconds.\n';
+ }
+ dialog.show(r);
+ });
+}
+//![2]
+
+//![1]
+function sendHighScore(name) {
+ var postman = new XMLHttpRequest()
+ var postData = "name=" + name + "&score=" + gameCanvas.score + "&gridSize=" + maxColumn + "x" + maxRow + "&time=" + Math.floor(gameDuration / 1000);
+ postman.open("POST", scoresURL, true);
+ postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ postman.onreadystatechange = function() {
+ if (postman.readyState == postman.DONE) {
+ dialog.show("Your score has been uploaded.");
+ }
+ }
+ postman.send(postData);
+}
+//![1]
+
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/README b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/README
new file mode 100644
index 000000000..eaa00fae3
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/README
@@ -0,0 +1 @@
+The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it.
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_data.xml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_data.xml
new file mode 100755
index 000000000..c3fd90d9c
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_data.xml
@@ -0,0 +1,2 @@
+<record><score>1000000</score><name>Alan the Tester</name><gridSize>0x0</gridSize><seconds>0</seconds></record>
+<record><score>6213</score><name>Alan</name><gridSize>12x17</gridSize><seconds>51</seconds></record>
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_style.xsl b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_style.xsl
new file mode 100755
index 000000000..670354c96
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_style.xsl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/">
+ <html>
+ <head><title>SameGame High Scores</title></head>
+ <body>
+ <h2>SameGame High Scores</h2>
+ <table border="1">
+ <tr bgcolor="lightsteelblue">
+ <th>Name</th>
+ <th>Score</th>
+ <th>Grid Size</th>
+ <th>Time, s</th>
+ </tr>
+ <xsl:for-each select="records/record">
+ <xsl:sort select="score" data-type="number" order="descending"/>
+ <tr>
+ <td><xsl:value-of select="name"/></td>
+ <td><xsl:value-of select="score"/></td>
+ <td><xsl:value-of select="gridSize"/></td>
+ <td><xsl:value-of select="seconds"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/scores.php b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/scores.php
new file mode 100755
index 000000000..daf480e21
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/scores.php
@@ -0,0 +1,31 @@
+<?php
+ $score = $_POST["score"];
+ echo "<html>";
+ echo "<head><title>SameGame High Scores</title></head><body>";
+ if($score > 0){#Sending in a new high score
+ $name = $_POST["name"];
+ $grid = $_POST["gridSize"];
+ $time = $_POST["time"];
+ if($name == "")
+ $name = "Anonymous";
+ $file = fopen("score_data.xml", "a");
+ $ret = fwrite($file, "<record><score>". $score . "</score><name>"
+ . $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
+ . $time . "</seconds></record>\n");
+ echo "Your score has been recorded. Thanks for playing!";
+ if($ret == False)
+ echo "<br/> There was an error though, so don't expect to see that score again.";
+ }else{#Read high score list
+ #Now uses XSLT to display. So just print the file. With XML cruft added.
+ #Note that firefox at least won't apply the XSLT on a php file. So redirecting
+ $file = fopen("scores.xml", "w");
+ $ret = fwrite($file, '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"
+ . '<?xml-stylesheet type="text/xsl" href="score_style.xsl"?>' . "\n"
+ . "<records>\n" . file_get_contents("score_data.xml") . "</records>\n");
+ if($ret == False)
+ echo "There was an internal error. Sorry.";
+ else
+ echo '<script type="text/javascript">window.location.replace("scores.xml")</script>';
+ }
+ echo "</body></html>";
+?>
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/samegame.qml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/samegame.qml
new file mode 100644
index 000000000..b241d0924
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/samegame.qml
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import "content"
+import "content/samegame.js" as SameGame
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+ Item {
+ id: gameCanvas
+ property int score: 0
+ property int blockSize: 40
+
+ anchors.centerIn: parent
+ width: parent.width - (parent.width % blockSize);
+ height: parent.height - (parent.height % blockSize);
+
+ MouseArea {
+ anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y);
+ }
+ }
+ }
+
+ Dialog {
+ id: dialog
+ anchors.centerIn: parent
+ z: 100
+ }
+
+ //![0]
+ Dialog {
+ id: nameInputDialog
+ anchors.centerIn: parent
+ z: 100
+
+ onClosed: {
+ if (nameInputDialog.inputText != "")
+ SameGame.saveHighScore(nameInputDialog.inputText);
+ }
+ }
+ //![0]
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: " + gameCanvas.score
+ }
+ }
+}
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/samegame4.qmlproject b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/samegame4.qmlproject
new file mode 100644
index 000000000..d4909f868
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/samegame4.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/background.jpg b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/background.jpg
new file mode 100644
index 000000000..903d395c8
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/background.jpg
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/blueStar.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/blueStar.png
new file mode 100644
index 000000000..ff9588f80
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/blueStar.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/blueStone.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/blueStone.png
new file mode 100644
index 000000000..20e43c75b
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/blueStone.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/greenStar.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/greenStar.png
new file mode 100644
index 000000000..cd0685471
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/greenStar.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/greenStone.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/greenStone.png
new file mode 100644
index 000000000..b568a1900
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/greenStone.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/redStar.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/redStar.png
new file mode 100644
index 000000000..0a4dffe58
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/redStar.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/redStone.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/redStone.png
new file mode 100644
index 000000000..36b09a268
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/redStone.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/star.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/star.png
new file mode 100644
index 000000000..defbde53c
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/star.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/yellowStone.png b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/yellowStone.png
new file mode 100644
index 000000000..b1ce76212
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/shared/pics/yellowStone.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame1.rst b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame1.rst
new file mode 100644
index 000000000..c8638ce06
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame1.rst
@@ -0,0 +1,70 @@
+.. _samegame1:
+
+QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks
+*************************************************************
+
+Creating the application screen
+===============================
+
+The first step is to create the basic QML items in your application.
+
+To begin with, we create our Same Game application with a main screen like this:
+
+.. figure:: declarative-adv-tutorial1.png
+ :align: center
+
+This is defined by the main application file, ``samegame.qml``, which looks like this:
+
+.. pysideinclude:: samegame/samegame1/samegame.qml
+ :snippet: 0
+
+This gives you a basic game window that includes the main canvas for the
+blocks, a "New Game" button and a score display.
+
+One item you may not recognize here
+is the SystemPalette item. This provides access to the Qt system palette
+and is used to give the button a more native look-and-feel.
+
+Notice the anchors for the ``Item``, ``Button`` and ``Text`` elements are set using
+group notation for readability.
+
+Adding Button and Block components
+==================================
+
+The ``Button`` item in the code above is defined in a separate component file named ``Button.qml``.
+To create a functional button, we use the QML elements Text and MouseArea inside a Rectangle.
+Here is the ``Button.qml`` code:
+
+.. pysideinclude:: samegame/samegame1/Button.qml
+ :snippet: 0
+
+This essentially defines a rectangle that contains text and can be clicked. The MouseArea
+has an ``onClicked()`` handler that is implemented to emit the ``clicked()`` signal of the
+``container`` when the area is clicked.
+
+In Same Game, the screen is filled with small blocks when the game begins.
+Each block is just an item that contains an image. The block
+code is defined in a separate ``Block.qml`` file:
+
+.. pysideinclude:: samegame/samegame1/Block.qml
+ :snippet: 0
+
+At the moment, the block doesn't do anything; it is just an image. As the
+tutorial progresses we will animate and give behaviors to the blocks.
+We have not added any code yet to create the blocks; we will do this
+in the next chapter.
+
+We have set the image to be the size of its parent Item using ``anchors.fill: parent``.
+This means that when we dynamically create and resize the block items
+later on in the tutorial, the image will be scaled automatically to the
+correct size.
+
+Notice the relative path for the Image element's ``source`` property.
+This path is relative to the location of the file that contains the Image element.
+Alternatively, you could set the Image source to an absolute file path or a URL
+that contains an image.
+
+You should be familiar with the code so far. We have just created some basic
+elements to get started. Next, we will populate the game canvas with some blocks.
+
+[Previous :ref:`qmladvancedtutorial`] [Next :ref:`samegame2`] \ No newline at end of file
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame2.rst b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame2.rst
new file mode 100644
index 000000000..6cc12d5ca
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame2.rst
@@ -0,0 +1,71 @@
+.. _samegame2:
+
+QML Advanced Tutorial 2 - Populating the Game Canvas
+****************************************************
+
+Generating the blocks in JavaScript
+===================================
+
+Now that we've written some basic elements, let's start writing the game.
+
+The first task is to generate the game blocks. Each time the New Game button
+is clicked, the game canvas is populated with a new, random set of
+blocks. Since we need to dynamically generate new blocks for each new game,
+we cannot use Repeater to define the blocks. Instead, we will
+create the blocks in JavaScript.
+
+Here is the JavaScript code for generating the blocks, contained in a new
+file, ``samegame.js``. The code is explained below.
+
+.. pysideinclude:: samegame/samegame2/samegame.js
+ :snippet: 0
+
+The ``startNewGame()`` function deletes the blocks created in the previous game and
+calculates the number of rows and columns of blocks required to fill the game window for the new game.
+Then, it creates an array to store all the game
+blocks, and calls ``createBlock()`` to create enough blocks to fill the game window.
+
+The ``createBlock()`` function creates a block from the ``Block.qml`` file
+and moves the new block to its position on the game canvas. This involves several steps:
+
+* ``Qt.createComponent()`` is called to
+ generate an element from ``Block.qml``. If the component is ready,
+ we can call ``createObject()`` to create an instance of the ``Block``
+ item.
+
+* If ``createObject()`` returned null (i.e. if there was an error
+ while loading the object), print the error information.
+
+* Place the block in its position on the board and set its width and
+ height. Also, store it in the blocks array for future reference.
+
+* Finally, print error information to the console if the component
+ could not be loaded for some reason (for example, if the file is
+ missing).
+
+Connecting JavaScript components to QML
+=======================================
+
+Now we need to call the JavaScript code in ``samegame.js`` from our QML files.
+To do this, we add this line to ``samegame.qml`` which imports
+the JavaScript file as a module:
+
+.. pysideinclude:: samegame/samegame2/samegame.qml
+ :snippet: 2
+
+This allows us to refer to any functions within ``samegame.js`` using "SameGame"
+as a prefix: for example, ``SameGame.startNewGame()`` or ``SameGame.createBlock()``.
+This means we can now connect the New Game button's ``onClicked`` handler to the ``startNewGame()``
+function, like this:
+
+.. pysideinclude:: samegame/samegame2/samegame.qml
+ :snippet: 1
+
+So, when you click the New Game button, ``startNewGame()`` is called and generates a field of blocks, like this:
+
+.. figure:: declarative-adv-tutorial2.png
+ :align: center
+
+Now, we have a screen of blocks, and we can begin to add the game mechanics.
+
+[Previous :ref:`samegame1`] [Next :ref:`samegame3`] \ No newline at end of file
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame3.rst b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame3.rst
new file mode 100644
index 000000000..a1fe44edd
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame3.rst
@@ -0,0 +1,95 @@
+.. _samegame3:
+
+QML Advanced Tutorial 3 - Implementing the Game Logic
+*****************************************************
+
+Making a playable game
+======================
+
+Now that we have all the game components, we can add the game logic that
+dictates how a player interacts with the blocks and plays the game
+until it is won or lost.
+
+To do this, we have added the following functions to ``samegame.js``:
+
+
+* ``handleClick(x,y)``
+* ``floodFill(xIdx,yIdx,type)``
+* ``shuffleDown()``
+* ``victoryCheck()``
+* ``floodMoveCheck(xIdx, yIdx, type)``
+
+As this is a tutorial about QML, not game design, we will only discuss ``handleClick()`` and ``victoryCheck()`` below since they interface directly with the QML elements. Note that although the game logic here is written in JavaScript, it could have been written in Python and then exposed to QML.
+
+Enabling mouse click interaction
+================================
+
+To make it easier for the JavaScript code to interface with the QML elements, we have added an Item called ``gameCanvas`` to ``samegame.qml``. It replaces the background as the item which contains the blocks. It also accepts mouse input from the user. Here is the item code:
+
+.. pysideinclude:: samegame/samegame3/samegame.qml
+ :snippet: 1
+
+The ``gameCanvas`` item is the exact size of the board, and has a ``score`` property and a MouseArea to handle mouse clicks.
+The blocks are now created as its children, and its dimensions are used to determine the board size so that
+the application scales to the available screen size.
+Since its size is bound to a multiple of ``blockSize``, ``blockSize`` was moved out of ``samegame.js`` and into ``samegame.qml`` as a QML property.
+Note that it can still be accessed from the script.
+
+When clicked, the MouseArea calls ``handleClick()`` in ``samegame.js``, which determines whether the player's click should cause any blocks to be removed, and updates ``gameCanvas.score`` with the current score if necessary. Here is the ``handleClick()`` function:
+
+.. pysideinclude:: samegame/samegame3/samegame.js
+ :snippet: 1
+
+Note that if ``score`` was a global variable in the ``samegame.js`` file you would not be able to bind to it. You can only bind to QML properties.
+
+Updating the score
+==================
+
+When the player clicks a block and triggers \c handleClick(), \c handleClick() also calls \c victoryCheck() to update the score and to check whether the player has completed the game. Here is the \c victoryCheck() code:
+
+.. pysideinclude:: samegame/samegame3/samegame.js
+ :snippet: 2
+
+This updates the ``gameCanvas.score`` value and displays a "Game Over" dialog if the game is finished.
+
+The Game Over dialog is created using a ``Dialog`` element that is defined in ``Dialog.qml``. Here is the ``Dialog.qml`` code. Notice how it is designed to be usable imperatively from the script file, via the functions and signals:
+
+.. pysideinclude:: samegame/samegame3/Dialog.qml
+ :snippet: 0
+
+And this is how it is used in the main ``samegame.qml`` file:
+
+.. pysideinclude:: samegame/samegame3/samegame.qml
+ :snippet: 2
+
+We give the dialog a ``z`` value of 100 to ensure it is displayed on top of our other components. The default ``z`` value for an item is 0.
+
+
+A dash of color
+---------------
+
+It's not much fun to play Same Game if all the blocks are the same color, so we've modified the ``createBlock()`` function in ``samegame.js`` to randomly create a different type of block (for either red, green or blue) each time it is called. ``Block.qml`` has also changed so that each block contains a different image depending on its type:
+
+.. pysideinclude:: samegame/samegame3/Block.qml
+ :snippet: 0
+
+
+A working game
+==============
+
+Now we now have a working game! The blocks can be clicked, the player can score, and the game can end (and then you can start a new one).
+Here is a screenshot of what has been accomplished so far:
+
+.. figure:: declarative-adv-tutorial3.png
+ :align: center
+
+This is what ``samegame.qml`` looks like now:
+
+.. pysideinclude:: samegame/samegame3/samegame.qml
+ :snippet: 0
+
+The game works, but it's a little boring right now. Where are the smooth animated transitions? Where are the high scores?
+If you were a QML expert you could have written these in the first iteration, but in this tutorial they've been saved
+until the next chapter - where your application becomes alive!
+
+[Previous :ref:`samegame2`] [Next :ref:`samegame4`]
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame4.rst b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame4.rst
new file mode 100644
index 000000000..50aaff16a
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame4.rst
@@ -0,0 +1,187 @@
+.. _samegame4:
+
+QML Advanced Tutorial 4 - Finishing Touches
+*******************************************
+
+Adding some flair
+=================
+
+Now we're going to do two things to liven up the game: animate the blocks and add a High Score system.
+
+We've also cleaned up the directory structure for our application files. We now have a lot of files, so all the
+JavaScript and QML files outside of ``samegame.qml`` have been moved into a new sub-directory named "content".
+
+In anticipation of the new block animations, ``Block.qml`` file is now renamed to ``BoomBlock.qml``.
+
+Animating block movement
+------------------------
+
+First we will animate the blocks so that they move in a fluid manner. QML has a number of methods for adding fluid
+movement, and in this case we're going to use the Behavior element to add a SpringAnimation.
+In ``BoomBlock.qml``, we apply a SpringAnimation behavior to the ``x`` and ``y`` properties so that the
+block will follow and animate its movement in a spring-like fashion towards the specified position (whose
+values will be set by ``samegame.js``).Here is the code added to ``BoomBlock.qml``:
+
+.. pysideinclude:: samegame/samegame4/content/BoomBlock.qml
+ :snippet: 1
+
+The ``spring`` and ``damping`` values can be changed to modify the spring-like effect of the animation.
+
+The ``enabled: spawned`` setting refers to the ``spawned`` value that is set from ``createBlock()`` in ``samegame.js``.
+This ensures the SpringAnimation on the ``x`` is only enabled after ``createBlock()`` has set the block to
+the correct position. Otherwise, the blocks will slide out of the corner (0,0) when a game begins, instead of falling
+from the top in rows. (Try commenting out ``enabled: spawned`` and see for yourself.)
+
+Animating block opacity changes
+-------------------------------
+
+Next, we will add a smooth exit animation. For this, we'll use a Behavior element, which allows us to specify
+a default animation when a property change occurs. In this case, when the ``opacity`` of a Block changes, we will
+animate the opacity value so that it gradually fades in and out, instead of abruptly changing between fully
+visible and invisible. To do this, we'll apply a Behavior on the ``opacity`` property of the ``Image``
+element in ``BoomBlock.qml``:
+
+.. pysideinclude:: samegame/samegame4/content/BoomBlock.qml
+ :snippet: 2
+
+Note the ``opacity: 0`` which means the block is transparent when it is first created. We could set the opacity
+in ``samegame.js`` when we create and destroy the blocks,
+but instead we'll use states, since this is useful for the next animation we're going to add.
+Initially, we add these States to the root element of ``BoomBlock.qml``:
+
+::
+
+ property bool dying: false
+ states: [
+ State{ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+ State{ name: "DeathState"; when: dying == true
+ PropertyChanges { target: img; opacity: 0 }
+ }
+ ]
+
+Now blocks will automatically fade in, as we already set ``spawned`` to true when we implemented the block animations.
+To fade out, we set ``dying`` to true instead of setting opacity to 0 when a block is destroyed (in the ``floodFill()`` function).
+
+Adding particle effects
+-----------------------
+
+Finally, we'll add a cool-looking particle effect to the blocks when they are destroyed. To do this, we first add a Particles element in
+``BoomBlock.qml``, like so:
+
+.. pysideinclude:: samegame/samegame4/content/BoomBlock.qml
+ :snippet: 3
+
+To fully understand this you should read the Particles documentation, but it's important to note that ``emissionRate`` is set
+to zero so that particles are not emitted normally.
+Also, we extend the ``dying`` State, which creates a burst of particles by calling the ``burst()`` method on the particles element. The code for the states now look
+like this:
+
+.. pysideinclude:: samegame/samegame4/content/BoomBlock.qml
+ :snippet: 4
+
+Now the game is beautifully animated, with subtle (or not-so-subtle) animations added for all of the
+player's actions. The end result is shown below, with a different set of images to demonstrate basic theming:
+
+.. figure:: declarative-adv-tutorial4.gif
+ :align: center
+
+The theme change here is produced simply by replacing the block images. This can be done at runtime by changing the \l Image \c source property, so for a further challenge, you could add a button that toggles between themes with different images.
+
+Keeping a High Scores table
+===========================
+
+Another feature we might want to add to the game is a method of storing and retrieving high scores.
+
+To do this, we will show a dialog when the game is over to request the player's name and add it to a High Scores table.
+This requires a few changes to ``Dialog.qml``. In addition to a ``Text`` element, it now has a
+``TextInput`` child item for receiving keyboard text input:
+
+.. pysideinclude:: samegame/samegame4/content/Dialog.qml
+ :snippet: 2
+ :prepend: Rectangle {
+ ...
+ :append: ...
+ }
+
+
+We'll also add a ``showWithInput()`` function. The text input will only be visible if this function
+is called instead of ``show()``. When the dialog is closed, it emits a ``closed()`` signal, and
+other elements can retrieve the text entered by the user through an ``inputText`` property:
+
+.. pysideinclude:: samegame/samegame4/content/Dialog.qml
+ :snippet: 1
+ :prepend: Rectangle {
+ ...
+ :append: ...
+ }
+
+Now the dialog can be used in ``samegame.qml``:
+
+.. pysideinclude:: samegame/samegame4/samegame.qml
+ :snippet: 0
+
+When the dialog emits the ``closed`` signal, we call the new ``saveHighScore()`` function in ``samegame.js``, which stores the high score locally in an SQL database and also send the score to an online database if possible.
+
+The ``nameInputDialog`` is activated in the ``victoryCheck()`` function in ``samegame.js``:
+
+.. pysideinclude:: samegame/samegame4/content/samegame.js
+ :snippet: 4
+ :prepend: function vitoryCheck() {
+ ...
+
+Storing high scores offline
+---------------------------
+
+Now we need to implement the functionality to actually save the High Scores table.
+
+Here is the ``saveHighScore()`` function in ``samegame.js``:
+
+.. pysideinclude:: samegame/samegame4/content/samegame.js
+ :snippet: 2
+
+First we call ``sendHighScore()`` (explained in the section below) if it is possible to send the high scores to an online database.
+
+Then, we use the Offline Storage API to maintain a persistant SQL database unique to this application. We create an offline storage database for the high scores using ``openDatabase()`` and prepare the data and SQL query that we want to use to save it. The offline storage API uses SQL queries for data manipulation and retrival, and in the ``db.transaction()`` call we use three SQL queries to initialize the database (if necessary), and then add to and retrieve high scores. To use the returned data, we turn it into a string with one line per row returned, and show a dialog containing that string.
+
+This is one way of storing and displaying high scores locally, but certainly not the only way. A more complex alternative would be to create a high score dialog component, and pass it the results for processing and display (instead of reusing the ``Dialog``). This would allow a more themeable dialog that could beter present the high scores. If your QML is the UI for a Python application, you could also have passed the score to a Python function to store it locally in a variety of ways, including a simple format without SQL or in another SQL database.
+
+Storing high scores online
+--------------------------
+
+You've seen how you can store high scores locally, but it is also easy to integrate a web-enabled high score storage into your QML application. The implementation we've done here is very
+simple: the high score data is posted to a php script running on a server somewhere, and that server then stores it and
+displays it to visitors. You could also request an XML or QML file from that same server, which contains and displays the scores,
+but that's beyond the scope of this tutorial. The php script we use here is available in the ``examples`` directory.
+
+If the player entered their name we can send the data to the web service us
+
+If the player enters a name, we send the data to the service using this code in ``samegame.js``:
+
+.. pysideinclude:: samegame/samegame4/content/samegame.js
+ :snippet: 1
+
+The XMLHttpRequest in this code is the same as the ``XMLHttpRequest()`` as you'll find in standard browser JavaScript, and can be used in the same way to dynamically get XML
+or QML from the web service to display the high scores. We don't worry about the response in this case - we just post the high
+score data to the web server. If it had returned a QML file (or a URL to a QML file) you could instantiate it in much the same
+way as you did with the blocks.
+
+An alternate way to access and submit web-based data would be to use QML elements designed for this purpose. XmlListModel
+makes it very easy to fetch and display XML based data such as RSS in a QML application (see the Flickr demo for an example).
+
+
+That's it!
+==========
+
+By following this tutorial you've seen how you can write a fully functional application in QML:
+
+* Build your application with QML elements.
+* Add application logic with JavaScript code.
+* Add animations with Behaviors and states.
+* Store persistent application data using, for example, the Offline Storage API or XMLHttpRequest.
+
+There is so much more to learn about QML that we haven't been able to cover in this tutorial. Check out all the
+demos and examples and the documentation to see all the things you can do with QML!
+
+[Previous :ref:`samegame3`] \ No newline at end of file
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial1.png b/sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial1.png
new file mode 100644
index 000000000..c9d3844cb
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial1.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial2.png b/sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial2.png
new file mode 100644
index 000000000..835484aa4
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial2.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial3_animation.gif b/sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial3_animation.gif
new file mode 100644
index 000000000..80b78dea9
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/declarative-tutorial3_animation.gif
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/helloworld.tar.bz2 b/sources/pyside2/doc/tutorials/qmltutorial/helloworld.tar.bz2
new file mode 100644
index 000000000..001a5258d
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/helloworld.tar.bz2
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/helloworld/Cell.qml b/sources/pyside2/doc/tutorials/qmltutorial/helloworld/Cell.qml
new file mode 100644
index 000000000..a561e34db
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/helloworld/Cell.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+import QtQuick 1.0
+
+//![1]
+Item {
+ id: container
+//![4]
+ property alias cellColor: rectangle.color
+//![4]
+//![5]
+ signal clicked(color cellColor)
+//![5]
+
+ width: 40; height: 25
+//![1]
+
+//![2]
+ Rectangle {
+ id: rectangle
+ border.color: "white"
+ anchors.fill: parent
+ }
+//![2]
+
+//![3]
+ MouseArea {
+ anchors.fill: parent
+ onClicked: container.clicked(container.cellColor)
+ }
+//![3]
+}
+//![0]
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial1.qml b/sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial1.qml
new file mode 100644
index 000000000..ef26bb1aa
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial1.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+//![3]
+import QtQuick 1.0
+//![3]
+
+//![1]
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+//![1]
+
+//![2]
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+ }
+//![2]
+}
+//![0]
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial2.qml b/sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial2.qml
new file mode 100644
index 000000000..f86da25b7
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial2.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+import QtQuick 1.0
+
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+ }
+
+ Grid {
+ id: colorPicker
+ x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4
+ rows: 2; columns: 3; spacing: 3
+
+//![1]
+ Cell { cellColor: "red"; onClicked: helloText.color = cellColor }
+//![1]
+ Cell { cellColor: "green"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "blue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "black"; onClicked: helloText.color = cellColor }
+ }
+}
+//![0]
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial3.qml b/sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial3.qml
new file mode 100644
index 000000000..7324c4df9
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/helloworld/tutorial3.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of PySide2.
+**
+** $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]
+import QtQuick 1.0
+
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+
+//![1]
+ MouseArea { id: mouseArea; anchors.fill: parent }
+//![1]
+
+//![2]
+ states: State {
+ name: "down"; when: mouseArea.pressed == true
+ PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" }
+ }
+//![2]
+
+//![3]
+ transitions: Transition {
+ from: ""; to: "down"; reversible: true
+ ParallelAnimation {
+ NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: Easing.InOutQuad }
+ ColorAnimation { duration: 500 }
+ }
+ }
+//![3]
+ }
+
+ Grid {
+ id: colorPicker
+ x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4
+ rows: 2; columns: 3; spacing: 3
+
+ Cell { cellColor: "red"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "green"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "blue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "black"; onClicked: helloText.color = cellColor }
+ }
+}
+//![0]
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/index.rst b/sources/pyside2/doc/tutorials/qmltutorial/index.rst
new file mode 100644
index 000000000..35cda3170
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/index.rst
@@ -0,0 +1,25 @@
+
+.. _qmltutorial:
+
+QML Tutorial
+************
+
+This tutorial gives an introduction to QML, the mark up language for Qt Quick. It doesn't cover everything;
+the emphasis is on teaching the key principles, and features are introduced as needed.
+
+Through the different steps of this tutorial we will learn about QML basic types, we will create our own QML component
+with properties and signals, and we will create a simple animation with the help of states and transitions.
+
+Chapter one starts with a minimal "Hello world" program and the following chapters introduce new concepts.
+
+The tutorial's source code can be downloaded :download:`here<helloworld.tar.bz2>`.
+
+Tutorial chapters:
+
+.. toctree::
+ :maxdepth: 1
+
+ step1.rst
+ step2.rst
+ step3.rst
+
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/step1.rst b/sources/pyside2/doc/tutorials/qmltutorial/step1.rst
new file mode 100644
index 000000000..02a1095bc
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/step1.rst
@@ -0,0 +1,66 @@
+.. _qmlbasictypes:
+
+QML Tutorial 1 - Basic Types
+****************************
+
+This first program is a very simple "Hello world" example that introduces some basic QML concepts.
+The picture below is a screenshot of this program.
+
+.. figure:: declarative-tutorial1.png
+ :align: center
+
+Here is the QML code for the application:
+
+.. pysideinclude:: helloworld/tutorial1.qml
+ :snippet: 0
+
+Walkthrough
+===========
+
+Import
+------
+
+First, we need to import the types that we need for this example. Most QML files will import the built-in QML
+types (like Rectangle, Image, ...) that come with Qt, using:
+
+.. pysideinclude:: helloworld/tutorial1.qml
+ :snippet: 3
+
+Rectangle element
+-----------------
+
+.. pysideinclude:: helloworld/tutorial1.qml
+ :snippet: 1
+
+We declare a root element of type Rectangle. It is one of the basic building blocks you can use to create an application in QML.
+We give it an ``id`` to be able to refer to it later. In this case, we call it "page".
+We also set the ``width``, ``height`` and ``color`` properties.
+The Rectangle element contains many other properties (such as ``x`` and ``y``), but these are left at their default values.
+
+Text element
+------------
+
+.. pysideinclude code/tutorial1.qml
+ :snippet: 2
+
+We add a Text element as a child of the root Rectangle element that displays the text 'Hello world!'.
+
+The ``y`` property is used to position the text vertically at 30 pixels from the top of its parent.
+
+The ``anchors.horizontalCenter`` property refers to the horizontal center of an element.
+In this case, we specify that our text element should be horizontally centered in the *page* element.
+
+The ``font.pointSize`` and ``font.bold properties`` are related to fonts and use the dot notation.
+
+
+Viewing the example
+-------------------
+
+To view what you have created, run the QML Viewer tool (located in the ``bin directory`` of your Qt installation) with your filename as the first argument.
+For example, to run the provided completed Tutorial 1 example from the install location, you would type:
+
+::
+
+ bin/qmlviewer tutorial1.qml
+
+[Previous :ref:`qmltutorial`][Next :ref:`qmlcomponents`]
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/step2.rst b/sources/pyside2/doc/tutorials/qmltutorial/step2.rst
new file mode 100644
index 000000000..4dacd00a9
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/step2.rst
@@ -0,0 +1,81 @@
+.. _qmlcomponents:
+
+QML Tutorial 2 - QML Components
+*******************************
+
+This chapter adds a color picker to change the color of the text.
+
+.. figure:: declarative-tutorial2.png
+ :align: center
+
+Our color picker is made of six cells with different colors.
+To avoid writing the same code multiple times for each cell, we create a new ``Cell`` component.
+A component provides a way of defining a new type that we can re-use in other QML files.
+A QML component is like a black-box and interacts with the outside world through properties, signals and functions and is generally
+defined in its own QML file.
+The component's filename must always start with a capital letter.
+
+Here is the QML code for ``Cell.qml``:
+
+.. pysideinclude:: helloworld/Cell.qml
+ :snippet: 0
+
+Walkthrough
+===========
+
+The Cell Component
+------------------
+
+.. pysideinclude:: helloworld/Cell.qml
+ :snippet: 1
+
+The root element of our component is an Item with the ``id`` *container*.
+An Item is the most basic visual element in QML and is often used as a container for other elements.
+
+.. pysideinclude:: helloworld/Cell.qml
+ :snippet: 4
+
+We declare a ``cellColor`` property. This property is accessible from *outside* our component, this allows us
+to instantiate the cells with different colors.
+This property is just an alias to an existing property - the color of the rectangle that compose the cell.
+
+.. pysideinclude:: helloworld/Cell.qml
+ :snippet: 5
+
+We want our component to also have a signal that we call *clicked* with a *cellColor* parameter of type *color*.
+We will use this signal to change the color of the text in the main QML file later.
+
+.. pysideinclude:: helloworld/Cell.qml
+ :snippet: 2
+
+Our cell component is basically a colored rectangle with the ``id`` *rectangle*.
+
+The ``anchors.fill`` property is a convenient way to set the size of an element.
+In this case the rectangle will have the same size as its parent.
+
+.. pysideinclude:: helloworld/Cell.qml
+ :snippet: 3
+
+In order to change the color of the text when clicking on a cell, we create a MouseArea element with
+the same size as its parent.
+
+A MouseArea defines a signal called *clicked*.
+When this signal is triggered we want to emit our own *clicked* signal with the color as parameter.
+
+The main QML file
+-----------------
+
+In our main QML file, we use our ``Cell`` component to create the color picker:
+
+.. pysideinclude:: helloworld/tutorial2.qml
+ :snippet: 0
+
+We create the color picker by putting 6 cells with different colors in a grid.
+
+.. pysideinclude:: helloworld/tutorial2.qml
+ :snippet: 1
+
+When the *clicked* signal of our cell is triggered, we want to set the color of the text to the *cellColor* passed as a parameter.
+We can react to any signal of our component through a property of the name *'onSignalName'*.
+
+[Previous :ref:`qmlbasictypes`][Next :ref:`qmlstatesandtransitions`]
diff --git a/sources/pyside2/doc/tutorials/qmltutorial/step3.rst b/sources/pyside2/doc/tutorials/qmltutorial/step3.rst
new file mode 100644
index 000000000..a72d1eac0
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmltutorial/step3.rst
@@ -0,0 +1,47 @@
+.. _qmlstatesandtransitions:
+
+QML Tutorial 3 - States and Transitions
+***************************************
+
+In this chapter, we make this example a little bit more dynamic by introducing states and transitions.
+
+We want our text to move to the bottom of the screen, rotate and become red when clicked.
+
+.. figure:: declarative-tutorial3_animation.gif
+ :align: center
+
+Here is the QML code:
+
+.. pysideinclude:: helloworld/tutorial3.qml
+ :snippet: 0
+
+Walkthrough
+===========
+
+.. pysideinclude:: helloworld/tutorial3.qml
+ :snippet: 2
+
+First, we create a new *down* state for our text element.
+This state will be activated when the MouseArea is pressed, and deactivated when it is released.
+
+The *down* state includes a set of property changes from our implicit *default state*
+(the items as they were initially defined in the QML).
+Specifically, we set the ``y`` property of the text to ``160``, the rotation to ``180`` and the ``color`` to red.
+
+.. pysideinclude:: helloworld/tutorial3.qml
+ :snippet: 3
+
+Because we don't want the text to appear at the bottom instantly but rather move smoothly,
+we add a transition between our two states.
+
+``from`` and ``to`` define the states between which the transition will run.
+In this case, we want a transition from the default state to our *down* state.
+
+Because we want the same transition to be run in reverse when changing back from the *down* state to the default state,
+we set ``reversible`` to ``true``.
+This is equivalent to writing the two transitions separately.
+
+The ParallelAnimation element makes sure that the two types of animations (number and color) start at the same time.
+We could also run them one after the other by using SequentialAnimation instead.
+
+[Previous :ref:`qmlcomponents`]
diff --git a/sources/pyside2/doc/typesystem_doc.xml.in b/sources/pyside2/doc/typesystem_doc.xml.in
new file mode 100644
index 000000000..50cb2a710
--- /dev/null
+++ b/sources/pyside2/doc/typesystem_doc.xml.in
@@ -0,0 +1,125 @@
+<?xml version="1.0" ?>
+<!--
+/****************************************************************************
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of PySide2.
+**
+** $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$
+**
+****************************************************************************/
+-->
+<typesystem package="PySide">
+ <suppress-warning text="File containing conversion code for *" />
+ <suppress-warning text="File for inject code not exist: *" />
+
+ <load-typesystem name="typesystem_core.xml" generate="yes"/>
+
+ @if_QtNetwork@
+ <load-typesystem name="typesystem_network.xml" generate="yes" />
+ @end_QtNetwork@
+
+ @if_QtXml@
+ <load-typesystem name="typesystem_xml.xml" generate="yes" />
+ @end_QtXml@
+
+ @if_QtScript@
+ <load-typesystem name="typesystem_script.xml" generate="yes" />
+ @end_QtScript@
+
+ @if_QtGui@
+ <load-typesystem name="typesystem_gui.xml" generate="yes"/>
+ @end_QtGui@
+
+ @if_QtHelp@
+ <load-typesystem name="typesystem_help.xml" generate="yes" />
+ @end_QtHelp@
+
+ @if_QtMultimedia@
+ <load-typesystem name="typesystem_multimedia.xml" generate="yes" />
+ @end_QtMultimedia@
+
+ @if_QtOpenGL@
+ <load-typesystem name="typesystem_opengl.xml" generate="yes" />
+ @end_QtOpenGL@
+
+ @if_QtScriptTools@
+ <load-typesystem name="typesystem_scripttools.xml" generate="yes" />
+ @end_QtScriptTools@
+
+ @if_QtSql@
+ <load-typesystem name="typesystem_sql.xml" generate="yes" />
+ @end_QtSql@
+
+ @if_QtSvg@
+ <load-typesystem name="typesystem_svg.xml" generate="yes" />
+ @end_QtSvg@
+
+ @if_QtTest@
+ <load-typesystem name="typesystem_test.xml" generate="yes" />
+ @end_QtTest@
+
+ @if_QtUiTools@
+ <load-typesystem name="typesystem_uitools.xml" generate="yes" />
+ @end_QtUiTools@
+
+ @if_QtWebKit@
+ <load-typesystem name="typesystem_webkit.xml" generate="yes" />
+ @end_QtWebKit@
+
+
+ @if_QtXmlPatterns@
+ <load-typesystem name="typesystem_xmlpatterns.xml" generate="yes" />
+ @end_QtXmlPatterns@
+
+
+ <suppress-warning text="Can't find qdoc3 file for class QMatrix4x3, tried: /home/hugo/src/pyside/build/doc/qdoc3-output/qmatrix4x3.xml" />
+ <suppress-warning text="Can't find qdoc3 file for class QMatrix3x4, tried: /home/hugo/src/pyside/build/doc/qdoc3-output/qmatrix3x4.xml" />
+ <suppress-warning text="Can't find qdoc3 file for class QMatrix2x3, tried: /home/hugo/src/pyside/build/doc/qdoc3-output/qmatrix2x3.xml" />
+ <suppress-warning text="Can't find qdoc3 file for class QMatrix4x2, tried: /home/hugo/src/pyside/build/doc/qdoc3-output/qmatrix4x2.xml" />
+ <suppress-warning text="Can't find qdoc3 file for class QMatrix3x3, tried: /home/hugo/src/pyside/build/doc/qdoc3-output/qmatrix3x3.xml" />
+ <suppress-warning text="Can't find qdoc3 file for class QMatrix2x2, tried: /home/hugo/src/pyside/build/doc/qdoc3-output/qmatrix2x2.xml" />
+ <suppress-warning text="Can't find qdoc3 file for class QMatrix3x2, tried: /home/hugo/src/pyside/build/doc/qdoc3-output/qmatrix3x2.xml" />
+ <suppress-warning text="Can't find qdoc3 file for class QMatrix2x4, tried: /home/hugo/src/pyside/build/doc/qdoc3-output/qmatrix2x4.xml" />
+
+ </typesystem>
diff --git a/sources/pyside2/header.BSD b/sources/pyside2/header.BSD
new file mode 100644
index 000000000..aa400a469
--- /dev/null
+++ b/sources/pyside2/header.BSD
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/header.BSD-OLD b/sources/pyside2/header.BSD-OLD
new file mode 100644
index 000000000..5d73a99e9
--- /dev/null
+++ b/sources/pyside2/header.BSD-OLD
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD-OLD$
+** 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$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/header.COMM b/sources/pyside2/header.COMM
new file mode 100644
index 000000000..1c8cb00e7
--- /dev/null
+++ b/sources/pyside2/header.COMM
@@ -0,0 +1,20 @@
+/******************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the <Fill> module.
+**
+** $QT_BEGIN_LICENSE:COMM$
+**
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** $QT_END_LICENSE$
+**
+******************************************************************************/
diff --git a/sources/pyside2/header.FDL b/sources/pyside2/header.FDL
new file mode 100644
index 000000000..90195db13
--- /dev/null
+++ b/sources/pyside2/header.FDL
@@ -0,0 +1,27 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/header.FDL-OLD b/sources/pyside2/header.FDL-OLD
new file mode 100644
index 000000000..58436c482
--- /dev/null
+++ b/sources/pyside2/header.FDL-OLD
@@ -0,0 +1,27 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL-OLD$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/header.GPL b/sources/pyside2/header.GPL
new file mode 100644
index 000000000..af4a1636b
--- /dev/null
+++ b/sources/pyside2/header.GPL
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 or (at your option) 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.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-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/header.GPL-EXCEPT b/sources/pyside2/header.GPL-EXCEPT
new file mode 100644
index 000000000..26ed5a245
--- /dev/null
+++ b/sources/pyside2/header.GPL-EXCEPT
@@ -0,0 +1,28 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/header.LGPL-NOGPL2 b/sources/pyside2/header.LGPL-NOGPL2
new file mode 100644
index 000000000..80b4449cb
--- /dev/null
+++ b/sources/pyside2/header.LGPL-NOGPL2
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-NOGPL2$
+** 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 3 or (at your option) 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.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-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/header.LGPL-ONLY b/sources/pyside2/header.LGPL-ONLY
new file mode 100644
index 000000000..9a676032e
--- /dev/null
+++ b/sources/pyside2/header.LGPL-ONLY
@@ -0,0 +1,22 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you have questions regarding the use of this file, please contact
+** us via http://www.qt.io/contact-us/.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
diff --git a/sources/pyside2/header.LGPL21 b/sources/pyside2/header.LGPL21
new file mode 100644
index 000000000..533390b07
--- /dev/null
+++ b/sources/pyside2/header.LGPL21
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/header.LGPL3 b/sources/pyside2/header.LGPL3
new file mode 100644
index 000000000..d9a65c2e4
--- /dev/null
+++ b/sources/pyside2/header.LGPL3
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/header.LGPL3-COMM b/sources/pyside2/header.LGPL3-COMM
new file mode 100644
index 000000000..b5dc15d38
--- /dev/null
+++ b/sources/pyside2/header.LGPL3-COMM
@@ -0,0 +1,28 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3-COMM$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/sources/pyside2/libpyside/CMakeLists.txt b/sources/pyside2/libpyside/CMakeLists.txt
new file mode 100644
index 000000000..481062caa
--- /dev/null
+++ b/sources/pyside2/libpyside/CMakeLists.txt
@@ -0,0 +1,166 @@
+project(libpyside)
+
+if(${Qt5Qml_FOUND})
+ if(NOT "${Qt5Qml_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQml/")
+ string(REPLACE "/QtCore" "/QtQml" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
+ list(APPEND Qt5Qml_PRIVATE_INCLUDE_DIRS ${replaceme})
+ list(REMOVE_DUPLICATES Qt5Qml_PRIVATE_INCLUDE_DIRS)
+ endif()
+endif()
+
+if(${Qt5Quick_FOUND})
+ if(NOT "${Qt5Quick_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQuick/")
+ string(REPLACE "/QtCore" "/QtQuick" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
+ list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${Qt5Qml_PRIVATE_INCLUDE_DIRS})
+ list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${replaceme})
+ list(REMOVE_DUPLICATES Qt5Quick_PRIVATE_INCLUDE_DIRS)
+ endif()
+endif()
+
+if(Qt5Qml_FOUND)
+ # Used for registering custom QQuickItem classes defined in Python code.
+ set(QML_SUPPORT 1)
+ set(QML_INCLUDES ${Qt5Qml_INCLUDE_DIRS})
+ set(QML_LIBRARIES ${Qt5Qml_LIBRARIES})
+
+ if(Qt5Qml_PRIVATE_INCLUDE_DIRS)
+ # Used for transforming QML exceptions into Python exceptions.
+ set(QML_PRIVATE_API_SUPPORT 1)
+ set(QML_INCLUDES ${QML_INCLUDES} ${Qt5Qml_PRIVATE_INCLUDE_DIRS})
+ else()
+ set(QML_PRIVATE_API_SUPPORT 0)
+ message(WARNING "QML private API include files could not be found, support for catching QML exceptions inside Python code will not work.")
+ endif()
+else()
+ set(QML_SUPPORT 0)
+ set(QML_PRIVATE_API_SUPPORT 0)
+ set(QML_INCLUDES "")
+ set(QML_LIBRARIES "")
+endif()
+
+qt5_wrap_cpp(DESTROYLISTENER_MOC "destroylistener.h")
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/signalmanager.cpp.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/signalmanager.cpp" @ONLY)
+
+set(libpyside_SRC
+ dynamicqmetaobject.cpp
+ destroylistener.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/signalmanager.cpp
+ globalreceiver.cpp
+ globalreceiverv2.cpp
+ pysideclassinfo.cpp
+ pysidemetafunction.cpp
+ pysidesignal.cpp
+ pysideslot.cpp
+ pysideproperty.cpp
+ pysideqflags.cpp
+ pysideweakref.cpp
+ pyside.cpp
+ ${DESTROYLISTENER_MOC}
+)
+
+# Add python files to project explorer in Qt Creator, when opening the CMakeLists.txt as a project,
+# so you can look up python files with the Locator.
+macro(add_other_files)
+ foreach(_it ${ARGN})
+ if(NOT IS_DIRECTORY ${_it})
+ get_filename_component(name ${_it} NAME)
+ if(NOT ${_it} MATCHES "^/\\\\..*$;~$")
+ set_source_files_properties(${_it} PROPERTIES HEADER_FILE_ONLY TRUE)
+ endif()
+ endif()
+ endforeach()
+endmacro()
+
+# Test files.
+file(GLOB_RECURSE pyside_folder_py_files "../*.py")
+
+# Example files.
+file(GLOB_RECURSE example_folder_py_files "../../pyside2-examples/*.py")
+
+# Mostly for setup.py.
+file(GLOB setup_folder_py_files "../../../*.py")
+
+set(other_files ${pyside_folder_py_files} ${example_folder_py_files} ${setup_folder_py_files})
+add_other_files(${other_files})
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR}
+ ${QML_INCLUDES}
+ ${Qt5Core_INCLUDE_DIRS})
+add_library(pyside2 SHARED ${libpyside_SRC} ${other_files})
+target_link_libraries(pyside2
+ ${SHIBOKEN_PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${QML_LIBRARIES}
+ ${Qt5Core_LIBRARIES})
+
+set_target_properties(pyside2 PROPERTIES
+ VERSION ${BINDING_API_VERSION}
+ SOVERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}"
+ OUTPUT_NAME "pyside2${pyside2_SUFFIX}${SHIBOKEN_PYTHON_EXTENSION_SUFFIX}"
+ DEFINE_SYMBOL PYSIDE_EXPORTS)
+
+if(Qt5Core_VERSION VERSION_GREATER "5.7.1")
+ set_property(TARGET pyside2 PROPERTY CXX_STANDARD 11)
+endif()
+
+if(QML_SUPPORT)
+ target_compile_definitions(pyside2 PUBLIC PYSIDE_QML_SUPPORT=1)
+endif()
+
+#
+# install stuff
+#
+
+set(libpyside_HEADERS
+ destroylistener.h
+ dynamicqmetaobject.h
+ globalreceiver.h
+ pysideclassinfo.h
+ pysideconversions.h
+ pysidemacros.h
+ signalmanager.h
+ pyside.h
+ pysidemetafunction.h
+ pysidesignal.h
+ pysideproperty.h
+ pysideqflags.h
+ pysideweakref.h
+)
+
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(LIBRARY_OUTPUT_SUFFIX ${CMAKE_DEBUG_POSTFIX})
+else()
+ set(LIBRARY_OUTPUT_SUFFIX ${CMAKE_RELEASE_POSTFIX})
+endif()
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D QT_NO_CAST_FROM_ASCII -D QT_NO_CAST_TO_ASCII")
+
+# create pkg-config file
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pyside2.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/pyside2${pyside2_SUFFIX}.pc" @ONLY)
+# create cmake-config files
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/PySide2Config.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/PySide2Config.cmake" @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/PySide2Config-spec.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/PySide2Config${SHIBOKEN_PYTHON_EXTENSION_SUFFIX}.cmake" @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/PySide2ConfigVersion.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/PySide2ConfigVersion.cmake" @ONLY)
+
+install(FILES ${libpyside_HEADERS}
+ DESTINATION include/${BINDING_NAME}${pyside2_SUFFIX})
+install(TARGETS pyside2 EXPORT pyside2
+ LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
+ ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
+ RUNTIME DESTINATION bin)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pyside2${pyside2_SUFFIX}.pc"
+ DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PySide2Config.cmake"
+ DESTINATION "${LIB_INSTALL_DIR}/cmake/PySide2-${BINDING_API_VERSION}")
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PySide2Config${SHIBOKEN_PYTHON_EXTENSION_SUFFIX}.cmake"
+ DESTINATION "${LIB_INSTALL_DIR}/cmake/PySide2-${BINDING_API_VERSION}")
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PySide2ConfigVersion.cmake"
+ DESTINATION "${LIB_INSTALL_DIR}/cmake/PySide2-${BINDING_API_VERSION}")
diff --git a/sources/pyside2/libpyside/PySide2Config-spec.cmake.in b/sources/pyside2/libpyside/PySide2Config-spec.cmake.in
new file mode 100644
index 000000000..205b6f10e
--- /dev/null
+++ b/sources/pyside2/libpyside/PySide2Config-spec.cmake.in
@@ -0,0 +1,18 @@
+# PYSIDE_INCLUDE_DIR - Directories to include to use PySide2
+# PYSIDE_LIBRARY - Files to link against to use PySide2
+# PYSIDE_PYTHONPATH - Path to where the PySide2 Python module files could be found
+# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide2
+
+SET(PYSIDE_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include/PySide2@pyside2_SUFFIX@")
+# Platform specific library names
+if(MSVC)
+ SET(PYSIDE_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@pyside2@pyside2_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@SHIBOKEN_PYTHON_EXTENSION_SUFFIX@.lib")
+elseif(CYGWIN)
+ SET(PYSIDE_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@pyside2@pyside2_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@SHIBOKEN_PYTHON_EXTENSION_SUFFIX@@CMAKE_IMPORT_LIBRARY_SUFFIX@")
+elseif(WIN32)
+ SET(PYSIDE_LIBRARY "@CMAKE_INSTALL_PREFIX@/bin/@CMAKE_SHARED_LIBRARY_PREFIX@pyside2@pyside2_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@SHIBOKEN_PYTHON_EXTENSION_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@")
+else()
+ SET(PYSIDE_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@pyside2@pyside2_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@SHIBOKEN_PYTHON_EXTENSION_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@")
+endif()
+SET(PYSIDE_PYTHONPATH "@SITE_PACKAGE@")
+SET(PYSIDE_TYPESYSTEMS "@CMAKE_INSTALL_PREFIX@/share/PySide2@pyside2_SUFFIX@/typesystems")
diff --git a/sources/pyside2/libpyside/PySide2Config.cmake.in b/sources/pyside2/libpyside/PySide2Config.cmake.in
new file mode 100644
index 000000000..cf3e6d1a6
--- /dev/null
+++ b/sources/pyside2/libpyside/PySide2Config.cmake.in
@@ -0,0 +1,5 @@
+if (NOT PYTHON_BASENAME)
+ message(STATUS "PySide2Config: Using default python: @SHIBOKEN_PYTHON_EXTENSION_SUFFIX@")
+ SET(PYTHON_BASENAME @SHIBOKEN_PYTHON_EXTENSION_SUFFIX@)
+endif()
+include(@LIB_INSTALL_DIR@/cmake/PySide2-@BINDING_API_VERSION@/PySide2Config${PYTHON_BASENAME}.cmake)
diff --git a/sources/pyside2/libpyside/PySide2ConfigVersion.cmake.in b/sources/pyside2/libpyside/PySide2ConfigVersion.cmake.in
new file mode 100644
index 000000000..f5073ce08
--- /dev/null
+++ b/sources/pyside2/libpyside/PySide2ConfigVersion.cmake.in
@@ -0,0 +1,10 @@
+set(PACKAGE_VERSION @BINDING_API_VERSION@)
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+endif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
diff --git a/sources/pyside2/libpyside/destroylistener.cpp b/sources/pyside2/libpyside/destroylistener.cpp
new file mode 100644
index 000000000..c1d3afb89
--- /dev/null
+++ b/sources/pyside2/libpyside/destroylistener.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "destroylistener.h"
+
+#include <QObject>
+#include <shiboken.h>
+#include <QDebug>
+#include <QMutex>
+
+PySide::DestroyListener* PySide::DestroyListener::m_instance = 0;
+
+namespace PySide
+{
+
+struct DestroyListenerPrivate
+{
+ static bool m_destroyed;
+};
+
+
+DestroyListener* DestroyListener::instance()
+{
+ if (!m_instance)
+ m_instance = new DestroyListener(0);
+ return m_instance;
+}
+
+void DestroyListener::destroy()
+{
+ if (m_instance) {
+ m_instance->disconnect();
+ delete m_instance;
+ m_instance = 0;
+ }
+}
+
+void DestroyListener::listen(QObject *obj)
+{
+ SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(obj);
+ if (!wrapper) // avoid problem with multiple inheritance
+ return;
+
+ if (Py_IsInitialized() == 0)
+ onObjectDestroyed(obj);
+ else
+ QObject::connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(onObjectDestroyed(QObject*)), Qt::DirectConnection);
+}
+
+void DestroyListener::onObjectDestroyed(QObject* obj)
+{
+ SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(obj);
+ if (wrapper) //make sure the object exists before destroy
+ Shiboken::Object::destroy(wrapper, obj);
+}
+
+DestroyListener::DestroyListener(QObject *parent)
+ : QObject(parent)
+{
+ m_d = new DestroyListenerPrivate();
+}
+
+DestroyListener::~DestroyListener()
+{
+ delete m_d;
+}
+
+}//namespace
+
diff --git a/sources/pyside2/libpyside/destroylistener.h b/sources/pyside2/libpyside/destroylistener.h
new file mode 100644
index 000000000..c4aa55494
--- /dev/null
+++ b/sources/pyside2/libpyside/destroylistener.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_DESTROY_LISTENER
+#define PYSIDE_DESTROY_LISTENER
+
+
+#include <QObject>
+#include "pysidemacros.h"
+
+namespace PySide
+{
+struct DestroyListenerPrivate;
+/// \deprecated This class is deprecated and isn't used by libpyside anymore.
+class PYSIDE_API DestroyListener : public QObject
+{
+ Q_OBJECT
+ public:
+ PYSIDE_DEPRECATED(static DestroyListener* instance());
+ static void destroy();
+ void listen(QObject* obj);
+
+ public slots:
+ void onObjectDestroyed(QObject* obj);
+
+ private:
+ static DestroyListener* m_instance;
+ DestroyListenerPrivate* m_d;
+ DestroyListener(QObject *parent);
+ ~DestroyListener();
+};
+
+}//namespace
+
+#endif
+
diff --git a/sources/pyside2/libpyside/dynamicqmetaobject.cpp b/sources/pyside2/libpyside/dynamicqmetaobject.cpp
new file mode 100644
index 000000000..651ed70c1
--- /dev/null
+++ b/sources/pyside2/libpyside/dynamicqmetaobject.cpp
@@ -0,0 +1,901 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "dynamicqmetaobject.h"
+#include "dynamicqmetaobject_p.h"
+#include "pysidesignal.h"
+#include "pysidesignal_p.h"
+#include "pysideproperty.h"
+#include "pysideproperty_p.h"
+#include "pysideslot_p.h"
+
+#include <QByteArray>
+#include <QString>
+#include <QStringList>
+#include <QList>
+#include <QLinkedList>
+#include <QObject>
+#include <cstring>
+#include <QDebug>
+#include <QMetaMethod>
+#include <shiboken.h>
+
+
+#define EMPTY_META_METHOD "0()"
+
+using namespace PySide;
+
+enum PropertyFlags {
+ Invalid = 0x00000000,
+ Readable = 0x00000001,
+ Writable = 0x00000002,
+ Resettable = 0x00000004,
+ EnumOrFlag = 0x00000008,
+ StdCppSet = 0x00000100,
+// Override = 0x00000200,
+ Constant = 0x00000400,
+ Final = 0x00000800,
+ Designable = 0x00001000,
+ ResolveDesignable = 0x00002000,
+ Scriptable = 0x00004000,
+ ResolveScriptable = 0x00008000,
+ Stored = 0x00010000,
+ ResolveStored = 0x00020000,
+ Editable = 0x00040000,
+ ResolveEditable = 0x00080000,
+ User = 0x00100000,
+ ResolveUser = 0x00200000,
+ Notify = 0x00400000
+};
+
+// these values are from moc source code, generator.cpp:66
+enum MethodFlags {
+ AccessPrivate = 0x00,
+ AccessProtected = 0x01,
+ AccessPublic = 0x02,
+ MethodMethod = 0x00,
+ MethodSignal = 0x04,
+ MethodSlot = 0x08,
+ MethodConstructor = 0x0c,
+ MethodCompatibility = 0x10,
+ MethodCloned = 0x20,
+ MethodScriptable = 0x40
+};
+
+enum MetaDataFlags {
+ IsUnresolvedType = 0x80000000,
+ TypeNameIndexMask = 0x7FFFFFFF
+};
+
+class DynamicQMetaObject::DynamicQMetaObjectPrivate
+{
+public:
+ QList<MethodData> m_methods;
+ QList<PropertyData> m_properties;
+
+ QMap<QByteArray, QByteArray> m_info;
+ QByteArray m_className;
+ bool m_updated; // when the meta data is not update
+ int m_methodOffset;
+ int m_propertyOffset;
+ int m_dataSize;
+ int m_emptyMethod;
+ int m_nullIndex;
+
+ DynamicQMetaObjectPrivate()
+ : m_updated(false), m_methodOffset(0), m_propertyOffset(0),
+ m_dataSize(0), m_emptyMethod(-1), m_nullIndex(0) {}
+
+ int createMetaData(QMetaObject* metaObj, QLinkedList<QByteArray> &strings);
+ void updateMetaObject(QMetaObject* metaObj);
+ void writeMethodsData(const QList<MethodData>& methods, unsigned int** data, QLinkedList<QByteArray>& strings, int* prtIndex, int nullIndex, int flags);
+ void writeStringData(char *, QLinkedList<QByteArray> &strings);
+ int getPropertyNotifyId(PySideProperty *property) const;
+};
+
+bool sortMethodSignalSlot(const MethodData &m1, const MethodData &m2)
+{
+ if (m1.methodType() == QMetaMethod::Signal)
+ return m2.methodType() == QMetaMethod::Slot;
+ return false;
+}
+
+static int registerString(const QByteArray& s, QLinkedList<QByteArray>& strings)
+{
+ int idx = 0;
+ QLinkedList<QByteArray>::const_iterator it = strings.begin();
+ QLinkedList<QByteArray>::const_iterator itEnd = strings.end();
+ while (it != itEnd) {
+ if (strcmp(*it, s) == 0)
+ return idx;
+ ++idx;
+ ++it;
+ }
+ strings.append(s);
+ return idx;
+}
+
+static int blobSize(QLinkedList<QByteArray> &strings)
+{
+ int size = strings.size() * sizeof(QByteArrayData);
+
+ QByteArray str;
+ QByteArray debug_str;
+ foreach (const QByteArray &field, strings) {
+ str.append(field);
+ str.append(char(0));
+
+ debug_str.append(field);
+ debug_str.append('|');
+ }
+ //qDebug()<<debug_str;
+ size += str.size();
+ return size;
+}
+
+static int aggregateParameterCount(const QList<MethodData> &methods)
+{
+ int sum = 0;
+ for (int i = 0; i < methods.size(); ++i)
+ sum += methods.at(i).parameterCount() * 2 + 1; // nb_param*2 (type and names) +1 for return type
+ return sum;
+}
+
+static void writeString(char *out, int i, const QByteArray &str,
+ const int offsetOfStringdataMember, int &stringdataOffset)
+{
+ int size = str.size();
+ qptrdiff offset = offsetOfStringdataMember + stringdataOffset
+ - i * sizeof(QByteArrayData);
+ const QByteArrayData data =
+ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset);
+
+ memcpy(out + i * sizeof(QByteArrayData), &data, sizeof(QByteArrayData));
+
+ memcpy(out + offsetOfStringdataMember + stringdataOffset, str.constData(), size);
+ out[offsetOfStringdataMember + stringdataOffset + size] = '\0';
+
+ stringdataOffset += size + 1;
+}
+
+static int qvariant_nameToType(const char* name)
+{
+ if (!name)
+ return 0;
+
+ if (strcmp(name, "QVariant") == 0)
+ return 0xffffffff;
+ if (strcmp(name, "QCString") == 0)
+ return QMetaType::QByteArray;
+ if (strcmp(name, "Q_LLONG") == 0)
+ return QMetaType::LongLong;
+ if (strcmp(name, "Q_ULLONG") == 0)
+ return QMetaType::ULongLong;
+ if (strcmp(name, "QIconSet") == 0)
+ return QMetaType::QIcon;
+
+ uint tp = QMetaType::type(name);
+ return tp < QMetaType::User ? tp : 0;
+}
+
+/*
+ Returns true if the type is a QVariant types.
+*/
+static bool isVariantType(const char* type)
+{
+ return qvariant_nameToType(type) != 0;
+}
+
+/*!
+ Returns true if the type is qreal.
+*/
+static bool isQRealType(const char *type)
+{
+ return strcmp(type, "qreal") == 0;
+}
+
+uint PropertyData::flags() const
+{
+ const QByteArray btype(type());
+ const char* typeName = btype.data();
+ uint flags = Invalid;
+ if (!isVariantType(typeName))
+ flags |= EnumOrFlag;
+ else if (!isQRealType(typeName))
+ flags |= qvariant_nameToType(typeName) << 24;
+
+ if (PySide::Property::isReadable(m_data))
+ flags |= Readable;
+
+ if (PySide::Property::isWritable(m_data))
+ flags |= Writable;
+
+ if (PySide::Property::hasReset(m_data))
+ flags |= Resettable;
+
+ if (PySide::Property::isDesignable(m_data))
+ flags |= Designable;
+ else
+ flags |= ResolveDesignable;
+
+ if (PySide::Property::isScriptable(m_data))
+ flags |= Scriptable;
+ else
+ flags |= ResolveScriptable;
+
+ if (PySide::Property::isStored(m_data))
+ flags |= Stored;
+ else
+ flags |= ResolveStored;
+
+ //EDITABLE
+ flags |= ResolveEditable;
+
+ if (PySide::Property::isUser(m_data))
+ flags |= User;
+ else
+ flags |= ResolveUser;
+
+ if (m_cachedNotifyId != -1)
+ flags |= Notify;
+
+ if (PySide::Property::isConstant(m_data))
+ flags |= Constant;
+
+ if (PySide::Property::isFinal(m_data))
+ flags |= Final;
+
+ return flags;
+}
+
+// const QByteArray with EMPTY_META_METHOD, used to save some memory
+const QByteArray MethodData::m_emptySig(EMPTY_META_METHOD);
+
+MethodData::MethodData()
+ : m_signature(m_emptySig)
+{
+}
+
+MethodData::MethodData(QMetaMethod::MethodType mtype, const QByteArray& signature, const QByteArray& rtype)
+ : m_signature(QMetaObject::normalizedSignature(signature.constData()))
+ , m_rtype(QMetaObject::normalizedSignature(rtype.constData()))
+ , m_mtype(mtype)
+{
+}
+
+void MethodData::clear()
+{
+ m_signature = m_emptySig;
+ m_rtype.clear();
+}
+
+bool MethodData::isValid() const
+{
+ return m_signature != m_emptySig;
+}
+
+QList<QByteArray> MethodData::parameterTypes() const
+{
+ const char *signature = m_signature.constData();
+ QList<QByteArray> list;
+ while (*signature && *signature != '(')
+ ++signature;
+ while (*signature && *signature != ')' && *++signature != ')') {
+ const char *begin = signature;
+ int level = 0;
+ while (*signature && (level > 0 || *signature != ',') && *signature != ')') {
+ if (*signature == '<')
+ ++level;
+ else if (*signature == '>')
+ --level;
+ ++signature;
+ }
+ list += QByteArray(begin, signature - begin);
+ }
+ return list;
+}
+
+int MethodData::parameterCount() const
+{
+ return parameterTypes().size();
+}
+
+QByteArray MethodData::name() const
+{
+ return m_signature.left(qMax(m_signature.indexOf('('), 0));
+}
+
+PropertyData::PropertyData()
+ : m_cachedNotifyId(0), m_data(0)
+{
+}
+
+PropertyData::PropertyData(const char* name, int notifyId, PySideProperty* data)
+ : m_name(name), m_cachedNotifyId(notifyId), m_data(data)
+{
+}
+
+QByteArray PropertyData::type() const
+{
+ return QByteArray(PySide::Property::getTypeName(m_data));
+}
+
+
+bool PropertyData::isValid() const
+{
+ return !m_name.isEmpty();
+}
+
+int PropertyData::cachedNotifyId() const
+{
+ return m_cachedNotifyId;
+}
+
+bool PropertyData::operator==(const PropertyData& other) const
+{
+ return m_data == other.m_data;
+}
+
+bool PropertyData::operator==(const char* name) const
+{
+ return m_name == name;
+}
+
+
+DynamicQMetaObject::DynamicQMetaObject(PyTypeObject* type, const QMetaObject* base)
+ : m_d(new DynamicQMetaObjectPrivate)
+{
+ d.superdata = base;
+ d.stringdata = NULL;
+ d.data = NULL;
+ d.extradata = NULL;
+ d.relatedMetaObjects = NULL;
+ d.static_metacall = NULL;
+
+ m_d->m_className = QByteArray(type->tp_name).split('.').last();
+ m_d->m_methodOffset = base->methodCount() - 1;
+ m_d->m_propertyOffset = base->propertyCount() - 1;
+ parsePythonType(type);
+}
+
+DynamicQMetaObject::DynamicQMetaObject(const char* className, const QMetaObject* metaObject)
+ : m_d(new DynamicQMetaObjectPrivate)
+{
+ d.superdata = metaObject;
+ d.stringdata = 0;
+ d.data = 0;
+ d.extradata = 0;
+ d.relatedMetaObjects = NULL;
+ d.static_metacall = NULL;
+
+ m_d->m_className = className;
+ m_d->m_methodOffset = metaObject->methodCount() - 1;
+ m_d->m_propertyOffset = metaObject->propertyCount() - 1;
+}
+
+DynamicQMetaObject::~DynamicQMetaObject()
+{
+ free(reinterpret_cast<char *>(const_cast<QByteArrayData *>(d.stringdata)));
+ free(const_cast<uint*>(d.data));
+ delete m_d;
+}
+
+int DynamicQMetaObject::addMethod(QMetaMethod::MethodType mtype, const char* signature, const char* type)
+{
+ int index = -1;
+ int counter = 0;
+
+ QList<MethodData>::iterator it = m_d->m_methods.begin();
+ for (; it != m_d->m_methods.end(); ++it) {
+ if ((it->signature() == signature) && (it->methodType() == mtype))
+ return m_d->m_methodOffset + counter;
+ else if (!it->isValid()) {
+ index = counter;
+ }
+ counter++;
+ }
+
+ // Common mistake not to add parentheses to the signature.
+ if ((strchr(signature, ')') == 0) || ((strchr(signature, '(') == 0))) {
+ const QString message =
+ QLatin1String("DynamicQMetaObject::addMethod: Invalid method signature "
+ "provided for ") + QLatin1String(signature);
+ const QByteArray messageLatin = message.toLatin1();
+ PyErr_WarnEx(PyExc_RuntimeWarning, messageLatin.constData(), 0);
+ return -1;
+ }
+
+ //has blank method
+ if (index != -1) {
+ m_d->m_methods[index] = MethodData(mtype, signature, type);
+ index++;
+ } else {
+ m_d->m_methods << MethodData(mtype, signature, type);
+ index = m_d->m_methods.size();
+ }
+
+ m_d->m_updated = false;
+ return m_d->m_methodOffset + index;
+}
+
+void DynamicQMetaObject::removeMethod(QMetaMethod::MethodType mtype, uint index)
+{
+ const char* methodSig = method(index).methodSignature();
+ QList<MethodData>::iterator it = m_d->m_methods.begin();
+ for (; it != m_d->m_methods.end(); ++it) {
+ if ((it->signature() == methodSig) && (it->methodType() == mtype)){
+ it->clear();
+ m_d->m_updated = false;
+ break;
+ }
+ }
+}
+
+int DynamicQMetaObject::addSignal(const char* signal, const char* type)
+{
+ return addMethod(QMetaMethod::Signal, signal, type);
+}
+
+int DynamicQMetaObject::addSlot(const char* slot, const char* type)
+{
+ return addMethod(QMetaMethod::Slot, slot, type);
+}
+
+void DynamicQMetaObject::removeSlot(uint index)
+{
+ removeMethod(QMetaMethod::Slot, index);
+}
+
+void DynamicQMetaObject::removeSignal(uint index)
+{
+ removeMethod(QMetaMethod::Signal, index);
+}
+
+int DynamicQMetaObject::addProperty(const char* propertyName, PyObject* data)
+{
+ int index = m_d->m_properties.indexOf(propertyName);
+ if (index != -1)
+ return m_d->m_propertyOffset + index;
+
+ // retrieve notifyId
+ PySideProperty *property = reinterpret_cast<PySideProperty *>(data);
+ const int notifyId = m_d->getPropertyNotifyId(property);
+
+ //search for a empty space
+ PropertyData blank;
+ index = m_d->m_properties.indexOf(blank);
+ if (index != -1) {
+ m_d->m_properties[index] = PropertyData(propertyName, notifyId, property);
+ } else {
+ m_d->m_properties << PropertyData(propertyName, notifyId, property);
+ index = m_d->m_properties.size();
+ }
+ m_d->m_updated = false;
+ return m_d->m_propertyOffset + index;
+}
+
+int DynamicQMetaObject::DynamicQMetaObjectPrivate::getPropertyNotifyId(PySideProperty *property) const
+{
+ int notifyId = -1;
+ if (property->d->notify) {
+ const char *signalNotify = PySide::Property::getNotifyName(property);
+ if (signalNotify) {
+ const MethodData signalObject(QMetaMethod::Signal, signalNotify, "");
+ notifyId = m_methods.indexOf(signalObject);
+ }
+ }
+ return notifyId;
+}
+
+void DynamicQMetaObject::addInfo(const char* key, const char* value)
+{
+ m_d->m_info[key] = value;
+}
+
+void DynamicQMetaObject::addInfo(QMap<QByteArray, QByteArray> info)
+{
+ QMap<QByteArray, QByteArray>::const_iterator i = info.constBegin();
+ while (i != info.constEnd()) {
+ m_d->m_info[i.key()] = i.value();
+ ++i;
+ }
+ m_d->m_updated = false;
+}
+
+const QMetaObject* DynamicQMetaObject::update() const
+{
+ if (!m_d->m_updated) {
+ m_d->updateMetaObject(const_cast<DynamicQMetaObject*>(this));
+ m_d->m_updated = true;
+ }
+ return this;
+}
+
+void DynamicQMetaObject::DynamicQMetaObjectPrivate::writeMethodsData(const QList<MethodData>& methods,
+ unsigned int** data,
+ QLinkedList<QByteArray>& strings,
+ int* prtIndex,
+ int nullIndex,
+ int flags)
+{
+ int index = *prtIndex;
+ int paramsIndex = index + methods.count() * 5;
+
+ QList<MethodData>::const_iterator it = methods.begin();
+
+ if (m_emptyMethod == -1)
+ m_emptyMethod = registerString(EMPTY_META_METHOD, strings);
+
+ for (; it != methods.end(); ++it) {
+ int name_idx = 0;
+ int argc = it->parameterCount();
+ if (it->signature() != EMPTY_META_METHOD)
+ name_idx = registerString(it->name(), strings);
+ else
+ name_idx = m_emptyMethod; // func name
+
+ (*data)[index++] = name_idx;
+ (*data)[index++] = argc; // argc (previously: arg name)
+ (*data)[index++] = paramsIndex; //parameter index
+ (*data)[index++] = nullIndex; // tags
+ (*data)[index++] = flags | (it->methodType() == QMetaMethod::Signal ? MethodSignal : MethodSlot);
+
+ if (it->methodType() == QMetaMethod::Signal)
+ (*data)[13] += 1; //signal count
+
+ paramsIndex += 1 + argc * 2;
+ }
+ *prtIndex = index;
+}
+
+void DynamicQMetaObject::parsePythonType(PyTypeObject *type)
+{
+ // Get all non-QObject-derived base types in method resolution order, filtering out the types
+ // that can't have signals, slots or properties.
+ // This enforces registering of all signals and slots at type parsing time, and not later at
+ // signal connection time, thus making sure no method indices change which would break
+ // existing connections.
+ const PyObject *mro = type->tp_mro;
+ const Py_ssize_t basesCount = PyTuple_GET_SIZE(mro);
+ PyTypeObject *qObjectType = Shiboken::Conversions::getPythonTypeObject("QObject*");
+ QVector<PyTypeObject *> basesToCheck;
+ for (Py_ssize_t i = 0; i < basesCount; ++i) {
+ PyTypeObject *baseType = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, i));
+ if (PyType_IsSubtype(baseType, qObjectType)
+ || baseType == reinterpret_cast<PyTypeObject *>(&SbkObject_Type)
+ || baseType == reinterpret_cast<PyTypeObject *>(&PyBaseObject_Type)) {
+ continue;
+ } else {
+ basesToCheck.append(baseType);
+ }
+ }
+
+ // Prepend the actual type that we are parsing.
+ basesToCheck.prepend(type);
+ // PYSIDE-315: Handle all signals first, in all involved types.
+ for (int baseIndex = 0, baseEnd = basesToCheck.size(); baseIndex < baseEnd; ++baseIndex) {
+ PyTypeObject *baseType = basesToCheck[baseIndex];
+ PyObject *attrs = baseType->tp_dict;
+ PyObject *key = 0;
+ PyObject *value = 0;
+ Py_ssize_t pos = 0;
+
+ while (PyDict_Next(attrs, &pos, &key, &value)) {
+ if (Signal::checkType(value)) {
+ // Register signals.
+ PySideSignal *data = reinterpret_cast<PySideSignal *>(value);
+ const char *signalName = Shiboken::String::toCString(key);
+ data->signalName = strdup(signalName);
+ QByteArray sig;
+ sig.reserve(128);
+ for (int i = 0; i < data->signaturesSize; ++i) {
+ sig = signalName;
+ sig += '(';
+ if (data->signatures[i])
+ sig += data->signatures[i];
+ sig += ')';
+ if (d.superdata->indexOfSignal(sig) == -1)
+ addSignal(sig, "void");
+ }
+ }
+ }
+ }
+
+ Shiboken::AutoDecRef slotAttrName(Shiboken::String::fromCString(PYSIDE_SLOT_LIST_ATTR));
+ // PYSIDE-315: Now take care of the rest.
+ // Signals and slots should be separated, unless the types are modified, later.
+ // We check for this using "is_sorted()". Sorting no longer happens at all.
+ for (int baseIndex = 0, baseEnd = basesToCheck.size(); baseIndex < baseEnd; ++baseIndex) {
+ PyTypeObject *baseType = basesToCheck[baseIndex];
+ PyObject *attrs = baseType->tp_dict;
+ PyObject *key = 0;
+ PyObject *value = 0;
+ Py_ssize_t pos = 0;
+
+ typedef std::pair<const char *, PyObject *> PropPair;
+ QVector<PropPair> properties;
+
+ while (PyDict_Next(attrs, &pos, &key, &value)) {
+ if (Property::checkType(value)) {
+ // Leave the properties to be registered after signals because they may depend on
+ // notify signals.
+ int index = d.superdata->indexOfProperty(Shiboken::String::toCString(key));
+ if (index == -1)
+ properties << PropPair(Shiboken::String::toCString(key), value);
+ } else if (PyFunction_Check(value)) {
+ // Register slots.
+ if (PyObject_HasAttr(value, slotAttrName)) {
+ PyObject *signatureList = PyObject_GetAttr(value, slotAttrName);
+ for (Py_ssize_t i = 0, i_max = PyList_Size(signatureList); i < i_max; ++i) {
+ PyObject *signature = PyList_GET_ITEM(signatureList, i);
+ QByteArray sig(Shiboken::String::toCString(signature));
+ // Split the slot type and its signature.
+ QList<QByteArray> slotInfo = sig.split(' ');
+ int index = d.superdata->indexOfSlot(slotInfo[1]);
+ if (index == -1)
+ addSlot(slotInfo[1], slotInfo[0]);
+ }
+ }
+ }
+ }
+
+ // Register properties
+ foreach (const PropPair &propPair, properties)
+ addProperty(propPair.first, propPair.second);
+ }
+}
+
+/*!
+ Allocate the meta data table.
+ Returns the index in the table corresponding to the header fields count.
+*/
+int DynamicQMetaObject::DynamicQMetaObjectPrivate::createMetaData(QMetaObject* metaObj, QLinkedList<QByteArray> &strings)
+{
+ const int n_methods = m_methods.size();
+ const int n_properties = m_properties.size();
+ const int n_info = m_info.size();
+
+ int header[] = {7, // revision (Used by moc, qmetaobjectbuilder and qdbus)
+ 0, // class name index in m_metadata
+ n_info, 0, // classinfo and classinfo index
+ n_methods, 0, // method count and method list index
+ n_properties, 0, // prop count and prop indexes
+ 0, 0, // enum count and enum index
+ 0, 0, // constructors (since revision 2)
+ 0, // flags (since revision 3)
+ 0}; // signal count (since revision 4)
+
+ const int HEADER_LENGHT = sizeof(header)/sizeof(int);
+
+ m_dataSize = HEADER_LENGHT;
+ m_dataSize += n_info*2; //class info: name, value
+ m_dataSize += n_methods*5; //method: name, argc, parameters, tag, flags
+ m_dataSize += n_properties*4; //property: name, type, flags
+ m_dataSize += 1; //eod
+
+ m_dataSize += aggregateParameterCount(m_methods); // types and parameter names
+
+ uint* data = reinterpret_cast<uint*>(realloc(const_cast<uint*>(metaObj->d.data), m_dataSize * sizeof(uint)));
+
+ Q_ASSERT(data);
+ std::memcpy(data, header, sizeof(header));
+
+ metaObj->d.data = data;
+
+ return HEADER_LENGHT;
+}
+
+// Writes strings to string data struct.
+// The struct consists of an array of QByteArrayData, followed by a char array
+// containing the actual strings. This format must match the one produced by
+// moc (see generator.cpp).
+void DynamicQMetaObject::DynamicQMetaObjectPrivate::writeStringData(char *out, QLinkedList<QByteArray> &strings)
+{
+ Q_ASSERT(!(reinterpret_cast<quintptr>(out) & (Q_ALIGNOF(QByteArrayData)-1)));
+
+ int offsetOfStringdataMember = strings.size() * sizeof(QByteArrayData);
+ int stringdataOffset = 0;
+ int i = 0;
+ foreach(const QByteArray& str, strings) {
+ writeString(out, i, str, offsetOfStringdataMember, stringdataOffset);
+ i++;
+ }
+}
+
+QList<MethodData>::iterator is_sorted_until(QList<MethodData>::iterator first,
+ QList<MethodData>::iterator last,
+ bool comp(const MethodData &m1, const MethodData &m2))
+{
+ if (first != last) {
+ QList<MethodData>::iterator next = first;
+ while (++next != last) {
+ if (comp(*next, *first))
+ return next;
+ ++first;
+ }
+ }
+ return last;
+}
+
+bool is_sorted(QList<MethodData>::iterator first, QList<MethodData>::iterator last,
+ bool comp(const MethodData &m1, const MethodData &m2))
+{
+ return is_sorted_until(first, last, comp) == last;
+}
+
+void DynamicQMetaObject::DynamicQMetaObjectPrivate::updateMetaObject(QMetaObject* metaObj)
+{
+ Q_ASSERT(!m_updated);
+ uint *data = const_cast<uint*>(metaObj->d.data);
+ int index = 0;
+ QLinkedList<QByteArray> strings;
+ m_dataSize = 0;
+
+ // Recompute the size and reallocate memory
+ // index is set after the last header field.
+ index = createMetaData(metaObj, strings);
+ data = const_cast<uint*>(metaObj->d.data);
+
+ registerString(m_className, strings); // register class string
+ m_nullIndex = registerString("", strings); // register a null string
+
+ // Write class info.
+ if (m_info.size()) {
+ if (data[3] == 0)
+ data[3] = index;
+
+ QMap<QByteArray, QByteArray>::const_iterator i = m_info.constBegin(); //TODO: info is a hash this can fail
+ while (i != m_info.constEnd()) {
+ int valueIndex = registerString(i.value(), strings);
+ int keyIndex = registerString(i.key(), strings);
+ data[index++] = keyIndex;
+ data[index++] = valueIndex;
+ i++;
+ }
+ }
+
+ // Write methods first, then properties, to be consistent with moc.
+ // Write signals/slots (signals must be written first, see indexOfMethodRelative in
+ // qmetaobject.cpp).
+
+ QList<MethodData>::iterator it;
+ // PYSIDE-315: Instead of sorting the items and maybe breaking indices,
+ // we ensure that the signals and slots are sorted by the improved parsePythonType().
+ // The order can only become distorted if the class is modified after creation.
+ // In that case, we give a warning.
+ if (!is_sorted(m_methods.begin(), m_methods.end(), sortMethodSignalSlot)) {
+ const char *metaObjectName = this->m_className.data();
+ PyObject *txt = PyBytes_FromFormat("\n\n*** Sort Warning ***\n"
+ "Signals and slots in QMetaObject '%s' are not ordered correctly, "
+ "this may lead to issues.\n", metaObjectName);
+ it = m_methods.begin();
+ QList<MethodData>::iterator end = m_methods.end();
+ QList<MethodData>::iterator until = is_sorted_until(m_methods.begin(), m_methods.end(),
+ sortMethodSignalSlot);
+ for (; it != end; ++it) {
+ PyObject *atxt = PyBytes_FromFormat("%d%s %s %s\n", it - m_methods.begin() + 1,
+ until >= it + 1 ? " " : "!",
+ it->methodType() == QMetaMethod::Signal ? "Signal" : "Slot ",
+ it->signature().data() );
+ PyBytes_ConcatAndDel(&txt, atxt);
+ }
+ PyErr_WarnEx(PyExc_RuntimeWarning, PyBytes_AsString(txt), 0);
+ Py_DECREF(txt);
+ // Prevent a warning from being turned into an error. We cannot easily unwind.
+ PyErr_Clear();
+ }
+
+ if (m_methods.size()) {
+ if (data[5] == 0)
+ data[5] = index;
+
+ writeMethodsData(m_methods, &data, strings, &index, m_nullIndex, AccessPublic);
+ }
+
+ // Write signal/slots parameters.
+ if (m_methods.size()) {
+ for (it = m_methods.begin(); it != m_methods.end(); ++it) {
+ QList<QByteArray> paramTypeNames = it->parameterTypes();
+ int paramCount = paramTypeNames.size();
+ for (int i = -1; i < paramCount; ++i) {
+ const QByteArray &typeName = (i < 0) ? it->returnType() : paramTypeNames.at(i);
+ int typeInfo;
+ if (QtPrivate::isBuiltinType(typeName))
+ typeInfo = QMetaType::type(typeName);
+ else
+ typeInfo = IsUnresolvedType | registerString(typeName, strings);
+ data[index++] = typeInfo;
+ }
+
+ // Parameter names (use a null string)
+ for (int i = 0; i < paramCount; ++i) {
+ data[index++] = m_nullIndex;
+ }
+ }
+ }
+
+ // Write properties.
+ if (m_properties.size()) {
+ if (data[7] == 0)
+ data[7] = index;
+
+ QList<PropertyData>::const_iterator i = m_properties.constBegin();
+ while (i != m_properties.constEnd()) {
+ if (i->isValid()) {
+ data[index++] = registerString(i->name(), strings); // name
+ } else
+ data[index++] = m_nullIndex;
+
+ // Find out the property type index.
+ int typeInfo = m_nullIndex;
+ if (i->isValid()) {
+ const QByteArray &typeName = i->type();
+ if (QtPrivate::isBuiltinType(typeName))
+ typeInfo = QMetaType::type(typeName);
+ else
+ typeInfo = IsUnresolvedType | registerString(typeName, strings);
+ }
+ data[index++] = typeInfo; // normalized type
+
+ data[index++] = i->flags();
+ i++;
+ }
+
+ // Write properties notify.
+ i = m_properties.constBegin();
+ while (i != m_properties.constEnd()) {
+ // Recompute notifyId, because sorting the methods might have changed the relative
+ // index.
+ const int notifyId = getPropertyNotifyId(i->data());
+ data[index++] = notifyId >= 0 ? static_cast<uint>(notifyId) : 0; //signal notify index
+ i++;
+ }
+ }
+
+ data[index++] = 0; // the end
+
+ // Create the m_metadata string.
+ int size = blobSize(strings);
+ char *blob =
+ reinterpret_cast<char *>(realloc(reinterpret_cast<char *>(const_cast<QByteArrayData *>(metaObj->d.stringdata)), size));
+ writeStringData(blob, strings);
+
+ metaObj->d.stringdata = reinterpret_cast<const QByteArrayData *>(blob);
+ metaObj->d.data = data;
+}
diff --git a/sources/pyside2/libpyside/dynamicqmetaobject.h b/sources/pyside2/libpyside/dynamicqmetaobject.h
new file mode 100644
index 000000000..ac8f4644d
--- /dev/null
+++ b/sources/pyside2/libpyside/dynamicqmetaobject.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 DYNAMICQMETAOBJECT_H
+#define DYNAMICQMETAOBJECT_H
+
+#include "pysidemacros.h"
+#include <sbkpython.h>
+#include <QMetaObject>
+#include <QMetaMethod>
+
+namespace PySide
+{
+
+class DynamicQMetaObject : public QMetaObject
+{
+public:
+ DynamicQMetaObject(const char* className, const QMetaObject* metaObject);
+ DynamicQMetaObject(PyTypeObject* type, const QMetaObject* metaobject);
+ ~DynamicQMetaObject();
+
+
+ int addMethod(QMetaMethod::MethodType mtype, const char* signature, const char* type);
+ void removeMethod(QMetaMethod::MethodType mtype, uint index);
+ int addSignal(const char* signal, const char* type = 0);
+ int addSlot(const char* slot, const char* type = 0);
+ int addProperty(const char* property, PyObject* data);
+ void addInfo(const char* key, const char* value);
+ void addInfo(QMap<QByteArray, QByteArray> info);
+
+ void removeSignal(uint idex);
+ void removeSlot(uint index);
+ void removeProperty(uint index);
+
+ const QMetaObject* update() const;
+
+private:
+ class DynamicQMetaObjectPrivate;
+ DynamicQMetaObjectPrivate* m_d;
+
+ void parsePythonType(PyTypeObject *type);
+};
+
+
+}
+#endif
diff --git a/sources/pyside2/libpyside/dynamicqmetaobject_p.h b/sources/pyside2/libpyside/dynamicqmetaobject_p.h
new file mode 100644
index 000000000..202e87b08
--- /dev/null
+++ b/sources/pyside2/libpyside/dynamicqmetaobject_p.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 DYNAMICMETAPROPERTY_P_H
+#define DYNAMICMETAPROPERTY_P_H
+
+#include <sbkpython.h>
+#include <QByteArray>
+#include <QMetaMethod>
+
+#define GLOBAL_RECEIVER_CLASS_NAME "__GlobalReceiver__"
+
+struct PySideProperty;
+namespace PySide
+{
+ class MethodData
+ {
+ public:
+ MethodData();
+ /**
+ * \param signature method signature
+ * \param type method return type
+ */
+ MethodData(QMetaMethod::MethodType mtype,
+ const QByteArray& signature,
+ const QByteArray& rtype = QByteArray("void"));
+ void clear();
+ bool isValid() const;
+ const QByteArray& signature() const { return m_signature; }
+ const QByteArray& returnType() const { return m_rtype; }
+ QMetaMethod::MethodType methodType() const { return m_mtype; }
+ //Qt5 moc: now we have to store method parameter names, count, type
+ QList<QByteArray> parameterTypes() const;
+ int parameterCount() const;
+ QByteArray name() const;
+ bool operator==(const MethodData& other) const;
+
+ private:
+ QByteArray m_signature;
+ QByteArray m_rtype;
+ QMetaMethod::MethodType m_mtype;
+ static const QByteArray m_emptySig;
+ };
+
+ class PropertyData
+ {
+ public:
+ PropertyData();
+ PropertyData(const char *name, int cachedNotifyId = 0, PySideProperty *data = 0);
+ const QByteArray& name() const { return m_name; }
+ PySideProperty *data() const { return m_data; }
+ QByteArray type() const;
+ uint flags() const;
+ bool isValid() const;
+ int cachedNotifyId() const;
+ bool operator==(const PropertyData& other) const;
+ bool operator==(const char* name) const;
+
+ private:
+ QByteArray m_name;
+ int m_cachedNotifyId;
+ PySideProperty* m_data;
+ };
+
+inline bool MethodData::operator==(const MethodData& other) const
+{
+ return m_mtype == other.methodType() && m_signature == other.signature();
+}
+
+}
+
+#endif
diff --git a/sources/pyside2/libpyside/globalreceiver.cpp b/sources/pyside2/libpyside/globalreceiver.cpp
new file mode 100644
index 000000000..e183e09ba
--- /dev/null
+++ b/sources/pyside2/libpyside/globalreceiver.cpp
@@ -0,0 +1,330 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "globalreceiver.h"
+#include "dynamicqmetaobject_p.h"
+#include "pysideweakref.h"
+
+#include <QMetaMethod>
+#include <QDebug>
+#include <QEvent>
+#include <QLinkedList>
+#include <autodecref.h>
+#include <sbkconverter.h>
+#include <gilstate.h>
+
+#include "typeresolver.h"
+#include "signalmanager.h"
+
+#define RECEIVER_DESTROYED_SLOT_NAME "__receiverDestroyed__(QObject*)"
+
+namespace PySide
+{
+class DynamicSlotData
+{
+ public:
+ DynamicSlotData(int id, PyObject* callback, GlobalReceiver* parent);
+ void addRef(const QObject* o);
+ void decRef(const QObject* o);
+ void clear();
+ int hasRefTo(const QObject* o) const;
+ int refCount() const;
+ int id() const;
+ PyObject* call(PyObject* args);
+ ~DynamicSlotData();
+ static void onCallbackDestroyed(void* data);
+
+ private:
+ int m_id;
+ bool m_isMethod;
+ PyObject* m_callback;
+ PyObject* m_pythonSelf;
+ PyObject* m_pyClass;
+ PyObject* m_weakRef;
+ GlobalReceiver* m_parent;
+ QLinkedList<const QObject*> m_refs;
+};
+
+}
+
+using namespace PySide;
+
+DynamicSlotData::DynamicSlotData(int id, PyObject* callback, GlobalReceiver* parent)
+ : m_id(id), m_pythonSelf(0), m_pyClass(0), m_weakRef(0), m_parent(parent)
+{
+ Shiboken::GilState gil;
+
+ m_isMethod = PyMethod_Check(callback);
+ if (m_isMethod) {
+ //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);
+#ifdef IS_PY3K
+ m_pyClass = 0;
+#else
+ m_pyClass = PyMethod_GET_CLASS(callback);
+#endif
+
+ m_pythonSelf = PyMethod_GET_SELF(callback);
+
+ //monitor class from method lifetime
+ m_weakRef = WeakRef::create(m_pythonSelf, DynamicSlotData::onCallbackDestroyed, this);
+ } else {
+ m_callback = callback;
+ Py_INCREF(m_callback);
+ }
+}
+
+PyObject* DynamicSlotData::call(PyObject* args)
+{
+ PyObject* callback = m_callback;
+
+ //create a callback based on method data
+ Shiboken::GilState gil;
+ if (m_isMethod)
+#ifdef IS_PY3K
+ callback = PyMethod_New(callback, m_pythonSelf);
+#else
+ callback = PyMethod_New(callback, m_pythonSelf, m_pyClass);
+#endif
+
+ PyObject* result = PyObject_CallObject(callback, args);
+
+ if (m_isMethod)
+ Py_DECREF(callback);
+
+ return result;
+}
+
+void DynamicSlotData::addRef(const QObject *o)
+{
+ m_refs.append(o);
+}
+
+void DynamicSlotData::decRef(const QObject *o)
+{
+ m_refs.removeOne(o);
+}
+
+int DynamicSlotData::refCount() const
+{
+ return m_refs.size();
+}
+
+int DynamicSlotData::id() const
+{
+ return m_id;
+}
+
+int DynamicSlotData::hasRefTo(const QObject *o) const
+{
+ return m_refs.count(o);
+}
+
+void DynamicSlotData::clear()
+{
+ Shiboken::GilState gil;
+ Py_XDECREF(m_weakRef);
+ m_weakRef = 0;
+ m_refs.clear();
+}
+
+DynamicSlotData::~DynamicSlotData()
+{
+ Shiboken::GilState gil;
+ clear();
+ if (!m_isMethod)
+ Py_DECREF(m_callback);
+}
+
+void DynamicSlotData::onCallbackDestroyed(void *data)
+{
+ Shiboken::GilState gil;
+ DynamicSlotData* self = reinterpret_cast<DynamicSlotData*>(data);
+
+ //Disconnect all sources
+ QMetaMethod m = self->m_parent->metaObject()->method(self->m_id);
+ QByteArray methodName = QByteArray::number(m.methodType()).append(m.methodSignature());
+ QLinkedList<const QObject*> sources = self->m_refs;
+ foreach(const QObject* src, sources)
+ const_cast<QObject*>(src)->disconnect(self->m_parent, methodName);
+ self->m_weakRef = 0;
+}
+
+GlobalReceiver::GlobalReceiver()
+ : m_metaObject(GLOBAL_RECEIVER_CLASS_NAME, &QObject::staticMetaObject)
+{
+ //slot used to be notifyed of object destrouction
+ m_metaObject.addSlot(RECEIVER_DESTROYED_SLOT_NAME);
+ m_metaObject.update();
+ setObjectName(QLatin1String("GLOBAL RECEIVER"));
+}
+
+GlobalReceiver::~GlobalReceiver()
+{
+ while(!m_slotReceivers.empty()) {
+ DynamicSlotData* data = m_slotReceivers.take(m_slotReceivers.begin().key());
+ data->clear();
+ delete data;
+ }
+}
+
+void GlobalReceiver::connectNotify(QObject* source, int slotId)
+{
+ if (m_slotReceivers.contains(slotId)) {
+ DynamicSlotData* data = m_slotReceivers[slotId];
+ if (!data->hasRefTo(source))
+ QObject::connect(source, SIGNAL(destroyed(QObject*)), this, "1" RECEIVER_DESTROYED_SLOT_NAME);
+ data->addRef(source);
+ }
+}
+
+void GlobalReceiver::disconnectNotify(QObject* source, int slotId)
+{
+ if (m_slotReceivers.contains(slotId)) {
+ DynamicSlotData *data = m_slotReceivers[slotId];
+ data->decRef(source);
+ if (data->refCount() == 0)
+ removeSlot(slotId);
+
+ if (!hasConnectionWith(source))
+ QObject::disconnect(source, SIGNAL(destroyed(QObject*)), this, "1" RECEIVER_DESTROYED_SLOT_NAME);
+ }
+}
+
+const QMetaObject* GlobalReceiver::metaObject() const
+{
+ return m_metaObject.update();
+}
+
+int GlobalReceiver::addSlot(const char* slot, PyObject* callback)
+{
+ int slotId = m_metaObject.addSlot(slot);
+ if (!m_slotReceivers.contains(slotId))
+ m_slotReceivers[slotId] = new DynamicSlotData(slotId, callback, this);
+
+ bool isShortCircuit = true;
+ for (int i = 0; slot[i]; ++i) {
+ if (slot[i] == '(') {
+ isShortCircuit = false;
+ break;
+ }
+ }
+
+ if (isShortCircuit)
+ m_shortCircuitSlots << slotId;
+
+ Q_ASSERT(slotId >= QObject::staticMetaObject.methodCount());
+ return slotId;
+}
+
+void GlobalReceiver::removeSlot(int slotId)
+{
+ if (m_slotReceivers.contains(slotId)) {
+ delete m_slotReceivers.take(slotId);
+ m_metaObject.removeSlot(slotId);
+ m_shortCircuitSlots.remove(slotId);
+ }
+}
+
+bool GlobalReceiver::hasConnectionWith(const QObject *object)
+{
+ QHash<int, DynamicSlotData*>::iterator i = m_slotReceivers.begin();
+ while(i != m_slotReceivers.end()) {
+ if (i.value()->hasRefTo(object)) {
+ return true;
+ }
+ i++;
+ }
+ return false;
+}
+
+int GlobalReceiver::qt_metacall(QMetaObject::Call call, int id, void** args)
+{
+ Q_ASSERT(call == QMetaObject::InvokeMetaMethod);
+ Q_ASSERT(id >= QObject::staticMetaObject.methodCount());
+ QMetaMethod slot = metaObject()->method(id);
+ Q_ASSERT(slot.methodType() == QMetaMethod::Slot);
+
+ if (strcmp(slot.methodSignature(), RECEIVER_DESTROYED_SLOT_NAME) == 0) {
+ QObject *arg = *(QObject**)args[1];
+
+ //avoid hash changes during the destruction
+ QHash<int, DynamicSlotData*> copy = m_slotReceivers;
+ QHash<int, DynamicSlotData*>::iterator i = copy.begin();
+ while(i != copy.end()) {
+ //Remove all refs
+ int refs = i.value()->hasRefTo(arg);
+ while(refs) {
+ disconnectNotify(arg, i.key());
+ refs--;
+ }
+ i++;
+ }
+ return -1;
+ }
+
+ DynamicSlotData* data = m_slotReceivers.value(id);
+ if (!data) {
+ qWarning() << "Unknown global slot, id:" << id;
+ return -1;
+ }
+
+ Shiboken::GilState gil;
+ PyObject* retval = 0;
+ if (m_shortCircuitSlots.contains(id)) {
+ retval = data->call(reinterpret_cast<PyObject*>(args[1]));
+ } else {
+ QList<QByteArray> paramTypes = slot.parameterTypes();
+ Shiboken::AutoDecRef preparedArgs(PyTuple_New(paramTypes.count()));
+ for (int i = 0, max = paramTypes.count(); i < max; ++i) {
+ const QByteArray& paramType = paramTypes[i];
+ Shiboken::Conversions::SpecificConverter converter(paramType.constData());
+ PyTuple_SET_ITEM(preparedArgs.object(), i, converter.toPython(args[i+1]));
+ }
+ retval = data->call(preparedArgs);
+ }
+
+ if (!retval)
+ PyErr_Print();
+ else
+ Py_DECREF(retval);
+
+ return -1;
+}
diff --git a/sources/pyside2/libpyside/globalreceiver.h b/sources/pyside2/libpyside/globalreceiver.h
new file mode 100644
index 000000000..d1114465a
--- /dev/null
+++ b/sources/pyside2/libpyside/globalreceiver.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 GLOBALRECEIVER_H
+#define GLOBALRECEIVER_H
+
+#include <sbkpython.h>
+#include <QObject>
+#include <QHash>
+#include <QSet>
+#include "dynamicqmetaobject.h"
+
+namespace PySide
+{
+
+class DynamicSlotData;
+
+class GlobalReceiver : public QObject
+{
+public:
+ GlobalReceiver();
+ ~GlobalReceiver();
+ int qt_metacall(QMetaObject::Call call, int id, void** args);
+ const QMetaObject* metaObject() const;
+ int addSlot(const char* slot, PyObject* callback);
+ void removeSlot(int slotId);
+ void connectNotify(QObject* sender, int slotId);
+ void disconnectNotify(QObject* sender, int slotId);
+ bool hasConnectionWith(const QObject* object);
+
+protected:
+ using QObject::connectNotify;
+ using QObject::disconnectNotify;
+
+private:
+ DynamicQMetaObject m_metaObject;
+ QSet<int> m_shortCircuitSlots;
+ QHash<int, DynamicSlotData* > m_slotReceivers;
+};
+
+}
+
+#endif
+
diff --git a/sources/pyside2/libpyside/globalreceiverv2.cpp b/sources/pyside2/libpyside/globalreceiverv2.cpp
new file mode 100644
index 000000000..a79d43c20
--- /dev/null
+++ b/sources/pyside2/libpyside/globalreceiverv2.cpp
@@ -0,0 +1,358 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "globalreceiverv2.h"
+#include "dynamicqmetaobject_p.h"
+#include "pysideweakref.h"
+
+#include <QMetaMethod>
+#include <QDebug>
+#include <QEvent>
+#include <QLinkedList>
+#include <autodecref.h>
+#include <gilstate.h>
+
+#include "typeresolver.h"
+#include "signalmanager.h"
+
+#define RECEIVER_DESTROYED_SLOT_NAME "__receiverDestroyed__(QObject*)"
+
+namespace
+{
+ static int DESTROY_SIGNAL_ID = 0;
+ static int DESTROY_SLOT_ID = 0;
+}
+
+namespace PySide
+{
+class DynamicSlotDataV2
+{
+ public:
+ DynamicSlotDataV2(PyObject* callback, GlobalReceiverV2* parent);
+ ~DynamicSlotDataV2();
+
+ int addSlot(const char* signature);
+ int id(const char* signature) const;
+ PyObject* callback();
+ QByteArray hash() const;
+ void notify();
+
+ static void onCallbackDestroyed(void* data);
+ static QByteArray hash(PyObject *callback);
+
+
+ private:
+ bool m_isMethod;
+ PyObject* m_callback;
+ PyObject* m_pythonSelf;
+ PyObject* m_pyClass;
+ PyObject* m_weakRef;
+ QMap<QByteArray, int> m_signatures;
+ GlobalReceiverV2* m_parent;
+ QByteArray m_hash;
+};
+
+}
+
+using namespace PySide;
+
+DynamicSlotDataV2::DynamicSlotDataV2(PyObject* callback, GlobalReceiverV2* parent)
+ : m_pythonSelf(0), m_pyClass(0), m_weakRef(0), m_parent(parent)
+{
+ Shiboken::GilState gil;
+
+ m_isMethod = PyMethod_Check(callback);
+ if (m_isMethod) {
+ //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
+ m_weakRef = WeakRef::create(m_pythonSelf, DynamicSlotDataV2::onCallbackDestroyed, this);
+
+ m_hash = QByteArray::number((qlonglong)PyObject_Hash(m_callback))
+ + QByteArray::number((qlonglong)PyObject_Hash(m_pythonSelf));
+
+ } else {
+ m_callback = callback;
+ Py_INCREF(m_callback);
+
+ m_hash = QByteArray::number((qlonglong)PyObject_Hash(m_callback));
+ }
+}
+
+QByteArray DynamicSlotDataV2::hash() const
+{
+ return m_hash;
+}
+
+QByteArray DynamicSlotDataV2::hash(PyObject* callback)
+{
+ Shiboken::GilState gil;
+ if (PyMethod_Check(callback))
+ return QByteArray::number((qlonglong)PyObject_Hash(PyMethod_GET_FUNCTION(callback)))
+ + QByteArray::number((qlonglong)PyObject_Hash(PyMethod_GET_SELF(callback)));
+ else
+ return QByteArray::number((qlonglong)PyObject_Hash(callback));
+}
+
+PyObject* DynamicSlotDataV2::callback()
+{
+ PyObject* callback = m_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);
+
+ return callback;
+}
+
+int DynamicSlotDataV2::id(const char* signature) const
+{
+ if (m_signatures.contains(signature))
+ return m_signatures[signature];
+ return -1;
+}
+
+int DynamicSlotDataV2::addSlot(const char* signature)
+{
+ int index = id(signature);
+ if (index == -1) {
+ DynamicQMetaObject *dmo = const_cast<DynamicQMetaObject*>(reinterpret_cast<const DynamicQMetaObject*>(m_parent->metaObject()));
+ index = m_signatures[signature] = dmo->addSlot(signature);
+ }
+ return index;
+}
+
+void DynamicSlotDataV2::onCallbackDestroyed(void *data)
+{
+ DynamicSlotDataV2* self = reinterpret_cast<DynamicSlotDataV2*>(data);
+ self->m_weakRef = 0;
+ Py_BEGIN_ALLOW_THREADS
+ delete self->m_parent;
+ Py_END_ALLOW_THREADS
+}
+
+DynamicSlotDataV2::~DynamicSlotDataV2()
+{
+ Shiboken::GilState gil;
+
+ Py_XDECREF(m_weakRef);
+ m_weakRef = 0;
+
+ if (!m_isMethod)
+ Py_DECREF(m_callback);
+}
+
+GlobalReceiverV2::GlobalReceiverV2(PyObject *callback, SharedMap map)
+ : QObject(0), m_metaObject(GLOBAL_RECEIVER_CLASS_NAME, &QObject::staticMetaObject), m_sharedMap(map)
+{
+ m_data = new DynamicSlotDataV2(callback, this);
+ m_metaObject.addSlot(RECEIVER_DESTROYED_SLOT_NAME);
+ m_metaObject.update();
+ m_refs.append(NULL);
+
+
+ if (DESTROY_SIGNAL_ID == 0)
+ DESTROY_SIGNAL_ID = QObject::staticMetaObject.indexOfSignal("destroyed(QObject*)");
+
+ if (DESTROY_SLOT_ID == 0)
+ DESTROY_SLOT_ID = m_metaObject.indexOfSlot(RECEIVER_DESTROYED_SLOT_NAME);
+
+
+}
+
+GlobalReceiverV2::~GlobalReceiverV2()
+{
+ m_refs.clear();
+ // Remove itself from map.
+ m_sharedMap->remove(m_data->hash());
+ // Suppress handling of destroyed() for objects whose last reference is contained inside
+ // the callback object that will now be deleted. The reference could be a default argument,
+ // a callback local variable, etc.
+ // The signal has to be suppressed because it would lead to the following situation:
+ // Callback is deleted, hence the last reference is decremented,
+ // leading to the object being deleted, which emits destroyed(), which would try to invoke
+ // the already deleted callback, and also try to delete the object again.
+ DynamicSlotDataV2 *data = m_data;
+ m_data = Q_NULLPTR;
+ delete data;
+}
+
+int GlobalReceiverV2::addSlot(const char* signature)
+{
+ return m_data->addSlot(signature);
+}
+
+void GlobalReceiverV2::incRef(const QObject* link)
+{
+ if (link) {
+ if (!m_refs.contains(link)) {
+ bool connected;
+ Py_BEGIN_ALLOW_THREADS
+ connected = QMetaObject::connect(link, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID);
+ Py_END_ALLOW_THREADS
+ if (connected)
+ m_refs.append(link);
+ else
+ Q_ASSERT(false);
+ } else {
+ m_refs.append(link);
+ }
+ } else {
+ m_refs.append(NULL);
+ }
+}
+
+void GlobalReceiverV2::decRef(const QObject* link)
+{
+ if (m_refs.size() <= 0)
+ return;
+
+
+ m_refs.removeOne(link);
+ if (link) {
+ if (!m_refs.contains(link)) {
+ bool result;
+ Py_BEGIN_ALLOW_THREADS
+ result = QMetaObject::disconnect(link, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID);
+ Py_END_ALLOW_THREADS
+ Q_ASSERT(result);
+ if (!result)
+ return;
+ }
+ }
+
+ if (m_refs.size() == 0)
+ Py_BEGIN_ALLOW_THREADS
+ delete this;
+ Py_END_ALLOW_THREADS
+
+}
+
+int GlobalReceiverV2::refCount(const QObject* link) const
+{
+ if (link)
+ return m_refs.count(link);
+
+ return m_refs.size();
+}
+
+void GlobalReceiverV2::notify()
+{
+ QSet<const QObject*> objs = QSet<const QObject*>::fromList(m_refs);
+ Py_BEGIN_ALLOW_THREADS
+ foreach(const QObject* o, objs) {
+ QMetaObject::disconnect(o, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID);
+ QMetaObject::connect(o, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID);
+ }
+ Py_END_ALLOW_THREADS
+}
+
+QByteArray GlobalReceiverV2::hash() const
+{
+ return m_data->hash();
+}
+
+QByteArray GlobalReceiverV2::hash(PyObject* callback)
+{
+ return DynamicSlotDataV2::hash(callback);
+}
+
+const QMetaObject* GlobalReceiverV2::metaObject() const
+{
+ return m_metaObject.update();
+}
+
+int GlobalReceiverV2::qt_metacall(QMetaObject::Call call, int id, void** args)
+{
+ Shiboken::GilState gil;
+ Q_ASSERT(call == QMetaObject::InvokeMetaMethod);
+ Q_ASSERT(id >= QObject::staticMetaObject.methodCount());
+
+ QMetaMethod slot = metaObject()->method(id);
+ Q_ASSERT(slot.methodType() == QMetaMethod::Slot);
+
+ if (!m_data) {
+ if (id != DESTROY_SLOT_ID) {
+ const QByteArray message = "PySide2 Warning: Skipping callback call "
+ + slot.methodSignature() + " because the callback object is being destructed.";
+ PyErr_WarnEx(PyExc_RuntimeWarning, message.constData(), 0);
+ }
+ return -1;
+ }
+
+ if (id == DESTROY_SLOT_ID) {
+ if (m_refs.size() == 0)
+ return -1;
+ QObject *obj = *(QObject**)args[1];
+ incRef(); //keep the object live (safe ref)
+ m_refs.removeAll(obj); // remove all refs to this object
+ decRef(); //remove the safe ref
+ } else {
+ bool isShortCuit = (strstr(slot.methodSignature(), "(") == 0);
+ Shiboken::AutoDecRef callback(m_data->callback());
+ SignalManager::callPythonMetaMethod(slot, args, callback, isShortCuit);
+ }
+
+ // SignalManager::callPythonMetaMethod might have failed, in that case we have to print the
+ // error so it considered "handled".
+ if (PyErr_Occurred()) {
+ int reclimit = Py_GetRecursionLimit();
+ // Inspired by Python's errors.c: PyErr_GivenExceptionMatches() function.
+ // Temporarily bump the recursion limit, so that PyErr_Print will not raise a recursion
+ // error again. Don't do it when the limit is already insanely high, to avoid overflow.
+ if (reclimit < (1 << 30))
+ Py_SetRecursionLimit(reclimit + 5);
+ PyErr_Print();
+ Py_SetRecursionLimit(reclimit);
+ }
+
+ return -1;
+}
diff --git a/sources/pyside2/libpyside/globalreceiverv2.h b/sources/pyside2/libpyside/globalreceiverv2.h
new file mode 100644
index 000000000..3ad9ba6b7
--- /dev/null
+++ b/sources/pyside2/libpyside/globalreceiverv2.h
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 GLOBALRECEIVER_V2_H
+#define GLOBALRECEIVER_V2_H
+
+#include <sbkpython.h>
+#include <QObject>
+#include <QHash>
+#include <QSet>
+#include <QSharedPointer>
+#include <QLinkedList>
+#include <QByteArray>
+
+#include "dynamicqmetaobject.h"
+
+namespace PySide
+{
+
+class DynamicSlotDataV2;
+class GlobalReceiverV2;
+
+typedef QMap<QByteArray, GlobalReceiverV2 *> GlobalReceiverV2Map;
+typedef QSharedPointer<GlobalReceiverV2Map> SharedMap;
+
+/**
+ * A class used to make the link between the C++ Signal/Slot and Python callback
+ * This class is used internally by SignalManager
+ **/
+
+class GlobalReceiverV2 : public QObject
+{
+public:
+ /**
+ * Create a GlobalReceiver object that will call 'callback' argumentent
+ *
+ * @param callback A Python callable object (can be a method or not)
+ * @param ma A SharedPointer used on Signal manager that contains all instaces of GlobalReceiver
+ **/
+ GlobalReceiverV2(PyObject *callback, SharedMap map);
+
+ /**
+ * Destructor
+ **/
+ ~GlobalReceiverV2();
+
+ /**
+ * Reimplemented function from QObject
+ **/
+ int qt_metacall(QMetaObject::Call call, int id, void** args);
+ const QMetaObject* metaObject() const;
+
+ /**
+ * Add a extra slot to this object
+ *
+ * @param signature The signature of the slot to be added
+ * @return The index of this slot on metaobject
+ **/
+ int addSlot(const char* signature);
+
+ /**
+ * Notify to GlobalReceiver about when a new connection was made
+ **/
+ void notify();
+
+ /**
+ * Used to increment the reference of the GlobalReceiver object
+ *
+ * @param link This is a optional paramenter used to link the ref to some QObject life
+ **/
+ void incRef(const QObject* link = 0);
+
+ /**
+ * Used to decrement the reference of the GlobalReceiver object
+ *
+ * @param link This is a optional paramenter used to dismiss the link ref to some QObject
+ **/
+ void decRef(const QObject* link = 0);
+
+ /*
+ * Return the count of refs which the GlobalReceiver has
+ *
+ * @param link If any QObject was passed, the function return the number of references relative to this 'link' object
+ * @return The number of references
+ **/
+ int refCount(const QObject* link) const;
+
+ /**
+ * Use to retrive the unique hash of this GlobalReceiver object
+ *
+ * @return a string with a unique id based on GlobalReceiver contents
+ **/
+ QByteArray hash() const;
+
+ /**
+ * Use to retrive the unique hash of the PyObject based on GlobalReceiver rules
+ *
+ * @param callback The Python callable object used to calculate the id
+ * @return a string with a unique id based on GlobalReceiver contents
+ **/
+ static QByteArray hash(PyObject* callback);
+
+private:
+ DynamicQMetaObject m_metaObject;
+ DynamicSlotDataV2 *m_data;
+ QList<const QObject*> m_refs;
+ int m_ref;
+ SharedMap m_sharedMap;
+};
+
+}
+
+#endif
diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp
new file mode 100644
index 000000000..7d05f45a5
--- /dev/null
+++ b/sources/pyside2/libpyside/pyside.cpp
@@ -0,0 +1,387 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "pyside.h"
+#include "signalmanager.h"
+#include "pysideclassinfo_p.h"
+#include "pysideproperty_p.h"
+#include "pysideproperty.h"
+#include "pysidesignal.h"
+#include "pysidesignal_p.h"
+#include "pysideslot_p.h"
+#include "pysidemetafunction_p.h"
+#include "pysidemetafunction.h"
+#include "dynamicqmetaobject.h"
+#include "destroylistener.h"
+
+#include <basewrapper.h>
+#include <conversions.h>
+#include <sbkconverter.h>
+#include <gilstate.h>
+#include <typeresolver.h>
+#include <bindingmanager.h>
+#include <algorithm>
+#include <cstring>
+#include <cctype>
+#include <QStack>
+#include <QCoreApplication>
+#include <QDebug>
+#include <QSharedPointer>
+
+static QStack<PySide::CleanupFunction> cleanupFunctionList;
+static void* qobjectNextAddr;
+
+namespace PySide
+{
+
+void init(PyObject *module)
+{
+ qobjectNextAddr = 0;
+ ClassInfo::init(module);
+ Signal::init(module);
+ Slot::init(module);
+ Property::init(module);
+ MetaFunction::init(module);
+ // Init signal manager, so it will register some meta types used by QVariant.
+ SignalManager::instance();
+}
+
+bool fillQtProperties(PyObject* qObj, const QMetaObject* metaObj, PyObject* kwds, const char** blackList, unsigned int blackListSize)
+{
+
+ PyObject *key, *value;
+ Py_ssize_t pos = 0;
+
+ while (PyDict_Next(kwds, &pos, &key, &value)) {
+ if (!blackListSize || !std::binary_search(blackList, blackList + blackListSize, std::string(Shiboken::String::toCString(key)))) {
+ QByteArray propName(Shiboken::String::toCString(key));
+ if (metaObj->indexOfProperty(propName) != -1) {
+ propName[0] = std::toupper(propName[0]);
+ propName.prepend("set");
+
+ Shiboken::AutoDecRef propSetter(PyObject_GetAttrString(qObj, propName.constData()));
+ if (!propSetter.isNull()) {
+ Shiboken::AutoDecRef args(PyTuple_Pack(1, value));
+ Shiboken::AutoDecRef retval(PyObject_CallObject(propSetter, args));
+ } else {
+ PyObject* attr = PyObject_GenericGetAttr(qObj, key);
+ if (PySide::Property::checkType(attr))
+ PySide::Property::setValue(reinterpret_cast<PySideProperty*>(attr), qObj, value);
+ }
+ } else {
+ propName.append("()");
+ if (metaObj->indexOfSignal(propName) != -1) {
+ propName.prepend('2');
+ PySide::Signal::connect(qObj, propName, value);
+ } else {
+ PyErr_Format(PyExc_AttributeError, "'%s' is not a Qt property or a signal", propName.constData());
+ return false;
+ };
+ }
+ }
+ }
+ return true;
+}
+
+void registerCleanupFunction(CleanupFunction func)
+{
+ cleanupFunctionList.push(func);
+}
+
+void runCleanupFunctions()
+{
+ //PySide::DestroyListener::instance()->destroy();
+ while (!cleanupFunctionList.isEmpty()) {
+ CleanupFunction f = cleanupFunctionList.pop();
+ f();
+ }
+ PySide::DestroyListener::destroy();
+}
+
+static void destructionVisitor(SbkObject* pyObj, void* data)
+{
+ void** realData = reinterpret_cast<void**>(data);
+ SbkObject* pyQApp = reinterpret_cast<SbkObject*>(realData[0]);
+ PyTypeObject* pyQObjectType = reinterpret_cast<PyTypeObject*>(realData[1]);
+
+ if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) {
+ if (Shiboken::Object::hasOwnership(pyObj) && Shiboken::Object::isValid(pyObj, false)) {
+ Shiboken::Object::setValidCpp(pyObj, false);
+
+ Py_BEGIN_ALLOW_THREADS
+ Shiboken::callCppDestructor<QObject>(Shiboken::Object::cppPointer(pyObj, pyQObjectType));
+ Py_END_ALLOW_THREADS
+ }
+ }
+
+};
+
+void destroyQCoreApplication()
+{
+ SignalManager::instance().clear();
+ QCoreApplication* app = QCoreApplication::instance();
+ if (!app)
+ return;
+
+ Shiboken::BindingManager& bm = Shiboken::BindingManager::instance();
+ SbkObject* pyQApp = bm.retrieveWrapper(app);
+ PyTypeObject* pyQObjectType = Shiboken::Conversions::getPythonTypeObject("QObject*");
+ assert(pyQObjectType);
+
+ void* data[2] = {pyQApp, pyQObjectType};
+ bm.visitAllPyObjects(&destructionVisitor, &data);
+
+ // in the end destroy app
+ // Allow threads because the destructor calls
+ // QThreadPool::globalInstance().waitForDone() which may deadlock on the GIL
+ // if there is a worker working with python objects.
+ Py_BEGIN_ALLOW_THREADS
+ delete app;
+ Py_END_ALLOW_THREADS
+}
+
+struct TypeUserData {
+ TypeUserData(PyTypeObject* type, const QMetaObject* metaobject) : mo(type, metaobject) {}
+ DynamicQMetaObject mo;
+ std::size_t cppObjSize;
+};
+
+std::size_t getSizeOfQObject(SbkObjectType* type)
+{
+ using namespace Shiboken::ObjectType;
+ TypeUserData* userData = reinterpret_cast<TypeUserData*>(getTypeUserData(reinterpret_cast<SbkObjectType*>(type)));
+ return userData->cppObjSize;
+}
+
+void initDynamicMetaObject(SbkObjectType* type, const QMetaObject* base, const std::size_t& cppObjSize)
+{
+ //create DynamicMetaObject based on python type
+ TypeUserData* userData = new TypeUserData(reinterpret_cast<PyTypeObject*>(type), base);
+ userData->cppObjSize = cppObjSize;
+ userData->mo.update();
+ Shiboken::ObjectType::setTypeUserData(type, userData, Shiboken::callCppDestructor<TypeUserData>);
+
+ //initialize staticQMetaObject property
+ void* metaObjectPtr = &userData->mo;
+ static SbkConverter* converter = Shiboken::Conversions::getConverter("QMetaObject");
+ if (!converter)
+ return;
+ Shiboken::AutoDecRef pyMetaObject(Shiboken::Conversions::pointerToPython(converter, metaObjectPtr));
+ PyObject_SetAttrString(reinterpret_cast<PyObject*>(type), "staticMetaObject", pyMetaObject);
+}
+
+void initDynamicMetaObject(SbkObjectType* type, const QMetaObject* base)
+{
+ initDynamicMetaObject(type, base, 0);
+}
+
+void initQObjectSubType(SbkObjectType *type, PyObject *args, PyObject * /* kwds */)
+{
+ PyTypeObject* qObjType = Shiboken::Conversions::getPythonTypeObject("QObject*");
+ QByteArray className(Shiboken::String::toCString(PyTuple_GET_ITEM(args, 0)));
+
+ PyObject* bases = PyTuple_GET_ITEM(args, 1);
+ int numBases = PyTuple_GET_SIZE(bases);
+ QMetaObject* baseMo = 0;
+ SbkObjectType* qobjBase = 0;
+
+ for (int i = 0; i < numBases; ++i) {
+ PyTypeObject* base = reinterpret_cast<PyTypeObject*>(PyTuple_GET_ITEM(bases, i));
+ if (PyType_IsSubtype(base, qObjType)) {
+ baseMo = reinterpret_cast<QMetaObject*>(Shiboken::ObjectType::getTypeUserData(reinterpret_cast<SbkObjectType*>(base)));
+ qobjBase = reinterpret_cast<SbkObjectType*>(base);
+ reinterpret_cast<DynamicQMetaObject*>(baseMo)->update();
+ break;
+ }
+ }
+ if (!baseMo) {
+ qWarning("Sub class of QObject not inheriting QObject!? Crash will happen when using %s.", className.constData());
+ return;
+ }
+
+ TypeUserData* userData = reinterpret_cast<TypeUserData*>(Shiboken::ObjectType::getTypeUserData(qobjBase));
+ initDynamicMetaObject(type, baseMo, userData->cppObjSize);
+}
+
+PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* name)
+{
+ PyObject* attr = PyObject_GenericGetAttr(self, name);
+ if (!Shiboken::Object::isValid(reinterpret_cast<SbkObject*>(self), false))
+ return attr;
+
+ if (attr && Property::checkType(attr)) {
+ PyObject *value = Property::getValue(reinterpret_cast<PySideProperty*>(attr), self);
+ Py_DECREF(attr);
+ if (!value)
+ return 0;
+ Py_INCREF(value);
+ attr = value;
+ }
+
+ //mutate native signals to signal instance type
+ if (attr && PyObject_TypeCheck(attr, &PySideSignalType)) {
+ PyObject* signal = reinterpret_cast<PyObject*>(Signal::initialize(reinterpret_cast<PySideSignal*>(attr), name, self));
+ PyObject_SetAttr(self, name, reinterpret_cast<PyObject*>(signal));
+ return signal;
+ }
+
+ //search on metaobject (avoid internal attributes started with '__')
+ if (!attr) {
+ const char* cname = Shiboken::String::toCString(name);
+ uint cnameLen = qstrlen(cname);
+ if (std::strncmp("__", cname, 2)) {
+ const QMetaObject* metaObject = cppSelf->metaObject();
+ //signal
+ QList<QMetaMethod> signalList;
+ for(int i=0, i_max = metaObject->methodCount(); i < i_max; i++) {
+ QMetaMethod method = metaObject->method(i);
+ const QByteArray methSig_ = method.methodSignature();
+ const char *methSig = methSig_.constData();
+ bool methMacth = !std::strncmp(cname, methSig, cnameLen) && methSig[cnameLen] == '(';
+ if (methMacth) {
+ if (method.methodType() == QMetaMethod::Signal) {
+ signalList.append(method);
+ } else {
+ PySideMetaFunction* func = MetaFunction::newObject(cppSelf, i);
+ if (func) {
+ PyObject *result = reinterpret_cast<PyObject *>(func);
+ PyObject_SetAttr(self, name, result);
+ return result;
+ }
+ }
+ }
+ }
+ if (signalList.size() > 0) {
+ PyObject* pySignal = reinterpret_cast<PyObject*>(Signal::newObjectFromMethod(self, signalList));
+ PyObject_SetAttr(self, name, pySignal);
+ return pySignal;
+ }
+ }
+ }
+ return attr;
+}
+
+bool inherits(PyTypeObject* objType, const char* class_name)
+{
+ if (strcmp(objType->tp_name, class_name) == 0)
+ return true;
+
+ PyTypeObject* base = (objType)->tp_base;
+ if (base == 0)
+ return false;
+
+ return inherits(base, class_name);
+}
+
+void* nextQObjectMemoryAddr()
+{
+ return qobjectNextAddr;
+}
+
+void setNextQObjectMemoryAddr(void* addr)
+{
+ qobjectNextAddr = addr;
+}
+
+} // namespace PySide
+
+// A QSharedPointer is used with a deletion function to invalidate a pointer
+// when the property value is cleared. This should be a QSharedPointer with
+// a void* pointer, but that isn't allowed
+typedef char any_t;
+Q_DECLARE_METATYPE(QSharedPointer<any_t>);
+
+namespace PySide
+{
+
+static void invalidatePtr(any_t* object)
+{
+ Shiboken::GilState state;
+
+ SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(object);
+ if (wrapper != NULL)
+ Shiboken::BindingManager::instance().releaseWrapper(wrapper);
+}
+
+static const char invalidatePropertyName[] = "_PySideInvalidatePtr";
+
+PyObject* getWrapperForQObject(QObject* cppSelf, SbkObjectType* sbk_type)
+{
+ PyObject* pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper(cppSelf));
+ if (pyOut) {
+ Py_INCREF(pyOut);
+ return pyOut;
+ }
+
+ // Setting the property will trigger an QEvent notification, which may call into
+ // code that creates the wrapper so only set the property if it isn't already
+ // set and check if it's created after the set call
+ QVariant existing = cppSelf->property(invalidatePropertyName);
+ if (!existing.isValid()) {
+ QSharedPointer<any_t> shared_with_del((any_t*)cppSelf, invalidatePtr);
+ cppSelf->setProperty(invalidatePropertyName, QVariant::fromValue(shared_with_del));
+ pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper(cppSelf));
+ if (pyOut) {
+ Py_INCREF(pyOut);
+ return pyOut;
+ }
+ }
+
+ const char* typeName = typeid(*cppSelf).name();
+ pyOut = Shiboken::Object::newObject(sbk_type, cppSelf, false, false, typeName);
+
+ return pyOut;
+}
+
+#ifdef PYSIDE_QML_SUPPORT
+static QuickRegisterItemFunction quickRegisterItem;
+
+QuickRegisterItemFunction getQuickRegisterItemFunction()
+{
+ return quickRegisterItem;
+}
+
+void setQuickRegisterItemFunction(QuickRegisterItemFunction function)
+{
+ quickRegisterItem = function;
+}
+#endif // PYSIDE_QML_SUPPORT
+
+} //namespace PySide
+
diff --git a/sources/pyside2/libpyside/pyside.h b/sources/pyside2/libpyside/pyside.h
new file mode 100644
index 000000000..3619e2875
--- /dev/null
+++ b/sources/pyside2/libpyside/pyside.h
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_H
+#define PYSIDE_H
+
+#include <sbkpython.h>
+#include <pysidemacros.h>
+
+#ifdef PYSIDE_QML_SUPPORT
+# include <qqml.h>
+#endif
+
+#include <QMetaType>
+#include <QHash>
+#include <QList>
+
+struct SbkObjectType;
+
+namespace PySide
+{
+
+PYSIDE_API void init(PyObject *module);
+
+/**
+ * Hash function used to enable hash on objects not supported on native Qt library which has toString function.
+ */
+template<class T>
+inline uint hash(const T& value)
+{
+ return qHash(value.toString());
+}
+
+/**
+ * Fill QObject properties and do signal connections using the values found in \p kwds dictonary.
+ * \param qObj PyObject fot the QObject.
+ * \param metaObj QMetaObject of \p qObj.
+ * \param blackList keys to be ignored in kwds dictionary, this string list MUST be sorted.
+ * \param blackListSize numbe rof elements in blackList.
+ * \param kwds key->value dictonary.
+ * \return True if everything goes well, false with a Python error setted otherwise.
+ */
+PYSIDE_API bool fillQtProperties(PyObject* qObj, const QMetaObject* metaObj, PyObject* kwds, const char** blackList, unsigned int blackListSize);
+
+/**
+* If the type \p T was registered on Qt meta type system with Q_DECLARE_METATYPE macro, this class will initialize
+* the meta type.
+*
+* Initialize a meta type means register it on Qt meta type system, Qt itself only do this on the first call of
+* qMetaTypeId, and this is exactly what we do to init it. If we don't do that, calls to QMetaType::type("QMatrix2x2")
+* could return zero, causing QVariant to not recognize some C++ types, like QMatrix2x2.
+*/
+template<typename T, bool OK = QMetaTypeId<T>::Defined >
+struct initQtMetaType {
+ initQtMetaType()
+ {
+ qMetaTypeId<T>();
+ }
+};
+
+// Template specialization to do nothing when the type wasn't registered on Qt meta type system.
+template<typename T>
+struct initQtMetaType<T, false> {
+};
+
+PYSIDE_DEPRECATED(PYSIDE_API void initDynamicMetaObject(SbkObjectType* type, const QMetaObject* base));
+PYSIDE_API void initDynamicMetaObject(SbkObjectType* type, const QMetaObject* base, const std::size_t& cppObjSize);
+PYSIDE_API void initQObjectSubType(SbkObjectType* type, PyObject* args, PyObject* kwds);
+
+/// Return the size in bytes of a type that inherits QObject.
+PYSIDE_API std::size_t getSizeOfQObject(SbkObjectType* type);
+
+typedef void (*CleanupFunction)(void);
+
+/**
+ * Register a function to be called before python die
+ */
+PYSIDE_API void registerCleanupFunction(CleanupFunction func);
+PYSIDE_API void runCleanupFunctions();
+
+/**
+ * Destroy a QCoreApplication taking care of destroy all instances of QObject first.
+ */
+PYSIDE_API void destroyQCoreApplication();
+
+/**
+ * Check for properties and signals registered on MetaObject and return these
+ * \param cppSelf Is the QObject which contains the metaobject
+ * \param self Python object of cppSelf
+ * \param name Name of the argument which the function will try retrieve from MetaData
+ * \return The Python object which contains the Data obtained in metaObject or the Python attribute related with name
+ */
+PYSIDE_API PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* name);
+
+/**
+ * Check if self inherits from class_name
+ * \param self Python object
+ * \param class_name strict with the class name
+ * \return Returns true if self object inherits from class_name, otherwise returns false
+ */
+PYSIDE_API bool inherits(PyTypeObject* self, const char* class_name);
+
+PYSIDE_API void* nextQObjectMemoryAddr();
+PYSIDE_API void setNextQObjectMemoryAddr(void* addr);
+
+PYSIDE_API PyObject* getWrapperForQObject(QObject* cppSelf, SbkObjectType* sbk_type);
+
+#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 *);
+PYSIDE_API QuickRegisterItemFunction getQuickRegisterItemFunction();
+PYSIDE_API void setQuickRegisterItemFunction(QuickRegisterItemFunction function);
+#endif // PYSIDE_QML_SUPPORT
+
+} //namespace PySide
+
+
+#endif // PYSIDE_H
+
diff --git a/sources/pyside2/libpyside/pyside2.pc.in b/sources/pyside2/libpyside/pyside2.pc.in
new file mode 100644
index 000000000..4f396ac72
--- /dev/null
+++ b/sources/pyside2/libpyside/pyside2.pc.in
@@ -0,0 +1,14 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@CMAKE_INSTALL_PREFIX@/include/PySide2@pyside2_SUFFIX@
+typesystemdir=@CMAKE_INSTALL_PREFIX@/share/PySide2@pyside2_SUFFIX@/typesystems
+pythonpath=@SITE_PACKAGE@
+
+Name: PySide2@pyside2_SUFFIX@
+Description: Support library for Python bindings of Qt5-based libraries.
+Version: @BINDING_API_VERSION_FULL@
+Libs: -L${libdir} -lpyside2@pyside2_SUFFIX@@SHIBOKEN_PYTHON_EXTENSION_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@
+Cflags: -I${includedir}
+Requires: shiboken2
+
diff --git a/sources/pyside2/libpyside/pysideclassinfo.cpp b/sources/pyside2/libpyside/pysideclassinfo.cpp
new file mode 100644
index 000000000..a80ed9c54
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideclassinfo.cpp
@@ -0,0 +1,229 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "pysideclassinfo.h"
+#include "pysideclassinfo_p.h"
+#include "dynamicqmetaobject.h"
+
+#include <shiboken.h>
+#include <QDebug>
+
+#define CLASSINFO_CLASS_NAME "ClassInfo"
+
+extern "C"
+{
+
+static PyObject* classInfoTpNew(PyTypeObject* subtype, PyObject* args, PyObject* kwds);
+static int classInfoTpInit(PyObject*, PyObject*, PyObject*);
+static void classInfoFree(void*);
+static PyObject* classCall(PyObject*, PyObject*, PyObject*);
+
+PyTypeObject PySideClassInfoType = {
+ PyVarObject_HEAD_INIT(0, 0)
+ "PySide2.QtCore." CLASSINFO_CLASS_NAME, /*tp_name*/
+ sizeof(PySideClassInfo), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ classCall, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ 0, /*tp_iter */
+ 0, /*tp_iternext */
+ 0, /*tp_methods */
+ 0, /*tp_members */
+ 0, /*tp_getset */
+ 0, /*tp_base */
+ 0, /*tp_dict */
+ 0, /*tp_descr_get */
+ 0, /*tp_descr_set */
+ 0, /*tp_dictoffset */
+ classInfoTpInit, /*tp_init */
+ 0, /*tp_alloc */
+ classInfoTpNew, /*tp_new */
+ classInfoFree, /*tp_free */
+ 0, /*tp_is_gc */
+ 0, /*tp_bases */
+ 0, /*tp_mro */
+ 0, /*tp_cache */
+ 0, /*tp_subclasses */
+ 0, /*tp_weaklist */
+ 0, /*tp_del */
+ 0, /*tp_version_tag */
+};
+
+PyObject *classCall(PyObject *self, PyObject *args, PyObject * /* kw */)
+{
+ if (!PyTuple_Check(args) || PyTuple_Size(args) != 1) {
+ PyErr_Format(PyExc_TypeError,
+ "The ClassInfo decorator takes exactly 1 positional argument (%zd given)",
+ PyTuple_Size(args));
+ return 0;
+ }
+
+ PySideClassInfo* data = reinterpret_cast<PySideClassInfo*>(self);
+ PySideClassInfoPrivate* pData = data->d;
+
+ if (pData->m_alreadyWrapped) {
+ PyErr_SetString(PyExc_TypeError, "This instance of ClassInfo() was already used to wrap an object");
+ return 0;
+ }
+
+ PyObject* klass;
+ klass = PyTuple_GetItem(args, 0);
+ bool validClass = false;
+
+ // This will sometimes segfault if you mistakenly use it on a function declaration
+ if (!PyType_Check(klass)) {
+ PyErr_SetString(PyExc_TypeError, "This decorator can only be used on class declarations");
+ return 0;
+ }
+
+ if (Shiboken::ObjectType::checkType(reinterpret_cast<PyTypeObject*>(klass))) {
+ PySide::DynamicQMetaObject* mo = reinterpret_cast<PySide::DynamicQMetaObject*>(Shiboken::ObjectType::getTypeUserData(reinterpret_cast<SbkObjectType*>(klass)));
+ if (mo) {
+ mo->addInfo(PySide::ClassInfo::getMap(data));
+ pData->m_alreadyWrapped = true;
+ validClass = true;
+ }
+ }
+
+ if (!validClass) {
+ PyErr_SetString(PyExc_TypeError, "This decorator can only be used on classes that are subclasses of QObject");
+ return 0;
+ }
+
+ Py_INCREF(klass);
+ return klass;
+}
+
+static PyObject *classInfoTpNew(PyTypeObject *subtype, PyObject * /* args */, PyObject * /* kwds */)
+{
+ PySideClassInfo* me = reinterpret_cast<PySideClassInfo*>(subtype->tp_alloc(subtype, 0));
+ me->d = new PySideClassInfoPrivate;
+
+ me->d->m_alreadyWrapped = false;
+
+ return reinterpret_cast<PyObject *>(me);
+}
+
+int classInfoTpInit(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ if (PyTuple_Check(args) && PyTuple_Size(args) > 0) {
+ PyErr_Format(PyExc_TypeError, "ClassInfo() takes exactly 0 positional arguments (%zd given)", PyTuple_Size(args));
+ return -1;
+ }
+
+ PySideClassInfo* data = reinterpret_cast<PySideClassInfo*>(self);
+ PySideClassInfoPrivate* pData = data->d;
+
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+
+ // PyDict_Next causes a segfault if kwds is empty
+ if (kwds && PyDict_Check(kwds) && PyDict_Size(kwds) > 0) {
+ while (PyDict_Next(kwds, &pos, &key, &value)) {
+ if (Shiboken::String::check(key) && Shiboken::String::check(value)) {
+ pData->m_data[Shiboken::String::toCString(key)] = Shiboken::String::toCString(value);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "All keys and values provided to ClassInfo() must be strings");
+ return -1;
+ }
+ }
+ }
+
+ return PyErr_Occurred() ? -1 : 1;
+}
+
+void classInfoFree(void *self)
+{
+ PyObject* pySelf = reinterpret_cast<PyObject*>(self);
+ PySideClassInfo* data = reinterpret_cast<PySideClassInfo*>(self);
+
+ delete data->d;
+ pySelf->ob_type->tp_base->tp_free(self);
+}
+
+
+} // extern "C"
+
+
+namespace PySide { namespace ClassInfo {
+
+void init(PyObject* module)
+{
+ if (PyType_Ready(&PySideClassInfoType) < 0)
+ return;
+
+ Py_INCREF(&PySideClassInfoType);
+ PyModule_AddObject(module, CLASSINFO_CLASS_NAME, reinterpret_cast<PyObject *>(&PySideClassInfoType));
+}
+
+bool checkType(PyObject* pyObj)
+{
+ if (pyObj)
+ return PyType_IsSubtype(pyObj->ob_type, &PySideClassInfoType);
+ return false;
+}
+
+QMap<QByteArray, QByteArray> getMap(PySideClassInfo* obj)
+{
+ return obj->d->m_data;
+}
+
+} //namespace Property
+} //namespace PySide
diff --git a/sources/pyside2/libpyside/pysideclassinfo.h b/sources/pyside2/libpyside/pysideclassinfo.h
new file mode 100644
index 000000000..9c92b3fcf
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideclassinfo.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_CLASSINFO_H
+#define PYSIDE_CLASSINFO_H
+
+#include <pysidemacros.h>
+#include <sbkpython.h>
+#include <QMap>
+#include <QByteArray>
+
+extern "C"
+{
+ extern PYSIDE_API PyTypeObject PySideClassInfoType;
+
+ struct PySideClassInfoPrivate;
+ struct PYSIDE_API PySideClassInfo
+ {
+ PyObject_HEAD
+ PySideClassInfoPrivate* d;
+ };
+};
+
+namespace PySide { namespace ClassInfo {
+
+PYSIDE_API bool checkType(PyObject* pyObj);
+PYSIDE_API QMap<QByteArray, QByteArray> getMap(PySideClassInfo* obj);
+
+} //namespace ClassInfo
+} //namespace PySide
+
+#endif
diff --git a/sources/pyside2/libpyside/pysideclassinfo_p.h b/sources/pyside2/libpyside/pysideclassinfo_p.h
new file mode 100644
index 000000000..3dbc0cd9a
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideclassinfo_p.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_CLASSINFO_P_H
+#define PYSIDE_CLASSINFO_P_H
+
+#include <sbkpython.h>
+#include <QMetaObject>
+#include "pysideclassinfo.h"
+
+#define __INFO_ATTR_NAME__ "__classInfo__"
+
+struct PySideClassInfo;
+
+extern "C"
+{
+
+struct PySideClassInfoPrivate {
+ QMap<QByteArray, QByteArray> m_data;
+ bool m_alreadyWrapped;
+};
+
+} // extern "C"
+
+namespace PySide { namespace ClassInfo {
+
+/**
+ * Init PySide QProperty support system
+ */
+void init(PyObject* module);
+
+
+} // namespace ClassInfo
+} // namespace PySide
+
+#endif
diff --git a/sources/pyside2/libpyside/pysideconversions.h b/sources/pyside2/libpyside/pysideconversions.h
new file mode 100644
index 000000000..ed8002fae
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideconversions.h
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDECONVERSIONS_H
+#define PYSIDECONVERSIONS_H
+
+#include <sbkpython.h>
+#include <QFlag>
+#include <conversions.h>
+#include <pysideqflags.h>
+
+template <typename QtDict>
+struct QtDictConverter
+{
+ static inline bool checkType(PyObject* pyObj)
+ {
+ return isConvertible(pyObj);
+ }
+
+ static inline bool isConvertible(PyObject* pyObj)
+ {
+ if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<QtDict>()))
+ return true;
+
+ if ((Shiboken::SbkType<QtDict>() && Shiboken::Object::checkType(pyObj)) || !PyDict_Check(pyObj))
+ return false;
+
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+
+ while (PyDict_Next(pyObj, &pos, &key, &value)) {
+ if (!Shiboken::Converter<typename QtDict::key_type>::isConvertible(key)
+ && !Shiboken::Converter<typename QtDict::mapped_type>::isConvertible(value)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<QtDict*>(cppObj)); }
+ static inline PyObject* toPython(const QtDict& cppobj)
+ {
+ PyObject* result = PyDict_New();
+ typename QtDict::const_iterator it = cppobj.begin();
+
+ for (; it != cppobj.end(); ++it) {
+ Shiboken::AutoDecRef keyObj(Shiboken::Converter<typename QtDict::key_type>::toPython(it.key()));
+ Shiboken::AutoDecRef valueObj(Shiboken::Converter<typename QtDict::mapped_type>::toPython(it.value()));
+ PyDict_SetItem(result, keyObj, valueObj);
+ }
+
+ return result;
+ }
+ static inline QtDict toCpp(PyObject* pyobj)
+ {
+ if (PyObject_TypeCheck(pyobj, Shiboken::SbkType<QtDict>()))
+ return *reinterpret_cast<QtDict *>(Shiboken::Object::cppPointer(reinterpret_cast<SbkObject *>(pyobj), Shiboken::SbkType<QtDict>()));
+
+ QtDict result;
+
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+
+ while (PyDict_Next(pyobj, &pos, &key, &value))
+ result[Shiboken::Converter<typename QtDict::key_type>::toCpp(key)] = Shiboken::Converter<typename QtDict::mapped_type>::toCpp(value);
+ return result;
+ }
+};
+
+template <typename MultiMap>
+struct QtMultiMapConverter
+{
+ static inline bool checkType(PyObject* pyObj)
+ {
+ return isConvertible(pyObj);
+ }
+
+ static inline bool isConvertible(PyObject* pyObj)
+ {
+ if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<MultiMap>()))
+ return true;
+
+ if ((Shiboken::SbkType<MultiMap>() && Shiboken::Object::checkType(pyObj)) || !PyDict_Check(pyObj))
+ return false;
+
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+
+ while (PyDict_Next(pyObj, &pos, &key, &value)) {
+ if (!Shiboken::Converter<typename MultiMap::key_type>::isConvertible(key)) {
+ if (PySequence_Check(value)) {
+ for (int i = 0, max = PySequence_Length(value); i < max; ++i) {
+ Shiboken::AutoDecRef item(PySequence_GetItem(value, i));
+ if (!Shiboken::Converter<typename MultiMap::mapped_type>::isConvertible(value))
+ return false;
+ }
+ } else if (!Shiboken::Converter<typename MultiMap::mapped_type>::isConvertible(value)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<MultiMap*>(cppObj)); }
+ static inline PyObject* toPython(const MultiMap& cppObj)
+ {
+ PyObject* result = PyDict_New();
+ typename MultiMap::const_iterator it = cppObj.begin();
+
+ for (; it != cppObj.end(); ++it) {
+ Shiboken::AutoDecRef key(Shiboken::Converter<typename MultiMap::key_type>::toPython(it.key()));
+ Shiboken::AutoDecRef value(Shiboken::Converter<typename MultiMap::mapped_type>::toPython(it.value()));
+
+ PyObject* values = PyDict_GetItem(result, key);
+ bool decRefValues = !values;
+ if (!values)
+ values = PyList_New(0);
+ PyList_Append(values, value);
+ PyDict_SetItem(result, key, values);
+ if (decRefValues) {
+ Py_DECREF(values);
+ }
+ }
+
+ return result;
+ }
+
+ static inline MultiMap toCpp(PyObject* pyObj)
+ {
+ if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<MultiMap>()))
+ return *reinterpret_cast<MultiMap *>(Shiboken::Object::cppPointer(reinterpret_cast<SbkObject *>(pyObj), Shiboken::SbkType<MultiMap>()));
+
+ MultiMap result;
+
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+
+ while (PyDict_Next(pyObj, &pos, &key, &value))
+ result[Shiboken::Converter<typename MultiMap::key_type>::toCpp(key)] = Shiboken::Converter<typename MultiMap::mapped_type>::toCpp(value);
+ return result;
+ }
+};
+
+template <typename T>
+struct QSequenceConverter
+{
+ static inline bool checkType(PyObject* pyObj)
+ {
+ return isConvertible(pyObj);
+ }
+
+ static inline bool isConvertible(PyObject* pyObj)
+ {
+ if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<T>()))
+ return true;
+ if ((Shiboken::SbkType<T>() && Shiboken::Object::checkType(pyObj)) || !PySequence_Check(pyObj))
+ return false;
+ for (int i = 0, max = PySequence_Length(pyObj); i < max; ++i) {
+ Shiboken::AutoDecRef item(PySequence_GetItem(pyObj, i));
+ if (!Shiboken::Converter<typename T::value_type>::isConvertible(item))
+ return false;
+ }
+ return true;
+ }
+ static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<T*>(cppObj)); }
+ static PyObject* toPython(const T& cppobj)
+ {
+ PyObject* result = PyList_New((int) cppobj.size());
+ typename T::const_iterator it = cppobj.begin();
+ for (int idx = 0; it != cppobj.end(); ++it, ++idx) {
+ typename T::value_type vh(*it);
+ PyList_SET_ITEM(result, idx, Shiboken::Converter<typename T::value_type>::toPython(vh));
+ }
+ return result;
+ }
+ static T toCpp(PyObject* pyobj)
+ {
+ if (PyObject_TypeCheck(pyobj, Shiboken::SbkType<T>()))
+ return *reinterpret_cast<T *>(Shiboken::Object::cppPointer(reinterpret_cast<SbkObject *>(pyobj), Shiboken::SbkType<T>()));
+
+ Shiboken::AutoDecRef fastSequence(PySequence_Fast(pyobj, "Invalid sequence object"));
+ T result;
+ for (int i = 0; i < PySequence_Size(pyobj); i++) {
+ PyObject* pyItem = PySequence_Fast_GET_ITEM(fastSequence.object(), i);
+ result << Shiboken::Converter<typename T::value_type>::toCpp(pyItem);
+ }
+ return result;
+ }
+};
+
+
+template <typename T>
+struct QFlagsConverter
+{
+ static inline bool checkType(PyObject* pyObj)
+ {
+ return PyObject_TypeCheck(pyObj, Shiboken::SbkType<T>());
+ }
+
+ static inline bool isConvertible(PyObject* pyObj)
+ {
+ return PyObject_TypeCheck(pyObj, Shiboken::SbkType<T>())
+ || PyObject_TypeCheck(pyObj, Shiboken::SbkType<typename T::enum_type>());
+ }
+
+ static inline PyObject* toPython(void* cppObj)
+ {
+ return toPython(*reinterpret_cast<T*>(cppObj));
+ }
+
+ static inline PyObject* toPython(const T& cppObj)
+ {
+ return reinterpret_cast<PyObject*>(PySide::QFlags::newObject(cppObj, Shiboken::SbkType<T>()));
+ }
+
+ static inline T toCpp(PyObject* pyObj)
+ {
+ /* this was long. Needed int in Qt5 */
+ int val = 0;
+ if (Shiboken::Enum::check(pyObj)) {
+ val = Shiboken::Enum::getValue(pyObj);
+ } else if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<T>())) {
+ val = PySide::QFlags::getValue(reinterpret_cast<PySideQFlagsObject*>(pyObj));
+ } else if (PyNumber_Check(pyObj)) {
+ Shiboken::AutoDecRef pyLong(PyNumber_Long(pyObj));
+ val = PyLong_AsLong(pyLong.object());
+ } else {
+ PyErr_BadArgument();
+ }
+ return T(QFlag(val));
+ }
+};
+
+#endif
diff --git a/sources/pyside2/libpyside/pysidemacros.h b/sources/pyside2/libpyside/pysidemacros.h
new file mode 100644
index 000000000..df1ed6e8c
--- /dev/null
+++ b/sources/pyside2/libpyside/pysidemacros.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDEMACROS_H
+#define PYSIDEMACROS_H
+
+#if defined _WIN32
+ #if PYSIDE_EXPORTS
+ #define PYSIDE_API __declspec(dllexport)
+ #else
+ #if defined __MINGW32__
+ #define PYSIDE_API
+ #else
+ #define PYSIDE_API __declspec(dllimport)
+ #endif
+ #endif
+ #define PYSIDE_DEPRECATED(func) __declspec(deprecated) func
+#else
+ #if __GNUC__ >= 4
+ #define PYSIDE_API __attribute__ ((visibility("default")))
+ #define PYSIDE_DEPRECATED(func) func __attribute__ ((deprecated))
+ #else
+ #define PYSIDE_API
+ #define PYSIDE_DEPRECATED(func) func
+ #endif
+#endif
+
+#endif
diff --git a/sources/pyside2/libpyside/pysidemetafunction.cpp b/sources/pyside2/libpyside/pysidemetafunction.cpp
new file mode 100644
index 000000000..039db513b
--- /dev/null
+++ b/sources/pyside2/libpyside/pysidemetafunction.cpp
@@ -0,0 +1,253 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "pysidemetafunction.h"
+#include "pysidemetafunction_p.h"
+
+#include <shiboken.h>
+#include <QObject>
+#include <QMetaMethod>
+#include <QDebug>
+
+extern "C"
+{
+
+struct PySideMetaFunctionPrivate
+{
+ QObject* qobject;
+ int methodIndex;
+};
+
+//methods
+static void functionFree(void*);
+static PyObject* functionCall(PyObject*, PyObject*, PyObject*);
+
+PyTypeObject PySideMetaFunctionType = {
+ PyVarObject_HEAD_INIT(0, 0)
+ /*tp_name*/ "PySide.MetaFunction",
+ /*tp_basicsize*/ sizeof(PySideMetaFunction),
+ /*tp_itemsize*/ 0,
+ /*tp_dealloc*/ 0,
+ /*tp_print*/ 0,
+ /*tp_getattr*/ 0,
+ /*tp_setattr*/ 0,
+ /*tp_compare*/ 0,
+ /*tp_repr*/ 0,
+ /*tp_as_number*/ 0,
+ /*tp_as_sequence*/ 0,
+ /*tp_as_mapping*/ 0,
+ /*tp_hash*/ 0,
+ /*tp_call*/ functionCall,
+ /*tp_str*/ 0,
+ /*tp_getattro*/ 0,
+ /*tp_setattro*/ 0,
+ /*tp_as_buffer*/ 0,
+ /*tp_flags*/ Py_TPFLAGS_DEFAULT,
+ /*tp_doc*/ "MetaFunction",
+ /*tp_traverse*/ 0,
+ /*tp_clear*/ 0,
+ /*tp_richcompare*/ 0,
+ /*tp_weaklistoffset*/ 0,
+ /*tp_iter*/ 0,
+ /*tp_iternext*/ 0,
+ /*tp_methods*/ 0,
+ /*tp_members*/ 0,
+ /*tp_getset*/ 0,
+ /*tp_base*/ 0,
+ /*tp_dict*/ 0,
+ /*tp_descr_get*/ 0,
+ /*tp_descr_set*/ 0,
+ /*tp_dictoffset*/ 0,
+ /*tp_init*/ 0,
+ /*tp_alloc*/ 0,
+ /*tp_new*/ PyType_GenericNew,
+ /*tp_free*/ functionFree,
+ /*tp_is_gc*/ 0,
+ /*tp_bases*/ 0,
+ /*tp_mro*/ 0,
+ /*tp_cache*/ 0,
+ /*tp_subclasses*/ 0,
+ /*tp_weaklist*/ 0,
+ /*tp_del*/ 0,
+ /*tp_version_tag*/ 0
+};
+
+void functionFree(void *self)
+{
+ PySideMetaFunction* function = reinterpret_cast<PySideMetaFunction*>(self);
+ delete function->d;
+}
+
+PyObject *functionCall(PyObject *self, PyObject *args, PyObject * /* kw */)
+{
+ PySideMetaFunction* function = reinterpret_cast<PySideMetaFunction*>(self);
+
+ PyObject* retVal;
+ if (!PySide::MetaFunction::call(function->d->qobject, function->d->methodIndex, args, &retVal))
+ return 0;
+ return retVal;
+}
+
+} // extern "C"
+
+namespace PySide { namespace MetaFunction {
+
+void init(PyObject* module)
+{
+ if (PyType_Ready(&PySideMetaFunctionType) < 0)
+ return;
+
+ PyModule_AddObject(module, "MetaFunction", reinterpret_cast<PyObject *>(&PySideMetaFunctionType));
+}
+
+PySideMetaFunction* newObject(QObject* source, int methodIndex)
+{
+ if (methodIndex >= source->metaObject()->methodCount())
+ return 0;
+
+ QMetaMethod method = source->metaObject()->method(methodIndex);
+ if ((method.methodType() == QMetaMethod::Slot) ||
+ (method.methodType() == QMetaMethod::Method)) {
+ PySideMetaFunction* function = PyObject_New(PySideMetaFunction, &PySideMetaFunctionType);
+ function->d = new PySideMetaFunctionPrivate();
+ function->d->qobject = source;
+ function->d->methodIndex = methodIndex;
+ return function;
+ }
+ return 0;
+}
+
+bool call(QObject* self, int methodIndex, PyObject* args, PyObject** retVal)
+{
+
+ QMetaMethod method = self->metaObject()->method(methodIndex);
+ QList<QByteArray> argTypes = method.parameterTypes();
+
+ // args given plus return type
+ Shiboken::AutoDecRef sequence(PySequence_Fast(args, 0));
+ int numArgs = PySequence_Fast_GET_SIZE(sequence.object()) + 1;
+
+ if (numArgs - 1 > argTypes.count()) {
+ PyErr_Format(PyExc_TypeError, "%s only accepts %d argument(s), %d given!",
+ method.methodSignature().constData(),
+ argTypes.count(), numArgs - 1);
+ return false;
+ }
+
+ if (numArgs - 1 < argTypes.count()) {
+ PyErr_Format(PyExc_TypeError, "%s needs %d argument(s), %d given!",
+ method.methodSignature().constData(),
+ argTypes.count(), numArgs - 1);
+ return false;
+ }
+
+ QVariant* methValues = new QVariant[numArgs];
+ void** methArgs = new void*[numArgs];
+
+ // Prepare room for return type
+ const char* returnType = method.typeName();
+ if (returnType && std::strcmp("void", returnType))
+ argTypes.prepend(returnType);
+ else
+ argTypes.prepend(QByteArray());
+
+ int i;
+ for (i = 0; i < numArgs; ++i) {
+ const QByteArray& typeName = argTypes[i];
+ // This must happen only when the method hasn't return type.
+ if (typeName.isEmpty()) {
+ methArgs[i] = 0;
+ continue;
+ }
+
+ Shiboken::Conversions::SpecificConverter converter(typeName);
+ if (converter) {
+ int typeId = QMetaType::type(typeName);
+ 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));
+ }
+ methArgs[i] = methValues[i].data();
+ if (i == 0) // Don't do this for return type
+ continue;
+ if (typeId == QVariant::String) {
+ QString tmp;
+ converter.toCpp(PySequence_Fast_GET_ITEM(sequence.object(), i - 1), &tmp);
+ methValues[i] = tmp;
+ } else {
+ converter.toCpp(PySequence_Fast_GET_ITEM(sequence.object(), i - 1), methArgs[i]);
+ }
+ } else {
+ PyErr_Format(PyExc_TypeError, "Unknown type used to call meta function (that may be a signal): %s", argTypes[i].constData());
+ break;
+ }
+ }
+
+ bool ok = i == numArgs;
+ if (ok) {
+ Py_BEGIN_ALLOW_THREADS
+ QMetaObject::metacall(self, QMetaObject::InvokeMetaMethod, method.methodIndex(), methArgs);
+ Py_END_ALLOW_THREADS
+
+ if (retVal) {
+ if (methArgs[0]) {
+ static SbkConverter* qVariantTypeConverter = Shiboken::Conversions::getConverter("QVariant");
+ Q_ASSERT(qVariantTypeConverter);
+ *retVal = Shiboken::Conversions::copyToPython(qVariantTypeConverter, &methValues[0]);
+ } else {
+ *retVal = Py_None;
+ Py_INCREF(*retVal);
+ }
+ }
+ }
+
+ delete[] methArgs;
+ delete[] methValues;
+
+ return ok;
+}
+
+
+} //namespace MetaFunction
+} //namespace PySide
+
diff --git a/sources/pyside2/libpyside/pysidemetafunction.h b/sources/pyside2/libpyside/pysidemetafunction.h
new file mode 100644
index 000000000..2be369407
--- /dev/null
+++ b/sources/pyside2/libpyside/pysidemetafunction.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_METAFUNCTION_H
+#define PYSIDE_METAFUNCTION_H
+
+#include <QObject>
+#include <QString>
+#include <QStringList>
+
+#include <pysidemacros.h>
+#include <sbkpython.h>
+
+extern "C"
+{
+ extern PYSIDE_API PyTypeObject PySideMetaFunctionType;
+
+ struct PySideMetaFunctionPrivate;
+ struct PYSIDE_API PySideMetaFunction
+ {
+ PyObject_HEAD
+ PySideMetaFunctionPrivate* d;
+ };
+}; //extern "C"
+
+namespace PySide { namespace MetaFunction {
+
+/**
+ * This function creates a MetaFunction object
+ *
+ * @param obj the QObject witch this fuction is part of
+ * @param methodIndex The index of this function on MetaObject
+ * @return Return a new reference of PySideMetaFunction
+ **/
+PYSIDE_API PySideMetaFunction* newObject(QObject* obj, int methodIndex);
+
+} //namespace MetaFunction
+} //namespace PySide
+
+#endif
diff --git a/sources/pyside2/libpyside/pysidemetafunction_p.h b/sources/pyside2/libpyside/pysidemetafunction_p.h
new file mode 100644
index 000000000..979bbb120
--- /dev/null
+++ b/sources/pyside2/libpyside/pysidemetafunction_p.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_METAFUNCTION_P_H
+#define PYSIDE_METAFUNCTION_P_H
+
+#include <sbkpython.h>
+#include <QList>
+#include <QByteArray>
+
+QT_BEGIN_NAMESPACE
+class QObject;
+QT_END_NAMESPACE
+
+namespace PySide { namespace MetaFunction {
+
+ void init(PyObject* module);
+ /**
+ * Does a Qt metacall on a QObject
+ */
+ bool call(QObject* self, int methodIndex, PyObject* args, PyObject** retVal = 0);
+
+} //namespace MetaFunction
+} //namespace PySide
+
+#endif
diff --git a/sources/pyside2/libpyside/pysideproperty.cpp b/sources/pyside2/libpyside/pysideproperty.cpp
new file mode 100644
index 000000000..07b9dfae5
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideproperty.cpp
@@ -0,0 +1,519 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "pysideproperty.h"
+#include "pysideproperty_p.h"
+#include "dynamicqmetaobject_p.h"
+#include "pysidesignal.h"
+#include "pysidesignal_p.h"
+
+#include <shiboken.h>
+#include <QDebug>
+
+
+#define QPROPERTY_CLASS_NAME "Property"
+
+extern "C"
+{
+
+static PyObject* qpropertyTpNew(PyTypeObject* subtype, PyObject* args, PyObject* kwds);
+static int qpropertyTpInit(PyObject*, PyObject*, PyObject*);
+static void qpropertyDeAlloc(PyObject* self);
+
+//methods
+static PyObject* qPropertyCall(PyObject*, PyObject*, PyObject*);
+static PyObject* qPropertySetter(PyObject*, PyObject*);
+static PyObject* qPropertyGetter(PyObject*, PyObject*);
+static int qpropertyTraverse(PyObject* self, visitproc visit, void* arg);
+static int qpropertyClear(PyObject* self);
+
+static PyMethodDef PySidePropertyMethods[] = {
+ {"setter", (PyCFunction)qPropertySetter, METH_O, 0},
+ {"write", (PyCFunction)qPropertySetter, METH_O, 0},
+ {"getter", (PyCFunction)qPropertyGetter, METH_O, 0},
+ {"read", (PyCFunction)qPropertyGetter, METH_O, 0},
+ {0, 0, 0, 0}
+};
+
+PyTypeObject PySidePropertyType = {
+ PyVarObject_HEAD_INIT(0, 0)
+ QPROPERTY_CLASS_NAME, /*tp_name*/
+ sizeof(PySideProperty), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ qpropertyDeAlloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ qPropertyCall, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+ 0, /*tp_doc */
+ qpropertyTraverse, /*tp_traverse */
+ qpropertyClear, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ 0, /*tp_iter */
+ 0, /*tp_iternext */
+ PySidePropertyMethods, /*tp_methods */
+ 0, /*tp_members */
+ 0, /*tp_getset */
+ 0, /*tp_base */
+ 0, /*tp_dict */
+ 0, /*tp_descr_get */
+ 0, /*tp_descr_set */
+ 0, /*tp_dictoffset */
+ qpropertyTpInit, /*tp_init */
+ 0, /*tp_alloc */
+ qpropertyTpNew, /*tp_new */
+ 0, /*tp_free */
+ 0, /*tp_is_gc */
+ 0, /*tp_bases */
+ 0, /*tp_mro */
+ 0, /*tp_cache */
+ 0, /*tp_subclasses */
+ 0, /*tp_weaklist */
+ 0, /*tp_del */
+ 0 /*tp_version_tag */
+};
+
+static void qpropertyMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::Call call, void** args)
+{
+ Shiboken::Conversions::SpecificConverter converter(pp->d->typeName);
+ Q_ASSERT(converter);
+
+ QByteArray type(pp->d->typeName);
+
+ switch(call) {
+ case QMetaObject::ReadProperty:
+ {
+ Shiboken::GilState gil;
+ PyObject* value = PySide::Property::getValue(pp, self);
+ if (value) {
+ converter.toCpp(value, args[0]);
+ Py_DECREF(value);
+ }
+ break;
+ }
+
+ case QMetaObject::WriteProperty:
+ {
+ Shiboken::GilState gil;
+ Shiboken::AutoDecRef value(converter.toPython(args[0]));
+ PySide::Property::setValue(pp, self, value);
+ break;
+ }
+
+ case QMetaObject::ResetProperty:
+ {
+ Shiboken::GilState gil;
+ PySide::Property::reset(pp, self);
+ break;
+ }
+
+ case QMetaObject::QueryPropertyDesignable:
+ case QMetaObject::QueryPropertyScriptable:
+ case QMetaObject::QueryPropertyStored:
+ case QMetaObject::QueryPropertyEditable:
+ case QMetaObject::QueryPropertyUser:
+ // just to avoid gcc warnings
+ case QMetaObject::InvokeMetaMethod:
+ case QMetaObject::CreateInstance:
+ case QMetaObject::IndexOfMethod:
+ case QMetaObject::RegisterPropertyMetaType:
+ case QMetaObject::RegisterMethodArgumentMetaType:
+ break;
+ }
+}
+
+
+static PyObject *qpropertyTpNew(PyTypeObject *subtype, PyObject * /* args */, PyObject * /* kwds */)
+{
+ PySideProperty* me = reinterpret_cast<PySideProperty*>(subtype->tp_alloc(subtype, 0));
+ me->d = new PySidePropertyPrivate;
+ memset(me->d, 0, sizeof(PySidePropertyPrivate));
+ PySidePropertyPrivate* pData = me->d;
+ pData->designable = true;
+ pData->scriptable = true;
+ pData->stored = true;
+ return reinterpret_cast<PyObject *>(me);
+}
+
+int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ PyObject* type = 0;
+ PySideProperty* data = reinterpret_cast<PySideProperty*>(self);
+ PySidePropertyPrivate* pData = data->d;
+ pData->metaCallHandler = &qpropertyMetaCall;
+
+ static const char *kwlist[] = {"type", "fget", "fset", "freset", "fdel", "doc", "notify",
+ "designable", "scriptable", "stored", "user",
+ "constant", "final", 0};
+ if (!PyArg_ParseTupleAndKeywords(args, kwds,
+ "O|OOOOsObbbbbb:QtCore.QProperty", (char**) kwlist,
+ /*OO*/ &type, &(pData->fget),
+ /*OOO*/ &(pData->fset), &(pData->freset), &(pData->fdel),
+ /*s*/ &(pData->doc),
+ /*O*/ &(pData->notify),
+ /*bbbbbb*/ &(pData->designable), &(pData->scriptable), &(pData->stored), &(pData->user), &(pData->constant), &(pData->final))) {
+ return 0;
+ }
+
+
+ pData->typeName = PySide::Signal::getTypeName(type);
+
+ if (!pData->typeName)
+ PyErr_SetString(PyExc_TypeError, "Invalid property type or type name.");
+ else if (pData->constant && (pData->fset || pData->notify))
+ PyErr_SetString(PyExc_TypeError, "A constant property cannot have a WRITE method or a NOTIFY signal.");
+
+ if (!PyErr_Occurred()) {
+ Py_XINCREF(pData->fget);
+ Py_XINCREF(pData->fset);
+ Py_XINCREF(pData->freset);
+ Py_XINCREF(pData->fdel);
+ Py_XINCREF(pData->notify);
+ return 1;
+ } else {
+ pData->fget = 0;
+ pData->fset = 0;
+ pData->freset = 0;
+ pData->fdel = 0;
+ pData->notify = 0;
+ return -1;
+ }
+}
+
+void qpropertyDeAlloc(PyObject* self)
+{
+ qpropertyClear(self);
+ Py_TYPE(self)->tp_free(self);
+}
+
+PyObject *qPropertyCall(PyObject *self, PyObject *args, PyObject * /* kw */)
+{
+ PyObject *callback = PyTuple_GetItem(args, 0);
+ if (PyFunction_Check(callback)) {
+ PySideProperty *prop = reinterpret_cast<PySideProperty*>(self);
+ PySidePropertyPrivate* pData = prop->d;
+
+ Py_INCREF(callback);
+ pData->fget = callback;
+
+ Py_INCREF(self);
+ return self;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "Invalid property usage.");
+ return 0;
+ }
+}
+
+PyObject* qPropertySetter(PyObject* self, PyObject* callback)
+{
+ if (PyFunction_Check(callback)) {
+ PySideProperty *prop = reinterpret_cast<PySideProperty*>(self);
+ PySidePropertyPrivate* pData = prop->d;
+
+ Py_INCREF(callback);
+ pData->fset = callback;
+
+ Py_INCREF(callback);
+ return callback;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "Invalid property setter agument.");
+ return 0;
+ }
+}
+
+PyObject* qPropertyGetter(PyObject* self, PyObject* callback)
+{
+ if (PyFunction_Check(callback)) {
+ PySideProperty *prop = reinterpret_cast<PySideProperty*>(self);
+ PySidePropertyPrivate* pData = prop->d;
+
+ Py_INCREF(callback);
+ pData->fget = callback;
+
+ Py_INCREF(callback);
+ return callback;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "Invalid property getter agument.");
+ return 0;
+ }
+}
+
+static int qpropertyTraverse(PyObject* self, visitproc visit, void* arg)
+{
+ PySidePropertyPrivate* data = reinterpret_cast<PySideProperty*>(self)->d;
+ if (!data)
+ return 0;
+
+ Py_VISIT(data->fget);
+ Py_VISIT(data->fset);
+ Py_VISIT(data->freset);
+ Py_VISIT(data->fdel);
+ Py_VISIT(data->notify);
+ return 0;
+}
+
+static int qpropertyClear(PyObject* self)
+{
+ PySidePropertyPrivate* data = reinterpret_cast<PySideProperty*>(self)->d;
+ if (!data)
+ return 0;
+
+ Py_CLEAR(data->fget);
+ Py_CLEAR(data->fset);
+ Py_CLEAR(data->freset);
+ Py_CLEAR(data->fdel);
+ Py_CLEAR(data->notify);
+
+
+ free(data->typeName);
+ free(data->doc);
+ free(data->notifySignature);
+ delete data;
+ reinterpret_cast<PySideProperty*>(self)->d = 0;
+ return 0;
+}
+
+} // extern "C"
+
+namespace {
+
+static PyObject* getFromType(PyTypeObject* type, PyObject* name)
+{
+ PyObject* attr = 0;
+ attr = PyDict_GetItem(type->tp_dict, name);
+ if (!attr) {
+ PyObject* bases = type->tp_bases;
+ int size = PyTuple_GET_SIZE(bases);
+ for(int i=0; i < size; i++) {
+ PyObject* base = PyTuple_GET_ITEM(bases, i);
+ attr = getFromType(reinterpret_cast<PyTypeObject*>(base), name);
+ if (attr)
+ return attr;
+ }
+ }
+ return attr;
+}
+
+} //namespace
+
+
+namespace PySide { namespace Property {
+
+void init(PyObject* module)
+{
+ if (PyType_Ready(&PySidePropertyType) < 0)
+ return;
+
+ Py_INCREF(&PySidePropertyType);
+ PyModule_AddObject(module, QPROPERTY_CLASS_NAME, reinterpret_cast<PyObject *>(&PySidePropertyType));
+}
+
+bool checkType(PyObject* pyObj)
+{
+ if (pyObj) {
+ return PyType_IsSubtype(pyObj->ob_type, &PySidePropertyType);
+ }
+ return false;
+}
+
+bool isPropertyType(PyObject* pyObj)
+{
+ return checkType(pyObj);
+}
+
+int setValue(PySideProperty* self, PyObject* source, PyObject* value)
+{
+ PyObject* fset = self->d->fset;
+ if (fset) {
+ Shiboken::AutoDecRef args(PyTuple_New(2));
+ PyTuple_SET_ITEM(args, 0, source);
+ PyTuple_SET_ITEM(args, 1, value);
+ Py_INCREF(source);
+ Py_INCREF(value);
+ Shiboken::AutoDecRef result(PyObject_CallObject(fset, args));
+ return (result.isNull() ? -1 : 0);
+ } else {
+ PyErr_SetString(PyExc_AttributeError, "Attibute read only");
+ }
+ return -1;
+}
+
+PyObject* getValue(PySideProperty* self, PyObject* source)
+{
+ PyObject* fget = self->d->fget;
+ if (fget) {
+ Shiboken::AutoDecRef args(PyTuple_New(1));
+ Py_INCREF(source);
+ PyTuple_SET_ITEM(args, 0, source);
+ return PyObject_CallObject(fget, args);
+ }
+ return 0;
+}
+
+int reset(PySideProperty* self, PyObject* source)
+{
+ PyObject* freset = self->d->freset;
+ if (freset) {
+ Shiboken::AutoDecRef args(PyTuple_New(1));
+ Py_INCREF(source);
+ PyTuple_SET_ITEM(args, 0, source);
+ Shiboken::AutoDecRef result(PyObject_CallObject(freset, args));
+ return (result.isNull() ? -1 : 0);
+ }
+ return -1;
+}
+
+const char* getTypeName(const PySideProperty* self)
+{
+ return self->d->typeName;
+}
+
+PySideProperty* getObject(PyObject* source, PyObject* name)
+{
+ PyObject* attr = 0;
+
+ if (Shiboken::Object::isUserType(source)) {
+ PyObject* dict = reinterpret_cast<SbkObject*>(source)->ob_dict;
+ if (dict)
+ attr = PyDict_GetItem(dict, name);
+ }
+
+ attr = getFromType(source->ob_type, name);
+ if (attr && checkType(attr)) {
+ Py_INCREF(attr);
+ return reinterpret_cast<PySideProperty*>(attr);
+ }
+
+ if (!attr)
+ PyErr_Clear(); //Clear possible error caused by PyObject_GenericGetAttr
+
+ return 0;
+}
+
+bool isReadable(const PySideProperty * /* self */)
+{
+ return true;
+}
+
+bool isWritable(const PySideProperty* self)
+{
+ return (self->d->fset != 0);
+}
+
+bool hasReset(const PySideProperty* self)
+{
+ return (self->d->freset != 0);
+}
+
+bool isDesignable(const PySideProperty* self)
+{
+ return self->d->designable;
+}
+
+bool isScriptable(const PySideProperty* self)
+{
+ return self->d->scriptable;
+}
+
+bool isStored(const PySideProperty* self)
+{
+ return self->d->stored;
+}
+
+bool isUser(const PySideProperty* self)
+{
+ return self->d->user;
+}
+
+bool isConstant(const PySideProperty* self)
+{
+ return self->d->constant;
+}
+
+bool isFinal(const PySideProperty* self)
+{
+ return self->d->final;
+}
+
+const char* getNotifyName(PySideProperty* self)
+{
+ if (!self->d->notifySignature) {
+ PyObject* str = PyObject_Str(self->d->notify);
+ self->d->notifySignature = strdup(Shiboken::String::toCString(str));
+ Py_DECREF(str);
+ }
+
+ return self->d->notifySignature;
+}
+
+void setMetaCallHandler(PySideProperty* self, MetaCallHandler handler)
+{
+ self->d->metaCallHandler = handler;
+}
+
+void setTypeName(PySideProperty* self, const char* typeName)
+{
+ self->d->typeName = strdup(typeName);
+}
+
+void setUserData(PySideProperty* self, void* data)
+{
+ self->d->userData = data;
+}
+
+void* userData(PySideProperty* self)
+{
+ return self->d->userData;
+}
+
+} //namespace Property
+} //namespace PySide
diff --git a/sources/pyside2/libpyside/pysideproperty.h b/sources/pyside2/libpyside/pysideproperty.h
new file mode 100644
index 000000000..9ac61dc23
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideproperty.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_PROPERTY_H
+#define PYSIDE_PROPERTY_H
+
+#include <pysidemacros.h>
+#include <sbkpython.h>
+#include <QObject>
+
+extern "C"
+{
+ extern PYSIDE_API PyTypeObject PySidePropertyType;
+
+ struct PySidePropertyPrivate;
+ struct PYSIDE_API PySideProperty
+ {
+ PyObject_HEAD
+ PySidePropertyPrivate* d;
+ };
+};
+
+namespace PySide { namespace Property {
+
+typedef void (*MetaCallHandler)(PySideProperty*,PyObject*,QMetaObject::Call, void**);
+
+PYSIDE_API bool checkType(PyObject* pyObj);
+
+/// @deprecated Use checkType
+PYSIDE_DEPRECATED(PYSIDE_API bool isPropertyType(PyObject* pyObj));
+
+/**
+ * This function call set property function and pass value as arg
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @param source The QObject witch has the property
+ * @param value The value to set in property
+ * @return Return 0 if ok or -1 if this function fail
+ **/
+PYSIDE_API int setValue(PySideProperty* self, PyObject* source, PyObject* value);
+
+/**
+ * This function call get property function
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @param source The QObject witch has the property
+ * @return Return the result of property get function or 0 if this fail
+ **/
+PYSIDE_API PyObject* getValue(PySideProperty* self, PyObject* source);
+
+/**
+ * This function return the notify name used on this property
+ *
+ * @param self The property object
+ * @return Return a const char with the notify name used
+ **/
+PYSIDE_API const char* getNotifyName(PySideProperty* self);
+
+
+/**
+ * This function search in the source object for desired property
+ *
+ * @param source The QObject object
+ * @param name The property name
+ * @return Return a new reference to property object
+ **/
+PYSIDE_API PySideProperty* getObject(PyObject* source, PyObject* name);
+
+PYSIDE_API void setMetaCallHandler(PySideProperty* self, MetaCallHandler handler);
+
+PYSIDE_API void setTypeName(PySideProperty* self, const char* typeName);
+
+PYSIDE_API void setUserData(PySideProperty* self, void* data);
+PYSIDE_API void* userData(PySideProperty* self);
+
+} //namespace Property
+} //namespace PySide
+
+#endif
diff --git a/sources/pyside2/libpyside/pysideproperty_p.h b/sources/pyside2/libpyside/pysideproperty_p.h
new file mode 100644
index 000000000..95ed2a0f8
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideproperty_p.h
@@ -0,0 +1,184 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_QPROPERTY_P_H
+#define PYSIDE_QPROPERTY_P_H
+
+#include <sbkpython.h>
+#include <QMetaObject>
+#include "pysideproperty.h"
+
+struct PySideProperty;
+
+extern "C"
+{
+
+struct PySidePropertyPrivate {
+ char* typeName;
+ PySide::Property::MetaCallHandler metaCallHandler;
+ PyObject* fget;
+ PyObject* fset;
+ PyObject* freset;
+ PyObject* fdel;
+ PyObject* notify;
+ char* notifySignature;
+ char* doc;
+ bool designable;
+ bool scriptable;
+ bool stored;
+ bool user;
+ bool constant;
+ bool final;
+ void* userData;
+};
+
+} // extern "C"
+
+namespace PySide { namespace Property {
+
+/**
+ * Init PySide QProperty support system
+ */
+void init(PyObject* module);
+
+/**
+ * This function call reset property function
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @param source The QObject witch has the property
+ * @return Return 0 if ok or -1 if this function fail
+ **/
+int reset(PySideProperty* self, PyObject* source);
+
+
+/**
+ * This function return the property type
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @return Return the property type name
+ **/
+const char* getTypeName(const PySideProperty* self);
+
+/**
+ * This function check if property has read function
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @return Return a boolean value
+ **/
+bool isReadable(const PySideProperty* self);
+
+/**
+ * This function check if property has write function
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @return Return a boolean value
+ **/
+bool isWritable(const PySideProperty* self);
+
+/**
+ * This function check if property has reset function
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @return Return a boolean value
+ **/
+bool hasReset(const PySideProperty* self);
+
+/**
+ * This function check if property has the flag DESIGNABLE setted
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @return Return a boolean value
+ **/
+bool isDesignable(const PySideProperty* self);
+
+/**
+ * This function check if property has the flag SCRIPTABLE setted
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @return Return a boolean value
+ **/
+bool isScriptable(const PySideProperty* self);
+
+/**
+ * This function check if property has the flag STORED setted
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @return Return a boolean value
+ **/
+bool isStored(const PySideProperty* self);
+
+/**
+ * This function check if property has the flag USER setted
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @return Return a boolean value
+ **/
+bool isUser(const PySideProperty* self);
+
+/**
+ * This function check if property has the flag CONSTANT setted
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @return Return a boolean value
+ **/
+bool isConstant(const PySideProperty* self);
+
+/**
+ * This function check if property has the flag FINAL setted
+ * This function does not check the property object type
+ *
+ * @param self The property object
+ * @return Return a boolean value
+ **/
+bool isFinal(const PySideProperty* self);
+
+} // namespace Property
+} // namespace PySide
+
+#endif
diff --git a/sources/pyside2/libpyside/pysideqflags.cpp b/sources/pyside2/libpyside/pysideqflags.cpp
new file mode 100644
index 000000000..380c67f61
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideqflags.cpp
@@ -0,0 +1,167 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "pysideqflags.h"
+#include <sbkenum.h>
+#include <autodecref.h>
+
+extern "C" {
+ struct SbkConverter;
+
+ /**
+ * Type of all QFlags
+ */
+ struct PySideQFlagsType
+ {
+ PyHeapTypeObject super;
+ SbkConverter** converterPtr;
+ SbkConverter* converter;
+ };
+
+ #define PYSIDE_QFLAGS(X) reinterpret_cast<PySideQFlagsObject*>(X)
+
+ PyObject *PySideQFlagsNew(PyTypeObject *type, PyObject *args, PyObject * /* kwds */)
+ {
+ long val = 0;
+ if (PyTuple_GET_SIZE(args)) {
+ PyObject* arg = PyTuple_GET_ITEM(args, 0);
+ if (Shiboken::isShibokenEnum(arg)) {// faster call
+ val = Shiboken::Enum::getValue(arg);
+ } else if (PyNumber_Check(arg)) {
+ Shiboken::AutoDecRef number(PyNumber_Long(arg));
+ val = PyLong_AsLong(number);
+ } else {
+ PyErr_SetString(PyExc_TypeError,"QFlags must be created using enums or numbers.");
+ return 0;
+ }
+ }
+ PySideQFlagsObject* self = PyObject_New(PySideQFlagsObject, type);
+ self->ob_value = val;
+ return reinterpret_cast<PyObject*>(self);
+ }
+
+ static long getNumberValue(PyObject* v)
+ {
+ Shiboken::AutoDecRef number(PyNumber_Long(v));
+ return PyLong_AsLong(number);
+ }
+
+ PyObject* PySideQFlagsRichCompare(PyObject* self, PyObject* other, int op)
+ {
+ int result = 0;
+ if (!PyNumber_Check(other)) {
+ PyErr_BadArgument();
+ return NULL;
+ }
+
+ long valA = PYSIDE_QFLAGS(self)->ob_value;
+ long valB = getNumberValue(other);
+
+ if (self == other) {
+ result = 1;
+ } else {
+ switch (op) {
+ case Py_EQ:
+ result = (valA == valB);
+ break;
+ case Py_NE:
+ result = (valA != valB);
+ break;
+ case Py_LE:
+ result = (valA <= valB);
+ break;
+ case Py_GE:
+ result = (valA >= valB);
+ break;
+ case Py_LT:
+ result = (valA < valB);
+ break;
+ case Py_GT:
+ result = (valA > valB);
+ break;
+ default:
+ PyErr_BadArgument();
+ return NULL;
+ }
+ }
+ if (result)
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+ }
+}
+
+namespace PySide
+{
+namespace QFlags
+{
+ PyTypeObject* create(const char* name, PyNumberMethods* numberMethods)
+ {
+ PyTypeObject* type = reinterpret_cast<PyTypeObject*>(new PySideQFlagsType);
+ ::memset(type, 0, sizeof(PySideQFlagsType));
+ Py_TYPE(type) = &PyType_Type;
+ type->tp_basicsize = sizeof(PySideQFlagsObject);
+ type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES;
+ type->tp_name = name;
+ type->tp_new = &PySideQFlagsNew;
+ type->tp_as_number = numberMethods;
+ type->tp_richcompare = &PySideQFlagsRichCompare;
+
+ PySideQFlagsType* flagsType = reinterpret_cast<PySideQFlagsType*>(type);
+ flagsType->converterPtr = &flagsType->converter;
+
+ if (PyType_Ready(type) < 0)
+ return 0;
+
+ return type;
+ }
+
+ PySideQFlagsObject* newObject(long value, PyTypeObject* type)
+ {
+ PySideQFlagsObject* qflags = PyObject_New(PySideQFlagsObject, type);
+ qflags->ob_value = value;
+ return qflags;
+ }
+
+ long getValue(PySideQFlagsObject* self)
+ {
+ return self->ob_value;
+ }
+}
+}
diff --git a/sources/pyside2/libpyside/pysideqflags.h b/sources/pyside2/libpyside/pysideqflags.h
new file mode 100644
index 000000000..500727eaf
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideqflags.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_QFLAGS_H
+#define PYSIDE_QFLAGS_H
+
+#include <sbkpython.h>
+#include "pysidemacros.h"
+
+
+extern "C"
+{
+ struct PYSIDE_API PySideQFlagsObject {
+ PyObject_HEAD
+ long ob_value;
+ };
+
+ PYSIDE_API PyObject* PySideQFlagsNew(PyTypeObject *type, PyObject *args, PyObject *kwds);
+ PYSIDE_API PyObject* PySideQFlagsRichCompare(PyObject *self, PyObject *other, int op);
+}
+
+
+namespace PySide
+{
+namespace QFlags
+{
+ /**
+ * Creates a new QFlags type.
+ */
+ PYSIDE_API PyTypeObject* create(const char* name, PyNumberMethods* numberMethods);
+ /**
+ * Creates a new QFlags instance of type \p type and value \p value.
+ */
+ PYSIDE_API PySideQFlagsObject* newObject(long value, PyTypeObject* type);
+ /**
+ * Returns the value held by a QFlag.
+ */
+ PYSIDE_API long getValue(PySideQFlagsObject* self);
+}
+}
+
+#endif
+
diff --git a/sources/pyside2/libpyside/pysidesignal.cpp b/sources/pyside2/libpyside/pysidesignal.cpp
new file mode 100644
index 000000000..e213ff069
--- /dev/null
+++ b/sources/pyside2/libpyside/pysidesignal.cpp
@@ -0,0 +1,1070 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "pysidesignal.h"
+#include "pysidesignal_p.h"
+#include "signalmanager.h"
+
+#include <shiboken.h>
+#include <QDebug>
+
+#define SIGNAL_CLASS_NAME "Signal"
+#define SIGNAL_INSTANCE_NAME "SignalInstance"
+#define QT_SIGNAL_SENTINEL '2'
+
+namespace PySide {
+namespace Signal {
+ //aux
+ class SignalSignature {
+ public:
+ SignalSignature() : m_attributes(QMetaMethod::Compatibility) {}
+ SignalSignature(QByteArray parameterTypes) : m_parameterTypes(parameterTypes),
+ m_attributes(QMetaMethod::Compatibility) {}
+ SignalSignature(QByteArray parameterTypes, QMetaMethod::Attributes attributes) :
+ m_parameterTypes(parameterTypes),
+ m_attributes(attributes) {}
+ QByteArray m_parameterTypes;
+ QMetaMethod::Attributes m_attributes;
+ };
+
+ static char* buildSignature(const char*, const char*);
+ static void appendSignature(PySideSignal*, const SignalSignature &);
+ static void instanceInitialize(PySideSignalInstance*, PyObject*, PySideSignal*, PyObject*, int);
+ static char* parseSignature(PyObject*);
+ static PyObject* buildQtCompatible(const char*);
+}
+}
+
+extern "C"
+{
+
+// Signal methods
+static int signalTpInit(PyObject*, PyObject*, PyObject*);
+static void signalFree(void*);
+static void signalInstanceFree(void*);
+static PyObject* signalGetItem(PyObject* self, PyObject* key);
+static PyObject* signalToString(PyObject* self);
+
+// Signal Instance methods
+static PyObject* signalInstanceConnect(PyObject*, PyObject*, PyObject*);
+static PyObject* signalInstanceDisconnect(PyObject*, PyObject*);
+static PyObject* signalInstanceEmit(PyObject*, PyObject*);
+static PyObject* signalInstanceGetItem(PyObject*, PyObject*);
+
+static PyObject* signalInstanceCall(PyObject* self, PyObject* args, PyObject* kw);
+static PyObject* signalCall(PyObject*, PyObject*, PyObject*);
+
+static PyObject* metaSignalCheck(PyObject*, PyObject*);
+
+static PyMappingMethods Signal_as_mapping = {
+ 0,
+ signalGetItem,
+ 0
+};
+
+static PyMethodDef Signal_methods[] = {
+ {"__instancecheck__", (PyCFunction)metaSignalCheck, METH_O, NULL},
+ {0, 0, 0, 0}
+};
+
+PyTypeObject PySideSignalMetaType = {
+ PyVarObject_HEAD_INIT(0, 0)
+ /*tp_name*/ "PySide2.QtCore.MetaSignal",
+ /*tp_basicsize*/ sizeof(PyTypeObject),
+ /*tp_itemsize*/ 0,
+ /*tp_dealloc*/ 0,
+ /*tp_print*/ 0,
+ /*tp_getattr*/ 0,
+ /*tp_setattr*/ 0,
+ /*tp_compare*/ 0,
+ /*tp_repr*/ 0,
+ /*tp_as_number*/ 0,
+ /*tp_as_sequence*/ 0,
+ /*tp_as_mapping*/ 0,
+ /*tp_hash*/ 0,
+ /*tp_call*/ 0,
+ /*tp_str*/ 0,
+ /*tp_getattro*/ 0,
+ /*tp_setattro*/ 0,
+ /*tp_as_buffer*/ 0,
+ /*tp_flags*/ Py_TPFLAGS_DEFAULT,
+ /*tp_doc*/ 0,
+ /*tp_traverse*/ 0,
+ /*tp_clear*/ 0,
+ /*tp_richcompare*/ 0,
+ /*tp_weaklistoffset*/ 0,
+ /*tp_iter*/ 0,
+ /*tp_iternext*/ 0,
+ /*tp_methods*/ Signal_methods,
+ /*tp_members*/ 0,
+ /*tp_getset*/ 0,
+ /*tp_base*/ &PyType_Type,
+ /*tp_dict*/ 0,
+ /*tp_descr_get*/ 0,
+ /*tp_descr_set*/ 0,
+ /*tp_dictoffset*/ 0,
+ /*tp_init*/ 0,
+ /*tp_alloc*/ 0,
+ /*tp_new*/ 0,
+ /*tp_free*/ 0,
+ /*tp_is_gc*/ 0,
+ /*tp_bases*/ 0,
+ /*tp_mro*/ 0,
+ /*tp_cache*/ 0,
+ /*tp_subclasses*/ 0,
+ /*tp_weaklist*/ 0,
+ /*tp_del*/ 0,
+ /*tp_version_tag*/ 0
+};
+
+PyTypeObject PySideSignalType = {
+ PyVarObject_HEAD_INIT(&PySideSignalMetaType, 0)
+ /*tp_name*/ "PySide2.QtCore." SIGNAL_CLASS_NAME,
+ /*tp_basicsize*/ sizeof(PySideSignal),
+ /*tp_itemsize*/ 0,
+ /*tp_dealloc*/ 0,
+ /*tp_print*/ 0,
+ /*tp_getattr*/ 0,
+ /*tp_setattr*/ 0,
+ /*tp_compare*/ 0,
+ /*tp_repr*/ 0,
+ /*tp_as_number*/ 0,
+ /*tp_as_sequence*/ 0,
+ /*tp_as_mapping*/ &Signal_as_mapping,
+ /*tp_hash*/ 0,
+ /*tp_call*/ signalCall,
+ /*tp_str*/ signalToString,
+ /*tp_getattro*/ 0,
+ /*tp_setattro*/ 0,
+ /*tp_as_buffer*/ 0,
+ /*tp_flags*/ Py_TPFLAGS_DEFAULT,
+ /*tp_doc*/ SIGNAL_CLASS_NAME,
+ /*tp_traverse*/ 0,
+ /*tp_clear*/ 0,
+ /*tp_richcompare*/ 0,
+ /*tp_weaklistoffset*/ 0,
+ /*tp_iter*/ 0,
+ /*tp_iternext*/ 0,
+ /*tp_methods*/ 0,
+ /*tp_members*/ 0,
+ /*tp_getset*/ 0,
+ /*tp_base*/ 0,
+ /*tp_dict*/ 0,
+ /*tp_descr_get*/ 0,
+ /*tp_descr_set*/ 0,
+ /*tp_dictoffset*/ 0,
+ /*tp_init*/ signalTpInit,
+ /*tp_alloc*/ 0,
+ /*tp_new*/ PyType_GenericNew,
+ /*tp_free*/ signalFree,
+ /*tp_is_gc*/ 0,
+ /*tp_bases*/ 0,
+ /*tp_mro*/ 0,
+ /*tp_cache*/ 0,
+ /*tp_subclasses*/ 0,
+ /*tp_weaklist*/ 0,
+ /*tp_del*/ 0,
+ /*tp_version_tag*/ 0
+};
+
+static PyMethodDef SignalInstance_methods[] = {
+ {"connect", (PyCFunction)signalInstanceConnect, METH_VARARGS|METH_KEYWORDS, 0},
+ {"disconnect", signalInstanceDisconnect, METH_VARARGS, 0},
+ {"emit", signalInstanceEmit, METH_VARARGS, 0},
+ {0, 0, 0, 0} /* Sentinel */
+};
+
+static PyMappingMethods SignalInstance_as_mapping = {
+ 0,
+ signalInstanceGetItem,
+ 0
+};
+
+PyTypeObject PySideSignalInstanceType = {
+ PyVarObject_HEAD_INIT(0, 0)
+ /*tp_name*/ "PySide2.QtCore." SIGNAL_INSTANCE_NAME,
+ /*tp_basicsize*/ sizeof(PySideSignalInstance),
+ /*tp_itemsize*/ 0,
+ /*tp_dealloc*/ 0,
+ /*tp_print*/ 0,
+ /*tp_getattr*/ 0,
+ /*tp_setattr*/ 0,
+ /*tp_compare*/ 0,
+ /*tp_repr*/ 0,
+ /*tp_as_number*/ 0,
+ /*tp_as_sequence*/ 0,
+ /*tp_as_mapping*/ &SignalInstance_as_mapping,
+ /*tp_hash*/ 0,
+ /*tp_call*/ signalInstanceCall,
+ /*tp_str*/ 0,
+ /*tp_getattro*/ 0,
+ /*tp_setattro*/ 0,
+ /*tp_as_buffer*/ 0,
+ /*tp_flags*/ Py_TPFLAGS_DEFAULT,
+ /*tp_doc*/ SIGNAL_INSTANCE_NAME,
+ /*tp_traverse*/ 0,
+ /*tp_clear*/ 0,
+ /*tp_richcompare*/ 0,
+ /*tp_weaklistoffset*/ 0,
+ /*tp_iter*/ 0,
+ /*tp_iternext*/ 0,
+ /*tp_methods*/ SignalInstance_methods,
+ /*tp_members*/ 0,
+ /*tp_getset*/ 0,
+ /*tp_base*/ 0,
+ /*tp_dict*/ 0,
+ /*tp_descr_get*/ 0,
+ /*tp_descr_set*/ 0,
+ /*tp_dictoffset*/ 0,
+ /*tp_init*/ 0,
+ /*tp_alloc*/ 0,
+ /*tp_new*/ PyType_GenericNew,
+ /*tp_free*/ signalInstanceFree,
+ /*tp_is_gc*/ 0,
+ /*tp_bases*/ 0,
+ /*tp_mro*/ 0,
+ /*tp_cache*/ 0,
+ /*tp_subclasses*/ 0,
+ /*tp_weaklist*/ 0,
+ /*tp_del*/ 0,
+ /*tp_version_tag*/ 0
+};
+
+int signalTpInit(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ static PyObject* emptyTuple = 0;
+ static const char* kwlist[] = {"name", 0};
+ char* argName = 0;
+
+ if (emptyTuple == 0)
+ emptyTuple = PyTuple_New(0);
+
+ if (!PyArg_ParseTupleAndKeywords(emptyTuple, kwds,
+ "|s:QtCore." SIGNAL_CLASS_NAME, const_cast<char**>(kwlist), &argName))
+ return 0;
+
+ bool tupledArgs = false;
+ PySideSignal* data = reinterpret_cast<PySideSignal*>(self);
+ if (argName) {
+ data->signalName = strdup(argName);
+ }
+
+ for (Py_ssize_t i = 0, i_max = PyTuple_Size(args); i < i_max; i++) {
+ PyObject* arg = PyTuple_GET_ITEM(args, i);
+ if (PySequence_Check(arg) && !Shiboken::String::check(arg)) {
+ tupledArgs = true;
+ char *sig = PySide::Signal::parseSignature(arg);
+ PySide::Signal::appendSignature(
+ data,
+ PySide::Signal::SignalSignature(sig));
+ free(sig);
+ }
+ }
+
+ if (!tupledArgs) {
+ char *sig = PySide::Signal::parseSignature(args);
+ PySide::Signal::appendSignature(
+ data,
+ PySide::Signal::SignalSignature(sig));
+ free(sig);
+ }
+
+ return 1;
+}
+
+void signalFree(void* self)
+{
+ PyObject* pySelf = reinterpret_cast<PyObject*>(self);
+ PySideSignal* data = reinterpret_cast<PySideSignal*>(self);
+
+ for (int i = 0, i_max = data->signaturesSize; i < i_max; i++) {
+ if (data->signatures[i])
+ free(data->signatures[i]);
+ }
+
+ free(data->signatures);
+ free(data->signatureAttributes);
+ free(data->signalName);
+ data->initialized = 0;
+ data->signaturesSize = 0;
+ Py_XDECREF(data->homonymousMethod);
+ data->homonymousMethod = 0;
+
+ pySelf->ob_type->tp_base->tp_free(self);
+}
+
+PyObject* signalGetItem(PyObject* self, PyObject* key)
+{
+ PySideSignal* data = reinterpret_cast<PySideSignal*>(self);
+ char* sigKey;
+ if (key) {
+ sigKey = PySide::Signal::parseSignature(key);
+ } else {
+ if (data->signatures[0])
+ sigKey = strdup(data->signatures[0]);
+ else
+ sigKey = strdup("void");
+ }
+ char* sig = PySide::Signal::buildSignature(data->signalName, sigKey);
+ free(sigKey);
+ PyObject* pySignature = Shiboken::String::fromCString(sig);
+ free(sig);
+ return pySignature;
+}
+
+
+PyObject* signalToString(PyObject* self)
+{
+ return signalGetItem(self, 0);
+}
+
+void signalInstanceFree(void* self)
+{
+ PyObject* pySelf = reinterpret_cast<PyObject*>(self);
+ PySideSignalInstance* data = reinterpret_cast<PySideSignalInstance*>(self);
+
+ PySideSignalInstancePrivate* dataPvt = data->d;
+ free(dataPvt->signalName);
+ free(dataPvt->signature);
+
+ Py_XDECREF(dataPvt->homonymousMethod);
+
+ if (dataPvt->next) {
+ Py_DECREF(dataPvt->next);
+ dataPvt->next = 0;
+ }
+ delete dataPvt;
+ data->d = 0;
+ pySelf->ob_type->tp_base->tp_free(self);
+}
+
+PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ PyObject* slot = 0;
+ PyObject* type = 0;
+ static const char* kwlist[] = {"slot", "type", 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds,
+ "O|O:" SIGNAL_INSTANCE_NAME, const_cast<char**>(kwlist), &slot, &type))
+ return 0;
+
+ PySideSignalInstance* source = reinterpret_cast<PySideSignalInstance*>(self);
+ Shiboken::AutoDecRef pyArgs(PyList_New(0));
+
+ bool match = false;
+ if (slot->ob_type == &PySideSignalInstanceType) {
+ PySideSignalInstance* sourceWalk = source;
+ PySideSignalInstance* targetWalk;
+
+ //find best match
+ while (sourceWalk && !match) {
+ targetWalk = reinterpret_cast<PySideSignalInstance*>(slot);
+ while (targetWalk && !match) {
+ if (QMetaObject::checkConnectArgs(sourceWalk->d->signature, targetWalk->d->signature)) {
+ PyList_Append(pyArgs, sourceWalk->d->source);
+ Shiboken::AutoDecRef sourceSignature(PySide::Signal::buildQtCompatible(sourceWalk->d->signature));
+ PyList_Append(pyArgs, sourceSignature);
+
+ PyList_Append(pyArgs, targetWalk->d->source);
+ Shiboken::AutoDecRef targetSignature(PySide::Signal::buildQtCompatible(targetWalk->d->signature));
+ PyList_Append(pyArgs, targetSignature);
+
+ match = true;
+ }
+ targetWalk = reinterpret_cast<PySideSignalInstance*>(targetWalk->d->next);
+ }
+ sourceWalk = reinterpret_cast<PySideSignalInstance*>(sourceWalk->d->next);
+ }
+ } else {
+ //try the first signature
+ PyList_Append(pyArgs, source->d->source);
+ Shiboken::AutoDecRef signature(PySide::Signal::buildQtCompatible(source->d->signature));
+ PyList_Append(pyArgs, signature);
+
+ PyList_Append(pyArgs, slot);
+ match = true;
+ }
+
+ if (type)
+ PyList_Append(pyArgs, type);
+
+ if (match) {
+ Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
+ Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->d->source, "connect"));
+ if (pyMethod.isNull()) { // PYSIDE-79: check if pyMethod exists.
+ PyErr_SetString(PyExc_RuntimeError, "method 'connect' vanished!");
+ return 0;
+ }
+ PyObject* result = PyObject_CallObject(pyMethod, tupleArgs);
+ if (result == Py_True)
+ return result;
+ else
+ Py_XDECREF(result);
+ }
+ if (!PyErr_Occurred()) // PYSIDE-79: inverse the logic. A Null return needs an error.
+ PyErr_Format(PyExc_RuntimeError, "Failed to connect signal %s.", source->d->signature);
+ return 0;
+}
+
+int argCountInSignature(const char *signature)
+{
+ return QByteArray(signature).count(",") + 1;
+}
+
+PyObject* signalInstanceEmit(PyObject* self, PyObject* args)
+{
+ PySideSignalInstance* source = reinterpret_cast<PySideSignalInstance*>(self);
+
+ Shiboken::AutoDecRef pyArgs(PyList_New(0));
+ int numArgsGiven = PySequence_Fast_GET_SIZE(args);
+ int numArgsInSignature = argCountInSignature(source->d->signature);
+
+ // If number of arguments given to emit is smaller than the first source signature expects,
+ // it is possible it's a case of emitting a signal with default parameters.
+ // Search through all the overloaded signals with the same name, and try to find a signature
+ // with the same number of arguments as given to emit, and is also marked as a cloned method
+ // (which in metaobject parlance means a signal with default parameters).
+ // @TODO: This should be improved to take into account argument types as well. The current
+ // assumption is there are no signals which are both overloaded on argument types and happen to
+ // have signatures with default parameters.
+ if (numArgsGiven < numArgsInSignature) {
+ PySideSignalInstance *possibleDefaultInstance = source;
+ while ((possibleDefaultInstance = possibleDefaultInstance->d->next)) {
+ if (possibleDefaultInstance->d->attributes & QMetaMethod::Cloned
+ && argCountInSignature(possibleDefaultInstance->d->signature) == numArgsGiven) {
+ source = possibleDefaultInstance;
+ break;
+ }
+ }
+ }
+ Shiboken::AutoDecRef sourceSignature(PySide::Signal::buildQtCompatible(source->d->signature));
+
+ PyList_Append(pyArgs, sourceSignature);
+ for (Py_ssize_t i = 0, max = PyTuple_Size(args); i < max; i++)
+ PyList_Append(pyArgs, PyTuple_GetItem(args, i));
+
+ Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->d->source, "emit"));
+
+ Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
+ return PyObject_CallObject(pyMethod, tupleArgs);
+}
+
+PyObject* signalInstanceGetItem(PyObject* self, PyObject* key)
+{
+ PySideSignalInstance* data = reinterpret_cast<PySideSignalInstance*>(self);
+ char* sigKey = PySide::Signal::parseSignature(key);
+ char* sig = PySide::Signal::buildSignature(data->d->signalName, sigKey);
+ free(sigKey);
+ const char* sigName = data->d->signalName;
+
+ while (data) {
+ if (strcmp(data->d->signature, sig) == 0) {
+ free(sig);
+ PyObject* result = reinterpret_cast<PyObject*>(data);
+ Py_INCREF(result);
+ return result;
+ }
+ data = reinterpret_cast<PySideSignalInstance*>(data->d->next);
+ }
+
+ PyErr_Format(PyExc_IndexError, "Signature %s not found for signal: %s", sig, sigName);
+ free(sig);
+ return 0;
+}
+
+PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args)
+{
+ PySideSignalInstance* source = reinterpret_cast<PySideSignalInstance*>(self);
+ Shiboken::AutoDecRef pyArgs(PyList_New(0));
+
+ PyObject* slot;
+ if (PyTuple_Check(args) && PyTuple_GET_SIZE(args))
+ slot = PyTuple_GET_ITEM(args, 0);
+ else
+ slot = Py_None;
+
+ bool match = false;
+ if (slot->ob_type == &PySideSignalInstanceType) {
+ PySideSignalInstance* target = reinterpret_cast<PySideSignalInstance*>(slot);
+ if (QMetaObject::checkConnectArgs(source->d->signature, target->d->signature)) {
+ PyList_Append(pyArgs, source->d->source);
+ Shiboken::AutoDecRef source_signature(PySide::Signal::buildQtCompatible(source->d->signature));
+ PyList_Append(pyArgs, source_signature);
+
+ PyList_Append(pyArgs, target->d->source);
+ Shiboken::AutoDecRef target_signature(PySide::Signal::buildQtCompatible(target->d->signature));
+ PyList_Append(pyArgs, target_signature);
+ match = true;
+ }
+ } else {
+ //try the first signature
+ PyList_Append(pyArgs, source->d->source);
+ Shiboken::AutoDecRef signature(PySide::Signal::buildQtCompatible(source->d->signature));
+ PyList_Append(pyArgs, signature);
+
+ // disconnect all, so we need to use the c++ signature disconnect(qobj, signal, 0, 0)
+ if (slot == Py_None)
+ PyList_Append(pyArgs, slot);
+ PyList_Append(pyArgs, slot);
+ match = true;
+ }
+
+ if (match) {
+ Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
+ Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->d->source, "disconnect"));
+ PyObject* result = PyObject_CallObject(pyMethod, tupleArgs);
+ if (!result || result == Py_True)
+ return result;
+ else
+ Py_DECREF(result);
+ }
+
+ PyErr_Format(PyExc_RuntimeError, "Failed to disconnect signal %s.", source->d->signature);
+ return 0;
+}
+
+PyObject* signalCall(PyObject* self, PyObject* args, PyObject* kw)
+{
+ PySideSignal* signal = reinterpret_cast<PySideSignal*>(self);
+
+ if (!signal->homonymousMethod) {
+ PyErr_SetString(PyExc_TypeError, "native Qt signal is not callable");
+ return 0;
+ }
+
+ descrgetfunc getDescriptor = signal->homonymousMethod->ob_type->tp_descr_get;
+ Shiboken::AutoDecRef homonymousMethod(getDescriptor(signal->homonymousMethod, 0, 0));
+
+ if (PyCFunction_GET_FLAGS(homonymousMethod.object()) & METH_STATIC)
+ return PyCFunction_Call(homonymousMethod, args, kw);
+
+ ternaryfunc callFunc = signal->homonymousMethod->ob_type->tp_call;
+ return callFunc(homonymousMethod, args, kw);
+}
+
+PyObject* signalInstanceCall(PyObject* self, PyObject* args, PyObject* kw)
+{
+ PySideSignalInstance* PySideSignal = reinterpret_cast<PySideSignalInstance*>(self);
+ if (!PySideSignal->d->homonymousMethod) {
+ PyErr_SetString(PyExc_TypeError, "native Qt signal is not callable");
+ return 0;
+ }
+
+ descrgetfunc getDescriptor = PySideSignal->d->homonymousMethod->ob_type->tp_descr_get;
+ Shiboken::AutoDecRef homonymousMethod(getDescriptor(PySideSignal->d->homonymousMethod, PySideSignal->d->source, 0));
+ return PyCFunction_Call(homonymousMethod, args, kw);
+}
+
+static PyObject *metaSignalCheck(PyObject * /* klass */, PyObject* args)
+{
+ if (PyType_IsSubtype(args->ob_type, &PySideSignalInstanceType))
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+}
+
+} // extern "C"
+
+namespace PySide {
+namespace Signal {
+
+void init(PyObject* module)
+{
+ if (PyType_Ready(&PySideSignalMetaType) < 0)
+ return;
+
+ if (PyType_Ready(&PySideSignalType) < 0)
+ return;
+
+ Py_INCREF(&PySideSignalType);
+ PyModule_AddObject(module, SIGNAL_CLASS_NAME, reinterpret_cast<PyObject *>(&PySideSignalType));
+
+ if (PyType_Ready(&PySideSignalInstanceType) < 0)
+ return;
+
+ Py_INCREF(&PySideSignalInstanceType);
+}
+
+bool checkType(PyObject* pyObj)
+{
+ if (pyObj)
+ return PyType_IsSubtype(pyObj->ob_type, &PySideSignalType);
+ return false;
+}
+
+void updateSourceObject(PyObject* source)
+{
+ PyTypeObject* objType = reinterpret_cast<PyTypeObject*>(PyObject_Type(source));
+
+ Py_ssize_t pos = 0;
+ PyObject* value;
+ PyObject* key;
+
+ while (PyDict_Next(objType->tp_dict, &pos, &key, &value)) {
+ if (PyObject_TypeCheck(value, &PySideSignalType)) {
+ Shiboken::AutoDecRef signalInstance(reinterpret_cast<PyObject *>(PyObject_New(PySideSignalInstance, &PySideSignalInstanceType)));
+ instanceInitialize(signalInstance.cast<PySideSignalInstance*>(), key, reinterpret_cast<PySideSignal*>(value), source, 0);
+ PyObject_SetAttr(source, key, signalInstance);
+ }
+ }
+
+ Py_XDECREF(objType);
+}
+
+char* getTypeName(PyObject* type)
+{
+ if (PyType_Check(type)) {
+ char* typeName = NULL;
+ if (PyType_IsSubtype(reinterpret_cast<PyTypeObject*>(type), reinterpret_cast<PyTypeObject*>(&SbkObject_Type))) {
+ SbkObjectType* objType = reinterpret_cast<SbkObjectType*>(type);
+ typeName = strdup(Shiboken::ObjectType::getOriginalName(objType));
+ } else {
+ // Translate python types to Qt names
+ PyTypeObject* objType = reinterpret_cast<PyTypeObject*>(type);
+ if (Shiboken::String::checkType(objType))
+ typeName = strdup("QString");
+ else if (objType == &PyInt_Type)
+ typeName = strdup("int");
+ else if (objType == &PyLong_Type)
+ typeName = strdup("long");
+ else if (objType == &PyFloat_Type)
+ typeName = strdup("double");
+ else if (objType == &PyBool_Type)
+ typeName = strdup("bool");
+ else if (Py_TYPE(objType) == &SbkEnumType_Type)
+ typeName = strdup(Shiboken::Enum::getCppName(objType));
+ else
+ typeName = strdup("PyObject");
+ }
+ return typeName;
+ } else if (type == Py_None) { // Must be checked before as Shiboken::String::check accepts Py_None
+ return strdup("void");
+ } else if (Shiboken::String::check(type)) {
+ const char *result = Shiboken::String::toCString(type);
+ if (!strcmp(result, "qreal"))
+ result = sizeof(qreal) == sizeof(double) ? "double" : "float";
+ return strdup(result);
+ }
+ return 0;
+}
+
+char* buildSignature(const char* name, const char* signature)
+{
+ QByteArray signal(name);
+ signal += '(';
+ signal += signature;
+ signal += ')';
+ return strdup(QMetaObject::normalizedSignature(signal));
+}
+
+char* parseSignature(PyObject* args)
+{
+ char* signature = 0;
+ if (args && (Shiboken::String::check(args) || !PySequence_Check(args)))
+ return getTypeName(args);
+
+ for (Py_ssize_t i = 0, i_max = PySequence_Size(args); i < i_max; i++) {
+ Shiboken::AutoDecRef arg(PySequence_ITEM(args, i));
+ char* typeName = getTypeName(arg);
+ if (typeName) {
+ if (signature) {
+ signature = reinterpret_cast<char*>(realloc(signature, (strlen(signature) + 1 + strlen(typeName)) * sizeof(char*)));
+ signature = strcat(signature, ",");
+ signature = strcat(signature, typeName);
+ free(typeName);
+ } else {
+ signature = typeName;
+ }
+ }
+ }
+ return signature;
+}
+
+void appendSignature(PySideSignal* self, const SignalSignature &signature)
+{
+ self->signaturesSize++;
+
+ if (self->signaturesSize > 1) {
+ self->signatures = reinterpret_cast<char **>(realloc(self->signatures, sizeof(char *) * self->signaturesSize));
+ self->signatureAttributes = reinterpret_cast<int *>(realloc(self->signatureAttributes, sizeof(int) * self->signaturesSize));
+ } else {
+ self->signatures = reinterpret_cast<char **>(malloc(sizeof(char *)));
+ self->signatureAttributes = reinterpret_cast<int *>(malloc(sizeof(int)));
+ }
+ self->signatures[self->signaturesSize - 1] = strdup(signature.m_parameterTypes);
+ self->signatureAttributes[self->signaturesSize - 1] = signature.m_attributes;
+}
+
+PySideSignalInstance* initialize(PySideSignal* self, PyObject* name, PyObject* object)
+{
+ PySideSignalInstance* instance = PyObject_New(PySideSignalInstance, &PySideSignalInstanceType);
+ SbkObject* sbkObj = reinterpret_cast<SbkObject*>(object);
+ if (!Shiboken::Object::wasCreatedByPython(sbkObj))
+ Py_INCREF(object); // PYSIDE-79: this flag was crucial for a wrapper call.
+ instanceInitialize(instance, name, self, object, 0);
+ return instance;
+}
+
+void instanceInitialize(PySideSignalInstance* self, PyObject* name, PySideSignal* data, PyObject* source, int index)
+{
+ self->d = new PySideSignalInstancePrivate;
+ PySideSignalInstancePrivate* selfPvt = self->d;
+ selfPvt->next = 0;
+ if (data->signalName)
+ selfPvt->signalName = strdup(data->signalName);
+ else {
+ selfPvt->signalName = strdup(Shiboken::String::toCString(name));
+ data->signalName = strdup(selfPvt->signalName);
+ }
+
+ selfPvt->source = source;
+ selfPvt->signature = buildSignature(self->d->signalName, data->signatures[index]);
+ selfPvt->attributes = data->signatureAttributes[index];
+ selfPvt->homonymousMethod = 0;
+ if (data->homonymousMethod) {
+ selfPvt->homonymousMethod = data->homonymousMethod;
+ Py_INCREF(selfPvt->homonymousMethod);
+ }
+ index++;
+
+ if (index < data->signaturesSize) {
+ selfPvt->next = PyObject_New(PySideSignalInstance, &PySideSignalInstanceType);
+ instanceInitialize(selfPvt->next, name, data, source, index);
+ }
+}
+
+bool connect(PyObject* source, const char* signal, PyObject* callback)
+{
+ Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source, "connect"));
+ if (pyMethod.isNull())
+ return false;
+
+ Shiboken::AutoDecRef pySignature(Shiboken::String::fromCString(signal));
+ Shiboken::AutoDecRef pyArgs(PyTuple_Pack(3, source, pySignature.object(), callback));
+ PyObject* result = PyObject_CallObject(pyMethod, pyArgs);
+ if (result == Py_False) {
+ PyErr_Format(PyExc_RuntimeError, "Failed to connect signal %s, to python callable object.", signal);
+ Py_DECREF(result);
+ result = 0;
+ }
+ return result;
+}
+
+PySideSignalInstance* newObjectFromMethod(PyObject* source, const QList<QMetaMethod>& methodList)
+{
+ PySideSignalInstance* root = 0;
+ PySideSignalInstance* previous = 0;
+ foreach (const QMetaMethod &m, methodList) {
+ PySideSignalInstance* item = PyObject_New(PySideSignalInstance, &PySideSignalInstanceType);
+ if (!root)
+ root = item;
+
+ if (previous)
+ previous->d->next = item;
+
+ item->d = new PySideSignalInstancePrivate;
+ PySideSignalInstancePrivate* selfPvt = item->d;
+ selfPvt->source = source;
+ Py_INCREF(selfPvt->source); // PYSIDE-79: an INCREF is missing.
+ QByteArray cppName(m.methodSignature());
+ cppName.truncate(cppName.indexOf('('));
+ // separe SignalName
+ selfPvt->signalName = strdup(cppName.data());
+ selfPvt->signature = strdup(m.methodSignature());
+ selfPvt->attributes = m.attributes();
+ selfPvt->homonymousMethod = 0;
+ selfPvt->next = 0;
+ }
+ return root;
+}
+
+PySideSignal* newObject(const char* name, ...)
+{
+ va_list listSignatures;
+ char* sig = 0;
+ PySideSignal* self = PyObject_New(PySideSignal, &PySideSignalType);
+ self->signalName = strdup(name);
+ self->signaturesSize = 0;
+ self->signatures = 0;
+ self->signatureAttributes = 0;
+ self->initialized = 0;
+ self->homonymousMethod = 0;
+
+ va_start(listSignatures, name);
+ sig = va_arg(listSignatures, char*);
+
+ while (sig != NULL) {
+ if (strcmp(sig, "void") == 0)
+ appendSignature(self, SignalSignature(""));
+ else
+ appendSignature(self, SignalSignature(sig));
+
+ sig = va_arg(listSignatures, char*);
+ }
+
+ va_end(listSignatures);
+
+ return self;
+}
+
+template<typename T>
+static typename T::value_type join(T t, const char* sep)
+{
+ typename T::value_type res;
+ if (!t.size())
+ return res;
+
+ typename T::const_iterator it = t.begin();
+ typename T::const_iterator end = t.end();
+ res += *it;
+ ++it;
+
+ while (it != end) {
+ res += sep;
+ res += *it;
+ ++it;
+ }
+ return res;
+}
+
+static void _addSignalToWrapper(SbkObjectType* wrapperType, const char* signalName, PySideSignal* signal)
+{
+ PyObject* typeDict = wrapperType->super.ht_type.tp_dict;
+ PyObject* homonymousMethod;
+ if ((homonymousMethod = PyDict_GetItemString(typeDict, signalName))) {
+ Py_INCREF(homonymousMethod);
+ signal->homonymousMethod = homonymousMethod;
+ }
+ PyDict_SetItemString(typeDict, signalName, reinterpret_cast<PyObject*>(signal));
+}
+
+// This function is used by qStableSort to promote empty signatures
+static bool compareSignals(const SignalSignature &sig1, const SignalSignature &)
+{
+ return sig1.m_parameterTypes.isEmpty();
+}
+
+void registerSignals(SbkObjectType* pyObj, const QMetaObject* metaObject)
+{
+ typedef QHash<QByteArray, QList<SignalSignature> > SignalSigMap;
+ SignalSigMap signalsFound;
+ for (int i = metaObject->methodOffset(), max = metaObject->methodCount(); i < max; ++i) {
+ QMetaMethod method = metaObject->method(i);
+
+ if (method.methodType() == QMetaMethod::Signal) {
+ QByteArray methodName(method.methodSignature());
+ methodName.chop(methodName.size() - methodName.indexOf('('));
+ SignalSignature signature;
+ signature.m_parameterTypes = join(method.parameterTypes(), ",");
+ if (method.attributes() & QMetaMethod::Cloned)
+ signature.m_attributes = QMetaMethod::Cloned;
+ signalsFound[methodName] << signature;
+ }
+ }
+
+ SignalSigMap::Iterator it = signalsFound.begin();
+ SignalSigMap::Iterator end = signalsFound.end();
+ for (; it != end; ++it) {
+ PySideSignal* self = PyObject_New(PySideSignal, &PySideSignalType);
+ self->signalName = strdup(it.key().constData());
+ self->signaturesSize = 0;
+ self->signatures = 0;
+ self->signatureAttributes = 0;
+ self->initialized = 0;
+ self->homonymousMethod = 0;
+
+ // Empty signatures comes first! So they will be the default signal signature
+ qStableSort(it.value().begin(), it.value().end(), &compareSignals);
+ SignalSigMap::mapped_type::const_iterator j = it.value().begin();
+ SignalSigMap::mapped_type::const_iterator endJ = it.value().end();
+ for (; j != endJ; ++j) {
+ const SignalSignature &sig = *j;
+ appendSignature(self, sig);
+ }
+
+ _addSignalToWrapper(pyObj, it.key(), self);
+ Py_DECREF(reinterpret_cast<PyObject *>(self));
+ }
+}
+
+PyObject* buildQtCompatible(const char* signature)
+{
+ QByteArray ba;
+ ba.append(QT_SIGNAL_SENTINEL);
+ ba.append(signature);
+ return Shiboken::String::fromStringAndSize(ba, ba.size());
+}
+
+void addSignalToWrapper(SbkObjectType* wrapperType, const char* signalName, PySideSignal* signal)
+{
+ _addSignalToWrapper(wrapperType, signalName, signal);
+}
+
+PyObject* getObject(PySideSignalInstance* signal)
+{
+ return signal->d->source;
+}
+
+const char* getSignature(PySideSignalInstance* signal)
+{
+ return signal->d->signature;
+}
+
+const char** getSignatures(PyObject* signal, int* size)
+{
+ PySideSignal* self = reinterpret_cast<PySideSignal*>(signal);
+ *size = self->signaturesSize;
+ return const_cast<const char**>(self->signatures);
+}
+
+QStringList getArgsFromSignature(const char* signature, bool* isShortCircuit)
+{
+ const QString qsignature = QLatin1String(signature);
+ QStringList result;
+ QRegExp splitRegex(QLatin1String("\\s*,\\s*"));
+
+ if (isShortCircuit)
+ *isShortCircuit = !qsignature.contains(QLatin1Char('('));
+ if (qsignature.contains(QLatin1String("()")) || qsignature.contains(QLatin1String("(void)"))) {
+ return result;
+ } else if (qsignature.contains(QLatin1Char('('))) {
+ static QRegExp regex(QLatin1String(".+\\((.*)\\)"));
+ //get args types
+ QString types = qsignature;
+ types.replace(regex, QLatin1String("\\1"));
+ result = types.split(splitRegex);
+ }
+ return result;
+}
+
+QString getCallbackSignature(const char* signal, QObject* receiver, PyObject* callback, bool encodeName)
+{
+ QByteArray functionName;
+ int numArgs = -1;
+ bool useSelf = false;
+ bool isMethod = PyMethod_Check(callback);
+ bool isFunction = PyFunction_Check(callback);
+
+ if (isMethod || isFunction) {
+ PyObject* function = isMethod ? PyMethod_GET_FUNCTION(callback) : callback;
+ PyCodeObject* objCode = reinterpret_cast<PyCodeObject*>(PyFunction_GET_CODE(function));
+ functionName = Shiboken::String::toCString(reinterpret_cast<PyFunctionObject*>(function)->func_name);
+ useSelf = isMethod;
+ numArgs = objCode->co_flags & CO_VARARGS ? -1 : objCode->co_argcount;
+ } else if (PyCFunction_Check(callback)) {
+ const PyCFunctionObject *funcObj = reinterpret_cast<const PyCFunctionObject *>(callback);
+ functionName = funcObj->m_ml->ml_name;
+ useSelf = funcObj->m_self;
+ const int flags = funcObj->m_ml->ml_flags;
+
+ if (receiver) {
+ //Search for signature on metaobject
+ const QMetaObject* mo = receiver->metaObject();
+ QByteArray prefix(functionName);
+ prefix += '(';
+ for (int i = 0; i < mo->methodCount(); i++) {
+ QMetaMethod me = mo->method(i);
+ if ((strncmp(me.methodSignature(), prefix, prefix.size()) == 0) &&
+ QMetaObject::checkConnectArgs(signal, me.methodSignature())) {
+ numArgs = me.parameterTypes().size() + useSelf;
+ break;
+ }
+ }
+ }
+
+ if (numArgs == -1) {
+ if (flags & METH_VARARGS)
+ numArgs = -1;
+ else if (flags & METH_NOARGS)
+ numArgs = 0;
+ }
+ } else if (PyCallable_Check(callback)) {
+ functionName = "__callback" + QByteArray::number((qlonglong)callback);
+ }
+
+ Q_ASSERT(!functionName.isEmpty());
+
+ bool isShortCircuit = false;
+
+ const QString functionNameS = QLatin1String(functionName);
+ QString signature = encodeName ? codeCallbackName(callback, functionNameS) : functionNameS;
+ QStringList args = getArgsFromSignature(signal, &isShortCircuit);
+
+ if (!isShortCircuit) {
+ signature.append(QLatin1Char('('));
+ if (numArgs == -1)
+ numArgs = std::numeric_limits<int>::max();
+ while (args.count() && (args.count() > (numArgs - useSelf))) {
+ args.removeLast();
+ }
+ signature.append(args.join(QLatin1Char(',')));
+ signature.append(QLatin1Char(')'));
+ }
+ return signature;
+}
+
+bool isQtSignal(const char* signal)
+{
+ return (signal && signal[0] == QT_SIGNAL_SENTINEL);
+}
+
+bool checkQtSignal(const char* signal)
+{
+ if (!isQtSignal(signal)) {
+ PyErr_SetString(PyExc_TypeError, "Use the function PySide2.QtCore.SIGNAL on signals");
+ return false;
+ }
+ return true;
+}
+
+QString codeCallbackName(PyObject* callback, const QString& funcName)
+{
+ if (PyMethod_Check(callback)) {
+ PyObject* self = PyMethod_GET_SELF(callback);
+ PyObject* func = PyMethod_GET_FUNCTION(callback);
+ return funcName + QString::number(quint64(self), 16) + QString::number(quint64(func), 16);
+ } else {
+ return funcName + QString::number(quint64(callback), 16);
+ }
+}
+
+} //namespace Signal
+} //namespace PySide
+
diff --git a/sources/pyside2/libpyside/pysidesignal.h b/sources/pyside2/libpyside/pysidesignal.h
new file mode 100644
index 000000000..ead62198c
--- /dev/null
+++ b/sources/pyside2/libpyside/pysidesignal.h
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_SIGNAL_H
+#define PYSIDE_SIGNAL_H
+
+#include <QObject>
+#include <QString>
+#include <QStringList>
+
+#include <pysidemacros.h>
+#include <sbkpython.h>
+#include <basewrapper.h>
+
+extern "C"
+{
+ extern PYSIDE_API PyTypeObject PySideSignalType;
+ extern PYSIDE_API PyTypeObject PySideSignalInstanceType;
+
+ // Internal object
+ struct PYSIDE_API PySideSignal;
+
+ struct PySideSignalInstancePrivate;
+ struct PYSIDE_API PySideSignalInstance
+ {
+ PyObject_HEAD
+ PySideSignalInstancePrivate* d;
+ };
+}; // extern "C"
+
+namespace PySide {
+namespace Signal {
+
+PYSIDE_API bool checkType(PyObject* type);
+
+/**
+ * This function creates a Signal object which stays attached to QObject class
+ *
+ * @param name of the Signal to be registered on meta object
+ * @param signatures a list of signatures supported by this signal, ended with a NULL pointer
+ * @return Return a new reference to PyObject* of type PySideSignal
+ * @deprecated Use registerSignals
+ **/
+PYSIDE_DEPRECATED(PYSIDE_API PySideSignal* newObject(const char* name, ...));
+
+/**
+ * Register all C++ signals of a QObject on Python type.
+ */
+PYSIDE_API void registerSignals(SbkObjectType* pyObj, const QMetaObject* metaObject);
+
+/**
+ * This function creates a Signal object which stays attached to QObject class based on a list of QMetaMethods
+ *
+ * @param source of the Signal to be registered on meta object
+ * @param methods a list of QMetaMethod wich contains the supported signature
+ * @return Return a new reference to PyObject* of type PySideSignal
+ **/
+PYSIDE_API PySideSignalInstance* newObjectFromMethod(PyObject* source, const QList<QMetaMethod>& methods);
+
+/**
+ * This function initializes the Signal object by creating a PySideSignalInstance
+ *
+ * @param self a Signal object used as base to PySideSignalInstance
+ * @param name the name to be used on PySideSignalInstance
+ * @param object the PyObject where the signal will be attached
+ * @return Return a new reference to PySideSignalInstance
+ **/
+PYSIDE_API PySideSignalInstance* initialize(PySideSignal* signal, PyObject* name, PyObject* object);
+
+/**
+ * This function is used to retrieve the object in which the signal is attached
+ *
+ * @param self The Signal object
+ * @return Return the internal reference to the parent object of the signal
+ **/
+PYSIDE_API PyObject* getObject(PySideSignalInstance* signal);
+
+/**
+ * This function is used to retrieve the signal signature
+ *
+ * @param self The Signal object
+ * @return Return the signal signature
+ **/
+PYSIDE_API const char* getSignature(PySideSignalInstance* signal);
+
+/**
+ * This function is used to retrieve the signal signature
+ *
+ * @param self The Signal object
+ * @return Return the signal signature
+ **/
+PYSIDE_API void updateSourceObject(PyObject* source);
+
+/**
+ * @deprecated Use registerSignals
+ **/
+PYSIDE_DEPRECATED(PYSIDE_API void addSignalToWrapper(SbkObjectType* wrapperType, const char* signalName, PySideSignal* signal));
+
+/**
+ * This function verifies if the signature is a QtSignal base on SIGNAL flag
+ * @param signature The signal signature
+ * @return Return true if this is a Qt Signal, otherwise return false
+ **/
+PYSIDE_API bool isQtSignal(const char* signature);
+
+/**
+ * This function is similar to isQtSignal, however if it fails, it'll raise a Python error instead.
+ *
+ * @param signature The signal signature
+ * @return Return true if this is a Qt Signal, otherwise return false
+ **/
+PYSIDE_API bool checkQtSignal(const char* signature);
+
+/**
+ * This function is used to retrieve the signature base on Signal and receiver callback
+ * @param signature The signal signature
+ * @param receiver The QObject which will receive the signal
+ * @param callback Callback function which will connect to the signal
+ * @param encodeName Used to specify if the returned signature will be encoded with Qt signal/slot style
+ * @return Return the callback signature
+ **/
+PYSIDE_API QString getCallbackSignature(const char* signal, QObject* receiver, PyObject* callback, bool encodeName);
+
+/**
+ * This function parses the signature and then returns a list of argument types.
+ *
+ * @param signature The signal signature
+ * @param isShortCircuit If this is a shortCircuit(python<->python) signal
+ * @return Return true if this is a Qt Signal, otherwise return false
+ * @todo replace return type by QList<QByteArray>
+ **/
+QStringList getArgsFromSignature(const char* signature, bool* isShortCircuit = 0);
+
+} // namespace Signal
+} // namespace PySide
+
+#endif
diff --git a/sources/pyside2/libpyside/pysidesignal_p.h b/sources/pyside2/libpyside/pysidesignal_p.h
new file mode 100644
index 000000000..b692b96ad
--- /dev/null
+++ b/sources/pyside2/libpyside/pysidesignal_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_QSIGNAL_P_H
+#define PYSIDE_QSIGNAL_P_H
+
+#include <sbkpython.h>
+
+extern "C"
+{
+ extern PyTypeObject PySideSignalType;
+
+ struct PySideSignal {
+ PyObject_HEAD
+ bool initialized;
+ char* signalName;
+ char** signatures;
+ int* signatureAttributes;
+ int signaturesSize;
+ PyObject* homonymousMethod;
+ };
+
+ struct PySideSignalInstance;
+ struct PySideSignalInstancePrivate {
+ char* signalName;
+ char* signature;
+ int attributes;
+ PyObject* source;
+ PyObject* homonymousMethod;
+ PySideSignalInstance* next;
+ };
+
+
+}; //extern "C"
+
+namespace PySide { namespace Signal {
+
+ void init(PyObject* module);
+ bool connect(PyObject* source, const char* signal, PyObject* callback);
+ char* getTypeName(PyObject*);
+ const char** getSignatures(PyObject* self, int *size);
+ QString codeCallbackName(PyObject* callback, const QString& funcName);
+
+}} //namespace PySide
+
+#endif
diff --git a/sources/pyside2/libpyside/pysideslot.cpp b/sources/pyside2/libpyside/pysideslot.cpp
new file mode 100644
index 000000000..c562e41e2
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideslot.cpp
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "dynamicqmetaobject_p.h"
+#include "pysidesignal_p.h"
+#include "pysideslot_p.h"
+
+#include <shiboken.h>
+#include <QString>
+#include <QMetaObject>
+
+#define SLOT_DEC_NAME "Slot"
+
+typedef struct
+{
+ PyObject_HEAD
+ char* slotName;
+ char* args;
+ char* resultType;
+} PySideSlot;
+
+extern "C"
+{
+
+static int slotTpInit(PyObject*, PyObject*, PyObject*);
+static PyObject* slotCall(PyObject*, PyObject*, PyObject*);
+
+// Class Definition -----------------------------------------------
+static PyTypeObject PySideSlotType = {
+ PyVarObject_HEAD_INIT(0, 0)
+ "PySide2.QtCore." SLOT_DEC_NAME, /*tp_name*/
+ sizeof(PySideSlot), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ slotCall, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ SLOT_DEC_NAME, /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ 0, /*tp_iter */
+ 0, /*tp_iternext */
+ 0, /*tp_methods */
+ 0, /*tp_members */
+ 0, /*tp_getset */
+ 0, /*tp_base */
+ 0, /*tp_dict */
+ 0, /*tp_descr_get */
+ 0, /*tp_descr_set */
+ 0, /*tp_dictoffset */
+ slotTpInit, /*tp_init */
+ 0, /*tp_alloc */
+ PyType_GenericNew, /*tp_new */
+ 0, /*tp_free */
+ 0, /*tp_is_gc */
+ 0, /*tp_bases */
+ 0, /*tp_mro */
+ 0, /*tp_cache */
+ 0, /*tp_subclasses */
+ 0, /*tp_weaklist */
+ 0, /*tp_del */
+ 0 /*tp_version_tag*/
+};
+
+int slotTpInit(PyObject *self, PyObject *args, PyObject *kw)
+{
+ static PyObject *emptyTuple = 0;
+ static const char *kwlist[] = {"name", "result", 0};
+ char* argName = 0;
+ PyObject* argResult = 0;
+
+ if (emptyTuple == 0)
+ emptyTuple = PyTuple_New(0);
+
+ if (!PyArg_ParseTupleAndKeywords(emptyTuple, kw, "|sO:QtCore." SLOT_DEC_NAME, (char**) kwlist, &argName, &argResult))
+ return 0;
+
+ PySideSlot *data = reinterpret_cast<PySideSlot*>(self);
+ for(Py_ssize_t i = 0, i_max = PyTuple_Size(args); i < i_max; i++) {
+ PyObject *argType = PyTuple_GET_ITEM(args, i);
+ char *typeName = PySide::Signal::getTypeName(argType);
+ if (typeName) {
+ if (data->args) {
+ data->args = reinterpret_cast<char*>(realloc(data->args, (strlen(data->args) + 1 + strlen(typeName)) * sizeof(char*)));
+ data->args = strcat(data->args, ",");
+ data->args = strcat(data->args, typeName);
+ free(typeName);
+ } else {
+ data->args = typeName;
+ }
+ } else {
+ PyErr_Format(PyExc_TypeError, "Unknown signal argument type: %s", argType->ob_type->tp_name);
+ return -1;
+ }
+ }
+
+ if (argName)
+ data->slotName = strdup(argName);
+
+ if (argResult)
+ data->resultType = PySide::Signal::getTypeName(argResult);
+ else
+ data->resultType = strdup("void");
+
+ return 1;
+}
+
+PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */)
+{
+ static PyObject* pySlotName = 0;
+ PyObject* callback;
+ callback = PyTuple_GetItem(args, 0);
+ Py_INCREF(callback);
+
+ if (PyFunction_Check(callback)) {
+ PySideSlot *data = reinterpret_cast<PySideSlot*>(self);
+
+ if (!data->slotName) {
+ PyObject *funcName = reinterpret_cast<PyFunctionObject*>(callback)->func_name;
+ data->slotName = strdup(Shiboken::String::toCString(funcName));
+ }
+
+
+ QByteArray returnType = QMetaObject::normalizedType(data->resultType);
+ QByteArray signature = QString().sprintf("%s(%s)", data->slotName, data->args).toUtf8();
+ signature = returnType + " " + signature;
+
+ if (!pySlotName)
+ pySlotName = Shiboken::String::fromCString(PYSIDE_SLOT_LIST_ATTR);
+
+ PyObject *pySignature = Shiboken::String::fromCString(signature);
+ PyObject *signatureList = 0;
+ if (PyObject_HasAttr(callback, pySlotName)) {
+ signatureList = PyObject_GetAttr(callback, pySlotName);
+ } else {
+ signatureList = PyList_New(0);
+ PyObject_SetAttr(callback, pySlotName, signatureList);
+ Py_DECREF(signatureList);
+ }
+
+ PyList_Append(signatureList, pySignature);
+ Py_DECREF(pySignature);
+
+ //clear data
+ free(data->slotName);
+ data->slotName = 0;
+ free(data->resultType);
+ data->resultType = 0;
+ free(data->args);
+ data->args = 0;
+ return callback;
+ }
+ return callback;
+}
+
+} // extern "C"
+
+namespace PySide { namespace Slot {
+
+void init(PyObject* module)
+{
+ if (PyType_Ready(&PySideSlotType) < 0)
+ return;
+
+ Py_INCREF(&PySideSlotType);
+ PyModule_AddObject(module, SLOT_DEC_NAME, reinterpret_cast<PyObject *>(&PySideSlotType));
+}
+
+} // namespace Slot
+} // namespace PySide
diff --git a/sources/pyside2/libpyside/pysideslot_p.h b/sources/pyside2/libpyside/pysideslot_p.h
new file mode 100644
index 000000000..33e881c18
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideslot_p.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYSIDE_SLOT_P_H
+#define PYSIDE_SLOT_P_H
+
+#include <sbkpython.h>
+#define PYSIDE_SLOT_LIST_ATTR "_slots"
+
+namespace PySide { namespace Slot {
+ void init(PyObject* module);
+}}
+
+#endif
diff --git a/sources/pyside2/libpyside/pysideweakref.cpp b/sources/pyside2/libpyside/pysideweakref.cpp
new file mode 100644
index 000000000..dfbf9e90c
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideweakref.cpp
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "pysideweakref.h"
+
+#include <sbkpython.h>
+
+typedef struct {
+ PyObject_HEAD
+ /* Type-specific fields go here. */
+ PySideWeakRefFunction weakref_func;
+ void* user_data;
+} PySideCallableObject;
+
+static PyObject* CallableObject_call(PyObject* callable_object, PyObject* args, PyObject* kw);
+
+static PyTypeObject PySideCallableObjectType = {
+ PyVarObject_HEAD_INIT(0, 0)
+ const_cast<char*>("PySide.Callable"),
+ sizeof(PySideCallableObject), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ CallableObject_call, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+ 0, /* tp_del */
+ 0 /* tp_version_tag */
+};
+
+static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args, PyObject * /* kw */)
+{
+ PySideCallableObject* obj = reinterpret_cast<PySideCallableObject *>(callable_object);
+ obj->weakref_func(obj->user_data);
+
+ Py_XDECREF(PyTuple_GET_ITEM(args, 0)); //kill weak ref object
+ Py_RETURN_NONE;
+}
+
+namespace PySide { namespace WeakRef {
+
+PyObject* create(PyObject* obj, PySideWeakRefFunction func, void* userData)
+{
+ if (obj == Py_None)
+ return 0;
+
+ if (Py_TYPE(&PySideCallableObjectType) == 0)
+ {
+ Py_TYPE(&PySideCallableObjectType) = &PyType_Type;
+ PyType_Ready(&PySideCallableObjectType);
+ }
+
+ PySideCallableObject* callable = PyObject_New(PySideCallableObject, &PySideCallableObjectType);
+ if (!callable || PyErr_Occurred())
+ return 0;
+
+ PyObject* weak = PyWeakref_NewRef(obj, reinterpret_cast<PyObject *>(callable));
+ if (!weak || PyErr_Occurred())
+ return 0;
+
+ callable->weakref_func = func;
+ callable->user_data = userData;
+ Py_DECREF(callable); // PYSIDE-79: after decref the callable is undefined (theoretically)
+
+ return reinterpret_cast<PyObject *>(weak);
+}
+
+} } //namespace
+
diff --git a/sources/pyside2/libpyside/pysideweakref.h b/sources/pyside2/libpyside/pysideweakref.h
new file mode 100644
index 000000000..7a7082345
--- /dev/null
+++ b/sources/pyside2/libpyside/pysideweakref.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 __PYSIDEWEAKREF__
+#define __PYSIDEWEAKREF__
+
+#include <pysidemacros.h>
+#include <sbkpython.h>
+
+typedef void (*PySideWeakRefFunction)(void* userData);
+
+namespace PySide { namespace WeakRef {
+
+PYSIDE_API PyObject* create(PyObject* ob, PySideWeakRefFunction func, void* userData);
+
+} //PySide
+} //WeakRef
+
+
+#endif
diff --git a/sources/pyside2/libpyside/signalmanager.cpp.in b/sources/pyside2/libpyside/signalmanager.cpp.in
new file mode 100644
index 000000000..473057cbc
--- /dev/null
+++ b/sources/pyside2/libpyside/signalmanager.cpp.in
@@ -0,0 +1,726 @@
+// -*- mode: cpp;-*-
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "signalmanager.h"
+#include "pysidesignal.h"
+#include "pysideproperty.h"
+#include "pysideproperty_p.h"
+#include "pyside.h"
+#include "dynamicqmetaobject.h"
+#include "pysidemetafunction_p.h"
+
+#include <QtCore>
+#include <QHash>
+#include <QStringList>
+#include <QMetaMethod>
+#include <autodecref.h>
+#include <gilstate.h>
+#include <QDebug>
+#include <limits>
+#include <algorithm>
+#include <typeresolver.h>
+#include <basewrapper.h>
+#include <sbkconverter.h>
+#include <conversions.h>
+
+// These private headers are needed to throw JavaScript exceptions
+#if @QML_PRIVATE_API_SUPPORT@
+ #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
+#error QSLOT_CODE and/or QSIGNAL_CODE changed! change the hardcoded stuff to the correct value!
+#endif
+#define PYSIDE_SLOT '1'
+#define PYSIDE_SIGNAL '2'
+#include "globalreceiverv2.h"
+#include "globalreceiver.h"
+
+#define PYTHON_TYPE "PyObject"
+
+namespace {
+ static PyObject *metaObjectAttr = 0;
+
+ static int callMethod(QObject* object, int id, void** args);
+ 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);
+ PySide::DynamicQMetaObject* meta = reinterpret_cast<PySide::DynamicQMetaObject*>(ptr);
+ SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(meta);
+ if (wrapper)
+ Shiboken::BindingManager::instance().releaseWrapper(wrapper);
+ delete meta;
+ }
+
+#else
+ static void destroyMetaObject(void* obj)
+ {
+ PySide::DynamicQMetaObject* meta = reinterpret_cast<PySide::DynamicQMetaObject*>(obj);
+ SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(meta);
+ if (wrapper)
+ Shiboken::BindingManager::instance().releaseWrapper(wrapper);
+ delete meta;
+ }
+#endif
+}
+
+namespace PySide {
+
+
+PyObjectWrapper::PyObjectWrapper()
+ :m_me(Py_None)
+{
+ Py_INCREF(m_me);
+}
+
+PyObjectWrapper::PyObjectWrapper(PyObject* me)
+ : m_me(me)
+{
+ Py_INCREF(m_me);
+}
+
+PyObjectWrapper::PyObjectWrapper(const PyObjectWrapper &other)
+ : m_me(other.m_me)
+{
+ Py_INCREF(m_me);
+}
+
+PyObjectWrapper::~PyObjectWrapper()
+{
+ // Check that Python is still initialized as sometimes this is called by a static destructor
+ // after Python interpeter is shutdown.
+ if (!Py_IsInitialized())
+ return;
+
+ Shiboken::GilState gil;
+ Py_DECREF(m_me);
+}
+
+PyObjectWrapper& PyObjectWrapper::operator=(const PySide::PyObjectWrapper& other)
+{
+ Py_INCREF(other.m_me);
+ Py_DECREF(m_me);
+ m_me = other.m_me;
+ return *this;
+}
+
+PyObjectWrapper::operator PyObject*() const
+{
+ return m_me;
+}
+
+QDataStream &operator<<(QDataStream& out, const PyObjectWrapper& myObj)
+{
+ if (Py_IsInitialized() == 0) {
+ qWarning() << "Stream operator for PyObject called without python interpreter.";
+ return out;
+ }
+
+ static PyObject *reduce_func = 0;
+
+ Shiboken::GilState gil;
+ if (!reduce_func) {
+ Shiboken::AutoDecRef pickleModule(PyImport_ImportModule("pickle"));
+ reduce_func = PyObject_GetAttrString(pickleModule, "dumps");
+ }
+ Shiboken::AutoDecRef repr(PyObject_CallFunctionObjArgs(reduce_func, (PyObject*)myObj, NULL));
+ if (repr.object()) {
+ const char* buff = 0;
+ Py_ssize_t size = 0;
+ if (PyBytes_Check(repr.object())) {
+ buff = PyBytes_AS_STRING(repr.object());
+ size = PyBytes_GET_SIZE(repr.object());
+ } else if (Shiboken::String::check(repr.object())) {
+ buff = Shiboken::String::toCString(repr.object());
+ size = Shiboken::String::len(repr.object());
+ }
+ QByteArray data(buff, size);
+ out << data;
+ }
+ return out;
+}
+
+QDataStream &operator>>(QDataStream& in, PyObjectWrapper& myObj)
+{
+ if (Py_IsInitialized() == 0) {
+ qWarning() << "Stream operator for PyObject called without python interpreter.";
+ return in;
+ }
+
+ static PyObject *eval_func = 0;
+
+ Shiboken::GilState gil;
+ if (!eval_func) {
+ Shiboken::AutoDecRef pickleModule(PyImport_ImportModule("pickle"));
+ eval_func = PyObject_GetAttrString(pickleModule, "loads");
+ }
+
+ QByteArray repr;
+ in >> repr;
+ Shiboken::AutoDecRef pyCode(PyBytes_FromStringAndSize(repr.data(), repr.size()));
+ Shiboken::AutoDecRef value(PyObject_CallFunctionObjArgs(eval_func, pyCode.object(), 0));
+ if (!value.object()) {
+ value = Py_None;
+ }
+ myObj = PyObjectWrapper(value);
+ return in;
+}
+
+};
+
+namespace Shiboken {
+
+template<>
+struct Converter<PySide::PyObjectWrapper>
+{
+ static PySide::PyObjectWrapper toCpp(PyObject* obj)
+ {
+ return PySide::PyObjectWrapper(obj);
+ }
+
+ static PyObject* toPython(void* obj)
+ {
+ return toPython(*reinterpret_cast<PySide::PyObjectWrapper*>(obj));
+ }
+
+ static PyObject* toPython(const PySide::PyObjectWrapper& obj)
+ {
+ Py_INCREF((PyObject*)obj);
+ return obj;
+ }
+};
+
+};
+
+using namespace PySide;
+
+struct SignalManager::SignalManagerPrivate
+{
+ SharedMap m_globalReceivers;
+
+ //Deprecated
+ GlobalReceiver m_globalReceiver;
+
+ SignalManagerPrivate()
+ {
+ m_globalReceivers = SharedMap( new QMap<QByteArray, GlobalReceiverV2*>() );
+ }
+
+ ~SignalManagerPrivate()
+ {
+ if (!m_globalReceivers.isNull()) {
+ // Delete receivers by always retrieving the current first element, because deleting a
+ // receiver can indirectly delete another one, and if we use qDeleteAll, that could
+ // cause either a double delete, or iterator invalidation, and thus undefined behavior.
+ while (!m_globalReceivers->isEmpty())
+ delete *m_globalReceivers->cbegin();
+ Q_ASSERT(m_globalReceivers->isEmpty());
+ }
+ }
+};
+
+static void clearSignalManager()
+{
+ PySide::SignalManager::instance().clear();
+}
+
+static void PyObject_PythonToCpp_PyObject_PTR(PyObject* pyIn, void* cppOut)
+{
+ *((PyObject**)cppOut) = pyIn;
+}
+static PythonToCppFunc is_PyObject_PythonToCpp_PyObject_PTR_Convertible(PyObject* pyIn)
+{
+ return PyObject_PythonToCpp_PyObject_PTR;
+}
+static PyObject* PyObject_PTR_CppToPython_PyObject(const void* cppIn)
+{
+ PyObject* pyOut = (PyObject*)cppIn;
+ if (pyOut)
+ Py_INCREF(pyOut);
+ return pyOut;
+}
+
+SignalManager::SignalManager() : m_d(new SignalManagerPrivate)
+{
+ // Register Qt primitive typedefs used on signals.
+ using namespace Shiboken;
+
+ // Register PyObject type to use in queued signal and slot connections
+ qRegisterMetaType<PyObjectWrapper>(PYTHON_TYPE);
+ qRegisterMetaTypeStreamOperators<PyObjectWrapper>(PYTHON_TYPE);
+ qRegisterMetaTypeStreamOperators<PyObjectWrapper>("PyObjectWrapper");
+ qRegisterMetaTypeStreamOperators<PyObjectWrapper>("PySide::PyObjectWrapper");
+
+ SbkConverter* converter = Shiboken::Conversions::createConverter(&PyBaseObject_Type, 0);
+ Shiboken::Conversions::setCppPointerToPythonFunction(converter, PyObject_PTR_CppToPython_PyObject);
+ Shiboken::Conversions::setPythonToCppPointerFunctions(converter, PyObject_PythonToCpp_PyObject_PTR, is_PyObject_PythonToCpp_PyObject_PTR_Convertible);
+ Shiboken::Conversions::registerConverterName(converter, PYTHON_TYPE);
+ Shiboken::Conversions::registerConverterName(converter, "object");
+ Shiboken::Conversions::registerConverterName(converter, "PyObjectWrapper");
+ Shiboken::Conversions::registerConverterName(converter, "PySide::PyObjectWrapper");
+
+ PySide::registerCleanupFunction(clearSignalManager);
+
+ if (!metaObjectAttr)
+ metaObjectAttr = Shiboken::String::fromCString("__METAOBJECT__");
+}
+
+void SignalManager::clear()
+{
+ delete m_d;
+ m_d = new SignalManagerPrivate();
+}
+
+SignalManager::~SignalManager()
+{
+ delete m_d;
+}
+
+SignalManager& SignalManager::instance()
+{
+ static SignalManager me;
+ return me;
+}
+
+QObject* SignalManager::globalReceiver()
+{
+ return &m_d->m_globalReceiver;
+}
+
+void SignalManager::globalReceiverConnectNotify(QObject* source, int slotIndex)
+{
+ m_d->m_globalReceiver.connectNotify(source, slotIndex);
+}
+
+void SignalManager::globalReceiverDisconnectNotify(QObject* source, int slotIndex)
+{
+ m_d->m_globalReceiver.disconnectNotify(source, slotIndex);
+}
+
+void SignalManager::addGlobalSlot(const char* slot, PyObject* callback)
+{
+ addGlobalSlotGetIndex(slot, callback);
+}
+
+int SignalManager::addGlobalSlotGetIndex(const char* slot, PyObject* callback)
+{
+ return m_d->m_globalReceiver.addSlot(slot, callback);
+}
+
+QObject* SignalManager::globalReceiver(QObject *sender, PyObject *callback)
+{
+ SharedMap globalReceivers = m_d->m_globalReceivers;
+ QByteArray hash = GlobalReceiverV2::hash(callback);
+ GlobalReceiverV2* gr = 0;
+ if (!globalReceivers->contains(hash)) {
+ gr = (*globalReceivers)[hash] = new GlobalReceiverV2(callback, globalReceivers);
+ if (sender) {
+ gr->incRef(sender); // create a link reference
+ gr->decRef(); // remove extra reference
+ }
+ } else {
+ gr = (*globalReceivers)[hash];
+ if (sender)
+ gr->incRef(sender);
+ }
+
+ return reinterpret_cast<QObject*>(gr);
+}
+
+int SignalManager::countConnectionsWith(const QObject *object)
+{
+ int count = 0;
+ for (GlobalReceiverV2Map::const_iterator it = m_d->m_globalReceivers->cbegin(), end = m_d->m_globalReceivers->cend(); it != end; ++it) {
+ if (it.value()->refCount(object))
+ count++;
+ }
+ return count;
+}
+
+void SignalManager::notifyGlobalReceiver(QObject* receiver)
+{
+ reinterpret_cast<GlobalReceiverV2*>(receiver)->notify();
+}
+
+void SignalManager::releaseGlobalReceiver(const QObject* source, QObject* receiver)
+{
+ GlobalReceiverV2* gr = reinterpret_cast<GlobalReceiverV2*>(receiver);
+ gr->decRef(source);
+}
+
+int SignalManager::globalReceiverSlotIndex(QObject* receiver, const char* signature) const
+{
+ return reinterpret_cast<GlobalReceiverV2*>(receiver)->addSlot(signature);
+}
+
+bool SignalManager::emitSignal(QObject* source, const char* signal, PyObject* args)
+{
+ if (!Signal::checkQtSignal(signal))
+ return false;
+ signal++;
+
+ int signalIndex = source->metaObject()->indexOfSignal(signal);
+ if (signalIndex != -1) {
+ // cryptic but works!
+ // if the signature doesn't have a '(' it's a shor circuited signal, i.e. std::find
+ // returned the string null terminator.
+ bool isShortCircuit = !*std::find(signal, signal + std::strlen(signal), '(');
+ if (isShortCircuit)
+ return emitShortCircuitSignal(source, signalIndex, args);
+ else
+ return MetaFunction::call(source, signalIndex, args);
+ }
+ return false;
+}
+
+int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id, void** args)
+{
+ const QMetaObject* metaObject = object->metaObject();
+ PySideProperty* pp = 0;
+ PyObject* pp_name = 0;
+ QMetaProperty mp;
+ PyObject* pySelf = 0;
+ int methodCount = metaObject->methodCount();
+ int propertyCount = metaObject->propertyCount();
+
+ if (call != QMetaObject::InvokeMetaMethod) {
+ mp = metaObject->property(id);
+ if (!mp.isValid()) {
+ return id - methodCount;
+ }
+
+ Shiboken::GilState gil;
+ pySelf = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(object);
+ Q_ASSERT(pySelf);
+ pp_name = Shiboken::String::fromCString(mp.name());
+ pp = Property::getObject(pySelf, pp_name);
+ if (!pp) {
+ qWarning("Invalid property: %s.", mp.name());
+ Py_XDECREF(pp_name);
+ return id - methodCount;
+ }
+ }
+
+ switch(call) {
+#ifndef QT_NO_PROPERTIES
+ case QMetaObject::ReadProperty:
+ case QMetaObject::WriteProperty:
+ case QMetaObject::ResetProperty:
+ case QMetaObject::QueryPropertyDesignable:
+ case QMetaObject::QueryPropertyScriptable:
+ case QMetaObject::QueryPropertyStored:
+ case QMetaObject::QueryPropertyEditable:
+ case QMetaObject::QueryPropertyUser:
+ pp->d->metaCallHandler(pp, pySelf, call, args);
+ break;
+#endif
+ case QMetaObject::InvokeMetaMethod:
+ id = callMethod(object, id, args);
+ break;
+
+ default:
+ qWarning("Unsupported meta invocation type.");
+ }
+
+ // WARNING Isn't safe to call any metaObject and/or object methods beyond this point
+ // because the object can be deleted inside the called slot.
+
+ if (call == QMetaObject::InvokeMetaMethod) {
+ id = id - methodCount;
+ } else {
+ id = id - propertyCount;
+ }
+
+ if (pp || pp_name) {
+ Shiboken::GilState gil;
+ Py_XDECREF(pp);
+ Py_XDECREF(pp_name);
+ }
+
+ // Bubbles Python exceptions up to the Javascript engine, if called from one
+ {
+ Shiboken::GilState gil;
+
+ if (PyErr_Occurred()) {
+
+#if @QML_PRIVATE_API_SUPPORT@
+ // This JS engine grabber based off of Qt 5.5's `qjsEngine` function
+ QQmlData *data = QQmlData::get(object, false);
+
+ if (data && !data->jsWrapper.isNullOrUndefined()) {
+ QV4::ExecutionEngine *engine = data->jsWrapper.engine();
+
+#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
+ QV4::Heap::ExecutionContext *ctx = engine->current;
+#elif QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
+ QV4::Heap::ExecutionContext *ctx = engine->currentContext();
+#else
+ QV4::ExecutionContext *ctx = engine->currentContext();
+#endif
+
+#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
+ if (ctx->type == QV4::Heap::ExecutionContext::Type_CallContext ||
+ ctx->type == QV4::Heap::ExecutionContext::Type_SimpleCallContext) {
+#elif QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ if (ctx->d()->type == QV4::ExecutionContext::Type_CallContext ||
+ ctx->d()->type == QV4::ExecutionContext::Type_SimpleCallContext) {
+#else
+ if (ctx->type == QV4::ExecutionContext::Type_CallContext ||
+ ctx->type == QV4::ExecutionContext::Type_SimpleCallContext) {
+#endif
+ PyObject *errType, *errValue, *errTraceback;
+ PyErr_Fetch(&errType, &errValue, &errTraceback);
+ // PYSIDE-464: The error is only valid before PyErr_Restore,
+ // PYSIDE-464: therefore we take local copies.
+ Shiboken::AutoDecRef objStr(PyObject_Str(errValue));
+ const QString errString = QLatin1String(Shiboken::String::toCString(objStr));
+ const bool isSyntaxError = errType == PyExc_SyntaxError;
+ const bool isTypeError = errType == PyExc_TypeError;
+ PyErr_Restore(errType, errValue, errTraceback);
+
+ 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) {
+ return engine->throwTypeError(errString);
+ } 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
+
+ int reclimit = Py_GetRecursionLimit();
+ // Inspired by Python's errors.c: PyErr_GivenExceptionMatches() function.
+ // Temporarily bump the recursion limit, so that PyErr_Print will not raise a recursion
+ // error again. Don't do it when the limit is already insanely high, to avoid overflow.
+ if (reclimit < (1 << 30))
+ Py_SetRecursionLimit(reclimit + 5);
+ PyErr_Print();
+ Py_SetRecursionLimit(reclimit);
+ }
+ }
+
+ return id;
+}
+
+int SignalManager::callPythonMetaMethod(const QMetaMethod& method, void** args, PyObject* pyMethod, bool isShortCuit)
+{
+ Q_ASSERT(pyMethod);
+
+ Shiboken::GilState gil;
+ PyObject* pyArguments = 0;
+
+ if (isShortCuit){
+ pyArguments = reinterpret_cast<PyObject*>(args[1]);
+ } else {
+ pyArguments = parseArguments(method.parameterTypes(), args);
+ }
+
+ if (pyArguments) {
+ Shiboken::Conversions::SpecificConverter* retConverter = NULL;
+ const char* returnType = method.typeName();
+ if (returnType && std::strcmp("", returnType) && std::strcmp("void", returnType)) {
+ retConverter = new Shiboken::Conversions::SpecificConverter(returnType);
+ if (!retConverter || !*retConverter) {
+ PyErr_Format(PyExc_RuntimeError, "Can't find converter for '%s' to call Python meta method.", returnType);
+ return -1;
+ }
+ }
+
+ Shiboken::AutoDecRef retval(PyObject_CallObject(pyMethod, pyArguments));
+
+ if (!isShortCuit && pyArguments){
+ Py_DECREF(pyArguments);
+ }
+
+ if (!retval.isNull() && retval != Py_None && !PyErr_Occurred() && retConverter) {
+ retConverter->toCpp(retval, args[0]);
+ }
+ delete retConverter;
+ }
+
+ return -1;
+}
+
+bool SignalManager::registerMetaMethod(QObject* source, const char* signature, QMetaMethod::MethodType type)
+{
+ int ret = registerMetaMethodGetIndex(source, signature, type);
+ return (ret != -1);
+}
+
+int SignalManager::registerMetaMethodGetIndex(QObject* source, const char* signature, QMetaMethod::MethodType type)
+{
+ Q_ASSERT(source);
+ const QMetaObject* metaObject = source->metaObject();
+ int methodIndex = metaObject->indexOfMethod(signature);
+ // Create the dynamic signal is needed
+ if (methodIndex == -1) {
+ SbkObject* self = Shiboken::BindingManager::instance().retrieveWrapper(source);
+ if (!Shiboken::Object::hasCppWrapper(self)) {
+ qWarning() << "Invalid Signal signature:" << signature;
+ return -1;
+ } else {
+ DynamicQMetaObject *dmo = 0;
+ PyObject *pySelf = reinterpret_cast<PyObject*>(self);
+ PyObject* dict = self->ob_dict;
+
+ // Create a instance meta object
+ if (!dict || !PyDict_Contains(dict, metaObjectAttr)) {
+ dmo = new DynamicQMetaObject(pySelf->ob_type, 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);
+ } else {
+ dmo = reinterpret_cast<DynamicQMetaObject*>(const_cast<QMetaObject*>(metaObject));
+ }
+
+ if (type == QMetaMethod::Signal)
+ return dmo->addSignal(signature);
+ else
+ return dmo->addSlot(signature);
+ }
+ }
+ return methodIndex;
+}
+
+bool SignalManager::hasConnectionWith(const QObject *object)
+{
+ return m_d->m_globalReceiver.hasConnectionWith(object);
+}
+
+const QMetaObject* SignalManager::retriveMetaObject(PyObject *self)
+{
+ Shiboken::GilState gil;
+ DynamicQMetaObject *mo = 0;
+ Q_ASSERT(self);
+
+ PyObject* dict = reinterpret_cast<SbkObject*>(self)->ob_dict;
+ if (dict && PyDict_Contains(dict, metaObjectAttr)) {
+ PyObject *pyMo = PyDict_GetItem(dict, metaObjectAttr);
+
+#ifdef IS_PY3K
+ mo = reinterpret_cast<DynamicQMetaObject*>(PyCapsule_GetPointer(pyMo, 0));
+#else
+ mo = reinterpret_cast<DynamicQMetaObject*>(PyCObject_AsVoidPtr(pyMo));
+#endif
+ } else {
+ mo = reinterpret_cast<DynamicQMetaObject*>(Shiboken::Object::getTypeUserData(reinterpret_cast<SbkObject*>(self)));
+ }
+
+ mo->update();
+ return mo;
+}
+
+namespace {
+
+static int callMethod(QObject* object, int id, void** args)
+{
+ const QMetaObject* metaObject = object->metaObject();
+ QMetaMethod method = metaObject->method(id);
+
+ if (method.methodType() == QMetaMethod::Signal) {
+ // emit python signal
+ QMetaObject::activate(object, id, args);
+ } else {
+ Shiboken::GilState gil;
+ PyObject* self = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(object);
+ QByteArray methodName = method.methodSignature();
+ methodName.truncate(methodName.indexOf('('));
+ Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(self, methodName));
+ return SignalManager::callPythonMetaMethod(method, args, pyMethod, false);
+ }
+ return -1;
+}
+
+
+static PyObject* parseArguments(const QList<QByteArray>& paramTypes, void** args)
+{
+ int argsSize = paramTypes.count();
+ PyObject* preparedArgs = PyTuple_New(argsSize);
+
+ for (int i = 0, max = argsSize; i < max; ++i) {
+ void* data = args[i+1];
+ const char* dataType = paramTypes[i].constData();
+ Shiboken::Conversions::SpecificConverter converter(dataType);
+ if (converter) {
+ PyTuple_SET_ITEM(preparedArgs, i, converter.toPython(data));
+ } else {
+ PyErr_Format(PyExc_TypeError, "Can't call meta function because I have no idea how to handle %s", dataType);
+ Py_DECREF(preparedArgs);
+ return 0;
+ }
+ }
+ return preparedArgs;
+}
+
+static bool emitShortCircuitSignal(QObject* source, int signalIndex, PyObject* args)
+{
+ void* signalArgs[2] = {0, args};
+ source->qt_metacall(QMetaObject::InvokeMetaMethod, signalIndex, signalArgs);
+ return true;
+}
+
+} //namespace
diff --git a/sources/pyside2/libpyside/signalmanager.h b/sources/pyside2/libpyside/signalmanager.h
new file mode 100644
index 000000000..6f2201ed0
--- /dev/null
+++ b/sources/pyside2/libpyside/signalmanager.h
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SIGNALMANAGER_H
+#define SIGNALMANAGER_H
+
+#include "pysidemacros.h"
+#include <sbkpython.h>
+#include <Qt>
+#include <QStringList>
+#include <QMetaMethod>
+
+namespace PySide
+{
+
+/// Thin wrapper for PyObject which increases the reference count at the constructor but *NOT* at destructor.
+class PYSIDE_API PyObjectWrapper
+{
+public:
+ PyObjectWrapper();
+ PyObjectWrapper(PyObject* me);
+ PyObjectWrapper(const PyObjectWrapper &other);
+ ~PyObjectWrapper();
+ operator PyObject*() const;
+ PyObjectWrapper& operator=(const PyObjectWrapper &other);
+private:
+ PyObject* m_me;
+ void* m_data; //future
+};
+
+PYSIDE_API QDataStream &operator<<(QDataStream& out, const PyObjectWrapper& myObj);
+PYSIDE_API QDataStream &operator>>(QDataStream& in, PyObjectWrapper& myObj);
+
+class PYSIDE_API SignalManager
+{
+public:
+ static SignalManager& instance();
+
+ QObject* globalReceiver(QObject* sender, PyObject* callback);
+ void releaseGlobalReceiver(const QObject* sender, QObject* receiver);
+ int globalReceiverSlotIndex(QObject* sender, const char* slotSignature) const;
+ void notifyGlobalReceiver(QObject* receiver);
+
+ bool emitSignal(QObject* source, const char* signal, PyObject* args);
+ static int qt_metacall(QObject* object, QMetaObject::Call call, int id, void** args);
+
+ // Used to register a new signal/slot on QMetaobject of source.
+ static bool registerMetaMethod(QObject* source, const char* signature, QMetaMethod::MethodType type);
+ static int registerMetaMethodGetIndex(QObject* source, const char* signature, QMetaMethod::MethodType type);
+
+ // used to discovery metaobject
+ static const QMetaObject* retriveMetaObject(PyObject* self);
+
+ // Used to discovery if SignalManager was connected with object "destroyed()" signal.
+ int countConnectionsWith(const QObject *object);
+
+ // Disconnect all signals managed by Globalreceiver
+ void clear();
+
+ // Utility function to call a python method usign args received in qt_metacall
+ static int callPythonMetaMethod(const QMetaMethod& method, void** args, PyObject* obj, bool isShortCuit);
+
+ PYSIDE_DEPRECATED(QObject* globalReceiver());
+ PYSIDE_DEPRECATED(void addGlobalSlot(const char* slot, PyObject* callback));
+ PYSIDE_DEPRECATED(int addGlobalSlotGetIndex(const char* slot, PyObject* callback));
+
+ PYSIDE_DEPRECATED(void globalReceiverConnectNotify(QObject *sender, int slotIndex));
+ PYSIDE_DEPRECATED(void globalReceiverDisconnectNotify(QObject *sender, int slotIndex));
+ PYSIDE_DEPRECATED(bool hasConnectionWith(const QObject *object));
+
+private:
+ struct SignalManagerPrivate;
+ SignalManagerPrivate* m_d;
+
+ SignalManager();
+ ~SignalManager();
+
+ // disable copy
+ SignalManager(const SignalManager&);
+ SignalManager operator=(const SignalManager&);
+};
+
+}
+
+Q_DECLARE_METATYPE(PySide::PyObjectWrapper)
+
+#endif
diff --git a/sources/pyside2/plugins/CMakeLists.txt b/sources/pyside2/plugins/CMakeLists.txt
new file mode 100644
index 000000000..0933cebbc
--- /dev/null
+++ b/sources/pyside2/plugins/CMakeLists.txt
@@ -0,0 +1,36 @@
+project(plugins)
+
+set(ui_plugin_src
+ customwidgets.cpp
+ customwidget.cpp
+)
+
+set(ui_plugin_moc
+ customwidget.h
+ customwidgets.h
+)
+
+include_directories(${Qt5Designer_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR})
+
+qt5_wrap_cpp(MOC_FILES ${ui_plugin_moc})
+add_library(uiplugin STATIC ${ui_plugin_src} ${MOC_FILES})
+if(CMAKE_HOST_UNIX AND NOT CYGWIN)
+ add_definitions(-fPIC)
+endif()
+add_definitions(-DQT_STATICPLUGIN)
+
+if(Qt5Core_VERSION VERSION_GREATER "5.7.1")
+ set_property(TARGET uiplugin PROPERTY CXX_STANDARD 11)
+endif()
+
+target_link_libraries(uiplugin
+ ${Qt5UiTools_LIBRARY}
+ ${SHIBOKEN_LIBRARY}
+ ${SHIBOKEN_PYTHON_LIBRARY})
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(LIBRARY_OUTPUT_SUFFIX ${CMAKE_DEBUG_POSTFIX})
+else()
+ set(LIBRARY_OUTPUT_SUFFIX ${CMAKE_RELEASE_POSTFIX})
+endif()
diff --git a/sources/pyside2/plugins/customwidget.cpp b/sources/pyside2/plugins/customwidget.cpp
new file mode 100644
index 000000000..771867796
--- /dev/null
+++ b/sources/pyside2/plugins/customwidget.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "customwidget.h"
+
+
+struct PyCustomWidgetPrivate
+{
+ PyObject* pyObject;
+ bool initialized;
+};
+
+PyCustomWidget::PyCustomWidget(PyObject* objectType)
+ : m_data(new PyCustomWidgetPrivate())
+{
+ m_data->pyObject = objectType;
+ m_name = QString(reinterpret_cast<PyTypeObject*>(objectType)->tp_name);
+}
+
+PyCustomWidget::~PyCustomWidget()
+{
+ delete m_data;
+}
+
+bool PyCustomWidget::isContainer() const
+{
+ return false;
+}
+
+bool PyCustomWidget::isInitialized() const
+{
+ return m_data->initialized;
+}
+
+QIcon PyCustomWidget::icon() const
+{
+ return QIcon();
+}
+
+QString PyCustomWidget::domXml() const
+{
+ return QString();
+}
+
+QString PyCustomWidget::group() const
+{
+ return QString();
+}
+
+QString PyCustomWidget::includeFile() const
+{
+ return QString();
+}
+
+QString PyCustomWidget::name() const
+{
+ return m_name;
+}
+
+QString PyCustomWidget::toolTip() const
+{
+ return QString();
+}
+
+QString PyCustomWidget::whatsThis() const
+{
+ return QString();
+}
+
+QWidget* PyCustomWidget::createWidget(QWidget* parent)
+{
+ //Create a python instance and return cpp object
+ PyObject* pyParent;
+ bool unkowParent = false;
+ if (parent) {
+ pyParent = reinterpret_cast<PyObject*>(Shiboken::BindingManager::instance().retrieveWrapper(parent));
+ if (pyParent) {
+ Py_INCREF(pyParent);
+ } else {
+ static Shiboken::Conversions::SpecificConverter converter("QWidget*");
+ pyParent = converter.toPython(&parent);
+ unkowParent = true;
+ }
+ } else {
+ Py_INCREF(Py_None);
+ pyParent = Py_None;
+ }
+
+ Shiboken::AutoDecRef pyArgs(PyTuple_New(1));
+ PyTuple_SET_ITEM(pyArgs, 0, pyParent); //tuple will keep pyParent reference
+
+ //Call python constructor
+ SbkObject* result = reinterpret_cast<SbkObject*>(PyObject_CallObject(m_data->pyObject, pyArgs));
+
+ QWidget* widget = 0;
+ if (result) {
+ if (unkowParent) //if parent does not exists in python, transfer the ownership to cpp
+ Shiboken::Object::releaseOwnership(result);
+ else
+ Shiboken::Object::setParent(pyParent, reinterpret_cast<PyObject*>(result));
+
+ widget = reinterpret_cast<QWidget*>(Shiboken::Object::cppPointer(result, Py_TYPE(result)));
+ }
+
+ return widget;
+}
+
+void PyCustomWidget::initialize(QDesignerFormEditorInterface* core)
+{
+ m_data->initialized = true;
+}
diff --git a/sources/pyside2/plugins/customwidget.h b/sources/pyside2/plugins/customwidget.h
new file mode 100644
index 000000000..1b854c69a
--- /dev/null
+++ b/sources/pyside2/plugins/customwidget.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 _PY_CUSTOM_WIDGET_H_
+#define _PY_CUSTOM_WIDGET_H_
+
+#include <shiboken.h>
+
+#include <QtCore/QtGlobal>
+#if (QT_VERSION < QT_VERSION_CHECK(5, 5, 0))
+ #include <QtDesigner/QDesignerCustomWidgetInterface>
+#else
+ #include <QtUiPlugin/QDesignerCustomWidgetInterface>
+#endif
+
+
+struct PyCustomWidgetPrivate;
+
+class PyCustomWidget: public QObject, public QDesignerCustomWidgetInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QDesignerCustomWidgetInterface)
+
+public:
+ PyCustomWidget(PyObject* objectType);
+ ~PyCustomWidget();
+
+ bool isContainer() const;
+ bool isInitialized() const;
+ QIcon icon() const;
+ QString domXml() const;
+ QString group() const;
+ QString includeFile() const;
+ QString name() const;
+ QString toolTip() const;
+ QString whatsThis() const;
+ QWidget *createWidget(QWidget *parent);
+ void initialize(QDesignerFormEditorInterface *core);
+
+private:
+ PyCustomWidgetPrivate* m_data;
+ QString m_name;
+};
+
+#endif
diff --git a/sources/pyside2/plugins/customwidgets.cpp b/sources/pyside2/plugins/customwidgets.cpp
new file mode 100644
index 000000000..01ef392b0
--- /dev/null
+++ b/sources/pyside2/plugins/customwidgets.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "customwidget.h"
+#include "customwidgets.h"
+
+
+struct PyCustomWidgetPrivate
+{
+ PyObject* pyObject;
+ bool initialized;
+};
+
+struct PyCustomWidgetsPrivate
+{
+ QList<QDesignerCustomWidgetInterface*> widgets;
+ ~PyCustomWidgetsPrivate();
+};
+
+
+PyCustomWidgetsPrivate::~PyCustomWidgetsPrivate()
+{
+ foreach(QDesignerCustomWidgetInterface* iface, widgets)
+ delete iface;
+ widgets.clear();
+}
+
+PyCustomWidgets::PyCustomWidgets(QObject *parent)
+ : QObject(parent), m_data(new PyCustomWidgetsPrivate)
+{
+}
+
+PyCustomWidgets::~PyCustomWidgets()
+{
+ delete m_data;
+}
+
+void PyCustomWidgets::registerWidgetType(PyObject* widget)
+{
+ m_data->widgets.append(new PyCustomWidget(widget));
+}
+
+QList<QDesignerCustomWidgetInterface*> PyCustomWidgets::customWidgets() const
+{
+ return m_data->widgets;
+}
+
+
diff --git a/sources/pyside2/plugins/customwidgets.h b/sources/pyside2/plugins/customwidgets.h
new file mode 100644
index 000000000..a666f66dd
--- /dev/null
+++ b/sources/pyside2/plugins/customwidgets.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 _PY_CUSTOM_WIDGETS_H_
+#define _PY_CUSTOM_WIDGETS_H_
+
+#include <shiboken.h>
+
+#include <QtCore/QtGlobal>
+#if (QT_VERSION < QT_VERSION_CHECK(5, 5, 0))
+ #include <QtDesigner/QDesignerCustomWidgetInterface>
+#else
+ #include <QtUiPlugin/QDesignerCustomWidgetInterface>
+#endif
+
+
+struct PyCustomWidgetsPrivate;
+
+class PyCustomWidgets: public QObject, public QDesignerCustomWidgetCollectionInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.PySide.PyCustomWidgetsInterface")
+
+public:
+ PyCustomWidgets(QObject *parent = 0);
+ ~PyCustomWidgets();
+ virtual QList<QDesignerCustomWidgetInterface*> customWidgets() const;
+ void registerWidgetType(PyObject* widget);
+
+private:
+ PyCustomWidgetsPrivate* m_data;
+};
+
+#endif
diff --git a/sources/pyside2/tests/CMakeLists.txt b/sources/pyside2/tests/CMakeLists.txt
new file mode 100644
index 000000000..2b7e3b0e1
--- /dev/null
+++ b/sources/pyside2/tests/CMakeLists.txt
@@ -0,0 +1,61 @@
+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()
+
+ # tests/QtWidgets/qstandarditemmodel_test.py needs shiboken2
+ if(WIN32)
+ set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR};${CMAKE_SOURCE_DIR}/tests/util;${CMAKE_BINARY_DIR}/tests/pysidetest;${CMAKE_BINARY_DIR}/../shiboken2/shibokenmodule;$ENV{PYTHONPATH}")
+ set(TEST_LIBRARY_PATH "${libpyside_BINARY_DIR};${pysidetest_BINARY_DIR};${SHIBOKEN_INCLUDE_DIR}/../../bin;$ENV{PATH}")
+ set(LIBRARY_PATH_VAR "PATH")
+ string(REPLACE "\\" "/" TEST_PYTHONPATH "${TEST_PYTHONPATH}")
+ string(REPLACE "\\" "/" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}")
+
+ string(REPLACE ";" "\\;" TEST_PYTHONPATH "${TEST_PYTHONPATH}")
+ string(REPLACE ";" "\\;" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}")
+ else()
+ set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util:${CMAKE_BINARY_DIR}/tests/pysidetest:${CMAKE_BINARY_DIR}/../shiboken2/shibokenmodule:$ENV{PYTHONPATH}")
+ set(TEST_LIBRARY_PATH "${libpyside_BINARY_DIR}:${pysidetest_BINARY_DIR}:$ENV{LD_LIBRARY_PATH}")
+ set(LIBRARY_PATH_VAR "LD_LIBRARY_PATH")
+ endif()
+
+
+ macro(TEST_QT_MODULE var name)
+ if(NOT DISABLE_${name} AND ${var})
+ add_subdirectory(${name})
+ endif()
+ endmacro()
+
+ 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})
+ set_tests_properties(${TEST_NAME} PROPERTIES
+ TIMEOUT ${CTEST_TESTING_TIMEOUT}
+ WILL_FAIL ${EXPECT_TO_FAIL}
+ ENVIRONMENT "PYTHONPATH=${TEST_PYTHONPATH};${LIBRARY_PATH_VAR}=${TEST_LIBRARY_PATH}")
+ endmacro()
+
+ add_subdirectory(pysidetest)
+ add_subdirectory(signals)
+
+ foreach(shortname IN LISTS all_module_shortnames)
+ message(STATUS "preparing tests for module 'Qt${shortname}'")
+ TEST_QT_MODULE(Qt5${shortname}_FOUND Qt${shortname})
+ endforeach()
+
+ #platform specific
+ if (ENABLE_MAC)
+ add_subdirectory(mac)
+ endif ()
+endif()
diff --git a/sources/pyside2/tests/QtConcurrent/CMakeLists.txt b/sources/pyside2/tests/QtConcurrent/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtConcurrent/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtConcurrent/this_module_loads_test.py b/sources/pyside2/tests/QtConcurrent/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtConcurrent/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtCore/CMakeLists.txt b/sources/pyside2/tests/QtCore/CMakeLists.txt
new file mode 100644
index 000000000..436af3dac
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/CMakeLists.txt
@@ -0,0 +1,121 @@
+PYSIDE_TEST(bug_278_test.py)
+PYSIDE_TEST(bug_332.py)
+PYSIDE_TEST(bug_408.py)
+PYSIDE_TEST(bug_428.py)
+PYSIDE_TEST(bug_462.py)
+PYSIDE_TEST(bug_505.py)
+PYSIDE_TEST(bug_515.py)
+PYSIDE_TEST(bug_606.py)
+PYSIDE_TEST(bug_656.py)
+PYSIDE_TEST(bug_686.py)
+PYSIDE_TEST(bug_699.py)
+PYSIDE_TEST(bug_706.py)
+PYSIDE_TEST(bug_820.py)
+PYSIDE_TEST(bug_826.py)
+PYSIDE_TEST(bug_829.py)
+PYSIDE_TEST(bug_835.py)
+PYSIDE_TEST(bug_920.py)
+PYSIDE_TEST(bug_927.py)
+PYSIDE_TEST(bug_931.py)
+PYSIDE_TEST(bug_938.py)
+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_PYSIDE-42.py)
+PYSIDE_TEST(bug_PYSIDE-164.py)
+PYSIDE_TEST(blocking_signals_test.py)
+PYSIDE_TEST(classinfo_test.py)
+PYSIDE_TEST(child_event_test.py)
+PYSIDE_TEST(deepcopy_test.py)
+PYSIDE_TEST(deletelater_test.py)
+PYSIDE_TEST(destroysignal_test.py)
+PYSIDE_TEST(duck_punching_test.py)
+PYSIDE_TEST(hash_test.py)
+PYSIDE_TEST(inherits_test.py)
+PYSIDE_TEST(max_signals.py)
+PYSIDE_TEST(missing_symbols_test.py)
+PYSIDE_TEST(mockclass_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)
+PYSIDE_TEST(qbytearray_test.py)
+PYSIDE_TEST(qcollator_test.py)
+PYSIDE_TEST(qcommandlineparser_test.py)
+PYSIDE_TEST(qcoreapplication_instance_test.py)
+PYSIDE_TEST(qdatastream_test.py)
+PYSIDE_TEST(qdatetime_test.py)
+PYSIDE_TEST(qdate_test.py)
+PYSIDE_TEST(qeasingcurve_test.py)
+PYSIDE_TEST(qenum_test.py)
+PYSIDE_TEST(qevent_test.py)
+PYSIDE_TEST(qfileinfo_test.py)
+PYSIDE_TEST(qfile_test.py)
+PYSIDE_TEST(qflags_test.py)
+PYSIDE_TEST(qinstallmsghandler_test.py)
+PYSIDE_TEST(qlinef_test.py)
+PYSIDE_TEST(qlocale_test.py)
+PYSIDE_TEST(qmetaobject_test.py)
+PYSIDE_TEST(qmimedatabase_test.py)
+PYSIDE_TEST(qmodelindex_internalpointer_test.py)
+PYSIDE_TEST(qobject_children_segfault_test.py)
+PYSIDE_TEST(qobject_connect_notify_test.py)
+PYSIDE_TEST(qobject_destructor.py)
+PYSIDE_TEST(qobject_event_filter_test.py)
+PYSIDE_TEST(qobject_inherits_test.py)
+PYSIDE_TEST(qobject_objectproperty_test.py)
+PYSIDE_TEST(qobject_parent_test.py)
+PYSIDE_TEST(qobject_property_test.py)
+PYSIDE_TEST(qobject_protected_methods_test.py)
+PYSIDE_TEST(qobject_test.py)
+PYSIDE_TEST(qobject_timer_event_test.py)
+PYSIDE_TEST(qobject_tr_as_instance_test.py)
+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(qresource_test.py)
+PYSIDE_TEST(qsize_test.py)
+PYSIDE_TEST(qslot_object_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)
+PYSIDE_TEST(qthread_test.py)
+PYSIDE_TEST(qtimer_singleshot_test.py)
+PYSIDE_TEST(qtimer_timeout_test.py)
+PYSIDE_TEST(qtnamespace_test.py)
+PYSIDE_TEST(qurl_test.py)
+PYSIDE_TEST(repr_test.py)
+PYSIDE_TEST(setprop_on_ctor_test.py)
+PYSIDE_TEST(staticMetaObject_test.py)
+PYSIDE_TEST(static_method_test.py)
+PYSIDE_TEST(static_protected_methods_test.py)
+PYSIDE_TEST(thread_signals_test.py)
+PYSIDE_TEST(tr_noop_test.py)
+PYSIDE_TEST(translation_test.py)
+PYSIDE_TEST(unaryoperator_test.py)
+PYSIDE_TEST(unicode_test.py)
+PYSIDE_TEST(versioninfo_test.py)
+
+if(X11)
+ PYSIDE_TEST(qhandle_test.py)
+endif()
diff --git a/sources/pyside2/tests/QtCore/blocking_signals_test.py b/sources/pyside2/tests/QtCore/blocking_signals_test.py
new file mode 100644
index 000000000..64d5335aa
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/blocking_signals_test.py
@@ -0,0 +1,134 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test case for QObject.signalsBlocked() and blockSignal()'''
+
+import unittest
+import os
+from tempfile import mkstemp
+
+from PySide2.QtCore import QObject, SIGNAL, QFile
+
+class TestSignalsBlockedBasic(unittest.TestCase):
+ '''Basic test case for signalsBlocked'''
+
+ def testBasic(self):
+ '''QObject.signalsBlocked() and blockSignals()
+ The signals aren't blocked by default.
+ blockSignals returns the previous value'''
+ obj = QObject()
+ self.assertTrue(not obj.signalsBlocked())
+ self.assertTrue(not obj.blockSignals(True))
+ self.assertTrue(obj.signalsBlocked())
+ self.assertTrue(obj.blockSignals(False))
+
+class TestSignalsBlocked(unittest.TestCase):
+ '''Test case to check if the signals are really blocked'''
+
+ def setUp(self):
+ #Set up the basic resources needed
+ self.obj = QObject()
+ self.args = tuple()
+ self.called = False
+
+ def tearDown(self):
+ #Delete used resources
+ del self.obj
+ del self.args
+
+ def callback(self, *args):
+ #Default callback
+ if args == self.args:
+ self.called = True
+ else:
+ raise TypeError("Invalid arguments")
+
+ def testShortCircuitSignals(self):
+ #Blocking of Python short-circuit signals
+ QObject.connect(self.obj, SIGNAL('mysignal()'), self.callback)
+
+ self.obj.emit(SIGNAL('mysignal()'))
+ self.assertTrue(self.called)
+
+ self.called = False
+ self.obj.blockSignals(True)
+ self.obj.emit(SIGNAL('mysignal()'))
+ self.assertTrue(not self.called)
+
+ def testPythonSignals(self):
+ #Blocking of Python typed signals
+ QObject.connect(self.obj, SIGNAL('mysignal(int,int)'), self.callback)
+ self.args = (1, 3)
+
+ self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args)
+ self.assertTrue(self.called)
+
+ self.called = False
+ self.obj.blockSignals(True)
+ self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args)
+ self.assertTrue(not self.called)
+
+class TestQFileSignalBlocking(unittest.TestCase):
+ '''Test case for blocking the signal QIODevice.aboutToClose()'''
+
+ def setUp(self):
+ #Set up the needed resources - A temp file and a QFile
+ self.called = False
+ handle, self.filename = mkstemp()
+ os.close(handle)
+
+ self.qfile = QFile(self.filename)
+
+ def tearDown(self):
+ #Release acquired resources
+ os.remove(self.filename)
+ del self.qfile
+
+ def callback(self):
+ #Default callback
+ self.called = True
+
+ def testAboutToCloseBlocking(self):
+ #QIODevice.aboutToClose() blocking
+
+ QObject.connect(self.qfile, SIGNAL('aboutToClose()'), self.callback)
+
+ self.assertTrue(self.qfile.open(QFile.ReadOnly))
+ self.qfile.close()
+ self.assertTrue(self.called)
+
+ self.called = False
+ self.qfile.blockSignals(True)
+
+ self.assertTrue(self.qfile.open(QFile.ReadOnly))
+ self.qfile.close()
+ self.assertTrue(not self.called)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_1019.py b/sources/pyside2/tests/QtCore/bug_1019.py
new file mode 100644
index 000000000..039c66dbd
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_1019.py
@@ -0,0 +1,60 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+
+class MyTimer (QTimer):
+ def __init__(self):
+ QTimer.__init__(self)
+ self.startCalled = False
+
+ @Slot()
+ def slotUsedToIncreaseMethodOffset(self):
+ pass
+
+class MyTimer2 (MyTimer):
+
+ @Slot()
+ def slotUsedToIncreaseMethodOffset2(self):
+ pass
+
+ def start(self):
+ self.startCalled = True
+ QCoreApplication.instance().quit()
+
+class TestBug1019 (unittest.TestCase):
+ def testIt(self):
+ app = QCoreApplication([])
+ t = MyTimer2()
+ QTimer.singleShot(0, t.start)
+ app.exec_()
+ self.assertTrue(t.startCalled)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_1031.py b/sources/pyside2/tests/QtCore/bug_1031.py
new file mode 100644
index 000000000..bdc159f0d
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_1031.py
@@ -0,0 +1,33 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+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
new file mode 100644
index 000000000..0ab09cc35
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_1063.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' unit test for BUG #1063 '''
+
+import unittest
+import tempfile
+from PySide2 import QtCore
+import os
+import py3kcompat as py3k
+
+class QTextStreamTestCase(unittest.TestCase):
+ def setUp(self):
+ self.temp_file = tempfile.NamedTemporaryFile(delete=False)
+ 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.stream = QtCore.QTextStream(self.f)
+
+ def testIt(self):
+ for s in self.strings:
+ self.stream << s
+
+ self.f.close()
+
+ # make sure we didn't get an empty file
+ self.assertNotEqual(QtCore.QFile(self.temp_file.name).size(), 0)
+
+ os.unlink(self.temp_file.name)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_1069.py b/sources/pyside2/tests/QtCore/bug_1069.py
new file mode 100644
index 000000000..90b66eaed
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_1069.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' unit test for BUG #1069 '''
+
+from PySide2 import QtCore
+import unittest
+
+class QDataStreamOpOverloadTestCase(unittest.TestCase):
+ def setUp(self):
+ self.ba = QtCore.QByteArray()
+ self.stream = QtCore.QDataStream(self.ba, QtCore.QIODevice.WriteOnly)
+
+ def testIt(self):
+ self.stream << "hello"
+ ok = False
+ for c in self.ba:
+ if c != b'\x00':
+ ok = True
+ break
+
+ self.assertEqual(ok, True)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_278_test.py b/sources/pyside2/tests/QtCore/bug_278_test.py
new file mode 100644
index 000000000..710971e63
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_278_test.py
@@ -0,0 +1,52 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2 import QtCore
+
+def setValue(o):
+ values = ['Name']
+ o.setProperty('test1', values)
+
+class QQtVersionTest(unittest.TestCase):
+ '''Tests for QVariant conversion of QStringList'''
+
+ def testGet(self):
+ o = QtCore.QObject()
+ setValue(o)
+ self.assertEqual(o.property('test1'), ['Name'])
+
+
+
+if __name__ == '__main__':
+ unittest.main()
+
+
diff --git a/sources/pyside2/tests/QtCore/bug_332.py b/sources/pyside2/tests/QtCore/bug_332.py
new file mode 100644
index 000000000..e863a93db
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_332.py
@@ -0,0 +1,46 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2 import QtCore
+
+class Lock(QtCore.QMutex):
+ def tryLock(self,timeoutt=10):
+ return QtCore.QMutex.tryLock(self,timeoutt)
+
+class TestBug(unittest.TestCase):
+
+ def testCase(self):
+ l = Lock()
+ l.tryLock() # this cause a assertion
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_408.py b/sources/pyside2/tests/QtCore/bug_408.py
new file mode 100644
index 000000000..5ccb25ee8
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_408.py
@@ -0,0 +1,56 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import *
+
+class MyDevice(QIODevice):
+ def __init__(self, txt):
+ QIODevice.__init__(self)
+ self.txt = txt
+ self.ptr = 0
+
+ def readData(self, size):
+ size = min(len(self.txt) - self.ptr, size)
+ retval = self.txt[self.ptr:size]
+ self.ptr += size
+ return retval
+
+class QIODeviceTest(unittest.TestCase):
+
+ def testIt(self):
+ device = MyDevice("hello world\nhello again")
+ device.open(QIODevice.ReadOnly)
+
+ s = QTextStream(device)
+ self.assertEqual(s.readLine(), "hello world")
+ self.assertEqual(s.readLine(), "hello again")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_428.py b/sources/pyside2/tests/QtCore/bug_428.py
new file mode 100644
index 000000000..d256fbfd8
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_428.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject
+
+class MyBaseObject(QObject):
+ def __init__(self, number):
+ self.myMember = 'myMember' + number
+ QObject.__init__(self)
+
+class QObjectConstructorTest(unittest.TestCase):
+ def testBug(self):
+ for i in range(10):
+ number = str(i)
+ obj = MyBaseObject(number)
+ self.assertEqual(obj.myMember, 'myMember' + number)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_462.py b/sources/pyside2/tests/QtCore/bug_462.py
new file mode 100644
index 000000000..14576c09c
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_462.py
@@ -0,0 +1,74 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+
+from PySide2.QtCore import QObject, QCoreApplication, QEvent, QThread
+
+class MyEvent(QEvent):
+ def __init__(self,i):
+ print("TYPE:", type(QEvent.User))
+ super(MyEvent,self).__init__(QEvent.Type(QEvent.User + 100 ))
+ self.i = i
+
+class MyThread (QThread):
+ def __init__(self,owner):
+ super(MyThread,self).__init__()
+ self.owner=owner;
+
+ def run(self):
+ for i in range(3):
+ e=MyEvent(i);
+ QCoreApplication.postEvent(self.owner,e)
+
+class MyBaseObject(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+ self.events = []
+ self.t = MyThread(self)
+ self.t.start()
+
+ def customEvent(self, event):
+ self.events.append(event)
+ if len(self.events) == 3:
+ self.t.wait()
+ self.app.quit()
+
+
+class CheckForEventsTypes(unittest.TestCase):
+ def testTypes(self):
+ o = MyBaseObject()
+ o.app = QCoreApplication(sys.argv)
+ o.app.exec_()
+ for e in o.events:
+ self.assertTrue(isinstance(e, MyEvent))
+ o.app = None
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_505.py b/sources/pyside2/tests/QtCore/bug_505.py
new file mode 100644
index 000000000..115f40ab5
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_505.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject
+
+class MyBaseObject(QObject):
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+ self.setObjectName("PySide")
+
+ def __del__(self):
+ if self.objectName() != "PySide":
+ raise NameError('Fail')
+
+class CheckForEventsTypes(unittest.TestCase):
+ def testDelObject(self):
+ p = MyBaseObject()
+ o = MyBaseObject(p)
+ del o
+ del p
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_515.py b/sources/pyside2/tests/QtCore/bug_515.py
new file mode 100644
index 000000000..8d57589d3
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_515.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+""" Unittest for bug #515 """
+""" http://bugs.openbossa.org/show_bug.cgi?id=515 """
+
+from PySide2 import QtCore
+
+callCleanup = False
+def _cleanup():
+ global callCleanup
+ callCleanup = True
+
+def _checkCleanup():
+ global callCleanup
+ assert(callCleanup)
+
+app = QtCore.QCoreApplication([])
+QtCore.qAddPostRoutine(_cleanup)
+QtCore.qAddPostRoutine(_checkCleanup)
+del app
diff --git a/sources/pyside2/tests/QtCore/bug_606.py b/sources/pyside2/tests/QtCore/bug_606.py
new file mode 100644
index 000000000..31aa000f0
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_606.py
@@ -0,0 +1,62 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+import PySide2
+from PySide2.QtCore import QPoint, QPointF
+from PySide2.QtCore import QLine, QLineF
+from PySide2.QtCore import QSize, QSizeF
+
+class testCases(unittest.TestCase):
+ def testQPointToTuple(self):
+ p = QPoint(1, 2)
+ self.assertEqual((1, 2), p.toTuple())
+
+ def testQPointFToTuple(self):
+ p = QPointF(1, 2)
+ self.assertEqual((1, 2), p.toTuple())
+
+ def testQLineToTuple(self):
+ l = QLine(1, 2, 3, 4)
+ self.assertEqual((1, 2, 3, 4), l.toTuple())
+
+ def testQLineFToTuple(self):
+ l = QLineF(1, 2, 3, 4)
+ self.assertEqual((1, 2, 3, 4), l.toTuple())
+
+ def testQSizeToTuple(self):
+ s = QSize(1, 2)
+ self.assertEqual((1, 2), s.toTuple())
+
+ def testQSizeFToTuple(self):
+ s = QSizeF(1, 2)
+ self.assertEqual((1, 2), s.toTuple())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_656.py b/sources/pyside2/tests/QtCore/bug_656.py
new file mode 100644
index 000000000..5eb1f2ce4
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_656.py
@@ -0,0 +1,37 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+
+class CoreApp(QCoreApplication):
+ def __init__(self,*args):
+ super(CoreApp,self).__init__(*args)
+ # It shouldn't crash after the __init__ call
+
+import sys
+app = CoreApp(sys.argv)
diff --git a/sources/pyside2/tests/QtCore/bug_686.py b/sources/pyside2/tests/QtCore/bug_686.py
new file mode 100644
index 000000000..a8c0973ee
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_686.py
@@ -0,0 +1,116 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import with_statement
+
+import unittest
+from PySide2.QtCore import *
+
+class MyWriteThread(QThread):
+ def __init__(self, lock):
+ QThread.__init__(self)
+ self.lock = lock
+ self.started = False
+ self.canQuit = False
+
+ def run(self):
+ self.started = True
+ while not self.lock.tryLockForWrite():
+ pass
+ self.canQuit = True
+
+class MyReadThread(QThread):
+ def __init__(self, lock):
+ QThread.__init__(self)
+ self.lock = lock
+ self.started = False
+ self.canQuit = False
+
+ def run(self):
+ self.started = True
+ while not self.lock.tryLockForRead():
+ pass
+ self.canQuit = True
+
+class MyMutexedThread(QThread):
+ def __init__(self, mutex):
+ QThread.__init__(self)
+ self.mutex = mutex
+ self.started = False
+ self.canQuit = False
+
+ def run(self):
+ self.started = True
+ while not self.mutex.tryLock():
+ pass
+ self.mutex.unlock()
+ self.canQuit = True
+
+class TestQMutex (unittest.TestCase):
+
+ def testReadLocker(self):
+ lock = QReadWriteLock()
+ thread = MyWriteThread(lock)
+
+ with QReadLocker(lock):
+ thread.start()
+ while not thread.started:
+ pass
+ self.assertFalse(thread.canQuit)
+
+ thread.wait(2000)
+ self.assertTrue(thread.canQuit)
+
+ def testWriteLocker(self):
+ lock = QReadWriteLock()
+ thread = MyReadThread(lock)
+
+ with QWriteLocker(lock):
+ thread.start()
+ while not thread.started:
+ pass
+ self.assertFalse(thread.canQuit)
+
+ thread.wait(2000)
+ self.assertTrue(thread.canQuit)
+
+ def testMutexLocker(self):
+ mutex = QMutex()
+ thread = MyMutexedThread(mutex)
+
+ with QMutexLocker(mutex):
+ thread.start()
+ while not thread.started:
+ pass
+ self.assertFalse(thread.canQuit)
+
+ thread.wait(2000)
+ self.assertTrue(thread.canQuit)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_699.py b/sources/pyside2/tests/QtCore/bug_699.py
new file mode 100644
index 000000000..203daf60a
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_699.py
@@ -0,0 +1,45 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+
+class TestBug699 (unittest.TestCase):
+
+ def defClass(self):
+ class Foo (QObject):
+ def foo(self):
+ pass
+
+ prop = Property(foo, foo)
+
+ def testIt(self):
+ self.assertRaises(TypeError, self.defClass)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_706.py b/sources/pyside2/tests/QtCore/bug_706.py
new file mode 100644
index 000000000..58acfe3c0
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_706.py
@@ -0,0 +1,55 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import *
+
+class MyModel (QAbstractListModel):
+ def rowCount(self, parent = None):
+ return 3
+
+class TestBug706(unittest.TestCase):
+
+ def mySlot(self, idx, start, end):
+ self.start = start
+ self.end = end
+
+ def testIt(self):
+ self.start = None
+ self.end = None
+
+ app = QCoreApplication([])
+ model = MyModel()
+ model.columnsAboutToBeInserted.connect(self.mySlot)
+ model.columnsAboutToBeInserted.emit(QModelIndex(), 0, 1)
+ self.assertEqual(self.start, 0)
+ self.assertEqual(self.end, 1)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_820.py b/sources/pyside2/tests/QtCore/bug_820.py
new file mode 100644
index 000000000..ef005fd55
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_820.py
@@ -0,0 +1,97 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import functools
+import unittest
+
+from PySide2.QtCore import QObject, Slot, Signal, SIGNAL
+
+def log_exception():
+ def log_exception_decorator(func):
+ @functools.wraps(func)
+ def wrapper(*args, **kwds):
+ try:
+ return func(*args, **kwds)
+ except Exception:
+ raise
+
+ return wrapper
+
+ return log_exception_decorator
+
+
+def log_exception2():
+ def log_exception_decorator(func):
+ def wrapper(*args, **kwds):
+ try:
+ return func(*args, **kwds)
+ except Exception:
+ raise
+
+ return wrapper
+
+ return log_exception_decorator
+
+class MyObject(QObject):
+
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+ self._mySlotcalled = False
+ self._mySlot2called = False
+
+ @Slot()
+ @log_exception()
+ def mySlot(self):
+ self._mySlotcalled = True
+
+ @Slot(name="mySlot2")
+ @log_exception2()
+ def mySlot2(self):
+ self._mySlot2called = True
+
+ def poke(self):
+ self.events.emit()
+
+ events = Signal()
+
+
+class SlotWithDecoratorTest(unittest.TestCase):
+ def testSlots(self):
+ o = MyObject()
+ self.assertTrue(o.metaObject().indexOfSlot("mySlot()") > 0)
+ self.assertTrue(o.metaObject().indexOfSlot("mySlot2()") > 0)
+
+ o.events.connect(o.mySlot)
+ o.events.connect(o.mySlot2)
+ o.poke()
+ self.assertTrue(o._mySlotcalled)
+ self.assertTrue(o._mySlot2called)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/bug_826.py b/sources/pyside2/tests/QtCore/bug_826.py
new file mode 100644
index 000000000..e94e4bdcf
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_826.py
@@ -0,0 +1,57 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import QEvent, Qt
+import PySide2
+
+import unittest
+
+TEST_EVENT_TYPE = QEvent.Type(QEvent.registerEventType())
+
+class TestEvent(QEvent):
+ TestEventType = QEvent.Type(QEvent.registerEventType())
+
+ def __init__(self, rand=0):
+ super(TestEvent, self).__init__(TestEvent.TestEventType)
+ self._rand = rand
+
+ def getRand(self):
+ return self._rand
+
+
+class TestEnums(unittest.TestCase):
+ def testUserTypesValues(self):
+ self.assertTrue(QEvent.User <= int(TestEvent.TestEventType) <= QEvent.MaxUser)
+ self.assertTrue(QEvent.User <= int(TEST_EVENT_TYPE) <= QEvent.MaxUser)
+
+ def testUserTypesRepr(self):
+ self.assertEqual(eval(repr(TestEvent.TestEventType)), TestEvent.TestEventType)
+ self.assertEqual(eval(repr(TEST_EVENT_TYPE)), TEST_EVENT_TYPE)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_829.py b/sources/pyside2/tests/QtCore/bug_829.py
new file mode 100644
index 000000000..5b14f7b59
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_829.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Copyright (C) 2011 Thomas Perl <thp.io/about>
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# Test case for PySide bug 829
+
+import unittest
+from PySide2.QtCore import QSettings
+import tempfile
+
+class QVariantConversions(unittest.TestCase):
+ def testDictionary(self):
+ confFile = tempfile.NamedTemporaryFile(delete=False)
+ s = QSettings(confFile.name, QSettings.IniFormat)
+ # Save value
+ s.setValue('x', {1: 'a'})
+ s.sync()
+ del s
+
+ # Restore value
+ s = QSettings(confFile.name, QSettings.IniFormat)
+ self.assertEqual(s.value('x'), {1: 'a'})
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_835.py b/sources/pyside2/tests/QtCore/bug_835.py
new file mode 100644
index 000000000..05918b9b6
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_835.py
@@ -0,0 +1,93 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+
+import unittest
+
+get_counter = 0
+set_counter = 0
+
+class Descriptor(object):
+ def __get__(self, obj, owner):
+ global get_counter
+
+ if not obj:
+ return self
+
+ get_counter += 1
+ return obj.var
+
+ def __set__(self, obj, value):
+ global set_counter
+
+ set_counter += 1
+ obj.var = value
+
+class FooBar(QObject):
+ test = Descriptor()
+ var = 0
+
+class SetAndGetTestCases(unittest.TestCase):
+ def setUp(self):
+ global get_counter
+ global set_counter
+
+ get_counter = 0
+ set_counter = 0
+
+ def testSetMethod(self):
+ global get_counter
+ global set_counter
+
+ f = FooBar()
+
+ f.test = 1
+ self.assertEqual(get_counter, 0)
+ self.assertEqual(set_counter, 1)
+
+ get_counter = 0
+ set_counter = 0
+
+ def testGetMethod(self):
+ global get_counter
+ global set_counter
+
+ f = FooBar()
+ f.test = 1
+ set_counter = 0
+
+ ret = f.test
+ self.assertEqual(get_counter, 1)
+ self.assertEqual(set_counter, 0)
+
+ get_counter = 0
+ set_counter = 0
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_920.py b/sources/pyside2/tests/QtCore/bug_920.py
new file mode 100644
index 000000000..7ffaafc0d
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_920.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import unittest
+import PySide2.QtCore as QtCore
+
+class Signaller(QtCore.QObject):
+ s1 = QtCore.Signal()
+ s2 = QtCore.Signal()
+
+class TestBug920(unittest.TestCase):
+
+ def testIt(self):
+ s = Signaller()
+ s.s1.connect(self.onSignal)
+ s.s2.connect(self.onSignal)
+ self.assertTrue(s.s1.disconnect(self.onSignal))
+ self.assertTrue(s.s2.disconnect(self.onSignal))
+
+ def onSignal(self):
+ pass
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_927.py b/sources/pyside2/tests/QtCore/bug_927.py
new file mode 100644
index 000000000..98126cf2c
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_927.py
@@ -0,0 +1,52 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import time
+import unittest
+
+from PySide2.QtCore import QTime, QRunnable, QThreadPool
+
+class Task(QRunnable):
+ def run(self):
+ t = QTime()
+ t.start()
+ time.sleep(2) # Sleep 2 seconds
+
+
+class QThreadPoolTest(unittest.TestCase):
+ '''This used to cause a segfault due the ownership control on globalInstance function '''
+ def testSlowJobs(self):
+ for i in range(3):
+ task = Task()
+ QThreadPool.globalInstance().start(task)
+ time.sleep(1) # Sleep 1 second
+
+ QThreadPool.globalInstance().waitForDone()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_931.py b/sources/pyside2/tests/QtCore/bug_931.py
new file mode 100644
index 000000000..aaec4d470
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_931.py
@@ -0,0 +1,49 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject, Signal
+o = QObject()
+class MyObject(QObject):
+ s = Signal(int)
+
+class CheckSignalType(unittest.TestCase):
+ def testSignal(self):
+ self.assertTrue(isinstance(QObject.destroyed, Signal))
+ self.assertEqual(type(QObject.destroyed), Signal)
+
+ self.assertEqual(type(o.destroyed).__name__, "SignalInstance")
+ self.assertNotEqual(type(o.destroyed), Signal)
+
+ self.assertTrue(isinstance(o.destroyed, Signal))
+ self.assertTrue(isinstance(MyObject.s, Signal))
+ self.assertFalse(isinstance(int, Signal))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_938.py b/sources/pyside2/tests/QtCore/bug_938.py
new file mode 100644
index 000000000..fdab35705
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_938.py
@@ -0,0 +1,42 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+
+class TestBug938 (unittest.TestCase):
+
+ def testIt(self):
+ b = QBuffer()
+ b.open(QBuffer.WriteOnly)
+ b.write("\x0023\x005")
+ b.close()
+ self.assertEqual(b.buffer().size(), 5)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_953.py b/sources/pyside2/tests/QtCore/bug_953.py
new file mode 100644
index 000000000..03e87bb37
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_953.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+
+class Dispatcher(QObject):
+ _me = None
+
+ def __init__(self):
+ super(Dispatcher, self).__init__()
+ self._me = self
+ QTimer.singleShot(0, self._finish)
+
+ def _finish(self):
+ del self._me # It can't crash here!
+ QTimer.singleShot(10, QCoreApplication.instance().quit)
+
+if __name__ == '__main__':
+ app = QCoreApplication([])
+ Dispatcher()
+ app.exec_()
diff --git a/sources/pyside2/tests/QtCore/bug_987.py b/sources/pyside2/tests/QtCore/bug_987.py
new file mode 100644
index 000000000..73704f86c
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_987.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import QObject
+
+import unittest
+
+
+class TestBug987(unittest.TestCase):
+ def callback(self):
+ pass
+
+ def testInvalidDisconnection(self):
+ o = QObject()
+ self.assertRaises(RuntimeError, o.destroyed.disconnect, self.callback)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_994.py b/sources/pyside2/tests/QtCore/bug_994.py
new file mode 100644
index 000000000..27171bb50
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_994.py
@@ -0,0 +1,54 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import py3kcompat as py3k
+from PySide2.QtCore import QIODevice, QTextStream
+
+
+class MyIODevice (QIODevice):
+ def readData(self, amount):
+ return py3k.b("\0a" * int(amount/2))
+
+ def readLineData(self, maxSize):
+ return py3k.b("\0b" * 4)
+
+ def atEnd(self):
+ return False
+
+class TestBug944 (unittest.TestCase):
+
+ def testIt(self):
+ device = MyIODevice()
+ device.open(QIODevice.ReadOnly)
+ s = QTextStream(device)
+ self.assertEqual(s.read(4), "\0a\0a")
+ self.assertEqual(device.readLine(), "\0b\0b\0b\0b")
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_PYSIDE-164.py b/sources/pyside2/tests/QtCore/bug_PYSIDE-164.py
new file mode 100644
index 000000000..8d13b8cb2
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_PYSIDE-164.py
@@ -0,0 +1,69 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import unittest
+
+from PySide2.QtCore import QCoreApplication, QEventLoop, QObject, Qt, QThread, QTimer, SIGNAL
+
+class Emitter(QThread):
+ def __init__(self):
+ QThread.__init__(self)
+
+ def run(self):
+ print("Before emit.")
+ self.emit(SIGNAL("signal(int)"), 0)
+ print("After emit.")
+
+class Receiver(QObject):
+ def __init__(self, eventloop):
+ QObject.__init__(self)
+ self.eventloop = eventloop
+
+ def receive(self, number):
+ print("Received number: %d" % number)
+ self.eventloop.exit(0)
+
+
+class TestBugPYSIDE164(unittest.TestCase):
+
+ def testBlockingSignal(self):
+ app = QCoreApplication.instance() or QCoreApplication([])
+ eventloop = QEventLoop()
+ emitter = Emitter()
+ receiver = Receiver(eventloop)
+ emitter.connect(emitter, SIGNAL("signal(int)"),
+ receiver.receive, Qt.BlockingQueuedConnection)
+ emitter.start()
+ retval = eventloop.exec_()
+ emitter.wait(2000)
+ self.assertEqual(retval, 0)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/bug_PYSIDE-42.py b/sources/pyside2/tests/QtCore/bug_PYSIDE-42.py
new file mode 100644
index 000000000..15b6fead8
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/bug_PYSIDE-42.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+import unittest
+
+class TestBugPYSIDE42 (unittest.TestCase):
+
+ def testIt(self):
+ obj1 = QFile()
+ obj2 = QObject()
+ hash1 = hash(obj1)
+ hash2 = hash(obj2)
+
+ self.assertNotEqual(hash1, hash2)
+ self.assertEqual(hash1, hash(obj1))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/child_event_test.py b/sources/pyside2/tests/QtCore/child_event_test.py
new file mode 100644
index 000000000..6b0ac211c
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/child_event_test.py
@@ -0,0 +1,81 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for QObject.childEvent and QTimer.childEvent overloading'''
+
+import unittest
+from time import sleep
+from PySide2.QtCore import QObject, QTimer, QCoreApplication
+
+from helper import UsesQCoreApplication
+
+class ExtQObject(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+ self.child_event_received = False
+
+ def childEvent(self, event):
+ QObject.childEvent(self, event)
+ self.child_event_received = True
+
+class ExtQTimer(QTimer):
+ def __init__(self):
+ QTimer.__init__(self)
+ self.child_event_received = False
+
+ def childEvent(self, event):
+ QTimer.childEvent(self, event)
+ self.child_event_received = True
+
+
+class TestChildEvent(UsesQCoreApplication):
+ '''Test case for QObject::childEvent and QTimer::childEvent'''
+
+ def setUp(self):
+ UsesQCoreApplication.setUp(self)
+
+ def tearDown(self):
+ UsesQCoreApplication.tearDown(self)
+
+ def testQObject(self):
+ parent = ExtQObject()
+ child = QObject()
+ child.setParent(parent)
+ self.assertTrue(parent.child_event_received)
+
+ def testQTimer(self):
+ parent = ExtQTimer()
+ child = QObject()
+ child.setParent(parent)
+ self.assertTrue(parent.child_event_received)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/classinfo_test.py b/sources/pyside2/tests/QtCore/classinfo_test.py
new file mode 100644
index 000000000..1ff67e19a
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/classinfo_test.py
@@ -0,0 +1,110 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import unittest
+
+from PySide2.QtCore import QObject, QCoreApplication, ClassInfo
+
+class TestClassInfo(unittest.TestCase):
+ def test_metadata(self):
+ @ClassInfo(author='pyside', url='http://www.pyside.org')
+ class MyObject(QObject):
+ pass
+
+ o = MyObject()
+ mo = o.metaObject()
+ self.assertEqual(mo.classInfoCount(), 2)
+
+ ci = mo.classInfo(0) #author
+ self.assertEqual(ci.name(), 'author')
+ self.assertEqual(ci.value(), 'pyside')
+
+ ci = mo.classInfo(1) #url
+ self.assertEqual(ci.name(), 'url')
+ self.assertEqual(ci.value(), 'http://www.pyside.org')
+
+ def test_verify_metadata_types(self):
+ valid_dict = { '123': '456' }
+
+ invalid_dict_1 = { '123': 456 }
+ invalid_dict_2 = { 123: 456 }
+ invalid_dict_3 = { 123: '456' }
+
+ ClassInfo(**valid_dict)
+
+ self.assertRaises(TypeError, ClassInfo, **invalid_dict_1)
+
+ # assertRaises only allows for string keywords, so a `try` must be used here.
+ try:
+ ClassInfo(**invalid_dict_2)
+ self.fail('ClassInfo() accepted invalid_dict_2!')
+ except TypeError:
+ pass
+
+ try:
+ ClassInfo(**invalid_dict_3)
+ self.fail('ClassInfo() accepted invalid_dict_3!')
+ except TypeError:
+ pass
+
+ def test_can_not_use_instance_twice(self):
+ decorator = ClassInfo(author='pyside', url='http://www.pyside.org')
+
+ @decorator
+ class MyObject1(QObject):
+ pass
+
+ class MyObject2(QObject):
+ pass
+
+ self.assertRaises(TypeError, decorator, MyObject2)
+
+ def test_can_only_be_used_on_qobjects(self):
+ def test_function(): pass
+ self.assertRaises(TypeError, ClassInfo(), test_function)
+
+ class NotAQObject(object): pass
+ self.assertRaises(TypeError, ClassInfo(), NotAQObject)
+
+ class QObjectSubclass(QObject): pass
+ ClassInfo()(QObjectSubclass)
+
+ class SubclassOfNativeQObjectSubclass(QCoreApplication): pass
+ ClassInfo()(SubclassOfNativeQObjectSubclass)
+
+ class SubclassOfPythonQObjectSubclass(QObjectSubclass): pass
+ ClassInfo()(SubclassOfPythonQObjectSubclass)
+
+if __name__ == '__main__':
+ if sys.version_info[0] < 2:
+ sys.exit(0)
+ elif (sys.version_info[0] == 2) and (sys.version_info[1] <= 5):
+ sys.exit(0)
+ else:
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/deepcopy_test.py b/sources/pyside2/tests/QtCore/deepcopy_test.py
new file mode 100644
index 000000000..9d8117449
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/deepcopy_test.py
@@ -0,0 +1,111 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from copy import deepcopy
+
+from PySide2.QtCore import QByteArray, QDate, QDateTime, QTime, QLine, QLineF
+from PySide2.QtCore import Qt, QSize, QSizeF, QRect, QRectF, QDir, QPoint, QPointF
+try:
+ from PySide2.QtCore import QUuid
+ HAVE_Q = True
+except ImportError:
+ HAVE_Q = False
+
+class DeepCopyHelper:
+ def testCopy(self):
+ copy = deepcopy([self.original])[0]
+ self.assertTrue(copy is not self.original)
+ self.assertEqual(copy, self.original)
+
+class QByteArrayDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QByteArray('the quick brown fox jumps over the lazy dog')
+
+
+class QDateDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QDate(2010, 11, 22)
+
+
+class QTimeDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QTime(11, 37, 55, 692)
+
+
+class QDateTimeDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QDateTime(2010, 5, 18, 10, 24, 45, 223, Qt.LocalTime)
+
+
+class QSizeDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QSize(42, 190)
+
+
+class QSizeFDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QSizeF(42.7, 190.2)
+
+
+class QRectDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QRect(100, 200, 300, 400)
+
+
+class QRectFDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QRectF(100.33, 200.254, 300.321, 400.123)
+
+class QLineDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QLine(1, 2, 3, 4)
+
+class QLineFDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QLineF(1.1, 2.2, 3.3, 4.4)
+
+class QPointDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QPoint(1, 2)
+
+class QPointFDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QPointF(1.1, 2.2)
+
+class QDirDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QDir("./")
+
+class QUuiCopy(DeepCopyHelper, unittest.TestCase):
+ @unittest.skipUnless(HAVE_Q, "QUuid is currently not supported on this platform.")
+ def setUp(self):
+ self.original = QUuid("67C8770B-44F1-410A-AB9A-F9B5446F13EE")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/deletelater_test.py b/sources/pyside2/tests/QtCore/deletelater_test.py
new file mode 100644
index 000000000..7a2ee03cc
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/deletelater_test.py
@@ -0,0 +1,50 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QTimer.singleShot'''
+
+import unittest
+
+from PySide2.QtCore import QObject, QTimer, QCoreApplication, SIGNAL
+from helper import UsesQCoreApplication
+
+class TestDeleteLater(UsesQCoreApplication):
+ '''Test case for function DeleteLater'''
+
+ def testCase(self):
+ o = QObject()
+ o.deleteLater()
+ del o
+ QTimer.singleShot(100, self.app.quit)
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/destroysignal_test.py b/sources/pyside2/tests/QtCore/destroysignal_test.py
new file mode 100644
index 000000000..0d48f283e
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/destroysignal_test.py
@@ -0,0 +1,55 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import QTimer, QObject
+import sys
+import unittest
+
+class TestDestroySignal(unittest.TestCase):
+ def onObjectDestroyed(self, timer):
+ self.assertTrue(isinstance(timer, QObject))
+ self._destroyed = True
+
+ def testSignal(self):
+ self._destroyed = False
+ t = QTimer()
+ t.destroyed[QObject].connect(self.onObjectDestroyed)
+ del t
+ self.assertTrue(self._destroyed)
+
+ def testWithParent(self):
+ self._destroyed = False
+ p = QTimer()
+ t = QTimer(p)
+ t.destroyed[QObject].connect(self.onObjectDestroyed)
+ del p
+ self.assertTrue(self._destroyed)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/duck_punching_test.py b/sources/pyside2/tests/QtCore/duck_punching_test.py
new file mode 100644
index 000000000..c0ee4403d
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/duck_punching_test.py
@@ -0,0 +1,102 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for duck punching new implementations of C++ virtual methods into object instances.'''
+
+import unittest
+import types
+import sys
+from PySide2.QtCore import QObject
+from helper import UsesQCoreApplication
+
+def MethodType(func, instance, instanceType):
+ if sys.version_info[0] == 3:
+ return types.MethodType(func, instance)
+ else:
+ return types.MethodType(func, instance, instanceType)
+
+class Duck(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+ def childEvent(self, event):
+ QObject.childEvent(self, event)
+
+class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication):
+ '''Test case for duck punching new implementations of C++ virtual methods into object instances.'''
+
+ def setUp(self):
+ #Acquire resources
+ self.duck_childEvent_called = False
+ UsesQCoreApplication.setUp(self)
+
+ def tearDown(self):
+ #Release resources
+ del self.duck_childEvent_called
+ UsesQCoreApplication.tearDown(self)
+
+
+ def testChildEventMonkeyPatch(self):
+ #Test if the new childEvent injected on QObject instance is called from C++
+ parent = QObject()
+ def childEvent(obj, event):
+ self.duck_childEvent_called = True
+ parent.childEvent = MethodType(childEvent, parent, QObject)
+ child = QObject()
+ child.setParent(parent)
+ self.assertTrue(self.duck_childEvent_called)
+ # This is done to decrease the refcount of the vm object
+ # allowing the object wrapper to be deleted before the
+ # BindingManager. This is useful when compiling Shiboken
+ # for debug, since the BindingManager destructor has an
+ # assert that checks if the wrapper mapper is empty.
+ parent.childEvent = None
+
+ def testChildEventMonkeyPatchWithInheritance(self):
+ #Test if the new childEvent injected on a QObject's extension class instance is called from C++
+ parent = Duck()
+ def childEvent(obj, event):
+ QObject.childEvent(obj, event)
+ self.duck_childEvent_called = True
+ child = QObject()
+ child.setParent(parent)
+ parent.childEvent = MethodType(childEvent, parent, QObject)
+ child = QObject()
+ child.setParent(parent)
+ self.assertTrue(self.duck_childEvent_called)
+ # This is done to decrease the refcount of the vm object
+ # allowing the object wrapper to be deleted before the
+ # BindingManager. This is useful when compiling Shiboken
+ # for debug, since the BindingManager destructor has an
+ # assert that checks if the wrapper mapper is empty.
+ parent.childEvent = None
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/hash_test.py b/sources/pyside2/tests/QtCore/hash_test.py
new file mode 100644
index 000000000..d1962bcf3
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/hash_test.py
@@ -0,0 +1,86 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QDate, QDateTime, QTime, QUrl
+from PySide2.QtCore import QLine, QPoint, QRect, QSize
+
+class HashTest(unittest.TestCase):
+ def testInsert(self):
+ myHash = {}
+ qdate = QDate.currentDate()
+ qdatetime = QDateTime.currentDateTime()
+ qtime = QTime.currentTime()
+ qurl = QUrl("http://www.pyside.org")
+ qpoint = QPoint(12, 42)
+
+ myHash[qdate] = "QDate"
+ myHash[qdatetime] = "QDateTime"
+ myHash[qtime] = "QTime"
+ myHash[qurl] = "QUrl"
+ myHash[qpoint] = "QPoint"
+
+ self.assertEqual(myHash[qdate], "QDate")
+ self.assertEqual(myHash[qdatetime], "QDateTime")
+ self.assertEqual(myHash[qtime], "QTime")
+ self.assertEqual(myHash[qurl], "QUrl")
+ self.assertEqual(myHash[qpoint], "QPoint")
+
+ def testQPointHash(self):
+ p1 = QPoint(12, 34)
+ p2 = QPoint(12, 34)
+ self.assertFalse(p1 is p2)
+ self.assertEqual(p1, p2)
+ self.assertEqual(hash(p1), hash(p2))
+
+ def testQSizeHash(self):
+ s1 = QSize(12, 34)
+ s2 = QSize(12, 34)
+ self.assertFalse(s1 is s2)
+ self.assertEqual(s1, s2)
+ self.assertEqual(hash(s1), hash(s2))
+
+ def testQRectHash(self):
+ r1 = QRect(12, 34, 56, 78)
+ r2 = QRect(12, 34, 56, 78)
+ self.assertFalse(r1 is r2)
+ self.assertEqual(r1, r2)
+ self.assertEqual(hash(r1), hash(r2))
+
+ def testQLineHash(self):
+ l1 = QLine(12, 34, 56, 78)
+ l2 = QLine(12, 34, 56, 78)
+ self.assertFalse(l1 is l2)
+ self.assertEqual(l1, l2)
+ self.assertEqual(hash(l1), hash(l2))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/inherits_test.py b/sources/pyside2/tests/QtCore/inherits_test.py
new file mode 100644
index 000000000..1fc620c9a
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/inherits_test.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject
+
+class MyObject(QObject):
+ pass
+
+class MainTest(unittest.TestCase):
+ def testInherits(self):
+ o = MyObject()
+ mo = o.metaObject()
+ self.assertEqual(mo.className(), 'MyObject')
+ self.assertTrue(o.inherits('MyObject'))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/max_signals.py b/sources/pyside2/tests/QtCore/max_signals.py
new file mode 100644
index 000000000..c3bb7b303
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/max_signals.py
@@ -0,0 +1,62 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL
+
+class MyObject(QObject):
+ pass
+
+
+class TestSignalLimitless(unittest.TestCase):
+ SIGNAL_MAX = 100
+ def test100DynamicSignals(self):
+
+ self.count = 0
+ def onSignal():
+ self.count += 1
+
+ #create 100 dynamic signals
+ o = MyObject()
+ for i in range(self.SIGNAL_MAX):
+ o.connect(SIGNAL('sig%d()'%i), onSignal)
+
+ #chek if the signals are valid
+ m = o.metaObject()
+ for i in range(self.SIGNAL_MAX):
+ self.assertTrue(m.indexOfSignal('sig%d()'%i) > 0)
+
+ #emit all 100 signals
+ for i in range(self.SIGNAL_MAX):
+ o.emit(SIGNAL('sig%d()'%i))
+
+ self.assertEqual(self.count, self.SIGNAL_MAX)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/missing_symbols_test.py b/sources/pyside2/tests/QtCore/missing_symbols_test.py
new file mode 100644
index 000000000..cc7b7a2b5
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/missing_symbols_test.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''(Very) Simple test case for missing names from QtCore'''
+
+import unittest
+from PySide2 import QtCore
+
+class MissingClasses(unittest.TestCase):
+
+ def testQSettings(self): # Bug 232
+ getattr(QtCore, 'QSettings')
+
+ def testQtTrNoop(self): # Bug 220
+ getattr(QtCore, 'QT_TR_NOOP')
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/mockclass_test.py b/sources/pyside2/tests/QtCore/mockclass_test.py
new file mode 100644
index 000000000..ab794b0a2
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/mockclass_test.py
@@ -0,0 +1,55 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# Test case for PySide bug 634
+# http://bugs.pyside.org/show_bug.cgi?id=634
+# Marcus Lindblom <macke@yar.nu>; 2011-02-16
+
+import unittest
+from PySide2.QtCore import QCoreApplication
+
+class Mock(object):
+ def __init__(self):
+ self.called = False
+ self.return_value = None
+
+ def __call__(self, *args, **kwargs):
+ self.called = True
+ return self.return_value
+
+
+class MockClassTest(unittest.TestCase):
+ def testMockQCoreApplication(self):
+ mock = Mock()
+ setattr(QCoreApplication, 'instance', mock)
+ QCoreApplication.instance()
+ self.assertTrue(mock.called)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/python_conversion.py b/sources/pyside2/tests/QtCore/python_conversion.py
new file mode 100644
index 000000000..4e04c1630
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/python_conversion.py
@@ -0,0 +1,93 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QLineF'''
+
+import unittest
+import datetime
+
+from PySide2.QtCore import QTime, QDateTime, QDate
+
+class TestDateTimeConversions (unittest.TestCase):
+ def testQDate(self):
+ date = datetime.date(2010, 4, 23)
+ other = QDate(date)
+ self.assertEqual(date.year, other.year())
+ self.assertEqual(date.month, other.month())
+ self.assertEqual(date.day, other.day())
+
+ self.assertEqual(date, other.toPython())
+
+ def testQTime(self):
+ time = datetime.time(11, 14, 0, 1000)
+ other = QTime(time)
+ self.assertEqual(time.hour, other.hour())
+ self.assertEqual(time.minute, other.minute())
+ self.assertEqual(time.second, other.second())
+ self.assertEqual(time.microsecond/1000, other.msec())
+
+ self.assertEqual(time, other.toPython())
+
+ def testQDateTime(self):
+ dateTime = datetime.datetime(2010, 4, 23, 11, 14, 0, 1000)
+ other = QDateTime(dateTime)
+
+ otherDate = other.date()
+ self.assertEqual(dateTime.year, otherDate.year())
+ self.assertEqual(dateTime.month, otherDate.month())
+ self.assertEqual(dateTime.day, otherDate.day())
+
+ otherTime = other.time()
+ self.assertEqual(dateTime.hour, otherTime.hour())
+ self.assertEqual(dateTime.minute, otherTime.minute())
+ self.assertEqual(dateTime.second, otherTime.second())
+ self.assertEqual(dateTime.microsecond/1000, otherTime.msec())
+
+ self.assertEqual(dateTime, other.toPython())
+
+ def testQDateTime6arg(self):
+ dateTime = datetime.datetime(2010, 4, 23, 11, 14, 7)
+ other = QDateTime(dateTime)
+
+ otherDate = other.date()
+ self.assertEqual(dateTime.year, otherDate.year())
+ self.assertEqual(dateTime.month, otherDate.month())
+ self.assertEqual(dateTime.day, otherDate.day())
+
+ otherTime = other.time()
+ self.assertEqual(dateTime.hour, otherTime.hour())
+ self.assertEqual(dateTime.minute, otherTime.minute())
+ self.assertEqual(dateTime.second, otherTime.second())
+ self.assertEqual(dateTime.microsecond/1000, otherTime.msec())
+
+ self.assertEqual(dateTime, other.toPython())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qabs_test.py b/sources/pyside2/tests/QtCore/qabs_test.py
new file mode 100644
index 000000000..8bfdf6452
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qabs_test.py
@@ -0,0 +1,48 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2 import QtCore
+
+
+class QAbsTest(unittest.TestCase):
+ '''Tests for QtCore.qAbs'''
+
+ def testBasic(self):
+ def check(x):
+ self.assertEqual(QtCore.qAbs(x), abs(x))
+
+ check(0)
+ check(-10)
+ check(10)
+ check(10.5)
+ check(-10.5)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qabstractitemmodel_test.py b/sources/pyside2/tests/QtCore/qabstractitemmodel_test.py
new file mode 100644
index 000000000..0c9da65c5
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qabstractitemmodel_test.py
@@ -0,0 +1,56 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+
+class MyModel (QAbstractListModel):
+ pass
+
+class Foo:
+ pass
+
+class TestQModelIndexInternalPointer(unittest.TestCase):
+
+ def testInternalPointer(self):
+ m = MyModel()
+ foo = Foo()
+ idx = m.createIndex(0,0, foo)
+
+ def testPassQPersistentModelIndexAsQModelIndex(self):
+ # Related to bug #716
+ m = MyModel()
+ idx = QPersistentModelIndex()
+ m.span(idx)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qabstracttransition_test.py b/sources/pyside2/tests/QtCore/qabstracttransition_test.py
new file mode 100644
index 000000000..84c6cff3c
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qabstracttransition_test.py
@@ -0,0 +1,184 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sys import getrefcount
+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/qanimationgroup_test.py b/sources/pyside2/tests/QtCore/qanimationgroup_test.py
new file mode 100644
index 000000000..85f4c27f8
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qanimationgroup_test.py
@@ -0,0 +1,53 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+
+class QAnimationGroupTest(unittest.TestCase):
+
+ def testBasic(self):
+ app = QCoreApplication([])
+
+ panim = QParallelAnimationGroup()
+ sanim = QSequentialAnimationGroup()
+ panim.addAnimation(sanim)
+
+ self.assertEqual(sanim.parent(), panim)
+
+ panim.clear()
+
+ self.assertRaises(RuntimeError, lambda :sanim.parent())
+
+ QTimer.singleShot(100, app.quit)
+ app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qbitarray_test.py b/sources/pyside2/tests/QtCore/qbitarray_test.py
new file mode 100644
index 000000000..4c165166e
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qbitarray_test.py
@@ -0,0 +1,148 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests if QBitArray class is iterable and also '~' (__invert__) and bitwise operators'''
+
+import unittest
+
+from PySide2.QtCore import QBitArray
+
+def bool_list_from_qbitarray(qbitarray):
+ '''This function is used instead of a list comprehension because
+ the QBitArray is being tested also to check if it is providing
+ the iterable protocol.
+ '''
+ qbitarray_values = []
+ for i in range(qbitarray.size()):
+ qbitarray_values.append(qbitarray.at(i))
+ return qbitarray_values
+
+class QBitArrayIsIterableTest(unittest.TestCase):
+ '''Tests if QBitArray class is iterable and also '~' (__invert__) and bitwise operators'''
+
+ def setUp(self):
+ #Acquire resources
+ self.qbitarray = QBitArray(3)
+ self.qbitarray_values = [True, False, False]
+ # WARNING: do not pythonify the following loop
+ for i in range(len(self.qbitarray_values)):
+ self.qbitarray.setBit(i, self.qbitarray_values[i])
+
+ self.inverted_qbitarray_values = [not bit for bit in self.qbitarray_values]
+
+ self.other_qbitarray = QBitArray(3)
+ self.other_qbitarray_values = [True, True, False]
+ # WARNING: do not pythonify the following loop
+ for i in range(len(self.other_qbitarray_values)):
+ self.other_qbitarray.setBit(i, self.other_qbitarray_values[i])
+
+ def tearDown(self):
+ #Release resources
+ del self.qbitarray
+ del self.other_qbitarray
+ del self.qbitarray_values
+ del self.other_qbitarray_values
+ del self.inverted_qbitarray_values
+
+ def testQBitArrayIsIterable(self):
+ #Tests if QBitArray class is iterable
+ qbitarray_is_iterable = True
+ try:
+ bitarray = [bit for bit in self.qbitarray]
+ except:
+ qbitarray_is_iterable = False
+ self.assertTrue(qbitarray_is_iterable)
+
+ def testQBitArrayInvertOperator(self):
+ #Tests QBitArray '~' (__invert__) operator
+ inverted_qbitarray = ~self.qbitarray
+ # WARNING: do not pythonify the following loop, the
+ # iterability of QBitArray class is tested in another place
+ inverted_qbitarray_values = bool_list_from_qbitarray(inverted_qbitarray)
+ self.assertEqual(self.inverted_qbitarray_values, inverted_qbitarray_values)
+
+ def testQBitArrayOrBitwiseOperator(self):
+ #Tests QBitArray '|' (or) operator
+ has_or_bitwise_operator = True
+ ored_qbitarray, ored_bool_list = None, None
+ try:
+ ored_qbitarray = self.qbitarray | self.other_qbitarray
+ ored_bool_list = [b1 | b2 for b1, b2 in zip(self.qbitarray_values, self.other_qbitarray_values)]
+ except:
+ has_or_bitwise_operator = False
+ self.assertTrue(has_or_bitwise_operator)
+ self.assertEqual(bool_list_from_qbitarray(ored_qbitarray), ored_bool_list)
+
+ def testQBitArrayAndBitwiseOperator(self):
+ #Tests QBitArray '&' (and) operator
+ has_and_bitwise_operator = True
+ anded_qbitarray, anded_bool_list = None, None
+ try:
+ anded_qbitarray = self.qbitarray | self.other_qbitarray
+ anded_bool_list = [b1 | b2 for b1, b2 in zip(self.qbitarray_values, self.other_qbitarray_values)]
+ except:
+ has_and_bitwise_operator = False
+ self.assertTrue(has_and_bitwise_operator)
+ self.assertEqual(bool_list_from_qbitarray(anded_qbitarray), anded_bool_list)
+
+ def testQBitArrayXorBitwiseOperator(self):
+ #Tests QBitArray '^' (xor) operator
+ has_xor_bitwise_operator = True
+ xored_qbitarray, xored_bool_list = None, None
+ try:
+ xored_qbitarray = self.qbitarray | self.other_qbitarray
+ xored_bool_list = [b1 | b2 for b1, b2 in zip(self.qbitarray_values, self.other_qbitarray_values)]
+ except:
+ has_xor_bitwise_operator = False
+ self.assertTrue(has_xor_bitwise_operator)
+ self.assertEqual(bool_list_from_qbitarray(xored_qbitarray), xored_bool_list)
+
+
+class QBitArrayGetItemTest(unittest.TestCase):
+ '''Test case for []/__getitem__ operator'''
+
+ def create_bitarray(self, values):
+ '''helper function to create a bit array'''
+ obj = QBitArray(len(values))
+ for i, value in enumerate(values):
+ obj.setBit(i, value)
+ return obj
+
+ def testSequenceProtocol(self):
+ '''QBitArray sequence protocol'''
+ data = [True, False, True]
+ obj = self.create_bitarray(data)
+ for reference, value in zip(data, obj):
+ self.assertEqual(reference, value)
+
+
+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
new file mode 100644
index 000000000..18e732f8c
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qbytearray_buffer_protocol_test.py
@@ -0,0 +1,53 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests QByteArray implementation of Python buffer protocol'''
+
+import unittest
+import py3kcompat as py3k
+
+from os.path import isdir
+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
new file mode 100644
index 000000000..641eeb066
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py
@@ -0,0 +1,72 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QByteArray concatenation with '+' operator'''
+
+import unittest
+
+from PySide2.QtCore import QByteArray
+
+class QByteArrayConcatenationOperatorTest(unittest.TestCase):
+ '''Test cases for QByteArray concatenation with '+' operator'''
+
+ def testConcatQByteArrayAndPythonString(self):
+ #Test concatenation of a QByteArray with a Python string, in this order
+ qba = QByteArray('foo')
+ result = qba + '\x00bar'
+ self.assertEqual(type(result), QByteArray)
+ self.assertEqual(result, 'foo\x00bar')
+
+ def testConcatPythonStringAndQByteArray(self):
+ #Test concatenation of a Python string with a QByteArray, in this order
+ concat_python_string_add_qbytearray_worked = True
+ qba = QByteArray('foo')
+ result = 'bar\x00' + qba
+ self.assertEqual(type(result), QByteArray)
+ self.assertEqual(result, 'bar\x00foo')
+
+ # NOTICE: Does not makes sense concat a unicode string with a QByteArray, because the
+ # user does not know nothing about the internal representation of the unicode string.
+ #def testConcatPythonUnicodeAndQByteArray(self):
+ ##Test concatenation of a Python unicode object with a QByteArray, in this order
+ #concat_python_unicode_add_qbytearray_worked = True
+ #qba = QByteArray('foo')
+ #result = None
+ #try:
+ #result = u'ümlaut' + qba
+ #except:
+ #concat_python_unicode_add_qbytearray_worked = False
+ #self.assertTrue(concat_python_unicode_add_qbytearray_worked)
+ #self.assertEqual(result.__class__.__name__, 'unicode')
+
+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
new file mode 100644
index 000000000..07b043df5
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py
@@ -0,0 +1,92 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QByteArray
+from helper.docmodifier import DocModifier
+
+class BaseQByteArrayOperatorIAdd(object):
+ '''Base class for QByteArray += operator tests.
+
+ Implementing classes should inherit from unittest.TestCase and implement
+ setUp, setting self.obj and self.orig_obj to the target QByteArray and original
+ one, respectively'''
+
+ __metaclass__ = DocModifier
+
+ def testSingleString(self):
+ '''QByteArray += string of size 1'''
+ s = '0'
+ 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 += string of size > 1'''
+ s = 'dummy'
+ self.obj += s
+ 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('array')
+ self.obj += s
+ self.assertEqual(self.obj, self.orig_obj + s)
+
+ def testChar(self):
+ '''QByteArray += char (number < 256)'''
+ s = ord('a')
+ self.obj += s
+ self.assertEqual(self.obj, self.orig_obj + s)
+ self.assertEqual(self.obj.size(), self.orig_obj.size() + 1)
+
+class NullQByteArrayOperatorIAdd(unittest.TestCase, BaseQByteArrayOperatorIAdd):
+ '''Test case for operator QByteArray += on null QByteArrays'''
+
+ doc_prefix = 'Null object'
+ doc_filter = lambda x: x.startswith('test')
+
+ def setUp(self):
+ self.obj = QByteArray()
+ self.orig_obj = QByteArray()
+
+
+class ValidQByteArrayOperatorIAdd(unittest.TestCase, BaseQByteArrayOperatorIAdd):
+ '''Test case for operator QByteArray += on valid QByteArrays'''
+
+ doc_prefix = 'Valid object'
+ doc_filter = lambda x: x.startswith('test')
+
+ def setUp(self):
+ self.obj = QByteArray('some byte array')
+ self.orig_obj = QByteArray('some byte array')
+
+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
new file mode 100644
index 000000000..73ba0cdb9
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qbytearray_operator_test.py
@@ -0,0 +1,116 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QByteArray operators'''
+
+import unittest
+import py3kcompat as py3k
+
+from PySide2.QtCore import QByteArray
+
+class QByteArrayOperatorEqual(unittest.TestCase):
+ '''TestCase for operator QByteArray == QByteArray'''
+
+ def testDefault(self):
+ #QByteArray() == QByteArray()
+ obj1 = QByteArray()
+ obj2 = QByteArray()
+ self.assertEqual(obj1, obj2)
+
+ def testSimple(self):
+ #QByteArray(some_string) == QByteArray(some_string)
+ string = 'egg snakes'
+ self.assertEqual(QByteArray(string), QByteArray(string))
+
+ def testPyString(self):
+ #QByteArray(string) == string
+ string = 'my test string'
+ self.assertEqual(QByteArray(string), string)
+
+ def testQString(self):
+ #QByteArray(string) == string
+ string = 'another test string'
+ self.assertEqual(QByteArray(string), string)
+
+class QByteArrayOperatorAt(unittest.TestCase):
+ '''TestCase for operator QByteArray[]'''
+
+ def testInRange(self):
+ #QByteArray[x] where x is a valid index
+ string = 'abcdefgh'
+ obj = QByteArray(string)
+
+ for i in range(len(string)):
+ self.assertEqual(obj[i], py3k.b(string[i]))
+
+ def testInRangeReverse(self):
+ #QByteArray[x] where x is a valid index (reverse order)
+ string = 'abcdefgh'
+ obj = QByteArray(string)
+
+ for i in range(len(string)-1, 0, -1):
+ self.assertEqual(obj[i], py3k.b(string[i]))
+
+
+ def testOutOfRange(self):
+ #QByteArray[x] where x is out of index
+ string = '1234567'
+ obj = QByteArray(string)
+ self.assertRaises(IndexError, lambda :obj[len(string)])
+
+ def testNullStrings(self):
+ ba = QByteArray('\x00')
+ self.assertEqual(ba.at(0), '\x00')
+ self.assertEqual(ba[0], py3k.b('\x00'))
+
+class QByteArrayOperatorLen(unittest.TestCase):
+ '''Test case for __len__ operator of QByteArray'''
+
+ def testBasic(self):
+ '''QByteArray __len__'''
+ self.assertEqual(len(QByteArray()), 0)
+ self.assertEqual(len(QByteArray('')), 0)
+ self.assertEqual(len(QByteArray(' ')), 1)
+ self.assertEqual(len(QByteArray('yabadaba')), 8)
+
+
+class QByteArrayOperatorStr(unittest.TestCase):
+ '''Test case for __str__ operator of QByteArray'''
+
+ def testBasic(self):
+ '''QByteArray __str__'''
+ self.assertEqual(QByteArray().__str__(), '')
+ self.assertEqual(QByteArray('').__str__(), '')
+ self.assertEqual(QByteArray('aaa').__str__(), 'aaa')
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qbytearray_test.py b/sources/pyside2/tests/QtCore/qbytearray_test.py
new file mode 100644
index 000000000..dce2b498c
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qbytearray_test.py
@@ -0,0 +1,194 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QByteArray'''
+
+import unittest
+import ctypes
+import pickle
+import py3kcompat as py3k
+
+from PySide2.QtCore import QByteArray, QSettings, QObject
+
+class QByteArrayTestToNumber(unittest.TestCase):
+ def testToNumberInt(self):
+ obj = QByteArray('37')
+ self.assertEqual((37, True), obj.toInt())
+
+ def testToNumberUShort(self):
+ obj = QByteArray('37')
+ self.assertEqual((37, True), obj.toUShort())
+
+ def testToNumberFloat(self):
+ obj = QByteArray('37.109')
+ self.assertEqual((ctypes.c_float(37.109).value, True),
+ obj.toFloat())
+
+ def testToNumberDouble(self):
+ obj = QByteArray('37.109')
+ self.assertEqual((ctypes.c_double(37.109).value, True),
+ obj.toDouble())
+
+ def testSetNum(self):
+ b = QByteArray()
+ b.setNum(py3k.long(-124124))
+ self.assertEqual(b, "-124124")
+ b = QByteArray()
+ b.setNum(-124124)
+ self.assertEqual(b, "-124124")
+ b = QByteArray()
+ b.setNum(-0.5)
+ self.assertEqual(b, "-0.5")
+
+ def testAppend(self):
+ b = QByteArray()
+ b.append("A")
+ self.assertEqual(b.size(), 1)
+ b.append("AB")
+ self.assertEqual(b.size(), 3)
+
+
+class QByteArraySplit(unittest.TestCase):
+ '''Test case for QByteArray.split'''
+
+ def testPathSeparator(self):
+ #QByteArray.split('/')
+ obj = QByteArray(unittest.__file__)
+ self.assertEqual(obj.split('/'), unittest.__file__.split('/'))
+
+class QByteArrayData(unittest.TestCase):
+
+ '''Test case for QByteArray.data'''
+
+ def testData(self):
+ url = QByteArray("http://web.openbossa.org/")
+ self.assertEqual(url.data(), py3k.b("http://web.openbossa.org/"))
+
+ def testDataWithZeros(self):
+ s1 = "123\000321"
+ ba = QByteArray(s1)
+ s2 = ba.data()
+ self.assertEqual(py3k.b(s1), s2)
+ self.assertEqual(s1, ba)
+
+class QByteArrayOperatorAtSetter(unittest.TestCase):
+ '''Test case for operator QByteArray[] - __setitem__'''
+
+ def testSetterString(self):
+ '''QByteArray[x] = pythonstring'''
+ obj = QByteArray('123456')
+ obj[1] = '0'
+ self.assertEqual(obj, QByteArray('103456'))
+
+ def testSetterStringLarge(self):
+ '''QByteArray[x] = pythonstring (larget than 1 char)'''
+ obj = QByteArray('123456')
+ obj[3] = 'abba'
+ self.assertEqual(obj, QByteArray('123abba56'))
+
+ def testSetterQByteArray(self):
+ '''QByteArray[x] = qbytearray'''
+ obj = QByteArray('123456')
+ obj[3] = QByteArray('array')
+ self.assertEqual(obj, QByteArray('123array56'))
+
+
+class QByteArrayOperatorAtSetterNegativeIndex(unittest.TestCase):
+ '''Test case for QByteArray[] - __setitem__ - for negative index'''
+
+ def testSetterNegativeIndex(self):
+ '''QByteArray[x] = string - negative index'''
+ obj = QByteArray('123456')
+ obj[-3] = 'array'
+ self.assertEqual(obj, QByteArray('123array56'))
+
+
+class QByteArrayOperatorAtSetterLargeIndex(unittest.TestCase):
+ '''Test case for QByteArray[] - __setitem__ - for 'overflown' index'''
+
+ def testSetterLargeIndexEmpty(self):
+ '''QByteArray[x] = somestring - Overflow index on empty string'''
+ # should pad with spaces if the index is larger
+ obj = QByteArray('')
+ obj[2] = 'a'
+ self.assertEqual(obj, QByteArray(' a'))
+
+ def testSetterLargeIndexNormal(self):
+ '''QByteArray[x] = somestring - Overflow index on normal string'''
+ # should pad with spaces if the index is larger
+ obj = QByteArray('mystring')
+ obj[10] = 'normal'
+ self.assertEqual(obj, QByteArray('mystring normal'))
+
+class QByteArrayOnQVariant(unittest.TestCase):
+ def testQByteArrayOnQVariant(self):
+ a = QSettings().value("some_prop", QByteArray())
+ self.assertEqual(type(a), QByteArray)
+
+class TestBug666(unittest.TestCase):
+ '''QByteArray does not support slices'''
+ def testIt(self):
+ if not py3k.IS_PY3K:
+ ba = QByteArray('1234567890')
+ self.assertEqual(ba[2:4], '34')
+ self.assertEqual(ba[:4], '1234')
+ self.assertEqual(ba[4:], '567890')
+ self.assertEqual(len(ba[4:1]), 0)
+
+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("321\x00123")
+ output = pickle.dumps(str(ba))
+ ba2 = pickle.loads(output)
+ self.assertEqual(ba, ba2)
+
+class QByteArrayBug720(unittest.TestCase):
+ def testIt(self):
+ ba = QByteArray(b"32\"1\x00123")
+ self.assertEqual(str(ba), "32\"1\x00123")
+ self.assertEqual(repr(ba), "PySide2.QtCore.QByteArray('32\"1\x00123')")
+
+class QByteArrayImplicitConvert(unittest.TestCase):
+ def testString(self):
+ # No implicit conversions from QByteArray to python string
+ ba = QByteArray("object name")
+ obj = QObject()
+ self.assertRaises(TypeError, obj.setObjectName, ba)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qcollator_test.py b/sources/pyside2/tests/QtCore/qcollator_test.py
new file mode 100644
index 000000000..0afb1ca8b
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qcollator_test.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QCollator'''
+
+import unittest
+import ctypes
+import sys
+
+from PySide2.QtCore import *
+
+class QCollatorTest(unittest.TestCase):
+ def testState(self):
+ c = QCollator()
+ c.setCaseSensitivity(Qt.CaseInsensitive)
+ c.setLocale(QLocale.German)
+
+ print("compare a and b:", c.compare("a", "b"))
+
+ self.assertEqual(c.caseSensitivity(), Qt.CaseInsensitive)
+ self.assertEqual(c.locale(), QLocale(QLocale.German))
+
+ c.setLocale(QLocale.French)
+ c.setNumericMode(True)
+ c.setIgnorePunctuation(True)
+ c.setLocale(QLocale.Norwegian)
+
+ self.assertEqual(c.caseSensitivity(), Qt.CaseInsensitive)
+ self.assertEqual(c.numericMode(), True)
+ self.assertEqual(c.ignorePunctuation(), True)
+ self.assertEqual(c.locale(), QLocale(QLocale.Norwegian))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qcommandlineparser_test.py b/sources/pyside2/tests/QtCore/qcommandlineparser_test.py
new file mode 100644
index 000000000..d752dfafe
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qcommandlineparser_test.py
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QCommandLineParser and QCommandLineOption'''
+
+import unittest
+import ctypes
+import sys
+
+from PySide2.QtCore import *
+
+class QCommandLineParserTest(unittest.TestCase):
+ def testParser(self):
+ app = QCoreApplication([])
+
+ parser1 = QCommandLineParser()
+ self.assertEqual(parser1.parse(["QtCore_qcommandlineparser_test", "file.txt"]), True)
+ self.assertEqual(parser1.positionalArguments(), ["file.txt"])
+
+ parser2 = QCommandLineParser()
+ self.assertEqual(parser2.addOption(QCommandLineOption("b")), True)
+ self.assertEqual(parser2.parse(["QtCore_qcommandlineparser_test", "-b"]), True)
+ self.assertEqual(parser2.optionNames(), ["b"])
+ self.assertEqual(parser2.isSet("b"), True)
+ self.assertEqual(parser2.values("b"), [])
+ self.assertEqual(parser2.positionalArguments(), [])
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qcoreapplication_instance_test.py b/sources/pyside2/tests/QtCore/qcoreapplication_instance_test.py
new file mode 100644
index 000000000..9be752cd8
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qcoreapplication_instance_test.py
@@ -0,0 +1,49 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QCoreApplication.instance static method'''
+
+import unittest
+
+from PySide2.QtCore import QCoreApplication
+
+class QCoreApplicationInstanceTest(unittest.TestCase):
+ '''Test cases for QCoreApplication.instance static method'''
+
+ def testQCoreApplicationInstance(self):
+ #Tests QCoreApplication.instance()
+ self.assertEqual(QCoreApplication.instance(), None)
+ app = QCoreApplication([])
+ self.assertEqual(QCoreApplication.instance(), app)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qdatastream_test.py b/sources/pyside2/tests/QtCore/qdatastream_test.py
new file mode 100644
index 000000000..309d55208
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qdatastream_test.py
@@ -0,0 +1,355 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QDataStream'''
+
+import unittest
+import py3kcompat as py3k
+
+from PySide2.QtCore import QBitArray, QByteArray, QIODevice, QDataStream, QDate, QTime, QDateTime
+
+def create_bitarray(string):
+ array = QBitArray(len(string))
+ for i, char in enumerate(string):
+ array.setBit(i, char != '0')
+ return array
+
+class QDataStreamWrite(unittest.TestCase):
+ '''Test case for QDatastream write* functions'''
+
+ def setUp(self):
+ self.ba = QByteArray()
+ self.read = QDataStream(self.ba, QIODevice.ReadOnly)
+ self.write = QDataStream(self.ba, QIODevice.WriteOnly)
+
+ def testWriteUInt8(self):
+ '''QDataStream.writeUInt8 (accepting str of size 1)'''
+ x = 0xFF
+ self.write.writeUInt8(x)
+ y = self.read.readUInt8()
+ self.assertEqual(x, y)
+
+ self.assertRaises(TypeError, self.write.writeUInt8, 'aaaaa')
+
+ def testWriteInt8(self):
+ '''QDataStream.writeInt8 (accepting str of size 1)'''
+ x = 65
+ self.write.writeInt8(chr(x))
+ y = self.read.readInt8()
+ self.assertEqual(x, y)
+
+ self.assertRaises(TypeError, self.write.writeInt8, 'aaaaa')
+
+ def testWriteUInt8Int(self):
+ '''QDataStream.writeUInt8 (accepting integer)'''
+ x = 0xFF
+ self.write.writeUInt8(x)
+ y = self.read.readUInt8()
+ self.assertEqual(x, y)
+
+ def testWriteInt8Int(self):
+ '''QDataStream.writeInt8 (accepting integer)'''
+ x = 65
+ self.write.writeInt8(x)
+ y = self.read.readInt8()
+ self.assertEqual(x, y)
+
+ def testWriteUInt16(self):
+ '''QDataStream.writeUInt16'''
+ x = 0x4423
+ self.write.writeUInt16(x)
+ y = int(self.read.readUInt16())
+ self.assertEqual(x, y)
+
+ def testWriteUInt32(self):
+ '''QDataStream.writeUInt32'''
+ x = 0xdeadbeef
+ self.write.writeUInt32(x)
+ y = int(self.read.readUInt32())
+ self.assertEqual(x, y)
+
+class QDataStreamShift(unittest.TestCase):
+ '''Test case for << and >> operators'''
+
+ def setUp(self):
+ self.ba = QByteArray()
+ self.stream = QDataStream(self.ba, QIODevice.WriteOnly)
+ self.read_stream = QDataStream(self.ba, QIODevice.ReadOnly)
+
+ def testQCharValid(self):
+ '''QDataStream <<>> QChar - valid'''
+ self.stream.writeQChar(42)
+
+ res = self.read_stream.readQChar()
+ self.assertEqual(res, py3k.unichr(42))
+
+ def testQCharNull(self):
+ '''QDataStream <<>> QChar - null'''
+ self.stream.writeQChar(None)
+
+ res = self.read_stream.readQChar()
+ self.assertEqual(res, py3k.unicode_('\x00'))
+
+ def testQByteArrayValid(self):
+ '''QDataStream <<>> QByteArray - valid'''
+ self.stream << QByteArray("hello")
+
+ res = QByteArray()
+
+ self.read_stream >> res
+ self.assertEqual(res, QByteArray("hello"))
+
+ def testQByteArrayEmpty(self):
+ '''QDataStream <<>> QByteArray - empty'''
+ self.stream << QByteArray("")
+
+ res = QByteArray()
+
+ self.read_stream >> res
+ self.assertEqual(res, QByteArray(""))
+ self.assertTrue(res.isEmpty())
+ self.assertFalse(res.isNull())
+
+ def testQByteArrayNull(self):
+ '''QDataStream <<>> QByteArray - null'''
+ self.stream << QByteArray()
+
+ res = QByteArray()
+
+ self.read_stream >> res
+ self.assertEqual(res, QByteArray())
+ self.assertTrue(res.isEmpty())
+ self.assertTrue(res.isNull())
+
+ def testQStringValid(self):
+ '''QDataStream <<>> QString - valid'''
+ self.stream.writeQString('Ka-boom')
+
+ res = self.read_stream.readQString()
+ self.assertEqual(res, py3k.unicode_('Ka-boom'))
+
+ def testQStringEmpty(self):
+ '''QDataStream <<>> QString - empty'''
+ self.stream.writeQString('')
+
+ res = self.read_stream.readQString()
+ self.assertEqual(res, py3k.unicode_(''))
+
+ def testQStringNull(self):
+ '''QDataStream <<>> QString - null'''
+ self.stream.writeQString(None)
+
+ res = self.read_stream.readQString()
+ self.assertEqual(res, py3k.unicode_(''))
+
+ def testQBitArrayNull(self):
+ '''QDataStream <<>> QBitArray - null'''
+ self.stream << QBitArray()
+
+ res = QBitArray()
+
+ self.read_stream >> res
+ self.assertEqual(res, QBitArray())
+
+ def testQBitArrayValid(self):
+ '''QDataStream <<>> QBitArray - valid'''
+ self.stream << create_bitarray('01010101')
+
+ res = QBitArray()
+
+ self.read_stream >> res
+ self.assertEqual(res, create_bitarray('01010101'))
+
+ def testQDateNull(self):
+ '''QDataStream <<>> QDate - null'''
+ self.stream << QDate()
+
+ res = QDate()
+
+ self.read_stream >> res
+ self.assertEqual(res, QDate())
+ self.assertFalse(res.isValid())
+ self.assertTrue(res.isNull())
+
+ def testQDateValid(self):
+ '''QDataStream <<>> QDate - valid'''
+ self.stream << QDate(2012, 12, 21)
+
+ res = QDate()
+
+ self.read_stream >> res
+ self.assertEqual(res, QDate(2012, 12, 21))
+ self.assertTrue(res.isValid())
+ self.assertFalse(res.isNull())
+
+
+ def testQTimeNull(self):
+ '''QDataStream <<>> QTime - null'''
+ self.stream << QTime()
+
+ res = QTime()
+
+ self.read_stream >> res
+ self.assertEqual(res, QTime())
+ self.assertFalse(res.isValid())
+ self.assertTrue(res.isNull())
+
+ def testQTimeValid(self):
+ '''QDataStream <<>> QTime - valid'''
+ self.stream << QTime(12, 12, 21)
+
+ res = QTime()
+
+ self.read_stream >> res
+ self.assertEqual(res, QTime(12, 12, 21))
+ self.assertTrue(res.isValid())
+ self.assertFalse(res.isNull())
+
+ def testQDateTimeNull(self):
+ '''QDataStream <<>> QDateTime - null'''
+
+ self.stream << QDateTime()
+
+ res = QDateTime()
+
+ self.read_stream >> res
+ self.assertEqual(res, QDateTime())
+ self.assertFalse(res.isValid())
+ self.assertTrue(res.isNull())
+
+ def testQDateTimeValid(self):
+ '''QDataStream <<>> QDateTime - valid'''
+ time = QTime(23, 23, 23)
+ date = QDate(2009, 1, 1)
+
+ self.stream << QDateTime(date, time)
+
+ res = QDateTime()
+
+ self.read_stream >> res
+ self.assertEqual(res, QDateTime(date, time))
+ self.assertTrue(res.isValid())
+ self.assertFalse(res.isNull())
+
+
+class QDataStreamShiftBitArray(unittest.TestCase):
+
+ def _check_bitarray(self, data_set):
+ '''Check the >> operator for the given data set'''
+
+ for data, expectedStatus, expectedString in data_set:
+ stream = QDataStream(data, QIODevice.ReadOnly)
+ string = QBitArray()
+ stream >> string
+
+ self.assertEqual(stream.status(), expectedStatus)
+ self.assertEqual(string.size(), expectedString.size())
+ self.assertEqual(string, expectedString)
+
+ def testOk(self):
+ '''QDataStream with valid QBitArray'''
+ data = []
+
+ data.append((QByteArray('\x00\x00\x00\x00'), QDataStream.Ok,
+ QBitArray()))
+ data.append((QByteArray('\x00\x00\x00\x01\x00'), QDataStream.Ok,
+ create_bitarray('0')))
+ data.append((QByteArray('\x00\x00\x00\x01\x01'), QDataStream.Ok,
+ create_bitarray('1')))
+ data.append((QByteArray('\x00\x00\x00\x02\x03'), QDataStream.Ok,
+ create_bitarray('11')))
+ data.append((QByteArray('\x00\x00\x00\x03\x07'), QDataStream.Ok,
+ create_bitarray('111')))
+ data.append((QByteArray('\x00\x00\x00\x04\x0f'), QDataStream.Ok,
+ create_bitarray('1111')))
+ data.append((QByteArray('\x00\x00\x00\x05\x1f'), QDataStream.Ok,
+ create_bitarray('11111')))
+ data.append((QByteArray('\x00\x00\x00\x06\x3f'), QDataStream.Ok,
+ create_bitarray('111111')))
+ data.append((QByteArray('\x00\x00\x00\x07\x7f'), QDataStream.Ok,
+ create_bitarray('1111111')))
+ data.append((QByteArray('\x00\x00\x00\x07\x7e'), QDataStream.Ok,
+ create_bitarray('0111111')))
+ data.append((QByteArray('\x00\x00\x00\x07\x00'), QDataStream.Ok,
+ create_bitarray('0000000')))
+ data.append((QByteArray('\x00\x00\x00\x07\x39'), QDataStream.Ok,
+ create_bitarray('1001110')))
+
+ self._check_bitarray(data)
+
+ def testPastEnd(self):
+ '''QDataStream >> QBitArray reading past the end of the data'''
+ data = []
+
+ data.append((QByteArray(), QDataStream.ReadPastEnd,
+ QBitArray()))
+ data.append((QByteArray('\x00'), QDataStream.ReadPastEnd,
+ QBitArray()))
+ data.append((QByteArray('\x00\x00'), QDataStream.ReadPastEnd,
+ QBitArray()))
+ data.append((QByteArray('\x00\x00\x00'), QDataStream.ReadPastEnd,
+ QBitArray()))
+ data.append((QByteArray('\x00\x00\x00\x01'), QDataStream.ReadPastEnd,
+ QBitArray()))
+ data.append((QByteArray('\x00\x00\x00\x02'), QDataStream.ReadPastEnd,
+ QBitArray()))
+ data.append((QByteArray('\x00\x00\x00\x03'), QDataStream.ReadPastEnd,
+ QBitArray()))
+ data.append((QByteArray('\x00\x00\x00\x04'), QDataStream.ReadPastEnd,
+ QBitArray()))
+
+ self._check_bitarray(data)
+
+ def testCorruptData(self):
+ '''QDataStream reading corrupt data'''
+ data = []
+
+ data.append((QByteArray('\x00\x00\x00\x01\x02'),
+ QDataStream.ReadCorruptData,
+ QBitArray()))
+
+ self._check_bitarray(data)
+
+class QDataStreamRawData(unittest.TestCase):
+ def testRawData(self):
+ data = QDataStream()
+ self.assertEqual(data.readRawData(4), None)
+
+ ba = QByteArray()
+ data = QDataStream(ba, QIODevice.WriteOnly)
+ data.writeRawData('AB\x00C')
+ self.assertEqual(ba.data(), py3k.b('AB\x00C'))
+
+ data = QDataStream(ba)
+ self.assertEqual(data.readRawData(4), py3k.b('AB\x00C'))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qdate_test.py b/sources/pyside2/tests/QtCore/qdate_test.py
new file mode 100644
index 000000000..9554e41e0
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qdate_test.py
@@ -0,0 +1,62 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QDate'''
+
+import unittest
+
+from PySide2.QtCore import *
+
+class TestQDate (unittest.TestCase):
+ def testGetDate(self):
+ date = QDate(2009, 22, 9)
+ tuple_ = date.getDate()
+ self.assertEqual(tuple, tuple_.__class__)
+ (y, m, d) = tuple_
+ self.assertEqual(date.year(), y)
+ self.assertEqual(date.month(), m)
+ self.assertEqual(date.day(), d)
+
+ def testGetWeekNumber(self):
+ date = QDate(2000, 1, 1)
+ tuple_ = date.weekNumber()
+ self.assertEqual(tuple, tuple_.__class__)
+ (week, yearNumber) = tuple_
+ self.assertEqual(week, 52)
+ self.assertEqual(yearNumber, 1999)
+
+ def testBooleanCast(self):
+ today = QDate.currentDate()
+ self.assertTrue(today)
+ nodate = QDate()
+ self.assertFalse(nodate)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qdatetime_test.py b/sources/pyside2/tests/QtCore/qdatetime_test.py
new file mode 100644
index 000000000..6df6edf70
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qdatetime_test.py
@@ -0,0 +1,51 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import datetime
+
+from PySide2.QtCore import QDateTime, QDate, QTime
+
+class TestQDate (unittest.TestCase):
+ def testDateConversion(self):
+ dateTime = QDateTime(QDate(2011, 5, 17), QTime(11, 1, 14, 15))
+ dateTimePy = QDateTime(datetime.date(2011, 5, 17), datetime.time(11, 1, 14, 15000))
+ self.assertEqual(dateTime, dateTimePy)
+
+ def testDateTimeConversion(self):
+ dateTime = QDateTime(QDate(2011, 5, 17), QTime(11, 1, 14, 15))
+ dateTimePy = QDateTime(datetime.datetime(2011, 5, 17, 11, 1, 14, 15000))
+ self.assertEqual(dateTime, dateTimePy)
+
+ def testDateTimeNow(self):
+ py = datetime.datetime.now()
+ qt = QDateTime(py)
+ self.assertEqual(qt, py)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qeasingcurve_test.py b/sources/pyside2/tests/QtCore/qeasingcurve_test.py
new file mode 100644
index 000000000..e6d8683b3
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qeasingcurve_test.py
@@ -0,0 +1,54 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QEasingCurve
+
+def myFunction(progress):
+ if progress == 1.0:
+ return 100.0
+ else:
+ return -100.0
+
+class TestQEasingCurve(unittest.TestCase):
+ def testCustomType(self):
+ ec = QEasingCurve()
+ ec.setCustomType(myFunction)
+ self.assertEqual(ec.valueForProgress(1.0), 100.0)
+ self.assertEqual(ec.valueForProgress(0.5), -100.0)
+
+ def testObjectCleanup(self):
+ for i in range(100):
+ ec = QEasingCurve()
+ ec.setCustomType(myFunction)
+ self.assertEqual(ec.valueForProgress(1.0), 100.0)
+ self.assertEqual(ec.valueForProgress(0.5), -100.0)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qenum_test.py b/sources/pyside2/tests/QtCore/qenum_test.py
new file mode 100644
index 000000000..c0c734278
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qenum_test.py
@@ -0,0 +1,74 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QEnum and QFlags'''
+
+import unittest
+
+from PySide2.QtCore import *
+
+class TestEnum(unittest.TestCase):
+
+ def testToInt(self):
+ self.assertEqual(QIODevice.NotOpen, 0)
+ self.assertEqual(QIODevice.ReadOnly, 1)
+ self.assertEqual(QIODevice.WriteOnly, 2)
+ self.assertEqual(QIODevice.ReadWrite, 1 | 2)
+ self.assertEqual(QIODevice.Append, 4)
+ self.assertEqual(QIODevice.Truncate, 8)
+ self.assertEqual(QIODevice.Text, 16)
+ self.assertEqual(QIODevice.Unbuffered, 32)
+
+ def testToIntInFunction(self):
+ self.assertEqual(str(int(QIODevice.WriteOnly)), "2")
+
+class TestQFlags(unittest.TestCase):
+ def testToItn(self):
+ om = QIODevice.NotOpen
+
+ self.assertEqual(om, QIODevice.NotOpen)
+ self.assertTrue(om == 0)
+
+ self.assertTrue(om != QIODevice.ReadOnly)
+ self.assertTrue(om != 1)
+
+ def testToIntInFunction(self):
+ om = QIODevice.WriteOnly
+ self.assertEqual(int(om), 2)
+
+ def testNonExtensibleEnums(self):
+ try:
+ om = QIODevice.OpenMode(QIODevice.WriteOnly)
+ self.assertFail()
+ except:
+ pass
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qevent_test.py b/sources/pyside2/tests/QtCore/qevent_test.py
new file mode 100644
index 000000000..f0c028f76
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qevent_test.py
@@ -0,0 +1,53 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QtCore.QEvent'''
+
+import unittest
+
+from PySide2.QtCore import QEvent
+
+class QEventTypeFlag(unittest.TestCase):
+ '''Test case for usage of QEvent.Type flags'''
+
+ def testFlagAccess(self):
+ #QEvent.Type flags usage
+
+ event = QEvent(QEvent.Timer)
+ self.assertEqual(event.type(), QEvent.Timer)
+
+ event = QEvent(QEvent.Close)
+ self.assertEqual(event.type(), QEvent.Close)
+
+ event = QEvent(QEvent.IconTextChange)
+ self.assertEqual(event.type(), QEvent.IconTextChange)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qfile_test.py b/sources/pyside2/tests/QtCore/qfile_test.py
new file mode 100644
index 000000000..b58e9b6ab
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qfile_test.py
@@ -0,0 +1,88 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+import os
+import tempfile
+import sys
+import py3kcompat as py3k
+
+from PySide2.QtCore import QDir, QFile, QIODevice, QSaveFile, QTemporaryDir
+
+class GetCharTest(unittest.TestCase):
+ '''Test case for QIODevice.getChar in QFile'''
+
+ def setUp(self):
+ '''Acquire resources'''
+ handle, self.filename = tempfile.mkstemp()
+ os.write(handle, py3k.b('a'))
+ os.close(handle)
+
+ def tearDown(self):
+ '''release resources'''
+ os.remove(self.filename)
+
+ def testBasic(self):
+ '''QFile.getChar'''
+ obj = QFile(self.filename)
+ obj.open(QIODevice.ReadOnly)
+ try:
+ self.assertEqual(obj.getChar(), (True, 'a'))
+ self.assertFalse(obj.getChar()[0])
+ finally:
+ obj.close()
+
+ def testBug721(self):
+ obj = QFile(self.filename)
+ obj.open(QIODevice.ReadOnly)
+ try:
+ memory = obj.map(0, 1)
+ self.assertEqual(len(memory), 1)
+ if sys.version_info[0] >= 3:
+ self.assertEqual(memory[0], ord('a'))
+ else:
+ self.assertEqual(memory[0], py3k.b('a'))
+ # now memory points to wild bytes... :-)
+ # uncommenting this must cause a segfault.
+ # self.assertEqual(memory[0], 'a')
+ finally:
+ obj.unmap(memory)
+ obj.close()
+
+ def testQSaveFile(self):
+ dir = QTemporaryDir(QDir.tempPath() + "/XXXXXX.dir")
+ self.assertTrue(dir.isValid())
+ saveFile = QSaveFile(dir.path() + "/test.dat")
+ self.assertTrue(saveFile.open(QIODevice.WriteOnly))
+ saveFile.write("Test")
+ self.assertTrue(saveFile.commit())
+ self.assertTrue(os.path.exists(QDir.toNativeSeparators(saveFile.fileName())))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qfileinfo_test.py b/sources/pyside2/tests/QtCore/qfileinfo_test.py
new file mode 100644
index 000000000..9d06aa955
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qfileinfo_test.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+import os
+import tempfile
+
+from PySide2.QtCore import QFile, QFileInfo
+
+class QFileConstructor(unittest.TestCase):
+ '''QFileInfo constructor with qfile'''
+
+ def testBasic(self):
+ '''QFileInfo(QFile)'''
+ obj = QFileInfo(QFile())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qflags_test.py b/sources/pyside2/tests/QtCore/qflags_test.py
new file mode 100644
index 000000000..571e85a7f
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qflags_test.py
@@ -0,0 +1,121 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QFlags'''
+
+import unittest
+from PySide2.QtCore import Qt, QTemporaryFile, QFile, QIODevice, QObject
+
+class QFlagTest(unittest.TestCase):
+ '''Test case for usage of flags'''
+
+ def testCallFunction(self):
+ f = QTemporaryFile()
+ self.assertTrue(f.open())
+ fileName = f.fileName()
+ f.close()
+
+ f = QFile(fileName)
+ self.assertEqual(f.open(QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite), True)
+ om = f.openMode()
+ self.assertEqual(om & QIODevice.Truncate, QIODevice.Truncate)
+ self.assertEqual(om & QIODevice.Text, QIODevice.Text)
+ self.assertEqual(om & QIODevice.ReadWrite, QIODevice.ReadWrite)
+ self.assertTrue(om == QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite)
+ f.close()
+
+
+class QFlagOperatorTest(unittest.TestCase):
+ '''Test case for operators in QFlags'''
+
+ def testInvert(self):
+ '''QFlags ~ (invert) operator'''
+ self.assertEqual(type(~QIODevice.ReadOnly), QIODevice.OpenMode)
+
+ def testOr(self):
+ '''QFlags | (or) operator'''
+ self.assertEqual(type(QIODevice.ReadOnly | QIODevice.WriteOnly), QIODevice.OpenMode)
+
+ def testAnd(self):
+ '''QFlags & (and) operator'''
+ self.assertEqual(type(QIODevice.ReadOnly & QIODevice.WriteOnly), QIODevice.OpenMode)
+
+ def testIOr(self):
+ '''QFlags |= (ior) operator'''
+ flag = Qt.WindowFlags()
+ self.assertTrue(Qt.Widget == 0)
+ self.assertFalse(flag & Qt.Widget)
+ result = flag & Qt.Widget
+ self.assertTrue(result == 0)
+ flag |= Qt.WindowMinimizeButtonHint
+ self.assertTrue(flag & Qt.WindowMinimizeButtonHint)
+
+ def testInvertOr(self):
+ '''QFlags ~ (invert) operator over the result of an | (or) operator'''
+ self.assertEqual(type(~(Qt.ItemIsSelectable | Qt.ItemIsEditable)), Qt.ItemFlags)
+
+ def testEqual(self):
+ '''QFlags == operator'''
+ flags = Qt.Window
+ flags |= Qt.WindowMinimizeButtonHint
+ flag_type = (flags & Qt.WindowType_Mask)
+ self.assertEqual(flag_type, Qt.Window)
+
+ self.assertEqual(Qt.KeyboardModifiers(Qt.ControlModifier), Qt.ControlModifier)
+
+ def testOperatorBetweenFlags(self):
+ '''QFlags & QFlags'''
+ flags = Qt.NoItemFlags | Qt.ItemIsUserCheckable
+ newflags = Qt.NoItemFlags | Qt.ItemIsUserCheckable
+ self.assertTrue(flags & newflags)
+
+ def testOperatorDifferentOrder(self):
+ '''Different ordering of arguments'''
+ flags = Qt.NoItemFlags | Qt.ItemIsUserCheckable
+ self.assertEqual(flags | Qt.ItemIsEnabled, Qt.ItemIsEnabled | flags)
+
+class QFlagsOnQVariant(unittest.TestCase):
+ def testQFlagsOnQVariant(self):
+ o = QObject()
+ o.setProperty("foo", QIODevice.ReadOnly | QIODevice.WriteOnly)
+ self.assertEqual(type(o.property("foo")), QIODevice.OpenMode)
+
+class QFlagsWrongType(unittest.TestCase):
+ def testWrongType(self):
+ '''Wrong type passed to QFlags binary operators'''
+
+ self.assertRaises(TypeError, Qt.NoItemFlags | '43')
+ self.assertRaises(TypeError, Qt.NoItemFlags & '43')
+ self.assertRaises(TypeError, 'jabba' & Qt.NoItemFlags)
+ self.assertRaises(TypeError, 'hut' & Qt.NoItemFlags)
+ self.assertRaises(TypeError, Qt.NoItemFlags & QObject())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qhandle_test.py b/sources/pyside2/tests/QtCore/qhandle_test.py
new file mode 100644
index 000000000..8ceee3684
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qhandle_test.py
@@ -0,0 +1,45 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QEnum and QFlags'''
+
+import unittest
+
+from PySide2.QtCore import QThread, Qt
+
+class TestHANDLE(unittest.TestCase):
+ def testIntConversion(self):
+ i = 0
+ h = QThread.currentThreadId()
+ i = 0 + int(h)
+ self.assertEqual(i, int(h))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qinstallmsghandler_test.py b/sources/pyside2/tests/QtCore/qinstallmsghandler_test.py
new file mode 100644
index 000000000..d8f7bb3a5
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qinstallmsghandler_test.py
@@ -0,0 +1,80 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for qInstallMsgHandler'''
+
+import unittest
+import sys
+
+from PySide2.QtCore import *
+
+param = []
+
+def handler(msgt, ctx, msg):
+ global param
+ param = [msgt, ctx, msg.strip()]
+
+def handleruseless(msgt, ctx, msg):
+ pass
+
+class QInstallMsgHandlerTest(unittest.TestCase):
+
+ def tearDown(self):
+ # Ensure that next test will have a clear environment
+ qInstallMessageHandler(None)
+
+ def testNone(self):
+ ret = qInstallMessageHandler(None)
+ self.assertEqual(ret, None)
+
+ def testRet(self):
+ ret = qInstallMessageHandler(None)
+ self.assertEqual(ret, None)
+ refcount = sys.getrefcount(handleruseless)
+ retNone = qInstallMessageHandler(handleruseless)
+ self.assertEqual(sys.getrefcount(handleruseless), refcount + 1)
+ rethandler = qInstallMessageHandler(None)
+ self.assertEqual(rethandler, handleruseless)
+ del rethandler
+ self.assertEqual(sys.getrefcount(handleruseless), refcount)
+
+ def testHandler(self):
+ rethandler = qInstallMessageHandler(handler)
+ qDebug("Test Debug")
+ self.assertEqual(param[0], QtDebugMsg)
+ self.assertEqual(param[2], "Test Debug")
+ qWarning("Test Warning")
+ self.assertEqual(param[0], QtWarningMsg)
+ self.assertEqual(param[2], "Test Warning")
+ qCritical("Test Critical")
+ self.assertEqual(param[0], QtCriticalMsg)
+ self.assertEqual(param[2], "Test Critical")
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qlinef_test.py b/sources/pyside2/tests/QtCore/qlinef_test.py
new file mode 100644
index 000000000..1388e5aac
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qlinef_test.py
@@ -0,0 +1,49 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QLineF'''
+
+import unittest
+import os
+
+from PySide2.QtCore import *
+
+class TestQLineF (unittest.TestCase):
+ def testIntersect(self):
+ l1 = QLineF(0, 0, 1, 0)
+ l2 = QLineF(1, -1, 1, 1)
+ tuple_ = l1.intersect(l2)
+ self.assertEqual(tuple, tuple_.__class__)
+ (value, p) = tuple_
+ self.assertEqual(QLineF.BoundedIntersection, value)
+ self.assertEqual(QPointF(1, 0), p)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qlocale_test.py b/sources/pyside2/tests/QtCore/qlocale_test.py
new file mode 100644
index 000000000..63aa3293d
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qlocale_test.py
@@ -0,0 +1,69 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QLocale'''
+
+import unittest
+import ctypes
+import sys
+
+from PySide2.QtCore import QLocale
+
+class QLocaleTestToNumber(unittest.TestCase):
+ def testToNumberInt(self):
+ obj = QLocale(QLocale.C)
+ self.assertEqual((37, True), obj.toInt('37'))
+
+ def testToNumberFloat(self):
+ obj = QLocale(QLocale.C)
+ self.assertEqual((ctypes.c_float(37.109).value, True),
+ obj.toFloat('37.109'))
+
+ def testToNumberDouble(self):
+ obj = QLocale(QLocale.C)
+ self.assertEqual((ctypes.c_double(37.109).value, True),
+ obj.toDouble('37.109'))
+
+ def testToNumberShort(self):
+ obj = QLocale(QLocale.C)
+ self.assertEqual((ctypes.c_short(37).value, True),
+ obj.toShort('37'))
+
+ def testToNumberULongLong(self):
+ obj = QLocale(QLocale.C)
+ self.assertEqual((ctypes.c_ulonglong(37).value, True),
+ obj.toULongLong('37'))
+
+ def testToNumberULongLongNegative(self):
+ obj = QLocale(QLocale.C)
+ self.assertTrue(not obj.toULongLong('-37')[1])
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qmetaobject_test.py b/sources/pyside2/tests/QtCore/qmetaobject_test.py
new file mode 100644
index 000000000..536fbe368
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qmetaobject_test.py
@@ -0,0 +1,84 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests for static methos conflicts with class methods'''
+
+import unittest
+
+from PySide2.QtCore import *
+
+class Foo(QFile):
+ pass
+
+class DynObject(QObject):
+ def slot(self):
+ pass
+
+class qmetaobject_test(unittest.TestCase):
+ """
+ def test_QMetaObject(self):
+ qobj = QObject()
+ qobj_metaobj = qobj.metaObject()
+ self.assertEqual(qobj_metaobj.className(), "QObject")
+
+ obj = QFile()
+ m = obj.metaObject()
+ self.assertEqual(m.className(), "QFile")
+ self.assertNotEqual(m.methodCount(), qobj_metaobj.methodCount())
+
+ obj = Foo()
+ m = obj.metaObject()
+ self.assertEqual(m.className(), "Foo")
+ f = QFile()
+ fm = f.metaObject()
+ self.assertEqual(m.methodCount(), fm.methodCount())
+ """
+
+ def test_DynamicSlotSignal(self):
+ o = DynObject()
+ o2 = QObject()
+
+ o.connect(o2, SIGNAL("bars()"), o.slot)
+ self.assertTrue(o2.metaObject().indexOfMethod("bars()") > -1)
+ #self.assertTrue(o.metaObject().indexOfMethod("bar()") == -1)
+ #self.assertTrue(o.metaObject().indexOfMethod("slot()") > -1)
+
+ #slot_index = o.metaObject().indexOfMethod("slot()")
+
+ #o.connect(o, SIGNAL("foo()"), o2, SIGNAL("bar()"))
+ #signal_index = o.metaObject().indexOfMethod("foo()");
+
+ #self.assertTrue(slot_index != signal_index)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qmimedatabase_test.py b/sources/pyside2/tests/QtCore/qmimedatabase_test.py
new file mode 100644
index 000000000..7bd9a4586
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qmimedatabase_test.py
@@ -0,0 +1,78 @@
+#!/usr/bin/python
+
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QMimeDatabase'''
+
+import unittest
+import ctypes
+import sys
+
+from PySide2.QtCore import QMimeDatabase
+
+class QMimeDatabaseTest(unittest.TestCase):
+ def testMimeTypeForName(self):
+ db = QMimeDatabase()
+
+ s0 = db.mimeTypeForName("application/x-zerosize")
+ self.assertTrue(s0.isValid())
+ self.assertEqual(s0.name(), "application/x-zerosize")
+ self.assertEqual(s0.comment(), "empty document")
+
+ s0Again = db.mimeTypeForName("application/x-zerosize")
+ self.assertEqual(s0Again.name(), s0.name())
+
+ s1 = db.mimeTypeForName("text/plain")
+ self.assertTrue(s1.isValid())
+ self.assertEqual(s1.name(), "text/plain")
+ # print("Comment is %s" % s1.comment())
+
+ krita = db.mimeTypeForName("application/x-krita")
+ self.assertTrue(krita.isValid())
+
+ # Test <comment> parsing with application/rdf+xml which has the english comment after the other ones
+ rdf = db.mimeTypeForName("application/rdf+xml")
+ self.assertTrue(rdf.isValid())
+ self.assertEqual(rdf.name(), "application/rdf+xml")
+ self.assertEqual(rdf.comment(), "RDF file")
+
+ bzip2 = db.mimeTypeForName("application/x-bzip2")
+ self.assertTrue(bzip2.isValid())
+ self.assertEqual(bzip2.comment(), "Bzip archive")
+
+ defaultMime = db.mimeTypeForName("application/octet-stream")
+ self.assertTrue(defaultMime.isValid())
+ self.assertEqual(defaultMime.name(), "application/octet-stream")
+ self.assertTrue(defaultMime.isDefault())
+
+ doesNotExist = db.mimeTypeForName("foobar/x-doesnot-exist")
+ self.assertTrue(not doesNotExist.isValid())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qmodelindex_internalpointer_test.py b/sources/pyside2/tests/QtCore/qmodelindex_internalpointer_test.py
new file mode 100644
index 000000000..e9732e3f7
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qmodelindex_internalpointer_test.py
@@ -0,0 +1,78 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test case for QAbstractListModel.createIndex and QModelIndex.internalPointer'''
+
+import sys
+import unittest
+from PySide2.QtCore import *
+
+class MyModel (QAbstractListModel):
+ pass
+
+class TestQModelIndexInternalPointer(unittest.TestCase):
+ ''' Test case for QAbstractListModel.createIndex and QModelIndex.internalPointer'''
+
+ def setUp(self):
+ #Acquire resources
+ self.model = MyModel()
+
+ def tearDown(self):
+ #Release resources
+ del self.model
+
+ def testInternalPointer(self):
+ #Test QAbstractListModel.createIndex and
+ #QModelIndex.internalPointer with regular
+ #Python objects
+ idx = self.model.createIndex(0, 0, "Hello")
+ self.assertEqual("Hello", idx.internalPointer())
+ a = [1, 2, 3]
+ idx = self.model.createIndex(0, 0, a)
+ self.assertEqual(a, idx.internalPointer())
+
+ def testReferenceCounting(self):
+ #Test reference counting when retrieving data with
+ #QModelIndex.internalPointer
+ a = [1, 2, 3]
+ a_refcnt = sys.getrefcount(a)
+ idx = self.model.createIndex(0, 0, a)
+ ptr = idx.internalPointer()
+ self.assertEqual(sys.getrefcount(a), a_refcnt + 1)
+
+ def testIndexForDefaultDataArg(self):
+ #Test QAbstractListModel.createIndex with a default
+ #value for data argument
+ idx = self.model.createIndex(0, 0)
+ self.assertEqual(None, idx.internalPointer())
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qobject_children_segfault_test.py b/sources/pyside2/tests/QtCore/qobject_children_segfault_test.py
new file mode 100644
index 000000000..651233d86
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_children_segfault_test.py
@@ -0,0 +1,56 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for parent-child relationship'''
+
+import unittest
+
+from PySide2.QtCore import QObject, QCoreApplication
+
+class ChildrenCoreApplication(unittest.TestCase):
+ '''Test case for calling QObject.children after creating a QCoreApp'''
+
+ def testQCoreAppChildren(self):
+ #QObject.children() after creating a QCoreApplication
+ # Minimal test:
+ # 1- Create QCoreApp
+ # 2- Create parent and childrens
+ # 3- While keeping the children alive, call parent.children()
+ # 4- Delete parent
+ app = QCoreApplication([])
+ parent = QObject()
+ children = [QObject(parent) for x in range(25)]
+ # Uncomment the lines below to make the test pass
+ # del children
+ # del child2
+ del parent # XXX Segfaults here
+ self.assertTrue(True)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qobject_connect_notify_test.py b/sources/pyside2/tests/QtCore/qobject_connect_notify_test.py
new file mode 100644
index 000000000..50b748ca5
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_connect_notify_test.py
@@ -0,0 +1,104 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test case for QObject::connectNotify()'''
+
+import unittest
+from PySide2.QtCore import *
+from helper import UsesQCoreApplication
+
+def cute_slot():
+ pass
+
+class Obj(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+ self.con_notified = False
+ self.dis_notified = False
+ self.signal = ""
+
+ def connectNotify(self, signal):
+ self.con_notified = True
+ self.signal = signal
+
+ def disconnectNotify(self, signal):
+ self.dis_notified = True
+
+ def reset(self):
+ self.con_notified = False
+ self.dis_notified = False
+
+class TestQObjectConnectNotify(UsesQCoreApplication):
+ '''Test case for QObject::connectNotify'''
+ def setUp(self):
+ UsesQCoreApplication.setUp(self)
+ self.called = False
+
+ def tearDown(self):
+ UsesQCoreApplication.tearDown(self)
+
+ def testBasic(self):
+ sender = Obj()
+ receiver = QObject()
+ sender.connect(SIGNAL("destroyed()"), receiver, SLOT("deleteLater()"))
+ self.assertTrue(sender.con_notified)
+ # When connecting to a regular slot, and not a python callback function, QObject::connect
+ # will use the non-cloned method signature, so connecting to destroyed() will actually
+ # connect to destroyed(QObject*).
+ self.assertEqual(sender.signal.methodSignature(), "destroyed(QObject*)")
+ sender.disconnect(SIGNAL("destroyed()"), receiver, SLOT("deleteLater()"))
+ self.assertTrue(sender.dis_notified)
+
+ def testPySignal(self):
+ sender = Obj()
+ receiver = QObject()
+ sender.connect(SIGNAL("foo()"), receiver, SLOT("deleteLater()"))
+ self.assertTrue(sender.con_notified)
+ sender.disconnect(SIGNAL("foo()"), receiver, SLOT("deleteLater()"))
+ self.assertTrue(sender.dis_notified)
+
+ def testPySlots(self):
+ sender = Obj()
+ receiver = QObject()
+ sender.connect(SIGNAL("destroyed()"), cute_slot)
+ self.assertTrue(sender.con_notified)
+ sender.disconnect(SIGNAL("destroyed()"), cute_slot)
+ self.assertTrue(sender.dis_notified)
+
+ def testpyAll(self):
+ sender = Obj()
+ receiver = QObject()
+ sender.connect(SIGNAL("foo()"), cute_slot)
+ self.assertTrue(sender.con_notified)
+ sender.disconnect(SIGNAL("foo()"), cute_slot)
+ self.assertTrue(sender.dis_notified)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qobject_destructor.py b/sources/pyside2/tests/QtCore/qobject_destructor.py
new file mode 100644
index 000000000..f1ffcaea7
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_destructor.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import unittest
+from PySide2 import QtCore
+
+class MyObject(QtCore.QObject):
+ def __init__(self, other=None):
+ QtCore.QObject.__init__(self, None)
+ self._o = other
+
+class TestDestructor(unittest.TestCase):
+ def testReference(self):
+ o = QtCore.QObject()
+ m = MyObject(o)
+ self.assertEqual(sys.getrefcount(o), 3)
+ del m
+ self.assertEqual(sys.getrefcount(o), 2)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qobject_event_filter_test.py b/sources/pyside2/tests/QtCore/qobject_event_filter_test.py
new file mode 100644
index 000000000..f90c377e4
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_event_filter_test.py
@@ -0,0 +1,143 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QObject.eventFilter'''
+
+import unittest
+import weakref
+import sys
+
+from PySide2.QtCore import QObject, QTimerEvent
+
+from helper import UsesQCoreApplication
+
+class FilterObject(QObject):
+ '''Filter object for the basic test'''
+ def __init__(self, obj=None, event_type=None, *args):
+ #Creates a new filter object
+ QObject.__init__(self, *args)
+ self.obj = obj
+ self.event_type = event_type
+ self.events_handled = 0
+ self.events_bypassed = 0
+
+ def setTargetObject(self, obj):
+ #Sets the object that will be filtered
+ self.obj = obj
+
+ def eventFilter(self, obj, event):
+ '''Just checks if is the correct object and event type
+ incrementing counter until reaching the limit. After that it
+ stops filtering the events for the object.'''
+ if (self.obj == obj):
+ if isinstance(event, self.event_type) and self.events_handled < 5:
+ self.events_handled += 1
+ return True
+ else:
+ self.events_bypassed += 1
+ return False
+ else:
+ return QObject.eventFilter(self, obj, event)
+
+class FilteredObject(QObject):
+ '''Class that will be filtered. Quits the app after 5 timer events'''
+ def __init__(self, app, *args):
+ QObject.__init__(self, *args)
+ self.app = app
+ self.times_called = 0
+
+ def timerEvent(self, evt):
+ #Overriden method
+ self.times_called += 1
+
+ if self.times_called == 5:
+ self.app.quit()
+
+class TestQObjectEventFilterPython(UsesQCoreApplication):
+ '''QObject.eventFilter - Reimplemented in python
+ Filters 5 TimerEvents and then bypasses the other events to the
+ timerEvent method. After 5 runs, the timerEvent method will ask
+ the core application to exit'''
+ def setUp(self):
+ #Acquire resources
+ UsesQCoreApplication.setUp(self)
+ self.obj_filter = FilterObject(event_type=QTimerEvent)
+ def tearDown(self):
+ #Release resources
+ del self.obj_filter
+ UsesQCoreApplication.tearDown(self)
+
+ def testEventFilter(self):
+ #QObject.eventFilter reimplemented in python
+ filtered = FilteredObject(self.app)
+ filtered.installEventFilter(self.obj_filter)
+ self.obj_filter.setTargetObject(filtered)
+
+ filtered.startTimer(0)
+
+ self.app.exec_()
+
+ self.assertEqual(filtered.times_called, 5)
+ self.assertEqual(self.obj_filter.events_handled, 5)
+
+ def testInstallEventFilterRefCountAfterDelete(self):
+ '''Bug 910 - installEventFilter() increments reference count on target object
+ http://bugs.pyside.org/show_bug.cgi?id=910'''
+ obj = QObject()
+ filt = QObject()
+
+ self.assertEqual(sys.getrefcount(obj), 2)
+ self.assertEqual(sys.getrefcount(filt), 2)
+ obj.installEventFilter(filt)
+ self.assertEqual(sys.getrefcount(obj), 2)
+ self.assertEqual(sys.getrefcount(filt), 2)
+
+ wref = weakref.ref(obj)
+ del obj
+ self.assertEqual(wref(), None)
+
+ def testInstallEventFilterRefCountAfterRemove(self):
+ # Bug 910
+ obj = QObject()
+ filt = QObject()
+
+ self.assertEqual(sys.getrefcount(obj), 2)
+ self.assertEqual(sys.getrefcount(filt), 2)
+ obj.installEventFilter(filt)
+ self.assertEqual(sys.getrefcount(obj), 2)
+ self.assertEqual(sys.getrefcount(filt), 2)
+ obj.removeEventFilter(filt)
+ self.assertEqual(sys.getrefcount(obj), 2)
+ self.assertEqual(sys.getrefcount(filt), 2)
+
+ wref = weakref.ref(obj)
+ del obj
+ self.assertEqual(wref(), None)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qobject_inherits_test.py b/sources/pyside2/tests/QtCore/qobject_inherits_test.py
new file mode 100644
index 000000000..8c4c797a4
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_inherits_test.py
@@ -0,0 +1,91 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QObject methods'''
+
+import unittest
+
+from PySide2.QtCore import QObject
+
+class InheritsCase(unittest.TestCase):
+ '''Test case for QObject.inherits'''
+
+ def testCppInheritance(self):
+ #QObject.inherits() for c++ classes
+ #An class inherits itself
+ self.assertTrue(QObject().inherits('QObject'))
+
+ def testPythonInheritance(self):
+ #QObject.inherits() for python classes
+
+ class Dummy(QObject):
+ #Dummy class
+ pass
+
+ self.assertTrue(Dummy().inherits('QObject'))
+ self.assertTrue(Dummy().inherits('Dummy'))
+ self.assertTrue(not Dummy().inherits('FooBar'))
+
+ def testPythonMultiInheritance(self):
+ #QObject.inherits() for multiple inheritance
+ # QObject.inherits(classname) should fail if classname isn't a
+ # QObject subclass
+
+ class Parent(object):
+ #Dummy parent
+ pass
+ class Dummy(QObject, Parent):
+ #Dummy class
+ pass
+
+ self.assertTrue(Dummy().inherits('QObject'))
+ self.assertTrue(not Dummy().inherits('Parent'))
+
+ def testSetAttributeBeforeCallingInitOnQObjectDerived(self):
+ '''Test for bug #428.'''
+ class DerivedObject(QObject):
+ def __init__(self):
+ self.member = 'member'
+ QObject.__init__(self)
+ obj0 = DerivedObject()
+ # The second instantiation of DerivedObject will generate an exception
+ # that will not come to surface immediately.
+ obj1 = DerivedObject()
+ # The mere calling of the object method causes
+ # the exception to "reach the surface".
+ obj1.objectName()
+
+ def testMultipleInheritance(self):
+ def declareClass():
+ class Foo(object, QObject):
+ pass
+
+ self.assertRaises(TypeError, declareClass)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qobject_objectproperty_test.py b/sources/pyside2/tests/QtCore/qobject_objectproperty_test.py
new file mode 100644
index 000000000..e1782e18c
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_objectproperty_test.py
@@ -0,0 +1,58 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for the bug #378
+http://bugs.openbossa.org/show_bug.cgi?id=378
+'''
+
+import unittest
+from PySide2.QtCore import QObject
+
+class ExtQObject(QObject):
+ def __init__(self):
+ # "foobar" will become a object attribute that will not be
+ # listed on the among the type attributes. Thus for bug
+ # condition be correctly triggered the "foobar" attribute
+ # must not previously exist in the parent class.
+ self.foobar = None
+ # The parent __init__ method must be called after the
+ # definition of "self.foobar".
+ QObject.__init__(self)
+
+class TestBug378(unittest.TestCase):
+ '''Test case for the bug #378'''
+
+ def testBug378(self):
+ obj = ExtQObject()
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qobject_parent_test.py b/sources/pyside2/tests/QtCore/qobject_parent_test.py
new file mode 100644
index 000000000..5a8c438d2
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_parent_test.py
@@ -0,0 +1,287 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for parent-child relationship'''
+
+import unittest
+from sys import getrefcount
+
+from PySide2.QtCore import *
+
+class ParentRefCountCase(unittest.TestCase):
+ '''Test case for the refcount changes of setParent'''
+
+ def setUp(self):
+ #Acquire resources
+ self.parent = QObject()
+ self.child = QObject()
+
+ def tearDown(self):
+ #Release resources
+ del self.child
+ del self.parent
+
+ def testSetParent(self):
+ #QObject.setParent() refcount changes
+ self.assertEqual(getrefcount(self.child), 2)
+ self.child.setParent(self.parent)
+ self.assertEqual(getrefcount(self.child), 3)
+
+ def testSetParentTwice(self):
+ self.assertEqual(getrefcount(self.child), 2)
+ self.child.setParent(self.parent)
+ self.assertEqual(getrefcount(self.child), 3)
+ self.child.setParent(self.parent)
+ self.assertEqual(getrefcount(self.child), 3)
+
+ def testConstructor(self):
+ #QObject(QObject) refcount changes
+ child = QObject(self.parent)
+ self.assertEqual(getrefcount(child), 3)
+
+class ParentCase(unittest.TestCase):
+ '''Small collection of tests related to parent-child relationship'''
+
+ def testSetParent(self):
+ #QObject.setParent()
+ parent = QObject()
+ child = QObject()
+ child.setParent(parent)
+
+ self.assertEqual(parent, child.parent())
+
+ def testParentConstructor(self):
+ #QObject(parent)
+ parent = QObject()
+ child = QObject(parent)
+
+ self.assertEqual(parent, child.parent())
+
+ orig_repr = repr(child)
+ del child
+ self.assertEqual(orig_repr, repr(parent.children()[0]))
+
+ def testChildren(self):
+ #QObject.children()
+ parent = QObject()
+ children = [QObject(parent) for x in range(25)]
+
+ self.assertEqual(parent.children(), children)
+
+ def testFindChild(self):
+ #QObject.findChild() with all QObject
+ parent = QObject()
+ name = 'object%d'
+ children = [QObject(parent) for i in range(20)]
+
+ for i, child in enumerate(children):
+ child.setObjectName(name % i)
+
+ for i, child in enumerate(children):
+ self.assertEqual(child, parent.findChild(QObject, name % i))
+
+ def testFindChildWithoutName(self):
+ parent = QObject()
+ name = 'object%d'
+ children = [QObject(parent) for i in range(20)]
+
+ for i, child in enumerate(children):
+ child.setObjectName(name % i)
+
+ child = parent.findChild(QObject)
+ self.assertTrue(isinstance(child, QObject))
+
+ def testFindChildren(self):
+ #QObject.findChildren() with all QObject
+ parent = QObject()
+ target_name = 'foo'
+ children = [QTimer(parent) for i in range(20)]
+ children.extend([QObject(parent) for i in range(20)])
+
+ for i, child in enumerate(children):
+ if i % 5 == 0:
+ child.setObjectName(target_name)
+ else:
+ child.setObjectName(str(i))
+
+ # Emulates findChildren with the intended outcome
+ target_children = [x for x in children if x.objectName() == target_name]
+ test_children = parent.findChildren(QObject, target_name)
+ self.assertEqual(target_children, test_children)
+
+ # test findChildren default value
+ res = parent.findChildren(QTimer)
+ self.assertEqual(len(res), 20)
+
+ # test findChildre with a regex
+ res = parent.findChildren(QObject, QRegExp("^fo+"))
+ self.assertEqual(res, test_children)
+
+
+ def testParentEquality(self):
+ #QObject.parent() == parent
+ parent = QObject()
+ child = QObject(parent)
+ self.assertEqual(parent, child.parent())
+
+
+class TestParentOwnership(unittest.TestCase):
+ '''Test case for Parent/Child object ownership'''
+
+ def testParentDestructor(self):
+ parent = QObject()
+ self.assertEqual(getrefcount(parent), 2)
+
+ child = QObject(parent)
+ self.assertEqual(getrefcount(child), 3)
+ self.assertEqual(getrefcount(parent), 2)
+
+ del parent
+ self.assertEqual(getrefcount(child), 2)
+
+ # this will fail because parent deleted child cpp object
+ self.assertRaises(RuntimeError, lambda :child.objectName())
+
+ # test parent with multiples children
+ def testMultipleChildren(self):
+ o = QObject()
+ self.assertEqual(getrefcount(o), 2)
+
+ c = QObject(o)
+ self.assertEqual(getrefcount(c), 3)
+ self.assertEqual(getrefcount(o), 2)
+
+ c2 = QObject(o)
+ self.assertEqual(getrefcount(o), 2)
+ self.assertEqual(getrefcount(c), 3)
+ self.assertEqual(getrefcount(c2), 3)
+
+ del o
+ self.assertEqual(getrefcount(c), 2)
+ self.assertEqual(getrefcount(c2), 2)
+
+ # this will fail because parent deleted child cpp object
+ self.assertRaises(RuntimeError, lambda :c.objectName())
+ self.assertRaises(RuntimeError, lambda :c2.objectName())
+
+ # test recursive parent
+ def testRecursiveParent(self):
+ o = QObject()
+ self.assertEqual(getrefcount(o), 2)
+
+ c = QObject(o)
+ self.assertEqual(getrefcount(c), 3)
+ self.assertEqual(getrefcount(o), 2)
+
+ c2 = QObject(c)
+ self.assertEqual(getrefcount(o), 2)
+ self.assertEqual(getrefcount(c), 3)
+ self.assertEqual(getrefcount(c2), 3)
+
+ del o
+ self.assertEqual(getrefcount(c), 2)
+ self.assertEqual(getrefcount(c2), 2)
+
+ # this will fail because parent deleted child cpp object
+ self.assertRaises(RuntimeError, lambda :c.objectName())
+ self.assertRaises(RuntimeError, lambda :c2.objectName())
+
+ # test parent transfer
+ def testParentTransfer(self):
+ o = QObject()
+ self.assertEqual(getrefcount(o), 2)
+
+ c = QObject()
+ self.assertEqual(getrefcount(c), 2)
+
+ c.setParent(o)
+ self.assertEqual(getrefcount(c), 3)
+
+ c.setParent(None)
+ self.assertEqual(getrefcount(c), 2)
+
+ del c
+ del o
+
+
+class ExtQObject(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+
+class ReparentingTest(unittest.TestCase):
+ '''Test cases for reparenting'''
+
+ def testParentedQObjectIdentity(self):
+ object_list = []
+ parent = QObject()
+ for i in range(3):
+ obj = QObject()
+ object_list.append(obj)
+ obj.setParent(parent)
+ for child in parent.children():
+ self.assertTrue(child in object_list)
+
+ def testParentedExtQObjectType(self):
+ object_list = []
+ parent = QObject()
+ for i in range(3):
+ obj = ExtQObject()
+ object_list.append(obj)
+ obj.setParent(parent)
+ for orig, child in zip(object_list, parent.children()):
+ self.assertEqual(type(orig), type(child))
+
+ def testReparentedQObjectIdentity(self):
+ object_list = []
+ old_parent = QObject()
+ new_parent = QObject()
+ for i in range(3):
+ obj = QObject()
+ object_list.append(obj)
+ obj.setParent(old_parent)
+ for obj in object_list:
+ obj.setParent(new_parent)
+ for child in new_parent.children():
+ self.assertTrue(child in object_list)
+
+ def testReparentedExtQObjectType(self):
+ object_list = []
+ old_parent = QObject()
+ new_parent = QObject()
+ for i in range(3):
+ obj = ExtQObject()
+ object_list.append(obj)
+ obj.setParent(old_parent)
+ for obj in object_list:
+ obj.setParent(new_parent)
+ for orig, child in zip(object_list, new_parent.children()):
+ self.assertEqual(type(orig), type(child))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qobject_property_test.py b/sources/pyside2/tests/QtCore/qobject_property_test.py
new file mode 100644
index 000000000..537a62471
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_property_test.py
@@ -0,0 +1,69 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QObject property and setProperty'''
+
+import unittest
+
+from PySide2.QtCore import QObject, Property, Signal
+
+class MyObjectWithNotifyProperty(QObject):
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+ self.p = 0
+
+ def readP(self):
+ return self.p
+
+ def writeP(self, v):
+ self.p = v
+ self.notifyP.emit()
+
+ notifyP = Signal()
+ myProperty = Property(int, readP, fset=writeP, notify=notifyP)
+
+class PropertyWithNotify(unittest.TestCase):
+ def called(self):
+ self.called_ = True
+
+ def testNotify(self):
+ self.called_ = False
+ obj = MyObjectWithNotifyProperty()
+ obj.notifyP.connect(self.called)
+ obj.myProperty = 10
+ self.assertTrue(self.called_)
+
+ def testHasProperty(self):
+ o = MyObjectWithNotifyProperty()
+ o.setProperty("myProperty", 10)
+ self.assertEqual(o.myProperty, 10)
+ self.assertEqual(o.property("myProperty"), 10)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qobject_protected_methods_test.py b/sources/pyside2/tests/QtCore/qobject_protected_methods_test.py
new file mode 100644
index 000000000..6aa68749b
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_protected_methods_test.py
@@ -0,0 +1,67 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QObject protected methods'''
+
+import unittest
+
+from PySide2.QtCore import QObject, QThread, SIGNAL
+
+class Dummy(QObject):
+ '''Dummy class'''
+ pass
+
+class QObjectReceivers(unittest.TestCase):
+ '''Test case for QObject.receivers()'''
+
+ def cb(self, *args):
+ #Dummy callback
+ pass
+
+ def testQObjectReceiversExtern(self):
+ #QObject.receivers() - Protected method external access
+
+ obj = Dummy()
+ self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 0)
+
+ QObject.connect(obj, SIGNAL("destroyed()"), self.cb)
+ self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 1)
+
+ def testQThreadReceiversExtern(self):
+ #QThread.receivers() - Inherited protected method
+
+ obj = QThread()
+ self.assertEqual(obj.receivers(SIGNAL('destroyed()')), 0)
+ QObject.connect(obj, SIGNAL("destroyed()"), self.cb)
+ self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 1)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qobject_test.py b/sources/pyside2/tests/QtCore/qobject_test.py
new file mode 100644
index 000000000..482ae78be
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_test.py
@@ -0,0 +1,72 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QObject methods'''
+
+import unittest
+import py3kcompat as py3k
+
+from PySide2.QtCore import QObject
+
+class ObjectNameCase(unittest.TestCase):
+ '''Tests related to QObject object name'''
+
+ def testSimple(self):
+ #QObject.objectName(string)
+ name = 'object1'
+ obj = QObject()
+ obj.setObjectName(name)
+
+ self.assertEqual(name, obj.objectName())
+
+ def testEmpty(self):
+ #QObject.objectName('')
+ name = ''
+ obj = QObject()
+ obj.setObjectName(name)
+
+ self.assertEqual(name, obj.objectName())
+
+ def testDefault(self):
+ #QObject.objectName() default
+ obj = QObject()
+ self.assertEqual('', obj.objectName())
+
+ def testUnicode(self):
+ name = py3k.unicode_('não')
+ #FIXME Strange error on upstream when using equal(name, obj)
+ obj = QObject()
+ obj.setObjectName(name)
+ self.assertEqual(obj.objectName(), name)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qobject_timer_event_test.py b/sources/pyside2/tests/QtCore/qobject_timer_event_test.py
new file mode 100644
index 000000000..75fb0902f
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_timer_event_test.py
@@ -0,0 +1,73 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for QObject.timerEvent overloading'''
+
+import unittest
+from time import sleep
+from PySide2.QtCore import QObject, QCoreApplication
+
+from helper import UsesQCoreApplication
+
+class Dummy(QObject):
+
+ def __init__(self, app):
+ super(Dummy, self).__init__()
+ self.times_called = 0
+ self.app = app
+
+ def timerEvent(self, event):
+ QObject.timerEvent(self, event)
+ event.accept()
+ self.times_called += 1
+
+ if self.times_called == 5:
+ self.app.exit(0)
+
+class QObjectTimerEvent(UsesQCoreApplication):
+
+ def setUp(self):
+ #Acquire resources
+ super(QObjectTimerEvent, self).setUp()
+
+ def tearDown(self):
+ #Release resources
+ super(QObjectTimerEvent, self).tearDown()
+
+ def testTimerEvent(self):
+ #QObject.timerEvent overloading
+ obj = Dummy(self.app)
+ timer_id = obj.startTimer(200)
+ self.app.exec_()
+ obj.killTimer(timer_id)
+ self.assertEqual(obj.times_called, 5)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qobject_tr_as_instance_test.py b/sources/pyside2/tests/QtCore/qobject_tr_as_instance_test.py
new file mode 100644
index 000000000..db52c1a49
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qobject_tr_as_instance_test.py
@@ -0,0 +1,67 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QObject's tr static methods.'''
+
+import os
+import unittest
+from PySide2.QtCore import QObject
+
+#from helper import UsesQCoreApplication
+
+class QObjectTrTest(unittest.TestCase):
+ '''Test case to check if QObject tr static methods could be treated as instance methods.'''
+
+ def setUp(self):
+ self.obj = QObject()
+
+ def tearDown(self):
+ del self.obj
+
+ def testTrCommonCase(self):
+ #Test common case for QObject.tr
+ invar1 = 'test1'
+ outvar1 = self.obj.tr(invar1)
+ invar2 = 'test2'
+ outvar2 = self.obj.tr(invar2, 'test comment')
+ self.assertEqual((invar1, invar2), (outvar1, outvar2))
+
+ def testTrAsInstanceMethod(self):
+ #Test QObject.tr as instance
+ invar1 = 'test1'
+ outvar1 = QObject.tr(self.obj, invar1)
+ invar2 = 'test2'
+ outvar2 = QObject.tr(self.obj, invar2, 'test comment')
+ self.assertEqual((invar1, invar2), (outvar1, outvar2))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qpoint_test.py b/sources/pyside2/tests/QtCore/qpoint_test.py
new file mode 100644
index 000000000..055a99659
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qpoint_test.py
@@ -0,0 +1,48 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QPoint and QPointF'''
+
+import unittest
+
+from PySide2.QtCore import QPoint, QPointF
+
+
+class QPointTest(unittest.TestCase):
+
+ def testQPointCtor(self):
+ point = QPoint(QPoint(10,20))
+
+class QPointFTest(unittest.TestCase):
+
+ def testQPointFCtor(self):
+ pointf = QPointF(QPoint(10,20))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qprocess_test.py b/sources/pyside2/tests/QtCore/qprocess_test.py
new file mode 100644
index 000000000..db006cae5
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qprocess_test.py
@@ -0,0 +1,58 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QProcess'''
+
+import unittest
+import os
+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))
+
+ def testPid(self):
+ p = QProcess()
+ p.start("dir")
+ p.waitForStarted()
+ pid = p.pid()
+ # We can't test the pid method result because it returns 0 when the
+ # process isn't running
+ if p.state() == QProcess.Running:
+ self.assertNotEqual(pid, 0)
+ else:
+ print("PROCESS ALREADY DEAD :-/")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qproperty_decorator.py b/sources/pyside2/tests/QtCore/qproperty_decorator.py
new file mode 100644
index 000000000..eacdecd37
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qproperty_decorator.py
@@ -0,0 +1,63 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import weakref
+import unittest
+
+from PySide2.QtCore import QObject, Property
+
+class MyObject(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+ self._value = None
+
+ @Property(int)
+ def value(self):
+ return self._value
+
+ @value.setter
+ def valueSet(self, value):
+ self._value = value
+
+
+class PropertyTest(unittest.TestCase):
+ def destroyCB(self, obj):
+ self._obDestroyed = True
+
+ def testDecorator(self):
+ self._obDestroyed = False
+ o = MyObject()
+ weak = weakref.ref(o, self.destroyCB)
+ o.value = 10
+ self.assertEqual(o._value, 10)
+ self.assertEqual(o.value, 10)
+ del o
+ self.assertTrue(self._obDestroyed)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qrect_test.py b/sources/pyside2/tests/QtCore/qrect_test.py
new file mode 100644
index 000000000..e9bc4d60d
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qrect_test.py
@@ -0,0 +1,141 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QRect'''
+
+import unittest
+
+from PySide2.QtCore import QPoint, QRect, QRectF
+
+class RectConstructor(unittest.TestCase):
+
+ def testDefault(self):
+ #QRect()
+ obj = QRect()
+
+ self.assertTrue(obj.isNull())
+
+ def testConstructorQPoint(self):
+ topLeft = QPoint(3, 0)
+ bottomRight = QPoint(0, 3)
+
+ rect1 = QRect(topLeft, bottomRight)
+ rect2 = QRect(topLeft, bottomRight)
+
+ self.assertEqual(rect1, rect2)
+
+class RectOperator(unittest.TestCase):
+ '''Test case for QRect operators'''
+
+ def testEqual(self):
+ '''QRect == QRect
+ Note: operator == must be working as it's the main check
+ for correctness'''
+ rect1 = QRect()
+ rect2 = QRect()
+ self.assertEqual(rect1, rect2)
+
+ rect1 = QRect(0, 4, 100, 300)
+ rect2 = QRect(0, 4, 100, 300)
+ self.assertEqual(rect1, rect2)
+
+ def testNullRectIntersection(self):
+ #QRect & QRect for null rects
+ rect1 = QRect()
+ rect2 = QRect()
+ rect3 = rect1 & rect2
+ self.assertEqual(rect3, rect1)
+ self.assertEqual(rect3, rect2)
+
+ def testNoIntersect(self):
+ '''QRect & QRect for non-intersecting QRects
+ Non-intersecting QRects return a 'null' QRect for operator &'''
+ rect1 = QRect(10, 10, 5, 5)
+ rect2 = QRect(20, 20, 5, 5)
+ rect3 = rect1 & rect2
+ self.assertEqual(rect3, QRect())
+
+ def testIntersectPartial(self):
+ #QRect & QRect for partial intersections
+ rect1 = QRect(10, 10, 10, 10)
+ rect2 = QRect(15, 15, 10, 10)
+ rect3 = rect1 & rect2
+ self.assertEqual(rect3, QRect(15, 15, 5, 5))
+
+ def testIntersetEnclosed(self):
+ #QRect & QRect for a qrect inside another
+ rect1 = QRect(10, 10, 20, 20)
+ rect2 = QRect(15, 15, 5, 5)
+ rect3 = rect1 & rect2
+ self.assertEqual(rect3, rect2)
+
+ def testNullRectIntersectBounding(self):
+ #QRect | QRect for null rects
+ rect1 = QRect()
+ rect2 = QRect()
+ rect3 = rect1 & rect2
+ self.assertEqual(rect3, rect1)
+ self.assertEqual(rect3, rect2)
+
+ def testNoIntersectBounding(self):
+ '''QRect | QRect for non-intersecting QRects
+ Non-intersecting QRects return a greater QRect for operator |'''
+ rect1 = QRect(10, 10, 5, 5)
+ rect2 = QRect(20, 20, 5, 5)
+ rect3 = rect1 | rect2
+ self.assertEqual(rect3, QRect(10, 10, 15, 15))
+
+ def testBoundingPartialIntersection(self):
+ #QRect | QRect for partial intersections
+ rect1 = QRect(10, 10, 10, 10)
+ rect2 = QRect(15, 15, 10, 10)
+ rect3 = rect1 | rect2
+ self.assertEqual(rect3, QRect(10, 10, 15, 15))
+
+ def testBoundingEnclosed(self):
+ #QRect | QRect for a qrect inside another
+ rect1 = QRect(10, 10, 20, 20)
+ rect2 = QRect(15, 15, 5, 5)
+ rect3 = rect1 | rect2
+ self.assertEqual(rect3, rect1)
+
+ def testGetCoordsAndRect(self):
+ rect1 = QRect(1, 2, 3, 4)
+ self.assertEqual(rect1.getRect(), (1, 2, 3, 4))
+ self.assertEqual(rect1.getCoords(), (1, 2, 3, 5))
+
+ rect1 = QRectF(1, 2, 3, 4)
+ self.assertEqual(rect1.getRect(), (1, 2, 3, 4))
+ self.assertEqual(rect1.getCoords(), (1, 2, 4, 6))
+
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qregexp_test.py b/sources/pyside2/tests/QtCore/qregexp_test.py
new file mode 100644
index 000000000..5a5db0c59
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qregexp_test.py
@@ -0,0 +1,48 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+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/qresource_test.py b/sources/pyside2/tests/QtCore/qresource_test.py
new file mode 100644
index 000000000..c7b28bfae
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qresource_test.py
@@ -0,0 +1,70 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QResource usage'''
+
+import unittest
+from helper import adjust_filename
+from PySide2.QtCore import QFile, QIODevice
+import resources_mc
+
+class ResourcesUsage(unittest.TestCase):
+ '''Test case for resources usage'''
+
+ def testPhrase(self):
+ #Test loading of quote.txt resource
+ f = open(adjust_filename('quoteEnUS.txt', __file__), "r")
+ orig = f.read()
+ f.close()
+
+ f = QFile(':/quote.txt')
+ f.open(QIODevice.ReadOnly) #|QIODevice.Text)
+ print("Error:", f.errorString())
+ copy = f.readAll()
+ f.close()
+ self.assertEqual(orig, copy)
+
+ def testImage(self):
+ #Test loading of sample.png resource
+ f = open(adjust_filename('sample.png', __file__), "rb")
+ orig = f.read()
+ f.close()
+
+ f = QFile(':/sample.png')
+ f.open(QIODevice.ReadOnly)
+ copy = f.readAll()
+ f.close()
+ self.assertEqual(len(orig), len(copy))
+ self.assertEqual(orig, copy)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qsize_test.py b/sources/pyside2/tests/QtCore/qsize_test.py
new file mode 100644
index 000000000..062232a54
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qsize_test.py
@@ -0,0 +1,55 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QSize'''
+
+import unittest
+
+from PySide2.QtCore import QSize
+
+class QSizeOperator(unittest.TestCase):
+ def testOperatorMultiply(self):
+ #QSize operator * float
+ # bug 131
+ a = QSize(1, 1)
+ x = a * 3.4
+ self.assertEqual(QSize(3, 3), x)
+
+ def testOperatorRevertedMultiply(self):
+ #QSize operator * float, reverted
+ # bug 132
+ a = QSize(1, 1)
+ x = 3.4 * a
+ self.assertEqual(QSize(3, 3), x)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qslot_object_test.py b/sources/pyside2/tests/QtCore/qslot_object_test.py
new file mode 100644
index 000000000..3fc1d9013
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qslot_object_test.py
@@ -0,0 +1,76 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2 import QtCore
+
+global qApp
+
+class objTest(QtCore.QObject):
+
+ def __init__(self, parent=None):
+ QtCore.QObject.__init__(self, parent)
+
+ self.ok = False
+
+ def slot(self):
+ global qApp
+
+ self.ok = True
+ qApp.quit()
+
+
+
+class slotTest(unittest.TestCase):
+ def quit_app(self):
+ global qApp
+
+ qApp.quit()
+
+ def testBasic(self):
+ global qApp
+ timer = QtCore.QTimer()
+ timer.setInterval(100)
+
+ my_obj = objTest()
+ my_slot = QtCore.SLOT("slot()")
+ QtCore.QObject.connect(timer, QtCore.SIGNAL("timeout()"), my_obj, my_slot)
+ timer.start(100)
+
+ QtCore.QTimer.singleShot(1000, self.quit_app)
+ qApp.exec_()
+
+ self.assertTrue(my_obj.ok)
+
+
+if __name__ == '__main__':
+ global qApp
+ qApp = QtCore.QCoreApplication([])
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qsrand_test.py b/sources/pyside2/tests/QtCore/qsrand_test.py
new file mode 100644
index 000000000..d7c6200bf
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qsrand_test.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import gc
+import unittest
+
+from PySide2.QtCore import qsrand
+
+class OverflowExceptionCollect(unittest.TestCase):
+ '''Test case for OverflowError exception during garbage collection. See bug #147'''
+
+ def testOverflow(self):
+ # NOTE: PyQt4 raises TypeError, but boost.python raises OverflowError
+ self.assertRaises(OverflowError, qsrand, 42415335332353253)
+ # should not abort if bug #147 is fixed
+ gc.collect()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qstandardpaths_test.py b/sources/pyside2/tests/QtCore/qstandardpaths_test.py
new file mode 100644
index 000000000..35e25e1f6
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qstandardpaths_test.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QStandardPaths'''
+
+import unittest
+import ctypes
+import sys
+
+from PySide2.QtCore import QStandardPaths
+
+class QStandardPathsTest(unittest.TestCase):
+ def testTestModeEnabled(self):
+ print("QStandardPaths.isTestModeEnabled:", QStandardPaths.isTestModeEnabled())
+ sp = True
+ QStandardPaths.setTestModeEnabled(sp)
+ self.assertEqual(QStandardPaths.isTestModeEnabled(), sp)
+ sp = False
+ QStandardPaths.setTestModeEnabled(sp)
+ self.assertEqual(QStandardPaths.isTestModeEnabled(), sp)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qstate_test.py b/sources/pyside2/tests/QtCore/qstate_test.py
new file mode 100644
index 000000000..f877d1ebb
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qstate_test.py
@@ -0,0 +1,64 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+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
new file mode 100644
index 000000000..6cfa59e1d
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qstatemachine_test.py
@@ -0,0 +1,97 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QObject, QState, QFinalState, SIGNAL
+from PySide2.QtCore import QTimer, QStateMachine
+from PySide2.QtCore import QParallelAnimationGroup
+
+from helper 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/qstorageinfo_test.py b/sources/pyside2/tests/QtCore/qstorageinfo_test.py
new file mode 100644
index 000000000..f1b90bb69
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qstorageinfo_test.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QStorageInfo'''
+
+import unittest
+
+from PySide2.QtCore import QStorageInfo
+
+class QandardPathsTest(unittest.TestCase):
+ def testQStorageInfo(self):
+ for v in QStorageInfo.mountedVolumes():
+ print(v.name(), v.rootPath(), v.device())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qstring_test.py b/sources/pyside2/tests/QtCore/qstring_test.py
new file mode 100644
index 000000000..7617d8bfc
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qstring_test.py
@@ -0,0 +1,51 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QString'''
+
+import unittest
+import py3kcompat as py3k
+from PySide2.QtCore import QObject
+
+class QStringConstructor(unittest.TestCase):
+ '''Test case for QString constructors'''
+
+ 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_('áâãà'))
+ obj.setObjectName(None)
+ self.assertEqual(obj.objectName(), py3k.unicode_(''))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qsysinfo_test.py b/sources/pyside2/tests/QtCore/qsysinfo_test.py
new file mode 100644
index 000000000..524728ef8
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qsysinfo_test.py
@@ -0,0 +1,42 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QSysInfo
+
+class TestQSysInfo(unittest.TestCase):
+ def testEnumEndian(self):
+ self.assertEqual(QSysInfo.BigEndian, 0)
+ self.assertEqual(QSysInfo.LittleEndian, 1)
+ self.assertTrue(QSysInfo.ByteOrder > -1)
+
+ def testEnumSizes(self):
+ self.assertTrue(QSysInfo.WordSize > 0)
+
+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
new file mode 100644
index 000000000..dbd812f91
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qtext_codec_test.py
@@ -0,0 +1,48 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import gc
+import unittest
+
+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
new file mode 100644
index 000000000..b1c9a8f3e
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qtextstream_test.py
@@ -0,0 +1,115 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QTextStream'''
+
+import unittest
+import py3kcompat as py3k
+
+from PySide2.QtCore import QByteArray, QTextStream, QIODevice, QTextCodec, QFile
+
+class QTextStreamShiftTest(unittest.TestCase):
+
+ def setUp(self):
+ self.ba = QByteArray()
+ self.read = QTextStream(self.ba, QIODevice.ReadOnly)
+ self.write = QTextStream(self.ba, QIODevice.WriteOnly)
+
+ def testNumber(self):
+ '''QTextStream << number'''
+
+ self.write << '4'
+ self.write.flush()
+ res = self.read.readLine()
+ self.assertTrue(isinstance(res, py3k.unicode))
+ self.assertEqual(res, '4')
+
+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()
+ self.obj.setDevice(device)
+ self.assertEqual(device, self.obj.device())
+ self.obj.setDevice(None)
+ self.assertEqual(None, self.obj.device())
+
+class QTextStreamInitialization(unittest.TestCase):
+
+ def testConstruction(self):
+ '''QTextStream construction'''
+ obj = QTextStream()
+
+ self.assertEqual(obj.codec(), QTextCodec.codecForLocale())
+ self.assertEqual(obj.device(), None)
+ self.assertEqual(obj.string(), None)
+
+ self.assertTrue(obj.atEnd())
+ self.assertEqual(obj.readAll(), '')
+
+class QTextStreamReadLinesFromDevice(unittest.TestCase):
+
+ def _check_data(self, data_set):
+
+ for data, lines in data_set:
+ stream = QTextStream(data)
+
+ res = []
+ while not stream.atEnd():
+ res.append(stream.readLine())
+
+ self.assertEqual(res, lines)
+
+ def testLatin1(self):
+ '''QTextStream readLine for simple Latin1 strings'''
+
+ data = []
+
+ data.append((QByteArray(), []))
+ data.append((QByteArray('\n'), ['']))
+ data.append((QByteArray('\r\n'), ['']))
+ data.append((QByteArray('ole'), ['ole']))
+ data.append((QByteArray('ole\n'), ['ole']))
+ data.append((QByteArray('ole\r\n'), ['ole']))
+ data.append((QByteArray('ole\r\ndole\r\ndoffen'), ['ole', 'dole', 'doffen']))
+
+ self._check_data(data)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qthread_prod_cons_test.py b/sources/pyside2/tests/QtCore/qthread_prod_cons_test.py
new file mode 100644
index 000000000..fc6f06416
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qthread_prod_cons_test.py
@@ -0,0 +1,136 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Producer-Consumer test/example with QThread'''
+
+import unittest
+from random import random
+import logging
+
+logging.basicConfig(level=logging.WARNING)
+
+from PySide2.QtCore import QThread, QCoreApplication, QObject, SIGNAL
+
+class Bucket(QObject):
+ '''Dummy class to hold the produced values'''
+ def __init__(self, max_size=10, *args):
+ #Constructor which receives the max number of produced items
+ super(Bucket, self).__init__(*args)
+ self.data = []
+ self.max_size = 10
+
+ def pop(self):
+ #Retrieves an item
+ return self.data.pop(0)
+
+ def push(self, data):
+ #Pushes an item
+ self.data.append(data)
+
+class Producer(QThread):
+ '''Producer thread'''
+
+ def __init__(self, bucket, *args):
+ #Constructor. Receives the bucket
+ super(Producer, self).__init__(*args)
+ self.runs = 0
+ self.bucket = bucket
+ self.production_list = []
+
+ def run(self):
+ #Produces at most bucket.max_size items
+ while self.runs < self.bucket.max_size:
+ value = int(random()*10) % 10
+ self.bucket.push(value)
+ self.production_list.append(value)
+ logging.debug('PRODUCER - pushed %d' % value)
+ self.runs += 1
+ self.msleep(5)
+
+
+
+class Consumer(QThread):
+ '''Consumer thread'''
+ def __init__(self, bucket, *args):
+ #Constructor. Receives the bucket
+ super(Consumer, self).__init__(*args)
+ self.runs = 0
+ self.bucket = bucket
+ self.consumption_list = []
+
+ def run(self):
+ #Consumes at most bucket.max_size items
+ while self.runs < self.bucket.max_size:
+ try:
+ value = self.bucket.pop()
+ self.consumption_list.append(value)
+ logging.debug('CONSUMER - got %d' % value)
+ self.runs += 1
+ except IndexError:
+ logging.debug('CONSUMER - empty bucket')
+ self.msleep(5)
+
+class ProducerConsumer(unittest.TestCase):
+ '''Basic test case for producer-consumer QThread'''
+
+ def setUp(self):
+ #Create fixtures
+ self.app = QCoreApplication([])
+
+ def tearDown(self):
+ #Destroy fixtures
+ del self.app
+
+ def finishCb(self):
+ #Quits the application
+ self.app.exit(0)
+
+ def testProdCon(self):
+ #QThread producer-consumer example
+ bucket = Bucket()
+ prod = Producer(bucket)
+ cons = Consumer(bucket)
+
+ prod.start()
+ cons.start()
+
+ QObject.connect(prod, SIGNAL('finished()'), self.finishCb)
+ QObject.connect(cons, SIGNAL('finished()'), self.finishCb)
+
+ self.app.exec_()
+
+ prod.wait(50)
+ cons.wait(50)
+
+ self.assertEqual(prod.production_list, cons.consumption_list)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qthread_signal_test.py b/sources/pyside2/tests/QtCore/qthread_signal_test.py
new file mode 100644
index 000000000..744797de9
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qthread_signal_test.py
@@ -0,0 +1,91 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for connecting signals between threads'''
+
+import unittest
+
+from PySide2.QtCore import QThread, QObject, SIGNAL, QCoreApplication
+
+thread_run = False
+
+class Source(QObject):
+ def __init__(self, *args):
+ QObject.__init__(self, *args)
+
+ def emit_sig(self):
+ self.emit(SIGNAL('source()'))
+
+class Target(QObject):
+ def __init__(self, *args):
+ QObject.__init__(self, *args)
+ self.called = False
+
+ def myslot(self):
+ self.called = True
+
+class ThreadJustConnects(QThread):
+ def __init__(self, source, *args):
+ QThread.__init__(self, *args)
+ self.source = source
+ self.target = Target()
+
+ def run(self):
+ global thread_run
+ thread_run = True
+ QObject.connect(self.source, SIGNAL('source()'), self.target.myslot)
+
+ while not self.target.called:
+ pass
+
+
+
+class BasicConnection(unittest.TestCase):
+
+ def testEmitOutsideThread(self):
+ global thread_run
+
+ app = QCoreApplication([])
+ source = Source()
+ thread = ThreadJustConnects(source)
+
+ QObject.connect(thread, SIGNAL('finished()'), lambda: app.exit(0))
+ thread.start()
+
+ while not thread_run:
+ pass
+
+ source.emit_sig()
+
+ app.exec_()
+ thread.wait()
+
+ self.assertTrue(thread.target.called)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qthread_test.py b/sources/pyside2/tests/QtCore/qthread_test.py
new file mode 100644
index 000000000..cee32d65b
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qthread_test.py
@@ -0,0 +1,108 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QThread'''
+
+import unittest
+from PySide2.QtCore import QThread, QCoreApplication, QObject, SIGNAL, QMutex, QTimer
+from PySide2.QtCore import QEventLoop
+
+from helper import UsesQCoreApplication
+
+mutex = QMutex()
+
+class Dummy(QThread):
+ '''Dummy thread'''
+ def __init__(self, *args):
+ super(Dummy, self).__init__(*args)
+ self.called = False
+
+ def run(self):
+ #Start-quit sequence
+ self.qobj = QObject()
+ mutex.lock()
+ self.called = True
+ mutex.unlock()
+
+class QThreadSimpleCase(UsesQCoreApplication):
+
+ def setUp(self):
+ UsesQCoreApplication.setUp(self)
+ self.called = False
+
+ def tearDown(self):
+ UsesQCoreApplication.tearDown(self)
+
+ def testThread(self):
+ #Basic QThread test
+ obj = Dummy()
+ obj.start()
+ self.assertTrue(obj.wait(100))
+
+ self.assertTrue(obj.called)
+
+ def cb(self, *args):
+ self.called = True
+ #self.exit_app_cb()
+
+ def abort_application(self):
+ if self._thread.isRunning():
+ self._thread.terminate()
+ self.app.quit()
+
+ def testSignalFinished(self):
+ #QThread.finished() (signal)
+ obj = Dummy()
+ QObject.connect(obj, SIGNAL('finished()'), self.cb)
+ mutex.lock()
+ obj.start()
+ mutex.unlock()
+
+ self._thread = obj
+ QTimer.singleShot(1000, self.abort_application)
+ self.app.exec_()
+
+ self.assertTrue(self.called)
+
+ def testSignalStarted(self):
+ #QThread.started() (signal)
+ obj = Dummy()
+ QObject.connect(obj, SIGNAL('started()'), self.cb)
+ obj.start()
+
+ self._thread = obj
+ QTimer.singleShot(1000, self.abort_application)
+ self.app.exec_()
+
+ self.assertEqual(obj.qobj.thread(), obj) # test QObject.thread() method
+ self.assertTrue(self.called)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qtimer_singleshot_test.py b/sources/pyside2/tests/QtCore/qtimer_singleshot_test.py
new file mode 100644
index 000000000..d5e945385
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qtimer_singleshot_test.py
@@ -0,0 +1,106 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QTimer.singleShot'''
+
+import unittest
+
+from PySide2.QtCore import QObject, QTimer, QCoreApplication, Signal
+from helper import UsesQCoreApplication
+
+class WatchDog(QObject):
+ '''Exits the QCoreApplication main loop after sometime.'''
+
+ def __init__(self, watched):
+ QObject.__init__(self)
+ self.times_called = 0
+ self.watched = watched
+
+ def timerEvent(self, evt):
+ self.times_called += 1
+ if self.times_called == 20:
+ self.watched.exit_app_cb()
+
+class TestSingleShot(UsesQCoreApplication):
+ '''Test case for QTimer.singleShot'''
+
+ def setUp(self):
+ #Acquire resources
+ UsesQCoreApplication.setUp(self)
+ self.watchdog = WatchDog(self)
+ self.called = False
+
+ def tearDown(self):
+ #Release resources
+ del self.watchdog
+ del self.called
+ UsesQCoreApplication.tearDown(self)
+
+ def callback(self):
+ self.called = True
+ self.app.quit()
+
+ def testSingleShot(self):
+ QTimer.singleShot(100, self.callback)
+ self.app.exec_()
+ self.assertTrue(self.called)
+
+class SigEmitter(QObject):
+
+ sig1 = Signal()
+
+
+class TestSingleShotSignal(UsesQCoreApplication):
+ '''Test case for QTimer.singleShot connecting to signals'''
+
+ def setUp(self):
+ UsesQCoreApplication.setUp(self)
+ self.watchdog = WatchDog(self)
+ self.called = False
+
+ def tearDown(self):
+ del self.watchdog
+ del self.called
+ UsesQCoreApplication.tearDown(self)
+
+ def callback(self):
+ self.called = True
+ self.app.quit()
+
+ def testSingleShotSignal(self):
+ emitter = SigEmitter()
+ emitter.sig1.connect(self.callback)
+ QTimer.singleShot(100, emitter.sig1)
+ self.app.exec_()
+ self.assertTrue(self.called)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qtimer_timeout_test.py b/sources/pyside2/tests/QtCore/qtimer_timeout_test.py
new file mode 100644
index 000000000..a185a65f4
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qtimer_timeout_test.py
@@ -0,0 +1,87 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for timeout() signals from QTimer object.'''
+
+import unittest
+import os
+import sys
+from tempfile import mkstemp
+from PySide2.QtCore import QObject, QTimer, SIGNAL
+from helper import UsesQCoreApplication
+
+class WatchDog(QObject):
+ '''Exits the QCoreApplication main loop after sometime.'''
+
+ def __init__(self, watched):
+ QObject.__init__(self)
+ self.times_called = 0
+ self.watched = watched
+
+ def timerEvent(self, evt):
+ self.times_called += 1
+ if self.times_called == 20:
+ self.watched.exit_app_cb()
+
+
+class TestTimeoutSignal(UsesQCoreApplication):
+ '''Test case to check if the signals are really being caught'''
+
+ def setUp(self):
+ #Acquire resources
+ UsesQCoreApplication.setUp(self)
+ self.watchdog = WatchDog(self)
+ self.timer = QTimer()
+ self.called = False
+
+ def tearDown(self):
+ #Release resources
+ del self.watchdog
+ del self.timer
+ del self.called
+ UsesQCoreApplication.tearDown(self)
+
+ def callback(self, *args):
+ #Default callback
+ self.called = True
+
+ def testTimeoutSignal(self):
+ #Test the QTimer timeout() signal
+ refCount = sys.getrefcount(self.timer)
+ QObject.connect(self.timer, SIGNAL('timeout()'), self.callback)
+ self.timer.start(4)
+ self.watchdog.startTimer(10)
+
+ self.app.exec_()
+
+ self.assertTrue(self.called)
+ self.assertEqual(sys.getrefcount(self.timer), refCount)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/qtnamespace_test.py b/sources/pyside2/tests/QtCore/qtnamespace_test.py
new file mode 100644
index 000000000..f00e7bd91
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qtnamespace_test.py
@@ -0,0 +1,48 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test suite for QtCore.Qt namespace'''
+
+import unittest
+
+from PySide2.QtCore import Qt
+
+class QtNamespace(unittest.TestCase):
+ '''Test case for accessing attributes from Qt namespace'''
+
+ def testBasic(self):
+ #Access to Qt namespace
+ getattr(Qt, 'Horizontal')
+ getattr(Qt, 'WindowMaximizeButtonHint')
+ self.assertTrue(True)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/quoteEnUS.txt b/sources/pyside2/tests/QtCore/quoteEnUS.txt
new file mode 100644
index 000000000..909b4fa17
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/quoteEnUS.txt
@@ -0,0 +1 @@
+Fine! Dishonor! Dishonor on you, dishonor on ya cow!
diff --git a/sources/pyside2/tests/QtCore/qurl_test.py b/sources/pyside2/tests/QtCore/qurl_test.py
new file mode 100644
index 000000000..595e5931f
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/qurl_test.py
@@ -0,0 +1,125 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test suite for QtCore.QUrl'''
+
+import unittest
+
+from PySide2.QtCore import QUrl
+
+class QUrlBasicConstructor(unittest.TestCase):
+ '''Tests the basic constructors'''
+
+ def testBasic(self):
+ #Default constructor for QUrl
+ url = QUrl()
+ self.assertEqual(url.toString(), "")
+
+ def testSetAttributes(self):
+ #Construct QUrl by set* methods
+ url = QUrl()
+
+ url.setScheme('ftp')
+ self.assertEqual(url.toString(), 'ftp:')
+
+ url.setHost('www.google.com')
+ self.assertEqual(url.toString(), 'ftp://www.google.com')
+
+ url.setPort(8080)
+ self.assertEqual(url.toString(), 'ftp://www.google.com:8080')
+
+ url.setPath('/mail/view')
+ self.assertEqual(url.toString(),
+ 'ftp://www.google.com:8080/mail/view')
+
+ url.setUserName('john')
+ self.assertEqual(url.toString(),
+ 'ftp://john@www.google.com:8080/mail/view')
+
+ url.setPassword('abc123')
+ self.assertEqual(url.toString(),
+ 'ftp://john:abc123@www.google.com:8080/mail/view')
+
+ def testPath(self):
+ url = QUrl("http://qt-project.org/images/ban/pgs_front.jpg")
+ self.assertEqual(url.path(), "/images/ban/pgs_front.jpg")
+
+# PYSIDE-345: No bindings for QUrlQuery
+# class QueryItemsTest(unittest.TestCase):
+# '''Test query item management'''
+#
+# def testQueryItems(self):
+# #QUrl.queryItems
+# url = QUrl('http://www.google.com/search?q=python&hl=en')
+# valid_data = [(('q'), ('python')), (('hl'), ('en'))]
+#
+# self.assertEqual(sorted(url.queryItems()), sorted(valid_data))
+#
+# def testEncodedQueryItems(self):
+# #QUrl.encodedQueryItems
+# url = QUrl('http://www.google.com/search?q=python&hl=en')
+# valid_data = [(('q'), ('python')), (('hl'), ('en'))]
+#
+# self.assertEqual(sorted(url.encodedQueryItems()), sorted(valid_data))
+#
+# def testSetQueryItems(self):
+# #QUrl.setQueryItems
+# urla = QUrl('http://www.google.com/search?q=python&hl=en')
+# urlb = QUrl('http://www.google.com/search')
+#
+# urlb.setQueryItems(urla.queryItems())
+#
+# self.assertEqual(urla, urlb)
+#
+# def testAddQueryItem(self):
+# #QUrl.addQueryItem
+# url = QUrl()
+# valid_data = [('hl', 'en'), ('user', 'konqui')]
+#
+# url.addQueryItem(*valid_data[0])
+# self.assertEqual(url.queryItems()[0], valid_data[0])
+#
+# url.addQueryItem(*valid_data[1])
+# self.assertEqual(sorted(url.queryItems()), sorted(valid_data))
+#
+# def testAllEncodedQueryItemsValues(self):
+# #QUrl.allEncodedQueryItemValues
+# url = QUrl()
+# key = 'key'
+# valid_data = ['data', 'valid', 'test']
+#
+# for i, data in enumerate(valid_data):
+# url.addQueryItem(key, data)
+# self.assertEqual(url.allEncodedQueryItemValues(key),
+# list(valid_data[:i+1]))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/repr_test.py b/sources/pyside2/tests/QtCore/repr_test.py
new file mode 100644
index 000000000..297960204
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/repr_test.py
@@ -0,0 +1,105 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import PySide2
+import unittest
+
+from PySide2.QtCore import QByteArray, QDate, QDateTime, QTime, QLine, QLineF
+from PySide2.QtCore import Qt, QSize, QSizeF, QRect, QRectF, QPoint, QPointF
+try:
+ from PySide2.QtCore import QUuid
+ HAVE_Q = True
+except ImportError:
+ HAVE_Q = False
+
+class ReprCopyHelper:
+ def testCopy(self):
+ copy = eval(self.original.__repr__())
+ self.assertTrue(copy is not self.original)
+ self.assertEqual(copy, self.original)
+
+class QByteArrayReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QByteArray('the quick brown fox jumps over the lazy dog')
+
+
+class QDateReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QDate(2010, 11, 22)
+
+
+class QTimeReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QTime(11, 37, 55, 692)
+
+
+class QDateTimeReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QDateTime(2010, 5, 18, 10, 24, 45, 223, Qt.LocalTime)
+
+
+class QSizeReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QSize(42, 190)
+
+
+class QSizeFReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QSizeF(42.7, 190.2)
+
+class QRectReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QRect(100, 200, 300, 400)
+
+class QRectFReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QRectF(100.33, 200.254, 300.321, 400.123)
+
+class QLineReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QLine(1, 2, 3, 4)
+
+class QLineFReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QLineF(1.1, 2.2, 3.3, 4.4)
+
+class QPointReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QPoint(1, 2)
+
+class QPointFReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QPointF(1.1, 2.2)
+
+class QUuiCopy(ReprCopyHelper, unittest.TestCase):
+ @unittest.skipUnless(HAVE_Q, "QUuid is currently not supported on this platform.")
+ def setUp(self):
+ self.original = QUuid("67C8770B-44F1-410A-AB9A-F9B5446F13EE")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/resources.qrc b/sources/pyside2/tests/QtCore/resources.qrc
new file mode 100644
index 000000000..0a0b03d40
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/resources.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file alias="quote.txt">quoteEnUS.txt</file>
+ <file alias="sample.png">sample.png</file>
+ </qresource>
+</RCC>
+
diff --git a/sources/pyside2/tests/QtCore/resources_mc.py b/sources/pyside2/tests/QtCore/resources_mc.py
new file mode 100644
index 000000000..6c4bd7901
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/resources_mc.py
@@ -0,0 +1,3571 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# Resource object code
+#
+# Created: Thu Feb 3 16:09:36 2011
+# by: The Resource Compiler for PySide (Qt v4.6.3)
+#
+# WARNING! All changes made in this file will be lost!
+
+from PySide2 import QtCore
+
+qt_resource_data = b"""\
+\x00\x00\x00\x35\
+\x46\
+\x69\x6e\x65\x21\x20\x44\x69\x73\x68\x6f\x6e\x6f\x72\x21\x20\x44\
+\x69\x73\x68\x6f\x6e\x6f\x72\x20\x6f\x6e\x20\x79\x6f\x75\x2c\x20\
+\x64\x69\x73\x68\x6f\x6e\x6f\x72\x20\x6f\x6e\x20\x79\x61\x20\x63\
+\x6f\x77\x21\x0a\
+\x00\x00\xda\x88\
+\x89\
+\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
+\x00\x00\xb1\x00\x00\x00\xd2\x08\x06\x00\x00\x00\x05\x49\x21\x31\
+\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
+\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\xa7\x93\x00\
+\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\
+\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xda\x03\x0a\
+\x0c\x02\x2e\xb0\x96\x99\x74\x00\x00\x00\x19\x74\x45\x58\x74\x43\
+\x6f\x6d\x6d\x65\x6e\x74\x00\x43\x72\x65\x61\x74\x65\x64\x20\x77\
+\x69\x74\x68\x20\x47\x49\x4d\x50\x57\x81\x0e\x17\x00\x00\x20\x00\
+\x49\x44\x41\x54\x78\xda\x94\xbd\xd9\xaf\x24\xd9\x7a\xdd\xf7\x8b\
+\x21\x33\x77\x44\xe4\x9c\xa7\xaa\xcf\xa9\xb1\xab\x87\x6b\xf2\x92\
+\xd4\x15\x49\x0b\x84\x64\xd9\x22\x64\x3f\xd8\x30\x0c\xd8\x8f\x34\
+\xfc\x68\x43\x7f\x8b\xfe\x04\x02\x06\xfc\x64\xbf\xd1\x06\x04\x13\
+\x7a\x30\x65\x59\x04\x4d\x03\xa4\x48\xba\x29\xf9\x72\xb8\xdd\x5d\
+\x55\x5d\xc3\x39\x75\xea\x9c\x9c\x23\xf6\xce\xcc\x18\xfc\xb0\x87\
+\x88\xc8\xcc\x6a\xd9\xd9\x68\x44\xce\x79\x2a\x73\xc5\x8a\xb5\xd7\
+\xb7\xbe\x2f\xbc\xdf\xff\x17\xbf\x57\x09\x00\x15\x82\xc8\x29\x89\
+\xb0\x97\x24\xaa\x90\x52\x51\x12\x91\x44\x95\xb9\x37\x42\x56\x1e\
+\x91\x97\x91\x4a\xcf\x3d\x27\x8a\x04\x12\x1a\xaf\xd6\xcf\x45\x54\
+\xa0\x3c\x7e\xfc\x22\xeb\xe7\x9b\xeb\xfa\xbd\xea\xdb\x08\x01\x4a\
+\x01\x11\x42\x54\x28\xe5\xe9\x2d\x20\xc0\xdd\x6e\x5e\xdc\x7d\x4a\
+\x02\x7d\x2a\xd1\x73\x8f\x79\x6a\x07\xa2\xa0\x22\xd6\xd7\x81\x24\
+\xdb\xe3\x8d\x87\xad\xf7\xc8\xe3\x12\x80\x30\xf3\xc9\xe3\x92\x30\
+\xf3\x09\x63\x81\x22\x43\x10\x03\x99\x79\x66\x6c\xfe\xce\x12\x94\
+\x5f\xbf\xc1\xd1\xed\x38\x28\xf4\xfb\x85\x11\x79\x2e\xf1\x37\x7d\
+\xb6\xb1\xe4\x61\x76\xe0\xf6\xe5\x82\xc3\x04\x46\xe3\x01\x00\x7d\
+\x42\xb6\xe4\x4c\xbd\x31\xd5\x70\xc3\xc6\xef\x33\x28\xb7\x78\xeb\
+\x01\xeb\x47\x01\x09\x3d\x52\x76\x24\xe8\x7f\x57\x90\x29\x3a\x71\
+\x0f\x45\xfd\x7d\x77\x85\x60\xaf\xd4\xc9\x37\x2e\x44\x81\x52\x01\
+\x82\x0a\x85\x87\xcc\x04\xdf\x7e\xbc\x67\x1c\x06\xfa\xfb\x99\x54\
+\xcc\x98\x50\x72\x4f\x12\x27\x88\x69\x42\x99\x15\x27\xef\xe3\xc7\
+\x41\xeb\xfe\xbd\x52\xc8\x4c\x00\x50\x72\x8f\xcf\x8c\x49\x2c\x29\
+\x45\x84\x1f\x07\x54\x9d\x11\xde\x61\xa5\x1f\xcf\x0a\x56\x73\xb8\
+\x5b\xbc\xa4\x5a\xae\x4f\xde\xdb\x1b\x0f\x19\x52\xf1\xd9\xe3\x11\
+\x4c\x1f\x52\x75\x46\x27\xcf\x79\xf4\xe8\x6b\x42\xfd\x63\x07\x20\
+\x72\x50\x01\xb0\xa7\x2b\xba\xec\x91\xec\xa5\x06\x88\xaf\x0e\x48\
+\x72\x03\x18\x0d\xea\x14\x8f\x3d\x12\x64\xc4\x1e\x40\xda\xfb\x61\
+\x8f\x44\x00\x25\x5e\x8d\x4f\xc0\x47\x52\x12\x31\x2c\x3d\xd6\x7e\
+\xe5\x6e\x83\x47\x15\x65\x78\xd2\xc3\x8f\xa0\x94\xfa\x47\x90\x91\
+\xa4\xb4\x3b\x8a\x52\x06\xd2\x12\x94\x05\xa9\xbe\x47\x99\x5d\x47\
+\x35\x76\x16\x0b\x68\x0d\xe4\x08\xa5\x4a\x03\x66\xe8\x09\xfd\xfc\
+\xca\x00\xaf\x12\x3d\xfa\xf3\x0d\x69\xdc\xa5\xf2\xf5\xeb\x06\xa5\
+\xc7\xc6\xaf\x18\x64\x3e\x79\x2c\xd0\x1f\x1a\x93\xc7\x10\x02\x82\
+\xb8\x01\xe4\x06\x58\x9b\x00\x06\x8a\x2a\x26\x40\x11\x67\x92\x2c\
+\x8e\xc8\x8a\x80\xa2\x27\x98\x50\xd6\xc0\xce\x24\x19\x53\x1e\xbe\
+\x80\x2d\x39\x7d\x42\xd4\x7c\x05\xd3\x11\x7d\x42\xf6\xd5\x16\x56\
+\x1e\x83\xd1\x96\xd5\x6a\x44\x39\xd8\x32\xe2\x82\x42\x1c\x10\xf8\
+\xa0\x34\x80\x01\x14\x1e\x5d\x21\xda\x80\xa5\xa2\x14\x91\x03\x73\
+\x57\x08\x94\x52\xee\x7e\x94\xe2\x2f\x6e\x7e\xce\x24\xeb\xc3\x64\
+\x48\x31\x9a\x10\x2c\x16\x94\x13\x0d\xc2\xae\xf8\x34\xfd\x34\x01\
+\x5c\x55\x63\xba\x62\x09\x68\x20\xfb\xcc\xea\xbf\xc9\x3e\x7f\x59\
+\x12\x24\xf5\x0e\xc0\xbc\x60\xbb\x08\x48\x3c\x48\xab\x09\x89\xb7\
+\x00\x20\x8d\xbb\x24\xcb\x35\x98\x1d\x1a\xc0\x3b\xac\x5a\x40\xf6\
+\x0e\x2b\x92\x7e\x07\xfd\x8d\x0b\xf3\x87\x88\x02\x44\x41\xa6\xe6\
+\x35\x9b\x01\x4a\xe4\x1a\xe8\xe6\xf6\x1e\xc9\x1e\x49\xd7\x80\xa7\
+\x4b\x64\x71\x85\xdf\x40\xed\xbe\x71\xbd\x06\x2c\x6c\xfd\xcc\xec\
+\xa9\x91\x7b\xcc\x93\xb1\x7e\x8e\xf4\xf0\x0d\xeb\x5b\x30\xa7\xd2\
+\x03\xa9\xdc\xbb\xc9\x06\x5f\xcb\x16\x9b\xd7\xcf\x50\xca\xd3\x47\
+\x81\x06\xb8\x85\xa8\xe8\x89\x88\x9d\x92\x20\x0a\xc7\xc0\x9e\xda\
+\xe9\x2f\x30\x38\xb8\x77\xdb\xf8\x15\xd1\x11\xb3\xb7\x18\x3a\x53\
+\xa7\x00\xb6\xc0\xed\x09\xb7\x0d\x76\x35\x80\x5b\xaf\xcf\x25\x59\
+\x11\x10\xb3\x26\x9c\x68\x60\x66\x0c\x99\x7a\x63\xba\x5e\x9f\x7c\
+\x9a\x68\x20\x37\x2e\x87\x95\xa7\x9f\x1f\xea\xf7\x4a\xf0\x89\x18\
+\x20\x44\x41\x11\x0b\x3a\x71\xef\x04\xc0\x80\x06\xea\x19\x66\xb6\
+\xc0\x96\x99\xe0\xe3\xdb\x1c\x80\x65\x5e\x10\xac\x34\x90\x3e\x96\
+\x17\x44\xb1\x3a\x01\xeb\xa7\x2e\x41\xb2\xd1\xdf\x7e\x56\xff\x0d\
+\xf6\xf5\x00\x45\x3a\x20\x48\x36\x54\x9d\x11\x65\x56\x50\xa4\x83\
+\xd6\xe3\x16\xc0\xcb\xaa\x20\xc9\xf6\xa4\x71\xb7\xf5\xfe\x16\xc0\
+\x96\xc9\x01\xd2\xed\x01\x3f\x57\x92\x03\x19\x76\xbb\xc9\x4b\x64\
+\xd8\x63\x93\x97\xe4\x4a\xb2\xc9\x4b\x0e\xee\x90\x69\x7e\x33\x15\
+\x9a\x43\xc7\xbe\x05\x5a\x0b\x72\xcb\x5b\xdd\x86\xb8\x28\x3f\x71\
+\xdd\x8f\x2a\x4a\x22\xfd\x3e\x91\xa8\x81\x6c\xbe\x78\xbb\xb5\xaf\
+\x29\xa5\x57\x33\xf5\xb1\xe4\x70\xd7\x23\x07\xe0\x63\x56\xf6\xcc\
+\xbf\x45\x19\x06\x06\xe8\x77\x05\x24\x29\x69\xd1\x31\xcc\x1c\x18\
+\x00\x1b\x90\x92\x91\xc7\x82\x4c\x1f\x73\xb4\x1c\x88\x85\x79\x9f\
+\x8c\xa2\x8a\xdb\x3f\xe6\x4e\x51\xf4\x04\x83\x3c\xa5\x9f\x45\x2d\
+\x70\x0f\x7b\x5d\x27\x27\xe2\xa0\x60\x3b\xd0\xe0\xf7\x37\x7d\xca\
+\xc1\x96\x65\xe5\xc3\xd8\x27\x9c\x8c\xc8\xa7\x89\xf9\xf4\x5a\xe2\
+\x6c\x07\x3e\x49\x6c\x8f\x44\x01\x3e\x29\x25\x09\x82\xaa\x75\x88\
+\xf7\xe3\xa0\x75\x88\x3f\xbe\xde\x7c\x7e\x3e\xd2\xdf\xe7\x22\xde\
+\x32\x0e\x03\x96\xb9\x06\xec\x67\x7e\xc5\xff\x9f\x4b\x91\x0e\xd8\
+\x2b\xd5\x02\xe6\xb9\xbf\xc1\x3b\xac\xf0\xe3\x80\x20\xd9\x38\xc0\
+\xa7\xd5\x84\x65\x55\xb0\xac\x0a\xc6\x5e\xe0\xe4\x5d\x4b\x5e\x18\
+\xf0\x1e\xcb\x0a\x1f\x40\xe5\xe6\x07\x31\xdb\x6a\xb5\x43\x76\x6f\
+\xc9\x52\xc3\x6b\xf7\x1e\x07\xb1\xa9\x59\x57\xe4\x0e\xa0\xea\x88\
+\x71\xbb\x47\xaa\xf8\xdf\x75\xb1\x80\x6c\x5e\xb7\x4c\xec\x47\x15\
+\xa5\x92\x24\x51\x85\x2f\x22\xf7\xce\xb5\x3e\xaf\xb9\x58\xfe\x88\
+\x0e\x3f\xa7\x97\x05\xe0\x91\x51\x88\x94\x8d\x5f\x69\x20\x43\x83\
+\x7d\x63\xc2\x4c\x19\x29\x11\x1b\x19\x12\xb6\x98\x16\xa0\xd3\x9b\
+\x12\xec\x94\xbb\xff\x18\xa8\x00\x59\x1c\x31\xec\x75\xb5\x84\x88\
+\x43\x26\x71\x5b\x72\x0c\x09\xf0\x1f\x7b\x84\x61\x84\xff\xd8\x63\
+\x1d\x7b\x24\x71\xc2\xe8\xf1\x23\xd4\x24\xc1\x9f\x14\x74\x27\x43\
+\xb6\x03\x9f\x69\xd8\x37\x47\x80\x94\xd5\xfa\xee\x93\x8c\xdb\xbc\
+\x58\x76\xb6\x5b\x61\x8e\xbc\x16\x58\xe1\xaa\x82\xcf\x87\x4c\xb2\
+\xbe\x03\x70\x1b\x24\xe9\x89\x0e\x3e\x77\xf1\xbc\x25\x9d\xde\x65\
+\x8b\x89\x9b\x92\xc6\x32\xb5\x05\x61\x91\x1a\xed\x3f\x29\x38\x70\
+\xe7\xc0\x6b\xc1\x9c\xc6\x5d\x56\xc5\x96\xdc\xdf\x9e\x30\xb1\x05\
+\x74\x52\x76\xf1\xe7\xb1\xbe\x21\xc3\x9e\x03\xef\x7d\x25\x51\xe9\
+\x73\x7d\x7f\xf7\x16\x6f\xd4\xc3\x33\xa0\xd8\x23\x41\x05\x7a\x2b\
+\x0a\xba\x44\x8e\x99\xed\xe3\x25\x91\xd6\xd2\x47\x2c\x7d\x0c\xc0\
+\x13\xc9\xd1\x7c\xcc\xcb\x5a\xbb\x43\xa9\x34\xc3\xfa\x51\x85\x3c\
+\x62\xbe\x7a\x39\x69\x24\x85\xf2\xea\x6d\x53\x52\x58\x80\x9a\x6d\
+\x45\x4c\xa0\x12\x06\xa5\xc7\x76\xaf\xa8\x44\x8f\x4c\x2f\x13\x90\
+\x4a\xb2\xf1\xab\xc6\xc2\x0d\x02\xe5\xd3\x31\x12\xa1\x29\x17\x8a\
+\x9e\xd0\x92\xe2\xdc\x4e\x3a\xd8\xd6\x6c\x1c\xd7\xdf\xd3\x64\x3a\
+\xe3\xb3\xe1\x8c\xd1\xf0\x82\x22\x16\x24\xf4\x98\x4d\x05\x13\x31\
+\x62\x22\x46\x88\x69\x42\x57\x08\x92\x38\x21\x89\x93\x13\xb0\x0a\
+\x62\x46\xc3\x36\x68\x7d\x25\x5b\x00\x6b\x5d\x37\x40\x14\x54\x2d\
+\xe9\xd3\x15\x82\x0f\xa5\xc7\x17\xd5\x80\x7c\x90\x30\x79\xe0\x9f\
+\x2c\x00\x7f\x4c\x07\x37\x3f\xa7\xaa\xc6\x1c\x76\x37\x6e\x51\xd7\
+\x94\x16\xcd\x1d\xcc\x02\xd0\x82\x7a\xbb\xa8\xc1\x0b\xb4\x98\xd8\
+\xf3\xe6\x84\x65\x9f\xd2\x5f\xb4\x64\x84\xdd\x01\x52\x7f\x8f\x2f\
+\x3e\xd6\xd4\xac\x1e\xac\x48\x6f\xbb\x04\xc9\x15\x22\x79\xcd\x32\
+\x1e\x9f\xa7\x4f\x51\x20\x54\x48\x97\x48\x83\x56\x74\xcc\xa2\x50\
+\x33\xb1\x05\xaf\x3a\xf3\xd2\x54\x1e\x39\x15\x91\xa8\xb7\x52\xd5\
+\xb7\x81\x2d\x9a\x85\x25\x90\x44\x42\xbb\x22\x44\x2d\x80\x47\x44\
+\x48\x64\x43\x54\x44\x48\x51\x19\x38\x37\x80\x2c\xaa\xda\xc5\x30\
+\x00\x2e\x44\xda\x62\xe2\x41\xe9\xe1\xa9\x82\x98\x2e\x91\xa8\x18\
+\x94\x9e\x63\xe1\x4e\x4f\xd0\x69\x68\x5d\x0b\x5a\xa7\x7f\xab\x98\
+\x49\xec\x33\xa1\x64\x81\xef\xd8\x36\x0c\x23\xfc\x49\xa1\xc1\x48\
+\x8f\x84\x1e\x13\x31\xd2\x32\x40\x44\x74\x85\xa0\x2b\x84\x5e\xfd\
+\xf7\x8b\x5a\x0a\x64\x6b\xf6\x4a\xb1\x5a\xdf\xb1\x79\xa7\x98\xe7\
+\x5b\xfa\x1b\xf3\x99\xf3\xa5\x01\x98\x80\x78\xe8\x40\x74\xcc\xc4\
+\x4d\xb0\xa5\x94\x27\x2e\x85\xd5\xc7\x0f\xfa\x4b\xe7\x4a\xe4\xe5\
+\xd4\x49\x8a\x7d\xfe\xf6\x64\xa1\xfa\x63\x8b\x3b\xcf\x5b\xb6\x34\
+\xbf\xd5\xc4\x4d\xe9\x52\x75\x46\x0e\x80\xe7\xdc\x06\x56\xa1\x03\
+\xf3\xb2\x2a\xa8\xd6\x93\x16\x13\xdb\xc5\x5d\x90\x6c\xdc\xe7\x86\
+\xcb\x78\xcc\xc4\x82\x2e\x7d\xce\xc5\x58\xb2\x38\x40\xb4\x7f\x48\
+\xd4\x91\xb0\x7f\xe8\x98\x7a\x00\xa0\x02\xba\xa2\x8b\x62\x6f\xd8\
+\x2e\xd0\xc7\xe6\xc6\x1e\x5b\x44\x15\x9e\x8c\xe9\x1e\x31\x6e\xd7\
+\x30\x69\x53\x42\x68\x17\x83\x1a\xc0\x66\x5b\x20\xe9\x13\x21\x1d\
+\xb0\x65\xad\x51\xab\x18\xe9\x65\x0e\xc0\xc7\xf6\x5c\xa4\x3c\x63\
+\xc9\x79\x2d\x69\xa1\x0c\x0b\x6b\xdd\x9e\x11\xa8\x84\xc8\x00\xde\
+\x31\xa4\x88\x0c\x30\x05\x01\x0a\xcf\x80\xf4\x90\x78\x3c\xac\x1a\
+\xd2\xa7\xf3\x04\xff\xb0\xa4\xec\x8c\x19\x1c\x24\x9b\x4e\x04\x87\
+\x25\xe5\xe8\x82\x27\x07\x49\xca\x8e\x72\x74\xc1\x2c\xa8\xce\xda\
+\x52\x30\x84\xac\x60\xaf\x94\x61\xbb\x21\x7e\x39\x39\x79\x6e\x18\
+\x46\x0c\x27\xda\x70\xc3\xab\xd9\x7e\xbf\xbd\xa5\xe4\x33\xba\xfd\
+\x05\x6c\x87\xf8\x86\x89\x89\xfb\x2d\x60\xed\x95\xa2\x10\x07\x22\
+\x06\xec\x51\x28\x3c\x07\xaa\xbd\x52\x74\x85\x60\x53\x44\x2c\xf3\
+\x3b\xc2\x4d\x4a\x10\x06\x5c\x4c\xc6\x6c\xbf\xff\x81\xd7\x6f\x97\
+\x84\xbf\x1e\x31\x11\x33\x67\xa5\x1d\x5b\x6a\xcd\x7f\x93\x9a\xa7\
+\xa4\x59\x0a\xa4\x5a\xe3\x4f\xee\x81\xc4\xd9\x6b\x7a\x61\xb7\x72\
+\xee\x84\x5b\xb0\xd2\x90\x45\xa3\xdc\x5d\x1d\x7b\x01\xde\x70\x01\
+\x8c\xf5\x77\x53\xb6\xdd\x89\xaa\x1a\x6b\x77\xe2\x59\xa4\x57\xe8\
+\x83\xd0\x67\xd2\x91\x6e\xdb\xbc\x0c\x42\x9f\x41\xe8\x23\x1a\x4e\
+\x46\x57\x74\xe9\x12\x39\x3b\xae\x7b\xc6\x69\x00\xa8\xa2\x0c\xdf\
+\x3c\xbe\x8f\x2a\xa7\xa1\xfd\xa8\x62\xdf\x94\x0f\x0d\x00\x97\xd2\
+\xd3\x00\x06\x22\xc3\xcc\xa9\xf4\x88\x3c\xfd\xfc\xc8\xab\xb0\x0a\
+\x39\x32\xff\x39\x96\x76\x87\x15\x0f\x41\xa6\xf7\x2f\x7c\xad\x89\
+\x0d\xa0\x2d\x13\xdb\x45\x5e\x24\x2a\x36\x7e\xe5\x3c\xe1\x09\x25\
+\xe3\x64\xc3\x70\xa2\xd9\xf5\x6a\x1a\xf2\xac\x17\x50\x4e\xa1\xec\
+\x8c\x29\xa7\x10\x07\x6b\x84\xf0\x99\x05\x15\x62\x9a\x30\x0b\x2a\
+\x26\x62\xc4\xe0\x20\xcd\xce\x30\xe2\xc1\xc0\x77\xcc\xea\x18\xb6\
+\xaf\xfd\xd0\xd2\x5f\xe0\xc7\x01\x62\x9a\x68\xe7\x27\xab\xef\xd7\
+\xd2\x63\x48\x21\x0e\x24\x71\x42\x11\x0b\xed\x3e\x3c\xaa\xdc\xf5\
+\x45\x19\x10\x64\x8a\xfd\x5d\x17\x5f\x49\x14\x9e\xf6\x87\xb3\xf5\
+\x09\x80\x03\xd5\x69\xb1\x70\xd3\x47\xde\x2b\xc5\xe0\x20\x19\x87\
+\x01\xf9\x20\x61\xbb\xd0\x7f\xc7\xe7\x5f\x3c\xe3\x65\x01\x7f\xfe\
+\xe7\x6f\xb9\xff\x6e\x89\x9a\xa7\xf8\xa4\xa8\x79\x4a\x31\x5f\x3a\
+\xf6\xf7\xe3\x00\x6f\x34\x85\xf9\x56\x1f\x31\x16\x01\xf3\x45\xc0\
+\xd8\x2b\x9d\x0c\xaa\xaa\xb1\x93\x0f\xe7\xd8\xb7\xc3\x05\xdb\xfd\
+\xde\x31\xb1\x05\xf0\xb2\x2a\x60\x51\x51\x6d\x47\x90\xad\x5b\x1e\
+\x33\x80\x3f\xf6\x49\xb7\x07\x2d\x00\xfd\x20\x01\x34\x80\xed\xed\
+\xc4\x93\x66\xd5\x18\x91\xab\x39\x21\x7d\x54\x83\x6d\xad\x96\x3d\
+\x5e\xc8\x95\x44\x54\x51\x46\xe9\x2c\xb3\x18\x90\x1a\xd4\xb2\x21\
+\x1f\xa4\xd2\xaf\x8d\xaa\x1f\x2d\x7f\x58\xa0\xa6\x46\x9c\xe8\x42\
+\xcb\xe9\x6b\x9a\xf7\x09\x7c\x14\x25\x8a\x58\xb3\x8e\x28\x50\xca\
+\xa3\x27\x22\x3c\x91\x39\x00\x6b\x9f\xb8\xf6\x85\x43\x2a\x2d\x13\
+\xa2\x10\xaf\x6a\xc8\x2c\x55\x32\x13\xa1\x96\xc7\xc1\x9a\x84\x29\
+\x25\x05\x1f\x45\x48\xe2\x57\x06\x80\x09\x92\x0d\x01\x7b\x20\xd1\
+\x2c\x87\x70\xee\x81\x64\x43\xc4\x00\x89\x07\x2c\x49\x08\x80\x35\
+\xc4\x43\x0d\xe4\xf9\x2d\xa8\x00\x21\x02\x4a\x0a\xe8\xaf\x09\x54\
+\x97\x94\x1d\x42\xf8\x04\xaa\x83\xa2\xa6\xb0\xd1\xf0\x82\x0e\x15\
+\x05\x70\xc8\x76\x04\x40\x11\x17\x28\x95\x50\x88\x0d\x81\xea\x18\
+\x1d\xdf\x39\xfb\xfd\x5a\x20\xdb\x62\x47\x31\x9a\xc0\xbd\x66\xc4\
+\xe5\xee\x9a\xe2\xb3\x2b\x7e\xf6\x1b\x3f\x43\xbe\x7a\xcd\xdb\xc5\
+\x9a\x3c\x2f\xf8\xea\xc1\x8c\x7c\xb1\xe4\xe5\xab\x1f\xe8\x7c\xbf\
+\xe6\x97\x7f\xf5\x21\x28\x78\x9b\xdd\xb1\xf9\x7e\xc3\xab\x97\xbf\
+\xa0\x3f\xb9\xe0\xf3\x17\xcf\xd9\x8e\xa7\x4c\xd0\x45\x8e\xaa\xaa\
+\xa5\x80\x95\x03\xf6\xfa\x87\xd2\xe3\xc0\x1d\x7d\x19\x43\x37\x87\
+\x51\x4e\x59\x6d\x59\xd2\xaf\x8f\xec\x71\x41\x27\x9e\xb5\x5e\x5b\
+\xa4\x03\x0e\xbb\xf7\x24\xfd\x8e\x06\xb1\x05\xac\x03\xa5\xbd\xad\
+\x02\x12\x21\x41\x44\x40\x61\xa4\x43\xe1\x00\x9c\x56\x8d\xe7\x36\
+\xfd\x60\x0b\xe0\x06\xa0\x01\x3a\x51\xc6\x41\x2a\x84\x01\xb2\x4f\
+\xd5\xf2\x85\x6d\xd5\xcf\x8f\xaa\x96\x71\x26\x91\x24\x51\xf4\x49\
+\x00\x9f\xfe\x40\x65\xcb\x5a\xb3\xd7\x2b\x2b\x29\x94\x44\x08\xed\
+\x4e\x48\x15\x13\x09\xcd\xc2\x21\x10\x1f\x2a\xaa\x78\xd5\x02\x71\
+\xbe\xde\xf0\x61\x0d\xa3\x61\x44\x21\xba\xa4\x99\xd6\x7e\x0f\xc2\
+\x0a\xca\x09\x29\x25\xb0\xb1\x4b\x57\x53\x45\xcb\x59\xd8\x4a\x20\
+\xf7\x28\x42\x02\x14\x59\x67\xc8\xe0\x70\x57\xaf\x17\x94\x22\x25\
+\x04\x42\xc8\x52\x56\x6b\x49\x18\x2a\x12\xa5\xdf\xc7\xee\x44\xed\
+\x23\x70\x0a\x24\x0e\x88\x6b\x34\xb9\x0c\xb3\x80\x22\xfe\x34\x70\
+\x8f\xdd\x82\x26\x98\x3f\xf3\x2b\x82\x30\x60\x39\x48\x58\xbe\x4b\
+\x11\xd3\x25\x0c\xe0\xf1\x6f\xfe\x1a\xf3\xfb\x35\xb3\xd5\x82\xbb\
+\xc5\x92\x8b\xc9\x98\xce\x62\xcd\xdd\x72\xc1\x9b\x77\x05\x30\xe1\
+\xf5\xea\x7b\xaa\x65\xc8\x7e\xf4\x80\x8b\xf1\x98\x8b\xc9\xf8\x93\
+\x8b\xb9\x26\x08\x83\x64\xc3\x67\x7e\x85\xe4\x82\x03\xcb\x9a\x89\
+\x8d\xa3\x58\x56\x5b\xaa\xf1\x8c\x73\xb5\x96\xc3\xee\x86\x34\x4b\
+\x35\x13\x77\x89\xd8\xab\xba\x4a\x67\x81\xbc\x57\xfb\x96\xce\x75\
+\xa5\xca\xc6\xe1\x3f\x91\xf2\x44\xf3\x5a\x3f\x57\xeb\x62\x08\xa4\
+\x47\x69\xc0\xad\x88\xe8\xe2\x81\x94\x4e\x3e\xf8\x8d\x85\x9c\x2b\
+\x63\x9b\xeb\xbe\xb9\x1e\x9d\x61\x5b\x0b\xee\xa8\xe1\x4e\xb4\xca\
+\xd1\xca\xab\x8b\x1c\xf8\xba\xb8\x41\xa6\xe5\x84\xa8\x1c\x1b\x6b\
+\x49\x11\xb9\xd2\x76\x10\x17\x44\xbd\x09\x4a\x95\x08\xa1\x8f\x4c\
+\x01\x11\xc5\xbb\x94\x70\xbc\x45\x70\xe1\x0e\xf7\x6c\xd7\xa4\xe6\
+\xcb\xd7\x40\xcb\x0d\xa0\xd1\xc0\xcc\x72\x88\x43\x03\x52\x48\xb3\
+\x14\x3f\xde\x91\x66\xf5\xe2\x47\xdb\x70\xfa\x79\xc4\x21\xa1\x71\
+\x32\x52\xeb\x6f\x1a\x47\xc3\x02\xda\x28\x65\xc0\xee\x20\x3d\x86\
+\x04\xac\x29\x28\xe2\xc2\x01\xbc\x59\x8e\xfe\x14\x13\x0b\x2a\xc7\
+\xc4\x51\xac\x28\x4a\xcd\xc6\x77\xcb\x05\x17\xff\x46\x4b\x8a\x7e\
+\xfa\x9a\x89\x0f\xc5\x63\xc1\x40\x1b\x7b\xfc\xf2\xaf\x3e\x44\x66\
+\xcf\xf8\x50\xea\xef\x77\xb6\x78\x00\x63\xf8\x7c\x32\x74\x00\x1e\
+\x4d\x6b\xdd\x1a\x24\x1b\x07\xda\xa6\x1c\xd0\xd2\x62\xce\x61\xb5\
+\xd4\x0c\xbc\x5a\x90\x45\x09\xfd\xf5\x18\x46\x39\xb3\xaa\xa0\xda\
+\x54\xe4\xfe\x96\x90\x87\xad\x85\x9d\x98\x42\xa7\x77\x59\x57\xec\
+\xba\xa2\x7b\x22\x0d\x9c\xe6\x6d\xdc\xa7\xce\xf9\xc0\x0d\x10\x36\
+\x75\x70\x20\x3d\x57\xc0\xd8\x9b\x6d\xb7\xc1\xba\xcd\xd7\x36\xfd\
+\x5f\xd9\xb8\x1e\xb5\x96\x6b\x5a\x4a\x70\x24\x33\xb0\x15\x2a\x03\
+\xdc\xf6\x4e\x57\x39\x37\xc5\x82\xba\x09\xe0\x8a\x18\xd1\x5c\xd1\
+\x2b\xc5\x26\x0b\x90\xbb\x05\x42\xf8\xba\x54\xdd\x94\x4a\xeb\x7a\
+\xa5\x9f\x66\x4b\x94\x52\xa8\xf9\x1e\xb9\x5b\x40\x96\xb3\xf5\x52\
+\x16\x59\xa9\xc1\x9b\x99\x05\x8a\xb9\xbe\x96\x5b\x88\x43\xfd\xb8\
+\x2d\xa1\x14\x0d\xbf\x35\xab\x17\x34\xe5\xa2\xed\xc3\xae\xe5\xf6\
+\x47\x59\xd5\x32\x71\x90\x05\x67\x01\x5c\x88\xc3\x89\x2b\x61\x4b\
+\xce\xda\xae\xab\xe8\x0a\xc1\x6c\x02\x83\x99\x96\x03\x87\xd5\x92\
+\x57\xdf\xff\xc0\xab\x05\x6c\x19\x93\xb2\x73\xef\xbb\xe9\xe8\xef\
+\x2c\x58\x2d\x90\xaf\x5e\xeb\x1d\x72\x90\x70\x31\x19\x73\x98\x8c\
+\x98\x4c\xd3\x56\x15\xaf\xcc\x0a\x67\xa7\x59\x67\x22\x48\x36\x94\
+\x4b\xfd\x5d\xac\xaa\x0a\x56\x21\xfe\x48\x2f\x6c\xcb\xa1\x26\x86\
+\x85\xaf\x8f\x86\x61\xd9\x3f\xa9\xd4\x55\x9d\xd1\x91\x26\x6e\x94\
+\x84\x9b\x8b\xb4\x63\x1f\x57\x57\xe2\x74\x2e\x42\x49\x45\x27\xaa\
+\x38\x48\x75\xe4\x4a\x68\xf6\xb5\x4c\x5b\x36\xae\xfb\x4d\x1b\xad\
+\x11\x2c\x6a\x32\x30\x47\xc0\x75\x60\x3d\x62\xe2\xda\x56\x13\x44\
+\x48\x04\xc2\x1d\x25\xd4\xa7\x02\x47\x8e\xa9\x33\x97\x9b\x50\x4a\
+\x22\x44\x44\x98\xf9\x60\x16\x76\x9b\x2c\x00\x16\xa4\x72\x07\xd9\
+\x54\x33\xe6\x7c\xc5\xbb\x65\xc9\x44\x7e\x64\xdb\xbf\x22\x3e\x54\
+\x06\x88\x3b\xf0\x04\x78\x8a\x78\xe5\x43\x08\x6b\x4f\xd5\xb9\x09\
+\x2f\x63\x58\x09\x5d\xd5\xcb\x72\x5b\x5f\xd2\x36\x5c\xaf\xcb\xda\
+\x53\x0c\xa3\x3e\x6b\xb9\x65\x68\xf3\x06\x93\x7b\x67\x51\x85\x59\
+\xc4\x30\xee\xff\x7f\xab\x98\x19\x26\x4e\x8e\xc4\xc7\x39\x79\x61\
+\xf3\x0c\x7a\xc1\xa7\xaf\x0f\x0e\x92\xd0\x17\x7c\x18\x4d\x18\xfe\
+\x6c\xc2\x37\x7f\xfe\x0d\x37\x7f\xfb\x1d\x00\x3f\x7d\xa8\xa9\xf5\
+\x62\x5c\x3b\x28\x77\xcb\x05\xe3\xa7\x4f\x18\xcc\x2e\xf8\xcc\xaf\
+\x0c\xfb\xae\xb4\x55\x58\x6a\x17\xc3\x3a\x1a\x96\x89\x2d\x98\x2d\
+\x90\xef\xbe\x5f\x3a\x57\xa2\x5c\x2d\xe8\xf3\x80\xb2\xb3\x87\x55\
+\x48\x39\x5c\xe2\x8d\x4a\xe0\x49\x4b\x8a\x34\xb5\x71\xd2\xef\x10\
+\x5a\xd0\xee\x39\x95\x06\x4e\x5a\x44\x15\x5d\xa9\x0b\x08\x5d\x0b\
+\x9d\x48\xa0\x9a\xbe\xae\x54\x1c\xa4\x87\x88\x2a\x0d\x77\x03\x52\
+\xcd\xce\xc2\x95\xa3\x6d\x65\x2e\x89\x04\xa9\xac\x8b\x1c\xf2\x18\
+\xbc\x55\x4c\xe4\x65\xad\x4c\x5b\x1b\xc0\xb5\x3f\x8c\x10\x67\x81\
+\xab\x8e\x00\x7c\x2c\x25\xdc\xfb\x29\x0f\xcf\x4f\xe9\x67\x09\x39\
+\x0a\x01\x7c\x54\x7a\xf7\x2e\x59\x72\xd8\xa4\xe0\x57\x78\xc5\x9c\
+\xc5\xed\x94\x22\x54\xed\x32\xbb\xf1\x52\x33\x51\x12\x28\x05\xf8\
+\xae\x10\x82\xd0\x80\x0d\xbc\x8c\x45\x15\x13\xec\x14\x0b\x63\xdb\
+\xad\x3d\x45\x51\xc5\x2c\xb2\x92\xc0\x33\xc0\x8e\x57\x90\xc1\x26\
+\x4c\x18\xe4\x69\xcd\xd2\x8d\x42\x89\x9f\x8d\x28\xe3\x15\x65\x67\
+\x0c\xc6\x0d\x19\x12\xb0\xce\xb4\x1f\x7d\x4e\x4a\x58\x4f\x58\xa7\
+\xd7\x54\xcb\x62\xf3\x95\x34\xe1\x28\x8f\xd1\x14\xba\xac\x51\xaa\
+\xe4\xef\xfc\xa3\x67\x8c\xdf\x3e\x61\xf9\xdd\x5b\xc6\x4f\x1f\x13\
+\x6e\x52\xc7\xba\x83\xd9\x05\x4f\x79\x6e\x4a\xd3\x95\x29\x35\x9b\
+\x85\xec\x76\xa8\x17\xa7\x8d\x94\x9b\x95\x14\x16\xbc\x45\x3a\xc0\
+\x1f\xfb\x5c\x4c\x0a\xde\x7c\xf8\x6b\x58\xc5\x64\x51\x42\x2c\x3f\
+\x92\x1d\x12\xe2\xe1\x12\xd6\x07\x2a\xff\xe2\x93\xba\xba\xea\x8c\
+\x1a\x9a\xb8\x01\xe4\x26\xa0\x1d\x78\xa5\x76\x85\x9b\x55\xb8\x52\
+\x7a\x0e\x94\x0a\x0c\x2b\x7b\x6e\xa1\x56\x1a\x4f\x58\x57\x1d\x6a\
+\xeb\xcc\x8f\x04\xbe\x94\x86\xcf\x9b\xa0\x6e\xfb\xb5\x78\x59\xcb\
+\xa9\x88\x1a\xce\x44\xdb\x1f\xe6\x4c\x04\xf4\x0c\x98\xcf\x00\xb8\
+\xa5\x8b\x55\x00\x5d\x1d\xb9\x54\x71\xd9\x08\xfa\xf8\x78\xc1\x80\
+\x70\xb1\x26\x1f\x02\x83\xda\x73\x0e\x33\x1f\x11\x0b\x17\x02\x2a\
+\xaa\x98\x40\x64\xa0\x34\x68\x8b\x5e\xac\x41\xdd\x03\x94\xcf\x20\
+\x48\xc9\x08\x08\xcc\xbf\xcd\x66\x2e\x26\xb1\xcf\x5a\xd6\xd2\x61\
+\x90\x14\x4c\xd2\x84\xfc\x53\xc5\x05\x53\x65\x1d\x1c\xa4\xa9\x88\
+\xa5\x4e\x52\x68\x4d\x5c\xeb\x68\x0b\x66\x6b\xb1\xd9\x20\x97\x95\
+\x19\x7b\x05\x5d\x11\xe9\x8a\x9e\x0a\xf0\x95\x24\xeb\x0c\x89\xc5\
+\x9a\x9f\x54\x4f\xf9\xc9\x17\x70\xff\xc5\x0b\xd6\xd5\x8a\x7c\xae\
+\x01\x35\x9b\x98\x52\xb5\x75\x4a\xa6\x38\x8a\x2a\x49\xa8\xaa\x31\
+\x9e\xb7\x3c\xf1\x96\xeb\x62\x48\xe0\x40\xf9\xa1\xf4\x28\xb2\x88\
+\x15\x15\x03\x99\x6a\x4d\x2c\x63\x4a\x99\xc2\xb0\x53\x07\xac\xce\
+\x64\x28\xbc\xc3\x4a\x97\x9d\x8f\x59\xb7\xbd\x72\x52\xee\x7e\x6d\
+\x87\x09\x2d\x3b\x4c\x50\xc7\x79\xbb\x86\x85\x5d\xde\xc1\xea\x61\
+\xf3\x7a\x11\x09\x84\x54\xee\xb1\xa8\xa1\xa3\x65\x83\x89\x9d\x94\
+\x30\x3f\xae\xb4\x8c\x6c\x41\xeb\x65\x48\xf3\x9f\xf3\x87\x95\xd2\
+\xc5\x8d\x63\x8b\xae\x51\xe4\xb0\x9f\x96\x37\xdc\x0a\x17\xc3\x24\
+\x76\xd7\x9b\xf9\x61\xfb\x3a\x1b\xf4\xc9\x5f\x0c\xa9\x82\xa9\xcb\
+\x16\xeb\xc7\x1a\x5f\xae\xf2\x5d\x39\xda\x7e\xe9\xc1\x4e\x11\x07\
+\x85\x03\xad\x8d\x61\x1e\x03\x78\x91\x95\x0c\x23\x2d\x19\x86\x95\
+\xc0\xab\x46\x2c\xf0\x5d\xe6\xb8\xa9\x9b\xfd\x6c\x84\x9f\x8d\x5c\
+\x49\x37\x8a\xef\x19\xd2\xd4\xd0\xc9\x09\x80\xcf\xbb\x13\x29\x89\
+\x0a\x11\x54\x8d\x50\x50\x0a\xa2\xe4\xc1\x21\x23\x62\x40\xb0\xbb\
+\x26\xf0\xde\x71\xe1\xad\xf8\x6a\x2f\xf9\xc9\x45\xc5\x2f\xf5\x33\
+\xfd\x78\xac\x18\x4d\x61\x38\x19\x9f\x94\xb6\x03\xef\xdd\x27\x3f\
+\xb7\x29\x2d\x9a\x21\xa3\xd1\x58\xef\x84\xb1\x4c\x29\xf9\x88\x3f\
+\x9a\x90\x1d\xba\xee\xbb\x3d\x97\x66\xab\x3a\x23\x5d\x76\xb6\xcc\
+\xeb\xd8\xf7\x48\x13\x1f\x87\x75\x2c\x38\x8b\x66\xe5\xcd\x80\xb2\
+\x4b\xa4\xb5\xaf\x88\xe8\x97\x71\xeb\xb1\xd2\x80\xce\x37\x1a\x98\
+\x23\x56\x6f\xb1\xaa\x97\x41\x15\x1b\x49\x51\xb5\x64\xc3\x89\x3f\
+\x7c\x9c\x9b\x68\x2c\x00\x2d\x5b\xdb\x05\x5d\xa0\x12\xc7\xc2\xde\
+\x51\x32\x0f\x60\xbb\x57\x28\x25\x1d\x50\x15\x31\x79\xa6\x1c\x90\
+\xbd\xf1\x90\x62\x90\x10\xc6\x25\x79\xe6\xbb\x14\x1b\xa2\xd4\x91\
+\x55\xfb\x85\xdb\x2f\x5d\x94\x64\x9d\xd3\x1d\xac\xa8\x62\x97\x27\
+\x5e\xcb\xad\x2e\x55\x67\xa5\x06\x34\x1a\xd4\xf6\x71\x1b\x22\x22\
+\xcb\xf1\x99\x69\x19\x61\x98\x38\x8a\x95\x73\x3a\x80\x86\x94\xc8\
+\x29\x3b\xe3\x23\x47\xa3\x1d\x06\x82\xd8\x2d\xec\xba\x42\x80\xf2\
+\xb5\x0f\x6d\xfe\x76\x5f\x69\x8f\xd7\x25\xe5\x6c\x9a\xb0\xb1\x18\
+\xf4\x95\x74\x59\x89\xbd\x52\x2d\x96\xf7\x49\x5d\xd1\xc5\xb2\xb1\
+\xbd\x7e\xbc\xc8\x6b\x16\x39\x36\xd5\x85\xbb\x1d\x77\xf6\x3f\x1a\
+\xc5\xb4\xdb\xb3\x9a\xd8\x8f\x2a\x94\x2d\x46\x9c\xa0\x46\xb3\xaf\
+\x27\xe3\xda\x03\x96\xed\x1d\x20\xf1\x32\xd6\xbe\xe7\xec\xb3\xd2\
+\xd9\x65\xed\xbc\xb0\x05\x78\xd3\xb1\x70\x4c\x6c\xca\xca\x2d\xb8\
+\x2a\x79\x26\xf0\x13\x9d\x08\x0a\x0d\x7c\x88\x84\xae\xcd\x09\x17\
+\x00\xca\xe8\xb5\x0a\x1d\x75\x97\x47\xbf\x2b\xd8\xfa\x29\x42\x44\
+\x48\xe5\x11\xc5\x25\x52\x49\xa2\xb8\x22\x37\x07\x68\x9d\x68\xcb\
+\x34\x58\xe3\x92\xdc\xb2\xbc\xf9\xe1\x85\xcd\x15\xdb\xc3\x9f\xbd\
+\xae\x7c\x17\xa0\x1f\xe4\xa9\x76\x25\x4c\xaa\x6d\x51\xc5\x2c\x4c\
+\x95\x70\x2d\x33\x26\x71\xdf\x69\xe0\x45\x56\x32\xc8\x53\x07\xe4\
+\x32\x5e\x39\x3d\xec\x67\x23\xd2\x78\x75\xe4\x1e\xef\xdc\xfd\xfe\
+\x61\x79\x96\x89\xf7\x4a\x91\xb2\x43\x66\x23\xee\xb3\x05\x33\x26\
+\xdc\xb3\x70\x5d\x1c\x92\x99\x0b\xef\x90\x65\xb5\xf7\x9d\xd5\x8c\
+\x5f\x4b\x17\xa3\xf7\x17\xef\xc8\x33\x9f\x65\x3e\x24\xdc\xdc\xd2\
+\x9f\x0c\xf9\xfa\x71\x8f\xa6\xc1\x7b\x5c\xaa\x76\x60\x36\x05\xca\
+\x55\x55\x31\xf0\xa0\x42\x67\xd9\xb7\x51\x46\xbc\x3e\xc0\xf8\x54\
+\x46\x1c\x83\x3a\x3c\xab\x21\x8d\x0c\x38\x66\x65\x5d\xc8\x88\x8c\
+\xcb\x60\x5d\x88\xca\xad\xc6\x6c\xf8\x27\x95\x6d\x5b\x4e\x44\x15\
+\xd8\x16\xa6\x33\x15\xba\xa8\xe1\x0b\x63\x98\x58\x36\x16\x70\xd1\
+\x89\x5f\xd1\xbe\x1e\xa4\x3e\x45\x22\x8d\xe7\x19\x6b\x29\x61\x74\
+\x70\x33\xb5\xe6\x18\x58\x05\xae\x72\x67\x3b\x3b\xb6\x4a\x01\x01\
+\x0a\x49\x64\x81\xec\x5e\x97\x91\xc7\x75\x2b\x92\x75\x34\x5c\x5b\
+\x92\x05\xaa\xf2\x81\x0c\xa1\xe2\x13\x1d\x67\x3b\x41\x28\xe2\xfa\
+\xc7\xdf\x29\xe7\x50\x60\x1d\x0c\xeb\x5c\x64\x39\x13\x80\x30\x3a\
+\xab\x87\xed\xd6\x7a\xc4\xc7\x8f\xdb\xd6\x25\xc7\xe0\x68\xc7\x63\
+\xbd\xe9\xb3\xdd\x5f\xa3\x78\x8b\x48\x07\xcc\x79\xa9\x19\x90\x0d\
+\x07\xee\xe8\x18\x49\x60\xf3\x0c\x1d\x2e\x38\xf0\x9a\x4e\x12\x41\
+\x9a\x40\x92\x9a\x0c\xf6\x15\xd3\x49\xa1\x8f\x18\x93\x0b\xfc\xde\
+\x88\xa7\xb1\x42\x66\x33\x3e\xbe\xfc\x86\x8f\x3c\xe7\xc1\x63\x23\
+\xad\xe2\xe1\x27\x43\xf5\x77\x8b\x25\xdb\xc5\x1d\xfd\xc9\x45\xeb\
+\xfe\xb8\xa9\x89\x8f\xd8\xfc\xb8\xb3\x23\xb4\xc0\xeb\x1c\x81\xd1\
+\x05\x76\x8c\xfd\xe6\xb6\x51\x45\x81\xc4\x23\xa6\x38\xb2\xd8\xdc\
+\x73\x84\x4e\x9a\xa9\xa3\x50\x8f\x05\x6a\xd4\xd0\xbb\x78\x19\x52\
+\x2a\x92\x48\x1c\x89\x04\xd9\x28\x33\x67\xed\x62\x88\x54\xf4\xcb\
+\x98\xad\x9f\xd1\x2f\x63\xca\x6a\x4b\x90\xf6\x51\x49\x0d\x9c\xc8\
+\x84\x7f\x44\xc3\x9d\xe8\x99\x9e\xb8\x4a\xf4\x4e\xe4\xc4\x09\x13\
+\x8b\x0a\xa9\x3c\x2a\x11\xe0\xa9\x82\x48\x64\xda\x86\x03\xfa\x24\
+\x90\x59\xfd\x9c\x81\x8a\x5d\x44\x53\x19\x50\x2b\xe5\x6b\x66\x36\
+\x92\x43\x58\xd6\xb6\x8f\x99\x85\xdf\xda\xfc\xdb\x16\xf8\x47\x6c\
+\x6c\xe4\xc6\x6e\xcf\xb0\xd7\xa5\x4a\xd2\x56\x15\xd1\xcf\x46\x44\
+\xf1\x3d\xeb\x46\x26\xb9\x20\x27\x25\xac\x01\x6c\x5e\x9f\x67\x2f\
+\x5d\x90\x3f\x8c\x25\xcf\x26\x0f\x5d\xae\x61\xd3\x79\xee\x02\x4c\
+\xb3\xe0\x19\x00\xf7\x85\xc7\xe0\xf0\xb0\xf1\xed\x3c\x44\x66\xc2\
+\x85\xe7\xa7\xfe\xe8\x24\x47\x6c\xfe\x71\x74\x7a\x63\xf2\xc5\x73\
+\xfc\xf9\x1b\x0e\xde\x63\x3a\x8f\x22\x5d\x5e\x27\x71\x0b\xbc\x63\
+\x40\xf7\x27\x17\x8e\x81\x87\x5e\xc9\xba\xf2\x09\xe3\x88\x78\x9d\
+\xe2\x0d\xe6\x28\x9e\x20\x3e\x91\x61\x66\xed\x69\x39\x21\x22\xa1\
+\xcb\xc1\x06\xcc\xbe\xd4\xdb\xbd\xd4\x8f\xf9\x52\xb6\xec\xb2\xc0\
+\x64\x1e\x8a\x06\xe0\xad\xee\xf5\x91\x94\x0a\xfc\x48\xcb\x05\xd1\
+\x14\x00\x86\x69\x2d\x18\x71\xcd\xa6\xfa\x59\x41\xea\xb3\xf6\x2b\
+\x92\x48\xd6\xcc\xac\xe6\x48\xd0\x1a\xdb\xd7\x00\x06\xd8\x26\x3a\
+\xb5\x5c\x50\x12\xa4\x7d\xca\x6a\xeb\x52\x6e\x51\x23\xbd\xa6\x0c\
+\x9b\xf6\x88\xd9\x71\x5e\x4e\xd8\x7e\xba\xfe\xa1\x64\x4b\x0d\x60\
+\xbd\x2d\x88\x44\x85\x52\x92\x64\x69\xbe\xfc\x81\x87\x17\x0c\x1a\
+\x7d\x76\x70\xd8\x29\x02\x51\x82\x52\x28\x15\x23\x0c\x58\x01\xa6\
+\x99\x47\x16\x57\x4e\xd3\x17\x76\xe1\xd7\x70\x60\x02\x2f\x63\x6d\
+\x16\x76\x64\xb9\x03\x35\xa2\x24\x3f\x48\xc2\x34\x69\x34\x9a\xe4\
+\x8e\x71\xf5\xdf\xbf\x65\xed\xf7\xcf\xba\x12\xf3\x6c\xce\xe2\xd5\
+\x86\xc9\xe7\xcf\xe8\x67\xe0\x4f\x6c\x61\x44\x7f\x8f\x63\x63\x44\
+\x0e\xe2\x94\x85\x79\xcb\x32\x97\x6c\x36\x7a\xa1\xb9\x04\x86\xcc\
+\x59\xe3\xb1\xfd\x3e\xa0\x3f\xd1\xa5\x66\xfd\x7b\xcf\x09\xe7\x26\
+\xa7\x3c\x1d\xd1\xf5\xfa\xc0\x9c\xed\xcb\x37\x7a\x31\x3c\x5d\xd2\
+\x7f\xb7\x25\xf9\x72\xd6\x62\x53\xbb\xd5\x72\xe0\xde\x01\x18\x60\
+\x5d\xf9\x0c\xbd\x12\x64\xda\x4e\x3a\x9e\x61\xe2\x32\x2b\x60\x58\
+\x11\x0a\xa0\x40\x22\xf0\x50\xc6\x45\x50\x40\xc7\xbe\x58\x7a\x54\
+\x51\x45\x60\x4b\xc5\xad\x36\xa4\x88\x22\xca\x60\x11\x22\xd8\x3a\
+\xf1\xaf\x5b\x8a\x32\x84\x01\x5c\x5c\x94\x64\x52\xe9\x6d\xe0\xeb\
+\xcc\x6f\xa3\xd8\x11\xa4\x3e\x65\xb5\x65\x1b\xf8\x0c\xcb\x98\xad\
+\x94\xe8\x67\xe9\x2c\x85\x8e\x66\xda\xfc\x80\xd0\xaf\x6f\xf8\x19\
+\x9d\x24\xe3\x90\xf6\x29\x1a\xcd\x97\x3d\x62\x76\x22\x73\xad\x52\
+\x4d\x00\x1f\x5f\x36\xbe\xce\x0e\x6f\x8b\x0e\xd1\xe0\xdf\x91\xcd\
+\x30\x00\xae\x8a\x8d\x0d\x91\x1e\xc9\x89\x1a\xc0\x7a\xab\x8b\x09\
+\xb6\x22\x88\x10\x47\xa5\x08\x0d\x5c\x5b\x20\xb1\xa5\xe6\x49\x96\
+\xb3\xf6\x14\xf1\xa1\x22\x0c\xa3\x9a\x89\x1b\x9e\xb1\x2e\x67\xe7\
+\x2c\xca\x80\xa9\x1f\x38\x56\xd6\xe5\x6f\x28\xdf\x55\x75\x45\x6c\
+\xf1\x3d\x0b\x60\xf5\x32\x60\xe0\xdd\x39\xb0\xcc\x06\x3e\x55\x30\
+\x65\x34\x1e\xb0\x5a\x6e\x1a\x7f\xd5\x7d\xbd\xe6\x32\xdb\x47\x93\
+\x81\x03\x6f\xdf\xe4\x3d\x6e\x57\x25\xbb\x72\x41\x6f\x55\x72\x98\
+\x68\x81\x3b\x1b\xe9\x9d\x77\x38\x99\xb2\x5f\xac\x51\x4a\xd1\x15\
+\xc9\x89\xe5\xe6\x9b\x1d\xd1\x63\x4a\xc5\x9c\x75\xe5\xb7\x81\xdc\
+\xac\x14\xf7\xd7\x94\xdb\xe1\x49\xe8\xdf\x55\xec\x02\x22\x8a\x48\
+\xd2\x95\x1e\x45\x54\x21\xa4\x87\x32\x7a\xb7\x59\x81\x73\x8b\x32\
+\x23\x0f\xb4\x5c\x88\x40\x28\x50\x03\x67\xbb\x95\x52\xea\xae\x65\
+\x22\x7c\x35\x27\x03\xf2\x55\x48\x16\xe7\x70\x00\x9f\xd0\x24\xdb\
+\x42\xed\xc2\x89\x9c\xb8\x71\x84\x89\x8c\xf4\x00\xed\x37\x27\x54\
+\xa7\xb5\x3c\x67\xa1\xe9\x18\xa2\xdc\xef\x89\x92\xb0\x4e\xb1\x19\
+\xf3\x5e\x9d\x69\xf6\xac\xce\xb0\xb1\x2d\x4f\xb7\xb5\x70\xa3\x5d\
+\x49\x05\x78\xe3\x1a\x7e\xc5\x20\xa1\xb0\x5a\x57\x65\x74\x7a\x53\
+\x0e\xbb\x66\x79\x25\xa3\xa8\xa6\xa8\xe5\x9a\x55\xb6\x67\xc4\x80\
+\x2c\xae\xc8\xe7\x7b\xe7\x6e\x0c\x07\x1d\xe6\xc5\x0e\x44\x0d\xe4\
+\xb5\xa7\x40\xc2\x10\xe1\xaa\x82\x6b\x4f\x31\x34\x4c\x6c\xf5\x32\
+\x71\xe8\x4a\xd5\xfd\x4d\xc9\x7a\x52\x34\x98\x38\x24\x5f\x6f\x08\
+\x27\x11\x53\x86\xae\x73\xa2\x3f\x29\x98\x4c\xe0\x62\xf2\x33\xf6\
+\x8b\xef\xf1\x99\x32\xf6\x4a\xf6\x95\x6e\x52\x7d\x61\xed\xb2\xb1\
+\x0f\xcb\x52\x6f\x81\x4e\xdc\xe3\x90\x35\x9c\x8e\xc6\x63\x4f\xbc\
+\x3e\xf0\x14\xc6\x3e\x45\x2c\x08\xde\x67\xfc\xdb\xf9\x96\xc3\x6a\
+\xc9\xaf\x98\x58\x67\x90\x05\xf8\x22\xc5\x25\x7b\x4c\xea\x4f\x4b\
+\x1c\xc9\x76\x71\x47\x32\xf1\x9d\x94\x38\x06\xb2\x00\x28\x27\xae\
+\x80\xd2\x64\x65\x9d\x9d\x30\x01\x74\xeb\x36\x78\xb2\xb6\xc6\x02\
+\x63\x7d\x15\x06\xb8\x2e\xd0\xde\xd0\xb9\x42\x2a\x23\x87\xf2\x96\
+\x13\xa1\x6d\x9a\x43\xa3\xb1\x32\x22\xee\xf4\x28\xc5\x54\x5b\x27\
+\x22\x32\x5b\x3d\xeb\xa2\xea\xc7\x44\x91\xa0\x30\xba\x56\xb7\x31\
+\x45\x6e\xdb\xea\xa8\x33\x00\x96\xe6\xf0\x2c\xa5\x32\x76\x4c\x64\
+\x42\xef\x25\x42\x54\x2e\x3b\x21\x1a\x8b\xba\x73\x00\xf6\xc8\xd8\
+\xf8\x15\xc9\xa1\x3c\xe9\x70\x96\xd6\x6b\x1e\xd7\x11\xff\xad\x9f\
+\x36\x58\x22\x43\x08\xdb\xb2\x94\x35\x58\x58\x7f\x6a\x12\x1c\x60\
+\xe0\xb1\xc6\xd3\x95\x3f\x20\xce\xbc\xba\x64\xed\xa4\x9d\x62\x10\
+\x17\x14\x55\xec\x00\x9d\x15\x01\x59\xc7\xd3\xc9\xba\x24\xd5\x76\
+\x5c\xec\xd7\x00\x8e\xdb\xeb\xf2\x66\x79\x24\x0c\x23\x92\x38\x61\
+\x32\x9d\xd5\x8c\x3f\xe8\xf0\xf4\xf1\x15\xc3\xc9\x98\x07\x5f\x7e\
+\xc1\x83\xc7\x3d\x18\xfb\x74\x27\x43\xc6\x13\x03\x5e\x03\x4e\xb7\
+\x35\x51\xcf\x4e\xdc\x70\x3a\xcc\x63\x55\xb9\x6a\xbd\x26\xc8\x14\
+\xc5\xa3\x98\x27\x13\x0d\x56\xdb\xad\xdd\x89\xf5\x71\xb4\xcc\x0a\
+\x17\x4d\xfd\xb1\x4b\x93\x85\x8f\x17\x76\xc7\x76\x5d\xba\x3d\xe0\
+\x97\xd2\xe3\x60\x80\x77\x68\x54\xdb\x9a\x16\x98\x03\x76\xc3\xdb\
+\x15\x0d\xbd\xdb\x64\xd0\x33\xc7\x5f\x10\x11\xd1\x24\x24\x4b\x2e\
+\xf0\x45\x0d\xd8\xaa\x1f\xeb\x34\x5c\x54\x39\x97\x57\x82\x03\x27\
+\xc7\xc5\x68\x0b\xda\xa6\xa1\x26\x74\x01\x46\xcb\x14\x79\xc6\x6a\
+\xf1\x5a\x1d\xd8\xad\x05\x89\xa9\xd6\x09\x11\xe9\xb6\xfd\x8e\xef\
+\x40\x6b\xc1\x7c\x0c\xea\x3c\x2e\xdb\xa1\x21\xd0\x92\x41\x94\xad\
+\x56\x26\x5b\xec\xf0\x2f\x9e\x52\x0c\x1e\x90\xc7\x25\xfe\xc5\x53\
+\xdd\x35\x1d\x47\x84\xd3\xae\x91\x1e\xb5\x2b\xb1\x34\xbe\xe9\x02\
+\xdf\xb1\x70\x7c\xa8\xc8\x3a\x9e\xc9\x73\x68\x3d\xbc\xc8\xca\x16\
+\x13\x77\x46\x55\x43\x5e\x68\x67\xc2\x76\x44\xef\x95\xe2\xd5\xcb\
+\x5f\xe8\xac\xef\xa6\xc4\xdf\x7e\xa0\xb8\xff\x86\xe2\xfb\xb9\x66\
+\x57\x13\xc2\x71\xdb\x26\xdb\x36\xfe\xdf\x6f\x6f\xf5\x76\xb1\x86\
+\x65\x49\x55\xae\x38\xac\x6a\x0f\xbc\x13\xf7\xdc\xc8\x80\xe9\x17\
+\x9f\xb3\xaa\x2a\x3e\x2e\xee\xe9\x4e\x86\x94\x62\xd6\xc8\x9b\x27\
+\xf8\xe8\x80\x7d\xdd\x28\x7a\xe1\xd8\x37\x59\x04\x2d\x36\x06\xc8\
+\xfd\xad\x2b\xa4\x9c\x6b\x52\x0d\xab\x28\x03\xe9\xd5\xe1\x19\x03\
+\x13\x81\x70\x5e\x71\x2d\x13\xbc\x56\x74\xb2\x95\x87\x20\x42\x52\
+\xb5\x53\x6a\x22\xd7\x93\x85\x9a\xa5\xe4\x46\x93\xe7\x71\xb9\xd8\
+\x39\xbe\x4a\x9d\x3c\x2e\xed\x82\xcd\xde\x67\x26\x02\x49\xa0\x5f\
+\x64\x7a\x87\x20\xd2\xbe\xb0\x69\x41\xe2\x4c\x97\x73\x93\x85\x2d\
+\x2b\x4b\xe5\xe1\x99\xd8\xa9\x05\xad\x95\x15\x76\xf2\x8f\x03\xb0\
+\x59\xcc\xe9\x49\x40\xa5\xb3\xd8\x94\x52\x08\x3b\x94\x44\x98\x8a\
+\x5c\x4f\x03\x39\x30\x56\x5c\xd1\xf0\x92\x6d\x89\x7a\x58\xe9\x06\
+\xad\x45\x55\x7b\xc8\x71\x50\xe0\x6f\xfa\xc4\x83\xed\x89\x76\x76\
+\x0b\xbe\x46\x1a\xee\xb0\xf2\xf4\x5a\xcb\xb1\x73\x6a\x5c\x0a\x78\
+\x9b\x49\x7e\xc8\xde\xf1\x2c\x7e\x4c\xc6\x90\xb2\xd4\xef\xe9\x57\
+\x3e\xf1\x62\x8d\x9a\x24\x0c\x97\x25\xeb\x71\x45\xb9\xd0\x7a\xb7\
+\x4e\xc7\x4d\xdd\xa2\x6e\xbc\xd2\x8b\x39\x7f\x92\xa0\xa8\x28\x17\
+\x23\xfc\x49\x41\xb6\x80\xb7\x8b\x35\x89\xb7\xe0\xd9\xaf\x3c\x41\
+\xc4\x7d\x3e\x6e\x34\x03\xaf\x4d\x85\xf3\x84\x55\x0d\x13\xd7\x8d\
+\xa2\x5a\x4e\x00\xdc\x72\xc0\x67\xc1\xc5\xe2\x21\xc1\xf4\x00\xf8\
+\xe4\x65\xff\xbc\x17\x6c\x41\x3c\xdf\x54\x44\xb9\x42\xe6\x25\x22\
+\x54\xd8\xce\xa4\xb2\x55\x46\x8e\xf0\xe5\xf9\x84\x82\x6a\x65\x2a\
+\xda\xc5\x0d\x0d\xe0\xcd\x49\x41\xc2\x5e\xfb\x54\xde\x41\x0a\x41\
+\xa4\x54\xed\x0f\x3b\xc0\x4a\x22\x21\x74\xa9\xb9\x51\xbd\xcb\x02\
+\x9f\x7e\xea\x53\xcc\xaa\xd6\xdf\x64\xab\x68\x9f\x5a\xd0\x35\xdb\
+\x93\xd4\x32\x68\x69\x62\xeb\x50\x0c\x4e\xfe\xbd\xd9\xc9\x6d\xa1\
+\x62\xc7\xc8\x1a\xc8\x3e\x42\x64\xee\xd8\x65\xc3\x40\x81\x97\xb5\
+\x87\xac\x54\x31\x50\xb2\xde\xed\xb5\x5f\x5c\x04\xf4\xb3\x88\x6d\
+\x2c\xc9\x81\x69\xa3\xec\xdc\x04\xb0\x5d\x04\x0e\x2b\x41\xb9\x08\
+\xd8\x0e\xf4\x2a\xc3\xb2\x73\xea\xe4\x46\x8f\x19\x13\x7e\xfa\xf8\
+\x67\x6e\x41\x96\x15\x11\x79\xa6\x18\x32\xe7\x36\x8e\x18\x02\x6f\
+\xa3\x1d\x43\xba\xf8\x93\x02\x1f\x5d\xf2\x1e\x8d\xa6\x4c\x0f\x4b\
+\xfc\xec\x0b\xc6\x23\x8f\xca\xd7\x12\xc1\x5f\xac\x18\x4e\xc6\xdc\
+\x4f\x2a\xfc\xc5\x8a\xf1\x17\x63\xc2\xc5\x92\xbb\xc5\x90\x37\xef\
+\x16\x4c\x33\xd8\xee\x74\xa5\xed\xcb\xa1\x47\xc7\x24\xeb\x9a\x12\
+\xa2\x29\x29\xf2\xec\x3c\x0a\xd2\x49\xe1\xa6\x6d\x08\x30\xc9\xb8\
+\xba\x68\xd2\x64\xe4\x50\x9b\xfd\x15\x03\x7c\x36\xb9\xa0\x13\xe2\
+\x1a\x3a\x05\xc2\xb8\x13\x19\x05\x10\x50\x39\xc6\x16\x26\x5b\x21\
+\x8e\x18\xd9\xea\xd9\x54\x7a\xf4\x3b\x7b\xb2\xc3\x00\xc8\xd9\x02\
+\x81\x54\x10\x9d\xd6\xdb\x4e\x8a\x1f\x8e\x89\x4d\x5a\xcd\x54\xea\
+\x22\x03\xe6\xd6\x7d\x40\x50\xc6\x4e\x4b\xdb\xe6\xd0\xf6\xac\x89\
+\xcc\xfd\x8d\xc7\x9a\xb8\x32\x0b\x33\x08\x8c\x4c\xa8\x5a\x5a\xf8\
+\xf4\x62\xbc\xe6\x62\xe3\x16\x27\xea\xcc\x0e\xa2\x41\xed\x1b\xfb\
+\x6d\x4e\x60\x3e\xaf\xe8\x09\x0d\xe6\xaa\xd6\xc2\xe0\xeb\xad\xd0\
+\x1d\xde\x76\xc1\xb3\xde\xc1\xb0\x17\x01\xca\x01\xbd\xc9\xca\xa0\
+\x47\x02\x9c\xbb\x24\xb1\xa9\xe0\x21\x18\x3f\x7d\x42\xb8\x49\xe9\
+\x4e\x9e\xd1\x05\xa2\x89\x62\xd3\x89\x74\x03\xd0\xea\x8e\x71\xef\
+\x8a\xe5\xee\x9a\x71\xef\x8a\xbb\xc5\x92\xe9\xa4\x60\xfe\xca\x94\
+\xd2\x78\x69\xaa\x6a\x13\x57\xa3\xbb\x5b\x4c\x18\x32\xe7\x8e\x29\
+\x77\x8b\xa5\x71\x78\x34\x83\x87\xbb\x3d\x79\x16\x71\x31\x9e\x50\
+\x4e\x86\x28\x8a\x13\xd9\x69\x01\x6c\x01\xb9\x1b\x97\xb0\x80\x64\
+\xe2\x73\x28\x3e\xf0\x78\xf1\x84\x74\x52\xb0\xae\xec\x20\x2c\xce\
+\x96\xaf\x7d\x52\x5d\xec\x18\x0c\x62\xa7\xe5\x06\xa6\x75\x48\x49\
+\x2d\x27\xea\x92\x70\x44\x61\xb5\x70\x43\x5b\xda\x38\xa6\x38\x93\
+\x03\xf6\x91\x26\xc0\xb1\xa9\xa1\x6a\x16\x91\xcd\x7e\x0c\x3b\x8c\
+\x30\x6a\x15\x94\xdb\xcd\x49\x91\x59\xb0\x49\x03\xee\x08\xd9\xaa\
+\xf4\xcd\x92\x82\xc2\xf6\xcb\xd9\xd6\xfc\xc6\xce\x55\x11\x23\x0c\
+\xd0\x76\xc6\xd7\x3d\x76\x29\x3c\x91\xa1\x96\x7b\x2a\xd1\x6b\x31\
+\xf1\xd6\x46\x34\xe3\xa3\x24\x55\x30\xe0\xb0\xd9\x20\x06\x89\x03\
+\xb6\xb2\xfa\x18\x9c\x57\x8c\x5b\xe4\x95\x2d\x06\x0e\x3c\x3d\x39\
+\x28\x35\x16\x5d\x62\x99\xdc\x56\xf6\x8c\x55\xb7\x46\xdb\x6c\x04\
+\x85\x8b\x74\x5a\x56\x76\x51\xcd\x66\xb0\xde\xb2\x31\x90\xc4\x39\
+\x12\x1d\x74\x0f\xc2\x80\x57\x1f\xfe\x8a\x7e\x57\x10\xee\x04\x79\
+\x76\xad\xa5\x6f\x3e\xe4\x62\x78\xed\x7a\xeb\xc2\x18\xe6\x8b\x88\
+\x3c\x96\x84\x59\x44\x1e\x0b\x53\xc8\x91\x0d\xfa\x92\x6c\x7a\x13\
+\xf2\x9d\x74\x05\x9d\x61\x35\x61\x34\x9a\xea\x46\xd9\x09\xbc\x01\
+\x62\xd6\x08\x1e\xb4\xfe\xed\xad\x30\x90\x92\x2c\xf3\x82\xa9\x17\
+\xba\x8e\x98\x4e\xf0\x19\xe9\xa4\x40\x72\x4f\xd4\x82\xb0\x0d\x18\
+\x0d\x1b\x8b\xbc\xc4\x44\x31\xed\x62\xce\xe8\x5d\xd5\xe8\x81\xb3\
+\xb2\xa0\x38\xb3\x60\xb2\x61\x20\xa1\x6c\x0f\x5e\x0d\x3e\x69\x3d\
+\x61\x36\x8d\xc7\x3e\x7d\xb1\x15\x38\xcb\xa6\x16\xe6\x91\x6d\xbb\
+\x6f\x48\x15\x07\x6f\xc3\xca\x49\x54\x71\x48\x03\x48\x24\xa8\xa8\
+\x9e\x94\x69\x62\x97\x98\xc5\x9b\x05\x74\xaf\x31\xc9\xd2\x02\xd8\
+\xca\x09\x31\xee\x1a\x56\x8e\x1c\x13\x27\x87\x92\x66\x48\x2c\x63\
+\x4f\x6c\xf4\x71\xb0\xd1\x51\xcd\x30\x36\xa0\xb3\x9f\xd3\x00\xad\
+\x6a\xe6\x2b\x44\xc9\x61\x37\x77\xce\xc5\x61\x37\x87\xa8\x24\x69\
+\xac\x13\x6a\x56\xcf\x48\xbd\x92\x40\xfa\xf8\xa2\x44\x1c\x22\x07\
+\xe0\xb5\xa7\x75\xf6\x49\xca\xed\xf8\x90\x4c\x08\xdc\xb3\xb9\x87\
+\x8b\xe1\x9e\x71\x3c\x26\xcf\x14\x0b\x25\x19\x18\xef\xfa\x62\xb8\
+\x67\xdc\xbb\xa2\x8c\x57\xae\x6b\x63\x70\x90\x04\x19\x74\x26\x3d\
+\x14\xa6\x0b\x64\x3a\xf9\xd1\xdf\xd0\xc6\x2f\x2b\xff\xd2\x84\x82\
+\x16\x74\xbd\x91\x2b\xbf\x5b\x09\xe1\xb6\x26\x60\x34\x0e\x77\xbc\
+\x5d\x94\x8e\x8d\xfd\xc9\x82\x74\x31\x21\x99\xcc\x18\x2c\xbe\x85\
+\xe1\x57\xba\x3d\x69\x7b\xa1\x19\xdc\x3a\x1c\x59\xe2\x2c\xb6\xd0\
+\xfa\xbe\x55\x54\x51\xca\xb8\x66\xd7\x48\xb4\x17\x69\xcd\x85\x9f\
+\x54\xf8\x4d\xf7\x41\x6d\x80\x01\xd2\xa6\x39\xc0\xb0\xf0\xce\x59\
+\x74\x41\x43\x38\x14\x48\x02\x3b\x53\xc2\x14\x43\xb6\x41\xe6\xc8\
+\xd7\x8d\x89\x35\xc5\x01\x54\x04\xaa\xd6\xc3\x56\x7f\x46\xa6\xca\
+\xe7\xba\x76\x45\xd5\x72\x20\x9a\x96\x9a\x65\xdf\xe3\xaa\x9d\x6d\
+\x16\xf5\x44\x81\x5a\xee\x9d\x2e\xb2\x4c\x7c\x2a\x26\x72\x0a\x21\
+\x08\x94\xc2\x0b\x29\xf9\xbd\x95\x00\x00\x20\x00\x49\x44\x41\x54\
+\x06\x6c\xf7\x77\x24\x45\x8f\xce\x80\x46\x67\x89\x72\xec\xac\x7d\
+\xe4\x7a\xf8\xa0\x10\x82\xd4\xcb\x48\x2a\xed\x4c\xf8\x55\xc6\x6e\
+\xa7\x0b\x0b\xc1\x46\x5b\xa9\x5f\x4c\x47\x2c\x6d\x2b\x96\xf9\xda\
+\x8a\x95\x2e\x96\xac\x1b\x9e\xf2\x8f\x01\xb8\xd9\xf2\x14\x74\x57\
+\x14\xbd\x09\x4f\xe2\x88\xee\x95\x68\xb5\xf2\xd7\xbf\x6a\xcf\x65\
+\x94\x01\x96\xa3\x89\xbb\xbe\xc8\x22\x4a\x5b\xf2\x68\xb4\x51\x35\
+\x27\x13\x09\xf1\xce\xe8\x7d\xc9\x3a\x8b\x78\x44\x40\x35\xdc\x00\
+\xbd\x96\x23\xe1\xa4\x84\x19\x66\x68\xc7\x66\xf5\x96\x3e\xfe\x64\
+\x41\xb9\x98\xe0\x4f\x16\xc0\x8c\xcd\xe4\x2b\x2e\x4c\x7b\x52\xd9\
+\x2f\xf0\xb7\xfa\xf5\xf6\x3d\xf6\x4a\xe9\xb2\xb3\xed\xc0\x08\xa4\
+\x6c\x31\x5e\x13\xb4\xcd\x7f\x6a\x57\x7a\x0e\xc0\x71\x51\x92\x89\
+\x9c\xb8\xe8\x91\x1d\x36\x2d\x85\xab\x7d\xdb\x1e\x19\xd0\x27\x62\
+\x6b\x80\x6b\x8b\x2b\x4d\x19\xd2\xeb\x47\xf8\x69\x40\x91\xa4\x48\
+\xe9\x1d\x39\x15\x5e\xad\x9e\x8d\x0e\xce\x84\x47\xac\xac\x7f\xbc\
+\xa3\x93\x14\x3a\xb3\xa0\x70\x4c\x6c\x01\xaa\x27\x60\xd6\x32\xa8\
+\xf7\x09\x9f\xd8\x16\x3b\x6c\x76\xc2\x96\xa3\xb7\x45\x87\x04\xad\
+\x7f\xad\x53\xb1\x53\xb9\x63\xe3\x3e\x17\x1a\xc8\xef\x2b\x78\xd4\
+\x6f\x15\x3b\x9a\x3e\xb2\x65\x66\x9f\x0c\x5d\x14\xcc\xb8\x55\x8a\
+\xe2\xed\x82\x0f\xab\x5b\x76\x77\x7b\x3e\x2c\xdf\xf2\x48\xe4\xfc\
+\xd5\x93\x9f\xf0\xd3\xe7\xda\x76\xaa\x06\x53\x3a\x55\xc2\xd5\x64\
+\x4c\xe0\x95\x40\x41\xbe\x92\x70\x26\xe2\xd9\xb4\xdd\xec\xed\xf5\
+\x22\x73\x76\x1f\x71\xa9\x3b\xb0\x33\x93\xcb\xcb\xd2\xd3\xd7\x34\
+\x0f\xdd\x71\x42\x9a\xa5\x5a\x5f\x37\x82\x44\xee\x08\x9a\x09\xfa\
+\x2c\x59\x2e\x20\x98\xe0\xbc\xe4\x92\x7b\x32\x86\x8c\x58\x81\xf2\
+\x4d\xa1\x83\xf6\xe2\x4e\x49\xba\x22\x22\xdc\xdc\x36\xdc\xa9\x19\
+\xcb\xe2\x9a\x31\x57\xa4\x8b\x92\xab\xa9\xfe\x4b\x9a\x4c\xdc\xf2\
+\x8a\x15\xba\xec\x8c\x49\xa4\x45\xd1\x84\x54\xea\x6a\x91\x30\x76\
+\x1a\x26\x81\x56\x18\xe0\xb9\xd2\x85\x19\xc8\x9d\xf5\xe3\xfa\xe7\
+\x92\xbe\x2b\x2b\x47\x91\x60\x7b\x34\x1c\xb0\xa9\x77\xb7\x48\x44\
+\x14\xd5\x95\x3f\x24\x24\x11\x30\xa5\x44\x11\xa4\x1e\x45\x52\x3a\
+\x2d\x8c\x8a\x9c\x6b\x81\x52\xc4\xf4\x88\x84\x44\xa8\x8c\x83\x9e\
+\xd3\xd3\xea\xa1\xeb\x89\xc8\x01\xd3\x5e\xb7\xba\xb8\x82\x93\xf6\
+\x24\x77\x5b\x05\x48\xea\x8a\x5d\x4e\x45\x1f\xc1\x76\x0f\xc9\x26\
+\x85\x60\xe0\xd8\xb8\xe9\x1b\x57\xfe\x0c\xaf\xeb\xa1\x96\x8a\x24\
+\x38\xb8\xb2\xb4\x17\x0c\x34\xd0\xb7\xd7\x6c\xc3\x09\x87\x4d\xca\
+\xdb\xbb\x0f\x6c\xb2\x15\x3f\x7c\xfb\xbd\xfe\x61\xa3\x4b\xd4\xf5\
+\x3b\xae\xf7\x1a\xe4\x7f\x79\xb7\x81\x3f\xff\xd7\xfc\xcb\x8b\x01\
+\x5f\x3e\xec\x90\x2d\x0b\xe2\x71\xc0\xdf\xfb\xfa\x37\x99\x3d\x0b\
+\x18\x8b\x3e\xb3\xcf\x1e\x30\x59\xc3\x75\x67\x8f\x98\x07\x84\x93\
+\x91\x2e\x96\x78\x05\x1e\xc9\x09\x30\x3d\xb5\x23\x4e\xba\x75\x07\
+\x36\xb0\x5e\x64\xc4\x41\x41\xb6\x08\x18\xf6\xba\x8d\xce\x6b\xbd\
+\x28\x94\xd9\x0c\x50\x8e\x6d\x93\x38\x41\x70\x8f\x6a\x4d\xe0\x94\
+\x2c\xb2\x31\xdb\xf8\x9a\x07\xf1\xd8\xb1\xeb\x7a\xb7\xe7\x89\xd7\
+\x83\x46\x50\xc8\x02\xf8\xb8\xd8\x91\x0f\xea\xeb\xe9\xc2\xca\xc9\
+\x7b\x60\xc2\x87\x6a\xc1\x8c\x19\x61\xb7\x51\x59\xb5\xd5\xbe\x6c\
+\x4d\x57\x24\x86\x89\x5b\xae\x6d\xbb\x4d\xc8\xea\x61\xcb\xa0\x96\
+\x4f\x14\x15\x42\x49\x5d\xc9\x33\x00\xb7\x56\x17\x46\x0a\xb8\x09\
+\xf2\x26\xff\x10\x48\x0f\x19\xd1\x7a\x3f\x5b\x1c\xd1\x96\x9a\xfe\
+\x1b\x92\x08\x48\xeb\x50\x7b\xa4\x1a\xf6\x9c\x93\x17\x0a\x44\x84\
+\x42\xb5\x7a\x1a\x6c\x5e\xa2\x6d\xff\x65\x8d\x83\xe5\xa9\x57\xdc\
+\x6a\x4f\x32\x5e\xf1\x71\xe9\x19\xd0\x63\x5f\x8b\x3b\x44\x3c\x3d\
+\x11\x18\x91\xc8\x08\xd1\xab\xfd\x3c\xee\x12\x66\xba\x2c\x1d\x6c\
+\x36\x04\x1b\xf8\xb6\x90\xdc\xbe\x7b\xc5\xab\x77\x19\xea\xfa\x1d\
+\x37\xcb\x37\xf5\x0e\x14\x6b\x6a\x98\x45\x4f\xb9\x97\x6f\x78\xf6\
+\xf4\xa7\x74\x0b\x0d\xea\xef\x6e\x0f\xa4\x77\x1b\x7e\x7a\x7b\xe0\
+\x7f\xf8\x8b\xff\x91\x17\xcf\x03\xa2\xc7\xff\x21\xff\xf1\x3f\xe8\
+\xf1\x60\xf4\x1f\x10\xcb\x15\x74\x21\xcf\xbb\xf8\x1d\x89\x57\x3d\
+\x04\x8e\x3a\xad\x9b\x15\x3c\x7a\x48\x46\x94\xdc\x33\xec\x75\xf5\
+\x00\xed\xd0\xce\x10\x6e\x57\xd1\xce\x8d\x67\x55\xce\x8d\xa9\x07\
+\xaf\x44\xb1\x62\x9f\x17\x7a\x04\x80\x29\xf5\xf7\xb3\xa8\x36\x33\
+\x1a\x91\xd4\x93\xe9\x9a\x4a\x4f\x1e\x7a\x6b\x6f\x4f\x16\x70\x87\
+\x93\x14\x0f\x17\x0b\x18\xce\xc8\xf7\x99\x03\xb2\x93\x23\xb6\x83\
+\xc5\xdf\xb7\x3d\xe4\x61\xe9\xb1\x95\xd2\x68\x52\xa9\x01\x28\x3d\
+\x8a\xc8\x00\xcf\x68\xe1\x75\x2a\x11\x89\x06\xa6\x02\x02\x93\x58\
+\x3b\x8e\xa7\xdb\x02\x48\xab\xf3\xf6\x9c\xa9\xd6\xd0\x9e\xa9\xf4\
+\xf0\xcd\x02\x4f\x2f\xec\xa4\x0b\xfc\x38\x6b\xad\xe1\x11\x97\xd5\
+\x16\x21\xa6\x28\x2a\x76\x66\xae\x84\x05\x72\xd3\x99\x50\x67\x5c\
+\x89\xe3\xdc\xc4\xb1\xfd\x66\xc3\xf1\x22\xee\x12\x66\x3e\xdb\x3d\
+\xa8\xe5\xbe\x55\x82\x6e\xca\x06\xab\x50\x42\x33\x88\xe5\xa6\x08\
+\xd8\xbc\xbb\x65\x79\x77\xcd\xdf\xbc\xc9\x1d\x38\x89\x1f\xb3\xca\
+\xbf\xe6\x8b\x81\xa2\x5b\xbc\x63\x1f\x3c\x6e\x01\x79\x16\x3d\x65\
+\x16\xa1\x1f\x7b\xfa\x53\xb6\xa6\xdf\xf7\x46\xbe\x81\xd7\x6f\xf8\
+\xfd\x6b\x9f\xaf\x2e\xbf\xe3\xf1\xd3\xdf\xe2\xcb\x9f\x8c\x08\x46\
+\xa5\x8e\x86\xae\x37\x8e\x4d\x5d\x51\x84\x7a\x0e\x73\x9a\xa5\x10\
+\xef\x48\x48\x4c\x6b\x93\x32\x91\xcd\x5e\xeb\x76\x42\xaf\x9e\x7b\
+\xd1\x92\x18\x5a\x4e\x94\x8b\x40\xa7\xe1\x0c\x4b\x87\x8d\xcc\xf3\
+\x49\x37\x89\x25\x9e\x13\x97\xc1\xa7\x14\x11\xdb\xc5\xc7\xd3\xcf\
+\x31\xda\xf8\x76\x82\xd3\xc4\xc7\xaf\xb7\x3a\x3b\x29\xbb\xa6\x65\
+\xdf\xf8\xba\xbe\x99\xe0\x6e\x17\x5c\x76\x3b\xd8\x56\x64\x81\x02\
+\x15\xa2\xa8\x78\x38\x6b\x03\xd1\x2d\xd4\x8e\xfc\x5f\xdf\xee\x08\
+\x8d\x12\x36\x47\xbd\x19\xc7\xd5\xbb\x56\xde\xd8\x31\xaf\x74\xa7\
+\x3a\x88\xec\x8e\x61\xc6\xf5\x1f\xbc\x7e\x63\x9a\x4e\xfb\x3c\x1e\
+\x9f\xb2\xd4\xf2\xa3\x56\xa5\x66\xc3\xa8\x75\x2b\x8e\x2b\x76\xeb\
+\xd8\xc7\xf7\x0b\x50\x92\x30\xbb\x38\xb1\xdc\x74\x9c\x32\xa5\xa8\
+\x12\x96\x4a\xb2\x58\x2c\xb9\xfb\xdb\x1f\x78\x69\xe6\x32\xdc\xef\
+\xeb\xe7\xcf\xa2\xa7\x20\x7f\x01\x3c\xe5\xe3\xc3\xe7\x3c\x0d\xcc\
+\x21\xfe\x16\xc2\x27\x2f\xe0\x5e\xdf\xde\x07\x8f\x99\x8f\x5e\x33\
+\x5d\x3d\x77\xe0\xee\x16\xba\x7f\xed\xdb\x1b\x8f\xf7\xea\xcf\xa8\
+\xe6\x13\x2e\xfe\xee\xd7\x8c\x45\x9f\xac\x0f\x76\xc4\xc4\xc4\x00\
+\x2b\xcf\x22\xbc\xfd\x12\x46\x38\x6d\x2b\x19\x99\xd6\x26\xad\x89\
+\xed\x10\x40\xdb\xea\x94\x92\xb7\xe4\x45\x13\xc0\x76\xa4\xc0\xc9\
+\xbf\x3d\x53\x10\xf7\x74\xff\xdf\xe4\x9e\xa6\xa5\xd3\x94\x0f\xee\
+\xfa\x27\x4e\xa1\xd0\x09\x3e\x63\x77\xf7\x81\xf1\x85\x4f\xba\x98\
+\xe8\xcc\xd0\x51\x83\x41\xf3\xfd\x5a\x4c\xec\x37\x42\xf1\x27\x8b\
+\xdc\xc0\x2e\xe5\x36\x08\x11\x35\x3a\x99\x55\x6d\x7c\x35\x1a\x33\
+\xa3\x33\xe0\x94\xb4\xa5\x84\x3c\x03\xe6\xd6\xb4\x9f\x93\xce\x46\
+\xe3\x25\xab\xfa\xb1\x43\x1a\xd0\x49\x0a\x0a\x0b\x76\x3b\x40\x45\
+\x54\x27\x65\x71\x61\x58\x53\xcf\x24\x6e\x3b\x17\x1a\xac\x09\x1b\
+\xbf\x6a\x8d\xb6\x02\x58\xc7\x3e\x9e\xaa\x88\x45\x0e\x22\x22\x38\
+\x94\xdc\xed\xef\xb9\x60\x76\x02\xe4\x55\xe5\x91\x2f\x17\xbc\x7e\
+\xbb\xe0\xf5\x9f\xfd\x6b\xae\xf7\x25\xe9\xdd\x86\xe4\x62\xd0\x06\
+\x30\xf0\xe2\xab\x7f\x00\xc0\x4f\x2e\x66\xfc\x5f\x87\x11\x7f\xbf\
+\xb3\x82\xce\xbd\xae\x52\x3d\x86\x37\xea\x9a\xd1\x7d\xce\x74\xf5\
+\xfc\x84\xa5\x01\xc6\x83\x1b\xb2\x65\xc1\x1f\x2e\xef\x78\x51\x24\
+\x3c\xfb\xf2\x09\x97\xcf\xd7\x04\xa3\xaf\x48\xb3\x1d\xfd\x2a\x6a\
+\x05\xfe\xf3\x5c\x92\x66\x11\xc4\x21\x65\x76\xcf\xf5\x62\x4f\x1c\
+\x14\x84\x59\xc4\x7a\xb7\xa7\x9f\x45\xa6\x62\xa7\xc1\x3a\x1a\x5e\
+\x1c\xfd\x00\xf7\x46\x72\xd4\xd2\xc3\x4e\x0f\xb2\x2d\x4b\x13\x11\
+\x51\x66\xf7\x67\x17\x89\x9f\xac\xd8\x0d\xda\x32\xe6\x50\x7c\xa0\
+\x77\xd1\x65\x79\x77\x4d\xef\xa2\x0b\xcc\x4c\x05\xf4\x47\xca\xce\
+\x0e\x58\x52\x1d\x85\x79\x2a\xa4\xe9\x4c\xde\x22\xf5\x4c\x09\x67\
+\x87\xe1\xba\x3b\xdc\x20\x6d\x75\xe4\x2a\x9c\x01\x63\xd0\x90\x26\
+\x67\x2b\x75\xe7\xcb\x5e\x8d\xec\x84\x6a\x06\x3c\x5a\xfa\x8c\x46\
+\x07\xc7\xb9\x2a\xa2\x6a\x1c\xfe\x43\x51\x11\x9a\x53\x1f\xb8\x8a\
+\x9d\xef\x52\xbf\x8e\x89\x0b\x91\xd2\x27\x66\x2b\xb4\x0f\xac\x94\
+\xa4\x1f\x0c\x10\x9d\x94\x2d\x29\xa2\x39\x1d\x49\x49\x3e\x2e\x56\
+\xfc\xe2\xdf\x7c\xcf\xcb\xd7\x6f\x48\xef\x74\x2e\x20\xb9\x18\x38\
+\x20\xcf\xa2\xa7\x0c\x1f\xc2\xd7\xbf\xf6\x05\x9f\x5d\x3d\xa5\x5c\
+\xf7\x99\x87\x1e\xff\x19\x70\xb3\xdc\x33\x9e\xe9\x21\x21\xcb\xbf\
+\x79\xcb\x53\x71\x05\x8f\x61\xfd\xae\xd6\xcf\x57\x5d\x9f\x3d\x70\
+\x2f\xdf\x00\x4f\xe9\xa2\x59\xf9\xe5\xab\xd7\x04\xea\x15\xd9\xe1\
+\xef\xf1\xc5\x57\xdf\xe2\x75\x9e\x52\x25\x29\xc5\xca\x07\xfa\x6c\
+\xf7\x8a\xe7\xbe\xaf\xa7\xc5\x65\x39\xf9\x62\x45\x8e\x07\x03\xed\
+\x3b\x8d\x7b\x57\x44\x13\x75\x04\xd6\xf3\xce\x73\x21\xba\x04\x6a\
+\x6f\x8a\x32\x5e\xab\x42\xb8\x57\xaa\x76\x30\x1a\x71\xcd\xba\xf1\
+\x34\x69\x6d\x8b\xde\x15\xe1\xe6\x07\x0e\xc5\x07\xc3\xc0\xba\x5c\
+\x5d\x2e\x26\x74\x02\x78\xb8\xf8\x1e\x86\x33\x42\x7f\xeb\x7e\xcd\
+\xe3\x1d\x22\xe9\x77\x08\x0f\x44\x7a\xa2\x62\x54\xb9\xe8\x65\xad\
+\x65\x95\x03\x30\x91\x3e\xac\x67\x87\x2e\x7e\x60\x60\x7a\x34\x57\
+\xa2\x06\xb0\x6c\xed\x00\x7d\xfb\x63\x2b\xb3\xc3\x44\xc7\x13\x7e\
+\x9a\x4c\xac\x1f\xf1\xb6\x15\xbd\x7e\xa4\xb3\xc2\xa2\x6a\xa5\xd6\
+\x38\x3e\xa5\x55\xe3\xf4\x60\x34\x4f\x0b\x66\xde\x51\x1c\x55\x1a\
+\x43\xe5\x9d\x48\x8a\xe6\xc2\x4e\x29\xdd\x67\x97\x31\x44\xa9\x0d\
+\x7d\x11\xbb\xbe\xba\x9c\xd2\x81\x77\x6b\x5e\x9b\x2f\x7d\x16\x8b\
+\x0d\xdf\xfd\xe5\x1f\xf3\xd2\x2c\xc6\x2c\xfb\x5a\x30\x03\x46\x0a\
+\x3c\x06\x15\xf0\xf9\x64\x4c\x32\xd1\xc5\x85\x70\x55\x71\xff\xc5\
+\x0b\xf2\xfb\x35\x9b\xfb\x3b\xe6\xbf\x35\x63\xf9\xdd\x5b\x6e\xee\
+\xee\x19\x3e\x7e\x0a\x87\x37\xac\x6f\x71\xda\xf9\xaa\xeb\x73\xdd\
+\x90\x17\xfb\xe0\x31\xdf\xde\xbc\xe3\x2b\xfe\x94\xb9\xf7\x35\xd3\
+\x2f\xa1\x58\xfd\xc4\xc8\x81\x85\x9e\xb8\xee\x5f\x81\xc9\xe3\x86\
+\x93\x11\xd3\x46\x77\x74\x84\x72\x5d\xd2\x1a\xc0\xe9\x19\x20\x9b\
+\xd0\x8e\xb2\xc3\x0c\xdb\xcf\x49\x33\x5c\x72\x2e\xcf\x25\x8c\xdb\
+\x3a\xb6\x14\x91\x2b\x70\xd8\xad\x67\xe6\xd8\x5d\x97\x57\x3c\x0b\
+\x4a\x7a\x17\x5d\x76\x77\x7b\xc7\xc6\x37\x8b\x2f\xe8\x15\x77\x84\
+\xe5\xdf\x39\x49\xc1\x95\xa6\x33\x3b\xdd\x1e\x08\x3b\x48\x94\xf4\
+\x10\x78\xad\xc6\xce\x52\x7a\xe6\xd4\x5e\x9e\x69\xee\xd4\x95\x39\
+\xa1\xb4\x1f\xdc\xca\x50\x28\xe9\x5c\x09\xfd\xe3\x5a\x45\xa4\x41\
+\x1b\xa4\x3e\x71\xb5\x25\x13\xa7\x5a\xda\xce\x21\xb6\x47\x02\x89\
+\x47\x5c\x94\xb0\x3e\xe8\x25\x42\x3f\x6e\x2f\x10\x8e\x00\x2c\xa8\
+\x58\xd8\x40\x90\xd2\x3e\xb7\x70\x61\x9c\xc8\x01\x59\x1d\xb1\xf2\
+\x49\x2a\xaa\x31\x3c\x51\x88\xc8\x01\xd4\xc7\xd3\x41\xa0\x32\x21\
+\xa7\x64\x4b\x46\x9f\xd8\x9d\x16\x01\xe0\xe3\xe2\x3d\x2f\x7f\x71\
+\x7d\x16\xc0\xcb\x71\xc4\x78\xa9\xbf\x99\xeb\x7d\xc9\x0b\xe0\x90\
+\xbd\xe3\xcf\xfe\x48\x31\x1e\x8f\x78\xfe\xec\x21\xa3\x2f\x86\x8c\
+\x83\x29\xab\xc9\x03\x1e\x3d\x19\x72\x2b\x61\x91\x57\xa8\x59\x84\
+\xb8\x97\xdc\xdc\xc1\xd0\xb0\xf2\xf7\x1b\xc1\x28\xd4\x32\x46\x33\
+\x32\x5c\x75\x35\x23\xa7\x1f\x0a\xbe\x15\x07\xbe\xe2\x9e\xe9\x97\
+\x7f\xcb\x65\xfc\x33\xe6\x0b\x7d\x3a\xad\xfd\x62\x0d\x93\xc4\x65\
+\x90\xdb\xe7\xc0\x4b\x1b\xdf\x48\xda\x62\xde\x20\x0b\x28\xe2\xa2\
+\x35\x1a\xa0\x5c\x28\xfc\x09\x24\x71\x0d\xe4\xa4\xe1\x82\x4d\xfc\
+\xe2\x6c\x89\xb9\x05\xe4\x26\xa3\x1e\xde\x40\xe7\xb1\x63\x62\xc0\
+\x5c\xff\xc0\x20\xb8\x3a\xab\x89\xf5\x18\x81\xa4\x0e\x00\x75\xa2\
+\xca\x00\x19\x57\x72\xb6\x00\x2d\x4c\x76\x42\x33\x99\x86\x42\x3e\
+\x3f\xd0\x79\x6c\xaa\x70\x91\x30\x2c\xae\x4b\xcd\xbe\xd7\x67\xeb\
+\x7b\xa6\x25\xc9\x27\x8a\xa4\xb9\xad\xa5\x88\x46\x79\xe6\xb4\xb6\
+\x34\xef\x19\x45\xc2\x74\x2d\xeb\x56\x26\x26\x3d\x77\x68\xaf\x27\
+\xbf\xab\x23\xde\xd6\x72\xa2\xc9\xd2\x75\x7b\xbe\x0d\xc4\x47\x2e\
+\x5d\x86\x19\x46\x2d\x84\x40\x2d\x7d\x42\x3b\xab\xd8\x9c\x98\xd1\
+\x2e\xf2\xb6\xa4\x84\xca\xa3\x14\x03\x60\xa3\x47\xbf\xa2\x25\x46\
+\x5f\xc4\x6c\xc9\x88\x22\xc1\x66\xe1\xf1\xf1\xfa\x9a\x6f\xfe\xcf\
+\x6b\xfa\xd7\xdf\x90\xe6\x9d\x16\xfb\xf6\xe3\x35\x49\x38\x68\xc1\
+\xc2\x97\x37\xec\xee\x9e\xc0\xc5\x3d\x72\x79\x4f\x59\x6d\xc9\x8a\
+\xc7\xbc\xb8\x0a\x18\xc7\x43\xf0\x21\x61\xc0\x8b\x9f\x7c\xc9\x57\
+\x8b\x19\x1f\x9e\x7b\xf0\xe7\xdf\x38\x56\xfe\xe2\x9d\x96\x12\x16\
+\xc0\x76\xe7\xd0\x54\x1f\xc2\xab\xd7\x04\x4a\xff\xdb\xfb\xbf\x91\
+\x52\x15\x1b\x92\xac\x42\x7d\xf6\xd0\x2d\xec\xdc\x62\xce\x6c\xb5\
+\x17\xbc\x6b\xf9\xc8\x3e\x82\x92\x94\xf5\x4e\xc2\xae\x4e\x9b\x85\
+\xb1\x84\x18\x86\xb4\x4f\xcf\x65\x99\x78\xb9\xbb\x26\xcf\x46\x8c\
+\x9b\x55\x6a\x53\x72\xf7\x4d\xb1\x4a\x6f\x7d\xf6\x96\x5a\x3a\x4f\
+\x39\x14\xd7\x9f\xd4\xbc\xd6\x62\xb3\x16\x5d\xb3\x62\xe7\xe6\x13\
+\x07\x44\x04\x0d\xae\x2a\x90\x46\xdc\x7a\x04\xd2\xd3\x16\x9a\x05\
+\xb8\xd2\xad\x45\xba\x65\xa9\x69\x9b\x29\x67\x79\xc5\x05\x64\x87\
+\x1d\x1c\xc0\x2b\x7a\x70\x50\xd0\xe9\x21\x03\x45\x54\x98\x25\xd6\
+\x61\x07\x41\xd4\x0a\xd2\x17\xcd\x6e\x65\xdb\xd1\xa1\x38\x93\x38\
+\x6e\x6b\x60\x94\x57\x57\xf7\x8e\xc0\x5b\x7f\x91\xb2\x5e\x8c\x58\
+\x50\x5b\xcf\x58\xc4\xad\xa1\x2a\xa1\xb2\xb2\x6a\x4d\x6c\x40\xdb\
+\xa7\x5e\xec\xf5\x89\xd9\xca\x8c\xc5\x62\xc5\xcb\x5f\x5c\xf3\xc3\
+\x9b\x9f\xb3\xd8\x45\x4c\x7a\xa7\x95\xaf\x77\x79\xce\xe3\xc6\xc2\
+\xee\xbb\xdb\x03\xf0\x96\xcf\xcc\x90\xbc\x1f\xee\xde\xf2\xc3\x77\
+\x6f\xf9\xf0\xe5\x13\xaa\xbe\xc7\x2c\x18\x31\x0a\xfa\x84\x93\x11\
+\xb3\x27\x0f\x39\xa4\x7d\x5e\xfc\xe6\x13\xf8\x33\xb8\xb9\xbb\x67\
+\x35\x0b\xc9\xdf\xbe\x3c\xf9\x9c\xab\xae\xcf\xf5\xbe\xe4\xaa\xeb\
+\xf3\xed\x8d\x07\xfc\x82\xdd\xf8\x92\x8b\xb0\xa0\x1a\x4c\x1d\xd0\
+\x5c\x07\x88\xa9\xc6\xd5\xee\x44\x7d\x6e\xbd\x3c\x53\xe4\xf1\x9e\
+\x4e\x4f\x30\x31\x7e\x72\x39\xb1\x33\x2f\xbc\x06\x7b\x9f\xd7\xce\
+\x3a\x59\xd7\x37\x5d\x21\x01\x9d\x66\x17\x58\x63\x36\x47\xb7\xc1\
+\xc4\x9d\xf8\x31\x87\xe2\x43\xcb\xa5\x38\x14\x1f\xd8\x14\x77\xc0\
+\x17\xad\x79\x1e\x2d\xbf\xd9\x16\x3b\x22\x24\xdb\x48\x77\x70\x54\
+\x64\x6e\xe1\x25\x51\x26\xf7\x50\x03\xa6\x14\x1d\xc8\x34\x7f\xb6\
+\x22\x21\x91\xd0\x0c\xbb\x3e\xc0\xb0\x43\x2c\x4d\x3a\x3f\x2b\x08\
+\xed\xa9\x36\x94\x47\x66\x7c\xc4\xb8\xd3\xa3\x3a\xd3\x09\x22\xcf\
+\x74\x88\xd4\x8b\xba\xe8\x14\xcc\x06\xb8\x91\xad\xd8\x99\x57\x58\
+\xfc\x0a\x4e\xf3\x1f\xe2\x68\xa9\x7b\x5c\xbd\x2b\x44\x4a\xa0\xb4\
+\x36\x54\x4a\x12\xe2\xe9\x69\xa0\xa2\xd6\xc2\x1b\xe5\xb1\xbe\x97\
+\xbc\x7c\xfd\x86\xc5\x4e\x1f\x8a\x6f\x97\xb7\x94\xf2\x23\x7e\xf4\
+\xc0\x6d\xbf\x78\xf4\x81\x2a\x7c\xec\x18\x3a\xb9\x18\xf0\xdd\xed\
+\x81\x6c\xf9\x9a\x78\x5c\xdb\x50\xd7\x3f\xcf\xf9\xfc\x71\xcc\x9b\
+\xbb\x37\x8c\x2f\xae\x18\xce\x03\xbe\x79\xf5\x57\xae\xcb\x66\xd0\
+\xdf\x73\x73\x47\xcb\xa9\x68\x5e\x2c\x1b\x37\x81\x5c\x7c\xf3\x06\
+\xef\xc1\x67\xf4\x1e\xed\x18\x35\x2c\xb3\x34\x83\x3c\xbf\xd3\x43\
+\x5c\x76\x4b\x13\x62\x12\x80\xae\xde\xd1\xeb\xba\x41\x29\x7a\x4c\
+\x86\x76\x1c\x44\x7c\xcf\x21\x0b\x28\x9c\x8c\x48\x5d\x37\x89\x1e\
+\x68\x98\xd6\xbe\xb1\x59\xd8\x75\x6c\xf3\xa4\xcd\x93\xd8\x3c\xb5\
+\x6a\x30\xf1\x99\x8b\x05\xf4\x3e\x9b\xd6\x7e\xbc\x8a\x8f\xa4\xc8\
+\xbd\x2e\x3b\x07\x52\xb3\x58\xd0\x58\x5a\x35\xe3\x92\x4d\xc6\x45\
+\xe9\x54\xdb\x7e\xda\x21\x57\xba\xdf\xcd\x49\x04\x57\xb1\x2b\xf5\
+\xe4\x16\x33\xf8\x62\xb8\x3e\x40\xa7\x47\xd5\x8f\x89\xb7\x86\x81\
+\x2d\x78\xb6\x19\x55\xdf\x33\x59\x63\xcf\x2d\x0e\xcf\xf9\xc7\x38\
+\xcd\x6b\xd8\x3f\xf5\xdb\xc5\x12\xd1\x38\xf5\x97\x09\x17\xc5\x8b\
+\x1d\xea\x51\xd7\xc5\x4a\xad\x25\x77\x3e\xfc\xab\x35\x7f\x61\xea\
+\xfc\x96\x91\x9b\x0b\x40\x3b\xe2\x2a\xc7\x63\x7b\x7d\xcd\x87\xf7\
+\xd7\xbc\x7d\x27\x99\xf4\x72\x07\x64\x3f\x7a\xc0\xf5\xf5\x47\x36\
+\xea\x8a\xe7\xd1\x8e\x6f\xe5\x1b\x1e\x4d\x15\xf1\x44\x90\x5c\x3c\
+\x76\x52\xe3\x26\x5e\x53\xed\x1f\xd7\x8b\xb3\x0d\xfc\xf5\xf5\x2f\
+\xf4\x0e\xbe\x7c\x4b\x19\x5d\x72\xd5\x0b\x29\x67\x0f\x88\xbc\x15\
+\xb2\x1a\x11\x5e\x48\x9e\x7f\xff\x96\x25\x97\xe7\xbd\x83\xbb\x0d\
+\x3f\x0d\x0f\xbc\x1e\x4f\xb9\xea\xfa\x7c\x58\xbe\x25\x50\xaf\x78\
+\x11\x7f\x8d\xba\x1c\x73\x55\x14\xbc\x3b\xe4\x2c\x97\x7b\x67\xbd\
+\x0d\x07\x3d\xc2\x49\xd4\xee\xd7\xcb\x72\xa7\x83\x13\xe7\x03\x07\
+\x1c\x8e\x9c\x8a\x66\x55\x70\x8d\x9e\xc8\x39\x5f\xac\xc9\x83\xc2\
+\x2d\xec\x4e\x98\xd8\xc4\x4c\x5b\x4c\xfc\x23\x72\xa2\x1b\xcf\xeb\
+\x1c\xb7\x28\xcd\xe0\x43\x9b\xc7\x30\x51\x4c\x94\xc4\x13\x15\x92\
+\x18\xdb\xbe\x7f\x30\x4c\x17\x34\x2c\x14\x1b\xc7\x3c\x18\x98\xf5\
+\x85\x0e\xe4\xb4\xea\x5e\x07\x74\xf4\xb2\xd3\x00\xb6\xd5\xb6\x96\
+\x43\x27\x13\x5d\x44\x31\xe0\x97\xd2\xa3\x1f\x09\x88\x6c\x20\x3c\
+\x6a\x49\x85\x48\x19\x77\xa2\xb5\xb0\x93\x14\x89\x66\xd9\xa2\xd1\
+\x0e\xef\x6d\xeb\x10\xfc\xa4\x1f\x71\x28\x63\xca\xed\x96\x83\xa7\
+\xc1\xbb\xf5\x33\xfa\x69\x4c\xc7\x10\x71\x2e\x2a\xba\x4a\x39\xb6\
+\x6b\x9e\x1e\xcc\x56\xe2\xb4\xb4\xd0\x05\x92\x91\x57\x91\x4a\x9f\
+\x74\xb1\xe3\xcd\x56\xb2\xbe\xc5\x49\x88\x49\x2f\x87\xde\x43\x16\
+\xbb\x90\xab\x2b\xa8\xf6\x1b\xe6\xf7\x5b\xa6\xab\x29\xef\xf9\x88\
+\x2f\x1f\xf0\x70\x5c\x3b\x15\x6f\x16\x53\x9e\xf2\x8e\xbf\xcc\x73\
+\x1e\x87\x21\x3a\x81\x6b\xa4\xc1\x12\xf6\x1b\xf0\x07\x6f\x29\x77\
+\x39\xbe\xbc\x71\x39\x8b\x57\xfe\x8e\xe9\x27\xd8\x2b\xb9\x18\xf0\
+\xf3\xbb\x0d\x09\x70\xb3\x7c\xc3\x25\x4f\x79\x3f\x0e\x79\x01\xc4\
+\xdb\x15\xeb\x87\x0f\x61\x1e\x33\x1e\x6b\x54\x0d\x7b\xdd\xd3\x00\
+\x90\xb9\x6e\xa5\xc7\xf5\x42\x03\xfe\xb0\xf9\x08\x9b\x0a\x6f\x3c\
+\x64\xca\xd0\x2c\xe4\x12\x88\x77\xad\xd7\x8f\x99\x50\xb2\x3d\x62\
+\xe2\x8c\x7a\x68\x46\xdc\x8a\x6f\xde\x2d\xbf\x39\x2b\x27\x5c\x46\
+\x32\xb8\x38\x91\x21\x7a\xca\xbd\x19\x8a\x68\x27\xc5\x57\x06\xc0\
+\x56\xdf\x76\x8c\xab\x60\x59\xb6\x38\x1a\xb4\x6d\x17\x73\xba\x63\
+\xb9\xa7\x81\x2b\x22\xa2\x89\x7e\x97\x4d\xdf\xa3\xea\xc7\x8d\x22\
+\x89\x65\xdd\xd8\x2d\xe2\xaa\x7e\xec\x1a\x46\x6d\x17\xf3\xf1\x28\
+\x69\xd9\x3c\x81\x62\xc3\x33\xa6\x51\xec\xa8\xdf\xbf\x7e\xde\xcc\
+\x9c\x07\xad\x93\x14\xf8\x9e\x1d\xac\xa2\x8f\x1a\x4d\x26\x0e\x95\
+\x47\x89\x71\x30\x84\xce\x22\xe7\xa2\x72\x6c\x0c\xf5\xf4\xcc\x50\
+\x79\xa4\xd2\xd7\x67\x7f\x52\x7b\xf2\xeb\x65\xeb\x90\xbe\x10\x6b\
+\xed\x4a\x8c\xe6\x3c\x1c\x3f\xe4\xf9\xe8\x4b\xae\xae\x1e\x70\x3f\
+\xdd\x73\x58\x4d\x9d\xdc\xb0\x8c\x3d\xe9\xe5\x6c\xb3\x21\xe3\xa5\
+\x24\xbd\xdb\xf0\x2e\xcf\xf1\xb2\x77\x4e\x12\x74\x8b\x77\x7c\xef\
+\xef\x50\xd7\xef\xf8\xee\xf6\xc0\x72\x73\xc9\xcb\xd7\x6f\xa8\x6e\
+\xfc\x13\x29\x61\x59\xd8\xca\x95\xf4\x6e\xc3\x36\x1b\x72\xbd\x2f\
+\xc9\xff\xf6\x03\xdf\xbe\x3e\xb0\x54\x5b\x86\x1b\x7d\x62\x9d\xe1\
+\x24\x76\x00\xb6\x13\x36\xc9\x72\xd6\x8b\x8c\xf5\x6e\xc9\x7a\xb7\
+\x67\xbd\xdb\xb3\xc0\x67\xd8\xeb\x52\xf4\x04\x9d\xc1\x03\x3a\x8f\
+\x1e\x32\x9d\x0c\x0d\x6b\x1b\x2b\x2e\xcb\x5b\x91\xd0\x6d\xac\x65\
+\x8b\x8e\x61\x6a\x26\x3e\x2e\xd1\x5b\x39\x71\xd8\xdd\xe0\x4d\xf3\
+\x96\x7c\xb8\xde\xb5\xd7\x15\x5a\x13\x5b\x77\xca\x9e\x8b\xa5\x30\
+\x80\x16\x5a\x13\x7b\xe6\x84\x2c\xf6\x47\xde\x34\xaa\x6a\x59\xe0\
+\x9b\xfb\xda\x05\x85\x8e\xed\xac\x88\x74\xf0\xbc\xe5\xf3\x46\xda\
+\x23\x26\xaa\xbd\xe7\x28\xaa\xb4\x53\x71\xb6\x25\xa9\x2e\x26\xe3\
+\x3a\x38\x4c\x00\x47\x79\xad\xb3\x82\xfe\xd8\xa5\xd7\x8f\x38\xa4\
+\x81\x3e\x59\x49\x30\x45\x71\x40\x50\x19\xd0\x6a\xbf\x59\xdb\x75\
+\x95\x63\x61\xbb\x80\x13\xce\x58\x0e\x40\xe4\x46\x0f\x9f\x9f\x9e\
+\x99\x2e\x76\xac\xd3\x2d\x2f\x5f\xbf\xe1\xed\x3b\xa9\x0d\x9e\xd1\
+\x9c\xd9\x4a\x91\xaa\x0d\x4f\x2e\x1e\x33\x7b\xf0\x94\xd1\x2c\x24\
+\x7f\x1b\xd1\x79\x27\x39\x74\xdf\xd7\x3b\x9e\x7c\xcf\x62\x24\x60\
+\x35\x6d\x2d\x04\xc7\x4b\xc9\x96\x21\x64\x1a\x88\xd7\xfb\x12\x6e\
+\x7c\xbe\xbd\x5b\x91\x5c\x0c\xf8\xe1\xcd\xcf\x1d\x40\xcf\x31\x70\
+\x13\xcc\xcd\xeb\x3f\xc4\x92\x70\xf9\x96\xcd\x5d\x87\x95\xe8\x13\
+\xf7\x2e\x59\x54\xfa\x2c\x2a\xc1\x22\x33\x1d\x29\x99\xcb\x3b\xc7\
+\x41\x8f\x4d\xa8\xc9\x68\xc6\x84\x32\x5e\x31\x01\x7c\xae\xf4\x18\
+\xab\xc3\x52\x0f\x67\xc9\x72\x73\xb6\xd3\x94\xb7\x59\xc2\x73\x3c\
+\x37\x11\x6e\xb8\xf4\x60\x3c\x82\x65\x49\xe7\x51\x55\x47\x52\xdd\
+\x11\xae\x66\xe3\xe1\xa2\x03\x9d\xa7\x80\x96\x13\x57\xbd\xb6\xf9\
+\x19\x6f\x1e\x34\x18\xbc\x31\xb0\x51\x94\x28\x15\xe8\xb2\xb3\x88\
+\x22\xbc\x6d\xd9\x0a\xe8\x34\xcb\xc3\x75\xa5\xad\x6a\xb4\x14\xe9\
+\xdb\xce\x0f\x36\x80\x2b\x90\x6c\x81\x81\x99\xf8\x33\x28\x2a\xb2\
+\xc0\x73\x85\x0f\x3b\x7f\x4d\x7a\x99\xfe\x0c\x13\x78\x2f\x0c\x80\
+\xb7\x48\xfa\xca\x7c\x8a\x01\xef\xa7\x7b\xdd\xda\xee\x84\x12\x11\
+\xba\xe6\x56\x72\x6f\xd4\xdb\x71\x35\x4f\x9f\x0e\x2c\x72\xcc\x5a\
+\x11\xb3\xb3\xc3\x01\x8d\x26\xd6\x3a\x58\x5b\x6c\x42\x44\x4e\x07\
+\x5b\xe0\xef\xd5\x9e\x0f\xef\xaf\xf9\xe3\xbf\x0a\x98\xde\xbf\x61\
+\x5e\xcd\x99\xfa\x8a\x1f\x4a\xc1\xd4\x7f\x03\x7f\x03\xcf\x3f\x7f\
+\xca\x17\xc5\xd7\xdc\x5c\x96\x78\x79\x07\x5e\xb5\xff\xe4\x89\x1a\
+\xb2\x30\xec\xdd\x04\xb3\xf5\x94\xdf\xe5\x39\x95\xfa\xc0\x44\x0d\
+\x5b\xc0\xb4\xdb\xc5\x2e\x74\xaf\x59\x88\x35\xdc\x81\xbf\xbb\xe5\
+\xde\xec\x1c\x33\xde\x53\xf6\xf4\x2c\xb5\x67\xfb\x88\x6c\x59\xb0\
+\x7b\xbb\x64\x79\xb1\xa5\xea\xcc\x49\x3f\xe8\xf7\x19\x8f\xc7\xe6\
+\x7b\x89\xdd\xf9\xa8\x75\x37\x5d\x69\xec\xb8\x7b\xb0\x45\x8c\xf8\
+\x9e\x74\x65\xf3\x17\xd6\x17\xd6\x79\x8b\x60\xa7\xa0\x17\x39\x97\
+\x63\x3d\xae\x18\x2e\x4b\xaa\xe1\x86\x43\x36\xa2\x13\x17\x0e\xc0\
+\x3a\xca\x99\x02\x31\x5d\x21\xf4\x74\xa2\xe6\x02\x75\x97\xb7\x80\
+\x9c\x0d\x3e\x12\x96\xbf\xd6\x98\x2e\xea\xb9\x4e\x99\xd5\xfa\x4e\
+\x0f\xd9\xde\x42\x9d\x0b\x3e\xec\x5a\xb3\x82\x2d\x1b\x47\xad\x13\
+\x82\x73\x02\x78\x54\xed\xd5\xf6\x8f\x78\xb6\x5f\xc6\xee\xf5\x11\
+\xb8\xe1\x80\x7d\xd3\x7a\x14\x89\x8a\x3e\x7a\x28\x76\xdf\x76\xd4\
+\x99\xb3\x7c\x5a\xcb\x2c\xfa\x31\x36\x6e\x9e\x3d\xf4\x4c\x1f\xb5\
+\x70\x27\xe5\x3e\x75\x42\x9a\xd5\x3a\x65\xd8\xa1\xc9\xd0\x4d\x00\
+\x2b\xe5\xb1\x59\x6a\x16\x5e\xdf\xc2\xb3\xe1\x96\xde\x65\x40\x35\
+\xeb\x43\xf5\x88\x72\x5b\x70\xb7\xee\x30\x5f\x49\xfe\x8f\x3f\xff\
+\x53\x7e\xef\x5f\xfc\x3e\xdf\xfe\x6f\x7f\x42\xa5\x4e\x75\xde\xed\
+\xf2\x96\x19\xef\x5b\x00\x5e\xec\x42\x57\x14\x99\x7e\x78\x0d\xab\
+\x5a\xf9\xfa\xbb\x5b\x16\x62\xcd\xed\xf2\x16\x7f\x77\x5b\xdf\xb7\
+\x0b\x99\xad\x14\xb7\xcb\x5b\x6e\x24\xb0\x9a\x72\x90\xef\xdd\xe3\
+\x00\x3f\xcf\x3b\x5c\xef\x4b\xde\xa7\x1f\xd9\xdc\x7d\x44\xca\x1d\
+\x62\xdc\x65\x3c\xee\xba\x93\xa9\x0f\x27\x71\x3b\x58\x7f\x54\x81\
+\xb3\xb7\xab\x24\x35\xce\x86\xe4\xcd\xbb\x35\x2b\x33\xde\x3e\x0e\
+\x0a\x37\x99\x33\x37\x33\xde\x18\xfb\x78\x8d\x3c\xf1\x69\x97\x78\
+\x8d\xb3\x66\x69\xfd\x3c\x51\x95\x4e\x4e\x08\x2a\xe7\x13\x87\x61\
+\x04\xc3\x0a\xdf\xe6\x26\xb4\x7e\xd5\xa3\xa8\x2c\x38\x5d\xde\xb7\
+\xd1\x91\x71\x0c\xe0\xbe\x95\x00\x46\xd3\x7a\xdb\x86\x5d\xd5\x8f\
+\x29\x92\xf4\x44\x40\x44\x46\xe3\x44\x06\x84\x5b\x03\x58\xe9\xca\
+\xd3\xf5\x4e\x11\x35\x18\x59\x8a\x7a\x28\x9f\x2e\x8c\xf4\x5c\xce\
+\x58\x77\x36\x47\x35\x3b\x37\xec\x35\x7d\x52\x6e\x79\xb6\xdf\xaf\
+\x9e\x12\xd4\x5c\xc8\xb5\xf5\x70\x6e\xce\x46\xaa\xa4\xe2\xc3\xc7\
+\x90\xbf\xdc\xd4\x3e\xed\xa3\x6e\xc4\x7c\xf6\xcb\x78\xcf\x47\x5c\
+\x0c\x1e\xc0\x60\x82\x2f\xfe\x3e\x9b\xad\xe0\xc3\x12\xb6\xff\x77\
+\xca\xfb\x7d\xdb\xdb\xee\x44\x8f\xda\x00\x6d\x58\x74\x8b\x5d\xa8\
+\x01\x69\x80\x7d\xbb\xbc\xe5\x9e\x47\x1c\x6e\x14\x9d\x4b\xc1\x8d\
+\xd4\x92\xa4\xb9\x75\x55\xae\xf9\x37\xda\xf9\x90\x70\x3f\x12\x0e\
+\xc8\x5e\xf6\x8e\xf7\x66\xfe\xc7\xa3\xd0\x23\x16\x25\xc3\xde\xb8\
+\x35\xe8\xdb\xe9\xda\xc6\x22\x2d\xcd\xf4\x54\xcd\xd5\x5a\xb2\xde\
+\xed\xa9\xde\x0e\x59\xef\xf6\xb0\xd9\x13\xc6\xc2\x9d\xfd\x29\x2b\
+\x02\x86\x04\x24\xb1\x9e\x32\xf4\xe9\x4b\xbd\xb8\x6b\x4e\xa8\x1f\
+\x3e\x3c\xcf\xc2\x1f\x96\x6f\x19\x04\x17\xe4\xfb\xf3\xdd\xe4\x93\
+\xe9\x4c\x4f\x00\xa2\x15\x93\xdc\x9c\xd8\x5b\xda\xf6\x92\xad\x06\
+\xd1\xe3\x92\x71\xe1\x16\x5c\x7a\x12\x4f\x16\xf8\x66\x52\xbc\x96\
+\x17\x52\xaa\x76\x89\xc2\x02\xce\x16\x0f\x84\xce\x58\x34\x83\xe8\
+\xf2\x18\xf6\x8d\x94\x5c\x6d\xb3\xed\x1c\x08\x95\x63\x62\xd9\x38\
+\x97\x88\x57\x6f\x8f\x00\x9c\x37\x66\xac\x7d\xea\x62\x99\x3a\x37\
+\x9f\xbb\xbe\x97\x70\x78\xc3\x78\xa9\x6d\x35\x0b\xc6\xab\xce\xdf\
+\xf2\xa8\x1b\x39\x66\xfe\xc9\x8b\x9c\xe7\x83\xc7\x9a\xa5\xcf\x79\
+\xa0\x0d\xf0\xdd\x48\x98\xf1\x9e\x83\x7c\x4f\x27\x7a\xe4\x98\xf4\
+\x20\xf5\x7d\x97\x11\xf5\x7d\x37\xaa\xf1\x3b\xe8\x1c\xee\xee\xa6\
+\x70\x5b\x3f\x7a\x50\x7f\x86\x79\xae\x05\xf2\x68\xb5\xe3\x4d\xea\
+\xb1\x54\x5b\x53\x23\x50\xba\x7d\xc9\x53\x0c\x2b\x41\xd6\xf1\xf4\
+\x18\xd8\x5c\x32\x5f\xac\xdd\xe2\x2e\x0e\x0a\xe7\x64\x6c\x63\xc9\
+\xb0\xd7\x25\x9c\x8c\x18\x4e\x62\x9e\xf4\xea\xef\x74\x4d\x41\x90\
+\x05\x84\xc3\x01\x43\x82\xda\x1f\x3e\x26\x8d\x46\xa1\x62\xd3\xd1\
+\xad\xfd\xeb\xdb\x1a\xc0\xea\xf5\x77\xad\xc5\x9d\x5b\xd8\x99\x69\
+\xf6\xd6\x27\x46\x94\xae\x62\xd7\x3a\x19\x42\xdc\xe9\x59\x5b\xa0\
+\x96\x0a\x26\x0b\x61\x2f\x76\x8c\x6b\x33\x3f\x1c\xb4\xc6\x4e\xe9\
+\x05\x62\x91\x94\xce\xff\x2d\xa2\xaa\xb5\x23\x1c\x27\x3e\xb7\x4a\
+\xd1\x17\xa2\xa5\x7f\x23\x23\x31\x4e\xcb\xcd\xb4\x2a\x7c\xee\xac\
+\x49\xcd\x8e\x0e\x57\xe9\x10\x66\xc4\x54\xd5\xaa\xda\xb5\x98\x56\
+\x14\xc0\x96\x24\xeb\xb6\xc1\x7d\xec\x94\xd8\xe2\xcd\xad\x66\xc8\
+\xc5\x4e\x2f\xe8\x2e\x23\xe8\x5c\x8a\x16\x33\x03\xdc\x4f\xf7\x0e\
+\xd8\xf6\xbe\x73\x60\xb6\x40\x6e\xde\x6e\x5e\x9a\x4c\x6b\x19\xbd\
+\x94\x1f\xb9\x09\xfa\xad\xfb\x7b\x97\xc1\x09\xe3\xdf\x48\x28\x7b\
+\x0f\xd9\x66\x43\xfe\x62\x71\x8d\xc8\x7f\x41\x55\x4d\x11\x87\xc8\
+\xb5\x28\x59\x40\xeb\xef\xcc\x1c\x8d\x62\x41\x1c\x14\x3a\xaa\x19\
+\x46\xae\x48\x72\x35\xe9\xd6\x7e\x72\x83\xb1\xe3\xa0\xd0\xc5\x8e\
+\xd8\x33\x1e\xb3\xe0\x90\x05\x7a\x56\xdb\x27\xba\x43\x40\x37\xa5\
+\xde\x2d\x17\x6e\x41\x77\xbd\xcb\x59\x5c\x3e\x6f\xb1\xb1\xb3\xd8\
+\xcc\x6f\x6a\x7d\x62\xd7\xd9\xe1\x98\xb8\x59\xac\x50\x52\x83\xb0\
+\xb1\xb8\xeb\x9b\xd6\x9b\xe2\xf8\x7c\x1e\xa2\x72\x9a\xb8\x99\x47\
+\xab\xfa\x5e\xad\x8f\x1b\x92\x44\x36\xb4\xae\x34\xe0\x75\x5a\xf8\
+\xa8\x25\xc8\xb9\x18\x6a\x61\x2a\x72\xf2\x13\xba\xf8\x4c\x19\xda\
+\x4a\x04\x25\x99\x05\x5d\xed\x3e\x28\x69\x16\x7f\x38\x76\xdd\x39\
+\x9d\xd6\x27\x8d\xf7\x27\x72\xa2\x09\xea\x7b\x29\xf9\xf0\xfe\xda\
+\x49\x89\x83\x7c\xcf\xeb\x1f\x16\xbc\x9f\x7f\x6c\x31\x64\x13\xcc\
+\x16\x54\x96\x2d\x8f\x41\x66\x6f\x37\xc1\xb9\xbb\x29\x78\xbf\x97\
+\x6e\x5b\xca\x8f\x6e\x3b\x9b\x77\xdd\x73\xed\xf5\xe6\x4e\x62\x3f\
+\xd3\xb2\xb4\x95\x28\x76\x81\xb7\xbd\xa9\x48\x8b\x1d\xf3\x62\xa7\
+\x4f\x24\x49\xe6\x66\x28\x5b\x67\x22\xeb\x78\x9a\x6d\x2d\x78\xe3\
+\xd0\x69\xe3\x34\xd3\xe0\xb5\xb7\x8b\x58\x83\xb7\x79\x5e\x11\x9d\
+\x5b\x6e\x58\x94\xe5\x4a\x77\xff\x64\x01\x90\x11\x64\xca\x1c\x21\
+\x33\x3a\xbd\xcb\xb3\x0b\xba\x0f\x4b\xdd\xb0\xf4\xd9\xf8\x09\x9b\
+\xe2\xae\xdd\x63\xd7\xc8\x61\x58\xb9\xe8\xdb\x1f\xdc\x95\x7a\x85\
+\x96\x04\xc1\xd1\x02\x6f\x6b\x40\xe9\xce\x9a\x74\xd4\x56\xa4\xdf\
+\xa7\x1d\x75\xdf\x1a\x95\xdb\x5c\x00\xda\xfb\x11\x95\x5b\xdc\x6d\
+\x1b\x8b\xb4\x02\xc9\x20\xfc\x8e\x87\xe1\x77\x5c\xc9\x3f\xe0\xaa\
+\xfa\x23\xbd\x95\x7f\xc0\x17\xf2\x0f\xce\x80\xb6\xbd\x60\xd3\x80\
+\xf5\x98\x65\x26\x8c\x53\xec\x48\xb2\xae\xfe\xe2\xcc\xde\x9c\x8b\
+\x8a\xb0\xb5\x43\xd4\x4c\x7c\x96\x8d\x8f\x80\x6d\x19\xd3\xbb\xdf\
+\x72\x58\x4d\xb9\xbe\xfe\x78\x02\x9e\x26\x2b\xf7\x2e\x83\xd6\x6d\
+\x0b\x44\x0b\xba\x47\xdd\x88\xdd\x4d\xc1\x61\x35\x75\x0c\x0e\x70\
+\x59\x6c\xf1\xa3\x07\xcc\xe6\x5d\x6e\x82\x3e\x9d\xd1\xdc\x5d\xff\
+\x14\xc3\x3f\xea\x46\x2d\x59\x71\x69\x9e\xf2\x43\x57\x7f\xe6\xc7\
+\x77\x5b\xd4\x72\x6e\x16\xad\x71\x6b\x01\x1c\x86\x91\x9b\x2c\xe4\
+\x16\x79\x59\xee\x0a\x1f\x55\x92\xb6\x16\x7b\x36\xe1\x36\x24\x30\
+\x27\x82\x84\xf5\xe6\x70\x32\x4a\x20\xc8\xb4\xbc\x50\x24\x0d\x99\
+\x11\xbb\x93\xd6\x58\x26\x6e\x82\xf7\x7a\x97\x13\xa8\x57\xec\xb3\
+\x69\x5b\x13\x1f\x9f\x17\x05\x08\x2d\x70\x20\x72\xbe\x6e\x3d\x0c\
+\xbb\x06\x68\xdf\x36\x6c\x46\xed\x2f\x4e\xdb\x64\xb5\x08\xd0\x0f\
+\x6b\xef\x37\x10\xc2\xcc\x1f\xae\x08\x54\xd4\x38\xac\xdb\x05\x9d\
+\xb6\xd9\xfa\x4a\x4b\x87\xad\x52\x7c\x5d\xfd\x11\xdf\x7f\xf7\x03\
+\xbf\xc6\x3f\x6f\x7d\xce\xe8\x57\x61\xf5\x6f\xe1\xea\x19\xcc\x57\
+\x5f\xb1\x0f\x3f\xd3\x96\x9a\xeb\xb9\x33\x21\x24\xa1\x13\x77\xf3\
+\xed\x1c\xdf\x4c\x90\xdf\x99\xf3\x8e\x1e\x33\x71\xcb\xff\x8d\xf7\
+\x66\xf4\x95\x70\xe5\x66\xcb\xca\x12\x49\x59\x64\xac\x6f\xe1\x71\
+\x18\xf2\xd6\x68\xd7\x6a\xd6\x67\x7e\x3f\x67\xea\x4d\x99\xdf\xcf\
+\x39\x78\x53\x3a\x68\x20\xdf\x04\xfd\x13\x90\x59\x0d\xfd\x88\xf7\
+\x0e\xcc\xb3\x79\x97\xf7\x53\xc9\xe5\x68\xcb\x4d\xd0\x77\xb7\x67\
+\x68\xb0\x5e\xca\x8f\xdc\x4f\xfb\x06\xf0\x30\x6b\xec\x0c\xcd\xf7\
+\x3d\x27\x45\xac\xa4\x78\x68\x54\xe2\x7b\x15\xf2\x2b\x71\xce\x78\
+\x3c\xd5\xa3\x18\x7a\x42\xcf\x76\x43\xb9\x59\x16\xf1\xa1\x22\x18\
+\x95\x78\x69\x52\x4b\x06\x03\xe6\x7e\x95\xd4\x21\xa2\x58\xe7\x62\
+\xc8\x20\xcf\xb7\x4c\xb3\xbe\xcb\x2b\xbb\x35\x85\x3f\x72\x92\x42\
+\x19\x3d\x6c\x2d\x36\x45\xd2\x38\x93\x93\x61\x62\x03\xde\x0f\xcb\
+\xb7\x5c\x8d\x9f\xf0\x76\xf7\x84\x17\xf1\xfc\x14\xc0\x26\x47\xe1\
+\x02\x41\x91\xd0\x91\xca\xed\x51\x91\xa3\xa5\x1f\x0d\xe0\xa4\x39\
+\x31\xe3\xb1\x47\xdb\x5c\x74\xe9\xbe\xbc\xa8\x15\xce\x29\x8c\x2e\
+\x2d\x94\x02\xe5\x11\x08\xd1\xf0\x89\x8d\x3b\x61\x98\x7e\xfe\xb1\
+\x38\x01\x30\x68\x00\x03\x24\x3f\xfc\x2e\xcb\xd5\xff\x4e\x37\xfb\
+\x43\xae\xaa\x3f\xa2\x77\xfb\xaf\xb8\x92\x7f\xa0\x65\x07\x92\x37\
+\xd7\xd7\x2c\xae\xaf\x5d\xa2\xae\xea\x7b\x2e\x5c\x6f\x83\xf1\x16\
+\xc0\xa1\x68\x9f\x69\x5e\x34\x0a\x21\xb9\xf2\x50\x4a\x91\x1b\xf6\
+\xbe\x5b\xea\x0a\xdd\xbb\x3c\x77\x8b\xba\x47\xdd\x88\xab\xab\x07\
+\x6e\x41\xd7\xbb\x0c\x9c\x56\xfd\x14\xd0\xec\x02\xce\x3e\xc7\x32\
+\xef\x61\xd5\x2e\x26\x77\x46\x73\x2e\x8b\x1a\xd8\x56\x4e\x58\x56\
+\xb7\x2c\xdb\x89\x1e\x69\xbb\xee\x13\x97\xcb\xa8\x5e\xdc\x7d\x36\
+\x7e\x42\x34\x11\xf8\xa2\x64\x1a\xf4\x18\xe4\xa9\x1b\x4e\x68\xe7\
+\x23\x03\x1a\xc0\x86\x79\x01\x2a\x4f\x03\x71\xeb\xa5\xee\xfe\xe6\
+\x49\xd6\xed\xc2\xae\x5e\x8d\xed\x9d\x94\x68\x6e\x15\x89\x91\x13\
+\x89\x73\x27\xe6\xe6\x24\xe7\x96\x89\x7d\x79\xe3\x98\x78\x72\xf3\
+\xba\xd6\xc4\x67\x2a\xb6\xd8\x28\xa6\x34\x4c\x1c\x34\x67\x12\x5b\
+\xa0\xba\xd3\xde\x4a\xe3\xe1\xd2\x6e\xf8\xb4\xaf\x55\xb5\x7b\x10\
+\x99\x96\x7f\xf7\x9e\x06\xb4\xf5\xb6\x7d\x98\x8e\x44\xc5\x42\xbe\
+\xe7\x4a\xea\x39\x0c\xf3\xee\xbf\xc7\xe8\xcb\x1a\xb4\x2d\xcd\xfe\
+\x52\x11\xbf\x10\x7c\xf9\xf2\x7f\x21\x7e\x21\xe0\x07\x13\x50\xf9\
+\x01\xbe\xe2\x77\x79\x13\xfd\xb7\x26\xe0\x08\x1f\xd7\x01\xdd\x87\
+\xbf\xc9\x58\x3c\xaa\xa7\x55\x9e\xe9\xf0\x68\xc6\x32\xed\x8e\x9b\
+\x2b\xcf\x65\x34\x6e\x17\x92\xb7\x77\x8a\x97\x6f\xdb\x83\xfb\x26\
+\xbd\xdc\x55\xde\x00\x9e\x9b\xaf\xef\x37\xa2\xf7\xdc\xf3\xa5\x73\
+\x16\xee\x47\x82\xd9\x4a\x71\x3f\x9a\xf3\xb0\xf7\x90\x85\x58\x73\
+\xb8\x79\xdf\x3a\xfc\xef\x6e\x0a\xee\xa7\x7b\xb7\x20\x9c\xcd\xbb\
+\xdc\x4c\xfb\x78\xf7\x5b\x2e\xc7\x5b\x6e\xa6\x7d\xa0\xcf\xcc\xb0\
+\xf7\x65\xa1\xff\x96\xf7\x12\x6e\x02\x3d\x69\xbd\x33\x14\x1c\x56\
+\x53\x7a\x97\x81\x4b\xd0\xe9\xfc\x59\x0d\xf2\x40\xbd\xc2\xdb\x3e\
+\x61\xb7\x93\x94\xbd\xb8\x35\x03\x19\x30\xed\x4c\x0d\x26\xad\x46\
+\x3a\xee\x64\x40\xdd\xdc\xda\xa2\x87\x1d\x45\x8b\xe9\x14\xc9\x73\
+\x09\x9b\x3d\x6b\x0a\x06\xe8\xb1\xb3\x76\x7e\xb2\x3d\x4f\x88\x6d\
+\x2a\x3d\x89\x70\x46\x97\x4e\x13\x5f\x8d\x9f\xf0\x61\xd4\xab\xa3\
+\x98\x67\x4a\xd7\xee\x77\x44\x08\x02\x75\x6c\x7f\x09\xe7\x32\x64\
+\x52\x21\xa9\x4f\xba\x58\x34\x7c\xe4\xbe\x10\xe6\x40\x6d\x2b\x6b\
+\x5a\x46\x38\x96\xc5\x04\x77\x94\x4e\x95\x79\x32\x23\x2a\x04\x15\
+\x86\x7d\x8d\x84\x78\xd6\x81\xe4\xbb\xdf\xd5\x9f\xf1\xec\x9f\x38\
+\x00\x5b\x09\x61\xc1\x6b\x81\x7c\x0c\x6a\xbb\x7d\x2a\xff\x7b\xf7\
+\xf8\xf2\xc5\x7f\xc5\x68\xf7\x15\x8a\x47\xda\xa5\x68\xe9\x66\xdd\
+\x8a\xe4\xe6\xa6\x19\x0f\xd9\xc9\x0d\xa5\xe8\x89\x29\xd1\xa3\x29\
+\xdd\xf9\x8a\x57\x7f\xfd\x3d\xa3\xfb\x25\xf7\xa6\x3c\xdc\xac\xbc\
+\xd1\xcb\x5d\xe5\xed\x20\xdf\xa3\x55\xde\x7b\xae\xaf\x3f\xf2\x6e\
+\x5b\xe0\xf7\x03\x0e\x57\x0f\xb8\x44\x11\x4f\x60\xd9\xfd\x8c\xce\
+\xe5\x07\x58\x4d\x79\xbd\xfa\xce\xb1\xb1\x5d\xac\x35\x81\xdc\x19\
+\xe3\x98\xb8\x33\x9a\x73\x33\xed\xb7\x00\x0e\x50\x6d\x57\xcc\xfb\
+\x02\x96\x50\xcd\xf6\xcc\x6e\xba\xf4\x2e\x1f\x38\x16\xbe\x91\xef\
+\xb9\xbf\x14\x4e\xfd\xce\xc6\x25\x1d\xff\x0e\x8f\x08\x3d\xc5\x2a\
+\x26\x0c\x23\x27\x25\xf4\x64\x7a\x13\x5e\x7f\xd7\x67\xc9\x9a\xe1\
+\xa0\x43\x18\x46\x0c\xca\x2d\x8b\x55\xc1\x6a\xb9\xe1\xbb\xa5\xc7\
+\x78\x5c\xb1\xac\x0a\xc6\x5e\xe0\xba\xf3\x96\x4b\x8f\x07\x55\xc5\
+\x43\x42\x16\x14\x84\xf3\x94\xce\x68\xe8\xf4\x73\x1d\x28\xcb\x5a\
+\x79\xe4\xeb\xa3\xa0\xd3\xb1\x3b\x51\xf7\x4c\xc6\x6d\x30\xaf\x3d\
+\xfc\x63\x8a\xce\xf0\x35\x90\x27\x3a\x3e\xe9\xca\xcd\x51\xbd\xea\
+\xb7\x20\x95\x8d\xa0\x4e\xd4\x00\x30\xc6\x3b\x8e\x1a\xa7\x24\x00\
+\x5c\x20\x9e\x46\xd8\xa7\x0f\x6c\xf2\x47\xfc\xe9\xb3\x7f\xca\xe8\
+\x57\xe1\xd1\xf0\x77\x4f\x24\x44\x13\xa8\xe7\xc0\xdc\xbc\x6d\x1f\
+\xff\x35\xfe\x39\xd3\xd1\xb7\x34\xcf\x34\xda\x3e\x12\x79\x47\xb7\
+\xdb\xef\xf7\xd3\xab\x47\xfc\xd2\xc3\x2f\xf8\x8d\x5f\xfa\x75\x7e\
+\xe7\x77\xfe\x4b\x56\xb3\x90\x77\x79\x4e\x3f\x5e\xb7\x42\x3f\x00\
+\x4f\x7d\x78\xf2\x38\xe2\xdf\xff\xb5\xdf\xe6\xeb\xdf\xfe\x4f\x98\
+\x7e\xfe\x9f\xf2\x1f\xfd\xce\xef\xf0\xdb\xff\xdd\x7f\xc3\xb3\x2f\
+\x7e\xc6\xdf\xbe\x0c\xf9\xc3\x9f\x87\x7c\xff\x5e\x31\x5e\x4a\x3c\
+\xf1\x59\x4b\x72\x58\x66\xb5\x60\x76\x7a\x36\xe8\x73\x59\x6c\x5d\
+\x88\xc8\x5e\x9f\xcd\xbb\x54\xb3\x3e\x53\x6f\x8a\xdf\xd7\x00\x9a\
+\x7a\xd3\x13\x0f\xf9\x9e\x47\x3c\x1c\x3f\x74\xe5\x6b\xfd\x47\x57\
+\xf4\x47\x5f\xe9\xe7\xa9\xbe\x9e\xef\xb6\x5b\x12\xcf\x77\xac\x37\
+\x07\x0e\x1f\xef\x79\xfd\xc3\x2d\xab\x37\xf7\xbc\x5c\x7c\xcf\x76\
+\x7f\x07\x1b\xed\x1f\x6f\xfc\x3e\x6b\x3c\x96\x4b\x8f\xd2\x68\x7f\
+\x7b\x26\xd0\x65\x55\xb0\x5c\x7a\x1c\xe6\x4b\x3e\x7a\xfa\xbb\x9d\
+\x8c\xf4\xdf\x76\x58\x79\x14\x71\x61\x1c\x8a\x76\xcf\x9e\x23\x84\
+\x9b\xd7\x94\xd1\x25\x65\x74\xc9\xe4\xe6\xb5\xf3\x8a\xad\x4f\x2c\
+\x5a\xf6\x5c\xe6\x16\x8c\x7a\x8c\x55\x53\xdb\x02\x3d\x95\x91\x89\
+\x18\x5f\x35\xa6\xfb\x98\x98\x64\x60\x9e\x13\x08\x71\x54\xf6\xad\
+\x90\xaa\x06\x70\x20\x84\x9b\xa1\x66\x27\xf8\xc4\x45\xd5\x2a\x61\
+\x7b\xdb\x0a\xb6\xd2\x55\xf6\x22\x35\xe1\x3d\xff\x84\x47\xc3\xdf\
+\x75\x0c\x7c\x8e\x71\xdd\xc2\xf9\x08\xcc\xf6\xf6\xf1\xf5\x41\xfe\
+\x3d\x9b\xfc\x57\x8d\x8f\x6c\x22\x97\x94\x27\x76\x9d\x95\x1b\x5b\
+\xb5\x60\xb0\x6d\x3f\xf6\x60\x1c\xf0\x54\x5c\xf1\xea\xc3\xcf\xd9\
+\xf6\x86\x75\xeb\x51\xfc\x18\xfa\x70\xd9\x1d\x21\xfe\x2e\x7c\xfd\
+\xac\x47\x67\xf6\x80\xc7\x0f\xea\x91\xa4\x6f\xff\xf3\xff\x9a\x5f\
+\x7c\xf3\xcf\xf8\x97\xbf\xf7\x27\xfc\x3f\x3f\xbf\xe5\x5d\xfe\x97\
+\x3c\xfe\xfa\x92\x87\xe3\x87\x2c\x46\x82\xc3\x8d\x72\x8b\x40\x2b\
+\x2b\x66\x8b\x3b\xee\xa7\x17\x8e\x75\x67\xf3\x2e\xf7\xd3\x3d\x97\
+\x05\xee\xba\x77\xbf\xe5\x7e\xa6\x65\x86\xd6\xce\x7b\xed\x66\x5c\
+\x3e\x00\x1e\x98\x00\xcf\x7b\x6e\x96\xf0\x70\xfc\x90\xcf\x86\x07\
+\xde\xab\x90\x17\xc5\x1d\xd5\xeb\x19\xde\xf2\x9e\xc5\x66\x06\xa3\
+\x1c\x56\x21\x25\x1f\xb9\x9e\xc3\xd5\x14\xa6\xe3\x0b\x18\x78\x3c\
+\x0f\xc6\x30\xe8\xba\x12\x6f\x9e\x4b\xa6\x93\x21\x17\x93\x17\x6e\
+\x42\xd0\x33\xcb\xf0\xe6\xc4\x8f\xeb\xdd\x03\xe2\x4c\xa2\x26\x5a\
+\x72\x0c\x67\x03\x9d\x68\xdb\x6e\x29\xfa\xfd\x86\xab\xd1\xee\x0c\
+\x59\x5c\x3e\x67\x7d\x0b\xcf\xcb\xd7\xce\x2b\x56\x37\xbb\xb6\x26\
+\x76\x85\x12\x9d\xc3\xe8\xc4\x45\x7d\xf6\x24\x0b\x60\xcb\xb0\xb1\
+\xd2\xfe\x6f\xd1\x00\x6c\xa0\xa2\xf3\xb6\x93\xd5\xc2\x8d\x60\x50\
+\x64\x16\x82\x36\x47\xe1\x6d\x2b\xb2\xc3\x0e\x2f\xa8\xf0\xb6\xc6\
+\x37\x6e\xb4\x2a\x79\xdb\x8c\xbc\x1f\xf1\x0b\xfe\x21\xac\x39\x01\
+\xb2\x05\x65\x13\x9c\x4d\xf0\x66\x2f\x55\x4b\x72\xb8\x7d\xfd\x87\
+\xdf\x65\xfb\xe5\x3f\x25\x1c\x97\xe4\x4b\x0f\xc4\xe9\x79\x3b\x74\
+\xdf\x5d\xec\x5c\x8e\x3e\x11\x1f\x56\xaf\xd8\x7a\xb7\x88\x43\x42\
+\xd5\x19\x51\x36\xce\x67\xb1\x10\x6b\x9e\xfa\x75\x4b\xd0\xcd\x34\
+\x87\xb9\x8f\xff\x2a\x60\xf9\x17\xff\x8a\xde\xd5\x13\x66\x2f\x4a\
+\x61\xbb\xb5\x57\x00\x00\x20\x00\x49\x44\x41\x54\xae\xa2\xa7\x8c\
+\x7e\xeb\xa7\x5c\x7c\xf9\x1d\xbf\xfe\xe2\x1f\xf1\xd5\x97\xff\x90\
+\x3f\xf9\x9f\xff\x57\xfe\xa7\x7f\xf6\x47\xbc\xfb\xc5\x5b\xf8\xfa\
+\xd4\x53\xbe\x1c\x6d\x99\xcd\xa7\x0e\xc0\x96\x99\xf5\x22\xcf\x30\
+\xf3\x68\xce\x6c\x3e\xa5\x33\x06\xcc\xc2\xaf\x66\xf5\x48\xeb\x70\
+\xf4\x22\xf2\x9e\x47\x5c\x46\xef\x29\x81\x9b\xfc\x73\x7e\x63\xb5\
+\xe3\xe3\xea\x5b\xf6\xd9\x94\x0f\xd5\x82\x08\xf8\xdc\x9b\xc2\xb8\
+\xc2\x1b\x7f\xc1\x97\x9f\x4f\xd8\xc6\x92\x7e\x16\xb5\x86\x77\x5b\
+\x00\xd7\xdb\xfb\x56\xe3\x28\xe8\x89\x43\xd5\x62\x0d\x4c\x58\xa3\
+\x98\x02\xfb\xed\x96\x43\xe5\xd1\x5d\x0f\x5c\x34\xd3\xfa\xcb\x82\
+\x98\x45\x26\x98\xfa\x35\x61\x0c\x1f\xc2\x4a\xf6\xb4\xac\xe8\x3d\
+\x61\x75\xa4\x89\x2d\x1b\x37\xab\x7e\x49\xbf\xa3\xe7\x4e\xf4\x1b\
+\x3e\x30\x4a\x9a\x74\x9a\x6e\x51\xda\x2a\xe9\xdc\x04\x17\x8a\x57\
+\xb2\x66\xe3\x46\x7a\x8d\x08\xe7\x74\x1c\x07\x81\xe2\x4e\x0f\x0a\
+\x5c\x27\x47\x9f\x08\x5b\xc7\x8b\x44\x45\xa0\x3c\x54\xf5\xdd\x59\
+\x5b\xed\xac\xd5\xf6\x5f\x88\x13\x90\x1f\x3f\x0f\x20\x5d\x7f\xcf\
+\x46\xfd\x8a\x61\x5a\x6b\xb5\x35\xcf\x2b\x12\x21\x54\x66\x66\xbb\
+\xd5\xc2\x63\xf1\xcd\x77\x4c\xff\xf1\x18\x8a\x05\xf3\x72\xc4\xcb\
+\x6f\xff\x98\xff\x97\xb1\x37\x0b\x92\xe5\xbe\xce\xfc\x7e\xb9\x55\
+\x65\x66\x65\xd6\xd6\xdd\xb7\xb7\xdb\xb7\xef\x0a\x10\x0b\x09\x82\
+\x94\x48\x88\x04\x29\x8a\xa3\x65\x28\x5b\x33\xf6\x84\x2d\xc6\x48\
+\xb2\x3c\x96\x46\xa1\xa7\x79\x72\xf8\xc1\x0f\x8e\x90\xdf\xec\x07\
+\xdb\x31\xe1\x07\x4d\x8c\x6c\x86\x56\xca\xb2\x3d\x5a\x47\xa4\x16\
+\x8b\x82\x28\x40\x24\x38\x20\x81\x0b\x5c\x2c\xbc\x6b\xef\xcb\xed\
+\xee\xda\x32\x2b\x33\xab\x72\xf3\xc3\x3f\xf3\x5f\x59\xdd\x17\xd2\
+\x54\x44\x47\xd6\xd2\x6b\xf5\xc9\x93\xdf\xf9\xce\x77\xbe\xe3\x3f\
+\xda\x65\xe3\x23\xab\x60\x8f\xc8\xed\x75\x8e\xba\x09\xf9\x91\xca\
+\x51\xb0\x4b\xf0\x28\x12\x8d\x8f\x91\x98\xce\x78\xf9\xda\x0a\xcf\
+\xbc\xb7\xcf\xb5\xa7\x6f\xd1\xf8\x44\x9d\x1f\x7b\xe1\xa3\x5c\xb9\
+\xfc\x4f\x68\xae\x6f\xf0\x6f\x7e\xf5\x77\x99\x1c\x4d\x2e\x74\xd9\
+\x54\x6b\x09\x86\xa9\xc8\xac\x5d\x47\x64\xe4\xce\xa2\xe4\x8f\x4b\
+\xb6\x62\xa5\xd5\x93\x70\x43\x7e\x5d\xb5\x4b\x17\xde\x46\xb5\x96\
+\x04\xed\x56\xfc\x1b\x94\x60\x1f\xea\xab\x2c\xb5\x6e\xf2\xfc\xad\
+\x9b\x1c\x6a\x53\x1a\x76\x1d\x2f\xd0\x64\x61\x97\xe1\x63\x43\x61\
+\xa2\xf2\x84\x2e\xa3\xad\xa3\x07\xc5\x4e\xbd\x71\x63\xee\xd8\x19\
+\x37\xd8\x56\x73\x94\xe8\xf0\x9c\xcd\x17\x4c\x73\x9f\x86\xe3\xc8\
+\xa6\x47\x6a\xa7\x44\x04\x58\xb6\x22\xd9\x89\xce\xd1\x36\xc3\x56\
+\x9d\x81\xb7\x42\xf3\x92\x28\xee\x5a\xc3\x59\x26\x8e\x0b\xae\xd9\
+\xac\x64\xe3\x88\x40\xe8\x89\xb5\x50\xc1\x2f\xf8\x61\xdf\x0a\x71\
+\xfd\x1c\x4d\x53\x29\x5d\x1b\x34\x14\x52\x22\xe2\x02\xf5\x36\x8b\
+\xc9\x8f\x38\x12\xba\xe2\x18\x4b\x2c\x65\xac\x32\x18\x73\x10\x25\
+\xac\x74\xf1\x66\xca\x63\xbf\x38\x6a\x58\xf4\xcb\xd5\x04\xe1\x3c\
+\x26\xae\x06\x63\x15\x23\x97\xcf\x3d\x29\xc8\xcf\x7f\xae\x7f\xe3\
+\x7a\xa5\x30\xb0\x3e\x24\x13\x2b\x17\x5c\x95\xde\x1b\x9d\x31\x79\
+\xf3\xeb\xd4\x59\xe6\xbb\x5b\x31\x7b\xfb\xe1\x1c\xbd\x05\xc0\xc3\
+\x43\xc2\x7e\x24\x33\x5f\x3c\xec\x62\xb4\x7a\xc4\xa3\x88\xdf\xfa\
+\xee\x5b\xb4\xde\x7a\xc4\x0f\x5c\x49\x78\xf9\xc5\x4f\x30\xfe\xcc\
+\xdb\x98\x9f\xfb\x29\x9e\xfb\xe2\x02\x3f\xb3\xff\x32\xaf\xfd\xe5\
+\x5f\x31\x39\x4a\x59\x5b\xb1\x24\x5f\x9c\xb5\x04\x27\xac\x9c\xc1\
+\x4a\xdb\x27\xce\xd7\x80\xe9\x5c\x26\x5e\xe8\xd5\xa0\x35\xc3\xcb\
+\x47\x9a\x23\xdb\xd0\x2b\xa9\x5f\xfc\x0e\x48\x86\xa2\xca\x13\xbf\
+\xd9\x3f\xa4\xf1\x7d\x0d\x77\x71\x49\x0e\x8f\xaa\x40\x69\x53\x6c\
+\xc6\x16\x91\x51\xe8\x4f\x8a\xd6\x74\xd9\x8d\xd3\x5a\x19\x8c\x93\
+\x0b\x2c\x45\x79\x1c\x4d\xa6\x24\x67\x03\x0c\x16\xe9\x2e\xa8\xb8\
+\xc5\x82\x1b\x9f\x84\x4e\x4b\x63\xea\xfb\xe0\x38\x73\xf0\xad\xdf\
+\x33\xa9\x0d\x4f\x24\x9c\x10\x93\x21\x47\xb4\x8e\x26\x98\x9b\x37\
+\x38\x66\x4f\x66\xe2\xb2\x59\x22\x5c\x87\x02\x4c\x02\x89\x89\xd5\
+\x52\x2f\x6c\x15\x81\x7c\x5e\x7a\x59\xbe\x1e\x9e\x2b\x8e\xc2\x22\
+\x80\x0d\x42\x01\x43\x42\x85\xf3\xdb\x23\x7c\x19\xac\x52\x0d\x21\
+\x77\x52\x68\xa6\x39\x73\xdb\xac\x60\xf2\x57\xef\x7c\xe9\x43\x39\
+\xcf\x6a\x40\x97\xb7\x77\xf8\xd2\x85\xe7\x5b\xcf\xc3\xf8\xca\x2f\
+\x33\xbe\xf2\xcb\xc4\xfa\x73\xe8\xd2\x15\xe8\x09\x05\x5e\xa1\xa8\
+\x22\x0a\xa5\xb7\x45\x58\xec\x50\xf6\x92\x35\x72\xb7\xcb\xc9\x83\
+\x37\xd9\x1e\x3e\xb8\xd0\x91\xdb\xcd\x90\x6a\xb2\xb9\x6c\x0a\xb4\
+\xda\x57\xe9\xb6\x2c\x1e\x0e\x5d\xde\xf9\x46\xca\x5f\xbc\xb6\xcd\
+\x5f\xfe\xc5\xd7\x98\xf6\xde\xa7\xfb\x42\x1b\xe7\xda\x06\xdb\x61\
+\x9d\x2c\x3c\x91\x05\x5b\xc9\x50\x2c\x17\xac\x44\x2f\xef\xcd\x15\
+\x79\x25\x4b\x51\x16\x79\xe5\x73\xc7\x83\x59\xf7\xf0\xac\x3b\xe5\
+\x78\x30\xfb\x3d\x56\x2c\x81\xdf\xfd\x60\x56\xdc\x79\xa7\x27\x74\
+\xe2\xc2\x6d\xa7\x68\x3b\x97\x41\x0b\xe0\xe4\x5d\x19\xbc\x25\x0f\
+\xac\x8c\x05\x7d\x56\xed\xc6\x95\x8f\x47\x93\x01\x83\xc1\x00\x86\
+\x3a\x6b\x9d\x84\x8e\x9a\x12\x0f\x15\xfa\xc3\x74\xae\xf1\x51\xe5\
+\x93\xcb\x42\x7a\xda\x5a\x92\x9a\x94\xce\xd1\x36\x03\x6f\x85\xfe\
+\xca\x26\x87\x93\x84\xd6\x70\x32\x47\xa7\x09\x8e\x79\xe6\xad\x37\
+\x8f\x89\x0b\x3c\x6b\x59\x39\xfd\x92\x22\x2b\xe9\xb4\xbe\xe8\x82\
+\x35\x11\x6b\xa6\x47\xe7\xa4\x38\x71\xa8\x88\xe5\xe6\x73\x19\x78\
+\x9e\x0f\x08\xe2\x09\x16\xb6\x80\x29\xc5\x66\xa4\xb9\x56\x6e\x81\
+\xa1\xaf\x18\xf0\xf5\xec\xaf\x78\x99\x7f\xf8\x36\xbc\x23\x82\xb5\
+\x6c\x8c\x54\xb3\xf2\x9d\x07\xff\x92\xda\xda\x75\x3c\xbd\xc0\x52\
+\x91\x52\x09\xe0\xb0\xe8\x4f\xce\xae\x0a\x22\x13\xe7\x33\x2f\x37\
+\x60\x6b\x3f\x00\x8e\xf1\x81\x81\xb7\x22\x03\xb4\x64\x27\xf6\xfc\
+\x7d\x16\x86\x11\x47\x15\x46\xc0\x68\xc1\xe4\x68\x86\x69\x8d\xa6\
+\x08\xc2\x3b\x1c\xb0\xb6\xbd\xc4\x35\x1e\x72\x7a\x3b\xe1\x7e\x07\
+\x94\x65\x03\xf7\xe1\x61\x51\xbd\x77\x61\x8e\x27\x16\x8f\x97\xdb\
+\x70\x7c\xe6\x73\xb4\xe0\x54\x20\x46\x54\x14\x76\xb0\xa0\x9e\xd2\
+\xcb\x4d\xd1\x31\xcc\x7b\xb2\xe0\x5b\x6e\xcf\x32\xf1\x59\xcb\x24\
+\x0b\x9a\xf2\xf7\xbe\x7f\xa4\x70\xed\x69\xe8\x3f\x36\x20\x0c\x51\
+\x34\x17\x02\x95\x49\x2a\x7e\x57\x45\x73\x19\xd9\x03\x6c\xad\x2e\
+\xdb\xc8\xfe\xd4\xa3\x11\x4c\xc1\x15\xef\xcd\xd8\x50\x69\xf4\xd2\
+\x42\x6f\xe2\xd0\xd0\x62\x1a\x41\xce\xb8\xd5\xc1\x01\xe2\x61\xb1\
+\x88\xb1\xdb\x90\x0c\xc5\x88\x94\x06\x62\x0f\x75\x56\x19\x44\x2b\
+\x33\x71\x89\x87\xdb\x1c\xc9\xe0\x19\xb6\xea\x4f\x16\x4e\x15\x90\
+\xc4\x84\x8b\x2a\x36\xc5\xcf\xe5\x3e\x66\x67\x2c\xf4\x13\xb6\x51\
+\x87\xa8\xb0\xb2\xc2\x91\x6b\x99\x9a\xb2\x13\x25\x96\x38\x96\x54\
+\xdc\x05\xb9\x64\x45\x83\xe1\x14\xd4\x5b\x58\x48\x2f\x4b\x41\x50\
+\x58\x60\xd4\x07\xe1\xd6\x1c\x14\xf8\x8f\x09\xe4\x5f\xcf\x6a\x73\
+\x30\xe3\x7b\xfc\x32\x93\x4b\x3f\x4c\x9c\x5c\x17\x2e\x99\xf2\xac\
+\xb7\x3e\x54\x0b\x21\x56\x25\x08\x58\x64\x12\x72\x96\x8b\x77\xf1\
+\x83\x37\xee\xf1\xdd\x3f\xf8\x4d\x6e\x9f\x7c\x5b\x34\x1e\x2c\xf0\
+\x83\x26\xbb\x19\xa2\x81\xc1\x9a\x0c\x60\xd5\x5a\x92\xfa\x86\x95\
+\xd4\x07\xe5\x60\x4e\x69\x76\x14\x42\xb2\x13\x71\x90\xee\x90\x1f\
+\xa9\xb4\x07\x21\xf9\x82\x73\x11\xef\x16\x59\xb9\x7c\x9c\x2f\x08\
+\x6c\x7c\x3c\x10\x54\x5c\x2f\xab\x00\x9f\x5c\xfc\xfc\x32\x63\x97\
+\xd4\x5b\xb5\xfb\x57\xd2\x6b\x65\x26\xb6\xdb\x1a\x93\xbd\x01\x4a\
+\xda\x03\x2f\xa7\xdf\xef\xd3\xef\xf7\x19\x8c\x12\x06\xbb\xd0\xef\
+\xf7\x89\x0f\x7c\x74\xdd\x22\x48\x35\xfc\x69\x44\x7c\x10\x33\xc8\
+\x53\xf0\x72\xc6\xa9\x41\xa3\x27\xb2\xa9\x53\x5b\xa4\x11\x4c\x69\
+\x69\x0e\xe3\xbc\x43\x43\xe9\xe3\x17\x06\xe4\xee\xb5\x26\x9d\x96\
+\x86\xa2\xb6\xc8\x2a\x30\xc2\x53\x1d\x49\xb5\x59\x76\x34\x97\x89\
+\xa9\x24\x8c\x92\x2b\x2e\x31\xb1\xea\xfb\x92\x67\xae\xca\x3c\xc7\
+\x7e\x8c\x9a\x5a\xb9\xd8\x5e\x64\x99\x72\xa6\x4e\xeb\x47\xf8\xd3\
+\x33\x88\x74\x31\xed\x61\x76\x65\xb6\x8d\x11\x03\x95\x71\xe1\x0a\
+\xa4\x95\xc7\x50\x91\x4a\xb7\x92\x27\x76\xe6\x66\xd4\xc2\xf9\x76\
+\x74\xa1\x66\x4b\x09\xb1\x22\xf1\xb5\xee\xc1\x16\xf6\xce\x0f\xf3\
+\xeb\x59\xed\x3f\x2a\x88\xcb\xcf\x7b\x07\x01\x41\x0e\x46\xbf\x5c\
+\xd1\x1f\x5b\xf2\xb2\x25\x3a\x72\x33\x71\x92\x98\xdf\x8b\x8a\x20\
+\xcf\x99\xf8\xe1\xac\x03\x54\x14\xac\xa3\xc7\x62\x60\xf3\x78\x64\
+\xcc\x4d\x59\x94\x19\x2d\xab\x5f\x92\x9d\xb0\xd2\x67\x62\xae\xd5\
+\x9c\xaf\x49\x01\x4f\x19\xe8\xdb\xb5\x75\x8e\x47\x86\x1c\x08\x2d\
+\x1b\x1d\x65\x93\x63\x2e\xdb\x14\x3f\x53\x64\x74\x73\xae\x90\x2b\
+\x3f\xbf\x97\xf7\x24\x5f\x5c\x3e\x5e\xe8\x9f\x62\x14\x85\xdf\x8a\
+\x35\xe3\xb2\xd5\xc9\x63\x82\xbe\x48\x50\x8f\x3b\x1d\xf2\x62\x51\
+\x62\x5b\xd1\xe8\x74\x3a\x74\x3a\x1d\x36\xaf\x3a\x6c\x76\xda\x74\
+\xda\x9b\x24\x89\xd0\x0e\x5f\xae\xad\x72\xe3\xc5\x75\xba\xd7\xaf\
+\xd1\x69\x6f\x72\xb9\xb6\x8a\xd2\xde\xa4\xd3\xde\x04\x3a\x28\xed\
+\x4d\x86\x03\x0f\xa7\x93\xa2\xb4\x9b\x05\x9b\x92\xa3\xa8\xad\x82\
+\x57\x2e\xf4\xc8\x85\x29\x84\x9b\xf9\x32\x8b\x7a\x86\xc5\xd1\xe9\
+\xd9\x9c\x30\x5e\xc2\xb2\xa2\xf1\x51\xf2\xc4\xb3\x13\xa1\x51\xd4\
+\x37\x36\x71\xa0\x89\x4c\xac\x99\x33\x0b\x14\xb9\xaa\xb6\xd3\x01\
+\xd3\xc2\x3f\x27\x92\xb7\xca\x9d\x64\x45\x86\x4b\xcb\x59\x8c\x42\
+\xbe\xa9\xf8\x02\x57\xeb\xa1\x28\x10\xc3\x7e\x84\xd5\xd7\x84\x25\
+\x40\x38\x2b\xf2\x6c\x3f\x28\xd8\x8b\x50\x66\x6a\x13\x13\x6f\xed\
+\x2a\x1f\x78\xdf\x62\xe7\xdd\xda\x3f\x98\x8d\x7f\x3d\xab\xb1\xf3\
+\xae\xf8\x90\x75\xd6\xce\x0e\xd1\x9a\x5a\x74\xe8\x66\xab\x74\x4b\
+\x56\x62\x5e\x64\x6f\x8a\x93\x71\xac\x51\x77\x8a\xe9\x90\x73\x3f\
+\x63\x6f\x3f\xe4\xe1\x41\x84\xff\x68\x97\xe5\xf6\x0c\x07\x5f\x76\
+\xd6\x65\x70\x9c\xc7\xc2\x17\x5a\xa9\x45\x96\x5e\x75\x14\xa9\x61\
+\x38\xaf\x3a\x2b\x71\xec\x4a\xea\xcb\x63\x99\x8d\x7b\x79\x8f\x23\
+\x4d\x04\x6a\xd9\xa5\xeb\xe5\x3d\x19\xb8\x0b\xbd\x9a\xcc\xc4\xcb\
+\x6d\x64\xa6\x2e\x8b\xba\x4e\xd4\xe4\xf1\xe0\x31\x07\xbd\x13\x8e\
+\x42\x21\x8e\xbf\xd4\xef\x33\xb6\xa7\x28\xed\x26\x69\x65\xcf\xc8\
+\xa8\xe8\xcc\x96\xf4\x5a\xd2\x1f\xb2\xab\xf6\xd8\x79\x38\xc6\x3b\
+\x3e\x62\x57\xed\xb1\x37\x3d\x04\xfa\x0c\xe8\xa3\xdb\x21\xba\x1d\
+\x62\xac\x5d\xa2\xe9\x1a\xb4\xe9\xa0\x77\x44\xf0\x96\x7a\x89\x86\
+\xcd\x9c\x9f\x5b\xe6\x38\x73\xf4\xdc\x95\xc2\xde\x61\xf4\x58\x64\
+\xe1\xb6\x3b\xeb\xda\x55\x31\x71\xc9\x2f\x6b\x41\xb9\x3b\x31\x10\
+\xdf\x53\xe8\x89\x43\xd1\x55\x3b\x27\x69\xb4\x2c\x53\x8c\xe0\x9b\
+\x16\xb9\x15\x48\xbf\x09\x2a\xd9\x56\x0b\x15\x69\xc4\xcd\x28\x16\
+\xc6\x28\x51\x28\x9c\x7e\xe2\x09\x49\xa0\x73\x9c\xf7\xc9\x23\xa1\
+\x8c\x3b\xe9\x47\xe8\x61\x48\xa0\xa9\x28\x7e\x40\xd8\x37\xb0\xd3\
+\x8c\xb0\x9f\x90\x0f\xb6\xd8\xe8\xc7\x8c\x57\x27\xbc\xf3\x76\xfd\
+\x43\xb3\xf1\xf0\x0e\xfc\xeb\xb7\x45\xf0\xde\xc9\xc6\x8c\x57\x67\
+\x7f\xe8\xf5\x2b\x57\xb0\x8d\xcf\xcc\x4f\x83\x48\x43\xc1\xf0\x82\
+\x88\x24\x8a\x14\x8c\x46\x4a\x3c\xd6\x64\xb3\xa3\xc4\xc4\x67\xe1\
+\x2e\x71\x78\x20\x29\xb0\x12\x5f\x6e\xa8\x82\xae\xea\x44\x4d\x09\
+\x27\x00\x96\xb5\x53\xb2\xf0\x44\x04\xab\xb5\x24\xb3\xe1\x6a\xa1\
+\xad\x56\x6a\x8b\x4f\xfc\x7b\x26\x47\xa9\xec\xd8\x1d\x0f\xb8\x70\
+\x5c\x6e\x8b\xa2\xad\x5a\xe4\x55\x03\xb9\xcc\xc6\x00\xf1\x28\x9a\
+\x3b\x56\x27\x3b\x0e\xf7\x52\xb2\xf0\x84\x61\xab\x4e\xb8\x7e\x95\
+\x89\x1f\x72\x3a\x0d\xd8\x3f\x1c\xd0\xef\xf7\x39\x9d\x06\xf4\xfb\
+\x7d\x0e\xa6\xa2\x73\x27\xd2\x66\x8d\x8e\x69\xd1\x5e\x37\x30\xdb\
+\x35\x3a\xed\x3a\xed\x95\x26\x7a\xb7\x56\x38\x06\x09\x65\x59\xa9\
+\x3f\x56\x3b\xe9\x1c\x6c\x68\xa2\x31\x0e\x98\x19\xb1\x14\x01\xdd\
+\xb0\x0b\x53\xc7\x61\xce\x4e\x2c\x10\x6d\xdb\x3d\xa2\xed\x1e\x49\
+\x38\x71\xfe\x56\x85\x13\x65\x46\x2e\x23\x56\xad\x96\x38\x98\xf9\
+\x6c\x73\x7d\xa9\x03\xb6\x72\x49\xaf\x11\x46\x62\xea\x23\x54\xf0\
+\xfb\x7d\xfc\x52\xe9\x66\x5a\xc2\x24\xa5\xea\x3f\x61\x5a\x34\x5b\
+\x1a\xcb\xad\x4b\xe2\x44\x70\x14\x1c\xd3\x22\x29\xa4\x9c\xbe\xd6\
+\x10\xcb\x6b\x34\x15\xf0\x38\x1d\x2f\xb2\xdb\x31\x78\x66\xe9\x65\
+\x94\xe7\x7b\xec\xbc\x5b\xe3\x5f\xbf\xfd\xe4\x8c\x5c\x06\x30\x80\
+\x77\xf7\xe7\xe4\xf3\xb7\x13\x95\x38\x3f\x38\x27\x96\xaf\xee\xfc\
+\x50\x66\x27\x6b\x41\xeb\xc5\xc5\xd6\xa6\xb2\x5a\x2e\xc7\x9d\x86\
+\xc9\x2d\x0c\x6b\x0d\xe5\xcc\x97\x01\x59\x36\x39\x72\x7b\x9d\x41\
+\x5b\x78\xaf\x95\x7a\xdd\x43\x3f\x67\xd5\x51\x38\x4e\x17\xc9\xc2\
+\x13\x9e\x1f\xac\xc9\x00\x5e\xd6\x4e\x9f\xf8\x8f\x31\xac\x35\xce\
+\xba\xd3\x39\xec\x5c\x66\x54\xe5\xcc\x27\x5f\x70\x64\x40\x57\xdb\
+\xca\x5d\xb5\x08\x52\x65\xa6\x6b\xee\xaa\x11\xbd\xcc\x64\xb9\x8d\
+\x84\x1f\xcb\xda\x29\x47\x61\x31\xba\x94\x8f\x58\xeb\x2e\xb1\xdc\
+\xbe\xcc\xc6\x92\x41\x77\xa3\xcd\x62\xcd\x66\x7d\xb5\x8d\xbe\xd0\
+\xa6\x6e\x5a\x74\x3a\x1d\xb1\xac\xd1\x36\x09\xd2\x59\x72\x68\xd6\
+\x6b\x98\xa6\x49\x33\x17\x1f\x25\xaf\x5c\x15\x0f\x25\x49\x38\xe7\
+\x22\x94\x24\x21\xa9\x9d\x4a\xaa\xad\x2a\x92\x97\x57\x29\x7b\x76\
+\x7f\xe0\xad\xcc\x65\xe2\x12\x4e\xc8\x02\xd0\x71\x64\x46\x8f\x8b\
+\x8c\x1c\x81\x98\x76\x9e\xf7\x98\x9c\x05\x74\x5a\x04\xad\x16\x2a\
+\x18\x84\x58\x15\x16\x42\xaa\x87\x8a\x06\x41\x69\xa6\x52\x7e\x84\
+\x08\xa3\xc0\xa0\x30\x48\x29\x9d\x35\x2d\x2b\x97\xd3\x1e\xaa\x95\
+\x0b\x45\x9c\x65\xe2\x03\xef\xef\xef\xc2\xe3\x1b\xd4\xf2\xa7\x04\
+\xce\x7d\xbb\x3e\x87\x7b\xab\x85\xdc\x9d\x6c\x4c\x7e\x47\xfc\x53\
+\xdd\xa7\x7e\x7b\x16\x14\xfa\x55\x3a\xd6\xf5\x4a\xf0\x7e\x88\x77\
+\xdb\xdc\x88\x53\x5d\x42\x9d\x30\x8a\x20\x8a\x48\x4e\x5d\x5a\xfa\
+\x3d\xe2\xf0\x80\xd5\xd5\x19\xa6\xdd\xcd\x40\x29\x6c\x54\x85\x6b\
+\x8f\xe8\x8e\x3d\x7b\x68\x08\xfb\x2a\x3f\x97\xd9\xf8\x4e\xfb\x80\
+\xc3\xa2\x7d\x7d\x9c\x8a\x2c\x6c\x77\x4c\x59\x18\xaa\x93\xc7\x42\
+\xe9\x96\xfa\x12\x26\xcc\x06\x24\x45\xa0\x56\x9f\xaf\x66\x62\x59\
+\xdc\xe5\x6b\x17\x9e\x2b\x83\x3e\x0b\x4f\xe4\x09\x75\xea\x9d\xd0\
+\x6d\x59\x3c\xff\xe2\x47\xa8\x2f\xd6\x08\xf4\x06\x69\xde\x40\xef\
+\xd6\x30\xb1\xe9\x98\x16\x1d\xd3\x42\xe9\xb4\xe5\x68\x12\xd8\x72\
+\xca\xa3\x9c\xc3\x4b\x92\x90\x91\x12\x09\xf1\x7c\xbd\x26\xc7\xfc\
+\x47\x93\xa9\x18\x1a\x2d\xf4\xc7\x49\x12\xd2\x6a\x5a\x8c\x03\x91\
+\x91\xcb\x2c\x5c\xc2\x09\xd5\xf7\x81\x06\x99\x21\x30\x5a\xb9\xc2\
+\xa1\x74\xbf\x1f\x78\x2b\x73\x22\xa0\xf3\x90\x22\xb5\x53\x89\xab\
+\xc7\xea\x14\x75\x6c\x65\x33\xea\xa9\xf8\x27\xa6\x15\xac\xca\x39\
+\x3a\xad\x54\x13\x39\xa6\x25\x82\xba\x90\x66\x6a\x17\x2c\x51\x28\
+\x3c\xdd\xaa\xcc\x72\xb9\x70\x3c\xaf\x28\xe6\x20\xd4\xeb\xe8\xab\
+\x6d\xe8\x36\x69\xad\xdc\xa2\x3d\xbc\x89\xf2\x7c\x8f\x3f\xfd\x5d\
+\x97\x7f\xa1\x4e\x2f\xe0\x60\x00\xe5\x79\xf1\x4f\xfd\x49\xe5\x27\
+\x79\xf9\xf9\xaf\x73\x37\xfc\x9f\x41\xb9\x01\x91\x52\xe8\x84\x0b\
+\xe1\x4f\x21\xa9\x94\x59\xb8\xa2\x81\x2e\x2d\x60\xc5\x54\x4b\x51\
+\x08\x86\x17\x47\x8d\x54\x6b\x09\xd5\x5a\xa2\x7b\xb2\x47\x3e\x5d\
+\xe7\xc6\x25\x03\x65\x25\x93\xa6\x25\xef\xad\xc6\x73\x83\x9a\x65\
+\xf0\x96\x99\xb9\xcc\xd6\xbb\x99\x28\x0c\x17\x86\x11\x47\x21\x1c\
+\x1e\x9e\xc8\xa0\x2b\x9b\xb7\x17\x02\xf5\xef\xb9\x9d\x87\x18\xcb\
+\x6d\x24\xb4\x50\xad\x25\x26\x47\x29\x87\x7b\x22\x0b\x3f\xf3\xe2\
+\x2d\x96\xdb\x97\x59\x6e\x5d\xa2\xdd\x6e\x63\x4b\x81\x79\x25\x40\
+\x26\xe2\x6f\x0f\x52\x8d\xb4\x2e\x32\x6e\x1f\x95\xa6\x25\xbe\xa7\
+\xa7\x37\xb0\xe3\x9c\xd1\x64\x4a\xaf\x3f\x62\xe7\xf8\x31\x23\x2f\
+\xc6\x09\x2c\x6c\x2d\x95\x1c\xb2\xae\x8b\x00\x2e\xb3\x70\x19\xc0\
+\xe5\x63\x4f\x75\x80\x31\x6a\x2c\xfe\xf8\xd2\x3c\x3c\x18\xa4\x4c\
+\xb5\x75\xda\xee\x11\x6a\x78\xc4\x61\x3e\xcb\xec\xd3\x02\x4e\x94\
+\x90\x42\x0b\x84\x8f\x6b\xc3\x31\x50\x1b\xa1\x2a\x2b\xf5\x52\xd4\
+\x5e\x06\xb0\x9d\x66\xd8\x69\x86\x1e\x9e\xb3\xb1\x2a\xb2\x6f\x19\
+\xb8\x17\xd6\xe6\x16\x81\x20\x97\x2f\x9a\x22\xdb\x96\x46\x85\x69\
+\x71\xa2\x94\x5f\xdb\x75\x15\xae\x2d\x76\xb1\x2d\x8b\x4e\xd6\xe4\
+\x0b\x9f\xff\xe2\x5c\xe0\x96\x90\xa2\x84\x11\x6f\xbf\x29\x84\x07\
+\x1f\xef\xfc\x02\xfb\x0b\x2b\x1c\x8c\x7e\x19\x4f\xbf\x2e\x5c\x3a\
+\x4d\x93\x64\x30\x28\xe8\xb2\x73\x53\xd2\xe7\x94\x6a\xf2\x14\x33\
+\x73\x4c\xd3\x14\xac\x85\x25\x0a\xdd\xf1\xa9\xc7\x61\xfc\xd4\xdc\
+\x3c\xdc\x5b\x7b\x39\xe3\xe3\x3d\x54\xee\xf1\x63\x2f\x3f\xc5\xad\
+\x97\x3e\x8a\xbb\xfc\x31\x39\x82\x54\x06\xf2\xf1\x40\x60\xd0\x9d\
+\xfd\x0e\x59\x78\xc2\x19\x6b\xd8\x1d\x81\xa7\xcb\x06\x49\xb5\x71\
+\xe2\xf9\x95\x69\x72\x3f\xbd\x10\xd4\xe5\x73\xe2\xd8\xff\xd0\xa0\
+\x3e\x1e\xcc\x98\x8b\xc9\x51\x2a\x83\xbc\xdb\xb2\x58\x6e\xc6\xd4\
+\x17\x6b\xac\x6c\x26\x42\x4f\x1c\xa9\xc2\xc2\xb5\xd0\xf8\x96\xbe\
+\x10\xe5\x73\x79\x7f\xc0\xfe\x78\xca\xc9\xf1\x01\xb7\x1f\xee\xf3\
+\xfa\x07\x77\xb9\xfb\xc1\x07\x7c\xf7\xfe\x2e\x0f\x0e\x0f\xd8\x9d\
+\x84\x44\x64\x82\x9e\xa3\x7f\xa1\x39\x32\x0b\xd6\x99\x87\x85\xa7\
+\x8a\x2c\x5c\xfa\xb8\x95\x16\x5a\x67\xe1\xae\x84\x11\x1f\x76\x53\
+\x9b\x22\x70\xcd\x39\x6a\x54\x50\x6c\x7a\x18\xcd\xfb\x12\x6b\x28\
+\x85\x07\xb1\x27\xc9\x31\x3f\x56\x70\x4a\xf1\x4c\x91\x79\x4b\x5d\
+\xb1\x71\xce\xab\xb8\x2c\x0a\xcb\xc5\xe3\x61\x18\x91\x72\xb1\x19\
+\xe2\x54\x2e\xed\x21\x16\x5a\xa7\x58\xb4\x68\xc1\xb5\xe6\x0f\xf0\
+\xf1\x4e\xc2\xd6\xc6\x37\xd9\x79\x77\x02\x1f\x9d\xf2\xea\x9d\x2f\
+\x71\x27\xfb\x33\x00\x3e\xf6\xe2\x3d\xda\xc3\x9b\x5c\x7d\x41\xe7\
+\xd9\xcd\x97\x85\x01\x92\x9c\x30\x89\xf8\xce\x77\x1e\xb1\x5a\xdf\
+\x25\x5b\x58\xc2\x6e\xc0\xae\x1f\xb2\xe1\x58\x2c\x75\x8a\x00\x0d\
+\x23\x82\x7e\x8f\xb8\x63\x16\x89\x7a\x42\x4c\x9f\x28\x99\x51\x71\
+\x83\xb6\x45\xfe\xf8\xb6\xcc\xd0\x0b\xbd\x1a\x3d\xe0\xad\xbd\x1e\
+\x8d\xe5\xcb\xfc\xd0\x0b\x2a\x57\x3e\xf5\x0c\x2b\x1b\x47\xfc\xed\
+\xff\x73\x83\xbf\x7b\x5f\x83\xfc\x35\xba\x47\x45\x3b\xd7\xd1\xa8\
+\xaf\x68\xac\x58\x4b\x64\x85\x41\x8a\x1f\x34\x89\x07\x8f\x99\x1c\
+\xef\xd2\xcb\x4c\x32\x3f\x65\xcc\x14\xd7\xb1\xe8\x67\x03\xf4\xc0\
+\xc4\x75\x34\xa0\x4f\xe6\x37\x51\x9d\x4e\x11\xb4\x85\x13\x10\x53\
+\x5c\x3a\x78\x7e\x88\xeb\x5c\xd4\x36\x2c\xb7\x41\xb5\x34\x0e\xa6\
+\x8e\x5c\xed\xad\xe6\x23\x36\xaf\x3e\x45\xa3\x2b\x4e\xfc\x47\x7b\
+\x09\x56\x3a\x00\x06\xc5\xea\x62\x70\x6a\xe2\xb8\xaf\x0e\x68\x16\
+\x5a\x06\xe1\xe9\x51\x9c\x58\x51\x48\xa7\xd3\xa4\x5e\xd0\x96\x1d\
+\xd3\x22\xad\x17\x54\xe4\xb0\x8f\x47\x4e\xb3\x08\xde\x20\xd5\xb0\
+\x99\xd9\xc8\xba\x99\x2f\x83\x17\xd5\x21\x73\x1c\x86\xa3\x90\xe5\
+\x26\x8c\x6d\x81\xbb\x17\xac\x0d\x06\x1e\xd4\xd8\x97\xc1\x3c\xf0\
+\x56\xe4\x4e\x12\x80\x24\x73\xd0\x64\xe7\xae\xd0\x26\x17\x7c\xb3\
+\xf4\x27\x0e\xb1\xa4\xbd\x2a\x51\x02\x08\x97\xf4\xf3\x2a\xfa\xf2\
+\x72\x6b\x22\x96\xc8\xb4\xc6\x0d\xfc\x62\x75\x58\xc9\x1d\xfb\x85\
+\x49\x77\x79\xa4\x32\x2c\x5a\xf5\xa8\x28\x67\xec\xac\x88\xd9\x65\
+\x1f\x70\x8d\x3a\xff\xd5\x47\x3f\xc2\xee\xf5\x67\x78\xe5\xe1\xfb\
+\xfc\xf4\xed\xaf\xf0\xbc\xfa\xb7\x02\x37\x0d\x6f\xf2\x85\xcf\x7f\
+\x91\xd6\xca\x2d\xd6\xeb\xcb\x72\xd4\xdf\x2a\x0b\x52\x33\xa4\x7e\
+\xf3\x19\x0e\xef\xbf\x0f\x27\x3a\x6b\xdd\x26\xd7\xcc\x70\x6e\xa8\
+\x54\xb5\x72\x74\x4b\x74\x97\xc4\x89\xd9\x21\xf2\x32\xfa\xb1\xc5\
+\x52\x57\xe7\x23\x2f\x75\x69\x3f\x7d\x99\x77\x6e\xff\x07\xb6\x5e\
+\x7f\x0f\xff\xd1\xee\xec\xd2\xed\xc1\xfb\x6f\xde\xe3\x6b\x03\x8f\
+\x1f\xfc\xcf\xee\xf3\xc9\x4f\x7c\x9a\xab\xbf\xf4\x73\xdc\x7a\xe7\
+\x36\x6f\xbc\x7a\x1d\x9f\xf7\x71\x8e\x37\x50\x96\x0d\x89\x9b\xc5\
+\x7f\x77\x24\xfd\x8b\x7b\x99\x89\xe7\x87\xc4\x4e\x0d\xc3\x17\x99\
+\xb8\xe3\xe4\x78\x45\x56\x6e\xd0\x44\x75\x46\x32\x90\xc7\x84\xb8\
+\x95\x2c\xd1\xa0\x46\x8f\x94\x2e\x33\x2d\x71\x95\x1b\x06\x0b\x56\
+\x80\xbb\x22\x6b\x5f\xbf\x76\x8b\x2b\x37\xaf\x73\xe9\xc6\x66\x31\
+\xc2\x50\x38\x3e\x15\xff\x4b\xbd\x48\x4c\x5d\x20\x9d\xb6\xd0\x6a\
+\x43\x3a\x99\x22\x18\x08\x33\x93\xc5\x5b\x75\x25\x18\x64\xf4\x51\
+\x51\xa2\x09\x4e\xcd\x94\x01\x0c\xa0\x7a\x0e\x74\x52\x19\xc0\x79\
+\x63\x8c\x37\x76\xc4\xe3\xc0\x41\xd7\x2d\x22\x1a\xa8\x81\x29\x33\
+\xf1\x8d\x4b\x06\x03\x6f\x1d\x06\xfb\xd8\x6d\xad\xc0\xc7\xf3\x58\
+\x58\x14\x85\xce\xdc\xf0\xa9\xdc\x63\x27\xc5\xec\x16\x28\xa1\x82\
+\x6a\x26\xb3\x82\xc8\x32\x71\xc2\x48\x76\xe4\xe2\x0a\x56\xd6\x42\
+\x05\x5f\x0d\xb0\xac\xfc\x82\x2d\xab\x66\x9a\xa4\x51\x24\x8f\x16\
+\x33\x75\x5c\x5a\xd1\x50\x94\x41\x1d\x86\x0a\x76\x9a\x0b\x89\x26\
+\x26\x53\x7d\x99\xe5\x16\x7c\xe1\x3a\x6c\x7d\xe3\x26\xbf\xf5\x78\
+\x99\x17\x6f\xbd\xc6\x8f\x7e\xe1\x5f\xb1\x79\x6b\x1d\x3b\x2a\xf6\
+\xdd\x45\x9c\x9b\xc1\x52\x58\x30\x15\xb2\x67\xae\x8a\xb3\xbc\x5b\
+\xc7\x2a\xf7\x89\x16\xda\x08\xcb\x34\xcf\x95\x7c\x39\xb0\x80\xdb\
+\x1f\x01\x36\x86\xe2\x89\xa5\x8f\x4f\xe2\x7d\x95\x26\xbd\xe1\x88\
+\x3f\x7e\x4b\x8c\xee\x7b\x67\x47\x18\xcb\x9f\xe3\xc7\xaf\x2d\xf2\
+\x89\x8d\x0e\xdb\x7b\x1d\x8e\x0f\x0e\x51\xc3\x23\x1e\xaa\x22\xd3\
+\xe4\x47\x2a\x0f\x0f\x22\x26\xc7\xbb\x9c\x8e\x0c\xc6\x14\x12\x4b\
+\x5f\x1c\x5d\x27\xc2\x2b\x24\xaa\xe2\x3e\xb8\x88\xe0\x6d\xf8\xb5\
+\x27\x66\xdd\x6e\x65\x4f\x5c\x2f\xef\xb1\x0c\xac\xac\x3e\x87\x6d\
+\x8f\xb8\xb6\xbe\xce\xa3\xfb\x0f\xe8\xf5\x15\xbe\xf8\x99\x0e\x37\
+\x57\x72\xdc\xee\x0a\x0b\x56\x9d\x34\xb7\x30\xea\x1d\xb4\x49\x84\
+\x55\x0c\xd5\x96\x59\x55\x9b\x44\x60\x4e\x49\x8b\xd7\xc5\x7b\xa6\
+\x0a\x0b\x40\x2d\x9d\x33\x53\xa1\x92\xe6\x3c\x35\xa7\x59\xb0\x18\
+\x49\x12\xe2\xdb\x21\x76\x92\xd2\x47\xa3\xab\x6a\xe4\x5e\x8e\xa7\
+\xce\xe0\xc5\xf9\x9b\xcc\xc4\x45\x81\x57\xb2\x14\xab\x4a\x32\x27\
+\xdf\xd4\x82\x96\x1c\x46\x4d\xed\x14\x83\x27\x6c\x14\xbd\x70\xb3\
+\x4c\x39\xae\x54\xbe\x65\x9a\x55\x32\x17\x8a\x1c\xeb\x11\x2e\x98\
+\x79\xa5\xbd\x6c\x49\x09\x67\xd9\x6e\x0e\x0b\xef\x8a\x92\x97\x4e\
+\x2b\x30\x26\x2c\x27\xac\xe3\x09\xf6\x48\x63\x94\xa7\xe8\x76\x82\
+\x6d\xd4\xd9\xcb\x6a\x74\x9e\xdd\x42\x7b\xa8\x70\x9c\xff\x2c\x97\
+\x17\x4d\x16\xc8\xc0\x9c\x59\xbf\x5a\x91\x22\x8a\xd2\xb2\x33\x17\
+\x28\xa8\x5a\x83\xfa\xa4\x47\xd4\x1f\x48\x08\x24\x3b\x75\x4f\x5a\
+\x8a\x16\xf6\x19\x8d\x43\x9a\x45\x76\x4e\xc7\x27\x6c\x6f\xdd\xe3\
+\xdd\xf7\x1e\xe3\x9a\xf3\x05\x54\xb7\x65\xf1\xa8\x77\xc4\x1f\xbf\
+\xf5\x88\x3f\x7e\xeb\x11\x1f\x7f\xe6\x11\xef\xdf\x5a\xe6\xe6\xa6\
+\x8d\xaa\x7d\x9a\xcb\xf9\x1e\xf7\x07\x0a\x0c\x0e\xd9\xcd\x60\xf2\
+\x68\x97\xe3\x01\x78\x7e\x8e\xeb\x8c\xc0\x37\x49\xec\x09\xf9\x28\
+\xc7\xd0\x4d\x19\xc0\x02\x1f\x8b\xfb\xfd\x6c\x40\xc7\x69\x8b\x23\
+\x6d\x09\x21\x24\x04\xa9\x24\x8c\xae\x1a\xf1\xe9\x85\x15\x8c\xb5\
+\x16\x76\xbb\xcb\x83\xc7\x31\x2b\x16\x1c\x76\x72\x1a\xcb\x97\x49\
+\xcd\xab\x74\xac\x19\x3c\x88\x27\x3d\xb4\xca\xb8\xbe\x36\x11\xc2\
+\x1a\x0d\x5b\x14\xee\x93\xf3\xdb\xa9\x32\xce\x39\x6c\x8b\x91\xa6\
+\x89\x38\x09\x95\x68\x02\x8d\x99\x78\x9e\x54\x58\x5d\xe1\xd6\x18\
+\x91\x92\xbb\x0a\xc5\x8c\xa9\xcc\xce\x42\xe0\x3e\x9f\x89\xcb\xcc\
+\x5b\xf2\xc5\x2d\xb6\x67\xed\xe5\x00\x1a\xc5\x74\x88\x9c\x12\x29\
+\x8a\x3c\xdd\x2a\x27\x94\xad\x52\xe7\x10\xce\x63\xe4\x48\xd0\x68\
+\x46\x45\x7d\xe6\x44\x96\x5c\x18\x63\xa7\x19\x9e\xa3\x14\x7b\x3f\
+\x66\x25\x93\x53\x1d\x5f\x2a\xe6\xed\xca\xad\x19\x56\x14\x51\x6e\
+\x75\x88\xc2\x10\x2b\x35\x45\x00\x17\x2e\x3b\x4d\x25\x23\x34\x73\
+\xea\x96\xc5\xb3\x5a\xc4\xfd\xad\x9f\x27\xdf\x3c\xe6\x27\xba\x75\
+\x0c\xb3\x0f\x74\xa4\x5b\x50\xd5\x2e\x36\x2c\x32\x31\x40\x43\x09\
+\xa1\xd3\x91\x85\x80\x45\x58\x08\x93\x8a\x1d\xd1\x61\xb9\xca\x61\
+\x16\x0c\x4a\xab\xce\x58\xab\x95\x12\x3c\xf2\xe3\x18\xd7\x3c\x94\
+\x4d\x85\xf2\x76\x3a\x32\x68\xb5\x5b\xe0\x41\x2f\x85\xbf\xb9\xf3\
+\x88\xb7\xf6\xca\xae\xd9\x43\xd9\x70\xe8\x65\xe1\x5c\x80\xba\xf9\
+\x2c\xe3\xea\x41\x5d\x2e\x2c\x8a\x93\x08\xa3\xb0\x53\x4d\xec\x09\
+\x7a\x50\xa7\xa3\xb6\x0b\x9c\x5c\x27\x23\x95\xb8\xb9\x85\x5b\x64\
+\x66\xf1\x3e\x74\xd5\x08\xa3\x69\xd2\xb0\x2f\x71\x65\x25\x07\x12\
+\x82\x9a\xca\xdf\x85\xd0\x6d\xde\xe0\xc5\xce\x2a\x37\x37\x0d\x1c\
+\x7d\x4c\x4e\x1d\x3d\x50\xd1\xed\x4c\x14\x74\x72\x99\xa4\x2d\xbb\
+\x60\xe7\xe7\xd8\x6c\xad\x4e\x50\xbc\xa7\xd5\x2c\x2c\xda\xd2\x16\
+\x03\x90\x70\xa2\xba\x85\xb4\x67\xe7\x98\x05\x3e\xee\x78\x39\xfd\
+\x4c\xbc\xe6\xa9\x0e\x49\x12\xa2\x05\xb3\xac\x3c\x3e\xf5\x18\x58\
+\xcf\x4a\x0c\x1c\x0c\x52\xda\xed\x23\x0e\x07\x3a\x3f\xa6\x05\x24\
+\x99\xf3\x44\x48\x21\xdb\xce\x8a\x1f\x40\xa4\xe3\xfa\x79\xe1\x9f\
+\x36\x7f\x4b\x09\x65\x03\x40\x2b\x98\x85\x12\x0a\xd8\x46\x5d\xfa\
+\x53\xa4\x17\xa4\x9a\x4f\x30\x9e\xaa\x70\xb4\xae\x9f\xa3\xf8\x39\
+\x56\x6a\x12\x6a\x11\x4a\x49\xbb\x35\x0d\x68\x1a\x58\xa9\xc9\xc4\
+\x0f\x09\xb1\xb9\x7a\x45\xe7\x85\xee\x9f\x8a\x4b\xb0\xb2\x36\xe7\
+\x16\x54\xde\x0f\x2b\x98\x37\x4b\xc7\x60\x89\x25\x07\x96\x69\xd2\
+\x31\x4d\x30\x3b\x73\x3c\x38\x96\x39\xa3\x11\x73\xf1\x77\xbb\xae\
+\x8d\x6a\x07\x9c\x45\x19\xbd\xdb\x03\x76\x46\xce\x05\x2a\x6b\xe0\
+\x88\xa2\xcd\xf3\x4d\x3c\xe3\x59\xba\xed\x0e\x69\x7b\x83\xde\x00\
+\x86\x83\x21\x77\xdf\x7a\xc8\xab\x6f\x3d\xe2\xf5\x87\x87\xf4\x06\
+\x02\x1e\xc8\x2c\xab\xcc\x02\x35\x4e\x22\xe2\x24\x2a\xf8\x6d\x13\
+\x37\x8f\x64\x70\x27\xf6\x44\x64\x60\x35\xc7\x75\x2c\xc6\x4c\xf1\
+\xfc\x90\x56\xe0\x56\x58\x8a\x59\x00\x7f\x7a\xa1\xcd\xf2\x52\x01\
+\xcf\xcc\xab\x92\x27\xde\xbc\xa6\x61\x6e\xde\x90\xfa\xe1\x34\x6f\
+\xa0\xdb\x99\x18\x0e\xb5\x33\xf4\x40\x9d\x9b\x59\x33\x2f\x4c\x14\
+\xdb\x04\xe9\x64\xae\xb9\x71\xfe\x96\x9b\x75\xfc\x69\x34\x37\x01\
+\x22\xdc\x2b\x6d\xec\x20\x2c\xae\x2a\xb3\xf4\xe6\x66\x42\x5c\x94\
+\xda\xb3\x9f\x56\x2e\x65\x2f\xa9\xb6\xea\xed\x30\xb5\xd1\x55\x1f\
+\x37\xf3\x19\x91\x4a\x0d\x45\x49\xb5\x8d\xfd\x18\x5d\xec\xd0\x98\
+\x10\xc4\x00\x13\xd1\x75\x2b\x60\x82\x53\x66\xd1\xca\xf8\x52\x89\
+\x85\xd3\xc2\x38\x5b\xc2\x85\x62\x1c\xdf\x2a\xee\x5b\x55\xc6\xa0\
+\xc2\x4c\xa4\x73\x6b\x09\x98\x1b\x22\x0d\xac\xc9\xec\x22\x37\x8a\
+\x09\x3b\x29\x9d\xa2\xc3\x77\xd4\xff\x4f\xa1\x53\x4a\x39\x43\xc2\
+\xc2\x26\x40\x40\x89\x19\x33\x21\xbc\x36\x8b\x8c\x62\xe6\xf4\xfb\
+\x03\xa9\xb6\xd3\x0a\xcd\x44\x29\x3e\xc2\x2a\x1d\x3d\x33\xc6\xa1\
+\x45\x03\x11\xf0\x47\xe3\x87\xc2\xae\xea\xf4\x8d\x0f\xc5\xa2\xb1\
+\x53\xa3\xcb\x7b\xe2\xf2\xe7\x37\x41\x2f\xd8\x84\x36\xb4\x80\x1e\
+\x29\x86\x3f\xc5\xf3\x9f\xf0\x8f\x2f\x60\x44\x35\x0b\x97\x01\x5e\
+\xc5\xc7\x5e\x91\x0e\x5c\x27\x2a\x8a\xbc\xb2\xd8\xd3\x8a\x4c\x6c\
+\xb1\xd6\x5d\xa2\x61\x77\xa8\xaf\x2e\xc8\xb1\x7c\x50\x58\xeb\x2e\
+\xcd\x35\x37\xce\x27\x94\xa4\x08\xe0\xf3\x9b\x57\xab\x33\x6c\x60\
+\x4b\x49\xe6\x93\x6e\x65\x61\x57\xcd\xce\xba\x6e\x61\xc7\x62\x0d\
+\x46\x99\x8d\xd7\x8d\xa9\xcc\xc0\x9e\xee\xc8\x79\xb9\xb3\x22\x9e\
+\xce\xef\xad\xb6\xdb\x1a\xc1\x20\x65\x55\x49\xa4\x8a\xad\x6c\x63\
+\xa7\xa4\xa8\xbe\x4f\xe6\x38\x32\x90\xd5\xb2\x55\x2c\x47\xd6\xcb\
+\x82\x26\x0a\x45\xa6\x2c\x2d\x58\x4b\x21\xbb\x29\xba\x73\x8e\xa4\
+\xd3\x84\xd9\xb6\x2c\xd0\x2a\x19\xb2\x0c\x5a\x2b\x52\xb0\xa2\x08\
+\xfb\x34\x94\x43\x98\xaa\xe2\x10\x68\x2a\xb9\x23\xcc\xae\xcb\x6c\
+\x1c\xc4\x93\xb9\xe5\x34\x61\x91\x2d\x57\x3a\xff\x9e\xb5\xcd\x87\
+\x52\xca\x59\x9e\x24\xe5\xb6\xd1\xb4\x82\x75\xad\x64\x22\x03\x35\
+\x26\x60\x74\x16\x72\xb6\x17\xe1\xf7\xfb\x78\xfd\x03\xa2\x28\x62\
+\x2f\x88\xe8\x13\x32\xee\x4f\x88\x22\x85\x2c\x1d\x33\x0e\x22\xa2\
+\xfe\x80\x47\x7b\x3e\xf9\x71\x7c\xa1\xdd\x5b\x75\xb9\xec\xa2\x91\
+\xf9\x4d\xf0\x40\x75\x46\xa8\xf9\x88\xcc\x4f\xf1\xfc\x50\x06\x70\
+\x99\x5d\x65\x51\x98\x1c\x3f\x59\x1f\x9b\x44\x17\x30\xb1\xeb\x44\
+\x73\x59\xbc\x2c\x06\xcb\xf0\xe9\xaa\x16\x57\xd6\x2c\x36\x94\x58\
+\x66\xe1\xd5\x8a\x66\xe2\xfa\x35\xd1\xdc\xb8\xb4\xbe\x8c\x65\xd5\
+\x45\x16\x0e\xc4\xba\x86\x24\x88\xd0\x6d\x93\xa4\x92\x8d\xa3\x39\
+\x18\x81\x84\x0f\x65\xfb\x39\x48\x27\x04\x86\x72\xa1\x39\x92\x9b\
+\x75\x9c\xda\xac\x4d\x5d\xe5\x89\xf5\x40\xc5\xd6\x52\x19\xc0\xe5\
+\xd8\x7f\xc9\xb1\x2c\xcc\xef\xdf\x9a\x5d\x07\x06\x22\x38\x0f\x73\
+\x7d\xe6\x8a\x59\xb4\xac\xcb\x2e\xa0\x9c\x76\x06\xd4\xb2\xf5\x8b\
+\x65\x8a\x0e\xdc\x39\x0b\xd4\x28\x0c\xa5\xc8\xa7\x0c\xd4\xb2\x79\
+\x51\xbe\x5e\x85\x1e\x56\xa4\x10\xa0\x16\xde\x6b\xa2\x71\xa2\xf8\
+\x81\xcc\xbe\x0b\xb9\xd8\xa3\x91\x36\xb2\x62\x0b\xa9\x60\x40\x72\
+\x6c\x49\xfd\xc8\x5f\xba\x02\x3f\x9e\x57\x1b\x1c\x6c\x5f\x97\xc1\
+\x29\x57\xe5\x56\x27\xb0\xab\xcd\x8c\x02\x22\xd8\x96\x45\x73\xbd\
+\xc7\x71\xfa\x06\xdf\xf7\xbe\x0a\xfa\x9b\x8c\x03\x85\x86\x2d\x4c\
+\x62\xfa\x39\x78\x9e\x90\x03\xb6\xfa\x23\x46\x67\x21\xc9\xde\x23\
+\xe2\xf0\x00\x2f\x5a\xc5\x68\xf5\x58\x5d\x5d\x92\xed\xe7\xd5\xd5\
+\xa5\x59\x57\xcc\xd1\xc0\xed\xe0\x45\xcf\x92\x29\x4d\x09\x15\x0c\
+\x7f\x2a\x03\x30\x4e\x22\x19\xbc\xaa\xbe\x4c\x9c\x44\x68\x0c\xe7\
+\x82\xb7\xcc\xca\x25\x6e\x4e\xec\x09\x78\x22\xa0\xdd\x3c\x9a\x73\
+\xdc\x15\xc1\xdc\xc1\x68\x9a\x28\xb5\x45\x1a\xf6\x25\xea\xab\x97\
+\x59\x1d\x45\x1c\x36\x4d\xc6\xc7\x29\x76\x5b\xc3\x5c\x5d\x67\xe9\
+\xa9\x45\xec\x92\x7a\x8c\x14\x92\xca\x25\x3c\x2a\x82\xcc\x53\xf3\
+\xb9\xbd\xd7\x65\x20\x27\x81\x3a\x17\xc0\xb6\x56\x97\xef\x6f\x55\
+\x57\x01\xe0\x4f\xa3\xbf\x37\x63\x97\x81\x5d\x16\x75\xe5\xe3\xb3\
+\xa2\x71\x33\x3e\xf5\x64\x16\xae\x76\xf0\xec\xb6\xc6\xaa\x16\xc8\
+\xef\xe1\xa9\x0e\x0d\x5b\x7c\x9f\xaa\x12\x4e\x8f\x8a\x0e\x9b\x9c\
+\xce\xb0\x2a\xc6\x29\x9a\x0a\x56\x77\xbe\x0d\x1d\x4e\x24\x37\x25\
+\x16\xd3\x98\x78\xc5\xc4\x47\xc7\x34\xf1\xa3\x90\x7a\xd1\xcc\xa8\
+\x0f\x8e\x50\x8a\x3d\x64\x81\x95\xa1\x98\x39\x5b\x96\x85\x43\x26\
+\xa8\xae\x28\x92\xd8\x59\x29\xb7\x29\x99\x39\xa3\xde\x08\xa5\xdb\
+\x04\x84\xcb\xbc\xae\x3e\xc7\x78\x75\xc2\x33\x4b\x0f\x81\x2f\x14\
+\xdb\x94\x94\x73\xeb\xc1\x22\x89\xc6\x75\xd3\x82\xa8\x47\xdf\xdc\
+\xe7\xdd\xdd\x3f\x83\xf4\x35\x00\xde\xef\x89\xbf\xf1\xb9\xa5\xcf\
+\x22\xfc\xf5\x2c\x3a\xb6\x49\x98\x5b\xdc\xed\x8f\x21\xab\x73\x7c\
+\xf8\x16\xc3\xe4\x16\xf0\x80\x9b\x2b\x87\xb2\x95\x6c\x58\x6b\xac\
+\x71\x20\x0d\x00\x0f\x8a\x6e\x82\x72\xe6\xd3\x48\xf6\x64\xa6\x2c\
+\x31\x6d\x6f\x00\xdd\x36\x68\x83\x21\x29\x2d\xd2\x4a\xf1\x56\x3e\
+\x2e\x03\xb8\x84\x14\x71\x12\x41\x1b\x0a\xef\x6b\x12\x7b\x82\x17\
+\x08\x26\xa3\x15\xd4\xc8\xfc\x1a\x6e\x3e\xa2\xab\x2a\xac\x3a\x16\
+\xd7\x36\x35\x16\xb4\x36\x93\xc3\x3d\x0e\x57\x2f\xcb\x69\x88\x35\
+\x33\xc1\x59\xde\xc7\xb4\xae\x91\xb2\xc0\x70\xd8\xc2\x69\x0e\xd0\
+\xbc\x13\x52\x77\xe6\xdd\x90\xd8\xe0\x06\x2a\x04\xc5\xff\xd6\x36\
+\x99\xd9\xbb\x22\x03\x53\xf0\xbf\xa9\x74\xcd\xbc\xe4\x19\xf8\xae\
+\xc8\xd4\x83\x82\x27\x16\x81\x6d\xcb\xe2\x2f\x09\x22\x9a\xe4\xc2\
+\x80\xbb\xd0\x58\xf4\x93\x10\x5d\x9d\xf1\xcd\x79\xbf\x28\xc2\x17\
+\x5d\xa6\xda\x3a\x67\xe1\x2e\xab\x35\x75\x2e\xa0\x0f\x53\x9b\x85\
+\x51\xb1\x6a\xb7\xe0\x99\x1b\x8e\x03\xc1\x0c\x17\xab\x06\xa1\x98\
+\xce\xc0\x22\x0e\x15\xfa\x05\x4e\x09\x34\x55\x72\xc3\xe5\xe4\x72\
+\x75\x49\xa2\x16\x2a\xf2\xd2\xaf\x87\x82\x9a\xb2\xa2\x08\xd7\xcf\
+\xd1\xc3\x10\xe5\x60\xca\xe9\x78\x91\xbc\xf7\x50\x16\x81\x66\xa7\
+\x23\x9c\x30\x9f\xd0\x02\x2e\x0b\x44\xd3\xb2\xb8\xb4\x7e\x95\xc4\
+\xb2\xa4\xa6\xe1\xda\xe5\x90\x56\xf0\xf3\x1c\x6c\x5f\x17\x2a\xb5\
+\x48\xe1\x71\xd8\xe3\x9d\xed\xbf\xe4\xfb\x93\x2d\xfc\xa8\x3f\xd7\
+\x8a\xf4\x92\x8c\x1d\xf5\x88\x77\xb7\xfe\x07\xde\x3f\x79\x55\x06\
+\xaf\xbc\x64\x27\x19\x53\x42\x82\xa8\x47\x18\xf6\xa1\xd0\x8f\x1c\
+\x9d\x9e\x31\x7a\x0c\xde\xf1\xdb\x73\x1a\x61\x63\xc5\x94\x73\x74\
+\x6b\x35\x4b\xb6\x8c\x95\x33\x5f\x52\x5e\x73\xf4\x53\x50\xa7\xab\
+\x41\x6f\x20\x02\xf6\x49\xb0\x41\x14\xca\xc3\x39\x66\x42\x69\x2a\
+\xf4\x33\x05\x75\x34\x00\xb7\x60\x30\x98\x1d\xc7\x4c\xe9\xb6\x2c\
+\x8c\xa6\xc9\x95\x7a\x8b\xfa\x69\x93\x83\x74\x47\x66\xe2\xea\x6d\
+\xa9\x75\x93\xd5\x85\x18\x27\xf6\x69\xeb\x23\xb9\xba\xa1\x84\x0f\
+\x26\xd0\x0d\xce\xd9\xd8\x06\x62\x61\xa2\x5d\x3e\xef\x09\x61\x8f\
+\x1d\x84\x22\x48\xbd\x29\x76\x6f\x82\x4f\x82\x3a\x39\x12\xc1\x3d\
+\x6e\x90\xa7\x9e\xc4\xd8\xd5\xa6\xc7\x79\x46\x63\x3e\x33\x8f\x59\
+\xec\xb4\x65\x26\x06\x61\x81\xf0\x24\x58\xa1\x36\x05\x84\x28\x33\
+\xf1\x38\x10\x22\x7b\xd5\xf7\x05\x3b\x11\x63\xc9\x81\x4f\x2c\x93\
+\xe6\x13\xd8\x89\xaa\x07\x9b\x55\xc2\x0f\xc1\x42\x91\x04\x3a\x56\
+\x2a\x2a\xfd\xb0\x1f\x31\x1a\xa6\x58\x7d\x8d\xe3\xbc\x4f\x53\xc9\
+\x88\x6e\x6c\xca\xc5\x8c\x73\xad\x67\x33\x2f\x4c\xb4\xc5\xd1\xb2\
+\x04\xcd\x56\x62\xe0\x52\x34\x5f\x42\x99\xa1\xfd\x9b\x22\x10\xa2\
+\x0e\x29\x21\x5b\x8f\xbf\xcb\x1f\xde\xfe\xb7\x7c\xf3\xce\x7f\xcf\
+\x7b\xdb\xaf\xe2\x85\x33\x06\x21\x1f\x4e\x38\x39\xfe\xd3\xb9\xe0\
+\xad\xde\x37\xf5\x08\xb3\xd3\xc6\xe9\x74\xb0\x3a\xe2\x32\xd9\x31\
+\x42\x76\xa3\x43\xb1\x5e\xab\xd5\x9b\x5b\x49\x50\xfa\x0f\x67\xe1\
+\x89\x14\xed\x94\x01\x3c\xb4\x3d\xdc\x7c\xc6\x34\x94\xc7\x5e\x3a\
+\x1f\xac\x4f\xba\x95\x01\x5e\x32\x15\xf9\x28\xa7\xa3\xe6\xa8\xfa\
+\xf2\x1c\x35\x57\xb6\x8f\xdd\x5c\xb0\x11\x6b\xdd\x25\xce\xda\x2e\
+\x93\xc5\x11\x6b\xda\x15\xc6\xc7\x29\x87\x85\xfc\x32\x18\xa4\xdc\
+\x3b\x78\xc4\x64\x6f\xc0\xe5\xf6\x0d\x6a\xed\x53\xc8\x66\x7c\x6b\
+\x9e\x7a\x12\x2e\x8c\x2a\x7b\x33\x66\xcf\x47\x8c\x50\x64\x20\x27\
+\x41\xc4\x70\xe0\x11\x1f\xf8\x0c\x07\x1e\xc3\x81\xc7\xe8\x6c\x9b\
+\xfe\x63\x83\x24\x88\x38\x53\x4f\x18\x8c\x12\xf2\xc1\xa8\x08\x76\
+\x4d\xb2\x12\x81\x9d\xcf\x69\x2a\x3a\x6a\x3a\x87\x99\x8f\xb3\xf9\
+\x93\x48\xee\xa8\xae\xdc\xaa\x70\xa2\x84\x11\x25\x53\xe1\xa9\x8e\
+\xb0\xb1\x32\x08\xe5\xe8\xbd\xc1\x6c\x4c\x47\x21\x90\x10\x22\xaa\
+\xd0\x66\xe5\x06\x24\x2c\x13\xc7\xb4\xd0\xed\x44\x70\xbc\xe9\xfc\
+\x2f\xe0\xda\x2d\xd4\x56\x87\xdc\x12\x70\x22\xd4\x22\x29\x34\xaa\
+\x1a\x4b\x95\x38\xdb\x27\xc4\x2a\xb4\x0d\x61\x18\x11\x86\x82\x4b\
+\xb6\x2c\x93\x38\x9a\x15\x00\x86\xd9\xe7\xbd\xed\x57\xb9\x7d\xfa\
+\x15\xa1\x05\xd8\x4f\xb8\x7d\xfa\x15\xee\x9e\xfc\x2e\x3b\x93\xad\
+\x42\xfa\xf8\x06\xef\x9f\xbc\xfa\xa1\x18\xcd\x30\xfb\x95\x6a\xdd\
+\x22\xc2\xe2\x74\x30\x60\xc3\x5c\x2d\x34\x9f\x5d\x28\xda\xb8\x07\
+\xd3\x90\x83\x69\xc8\xfe\xbd\x23\xee\xef\x85\x73\xc5\xd5\x98\x29\
+\x7a\x50\xc7\x53\xcc\x19\x1c\x28\x82\x52\x63\x38\x07\x1f\x3e\x2c\
+\x90\x65\xa1\xa8\x21\xb3\x77\x19\xd4\x55\x1a\xae\x6c\xb2\xac\x3a\
+\x0a\x1f\x69\x74\x58\x6e\xc6\xac\x69\x57\xd0\x33\x31\x6c\x3a\x39\
+\xdc\x93\x9f\xf7\x68\x3b\xe5\x7f\xfc\x3f\xfe\x6f\xfe\xe8\xab\xbf\
+\xc3\x5a\x57\x5c\xa5\x9c\xe4\x54\x0c\x85\x7a\x39\x79\xea\x89\x8f\
+\xc1\x48\x7c\xa4\x9e\x78\xbe\x7c\x3c\x18\x31\x4c\x7d\x46\x28\x34\
+\xc9\xe5\xd8\x51\xab\xed\x16\xc5\xee\xa2\xc4\xc2\x6a\x14\x63\xb0\
+\x28\x5f\x8b\xbd\x93\x4a\x16\xae\xcf\x4d\x48\x97\x54\x5b\x19\xd8\
+\xba\x3a\xdf\x44\x3a\x9f\x89\xed\xb6\xc6\x59\xc7\x44\x2f\x78\xe2\
+\xb2\xa0\x2b\x27\xa7\xdd\xcc\x17\x23\xfb\xf1\x39\xf2\x45\x0b\x15\
+\xcc\x62\x3a\xa3\x1c\x10\x35\x08\xe9\x17\xa3\xf9\x17\x6e\xc5\x42\
+\xc6\xc0\xb1\xc5\x0a\xad\xae\x41\xb0\xd6\x82\x4e\x07\xbf\x58\x38\
+\x5e\x2e\x61\xec\x17\xcd\x94\xf4\x1c\xe3\x21\x99\x0d\x98\xe3\xaa\
+\xa5\x9a\xce\xb2\x68\x05\x3f\xcf\xd0\xfe\x4d\x3c\x7f\x55\x06\x6f\
+\x79\x7b\x6f\x38\xe6\xfd\x93\x57\x19\x1e\xdd\x63\x67\xb2\xc5\xd6\
+\x4e\x32\xf7\xfa\x05\x36\x20\xea\xcc\xf1\xca\x7a\xa7\x49\x72\xea\
+\x32\xda\x9f\x59\xb7\x32\xec\x4a\xfb\x56\xe5\xcc\x67\xe0\x88\xe0\
+\xea\x0d\xfa\x92\xa7\x6d\x30\x6b\x09\x97\x4c\x44\x57\x9b\x65\xd9\
+\x38\x89\x18\x28\xf9\x85\x40\x2e\x9f\xab\x06\x70\x2f\x85\x61\x3a\
+\x9c\x2b\xf4\xca\xa3\x9b\x47\x74\x5b\x16\xd7\x5b\x1e\x57\xea\x2d\
+\x26\x8b\x23\x09\x25\x76\x72\xc1\xa2\xd4\x57\x2f\xcf\x7d\xcf\xfb\
+\x5b\x11\xaf\xff\xc6\x9f\xf1\x27\xbf\xfd\x7d\x8c\x56\x46\x9e\x77\
+\xc9\x07\x23\xc6\x76\x0d\xbc\x5c\x7c\x80\x98\x60\xf6\xf2\xd9\x24\
+\xb3\x5d\x34\x7b\x8a\xd7\xcb\x40\x6e\xb5\x5d\x70\x6b\xb4\x36\x16\
+\x38\x53\x33\x5a\x6d\x17\xa7\xb6\x8a\xd5\x71\x49\xdc\x06\x7a\x4f\
+\xb4\xe4\x5a\x9a\x43\x60\x5b\xb3\xc9\x8f\x0f\x29\xf4\xb4\x40\x23\
+\xc9\xba\x12\x13\x97\x38\xb8\x9a\x8d\x83\x41\x4a\xbd\x7f\x89\x44\
+\xf5\xe7\x98\x8d\x5e\x52\xe1\x2d\x47\x0a\xba\x59\x76\xa3\xc3\x88\
+\x18\x05\x2d\x0a\x49\x02\x5d\xb4\x7d\x43\x55\x58\x3f\x15\x7b\xe8\
+\x64\xfe\x54\x02\xc1\x2f\x16\x63\xfd\x3d\xec\x02\x8e\x88\xa0\xec\
+\x17\xcb\x5c\x3a\x45\x9f\x3b\x04\x52\xcb\x22\xe9\x0b\xa1\x91\x63\
+\xe5\x85\x6e\x19\xe9\x3e\x24\x79\x64\xb2\x42\x46\x54\x6a\x76\xcc\
+\xd9\x04\x09\xc2\x27\x78\x6b\x67\x3e\x40\x9f\x6d\x35\x78\x6f\x38\
+\x06\xbe\xc2\x0b\xfc\x02\x5b\x5b\xdf\x84\x96\x08\xf4\x6b\xeb\x17\
+\x3b\xeb\x7b\xa7\x11\x8b\x49\x0f\x55\x6b\xd0\x98\x4c\x79\xe4\x3f\
+\xe4\xd1\xfd\x77\x8a\xe5\x8a\xd0\x67\xb6\xf5\xb3\xf9\xa1\xce\xa2\
+\x00\x00\x20\x00\x49\x44\x41\x54\xcf\x1a\x9b\x3f\xb4\xc9\x95\xe3\
+\x98\x38\x3c\xe0\xee\x23\x9d\x31\xe0\x72\x28\xcd\xfc\x44\x37\x6d\
+\x02\xa3\x7c\x0e\x46\x9c\xc7\xbf\x29\x2d\x06\x4a\x4e\x3b\x9f\xbf\
+\x8c\xf6\xd2\xd9\xeb\x55\x48\x12\x27\x11\x5d\x8d\x82\xf9\x88\x49\
+\x1a\x62\x9a\xf2\x78\x64\xb0\x10\x3c\x46\xc7\xa4\x7e\xda\x84\x65\
+\x18\x1f\xa7\x34\x96\x35\x29\xd4\x87\x7b\xfc\xd1\xde\x19\xfe\xd7\
+\xfe\x98\x6b\x4f\xdf\xc2\x5d\x54\xa1\x09\x8d\x51\x07\x5c\x05\x45\
+\x73\xc9\x53\x4f\x64\xe7\x36\xa2\x08\x5b\xcb\x59\x0b\x14\x46\x45\
+\x07\xae\xcc\xd0\x07\x76\x8d\x86\x16\xe3\x8f\x1d\xdc\x4c\xa1\xd5\
+\x76\x19\xa6\x3e\x8a\xa6\x30\x0e\x23\x16\xac\xc7\x64\xdd\x0d\xa0\
+\xf7\xa1\x38\xb8\xda\xae\x2e\xa7\x3e\xf4\xa0\x27\x31\xf1\x74\xe3\
+\x59\x59\xd8\x55\x6f\x0e\x3b\xc0\x75\x92\x24\x44\xd1\x5b\x24\xc9\
+\x2c\xa0\x3d\xd5\x99\x37\x4f\x31\x81\xa4\xd8\xf3\xac\xdb\x89\x64\
+\x14\x88\xc2\x79\x5f\x89\x73\x78\x19\x20\x33\x67\xff\x94\x7e\x14\
+\x51\x37\x33\xea\xa5\x1d\x7d\x81\x7b\x35\x2c\xb9\x0f\x3a\xec\x47\
+\x72\xa8\xb4\xc4\xbf\x5a\xa8\x08\x0e\x38\x8c\x24\xa4\x98\x1b\xa8\
+\xdc\x7c\x88\x77\xf7\xe7\x48\xb2\x77\x49\x86\xbf\x07\x20\x03\xf4\
+\xd1\x7e\x22\x03\x79\x6b\x27\x61\xd0\xba\x3f\xbb\xb4\x3e\x21\x23\
+\x5f\x5e\x34\x51\xb5\x06\x1d\x05\x46\x63\xbf\x22\xfa\x3f\x60\x7b\
+\xf8\x00\xff\xd1\x2e\xdb\xc3\x07\xbc\xf5\x78\x9b\x38\x3c\x60\x5d\
+\xd7\xf9\xdc\x67\x9e\xe2\xd6\x17\x7e\x94\x9f\xf8\xb1\x4d\x9e\x7b\
+\xf6\xd2\x1c\xd5\x56\x16\x5f\x55\xaa\x4c\x63\xc8\x40\xc9\x59\xc8\
+\x47\x0c\x94\x5c\x06\xe8\xf9\x00\xae\x06\xf8\x93\x20\x47\xa6\x34\
+\x59\x6c\xc6\x5c\x59\x13\x19\x7f\x67\x32\xfb\x9c\xe3\x91\xc1\x64\
+\x71\x84\x9e\x1d\x62\x5f\x3e\x65\x7c\x3c\x0b\x9e\x9b\x9b\xd7\x71\
+\x17\x37\x79\x63\x47\xe7\x95\x3f\xfa\x6d\xe8\x17\xfc\x7d\x77\x8a\
+\xa2\xb9\x24\x76\x86\xa2\xb9\x45\x07\x4f\x64\xdc\x24\x50\x8b\x2c\
+\x9a\xa1\x17\xaf\x1b\x6b\x0e\x4e\xcd\x44\xd1\x5c\x94\x68\x82\x3f\
+\x15\x18\xb9\xa5\x39\x78\x6a\x8e\x1a\xc5\xe4\x66\x9d\x8c\x1e\x81\
+\x9d\x4b\x03\x42\x89\xe5\x3d\xe7\x89\x74\x1b\x34\xe6\xd8\x89\x5a\
+\xba\x7f\x21\x80\x57\x95\x04\xbf\xb3\x39\xd3\x6a\x90\x0a\x96\xa2\
+\x80\x16\x49\x12\x8a\x4c\x5c\x95\x81\x39\x66\xb1\xe3\xc8\x2c\x3a\
+\x5c\x85\xc8\x47\xc3\x22\x0e\x23\x34\xcb\x9a\x2b\xf6\xca\x72\x6d\
+\x12\x05\xa5\x4e\x4c\x14\x86\x51\x50\x74\xc7\x66\x66\x24\x32\x53\
+\x47\xb3\x8e\x1c\x56\x86\x92\xd6\x09\xe2\x44\xb6\x8d\xe4\xe2\x46\
+\x39\x6d\x91\xe3\x14\x13\xd9\x49\xf2\x2a\xf0\x45\xf4\xd6\x97\x09\
+\xe3\x5f\xe5\x51\xc1\xc4\x5c\x5b\xd7\x79\x6f\x38\xe6\xd9\x56\x83\
+\xb7\xf6\xbf\xc2\xdb\x6f\xde\xe2\x63\x2f\xde\x9b\x0b\x74\x39\xab\
+\x95\x3f\x85\xdb\xe9\x60\x91\x11\x46\x0a\x9b\x37\xdb\x6c\xd2\xe6\
+\xf2\xa2\xc9\x4b\x67\x9f\xe2\x2c\x0f\x49\x0e\x07\x72\xed\xed\xf6\
+\xf0\x01\x93\x57\xef\xf2\xe8\xfe\x03\xae\xdd\xbc\xc1\xb5\x4f\xa9\
+\x2c\xbc\xf3\x14\xb7\x4f\x7a\xb0\x53\x71\xc3\x29\x34\x0f\xe5\xed\
+\x4c\x69\xa2\xa4\x1e\x67\x5a\x93\x85\x7c\x34\xc7\x52\x68\x0c\xe9\
+\x65\x0a\x2d\xb5\xf9\xa1\x01\x5c\xc2\x92\x6e\x33\x96\x33\x73\x92\
+\x2b\x3e\xde\x23\xa8\x2d\x62\x03\xb5\xd1\x63\x76\x9a\x97\xb8\xb2\
+\x03\x8d\x55\x0d\x8e\xc4\xc9\x78\xea\x9d\xb0\xe8\x2e\xd1\x1b\x8d\
+\x38\x7a\xbd\xcf\xdb\x1f\xf9\x16\x9f\xfc\xc9\x97\x60\x0c\x89\x9d\
+\x11\x45\x21\x4e\x31\xfe\x1e\x16\xa6\x7e\x4a\x34\xc1\x2c\x82\xda\
+\x84\x4a\x8b\x5a\x50\x72\x6b\xd4\x19\xa1\x90\x07\x53\x86\xa9\x8f\
+\x65\x37\xe8\x99\x06\x6e\xa6\x10\x14\x63\x4d\xea\xe4\x88\xac\x58\
+\x28\xa3\xeb\x16\x49\x31\x39\x5d\x35\xe3\x2e\x19\x6f\xa5\xa3\x5e\
+\xc8\xc4\x55\x6c\x5c\x4e\x76\x64\x23\x31\x0d\x9a\x24\x21\xa5\x53\
+\x4a\x13\x4d\xe4\xfd\x66\x5e\xf0\xc4\x72\x70\x31\x87\x50\x21\xb4\
+\x72\x0c\x59\xd0\x39\x18\x84\x84\x16\x72\x71\xf9\x6c\x1a\x4f\x3c\
+\x6e\x9e\xc3\xca\xa5\xdc\x32\x2e\x9c\x34\x4d\x29\xd5\x01\x8a\xac\
+\x1d\x10\x02\x2e\x81\x96\x60\x39\x3a\x61\x98\x14\x5d\xc0\x59\x6b\
+\x58\x37\x33\x32\x9a\xd4\x8a\xe0\x1b\xb4\x5e\x01\xbe\x48\x32\xfc\
+\x3d\xac\xac\xce\xb5\x75\x9d\x47\xfb\x02\xff\x3e\xbb\x2e\x32\xb1\
+\x45\x5d\x06\xf0\xf9\xdb\x33\x5d\x85\xd6\xca\x2d\x08\x1b\xf4\x95\
+\x00\xc2\x08\x6f\xff\xa8\x70\xfb\x11\x96\xfb\xc9\x24\x81\xe5\x7d\
+\x7e\x64\xfd\x69\xec\x8f\x76\xc9\xc6\xbf\xc4\x07\xdf\x7e\xc8\xdf\
+\xfe\xcd\x5f\xb1\xb7\x1f\xf2\x77\xbf\xe1\xb0\x6a\xbc\x22\xe9\xb6\
+\x83\x05\xc1\x54\xe8\x41\x1d\x37\x8f\x28\x4b\x15\x25\xf5\xc8\x35\
+\xf7\x42\x00\x0b\x38\xd1\xa2\xa5\xc2\x30\x1b\xa1\x07\x36\x0d\xe7\
+\x43\x8a\x3f\xb7\x03\x44\xc4\xa3\x88\xc3\x0a\xc4\x5a\x75\x14\xf2\
+\xe9\x29\x41\x7f\x91\x40\x69\xa2\x37\xcb\xe0\x4e\x4b\x89\xb8\xa0\
+\xfd\xbc\x13\x16\x9b\x37\x78\x5b\x39\xa0\x7b\xf0\x88\x6b\x0f\x6e\
+\xe1\x5c\x5b\x64\x1c\x8a\x55\xc0\x5e\x34\x9b\x7a\x51\x08\xc8\x4d\
+\x9b\x28\x0a\x30\x4d\x8b\x24\x50\x49\xec\x0c\x93\xa0\xa0\xcf\x54\
+\x02\xdb\xa4\x1d\x58\xf4\x19\xd1\xd2\x1c\x46\x41\x97\x66\x31\xf8\
+\x59\x76\xf7\xec\x69\x97\x32\xa3\xc9\xac\xeb\x4d\xb1\xcf\x65\xe8\
+\x71\x00\x49\xd6\x65\xb4\xbf\x3b\x87\x89\xab\xd9\xb8\x2a\xc5\xac\
+\x4e\x8b\xb8\x99\x4f\x2f\xd3\x68\x35\xad\xc2\x64\xbb\x12\xc0\x31\
+\x16\xe1\x79\xdd\xb0\x99\x12\x87\x0a\x56\xa8\x30\x31\x85\x54\x4f\
+\xc3\xfa\x7b\x2b\xed\xf2\xc4\xc8\x4c\x45\x32\x1e\x73\xf2\x4e\x20\
+\xed\x98\x44\x1d\xbd\xe8\xda\x95\x8d\x13\xf1\x7d\xc7\x56\x46\xcd\
+\x74\x51\x69\x52\x37\x67\x99\xb4\x3d\xbc\xc9\xee\xc1\x26\x7a\xeb\
+\xcb\x73\x50\xa1\xcc\xb6\x96\x2f\xde\xbd\xb7\xdf\xbc\x45\xe8\x4c\
+\x2e\xfc\x5e\x35\xf5\xbf\xc1\x9a\x5e\xe2\xc4\x3f\x65\xb4\xd7\x67\
+\x74\x16\xb2\xb5\x1f\xf0\x68\x7b\x97\xec\xf6\x6d\x1e\x6d\x6d\x13\
+\xee\xff\x2d\xea\x96\xc6\xde\xfd\x3f\x67\xe1\x83\xbf\xe3\x73\x37\
+\x1e\xf3\x33\xff\xf2\x13\xfc\xea\x6f\xfd\x77\xfc\x4f\xff\xe6\x7f\
+\xe7\x67\x7f\xea\xd3\x18\xd6\x1a\x77\x1f\xe9\xdc\x7d\xa4\xe3\x6f\
+\x9f\x48\xa1\xba\xa7\x98\x73\x81\xd8\xce\x67\xae\x8f\xe7\xe1\x03\
+\x40\x4b\x6d\x5e\xa0\xdc\x4a\x96\x02\xb7\x33\x9b\x6a\xfe\x30\xf1\
+\xcd\xf4\x94\xb3\xb6\x2b\x70\xf1\x13\x6e\xca\x66\x4b\x4c\x44\xe7\
+\x6b\xd4\x4f\x9b\xec\xe5\x6d\xc2\xa2\x59\x55\xf2\xc6\x4a\x34\x41\
+\x21\xc0\xc9\x1a\x58\xa6\x58\x38\x5f\x72\xc9\x7a\xa0\x4a\xfe\xb7\
+\xec\xf6\x0d\xe8\xa3\xb4\x9b\x45\x21\xd7\xc7\x60\x71\xd6\xd5\x2b\
+\x68\xb9\xf3\x1d\xbd\xf3\x10\x23\x48\xc5\xd8\xbe\x36\xec\xd3\x5c\
+\xdf\x98\xe3\x89\xab\x85\x5d\x75\xc6\xae\x4a\xd1\x8d\x5c\x85\x8e\
+\x2a\x6c\x00\xc6\xea\x14\xed\x17\xff\xeb\x2f\xff\x8a\x0e\xa8\x89\
+\x82\x9e\x24\xd4\x0c\x71\x22\xd5\x12\x05\x3d\x0a\xd1\x93\x04\xc5\
+\xd5\xd1\x0c\xd0\x93\x18\x8d\x84\x29\x86\xa4\xe5\x94\x22\x1b\xab\
+\x18\xe4\x24\x92\xaa\x8b\xb1\xa8\x25\xb3\xcf\x51\x99\x71\xc5\x96\
+\xa1\x93\x62\x54\x8c\xe0\x22\x62\x55\xc1\x30\x74\x30\x4d\x6c\x1d\
+\x14\xea\xd4\x4d\x9d\x20\xb3\xc8\xb5\x3a\x5e\x36\xe2\x71\xfe\xef\
+\xb8\xba\x92\xe0\x0d\x3b\x1c\xbe\xb1\x8d\x72\xa9\x18\x25\xf2\x32\
+\x3a\x4d\x95\xc3\x3c\xc4\x98\xea\x2c\xaf\xf6\x30\xa6\xfa\x1c\x66\
+\xfe\xcc\x8d\xcf\xd3\x5d\x79\x89\xae\xbd\x44\xbd\x6e\x50\x37\x14\
+\xb2\x85\x36\x76\xb6\xc6\x7e\xf2\x01\x77\xb6\x15\x26\x83\x6d\xa6\
+\x6a\x9d\xfe\x60\x80\x91\x65\xec\xbd\x99\xf3\xc6\x5f\xff\x21\x6a\
+\xf8\x3a\x6b\xa9\x4f\x67\xc1\xe3\xb3\x3f\xb4\xc6\x17\xfe\xe9\x97\
+\x59\x79\xee\x29\x06\x93\x6d\x1e\xef\xe8\x4c\xa3\x13\xe2\x72\xb7\
+\x71\x26\x7e\x66\x3a\x56\x09\xf5\x31\x2d\xb5\xc9\xd8\x8f\xa9\xd5\
+\x04\x3e\x48\xfd\x84\x7a\x2d\xc6\xf7\x35\xac\x9a\x2f\x77\xb4\x69\
+\x0c\xd1\xf5\x36\x75\x37\xa1\x6b\x59\x84\xb9\x8e\x55\xc9\x44\xd9\
+\x24\x91\x1f\x43\x2f\xa1\x55\xac\x9f\x5d\x4d\x14\x8c\xc6\x21\x8e\
+\xd9\x64\xd8\xee\xa3\x9b\x8b\xf8\x9e\x4a\xcf\x88\x51\xce\x7c\x2c\
+\x25\xe1\x99\x4f\xac\xb0\x70\xe3\x32\x2d\xd7\x66\xd5\x5d\xa6\x96\
+\xe5\xc4\x9a\x82\x12\x65\xc5\x32\x4a\xa8\xe5\x35\xd4\x58\xa1\x5e\
+\xc1\xec\xbe\x3a\xa6\x96\x8b\x00\xcc\x8c\x29\x09\x31\x6a\xdc\x25\
+\x1f\x3c\xa6\xd6\x71\x38\xeb\xeb\x9c\xa9\x27\xb4\x8c\x04\xd7\x76\
+\x19\x4d\x5b\x44\xe9\x09\x79\x6a\x52\xaf\x6b\x04\xe9\x04\x63\x9c\
+\x41\x79\x5f\x15\xef\x8d\xa1\xe6\xa4\xa9\x81\x5f\x5f\xe0\xcd\x6f\
+\x7e\x93\xe1\xe8\x84\x49\xbd\xc6\xc2\xd9\x19\x43\xd3\xc2\xd5\x14\
+\xf2\xec\x21\x6b\xaa\xcb\xc6\x33\x9b\xb4\xad\x0e\x51\xae\x12\xe5\
+\x85\x47\x45\x9c\xc9\x8c\xfc\x6b\xff\xe7\x1f\xa1\x0b\x6b\x53\x87\
+\x04\x5f\x98\xc1\x61\x61\x11\xcc\x74\x0b\xa6\x45\x1c\xce\xb2\x68\
+\x35\xb3\x96\xc1\x1a\x57\x38\xd7\x27\x57\xe6\xd6\xdc\x72\x9b\xb0\
+\x92\xad\x6b\xa1\x32\x6f\x08\x57\xb9\x1d\x4c\x32\xd6\xcc\x33\x0e\
+\x22\x91\x05\x1a\x87\x75\x0e\x82\xeb\x5c\xbd\xa2\xf3\xe7\xcf\x7d\
+\x89\x65\x7e\x67\xae\x80\x7b\x76\xbd\xc1\x23\x3f\x99\x7b\xee\xda\
+\xba\xce\x4f\x7e\xfc\x0b\x2c\x2d\xff\x27\x5c\xaa\x5f\x2d\x76\x74\
+\x44\xf2\x0a\xd0\x6f\x4c\x66\x45\xdd\x51\x4a\xef\xf6\xdb\x2c\x6f\
+\x74\x08\xba\x4b\x40\x1f\xbb\xb6\xce\x07\xbf\xb7\xc7\xdf\xd5\xff\
+\x3f\xae\x6f\xbe\x0e\xc0\x47\x3e\xb3\xc6\x27\xd7\x6e\xb1\xf1\x8f\
+\x3f\xc3\x6b\xee\x21\xb7\x4f\x74\xde\x7a\x73\x0b\xc3\x9f\xce\xb1\
+\x0f\x25\xe6\x05\x9b\xb1\x1f\x93\xd8\x21\x2d\xa7\x49\x4a\x8b\xa6\
+\x33\x94\x99\x57\x64\xab\x56\xf1\xae\x74\x8a\x63\xff\x43\xdf\xcf\
+\x72\xa2\xba\xf4\xb5\x98\x36\x2f\x09\xaa\xad\x07\x70\x0f\x75\x22\
+\x0c\x59\x0e\xfd\x14\x9a\xb0\xdc\x8c\x59\x6e\x5f\xe6\xc6\x66\xca\
+\x38\x99\x5c\xd0\xc7\x34\xe2\x0c\xb4\xf3\x97\xed\x1c\x37\x6b\xe0\
+\xa9\xb9\x94\xbd\x8a\x0c\xdd\x07\x57\x11\x8d\x92\xc6\x18\xb5\x1f\
+\x33\xb6\x6c\x8c\x54\xa3\x49\x0f\x34\x87\x51\x01\x21\x12\x54\x90\
+\xf3\x95\x36\x78\xa1\xc8\xca\xde\x94\xc6\xba\x45\x6f\x5f\x70\xd8\
+\x49\xfb\x13\xac\xd6\x1e\xb0\xdd\xee\x4a\x38\xa1\xa8\xd7\x39\xcc\
+\x61\xc2\x31\x70\x4d\xb2\x1a\x1d\x35\x95\x7c\x71\x3f\x2b\xd6\x1d\
+\xa4\x1d\x13\xc2\x14\xbd\xf0\xee\x4d\xa2\x10\xaf\xd2\xc9\xd1\x41\
+\x42\x0c\x2b\x8c\x88\x2d\xeb\x42\x73\xc4\xac\x48\xfa\xce\x5f\x00\
+\x8d\x8a\xb2\x38\x0b\x15\x72\x2b\x90\x01\x3f\xb3\x69\x61\x7e\x2b\
+\x53\xc9\x48\x98\x11\x07\x91\xc9\x42\x9e\x31\x6d\x5d\x63\xaf\xbf\
+\xca\x20\xfb\x0a\xbb\xf7\xbf\xc4\xf2\xc2\xd7\xe7\x0a\xb8\xf2\x76\
+\x6d\x5d\xa7\x15\xfc\xfc\x5c\x97\xaf\x96\x3f\xc5\x7a\x7d\x79\x26\
+\x12\x2a\x30\x77\x33\xea\x73\x82\xc9\x60\xef\x69\xe0\x51\x65\x6a\
+\xb8\x4f\x3c\x8a\x88\x2e\xf5\x78\x6a\xba\xce\x71\xba\xc8\x71\x00\
+\x3b\x77\xf7\x50\x6a\x8b\xfc\x7e\xff\x80\x1f\x68\x6f\xd3\xe8\xde\
+\xa2\xd7\x9a\x70\x39\x5c\x27\x5e\x8d\x78\xf7\xf0\x08\x86\xa2\x62\
+\x6e\x34\x0d\x81\xd7\xba\xcb\x6c\x5c\xb6\x8a\x89\x66\x97\x2c\x39\
+\xa6\xa5\xb5\x80\xd6\x6c\xbe\xc7\x2d\x27\x34\x2c\x7a\x59\x9f\x5e\
+\x56\xdc\x1f\x86\xe0\x96\xcf\x9b\x52\xbd\x56\x8a\xee\x71\x2c\x76\
+\x26\x43\xae\xec\xc0\x6e\x6e\x90\x4f\x4f\x39\xf4\x73\x8e\x07\x42\
+\x73\xac\x3a\x1a\xbd\x6c\x84\xa2\x5e\xe7\xd9\x4f\x6a\xb8\x8b\x9f\
+\x20\x88\x54\xc2\x48\xc1\xcd\x14\xbc\x22\x38\x7d\x03\xdc\xac\x0c\
+\xdc\x2e\xd0\x17\x81\x1b\x08\xad\x76\x29\xa4\x8f\x0a\xd5\x9b\xa2\
+\xb9\x15\xe8\x98\x57\xc4\x43\x8a\xa4\xe6\x02\xb7\x81\x4e\x4e\x80\
+\x8d\x4d\x3a\x5f\xd4\xb9\x35\xe1\x0c\xd4\x12\x05\x7b\x4b\xbf\xc7\
+\xe1\x14\x36\x07\x3d\xb6\xdb\x5d\x09\x2d\x56\x95\x84\x3a\xcb\x73\
+\xf8\xba\xaa\x88\x93\x3c\xb1\xc4\xc3\x61\xb9\xdb\xcd\x22\x26\xc0\
+\x28\xd4\xfe\xfd\x0a\xbd\x16\x5a\x79\x91\x27\xac\x8b\x58\xf7\x5c\
+\xe6\x45\x1a\x70\xcf\xa8\x38\xd5\xca\x49\x8b\x6c\x3f\x1b\x37\x14\
+\x5b\x4a\xcb\x5d\xce\x16\x30\x54\x72\x3a\x39\x1c\x44\x26\x6d\xa3\
+\x41\x3f\xde\x23\xed\x9f\xd1\x79\x76\x8b\x6f\xfe\xfb\x5b\xc0\x7d\
+\xd8\xb9\xf5\xa1\x3f\xff\x6a\x7d\x13\x96\xf7\x99\x2a\x2f\x73\xb0\
+\x7d\x9d\xcb\x9b\x2f\x17\xeb\xc8\x84\x6b\x8c\x19\xaa\x58\x56\x46\
+\x88\x45\x3b\xe8\xd3\xd2\xef\xd1\x2b\xc4\xef\xdd\xd6\xec\x77\x0b\
+\x8e\x2c\x76\xd4\x90\x5e\x76\x57\x9c\x14\x2b\x21\xad\x74\x91\xe5\
+\xe9\x1e\xaf\xeb\x21\xda\xc0\xe0\x8a\xb9\xcf\x6e\xb4\x3e\x87\x83\
+\xc7\xea\x94\x06\x06\x5a\x73\x80\x9b\xb7\x00\x4b\x4e\x63\x64\xfe\
+\x06\xe4\x23\x32\xa5\x89\x8a\x06\x6e\x5f\x06\xf0\xe9\xc8\x60\xb1\
+\x09\xbd\x61\x48\xcf\x35\xc1\x0d\x81\x0e\xbd\x61\xbf\xb8\x2f\xfc\
+\x28\x4a\xac\xbc\x73\x10\x62\x34\x4d\x0e\xfd\x81\xb4\xae\x3a\x1d\
+\x19\xa8\xce\xa8\xe0\x89\xfa\xe0\xc1\x83\xef\x7f\x8b\xef\xbf\x96\
+\xb3\xfe\xdc\x2a\xa1\x16\xe1\x45\x0a\x0e\x2e\x69\x60\x11\xdb\x01\
+\x35\xb3\x26\x0b\xd2\x5e\x69\x09\x30\x84\x86\x65\x62\x4e\x8b\xeb\
+\xa4\x9a\x42\xa4\xc9\x29\x0e\x80\x78\x1c\xa2\x07\x11\x8d\xc5\x18\
+\xa8\x31\xa2\x4b\x93\x1e\x8a\xe6\x62\x07\x82\x6e\x0b\x52\xe4\x5e\
+\xbb\x32\x0b\xe3\xd6\x04\xbb\x30\xec\x33\x5c\xd0\x61\x4f\x04\x6d\
+\x99\x89\x6b\x8f\x4f\x99\x5e\x5a\x64\xd8\xaa\xcb\x4c\x0c\x42\x04\
+\xe4\x5d\x18\x58\x05\x3d\x2e\x38\x62\x2a\x05\x9d\x4b\xe1\xda\x13\
+\x2a\xd2\x97\xb8\xea\x00\x64\x86\x11\x69\x31\xce\x54\xce\xdc\x95\
+\xa3\x97\xd5\xcc\x6b\x5e\x10\xd2\x17\x99\xbb\x42\xbd\x95\x59\x58\
+\x2c\x83\x34\x2f\x64\xe2\x49\x98\xd1\xa1\xc5\x59\x32\xa0\x71\x78\
+\x51\xee\x57\x7a\x50\x7c\xec\xc5\x7b\xb3\xe6\xc6\xf2\x3e\xba\xfa\
+\x1c\x64\x70\xf5\x0a\xe8\xfb\xc7\xec\x2c\x42\x27\x6b\x62\x60\x13\
+\x11\x11\x45\x30\x3a\x13\xfb\x9a\xcb\xc2\x62\xb9\x0d\xc7\x03\x53\
+\x8e\xfe\xe0\x85\xf4\xdc\x70\x2e\xa8\x03\xee\x32\x5c\x09\x79\xf6\
+\xbe\xc1\x6e\xbe\x8b\xb8\x0e\xec\x72\xa4\x39\x28\x99\x37\x33\x27\
+\x18\x29\x33\xff\x5b\x99\x41\x2d\x7a\x4e\xa9\x81\x1d\x81\x27\x5a\
+\xc9\xbd\x61\x48\x8f\x10\xd5\x0d\x39\x1d\x35\x51\xdd\x10\xbc\x7e\
+\x91\xa9\xfb\x32\x53\x0b\xa8\xd1\xa7\x97\xcd\x8a\xbe\xe3\x81\x08\
+\xd4\x4c\x69\x16\xe3\xff\x5a\x45\x38\xdf\xa1\xdb\x8a\xd8\x39\x08\
+\xf9\xf3\xbf\xf9\x36\x3f\x6a\x5e\xe5\xfa\x3f\x5a\x27\x39\x55\x21\
+\x4c\x50\xcc\x84\x1a\x35\x99\x60\xb2\x50\x41\x35\x2d\xb2\x28\xa4\
+\x99\x29\xa4\xc0\x59\x18\xd0\xb0\x4c\xb4\xb3\x29\x69\x23\x23\xee\
+\x87\x0c\x06\x43\x74\xdb\x22\x09\x42\x74\x3b\x11\x41\xab\x19\x40\
+\x4f\x76\xf8\x02\x3b\xc7\xf6\xa6\x42\x5e\x6f\xe7\xd8\x81\x22\x8a\
+\x3f\xb7\x2e\xf6\xdc\xad\x2b\x0c\x4e\x12\x5a\x67\x09\x3b\xa7\x1e\
+\x87\x8b\xae\xcc\xc4\xab\x97\x16\x39\x9c\x66\x7c\x62\x28\x32\x71\
+\xd9\xae\xee\x67\x1a\x64\x33\x83\x96\x8e\x9a\x8a\x41\x51\xbd\x17\
+\x93\x48\x6d\xc4\x19\x16\x0b\xf8\x76\x42\xde\x13\x15\xb4\x62\xb7\
+\x30\x80\x04\xd0\x7b\x3a\xd8\x7d\x30\xad\x8a\x34\x33\x42\x43\x41\
+\xa1\x47\x8e\x2d\x7c\x2b\xe4\x88\x87\x78\x2d\xaa\x9c\x24\x5a\xa8\
+\x88\x0d\x9e\xf9\x03\x31\xbb\x67\xad\x41\xa8\x14\x1c\x74\x3e\x6f\
+\xce\x9d\x2e\xa0\xe1\x61\x53\xc3\xd4\x23\xf4\xd6\x97\xf9\xa8\xf1\
+\x87\xbc\xfb\x5e\x4c\x76\x6b\x85\x5b\x9f\xbb\x83\xe5\xd7\x65\x20\
+\x03\x12\x4a\x04\xf9\x1f\xf0\xb5\xdb\xaf\x70\x6d\x5d\xe7\x36\xd0\
+\x7a\xf8\xf3\x5c\xbd\xa2\x73\xeb\xca\x75\xe2\xa8\x83\x12\x29\x1c\
+\x1f\x1c\xb2\x35\xd9\xa6\x3f\xd1\x67\x01\x51\x09\x96\x7e\x43\x81\
+\x0c\xd4\xd1\x80\x56\xbb\x45\x3f\x53\xe8\xa8\x39\xc1\x3d\x8b\xbf\
+\x56\x4c\x5c\x67\xa6\x9e\xf3\xfd\x90\x3c\xc9\x19\xfb\x31\x8d\xac\
+\x86\xd6\x14\x13\x25\xc3\x74\x48\xcb\x6b\x51\xb2\x6c\xc2\x33\xad\
+\xf4\x93\x80\x5e\x16\x16\x41\xda\x11\x01\xab\xcc\x9a\x1c\xaa\x37\
+\x2a\x68\xb6\xd2\x87\xa2\x2f\x7f\xb7\xed\x91\xd0\x1a\x7b\x8a\x09\
+\x0a\xb8\x8e\x46\x5c\x06\xa4\x53\x99\x84\x2e\x9d\x84\x0e\x42\xee\
+\xbe\xf2\x75\x5e\xfc\xe4\x2f\xf2\xec\xb3\x26\x7b\x87\x42\x28\x5f\
+\x62\x5d\x5f\x1d\x93\x9b\xf6\x1c\xb4\xd3\x81\xba\x69\x15\xd0\xc3\
+\x42\x07\x14\x26\xb4\x25\xdd\x53\xa3\xd3\xe9\x08\x3e\xd9\x9b\xca\
+\x00\x1e\xa1\x08\x28\x61\xe7\x42\xce\x99\x4e\x44\x16\x4e\x27\x82\
+\xb9\xb0\x61\x95\x7a\x11\x55\xf3\x98\x18\xa0\xf6\xf8\x14\xda\x5d\
+\x69\xb2\xdd\x51\x53\x19\xc8\xe5\xfd\xea\x94\x88\xf6\x5f\xfc\xf4\
+\x8f\xfc\x4a\x42\x88\x81\x4d\x42\x48\x42\x08\xf1\x04\x8b\x05\x01\
+\x29\x8c\x0c\x35\xd0\x89\xe3\x3e\x06\x36\xaa\x91\xe1\x27\x09\xd3\
+\x24\xa1\x96\x24\x78\x7a\x4c\x8e\x41\x14\x25\x4c\xf4\x98\x29\x31\
+\x71\x94\x00\x06\x89\xfc\x35\x21\x4b\x14\xb2\x44\x41\xb1\x72\x32\
+\x0c\xe2\xe4\x4d\x3e\xd8\xff\x36\x0b\xcd\x65\x74\xe3\x92\x1c\x63\
+\xb2\x30\x88\x8d\x9c\x3a\x53\xb4\x54\xc1\xa6\x46\x6a\x66\x4c\x26\
+\x3e\x63\xe5\x1b\xdc\x7b\xfb\x98\x93\x93\x4c\xec\x55\xde\xb9\x44\
+\xf3\xd6\x21\x9f\xfb\xd8\x98\xab\xfa\xbf\xe0\xa5\xa7\x7f\x90\xcd\
+\xa7\x9f\x26\x0d\x56\x89\xf9\x80\x7b\x47\x5b\x0c\xbc\x8c\xc3\x3c\
+\x64\x2f\x7b\x83\x3b\xfd\xef\xb0\xa8\x83\x37\x9e\xd2\x4e\x1b\x0c\
+\xec\x2d\xfa\xdf\x07\x6d\x1a\x31\x6d\xa7\xc4\x6c\x31\xad\x5f\x47\
+\x09\x85\x88\x3d\x19\x9b\xb4\xea\x09\x66\x6c\xc2\x14\xa6\xd1\x90\
+\x49\x34\x21\x74\x2d\xd2\x30\x91\x8f\x83\xc8\x44\x53\x75\xb2\x2c\
+\x21\x9e\x66\xc4\x4a\x4a\xbd\x36\x2b\x77\x4d\xd5\x24\xac\x25\x58\
+\x8a\x81\xd1\x34\x71\x4c\xa8\x4f\x15\xc2\x5a\x42\x57\xb5\x08\x73\
+\xb7\xc8\xb8\x1d\x16\xcc\x29\xe1\x28\x41\x71\x6d\xb2\xb8\x86\x52\
+\x1b\x02\x1d\xfc\xe9\x84\xfa\x24\xa1\x6f\x4c\x48\xc6\x85\xb6\x42\
+\xb1\xa9\xa1\x11\xda\x01\xc9\x38\x27\xd7\x03\x42\xc5\xc0\x3a\x57\
+\x2a\x8b\xe9\x14\x97\xb7\xb6\x1f\x92\x3c\x7a\xc4\xf2\xd3\x4b\x58\
+\x96\x42\x10\x66\xc4\x7e\xc8\xd4\xc8\x69\xc4\x19\x5a\xc3\xc0\x0c\
+\xc7\xd4\x95\x3a\x53\x45\x4c\x87\x5b\x53\xc1\x17\x5b\x53\x15\xcd\
+\xca\x31\xb3\x4b\x58\x16\x58\x96\x85\x65\x59\x34\xc9\x31\x62\x85\
+\xc0\xce\x71\xe2\x99\xd6\xc2\x88\x15\x62\x03\x8c\x71\x46\x6c\x40\
+\x9c\xa7\xd8\x81\x78\x0e\x6c\x54\x4b\x25\x1f\x2b\xdc\x79\xff\xfb\
+\x78\x8f\xdf\x66\x52\xaf\xb1\x39\xe8\x31\x34\x2d\x86\xa6\xc5\x8a\
+\xbe\xc5\xd2\xd4\x61\xe3\x99\x4d\x14\x12\xf2\x22\x60\xa3\x5c\xa5\
+\xa3\xa6\x44\xb9\x4a\x96\x25\xfc\xd6\x57\xfe\x10\xd5\x62\x01\xd7\
+\x6e\x11\xd9\x09\xae\xdd\x62\x59\xe9\xe0\xda\x2d\x74\x3b\x41\xb7\
+\x13\xc1\x5c\x74\x0d\xc2\x5c\x7c\x0e\xa6\x45\x6e\xe6\x58\x1d\x13\
+\xc5\xcc\x31\x8a\x49\x00\xdd\xb4\x30\xb0\x31\xb0\xd1\xcd\x99\xfa\
+\x21\x89\x42\x4c\xc0\x8c\x42\xcc\x28\x44\x09\xed\x19\x9e\x4e\x5f\
+\xe3\xde\xce\xc3\x62\x0a\x44\x29\x67\x92\x69\x84\x2a\x2a\x4d\x6c\
+\x12\xd2\xa2\x7d\xed\x98\x1d\xf6\x5f\xbf\xc9\xfe\xc1\x4c\x20\x74\
+\xeb\x73\x77\x24\x0b\xf1\xc2\xa7\x9e\xe1\xd6\xe6\x3f\xe1\x52\xfd\
+\x2a\x97\xd5\x29\x07\xdb\xd7\xe7\xba\x75\x96\x5f\xc7\xf2\xeb\x7c\
+\xed\xad\x57\xf8\xc3\xdb\xff\x96\xbb\xe9\x9f\xb2\xb5\x93\x30\x3e\
+\xf5\x78\x3c\x78\xcc\xe9\xe1\xeb\xb4\x94\x17\x58\xab\x59\x2c\xb7\
+\x3b\xe4\x0b\x1b\x73\xe3\x45\xa5\x26\x42\xd5\x97\xe9\x8c\x73\x94\
+\xa6\x42\x4b\x6b\x15\x45\x1a\x9c\xa4\x21\x03\x25\x27\x76\x75\x9a\
+\xce\x6c\xec\xa0\x7c\xfd\x82\x92\xae\x69\xce\x15\x6c\x42\x1f\xd1\
+\xa7\x37\x0c\xe5\x7d\x31\xf2\xd4\x14\xe3\xfa\x45\xd6\xed\x8c\x73\
+\xc9\x4b\xcf\xae\x3e\xae\x3c\xb6\xfd\xf3\x56\x58\x45\x07\xb1\x3b\
+\xa5\xdb\xbc\xc1\xab\x8f\x8e\xf8\xcb\x5f\xfd\x0e\x4d\x7f\x97\x56\
+\xc3\x43\x35\x81\x48\xc3\x37\x1c\xa2\xc1\x94\xb1\xa1\x12\xa8\xa7\
+\xb8\x99\x82\xe6\x09\x51\x8f\xe6\x8d\x69\x92\x17\x8f\xfb\x52\xe9\
+\x56\xc2\x06\x79\xe5\xb4\x73\x9a\xe4\x0c\x0b\xab\x5a\x5b\xab\xcb\
+\x6c\x6c\x07\x8a\xe4\x8b\xed\x20\x84\x20\x61\x90\xcc\xff\x9e\xdb\
+\xed\x2e\x4a\x20\xda\xcf\x47\x89\x18\x78\x9d\x70\x4c\xab\xf4\x7e\
+\xf6\xa6\xe8\xba\x45\x3f\xd3\xe6\x70\xb1\xaa\xdb\x09\x3e\x60\x06\
+\xe2\x1f\xde\xb3\xc4\x6e\x0d\x1f\xc4\x0a\x00\x53\x00\x7a\xbb\x31\
+\x73\xc1\xb4\x2d\x21\xa0\x4f\x2c\x6b\x0e\xc5\x1a\x56\x8e\x61\xe5\
+\x98\xc5\xe5\xc8\xb4\x4c\x9c\x4e\x47\xf8\xfe\x9a\x16\xe0\xa2\x12\
+\x12\x84\x21\x77\xf3\xff\x55\xd0\x43\xca\x5d\xe2\xfc\xa0\x70\xf0\
+\x11\x05\x9e\x6e\xe6\x4c\xa3\x79\x83\xef\x99\xf1\x21\x64\xb7\x56\
+\xf8\xd8\x8b\xf7\x64\x60\x86\xce\x84\xdb\xdf\x79\x9f\xa4\x7f\x80\
+\xe7\x05\x6c\xed\x07\x24\xc3\xdf\xbb\x80\xa1\xab\x0d\x90\xaf\xbd\
+\xf5\x0a\xca\xde\x1b\x38\xcf\x37\xb8\xfe\xf2\x35\x3e\x7e\xeb\x9f\
+\x61\xac\xcc\x3b\xb2\x8b\x4b\x79\x87\x7e\x43\xa1\xad\x37\x51\xf5\
+\x65\x31\xc8\xa9\x98\x74\xd4\x1c\x4f\x99\x0d\x78\xb6\x73\x45\x52\
+\x6b\x23\xdf\x96\xcd\x8b\x52\x99\x86\x27\xa0\x83\xf4\x10\x2e\x9c\
+\xe0\x05\xb6\xed\xc8\x21\xd0\x4c\x69\xa2\xe6\x23\x7a\x03\x71\xe2\
+\xa8\xf9\x88\x38\x11\x3f\xb3\x2a\xcb\x1c\x33\x65\xcc\x14\x35\x1f\
+\x49\x51\x7e\xf5\xb9\x6a\x20\x1b\xad\xde\x9c\x1b\xfd\x9f\xbf\xfb\
+\x36\xbf\xf3\x17\xc7\x4c\xb3\x45\xda\xed\x36\x0d\x2d\x46\x89\x26\
+\xe4\x66\x9d\x1c\x1b\x3b\x5b\xc4\x57\xc7\x28\x9a\x2b\x8f\x23\x14\
+\x52\xb7\x41\x93\x99\xfa\x6d\x54\x42\xc5\x73\xc3\xa7\x33\x9e\x6e\
+\x3a\xd7\xfc\x28\x1b\x22\x81\x7d\x8e\xe2\x5b\x9c\xb1\x1d\x57\xa6\
+\x16\x87\xd3\x4c\x52\x6d\x25\x3b\x51\x16\x86\x25\x4b\x51\x1e\xc7\
+\xea\x14\xd5\x9f\xfb\x25\x74\x12\x7c\x72\x33\x27\xd4\x45\x00\xf8\
+\x51\x48\x82\x2f\x46\x7e\x0a\x86\x22\x0e\x15\x6a\x85\x68\xc7\x8f\
+\x42\x92\xa2\xfb\x53\x32\x1c\x51\x18\x11\x59\xa6\x38\x16\x18\xcb\
+\x04\x22\x33\x11\x8f\xf5\x37\x61\xbf\x25\xb3\x71\x9c\x6c\x31\xee\
+\x4f\xe4\x40\x7d\x52\x14\x7d\x7e\xb9\xfe\xd4\x6e\xa0\x16\x93\xd5\
+\xed\xa5\xcb\x7c\xfe\x7a\x3e\x17\x94\x65\xa7\xee\xfb\xde\x57\x85\
+\xca\x6d\xb2\xcd\x9d\x6c\xcc\x9d\x6c\x4c\xe8\x4c\xe4\xeb\xe5\xb1\
+\xfc\xba\x37\x1b\x62\x82\xe3\xea\x15\x9d\x5b\x2f\x7d\x94\xab\x1f\
+\x79\x99\xeb\x2f\x5f\x63\xf3\x4a\x87\xfe\xd9\x90\x87\xc3\x1e\xbb\
+\x7b\x8f\xd1\x83\x3a\x63\xa6\x85\x7d\x54\x73\x6e\xa0\xb3\x1a\x58\
+\x4f\x52\xa8\xa5\xb4\x64\xa0\xe3\x09\xe6\xe1\x78\xd0\xe7\xd4\x3b\
+\xe1\x74\x64\x14\xde\x14\x21\x78\x30\x48\x46\x0c\x92\x11\x0f\xb3\
+\xfc\xc2\x15\xa0\xbc\x2a\x9c\x0f\xe6\xf3\x8f\xdd\x3c\x92\xc1\x5f\
+\x1a\x15\x1e\x0f\x90\x8b\x69\xc8\xd7\x20\x5f\xe3\x4f\xff\xe0\x2f\
+\xf9\xf6\x6f\xfc\x11\xb6\x3f\xa4\xbe\x64\xe1\xe8\xc7\x4c\x10\xb3\
+\x86\x83\xa4\x89\x93\x35\xf0\xd5\x31\x4e\xd6\x98\x1b\xfc\x2c\xb3\
+\xac\xd0\x2f\xcc\xe4\x9a\xe5\xe3\x11\x0a\x0b\x43\x45\x66\x66\x91\
+\x79\x95\x0b\x5d\xbb\xb9\x04\x55\x14\xd6\xe3\x53\x4f\x66\xe3\xa3\
+\xc1\xae\x7c\x7d\x58\x9a\x2f\x16\x27\x85\xcc\xc2\xde\x54\x2c\x63\
+\x0c\xc6\x88\x2c\x6b\x27\x24\x81\x4e\x30\x86\xa6\x69\x63\x14\x57\
+\xe2\x50\xaf\xe3\xea\x2a\x5e\x92\x15\x60\xdf\x2d\xce\x79\x11\xbc\
+\x66\xa0\x13\xd9\x09\x49\x14\xe2\x98\x56\x31\x32\x1f\xcd\xfc\xa5\
+\x8a\x63\x64\x99\x85\xdc\x33\xb8\xf0\x47\x6c\x1d\x64\x3c\xbb\x19\
+\x10\x16\xd6\x54\x94\x36\x01\x66\x0e\x4a\x80\xe7\x5b\x50\x04\xf1\
+\xe6\x95\x0e\x3f\xf2\x85\x7f\x0e\xc0\x77\x1f\xff\xb7\xf4\xf7\xaf\
+\xd2\x79\x76\x0b\x02\x38\xd8\xbe\xce\xd5\xba\x28\xa8\xfc\x37\x5f\
+\xc2\x79\xf1\xdb\x32\x70\xcb\xe0\x2d\xb3\x77\xf9\x58\xd9\x7b\x03\
+\xae\xbc\xc4\xfd\xad\xdb\x5c\xcf\xea\xa8\xd7\x5f\xe0\xea\x15\x9d\
+\x1f\xf9\xd1\x7f\xcc\x2b\xaf\xbe\xc9\xd6\xdd\x0f\xe8\x9f\x0d\x45\
+\x23\x23\x19\x61\xf8\x17\xf9\xec\xb1\x1f\xd3\x70\x0c\x19\xc0\x0d\
+\xc7\x28\xda\xcd\x23\x5a\x6a\x53\xe8\x90\x2b\x6a\x35\x06\x14\x9c\
+\x0f\xc5\xfd\x99\xe6\xe2\xc3\x4e\x88\x32\x98\xcf\x4f\x90\x9c\x1f\
+\x7d\xea\x8d\x14\x68\x0a\x49\xa8\xa1\x97\xde\x6e\xa5\x21\xcc\x10\
+\x9a\x33\xac\xfe\xd5\x6f\x7c\x93\xb3\xe3\x01\x3f\xfc\x4f\x3b\x74\
+\x9f\xf9\x0c\xab\x78\x0c\xc7\xa0\xd5\xce\xf0\x58\x40\x89\x34\xa8\
+\x95\xfc\xb1\x22\x8e\xb8\xe4\xc5\xef\x2e\x82\x37\x9f\x0d\x96\xda\
+\x19\xcd\x00\xce\x5a\xb9\x54\x8b\x88\x39\xbd\x69\x25\x0b\xe7\xd8\
+\x41\x48\xa2\xa5\xe8\x5e\xc6\x43\xcf\x94\x9d\x5b\xc7\x1e\x41\x30\
+\x62\xa5\xbd\x51\xb4\x9f\x45\xcc\x65\xf5\x15\x49\xcd\x05\xa9\x26\
+\x1c\x86\x0a\x0f\xa3\xb1\x1f\xa3\xdb\x0d\x70\xcd\x9c\xb8\x67\x10\
+\x72\x46\x57\x59\x90\xdf\x34\x02\x5c\xbd\xe8\xa3\xbb\xe5\x1b\xea\
+\x4b\x52\x7b\xd6\x53\xf7\x67\x9a\x89\x32\x78\x2d\xb3\xb0\x29\x2c\
+\xec\x0a\x8b\xe7\x13\xcb\xe2\xe1\xce\x07\x73\x63\x43\xcf\x2c\xdd\
+\x25\x08\x3f\xc9\x25\x6b\x26\xfe\x91\xbb\xed\x2c\x18\x26\x6f\xb1\
+\x3f\xed\xb1\xe7\xef\x73\xd9\x59\xe7\xda\x62\x39\x46\xff\xbf\xc0\
+\x25\x48\xb2\x77\x79\xe5\x9b\xdf\xe0\x70\xfd\x5d\x86\x76\x03\x6f\
+\xef\xe7\xd8\xbc\xd2\xe1\xf4\x4e\x97\xe8\xa5\x43\x09\x39\x9e\x14\
+\xd0\xb1\xfb\x00\x78\x89\x9b\x57\x5f\x20\xc9\xde\x25\xcb\xde\x85\
+\xe3\x75\x92\xe5\x77\x79\xf9\xc6\x35\x2e\x5f\x56\xd9\xbd\x7f\x48\
+\x7c\x24\x9a\x19\x49\xe6\x49\xdf\x88\x93\x34\x04\x05\xda\xce\xfc\
+\xf8\xd5\x30\x1b\xc9\x8e\x9d\x10\xf9\x58\x45\x70\xb7\x24\x7b\x41\
+\xa1\xc0\x2a\x4f\x80\xea\x11\x57\xa7\x9d\x2b\x4f\xcc\xec\xd5\x00\
+\xd7\x18\x72\xa6\x34\xe7\x3f\xa7\x99\xc3\x48\x41\x6b\x0e\x88\x93\
+\x52\x70\x2f\xe6\xf8\x1a\xd4\x0a\x1e\x59\xa3\xab\x46\xdc\xdf\x8a\
+\xe8\x0d\x5f\xe7\xde\x5e\xc2\x33\x5f\xac\xf1\x23\xff\x68\x93\x56\
+\x0b\x86\x63\x17\x8d\x33\x2c\xad\x4e\x62\xd7\xc4\x30\x69\xa1\xb3\
+\xa0\x36\x7f\x12\x6b\xca\x18\xdd\x6e\x08\xc1\x50\xa0\x32\x2c\x34\
+\xc8\xb4\xcb\xc0\x16\x6c\x84\x1d\x08\xf8\xd1\x0c\x20\xb0\x2d\x6c\
+\x52\x12\xb7\xc1\x75\x37\x62\x67\x20\x78\xe2\xfb\xa7\x4d\x21\x06\
+\x7a\x7c\x8a\x52\x0b\x19\x5e\xba\x4a\xdb\x74\x60\x72\x44\xe6\xae\
+\xcc\x0d\xa3\x06\xe9\x84\xc0\xb6\x05\x13\xf4\x4b\x3f\xfb\xcf\x7e\
+\xc5\x1b\x8d\x04\x2b\x01\x18\xd8\x04\xca\x94\x2c\x31\x41\xcf\x25\
+\x84\xb0\x42\x85\x28\xca\x69\x64\x6a\x05\x50\x1b\x98\x7a\x4e\x4d\
+\x37\x98\x26\x09\x59\x92\xa0\xea\x86\x50\xc1\x85\x29\x86\x21\x9a\
+\x22\x13\x1c\x8c\x24\x2e\x06\x46\xa1\x37\x18\x93\xe6\x6f\x89\x81\
+\x46\x4b\x01\xf5\x0a\x0b\x8d\x8f\xa2\x1a\x16\x49\x92\x60\xe8\x3a\
+\x09\x70\x12\xbe\xcb\x69\xff\x5b\xbc\x7b\xff\x1b\x7c\xf0\xad\xaf\
+\xd2\x7f\xb8\x4c\xf7\xd9\x36\x37\x6e\x3c\x83\xe9\x3a\x2c\x2d\x98\
+\xb8\x8d\x26\x23\xcf\xe2\x7b\xfd\xaf\x62\x4c\x75\x06\x5e\x46\x50\
+\x7b\x0b\x3b\xbc\x45\xbd\x13\xe2\x7a\x97\x88\xcc\x99\x96\xa2\xd3\
+\x54\xe9\x34\x55\x96\xcc\x1a\x9d\xa6\xca\xdd\xd1\x84\xa3\xbb\x43\
+\xf2\xbd\x3b\x74\xd3\x4d\x9e\x6e\xe7\x9c\x3a\x1e\x5b\x3b\x09\xc3\
+\xed\xbf\x62\xab\x77\x9f\xcd\xeb\xcf\xd3\x55\x1f\x60\x2d\x5d\xa1\
+\x33\x99\x72\x96\x4d\x38\x8b\x62\xda\xb9\x82\x89\x08\xb6\xd4\x4f\
+\xa4\x3e\xc2\x54\xea\x4c\xf2\x09\x93\x7c\x82\x1e\x58\x24\x76\x88\
+\x1a\x1b\xc4\x85\xb8\x25\x6c\xf8\xa4\x89\x3a\x7b\xac\x8f\x51\x63\
+\x83\x5a\xa4\x13\x34\x0b\x48\xa6\x5c\xd4\x1e\x0f\xb3\x11\xa6\x52\
+\xc7\x44\x61\x98\x8d\xa8\x29\x2d\xf9\xf3\x4d\x14\xc1\x4d\xd7\x41\
+\xab\x0f\x49\x47\x6d\xa8\x43\x98\x8b\x40\x9e\x2a\x3a\x35\x34\xd4\
+\x7c\x04\x75\x8b\x4b\x2f\xbd\xc4\xca\xd2\x06\x7b\x3d\x9b\x93\x41\
+\xcc\x3b\x6f\xbd\xcd\x69\x3f\xc2\xe8\x8f\x68\x99\x1a\x8e\x69\xa0\
+\x28\x21\xea\x74\x04\xf9\x90\x3c\xd3\xa8\xa9\x19\xe4\x53\x5a\xb6\
+\xcb\x24\x9f\x42\x3e\x45\x49\x5c\xb2\x58\x21\x4f\x3d\x0c\xc7\xc0\
+\x4d\xeb\x4c\xa2\x29\x13\x23\x46\x51\xeb\xa8\x46\x2e\x33\xb0\x13\
+\x97\x9c\x71\x82\xde\x70\xe8\x07\xf0\x17\x6f\xec\xa2\x46\x87\x4c\
+\xea\x35\xe2\x60\x4a\x9d\x53\x06\xee\x32\x18\x4d\xae\x25\x09\x4b\
+\xb7\x56\xc9\xda\x4b\xe8\xc3\x9c\xd8\x00\x3b\x48\x08\xf4\x1a\xb6\
+\xa6\x62\xa8\x39\x5f\xf9\x77\xff\x2f\xba\x17\x0c\x99\x9c\x4e\xa5\
+\x97\x6f\x54\x92\x62\x66\x4a\x68\xe5\x24\x5e\x8e\x8e\x82\x97\x64\
+\xb8\xba\x2a\xf1\x6f\x5e\x30\x13\x11\x08\x88\x50\x39\x41\xad\x0a\
+\x87\x1c\xa3\x80\xe5\x63\x58\x14\x13\xd5\x17\x95\x59\xef\x9f\xbc\
+\xca\xd3\xee\xcf\x90\x5a\x42\x5f\x11\x02\x51\xf8\xee\xdc\xb8\xfd\
+\x9d\x2c\xc6\x9f\x86\xdc\xd2\x6f\x48\xfd\x43\x84\x82\x69\x9a\x34\
+\x2e\x4d\xf9\x78\xe7\x17\xf8\x56\xfc\xab\x32\xdb\xa6\xfa\x3d\xb4\
+\xe4\x16\xa9\x2e\xbc\x8c\x3b\xcf\x6e\xc9\x51\xa6\x6a\x46\x6e\x0f\
+\x6f\x72\xe9\x6c\x83\xef\x05\xb7\xf9\x93\xd7\xfe\x84\xf5\xb5\x80\
+\xc5\xd5\x4f\xf3\x03\xed\x98\x23\xfd\x53\x90\xbc\x22\x26\x45\x10\
+\xf2\x82\xfa\xb5\x0d\x9e\xbf\x15\xb1\xf7\x70\x91\xc1\xc9\x9e\xc8\
+\xca\x5e\x42\xec\xea\x0c\xd3\xd1\xb9\xa9\x67\x6b\xee\x98\xd8\x21\
+\x7a\x60\xc9\xc0\xae\xbe\x06\x30\x74\x86\x18\x9e\x55\x29\xde\x90\
+\x5f\xd7\x52\x9b\xe8\x81\xc5\xc0\x15\x42\xfb\x96\x2a\xb2\x3a\x88\
+\x2b\xc1\xd8\x8f\x69\x34\xcb\x8c\xde\x82\x66\x8e\x36\xe8\xd3\x5a\
+\xe8\xe0\x29\xa6\xf0\xc1\xf0\x22\x70\xe1\xb3\x9f\xdc\xe0\xa7\xff\
+\xf9\x17\x59\x59\xb9\xce\xeb\x6f\xbc\xc7\xb7\xbf\xf5\x1d\xd9\xe6\
+\x3d\x8a\x1e\xb1\xb6\xb7\x44\x6d\x51\x9c\x60\xf5\xfe\x25\xbc\xf4\
+\x14\xb7\xd8\x9b\x93\xe7\x5d\x89\x8b\xe7\xa6\x43\x4a\xec\x5b\x8e\
+\x3c\x15\x18\x39\x28\x47\x9c\x02\x24\x7f\xfc\x61\x37\xa7\xd8\x99\
+\xbd\x39\xe8\xb1\x53\x0b\x69\x5c\x11\x23\x57\xb6\x3f\xc4\xb7\x3b\
+\x12\x9a\x88\x4c\x2c\x06\x52\xc7\x7e\x8c\x6e\xb1\x00\x8b\x67\x34\
+\xbb\x39\x61\x41\x97\xc5\x04\x8c\x73\x0b\x95\x00\xdd\x55\xc8\x02\
+\x1b\x57\x9f\x15\x70\x12\x87\x15\xf8\xb6\xa4\xd9\xb0\x4c\xe2\xb0\
+\x87\x81\x2d\xb3\x77\x39\x64\x12\x87\x63\xa9\xac\xb8\xba\xa6\x72\
+\x77\x6f\x5e\xe7\xfb\x68\xf4\x06\xcf\x76\x5e\x16\xd6\x53\x51\x9f\
+\xbd\x9d\x87\x90\xbd\x26\xa7\x94\xf3\x3b\x5d\x1a\xc6\x5d\x36\xb4\
+\x44\x2e\x89\x29\x27\x4a\x26\xd6\x75\xae\x5e\xb9\xc7\x5b\xb7\x67\
+\xc1\x39\x68\xdd\xa7\x3d\x84\x6c\x6f\x83\x61\x7e\x1b\x10\x94\xcd\
+\x0f\x76\x0e\x41\x05\xbd\xf5\x65\x76\xef\x1f\xb2\xbd\xd3\x67\xff\
+\xec\x84\x7c\xe1\x29\xda\x4b\x00\x77\x39\x3d\x7c\x9d\xdf\x7f\xd3\
+\xc2\x5e\xf9\x1e\x4f\xdb\x2f\xf0\x78\x61\x97\x6b\xba\xcd\x23\x66\
+\x3a\x8d\x95\xd4\x47\x51\x73\xfa\x4d\x85\x58\xd1\x31\xbc\x84\xc4\
+\x9e\x0f\xe0\x32\x68\xcf\x07\x75\xf9\x7c\x62\x87\x44\xc9\x18\x33\
+\x98\x15\x4f\xcd\xc4\x67\x54\x70\xa2\x0d\xc7\x60\x98\x8d\xe8\xaa\
+\x39\xbd\x6c\x44\xcb\x69\x42\x2e\xd8\x8f\xc4\x1e\xd1\x75\x72\xc9\
+\x86\x94\x9f\xab\x63\x49\xec\xad\x2e\xae\x42\x51\x10\xf6\x06\x70\
+\xb3\x6b\xb1\x79\x75\x83\x9b\x57\x63\x56\xf3\x57\xb9\xd4\x35\xf9\
+\xe9\xff\xfc\x26\x2f\xbd\x20\xae\x20\x4d\x7f\x97\x83\xf4\x29\x9c\
+\xf8\x21\xf5\x7e\x8d\xc3\xd4\x66\x3a\x7d\x8d\xc9\xe3\x65\x98\x7e\
+\x1f\xd7\xfa\x2c\x63\x77\x42\x23\x10\x70\x28\x77\xbd\xb9\x40\x3e\
+\x98\x9e\xd2\xd0\xea\x2c\x0c\x15\xce\x5a\xa2\xc8\x23\x50\xd0\xed\
+\x8c\x51\xa0\x8a\xc2\x2f\x50\x19\x21\xbc\x90\x75\x6f\x3c\x6f\xc2\
+\x12\x34\x71\xd8\x67\xbb\xbd\x8e\x12\xec\x73\x10\xe9\x7c\xec\x43\
+\x02\xbe\xd4\x62\x34\x1c\x03\x35\xb2\x13\x8c\xee\x0a\x8f\x13\x93\
+\x98\x00\x2f\xc9\x48\x2c\x0b\xd5\x2e\x46\xa5\xbd\x9c\x2c\x1d\x13\
+\x13\x10\xea\x75\xf2\x8a\xb7\x5a\xc9\x0b\xcf\x04\xf5\x91\xdc\x8e\
+\x94\x05\x76\x25\x33\x8f\xe7\xf5\xc4\x8f\x6f\x80\xf6\xd9\x0b\xe3\
+\xf4\x23\x80\xfe\x84\xbd\xca\x34\x73\xa9\x5e\x7b\x27\x5e\x60\x1c\
+\x3f\xc5\xd6\x64\x1b\xf2\x07\x98\xa6\x89\x1a\x99\xc4\xb9\x4b\xbb\
+\xa3\xa3\xab\xcf\xf1\xf1\xce\x2f\xcc\xd1\x68\x83\xd6\x7d\x86\xf9\
+\x6d\xc6\xf1\x53\xf4\x77\x7b\xf4\x77\x7b\xec\xbc\xf3\x29\xf4\xb3\
+\xcf\x03\xf0\xb9\x2f\x6e\xf0\xc3\x3f\xfe\x53\xac\xff\x60\x84\x7f\
+\x75\x11\x7f\xfb\x84\xbd\xa3\x65\xf6\x8e\x96\xc9\x17\x36\x04\xe3\
+\x11\xdc\x26\xb9\x67\xf2\x60\x4b\xb8\xa5\x2c\x1d\x5a\x64\x7b\x1b\
+\xe8\xb7\x4a\xc5\xd9\xec\xb2\x9f\x6b\xae\xcc\xb4\xd5\xa0\x8d\x92\
+\xf1\xdc\xb1\xfa\xba\xa9\x37\xe4\x6b\x7a\x60\xd1\x6b\x6a\x73\x05\
+\x63\xae\xb9\xa4\xb4\xe4\xd7\x48\x35\x9c\xda\x94\x54\x5e\x62\x87\
+\x0c\x33\x51\x44\x36\x1c\x43\xaa\xe3\x4a\xe7\x21\xd7\x89\xf8\xe2\
+\xf3\x5d\xbe\xf0\xc3\x57\xf9\xf1\x1f\xba\xc9\x0f\x3d\xb3\x49\xef\
+\x24\x25\x7a\xf0\x1e\x83\xb7\xbf\x49\xd3\xdf\xa5\xe9\xef\x32\x8a\
+\x0e\x58\x2b\x46\x6f\xce\x3a\x26\xdd\xd6\x7d\xa8\x3d\x4d\xfd\xd2\
+\x31\xd4\x9e\xc6\x4b\x4f\x31\xf4\x87\x28\x69\x4f\x7c\x28\x3d\xf2\
+\xc1\x48\x4e\x4a\x37\x02\x31\x84\x7a\xd6\xca\x65\x26\x16\x0e\x9c\
+\x42\x40\x34\x42\x11\xd6\x59\xc5\xf4\x48\xe2\x36\x68\xe9\x22\x31\
+\x6c\x0e\x7a\x17\x02\xb5\x35\x9c\x08\x4c\x5c\x72\xce\x55\x9d\x72\
+\x51\xe8\x8d\xfd\x18\xbd\x0c\x4a\xc1\x40\x98\xa2\x90\xab\x24\x5c\
+\x8f\x1c\xdd\x55\x30\x42\x9b\x88\x8c\x28\x31\x71\x4d\x55\x36\x32\
+\xf4\x62\x01\x4d\x49\xaf\x59\xc5\x64\x48\x23\x0c\x67\xc5\xdd\xb9\
+\x25\x36\xc9\xfa\x32\xec\xcc\x67\xe2\xa9\x72\x17\x3d\xfc\x24\x5e\
+\x6f\xc4\x54\xb9\x3b\x17\xdc\x7b\xfd\x55\x3e\x6a\x9c\xb1\x7f\x10\
+\xa2\xec\x05\xa0\x7c\x89\x96\xe9\xd2\x32\x61\xdc\x6d\xc0\x3e\x1c\
+\x65\xef\x4a\x1a\xad\x9c\xf8\x00\xe8\x6c\x74\x19\x3f\x2c\xde\x14\
+\xe5\x05\xb2\xf0\x84\x37\xf7\x0f\x60\x1f\x94\x6b\x97\xd9\xfc\x0c\
+\x5c\xbb\xfc\xaf\xf8\x51\xe0\xfe\xf5\x4b\xec\xde\x3f\x64\xe7\xcd\
+\xb7\xe1\x6c\xc4\x78\xa1\xd8\xd9\x61\xde\xc5\x0d\x61\xb8\x2b\xe4\
+\x31\xe3\xb8\x41\x63\xb7\x07\x95\x3d\x76\x73\x7f\x9f\x1d\xd2\x55\
+\xf3\x22\x63\x86\x5c\x1a\xe5\xf4\xec\x10\x33\x68\xcc\x65\xda\xc4\
+\x0e\xe9\x8e\x52\x1e\xa3\xc8\x60\x3e\xff\x7d\x16\xf2\x9c\x5e\xa6\
+\xa0\x33\x9f\xd1\x35\x47\x48\x3c\x7b\x99\x42\xae\xb9\xf2\x44\xea\
+\x6a\x85\xfb\x66\x1e\xd1\x6a\xb7\x58\x6e\x77\xf8\xec\x8b\x2b\x34\
+\xba\xb7\x78\xea\x6a\xca\x92\x95\xb2\x6a\x6d\x30\x71\x84\x19\xcc\
+\x28\x3a\xa0\x69\x8a\xbf\xa3\x3c\xd6\xfd\x35\x70\x1e\x52\xf7\xd7\
+\x84\xef\x83\xb5\x21\x9d\x81\x0e\x0f\x76\x61\x4d\xc0\x0c\x3f\x69\
+\xd0\x70\x15\x5a\x9a\x23\xe6\xee\xda\xae\xec\xd8\x55\xa9\xb8\x79\
+\x88\xa5\x82\x2d\x5c\xe6\xf3\xbd\x5d\x86\xc9\x2d\x74\xbe\x27\x5a\
+\xce\x15\xaa\xcd\xb1\x91\x83\xaf\x92\x9d\xb0\x2b\x22\xa2\x0a\xc5\
+\xa6\x8a\x3d\x15\x02\x1a\xcc\x18\x08\xe1\x92\x13\x13\xa0\x6a\x0d\
+\x12\x2f\x97\xd0\xc1\xd5\x55\x99\xb1\xcb\x13\x20\x0e\x95\x39\xea\
+\xac\x8a\x89\xcf\x07\x30\x61\x84\x85\xc5\xd3\xee\xcf\xcc\x65\x63\
+\xd2\xd7\xe8\xab\x23\xb6\x92\x7b\x17\x3c\x23\x2e\x77\x0e\x19\xc7\
+\x4f\xd1\x51\x73\x6e\xbc\xfc\x8b\xfc\xc0\x0f\x76\x68\x2d\x6f\x62\
+\x77\x5b\x58\xbd\x43\xa2\xc1\xf7\xd9\x3d\xd8\x64\xf7\xfe\x21\xed\
+\xe1\xcd\x0b\x6f\x5c\xb9\xec\xf0\x60\x1a\xe2\x99\x07\xb8\xd1\x1a\
+\x2d\xe5\x05\xee\xbd\x9f\xf1\xf5\xff\xed\x1b\xfc\xd9\xaf\xfd\x1a\
+\xde\x1b\x7f\xc2\xd5\x2b\x3a\x9f\x7b\xee\x25\x3e\xfb\x5f\xfe\x04\
+\xf9\xc2\x06\xca\xd9\x2e\xca\xd9\x2e\xe3\xf8\x29\xa9\xab\x08\x8e\
+\xd6\x68\x18\x77\x09\x8e\xd6\xe8\x67\x83\xf9\x2e\x5c\x81\x8d\xf5\
+\xc0\x92\x59\x12\x90\x41\x0b\xf0\xb8\xca\xec\x8c\x32\x46\xba\x83\
+\xde\x54\x2f\x40\x8e\xf2\x7e\x2f\x53\xe6\xb2\x70\xa3\x60\x42\xce\
+\x14\x91\x75\x5b\x6a\xf3\x42\x01\x58\x8e\xf8\xbf\x78\xfd\x29\x3e\
+\xfb\xe2\x0a\xb7\xd6\xae\xf1\xd9\x67\xa6\x2c\x59\x29\xdd\x25\x4d\
+\x06\xb0\x0c\xd8\x22\x98\xcb\xdb\xc4\x99\x05\x76\xf9\xb9\x87\xe1\
+\x2e\x87\xe1\x2e\xab\xd6\x06\x0b\xfd\x08\x2f\x3d\xc5\xd1\xc7\x84\
+\xc6\x84\x7d\x75\xd6\xfc\x10\x7a\x11\x5f\x36\x48\x12\xe9\x87\x5c\
+\xb0\x5c\xc5\xfd\x0e\x19\xca\xe5\xf5\x0b\x5c\x71\xb5\xf9\x31\x3e\
+\x4e\x19\x44\x3e\xea\xe4\x68\x46\xd7\x79\x53\x02\x7b\xd6\x29\x1c\
+\xfb\xf1\x6c\xb8\xc2\xc0\xc6\x08\x91\x7c\xb0\xa0\x54\x14\x32\x5d\
+\x5c\x02\xa7\xf9\x02\xa6\x7e\x86\x97\x98\x72\x6a\x2e\x4a\x4c\xa6\
+\x9a\x25\x0c\xad\x8b\x13\xc1\xc0\xe6\x1f\xbc\x85\x11\x56\xc7\xa4\
+\x36\x7a\x8a\xa9\x86\x2c\xde\x3e\xd4\xec\xc4\xbb\xc1\xe6\x95\x0e\
+\x5c\xe9\x70\x79\xd1\x64\xf7\x9e\xce\xc3\x83\xef\x72\xf4\x1f\xfe\
+\x8a\x07\x8f\x63\xf6\xfc\x7d\x36\x54\xb1\xae\x76\x3b\xba\x47\xe3\
+\xb0\xce\xb5\xf5\xd9\xf8\x92\x6a\x2d\x41\x3e\xfb\x27\xa9\xd6\x12\
+\xc3\xfc\x36\x2e\x6b\x44\x97\x7a\x18\xd1\x1a\xbf\xff\xd7\xef\x63\
+\xbf\xff\x3d\x99\xbd\xd7\x6a\x1b\x1c\x54\x02\xb9\x0c\x60\xe8\x13\
+\x1c\x95\x26\xd7\x0a\xf9\x28\x97\xd8\x6c\xec\xc7\x18\x9e\xf8\x99\
+\x4d\x27\x98\x0b\x40\x3d\xb0\x04\xfe\xd5\x1b\x02\x3a\x34\x55\x49\
+\x15\x57\x03\xb7\x84\x16\xd5\xcc\xdc\x74\x82\xb9\x93\x22\x76\x05\
+\x06\xa7\x08\xe8\xaa\x3f\x45\xa9\x3f\x7e\xe6\xc5\x5b\xdc\xbc\x1a\
+\xb3\x62\x5e\x43\xff\x84\x06\xfd\x6c\x2e\x70\x27\xce\x81\xc8\xc2\
+\x8b\x6b\x73\xd9\xb8\x7a\xbf\xbe\x08\x9c\x8a\xcf\xbd\xba\xb8\x21\
+\x02\xdd\x87\xe1\x60\x93\xd5\xf6\x36\x67\x1c\x63\x27\xcb\x88\x66\
+\x6f\x5d\x62\xe3\xb2\xd0\x2b\x1f\x57\x03\xb9\x0c\xe6\x91\x12\x31\
+\xd8\x3d\x45\x1f\x7c\x4f\x06\xee\xf8\xd4\x13\x8b\xd4\x03\x91\x89\
+\xcb\xb6\xb3\xaf\x6f\x80\x2e\x54\x71\x12\x13\x17\x8c\x87\xa0\x7f\
+\x8b\x46\x46\x99\x61\xc1\xc4\x4a\x26\xb2\x63\x27\x05\x4b\xca\x19\
+\x06\x36\x53\x4d\xe0\xe5\xc4\xcb\x31\xf5\x08\x88\xf0\x12\x13\x53\
+\x17\x27\x42\x4c\x80\x11\xb9\xc4\xa6\xf7\xa1\x01\x6d\x58\x82\x2e\
+\xbf\xbc\xf9\x32\xde\xe4\x16\x27\x85\xe3\x69\x47\x7d\x30\x37\x2a\
+\xf9\x4c\x57\x61\xe7\xdd\x1a\x37\xd6\x2e\x91\x6f\xc1\xc3\x83\x88\
+\x0f\xfe\xe2\xbb\x7c\xe5\xbd\xff\x8b\xc3\xc3\x13\xb1\xbc\x25\x89\
+\xb8\xd9\xb9\xc1\xee\xc7\x1b\x6c\x04\xfb\x5c\xbd\xfe\x79\x39\xd2\
+\x2f\xab\xfe\x02\x17\x5f\xbe\x7e\xca\xde\xc3\xa7\x68\x15\x34\xed\
+\x91\xe6\x70\x79\xe3\xff\xe7\xec\x4d\x63\x24\x49\xef\x33\xbf\x5f\
+\x44\x46\x1e\x91\x77\x66\xdd\xdd\x55\xdd\x5d\xd5\xdd\xc3\x69\x0e\
+\x39\x33\xa4\x48\x91\xa2\xa4\x15\xe1\x7e\xba\x07\x00\x00\x20\x00\
+\x49\x44\x41\x54\xb5\xdc\x5d\xd0\xdc\xc5\x7a\xd7\xd2\xae\xbd\x6b\
+\x08\x82\x05\x08\x86\x77\x05\xfb\xc3\x2e\x20\xd8\x1f\x6c\xd9\x30\
+\x60\xaf\xe1\x05\x0c\xfb\x83\xf5\xc1\xb2\x56\xb0\x21\xcb\xd6\xb5\
+\xb2\x6e\xea\xe0\x50\x9a\xa1\x66\x28\x72\x86\x33\x54\x4f\xcf\x74\
+\x75\xd7\xdd\x75\x57\x9e\x11\x19\x79\xc4\xe1\x0f\x6f\xbc\x6f\xbe\
+\x11\x99\xd5\x43\x39\x1b\x8d\xc8\x23\x32\x2b\x33\xe2\x79\x9f\x78\
+\xfe\x77\x93\xa3\x9d\x32\xa5\xd5\x63\x06\xa7\x36\xc5\x55\x0f\x7f\
+\xbb\x00\x5c\x50\x2a\x1c\x53\x5b\x7b\x45\xbd\x5f\x82\xb9\x45\x15\
+\x23\xec\x63\xf6\x3a\xaa\xc0\x53\x1a\x57\x92\x1d\x74\x00\x2b\x2d\
+\x5c\x35\x19\xf6\x04\x80\xfd\x5e\x48\xc1\x2a\x31\xa9\x58\x04\xed\
+\x2e\x05\xab\xa4\x0c\xbe\x82\x25\x64\x47\xab\x9a\x11\x6c\x5c\xf4\
+\xb0\xe2\x85\x22\x19\xbf\x54\xce\xce\x74\xd3\x14\xe9\xa4\x0d\x7e\
+\xf4\xae\xc9\xb8\x3a\x61\xa5\x52\xa4\xbc\x60\xb0\xd4\x8e\xdb\xd4\
+\x2e\x65\x68\x5d\x04\x34\x97\x8e\x15\x98\x7b\x1c\x0b\x50\x3b\x24\
+\x18\x5a\x82\x39\xbf\x08\xce\xe5\xe7\xd9\xeb\x5e\x02\xf7\x58\xcb\
+\x0c\xa8\xd5\xf7\xb5\x90\x76\x48\x8d\x3e\x93\xae\x8b\x63\x2d\x02\
+\xd3\x28\x9f\x9e\x3c\xaf\x87\xa4\x1d\xd3\xe5\x56\x54\x25\x73\x23\
+\x8b\x5f\xff\x34\x56\xe7\x6d\xc5\xc4\x72\x00\xbc\x5a\x70\xac\x50\
+\xf6\xdb\x74\xc6\x0b\x74\x03\xd1\x2a\x40\x06\x56\x40\x4c\x14\xb5\
+\x26\x0c\xa8\x58\x45\xc5\xc6\x43\x62\x99\xe0\x8b\x68\x5d\xc1\x1a\
+\x32\xf4\x0b\x62\x3c\x96\x35\xc0\x2c\x46\x0a\xc0\xe3\x68\x81\x9c\
+\x71\xa5\x34\xb3\x64\x6f\x09\xe0\x34\x33\x67\xed\x88\x81\xe7\xb1\
+\xbd\xff\x6d\x95\x37\x91\x8b\x5e\x20\xc7\x0b\x31\xa3\xdc\x01\x76\
+\x78\xd0\x34\x78\xd4\x8a\x78\xd4\x8a\x28\x01\x2b\x95\x22\x4f\x98\
+\x30\x3a\x3b\xe4\x1b\xc0\xc3\xb7\xb6\xa1\x1a\x51\xb7\xaa\x74\x18\
+\xb2\xdf\x7f\x46\xf8\xb5\x33\x0e\xea\x35\xa2\xbd\x36\xeb\x5b\x6b\
+\xd0\x86\xcd\x8f\xef\xd1\xee\x0a\x66\xe5\xf0\x31\x47\x3b\x2f\x50\
+\xca\x3e\xa6\x1b\x09\x7d\x4c\xf6\x5d\xf5\x9c\x3b\x79\x81\xd5\xba\
+\xc3\xe9\x64\x43\x68\xe0\xe1\x0d\xb5\x00\x2a\xc3\x1b\x50\x78\x0c\
+\xab\x82\x8d\x9b\xb4\x69\xf5\xa6\xbd\xd4\x64\xb9\x91\xce\x96\xba\
+\x77\xc2\xaa\x9a\xe2\x31\x9e\x00\x6b\xbc\x95\x80\xcc\x5a\xa5\x19\
+\x46\xee\x59\x65\x2c\x2d\xb8\x29\xd9\xb8\x54\xce\x2a\x30\x27\x00\
+\x5c\x81\x57\xd7\x9b\x94\x56\xd6\xc9\xdf\x99\x70\xab\x52\xa4\xb9\
+\x30\xa6\x6e\x4f\x73\x28\x5a\x17\x81\x02\xef\x89\x77\x48\x73\xe9\
+\x58\xb1\xf2\x0c\x43\xc7\x6c\x5c\xb8\xfb\x71\x88\xee\xb3\xff\xf6\
+\xb7\x79\xfc\xf4\x9b\x9c\x76\x0e\x19\xb4\x87\x7c\xac\x71\xc5\x6a\
+\xed\x26\x0b\x9f\xda\xe0\xb3\x2f\xdc\x60\x52\xfb\x12\x74\x9f\x10\
+\x45\x4d\x9c\xac\x4b\x69\x12\x2a\xcf\x45\x2d\x53\x4e\xf4\x7d\x2b\
+\x87\x25\x7a\xa3\x31\xe1\xd0\x53\x4c\x3c\xe3\xa5\x28\xf6\x54\x2a\
+\xa6\x72\xd7\x55\x4a\xaa\x89\xfd\x90\xb8\x21\x62\x35\xc2\x32\x86\
+\x06\x7d\x2b\xc9\xc4\x12\xcc\xd2\xd8\x93\xcc\x3c\xf4\x45\x88\xd0\
+\xaa\x18\xe0\xc5\x63\x05\x2c\x12\xba\x57\x56\x86\x48\x00\x2b\x57\
+\x9b\x5d\x60\xe2\x0d\xd9\x3b\xff\x36\xe3\xf0\x17\xb5\x06\x7f\xaf\
+\xf3\xa0\x69\x40\xe6\x07\x79\x78\xf8\x98\x17\x6e\xbc\xc8\x6f\xbd\
+\x97\xf4\x25\x1a\x93\x15\x16\x3a\x8f\xc8\xaf\x6c\xc4\x8d\xfe\xb6\
+\xc9\x16\x3e\x8e\xeb\xef\x28\x36\x32\xad\x15\xba\x9d\x33\xc2\xd0\
+\xa0\x73\x01\x0d\x33\xa2\x7d\x58\xa5\x66\x08\x2f\xc3\x0b\x96\xcd\
+\x99\x61\x63\xae\x37\x09\x8f\x36\xe2\x16\xad\xaf\x50\x09\x2e\x98\
+\xb4\x9b\xb0\xfc\x98\x53\xa6\xc3\x17\xa5\x76\x3e\xcd\x94\xa1\xf0\
+\x98\xc1\xa9\x2d\x74\x32\x87\xb4\x43\x03\xa3\x2a\x3a\xbe\x4f\x23\
+\x72\xc5\x84\xac\xd0\xdd\x6b\x7e\x2f\xc4\x7a\xce\x88\x1f\x25\x0f\
+\x9e\x63\x24\xea\x75\x79\x69\xf6\xd5\x01\x7c\xef\x4e\x72\x42\x4c\
+\xc7\x7b\x46\xdd\x4e\x8e\x11\x10\x00\x16\xac\xbc\x66\x13\x6f\x37\
+\x12\x60\xa6\x20\x00\x5c\x28\x2d\x72\xef\xd3\x5b\x6c\x6d\xdd\xe1\
+\xbd\x6f\xdf\xe7\x7f\xfe\x7f\xdf\xe4\xcd\xf7\xff\x98\x3f\x63\x85\
+\xdb\xb6\xcb\xcb\x5f\xfd\x7d\xde\xff\xd4\x67\xf9\x7b\xff\xc9\x6d\
+\x6e\x37\x36\xd9\x6f\xef\x62\x52\x42\xd5\xed\x6b\xb9\x15\x51\xd0\
+\x27\x5b\x29\x31\xe9\xbb\x50\xc8\xa9\x5c\x62\x1d\xc8\x12\xc0\xd2\
+\x3b\x91\xf8\x8c\x81\x41\x2f\xd6\xd5\xd5\x38\x02\xa8\x34\xb1\x94\
+\x14\xb2\x3a\x5e\xea\x62\x09\x6a\x29\x2d\x0a\xd6\x90\xf1\x60\x21\
+\xd6\xc0\x02\xe8\x82\x79\xa7\x80\xb5\x3c\x4f\xb1\xb0\xa7\x97\x36\
+\x69\x33\xed\x66\x82\x1d\xad\x08\x78\x5d\x19\x78\x0f\x9a\x86\x7a\
+\x7e\xf3\xea\x2e\x23\xff\x28\xae\xd1\xbb\x10\x45\xa9\xd5\x08\xfc\
+\x1d\x35\x81\xc8\xa8\x1a\x58\x83\x3c\xa6\xb5\x42\xcd\x14\xe3\x02\
+\xfa\x40\xeb\x03\x78\x56\xdd\xa6\x61\x46\x84\xf5\x06\xf7\x1f\x5c\
+\x11\xad\xff\x0d\xb8\x03\xd9\xd8\x47\x4c\xa6\x4c\x69\x59\x48\x89\
+\xd2\xaa\xf0\x8a\x48\xe9\x50\xa9\x83\x71\x75\xc8\x20\xfe\xe2\xa5\
+\xec\x63\x06\xd8\x58\x83\xbc\xea\xb3\x56\x37\xab\x74\x2a\x11\x46\
+\xd0\x9f\x31\xca\x54\x40\x03\x21\x23\x0a\x83\x52\x02\xdc\xa5\x30\
+\x87\x6b\x8e\xe7\x02\x58\x0f\x8c\xb4\x8a\x1e\xd6\x60\x42\xb5\x3c\
+\x6d\xac\x22\x73\x29\x9a\x35\xd1\x31\xbe\xbc\x61\xb0\x5c\x10\x12\
+\x02\xa0\xb2\xb0\x4a\xeb\xea\x94\xca\xc2\x2a\x10\x70\xe1\x65\x58\
+\x9a\xc3\xca\x12\xd0\x27\x17\x87\xca\x2b\xd5\xf1\xde\xa4\xb5\x9d\
+\xe3\x07\x2f\xa1\xf0\x37\xff\x46\x9c\x45\x18\xf1\xf2\xf7\xbd\xcc\
+\xff\xd0\xa8\xf2\xcb\x2f\x2e\xf1\xf3\xff\xeb\xff\xc5\xbe\x97\xe7\
+\xd2\x2f\xb3\xf8\xf0\x3d\xdc\x7f\x7d\xce\x57\x7e\xf2\xef\x73\xeb\
+\xd3\x9f\x63\x70\x7c\x86\x1b\x64\x21\x18\x52\xce\x25\x03\x22\x7e\
+\x5c\xa3\x57\x8d\x0a\x5c\x5d\x66\xe7\x06\x3c\x9c\x41\x15\x73\x74\
+\x4e\xe9\xc5\x64\xf5\x6a\x14\xf4\x45\x7f\x65\x2d\x4f\xa3\x54\xce\
+\x92\xf9\x07\x3f\xf9\x4f\x7e\x6e\x1c\x46\xd8\xfe\x88\x61\x6c\xb0\
+\x15\xac\x21\x7e\x68\xe1\x87\x96\xba\x0f\x60\x99\x3e\x93\x20\xc2\
+\x34\x3d\x32\x64\x19\x87\x11\x56\xce\xc7\x18\x1a\x04\xd6\x04\xd3\
+\xf7\x15\x98\xf3\x7e\x0e\x3f\x0b\x96\xe7\x31\xb6\x2d\xe5\xb5\xa8\
+\xd6\x8e\xb8\xea\xbd\xc3\xe5\x35\x25\x7a\x97\x9e\x08\x45\x9f\xbc\
+\xf9\x80\xc2\xd5\x12\xd6\x55\x95\x76\x77\xcc\x5b\x57\x1d\x1e\xef\
+\xed\x91\x5d\xbc\x64\xbf\x56\x63\x6b\xa9\x45\xbf\x9f\x05\x31\x72\
+\x84\x30\xf4\xc9\x98\x16\xe3\xf1\x94\xf2\xc2\xd0\x87\x91\x48\x66\
+\x3f\xef\x44\x5c\x5c\x7a\x8c\x8f\x5b\x2c\xe4\x4f\xa8\xde\xf9\x18\
+\xb7\x22\x1f\x7f\x60\x30\xe2\x8c\x71\x7e\x8b\x5c\xe6\x4a\x80\xb9\
+\x26\x1e\x47\xf9\x3d\x26\xce\x32\xd1\xc2\x12\x86\xd7\x63\xe2\x64\
+\x69\x87\x06\x61\x36\x10\xe3\x4d\x62\x26\x68\xe4\x1c\x26\xee\x34\
+\xe0\x60\x8a\xcc\x6f\xc2\xac\x8f\x35\xb0\x19\x7b\x63\xac\xaa\xa9\
+\x1e\x97\xc2\x1c\x13\x23\x60\x62\xcc\xe6\xfd\x56\x7d\x07\xb7\x1c\
+\xf7\xe5\x9d\x64\xa9\x96\x07\x78\x91\x81\x39\xc9\xaa\xf2\x7e\xaf\
+\x6b\xd0\x2c\x4e\x01\xbc\x75\x7f\x85\x92\x55\xe2\xde\xed\xa9\x9c\
+\x19\x7b\x4e\x0c\x60\x38\x3b\x3b\x67\x7d\xc1\xe6\xc2\xcb\x50\xca\
+\x4e\x89\x65\xcd\xde\xc0\xf1\x7b\x78\x83\xe9\x73\x17\x5e\x86\xde\
+\x69\x95\x0f\xbe\x71\xc8\xd7\x7f\xe5\x6b\x5c\xee\x3f\xe1\x85\x4f\
+\xbe\x82\x5d\x76\x70\x4b\x36\x8d\xb5\x25\xb6\xee\x7f\x8c\xbf\xf3\
+\xf2\x8b\x7c\xf5\xe1\x11\x8e\x13\x50\xb7\x8a\xbc\x7d\x70\x89\xfb\
+\xf5\xd7\x29\xdc\xf4\x78\x61\xf5\x2e\x41\xc9\x20\x37\x09\x31\xcc\
+\x3c\xc8\x10\x75\x2c\x2f\x5c\xcb\xc7\xb0\xb3\xf4\x7a\x97\xbc\xf5\
+\xc6\xeb\xd8\xd6\xd4\xe8\x1c\x4f\xf2\x71\xf3\x19\x97\xd5\x5c\x8d\
+\xad\xcf\x6f\x60\x79\x6b\x8c\x30\xc8\x96\xb3\x54\x07\x06\x79\xc0\
+\x9b\x98\xe4\x81\xff\xe5\xdf\xfc\x3f\x64\x7e\xfc\x27\xfe\xf1\xcf\
+\x01\xf8\x71\x4f\x80\x8a\x9f\x25\xf2\x27\x64\xc3\x80\x6c\x18\x30\
+\xa4\x30\x03\xea\xa1\x5f\xc0\x34\x3d\xfc\xd0\x22\x34\x6a\x64\xb2\
+\x82\x89\x87\x51\x15\xc3\xe8\xe1\x4f\x6a\xe4\x0c\x1f\x7c\x8f\x71\
+\xb4\x40\xd6\xef\x91\xf7\x73\xb8\x91\xcd\x64\xb2\x42\x77\x74\xc5\
+\x52\xe1\x90\x25\xdb\x98\x01\xf3\x83\xa6\xc1\x37\x5e\xbf\x4d\xdd\
+\xbf\x03\x41\x95\xcb\xee\x05\xdf\xba\xff\x2d\x46\x2d\x9f\x83\xf3\
+\x90\x8b\x8b\x90\x4f\xfe\xad\x13\x38\xb7\xa9\x56\x26\xf4\x2e\x85\
+\x81\x13\x95\x03\xc2\x6c\x80\x39\x99\x82\xb8\x15\x4d\x28\x60\xe0\
+\x38\x19\x72\xb9\x0c\x97\x97\x13\xba\x83\x31\x4f\x9e\x9c\x72\xbe\
+\x73\x44\xb8\xde\xc3\xa8\xf6\xa8\x2c\xfc\x6d\xca\xb5\x0f\xb8\xba\
+\xda\x80\x62\x8d\x5c\xe6\x8a\x49\xb8\xc0\x24\x5c\xa0\x54\xdb\xc3\
+\xbf\x18\x08\x29\xe1\xf5\xb0\x0d\x18\x46\x06\x5c\x88\x3c\x85\x41\
+\xde\xa4\xc8\x08\xd7\xf2\x29\x18\x79\x02\xd7\xc4\x2f\x7a\x54\x46\
+\x25\x02\x5f\xdc\xcf\x05\x45\xcc\x49\x16\x73\x92\x55\xec\x7b\xdd\
+\x2d\x5f\xf5\x99\xb8\x62\x7f\xbf\xe8\xe1\xc5\xee\xb3\x4a\xbe\xa8\
+\x6a\xf7\x9a\x8d\x88\x95\x8d\x06\xeb\x0b\x59\xb6\xee\xaf\x50\x69\
+\x42\xde\x86\x72\x7e\xca\x6c\x95\x85\x55\x9c\xd3\x88\x5c\xd9\x20\
+\x5f\x2c\x33\xf0\xcd\x04\x13\x03\x38\x7e\x0f\x72\x1f\x83\xe0\x8a\
+\x0b\x2f\xc3\xf9\x91\x41\xfb\x69\xc0\x37\x8f\x8e\x79\xfb\xd1\x01\
+\x6f\x1c\xfa\xbc\xbb\x7f\xc6\xc1\xaf\x7f\x97\x85\xdb\x11\x77\x6e\
+\x3f\x80\x4c\x01\xdf\xce\x71\xab\xb1\xc8\xf7\xdf\x59\xe6\xd9\x38\
+\xc7\xc3\xed\x03\x26\x66\x95\x67\xe3\x21\xce\xce\x77\xa8\xad\x67\
+\x59\xb9\xd1\x24\x18\x16\x71\xfd\x88\xa5\x6c\x71\x9a\x6b\x91\xa9\
+\x90\xf5\x47\x50\x5c\x64\x6f\xcf\xe3\xfd\x47\x0f\x13\x20\x2e\x17\
+\x7b\x8c\x27\x79\x8c\xc0\xe5\xc1\x8b\x8b\x2c\x2d\xdf\xc2\xce\x07\
+\xe4\x02\x9b\xec\xc4\x50\xd2\x42\x26\xe4\xff\xca\x2f\xfe\xb6\x90\
+\x13\x51\x77\x84\x11\x8b\xe8\xbe\x35\x01\xf2\x6a\x78\x8b\x74\xa5\
+\x29\x39\x11\xbb\xda\x86\x7e\x41\x79\x27\x94\x7f\xcf\xf0\x70\x23\
+\x21\x37\xa4\x26\xce\x1a\x9e\xea\x4b\x11\x06\x2e\x05\x6b\x48\x2e\
+\x12\xae\xb5\x79\x3d\x84\xbf\xf1\xfa\x6d\xc2\xa3\x0d\x06\xf6\x90\
+\x62\xa3\xc0\xc5\x5a\x12\xe5\xe1\xfd\x55\xa0\xcf\x77\x27\x0b\x34\
+\x2f\x3c\x8c\xaa\xf2\xc3\x27\x7a\xa1\x4d\xfc\xa1\x9e\x6c\xa7\xf4\
+\xaa\x0c\xd3\xb6\xc2\x1e\xbb\x7f\xd8\xa3\x5e\xaf\xf1\x62\xf3\x5b\
+\x98\xf6\x06\xeb\x5b\x87\x71\x98\x3a\x96\x0e\xa7\x36\x03\x6c\xe5\
+\x33\x16\xc5\x8a\xb1\x5b\xad\x2a\x00\x95\x35\x27\xf4\x28\xd2\x2c\
+\x0f\x68\xc5\x61\x5f\x6b\x60\xcf\x00\x55\xc9\x88\x6a\xa4\xb5\x01\
+\x4d\xbe\x56\xf5\x45\x7b\x26\xb9\x0c\x65\x16\x5c\xcd\xac\xaa\xcc\
+\xb4\x5a\xa3\xc6\xab\x0f\x9a\xb1\x7c\x58\xa6\x12\x27\xf4\x49\x19\
+\x21\x6d\x08\x80\xc6\xea\x21\x76\xff\xd3\xf4\x2a\xd3\xe1\x2d\xa3\
+\xf3\x15\x11\x81\x53\xd4\xf7\x21\x17\x5e\x06\xe7\x34\x62\xfb\x78\
+\x97\x9d\xed\x33\x0e\x8e\x3d\x2e\x7b\x59\xee\xdd\xbe\x01\xc6\x31\
+\xbf\xb1\xf3\x3a\xc1\x7f\xf1\x88\x27\xff\xf1\x84\x1f\xfb\xf7\xff\
+\x19\xf5\xd2\x15\xbd\x46\x9e\x57\xbf\xf4\x2a\x3f\x7b\xe7\x36\xff\
+\x0a\x78\xf3\x6b\x7f\xcc\x62\x65\x89\x6f\x1e\xc2\x8d\x7f\xfb\x3e\
+\x4b\xb5\x7b\x34\xef\x82\xe7\x56\x38\x26\xa0\xcc\xd4\xed\xf6\xbc\
+\x9b\x33\x98\xed\x66\xd4\xce\xe6\x30\xc6\x86\x32\x12\x25\x80\xfd\
+\x81\x29\x3a\x00\xfd\xf8\x4f\xfc\xe3\x9f\x33\x62\x31\x1c\x75\x47\
+\xc8\xfb\xbe\x69\x29\x76\x96\x00\x1e\xfa\x05\xa2\x68\x02\xa5\x2c\
+\xe1\x18\xc5\xce\x7e\x68\x91\x37\xe3\x9e\x5e\x46\x8f\x0c\x59\x06\
+\x7e\x06\xd3\xf4\x18\xf8\x19\x6c\x33\x27\xf4\x75\x29\x4b\xde\xcf\
+\x51\x2d\x2d\xd1\x77\xc7\x34\x4b\x25\x96\x0a\x87\x5c\x7a\x22\x31\
+\xe7\x62\x34\x21\x30\x7b\xd8\x79\x8b\xe5\xaa\x8f\x91\xe9\x53\xae\
+\x1d\x70\x1e\x4d\x30\x96\x3d\xce\x1f\xe6\x31\x5a\x0e\xcb\x2f\x8d\
+\x59\xbe\x82\x9e\xdb\x24\xeb\x1a\x62\x1c\x97\x33\x62\x6c\x58\x62\
+\xd0\x4b\xe8\xc7\xd5\xd6\x86\x0a\x10\x74\x8c\x88\x8a\x65\x13\x86\
+\x22\xdb\xac\x64\x0c\xc9\x19\x35\x32\xa3\x2e\xdb\xad\x2e\xee\xd5\
+\x33\xce\x2e\x2d\x7c\xf7\x8a\x6c\xd9\xc7\x9d\xbc\x40\xa9\x76\xc6\
+\xc4\xc9\xaa\xad\x04\xb0\xcc\x26\x23\x0f\x93\x71\xa8\x3c\x07\x92\
+\x3d\xf5\x6d\x98\xf5\x15\x0b\x03\x2a\x73\x4d\xbf\xc9\xfd\x27\x41\
+\x49\xed\x27\xf7\xad\xe4\x8b\x8a\x7d\x0b\xb5\x02\xaf\xde\x9d\x05\
+\x30\x40\xc5\x5c\x87\x4c\x1c\xde\xcf\xb8\x8c\x3d\x07\xab\x78\x93\
+\x30\xff\x01\x21\x35\xaa\xfd\x45\xda\xe6\x90\x6a\xbd\x9f\x90\x0e\
+\x03\xdf\xe4\xc9\xde\x0e\xad\xf7\x43\x5e\x3f\x18\xd0\x3a\xbd\xa2\
+\xd5\xf5\x58\xa8\xae\xab\x16\x58\x3f\x52\x1e\xf1\xa7\xc3\x32\x7f\
+\xf0\xbb\xbf\x4d\xdd\x3b\xe6\xe3\x4b\x2f\x61\xaf\x2e\xc7\x95\x29\
+\x79\xbe\xf8\xea\x5d\x1e\x9e\x79\x3c\xdc\x3e\xe0\x46\x29\xcf\xdb\
+\x07\x97\x64\x4e\x0f\xd9\xfa\xf4\x3a\xd5\x8a\xc5\xb0\x6f\x32\xca\
+\xda\x4c\x46\x23\xf2\xd9\x12\xae\x1f\x51\xcc\x5a\x3c\x3b\x1f\xcc\
+\x30\xb1\x39\x3a\x27\xb2\x4a\x18\x81\x8b\xbd\xb4\xcc\xbd\xad\x9b\
+\x64\x73\x8b\x94\x27\x50\x30\x73\x74\x03\x87\xb1\x99\x27\x18\x3a\
+\xd4\xcc\x1c\x3f\xff\xcb\xbf\x4e\xe6\x27\xfe\xc9\xbf\xfb\x73\x12\
+\xac\x45\x2b\xc0\x37\x2d\xda\x13\x1b\x3b\x93\x34\x36\xa4\x2e\x2e\
+\x58\x43\xc2\xac\x00\x71\xc1\x1a\x62\x99\x3e\x7e\x68\x61\x9a\x1e\
+\xc3\xa8\x4a\xc1\x98\x66\xbc\x49\xdd\x6c\x9a\x53\x59\x91\x21\x4b\
+\x86\x2c\xc5\xc5\x5b\x58\x85\x1b\x94\x2a\x5f\xa2\x18\x8d\xd8\x3b\
+\x38\x22\x1b\xeb\xd9\xf6\xe2\x09\x95\x9b\x5d\x0a\x57\x4b\x84\xf9\
+\x36\xa5\x1b\x11\xed\xbf\xa8\x13\x3c\x9d\xe0\xe5\x4d\x4e\xc7\xb7\
+\x39\x0f\x8b\x94\x4f\x9e\x61\x98\x65\xaa\xe3\x0c\x8e\x61\x4c\x75\
+\xb0\x96\x77\x5b\x8d\xd3\x23\x87\x06\xe4\xc2\x80\x8e\x11\x31\x34\
+\xc0\x8b\x53\x1a\x23\x0a\x14\x8c\x3c\x8e\x93\x61\xdc\x17\xc3\x4d\
+\xba\x97\x65\x8a\x91\xd0\xc0\xd0\x60\xe2\xf8\xb4\xa8\xd2\x34\x46\
+\x78\x43\x18\x45\x23\x02\xd7\x24\x37\xb4\xf0\x4a\x42\x0f\x57\xcb\
+\x03\x5c\xcb\x57\x46\x9b\x04\xa3\xdc\x4a\x50\xa7\xf5\xef\xc8\xcc\
+\x4d\xf5\x6f\xac\x87\xa5\xec\x98\x18\x01\xb9\x5c\x46\xe9\xdf\x8f\
+\xdd\xac\xf2\xe2\x8a\x41\xa1\x94\x04\xf0\x4a\xa5\x38\x05\xb0\x26\
+\x27\x44\x5f\x0f\x01\x60\xaf\xf2\x36\x0b\x76\x59\x01\x77\xe0\x9b\
+\x38\xa7\x11\xfd\xed\x23\xbe\xf9\xc1\x84\x6f\x6f\x6f\x73\x76\xe2\
+\x31\x18\x65\x58\xa8\xae\xd3\x8a\x5a\x78\x91\x85\x87\x47\x2f\x73\
+\x83\x62\xbe\x44\x60\x65\xf9\xe3\xd7\xdf\xa0\x7f\xf2\x2e\x9f\xa8\
+\xaf\x53\xdc\x68\x60\xe6\xc6\x14\x16\x1a\x7c\xe1\x07\x3e\xc5\x07\
+\x7b\x1d\x25\x2d\xee\xf6\x73\x9c\x1d\x5c\xf0\xb9\x57\x6d\xfc\xea\
+\x3a\x13\xa7\x4f\x29\x63\xe0\xfa\x11\xa5\xcc\x84\x28\x58\xe4\xb8\
+\xf3\x98\xf7\xdf\xdf\x57\x20\x6e\x8f\x2c\x8a\xf4\x15\x88\xef\x17\
+\x2b\x6c\x7d\x7e\x83\x49\x2f\xcb\xd8\xcc\x33\x0c\x1c\x6a\x99\xb2\
+\xda\xf6\x30\xf8\xc5\x5f\xfe\x35\x61\xd8\x29\xa0\xc6\x60\x96\x00\
+\xd6\x99\x39\x01\xe6\xa0\x44\x3e\xd3\x17\x2e\xb7\x18\xc4\x96\xe9\
+\x13\x50\x24\x67\xf8\xca\xf0\x9b\x30\xc0\x36\x73\x84\x4c\x98\x04\
+\x11\x94\xb2\x0c\x87\x11\x79\x53\xe4\x26\x67\x83\x12\x76\x71\x15\
+\xb7\xd3\x66\x64\xbd\xcb\x49\xe4\xf1\xc2\x52\x01\xe7\x4a\xe4\xfc\
+\x0e\x17\x2e\xd8\x6c\xff\x30\xc1\x59\x91\x61\xc5\xa2\x91\x5b\x22\
+\x6b\x44\xac\xd7\x7a\xdc\x9b\x34\x58\xa8\xd7\x69\x56\xb3\x9c\xf5\
+\xc4\x84\x4e\x59\x71\xac\xae\x1e\x31\x13\x0f\xf2\x26\x0b\x51\x8f\
+\x88\x82\xca\xd3\xd5\xf3\x6f\xe9\x19\xe4\x2a\x22\xbf\xd7\xca\x89\
+\x96\x53\x41\x98\xc1\xf7\x0b\xe4\xd6\x1a\x18\x5e\x06\x9b\x2e\xed\
+\xd0\xa0\x33\x8e\xa8\x1b\x05\x26\xe3\x90\x5c\xc5\xa4\x60\xe4\xf1\
+\x2c\x97\x9c\x51\x23\x70\x67\x1b\x72\x55\xcb\x03\x46\xe3\xec\x5c\
+\x30\x4b\x00\xab\x4b\xbd\x99\x13\x00\x2e\x8b\x86\x78\xb9\x5c\x46\
+\x34\x18\xd4\x3c\x10\x3a\x80\x1b\xed\x2c\xb5\xe5\xd9\x4a\x13\x63\
+\xb2\x42\xa9\x7c\x48\x18\xbb\xe3\xc2\xfc\x07\xd4\xed\x9b\x5c\x78\
+\x62\x41\xf7\xaf\x4e\x19\x7b\x0e\x4f\x8e\x2e\xf8\x83\x0f\x26\x5c\
+\x3d\x3b\x54\xc9\xf2\x46\xce\xc4\x75\x1c\x0c\xad\x3b\xa5\x17\xff\
+\x5b\xc8\x2f\x12\x65\x3c\x3e\x3c\xed\x70\xfa\xfa\x1e\x2f\xdd\xbd\
+\xa4\x72\xe7\x53\x90\x29\x50\x2a\x98\xfc\xc8\x8b\x5b\x3c\x3c\xf3\
+\x38\xda\xdb\xe1\x70\x78\xc4\xc3\xc3\x1d\x16\x7d\x9f\x97\x3f\x96\
+\x21\x30\x8a\xb8\x81\x09\x85\x0c\xb9\x30\xc2\x30\x43\x4e\x5b\x59\
+\xde\x7f\xf4\x90\x61\x60\x62\x5b\x21\xc3\xc0\x64\xb1\x31\x51\x9a\
+\xb8\x76\x67\x95\xad\x1b\xeb\x80\x4d\xcd\xcc\x31\xea\x8d\x18\x65\
+\x27\x22\x57\x23\x70\xc8\x96\xb3\xfc\xc2\x2f\xfd\x7a\x72\x40\xb9\
+\x94\x0c\xea\x60\xd4\xe6\xcf\x26\x0b\x03\x57\x19\x7c\x52\x1b\x0f\
+\xfd\x02\x56\x65\x40\xbf\x2f\x06\x9a\xfb\x95\x08\xbf\x5f\x60\x48\
+\xa8\xc2\xd4\xd3\x28\x5f\xec\x53\x5d\x2a\xe1\x5e\xf4\x55\xc6\xda\
+\xc7\x6b\xa5\x44\x97\xcb\xfa\xe3\x8f\x93\x77\xaa\x2c\x2f\xc2\x32\
+\x90\xdf\xa8\x72\x70\xd7\xe3\xd6\xd8\xe6\x20\xe7\x69\x61\xe4\x21\
+\x27\x8f\x1f\xd3\xd2\x0b\x29\xe3\x5c\x5b\xbf\xe8\xb1\x94\x59\x66\
+\xe2\x0b\x40\xd7\xf5\x2a\x0a\x73\x2c\xf4\xa9\x09\xa5\x5e\x4e\xf4\
+\xbe\x95\x2d\xa8\xa4\x5b\x67\xbf\x8b\x51\x16\x85\x9b\xdd\xb0\x8b\
+\x21\x9a\xe3\xa8\x84\x1c\xd7\x99\x40\x11\xd5\x73\x4d\x0f\x4c\xf8\
+\x45\x2f\xf6\xeb\x4e\x34\x1f\x32\x73\xc3\xc9\x7a\x30\x43\xef\x9e\
+\xd9\xac\xad\x6a\x2e\xb4\x24\x03\xe7\xd7\xd6\x39\xed\xef\x26\xf4\
+\x30\x40\x79\xd5\x60\xc2\xad\xb8\xe8\x20\xa0\xe3\x91\x00\xf0\x59\
+\x7f\xc0\x93\xbd\x2c\x8f\xde\xd9\xe3\xb2\x97\x05\xb2\xaa\x57\x85\
+\x6c\x7f\x95\xbe\xb5\x08\x20\x6a\xd1\xac\xde\x05\xe0\x4f\x7a\x0f\
+\x09\x7e\xf6\x11\x3f\xf5\x9f\xdf\xe6\x85\x7f\xef\xd3\x98\x61\x83\
+\xfa\x66\x93\x7f\xf5\x5f\xff\x34\x3f\x1b\x6b\x64\x80\xff\xe9\xb7\
+\xde\xc3\x37\xd7\xf8\x77\xfe\xe9\x4b\x0c\xfc\x88\xc1\xb0\x4d\x29\
+\xae\x00\x3f\xbd\x14\x35\x7d\x8d\xbc\x20\x9e\x05\x8e\x19\xb4\x81\
+\xfc\xac\x2e\xee\x76\x66\xb5\xb4\x3f\x30\x29\x85\x39\xd1\xa0\xa0\
+\x10\x77\x29\xd6\x01\xac\x1b\x76\xe9\x9b\x7c\x4d\xdf\x5f\x82\x74\
+\x26\x6b\x29\x4e\x2a\xd2\xff\x46\xdf\x0f\xb1\x2a\x06\xa3\xa1\xc9\
+\xe9\xa3\xbd\xb9\x9d\x7d\x00\x96\x0b\xcb\xac\x2c\x79\xdc\xc8\xdc\
+\xe2\x96\x91\x65\x61\xa5\xce\xa7\x1a\x6b\x2c\xac\xd4\xd9\xba\x73\
+\x87\xd5\xfa\x06\xab\xf5\x0d\xbe\xf0\xf1\xfb\xdc\x7a\xe5\x8b\x82\
+\x59\x35\x00\xcb\x04\x99\xce\x9c\x03\x40\xcf\x10\xd1\x2f\xad\x54\
+\x48\x2f\xef\x71\x9d\x89\xf0\x05\xb7\xfa\xb4\x3a\x72\x86\xb0\xad\
+\x52\x2e\xf5\x84\x9c\x74\xee\x43\x2b\x34\xd4\xf3\xf2\xbb\xc8\xfd\
+\xf5\x72\x7e\x3d\xc2\x17\x50\x53\x00\xce\xd0\xa5\x99\x81\x17\xee\
+\xdc\xe1\xf6\x9d\x8d\xb9\x00\x06\x88\xb2\x67\x73\x25\x84\x88\xbe\
+\x8a\x34\xc1\x9d\xa3\x0b\x26\xdc\x22\xcb\x01\xce\x69\xc4\xd3\xc3\
+\x55\xde\x7b\x27\xe0\xd1\xdb\xae\x62\x5f\x09\xda\x16\x02\xc0\xb2\
+\x52\x5a\xaf\x98\x96\xe3\x80\xf7\xfb\xcf\x44\xbb\xaf\xea\x5d\x7e\
+\xe3\x38\xe2\x7f\xff\xef\xfe\x4b\xce\xfe\xf4\x37\x09\xcd\x76\x0c\
+\x44\x83\xff\xf4\xef\x7f\x9e\xca\xfa\x16\x93\xf3\x47\xb4\xda\x06\
+\x6f\x7e\xfb\x77\x79\xfb\xe1\x1f\x51\x2b\x89\xf3\x70\x15\x64\x54\
+\x3a\xa6\x32\xde\x46\x56\x3c\xa6\x41\xef\x00\x15\x5f\x55\x75\x5c\
+\xf5\xa7\x19\x72\x55\x22\xd1\x01\x48\x02\x4b\x67\x61\x19\xa1\x93\
+\xcf\xe9\x85\xa2\x05\x6b\x88\x17\xb3\x70\xdb\xec\x61\x8f\x97\x13\
+\xde\x0b\xc1\xc8\x86\xa8\x08\xa9\xcc\xd6\x87\xc9\x7d\xf2\x85\x22\
+\xfb\xdb\x87\xfc\x9f\xbf\xff\xfb\xac\x6f\xad\xd1\x58\xdb\x4b\xec\
+\xf7\x29\xe7\xa7\xb9\x71\xc3\x8f\xe3\xe7\x00\xeb\xe8\x50\x2f\xe1\
+\xc3\x2a\x1c\x0f\x05\x6b\x7f\x76\xb3\xc4\xc3\xf7\xf2\x74\x3a\xfd\
+\x44\x0e\x83\x1e\x45\x2b\x85\x39\x5c\x67\x9c\xa8\x6f\xc3\x8c\xbd\
+\x16\x3d\x43\x31\xb1\x6b\x8e\xd5\x73\x92\xad\xa5\x6b\x4c\xa6\x3d\
+\x76\xe3\x9c\x5e\x09\x4c\x09\x48\xc9\xb6\x2e\x93\x44\xf2\xbb\x04\
+\x7a\xd0\xab\x53\xad\x76\x14\x53\xcb\x1e\xc5\x72\x41\x64\xe8\x52\
+\xb1\x36\x58\x59\xcf\x70\xff\x81\xc9\x72\x21\x43\xa5\xb9\x3c\x73\
+\x1c\x25\xfb\xea\x2c\xdc\x8f\x83\x1b\x62\x2b\x98\xb8\xb9\x30\xa6\
+\x7d\x1a\x71\x3a\xf4\x79\xb2\x77\xc4\xa3\x77\x44\xfe\xee\x65\x3f\
+\xc9\xbe\x9d\x32\xd4\x1d\x68\x95\x83\x69\x87\x1f\x8d\x99\x25\xa0\
+\xc5\xa4\x54\x9b\x56\xd4\xe2\xde\x9d\x02\xaf\x75\x3d\xf8\xd9\x5f\
+\xe0\xbf\xfd\xd5\x2f\x62\xdd\x01\xb3\x7e\x87\x57\xbf\xf4\x2a\xff\
+\xa2\xd5\xe1\x5f\x03\xfd\xa3\x1d\xbe\xfa\xee\x23\xee\x7f\xf5\x92\
+\xad\xa6\xc1\xda\x9d\x09\xed\xab\x01\xbe\x96\x6f\xde\x1e\x59\x2c\
+\x70\xcc\xa9\x07\x61\x7d\x19\x73\x74\xae\xb2\xd8\x64\xa5\x48\xf6\
+\x20\x62\xd2\x98\x56\x8d\xc8\x6c\x39\x71\x25\x4e\xb1\x6a\xd4\x15\
+\x00\xd6\x99\x58\xa6\x69\x56\x2c\x53\x81\x74\x1c\x2d\x60\x8f\x97\
+\x15\x30\xa3\xee\x68\x86\x99\x93\x12\x62\xea\xae\x6b\x56\x0c\xf6\
+\xb7\x9f\xf1\xdb\xff\xe3\xaf\x13\xed\x8b\x94\x9f\xef\x73\xbe\x28\
+\xfc\xc4\x4b\x3f\xc4\x57\x8c\xaf\xb0\x56\x79\xc6\x8d\x92\x68\x9a\
+\x71\xa3\xb4\x44\x94\x3d\x53\x8f\xcb\xab\x86\xda\xae\xd4\xd7\xb9\
+\x51\xf0\x29\xd6\x33\xd3\xaa\xde\xde\xd4\x2b\x21\x80\x3b\x51\xc0\
+\x95\xcc\x3b\xf7\x75\x9d\x91\xe3\x9e\x06\xfa\xf3\x93\x8a\x85\x11\
+\xf4\x71\x9d\x89\x02\xf0\xa4\x62\xcd\x24\xff\xe8\xee\xbc\xaa\x9f\
+\xf4\xa7\xe9\x9f\x59\x33\xab\x6a\x92\x92\x5c\x34\xb5\x7a\x8d\xb5\
+\xf5\x0c\x37\x9a\x4b\x2c\x17\x96\xe7\x5e\xa1\x56\x2a\x45\xce\xfa\
+\x83\x84\x06\x6e\x2e\x8c\x13\x8c\xdc\xbf\x12\xe9\x8b\xad\xab\x1c\
+\xee\x59\xc0\x77\xde\x5f\xe0\xd1\x3b\xdb\x71\x9b\x80\x42\x42\x32\
+\xc8\xfb\x66\x39\x43\x5d\xfb\xba\x66\x39\x33\x33\x68\x32\x74\x92\
+\x97\xfa\x66\xf5\x2e\xbf\x75\x74\xc5\x6f\xff\x57\xff\x0d\x61\x4b\
+\xb0\x71\xd7\xb0\xf8\x3b\x9f\x79\x99\x97\xee\x8b\x31\xc6\xf5\x66\
+\x85\x3f\x7c\xf8\x1e\x7f\xf1\xb5\xd7\x71\xba\x17\x94\x1a\x79\xfc\
+\x14\x13\x5f\xd5\x0a\x2c\xc7\x00\xbe\xe2\x06\xd1\xf8\x52\xe5\x13\
+\x03\xf8\xd5\x56\x82\x8d\x75\xb7\xa9\x39\x88\x8d\xda\x28\x8e\x53\
+\x4b\x1d\x3c\x70\xd1\x7c\xc1\x02\x8c\x6e\x64\x53\xb0\x44\x8e\xb0\
+\xf4\xf9\xca\xa4\x1f\xa3\x26\x80\xef\xe5\xce\x95\xac\x90\x6c\xac\
+\x12\x88\x62\x1d\x7c\x75\x34\xe4\x6b\xbf\xfe\x4d\x9e\xb4\x9f\xd2\
+\x69\xf5\x59\xbe\xda\xa0\xdf\x12\x40\x2e\xec\x3e\xa0\xb2\xb0\xca\
+\xcd\xdc\x27\xe8\x55\x2e\x15\x70\xe5\xa5\xf2\x46\x69\x89\x6a\x7f\
+\x91\xcd\xcd\x90\x6a\x7f\x91\x8d\x8c\x4b\x79\xd5\x60\xd0\xd1\xb4\
+\x9c\x04\xa2\xce\xaa\x12\x60\xf1\x6b\x0a\xcc\xf1\xeb\x6a\xab\x57\
+\x1d\x6b\x60\xd4\x2b\x98\x75\xb0\xa6\x73\x79\x75\x4d\x2b\x2b\x35\
+\xa6\xd5\xce\xb3\x61\xd6\x7a\xd7\x4c\x04\x31\x5e\x5d\x6f\x72\xff\
+\x81\xc9\xe6\xed\x0c\x95\x26\xb3\x5e\x08\xe0\xa4\x7f\x73\x46\x07\
+\xb7\xae\x72\x54\x16\x56\xc9\x72\xa0\x18\xd9\x39\x8d\x78\xb2\x3f\
+\xe0\x57\xbf\xf5\x4d\xde\xfd\xe6\xeb\xb4\xba\xde\x73\xe5\x42\x2b\
+\x6e\x14\x6e\x96\xc5\xfd\xd0\x09\xa8\x94\x6d\xd5\xbf\xc2\x65\x9c\
+\x78\x7f\x2b\x2c\x80\x71\x4c\x60\x36\x79\xeb\xfd\x6d\xfe\xf2\xb7\
+\xbe\x4a\x14\xec\x51\x8b\x7c\x8c\xad\x65\xfe\xd9\x7f\xf8\x25\x2a\
+\xeb\x5b\xb8\xd6\x3a\x4f\xf6\x86\xfc\xd5\x1f\xfc\x11\x1f\xbe\xf1\
+\x94\xc6\x64\x4c\x33\x35\x0b\x7a\xa1\x3b\xe4\xbc\x73\x4e\x98\x9f\
+\x2e\x5c\x79\x95\x15\x12\xae\x89\x5b\x1c\x27\x6a\xf8\xe4\x79\x30\
+\x8b\x5a\x41\x81\x97\x3b\x57\x60\x96\xcf\xeb\x00\x34\x8b\xc9\xac\
+\xb4\xa1\x9f\x4c\xdb\xf4\xac\x7c\x82\x9d\x6d\x7f\x84\xdf\x8f\x30\
+\x33\xe2\xc3\x2a\x95\x22\x97\xdd\x5d\x7e\xed\xd7\xbe\xce\xc3\xf7\
+\xcf\xa9\x5b\x55\x32\xd5\x0e\xc5\x46\x41\x9d\x24\xa5\x83\x62\xa3\
+\x04\xa0\x57\xb9\xa4\xda\x5f\x54\x4e\xfb\xfc\x7a\x5d\x39\xed\xcf\
+\xe3\x01\x8e\x85\xb5\x9b\xac\xad\x2d\x25\x81\xa2\x81\x59\x3d\xdf\
+\x33\x66\x8c\x3f\xfd\x39\xf9\xfc\xa4\x62\x25\xc0\x6b\x0d\x6c\xb2\
+\x7d\x9f\x6e\xd8\x4b\xfc\x0d\xf9\x19\x72\x2b\xf7\x97\x8f\x9b\x66\
+\xa4\x72\x28\xa4\xa1\x29\x35\xb3\x6e\xc0\xdd\xbb\x53\x60\x65\xa3\
+\xa1\xf4\xef\x3c\xe9\x20\xc1\xbb\x56\x79\x36\xa3\x8d\x9b\x0b\x63\
+\x9c\xd3\x48\x19\x74\x4f\xf6\x76\xf8\xea\x5f\x3c\xe1\xb5\xd7\xc6\
+\x9c\x1d\xb6\x55\xa2\x50\xdf\xf1\x12\xcc\x2b\xb5\x70\xe8\x04\x4a\
+\xf7\xca\xfb\x2e\x63\xda\x61\x87\x12\x39\xd1\x71\x33\x1a\x2a\x40\
+\xeb\x40\xae\x37\x2b\xfc\xc6\x71\xc4\xff\xf1\xab\xbf\x40\xe7\xbd\
+\xdf\xc4\x98\x74\x31\x87\x23\x3e\xfd\xc2\xdd\x04\x1b\xbf\xe6\x85\
+\xfc\xe1\xd7\xdf\xe4\x6c\xf8\x94\x61\xd6\xa3\xf7\xec\x50\x8d\x1b\
+\x96\x7a\xd8\x1c\x9d\xb3\xc0\x31\x46\x6e\x91\x1b\x05\x5f\x94\x27\
+\xf5\x23\x8c\xa0\xa5\x6a\xfb\x66\xfc\xec\xad\x62\x97\xa8\x3b\xc2\
+\x5e\x88\xb0\xc7\xcb\x53\x46\xd5\xf2\x89\x65\xef\x89\x84\x11\x61\
+\x99\x4a\x72\xd8\xfe\x28\x21\x19\x6c\x7f\x84\x77\x65\x24\xbc\x19\
+\x56\xa5\x42\xbf\x3f\xe0\x77\x7f\xe3\x21\x6f\xfc\xd9\x1f\xa9\x95\
+\x5d\xab\x0b\x4b\xd5\x30\xb7\x38\xe9\x8b\x6c\x2b\xe7\x34\xa2\x57\
+\xb9\x64\x74\xbe\xa2\x00\x7c\xec\x5e\xe0\x9c\x46\x1c\xbb\x17\xec\
+\x7e\xb8\x4d\xaf\x72\xc9\xee\xae\xc9\x72\x5b\x9c\xa0\xcf\x7d\xfc\
+\x0e\x9b\xf7\xee\xd2\xac\x37\xa6\xa0\x95\xe0\x8c\x8d\xb5\x19\x03\
+\x4e\xb2\x63\x7c\x5f\x02\x50\xa6\x48\xa6\x8b\x3b\xa5\x51\x27\xb3\
+\xd4\xe6\x97\xdf\xd8\x09\xe3\xad\x15\x1a\x34\x7b\x41\x82\xdd\xa5\
+\x61\x28\xd9\x77\xb3\x29\x3c\x10\x42\x03\x2f\xcf\x30\xf0\x59\x7f\
+\x90\x00\xaf\x8c\xc8\x25\x0c\xa3\xd3\x0d\xa2\xec\x19\xce\x69\xc4\
+\x1b\xdf\x9d\xf0\xee\x5b\x67\xfc\xc9\xdb\x8f\x79\xb2\xbf\x23\x7a\
+\xbb\x55\x44\xd7\x22\xa1\x69\x05\x98\x25\x20\xa5\x84\x90\x4c\x2c\
+\x25\x84\x18\x8c\x5e\x51\xdd\x8f\x64\x27\x23\xd9\x3a\x4b\x02\xd9\
+\x2c\x67\xa8\x37\x2b\xfc\xc9\x3b\x7d\x3e\xf8\x9d\xa7\x30\x38\xa5\
+\x6a\x3a\x98\x75\x93\xff\xe0\x27\xff\x96\x62\xe3\x56\xdb\xa0\xbe\
+\xd7\xe1\xc3\x37\x9e\xd2\xe9\x74\xa8\xce\x57\x4b\x4a\x4e\x1c\x0f\
+\x2d\x3a\x43\xf1\xe5\xda\xe6\xfc\x9e\x76\xa5\x30\x87\xd9\x1c\xd4\
+\x12\xac\x0a\xd0\x2a\x26\xa7\xf8\xb8\x91\xad\x80\xac\x8a\x49\x87\
+\x1e\x52\x8a\x78\x56\x1e\x23\x6e\x3d\x65\xfb\x23\xa2\x41\x97\x62\
+\x49\x48\x12\x2f\x77\x2e\x02\x24\x83\x90\xc7\x5f\xdf\xe3\xaf\xbe\
+\xf6\x8c\x52\x39\x4b\xa5\x70\x42\xa5\x2c\x9a\xf7\xad\x54\x27\xdc\
+\x5b\x8d\x30\xb5\x6a\x62\x09\x58\xb9\x55\x49\x2b\x71\x2f\x33\xe7\
+\x34\x22\xca\x9e\xa9\x7d\x72\xfe\x19\x9b\xb7\x37\x58\x5b\x5b\xc2\
+\x35\xc7\xb8\xce\x44\x48\x84\x58\xf3\xea\xf7\x13\x97\x7e\x4d\x3f\
+\x5b\x03\x5b\x31\xb0\xd2\xb4\x31\x20\x25\x98\xf5\x8c\xb3\x52\x59\
+\x44\xda\xe4\x7f\xdd\xeb\x20\xdf\x57\x33\xab\xb4\xaa\x99\xc4\xdf\
+\x95\x8d\x4f\x64\x16\x5a\xb6\x5a\xa0\xbc\xa1\x95\x86\xb5\x66\x59\
+\x58\x6a\xe0\xb3\xfe\x60\xc6\x2b\x21\x2f\xbd\x4f\xf6\x07\x7c\xf5\
+\x2f\x9e\xf0\xe8\x9d\x6d\xfe\xf4\xaf\x5a\xd4\xad\x2a\xcd\x5b\xf5\
+\x18\xb4\x05\x35\xfd\xb4\xef\x78\x54\xca\xb6\x92\x0a\x92\x91\x75\
+\x3d\x1c\x3a\x81\x6a\xdf\x25\x81\xad\xb7\xd2\x2a\x91\xa3\xa3\x8d\
+\xa8\x5b\xac\x2c\x11\x98\x4d\xfe\xed\x6f\xbe\x46\x6b\xe7\xf7\x94\
+\xb7\xe2\x53\x5b\x9b\x8a\x8d\xb3\xcb\x0f\x78\xcd\x0b\xd9\x3e\xde\
+\x65\x10\x57\xac\x67\xed\x1b\xca\xc5\x96\xbe\xe9\x57\xe5\x46\xd8\
+\x15\x72\xa2\x1f\x89\x0c\x39\xcd\xc6\x30\x13\xec\x19\xb3\xaf\x3d\
+\x5e\x4e\x30\x6b\x18\xb8\xaa\x82\x59\x37\xde\x24\x50\x75\x46\xf6\
+\xac\x3c\x5e\x54\x13\x9a\x7a\xa9\x4b\x25\x7f\x17\xdf\xb6\x79\xeb\
+\xdd\x0f\xf9\xed\xaf\xfe\x2a\xf8\x3b\x82\x2d\xe5\x17\x6d\x2e\x61\
+\x98\x5b\x1c\x0f\x2d\x56\x0b\x9b\x73\xf5\x90\xfa\xc2\x67\x01\xdf\
+\xce\x95\x67\x72\x04\xa2\xec\x19\x3b\x3b\xaf\xf3\xe2\xca\x33\x3e\
+\xf3\xc9\x2f\x2a\x00\xea\x5a\x77\x86\x7d\xe3\x4b\x7e\xa7\x16\x26\
+\x58\x52\xa5\x48\xc6\xc0\xd6\xfd\xb8\xe9\x5c\x07\x99\x4b\x9c\x76\
+\xb1\xe9\xef\x93\x0b\x60\x5e\x32\x7b\xf3\x56\xc4\xad\x1b\x36\x9f\
+\x5b\xa8\xb3\x5c\x58\x9e\x61\xe1\x46\x3b\xab\xc0\xbb\x5a\xd8\xe4\
+\xac\x3f\x48\x1c\x23\x63\xb2\xc2\x49\xff\x26\x67\xfd\x01\x3b\x7b\
+\x7b\xec\x6c\x9f\xf1\xed\xf7\x4e\xb9\xec\x65\xb5\x63\xdc\x8e\xbd\
+\x0a\xb6\xca\xfd\x10\x3d\xe5\x82\x84\x34\x90\x60\x95\xc0\x34\xcb\
+\x19\xfc\xe2\x28\xf6\x04\xe5\x14\x78\xf5\x4e\xa1\x4d\x6d\xd0\x47\
+\x2b\x6a\x29\xc9\xf0\x07\xff\xf7\x5b\x0c\xdd\x0f\x31\x26\x5d\x72\
+\x8d\xbc\xd2\xc6\x20\xfa\x2e\x77\xbf\x66\x72\xfe\x6c\xba\x10\xcf\
+\x3b\x42\x42\xcc\xbb\x45\x91\xd0\xc2\x41\xc7\x10\x72\xa2\x62\x50\
+\xca\x4c\x12\xc6\x9d\x39\x70\x85\x31\x37\x70\x3f\xba\x34\x4e\xd6\
+\xd2\xcd\xfc\xa1\x41\x97\x81\x2b\x00\x5d\xe8\x9d\x2b\x03\x51\xea\
+\xe3\xc9\xd1\x90\xdf\xfd\xc5\xd7\x68\x1d\x74\xd4\xc1\x14\xa5\x34\
+\xb0\x79\x3b\x43\xb9\xbe\xc3\x8d\x82\xaf\x80\x7b\x3c\xb4\x58\x68\
+\xef\xf1\xe4\xd4\xe0\x78\x68\xe1\x9e\x05\x9c\x0e\x77\xe9\xd6\xf2\
+\x98\x6c\xe3\x9e\x05\xea\x79\x79\x32\x8d\xc9\x0a\xce\x69\xc4\xc7\
+\x36\x2c\x9a\xf5\x06\x43\xdf\xa5\x63\x44\x09\x46\xcd\xd0\x55\x79\
+\x14\x12\xa4\xd9\xbe\xaf\x3c\x04\x7e\xd1\x23\xdb\xf7\x67\x8c\x3c\
+\xdd\xa7\x2b\x1f\xcb\x82\xd0\x34\x0b\x57\xcb\x83\x19\xd7\x9e\x5c\
+\x00\x19\xba\x6a\x18\x8d\xac\x44\x2e\x6f\x18\xb4\x96\x7b\x09\x16\
+\x96\xff\xdb\x8d\xe9\xc2\x3a\x1d\x8a\xa0\x46\x94\x3d\x53\xc0\x3e\
+\x1e\x5a\x98\x6c\xc7\x81\x8b\x6d\xde\xfe\xc0\x4f\x30\xa9\x04\x6d\
+\xa7\x2c\x1e\xf7\x1d\x8f\x86\x59\xc7\x65\xac\x58\x57\x9e\x0f\x09\
+\x54\xf9\x7c\xdf\xf1\x54\x42\x95\x64\x61\xd9\x9d\x53\x7d\xd7\x94\
+\x3e\x5e\xac\x2c\xd1\x6a\x1b\xbc\xfe\xce\xdb\x0c\x9f\xbe\x4f\x68\
+\xb6\xa9\x45\x7e\x42\x1b\x77\x5a\x7d\xde\x31\x77\x78\xed\x8f\xff\
+\x94\xe1\xc9\xb3\xb9\x78\x6a\xe4\x7d\x4e\x9c\x78\x40\xa4\x21\xb4\
+\x70\xaf\x59\xc5\x08\x5a\x49\x16\x0e\x46\xc2\x3b\x21\x19\xb4\x58\
+\x42\x79\x17\xd2\x99\x6b\xba\xac\xb0\x2a\x15\xac\x8a\x81\x67\x09\
+\xe0\x17\x4b\x60\x23\x7a\x32\xd8\x46\x57\xf4\x31\x5e\xea\xaa\x40\
+\x47\x7f\xf4\x94\x5f\xfb\xb5\xaf\x33\x39\x7f\x44\x76\xf9\xc1\x74\
+\x15\x9b\x43\xc5\xc2\x21\xa2\xd3\xbb\x04\xa8\xdb\xda\xe6\x20\x9a\
+\x10\x85\x3b\xd4\xba\x23\xba\xb5\x7c\x82\x81\xba\xb5\xbc\x7a\x5e\
+\xf7\x27\xde\x28\x2d\x51\x7e\x39\xc3\xad\xad\x57\xf0\x82\x20\x61\
+\x60\x89\xcc\xb5\x38\x49\x29\xe8\xab\xdc\x5f\xf9\x58\x82\x52\x37\
+\xd8\x66\x18\x3a\x7e\x6c\x0d\x6c\x8c\xa0\x9f\xe8\xe2\x23\x75\xae\
+\xac\xbc\xd0\x17\x81\xde\xea\x35\x43\x97\x5a\x46\x00\xf8\xfe\x03\
+\x53\x05\x75\x94\xad\xd1\x64\x46\x13\x57\xba\xb7\x66\xdc\x6a\x67\
+\xfd\x01\x6e\x6b\x9b\xf7\xde\x09\x78\xe3\xdb\xef\xf1\x64\x6f\xa8\
+\x64\x41\xb7\xd8\x57\x8c\x1a\x99\x15\xb2\xce\x58\xe9\x5a\x09\x38\
+\xc9\xbc\xb2\x62\x5b\xea\x5c\xf9\xbc\xde\xff\x58\xb2\xb0\x5e\x4d\
+\xa2\x7f\x9e\x32\x10\xa3\xa7\x64\xaa\x1d\xbe\x75\x60\xf1\xc1\xef\
+\x3c\xc5\x74\x46\xc2\xc8\xd3\xb4\x71\x76\xf9\x01\x97\x3d\xb1\xe8\
+\x5e\xff\xf6\x37\x94\x61\x97\x0e\x7c\xac\x95\x0d\xdc\xb3\x80\xa8\
+\xd2\xc4\x08\x5a\xd0\x8d\x65\x5e\x26\x36\xa4\x8b\x39\x4a\x99\xbc\
+\xf0\x4e\xd8\x46\x97\x68\xd0\x55\x6e\xb5\xc2\x45\x2d\x61\xbc\xc9\
+\x66\x28\x6e\x24\xaa\x9a\xc3\x41\xa8\x5e\x93\x72\xa2\x15\xf9\x71\
+\xe2\xce\x94\x81\xbd\xdc\x39\xfd\xd1\x19\x5f\xff\x8d\x90\x87\xef\
+\x9f\x93\x5d\x7e\x40\xa5\x70\xa2\x19\x3c\xe2\xa0\xe4\xce\x2f\x71\
+\x5b\xdb\x6c\x1f\xef\xd2\x6f\x4d\x07\xf0\x19\xe6\xd6\xf4\x72\x11\
+\x6b\xe5\x5a\x77\x44\xc8\xfd\x84\x76\x06\xd1\x9f\xe0\x46\x69\x89\
+\x5e\xe5\x92\xd5\xae\xc9\x46\xa3\x45\x79\xb1\xa9\xdc\x57\xd2\xa3\
+\x20\x7d\xbb\x72\x4b\xaa\xf8\x72\x52\xb1\xa6\x9a\x38\x96\x14\x92\
+\x45\xab\xbe\x93\x78\x8f\x94\x11\x12\xf8\xf5\xc8\x98\x61\xef\xf4\
+\x63\x05\xe0\x8d\x86\x1a\xdf\x25\x01\x2c\x41\x2b\x59\xb8\xd1\x9e\
+\x32\x4e\x71\xfd\x32\xa1\x89\x85\xf7\x21\xab\xe4\x03\x7d\x61\xfd\
+\xcb\xa0\x85\x6c\xb6\xdd\x29\x43\xd6\x19\x33\x29\xe7\x14\xf0\x74\
+\x90\x96\xc8\x29\xb6\x95\x3a\x57\xbe\x26\x41\x9a\xbe\xf5\x8d\x02\
+\x7e\x71\xa4\x5e\x4b\xba\xec\xaa\x6c\x36\x57\xe9\x5e\xb5\x79\x6b\
+\xcf\x65\xec\xff\x99\xd2\xc6\x77\x63\x6d\x3c\x39\x7f\x84\x6b\xad\
+\x27\x5b\x2a\xd8\x70\x9a\xba\xc8\x1b\xb9\x45\x4a\x2b\x19\x8c\x7e\
+\x8b\x28\xd3\x24\xac\x76\x84\x9b\x2d\x66\xe2\xd2\x60\x3c\xf5\x13\
+\x7b\x51\x2d\xa1\x71\x8b\x25\x91\x18\x5f\xb1\x4c\xdc\xc8\x06\xca\
+\x98\x99\x92\xea\x02\x34\xf5\xaf\x65\x12\x39\x16\xc5\x12\x4a\x3e\
+\xb4\x27\x36\x95\xfc\x0a\xdd\x77\x07\x22\x86\xee\xef\x30\x29\x1c\
+\x29\x57\x4e\x8b\x80\xa6\x39\xe4\xd4\x83\x0f\xdc\x36\x67\xbd\x2c\
+\x67\x3d\xf1\xe5\xa2\x70\x87\xb3\x5e\x56\x0c\xe3\xcb\xdc\x4a\xb0\
+\x70\xb7\x96\xe7\x46\xc1\x27\xe4\x7e\xc2\x11\x0e\x28\xe3\xef\xd0\
+\x35\x58\xad\x6f\x24\x7c\xc0\xf3\xd8\x75\x5e\x70\xc2\x08\xfa\x09\
+\xc3\xad\xea\x3b\x8a\x59\x7b\x56\x99\x52\x39\xab\xc0\xac\x03\x35\
+\xad\x87\x75\x2f\x87\xee\xda\xab\x65\x6a\x34\x6b\x36\x6b\x65\x43\
+\xb9\xd2\xce\x87\xe7\x09\x63\x4e\xb2\xf0\x41\x34\x49\xb0\xae\x2e\
+\x37\x9e\xec\x65\x79\xf2\xf4\x30\x21\x1f\x24\x40\xa5\x1c\x70\x19\
+\x2b\x00\xeb\x06\x9b\x04\xb4\xce\xc6\xe9\xed\xdc\x3a\x40\x5f\x74\
+\xd6\x9c\xf8\x43\xd5\x99\x3e\xbd\x7f\xa7\x4c\x9c\x8b\x01\x27\xef\
+\xfc\x25\x7f\xf5\x97\x21\x70\x85\x31\xe9\x72\xb7\x9e\xe1\xcb\x3f\
+\xf4\x22\xcd\x4f\xff\xdd\xf8\x12\x71\x83\xb3\xb8\x6d\x47\x1a\xc0\
+\x13\xef\x38\xf1\x9c\x11\xb4\x30\x0d\x69\x0b\x39\xb8\x41\x16\xb7\
+\x38\x0d\x6c\x99\x00\x5e\x54\x53\x8d\xb5\x3d\x2b\x8f\x9b\xcf\x29\
+\xc0\xda\x9e\x8b\x59\x14\x4d\x54\xb2\x14\x09\x03\x57\x05\x33\xa4\
+\x9c\x90\x1e\x0a\x29\x45\x1a\x59\x8f\xd3\xc3\x36\x7f\xfe\x8d\xc7\
+\xe0\xef\x80\x15\x5b\xa7\xce\x98\x6e\xb1\x2f\x1c\xeb\x61\x81\x95\
+\xcc\x34\x59\x7b\x83\x67\x9c\xf5\xb2\xe4\x2f\xab\xac\xc4\x3d\x74\
+\x4b\x2b\x99\x84\x85\x7a\xa3\x20\x1a\xde\x01\x8c\x4e\x8e\x66\x13\
+\xaa\x4f\x23\x96\xdb\xed\xc4\x68\xd5\xeb\x8a\x2f\x55\xb2\x79\xec\
+\x41\x90\x2d\xa3\x74\xab\x37\x30\x9b\x33\xb9\x0f\x41\xbd\x81\x5f\
+\xf4\x12\x0b\x62\x52\xb1\x12\xbe\x66\xe9\x86\xd3\x17\x49\xa6\xda\
+\x49\x64\xa3\xe9\xf9\x21\x69\x26\xd6\x1f\xa7\x75\xf2\xee\x7e\xc0\
+\xa3\x77\xb6\x39\x39\x0a\x12\xec\x28\x99\x31\xcd\xb4\x52\x4a\x28\
+\xd7\xa1\x33\x9e\xd9\x6f\xc6\x80\x8e\x35\x70\x1a\xa4\x12\xc8\x66\
+\xd4\x4b\x68\x6f\xa9\xb9\xf5\xc5\xf2\x9a\x17\xf2\xc1\x6b\x5f\xe3\
+\xea\xd1\xd5\x54\xeb\xbe\xf2\xb2\x62\xe3\xcb\xfe\x85\xaa\x9b\xd4\
+\x6f\xa7\x9e\xf0\x58\xe8\xd8\x88\x32\xcd\x79\xe9\xf3\x74\x7a\x3e\
+\x54\x23\x21\x27\x8a\xa5\x64\x32\x4f\x18\xb8\x62\xc8\x4c\x51\x54\
+\x2d\xdb\x9e\x41\xce\xb8\x4a\xf8\x81\x7d\x1c\x8c\x5a\x1e\x8b\xa9\
+\xb7\x40\x32\xf1\x65\xa7\xc3\x77\x7e\xe7\x1b\x3c\x7c\xef\x4d\x4a\
+\xe4\x98\x14\x8e\x14\x2b\x58\x83\x7c\xac\xc3\xda\x53\xf1\x9e\x7b\
+\xc6\x21\xc2\x47\x3c\x5a\x14\xc3\x03\x6f\x64\x6e\xcd\xb8\x90\xdc\
+\xb3\x80\x4a\xf7\x16\x83\x4e\x40\xbb\x31\xa1\xd6\x1d\x71\x3a\xdc\
+\x4d\x78\x32\x0e\x83\x52\xa2\x9b\x4c\x3a\xa0\x21\xc1\xaa\x4b\x0a\
+\xf9\x5a\xda\x7d\xe6\x9a\x63\xaa\xe5\x41\xc2\x78\xd3\xc1\x2e\x19\
+\xb7\x1e\x89\xd2\xf1\x6e\xd8\x4b\x84\x91\x75\xc6\xae\xd5\x6b\x6c\
+\xd5\xfa\x8a\x81\xd3\x01\x0d\xdd\xad\x26\xef\x4b\xe0\x02\x9c\xf5\
+\xb2\xec\xee\x07\xca\xfb\xa0\x03\x71\xe2\xcf\x02\x2e\x0d\x52\xe9\
+\x69\x90\x7e\x62\x5d\x36\xcc\xc4\x00\xa2\xa4\x01\xa7\x37\xf4\x96\
+\xc6\x9d\x94\x1b\x69\xf6\x07\xa8\x2c\xde\xa6\x7b\xd5\xe6\xf5\x77\
+\xde\xc6\x3f\x79\x08\x03\x11\x02\xff\xfc\xed\x1a\xaf\xbe\xb8\x44\
+\x76\xf9\x01\xae\xb5\x4e\x7f\xb8\xc6\xa4\x37\x64\x74\x3a\x5d\x90\
+\x2b\x99\x4b\xa5\x93\xd3\x1e\x2a\x11\xb1\x2b\x53\x1a\x8c\x99\xb8\
+\x19\xea\x55\x2b\xd6\xc4\x2c\x10\x0d\xba\x2a\x60\x21\xdd\x65\x22\
+\xe1\xa7\xac\x65\x45\x15\x15\x3b\x5b\x94\x45\x07\x79\x3f\x1b\x97\
+\x33\x25\xb3\xd6\x76\x8f\x1c\x5e\x7f\xa7\x05\xd6\x56\x22\x46\xdf\
+\x8c\x5b\xde\x34\xcc\x88\x96\xd6\x01\xaa\x79\x3e\x8d\xc7\x4b\x29\
+\x71\x1c\x1c\x70\x3c\xb4\x14\x48\x4d\xb6\x39\x89\x2c\x8e\x83\x03\
+\xa2\x70\x87\x7e\x0b\x8e\x83\x03\x2a\xdd\x5b\xca\x7a\xd7\xeb\xb4\
+\xb2\x7d\x3f\xd9\xc0\x4f\x73\xaf\xc9\xfc\x07\xbd\xe2\xb8\x14\xe6\
+\xe6\x06\x30\xf4\x26\x28\x52\x2f\x4b\xc3\x50\x06\x36\xf4\x90\xb4\
+\x0c\x43\xeb\x4c\xdd\xac\xc3\x67\x1a\x3e\x85\x17\x85\x4b\x50\x4a\
+\x88\xe7\xdd\x74\x50\x9f\xf5\x84\x7c\xf8\xf6\x7b\xa7\x74\xfc\xa4\
+\x01\xe6\x32\x4e\x34\x51\xd1\x8d\x2e\xb9\x9f\xae\x7d\xe7\x01\x3d\
+\xdd\x02\x40\xba\xd2\x74\x96\x96\x7f\x23\x6b\x89\xd7\x24\x53\xeb\
+\xfe\x62\xfd\x6f\x06\x66\x93\x6f\x1d\x58\xec\xbe\xf9\x94\x8b\xc3\
+\x7d\x8c\x89\xb0\xbb\xbe\xf0\x7d\x2f\x2b\x77\x5b\xc9\x3f\x52\xa1\
+\xeb\xd0\xbb\x20\xf4\x2e\x30\x72\x8b\xb3\xdf\x33\x0e\x37\x8b\x88\
+\x9d\x43\x27\x0a\xc8\x96\xa6\xc0\x37\x3b\x97\x27\x4a\x1a\x78\x57\
+\x46\x22\xf9\xc7\xf2\x2e\x54\x98\x59\x6f\x6f\x35\x4d\x49\x9b\xad\
+\xd6\xbd\x68\x89\x1f\x5b\xbe\xd9\x67\x52\x38\xa2\xef\x78\xea\x12\
+\xd6\x8e\xbd\x03\x7d\x47\x4c\xa3\x97\xfd\xcd\x74\x17\x93\x3c\x69\
+\xf9\xcb\x2a\x6e\x6b\x9b\x7e\x4b\x18\x74\xfd\x96\xd0\xcb\x72\xa2\
+\xbc\xdc\x9e\x44\x02\xe0\x12\xcc\x1b\x19\x97\xa8\x78\x53\x01\x4e\
+\xca\x87\xeb\x72\x22\x54\x10\xc4\x1c\xcf\x78\x27\xd2\x59\x68\x3a\
+\x78\x3b\x46\xa4\xb2\xd7\xa6\x33\x9c\x67\x33\xe7\x36\x6a\x59\x56\
+\xea\x0d\xfc\xd2\xb2\x92\x0f\xd7\x25\xf6\x28\xbf\x69\x0c\xf2\xf3\
+\xe1\xb9\x02\xf0\xd9\x61\x5b\x8c\x5b\xb0\x92\xb3\x42\xd2\x63\x0f\
+\xd2\x0c\xab\xdf\xaf\x94\x87\x6a\xd6\xc8\x3c\xcd\xab\xfa\x18\xc7\
+\x21\x6a\x1d\xe4\xb2\x45\x01\x88\x76\x01\x62\xc2\xd3\x73\x16\x45\
+\x4c\x1a\x27\x1f\x3e\xc3\xcd\xf7\x08\xcd\x36\x95\x7c\x86\xc6\x0b\
+\x5b\xca\xdd\xe6\xb4\xe4\x57\x92\x00\x00\x20\x00\x49\x44\x41\x54\
+\x5a\xeb\xca\x28\x3c\xeb\x88\xf6\x62\x69\x7d\x3c\xe2\x4c\x85\x9b\
+\xaf\x8a\x13\x26\x6e\x66\x0a\xe0\x58\xd6\x9a\xe1\xc2\x92\x72\x8f\
+\xd9\x86\x08\x41\xcb\x00\x86\xcc\xfd\x95\x00\x96\x92\x43\xb2\x6f\
+\x1a\xd8\x51\x77\x44\xe0\x4e\x3d\x10\xd9\xe1\xba\xba\x94\x4d\xfc\
+\x61\x82\x0d\x4c\x6b\x05\xfa\x10\x8d\x2f\x71\xcf\x16\x18\xb4\x87\
+\x0c\xda\xe2\x00\x0e\xda\x43\x3e\x70\xdb\xf8\x07\x43\xce\x7a\x59\
+\x8e\x83\x69\x0b\xcd\x83\x9c\xc7\x59\x2f\xcb\x68\xb1\xa7\x0c\xc1\
+\x4a\xf7\x16\xfd\x9a\x60\xee\x5e\xe5\x92\xcd\xdb\x1b\x2c\x65\x92\
+\xbd\x80\x75\x60\xea\x9a\x55\x07\x72\x9a\x89\xd3\x41\x8c\x74\xe2\
+\x8f\x8c\xcc\xb9\xce\x44\x19\x80\xd5\xf2\x80\x6c\xdf\x27\x43\x97\
+\x6a\x79\x30\x63\xc8\xcd\xbb\x55\x9a\x49\xe0\x4a\x83\xcf\x3d\x5b\
+\x50\x00\x16\x33\x38\x0a\x33\xc0\x9b\x07\x64\x1d\x4c\xba\x97\xa1\
+\xef\x14\x94\xbf\xf7\x3a\xa3\x4d\xee\xa3\x0f\xd6\x91\x7f\xb7\x1e\
+\x19\xea\xb1\x7e\x25\xa8\x3b\xd3\xbf\x23\x3f\xbb\x6e\x55\xe9\x06\
+\x5d\x1e\x05\x63\xf2\x7b\x87\xca\xc0\x03\x78\xf5\xc5\xa5\x44\xa4\
+\x4f\xca\xa3\xe3\xb1\xa7\xb4\xf0\x89\x13\x71\xa3\xe0\x33\xf1\xb7\
+\xb8\x8a\x9b\xa9\x64\x5c\x93\x6c\x29\xa0\x34\xc8\x31\x71\x33\x8a\
+\xa1\x55\xc4\xce\x8b\x6a\x78\x51\x0d\xdb\xe8\xce\x00\x73\xc6\x8f\
+\x37\xb1\x67\xb6\x97\x9d\x0e\x57\x91\xc7\xee\x91\xc3\xde\x5b\xef\
+\x63\x5c\x39\x4c\x0a\x47\x31\x18\xf2\xea\x80\xe8\x07\xb0\x1b\x74\
+\x39\x71\xa2\x38\xed\xee\x4a\x01\x58\xe9\xdb\x28\x8b\x91\x7b\xa6\
+\xd8\xf9\xac\x97\xe5\xd6\xd8\xe6\xd6\xd8\x56\xde\x0c\xc3\xdc\xe2\
+\x38\x38\xc0\xe9\x6c\xb1\xd0\xde\xe3\x9d\xb7\x77\x18\x9e\x3c\x53\
+\x56\xb8\x0e\x44\x09\x60\xd1\x10\xdb\x4b\xe4\x44\x74\x6a\xa1\x8a\
+\xac\xcd\xcb\x87\x48\x34\x3d\x29\x67\xc9\x74\xda\xca\x07\xac\xbf\
+\xa7\x15\x1a\xca\x2d\x27\x73\x22\x9e\x07\xe0\xf3\xe1\x79\x42\x3a\
+\xc8\xe7\x9c\xc3\x88\xe3\xd6\x05\x8f\xf7\xf6\x12\x43\x67\xf4\x63\
+\x98\xb5\x0a\x33\xcc\x3c\x4f\xc7\xea\xa0\xee\x1b\x05\x05\x58\xf9\
+\x3f\x6b\x15\x08\xfd\xb3\x29\x90\x8d\xe7\xb3\xfd\x75\x8b\xa6\xe3\
+\xf7\x94\x7d\x61\x46\x3d\xe8\x84\x1c\xb7\xb6\xd9\xdb\x1f\x13\xb6\
+\x62\x9f\xb8\x0d\xab\x8b\x0b\x4a\x52\xe8\x89\x48\x0b\xed\x4b\xce\
+\x02\x21\x27\xa4\x0b\x72\xc8\x10\xc3\x89\x08\x4a\x71\x43\x1f\x37\
+\xa3\xe4\xc4\xc4\xcd\x4c\x2b\x3b\x8e\xc2\x9c\x02\xaf\x04\xb2\x8c\
+\xbe\x19\xb5\xfc\x0c\x90\x0b\xa5\x7d\xe5\x85\xf0\x72\xe7\x34\xb2\
+\x02\x08\x12\xc0\x0f\xdf\x7b\x93\x16\xc2\x5a\xd5\x5d\x3a\xfa\x41\
+\x50\x07\xa8\x37\xe4\xc4\x89\x70\x0e\x93\x55\x21\xd1\x58\xac\xc8\
+\xf5\xb1\x00\xb0\xf4\x58\xe8\x65\x49\x80\x1a\x15\x15\x85\x3b\x7c\
+\xcb\x13\x1e\x8e\xa7\x1f\xfe\x85\x00\x9f\xd6\x32\x55\xca\x00\x1d\
+\xc0\x7a\x80\x43\x1a\x75\xe9\xe0\xc6\x3c\x9d\x2c\xbd\x14\x7a\x25\
+\xb5\x9e\x23\x0c\x62\x08\xa3\x34\xe4\x74\xc6\xfd\x28\xf9\x20\x82\
+\x37\x0b\x7c\xe7\xa8\xc5\xd9\x61\x5b\x31\xbc\xce\xc2\xcf\x03\xae\
+\x0e\xcc\x79\x52\x43\x67\x57\xfd\x33\x03\x6a\xaa\x29\xb7\xfe\x19\
+\xe9\x5b\xa2\x03\xe7\x75\xee\xb8\xd6\x48\xc9\x8d\xc3\x68\x89\x63\
+\xf7\x82\xf6\xd9\xd4\x0b\x51\xbf\xbb\xce\xad\xaa\xa3\xc2\xd5\x7a\
+\xec\x40\xf7\x56\x1c\x0f\x2d\x2a\xd6\x31\xa6\x51\x26\xe3\x9a\x04\
+\xa5\x90\xba\x91\x21\x28\x85\xd3\x8c\xb6\x6a\x24\x40\xbc\x60\xd8\
+\xd0\xac\xce\x0f\x29\xc7\x3d\x29\xa4\xfb\xac\x3d\xb1\x95\x17\x22\
+\xea\x8e\x18\xba\xb7\xb9\xec\x08\x2b\xcd\x3f\xda\x65\xbf\xfb\x14\
+\xac\x2d\x31\x32\xab\x3c\xbb\x72\x3b\x86\x68\x3b\x25\x0f\x5c\xab\
+\x3b\x1d\x50\x28\x81\xab\xdf\x0e\xb9\xc9\x4a\x75\x32\x03\xe4\x85\
+\x4e\x9f\xdd\x7d\x41\x51\xbb\xfb\x01\xbb\xfb\x01\xcd\xf3\x2a\xee\
+\xd9\x11\x7f\xfe\xc1\x00\x3a\xbd\x19\x8d\xab\x1b\x67\x12\xd0\xcf\
+\x73\xc3\xc9\xe8\x9c\x0e\x64\x09\x6c\xf9\x79\x3a\x80\xd3\xfe\xe0\
+\xc2\x8b\x2b\x09\x0d\xac\x33\xee\xf9\xf0\x3c\x61\xe0\x45\xe3\x38\
+\x83\xef\x30\x62\x7f\xef\x50\x69\xcf\xeb\xd8\xef\xa3\x9e\xbf\x8e\
+\x34\xd2\x8b\x20\x0d\xe4\x34\x18\xaf\xfb\x7b\x92\xad\x13\x2e\x3a\
+\x2d\x53\x50\x1a\x77\x67\x87\x6d\xe5\x0e\x0d\xcd\x27\x54\xf2\x19\
+\x6e\xd7\x16\xa8\xac\x88\x41\x06\xd1\x82\x00\x49\x7f\xb8\xa6\x48\
+\x4d\x77\xa9\x4e\xfc\x2d\xea\x46\x3c\xd0\x87\x88\x4e\x14\x90\x71\
+\x4d\xc5\xc6\xae\x33\xc1\x1c\x2e\x75\xb9\x8a\x3c\x91\x37\xbc\x94\
+\x64\x63\x19\x42\x8e\xba\x23\x15\xc9\x2b\x94\xf6\x13\x09\xf4\x6b\
+\x76\x5b\xb1\xf0\xd1\x33\x0f\xe7\x59\x05\xfc\x1d\x2a\x65\x9b\xc6\
+\x42\x8d\x97\xd6\x56\x55\x7a\xa4\xd4\x55\xed\x7e\x98\x90\x14\xad\
+\xae\xa7\xdc\x6d\x3a\x90\xa3\xf1\x25\x46\xee\x19\xfe\xc1\x50\x49\
+\x0a\x29\x39\x0e\xa3\xd8\x30\x3b\x9b\xfa\x8b\x0f\x46\xe2\xfb\x77\
+\x3a\x7d\xae\x3a\x9d\xb9\x27\x54\x7a\x0f\xd2\x0c\xab\x3f\xd6\x19\
+\x3a\x1d\x8e\xd6\x47\x7a\xc9\x5c\x0b\x23\xe8\x8b\xdf\x17\x37\x38\
+\x59\xd9\x68\x70\xfb\xce\xc6\x47\x1a\x6e\xd3\xc4\xa6\x05\x8c\xdc\
+\x33\x9e\xee\x2d\x70\xe2\x44\xec\xb6\x4e\x13\xde\x9b\xff\x3f\xc0\
+\x9d\x07\xc4\xb4\x1c\x79\xee\xe7\xc5\xf3\xf0\x5c\x67\x22\x16\xaa\
+\xe6\x07\xd7\x59\x5e\x77\xf3\x51\x8d\x12\x95\x31\xcd\x46\x44\xf7\
+\xaa\xcd\x69\xf7\x19\xfe\xc9\x43\x25\x29\xac\x85\x29\x61\x3a\xcf\
+\x84\xbb\x52\x46\x73\x2f\x7b\x59\x46\xa7\x41\xc2\x4b\xd1\x89\x02\
+\x25\x25\x80\x84\xb4\x28\x95\xb3\x98\x7a\x98\x59\x32\xac\x04\xb0\
+\xfe\x9c\x64\x63\xf9\x58\x26\xd0\xb7\x4d\x21\xba\xf7\xf7\xb6\x71\
+\x76\x0f\x15\x80\xa3\x85\x32\xb7\x6f\x35\xd8\xbc\x77\x97\x5b\x5b\
+\xaf\xd0\xa9\x85\x73\xfd\xb1\x41\xaf\x1e\x5b\xa7\xc2\x6f\x7c\xe2\
+\x44\x09\x0b\xd5\x39\x8c\x38\x8c\xb2\x0c\xda\x43\xdc\xb3\x23\xdc\
+\xb3\x23\xa2\xf1\xa5\xfa\x2f\xc1\x2e\xef\x97\x56\xd6\xe7\xea\x5a\
+\xbf\xe8\x31\xa9\x58\x89\x82\xcf\x79\x60\xd6\xbf\x9f\x5f\xf4\x04\
+\x40\xb5\x1c\x60\x1d\xc0\x51\xa6\x92\xa8\x93\xcb\x54\x3b\xa2\xbc\
+\xa8\x6c\x50\x5a\xb9\x9a\x09\x64\xe8\x00\x96\xf2\x49\xdf\x9e\x9c\
+\x3c\xe6\xd1\x9e\x90\x10\x59\xab\x90\x60\xf9\xef\xe5\xfe\x5f\x07\
+\xe8\xcf\xf3\x6e\x48\x63\x57\x5e\x6d\x16\xa2\x5e\x02\x9c\xcf\xfb\
+\x6c\x5d\x8e\xf5\x8d\x02\xd4\x4d\x06\x9d\x2a\xef\xb5\x8e\xe3\x64\
+\xad\x2e\xb5\xb0\x97\x30\xee\xd2\x49\x4b\x18\xc7\x1c\xb7\xa6\xb2\
+\x22\x8c\x92\x25\x5e\x19\xad\x35\x82\xeb\x4c\x84\x9c\x58\x37\xc7\
+\x44\xdd\x91\x48\x8e\x37\xba\x1c\xc5\xa5\x3b\x92\x99\xa5\x2e\x96\
+\x00\x1e\x2e\x75\x29\x5c\xd4\x54\x9e\x84\x7f\xd2\x21\x3a\x9b\xb0\
+\xdf\x7f\x06\xd6\x16\x2b\x75\xb8\x91\x13\x27\xdb\x58\x0d\xb9\xf3\
+\xb9\x8f\xb3\x94\x7f\x89\xa3\xc9\xe5\xcc\x6a\xcf\x54\x3b\x62\xfe\
+\x71\x1f\xe5\x72\x5b\xc9\x08\x81\x2f\x45\xbe\x0e\x52\x79\x93\xcc\
+\x9d\xde\xee\x1c\x0f\xa1\x5e\x55\x1d\xd9\x75\x90\xea\x7a\x38\x3d\
+\x1c\x66\x1e\x2b\xeb\xaf\xe9\xc0\x4e\xcb\x11\xd7\x99\x90\x09\x5b\
+\x6c\x36\x57\x79\x75\xbd\xa9\x74\xb0\x1e\x85\x3b\xeb\x65\x95\xc1\
+\x26\x81\xbb\xeb\x0f\xd4\xef\xfb\xce\x51\x04\xfd\x24\xc8\xe4\x40\
+\x46\x79\x05\xd1\xef\xcf\x2b\x8f\x9a\x07\xe8\x4e\x2d\x7c\x2e\xd8\
+\xaf\x03\xa2\xaa\x02\x8f\x8d\xd5\xef\x65\x41\xe8\x59\x83\x7a\x6e\
+\xf5\x71\x4b\xe4\xba\x48\x5d\x1c\x99\xd5\x19\xe3\x4e\x37\xf0\x2e\
+\x7b\x59\x65\xd8\x95\xad\x64\x7a\xa5\x04\xb4\xdc\x2a\xc3\x4e\xca\
+\x07\xc9\xc0\x0b\x86\x9d\xd0\xc4\x51\x77\x34\x95\x1a\xb9\x73\x05\
+\x60\xc9\xc6\xbb\xfb\x87\x7c\x67\x47\xf4\x98\xbd\x6d\x8f\x30\xed\
+\x25\xb2\xab\x05\xd6\xcb\x37\xb9\x73\xcb\xe2\xde\xc7\xee\xf3\x89\
+\x1f\xbd\x49\x79\xb1\xa9\x26\xd1\xab\xd0\x6e\xac\xc3\xe4\x20\x6f\
+\xc9\xc8\xd2\xf9\x2d\xd9\x19\xe0\x2c\x58\x54\xf7\xd3\x80\x9e\xf4\
+\x86\x1c\x1c\x7b\x9c\x9c\x3c\xc6\x08\x45\x86\x59\x7a\x98\x8b\xee\
+\x61\x90\x1e\x04\xbf\xe8\xcd\x14\x73\x4a\xd6\x95\xfb\xcb\x13\xa3\
+\xfb\x8d\xf5\xc7\x55\xdf\xa1\xb6\xd0\x48\x78\x22\x96\x0b\xcb\xf4\
+\x5b\x53\xe6\x35\x72\xcf\x70\x0e\x23\x1e\xfb\xcf\xd4\x6f\xf0\xb7\
+\x0b\x9c\x38\x11\xdf\x39\x6a\xd1\x0e\x3b\x4a\x03\x77\x8c\x68\x2e\
+\xe8\x74\x20\xab\x63\x28\x2f\xf7\xa9\xd7\x75\xf9\xa6\x6f\xbf\x57\
+\x30\xa7\xf3\x4e\xbe\x17\xb6\xd7\x17\x94\x7c\x6d\xe8\xbb\xec\x74\
+\x2b\x38\xa7\x11\x9d\xa1\x43\x68\xb6\x29\xd8\x49\xe3\x4e\xea\x61\
+\x3d\xc3\x4e\x1e\xa3\xab\x8e\x99\x00\xad\x69\x94\x09\x23\x47\xe5\
+\x52\xa8\xa4\x78\xf3\xea\x82\xa3\x30\xc7\xe8\x72\xac\xbc\x14\x57\
+\x91\xa7\x74\xb0\x64\x5c\xc9\xc6\x92\x99\x0b\x17\x35\xae\x22\x8f\
+\xa3\x67\x22\xa0\x51\x29\xdb\x64\x6b\x49\x7f\xd1\xde\x81\x4f\xe0\
+\x9e\xb0\xbe\x6e\x26\x58\x2d\x1d\x7c\xe8\x39\x45\xba\x9d\xee\x8c\
+\xb8\xd7\x81\x2a\x2d\x57\xf9\x03\x0f\x8e\x85\x51\x38\xe9\x0d\x69\
+\x85\x9e\xf8\xdf\x81\x4e\xa7\xab\x66\x64\x5c\xc7\xb4\x3d\xa7\x48\
+\xd5\x77\xc4\x90\x18\x6d\x30\xcc\xdc\xf0\x73\xaa\xbf\x84\xee\x72\
+\xab\x96\x07\x50\x37\x55\x7d\x5c\x22\x68\xb3\x28\x02\x30\x6f\x39\
+\x7b\x42\x2e\x38\x11\x85\x73\x41\xcf\x8f\xfd\x67\x6a\xd1\x02\x6a\
+\xf6\x47\x1a\xb0\x3a\x30\x5d\x67\xa2\x80\x22\xbf\xe3\x44\x1b\xa1\
+\x9b\xb8\x55\x93\x8f\xd3\x2c\x9e\xce\xed\xb8\x8e\x91\xd3\x36\x41\
+\x22\xd3\xac\x6a\x24\x5d\x79\x73\x3e\x6b\x99\x88\x56\xd7\x53\xc6\
+\x9d\xe9\x8c\xa8\xe4\x33\x34\xfd\x48\x19\x77\xa5\xb8\xff\xb4\x64\
+\xe2\x79\x9e\x0f\x09\x5a\x09\x60\x5d\x62\x98\x57\x91\xc7\x45\xb3\
+\xcc\xba\x29\xa6\x8a\x1e\x85\x39\xae\x22\x8f\x75\x73\xcc\x55\xe4\
+\xa9\x5c\x08\xdb\x17\x6c\xdc\x9e\xd8\xca\xb0\x1b\x2e\x75\xf1\x2f\
+\x2b\xec\x77\x9f\x72\x11\x78\x44\x0b\x65\xf2\x9b\x1b\x64\x57\x85\
+\xe5\x6a\x0c\x9e\xc1\xce\x09\x4f\xf6\xde\xe5\xe8\x28\xa4\x5e\xab\
+\xcd\xd5\x4f\x32\xdf\xb6\x15\x1a\x74\x3b\x5d\x76\x5b\xa7\x2a\xc3\
+\x49\x02\xba\x5f\x38\x56\xf7\xd3\xc0\xdd\xef\x45\xf4\x9d\x42\xa2\
+\xc9\x89\x1c\xee\x22\x07\x1e\x02\x34\x7b\x41\x82\x8d\x75\xf0\xce\
+\xd3\xc9\x7a\x7e\xc5\xf3\xea\xea\x36\x9b\xab\x33\xa9\x95\xe7\xc3\
+\x73\x31\xfc\x1c\x31\x10\xf2\xc4\x89\x38\xeb\xb4\x69\x85\x62\xe1\
+\x15\xce\x9b\x9c\x75\xda\xb4\x43\x23\x61\xc4\xe9\x40\xd5\xb7\x7a\
+\xf1\xaa\x7e\x5f\x26\xf5\x1b\x41\x3f\x31\x0b\x5a\xff\xde\xf2\x33\
+\x25\x6b\xcf\x63\x58\xd7\x99\x90\xa1\x9b\xcc\xc0\x0b\x73\x2a\x45\
+\x75\x1e\x80\x75\x03\x7d\x26\x33\xb0\x27\x00\x1e\xd4\x1b\xca\xb8\
+\xeb\x5f\x5e\xe0\x8f\xe3\x29\x5c\x0b\x9a\xe1\xd6\xea\x27\x24\x45\
+\xdf\x28\xa8\x73\xed\xc5\x73\xf5\xc2\xc8\x49\x00\x58\x07\xb2\x59\
+\x5a\x1e\xb3\x58\xaf\x2b\x1d\xbc\x6e\x8e\x59\x30\x6c\x8e\xc2\x9c\
+\x02\xf2\x82\x61\x73\xe8\x08\x66\x96\x3e\x62\x10\xb9\xc7\xd6\x62\
+\x1f\xc3\x78\x85\x7a\x64\x28\x1d\xac\xdc\x63\xa1\xd0\xa8\x3b\xaf\
+\xef\x32\xde\x13\xef\x93\x39\xbe\xe9\x03\x23\x67\xba\x49\x40\x77\
+\x3b\x7b\x89\x93\x2e\x26\x16\x4d\x99\xab\x15\x7a\xf1\x7e\x5d\x11\
+\x12\xed\xf4\x13\x4c\x20\x87\xbb\xe8\x33\x33\xa8\x9b\x33\x2e\xb3\
+\xe7\x69\x61\xfd\xf3\xf4\xf2\x24\x7d\x9f\x5a\xa6\xa6\x1a\x5d\x8b\
+\x61\xe7\xd3\xdb\xae\x3f\xc0\x39\x8c\xe8\x46\xef\x72\xd6\x69\xd3\
+\x34\x6d\xf5\xdd\xe5\x55\xc3\xec\x25\xdd\x10\x93\x8a\x95\x60\x5e\
+\x1d\x20\x69\x2d\xac\x57\x5e\xeb\xad\x04\xe6\x85\xd8\xd3\x9f\x21\
+\x35\xaf\x9e\x52\xaa\xe7\x89\x7c\x94\xa4\x88\x7a\x11\x8d\x8a\x99\
+\x04\x70\x2c\x61\x4a\x61\x4e\x15\xe7\x36\xe3\xd4\x99\x41\xa7\xca\
+\xe8\xa8\xc3\x38\x3f\xf5\xcc\x2c\xdc\x11\x57\x93\xec\xf2\x03\x42\
+\x27\x50\xff\x2b\x91\x20\xa8\xed\xe3\x5d\x6a\xb1\xc7\xc9\x34\xca\
+\x0c\x26\xb9\x19\x4d\x0c\x60\x95\x82\x4d\x42\x5c\x16\xeb\xf5\x38\
+\x42\xb2\x0c\xdd\x11\x8b\xf5\x3a\x5e\x77\xc4\x82\x21\x18\x37\xe3\
+\xde\xc6\xc8\x7a\xb8\xe7\x39\xec\x7a\x9e\xcb\x4e\x87\x05\xc3\x66\
+\xf7\xc8\x81\xcb\x37\x68\xd6\x1b\x64\x57\x0b\x6c\x98\x02\xbc\x93\
+\xd3\x21\xc7\x63\x0f\xe3\x2a\x76\x6a\x13\x40\xa7\x07\x18\xb1\x6b\
+\xca\x9e\xd1\xaa\x3d\x0b\xd5\xa3\xb7\xe6\xd4\x68\x11\x89\xd6\xfe\
+\x15\x0f\xfa\xd0\x8a\xfb\xf1\xb7\xf0\xe8\x06\x5d\x4c\x6b\x85\xe0\
+\x9a\xcb\x98\x35\xb0\xd5\x9c\x0c\xc5\xbc\xf1\x02\xb9\xee\xf2\x38\
+\x0f\xd4\x7a\xe7\x1e\x2b\x6e\x7c\x22\x07\x2a\x6e\xd4\xb2\x09\x19\
+\x71\x73\xf2\x03\x89\x80\xc5\xd2\x38\xe2\xe0\xd8\x63\x10\xda\x89\
+\x85\xd7\x77\xa6\x2e\x2a\x11\xf1\x43\xb1\xa8\x94\x06\x7a\xc7\xa2\
+\x49\xc5\x82\x48\xb8\xf7\x6a\xe5\xaa\x72\xf5\xa9\x2b\x45\x0c\x7c\
+\xc9\x9a\x92\x9d\xb3\xf1\xa2\x70\xfb\xc9\xb4\xd1\x7a\x39\x0b\x44\
+\x33\x75\x85\x35\x6a\x22\x73\x2f\xfe\x7d\x32\x37\xba\x6e\x56\x67\
+\x02\x1e\x13\x7f\x48\xbb\x1f\xb2\x64\xd9\x94\xca\x4c\x7b\x7c\xf4\
+\x72\x64\xc2\x16\x41\x3c\x6d\x55\x04\x3d\xda\x1c\xb7\xb6\x39\x76\
+\x1f\x70\xef\xc0\xa0\xb8\x71\x48\x73\xe1\x06\x1b\x85\x35\x2a\xeb\
+\x5b\xf4\x8f\x76\xa6\x0b\xc7\x5a\x07\x7f\x87\x70\x6f\x9a\xbe\x30\
+\x98\x8c\x80\x1c\xe5\x5c\x0e\x34\xbf\xb4\x33\x8e\x87\x31\xca\x22\
+\xd0\xc4\xa5\x22\x2e\xfb\x31\x6a\x79\x8c\x5a\x9e\x52\xb0\xa9\xa2\
+\x72\xeb\x8b\x05\xa2\x18\xe4\x99\xa6\xd0\x77\x6b\x6b\x4b\xdc\xda\
+\x7a\x85\xf5\xf2\x4d\x8e\x72\x2b\xd0\x15\xcf\x1b\x57\x0e\x2d\x02\
+\x5a\x9d\x36\x74\x7a\xaa\x79\xc9\x3c\x36\x94\x9e\x04\x31\x35\xc8\
+\x26\x13\xb6\xa0\x67\x08\x3f\x72\x47\x38\xfe\xf5\xff\x00\xe1\xe5\
+\xc9\xb5\x9a\x4e\x4a\x88\x19\x63\x44\xbb\x02\xa4\x59\xa6\x66\x56\
+\x67\xa2\x79\x7e\xd1\x13\xf9\x11\x5a\xe7\x9e\x9e\x55\xa6\xea\x3b\
+\x34\x6b\xb6\x2a\x31\x4a\xdf\x8e\x5b\x17\x1c\x1c\x7b\x0a\xb8\xf2\
+\xaa\xd1\xea\x24\x93\x69\xea\xf5\x4a\xe2\x72\x4f\xcf\x50\x60\xec\
+\xd4\x42\xda\xa3\x5e\x3c\x61\xa9\xa0\xd8\x56\xce\x7b\x56\xa0\xbc\
+\xc6\xf7\x7d\x9d\x9f\x3c\x1d\x95\xd4\x0d\x6d\xf9\xfb\x24\x53\xeb\
+\x5d\x8a\xd2\x40\x96\xb9\x14\xfa\x42\x70\xcd\x31\x41\xbd\x41\xa6\
+\xd3\xa6\xd9\x10\x41\x8f\x8b\x74\x2b\xbc\xe1\xec\x31\x53\x7a\xb8\
+\x70\x42\x25\x1a\x52\x5b\x68\x88\x1c\x99\x23\x71\xa5\x2a\x66\xc7\
+\x38\xe3\xb1\x60\xe0\xb8\x54\xa9\x98\x15\x6e\x40\xeb\xf4\xd1\x1e\
+\xd6\x5a\xfd\xda\x1f\xbd\x51\xb6\x19\x65\x4a\x1a\x38\x0a\x88\x41\
+\x19\x60\x37\x61\x73\xbd\x8c\x7f\xef\xae\x72\xa7\xdd\x3c\xb5\xd8\
+\xf5\xf6\x39\x39\xb9\x50\xec\xab\x0e\x76\xcc\x2c\xe9\xc1\xdd\x69\
+\xf0\x15\xac\x52\xac\x57\xc7\xe0\x14\x81\x79\x40\x2d\xe2\x57\x3d\
+\xfc\x9e\xcb\x72\xdd\xe0\xbc\x13\x25\xe6\x24\xa7\x3f\x4f\x2d\xd0\
+\xa0\x0f\xd8\x73\x0d\x11\x31\x89\x47\x78\x23\xdc\xfe\x34\x8b\xed\
+\xaa\x62\x91\xc5\x9f\xeb\x8d\x90\x3a\x58\x67\xe0\xe3\xd6\x85\xd2\
+\xec\xf4\xa7\x9e\x17\x7d\xe6\x5d\x5d\x16\x9c\xfa\x43\xc5\x92\xa3\
+\xb6\xc3\xc6\x9d\x06\x5f\x7a\xe5\x25\x8a\xdf\x27\xaa\x59\x8e\x8e\
+\x42\xf6\xb7\xf3\x1c\x7e\xe7\x37\xa7\xa9\x9d\x65\x31\x2a\xb7\x16\
+\x7f\xcf\x6e\xd1\x83\x38\x47\xba\x1b\xf4\x00\x9b\x7a\xd7\xc4\x35\
+\xe7\x87\xd3\x67\xec\x92\x8a\x35\x3b\x82\xa1\x1a\x7d\xcf\x5e\x09\
+\xd7\x99\x88\x6c\x39\xf9\x19\x3d\x43\x68\xe1\xa0\x4b\x00\x2c\x55\
+\x60\xa7\x5b\xe1\x4b\xf2\x9c\x30\x20\xdb\xee\xb2\xba\xb8\xc0\xad\
+\xaa\xc3\x43\x92\xdd\x88\xfa\x86\xc8\xe5\x70\xcf\x8e\x38\x76\xd7\
+\x69\x70\x87\xc1\x24\x37\x35\xf0\x6a\x3e\x61\xe4\x30\x98\xe4\xc4\
+\x1c\x3b\x00\xff\xa4\x43\xef\x9c\xb9\xcd\x2c\x76\xe9\x70\x18\x5c\
+\xb0\x21\x9b\x6e\x67\x37\xb0\x16\x3d\xe8\x78\x5c\x76\x3a\xec\x1e\
+\x39\x18\xab\x21\xcd\xee\x6d\x5a\xec\xab\x6c\xa4\x76\x0c\x60\x79\
+\x59\xcb\xf6\x7d\xa8\x66\xc1\x99\x3f\x81\x3e\x7d\x19\x97\xc3\x0a\
+\xa5\x81\xa6\xef\x2b\x81\xe9\xf7\x42\xac\xaa\xc9\x79\x27\x54\xc3\
+\x0c\xf5\xf7\xa5\x01\x3c\x2f\x99\x67\x9e\x7c\x90\xd3\xea\x6b\x66\
+\x95\x6e\xb1\x47\xb6\x9f\x7c\x4f\x6d\xa1\x41\xf1\xbe\x37\x53\x62\
+\x24\x3c\x10\x17\x42\xb7\xc7\xe0\xad\xc5\x6d\x4c\x45\xc6\x5b\x72\
+\x68\xa3\x94\x00\x2a\x21\x7c\x73\x8d\x4f\xbd\x7c\x8b\xaf\xfc\xa3\
+\xaf\x50\xfa\xc4\x0b\x5c\x99\xd0\xde\x1e\xf1\x27\xfc\x1e\x3b\x4f\
+\x2d\xba\x81\x90\x13\xad\xd0\x88\x67\x47\xcb\xdc\x0d\x21\x21\xba\
+\x7a\xc6\x5e\x0c\x28\x29\x2f\x66\x7e\x73\xdc\xc2\xb6\x1b\x4e\x7f\
+\x9f\x3c\x76\x69\x43\x4d\x77\x9d\x49\x29\xa1\x8c\xc8\x9e\x41\xb5\
+\x3a\xa0\xe7\xa4\xdc\x73\x64\x45\x20\x4b\xef\x6d\x17\x8f\xb9\x5d\
+\x2a\x14\xe8\x67\x8d\x19\x26\x56\xa5\x6b\xe5\x21\xdd\x8e\xf0\x42\
+\x1d\x0f\x2d\x36\x8d\x0e\x9d\x48\xe4\x87\x86\x91\x83\xd9\xab\x63\
+\xd6\x62\x92\xab\x46\x58\x7f\xfe\xf0\x4d\x8c\xc2\x0a\x37\x2d\x8b\
+\xab\x7d\xc1\xa6\xd1\xa9\x89\xb5\xbe\x49\xe0\x3f\xa5\xd9\xbd\xcd\
+\xed\xca\x11\xa1\x1d\xb7\x0d\x9d\x1c\xb2\x7b\x64\xb1\x91\xf1\x39\
+\x0c\x2c\x02\x5f\x18\x33\xad\xda\x3e\xd1\xa9\xc9\x33\x3f\x3e\x29\
+\x12\xc0\x9a\x2b\xa8\x1b\xf4\xa0\x48\xa2\xc0\x52\x19\x53\xd2\x10\
+\xd3\xb6\x0c\x50\xc3\x0b\x67\x46\xca\x0e\x52\xef\x21\xf6\xe1\x22\
+\x64\x49\x61\x30\x7f\xe0\xb7\xc8\x62\x9b\x0f\xe0\x9a\x53\x4b\x9c\
+\x7c\xb7\x2f\x98\x59\xf7\x0f\x37\x7b\x01\xcd\xda\x0d\x3e\xbe\xb9\
+\x30\x13\x42\x96\xfe\x6a\x9d\x7d\xbb\x41\x37\x1e\x30\x8e\xda\xaa\
+\x4b\x7b\xd7\x84\x6a\x96\x97\x1e\xbc\xc0\xe6\xbd\xbb\xdc\x5d\xce\
+\x72\xeb\xde\x16\xc5\x9b\x2b\x74\xdb\x01\xa7\xef\x74\x78\xfd\x83\
+\x3f\x63\xef\xf1\x07\x64\xfb\x3e\xf5\xfa\x72\x9c\xd2\x6a\x43\x6c\
+\x68\x4a\x26\x15\xfa\xf5\xfa\xe8\xa3\xf4\x77\x2b\xad\x1d\x77\xfb\
+\x94\xbf\x6f\x26\x27\x79\x4e\xee\x35\xc0\x45\xe0\xb1\x64\xd9\xd4\
+\x25\x1b\x57\xa3\x69\x3b\x83\xf8\x73\xab\xe5\x81\xf0\xff\xc7\x00\
+\x0e\xea\x0d\x76\x5b\xa7\x1c\x07\x07\x94\xdb\xfb\x30\xfc\x24\x64\
+\xcb\x2c\xad\x5b\xc2\xcd\xf6\xfe\x1f\xd3\x1f\xae\x51\xe2\x48\x54\
+\x89\x94\x1b\x10\xe7\x9b\xd7\x52\xc9\x67\x83\x49\x8e\x62\xb5\xc3\
+\x60\x3c\x6d\x0c\x69\xad\x97\x6f\x2a\xe0\x3d\xf3\x7d\x38\x82\x68\
+\x78\x02\x1f\x3c\x8b\x13\x70\x4e\xe0\x02\x8c\x82\xf8\xa1\x37\x63\
+\x6b\x69\x37\x96\x0f\x00\xd1\xa9\xd0\x38\x47\xcf\x3c\x26\xde\x31\
+\xce\xb3\x8a\xd0\x4c\xfe\x90\x4e\xcc\x04\xf5\xc8\x48\x8c\xbc\xd5\
+\xe7\xb4\xc9\xc7\x12\xb0\x0a\x9c\x96\x60\xdd\x4c\xa6\x06\x74\xa7\
+\xcc\x1a\x3b\x0a\x74\xd0\x4b\x26\x2e\x0c\x4a\x0c\x7b\x2e\x3e\x42\
+\x52\xe8\x4c\x2c\x80\xd8\x67\xe8\x4f\xf7\x6f\xf6\x02\xa5\xc3\x25\
+\x80\xf5\x74\x4d\x6b\x20\x18\xd9\x65\x42\xd3\x8c\xa8\xdd\x91\x79\
+\x11\x57\x8a\x85\xa5\x0f\x58\x67\xe0\x80\x9a\xca\xb3\xf0\x7d\xf1\
+\x7d\xe4\x1c\x3b\xc8\xaa\xb6\xb2\x9f\xb9\xb3\xcc\xdf\xfc\xa7\xf7\
+\xb9\x63\xdd\xc7\x66\x81\xca\x4d\x8b\x63\xe0\xe8\x9b\xdf\xe5\xe7\
+\xff\xb7\xd7\x79\xba\x2d\x86\xf3\x98\xc5\x08\x3a\x02\x28\xa5\x6a\
+\x36\x31\x9c\xd1\xed\x4f\x70\x99\x02\x52\x1a\x7c\x89\x81\x90\x45\
+\x0f\xd7\x91\xe0\x1c\xcf\x18\xae\x3a\x0b\xeb\x4c\x3d\x4f\x53\x5f\
+\x04\x1e\x75\x8c\x44\x74\xcf\x35\xc7\x6a\xa8\x8e\x34\x56\xe9\x19\
+\x64\x9b\x79\x2a\xd1\x90\xee\x55\x88\x7f\x30\xe4\x24\x28\xb2\x64\
+\x3a\xc0\x22\x8d\xc1\xd4\xc5\x39\x29\x1c\x81\x13\xbb\xd8\x1c\x8f\
+\x5a\xa6\x46\xb7\xd3\xe5\x38\x38\xe0\x13\xbc\x48\x31\x9b\x67\x30\
+\x11\x3a\x58\x4a\x0b\x95\x9d\xa8\x03\x53\x6e\x29\xdf\x9c\x7b\x99\
+\x7f\xe6\xfb\x18\x83\x67\xc2\x78\x03\x38\x12\xef\x79\xe6\xfb\xd4\
+\x3b\x1e\xfb\xdd\xfd\xb8\x55\xeb\x98\x8b\xc0\x03\x63\x3a\x87\x58\
+\x9d\xd0\x39\xab\x3e\x5d\x41\xa1\xef\x53\xb0\x4a\xd0\xf7\x09\xe2\
+\xfb\xf3\xe4\x85\x3c\xf8\xe9\xc9\x9d\x72\x7f\xc9\xf4\x69\x5f\xb0\
+\xf4\x88\xe8\x60\x96\xba\xd9\x2f\x6a\x03\x15\x7b\x39\xaa\xa1\x43\
+\x2d\xd3\x88\x27\x77\x4e\x01\x7c\x30\xbc\xc9\xc8\x39\x54\x00\x6e\
+\xb5\x0d\x5c\x53\xe8\x78\x0b\x9b\xf1\xf8\x04\x62\x83\x4c\xaf\xd3\
+\x93\x03\xcc\xd7\xca\x06\x7b\x07\x3e\x66\xb8\xc3\xa0\xb3\xcd\xe9\
+\x1f\x1f\xf2\x03\xaf\xfe\x10\x00\x9f\xf8\xd1\x9b\xdc\xb6\x3f\x4b\
+\x6b\xe1\x81\xb2\xe0\xcf\xb6\xdf\xa0\x49\x53\x63\xc0\x89\x02\xae\
+\x3c\xc6\x6e\x6c\x43\xc8\xb6\x5c\xfa\xa0\x48\x1d\x74\x7a\xf0\x46\
+\x12\x86\x3c\x4e\x99\xb8\x87\xf2\xdc\x4e\x9e\xb1\x8c\x90\x19\xe9\
+\x72\xf1\xcf\xb8\xf4\xaa\x59\x91\x9f\x1c\x67\xca\x1d\x8c\xba\x30\
+\xfe\x10\xf8\x7e\x16\x32\x11\x7b\x95\x12\x5b\x95\x21\x0f\xd7\xb7\
+\xe8\xef\xed\x28\xcf\x83\xe8\xfb\x86\x60\xe3\x5e\x96\x43\xd7\xa0\
+\x52\x14\x03\x0b\x07\x13\x7d\x5e\x74\x9c\x69\x28\xe5\x43\x7a\x9b\
+\x06\xef\x4d\xcb\xe2\xa6\x65\x11\x59\x37\xb9\xa9\x3d\x0f\x10\x9d\
+\x4d\x78\x77\xe7\x21\x51\xdc\x0e\xe9\x22\xf0\x94\x1f\xd3\x2f\x82\
+\x3b\xe7\xb2\x95\x98\x7d\x9c\x9a\x44\x6f\x61\xce\x68\x59\x09\xc8\
+\xb4\xbc\x60\x30\xdf\xf8\x48\x03\x7e\xd8\x73\xa7\x2e\x37\x8d\xe9\
+\xe5\xdf\xed\x59\x82\xe5\xba\xe5\x6e\xa2\xb3\x8f\x72\xb1\x99\x4d\
+\x56\x36\xea\xca\x9d\x26\x2b\x2f\x46\xad\x29\x80\x0f\xbb\x13\x86\
+\xa1\x0b\xa1\xb6\x80\x62\x00\xcb\xef\x2a\xbd\x1d\x3d\x47\x8c\x0d\
+\x33\x72\x8b\xac\x5c\x1e\xf0\xd4\xbf\xc3\x07\xaf\x3f\x06\xe3\x98\
+\xa8\x78\x93\xfb\x9f\xff\x24\x3f\x76\xe3\x0b\x14\xbf\xfc\x05\x26\
+\x8d\x02\x17\xad\x2f\xf1\xd6\x1f\xee\xf2\x26\x30\x39\x7f\x04\x3d\
+\x03\xbf\xec\xc5\xda\xb8\x88\xcb\xac\xf4\x91\x25\x55\x69\x3b\x20\
+\x13\xb6\xf0\xcb\x99\xc4\x00\xf5\x82\x55\x12\x83\xd1\x7b\x0e\xe7\
+\xb8\xe0\x94\x66\xd2\x2b\xf5\xec\x36\xf5\x58\x6b\x40\x9e\x96\x23\
+\xea\xbd\x71\x0e\x89\xe5\x9e\xb3\xbb\x6b\xb2\xb1\x75\xc1\xc2\xc6\
+\x6d\x2a\x0b\x8b\x74\x17\xe4\x49\xd8\xc2\x2c\x9c\x28\x03\xaf\x44\
+\x8e\x7e\x27\x6e\xec\xee\x6f\x03\x9f\xc1\x1f\x58\x58\xc5\x3e\x50\
+\x49\x78\x44\x4c\x80\xae\x7f\x7f\xea\xc4\x8e\x01\x6c\xac\x86\x82\
+\x79\x57\x43\x6e\x5a\x96\x92\x0e\xfa\x56\x32\xf7\x7e\xf7\x29\xad\
+\x83\x4e\x02\xc0\x1d\x23\xa2\x66\x56\xe7\xb2\xaf\x1e\x54\x48\xaf\
+\x74\x69\xb0\xe9\x46\x9c\x6e\xa4\xe9\xa1\x64\xfd\x73\xd3\x9a\x59\
+\x37\xfe\x74\x50\xfb\xbd\x90\x28\x53\x51\x72\x42\x06\x32\xfc\xa2\
+\x97\x00\x70\xa2\x8a\x23\x14\x5d\xd1\xd7\xca\xd3\x0a\x8d\x83\xe1\
+\x4d\x8e\x5b\xc2\x88\x6b\x75\x62\x00\xfb\xee\xdc\x2b\x80\xba\x52\
+\xc4\x7f\xaf\x15\x0a\x5f\x79\xd0\xab\x73\xdc\xba\xc0\xfe\xf4\x16\
+\x3f\x7c\xcb\xe0\xc1\x8f\xdf\xe3\xc5\x1f\xfc\x22\x9b\xb7\x37\xf0\
+\x4f\x3a\x7c\xeb\xf0\x82\x77\xdf\x38\xe1\xfd\xdf\xd9\x65\xcd\xdb\
+\xe7\x1f\xfc\x0d\x93\x2f\xff\xc4\x06\xd9\xe5\x07\x1c\x4d\x2e\x89\
+\x32\x95\x44\xcf\x37\xfd\x7b\xcf\xdb\xca\xbf\x9f\x0e\xb3\xeb\x84\
+\x71\x8e\x91\x78\xec\x9a\x63\x5c\x73\x3c\x75\xb3\x69\x1d\x46\x13\
+\xb3\x4f\xb4\x9b\x1e\xf5\xd3\x0d\xbb\x9d\xae\x00\xdf\xd9\xf0\x29\
+\xe3\xe1\x15\x99\x6e\x9b\x8d\xc2\x9a\xc8\xa1\xf0\x77\x66\xab\x45\
+\xea\x26\x83\xf6\x90\x6a\x7f\x91\xfe\xa0\x8b\x55\xf4\xf1\x07\x96\
+\x62\x61\x95\x3b\x11\x9d\x9a\xd4\xd7\x3f\x4c\x80\x57\x82\xba\xcc\
+\x83\x19\x46\x4e\x3f\xb6\xd6\x37\xb9\x5d\xbb\x4b\xb6\x99\xe7\x22\
+\xf0\x44\xda\x5e\x2a\x14\x19\x65\x2a\x89\x18\xbc\x7e\x40\xf5\x01\
+\x31\xd7\x01\x53\x02\x21\x0d\x50\xc9\xdc\x12\x2c\x2a\xd4\xdc\x0b\
+\x67\x16\x8d\xee\xa9\xd0\xf5\xae\xcc\xa3\xb8\xce\x53\xe2\x3a\x13\
+\x6a\x77\xa6\xc9\x3d\x52\x03\x37\x2f\x8e\x14\x80\xaf\x3a\x9d\x04\
+\x9b\xe9\xdf\x5b\x7e\x17\x1d\x60\x7a\x7f\x8b\xb3\xc3\x36\x7b\xaf\
+\x1d\x52\x5e\x35\xf8\xe2\x67\x3e\xc7\x8f\xfe\xbd\xcf\xf2\xf2\x27\
+\x57\xb9\x73\xb3\xc8\x46\xc6\xe7\x5b\xdf\x7d\x8d\xdf\xfa\x8d\x5f\
+\xe1\xf7\x7e\xf5\xf7\x38\x0a\x73\xdc\xbb\xf3\x0a\xad\x07\x1b\x34\
+\xf2\xd5\x99\x06\xdf\xd7\x79\x5c\x12\x55\xdf\x73\x8e\xb1\x7e\x7f\
+\x99\x48\x91\x46\x22\x76\x10\xf4\xe7\xba\xe9\xd2\xcf\xa5\xcf\xab\
+\xee\x92\x6b\x75\x3d\xa2\xec\x19\x79\x56\x70\x49\x85\xb2\xad\x64\
+\xb9\x52\x89\x1c\x01\x35\xd1\xe2\xd5\xbd\x60\xa3\x34\xdf\xe5\x57\
+\x2a\x67\xb1\xee\x7f\xfe\x93\xf8\x97\x15\xac\xcf\xf7\x45\xf4\x0d\
+\x78\xf5\xee\x90\xc3\xe0\x2e\x0b\x77\x7c\x02\x1f\x16\xec\x0d\x5a\
+\xec\xc7\xa0\xfe\x50\x31\xf6\xfa\xba\xa8\xe6\x30\x56\xb2\xe2\x4b\
+\x04\x0f\x55\x56\x5a\x3d\x32\xe8\xc4\x91\x26\x79\x49\x13\xee\x9e\
+\xf9\x2e\xae\xb4\x3e\x53\x46\x9a\xef\x42\x0f\x7c\xdc\x84\x11\x37\
+\x57\x0f\xc7\xd2\x41\xee\x3b\xec\xb9\x09\xa3\x45\x07\xb2\x6e\xd0\
+\x28\x3d\x88\xa9\x5c\x4d\xcd\xfa\x40\x15\x82\x16\x57\x93\x25\x56\
+\x8f\xfd\x67\x14\xce\x9b\x74\x3b\x5d\xdc\x98\x09\x75\xf6\x95\x2c\
+\xaf\xff\x16\x7d\xe1\xd6\x23\x43\xc8\x8c\x6a\xc4\xf6\x55\x87\xee\
+\xaf\x7f\x9d\x47\xef\xdc\xa0\xfc\xca\x21\x0b\x5d\xd1\x19\xe9\x0b\
+\x1f\xbf\x4f\xb1\x9e\x61\xf3\xde\x5d\x8e\xc7\x1e\x61\x7e\x19\x3f\
+\x7c\x88\x65\xbe\xc4\x0f\x1b\x23\xde\x90\x2e\xba\x39\x2c\x7c\x5d\
+\xe4\x32\x7d\xac\xf5\xab\x97\xce\xc4\x46\x3f\x22\xdf\x28\xcf\x1c\
+\x2f\x5d\xeb\xea\xe4\x23\xc9\x44\x12\x4b\xda\xd5\x26\xd9\xbf\x06\
+\x8c\x0f\x26\xf0\xfd\x10\x19\x5d\x20\x98\x1b\xf4\x90\x92\xa2\xa9\
+\x35\x79\xba\x74\x45\xae\x85\x55\xf4\x29\x7a\x2e\x7d\x16\x89\x68\
+\x09\x4d\xbc\xba\xb1\x81\xb3\x50\xa6\x5c\x74\x58\xdd\x00\xbf\x2f\
+\xc2\x2b\x2b\xdd\x51\x9c\x00\xf4\x4a\x2c\x6b\xea\xf8\xf9\x0e\xd6\
+\xda\x2b\xec\x5a\x9a\x53\x70\x1d\xd6\xfd\xa7\xec\xaf\x6f\xb1\xfb\
+\xd6\x9f\x53\xcf\x2e\xaa\x4b\x88\x8c\x0e\xd5\xca\xc2\xdf\x0a\x95\
+\x19\x8b\x39\x7d\x5f\xd7\xc9\xc2\xa8\x22\x21\x23\xa4\x0b\x2d\xed\
+\x47\x96\x5e\x09\xaa\xe2\x3d\xfa\xeb\xe9\x13\xb6\x4c\xa4\x2e\x9b\
+\xcb\x44\xf4\x00\x33\xec\x01\x75\xc2\x4e\x87\xe5\x66\x4d\x65\xb9\
+\xd5\xea\x0d\x5e\xb0\xa6\x39\xc2\xdb\x8f\x42\x0a\xbd\x26\xbb\xad\
+\x53\x7a\x4e\x51\x7d\xae\x6e\xc0\x0d\xfd\xa9\x27\xc2\x1a\xd8\x6a\
+\xa1\xc8\xdf\xa4\x8f\xba\x2d\x58\x25\x7a\xc0\x5b\x3b\x27\x98\x4f\
+\x3e\x24\x72\x2b\x2c\x55\x44\x7f\xb2\xf5\x7b\x5f\x64\xf3\xde\x06\
+\x5f\x78\x61\x93\x93\x70\x0d\xcb\x14\x44\xf3\xf0\xfd\xf3\x99\x2b\
+\xca\x75\x41\xa3\x79\x72\x4b\x5e\xb9\xe8\xcd\x46\x36\x0b\x56\x89\
+\x11\xce\xcc\xfe\x05\xab\x94\x18\xb2\xa3\x37\x57\xd4\xf7\xd5\xff\
+\xa6\x0c\x9b\x97\xca\x62\xd0\x7a\x37\x80\x9d\xfd\x3e\x2f\x5e\x5e\
+\xd0\xb8\xb5\xc5\x62\x63\x13\xd8\x4b\xba\xd9\xfc\x23\x05\xe4\xbe\
+\x51\x50\x19\x8b\x1e\x57\x71\xe3\xca\x0a\xbd\xc8\xc3\x2a\x7a\xf8\
+\x72\x1c\xb2\x4d\x0e\x8a\x5a\x32\x45\x25\xbe\xd4\x55\x2a\xac\x02\
+\x36\x01\x1e\x19\xc2\x41\x48\x18\xe7\x57\xc8\x3c\x8b\x28\x06\xfa\
+\xf2\xc2\x57\xc8\x58\x1f\xb2\xf3\xb4\x09\x5d\xe1\x10\x97\xda\x78\
+\x52\xb1\xe8\x10\x51\x37\xab\x74\x88\x34\x46\xf6\x67\xee\xa7\xa5\
+\x86\xce\x64\xf2\x80\x4b\xb6\x4d\xb0\xb5\xe6\x52\x4b\xeb\x69\xdd\
+\x90\x93\x8f\x7b\x56\x19\x7c\x97\xaa\xef\x08\x30\x03\x8b\x66\x85\
+\x16\x90\xcb\xad\xd1\x73\x44\x7e\x44\xed\x4e\x43\x25\xb9\xef\xfa\
+\x03\xc2\xa3\x0d\xfa\x85\x77\x39\xd9\x1b\x27\xb4\xa8\x34\xe0\x74\
+\x06\x4e\xe8\xd3\xd8\xaf\x9d\xce\x8e\x2b\x55\xb3\x4c\x0c\x8b\x7a\
+\xd7\xa4\x64\xe6\xa0\x5e\xa7\xb9\x04\x9f\x7a\xe5\x05\x3e\xf1\xa9\
+\x17\x09\xef\x3c\xc3\xdc\x3b\xe5\x1b\xe7\x13\x16\x6c\x9f\xab\x27\
+\x87\xbc\xf1\xfe\x5f\x31\x39\x3f\x52\x75\xea\xfa\x15\x4e\xff\x3e\
+\xf2\x6f\xa6\x01\xac\xa2\x9a\xbd\x59\x90\x0e\x7d\x97\x51\xdb\x21\
+\xaa\x18\x62\xa1\xa7\x5e\x5b\x26\xa2\xe7\x94\x67\xe4\x42\x9a\xcd\
+\xe5\xdf\xc9\x84\x2d\x4a\xd5\xc6\x34\x5a\xd9\x11\x39\x14\xa3\xa3\
+\x0e\xd1\xfa\x39\xb9\x8d\x06\x37\x3e\x56\xe5\x3b\x1f\xc4\x55\x1c\
+\xbe\xf0\x50\xa8\x4e\x9b\x8e\xc8\x58\x3c\x1e\x5a\xdc\x02\xaa\x46\
+\xc8\x80\x3e\x90\x4c\x1d\xb0\x3c\xc6\xe4\x0b\x21\xa3\xa1\x39\xb3\
+\x55\x65\x4b\xe4\xe2\x39\x83\x7a\xf5\xab\x07\x95\x05\xb2\xb4\xa8\
+\x34\x96\xf9\xdb\x1b\x77\xf9\xb3\x3f\x3a\x10\xe1\x51\x3f\x62\xc9\
+\xb2\x55\x75\x82\x14\xfb\x75\xb3\x4a\x27\x8e\xf5\xcb\xe8\x92\x9e\
+\xb4\xa2\x07\x23\x54\x07\xf6\x5e\x88\x15\x9f\xb1\x82\x55\x52\x5e\
+\x06\xc9\x76\x09\x66\xd1\xa4\x83\x7c\x6f\xda\x9f\x2c\x13\x78\x86\
+\x18\x0a\xcc\xca\xa0\x89\x43\xca\x3d\xab\x4c\x50\x6f\xb0\x12\x37\
+\xaa\xde\xf5\x07\x2c\x9d\xd8\x7c\xe7\xe4\x31\x7d\xa7\x41\xcf\xe9\
+\xcf\x8d\x06\x8e\xc7\x27\xe4\x58\x9b\x0b\x64\xfd\x52\xde\x2d\x8a\
+\xc8\x9b\xeb\x4c\xc8\x02\xae\x29\x82\x2b\x5b\xa6\x41\xf1\xbe\x17\
+\x03\x58\x5c\x52\x9f\x9e\x4f\x78\xfd\xf7\xdf\x10\x9d\x7f\x34\xf7\
+\x98\xee\x49\xd1\x43\xe9\xba\x27\x64\x9e\x4e\x4f\x3f\x97\x5e\xf0\
+\x51\x3c\xd4\xe5\x42\x73\x02\x0c\xf5\x63\x74\x8d\x7c\x49\x2f\x08\
+\x19\xe4\xd0\x23\x7f\xd4\xc5\x39\xea\x55\x2e\x31\x96\x97\xb1\xa9\
+\xf0\xc9\xdb\x9f\xe1\x83\xca\x43\xe1\x75\xf1\x87\x98\x75\x5b\x25\
+\xc8\xcb\x71\x63\x2a\xd0\x61\x87\xf8\x03\x8b\xaa\x11\xd2\x1b\x78\
+\x58\x45\x5b\x34\x14\xb4\xc9\x61\x0e\x23\x6c\x02\xcc\x61\x3c\x93\
+\x21\xde\xe6\x0b\x61\xfc\x21\xde\x14\xb8\x6a\x2b\x9e\xb7\xb1\xf1\
+\xdb\x67\xd8\x35\x9f\x9f\xfa\x99\x2f\x51\x5f\x7c\x85\xa3\xab\x2b\
+\x2e\x02\x4f\x95\x85\x4b\x4f\x85\x9e\xef\x2a\x19\x44\x4f\xc8\x49\
+\x07\x19\x74\x9d\xab\x07\x44\xae\xab\x8f\xd3\x25\x84\xae\x9d\x75\
+\x00\x5b\x55\x53\x49\x89\x79\x9a\xb0\x67\x95\xa9\x96\x07\xdc\x6b\
+\x8a\xa6\x27\x17\x6b\x1e\x4b\x27\x36\x8f\xfd\x67\xa2\x61\x75\x47\
+\x00\xd8\x0c\x7b\x33\x97\xe1\x5c\x6e\x6d\xae\xaf\x3b\xed\x03\xd7\
+\x7f\x8f\xdc\x2f\xdb\xf7\x69\x05\x70\xf6\xa4\xc1\xd7\x77\xf6\xf8\
+\xf3\x3f\x3d\xe4\x4f\x7f\x79\x9b\x3f\xfc\xfd\xaf\xb1\xb3\xbb\xaf\
+\x0a\x5f\xe7\x75\x2c\x92\xbf\x4d\x97\x4e\xba\x36\x9f\xe7\xb9\x19\
+\xfa\xae\xea\xe1\x5c\xb0\x4a\x18\xfd\x88\x65\xa6\xc6\x53\x54\x31\
+\xbe\xa7\xec\x3e\xdd\x08\xd4\x8f\xa5\xde\x6d\xbf\x63\x88\x3e\x75\
+\x74\x42\x0e\x23\x31\xfd\xaa\x7d\xb0\xc3\x78\x78\x45\x34\x39\xa6\
+\x7a\x73\x43\x94\x2a\xf5\x0c\xfa\xc3\x35\xd5\xa4\xb0\xef\x14\x68\
+\x85\x1e\x6e\x5c\xde\x24\x3d\x13\x03\x3b\xc4\x88\xfd\x76\x71\x65\
+\x87\x97\x64\x57\x5d\x64\x0f\x0b\x78\xaa\xf1\xc6\x75\x40\x06\x8f\
+\x0c\xfe\xf1\x29\x9b\xf7\xef\xf3\x77\xff\xa3\x2f\xb2\x79\xf3\x87\
+\x45\x3a\x60\xa7\x4f\xa7\xd3\xa7\x51\x31\x67\xaa\x14\xd2\xae\x35\
+\xc9\xc6\x3a\xa8\x25\xf8\xfc\xa2\x37\xd7\xeb\x20\x73\x85\x75\xb6\
+\x9d\x77\x40\x75\x40\xeb\xde\x82\x74\xd8\xbb\xea\x3b\x54\xcb\x03\
+\x6a\xf5\x1a\xc3\xe5\x16\x17\x6b\x9e\x0a\x27\x9f\x3d\x69\x24\x72\
+\x7f\x43\xb3\x3a\xa3\x27\xa5\x6e\xd7\x7f\x83\xee\x19\xf0\x8b\xc2\
+\xaf\x2b\xaf\x4c\x52\xfb\x27\x4a\x8d\x3a\x7d\xfe\xe4\x37\xff\x8c\
+\xd7\x5e\x7b\x97\x6f\xfe\xe5\x43\x26\xad\x11\xcd\x5a\x93\x4c\xa3\
+\x96\x30\x98\x66\x02\x42\x73\xb4\x70\x9a\x69\xd3\xc7\xd0\xce\x64\
+\xd4\x6b\x51\xc5\x48\x64\x9b\x49\x80\x7b\x41\xa0\xfe\xeb\xbf\x51\
+\xff\xdb\xf3\x58\x58\x5d\x2d\xc2\x1e\xf5\xc8\x20\xca\x54\xb8\x0c\
+\xfb\x42\x1e\xc4\x6d\x78\x33\x83\x0c\x4e\x2f\x69\x34\xcb\x86\x3b\
+\x6a\x94\xc2\x9c\x61\xb0\xfe\xc0\x22\xa2\x05\xf4\xa7\x7e\x62\xfd\
+\x66\x93\xc3\x63\xac\x6d\x03\xf5\x8a\xbe\xd7\x8c\x21\xd1\xee\xe0\
+\x84\x7d\x7e\xe0\x2b\x3f\xcc\x7f\xf6\xdf\xff\x34\x5f\xfe\x47\xff\
+\x82\x8d\x57\xff\x21\xed\x51\x0f\x6b\x90\x57\x6d\xa5\x9e\x5b\xb3\
+\x15\x03\x59\x4f\x85\xd4\x99\x38\x11\x42\xd6\xc0\x9b\x8e\xc8\xa5\
+\xc1\xec\x05\xc1\x5c\xd9\x31\xb3\x30\xea\x26\xb5\x7a\x8d\xe2\xaa\
+\xc7\x0b\xd6\x4d\xda\x87\x2d\xfc\xed\x02\x1f\xb4\x3a\x84\xfe\x19\
+\xe7\x9d\x48\x81\xc4\x0c\x7b\xea\x04\xea\x27\x54\x46\xc8\xa2\x4c\
+\x25\xb9\xc8\xa4\x8f\x36\x9e\x24\xaa\x03\x41\x56\x54\xeb\x9f\xa3\
+\xb2\xcf\xcc\x31\x9d\x5a\x98\x58\xe0\xba\x54\x4a\xbf\x4f\x6f\x18\
+\x93\xf0\xfa\xa4\xae\x46\x33\xe9\xb7\xfd\x28\xc1\xbe\x12\xe0\xe9\
+\xed\xf3\x5c\x74\xf2\xb1\x5e\x64\xaa\x8f\x06\xce\xe5\xd6\xa6\x87\
+\xba\x50\x26\x73\xcb\xa4\xb1\x24\xbe\xcb\xad\xaa\x43\x76\xf9\x81\
+\xea\xdb\xa7\x7c\xce\x41\x57\xb5\x6a\x98\xbd\x55\x24\x13\xdb\x0a\
+\x98\x1e\x19\x60\xda\x0d\x5e\x00\xd8\x4e\x30\xee\x3c\x36\xb6\xc9\
+\xe1\xd9\x25\xec\xf6\x19\xe5\x41\xc8\xe6\xfd\xfb\x7c\xf9\x67\x5e\
+\xe4\x9f\xff\xcb\x1f\xe3\xe5\xcf\xfd\x24\x9d\x4e\x5f\xc9\x0b\x29\
+\x27\xae\x3a\x1d\xd5\xb3\x21\x68\x77\x71\x2e\x5b\x04\xed\x6e\xe2\
+\xc4\xea\x27\xbb\x69\x46\x89\xcb\xa5\x7e\x72\xd2\x60\xd4\x41\xdf\
+\x1e\xf5\x68\x68\x03\xaf\xf5\x13\x19\x76\x3a\x0a\x84\x4d\x33\x4a\
+\x00\xf8\xb1\xff\x8c\xca\xf0\x06\x67\x9d\x36\x51\x6f\x9a\xe4\x22\
+\x59\x47\x67\x62\x9d\x89\xa4\x91\xaa\x03\x53\xff\xbe\xf3\x6a\xd6\
+\x9e\x97\xa4\xaf\x2f\x6c\x3d\x99\x67\x1e\xdb\xa6\x0d\xdb\xb4\x4f\
+\x5d\x2e\x3a\xf9\xf7\x24\xbb\xea\xf2\xc1\x48\xcd\xe7\xf6\x82\x20\
+\x01\x60\x3d\xb2\x9a\x06\xb2\xdc\x66\xc2\x56\x02\xc8\xba\xcd\xd0\
+\x0a\x45\xbd\x5d\x67\xe8\x60\x3a\x19\x36\x1b\x9b\xd4\x3f\xb6\x7e\
+\xed\xef\xaf\x65\x6a\x2c\x74\xfa\x8c\x2e\xc7\xca\xc5\x66\x15\x7d\
+\x15\xf0\x50\x33\x3b\x04\x1c\x05\xeb\xba\x03\x83\x52\x31\x96\x11\
+\xde\x50\x03\xab\x27\x0c\x3c\x6f\xa8\xc0\xec\x69\xd3\x73\x04\x73\
+\x67\x70\x46\x2d\x9c\xab\xef\xb2\x10\xc2\xda\xcd\x02\x3f\xf5\x33\
+\x5f\x62\xe3\xd5\x7f\x48\xb6\xef\xb3\x7b\xf6\x8c\xa3\xab\x2b\x8e\
+\xae\xae\xf0\x82\x80\xd2\xfa\x02\x77\xee\xbf\xc4\xbd\xef\xfb\x24\
+\xeb\x77\x37\x71\xfb\x22\x09\xbc\xdf\x9e\xa8\xd2\x22\x79\x70\x64\
+\xbe\xb0\xae\x8b\xd3\x72\x61\x1e\x2b\xd8\x99\x4c\xe2\x79\x9d\x89\
+\xc3\x38\x09\x5e\x3e\x27\xcb\x87\x54\x75\x75\xa7\x1d\xfb\x82\x27\
+\x73\x3d\x1e\x73\xfd\xd5\x73\xca\xfd\xf5\xe8\xa0\x7e\xa5\xf9\x5e\
+\x92\xf8\xf5\x54\xcd\x79\x85\x04\x69\x37\xe2\x75\x36\x42\x3a\xfa\
+\x79\xdd\x4d\x67\x63\xa3\x1f\xcd\x00\xf8\xba\x9b\xfc\xfd\x32\x17\
+\x5c\x8f\xe2\x49\xe9\x98\xcb\xad\xd1\xed\x74\x39\x88\x26\x71\xbd\
+\xdd\x25\xad\xb0\xcb\x6a\x7d\xda\x11\x68\x5e\x4f\x8b\xc3\x28\xcb\
+\xbd\xdb\x59\x0d\xbc\xe2\xd8\x55\x8d\x30\xce\x01\xf7\xda\x60\x17\
+\x94\x7c\x28\x15\x03\xdc\xc1\x90\x52\xb1\x00\xb6\x94\x14\x36\xee\
+\x60\x88\x59\x1c\x63\xdb\x0d\x6c\xaf\x0d\x76\x43\xe4\x73\xe2\x29\
+\x30\xdb\x71\x02\x87\x07\x74\xdb\x5d\x6c\xc6\xbc\xd0\x28\xf1\xcf\
+\xff\xe5\x8f\xf1\xdd\x77\x6f\x71\xb5\x67\xe1\xf0\x88\x9b\x96\x85\
+\xb5\xbe\xc9\x67\x3f\xb1\x8e\x99\x29\x31\xa0\x8a\x37\xec\xf0\xe4\
+\xc3\x6d\xf6\xf7\xb6\xd9\x7b\xfc\x01\xbb\x3b\x07\xb4\x2f\x5b\x84\
+\x03\x71\x50\x6f\x7d\xf2\x8e\xb8\xbc\x1e\x5d\x25\x4f\x60\x2f\x19\
+\xd8\x90\xec\x5b\x69\x64\x67\x2e\xb9\x72\xff\x74\x35\x87\x9c\x66\
+\x34\x5c\x6e\x51\x19\xde\xa0\x5f\x38\x56\x35\x7d\x22\x78\x33\x99\
+\x3d\x61\xd7\xe4\x6c\xe8\x41\x81\x04\xd8\x52\xa9\xa1\xba\x57\x26\
+\xed\x39\x98\xe7\xf9\x98\x97\x0b\x3d\xcf\x38\xd5\x17\xb8\xf4\x5f\
+\x17\x72\x6b\x33\x57\x8d\x79\x0c\x9b\x96\x14\xcf\x33\xee\xae\x5b\
+\x78\xfa\x77\xd7\x93\xe4\xeb\x55\xa0\x9c\x85\x4e\xc8\xce\xf6\x19\
+\xfc\x28\x84\x3d\xb0\xcc\x88\xe5\xf6\xd4\xc5\x9b\x2d\x7c\x1c\xfc\
+\xa3\x69\x92\x7c\xec\x21\x79\xb2\x3f\x41\x14\x8f\x57\xa8\x1a\x2e\
+\x66\xad\xa1\x65\xb1\xd9\x0d\x3c\xc6\x84\x83\x21\xa5\x62\x14\x33\
+\x71\x14\x3f\x17\x0a\x30\x7b\x6d\x4a\xc5\x06\x78\x6d\x3c\x1b\xc2\
+\xc8\xa6\xa4\x71\xb0\x8d\x87\x3b\x30\xa0\x88\x02\xbd\x40\xf3\x90\
+\xb6\x9d\x61\xed\x66\x85\xd5\xfa\x97\xe1\x8b\x7d\x9a\x93\x2f\xd1\
+\x0f\xce\xc0\x8e\x2d\xea\xa1\x41\x35\x9f\x63\x62\x98\x6c\xae\x7e\
+\x19\x7e\xe4\xcb\x9c\x76\xae\x28\x5c\x79\x9c\x5e\x5e\x71\x38\x14\
+\xb5\x56\x9b\xeb\x65\x7e\xe9\x17\xdf\xe7\xe8\xe9\x2f\x51\x5e\x6c\
+\x52\xe8\x97\x12\x8c\xa3\x4b\x0a\x3b\x93\xc1\xef\x85\xea\x44\xa5\
+\xfd\xc4\x89\xbc\x64\x50\x32\xa2\x70\xde\xa4\xbf\x3c\x05\xf0\xe1\
+\xd1\x64\xd6\xf7\x0a\xd3\x54\xd0\x54\xb4\x4a\x82\x37\x51\xb0\x3a\
+\x27\x62\x26\xdf\x2b\x7d\xbb\xe9\xab\xc8\x3c\x00\x4f\xa5\x85\x3d\
+\x03\xd8\xeb\x8c\xbb\xa1\xef\xce\x05\xf0\xf3\x58\x38\x0d\x64\xf9\
+\xf8\xa3\xde\x3b\x6f\x11\x59\x55\x93\x9a\x53\x9b\xe6\x5b\x68\x79\
+\x14\x17\xdd\x27\x74\xbd\x4d\x8a\x1b\x4d\xce\xdb\x65\x95\xcd\x76\
+\xf8\x9d\xdf\x84\x7a\x45\x25\x01\xb5\x3a\x43\xa2\xf1\x25\x3b\x3b\
+\x5f\xe3\xac\x73\x9f\xd0\x5e\x65\x3d\x3a\x22\xb8\xb8\x43\x36\xb3\
+\x22\x98\x38\xe7\x0d\x71\x23\x62\xe0\x66\x00\xe1\x56\x93\xa0\x06\
+\x31\x39\xc9\x64\x0c\x76\x89\x9a\x17\x32\x2e\x16\x14\x5b\x0b\xd0\
+\xa2\xee\xd7\xbc\x90\x76\x24\x24\x89\x1b\x89\xa1\x20\xfd\xf6\x1e\
+\x50\xc6\x26\x47\xbf\xd0\x87\xe1\x90\xf6\x50\x04\x50\xcc\xa2\x09\
+\x23\xd1\x7f\x78\xc4\x3e\xe5\x7c\x93\xb5\x9b\x05\xa2\x46\x8e\xca\
+\x46\x86\xef\x2f\x2c\xd1\x8b\x2a\x74\xfc\x08\x78\x7f\x06\x54\x32\
+\x32\x96\x0e\x47\x5b\x55\x13\xbb\x97\xd4\x89\xfa\x89\x58\x26\x02\
+\x33\xa2\xa6\x55\x66\x65\xab\x05\x5a\xa7\x36\xa1\x53\xa5\xef\x1f\
+\xe2\x17\x0d\xf5\xb9\x7a\x16\x5a\x9a\x19\x25\xcb\xce\x1b\x1b\x76\
+\x2d\x60\x32\x15\xfc\x62\x7f\xc6\x68\xbd\x8e\x85\x75\x69\x31\x6f\
+\xdf\xeb\xd8\x3c\x0d\x60\xb9\xbd\x4e\x26\xa4\xd9\x57\x02\x7b\x58\
+\x71\x3f\x52\xfa\xa4\x33\xe2\x7c\x3c\x55\x3c\xaa\x1b\xcf\x27\x4e\
+\x84\x73\x1a\xc1\x4b\x50\x2a\xd6\xb9\x5d\x0b\xf9\xa3\x85\xe9\x24\
+\x57\xd5\x7d\xde\x11\x81\xb3\x13\x27\x62\x0b\x18\x74\x02\xe8\x3c\
+\xe3\xcf\xc7\x11\x6b\xb9\x7d\x8a\xf5\xb8\x5f\x45\x5b\x03\xb0\x60\
+\xde\x08\xbc\x36\x66\xd1\x14\xec\x8a\x18\xc2\x68\x93\xc3\xf6\x5c\
+\xc6\x76\x21\x96\x1d\x05\xc5\xd6\x60\x83\xd7\x26\x1c\x84\x8c\xed\
+\x82\x00\xf0\x60\x48\xc3\x40\x19\x89\xe0\xe0\xd1\xa2\xdf\x3e\xe6\
+\x6a\x60\x88\xbf\xa5\x0d\x77\xb4\x3c\x0f\xbf\xdf\xa7\x73\xb9\x4f\
+\xfb\x60\x97\x5e\xfb\x12\x77\x30\xe4\xe0\xa2\x45\xd6\xe8\xd3\xbe\
+\x10\x6e\x99\x46\xbe\x4a\xb6\xef\x27\x12\x80\xfc\x5e\x48\xa6\x51\
+\x4b\xe8\xbd\xb4\x81\x93\x28\x1f\xf3\x1d\xe1\x89\x88\x4b\x87\xa4\
+\x16\x96\xed\x00\x3a\x7e\x8f\x80\x5a\xc2\x80\x92\x4c\x28\x8b\x35\
+\x96\x90\x1f\x66\x00\x00\x19\x9b\x49\x44\x41\x54\xe7\xb9\x08\xe7\
+\x25\xc4\x3c\x4f\xeb\x5e\x67\x20\x3d\xef\x52\x7d\x1d\xeb\x5d\x07\
+\xfc\x8f\x62\xe0\xb4\x21\xa7\x3f\x27\xb7\x12\xd8\xba\xee\x7d\xde\
+\xad\xea\x3b\x33\xae\x38\x55\x84\xea\x14\x55\x4f\x89\xce\xd0\x81\
+\x81\x60\x1a\x99\xcd\xe6\x3a\x13\x5c\x6b\x3d\x31\x7b\x6f\xd2\x1b\
+\xb2\xbb\x1f\xcc\x0c\x14\x1a\x74\x82\x69\x8d\x1d\xde\x90\x30\xb2\
+\x63\xe0\xc6\xa0\x8c\x41\xe6\x61\x12\x46\x36\x0c\x86\x94\x8a\x0d\
+\xdc\x81\xec\x86\x28\xb6\x42\x82\x88\xd7\x4a\x5e\x1b\x77\x20\x58\
+\x19\x40\x2e\x10\x77\x50\xc4\x2c\x9a\x84\x83\x90\x6c\xd1\x66\x3c\
+\x20\x66\xf9\x82\x08\x67\x07\x11\x54\x6c\xcc\x81\x18\x76\x03\x65\
+\x6c\xcf\x8d\x47\x90\x4d\x6f\xfb\x95\x09\x81\x66\xad\xeb\xae\x23\
+\xe9\xd9\x98\x77\xc2\x66\x0c\xbf\x38\x72\xd4\xac\xd9\x0c\x97\x5b\
+\xb4\x4e\x81\xd3\xe9\xd8\x58\x59\xf9\xa0\x97\xb9\x8b\xf1\x60\x36\
+\xa8\xd6\xae\x3c\xb7\x4e\xf0\x3a\x69\x90\x0e\x76\xcc\x2b\xa3\x9a\
+\xc7\xa6\x32\xd7\xa1\xea\x3b\x60\x25\x93\x73\x9e\xc7\xb8\xd7\x45\
+\xe6\xa4\x67\xc2\xae\x64\x66\xa4\x83\x64\xdf\x8f\x5a\x44\xd7\xdd\
+\xf4\x48\x68\x42\x1b\xc7\x00\x6f\x75\xb3\x6c\x1f\xef\xb2\x79\x79\
+\x9f\x71\xe3\x52\xb5\x42\x00\xa8\x2f\xbe\x42\xc9\x3f\xc2\x25\x1e\
+\x96\x33\xc8\x89\xb9\x1e\xbb\x01\xd9\xd6\x9b\xec\xda\xa2\x11\xe1\
+\x51\x3c\x13\xda\x35\xc7\x98\x25\xc3\xc3\xb3\x93\x07\x52\x32\xa4\
+\x1b\xd9\x53\x76\x8e\x3d\x18\xf2\x35\x09\x54\x8f\x0c\x0d\x03\xdc\
+\xc1\x50\x0d\x6c\x74\x07\x43\x4a\x86\x17\x33\xb2\x91\x60\x64\xc9\
+\xee\xf2\x7e\xc3\x40\xcc\xc9\x1b\x08\x17\x56\x38\x28\xe2\xf7\xfb\
+\x49\x00\x7b\x31\xe8\x1e\x1d\x26\x00\x3c\x4f\x1b\xea\x27\x49\xfa\
+\x88\xf5\xe7\x97\xeb\xa2\x7f\xb0\x64\xe1\xc1\xa9\xad\x98\xb8\x1d\
+\x1a\x89\x80\x86\x3e\x3a\x37\xca\x54\x54\x85\x8a\x2c\xed\x7f\x5e\
+\x33\xc2\xeb\x4e\xb6\xfe\x9e\x66\x2f\x98\x49\x50\xba\xee\xf3\xf4\
+\xae\x45\x32\x8f\x61\xde\x71\x78\x1e\x80\x13\xf1\x80\x4c\x86\xe2\
+\xc0\x9c\x6b\xd4\x49\x00\xe7\x1b\xe5\x6b\x3d\x10\xcf\x5b\xb4\x55\
+\xdf\x99\xd9\x47\x36\x9f\x39\xc7\x80\x0a\xdc\xc8\xdc\xe2\xa2\xfb\
+\x84\xbd\xfd\x0e\xbd\x6e\x3c\x7f\x7a\xe5\x65\x2e\x46\x0f\xd5\xb0\
+\xc6\x86\x99\x5c\x48\xa6\x3d\xed\xa4\xe9\xec\x1e\x72\x7a\xf2\x50\
+\x04\x3b\xdc\xc8\xc6\xf6\xc4\x0f\x95\xdb\x34\x03\xba\x03\x43\x4d\
+\x13\x75\x23\x7b\xca\xbe\x31\xa0\xc7\x78\x94\x8a\x51\xac\x83\x05\
+\xa3\x7b\x76\x09\x3c\xf1\xe5\xc6\x76\x21\x01\x7c\x01\x74\x61\x40\
+\xb6\x23\x68\x18\xc9\xc5\x63\x66\x4a\x94\x46\xf1\xb0\x14\x3f\xcb\
+\x85\x35\x4d\xb6\xb9\x6a\xf7\xa7\x8d\xb2\xb5\x88\x5e\xfa\xe0\xea\
+\x4e\xfa\x99\x83\x5f\x11\xff\x5b\xa1\x47\x71\x75\xda\x1b\xc2\xec\
+\x75\x12\x1d\x20\x65\xc8\x54\xef\x9c\x23\x9d\xf7\x69\x00\xeb\x3e\
+\xdc\xeb\xf2\x79\xd3\xcf\x5d\x35\xea\xcf\xcd\x6b\xd0\xfd\xbb\xe9\
+\x08\x9d\x04\xf3\x3c\x59\x91\xce\xd8\xfb\x28\xe0\x49\x00\x4b\xf0\
+\x0e\x8a\x21\x51\xc5\x60\xd4\x76\xe6\x12\xc4\xbc\x85\xa1\x7f\x87\
+\x73\x66\xbd\x1a\x7a\xc2\x14\x7d\x31\xf9\xaa\xda\x5f\xa4\x13\x05\
+\xf8\x57\x1d\x98\x1c\xe2\xf0\x88\xa5\xfc\x4b\x94\xfc\xa3\x78\xe4\
+\x6e\x35\x96\x7b\x43\xd5\xe3\x2f\x6b\xdf\x10\xf2\xe3\xc5\x35\xf2\
+\xcd\x57\x66\x99\x58\x6e\x15\xdb\x1a\x1e\x66\xd1\x14\xa0\x8b\xc1\
+\x39\x05\x60\x41\x81\xdd\x8d\x6c\xc1\xb0\xb1\x96\x0e\x07\x21\x36\
+\x39\xf5\x1e\x25\x41\xe4\x56\xbe\x2f\x66\xe5\x31\xde\xdc\xc5\x03\
+\xe0\xe6\x73\x54\x02\x97\xd1\xbe\x33\x17\x30\xb2\x7a\xe3\x3a\x37\
+\x93\xbc\x2d\x13\xcd\xb4\xa2\x6a\x9a\xb6\xf2\x44\xb4\x3a\x71\xc5\
+\x45\x2f\xbc\x36\x39\x7e\x12\x57\x15\xfb\x45\xef\xb9\x1d\x23\x75\
+\xc0\xe9\x06\x67\xda\xaf\x7d\x9d\x7b\x6d\x1e\xe8\x54\x37\xcf\x54\
+\x07\xcf\xe7\xb1\xb8\xd1\x8f\x54\x15\x87\x7e\x2c\xe6\x49\x85\x74\
+\xb8\x59\x6a\xe1\x51\xdb\xf9\x6b\xc9\xa5\xe7\x2d\x98\x8e\x21\xf2\
+\x33\x64\x14\xee\xbc\xd1\x20\xec\xb6\xe9\x76\x32\xaa\xcc\x2d\x51\
+\xd9\x11\xdf\x5a\x61\x41\xb1\xf0\x02\xc7\x0a\xc8\xf2\x78\x98\xe2\
+\x12\x2e\xf4\x6f\x9a\x89\xa5\x9c\xf0\xec\x52\x82\x89\xcd\xa2\xa9\
+\x58\x56\x86\xa5\x25\xa8\xed\xd4\x84\x4a\x7b\xce\xc4\x4a\x7d\x91\
+\xc8\xbf\xa3\xd8\x38\x66\x60\x37\x9f\x53\xf7\x3d\xc6\xec\xd6\x44\
+\xe6\xff\x42\xa3\x32\xc3\x70\x69\x97\xd9\xbc\xa0\x87\x3c\x99\xb5\
+\x7a\x4d\x3b\x38\x9e\x92\x11\x19\xba\x09\x43\x4e\xea\xe1\x79\x7d\
+\x81\xf5\x46\x83\xf3\x2a\x52\x94\xd7\x42\x0b\x80\xa4\x81\x36\xa9\
+\x58\xcf\xf5\x0f\xa7\x75\x6c\xba\xb4\xe8\xa3\x64\x83\xcc\x87\x98\
+\xb7\x28\x74\x57\x5a\x7a\x2b\xaf\x5e\x12\xcc\xd7\xf9\x8a\xd3\xdf\
+\xf3\xa3\x8c\xd2\xb9\x8d\xcf\x8f\x1e\xd3\x8b\xe2\xcc\x36\xd9\xf9\
+\xc0\xdf\xa1\x53\x4e\x8e\x2e\x6b\x9a\xc3\x04\x0b\x37\xf2\x3e\xed\
+\x91\xc5\x02\xc7\x04\xf5\x86\x90\x13\x20\xc6\x79\xa5\xb5\x31\xa0\
+\x98\x55\xc8\x88\x82\x02\xae\x7c\x2c\xa5\x86\x64\x59\xe1\x53\x2e\
+\xcc\xb0\xaf\xee\x89\x50\xab\x2d\xd6\xd0\xd2\x08\xd4\x6f\xe9\xf6\
+\x5a\xd6\xd9\x1b\x62\xbf\x51\x4f\x85\x6e\xf5\x26\x29\xcf\x0b\xdf\
+\xce\x63\xe1\x04\x43\x74\xba\x2a\xa7\x61\xe8\xbb\xc9\x71\xb7\x1a\
+\xf3\xcb\x06\x7e\xb2\x86\xec\xa3\x52\x2e\xe7\x45\x14\x25\xb8\xf5\
+\xa6\xdd\xd7\xe5\xe3\xea\xb5\x85\xf3\xa2\x92\x69\x00\xeb\x3a\xf9\
+\xa3\x02\x13\x12\x9c\x69\x20\xeb\x00\x46\x15\x0b\x7c\xf4\xe7\xc9\
+\x4c\xb8\xf4\x3e\x7e\xd1\x53\x19\x6d\xd9\xbe\xaf\x16\xa1\x7b\x76\
+\xc4\xf1\xd0\xc2\xe3\x0a\xa7\x7d\x39\x53\xa6\x24\x01\x6c\x96\x7b\
+\x6a\x98\xfd\x02\xc7\x84\xf9\x65\xda\x23\x8b\x46\xde\x27\xcc\x2f\
+\x4f\x3b\xc5\x9b\x45\x13\x33\x33\xdf\xb8\xd3\x5d\x61\x52\x07\xeb\
+\xc0\x35\x8b\xa6\x02\xa3\xbc\xaf\x22\x7e\x29\xb6\xd5\xc1\x3b\x0f\
+\xc8\x92\x81\xa5\x2e\x96\xf7\xfd\x8c\x88\xce\x5c\x8c\x1e\x62\x67\
+\x32\x89\xde\x63\x7a\xd2\xcb\x75\x01\x83\x56\x35\x33\xc3\xc2\xea\
+\xb5\xce\x34\x2f\x43\x26\xec\xa4\xdb\x94\xca\x7e\x65\x52\x0f\xeb\
+\x35\x72\xe9\x44\xfe\x79\x57\x89\x79\x85\xab\xf3\xea\x04\xe7\xb1\
+\x9d\x9e\x4e\xfa\xbc\x80\x48\xc1\x2a\x71\x8e\xf1\x91\x9e\x83\x79\
+\x6e\xb4\xa8\x62\x60\x86\x3d\x06\xc5\x10\x33\xec\x29\x7b\xc2\x0b\
+\x02\x42\xb3\xfa\x91\x52\xc2\xe8\x47\x8a\xf9\xd3\x0b\x2c\x3d\xcd\
+\x55\xbf\xdd\x28\xf8\x6a\xac\x86\xaa\x7a\xf6\x77\xd4\xd4\x2d\x39\
+\x57\x0f\x44\xa5\x4b\x98\x5f\xa6\x5c\xec\x61\xac\x64\x69\x8f\x2c\
+\x95\xf2\x99\x70\xa0\x4a\x0f\x82\xd4\xc0\xf3\x40\xa7\xd8\x3a\x36\
+\xd6\xa4\x04\xf1\xec\xd2\xf4\xfd\xb1\xe1\x97\xd8\xff\x1a\x49\x91\
+\xfe\x7c\x9d\x81\xe5\x7d\xb3\x7f\xc5\xd5\x9e\xa5\x0e\x9c\xbc\xbc\
+\xcf\x6b\xa4\x9d\xbe\xcc\x59\x55\x53\xa5\x3f\xa6\x6f\x7d\xa7\x80\
+\xeb\x4c\x12\x46\x87\x04\x64\xba\x87\x82\x64\x4e\xe9\xad\x78\x9e\
+\xd7\x21\xed\x5f\x4e\x97\x52\xcd\x73\x8b\xa5\xa3\x6f\x33\x69\x94\
+\xa9\x36\x5e\x69\x40\xcb\x1c\xe7\xef\xc5\x90\x9b\xc7\xc8\xa1\x59\
+\xc5\xce\x64\x12\xa0\x95\x60\xfe\x28\x36\x5e\xaa\x3c\x5f\x13\xcf\
+\x1b\x95\x06\x60\xad\xbf\xc0\xa7\x6f\xaf\x50\xb9\x5b\xa7\x76\xe5\
+\x2b\x26\x96\x03\x1e\xd5\x64\xa7\xbe\x90\xae\xe5\x4f\x94\x60\x6b\
+\x8d\xdb\x77\xee\xf3\xd9\xcd\x12\xa5\xc5\xca\xb4\x53\xfc\x34\x20\
+\xc1\xb5\x06\x56\x1a\xe8\xd2\x28\x93\xfb\xea\x9f\xa1\xbb\xd1\xd2\
+\x9f\xad\x33\xf3\x3c\x89\x61\x66\x4a\x53\xf0\x66\x4a\x94\x8a\x05\
+\x5a\x65\xe3\xda\xa4\x98\x8f\xd2\x63\x12\xc0\xf3\x58\x78\xe2\x0f\
+\x67\xda\x01\xe8\x80\xd4\x2b\x7c\xd3\x63\x76\xe7\x31\x70\x5a\x23\
+\x26\x7a\x65\x68\xef\xb9\xce\x00\x4d\x4b\x88\x99\x56\x05\xda\x02\
+\x48\xef\x2f\x13\x6c\xce\x31\x54\xc5\xf2\xf3\x58\x78\x50\x0c\x31\
+\xfa\x11\x46\x3f\xc2\x0b\x82\x84\x14\xf8\xeb\x24\xfe\x48\x9d\x2e\
+\x17\xe2\x75\x6e\x3d\x69\x5f\xe8\xb2\xce\x3f\x7a\x8c\x1b\x8c\x58\
+\x08\x97\xa8\xde\x14\xd3\xa6\x26\xc3\xf7\x13\xb3\x0f\x27\xfe\x90\
+\xee\x55\x9b\x17\x4b\x0d\xbe\xb8\xf5\x80\x2f\x6e\x3d\x60\x73\xbd\
+\x4c\xf9\xd3\x2f\xf1\x23\x0f\x3e\x2f\x70\x62\x16\xcd\x84\xfe\xd5\
+\x19\x30\x6d\x80\x5d\xf7\xdc\x75\x9a\xf7\x3a\xf0\xce\x63\xfb\x34\
+\x90\x81\xff\xaf\xb3\xab\xeb\x71\x1c\x4b\xcb\x8f\x3f\x52\x89\xed\
+\x38\x76\x52\x55\xdd\xd5\xbd\xdd\x3d\x3d\xd5\x3b\x2b\xcd\xdc\xec\
+\x0a\x84\x84\xd0\x08\x81\x10\xdc\x00\x17\x08\xc1\x25\xab\x15\x3f\
+\x8a\x0b\x7e\x01\x3f\x61\xaf\xd1\x0a\xd0\x22\x56\xa3\xd5\xd0\x30\
+\x3d\xd3\xd3\x1f\xc5\x54\x77\x57\x25\x71\xe2\xd8\x49\x2a\x8e\xcd\
+\x85\xfd\x9e\xbc\xe7\xe4\x1c\x27\xbd\x96\x4a\x49\x1c\x97\x93\xd8\
+\x8f\x1f\x3f\xef\x37\xc6\xab\xa6\x4d\xd6\xed\x16\x0b\x3c\x97\xc0\
+\xcb\x0d\x23\xe9\xea\x66\xd1\x39\x77\x60\xd7\x43\x06\x07\xfb\x5d\
+\x3f\x67\x49\xdd\x15\x5d\xe7\x9e\x6a\x9b\xa8\xa4\xba\xd7\xa2\x96\
+\xdb\xad\x64\x74\x2a\xd5\x29\x3a\x26\xd5\xbd\x56\x93\xfb\xdb\x3e\
+\xe7\xee\xee\x1a\xf7\x50\xe1\x26\x05\x4e\xed\x61\xab\x3b\xcd\xcf\
+\x6d\xe1\x4a\xf3\x73\x5b\xf2\x11\xab\xc1\x0e\x93\xa4\x20\x1d\x4c\
+\x1e\x0c\xd3\x9d\x45\x92\x6f\xa5\x05\x34\x4d\x51\xfa\x17\x16\xa6\
+\xd3\x04\x63\xfb\x46\xe4\xc8\x74\x7a\x5f\x88\x9c\xe2\x00\x27\x82\
+\x8d\xdf\x9c\x2c\xf1\x38\xa8\x30\x18\x0d\xf0\x69\xff\x1c\xbf\xef\
+\x04\x88\x7e\x14\x34\x77\x0a\xca\x5f\x60\xac\x49\x20\xca\x2a\x0f\
+\xe5\x36\xd3\x4a\x0b\x0e\x46\x13\x7b\x9b\x24\x03\xdf\x77\xdb\x32\
+\xec\x2c\xd1\xeb\x55\xb0\xe3\x33\xbc\x7e\xd1\x95\xd8\xb0\x93\x16\
+\x72\xbe\xac\x26\x49\x9e\x32\xd4\x86\x1a\x39\xc1\x07\x0f\x9a\xdc\
+\x59\x6d\xc1\x0c\x5d\x7f\x85\xb6\x5c\x02\xae\x89\x75\x40\x36\x25\
+\xd3\xa8\x91\xb9\x36\x6f\x46\x69\x0f\x30\x77\xfb\xe8\x0e\xfb\x18\
+\x97\xd3\x83\x49\x3e\x7e\x6e\x4b\x46\x9c\xc9\xf5\x66\xb3\x8b\x9d\
+\x3f\xae\xa7\x0b\x8c\xa2\x91\xf0\x82\x1c\x23\x61\x22\x7b\x20\x6c\
+\x94\xc5\xbb\x0a\xb1\x95\xe0\xb4\x3c\xc7\xe3\x5e\x9d\x30\x9f\xdc\
+\x7e\xa5\x77\x71\xbe\xbf\xc2\xcd\xec\x5b\x54\x2b\x0b\x3d\x58\xc8\
+\xbd\xa0\x69\xba\x0d\xbd\x9c\x90\x4e\x68\x18\x1e\x05\x4e\x1d\x5b\
+\xb7\xc9\x12\x21\x17\x0c\x0c\x4e\xeb\x57\x2b\x0b\xdd\x55\x61\x4c\
+\x7b\x54\xcb\x8e\xf8\x42\x29\x96\x3a\x16\xe6\xe5\xe6\x87\xa2\x5b\
+\x5c\x4e\xb4\x01\xfc\x90\x05\xaf\xf6\x66\x30\xb5\xa0\x6d\x03\x83\
+\x29\xe0\xc0\xc1\x7c\x48\x4a\x70\x20\x7b\x8e\x23\x5e\xe7\x7e\xa9\
+\xdd\x9e\x17\x00\xf0\x7d\xd3\xc5\x62\xa5\x15\x4e\xed\xa1\xd6\x87\
+\x2d\xce\x67\x79\x02\xcc\x6b\x77\xe5\x68\xbe\xbb\x70\xd6\xf1\x05\
+\x56\x41\x0a\x6c\xde\x8a\xb0\xb3\xd4\xb8\x1b\x27\x98\x0c\x9c\x5d\
+\xd2\x10\x80\xfe\xd2\x97\x71\x74\xe8\x44\x50\x1f\x0a\x2e\x33\x38\
+\x38\xdb\xbc\x0f\x6d\x12\x43\x27\x2f\x74\xeb\x9d\x6e\xff\xa3\x4f\
+\x28\x19\x73\xe5\x20\xde\xab\xd1\x22\x6b\x57\xa7\xa5\xdb\xc0\xc3\
+\x5d\x62\xba\xd0\xb2\x09\x54\x26\x69\xa0\x93\x1c\x3a\x3d\x7d\x28\
+\xc0\x70\xcc\x05\xa8\x33\xe4\x48\x13\xab\x12\x43\xf5\x19\x5b\x41\
+\x6a\xbc\xc0\x28\xa2\x57\x85\x16\xc6\xe5\x54\x44\xea\xb4\x9a\xb8\
+\xe9\x9a\x19\x57\x16\x6e\xcb\x54\x14\x1e\x58\x8b\x0a\xae\x7d\x01\
+\x74\x1e\x0b\x26\x56\x67\x4a\x47\xf6\x00\xef\x93\x29\x7e\x58\xd5\
+\x44\xb2\xf0\x72\xf4\x4f\x4e\x76\xe3\x0e\x4c\x7e\x59\x93\xa1\xc5\
+\xb7\xe5\x52\xc3\xe4\x07\x36\x01\xd8\x24\x47\xf8\x7a\xfa\xbc\xe5\
+\x2a\x41\x55\x7d\x85\xc5\xed\x44\x5b\x11\xa1\xde\xea\x46\x76\x85\
+\x2d\x22\x0c\xed\x4a\xf4\x09\x16\xbf\xb3\x78\x2f\x9a\x9e\x1c\xcb\
+\xa0\x1c\xb8\xbc\x01\xe2\x31\xc1\x0a\x9d\x34\x30\x19\x83\xba\x10\
+\xef\xa1\x7c\x08\xca\x55\x38\xd6\xad\x46\x86\x1c\x01\x3a\x4b\x4b\
+\x01\xdc\x05\xaa\x3d\x4d\xac\x2b\xc3\x22\x29\x41\x5d\x82\xb8\x0c\
+\xe1\x79\x13\xf4\x3b\x85\x6b\x6d\x6e\x69\x35\x76\x95\xbe\x16\x9a\
+\x38\x3e\xfb\xe9\x3e\x81\xb8\x3d\xcc\x5e\x4d\x61\xe3\x05\xfc\xa5\
+\x5d\x8f\x3e\xb0\x73\xb1\x4f\x5b\x07\x56\x93\xa1\xa5\xbe\xe6\x72\
+\xc0\xe4\x6d\x38\xa4\x8f\x4d\x40\x27\xcd\xbc\x5d\xdf\xe0\x7f\x92\
+\x7b\x62\x06\xb0\xc9\x88\x53\xd7\x39\x4d\x37\x64\x92\x13\xb3\x64\
+\x86\x69\x69\xed\x0d\xe1\x3e\x74\xfb\xe7\xc0\x55\xf5\xb0\x4e\x27\
+\x9a\x7c\xb9\x52\x89\x94\xc6\x43\xa1\x0b\x39\x1f\xca\x0f\xa6\x85\
+\x3c\x12\x26\x39\xa2\xa6\x54\xf2\x10\x73\x1f\x96\xa4\x8b\x89\xa1\
+\x4d\x99\x6c\x5c\x4a\x10\x80\xb9\x51\xc8\x7d\xd5\x54\xc9\x2d\xec\
+\x86\x66\x56\x34\xff\xae\xf5\x50\x19\x08\x4d\x4c\x8d\x05\x33\xdc\
+\x21\x73\x1f\x89\x74\xcc\xe8\x74\x88\x45\x72\x89\x13\x7f\x52\xf7\
+\x27\x5e\xb9\x40\xaf\xd8\x97\x13\x2a\x58\x0f\x81\x51\x35\xd0\xd2\
+\xc2\xac\xad\x0f\x19\x7e\xba\x0b\x20\x74\x6d\x2c\xe1\x88\x68\xdd\
+\xa1\x88\x11\xdd\x7a\xa2\x38\x92\xc0\x4b\x60\xb6\xe7\x89\xdc\xb1\
+\x11\xfa\xea\x08\xde\x9c\xf0\x90\xc1\x67\xca\xf1\x35\x05\x2e\x78\
+\xd4\x4e\xa7\xc7\x8f\xc9\x44\xe3\xeb\x88\xf9\x78\xd2\x8d\x29\x3a\
+\xc7\x75\x30\xf9\x81\xe9\xf5\x02\x15\x82\xd0\x86\x9f\xdb\x22\x7b\
+\x4d\x05\x3d\x81\x76\x3d\x5d\xec\x35\x5b\xa1\xe7\x04\x50\x5e\x38\
+\x1b\xf4\x3b\x52\xab\xd7\xb9\xdb\x17\x9d\x7d\xd2\x7c\x86\xc5\xdd\
+\x9d\xd0\xc4\x70\x2f\x77\x43\xd5\x8b\x97\x08\x58\xda\x42\x55\xbe\
+\x44\x52\xc5\x20\x8d\xd8\x2f\xfd\xda\x4f\xcc\xa5\x81\xca\xc4\x3a\
+\x66\xe6\xa0\xa5\xff\x21\x16\xe7\x6c\xae\xfb\x5f\x75\x5d\x1b\x23\
+\x93\xe4\x28\x9c\x21\xc6\xaf\x5c\xdc\xac\xbf\x16\x09\xf1\x04\x34\
+\x35\xb9\x66\xd0\xcf\x05\x03\x73\xf0\x4e\x4b\x0b\xd3\xd2\x92\x58\
+\xd0\x94\xa3\xa0\x1a\x89\x26\xd9\xa1\x36\x25\x31\xe5\x2f\xe8\xa4\
+\x0f\xaf\x34\x69\xd3\xf9\xc7\x48\x14\x62\xbe\x7b\xa8\x8e\xce\x54\
+\xb3\xd2\x4a\xd4\x2e\x02\x40\xd6\x0c\x55\xcc\xd2\x12\xb9\x5f\x4a\
+\x12\x41\x65\xe3\x2a\xb4\xf6\x52\x34\xf9\x42\x17\x13\x97\x4d\x62\
+\x74\xef\xa0\x42\x1c\x87\x75\xdf\x3a\x40\x8c\x32\xd8\xe6\x1e\xe6\
+\x1f\x80\x37\xf3\x7a\xbf\x34\x8f\x5a\x32\xc6\xc7\x53\x56\xba\x5f\
+\xdf\x95\xcb\x6a\xb1\x1f\xb1\xe3\x4c\x5c\x6e\x33\xac\x9c\x07\xe2\
+\x39\x25\xe3\x98\x34\xb3\xee\x71\x2f\xf2\xe6\x1c\x17\x45\x22\x56\
+\x0f\xfc\x1e\xec\x74\xbc\xe7\x21\x20\xa0\xf1\x6e\x36\xc4\x00\x94\
+\x27\xcc\xbd\x12\xd5\xbc\x12\x65\xf7\xc7\x30\x27\x67\x60\xb5\x5a\
+\x58\xcd\xef\xd5\xb9\xcb\xa6\xeb\xb9\x36\x02\xa7\x7e\xd6\xa1\xd4\
+\x46\x1d\x90\x4d\xf2\xa3\x2d\xe4\xcc\x75\x2f\x31\x67\x1f\xb5\x1e\
+\x26\x90\xda\x7e\x65\xcc\xad\x38\x74\x17\x54\x2f\x16\x0a\xb6\xf0\
+\x1e\xcf\xd4\x5d\x7e\x53\xac\x44\xff\x89\x34\x7a\x03\x0f\xa7\x70\
+\x46\x29\x06\xf7\xea\xde\x13\x9b\x0f\xcf\x45\x90\x83\xe7\x50\x44\
+\xa7\x43\x3c\xb9\xf3\x90\xe6\x33\xf8\x4d\x94\x38\xdf\xd4\x43\x1f\
+\x6d\x1d\x5b\x12\x08\x7b\xdb\xeb\xbd\x9c\x86\x43\x40\x56\xf5\xb5\
+\x0a\xe8\x63\x16\xce\xd8\x39\x06\x58\xe0\xf9\x5e\xa4\x8e\x17\x86\
+\xf6\xdc\x40\x54\x6b\x88\x26\xe2\xe9\x8e\x8d\x3f\xc6\x0d\x26\xf9\
+\x9a\x59\x36\x9a\xc8\xd3\x50\xf4\x2c\x15\xa0\xf2\xfc\x8d\x61\x77\
+\xd0\x9a\xa8\xa3\x03\xe4\xb1\x9e\x97\x63\xa2\x94\x7b\xb2\x2d\xb4\
+\xb5\xd9\x6a\x41\x68\x0b\x19\xc1\x81\x6c\x62\x61\xdd\xf7\xe5\x7a\
+\x1a\x00\x46\xd1\x68\x3f\x9f\x98\x9a\x72\x37\x15\x1c\xd4\x7f\x22\
+\x9c\x3d\xc1\x12\xe3\x5a\xdf\x36\xde\x89\xce\xbd\xcf\xb5\x61\xfd\
+\xd9\x76\x86\xbb\x7b\x75\x7b\x57\xca\x7c\x13\x86\x9d\x0a\x3c\xdb\
+\x09\x5a\x59\x15\xa8\x13\xd5\xf9\x63\x9b\xf1\xf7\x31\x80\xe5\xa0\
+\xa7\x7d\x2f\x57\x09\x5e\xbf\xe8\x4a\x4c\xcc\x7b\xad\xf1\xdb\x96\
+\xea\x13\x8e\xe2\x08\xe9\xa2\xb7\x37\xb3\x58\x3d\x31\x6a\x6e\x00\
+\x35\x64\x59\x15\x19\x2a\x27\x6c\xad\x6d\xa3\xfe\x13\x62\xe2\x53\
+\xc3\xc4\xea\xc9\xd5\xb5\x5a\x35\x19\x74\x2a\x60\x8e\xc9\x37\x6e\
+\xf3\x31\x9b\xd2\x2e\xad\xb4\x12\x00\x0f\xac\x4c\xfc\x71\xe3\x8e\
+\xf6\x69\x0a\x65\xf3\xf0\xb4\x95\x56\x7b\x41\x96\x41\xb1\xa8\xbb\
+\xcd\xb3\xa0\x50\x69\x0f\x44\x62\x7c\xe8\x47\xf0\x86\xf5\x7b\xd6\
+\xfd\x8e\xf0\x29\xd3\xa8\x31\x00\xb0\xab\x39\x22\x27\xc2\x03\xab\
+\x80\x87\xd3\xba\x91\x20\x73\xdd\xd9\x6d\x40\xe2\x8f\x92\x5b\xad\
+\x61\xe5\x36\x76\x3e\x96\x85\x4d\xe0\x4f\xdd\xfa\x87\x79\xbd\x58\
+\x62\x61\x5d\x57\x47\xea\xde\x23\x5f\x69\x35\x1b\x17\xfe\x5a\x78\
+\x24\x4c\xc5\x97\xaa\xcb\x27\x9d\xee\x32\xd5\xac\x6d\x6a\x94\x01\
+\xc4\xda\xab\x22\x83\x33\x8c\x04\x83\xf7\xcf\x46\xe2\xe4\xea\x12\
+\x7e\xd4\x0b\xc1\xf4\x5c\x17\xbc\x38\x54\x1c\xba\xd7\xe1\xbd\x69\
+\x98\xcd\x41\x29\xb4\x71\x90\x0a\xb6\xcd\xaa\x00\x0b\x00\x55\x16\
+\x0a\x83\x8f\xef\x53\xf5\x80\x50\x24\xaf\xcd\xfb\xc1\xf3\xb8\xd5\
+\x0c\xb6\x51\x54\x03\x31\xb6\x12\x5c\xc4\x0f\x1b\x89\x53\x4f\x26\
+\xe8\x8c\xba\x3b\xe3\xae\xd1\xc3\x3f\xfb\x7c\x84\xde\x27\xcf\xe4\
+\xa8\x6b\xd3\xe3\xc3\x2e\xb7\x19\xa6\x9b\xa6\xc6\x6c\xe3\xed\x19\
+\x66\x5c\xcf\x92\x4e\x56\x0d\x3b\xf5\xaf\x8d\x6d\xdb\x0c\x3f\x75\
+\x7d\xea\x04\x48\xfe\xf7\x4a\xb0\x9b\xe9\x24\xaa\x00\x9e\x25\x33\
+\x31\x8a\xcb\x9e\x27\xda\x72\xa2\xb6\x25\x1c\x76\x44\xe1\x69\xe5\
+\x84\x98\xae\xe7\xa8\x9c\x50\xea\xe9\xa6\xea\x67\x5e\xa8\xba\xb8\
+\x9d\xec\x49\x13\xf5\xf6\x7f\x6c\x95\xb3\xca\xde\x26\xa3\xd4\xc4\
+\xcc\x54\x9d\x41\xc0\xa5\x3b\xc4\x02\x75\x24\x6e\x01\x26\x2f\xb2\
+\x50\x44\xed\x74\xee\x35\x1e\xcc\xa0\x48\x9e\x49\x37\xab\x44\x43\
+\x4c\xdc\x71\x7b\xe8\xb9\x01\xbe\x7f\xf9\xc3\xee\x77\x01\xf8\x9c\
+\x0d\x02\x4d\x92\x54\xcc\x09\x21\x36\x0e\xee\x3f\x42\xf7\xec\x44\
+\x74\x01\x02\x00\xa7\xc9\x36\xb4\x6d\x27\xc0\x13\xab\x40\xb9\xcd\
+\x30\xec\xd4\x01\x06\x02\x35\x67\x47\x4a\xc6\xf1\x31\x17\x60\xa7\
+\x6d\x49\x82\x70\x29\x62\x02\xb0\xca\xbc\x6d\xbe\xe9\x55\xba\xc1\
+\xdb\xd5\x35\xd2\xab\x97\xc2\x33\xc1\xbd\x02\x34\x89\x48\xa6\xd1\
+\x06\xd4\xe1\x2e\x47\x42\x57\xe7\xd6\x6a\x54\x4e\x37\x12\x38\x3d\
+\xc7\xc1\x76\x3a\x43\xff\x6c\x64\xd4\xcf\x1c\x58\xbc\xf7\x9b\x8e\
+\x41\x75\xfe\xed\x36\xcd\xae\x6e\xdf\x16\x1c\x31\x7d\x2e\x67\xe2\
+\xe5\x76\x0b\xdb\xaf\xa4\x47\x8a\xd6\x95\xb9\xa5\xf5\x13\x93\x57\
+\xc3\xc4\xba\x26\xf0\xaa\x9d\xe3\x37\x93\xb5\x08\xce\x90\xb7\xe1\
+\x7c\xd4\x81\xfb\xf0\x3e\x2e\x43\x16\x6e\xe6\x29\xaf\xb1\x8d\xcb\
+\xa7\x4f\x11\xfa\x35\x59\xd1\xd0\x19\xda\xa7\x5d\x6e\x33\xbc\xa9\
+\x5c\x09\x54\x34\x8c\xdc\xe4\x5d\xa0\xf7\xc7\xab\x12\xa7\x3d\x5b\
+\xcb\xae\xe3\x55\x89\xb0\xe8\x68\xe5\x84\x6e\x7b\x95\xf1\x29\x29\
+\xe9\xd5\x7f\xfc\x37\x92\xdb\xaf\x76\x1d\x21\x99\xf6\x34\xc9\x08\
+\x62\x62\x0a\x7a\xb4\xb1\x30\x6f\x61\x4a\x07\xdc\x73\x1c\x09\xc8\
+\xa2\x69\x34\x63\x5b\x1d\x38\x4d\xef\xa9\xcc\xad\x26\xc6\xb7\xe9\
+\x5a\x3e\x35\x95\xeb\xec\x63\x42\xcd\x94\xac\xce\x41\xe7\x39\x8e\
+\xa4\x63\xcb\x7c\xe7\x27\x26\xaf\x05\x07\x28\xff\xcc\xee\xb0\x2f\
+\x12\xe7\x4d\xe0\x35\x1d\x17\xd2\xaf\x99\x7d\x87\xb9\xdb\xc7\x74\
+\x36\x13\x49\x3d\x6f\x5f\xbe\x07\x92\x7a\x9f\xe1\xa3\xcb\xfa\x5c\
+\xcf\x2d\xc9\x1b\x95\x4d\x5e\x20\xcd\xeb\xe3\xef\xfa\x1e\xb6\x6c\
+\xfc\xaf\x7c\x89\x27\xbb\x94\x45\xce\xc6\xd3\x8d\x27\x01\x97\xc0\
+\x36\xec\x2c\xf7\xf4\xf3\x78\x55\x8a\xf7\x52\x77\x63\xf4\x1f\x9b\
+\xc0\x4d\xfb\x2f\x9c\x21\x7e\xfb\xd5\xaf\xa5\xf9\x14\x1c\xc8\xa6\
+\x89\xf2\xb3\xa4\x4e\xfa\x99\x34\xc7\x7e\x52\xb6\x57\x3b\x70\xc7\
+\x3f\xf5\x28\xa3\x5e\xc0\xe9\x74\x23\xf5\x2e\xd3\x55\x90\xe8\xc0\
+\xcb\x53\x13\xb9\xe1\xa8\x1a\x80\x87\x5c\x6f\x9c\xe9\x8b\x79\xa9\
+\xcd\xf1\x6d\xbb\x68\x54\x23\x8e\x83\x92\xfc\xc4\xc4\xc4\x7d\xec\
+\xb6\x25\xd7\x1b\xe5\x53\xa8\xbf\xab\xca\x42\x2d\x78\x75\xe7\xc4\
+\x24\x73\x86\x51\x84\x37\x3f\x2c\xf1\xcd\x2b\x07\xd3\x69\x82\x22\
+\x5f\x8a\xea\x8e\x7a\x0e\x78\x25\x6a\x1a\x89\xb5\xd7\xb7\x77\x28\
+\x72\x17\x45\xbe\x84\x43\x21\x6d\xf2\x13\x13\x40\xa7\xc1\x4e\x4c\
+\x8b\x75\x0a\x80\x9f\x58\xc5\x4e\x3b\x37\xa0\x27\xe0\x11\x8b\x1b\
+\x83\x26\x49\xbc\x97\x2b\xac\x3e\x17\x92\xe6\xe6\x46\x04\x39\xc8\
+\x33\xc1\xdb\x38\x71\x16\x1e\xd9\x9e\x08\x66\x94\x83\x18\xb3\x64\
+\x06\x07\xcd\x4c\xe5\x23\xb4\x30\xf7\x04\x78\x8e\x83\xc5\xed\x04\
+\x9e\xe3\x48\xae\x32\xea\xef\xa6\x7a\x1b\x54\xef\x01\xe5\x14\xd0\
+\xfe\xee\xee\xae\x85\x5f\xd4\x54\x2f\xf7\x31\x52\x47\xc7\xc2\x6a\
+\x6f\x0d\x2e\x21\xd4\xe8\x1b\x4f\xbf\x24\x16\xa6\x8b\x83\x00\x4c\
+\x2e\xb7\xe5\x76\x2b\x19\x81\x3c\xeb\x4d\x07\x50\xb5\x7b\x3c\xfd\
+\x51\x47\x20\x7e\xec\x6e\xcb\x14\x9d\x41\x0f\x0f\x7b\x05\xfc\x4e\
+\x17\xae\xef\x89\xea\x8e\x4d\xe8\x8a\x2a\x90\x4d\xe8\x8a\xfc\xe3\
+\x9a\x85\x8b\x66\x9e\xdd\x52\x61\xe2\x44\x49\x1a\x67\xaf\x87\x9d\
+\xa5\xc4\xca\xa9\xbb\xc1\x30\xeb\x4a\xa0\xa7\x6d\xc2\xa2\x23\x19\
+\x89\x7c\x5f\xd3\x8d\x07\xc4\x89\x00\x2c\xdf\xaf\x90\x2f\xcd\xb6\
+\x54\x9f\xf7\xf5\x8b\x97\xcd\x60\xee\x70\x2f\x5a\xc6\x17\x5e\xb5\
+\x6c\xcf\x13\x91\x04\xcf\x7b\x1a\xb7\x2d\x9c\x39\x97\xdb\x2d\x86\
+\xdd\x81\x30\xe2\x74\x8d\xab\xd5\xb4\x47\xee\xfe\xe2\x21\x5e\xd5\
+\xc3\xa0\xba\xca\x78\x9e\x6e\x9b\xdc\xd1\x31\x35\xff\x0e\x04\x42\
+\xd5\xe8\x35\x95\xdc\x7b\x8e\x03\xdb\xaf\xa4\x80\x07\xb9\xd5\x82\
+\xd0\x16\xc1\x11\x62\xe1\x2a\xb4\xe0\xa4\xb2\x8c\x30\x75\x16\xd2\
+\x1d\x6f\x6e\x10\xf2\xf7\x29\xf4\x3c\x9f\x6d\xb1\xcd\x3d\x89\x89\
+\xa9\x8e\x52\xf5\x19\xd7\x4c\xec\xa2\xf0\x7b\x58\xa1\xaa\x99\x98\
+\xc0\x35\xdd\x78\x78\x68\x25\xe0\xaf\x09\x58\xc3\xce\x52\x7a\x44\
+\x5c\x77\xc9\x89\xf3\x44\xda\x86\xdc\x62\x61\xd1\xc1\xb0\xb3\xac\
+\x7d\xbd\xcd\xb6\xc4\xb0\x62\x7d\x12\xe3\xb4\x67\xcb\xc0\x0f\xd6\
+\xe2\xf9\xfa\xf5\x02\xe9\xd5\x4b\x6c\x42\xb7\x9e\x13\xcd\x0e\x1e\
+\x6f\x88\x0d\xd4\x15\x0c\x43\xbb\xc2\x30\x6b\xa2\x4f\x4d\x17\x9f\
+\x0f\x49\x75\xf0\xd6\x46\x27\x9b\x9f\x60\x95\xd1\x78\x78\x5b\x6d\
+\x72\xa2\x73\xfc\x4f\xd7\x73\xb1\x4f\x62\x61\x9d\xaf\xf7\xa4\xe9\
+\x58\xa9\xfa\x94\x55\xc0\x91\x67\x86\x03\xfa\x90\x71\xa7\xcb\x6d\
+\xa0\xd7\x64\xc8\x91\x06\xe6\x79\x14\xdc\x77\x4c\xdb\x02\xc0\x26\
+\x8a\x85\x37\x42\x0d\x7a\x98\xc2\xee\xf7\xb0\x33\x04\x79\x5e\x8a\
+\x64\xc0\xe3\x05\x96\x18\xa3\xc2\x04\xd1\xb8\xc0\x93\xc1\x02\x71\
+\x1c\xd6\x4c\x3c\xdf\x7d\xf7\x7c\xba\x82\xb3\x7a\x25\xd8\xb8\xd3\
+\x74\x8c\x92\x34\xf1\xb0\xb3\xc4\x0f\x55\x2c\x58\x31\xce\x77\x80\
+\xae\x57\xb0\xc7\x86\x31\x13\x3f\x16\xeb\x38\xab\xbe\xa9\x5c\x20\
+\x89\x05\xa8\xa7\x1b\x0f\x48\x62\x90\x3b\x2f\xeb\x9e\x88\xfd\xa5\
+\x8b\x40\x7c\xe6\xb0\xb3\xac\x2f\x06\x27\xd8\x95\xab\xa4\x85\xf9\
+\xb6\xfa\x61\x04\x60\x2a\x45\x75\x48\x62\xf0\x4e\x3e\xba\xe2\x51\
+\xf5\x64\xab\xc6\x0a\x9f\x67\xa1\x03\xa0\x3a\x70\x85\x77\xa4\xe7\
+\xda\xd5\x94\x3e\xc9\x3f\xbb\xad\x9e\x8d\xbe\xab\x3b\xb0\xb5\x17\
+\x98\x2e\x24\xdd\xa6\x45\xa9\x7e\x8e\x7a\xae\x99\x32\xdd\x4c\x59\
+\x6c\xc7\x32\x30\x65\xb4\xd1\xfe\x74\xc3\x1a\x01\x20\x9d\x00\xeb\
+\xdb\x3b\x3c\xff\xb0\x5b\x77\xb3\x5d\xd6\xe3\x31\x06\x95\xe8\x38\
+\x5f\xdd\xdd\x4a\x6c\x4c\xe7\x37\x28\x4f\x60\x13\x58\xab\xd9\x5a\
+\x32\xe4\xac\xea\x3e\x86\x9d\x65\xbd\x3e\x89\xa5\x6d\xb8\x8c\xa8\
+\x66\x6b\xa1\x9b\xf9\x73\xa1\xaf\x1b\x96\xe6\xff\x43\x7a\xba\xdc\
+\x66\x98\x06\xeb\x5a\x27\x33\xd9\xb1\x4a\x37\x42\x0f\xab\xbd\x1f\
+\x82\x7e\x47\x00\x75\x75\x6f\xe7\x8f\xa5\x64\x77\x0a\x35\xeb\xe6\
+\x7c\xa8\xc6\x12\x3f\xe0\x6a\xc0\xc3\x04\x5c\x93\x1b\x8c\x33\xa6\
+\xee\x7d\xce\xda\xc7\x74\xb1\xe4\xdf\x55\xd5\xe3\x6d\x81\x91\x43\
+\x2e\xb7\xdc\x2f\xf7\x0a\x43\xb9\xeb\x4d\x8d\xf2\x05\x96\x5c\x37\
+\xa7\x76\xea\xa7\x7e\x77\x6a\xdf\x09\x7e\x81\xa8\x13\xaf\x7a\x6e\
+\x80\xb3\x51\x84\xce\xa0\x07\xcb\xbe\xc4\xf5\xba\x10\x59\x6c\x6f\
+\xe6\x7d\x9c\x3b\x1e\x36\x93\xb5\x48\x8e\x9f\xbb\x7d\x5c\x2f\x2a\
+\x91\x14\x0f\x00\x61\x3f\x93\x99\x78\xd8\x59\x0a\x56\x15\x60\x66\
+\x8c\x8b\x38\x91\xb6\x91\xc0\x1e\x75\x85\xac\x48\xfc\x58\x68\x5d\
+\xa1\x79\xe3\x64\xef\x7f\x54\x23\xb2\xdc\x66\x62\xbb\xd3\x9e\x8d\
+\xe5\x2a\x11\x7a\x58\x5d\x28\x4b\x0d\x80\x68\x41\x35\x2d\x2d\x94\
+\xc5\x7b\x6d\x29\xd2\xa1\x72\x1d\xdd\x49\xe4\x27\xf3\x10\xe0\x38\
+\x33\xf2\x7e\x0d\xa6\x6d\x0f\x75\x83\xd7\x7d\x66\xdb\x76\x1f\xb3\
+\x88\x64\xf8\x06\x98\xdc\x73\x91\xfb\x25\xfc\xdc\xde\x63\xe4\xa1\
+\xfb\xc9\x9e\xf1\xa6\x16\x26\x70\x03\xd8\x14\x45\xa4\xa1\x3c\x6e\
+\xee\xe1\xee\xee\x1a\x5b\x44\x78\x38\xaa\x5b\x53\x3d\xe8\xd6\xb9\
+\x13\xe3\xe5\x5b\x3c\xe8\x7c\x03\xb8\x97\x75\xd4\xae\x09\x74\x6c\
+\xc7\xff\xb7\xb7\x4f\x92\x13\x41\x79\x02\xdb\x8a\xba\x98\x6e\x3c\
+\xc4\x79\xb2\x0f\xe6\x38\x01\xbd\x2f\x69\x60\x0e\x76\x26\x2b\x88\
+\xd5\x25\x0d\xdd\x6c\xab\xfa\x9e\xd5\x85\x1b\x8f\xdb\xec\x7a\xcf\
+\x23\x41\x57\x31\x01\x95\x06\x25\x72\x0d\x4c\x2c\xbc\x45\xf4\xd1\
+\x27\x98\x37\x0d\x51\x83\x15\x6d\xfd\x21\xda\xc0\xac\xbb\x05\x9b\
+\x52\x37\x75\xb9\x16\x6d\x6e\xbc\x63\xbd\x18\x5a\x49\x51\x05\x70\
+\xcb\x99\x30\xe6\x72\x7f\xe7\xbe\xb3\x82\x54\x7c\x9f\x2c\x2d\x31\
+\x99\x4d\x8c\x95\xd3\x04\x4c\x7a\xce\xbd\x32\xfc\x58\xf1\xc1\xf0\
+\x94\x3b\x31\x72\x00\x7f\xd8\x83\x1f\x37\xc7\xaa\x61\xe2\xeb\xcd\
+\x4f\x10\x14\x57\x52\xd8\x79\xd3\x74\x42\x27\xfd\x4c\x72\xd1\xcd\
+\x57\x75\x16\x1b\x81\x31\xf1\x63\x09\x98\x56\xd4\x05\x92\x58\x0b\
+\x56\xf1\x3e\x03\x28\x67\x65\x6e\x1c\x56\xb3\xb5\xb4\x6f\xba\x10\
+\x54\xc6\xa6\xf5\x81\xdf\xc3\x8b\xcd\x4f\x91\x5e\xbd\x14\x09\xd5\
+\xf4\xe3\x79\x13\x14\x6a\x88\x4d\xae\x35\xce\xc2\x6a\x05\xf2\x31\
+\x27\x5f\x95\x13\x3a\xad\xa9\xb2\x3a\x4f\xb9\x34\x4d\x33\x32\x25\
+\xfb\xa8\x6c\x7b\xc8\x07\x7c\x28\xa0\xa2\x3e\xaa\x1d\x83\xd4\x8b\
+\x64\x13\xc5\x52\xa9\x3e\x00\xb8\xe5\x0c\xcf\xce\x9f\xe0\xcf\xfe\
+\xe6\x8f\xf1\x57\x7f\xfe\xb7\x78\xf6\xd9\x97\x58\xa0\xc2\x64\x36\
+\x91\x59\xb0\x39\x2f\x9b\x66\x3a\xec\x26\x74\xb5\xd3\x92\xd4\x7e\
+\x74\x52\x0e\x45\x08\x5c\x3e\x7d\x8a\xfb\x71\x1d\x4e\x06\x80\x59\
+\xf1\x19\x46\xe3\xe7\xc8\x70\x87\xce\xa8\xdb\x64\x10\xb1\xd6\x01\
+\xf8\x0c\x1e\x4e\x51\xf8\x3d\x0c\xed\xb1\x38\xd7\x76\xe2\xc7\x12\
+\xc3\x72\x46\xad\xac\xf7\x42\x22\x70\x30\x73\xff\xb1\xca\xc2\x56\
+\xd4\x15\x4c\xfc\xc4\x2a\x60\x45\x5d\xf1\xa8\x03\x3f\xbf\x28\xaa\
+\xd9\x1a\xa9\x13\xe0\xd3\xd9\x4b\xc1\xc4\xbc\x13\x4f\x14\x47\xa2\
+\x97\x30\x67\x61\xf2\x0d\xeb\x0e\xde\xa1\x5b\xab\x89\x05\x8f\xd1\
+\xc2\xdc\xd0\x3a\xc4\xfc\x87\x7a\x4d\xa8\xdf\xe1\x50\x51\xa9\xe9\
+\xbb\xea\xa6\x37\xa9\xfb\x26\xd9\xc0\x8d\x37\x4a\x8c\xbf\xff\x78\
+\x88\xbf\xff\xbd\x2f\xf1\x77\xff\xf8\x17\xf8\xcb\x5f\xfc\x09\x7e\
+\xf6\xa7\xff\x00\xfb\x49\x2c\x7d\x26\x75\xf3\x21\x37\x58\x5c\xd5\
+\xf3\x38\xa8\x6b\xa8\xea\x37\xe6\xcf\xe9\x7c\xde\x8f\x87\xb0\x51\
+\x4f\x0a\x0d\x47\x17\xf5\x36\xc9\x7f\xe1\xf5\xb2\xbb\xbb\x58\x9a\
+\x69\xb4\x3c\xf1\x68\x89\x31\xdc\x7c\x85\x69\xb9\xcb\x66\xb3\xe3\
+\x3c\x41\xe2\xc7\xd8\x66\xd7\x20\x40\xab\x8f\xfc\x56\xcf\x19\x95\
+\x18\x94\xc0\x4b\x86\xdc\x6d\x92\xe0\xdd\xed\x18\xf3\x6c\x81\xb0\
+\xe8\xe0\xa4\x77\x82\x6a\xb6\xc6\xbb\xe7\xaf\x50\xcd\xd6\x38\xef\
+\x9f\xc1\x19\x8d\xa4\x30\x36\xff\x0c\xee\x99\xa0\x36\xaa\xd6\xc0\
+\x92\x7c\xc2\x94\x27\x51\x0e\x62\xa9\x31\xb6\xea\x4b\xd6\x25\xed\
+\x10\x00\x45\xb7\x74\xc7\x39\xe8\xb3\x35\xe9\x5c\x75\x3d\x1f\x35\
+\xdb\xa6\x5f\x0f\x31\xf1\x31\x3d\x29\xd4\x46\x31\x3c\x22\x48\x39\
+\x17\x6d\xee\x3b\x49\x62\x04\xb5\x3f\xf9\xe1\xe8\x1c\xdd\x2f\xde\
+\x62\xf4\x49\x81\x3f\xf8\xf2\x8f\xf0\xf3\x5f\x7c\x81\xcb\x67\x7f\
+\x2d\xa2\x98\xab\x22\xdb\xeb\x16\x9a\x58\x95\x54\xa1\x4c\x2c\xad\
+\x66\xaf\xd1\x7a\xf2\x04\x95\xf8\xac\x66\xe0\xef\xd6\x78\xbb\x75\
+\x45\x7f\x35\xee\x52\xe5\x7e\x66\x11\x17\xa8\x0a\x8c\xec\x4a\xcc\
+\xb1\x73\x09\xa8\x63\xc3\x8f\x13\xc6\x9a\x06\xe0\xdb\xec\x1a\x56\
+\x1c\x23\x9e\x25\xb8\xad\x96\x38\x8b\x81\x69\x00\xfc\xe7\x2f\x57\
+\xf8\xfa\xdf\xfe\x19\x0f\x1e\xd4\xc2\xbd\x73\xd1\xc3\xe6\xdd\xae\
+\x3d\xe7\xa3\x1f\x79\xf8\xf4\x93\x3a\x09\xda\x7d\x10\xe3\xd3\xfe\
+\x39\x42\xab\x40\x1a\x75\x11\xbb\x8a\x5f\xd3\x09\x81\x0a\xda\x06\
+\x28\xa9\xd5\x83\x3d\x7f\x2f\xaa\x39\x26\xdb\x9d\xe1\xc7\xa7\x27\
+\x1d\x0a\x39\x93\x9c\xd0\x59\xfc\xe4\x3e\x53\xf7\x43\xfb\x56\xd7\
+\x07\x56\x86\x12\x83\xdf\xc9\xe8\x52\x0d\xa4\x43\xcf\x79\xe4\x8f\
+\x86\xb5\x8b\x01\x39\xa0\xca\x8a\x8d\xf4\x7b\xd5\x32\x25\x71\x9c\
+\xb3\x3e\x86\x91\x05\x7f\xd8\x03\x3e\x3c\x83\x5b\x14\xf0\x56\x2f\
+\xf0\xfd\xd5\x02\xb8\xfd\x55\x3d\x30\xb3\xf9\xcd\xab\x22\x03\x16\
+\x01\x3a\x00\xd0\x54\x6d\x6c\x8a\x15\x62\x58\x02\xcc\x71\xb1\xaa\
+\x47\x7e\x35\xc6\x17\xc9\x82\x78\x66\xc3\x19\x45\x78\xd0\xb4\x26\
+\xeb\x3d\x39\x87\x0b\x1f\xd1\xaf\x6a\xc9\x78\xb3\xfe\x5a\x9a\x3e\
+\x1b\x57\x96\x16\x9b\x1b\x3f\x87\x9b\x03\x98\x5b\x70\xd7\xaf\x17\
+\x18\x9f\x2d\x85\x41\x35\x06\x80\x6c\x29\x1e\x01\xe0\xdd\x6d\x08\
+\xf7\xcc\xf0\xde\xb7\x5b\xb8\xcd\xff\xdf\x26\x09\xbe\xbf\xba\xc2\
+\xbf\xfe\xcb\x3f\xc9\x9f\x78\x0d\x54\xa7\x7d\x5c\x6c\x17\x58\x2f\
+\x6f\xf0\xdd\x04\xf8\xee\xb7\xff\x2e\xde\xfe\xf1\xb3\xc7\x78\xfa\
+\xf9\x1f\xe2\xfe\xc3\x07\x58\x84\x13\x49\x73\xf6\xc3\x11\x46\x0d\
+\x4e\x46\xb6\x27\x98\x38\x5d\xf4\x10\x56\x2b\xc0\x89\x30\x99\x5a\
+\x70\x06\x89\x18\x0d\xe9\xe6\x1e\x0a\xec\x2a\x2c\x3e\x66\x0c\x80\
+\xae\x2f\x9a\xee\x42\xe0\x51\x32\xbe\xaf\xf2\x40\x5b\x2b\xb3\xc6\
+\xcd\x8c\xc6\x5c\x5b\x11\x29\x00\x9c\xc6\x31\x12\xab\xc2\x69\x15\
+\x8b\xdb\xfc\xc6\x8a\x80\xb4\x10\xc0\xad\x13\x78\x02\xac\xb1\xd8\
+\xab\x50\xf6\x1c\xa7\xc9\xfa\xab\xf0\xfc\x37\x2f\x90\x4f\x57\x78\
+\xb7\x04\xae\xaf\x6f\x90\x2e\x96\x78\xff\xfd\x35\x2c\x00\xc3\xa1\
+\xdc\x44\xe5\x34\x8e\xa5\xe4\xf5\xd8\x1d\xd4\x53\x8f\x00\xc4\x8b\
+\x7a\x02\x52\xbc\x00\xb2\xd1\x9d\x28\xf8\xcc\x46\x77\x08\xfb\x11\
+\x82\xfb\x8f\x50\x7a\x17\xb8\xd7\xe9\x22\x0f\xa2\xba\x17\xdb\xb7\
+\xdf\xd4\xd2\xc4\xbd\xc4\xa6\x77\x85\x78\x01\xc0\x3d\x81\x13\xcf\
+\xf0\x70\x74\x8e\xd2\xbb\x80\x87\x53\x78\x16\x50\x34\x8c\x8c\x41\
+\x85\xff\x07\x5b\x53\xe4\xea\xf5\xd8\xe3\x94\x00\x00\x00\x00\x49\
+\x45\x4e\x44\xae\x42\x60\x82\
+"""
+
+qt_resource_name = b"""\
+\x00\x09\
+\x06\xa8\xaa\x74\
+\x00\x71\
+\x00\x75\x00\x6f\x00\x74\x00\x65\x00\x2e\x00\x74\x00\x78\x00\x74\
+\x00\x0a\
+\x07\x2b\x67\xc7\
+\x00\x73\
+\x00\x61\x00\x6d\x00\x70\x00\x6c\x00\x65\x00\x2e\x00\x70\x00\x6e\x00\x67\
+"""
+
+qt_resource_struct = b"""\
+\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x01\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
+\x00\x00\x00\x18\x00\x00\x00\x00\x00\x01\x00\x00\x00\x39\
+"""
+
+def qInitResources():
+ QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
+
+def qCleanupResources():
+ QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
+
+qInitResources()
diff --git a/sources/pyside2/tests/QtCore/sample.png b/sources/pyside2/tests/QtCore/sample.png
new file mode 100644
index 000000000..60450f0dc
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/sample.png
Binary files differ
diff --git a/sources/pyside2/tests/QtCore/setprop_on_ctor_test.py b/sources/pyside2/tests/QtCore/setprop_on_ctor_test.py
new file mode 100644
index 000000000..b8b7e1cac
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/setprop_on_ctor_test.py
@@ -0,0 +1,41 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+
+
+class SetPropOnCtorTest(unittest.TestCase):
+ def testIt(self):
+ obj = QEventTransition(targetStates = [QState()])
+ self.assertEqual(len(obj.targetStates()), 1);
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/staticMetaObject_test.py b/sources/pyside2/tests/QtCore/staticMetaObject_test.py
new file mode 100644
index 000000000..88e87f1bb
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/staticMetaObject_test.py
@@ -0,0 +1,51 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject, Slot, QMetaObject
+
+class MyObject(QObject):
+ @Slot(int, str)
+ def slot1(self, a, b):
+ pass
+
+class testAttribute(unittest.TestCase):
+ def testBug896(self):
+ mo = MyObject.staticMetaObject
+ self.assertTrue(isinstance(mo, QMetaObject))
+ self.assertEqual(mo.className(), 'MyObject')
+ self.assertTrue(mo.indexOfSlot('slot1(int,QString)') > -1)
+
+ def testDuplicateSlot(self):
+ mo = MyObject.staticMetaObject
+ self.assertEqual(mo.indexOfSignal('destroyed(void)'), -1)
+ self.assertTrue(mo.indexOfSignal('destroyed()') > -1)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/static_method_test.py b/sources/pyside2/tests/QtCore/static_method_test.py
new file mode 100644
index 000000000..736feaea4
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/static_method_test.py
@@ -0,0 +1,84 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for overloads involving static and non-static versions of a method.'''
+
+import os
+import unittest
+
+from PySide2.QtCore import QFile
+
+class StaticNonStaticMethodsTest(unittest.TestCase):
+ '''Test cases for overloads involving static and non-static versions of a method.'''
+
+ def setUp(self):
+ filename = 'somefile%d.txt' % os.getpid()
+ self.existing_filename = os.path.join(os.path.curdir, filename)
+ self.delete_file = False
+ if not os.path.exists(self.existing_filename):
+ f = open(self.existing_filename, 'w')
+ for line in range(10):
+ f.write('sbrubbles\n')
+ f.close()
+ self.delete_file = True
+
+ self.non_existing_filename = os.path.join(os.path.curdir, 'inexistingfile.txt')
+ i = 0
+ while os.path.exists(self.non_existing_filename):
+ i += 1
+ filename = 'inexistingfile-%d.txt' % i
+ self.non_existing_filename = os.path.join(os.path.curdir, filename)
+
+ def tearDown(self):
+ if self.delete_file:
+ os.remove(self.existing_filename)
+
+ def testCallingStaticMethodWithClass(self):
+ '''Call static method using class.'''
+ self.assertTrue(QFile.exists(self.existing_filename))
+ self.assertFalse(QFile.exists(self.non_existing_filename))
+
+ def testCallingStaticMethodWithInstance(self):
+ '''Call static method using instance of class.'''
+ f = QFile(self.non_existing_filename)
+ self.assertTrue(f.exists(self.existing_filename))
+ self.assertFalse(f.exists(self.non_existing_filename))
+
+ def testCallingInstanceMethod(self):
+ '''Call instance method.'''
+ f1 = QFile(self.non_existing_filename)
+ self.assertFalse(f1.exists())
+ f2 = QFile(self.existing_filename)
+ self.assertTrue(f2.exists())
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/static_protected_methods_test.py b/sources/pyside2/tests/QtCore/static_protected_methods_test.py
new file mode 100644
index 000000000..c6339b1fe
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/static_protected_methods_test.py
@@ -0,0 +1,59 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for static protected methods'''
+
+import unittest, time
+
+from PySide2.QtCore import QThread
+
+class Test (QThread):
+ def run(self):
+ start = time.time()
+ self.sleep(1)
+ self.time_elapsed = time.time() - start
+
+class QStaticProtectedCall(unittest.TestCase):
+ '''Test case for static protected method call'''
+
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def testPathSeparator(self):
+ thread = Test()
+ thread.start()
+ self.assertTrue(thread.wait(2000))
+ self.assertTrue(thread.time_elapsed <= 1.1) # tolarance of 100ms
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/thread_signals_test.py b/sources/pyside2/tests/QtCore/thread_signals_test.py
new file mode 100644
index 000000000..351c6f5d7
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/thread_signals_test.py
@@ -0,0 +1,61 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test case for QObject.signalsBlocked() and blockSignal()'''
+
+import unittest
+import os
+from tempfile import mkstemp
+
+from PySide2.QtCore import QObject, SIGNAL, QFile, QThread, QTimer, Qt
+from helper import UsesQCoreApplication
+
+class MyThread(QThread):
+
+ def run(self):
+ self.emit(SIGNAL("test(const QString&)"), "INdT - PySide");
+
+class TestThreadSignal(UsesQCoreApplication):
+
+ __called__ = True
+ def _callback(self, msg):
+ self.assertEqual(msg, "INdT - PySide")
+ self.__called__ = True
+ self.app.quit()
+
+ def testThread(self):
+ t = MyThread()
+ QObject.connect(t, SIGNAL("test(const QString&)"), self._callback);
+ t.start()
+
+ self.app.exec_()
+ t.wait()
+ self.assertTrue(self.__called__);
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtCore/tr_noop_test.py b/sources/pyside2/tests/QtCore/tr_noop_test.py
new file mode 100644
index 000000000..6c37cfe23
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/tr_noop_test.py
@@ -0,0 +1,76 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+import sys
+from PySide2.QtCore import QT_TR_NOOP, QT_TR_NOOP_UTF8
+from PySide2.QtCore import QT_TRANSLATE_NOOP, QT_TRANSLATE_NOOP3, QT_TRANSLATE_NOOP_UTF8
+
+class QtTrNoopTest(unittest.TestCase):
+
+ def setUp(self):
+ self.txt = 'Cthulhu fhtag!'
+
+ def tearDown(self):
+ del self.txt
+
+ def testQtTrNoop(self):
+ refcnt = sys.getrefcount(self.txt)
+ result = QT_TR_NOOP(self.txt)
+ self.assertEqual(result, self.txt)
+ self.assertEqual(sys.getrefcount(result), refcnt + 1)
+
+ def testQtTrNoopUtf8(self):
+ refcnt = sys.getrefcount(self.txt)
+ result = QT_TR_NOOP_UTF8(self.txt)
+ self.assertEqual(result, self.txt)
+ self.assertEqual(sys.getrefcount(result), refcnt + 1)
+
+ def testQtTranslateNoop(self):
+ refcnt = sys.getrefcount(self.txt)
+ result = QT_TRANSLATE_NOOP(None, self.txt)
+ self.assertEqual(result, self.txt)
+ self.assertEqual(sys.getrefcount(result), refcnt + 1)
+
+ def testQtTranslateNoopUtf8(self):
+ refcnt = sys.getrefcount(self.txt)
+ result = QT_TRANSLATE_NOOP_UTF8(self.txt)
+ self.assertEqual(result, self.txt)
+ self.assertEqual(sys.getrefcount(result), refcnt + 1)
+
+ def testQtTranslateNoop3(self):
+ refcnt = sys.getrefcount(self.txt)
+ result = QT_TRANSLATE_NOOP3(None, self.txt, None)
+ self.assertEqual(result, self.txt)
+ self.assertEqual(sys.getrefcount(result), refcnt + 1)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/translation_test.py b/sources/pyside2/tests/QtCore/translation_test.py
new file mode 100644
index 000000000..338571271
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/translation_test.py
@@ -0,0 +1,85 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests to test QTranslator and translation in general.'''
+
+import os
+import unittest
+import py3kcompat as py3k
+from PySide2.QtCore import QObject, QTranslator, QCoreApplication
+
+from helper import UsesQCoreApplication
+
+class TranslationTest(UsesQCoreApplication):
+ '''Test case for Qt translation facilities.'''
+
+ def setUp(self):
+ super(TranslationTest, self).setUp()
+ self.trdir = os.path.join(os.path.dirname(__file__), 'translations')
+
+ def testLatin(self):
+ #Set string value to Latin
+ translator = QTranslator()
+ translator.load(os.path.join(self.trdir, 'trans_latin.qm'))
+ self.app.installTranslator(translator)
+
+ obj = QObject()
+ obj.setObjectName(obj.tr('Hello World!'))
+ self.assertEqual(obj.objectName(), py3k.unicode_('Orbis, te saluto!'))
+
+ def testRussian(self):
+ #Set string value to Russian
+ translator = QTranslator()
+ translator.load(os.path.join(self.trdir, 'trans_russian.qm'))
+ self.app.installTranslator(translator)
+
+ obj = QObject()
+ obj.setObjectName(obj.tr('Hello World!'))
+ self.assertEqual(obj.objectName(), py3k.unicode_('привет мир!'))
+
+ def testUtf8(self):
+ translator = QTranslator()
+ translator.load(os.path.join(self.trdir, 'trans_russian.qm'))
+ self.app.installTranslator(translator)
+
+ obj = QObject()
+ obj.setObjectName(obj.tr('Hello World!'))
+ self.assertEqual(obj.objectName(), py3k.unicode_('привет мир!'))
+
+ def testTranslateWithNoneDisambiguation(self):
+ value = 'String here'
+ obj = QCoreApplication.translate('context', value, None)
+ self.assertTrue(isinstance(obj, py3k.unicode))
+ self.assertEqual(obj, value)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/translations/trans_latin.qm b/sources/pyside2/tests/QtCore/translations/trans_latin.qm
new file mode 100644
index 000000000..efdbee8c7
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/translations/trans_latin.qm
Binary files differ
diff --git a/sources/pyside2/tests/QtCore/translations/trans_latin.ts b/sources/pyside2/tests/QtCore/translations/trans_latin.ts
new file mode 100644
index 000000000..b9fcf41be
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/translations/trans_latin.ts
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1" language="lt">
+<defaultcodec></defaultcodec>
+<context>
+ <name>QObject</name>
+ <message>
+ <source>Hello World!</source>
+ <translation>Orbis, te saluto!</translation>
+ </message>
+</context>
+</TS>
diff --git a/sources/pyside2/tests/QtCore/translations/trans_russian.qm b/sources/pyside2/tests/QtCore/translations/trans_russian.qm
new file mode 100644
index 000000000..5f16552a7
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/translations/trans_russian.qm
Binary files differ
diff --git a/sources/pyside2/tests/QtCore/translations/trans_russian.ts b/sources/pyside2/tests/QtCore/translations/trans_russian.ts
new file mode 100644
index 000000000..d1ba49bd2
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/translations/trans_russian.ts
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1" language="ru">
+<defaultcodec></defaultcodec>
+<context>
+ <name>QObject</name>
+ <message>
+ <source>Hello World!</source>
+ <translation>привет мир!</translation>
+ </message>
+</context>
+</TS>
diff --git a/sources/pyside2/tests/QtCore/unaryoperator_test.py b/sources/pyside2/tests/QtCore/unaryoperator_test.py
new file mode 100644
index 000000000..7e9897b7f
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/unaryoperator_test.py
@@ -0,0 +1,67 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests the presence of unary operator __neg__ on the QPoint class'''
+
+import unittest
+
+from PySide2.QtCore import QPoint
+
+class NegUnaryOperatorTest(unittest.TestCase):
+ '''Tests the presence of unary operator __neg__ on the QPoint class'''
+
+ def setUp(self):
+ #Acquire resources
+ self.x, self.y = 10, 20
+ self.neg_x, self.neg_y = -self.x, -self.y
+ self.qpoint = QPoint(self.x, self.y)
+
+ def tearDown(self):
+ #Release resources
+ del self.qpoint
+ del self.x
+ del self.y
+ del self.neg_x
+ del self.neg_y
+
+ def testNegUnaryOperator(self):
+ #Test __neg__ unary operator on QPoint class
+ __neg__method_exists = True
+ try:
+ neg_qpoint = -self.qpoint
+ except:
+ __neg__method_exists = False
+
+ self.assertTrue(__neg__method_exists)
+ self.assertEqual(self.qpoint, -neg_qpoint)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/unicode_test.py b/sources/pyside2/tests/QtCore/unicode_test.py
new file mode 100644
index 000000000..bf431c918
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/unicode_test.py
@@ -0,0 +1,62 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QString conversion to/from Python Unicode'''
+
+import unittest
+import py3kcompat as py3k
+
+from PySide2.QtCore import QObject
+
+class UnicodeConversion(unittest.TestCase):
+ '''Test case for QString to/from Python Unicode conversion'''
+
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def testSetRegularStringRetrieveUnicode(self):
+ #Set regular Python string retrieve unicode
+ obj = QObject()
+ obj.setObjectName('test')
+ self.assertEqual(obj.objectName(), py3k.unicode_('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'))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtCore/versioninfo_test.py b/sources/pyside2/tests/QtCore/versioninfo_test.py
new file mode 100644
index 000000000..47e90bab1
--- /dev/null
+++ b/sources/pyside2/tests/QtCore/versioninfo_test.py
@@ -0,0 +1,48 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import PySide2
+
+class TestVersionInfo(unittest.TestCase):
+ def testIt(self):
+
+ v = PySide2.__version_info__
+ self.assertEqual(type(v), tuple)
+ self.assertEqual(len(v), 5)
+ self.assertEqual(type(v[0]), int)
+ self.assertEqual(type(v[1]), int)
+ self.assertEqual(type(v[2]), int)
+ self.assertEqual(type(v[3]), str)
+ self.assertEqual(type(v[4]), int)
+
+ self.assertEqual(type(PySide2.__version__), str)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtDesigner/CMakeLists.txt b/sources/pyside2/tests/QtDesigner/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtDesigner/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtDesigner/this_module_loads_test.py b/sources/pyside2/tests/QtDesigner/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtDesigner/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtGui/CMakeLists.txt b/sources/pyside2/tests/QtGui/CMakeLists.txt
new file mode 100644
index 000000000..63cf3c35f
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/CMakeLists.txt
@@ -0,0 +1,47 @@
+#Keep this in alphabetical sort
+
+PYSIDE_TEST(bug_300_test.py)
+PYSIDE_TEST(bug_367.py)
+PYSIDE_TEST(bug_480.py)
+PYSIDE_TEST(bug_500.py)
+PYSIDE_TEST(bug_606.py)
+PYSIDE_TEST(bug_617.py)
+PYSIDE_TEST(bug_652.py)
+PYSIDE_TEST(bug_660.py)
+PYSIDE_TEST(bug_716.py)
+PYSIDE_TEST(bug_740.py)
+PYSIDE_TEST(bug_743.py)
+PYSIDE_TEST(bug_991.py)
+PYSIDE_TEST(bug_1091.py)
+PYSIDE_TEST(bug_PYSIDE-41.py)
+PYSIDE_TEST(bug_PYSIDE-344.py)
+PYSIDE_TEST(deepcopy_test.py)
+PYSIDE_TEST(float_to_int_implicit_conversion_test.py)
+PYSIDE_TEST(pyside_reload_test.py)
+PYSIDE_TEST(qcolor_test.py)
+PYSIDE_TEST(qcolor_reduce_test.py)
+PYSIDE_TEST(qcursor_test.py)
+PYSIDE_TEST(qdatastream_gui_operators_test.py)
+PYSIDE_TEST(qdesktopservices_test.py)
+PYSIDE_TEST(qfontmetrics_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)
+PYSIDE_TEST(qpixmap_test.py)
+PYSIDE_TEST(qpixmapcache_test.py)
+PYSIDE_TEST(qpolygonf_test.py)
+PYSIDE_TEST(qkeysequence_test.py)
+PYSIDE_TEST(qradialgradient_test.py)
+PYSIDE_TEST(qrasterwindow_test.py)
+PYSIDE_TEST(qregion_test.py)
+PYSIDE_TEST(qstylehints_test.py)
+PYSIDE_TEST(qtextdocument_undoredo_test.py)
+PYSIDE_TEST(qtextdocumentwriter_test.py)
+PYSIDE_TEST(qtextline_test.py)
+PYSIDE_TEST(qtransform_test.py)
+PYSIDE_TEST(repr_test.py)
+PYSIDE_TEST(timed_app_test.py)
diff --git a/sources/pyside2/tests/QtGui/bug_1091.py b/sources/pyside2/tests/QtGui/bug_1091.py
new file mode 100644
index 000000000..4fbdfe89f
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_1091.py
@@ -0,0 +1,40 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' unit test for BUG #1091 '''
+
+import unittest
+from PySide2 import QtGui
+
+class QPainterTestCase(unittest.TestCase):
+ def testIt(self):
+ self.assertTrue("PixmapFragment" in dir(QtGui.QPainter))
+ self.assertTrue("drawPixmapFragments" in dir(QtGui.QPainter))
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/bug_300_test.py b/sources/pyside2/tests/QtGui/bug_300_test.py
new file mode 100644
index 000000000..1ab71569a
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_300_test.py
@@ -0,0 +1,45 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtGui import QStringListModel
+from PySide2.QtCore import QModelIndex
+import unittest
+
+class TestQAbstractItemModelSignals(unittest.TestCase):
+ def sigCallback(self, index, r, c):
+ self._called = True
+
+ def testSignals(self):
+ self._called = False
+ m = QStringListModel()
+ m.rowsAboutToBeInserted[QModelIndex,int,int].connect(self.sigCallback)
+ m.insertRows(0, 3)
+ self.assertTrue(self._called)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/bug_367.py b/sources/pyside2/tests/QtGui/bug_367.py
new file mode 100644
index 000000000..375412b95
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_367.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 367: http://bugs.openbossa.org/show_bug.cgi?id=367'''
+
+import sys
+import unittest
+from helper import UsesQApplication
+from PySide2 import QtCore,QtGui
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ model = QtGui.QStandardItemModel()
+ parentItem = model.invisibleRootItem()
+ for i in range(10):
+ item = QtGui.QStandardItem()
+ rcount = sys.getrefcount(item)
+ parentItem.appendRow(item)
+ self.assertEqual(rcount+1, sys.getrefcount(item))
+ parentItem = item
+
+ self.assertTrue(True)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/bug_480.py b/sources/pyside2/tests/QtGui/bug_480.py
new file mode 100644
index 000000000..75524841f
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_480.py
@@ -0,0 +1,53 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2 import QtWidgets
+
+class BuggyWidget(QtWidgets.QWidget):
+ def setup(self):
+ self.verticalLayout = QtWidgets.QVBoxLayout(self)
+ self.gridLayout = QtWidgets.QGridLayout()
+ self.lbl = QtWidgets.QLabel(self)
+ self.gridLayout.addWidget(self.lbl, 0, 1, 1, 1)
+
+ # this cause a segfault during the ownership transfer
+ self.verticalLayout.addLayout(self.gridLayout)
+
+class LayoutTransferOwnerShip(unittest.TestCase):
+ def testBug(self):
+ app = QtWidgets.QApplication([])
+ w = BuggyWidget()
+ w.setup()
+ w.show()
+ self.assertTrue(True)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtGui/bug_500.py b/sources/pyside2/tests/QtGui/bug_500.py
new file mode 100644
index 000000000..b6f941633
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_500.py
@@ -0,0 +1,43 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import *
+from PySide2.QtPrintSupport import *
+from helper import UsesQApplication
+
+class NeverDiesTest(UsesQApplication):
+
+ def testIt(self):
+ QPrintDialog()
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/bug_606.py b/sources/pyside2/tests/QtGui/bug_606.py
new file mode 100644
index 000000000..99dc6e95d
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_606.py
@@ -0,0 +1,54 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+import PySide2
+from PySide2.QtGui import QVector2D, QVector3D, QVector4D
+from PySide2.QtGui import QColor
+
+class testCases(unittest.TestCase):
+ def testQVector2DToTuple(self):
+ vec = QVector2D(1, 2)
+ self.assertEqual((1, 2), vec.toTuple())
+
+ def testQVector3DToTuple(self):
+ vec = QVector3D(1, 2, 3)
+ self.assertEqual((1, 2, 3), vec.toTuple())
+
+ def testQVector4DToTuple(self):
+ vec = QVector4D(1, 2, 3, 4)
+ self.assertEqual((1, 2, 3, 4), vec.toTuple())
+
+ def testQColorToTuple(self):
+ c = QColor(0, 0, 255)
+ c.setRgb(1, 2, 3)
+ self.assertEqual((1, 2, 3, 255), c.toTuple())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/bug_617.py b/sources/pyside2/tests/QtGui/bug_617.py
new file mode 100644
index 000000000..35239ef46
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_617.py
@@ -0,0 +1,49 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import QEvent
+from PySide2.QtGui import QColor
+import unittest
+
+class MyEvent(QEvent):
+ def __init__(self):
+ QEvent.__init__(self, QEvent.Type(999))
+
+
+class Bug617(unittest.TestCase):
+ def testRepr(self):
+ c = QColor.fromRgb(1, 2, 3, 4)
+ s = c.spec()
+ self.assertEqual(repr(s), repr(QColor.Rgb))
+
+ def testOutOfBounds(self):
+ e = MyEvent()
+ self.assertEqual(repr(e.type()), 'PySide2.QtCore.QEvent.Type(999)')
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/bug_652.py b/sources/pyside2/tests/QtGui/bug_652.py
new file mode 100644
index 000000000..4f7089659
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_652.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtGui import *
+
+class MyData(QTextBlockUserData):
+ def __init__(self, data):
+ QTextBlockUserData.__init__(self)
+ self.data = data
+
+ def getMyNiceData(self):
+ return self.data
+
+class TestBug652(unittest.TestCase):
+ """Segfault when using QTextBlock::setUserData due to missing ownership transfer"""
+ def testIt(self):
+ td = QTextDocument()
+ tc = QTextCursor(td)
+ tc.insertText("Hello world")
+ heyHo = "hey ho!"
+ tc.block().setUserData(MyData(heyHo))
+ self.assertEqual(type(tc.block().userData()), MyData)
+ self.assertEqual(tc.block().userData().getMyNiceData(), heyHo)
+
+ del tc
+ tc = QTextCursor(td)
+ blk = tc.block()
+ self.assertEqual(type(blk.userData()), MyData)
+ self.assertEqual(blk.userData().getMyNiceData(), heyHo)
+
+if __name__ == "__main__":
+ unittest.main() \ No newline at end of file
diff --git a/sources/pyside2/tests/QtGui/bug_660.py b/sources/pyside2/tests/QtGui/bug_660.py
new file mode 100644
index 000000000..5dbb9e4e9
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_660.py
@@ -0,0 +1,55 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import py3kcompat as py3k
+from PySide2.QtGui import QStandardItemModel, QStandardItem
+
+class MyItemModel(QStandardItemModel):
+ def __init__(self,parent=None):
+ super(MyItemModel,self).__init__(parent)
+ self.appendRow([QStandardItem('Item 1'),])
+
+ def mimeTypes(self):
+ mtypes = super(MyItemModel,self).mimeTypes()
+ mtypes.append(py3k.unicode_('application/my-form'))
+ return mtypes
+
+ def mimeData(self,indexes):
+ self.__mimedata = super(MyItemModel,self).mimeData(indexes)
+ self.__mimedata.setData(py3k.unicode_('application/my-form'), 'hi')
+ return self.__mimedata
+
+class TestBug660(unittest.TestCase):
+ '''QMimeData type deleted prematurely when overriding mime-type in QStandardItemModel drag and drop'''
+ def testIt(self):
+ model = MyItemModel()
+ model.mimeData([model.index(0, 0)]) # if it doesn't raise an exception it's all right!
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/bug_716.py b/sources/pyside2/tests/QtGui/bug_716.py
new file mode 100644
index 000000000..49a329bc2
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_716.py
@@ -0,0 +1,37 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import Qt, QPersistentModelIndex
+from PySide2.QtGui import QStringListModel
+
+if __name__ == '__main__':
+ stringListModel = QStringListModel(['one', 'two'])
+ idx = stringListModel.index(1, 0)
+ persistentModelIndex = QPersistentModelIndex(idx)
+ stringListModel.data(persistentModelIndex, Qt.DisplayRole)
+
diff --git a/sources/pyside2/tests/QtGui/bug_740.py b/sources/pyside2/tests/QtGui/bug_740.py
new file mode 100644
index 000000000..a77abc118
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_740.py
@@ -0,0 +1,41 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import py3kcompat as py3k
+from helper 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')
+ bim = QBitmap.fromData(QSize(8, 48), dataBits, QImage.Format_Mono) # missing function
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/bug_743.py b/sources/pyside2/tests/QtGui/bug_743.py
new file mode 100644
index 000000000..d2339921f
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_743.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtGui import QMatrix4x4
+
+class TestQMatrix(unittest.TestCase):
+ def testOperator(self):
+ m = QMatrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
+ v = 1
+ for x in range(4):
+ for y in range(4):
+ self.assertEqual(m[x,y], v)
+ v += 1
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/bug_991.py b/sources/pyside2/tests/QtGui/bug_991.py
new file mode 100644
index 000000000..034efb350
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_991.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QObject
+from PySide2.QtGui import QPen, QBrush
+
+class TestBug991 (unittest.TestCase):
+ def testReprFunction(self):
+ reprPen = repr(QPen())
+ self.assertTrue(reprPen.startswith("<PySide2.QtGui.QPen"))
+ reprBrush = repr(QBrush())
+ self.assertTrue(reprBrush.startswith("<PySide2.QtGui.QBrush"))
+ reprObject = repr(QObject())
+ self.assertTrue(reprObject.startswith("<PySide2.QtCore.QObject"))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/bug_PYSIDE-344.py b/sources/pyside2/tests/QtGui/bug_PYSIDE-344.py
new file mode 100644
index 000000000..b67cdf231
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_PYSIDE-344.py
@@ -0,0 +1,64 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for PYSIDE-344, imul/idiv are used instead of mul/div, modifying the argument passed in'''
+
+import unittest
+
+from PySide2.QtCore import *
+from PySide2.QtGui import *
+
+def testList():
+ return [QPoint(10, 10), QPointF(1, 1), QSize(10, 10), QSizeF(1, 1),
+ QMargins(10, 10, 10, 10),
+ QTransform(), QMatrix4x4(),
+ QVector2D(1, 1), QVector3D(1, 1, 1), QVector4D(1, 1, 1, 1),
+ QQuaternion(1, 1, 1, 1)]
+
+class TestMulDiv(unittest.TestCase):
+
+ def testMultiplication(self):
+ fails = ''
+ for a in testList():
+ mul = (a * 2)
+ if a == mul:
+ fails += ' ' + type(a).__name__
+ self.assertEqual(fails, '')
+
+ def testDivision(self):
+ fails = ''
+ for a in testList():
+ div = (a * 2)
+ if a == div:
+ fails += ' ' + type(a).__name__
+ self.assertEqual(fails, '')
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/bug_PYSIDE-41.py b/sources/pyside2/tests/QtGui/bug_PYSIDE-41.py
new file mode 100644
index 000000000..b9007c8ca
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/bug_PYSIDE-41.py
@@ -0,0 +1,72 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# TODO:
+# move this to QtCore -- QStringListModel is part of QtGui and there is no
+# simple model class appropriate for this test in QtCore.
+
+import unittest
+
+from PySide2.QtCore import *
+from PySide2.QtGui import *
+
+
+class TestBugPYSIDE41(unittest.TestCase):
+
+ def testIt(self):
+
+ # list of single-character strings
+ strings = list('abcdefghijklmnopqrstuvwxyz')
+
+ model = QStringListModel(strings)
+
+ # Test hashing of both QModelIndex and QPersistentModelIndex
+ indexFunctions = []
+ indexFunctions.append(model.index)
+ indexFunctions.append(lambda i: QPersistentModelIndex(model.index(i)))
+
+ for indexFunction in indexFunctions:
+
+ # If two objects compare equal, their hashes MUST also be equal. (The
+ # reverse is not a requirement.)
+ for i, _ in enumerate(strings):
+ index1 = indexFunction(i)
+ index2 = indexFunction(i)
+ self.assertEqual(index1, index2)
+ self.assertEqual(hash(index1), hash(index2))
+
+ # Adding the full set of indexes to itself is a no-op.
+ allIndexes1 = set(indexFunction(i) for i, _ in enumerate(strings))
+ allIndexes2 = set(indexFunction(i) for i, _ in enumerate(strings))
+ allIndexesCombined = allIndexes1 & allIndexes2
+ self.assertEqual(allIndexes1, allIndexesCombined)
+ self.assertEqual(allIndexes2, allIndexesCombined)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/deepcopy_test.py b/sources/pyside2/tests/QtGui/deepcopy_test.py
new file mode 100644
index 000000000..00df25cba
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/deepcopy_test.py
@@ -0,0 +1,150 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from copy import deepcopy
+
+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
+from PySide2.QtGui import QVector2D, QVector3D, QVector4D
+from PySide2.QtGui import QColor, QTransform, QKeySequence, QQuaternion
+from PySide2.QtGui import QPolygon
+
+class DeepCopyHelper:
+ def testCopy(self):
+ copy = deepcopy([self.original])[0]
+ self.assertTrue(copy is not self.original)
+ self.assertEqual(copy, self.original)
+
+class DeepCopyColorHelperF:
+ def testCopy(self):
+ copy = deepcopy([self.original])[0]
+ self.assertTrue(copy is not self.original)
+ self.assertEqual(copy.spec(), self.original.spec())
+ # impossible to compare float point
+ # self.assertEqual(copy, self.original)
+
+
+class QColorDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QColor("red")
+
+class QColorRGBDeepCopy(DeepCopyColorHelperF, unittest.TestCase):
+ def setUp(self):
+ self.original = QColor.fromRgbF(0.2, 0.3, 0.4, 0.5)
+
+class QColorHSLDeepCopy(DeepCopyColorHelperF, unittest.TestCase):
+ def setUp(self):
+ self.original = QColor.fromHslF(0.2, 0.3, 0.4, 0.5)
+
+class QColorHSVDeepCopy(DeepCopyColorHelperF, unittest.TestCase):
+ def setUp(self):
+ self.original = QColor.fromHsvF(0.2, 0.3, 0.4, 0.5)
+
+class QColorCMYKDeepCopy(DeepCopyColorHelperF, unittest.TestCase):
+ def setUp(self):
+ self.original = QColor.fromCmykF(0.2, 0.3, 0.4, 0.5, 0.6)
+
+class QTransformDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QTransform(1, 2, 3, 4, 5, 6, 7, 8)
+
+class QKeySequenceDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QKeySequence("Ctrl+P")
+
+class QQuaternionDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QQuaternion(1, 2, 3, 4)
+
+class QVector2DDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QVector2D(1, 2)
+
+class QVector3DDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QVector3D(1, 2, 3)
+
+class QVector4DDeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QVector4D(1, 2, 3, 4)
+
+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
+"""
+class QMatrix2x2DeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix2x2([1, 2, 3, 4])
+
+class QMatrix2x3DeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix2x3([1, 2, 3, 4, 5, 6])
+
+class QMatrix2x4DeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix2x4([1, 2, 3, 4, 5, 6, 7, 8])
+
+class QMatrix3x2DeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix3x2([1, 2, 3, 4, 5, 6])
+
+class QMatrix3x3DeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix3x3([1, 2, 3, 4, 5, 6, 7, 8, 9])
+
+class QMatrix3x4DeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix3x4([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
+
+class QMatrix4x2DeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix4x2([1, 2, 3, 4, 5, 6, 7, 8])
+
+class QMatrix4x3DeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix4x3([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
+
+class QMatrix4x4DeepCopy(DeepCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix4x4([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
+"""
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/float_to_int_implicit_conversion_test.py b/sources/pyside2/tests/QtGui/float_to_int_implicit_conversion_test.py
new file mode 100644
index 000000000..a2a9e2e1a
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/float_to_int_implicit_conversion_test.py
@@ -0,0 +1,59 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QImage'''
+
+import unittest
+
+from PySide2.QtGui import QImage, qRgb
+
+from helper import UsesQApplication
+
+class SetPixelFloat(UsesQApplication):
+ '''Test case for calling setPixel with float as argument'''
+
+ def setUp(self):
+ #Acquire resources
+ super(SetPixelFloat, self).setUp()
+ self.color = qRgb(255, 0, 0)
+ self.image = QImage(200, 200, QImage.Format_RGB32)
+
+ def tearDown(self):
+ #Release resources
+ del self.color
+ del self.image
+ super(SetPixelFloat, self).tearDown()
+
+ def testFloat(self):
+ #QImage.setPixel(float, float, color) - Implicit conversion
+ self.image.setPixel(3.14, 4.2, self.color)
+ self.assertEqual(self.image.pixel(3.14, 4.2), self.color)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/pyside_reload_test.py b/sources/pyside2/tests/QtGui/pyside_reload_test.py
new file mode 100644
index 000000000..587e4cebc
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/pyside_reload_test.py
@@ -0,0 +1,84 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import os
+import sys
+import shutil
+import unittest
+import py3kcompat as py3k
+
+orig_path = os.path.join(os.path.dirname(__file__))
+workdir = os.getcwd()
+src = os.path.normpath(os.path.join(orig_path, '..', 'QtWidgets', 'test_module_template.py'))
+dst = os.path.join(workdir, 'test_module.py')
+shutil.copyfile(src, dst)
+sys.path.append(workdir)
+
+def reload_module(moduleName):
+ if py3k.IS_PY3K:
+ import imp
+ imp.reload(moduleName)
+ else:
+ reload(moduleName)
+
+def increment_module_value():
+ modfile = open(dst, 'a')
+ modfile.write('Sentinel.value += 1' + os.linesep)
+ modfile.flush()
+ modfile.close()
+ if not sys.dont_write_bytecode:
+ if py3k.IS_PY3K:
+ import imp
+ cacheFile = imp.cache_from_source(dst)
+ else:
+ cacheFile = dst + 'c'
+ os.remove(cacheFile)
+
+class TestModuleReloading(unittest.TestCase):
+
+ def testModuleReloading(self):
+ '''Test module reloading with on-the-fly modifications.'''
+
+ import test_module
+ self.assertEqual(test_module.Sentinel.value, 10)
+
+ increment_module_value()
+ reload_module(sys.modules['test_module'])
+ self.assertEqual(test_module.Sentinel.value, 11)
+
+ reload_module(sys.modules['test_module'])
+ self.assertEqual(test_module.Sentinel.value, 11)
+
+ increment_module_value()
+ reload_module(sys.modules['test_module'])
+ self.assertEqual(test_module.Sentinel.value, 12)
+
+if __name__ == "__main__":
+ unittest.main()
+
+
diff --git a/sources/pyside2/tests/QtGui/qcolor_reduce_test.py b/sources/pyside2/tests/QtGui/qcolor_reduce_test.py
new file mode 100644
index 000000000..a5a91e099
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qcolor_reduce_test.py
@@ -0,0 +1,59 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import pickle
+from PySide2.QtGui import QColor
+
+class TestQColor (unittest.TestCase):
+ def reduceColor(self, c):
+ p = pickle.dumps(c)
+ c2 = pickle.loads(p)
+ self.assertEqual(c.spec(), c2.spec())
+ self.assertEqual(c, c2)
+
+ def testReduceEmpty(self):
+ self.reduceColor(QColor())
+
+ def testReduceString(self):
+ self.reduceColor(QColor('gray'))
+
+ def testReduceRGB(self):
+ self.reduceColor(QColor.fromRgbF(0.1, 0.2, 0.3, 0.4))
+
+ def testReduceCMYK(self):
+ self.reduceColor(QColor.fromCmykF(0.1, 0.2, 0.3, 0.4, 0.5))
+
+ def testReduceHsl(self):
+ self.reduceColor(QColor.fromHslF(0.1, 0.2, 0.3, 0.4))
+
+ def testReduceHsv(self):
+ self.reduceColor(QColor.fromHsvF(0.1, 0.2, 0.3, 0.4))
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qcolor_test.py b/sources/pyside2/tests/QtGui/qcolor_test.py
new file mode 100644
index 000000000..10c4c9076
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qcolor_test.py
@@ -0,0 +1,122 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import colorsys
+import PySide2
+
+from PySide2.QtCore import Qt
+from PySide2.QtGui import QColor
+
+
+class QColorGetTest(unittest.TestCase):
+
+ def setUp(self):
+ self.color = QColor(20, 40, 60, 80)
+
+ def testGetRgb(self):
+ self.assertEqual(self.color.getRgb(), (20, 40, 60, 80))
+
+ def testGetHslF(self):
+ hls = colorsys.rgb_to_hls(20.0/255, 40.0/255, 60.0/255)
+ hsla = hls[0], hls[2], hls[1], self.color.alphaF()
+ for x, y in zip(self.color.getHslF(), hsla): # Due to rounding problems
+ self.assertTrue(x - y < 1/100000.0)
+
+ def testGetHsv(self):
+ hsv = colorsys.rgb_to_hsv(20.0/255, 40.0/255, 60.0/255)
+ hsva = int(hsv[0]*360.0), int(hsv[1]*255), int(hsv[2]*256), self.color.alpha()
+ self.assertEqual(self.color.getHsv(), hsva)
+
+ def testGetCmyk(self): # not supported by colorsys
+ self.assertEqual(self.color.getCmyk(), (170, 85, 0, 195, 80))
+
+ def testGetCmykF(self): # not supported by colorsys
+ for x, y in zip(self.color.getCmykF(), (170/255.0, 85/255.0, 0, 195/255.0, 80/255.0)):
+ self.assertTrue(x - y < 1/10000.0)
+
+
+class QColorQRgbConstructor(unittest.TestCase):
+ '''QColor(QRgb) constructor'''
+ # Affected by bug #170 - QColor(QVariant) coming before QColor(uint)
+ # in overload sorting
+
+ def testBasic(self):
+ '''QColor(QRgb)'''
+ color = QColor(255, 0, 0)
+ #QRgb format #AARRGGBB
+ rgb = 0x00FF0000
+ self.assertEqual(QColor(rgb), color)
+
+
+class QColorEqualGlobalColor(unittest.TestCase):
+
+ def testEqualGlobalColor(self):
+ '''QColor == Qt::GlobalColor'''
+ self.assertEqual(QColor(255, 0, 0), Qt.red)
+
+
+class QColorCopy(unittest.TestCase):
+
+ def testDeepCopy(self):
+ '''QColor deepcopy'''
+
+ from copy import deepcopy
+
+ original = QColor(0, 0, 255)
+ copy = deepcopy([original])[0]
+
+ self.assertTrue(original is not copy)
+ self.assertEqual(original, copy)
+ del original
+ self.assertEqual(copy, QColor(0, 0, 255))
+
+ def testEmptyCopy(self):
+ from copy import deepcopy
+
+ original = QColor()
+ copy = deepcopy([original])[0]
+ self.assertTrue(original is not copy)
+ self.assertEqual(original, copy)
+ del original
+ self.assertEqual(copy, QColor())
+
+
+class QColorRepr(unittest.TestCase):
+ def testReprFunction(self):
+ c = QColor(100, 120, 200)
+ c2 = eval(c.__repr__())
+ self.assertEqual(c, c2)
+
+ def testStrFunction(self):
+ c = QColor('red')
+ c2 = eval(c.__str__())
+ self.assertEqual(c, c2)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qcursor_test.py b/sources/pyside2/tests/QtGui/qcursor_test.py
new file mode 100644
index 000000000..f19fbd028
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qcursor_test.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test for Bug 630 - Fails to resolve overload for QCursor(QBitmap, QBitmap, int, int)
+http://bugs.openbossa.org/show_bug.cgi?id=630
+'''
+
+import unittest
+from PySide2.QtGui import QBitmap, QCursor, QPixmap
+from helper import UsesQApplication
+
+class TestQCursor(UsesQApplication):
+ def testQCursorConstructor(self):
+ bmp = QBitmap(16, 16)
+ cursor = QCursor(bmp, bmp, 16, 16)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtGui/qdatastream_gui_operators_test.py b/sources/pyside2/tests/QtGui/qdatastream_gui_operators_test.py
new file mode 100644
index 000000000..932bb0cbf
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qdatastream_gui_operators_test.py
@@ -0,0 +1,63 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+
+from PySide2.QtCore import QDataStream, QByteArray, QIODevice, Qt
+from PySide2.QtGui import QPixmap, QColor
+
+from helper import UsesQApplication
+
+class QPixmapQDatastream(UsesQApplication):
+ '''QDataStream <<>> QPixmap'''
+
+ def setUp(self):
+ super(QPixmapQDatastream, self).setUp()
+ self.source_pixmap = QPixmap(100, 100)
+ self.source_pixmap.fill(Qt.red)
+ self.output_pixmap = QPixmap()
+ self.buffer = QByteArray()
+ self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly)
+ self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly)
+
+ def testStream(self):
+ self.write_stream << self.source_pixmap
+
+ self.read_stream >> self.output_pixmap
+
+ image = self.output_pixmap.toImage()
+ pixel = image.pixel(10,10)
+ self.assertEqual(pixel, QColor(Qt.red).rgba())
+ self.assertEqual(self.source_pixmap.toImage(), self.output_pixmap.toImage())
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qdesktopservices_test.py b/sources/pyside2/tests/QtGui/qdesktopservices_test.py
new file mode 100644
index 000000000..edeb32a08
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qdesktopservices_test.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QDesktopServices'''
+
+import unittest
+
+from PySide2.QtGui import QDesktopServices
+from PySide2.QtCore import QUrl
+
+class QDesktopServicesTest(unittest.TestCase):
+ def testOpenUrl(self):
+ # At the bare minimum check that they return false for invalid url's
+ url = QUrl()
+ self.assertEqual(QDesktopServices.openUrl(url), False)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qfontmetrics_test.py b/sources/pyside2/tests/QtGui/qfontmetrics_test.py
new file mode 100644
index 000000000..140fc1321
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qfontmetrics_test.py
@@ -0,0 +1,226 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests for inject codes and modifications on QFontMetrics
+ and QFontMetricsF'''
+
+import unittest
+from PySide2.QtGui import QFont, QFontMetrics, QFontMetricsF
+from PySide2.QtCore import QRect, QRectF, Qt, QSize, QSizeF
+from helper import UsesQApplication
+
+
+class QFontMetricsTest(UsesQApplication):
+ '''Base class for QFontMetrics tests'''
+
+ def setUp(self):
+ super(QFontMetricsTest, self).setUp()
+ self.font = QFont()
+ self.metrics = QFontMetrics(self.font)
+
+ def tearDown(self):
+ del self.metrics
+ del self.font
+ super(QFontMetricsTest, self).tearDown()
+
+
+class BoundingRectTest(QFontMetricsTest):
+ '''Tests for QFontMetrics.boundingRect inject code'''
+
+ def testIntDefault(self):
+ '''QFontMetrics.boundingRect(int, int, int, int, ...) - default args'''
+ rect = self.metrics.boundingRect(0, 0, 0, 0,
+ Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT')
+ self.assertTrue(isinstance(rect, QRect))
+
+ def testIntWithArg(self):
+ '''QFontMetrics.boundingRect(int, int, int, int, ...) - single arg'''
+ rect = self.metrics.boundingRect(0, 0, 0, 0,
+ Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT', 2)
+ self.assertTrue(isinstance(rect, QRect))
+
+ def testIntWithFull(self):
+ '''QFontMetrics.boundingRect(int, int, int, int, ...) - all argss'''
+ rect = self.metrics.boundingRect(0, 0, 0, 0,
+ Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT', 20, [1, 2, 3, 4, 5])
+ self.assertTrue(isinstance(rect, QRect))
+
+ def testIntTypeError(self):
+ '''QFontMetrics.boundingRect(int, int, int, int, ...) - type error'''
+ self.assertRaises(TypeError, self.metrics.boundingRect, 0, 0, 0, 0,
+ Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT', 20, ['aaaa', 'ase'])
+
+ def testQRectDefault(self):
+ '''QFontMetrics.boundingRect(QRect, ...) - default args'''
+ arg = QRect(0, 0, 100, 200)
+ rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT')
+ self.assertTrue(isinstance(rect, QRect))
+
+ def testQRectWithArg(self):
+ '''QFontMetrics.boundingRect(QRect, ...) - only tabstops'''
+ arg = QRect(0, 0, 100, 200)
+ rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT', 2)
+ self.assertTrue(isinstance(rect, QRect))
+
+ def testQRectWithFull(self):
+ '''QFontMetrics.boundingRect(QRect, ...) - all arguments'''
+ arg = QRect(0, 0, 100, 200)
+ rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT', 20,
+ [1, 2, 3, 4, 5])
+ self.assertTrue(isinstance(rect, QRect))
+
+ def testQRectTypeError(self):
+ '''QFontMetrics.boundingRect(QRect, ...) - type error'''
+ arg = QRect(0, 0, 100, 200)
+ self.assertRaises(TypeError, self.metrics.boundingRect, arg,
+ Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT', 20, ['aaaa', 'ase'])
+
+
+class SizeTest(QFontMetricsTest):
+ '''Tests for QFontMetrics.size inject code'''
+
+ def testDefault(self):
+ '''QFontMetrics.size - default arguments'''
+ size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
+ 'PySide by INdT')
+ self.assertTrue(isinstance(size, QSize))
+
+ def testWithTabStops(self):
+ '''QFontMetrics.size - only tabstops'''
+ size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
+ 'PySide by INdT', 2)
+ self.assertTrue(isinstance(size, QSize))
+
+ def testFull(self):
+ '''QFontMetrics.size - all arguments'''
+ size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
+ 'PySide by INdT', 2, [1, 2, 3, 4])
+ self.assertTrue(isinstance(size, QSize))
+
+ def testTypeError(self):
+ '''QFontMetrics.size - type error'''
+ self.assertRaises(TypeError, self.metrics.size,
+ Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT', 20, ['aaaa', 'ase'])
+
+
+class QFontMetricsFTest(UsesQApplication):
+ '''Base class for QFontMetrics tests'''
+
+ def setUp(self):
+ super(QFontMetricsFTest, self).setUp()
+ self.font = QFont()
+ self.metrics = QFontMetricsF(self.font)
+
+ def tearDown(self):
+ del self.metrics
+ del self.font
+ super(QFontMetricsFTest, self).tearDown()
+
+
+class FBoundingRectTest(QFontMetricsFTest):
+ '''Tests for QFontMetricsF.boundingRect inject code'''
+
+ def testQRectDefault(self):
+ '''QFontMetricsF.boundingRect(QRectF, ...) - default args'''
+ arg = QRectF(0, 0, 100, 200)
+ rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT')
+ self.assertTrue(isinstance(rect, QRectF))
+
+ def testQRectWithArg(self):
+ '''QFontMetricsF.boundingRect(QRectF, ...) - only tabstops'''
+ arg = QRectF(0, 0, 100, 200)
+ rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT', 2)
+ self.assertTrue(isinstance(rect, QRectF))
+
+ def testQRectWithFull(self):
+ '''QFontMetricsF.boundingRect(QRectF, ...) - all arguments'''
+ arg = QRectF(0, 0, 100, 200)
+ rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT', 20,
+ [1, 2, 3, 4, 5])
+ self.assertTrue(isinstance(rect, QRectF))
+
+ def testQRectTypeError(self):
+ '''QFontMetricsF.boundingRect(QRectF, ...) - type error'''
+ arg = QRectF(0, 0, 100, 200)
+ self.assertRaises(TypeError, self.metrics.boundingRect, arg,
+ Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT', 20, ['aaaa', 'ase'])
+
+
+class FSizeTest(QFontMetricsFTest):
+ '''Tests for QFontMetricsF.size inject code'''
+
+ def testDefault(self):
+ '''QFontMetricsF.size - default arguments'''
+ size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
+ 'PySide by INdT')
+ self.assertTrue(isinstance(size, QSizeF))
+
+ def testWithTabStops(self):
+ '''QFontMetricsF.size - only tabstops'''
+ size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
+ 'PySide by INdT', 2)
+ self.assertTrue(isinstance(size, QSizeF))
+
+ def testFull(self):
+ '''QFontMetricsF.size - all arguments'''
+ size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine,
+ 'PySide by INdT', 2, [1, 2, 3, 4])
+ self.assertTrue(isinstance(size, QSizeF))
+
+ def testTypeError(self):
+ '''QFontMetricsF.size - type error'''
+ self.assertRaises(TypeError, self.metrics.size,
+ Qt.TextExpandTabs | Qt.AlignLeft,
+ 'PySide by INdT', 20, ['aaaa', 'ase'])
+
+
+class QCharTest(QFontMetricsFTest):
+
+ def testBoundingRect(self):
+ retCh = self.metrics.boundingRectChar('a')
+ self.assertEqual(type(retCh), QRectF)
+
+ def testWith(self):
+ retCh = self.metrics.widthChar('a')
+ self.assertTrue(retCh > 0)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qicon_test.py b/sources/pyside2/tests/QtGui/qicon_test.py
new file mode 100644
index 000000000..2a56b455c
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qicon_test.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import TimedQApplication
+from PySide2.QtGui import QIcon
+
+
+class QIconCtorWithNoneTest(TimedQApplication):
+ '''Test made by seblin, see Bug #944: http://bugs.pyside.org/show_bug.cgi?id=944'''
+
+ def testQIconCtorWithNone(self):
+ icon = QIcon(None)
+ pixmap = icon.pixmap(48, 48)
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qitemselection_test.py b/sources/pyside2/tests/QtGui/qitemselection_test.py
new file mode 100644
index 000000000..d8f2ab230
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qitemselection_test.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import UsesQApplication
+from PySide2.QtCore import QItemSelection
+from PySide2.QtGui import QStandardItemModel
+
+class QItemSelectionTest(UsesQApplication):
+ def testLen(self):
+ model = QStandardItemModel(2, 2)
+ model.insertRow(0)
+ model.insertRow(1)
+ model.insertColumn(0)
+ model.insertColumn(1)
+ selection = QItemSelection(model.index(0,0), model.index(1,1))
+ self.assertEqual(len(selection), 1)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtGui/qkeysequence_test.py b/sources/pyside2/tests/QtGui/qkeysequence_test.py
new file mode 100644
index 000000000..3e62a4632
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qkeysequence_test.py
@@ -0,0 +1,48 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import Qt
+from PySide2.QtGui import QKeySequence
+
+from helper import UsesQApplication
+
+class QKeySequenceTest(UsesQApplication):
+
+ def testGetItemOperator(self):
+ # bug #774
+ ks = QKeySequence(Qt.SHIFT, Qt.CTRL, Qt.Key_P, Qt.Key_R)
+ self.assertEqual(ks[0], Qt.SHIFT)
+ self.assertEqual(ks[1], Qt.CTRL)
+ self.assertEqual(ks[2], Qt.Key_P)
+ self.assertEqual(ks[3], Qt.Key_R)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qmatrix_test.py b/sources/pyside2/tests/QtGui/qmatrix_test.py
new file mode 100644
index 000000000..944b052cc
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qmatrix_test.py
@@ -0,0 +1,86 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QPoint
+from PySide2.QtGui import QMatrix, 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(point * matrix, qpointTimesQMatrix(point, matrix))
+
+ def testMatrixWithWrongType(self):
+ matrix = QMatrix(11, 12, 21, 22, 100, 200)
+ point = QPoint(3, 3)
+ self.assertRaises(TypeError, matrix.__mul__, point)
+
+ 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/qopenglbuffer_test.py b/sources/pyside2/tests/QtGui/qopenglbuffer_test.py
new file mode 100644
index 000000000..cae789ac4
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qopenglbuffer_test.py
@@ -0,0 +1,93 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QOpenGLBuffer'''
+
+import unittest
+import ctypes
+import sys
+
+from helper import UsesQApplication
+from PySide2.QtGui import QOpenGLBuffer
+from PySide2 import QtGui
+
+def createSurface(surfaceClass):
+ if surfaceClass == QtGui.QSurface.Window:
+ window = QtGui.QWindow()
+ window.setSurfaceType(QtGui.QWindow.OpenGLSurface)
+ window.setGeometry(0, 0, 10, 10)
+ window.create()
+ return window
+ elif surfaceClass == QtGui.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
+ if format.redBufferSize() == -1:
+ window = QtGui.QWindow()
+ window.setSurfaceType(QtGui.QWindow.OpenGLSurface)
+ window.setGeometry(0, 0, 10, 10)
+ window.create()
+ format = window.format()
+ offscreenSurface = QtGui.QOffscreenSurface()
+ offscreenSurface.setFormat(format)
+ offscreenSurface.create()
+ return offscreenSurface
+ return 0
+
+class QOpenGLBuffer(UsesQApplication):
+ def testBufferCreate(self):
+ surface = createSurface(QtGui.QSurface.Window)
+ ctx = QtGui.QOpenGLContext()
+ ctx.create()
+ ctx.makeCurrent(surface)
+
+ buf = QtGui.QOpenGLBuffer()
+
+ self.assertTrue(not buf.isCreated())
+
+ self.assertTrue(buf.create())
+ self.assertTrue(buf.isCreated())
+
+ self.assertEqual(buf.type(), QtGui.QOpenGLBuffer.VertexBuffer)
+
+ buf.bind()
+ buf.allocate(128)
+ self.assertEqual(buf.size(), 128)
+
+ buf.release()
+
+ buf.destroy()
+ self.assertTrue(not buf.isCreated())
+
+ ctx.doneCurrent()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qpainter_test.py b/sources/pyside2/tests/QtGui/qpainter_test.py
new file mode 100644
index 000000000..7cecede51
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qpainter_test.py
@@ -0,0 +1,111 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtGui import QPainter, QLinearGradient
+from PySide2.QtCore import QLine, QLineF, QPoint, QPointF, QRect, QRectF, Qt
+
+class QPainterDrawText(unittest.TestCase):
+
+ def setUp(self):
+ self.painter = QPainter()
+ self.text = 'teste!'
+
+ def tearDown(self):
+ del self.text
+ del self.painter
+
+ def testDrawText(self):
+ # bug #254
+ rect = self.painter.drawText(100, 100, 100, 100,
+ Qt.AlignCenter | Qt.TextWordWrap,
+ self.text)
+ self.assertTrue(isinstance(rect, QRect))
+
+ def testDrawTextWithRect(self):
+ # bug #225
+ rect = QRect(100, 100, 100, 100)
+ newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap,
+ self.text)
+
+ self.assertTrue(isinstance(newRect, QRect))
+
+ def testDrawTextWithRectF(self):
+ '''QPainter.drawText(QRectF, ... ,QRectF*) inject code'''
+ rect = QRectF(100, 52.3, 100, 100)
+ newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap,
+ self.text)
+
+ self.assertTrue(isinstance(newRect, QRectF))
+
+ def testDrawOverloads(self):
+ '''Calls QPainter.drawLines overloads, if something is
+ wrong Exception and chaos ensues. Bug #395'''
+ self.painter.drawLines([QLine(QPoint(0,0), QPoint(1,1))])
+ self.painter.drawLines([QPoint(0,0), QPoint(1,1)])
+ self.painter.drawLines([QPointF(0,0), QPointF(1,1)])
+ self.painter.drawLines([QLineF(QPointF(0,0), QPointF(1,1))])
+ self.painter.drawPoints([QPoint(0,0), QPoint(1,1)])
+ self.painter.drawPoints([QPointF(0,0), QPointF(1,1)])
+ self.painter.drawConvexPolygon([QPointF(10.0, 80.0),
+ QPointF(20.0, 10.0),
+ QPointF(80.0, 30.0),
+ QPointF(90.0, 70.0)])
+ self.painter.drawConvexPolygon([QPoint(10.0, 80.0),
+ QPoint(20.0, 10.0),
+ QPoint(80.0, 30.0),
+ QPoint(90.0, 70.0)])
+ self.painter.drawPolygon([QPointF(10.0, 80.0),
+ QPointF(20.0, 10.0),
+ QPointF(80.0, 30.0),
+ QPointF(90.0, 70.0)])
+ self.painter.drawPolygon([QPoint(10.0, 80.0),
+ QPoint(20.0, 10.0),
+ QPoint(80.0, 30.0),
+ QPoint(90.0, 70.0)])
+ self.painter.drawPolyline([QPointF(10.0, 80.0),
+ QPointF(20.0, 10.0),
+ QPointF(80.0, 30.0),
+ QPointF(90.0, 70.0)])
+ self.painter.drawPolyline([QPoint(10.0, 80.0),
+ QPoint(20.0, 10.0),
+ QPoint(80.0, 30.0),
+ QPoint(90.0, 70.0)])
+
+class SetBrushWithOtherArgs(unittest.TestCase):
+ '''Using qpainter.setBrush with args other than QBrush'''
+
+ def testSetBrushGradient(self):
+ painter = QPainter()
+ gradient = QLinearGradient(0, 0, 0, 0)
+ painter.setBrush(gradient)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtGui/qpdfwriter_test.py b/sources/pyside2/tests/QtGui/qpdfwriter_test.py
new file mode 100644
index 000000000..f97c85b39
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qpdfwriter_test.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from helper import UsesQApplication
+from PySide2.QtGui import QPageLayout, QPageSize, QPdfWriter, QTextDocument
+from PySide2.QtCore import QDir, QMarginsF, QTemporaryFile
+
+class QPdfWriterTest(UsesQApplication):
+
+ def testWrite(self):
+ temporaryFile = QTemporaryFile(QDir.tempPath() + "/pdfwriter_test_XXXXXX.pdf")
+ self.assertTrue(temporaryFile.open())
+ pdfWriter = QPdfWriter(temporaryFile)
+ pdfWriter.setPageLayout(QPageLayout(QPageSize(QPageSize.A4), QPageLayout.Portrait, QMarginsF(10, 10, 10, 10)))
+ doc = QTextDocument("Some text")
+ doc.print_(pdfWriter)
+ temporaryFile.close()
+ self.assertTrue(temporaryFile.size() > 0)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qpixelformat_test.py b/sources/pyside2/tests/QtGui/qpixelformat_test.py
new file mode 100644
index 000000000..c7f14ff24
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qpixelformat_test.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit test for QPixelFormat'''
+
+import unittest
+
+from helper import UsesQApplication
+from PySide2.QtCore import QSize, Qt
+from PySide2.QtGui import QColor, QImage, QPixelFormat
+
+class QPixelFormatTest(UsesQApplication):
+ def test(self):
+ image = QImage(QSize(200, 200), QImage.Format_ARGB32)
+ image.fill(QColor(Qt.red))
+ pixelFormat = image.pixelFormat()
+ print(pixelFormat.greenSize())
+ self.assertEqual(pixelFormat.alphaSize(), 8)
+ self.assertEqual(pixelFormat.redSize(), 8)
+ self.assertEqual(pixelFormat.greenSize(), 8)
+ self.assertEqual(pixelFormat.blueSize(), 8)
+ self.assertEqual(pixelFormat.bitsPerPixel(), 32)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qpixmap_test.py b/sources/pyside2/tests/QtGui/qpixmap_test.py
new file mode 100644
index 000000000..b637f4d13
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qpixmap_test.py
@@ -0,0 +1,85 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+import os
+from helper import UsesQApplication
+from PySide2.QtGui import *
+from PySide2.QtCore import *
+
+class QPixmapTest(UsesQApplication):
+ def testQVariantConstructor(self):
+ obj = QObject()
+ pixmap = QPixmap()
+ obj.setProperty('foo', pixmap)
+ self.assertEqual(type(obj.property('foo')), QPixmap)
+
+ def testQSizeConstructor(self):
+ pixmap = QPixmap(QSize(10,20))
+ self.assertTrue(pixmap.size().height(), 20)
+
+ def testQStringConstructor(self):
+ pixmap = QPixmap("Testing!")
+
+ def testQPixmapLoadFromDataWithQFile(self):
+ f = QFile(os.path.join(os.path.dirname(__file__), 'sample.png'))
+ self.assertTrue(f.open(QIODevice.ReadOnly))
+ data = f.read(f.size())
+ f.close()
+ pixmap = QPixmap()
+ self.assertTrue(pixmap.loadFromData(data))
+
+ def testQPixmapLoadFromDataWithPython(self):
+ data = open(os.path.join(os.path.dirname(__file__),'sample.png'),'rb').read()
+ pixmap = QPixmap()
+ self.assertTrue(pixmap.loadFromData(data))
+
+
+class QPixmapToImage(UsesQApplication):
+
+ def testFilledImage(self):
+ '''QPixmap.fill + toImage + image.pixel'''
+ pixmap = QPixmap(100, 200)
+ pixmap.fill(Qt.red) # Default Qt.white
+
+ self.assertEqual(pixmap.height(), 200)
+ self.assertEqual(pixmap.width(), 100)
+
+ image = pixmap.toImage()
+
+ self.assertEqual(image.height(), 200)
+ self.assertEqual(image.width(), 100)
+
+ pixel = image.pixel(10,10)
+ self.assertEqual(pixel, QColor(Qt.red).rgba())
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtGui/qpixmapcache_test.py b/sources/pyside2/tests/QtGui/qpixmapcache_test.py
new file mode 100644
index 000000000..83e26411d
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qpixmapcache_test.py
@@ -0,0 +1,72 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from helper import UsesQApplication
+from PySide2.QtGui import QPixmapCache, QPixmap
+
+
+class QPixmapCacheTest(UsesQApplication):
+
+ def testWithString(self):
+ pm1 = QPixmap()
+ ok = QPixmapCache.find('img', pm1)
+ self.assertFalse(ok)
+
+ self.assertEqual(QPixmapCache.find('img'), None)
+
+ pm2 = QPixmap()
+ ok = QPixmapCache.insert('img', pm2)
+ self.assertTrue(ok)
+
+ pm3 = QPixmap()
+ ok = QPixmapCache.find('img', pm3)
+ self.assertTrue(ok)
+ b1 = QPixmapCache.find('img').toImage().bits()
+ b2 = pm3.toImage().bits()
+ self.assertEqual(QPixmapCache.find('img').toImage().bits(), pm3.toImage().bits())
+
+ def testWithKey(self):
+ pm1 = QPixmap()
+ ok = QPixmapCache.find(QPixmapCache.Key(), pm1)
+ self.assertFalse(ok)
+
+ self.assertEqual(QPixmapCache.find(QPixmapCache.Key()), None)
+
+ pm2 = QPixmap()
+ key = QPixmapCache.insert(pm2)
+
+ pm3 = QPixmap()
+ ok = QPixmapCache.find(key, pm3)
+ self.assertTrue(ok)
+
+ self.assertEqual(QPixmapCache.find(key).toImage().bits(), pm3.toImage().bits())
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtGui/qpolygonf_test.py b/sources/pyside2/tests/QtGui/qpolygonf_test.py
new file mode 100644
index 000000000..7c243b903
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qpolygonf_test.py
@@ -0,0 +1,55 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+from PySide2.QtGui import *
+
+class QPolygonFNotIterableTest(unittest.TestCase):
+ """Test if a QPolygonF is iterable"""
+ def testIt(self):
+ p = QPolygonF(4)
+ self.assertEqual(len(p), 4)
+
+ for i in range(0, 4):
+ p[i] = QPointF(float(i), float(i))
+
+ i = 0
+ for point in p:
+ self.assertEqual(int(point.x()), i)
+ self.assertEqual(int(point.y()), i)
+ i += 1;
+
+ def testPolygonShiftOperators(self):
+ p = QPolygon()
+ self.assertEqual(len(p), 0)
+ p << QPoint(10, 20) << QPoint(20, 30) << [QPoint(20, 30), QPoint(40, 50)]
+ self.assertEqual(len(p), 4)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qradialgradient_test.py b/sources/pyside2/tests/QtGui/qradialgradient_test.py
new file mode 100644
index 000000000..16dbf7ded
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qradialgradient_test.py
@@ -0,0 +1,57 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtGui import QRadialGradient
+from PySide2.QtCore import QPointF
+
+class QRadialGradientConstructor(unittest.TestCase):
+ def _compare(self, qptf, tpl):
+ self.assertEqual((qptf.x(), qptf.y()), tpl)
+
+ def _assertValues(self, grad):
+ self._compare(grad.center(), (1.0, 2.0))
+ self._compare(grad.focalPoint(), (3.0, 4.0))
+ self.assertEqual(grad.radius(), 5.0)
+
+ def testAllInt(self):
+ grad = QRadialGradient(1, 2, 5, 3, 4)
+ self._assertValues(grad)
+
+ def testQPointF(self):
+ grad = QRadialGradient(QPointF(1, 2), 5, QPointF(3, 4))
+ self._assertValues(grad)
+
+ def testSetQPointF(self):
+ grad = QRadialGradient()
+ grad.setCenter(QPointF(1, 2))
+ self._compare(grad.center(), (1.0, 2.0))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qrasterwindow_test.py b/sources/pyside2/tests/QtGui/qrasterwindow_test.py
new file mode 100644
index 000000000..db756ff85
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qrasterwindow_test.py
@@ -0,0 +1,86 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit test for QBackingStore, QRasterWindow and QStaticText'''
+
+import unittest
+
+from helper import UsesQApplication
+from PySide2.QtCore import QEvent, QPoint, QRect, QSize, QTimer, Qt
+from PySide2.QtGui import QColor, QBackingStore, QPaintDevice, QPainter, QWindow, QPaintDeviceWindow, QRasterWindow, QRegion, QStaticText
+
+# QWindow rendering via QBackingStore
+class TestBackingStoreWindow(QWindow):
+ def __init__(self):
+ super(TestBackingStoreWindow, self).__init__()
+ self.backingStore = QBackingStore(self)
+ self.text = QStaticText("BackingStoreWindow")
+
+ def event(self, event):
+ if event.type() == QEvent.Resize:
+ self.backingStore.resize(self.size())
+ self.render()
+ elif event.type() == QEvent.UpdateRequest or event.type() == QEvent.Expose:
+ self.backingStore.flush(QRegion(QRect(QPoint(0, 0), self.size())))
+
+ return QWindow.event(self, event)
+
+ def render(self):
+ clientRect = QRect(QPoint(0, 0), self.size())
+ painter = QPainter(self.backingStore.paintDevice())
+ painter.fillRect(clientRect, QColor(Qt.green))
+ painter.drawStaticText(QPoint(10, 10), self.text)
+
+# Window using convenience class QRasterWindow
+class TestRasterWindow(QRasterWindow):
+ def __init__(self):
+ super(TestRasterWindow, self).__init__()
+ self.text = QStaticText("QRasterWindow")
+
+ def paintEvent(self, event):
+ clientRect = QRect(QPoint(0, 0), self.size())
+ painter = QPainter(self)
+ painter.fillRect(clientRect, QColor(Qt.red))
+ painter.drawStaticText(QPoint(10, 10), self.text)
+
+class QRasterWindowTest(UsesQApplication):
+ def test(self):
+ rasterWindow = TestRasterWindow()
+ rasterWindow.setFramePosition(QPoint(100, 100))
+ rasterWindow.resize(QSize(400, 400))
+ rasterWindow.show()
+ backingStoreWindow = TestBackingStoreWindow()
+ backingStoreWindow.setFramePosition(QPoint(600, 100))
+ backingStoreWindow.resize(QSize(400, 400))
+ backingStoreWindow.show()
+
+ QTimer.singleShot(100, self.app.quit)
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qregion_test.py b/sources/pyside2/tests/QtGui/qregion_test.py
new file mode 100644
index 000000000..e3af650e5
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qregion_test.py
@@ -0,0 +1,49 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+
+from PySide2.QtGui import QRegion
+from PySide2.QtCore import QPoint
+from helper import UsesQApplication
+
+class QRegionTest(UsesQApplication):
+
+ def testFunctionUnit(self):
+ r = QRegion(0, 0, 10, 10)
+ r2 = QRegion(5, 5, 10, 10)
+
+ ru = r.united(r2)
+ self.assertTrue(ru.contains(QPoint(0,0)))
+ self.assertTrue(ru.contains(QPoint(5,5)))
+ self.assertTrue(ru.contains(QPoint(10,10)))
+ self.assertTrue(ru.contains(QPoint(14,14)))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qstylehints_test.py b/sources/pyside2/tests/QtGui/qstylehints_test.py
new file mode 100644
index 000000000..c3d99aa3f
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qstylehints_test.py
@@ -0,0 +1,42 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit test for QStyleHints'''
+
+import unittest
+
+from helper import UsesQApplication
+from PySide2.QtGui import QStyleHints
+
+class QStyleHintsTest(UsesQApplication):
+ def test(self):
+ styleHints = self.app.styleHints()
+ self.assertTrue(styleHints.startDragDistance() > 0)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qtextdocument_undoredo_test.py b/sources/pyside2/tests/QtGui/qtextdocument_undoredo_test.py
new file mode 100644
index 000000000..9d237f6d4
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qtextdocument_undoredo_test.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtGui import QTextDocument, QTextCursor
+
+class QTextDocumentTest(unittest.TestCase):
+
+ def testUndoRedo(self):
+ text = 'foobar'
+ doc = QTextDocument(text)
+
+ self.assertFalse(doc.isRedoAvailable())
+ self.assertTrue(doc.isUndoAvailable())
+ self.assertEqual(doc.toPlainText(), text)
+
+ cursor = QTextCursor(doc)
+ doc.undo(cursor)
+
+ self.assertTrue(doc.isRedoAvailable())
+ self.assertFalse(doc.isUndoAvailable())
+ self.assertEqual(doc.toPlainText(), '')
+
+ doc.redo(cursor)
+
+ self.assertFalse(doc.isRedoAvailable())
+ self.assertTrue(doc.isUndoAvailable())
+ self.assertEqual(doc.toPlainText(), text)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py b/sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py
new file mode 100644
index 000000000..c65d09633
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtGui import QTextDocumentWriter, QTextDocument
+from PySide2.QtCore import QBuffer
+
+class QTextDocumentWriterTest(unittest.TestCase):
+
+ def testWrite(self):
+ text = 'foobar'
+ doc = QTextDocument(text)
+ b = QBuffer()
+ b.open(QBuffer.ReadWrite)
+ writer = QTextDocumentWriter(b, "plaintext");
+ writer.write(doc);
+ b.close()
+ self.assertEqual(b.buffer(), text)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/qtextline_test.py b/sources/pyside2/tests/QtGui/qtextline_test.py
new file mode 100644
index 000000000..a541c6cf5
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qtextline_test.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtGui import QTextLayout
+from helper import UsesQApplication
+
+class QTextLineTest(UsesQApplication):
+
+ def testCursorToX(self):
+ textLayout = QTextLayout()
+ textLayout.beginLayout()
+ line = textLayout.createLine()
+ self.assertTrue(line.isValid())
+ x, cursorPos = line.cursorToX(0)
+ self.assertEqual(type(x), float)
+ self.assertEqual(type(cursorPos), int)
+ x, cursorPos = line.cursorToX(1)
+ self.assertEqual(type(x), float)
+ self.assertEqual(type(cursorPos), int)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtGui/qtransform_test.py b/sources/pyside2/tests/QtGui/qtransform_test.py
new file mode 100644
index 000000000..654484f9d
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/qtransform_test.py
@@ -0,0 +1,101 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QPointF
+from PySide2.QtGui import QTransform, QPolygonF, QPolygonF
+
+class QTransformTest(unittest.TestCase):
+
+ def testMap(self):
+ transform = QTransform()
+ values = (10.0, 20.0)
+ tx, ty = transform.map(*values)
+ self.assertTrue(isinstance(tx, float))
+ self.assertTrue(isinstance(ty, float))
+ self.assertEqual((tx, ty), values)
+
+ def testquadToQuad(self):
+ q1 = QPolygonF()
+ q1.append(QPointF(10.0, 10.0))
+ q1.append(QPointF(20.0, 10.0))
+ q1.append(QPointF(10.0, -10.0))
+ q1.append(QPointF(20.0, -10.0))
+
+ q2 = QPolygonF()
+ q2.append(QPointF(20.0, 20.0))
+ q2.append(QPointF(30.0, 20.0))
+ q2.append(QPointF(20.0, -20.0))
+ q2.append(QPointF(30.0, -20.0))
+
+ t1 = QTransform()
+ r1 = QTransform.quadToQuad(q1, q2, t1)
+ r2 = QTransform.quadToQuad(q1, q2)
+
+ self.assertTrue(r1)
+ self.assertTrue(r2)
+
+ self.assertEqual(t1, r2)
+
+ def testquadToSquare(self):
+ q1 = QPolygonF()
+ q1.append(QPointF(10.0, 10.0))
+ q1.append(QPointF(20.0, 10.0))
+ q1.append(QPointF(10.0, -10.0))
+ q1.append(QPointF(20.0, -10.0))
+
+ t1 = QTransform()
+ r1 = QTransform.quadToSquare(q1, t1)
+ r2 = QTransform.quadToSquare(q1)
+
+ self.assertTrue(r1)
+ self.assertTrue(r2)
+
+ self.assertEqual(t1, r2)
+
+
+ def testsquareToQuad(self):
+ q1 = QPolygonF()
+ q1.append(QPointF(10.0, 10.0))
+ q1.append(QPointF(20.0, 10.0))
+ q1.append(QPointF(10.0, -10.0))
+ q1.append(QPointF(20.0, -10.0))
+
+ t1 = QTransform()
+ r1 = QTransform.squareToQuad(q1, t1)
+ r2 = QTransform.squareToQuad(q1)
+
+ self.assertTrue(r1)
+ self.assertTrue(r2)
+
+ self.assertEqual(t1, r2)
+
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtGui/repr_test.py b/sources/pyside2/tests/QtGui/repr_test.py
new file mode 100644
index 000000000..90307e64c
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/repr_test.py
@@ -0,0 +1,117 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+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
+from PySide2.QtGui import QVector2D, QVector3D, QVector4D
+from PySide2.QtGui import QColor, QTransform, QKeySequence, QQuaternion
+from PySide2.QtGui import QPolygon
+
+class ReprCopyHelper:
+ def testCopy(self):
+ copy = eval(self.original.__repr__())
+ self.assertTrue(copy is not self.original)
+ self.assertEqual(copy, self.original)
+
+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")
+
+class QQuaternionReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QQuaternion(1, 2, 3, 4)
+
+class QVector2DReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QVector2D(1, 2)
+
+class QVector3DReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QVector3D(1, 2, 3)
+
+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
+"""
+class QMatrix2x2ReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix2x2([1, 2, 3, 4])
+
+class QMatrix2x3ReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix2x3([1, 2, 3, 4, 5, 6])
+
+class QMatrix2x4ReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix2x4([1, 2, 3, 4, 5, 6, 7, 8])
+
+class QMatrix3x2ReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix3x2([1, 2, 3, 4, 5, 6])
+
+class QMatrix3x3ReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix3x3([1, 2, 3, 4, 5, 6, 7, 8, 9])
+
+class QMatrix3x4ReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix3x4([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
+
+class QMatrix4x2ReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix4x2([1, 2, 3, 4, 5, 6, 7, 8])
+
+class QMatrix4x3ReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix4x3([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
+
+class QMatrix4x4ReprCopy(ReprCopyHelper, unittest.TestCase):
+ def setUp(self):
+ self.original = QMatrix4x4([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
+"""
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtGui/sample.png b/sources/pyside2/tests/QtGui/sample.png
new file mode 100644
index 000000000..60450f0dc
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/sample.png
Binary files differ
diff --git a/sources/pyside2/tests/QtGui/timed_app_test.py b/sources/pyside2/tests/QtGui/timed_app_test.py
new file mode 100644
index 000000000..487e4a925
--- /dev/null
+++ b/sources/pyside2/tests/QtGui/timed_app_test.py
@@ -0,0 +1,41 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import TimedQApplication
+
+class TestTimedApp(TimedQApplication):
+ '''Simple test case for TimedQApplication'''
+
+ def testFoo(self):
+ #Simple test of TimedQApplication
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtHelp/CMakeLists.txt b/sources/pyside2/tests/QtHelp/CMakeLists.txt
new file mode 100644
index 000000000..d0ba2d80c
--- /dev/null
+++ b/sources/pyside2/tests/QtHelp/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(help_test.py)
diff --git a/sources/pyside2/tests/QtHelp/help_test.py b/sources/pyside2/tests/QtHelp/help_test.py
new file mode 100644
index 000000000..a99636508
--- /dev/null
+++ b/sources/pyside2/tests/QtHelp/help_test.py
@@ -0,0 +1,41 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtHelp import QHelpEngine
+
+from helper import UsesQApplication
+
+class QHelpEngineCreation(UsesQApplication):
+
+ def testConstructor(self):
+ helpEngine = QHelpEngine('mycollection.qch')
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtMacExtras/CMakeLists.txt b/sources/pyside2/tests/QtMacExtras/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtMacExtras/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtMacExtras/this_module_loads_test.py b/sources/pyside2/tests/QtMacExtras/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtMacExtras/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtMultimedia/CMakeLists.txt b/sources/pyside2/tests/QtMultimedia/CMakeLists.txt
new file mode 100644
index 000000000..62150eb79
--- /dev/null
+++ b/sources/pyside2/tests/QtMultimedia/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(audio_test.py)
diff --git a/sources/pyside2/tests/QtMultimedia/audio_test.py b/sources/pyside2/tests/QtMultimedia/audio_test.py
new file mode 100644
index 000000000..66db5e1ec
--- /dev/null
+++ b/sources/pyside2/tests/QtMultimedia/audio_test.py
@@ -0,0 +1,71 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QHttp'''
+
+import unittest
+
+from PySide2.QtCore import *
+from PySide2.QtMultimedia import *
+
+class testAudioDevices(unittest.TestCase):
+
+ def testListDevices(self):
+ valid = False
+ devices = QAudioDeviceInfo.availableDevices(QAudio.AudioOutput)
+ if not len(devices):
+ return
+
+ valid = True
+ for devInfo in devices:
+ if devInfo.deviceName() == 'null':
+ # skip the test if the only device found is a invalid device
+ if len(devices) == 1:
+ return
+ else:
+ continue
+ fmt = QAudioFormat()
+ for codec in devInfo.supportedCodecs():
+ fmt.setCodec(codec)
+ for frequency in devInfo.supportedSampleRates():
+ fmt.setSampleRate(frequency)
+ for channels in devInfo.supportedChannelCounts():
+ fmt.setChannelCount(channels)
+ for sampleType in devInfo.supportedSampleTypes():
+ fmt.setSampleType(sampleType)
+ for sampleSize in devInfo.supportedSampleSizes():
+ fmt.setSampleSize(sampleSize)
+ for endian in devInfo.supportedByteOrders():
+ fmt.setByteOrder(endian)
+ if devInfo.isFormatSupported(fmt):
+ return
+ self.assertTrue(False)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtMultimediaWidgets/CMakeLists.txt b/sources/pyside2/tests/QtMultimediaWidgets/CMakeLists.txt
new file mode 100644
index 000000000..2fc655f89
--- /dev/null
+++ b/sources/pyside2/tests/QtMultimediaWidgets/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(qmultimediawidgets.py)
diff --git a/sources/pyside2/tests/QtMultimediaWidgets/qmultimediawidgets.py b/sources/pyside2/tests/QtMultimediaWidgets/qmultimediawidgets.py
new file mode 100644
index 000000000..734dca9e5
--- /dev/null
+++ b/sources/pyside2/tests/QtMultimediaWidgets/qmultimediawidgets.py
@@ -0,0 +1,59 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QtMultimediaWidgets'''
+
+import unittest
+
+from helper import UsesQApplication
+from PySide2.QtMultimediaWidgets import QGraphicsVideoItem, QVideoWidget
+from PySide2.QtWidgets import QGraphicsScene, QGraphicsView, QVBoxLayout, QWidget
+from PySide2.QtCore import QTimer
+
+class MyWidget(QWidget):
+ def __init__(self):
+ QWidget.__init__(self)
+
+ layout = QVBoxLayout(self)
+ layout.addWidget(QVideoWidget())
+
+ graphicsScene = QGraphicsScene()
+ graphicsView = QGraphicsView(graphicsScene)
+ graphicsScene.addItem(QGraphicsVideoItem())
+ layout.addWidget(graphicsView)
+
+class QMultimediaWidgetsTest(UsesQApplication):
+ def testMultimediaWidgets(self):
+ w = MyWidget()
+ w.show()
+
+ timer = QTimer.singleShot(100, self.app.quit)
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtNetwork/CMakeLists.txt b/sources/pyside2/tests/QtNetwork/CMakeLists.txt
new file mode 100644
index 000000000..f93de5c17
--- /dev/null
+++ b/sources/pyside2/tests/QtNetwork/CMakeLists.txt
@@ -0,0 +1,7 @@
+PYSIDE_TEST(bug_446.py)
+PYSIDE_TEST(bug_1084.py)
+PYSIDE_TEST(accessManager_test.py)
+# Qt5: QHttp is gone PYSIDE_TEST(http_test.py)
+PYSIDE_TEST(tcpserver_test.py)
+PYSIDE_TEST(udpsocket_test.py)
+PYSIDE_TEST(qipv6address_test.py)
diff --git a/sources/pyside2/tests/QtNetwork/accessManager_test.py b/sources/pyside2/tests/QtNetwork/accessManager_test.py
new file mode 100644
index 000000000..11b21e841
--- /dev/null
+++ b/sources/pyside2/tests/QtNetwork/accessManager_test.py
@@ -0,0 +1,71 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QHttp'''
+
+import unittest
+
+from PySide2.QtCore import *
+from PySide2.QtNetwork import *
+
+from helper import UsesQCoreApplication
+from httpd import TestServer
+
+class AccessManagerCase(UsesQCoreApplication):
+
+ def setUp(self):
+ super(AccessManagerCase, self).setUp()
+ self.httpd = TestServer()
+ self.httpd.start()
+ self.called = False
+
+ def tearDown(self):
+ super(AccessManagerCase, self).tearDown()
+ if self.httpd:
+ self.httpd.shutdown()
+ self.httpd = None
+
+ def goAway(self):
+ self.httpd.shutdown()
+ self.app.quit()
+ self.httpd = None
+
+ def slot_replyFinished(self, reply):
+ self.assertEqual(type(reply), QNetworkReply)
+ self.called = True
+ self.goAway()
+
+ def testNetworkRequest(self):
+ manager = QNetworkAccessManager()
+ manager.finished.connect(self.slot_replyFinished)
+ manager.get(QNetworkRequest(QUrl("http://127.0.0.1:%s" % self.httpd.port())))
+ self.app.exec_()
+ self.assertTrue(self.called)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtNetwork/bug_1084.py b/sources/pyside2/tests/QtNetwork/bug_1084.py
new file mode 100644
index 000000000..b2d990196
--- /dev/null
+++ b/sources/pyside2/tests/QtNetwork/bug_1084.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' unit test for BUG #1084 '''
+
+import unittest
+from PySide2 import QtNetwork
+import py3kcompat as py3k
+
+class QTcpSocketTestCase(unittest.TestCase):
+ def setUp(self):
+ self.sock = QtNetwork.QTcpSocket()
+ self.sock.connectToHost('127.0.0.1', 25)
+
+ def testIt(self):
+ self.sock.write(py3k.unicode_('quit'))
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtNetwork/bug_446.py b/sources/pyside2/tests/QtNetwork/bug_446.py
new file mode 100644
index 000000000..4d3f3c0e9
--- /dev/null
+++ b/sources/pyside2/tests/QtNetwork/bug_446.py
@@ -0,0 +1,76 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import *
+from PySide2.QtNetwork import *
+
+from helper import UsesQCoreApplication
+
+class HttpSignalsCase(UsesQCoreApplication):
+ '''Test case for launching QHttp signals'''
+ DATA = "PySide rocks"
+
+ def onError(self):
+ self.assertTrue(False)
+
+ def onNewConnection(self):
+ self.serverConnection = self.server.nextPendingConnection()
+ self.serverConnection.error.connect(self.onError)
+ self.serverConnection.write(HttpSignalsCase.DATA)
+ self.server.close()
+
+ def onReadReady(self):
+ data = self.client.read(100)
+ self.assertEqual(data.size(), len(HttpSignalsCase.DATA))
+ self.assertEqual(data, HttpSignalsCase.DATA)
+ self.done()
+
+ def onClientConnect(self):
+ self.client.readyRead.connect(self.onReadReady)
+
+ def initServer(self):
+ self.server = QTcpServer()
+ self.server.newConnection.connect(self.onNewConnection)
+ self.assertTrue(self.server.listen())
+ self.client = QTcpSocket()
+ self.client.connected.connect(self.onClientConnect)
+ self.client.connectToHost(QHostAddress(QHostAddress.LocalHost), self.server.serverPort())
+
+ def done(self):
+ self.serverConnection.close()
+ self.client.close()
+ self.app.quit()
+
+ def testRun(self):
+ self.initServer()
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtNetwork/qipv6address_test.py b/sources/pyside2/tests/QtNetwork/qipv6address_test.py
new file mode 100644
index 000000000..e51760504
--- /dev/null
+++ b/sources/pyside2/tests/QtNetwork/qipv6address_test.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QIPv6Address'''
+
+import unittest
+
+from PySide2.QtNetwork import *
+
+class QIPv6AddressGetItemTest(unittest.TestCase):
+ def testLength(self):
+ ip = QIPv6Address()
+ self.assertEqual(len(ip), 16)
+
+ def testSetItemNegativeIndex(self):
+ ip = QIPv6Address()
+ ip[-1] = 8
+ self.assertEqual(ip[-1], 8)
+
+ def testSetItemLargeIndex(self):
+ ip = QIPv6Address()
+ self.assertRaises(IndexError, ip.__setitem__, 32, 16)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtNetwork/tcpserver_test.py b/sources/pyside2/tests/QtNetwork/tcpserver_test.py
new file mode 100644
index 000000000..3c13a1849
--- /dev/null
+++ b/sources/pyside2/tests/QtNetwork/tcpserver_test.py
@@ -0,0 +1,52 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QTCPServer'''
+
+import unittest
+
+from PySide2.QtNetwork import QTcpServer
+
+class ListenDefaultArgsCase(unittest.TestCase):
+ '''Test case for TcpServer.listen with default args'''
+
+ def setUp(self):
+ #Acquire resources
+ self.server = QTcpServer()
+
+ def tearDown(self):
+ #Release resources
+ del self.server
+
+ def testDefaultArgs(self):
+ # @bug 108
+ #Default arguments for QTcpServer.listen
+ self.server.listen()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtNetwork/udpsocket_test.py b/sources/pyside2/tests/QtNetwork/udpsocket_test.py
new file mode 100644
index 000000000..4e3d9ae62
--- /dev/null
+++ b/sources/pyside2/tests/QtNetwork/udpsocket_test.py
@@ -0,0 +1,78 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QUdpSocket'''
+
+import unittest
+
+from PySide2.QtCore import QUrl, QObject, SIGNAL, QCoreApplication, QTimer
+from PySide2.QtNetwork import QUdpSocket, QHostAddress
+
+class HttpSignalsCase(unittest.TestCase):
+ '''Test case for bug #124 - readDatagram signature
+
+ QUdpSocket.readDatagram must return a tuple with the datagram, host and
+ port, while receiving only the max payload size.'''
+
+ def setUp(self):
+ #Acquire resources
+ self.called = False
+ self.app = QCoreApplication([])
+
+ self.socket = QUdpSocket()
+
+ self.server = QUdpSocket()
+ self.server.bind(QHostAddress(QHostAddress.LocalHost), 45454)
+
+ def tearDown(self):
+ #Release resources
+ del self.socket
+ del self.server
+ del self.app
+
+ def sendPackage(self):
+ addr = QHostAddress(QHostAddress.LocalHost)
+ self.socket.writeDatagram('datagram', addr, 45454)
+
+ def callback(self):
+ while self.server.hasPendingDatagrams():
+ datagram, host, port = self.server.readDatagram(self.server.pendingDatagramSize())
+ self.called = True
+ self.app.quit()
+
+ def testDefaultArgs(self):
+ #QUdpSocket.readDatagram pythonic return
+ # @bug 124
+ QObject.connect(self.server, SIGNAL('readyRead()'), self.callback)
+ self.sendPackage()
+ self.app.exec_()
+
+ self.assertTrue(self.called)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtOpenGL/CMakeLists.txt b/sources/pyside2/tests/QtOpenGL/CMakeLists.txt
new file mode 100644
index 000000000..b37a9ddce
--- /dev/null
+++ b/sources/pyside2/tests/QtOpenGL/CMakeLists.txt
@@ -0,0 +1,2 @@
+PYSIDE_TEST(qglbuffer_test.py)
+PYSIDE_TEST(qglwidget_test.py)
diff --git a/sources/pyside2/tests/QtOpenGL/qglbuffer_test.py b/sources/pyside2/tests/QtOpenGL/qglbuffer_test.py
new file mode 100644
index 000000000..fc65052ce
--- /dev/null
+++ b/sources/pyside2/tests/QtOpenGL/qglbuffer_test.py
@@ -0,0 +1,72 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QGLBuffer'''
+
+import unittest
+
+from PySide2.QtCore import QByteArray
+from PySide2.QtOpenGL import QGLBuffer, QGLWidget
+import py3kcompat as py3k
+from helper import UsesQApplication
+
+class QGLBufferTest(UsesQApplication):
+ 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("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()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtOpenGL/qglwidget_test.py b/sources/pyside2/tests/QtOpenGL/qglwidget_test.py
new file mode 100644
index 000000000..48774f280
--- /dev/null
+++ b/sources/pyside2/tests/QtOpenGL/qglwidget_test.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+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/QtPrintSupport/CMakeLists.txt b/sources/pyside2/tests/QtPrintSupport/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtPrintSupport/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtPrintSupport/this_module_loads_test.py b/sources/pyside2/tests/QtPrintSupport/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtPrintSupport/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtQml/CMakeLists.txt b/sources/pyside2/tests/QtQml/CMakeLists.txt
new file mode 100755
index 000000000..8460a8f0b
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/CMakeLists.txt
@@ -0,0 +1,20 @@
+PYSIDE_TEST(bug_451.py)
+PYSIDE_TEST(bug_456.py)
+PYSIDE_TEST(bug_557.py)
+PYSIDE_TEST(bug_726.py)
+PYSIDE_TEST(bug_814.py)
+PYSIDE_TEST(bug_825.py)
+PYSIDE_TEST(bug_847.py)
+PYSIDE_TEST(bug_915.py)
+PYSIDE_TEST(bug_926.py)
+PYSIDE_TEST(bug_951.py)
+PYSIDE_TEST(bug_995.py)
+PYSIDE_TEST(bug_997.py)
+PYSIDE_TEST(bug_1029.py)
+PYSIDE_TEST(qqmlnetwork_test.py)
+PYSIDE_TEST(qquickview_test.py)
+PYSIDE_TEST(connect_python_qml.py)
+PYSIDE_TEST(registertype.py)
+PYSIDE_TEST(javascript_exceptions.py)
+PYSIDE_TEST(qqmlincubator_incubateWhile.py)
+PYSIDE_TEST(qquickitem_grabToImage.py)
diff --git a/sources/pyside2/tests/QtQml/bug_1029.py b/sources/pyside2/tests/QtQml/bug_1029.py
new file mode 100755
index 000000000..c5555393b
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_1029.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import gc
+
+from PySide2.QtCore import QUrl
+from PySide2.QtGui import QGuiApplication
+from PySide2.QtQml import qmlRegisterType
+from PySide2.QtQuick import QQuickView, QQuickItem
+
+def register_qml_types():
+ class TestClass(QQuickItem):
+ def __init__(self, parent = None):
+ QQuickItem.__init__(self, parent)
+
+ qmlRegisterType(TestClass, "UserTypes", 1, 0, "TestClass")
+
+def main():
+ app = QGuiApplication([])
+
+ # reg qml types here
+ register_qml_types()
+
+ # force gc to run
+ gc.collect()
+
+ view = QQuickView()
+ url = QUrl(__file__.replace(".py", ".qml"))
+ view.setSource(url)
+
+if __name__ == "__main__":
+ main()
diff --git a/sources/pyside2/tests/QtQml/bug_1029.qml b/sources/pyside2/tests/QtQml/bug_1029.qml
new file mode 100755
index 000000000..d47f31f44
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_1029.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import UserTypes 1.0
+
+Rectangle
+{
+ width: 200
+ height: 200
+
+ color: "#ff0000"
+
+ TestClass
+ {
+
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/bug_451.py b/sources/pyside2/tests/QtQml/bug_451.py
new file mode 100755
index 000000000..58ee64eb4
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_451.py
@@ -0,0 +1,100 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''
+Test bug 451: http://bugs.openbossa.org/show_bug.cgi?id=451
+
+An archive of said bug:
+https://srinikom.github.io/pyside-bz-archive/451.html
+'''
+
+import sys
+import unittest
+
+from helper import adjust_filename
+
+from PySide2 import QtCore, QtGui, QtQuick
+
+class PythonObject(QtCore.QObject):
+ def __init__(self):
+ QtCore.QObject.__init__(self, None)
+ self._called = ""
+ self._arg1 = None
+ self._arg2 = None
+
+ def setCalled(self, v):
+ self._called = v
+
+ def setArg1(self, v):
+ self._arg1 = v
+
+ def setArg2(self, v):
+ self._arg2 = v
+
+ def getCalled(self):
+ return self._called
+
+ def getArg1(self):
+ return self._arg1
+
+ def getArg2(self):
+ return self._arg2
+
+ called = QtCore.Property(str, getCalled, setCalled)
+ arg1 = QtCore.Property(int, getArg1, setArg1)
+ arg2 = QtCore.Property('QVariant', getArg2, setArg2)
+
+class TestBug(unittest.TestCase):
+ def testQMLFunctionCall(self):
+ app = QtGui.QGuiApplication(sys.argv)
+ view = QtQuick.QQuickView()
+
+ obj = PythonObject()
+ context = view.rootContext()
+ context.setContextProperty("python", obj)
+ view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('bug_451.qml', __file__)))
+ root = view.rootObject()
+ root.simpleFunction()
+ self.assertEqual(obj.called, "simpleFunction")
+
+ root.oneArgFunction(42)
+ self.assertEqual(obj.called, "oneArgFunction")
+ self.assertEqual(obj.arg1, 42)
+
+ root.twoArgFunction(10, app)
+ self.assertEqual(obj.called, "twoArgFunction")
+ self.assertEqual(obj.arg1, 10)
+ self.assertEqual(obj.arg2, app)
+
+ rvalue = root.returnFunction()
+ self.assertEqual(obj.called, "returnFunction")
+ self.assertEqual(rvalue, 42)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/bug_451.qml b/sources/pyside2/tests/QtQml/bug_451.qml
new file mode 100755
index 000000000..60219b68e
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_451.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+
+ function simpleFunction() {
+ python.called = "simpleFunction"
+ }
+
+ function oneArgFunction(x) {
+ python.called = "oneArgFunction"
+ python.arg1 = x
+ }
+
+ function twoArgFunction(x, y) {
+ python.called = "twoArgFunction"
+ python.arg1 = x
+ python.arg2 = y
+ }
+
+ function returnFunction() {
+ python.called = "returnFunction"
+ return 42
+ }
+
+}
diff --git a/sources/pyside2/tests/QtQml/bug_456.py b/sources/pyside2/tests/QtQml/bug_456.py
new file mode 100755
index 000000000..d9a67fe19
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_456.py
@@ -0,0 +1,70 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import adjust_filename, TimedQApplication
+
+from PySide2 import QtCore, QtGui, QtQuick
+
+class RotateValue(QtCore.QObject):
+ def __init__(self):
+ super(RotateValue,self).__init__()
+
+ @QtCore.Slot(result=int)
+ def val(self):
+ return 100
+
+ def setRotation(self, v):
+ self._rotation = v
+
+ def getRotation(self):
+ return self._rotation
+
+ rotation = QtCore.Property(int, getRotation, setRotation)
+
+class TestConnectionWithInvalidSignature(TimedQApplication):
+
+ def testSlotRetur(self):
+ view = QtQuick.QQuickView()
+ rotatevalue = RotateValue()
+
+ timer = QtCore.QTimer()
+ timer.start(2000)
+
+ context = view.rootContext()
+ context.setContextProperty("rotatevalue", rotatevalue)
+ view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('bug_456.qml', __file__)))
+ root = view.rootObject()
+ button = root.findChild(QtCore.QObject, "buttonMouseArea")
+ view.show()
+ button.entered.emit()
+ self.assertEqual(rotatevalue.rotation, 100)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/bug_456.qml b/sources/pyside2/tests/QtQml/bug_456.qml
new file mode 100755
index 000000000..ebbff02d5
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_456.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+
+ width: 500; height: 200
+ color: "lightgray"
+
+ Rectangle {
+ id: button
+ width: 150; height: 40
+ color: "darkgray"
+ anchors.horizontalCenter: page.horizontalCenter
+ y: 120
+ MouseArea {
+ id: buttonMouseArea
+ objectName: "buttonMouseArea"
+ anchors.fill: parent
+ onEntered: {
+ rotatevalue.rotation = rotatevalue.val()
+ }
+ }
+ Text {
+ id: buttonText
+ text: "Press me!"
+ anchors.horizontalCenter: button.horizontalCenter
+ anchors.verticalCenter: button.verticalCenter
+ font.pointSize: 16;
+ }
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/bug_557.py b/sources/pyside2/tests/QtQml/bug_557.py
new file mode 100755
index 000000000..96e89d6d6
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_557.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+from helper import adjust_filename
+
+from PySide2.QtCore import QUrl
+from PySide2.QtGui import QGuiApplication
+from PySide2.QtQml import QQmlEngine, QQmlComponent
+
+app = QGuiApplication(sys.argv)
+
+engine = QQmlEngine()
+component = QQmlComponent(engine)
+
+# This should segfault if the QDeclarativeComponent has not QQmlEngine
+component.loadUrl(QUrl.fromLocalFile(adjust_filename('foo.qml', __file__)))
+
diff --git a/sources/pyside2/tests/QtQml/bug_726.py b/sources/pyside2/tests/QtQml/bug_726.py
new file mode 100755
index 000000000..f440b64da
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_726.py
@@ -0,0 +1,71 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import adjust_filename, TimedQApplication
+
+from PySide2 import QtCore, QtGui, QtQuick
+
+class ProxyObject(QtCore.QObject):
+ def __init__(self):
+ super(ProxyObject,self).__init__()
+ self._o = None
+ self._receivedName = ""
+
+ @QtCore.Slot(result='QObject*')
+ def getObject(self):
+ if self._o:
+ return self._o
+
+ self._o = QtCore.QObject()
+ self._o.setObjectName("PySideObject")
+ return self._o
+
+ @QtCore.Slot(str)
+ def receivedObject(self, name):
+ self._receivedName = name
+
+
+class TestConnectionWithInvalidSignature(TimedQApplication):
+
+ def testSlotRetur(self):
+ view = QtQuick.QQuickView()
+ proxy = ProxyObject()
+
+ context = view.rootContext()
+ context.setContextProperty("proxy", proxy)
+ view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('bug_726.qml', __file__)))
+ root = view.rootObject()
+ button = root.findChild(QtCore.QObject, "buttonMouseArea")
+ view.show()
+ button.entered.emit()
+ self.assertEqual(proxy._receivedName, "PySideObject")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/bug_726.qml b/sources/pyside2/tests/QtQml/bug_726.qml
new file mode 100755
index 000000000..d03376409
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_726.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+
+ width: 500; height: 200
+ color: "lightgray"
+
+ Rectangle {
+ id: button
+ width: 150; height: 40
+ color: "darkgray"
+ anchors.horizontalCenter: page.horizontalCenter
+ y: 120
+ MouseArea {
+ id: buttonMouseArea
+ objectName: "buttonMouseArea"
+ anchors.fill: parent
+ onEntered: {
+ proxy.receivedObject(proxy.getObject().objectName)
+ }
+ }
+ Text {
+ id: buttonText
+ text: "Press me!"
+ anchors.horizontalCenter: button.horizontalCenter
+ anchors.verticalCenter: button.verticalCenter
+ font.pointSize: 16;
+ }
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/bug_814.py b/sources/pyside2/tests/QtQml/bug_814.py
new file mode 100755
index 000000000..be6eea964
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_814.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Copyright (C) 2011 Thomas Perl <m@thp.io>
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# Test case for PySide bug 814
+# http://bugs.pyside.org/show_bug.cgi?id=814
+# archive:
+# https://srinikom.github.io/pyside-bz-archive/814.html
+# 2011-04-08 Thomas Perl <m@thp.io>
+# Released under the same terms as PySide itself
+
+import unittest
+
+from helper import adjust_filename, TimedQApplication
+
+from PySide2.QtCore import QUrl, QAbstractListModel, QModelIndex, Qt
+from PySide2.QtQuick import QQuickView
+
+class ListModel(QAbstractListModel):
+ def __init__(self):
+ QAbstractListModel.__init__(self)
+
+ def roleNames(self):
+ return { Qt.DisplayRole: 'pysideModelData' }
+
+ def rowCount(self, parent = QModelIndex()):
+ return 3
+
+ def data(self, index, role):
+ if index.isValid() and role == Qt.DisplayRole:
+ return 'blubb'
+ return None
+
+class TestBug814(TimedQApplication):
+ def testAbstractItemModelTransferToQML(self):
+ view = QQuickView()
+ model = ListModel()
+ view.rootContext().setContextProperty("pythonModel", model)
+ view.setSource(QUrl.fromLocalFile(adjust_filename('bug_814.qml', __file__)))
+ root = view.rootObject()
+ view.show()
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtQml/bug_814.qml b/sources/pyside2/tests/QtQml/bug_814.qml
new file mode 100755
index 000000000..bc5c23fa1
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_814.qml
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListView {
+ width: 300; height: 300
+ delegate: Text { text: pysideModelData }
+ model: pythonModel
+}
+
diff --git a/sources/pyside2/tests/QtQml/bug_825.py b/sources/pyside2/tests/QtQml/bug_825.py
new file mode 100755
index 000000000..8e896f599
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_825.py
@@ -0,0 +1,82 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import adjust_filename
+
+from PySide2.QtCore import Qt, QUrl, QTimer
+from PySide2.QtGui import QGuiApplication, QPen
+from PySide2.QtWidgets import QGraphicsItem
+from PySide2.QtQml import qmlRegisterType
+from PySide2.QtQuick import QQuickView, QQuickItem, QQuickPaintedItem
+
+paintCalled = False
+
+class MetaA(type):
+ pass
+
+class A(object):
+ __metaclass__ = MetaA
+
+MetaB = type(QQuickPaintedItem)
+B = QQuickPaintedItem
+
+class MetaC(MetaA, MetaB):
+ pass
+
+class C(A, B):
+ __metaclass__ = MetaC
+
+class Bug825 (C):
+ def __init__(self, parent = None):
+ QQuickPaintedItem.__init__(self, parent)
+
+ def paint(self, painter):
+ global paintCalled
+ pen = QPen(Qt.black, 2)
+ painter.setPen(pen);
+ painter.drawPie(self.boundingRect(), 0, 128);
+ paintCalled = True
+
+class TestBug825 (unittest.TestCase):
+ def testIt(self):
+ global paintCalled
+ app = QGuiApplication([])
+ qmlRegisterType(Bug825, 'bugs', 1, 0, 'Bug825')
+ self.assertRaises(TypeError, qmlRegisterType, A, 'bugs', 1, 0, 'A')
+
+ view = QQuickView()
+ view.setSource(QUrl.fromLocalFile(adjust_filename('bug_825.qml', __file__)))
+ view.show()
+ QTimer.singleShot(250, view.close)
+ app.exec_()
+ self.assertTrue(paintCalled)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/bug_825.qml b/sources/pyside2/tests/QtQml/bug_825.qml
new file mode 100755
index 000000000..04572dc97
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_825.qml
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import bugs 1.0
+
+Item {
+ width: 300; height: 200
+
+ Bug825 {
+ anchors.fill: parent
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/bug_847.py b/sources/pyside2/tests/QtQml/bug_847.py
new file mode 100755
index 000000000..e46888d17
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_847.py
@@ -0,0 +1,79 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Copyright (C) 2011 Thomas Perl <m@thp.io>
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# Testcase for PySide bug 847
+# Released under the same terms as PySide itself
+# 2011-05-04 Thomas Perl <m@thp.io>
+
+from __future__ import print_function
+
+import unittest
+
+from helper import adjust_filename, UsesQApplication
+
+from PySide2.QtCore import Slot, Signal, QUrl, QTimer, QCoreApplication
+from PySide2.QtQuick import QQuickView
+
+class View(QQuickView):
+ def __init__(self):
+ QQuickView.__init__(self)
+
+ called = Signal(int, int)
+
+ @Slot(int, int)
+ def blubb(self, x, y):
+ self.called.emit(x, y)
+
+class TestQML(UsesQApplication):
+ def done(self, x, y):
+ self._sucess = True
+ self.app.quit()
+ print("done called")
+
+ def testPythonSlot(self):
+ self._sucess = False
+ view = View()
+
+ # Connect first, then set the property.
+ view.called.connect(self.done)
+ view.setSource(QUrl.fromLocalFile(adjust_filename('bug_847.qml', __file__)))
+ view.rootObject().setProperty('pythonObject', view)
+
+ view.show()
+ # Essentially a timeout in case method invocation fails.
+ QTimer.singleShot(2000, QCoreApplication.instance().quit)
+ self.app.exec_()
+ self.assertTrue(self._sucess)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtQml/bug_847.qml b/sources/pyside2/tests/QtQml/bug_847.qml
new file mode 100755
index 000000000..ea764ede9
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_847.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 500
+ height: 500
+ color: 'red'
+
+ property variant pythonObject: undefined
+
+ Text {
+ anchors.centerIn: parent
+ text: 'click me'
+ color: 'white'
+ }
+
+ onPythonObjectChanged: {
+ if (pythonObject) {
+ // Delay execution of method invocation, so that the event loop has a chance to start,
+ // which will subsequently be stopped by the method.
+ timer.start()
+ }
+ }
+
+ Timer {
+ id: timer
+ interval: 100; running: false;
+ onTriggered: {
+ if (pythonObject) {
+ pythonObject.blubb(42, 84)
+ }
+ }
+ }
+}
+
diff --git a/sources/pyside2/tests/QtQml/bug_915.py b/sources/pyside2/tests/QtQml/bug_915.py
new file mode 100755
index 000000000..c94612334
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_915.py
@@ -0,0 +1,58 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import TimedQApplication
+
+from PySide2.QtQuick import QQuickView, QQuickItem
+
+class TestBug915(TimedQApplication):
+ def testReturnPolicy(self):
+ view = QQuickView()
+
+ item1 = QQuickItem()
+ item1.setObjectName("Item1")
+ item1.setParentItem(view.contentItem())
+ self.assertEqual(item1.objectName(), "Item1") # check if the item still valid
+
+ item2 = QQuickItem()
+ item2.setObjectName("Item2")
+ item2.setParentItem(view.contentItem())
+ item1 = None
+ self.assertEqual(item2.objectName(), "Item2") # check if the item still valid
+
+ view = None
+
+if __name__ == '__main__':
+ unittest.main()
+
+
diff --git a/sources/pyside2/tests/QtQml/bug_926.py b/sources/pyside2/tests/QtQml/bug_926.py
new file mode 100755
index 000000000..5f6251aa5
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_926.py
@@ -0,0 +1,69 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import unittest
+
+from helper import adjust_filename
+
+from PySide2.QtCore import QUrl, QTimer, QObject, Signal, Property
+from PySide2.QtGui import QGuiApplication
+from PySide2.QtQml import qmlRegisterType
+from PySide2.QtQuick import QQuickView
+
+class MyClass (QObject):
+
+ def __init__(self):
+ super(MyClass,self).__init__()
+ self.__url = QUrl()
+
+ def getUrl(self):
+ return self.__url
+
+ def setUrl(self,value):
+ newUrl = QUrl(value)
+ if (newUrl != self.__url):
+ self.__url = newUrl
+ self.urlChanged.emit()
+
+ urlChanged = Signal()
+ urla = Property(QUrl, getUrl, setUrl, notify = urlChanged)
+
+class TestBug926 (unittest.TestCase):
+ def testIt(self):
+ app = QGuiApplication([])
+ qmlRegisterType(MyClass,'Example',1,0,'MyClass')
+ view = QQuickView()
+ view.setSource(QUrl.fromLocalFile(adjust_filename('bug_926.qml', __file__)))
+ self.assertEqual(len(view.errors()), 0)
+ view.show()
+ QTimer.singleShot(0, app.quit)
+ app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/bug_926.qml b/sources/pyside2/tests/QtQml/bug_926.qml
new file mode 100755
index 000000000..0133ebf52
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_926.qml
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Example 1.0
+
+Rectangle {
+ width: 100
+ height: 62
+
+ MyClass {
+ id: myClass
+ urla: "http://www.pyside.org"
+ }
+
+ Text {
+ id: name
+ text: myClass.urla
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/bug_951.py b/sources/pyside2/tests/QtQml/bug_951.py
new file mode 100755
index 000000000..897412bd1
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_951.py
@@ -0,0 +1,61 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import adjust_filename, TimedQApplication
+
+from PySide2.QtCore import QUrl
+from PySide2.QtQml import qmlRegisterType
+from PySide2.QtQuick import QQuickItem, QQuickView
+
+class MyItem(QQuickItem):
+ COMPONENT_COMPLETE_CALLED = False
+ def __init__(self,parent=None):
+ super(MyItem, self).__init__(parent)
+ self.setObjectName("myitem")
+
+ def componentComplete(self):
+ MyItem.COMPONENT_COMPLETE_CALLED = True
+ super(MyItem, self).componentComplete()
+
+class TestRegisterQMLType(TimedQApplication):
+ def setup(self):
+ TimedQApplication.setup(self, 100 * 3) # 3s
+
+ def testSignalEmission(self):
+ qmlRegisterType(MyItem, "my.item", 1, 0, "MyItem")
+
+ view = QQuickView()
+ view.setSource(QUrl.fromLocalFile(adjust_filename('bug_951.qml', __file__)))
+
+ self.app.exec_()
+ self.assertTrue(MyItem.COMPONENT_COMPLETE_CALLED)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/bug_951.qml b/sources/pyside2/tests/QtQml/bug_951.qml
new file mode 100755
index 000000000..8b93bfc6d
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_951.qml
@@ -0,0 +1,35 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import my.item 1.0
+Rectangle{
+ width:10
+ height:10
+ MyItem{ }
+}
diff --git a/sources/pyside2/tests/QtQml/bug_995.py b/sources/pyside2/tests/QtQml/bug_995.py
new file mode 100755
index 000000000..d891f3445
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_995.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from helper import adjust_filename, UsesQApplication
+
+from PySide2.QtGui import QGuiApplication
+from PySide2.QtQuick import QQuickView
+
+app = QGuiApplication([])
+view = QQuickView(adjust_filename('bug_995.qml', __file__))
+view.show()
+view.resize(200, 200)
+contentItem = view.contentItem()
+item = contentItem.childAt(100, 100)
+
+# it CAN NOT crash here
+print(item)
+
diff --git a/sources/pyside2/tests/QtQml/bug_995.qml b/sources/pyside2/tests/QtQml/bug_995.qml
new file mode 100755
index 000000000..fcc33975c
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_995.qml
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 100
+ height: 100
+ color: "red"
+
+ Text {
+ text: "Hello World"
+ anchors.centerIn: parent
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/bug_997.py b/sources/pyside2/tests/QtQml/bug_997.py
new file mode 100755
index 000000000..fcb260cf3
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_997.py
@@ -0,0 +1,52 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import adjust_filename, UsesQApplication
+
+from PySide2 import QtCore, QtQml, QtQuick
+
+class TestBug(UsesQApplication):
+ def testQMLFunctionCall(self):
+ ownerData = QtQml.QQmlPropertyMap()
+ ownerData.insert('name', 'John Smith')
+ ownerData.insert('phone', '555-5555')
+ ownerData.insert('newValue', '')
+
+ view = QtQuick.QQuickView()
+ ctxt = view.rootContext()
+ ctxt.setContextProperty('owner', ownerData)
+ view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('bug_997.qml', __file__)))
+ view.show()
+ QtCore.QTimer.singleShot(1000, self.app.quit)
+ self.app.exec_()
+ self.assertEqual(ownerData.value('newName'), ownerData.value('name'))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/bug_997.qml b/sources/pyside2/tests/QtQml/bug_997.qml
new file mode 100755
index 000000000..24f5ae51f
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/bug_997.qml
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Text {
+ text: owner.name + " " + owner.phone
+ Component.onCompleted: { owner.newName = owner.name }
+}
diff --git a/sources/pyside2/tests/QtQml/connect_python_qml.py b/sources/pyside2/tests/QtQml/connect_python_qml.py
new file mode 100644
index 000000000..3eeffd0d3
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/connect_python_qml.py
@@ -0,0 +1,65 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''
+Test case for bug #442
+
+archive:
+https://srinikom.github.io/pyside-bz-archive/442.html
+'''
+
+import unittest
+
+from helper import adjust_filename, TimedQApplication
+
+from PySide2 import QtCore, QtGui, QtQuick
+
+class TestConnectionWithInvalidSignature(TimedQApplication):
+ def onButtonClicked(self):
+ self.buttonClicked = True
+ self.app.quit()
+
+ def onButtonFailClicked(self):
+ pass
+
+ def testFailConnection(self):
+ self.buttonClicked = False
+ self.buttonFailClicked = False
+ view = QtQuick.QQuickView()
+ view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('connect_python_qml.qml', __file__)))
+ root = view.rootObject()
+ button = root.findChild(QtCore.QObject, "buttonMouseArea")
+ self.assertRaises(TypeError, QtCore.QObject.connect, [button,QtCore.SIGNAL('entered()'), self.onButtonFailClicked])
+ button.entered.connect(self.onButtonClicked)
+ button.entered.emit()
+ view.show()
+ self.app.exec_()
+ self.assertTrue(self.buttonClicked)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/connect_python_qml.qml b/sources/pyside2/tests/QtQml/connect_python_qml.qml
new file mode 100755
index 000000000..79a364159
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/connect_python_qml.qml
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+
+ Rectangle {
+ id: button
+ width: 150; height: 40
+ color: "darkgray"
+ anchors.horizontalCenter: page.horizontalCenter
+ y: 150
+ MouseArea {
+ id: buttonMouseArea
+ objectName: "buttonMouseArea"
+ anchors.fill: parent
+ }
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/hw.qml b/sources/pyside2/tests/QtQml/hw.qml
new file mode 100755
index 000000000..0e682bf40
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/hw.qml
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+ }
+
+ Image {
+ // It's okay for this to fail.
+ source: "http://localhost/logo.png"
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/javascript_exceptions.py b/sources/pyside2/tests/QtQml/javascript_exceptions.py
new file mode 100644
index 000000000..513a22a3e
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/javascript_exceptions.py
@@ -0,0 +1,103 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import adjust_filename, UsesQApplication
+
+from PySide2.QtCore import Slot, Property, Signal, QObject, QUrl
+from PySide2.QtQml import QJSEngine, qmlRegisterType
+from PySide2.QtQuick import QQuickView
+
+test_error_message = "This is an error."
+
+method_test_string = """
+(function (obj) {
+ obj.methodThrows();
+})
+"""
+
+property_test_string = """
+(function (obj) {
+ obj.propertyThrows;
+})
+"""
+
+test_1 = False
+test_2 = False
+
+class TestClass(QObject):
+ @Slot()
+ def methodThrows(self):
+ raise TypeError(test_error_message)
+
+ @Property(str)
+ def propertyThrows(self):
+ raise TypeError(test_error_message)
+
+ @Slot(int)
+ def passTest(self, test):
+ global test_1, test_2
+
+ if test == 1:
+ test_1 = True
+ else:
+ test_2 = True
+
+class JavaScriptExceptionsTest(UsesQApplication):
+ def test_jsengine(self):
+ engine = QJSEngine()
+ test_object = TestClass()
+ test_value = engine.newQObject(test_object)
+
+ result_1 = engine.evaluate(method_test_string).call([test_value])
+
+ self.assertTrue(result_1.isError())
+ self.assertEqual(result_1.property('message').toString(), test_error_message)
+ self.assertEqual(result_1.property('name').toString(), 'TypeError')
+
+ result_2 = engine.evaluate(property_test_string).call([test_value])
+
+ self.assertTrue(result_2.isError())
+ self.assertEqual(result_2.property('message').toString(), test_error_message)
+ self.assertEqual(result_2.property('name').toString(), 'TypeError')
+
+ def test_qml_type(self):
+ qmlRegisterType(TestClass, 'JavaScriptExceptions', 1, 0, 'JavaScriptExceptions');
+
+ view = QQuickView()
+ qml_url = QUrl.fromLocalFile(adjust_filename('javascript_exceptions.qml', __file__))
+
+ view.setSource(qml_url)
+
+ self.assertTrue(test_1)
+ self.assertTrue(test_2)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/javascript_exceptions.qml b/sources/pyside2/tests/QtQml/javascript_exceptions.qml
new file mode 100644
index 000000000..6d0e062cf
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/javascript_exceptions.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Controls 1.0
+import JavaScriptExceptions 1.0
+
+Rectangle {
+ JavaScriptExceptions {
+ id: obj
+ }
+
+ Component.onCompleted: {
+ // Method call test
+ try {
+ obj.methodThrows();
+ } catch(e) {
+ obj.passTest(1);
+ }
+
+ // Property accessor test
+ try {
+ obj.propertyThrows;
+ } catch(e) {
+ obj.passTest(2);
+ }
+ }
+} \ No newline at end of file
diff --git a/sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile.py b/sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile.py
new file mode 100644
index 000000000..26be20f15
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile.py
@@ -0,0 +1,96 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+from helper import adjust_filename
+
+from PySide2.QtCore import QObject, QUrl, Slot, QTimer
+from PySide2.QtGui import QGuiApplication
+from PySide2.QtQml import QQmlIncubationController, VolatileBool
+from PySide2.QtQuick import QQuickView
+
+class CustomIncubationController(QObject, QQmlIncubationController):
+ def __init__(self, test):
+ QObject.__init__(self)
+ QQmlIncubationController.__init__(self)
+ self.test = test
+ self.interrupted = False
+
+ # Incubate every 50 milliseconds
+ self.startTimer(50)
+ self.incubationShouldContinue = VolatileBool(True)
+ self.test.assertEqual(self.incubationShouldContinue.get(), True)
+
+ @Slot()
+ def interrupter(self):
+ if not self.interrupted:
+ self.interrupted = True
+ self.incubationShouldContinue.set(False)
+ self.test.assertEqual(self.incubationShouldContinue.get(), False)
+ QTimer.singleShot(0, QGuiApplication.instance().quit)
+
+ def timerEvent(self, ev):
+ # Incubate items for 2000 milliseconds, or until the volatile bool is set to false.
+ self.incubateWhile(self.incubationShouldContinue, 2000)
+
+class TestBug(unittest.TestCase):
+ def testIncubateWhileCall(self):
+ app = QGuiApplication(sys.argv)
+ view = QQuickView()
+ controller = CustomIncubationController(self)
+ view.engine().setIncubationController(controller)
+ view.setResizeMode(QQuickView.SizeRootObjectToView)
+ view.setSource(QUrl.fromLocalFile(adjust_filename('qqmlincubator_incubateWhile.qml',
+ __file__)))
+ view.show()
+
+ root = view.rootObject()
+ # The QML code will issue an interrupt signal after half of its items are loaded.
+ root.shouldInterrupt.connect(controller.interrupter)
+ res = app.exec_()
+
+ itemsToCreate = root.property("itemsToCreate")
+ loadedItems = root.property("loadedItems")
+ self.assertEqual(loadedItems, itemsToCreate / 2)
+
+ # Finish incubating the remaining items.
+ controller.incubateFor(1000)
+ loadedItems = root.property("loadedItems")
+ self.assertEqual(loadedItems, itemsToCreate)
+
+ # Deleting the view before it goes out of scope is required to make sure all child QML
+ # instances are destroyed in the correct order.
+ del view
+ del app
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile.qml b/sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile.qml
new file mode 100644
index 000000000..3f4fe8214
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+
+Rectangle {
+ id: root
+ objectName: "theNicestRoot"
+ width: 400; height: 400
+
+ signal shouldInterrupt()
+ property int loadedItems: 0
+ property int itemsToCreate: 10
+
+ Row {
+ anchors.centerIn: parent
+ spacing: 20
+
+ Rectangle {
+ id: initialRectangle
+ width: 10; height: 10
+ color: "red"
+ }
+
+ Repeater {
+ model: itemsToCreate
+ Loader {
+ id: loader
+ asynchronous: true
+ source: "qqmlincubator_incubateWhile_component.qml"
+ onLoaded: {
+ root.loadedItems += 1
+
+ // Interrupt incubation after half of the items are loaded.
+ if (root.loadedItems >= (itemsToCreate / 2)) {
+ root.shouldInterrupt()
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile_component.qml b/sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile_component.qml
new file mode 100644
index 000000000..654cf2281
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/qqmlincubator_incubateWhile_component.qml
@@ -0,0 +1,35 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 10; height: 10
+ color: "yellow"
+}
diff --git a/sources/pyside2/tests/QtQml/qqmlnetwork_test.py b/sources/pyside2/tests/QtQml/qqmlnetwork_test.py
new file mode 100755
index 000000000..fab3af8c8
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/qqmlnetwork_test.py
@@ -0,0 +1,70 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QQmlNetwork'''
+
+from __future__ import print_function
+
+import unittest
+
+from PySide2.QtCore import QUrl
+from PySide2.QtQuick import QQuickView
+from PySide2.QtQml import QQmlNetworkAccessManagerFactory
+from PySide2.QtNetwork import QNetworkAccessManager
+
+from helper import adjust_filename, TimedQApplication
+
+class CustomManager(QNetworkAccessManager):
+ def createRequest(self, op, req, data = None):
+ print(">> createRequest ", self, op, req.url(), data)
+ return QNetworkAccessManager.createRequest(self, op, req, data)
+
+class CustomFactory(QQmlNetworkAccessManagerFactory):
+ def create(self, parent = None):
+ return CustomManager()
+
+class TestQQmlNetworkFactory(TimedQApplication):
+ def setUp(self):
+ TimedQApplication.setUp(self, timeout=1000)
+
+ def testQQuickNetworkFactory(self):
+ view = QQuickView()
+ self.factory = CustomFactory()
+ view.engine().setNetworkAccessManagerFactory(self.factory)
+
+ url = QUrl.fromLocalFile(adjust_filename('hw.qml', __file__))
+
+ view.setSource(url)
+ view.show()
+
+ self.assertEqual(view.status(), QQuickView.Ready)
+
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/qquickitem_grabToImage.py b/sources/pyside2/tests/QtQml/qquickitem_grabToImage.py
new file mode 100644
index 000000000..91835e689
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/qquickitem_grabToImage.py
@@ -0,0 +1,79 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from helper import adjust_filename, TimedQApplication
+from PySide2 import QtCore, QtGui, QtQuick
+
+class TestGrabToSharedPointerImage(TimedQApplication):
+ def setUp(self):
+ TimedQApplication.setUp(self, 1000)
+
+ def testQQuickItemGrabToImageSharedPointer(self):
+ view = QtQuick.QQuickView()
+ view.setSource(QtCore.QUrl.fromLocalFile(
+ adjust_filename('qquickitem_grabToImage.qml', __file__)))
+ view.show()
+
+ # Get the QQuickItem objects for the blue Rectangle and the Image item.
+ root = view.rootObject()
+ blueRectangle = root.findChild(QtQuick.QQuickItem, "blueRectangle")
+ imageContainer = root.findChild(QtQuick.QQuickItem, "imageContainer")
+
+ # Start the image grabbing.
+ grabResultSharedPtr = blueRectangle.grabToImage()
+
+ # Implicit call of operator bool() of the smart pointer, to check that it holds
+ # a valid pointer.
+ self.assertTrue(grabResultSharedPtr)
+
+ self.grabbedColor = None
+ def onGrabReady():
+ # Signal early exit.
+ QtCore.QTimer.singleShot(0, self.app.quit)
+
+ # Show the grabbed image in the QML Image item.
+ imageContainer.setProperty("source", grabResultSharedPtr.url())
+
+ # Wait for signal when grabbing is complete.
+ grabResultSharedPtr.ready.connect(onGrabReady)
+ self.app.exec_()
+
+ # Get the first pixel color of the grabbed image.
+ self.image = grabResultSharedPtr.image()
+ self.assertTrue(self.image)
+ self.grabbedColor = self.image.pixelColor(0,0)
+ self.assertTrue(self.grabbedColor.isValid())
+
+ # Compare the grabbed color with the one we set in the rectangle.
+ blueColor = QtGui.QColor("blue")
+ self.assertEqual(self.grabbedColor, blueColor)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/qquickitem_grabToImage.qml b/sources/pyside2/tests/QtQml/qquickitem_grabToImage.qml
new file mode 100644
index 000000000..d103cf076
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/qquickitem_grabToImage.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: root
+ width: 600
+ height: 600
+
+ Rectangle {
+ id: blue
+ objectName: "blueRectangle"
+ width: 200
+ height: 200
+ anchors.top: root.top
+ anchors.horizontalCenter: root.horizontalCenter
+ color: "blue"
+ }
+
+ Text {
+ text: qsTr("Original blue rectangle")
+ anchors.left: blue.right
+ anchors.verticalCenter: blue.verticalCenter
+ }
+
+ Image {
+ id: imageContainer
+ objectName: "imageContainer"
+ width: 200
+ height: 200
+ anchors.bottom: root.bottom
+ anchors.horizontalCenter: root.horizontalCenter
+ }
+
+ Text {
+ text: qsTr("Image with the source URL set to the result of calling QQuickItem::grabToImage on the rectangle. If you see a second blue rectangle, that means it works.")
+ anchors.left: imageContainer.right
+ anchors.verticalCenter: imageContainer.verticalCenter
+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
+ width: 200
+ }
+
+}
diff --git a/sources/pyside2/tests/QtQml/qquickview_test.py b/sources/pyside2/tests/QtQml/qquickview_test.py
new file mode 100755
index 000000000..e65eb3afc
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/qquickview_test.py
@@ -0,0 +1,86 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QQuickView'''
+
+import unittest
+
+from helper import adjust_filename, TimedQApplication
+
+from PySide2.QtCore import QUrl, QObject, Property, Slot
+from PySide2.QtQuick import QQuickView
+
+class MyObject(QObject):
+ def __init__(self, text, parent=None):
+ QObject.__init__(self, parent)
+ self._text = text
+
+ def getText(self):
+ return self._text
+
+
+ @Slot(str)
+ def qmlText(self, text):
+ self._qmlText = text
+
+ title = Property(str, getText)
+
+
+class TestQQuickView(TimedQApplication):
+
+ def testQQuickViewList(self):
+ view = QQuickView()
+
+ dataList = ["Item 1", "Item 2", "Item 3", "Item 4"]
+
+ ctxt = view.rootContext()
+ ctxt.setContextProperty("myModel", dataList)
+
+ url = QUrl.fromLocalFile(adjust_filename('view.qml', __file__))
+ view.setSource(url)
+ view.show()
+
+ self.assertEqual(view.status(), QQuickView.Ready)
+
+
+ def testModelExport(self):
+ view = QQuickView()
+ dataList = [MyObject("Item 1"), MyObject("Item 2"), MyObject("Item 3"), MyObject("Item 4")]
+
+ ctxt = view.rootContext()
+ ctxt.setContextProperty("myModel", dataList)
+
+ url = QUrl.fromLocalFile(adjust_filename('viewmodel.qml', __file__))
+ view.setSource(url)
+ view.show()
+
+ self.assertEqual(view.status(), QQuickView.Ready)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/registertype.py b/sources/pyside2/tests/QtQml/registertype.py
new file mode 100755
index 000000000..82bac32b1
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/registertype.py
@@ -0,0 +1,118 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import unittest
+
+import helper
+
+from PySide2.QtCore import Property, QTimer, QUrl
+from PySide2.QtGui import QGuiApplication, QPen, QColor, QPainter
+from PySide2.QtQml import qmlRegisterType, ListProperty
+from PySide2.QtQuick import QQuickView, QQuickItem, QQuickPaintedItem
+
+class PieSlice (QQuickPaintedItem):
+ def __init__(self, parent = None):
+ QQuickPaintedItem.__init__(self, parent)
+ self._color = QColor()
+ self._fromAngle = 0
+ self._angleSpan = 0
+
+ def getColor(self):
+ return self._color
+
+ def setColor(self, value):
+ self._color = value
+
+ def getFromAngle(self):
+ return self._angle
+
+ def setFromAngle(self, value):
+ self._fromAngle = value
+
+ def getAngleSpan(self):
+ return self._angleSpan
+
+ def setAngleSpan(self, value):
+ self._angleSpan = value
+
+ color = Property(QColor, getColor, setColor)
+ fromAngle = Property(int, getFromAngle, setFromAngle)
+ angleSpan = Property(int, getAngleSpan, setAngleSpan)
+
+ def paint(self, painter):
+ global paintCalled
+ pen = QPen(self._color, 2)
+ painter.setPen(pen);
+ painter.setRenderHints(QPainter.Antialiasing, True);
+ painter.drawPie(self.boundingRect(), self._fromAngle * 16, self._angleSpan * 16);
+ paintCalled = True
+
+class PieChart (QQuickItem):
+ def __init__(self, parent = None):
+ QQuickItem.__init__(self, parent)
+ self._name = ''
+ self._slices = []
+
+ def getName(self):
+ return self._name
+
+ def setName(self, value):
+ self._name = value
+
+ name = Property(str, getName, setName)
+
+ def appendSlice(self, _slice):
+ global appendCalled
+ _slice.setParentItem(self)
+ self._slices.append(_slice)
+ appendCalled = True
+
+ slices = ListProperty(PieSlice, append=appendSlice)
+
+appendCalled = False
+paintCalled = False
+
+class TestQmlSupport(unittest.TestCase):
+
+ def testIt(self):
+ app = QGuiApplication([])
+
+ qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart');
+ qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice");
+
+ view = QQuickView()
+ view.setSource(QUrl.fromLocalFile(helper.adjust_filename('registertype.qml', __file__)))
+ view.show()
+ QTimer.singleShot(250, view.close)
+ app.exec_()
+ self.assertTrue(appendCalled)
+ self.assertTrue(paintCalled)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtQml/registertype.qml b/sources/pyside2/tests/QtQml/registertype.qml
new file mode 100755
index 000000000..cfa7fce8f
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/registertype.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Charts 1.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ slices: [
+ PieSlice {
+ anchors.fill: parent
+ color: "red"
+ fromAngle: 0; angleSpan: 110
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "black"
+ fromAngle: 110; angleSpan: 50
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "blue"
+ fromAngle: 160; angleSpan: 100
+ }
+ ]
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/view.qml b/sources/pyside2/tests/QtQml/view.qml
new file mode 100755
index 000000000..8cc50e782
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/view.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ width: 100
+ Text { text: modelData }
+ }
+ }
+}
diff --git a/sources/pyside2/tests/QtQml/viewmodel.qml b/sources/pyside2/tests/QtQml/viewmodel.qml
new file mode 100755
index 000000000..18f799da8
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/viewmodel.qml
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListView {
+ width: 100; height: 100
+ anchors.fill: parent
+
+ model: myModel
+ delegate: Rectangle {
+ height: 25
+ width: 100
+ Text { text: title }
+ }
+}
+
diff --git a/sources/pyside2/tests/QtQuick/CMakeLists.txt b/sources/pyside2/tests/QtQuick/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtQuick/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtQuick/this_module_loads_test.py b/sources/pyside2/tests/QtQuick/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtQuick/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtQuickWidgets/CMakeLists.txt b/sources/pyside2/tests/QtQuickWidgets/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtQuickWidgets/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtQuickWidgets/this_module_loads_test.py b/sources/pyside2/tests/QtQuickWidgets/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtQuickWidgets/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtScript/CMakeLists.txt b/sources/pyside2/tests/QtScript/CMakeLists.txt
new file mode 100644
index 000000000..dfea68df0
--- /dev/null
+++ b/sources/pyside2/tests/QtScript/CMakeLists.txt
@@ -0,0 +1,5 @@
+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
new file mode 100644
index 000000000..623610ac0
--- /dev/null
+++ b/sources/pyside2/tests/QtScript/base_test.py
@@ -0,0 +1,32 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+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
new file mode 100644
index 000000000..740180709
--- /dev/null
+++ b/sources/pyside2/tests/QtScript/bug_1022.py
@@ -0,0 +1,41 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+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
new file mode 100644
index 000000000..15f50fe29
--- /dev/null
+++ b/sources/pyside2/tests/QtScript/engine_test.py
@@ -0,0 +1,41 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+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/property_test.py b/sources/pyside2/tests/QtScript/property_test.py
new file mode 100644
index 000000000..b958d3106
--- /dev/null
+++ b/sources/pyside2/tests/QtScript/property_test.py
@@ -0,0 +1,90 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject, Property, QCoreApplication
+from PySide2.QtScript import QScriptEngine
+
+class MyObject(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)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtScript/qscriptvalue_test.py b/sources/pyside2/tests/QtScript/qscriptvalue_test.py
new file mode 100644
index 000000000..1e1a16677
--- /dev/null
+++ b/sources/pyside2/tests/QtScript/qscriptvalue_test.py
@@ -0,0 +1,72 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import unittest
+
+from PySide2.QtScript import *
+
+# Required for eval() to work
+import PySide2.QtScript
+
+from helper 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
new file mode 100644
index 000000000..ee22737c6
--- /dev/null
+++ b/sources/pyside2/tests/QtScriptTools/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(debugger_test.py)
diff --git a/sources/pyside2/tests/QtScriptTools/debugger_test.py b/sources/pyside2/tests/QtScriptTools/debugger_test.py
new file mode 100644
index 000000000..ea8e557a6
--- /dev/null
+++ b/sources/pyside2/tests/QtScriptTools/debugger_test.py
@@ -0,0 +1,75 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import SIGNAL, QTimer
+from PySide2.QtScript import QScriptEngine
+from PySide2.QtScriptTools import QScriptEngineDebugger
+
+from helper 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/CMakeLists.txt b/sources/pyside2/tests/QtSql/CMakeLists.txt
new file mode 100644
index 000000000..8db3a9813
--- /dev/null
+++ b/sources/pyside2/tests/QtSql/CMakeLists.txt
@@ -0,0 +1,3 @@
+PYSIDE_TEST(bug_1013.py)
+PYSIDE_TEST(qsqldatabaseandqueries_test.py)
+PYSIDE_TEST(qvarianttype_test.py)
diff --git a/sources/pyside2/tests/QtSql/bug_1013.py b/sources/pyside2/tests/QtSql/bug_1013.py
new file mode 100644
index 000000000..8657fb9d2
--- /dev/null
+++ b/sources/pyside2/tests/QtSql/bug_1013.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+from PySide2.QtSql import *
+import unittest
+
+class TestBug1013 (unittest.TestCase):
+
+ def someSlot(self, row, record):
+ record.setValue(0, 2)
+ self._wasCalled = True
+
+ def testIt(self):
+ app = QCoreApplication([])
+ db = QSqlDatabase.addDatabase('QSQLITE')
+ db.setDatabaseName(':memory:')
+ db.open()
+ query = QSqlQuery()
+ query.exec_('CREATE TABLE "foo" (id INT);')
+ model = QSqlTableModel()
+ model.setTable('foo')
+
+ self._wasCalled = False
+ model.primeInsert.connect(self.someSlot)
+ model.select()
+ QTimer.singleShot(0,lambda: model.insertRow(0) and app.quit())
+ app.exec_()
+ self.assertTrue(self._wasCalled)
+ self.assertEqual(model.data(model.index(0, 0)), 2)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtSql/qsqldatabaseandqueries_test.py b/sources/pyside2/tests/QtSql/qsqldatabaseandqueries_test.py
new file mode 100644
index 000000000..b99946c44
--- /dev/null
+++ b/sources/pyside2/tests/QtSql/qsqldatabaseandqueries_test.py
@@ -0,0 +1,99 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QtSql database creation, destruction and queries'''
+
+import sys
+import unittest
+
+from PySide2 import QtSql
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+class Foo(QWidget):
+ def __init__(self):
+ QWidget.__init__(self)
+ self.model = QtSql.QSqlTableModel()
+
+class SqlDatabaseCreationDestructionAndQueries(unittest.TestCase):
+ '''Test cases for QtSql database creation, destruction and queries'''
+
+ def setUp(self):
+ #Acquire resources
+ self.assertFalse(not QtSql.QSqlDatabase.drivers(), "installed Qt has no DB drivers")
+ self.assertTrue("QSQLITE" in QtSql.QSqlDatabase.drivers(), "\"QSQLITE\" driver not available in this Qt version")
+ self.db = QtSql.QSqlDatabase.addDatabase("QSQLITE")
+ self.db.setDatabaseName(":memory:")
+ self.assertTrue(self.db.open())
+
+ def tearDown(self):
+ #Release resources
+ self.db.close()
+ QtSql.QSqlDatabase.removeDatabase(":memory:")
+ del self.db
+
+ def testTableCreationAndDestruction(self):
+ #Test table creation and destruction
+ query = QtSql.QSqlQuery()
+ query.exec_("CREATE TABLE dummy(id int primary key, dummyfield varchar(20))")
+ query.exec_("DROP TABLE dummy")
+ query.clear()
+
+ def testTableInsertionAndRetrieval(self):
+ #Test table creation, insertion and retrieval
+ query = QtSql.QSqlQuery()
+ query.exec_("CREATE TABLE person(id int primary key, "
+ "firstname varchar(20), lastname varchar(20))")
+ query.exec_("INSERT INTO person VALUES(101, 'George', 'Harrison')")
+ query.prepare("INSERT INTO person (id, firstname, lastname) "
+ "VALUES (:id, :firstname, :lastname)")
+ query.bindValue(":id", 102)
+ query.bindValue(":firstname", "John")
+ query.bindValue(":lastname", "Lennon")
+ query.exec_()
+
+ lastname = ''
+ query.exec_("SELECT lastname FROM person where id=101")
+ self.assertTrue(query.isActive())
+ query.next()
+ lastname = query.value(0)
+ self.assertEqual(lastname, 'Harrison')
+
+ def testTableModelDeletion(self):
+ app = QApplication([])
+
+ bar = Foo()
+ model = bar.model
+ del bar
+ del app
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtSql/qvarianttype_test.py b/sources/pyside2/tests/QtSql/qvarianttype_test.py
new file mode 100644
index 000000000..1eb532cea
--- /dev/null
+++ b/sources/pyside2/tests/QtSql/qvarianttype_test.py
@@ -0,0 +1,62 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QVariant::Type converter'''
+import unittest
+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)
+
+ f = QSqlField("name", "QString")
+ self.assertEqual(f.type(), py3k.unicode)
+
+ f = QSqlField("name", "double")
+ self.assertEqual(f.type(), float)
+
+ f = QSqlField("name", float)
+ self.assertEqual(f.type(), float)
+
+ 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)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtSvg/CMakeLists.txt b/sources/pyside2/tests/QtSvg/CMakeLists.txt
new file mode 100644
index 000000000..4f5e2805f
--- /dev/null
+++ b/sources/pyside2/tests/QtSvg/CMakeLists.txt
@@ -0,0 +1,3 @@
+PYSIDE_TEST(qsvggenerator_test.py)
+PYSIDE_TEST(qsvgrenderer_test.py)
+PYSIDE_TEST(qsvgwidget_test.py)
diff --git a/sources/pyside2/tests/QtSvg/qsvggenerator_test.py b/sources/pyside2/tests/QtSvg/qsvggenerator_test.py
new file mode 100644
index 000000000..4605eb455
--- /dev/null
+++ b/sources/pyside2/tests/QtSvg/qsvggenerator_test.py
@@ -0,0 +1,63 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sys import getrefcount
+from PySide2.QtCore import QBuffer
+from PySide2.QtSvg import QSvgGenerator
+
+class QSvgGeneratorTest(unittest.TestCase):
+
+ def testRefCountOfTOutputDevice(self):
+ generator = QSvgGenerator()
+ iodevice1 = QBuffer()
+ refcount1 = getrefcount(iodevice1)
+
+ generator.setOutputDevice(iodevice1)
+
+ self.assertEqual(generator.outputDevice(), iodevice1)
+ self.assertEqual(getrefcount(generator.outputDevice()), refcount1 + 1)
+
+ iodevice2 = QBuffer()
+ refcount2 = getrefcount(iodevice2)
+
+ generator.setOutputDevice(iodevice2)
+
+ self.assertEqual(generator.outputDevice(), iodevice2)
+ self.assertEqual(getrefcount(generator.outputDevice()), refcount2 + 1)
+ self.assertEqual(getrefcount(iodevice1), refcount1)
+
+ del generator
+
+ self.assertEqual(getrefcount(iodevice2), refcount2)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtSvg/qsvgrenderer_test.py b/sources/pyside2/tests/QtSvg/qsvgrenderer_test.py
new file mode 100644
index 000000000..976a2e5ac
--- /dev/null
+++ b/sources/pyside2/tests/QtSvg/qsvgrenderer_test.py
@@ -0,0 +1,53 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest, os
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+from PySide2.QtSvg import *
+
+class QSvgRendererTest(unittest.TestCase):
+
+ def testLoad(self):
+ tigerPath = os.path.join(os.path.dirname(__file__), 'tiger.svg')
+ app = QApplication([])
+
+ fromFile = QSvgRenderer(tigerPath)
+ self.assertTrue(fromFile.isValid())
+
+ tigerFile = QFile(tigerPath)
+ tigerFile.open(QFile.ReadOnly)
+ tigerData = tigerFile.readAll()
+ fromContents = QSvgRenderer(tigerData)
+ self.assertTrue(fromContents.isValid())
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtSvg/qsvgwidget_test.py b/sources/pyside2/tests/QtSvg/qsvgwidget_test.py
new file mode 100644
index 000000000..31152f9ab
--- /dev/null
+++ b/sources/pyside2/tests/QtSvg/qsvgwidget_test.py
@@ -0,0 +1,55 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest, os
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+from PySide2.QtSvg import *
+
+class QSvgWidgetTest(unittest.TestCase):
+
+ def testLoad(self):
+ tigerPath = os.path.join(os.path.dirname(__file__), 'tiger.svg')
+
+ app = QApplication([])
+ fromFile = QSvgWidget()
+ fromFile.load(tigerPath)
+ self.assertTrue(fromFile.renderer().isValid())
+
+ tigerFile = QFile(tigerPath)
+ tigerFile.open(QFile.ReadOnly)
+ tigerData = tigerFile.readAll()
+ fromContents = QSvgWidget()
+ fromContents.load(tigerData)
+ self.assertTrue(fromContents.renderer().isValid())
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtSvg/tiger.svg b/sources/pyside2/tests/QtSvg/tiger.svg
new file mode 100644
index 000000000..983e57026
--- /dev/null
+++ b/sources/pyside2/tests/QtSvg/tiger.svg
@@ -0,0 +1,730 @@
+<?xml version="1.0"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ height="800">
+ <g transform="translate(200,200)" style="fill-opacity:1; fill:none;">
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-122.304 84.285C-122.304 84.285 -122.203 86.179 -123.027 86.16C-123.851 86.141 -140.305 38.066 -160.833 40.309C-160.833 40.309 -143.05 32.956 -122.304 84.285z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-118.774 81.262C-118.774 81.262 -119.323 83.078 -120.092 82.779C-120.86 82.481 -119.977 31.675 -140.043 26.801C-140.043 26.801 -120.82 25.937 -118.774 81.262z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-91.284 123.59C-91.284 123.59 -89.648 124.55 -90.118 125.227C-90.589 125.904 -139.763 113.102 -149.218 131.459C-149.218 131.459 -145.539 112.572 -91.284 123.59z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-94.093 133.801C-94.093 133.801 -92.237 134.197 -92.471 134.988C-92.704 135.779 -143.407 139.121 -146.597 159.522C-146.597 159.522 -149.055 140.437 -94.093 133.801z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-98.304 128.276C-98.304 128.276 -96.526 128.939 -96.872 129.687C-97.218 130.435 -147.866 126.346 -153.998 146.064C-153.998 146.064 -153.646 126.825 -98.304 128.276z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-109.009 110.072C-109.009 110.072 -107.701 111.446 -108.34 111.967C-108.979 112.488 -152.722 86.634 -166.869 101.676C-166.869 101.676 -158.128 84.533 -109.009 110.072z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-116.554 114.263C-116.554 114.263 -115.098 115.48 -115.674 116.071C-116.25 116.661 -162.638 95.922 -174.992 112.469C-174.992 112.469 -168.247 94.447 -116.554 114.263z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-119.154 118.335C-119.154 118.335 -117.546 119.343 -118.036 120.006C-118.526 120.669 -167.308 106.446 -177.291 124.522C-177.291 124.522 -173.066 105.749 -119.154 118.335z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-108.42 118.949C-108.42 118.949 -107.298 120.48 -107.999 120.915C-108.7 121.35 -148.769 90.102 -164.727 103.207C-164.727 103.207 -153.862 87.326 -108.42 118.949z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-128.2 90C-128.2 90 -127.6 91.8 -128.4 92C-129.2 92.2 -157.8 50.2 -177.001 57.8C-177.001 57.8 -161.8 46 -128.2 90z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-127.505 96.979C-127.505 96.979 -126.53 98.608 -127.269 98.975C-128.007 99.343 -164.992 64.499 -182.101 76.061C-182.101 76.061 -169.804 61.261 -127.505 96.979z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.172">
+ <path d="M-127.62 101.349C-127.62 101.349 -126.498 102.88 -127.199 103.315C-127.9 103.749 -167.969 72.502 -183.927 85.607C-183.927 85.607 -173.062 69.726 -127.62 101.349z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000">
+ <path d="M-129.83 103.065C-129.327 109.113 -128.339 115.682 -126.6 118.801C-126.6 118.801 -130.2 131.201 -121.4 144.401C-121.4 144.401 -121.8 151.601 -120.2 154.801C-120.2 154.801 -116.2 163.201 -111.4 164.001C-107.516 164.648 -98.793 167.717 -88.932 169.121C-88.932 169.121 -71.8 183.201 -75 196.001C-75 196.001 -75.4 212.401 -79 214.001C-79 214.001 -67.4 202.801 -77 219.601L-81.4 238.401C-81.4 238.401 -55.8 216.801 -71.4 235.201L-81.4 261.201C-81.4 261.201 -61.8 242.801 -69 251.201L-72.2 260.001C-72.2 260.001 -29 232.801 -59.8 262.401C-59.8 262.401 -51.8 258.801 -47.4 261.601C-47.4 261.601 -40.6 260.401 -41.4 262.001C-41.4 262.001 -62.2 272.401 -65.8 290.801C-65.8 290.801 -57.4 280.801 -60.6 291.601L-60.2 303.201C-60.2 303.201 -56.2 281.601 -56.6 319.201C-56.6 319.201 -37.4 301.201 -49 322.001L-49 338.801C-49 338.801 -33.8 322.401 -40.2 335.201C-40.2 335.201 -30.2 326.401 -34.2 341.601C-34.2 341.601 -35 352.001 -30.6 340.801C-30.6 340.801 -14.6 310.201 -20.6 336.401C-20.6 336.401 -21.4 355.601 -16.6 340.801C-16.6 340.801 -16.2 351.201 -7 358.401C-7 358.401 -8.2 307.601 4.6 343.601L8.6 360.001C8.6 360.001 11.4 350.801 11 345.601C11 345.601 25.8 329.201 19 353.601C19 353.601 34.2 330.801 31 344.001C31 344.001 23.4 360.001 25 364.801C25 364.801 41.8 330.001 43 328.401C43 328.401 41 370.802 51.8 334.801C51.8 334.801 57.4 346.801 54.6 351.201C54.6 351.201 62.6 343.201 61.8 340.001C61.8 340.001 66.4 331.801 69.2 345.401C69.2 345.401 71 354.801 72.6 351.601C72.6 351.601 76.6 375.602 77.8 352.801C77.8 352.801 79.4 339.201 72.2 327.601C72.2 327.601 73 324.401 70.2 320.401C70.2 320.401 83.8 342.001 76.6 313.201C76.6 313.201 87.801 321.201 89.001 321.201C89.001 321.201 75.4 298.001 84.2 302.801C84.2 302.801 79 292.401 97.001 304.401C97.001 304.401 81 288.401 98.601 298.001C98.601 298.001 106.601 304.401 99.001 294.401C99.001 294.401 84.6 278.401 106.601 296.401C106.601 296.401 118.201 312.801 119.001 315.601C119.001 315.601 109.001 286.401 104.601 283.601C104.601 283.601 113.001 247.201 154.201 262.801C154.201 262.801 161.001 280.001 165.401 261.601C165.401 261.601 178.201 255.201 189.401 282.801C189.401 282.801 193.401 269.201 192.601 266.401C192.601 266.401 199.401 267.601 198.601 266.401C198.601 266.401 211.801 270.801 213.001 270.001C213.001 270.001 219.801 276.801 220.201 273.201C220.201 273.201 229.401 276.001 227.401 272.401C227.401 272.401 236.201 288.001 236.601 291.601L239.001 277.601L241.001 280.401C241.001 280.401 242.601 272.801 241.801 271.601C241.001 270.401 261.801 278.401 266.601 299.201L268.601 307.601C268.601 307.601 274.601 292.801 273.001 288.801C273.001 288.801 278.201 289.601 278.601 294.001C278.601 294.001 282.601 270.801 277.801 264.801C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 156.001C307.401 156.001 307.001 154.401 303.801 150.401C303.801 150.401 282.201 95.6 302.601 117.601C302.601 117.601 314.451 131.151 308.051 108.351C308.051 108.351 298.94 84.341 299.717 80.045L-129.83 103.065z"/>
+ </g>
+ <g style="fill: #cc7226; stroke:#000000">
+ <path d="M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 -53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 -119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 -139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 -129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 -103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 -51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 -42 -69.4 -39.2C-69.4 -39.2 -77 -25.2 -75.8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 -6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 -97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245z"/>
+ </g>
+ <g style="fill: #cc7226">
+ <path d="M-115.6 102.6C-140.6 63.2 -126.2 119.601 -126.2 119.601C-117.4 154.001 12.2 116.401 12.2 116.401C12.2 116.401 181.001 86 192.201 82C203.401 78 298.601 84.4 298.601 84.4L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 46.8C177.801 47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 60.4C23.4 49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 99.6 -39 93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91L-115.6 102.6z"/>
+ </g>
+ <g style="fill: #e87f3a">
+ <path d="M133.51 25.346C127.11 26.146 101.743 2.407 116.71 34.146C133.31 69.346 58.31 73.346 41.51 62.146C24.709 50.946 48.71 80.546 48.71 80.546C67.11 100.546 32.709 83.746 32.709 83.746C-1.691 70.946 -25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 88.546 -45.87 72.012 -77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 64.346 -125.546 122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 87.746 193.51 83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 196.71 42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346z"/>
+ </g>
+ <g style="fill: #ea8c4d">
+ <path d="M134.819 27.091C128.419 27.891 103.685 3.862 118.019 35.891C134.219 72.092 59.619 75.092 42.819 63.892C26.019 52.692 50.019 82.292 50.019 82.292C68.419 102.292 34.019 85.492 34.019 85.492C-0.381 72.692 -24.382 98.292 -27.582 99.092C-30.782 99.892 -35.582 103.092 -36.382 96.692C-37.182 90.292 -44.43 73.925 -76.382 99.892C-98.855 117.983 -112.036 97.074 -112.036 97.074L-115.636 105.692C-139.436 66.692 -124.891 125.71 -124.891 125.71C-116.091 160.11 14.819 119.892 14.819 119.892C14.819 119.892 183.619 89.492 194.819 85.492C206.019 81.492 299.474 87.746 299.474 87.746L294.02 69.928C229.219 23.528 211.619 47.891 198.019 43.891C184.419 39.891 186.819 49.491 183.619 50.292C180.419 51.092 141.219 26.291 134.819 27.091z"/>
+ </g>
+ <g style="fill: #ec9961">
+ <path d="M136.128 28.837C129.728 29.637 104.999 5.605 119.328 37.637C136.128 75.193 60.394 76.482 44.128 65.637C27.328 54.437 51.328 84.037 51.328 84.037C69.728 104.037 35.328 87.237 35.328 87.237C0.928 74.437 -23.072 100.037 -26.272 100.837C-29.472 101.637 -34.272 104.837 -35.072 98.437C-35.872 92.037 -42.989 75.839 -75.073 101.637C-98.782 120.474 -111.655 100.11 -111.655 100.11L-115.655 107.237C-137.455 70.437 -124.236 128.765 -124.236 128.765C-115.436 163.165 16.128 121.637 16.128 121.637C16.128 121.637 184.928 91.237 196.129 87.237C207.329 83.237 299.911 89.419 299.911 89.419L294.529 71.092C229.729 24.691 212.929 49.637 199.329 45.637C185.728 41.637 188.128 51.237 184.928 52.037C181.728 52.837 142.528 28.037 136.128 28.837z"/>
+ </g>
+ <g style="fill: #eea575">
+ <path d="M137.438 30.583C131.037 31.383 106.814 7.129 120.637 39.383C137.438 78.583 62.237 78.583 45.437 67.383C28.637 56.183 52.637 85.783 52.637 85.783C71.037 105.783 36.637 88.983 36.637 88.983C2.237 76.183 -21.763 101.783 -24.963 102.583C-28.163 103.383 -32.963 106.583 -33.763 100.183C-34.563 93.783 -41.548 77.752 -73.763 103.383C-98.709 122.965 -111.273 103.146 -111.273 103.146L-115.673 108.783C-135.473 73.982 -123.582 131.819 -123.582 131.819C-114.782 166.22 17.437 123.383 17.437 123.383C17.437 123.383 186.238 92.983 197.438 88.983C208.638 84.983 300.347 91.092 300.347 91.092L295.038 72.255C230.238 25.855 214.238 51.383 200.638 47.383C187.038 43.383 189.438 52.983 186.238 53.783C183.038 54.583 143.838 29.783 137.438 30.583z"/>
+ </g>
+ <g style="fill: #f1b288">
+ <path d="M138.747 32.328C132.347 33.128 106.383 9.677 121.947 41.128C141.147 79.928 63.546 80.328 46.746 69.128C29.946 57.928 53.946 87.528 53.946 87.528C72.346 107.528 37.946 90.728 37.946 90.728C3.546 77.928 -20.454 103.528 -23.654 104.328C-26.854 105.128 -31.654 108.328 -32.454 101.928C-33.254 95.528 -40.108 79.665 -72.454 105.128C-98.636 125.456 -110.891 106.183 -110.891 106.183L-115.691 110.328C-133.691 77.128 -122.927 134.874 -122.927 134.874C-114.127 169.274 18.746 125.128 18.746 125.128C18.746 125.128 187.547 94.728 198.747 90.728C209.947 86.728 300.783 92.764 300.783 92.764L295.547 73.419C230.747 27.019 215.547 53.128 201.947 49.128C188.347 45.128 190.747 54.728 187.547 55.528C184.347 56.328 145.147 31.528 138.747 32.328z"/>
+ </g>
+ <g style="fill: #f3bf9c">
+ <path d="M140.056 34.073C133.655 34.873 107.313 11.613 123.255 42.873C143.656 82.874 64.855 82.074 48.055 70.874C31.255 59.674 55.255 89.274 55.255 89.274C73.655 109.274 39.255 92.474 39.255 92.474C4.855 79.674 -19.145 105.274 -22.345 106.074C-25.545 106.874 -30.345 110.074 -31.145 103.674C-31.945 97.274 -38.668 81.578 -71.145 106.874C-98.564 127.947 -110.509 109.219 -110.509 109.219L-115.709 111.874C-131.709 81.674 -122.273 137.929 -122.273 137.929C-113.473 172.329 20.055 126.874 20.055 126.874C20.055 126.874 188.856 96.474 200.056 92.474C211.256 88.474 301.22 94.437 301.22 94.437L296.056 74.583C231.256 28.183 216.856 54.874 203.256 50.874C189.656 46.873 192.056 56.474 188.856 57.274C185.656 58.074 146.456 33.273 140.056 34.073z"/>
+ </g>
+ <g style="fill: #f5ccb0">
+ <path d="M141.365 35.819C134.965 36.619 107.523 13.944 124.565 44.619C146.565 84.219 66.164 83.819 49.364 72.619C32.564 61.419 56.564 91.019 56.564 91.019C74.964 111.019 40.564 94.219 40.564 94.219C6.164 81.419 -17.836 107.019 -21.036 107.819C-24.236 108.619 -29.036 111.819 -29.836 105.419C-30.636 99.019 -37.227 83.492 -69.836 108.619C-98.491 130.438 -110.127 112.256 -110.127 112.256L-115.727 113.419C-130.128 85.019 -121.618 140.983 -121.618 140.983C-112.818 175.384 21.364 128.619 21.364 128.619C21.364 128.619 190.165 98.219 201.365 94.219C212.565 90.219 301.656 96.11 301.656 96.11L296.565 75.746C231.765 29.346 218.165 56.619 204.565 52.619C190.965 48.619 193.365 58.219 190.165 59.019C186.965 59.819 147.765 35.019 141.365 35.819z"/>
+ </g>
+ <g style="fill: #f8d8c4">
+ <path d="M142.674 37.565C136.274 38.365 108.832 15.689 125.874 46.365C147.874 85.965 67.474 85.565 50.674 74.365C33.874 63.165 57.874 92.765 57.874 92.765C76.274 112.765 41.874 95.965 41.874 95.965C7.473 83.165 -16.527 108.765 -19.727 109.565C-22.927 110.365 -27.727 113.565 -28.527 107.165C-29.327 100.765 -35.786 85.405 -68.527 110.365C-98.418 132.929 -109.745 115.293 -109.745 115.293L-115.745 114.965C-129.346 88.564 -120.963 144.038 -120.963 144.038C-112.163 178.438 22.673 130.365 22.673 130.365C22.673 130.365 191.474 99.965 202.674 95.965C213.874 91.965 302.093 97.783 302.093 97.783L297.075 76.91C232.274 30.51 219.474 58.365 205.874 54.365C192.274 50.365 194.674 59.965 191.474 60.765C188.274 61.565 149.074 36.765 142.674 37.565z"/>
+ </g>
+ <g style="fill: #fae5d7">
+ <path d="M143.983 39.31C137.583 40.11 110.529 17.223 127.183 48.11C149.183 88.91 68.783 87.31 51.983 76.11C35.183 64.91 59.183 94.51 59.183 94.51C77.583 114.51 43.183 97.71 43.183 97.71C8.783 84.91 -15.217 110.51 -18.417 111.31C-21.618 112.11 -26.418 115.31 -27.218 108.91C-28.018 102.51 -34.346 87.318 -67.218 112.11C-98.345 135.42 -109.363 118.329 -109.363 118.329L-115.764 116.51C-128.764 92.51 -120.309 147.093 -120.309 147.093C-111.509 181.493 23.983 132.11 23.983 132.11C23.983 132.11 192.783 101.71 203.983 97.71C215.183 93.71 302.529 99.456 302.529 99.456L297.583 78.074C232.783 31.673 220.783 60.11 207.183 56.11C193.583 52.11 195.983 61.71 192.783 62.51C189.583 63.31 150.383 38.51 143.983 39.31z"/>
+ </g>
+ <g style="fill: #fcf2eb">
+ <path d="M145.292 41.055C138.892 41.855 112.917 18.411 128.492 49.855C149.692 92.656 70.092 89.056 53.292 77.856C36.492 66.656 60.492 96.256 60.492 96.256C78.892 116.256 44.492 99.456 44.492 99.456C10.092 86.656 -13.908 112.256 -17.108 113.056C-20.308 113.856 -25.108 117.056 -25.908 110.656C-26.708 104.256 -32.905 89.232 -65.908 113.856C-98.273 137.911 -108.982 121.365 -108.982 121.365L-115.782 118.056C-128.582 94.856 -119.654 150.147 -119.654 150.147C-110.854 184.547 25.292 133.856 25.292 133.856C25.292 133.856 194.093 103.456 205.293 99.456C216.493 95.456 302.965 101.128 302.965 101.128L298.093 79.237C233.292 32.837 222.093 61.856 208.493 57.856C194.893 53.855 197.293 63.456 194.093 64.256C190.892 65.056 151.692 40.255 145.292 41.055z"/>
+ </g>
+ <g style="fill: #ffffff">
+ <path d="M-115.8 119.601C-128.6 97.6 -119 153.201 -119 153.201C-110.2 187.601 26.6 135.601 26.6 135.601C26.6 135.601 195.401 105.2 206.601 101.2C217.801 97.2 303.401 102.8 303.401 102.8L298.601 80.4C233.801 34 223.401 63.6 209.801 59.6C196.201 55.6 198.601 65.2 195.401 66C192.201 66.8 153.001 42 146.601 42.8C140.201 43.6 114.981 19.793 129.801 51.6C152.028 99.307 69.041 89.227 54.6 79.6C37.8 68.4 61.8 98 61.8 98C80.2 118.001 45.8 101.2 45.8 101.2C11.4 88.4 -12.6 114.001 -15.8 114.801C-19 115.601 -23.8 118.801 -24.6 112.401C-25.4 106 -31.465 91.144 -64.6 115.601C-98.2 140.401 -108.6 124.401 -108.6 124.401L-115.8 119.601z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-74.2 149.601C-74.2 149.601 -81.4 161.201 -60.6 174.401C-60.6 174.401 -59.2 175.801 -77.2 171.601C-77.2 171.601 -83.4 169.601 -85 159.201C-85 159.201 -89.8 154.801 -94.6 149.201C-99.4 143.601 -74.2 149.601 -74.2 149.601z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M65.8 102C65.8 102 83.498 128.821 82.9 133.601C81.6 144.001 81.4 153.601 84.6 157.601C87.801 161.601 96.601 194.801 96.601 194.801C96.601 194.801 96.201 196.001 108.601 158.001C108.601 158.001 120.201 142.001 100.201 123.601C100.201 123.601 65 94.8 65.8 102z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-54.2 176.401C-54.2 176.401 -43 183.601 -57.4 214.801L-51 212.401C-51 212.401 -51.8 223.601 -55 226.001L-47.8 222.801C-47.8 222.801 -43 230.801 -47 235.601C-47 235.601 -30.2 243.601 -31 250.001C-31 250.001 -24.6 242.001 -28.6 235.601C-32.6 229.201 -39.8 233.201 -39 214.801L-47.8 218.001C-47.8 218.001 -42.2 209.201 -42.2 202.801L-50.2 205.201C-50.2 205.201 -34.731 178.623 -45.4 177.201C-51.4 176.401 -54.2 176.401 -54.2 176.401z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-21.8 193.201C-21.8 193.201 -19 188.801 -21.8 189.601C-24.6 190.401 -55.8 205.201 -61.8 214.801C-61.8 214.801 -27.4 190.401 -21.8 193.201z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-11.4 201.201C-11.4 201.201 -8.6 196.801 -11.4 197.601C-14.2 198.401 -45.4 213.201 -51.4 222.801C-51.4 222.801 -17 198.401 -11.4 201.201z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M1.8 186.001C1.8 186.001 4.6 181.601 1.8 182.401C-1 183.201 -32.2 198.001 -38.2 207.601C-38.2 207.601 -3.8 183.201 1.8 186.001z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-21.4 229.601C-21.4 229.601 -21.4 223.601 -24.2 224.401C-27 225.201 -63 242.801 -69 252.401C-69 252.401 -27 226.801 -21.4 229.601z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-20.2 218.801C-20.2 218.801 -19 214.001 -21.8 214.801C-23.8 214.801 -50.2 226.401 -56.2 236.001C-56.2 236.001 -26.6 214.401 -20.2 218.801z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-34.6 266.401L-44.6 274.001C-44.6 274.001 -34.2 266.401 -30.6 267.601C-30.6 267.601 -37.4 278.801 -38.2 284.001C-38.2 284.001 -27.8 271.201 -22.2 271.601C-22.2 271.601 -14.6 272.001 -14.6 282.801C-14.6 282.801 -9 272.401 -5.8 272.801C-5.8 272.801 -4.6 279.201 -5.8 286.001C-5.8 286.001 -1.8 278.401 2.2 280.001C2.2 280.001 8.6 278.001 7.8 289.601C7.8 289.601 7.8 300.001 7 302.801C7 302.801 12.6 276.401 15 276.001C15 276.001 23 274.801 27.8 283.601C27.8 283.601 23.8 276.001 28.6 278.001C28.6 278.001 39.4 279.601 42.6 286.401C42.6 286.401 35.8 274.401 41.4 277.601C41.4 277.601 48.2 277.601 49.4 284.001C49.4 284.001 57.8 305.201 59.8 306.801C59.8 306.801 52.2 285.201 53.8 285.201C53.8 285.201 51.8 273.201 57 288.001C57 288.001 53.8 274.001 59.4 274.801C65 275.601 69.4 285.601 77.8 283.201C77.8 283.201 87.401 288.801 89.401 219.601L-34.6 266.401z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-29.8 173.601C-29.8 173.601 -15 167.601 25 173.601C25 173.601 32.2 174.001 39 165.201C45.8 156.401 72.6 149.201 79 151.201L88.601 157.601L89.401 158.801C89.401 158.801 101.801 169.201 102.201 176.801C102.601 184.401 87.801 232.401 78.2 248.401C68.6 264.401 59 276.801 39.8 274.401C39.8 274.401 19 270.401 -6.6 274.401C-6.6 274.401 -35.8 272.801 -38.6 264.801C-41.4 256.801 -27.4 241.601 -27.4 241.601C-27.4 241.601 -23 233.201 -24.2 218.801C-25.4 204.401 -25 176.401 -29.8 173.601z"/>
+ </g>
+ <g style="fill: #e5668c">
+ <path d="M-7.8 175.601C0.6 194.001 -29 259.201 -29 259.201C-31 260.801 -16.34 266.846 -6.2 264.401C4.746 261.763 45 266.001 45 266.001C68.6 250.401 81.4 206.001 81.4 206.001C81.4 206.001 91.801 182.001 74.2 178.801C56.6 175.601 -7.8 175.601 -7.8 175.601z"/>
+ </g>
+ <g style="fill: #b23259">
+ <path d="M-9.831 206.497C-6.505 193.707 -4.921 181.906 -7.8 175.601C-7.8 175.601 54.6 182.001 65.8 161.201C70.041 153.326 84.801 184.001 84.4 193.601C84.4 193.601 21.4 208.001 6.6 196.801L-9.831 206.497z"/>
+ </g>
+ <g style="fill: #a5264c">
+ <path d="M-5.4 222.801C-5.4 222.801 -3.4 230.001 -5.8 234.001C-5.8 234.001 -7.4 234.801 -8.6 235.201C-8.6 235.201 -7.4 238.801 -1.4 240.401C-1.4 240.401 0.6 244.801 3 245.201C5.4 245.601 10.2 251.201 14.2 250.001C18.2 248.801 29.4 244.801 29.4 244.801C29.4 244.801 35 241.601 43.8 245.201C43.8 245.201 46.175 244.399 46.6 240.401C47.1 235.701 50.2 232.001 52.2 230.001C54.2 228.001 63.8 215.201 62.6 214.801C61.4 214.401 -5.4 222.801 -5.4 222.801z"/>
+ </g>
+ <g style="fill: #ff727f; stroke:#000000">
+ <path d="M-9.8 174.401C-9.8 174.401 -12.6 196.801 -9.4 205.201C-6.2 213.601 -7 215.601 -7.8 219.601C-8.6 223.601 -4.2 233.601 1.4 239.601L13.4 241.201C13.4 241.201 28.6 237.601 37.8 240.401C37.8 240.401 46.794 241.744 50.2 226.801C50.2 226.801 55 220.401 62.2 217.601C69.4 214.801 76.6 173.201 72.6 165.201C68.6 157.201 54.2 152.801 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-8.2 249.201C-8.2 249.201 -9 247.201 -13.4 246.801C-13.4 246.801 -35.8 243.201 -44.2 230.801C-44.2 230.801 -51 225.201 -46.6 236.801C-46.6 236.801 -36.2 257.201 -29.4 260.001C-29.4 260.001 -13 264.001 -8.2 249.201z"/>
+ </g>
+ <g style="fill: #cc3f4c">
+ <path d="M71.742 185.229C72.401 177.323 74.354 168.709 72.6 165.201C66.154 152.307 49.181 157.695 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401C-9.8 174.401 -11.545 188.364 -10.705 198.376C-10.705 198.376 26.6 186.801 27.4 192.401C27.4 192.401 29 189.201 38.2 189.201C47.4 189.201 70.142 188.029 71.742 185.229z"/>
+ </g>
+ <g style="stroke:#a51926; stroke-width:2">
+ <path d="M28.6 175.201C28.6 175.201 33.4 180.001 29.8 189.601C29.8 189.601 15.4 205.601 17.4 219.601"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-19.4 260.001C-19.4 260.001 -23.8 247.201 -15 254.001C-15 254.001 -10.2 256.001 -11.4 257.601C-12.6 259.201 -18.2 263.201 -19.4 260.001z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-14.36 261.201C-14.36 261.201 -17.88 250.961 -10.84 256.401C-10.84 256.401 -6.419 258.849 -7.96 259.281C-12.52 260.561 -7.96 263.121 -14.36 261.201z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-9.56 261.201C-9.56 261.201 -13.08 250.961 -6.04 256.401C-6.04 256.401 -1.665 258.711 -3.16 259.281C-6.52 260.561 -3.16 263.121 -9.56 261.201z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-2.96 261.401C-2.96 261.401 -6.48 251.161 0.56 256.601C0.56 256.601 4.943 258.933 3.441 259.481C0.48 260.561 3.441 263.321 -2.96 261.401z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M3.52 261.321C3.52 261.321 0 251.081 7.041 256.521C7.041 256.521 10.881 258.121 9.921 259.401C8.961 260.681 9.921 263.241 3.52 261.321z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M10.2 262.001C10.2 262.001 5.4 249.601 14.6 256.001C14.6 256.001 19.4 258.001 18.2 259.601C17 261.201 18.2 264.401 10.2 262.001z"/>
+ </g>
+ <g style="stroke:#a5264c; stroke-width:2">
+ <path d="M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 245.201 12.6 245.201"/>
+ </g>
+ <g style="stroke:#a5264c; stroke-width:2">
+ <path d="M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 238.001 47.6 233.801 52.6 230.801"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M33 237.601C33 237.601 29 226.801 26.2 239.601C23.4 252.401 20.2 256.001 18.6 258.801C18.6 258.801 18.6 264.001 27 263.601C27 263.601 37.8 263.201 38.2 260.401C38.6 257.601 37 246.001 33 237.601z"/>
+ </g>
+ <g style="stroke:#a5264c; stroke-width:2">
+ <path d="M47 244.801C47 244.801 50.6 242.401 53 243.601"/>
+ </g>
+ <g style="stroke:#a5264c; stroke-width:2">
+ <path d="M53.5 228.401C53.5 228.401 56.4 223.501 61.2 222.701"/>
+ </g>
+ <g style="fill: #b2b2b2">
+ <path d="M-25.8 265.201C-25.8 265.201 -7.8 268.401 -3.4 266.801C-3.4 266.801 5.4 266.801 -3 268.801C-3 268.801 -15.8 268.801 -23.8 267.601C-23.8 267.601 -35.4 262.001 -25.8 265.201z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-11.8 172.001C-11.8 172.001 5.8 172.001 7.8 172.801C7.8 172.801 15 203.601 11.4 211.201C11.4 211.201 10.2 214.001 7.4 208.401C7.4 208.401 -11 175.601 -14.2 173.601C-17.4 171.601 -13 172.001 -11.8 172.001z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-88.9 169.301C-88.9 169.301 -80 171.001 -67.4 173.601C-67.4 173.601 -62.6 196.001 -59.4 200.801C-56.2 205.601 -59.8 205.601 -63.4 202.801C-67 200.001 -81.8 186.001 -83.8 181.601C-85.8 177.201 -88.9 169.301 -88.9 169.301z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-67.039 173.818C-67.039 173.818 -61.239 175.366 -60.23 177.581C-59.222 179.795 -61.432 183.092 -61.432 183.092C-61.432 183.092 -62.432 186.397 -63.634 184.235C-64.836 182.072 -67.708 174.412 -67.039 173.818z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-67 173.601C-67 173.601 -63.4 178.801 -59.8 178.801C-56.2 178.801 -55.818 178.388 -53 179.001C-48.4 180.001 -48.8 178.001 -42.2 179.201C-39.56 179.681 -37 178.801 -34.2 180.001C-31.4 181.201 -28.2 180.401 -27 178.401C-25.8 176.401 -21 172.201 -21 172.201C-21 172.201 -33.8 174.001 -36.6 174.801C-36.6 174.801 -59 176.001 -67 173.601z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-22.4 173.801C-22.4 173.801 -28.85 177.301 -29.25 179.701C-29.65 182.101 -24 185.801 -24 185.801C-24 185.801 -21.25 190.401 -20.65 188.001C-20.05 185.601 -21.6 174.201 -22.4 173.801z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-59.885 179.265C-59.885 179.265 -52.878 190.453 -52.661 179.242C-52.661 179.242 -52.104 177.984 -53.864 177.962C-59.939 177.886 -58.418 173.784 -59.885 179.265z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-52.707 179.514C-52.707 179.514 -44.786 190.701 -45.422 179.421C-45.422 179.421 -45.415 179.089 -47.168 178.936C-51.915 178.522 -51.57 174.004 -52.707 179.514z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-45.494 179.522C-45.494 179.522 -37.534 190.15 -38.203 180.484C-38.203 180.484 -38.084 179.251 -39.738 178.95C-43.63 178.244 -43.841 174.995 -45.494 179.522z"/>
+ </g>
+ <g style="fill: #ffffcc; stroke:#000000; stroke-width:0.5">
+ <path d="M-38.618 179.602C-38.618 179.602 -30.718 191.163 -30.37 181.382C-30.37 181.382 -28.726 180.004 -30.472 179.782C-36.29 179.042 -35.492 174.588 -38.618 179.602z"/>
+ </g>
+ <g style="fill: #e5e5b2">
+ <path d="M-74.792 183.132L-82.45 181.601C-85.05 176.601 -87.15 170.451 -87.15 170.451C-87.15 170.451 -80.8 171.451 -68.3 174.251C-68.3 174.251 -67.424 177.569 -65.952 183.364L-74.792 183.132z"/>
+ </g>
+ <g style="fill: #e5e5b2">
+ <path d="M-9.724 178.47C-11.39 175.964 -12.707 174.206 -13.357 173.8C-16.37 171.917 -12.227 172.294 -11.098 172.294C-11.098 172.294 5.473 172.294 7.356 173.047C7.356 173.047 7.88 175.289 8.564 178.68C8.564 178.68 -1.524 176.67 -9.724 178.47z"/>
+ </g>
+ <g style="fill: #cc7226">
+ <path d="M43.88 40.321C71.601 44.281 97.121 8.641 98.881 -1.04C100.641 -10.72 90.521 -22.6 90.521 -22.6C91.841 -25.68 87.001 -39.76 81.721 -49C76.441 -58.24 60.54 -57.266 43 -58.24C27.16 -59.12 8.68 -35.8 7.36 -34.04C6.04 -32.28 12.2 6.001 13.52 11.721C14.84 17.441 12.2 43.841 12.2 43.841C46.44 34.741 16.16 36.361 43.88 40.321z"/>
+ </g>
+ <g style="fill: #ea8e51">
+ <path d="M8.088 -33.392C6.792 -31.664 12.84 5.921 14.136 11.537C15.432 17.153 12.84 43.073 12.84 43.073C45.512 34.193 16.728 35.729 43.944 39.617C71.161 43.505 96.217 8.513 97.945 -0.992C99.673 -10.496 89.737 -22.16 89.737 -22.16C91.033 -25.184 86.281 -39.008 81.097 -48.08C75.913 -57.152 60.302 -56.195 43.08 -57.152C27.528 -58.016 9.384 -35.12 8.088 -33.392z"/>
+ </g>
+ <g style="fill: #efaa7c">
+ <path d="M8.816 -32.744C7.544 -31.048 13.48 5.841 14.752 11.353C16.024 16.865 13.48 42.305 13.48 42.305C44.884 33.145 17.296 35.097 44.008 38.913C70.721 42.729 95.313 8.385 97.009 -0.944C98.705 -10.272 88.953 -21.72 88.953 -21.72C90.225 -24.688 85.561 -38.256 80.473 -47.16C75.385 -56.064 60.063 -55.125 43.16 -56.064C27.896 -56.912 10.088 -34.44 8.816 -32.744z"/>
+ </g>
+ <g style="fill: #f4c6a8">
+ <path d="M9.544 -32.096C8.296 -30.432 14.12 5.761 15.368 11.169C16.616 16.577 14.12 41.537 14.12 41.537C43.556 32.497 17.864 34.465 44.072 38.209C70.281 41.953 94.409 8.257 96.073 -0.895C97.737 -10.048 88.169 -21.28 88.169 -21.28C89.417 -24.192 84.841 -37.504 79.849 -46.24C74.857 -54.976 59.824 -54.055 43.24 -54.976C28.264 -55.808 10.792 -33.76 9.544 -32.096z"/>
+ </g>
+ <g style="fill: #f9e2d3">
+ <path d="M10.272 -31.448C9.048 -29.816 14.76 5.681 15.984 10.985C17.208 16.289 14.76 40.769 14.76 40.769C42.628 31.849 18.432 33.833 44.136 37.505C69.841 41.177 93.505 8.129 95.137 -0.848C96.769 -9.824 87.385 -20.84 87.385 -20.84C88.609 -23.696 84.121 -36.752 79.225 -45.32C74.329 -53.888 59.585 -52.985 43.32 -53.888C28.632 -54.704 11.496 -33.08 10.272 -31.448z"/>
+ </g>
+ <g style="fill: #ffffff">
+ <path d="M44.2 36.8C69.4 40.4 92.601 8 94.201 -0.8C95.801 -9.6 86.601 -20.4 86.601 -20.4C87.801 -23.2 83.4 -36 78.6 -44.4C73.8 -52.8 59.346 -51.914 43.4 -52.8C29 -53.6 12.2 -32.4 11 -30.8C9.8 -29.2 15.4 5.6 16.6 10.8C17.8 16 15.4 40 15.4 40C40.9 31.4 19 33.2 44.2 36.8z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M90.601 2.8C90.601 2.8 62.8 10.4 51.2 8.8C51.2 8.8 35.4 2.2 26.6 24C26.6 24 23 31.2 21 33.2C19 35.2 90.601 2.8 90.601 2.8z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M94.401 0.6C94.401 0.6 65.4 12.8 55.4 12.4C55.4 12.4 39 7.8 30.6 22.4C30.6 22.4 22.2 31.6 19 33.2C19 33.2 18.6 34.8 25 30.8L35.4 36C35.4 36 50.2 45.6 59.8 29.6C59.8 29.6 63.8 18.4 63.8 16.4C63.8 14.4 85 8.8 86.601 8.4C88.201 8 94.801 3.8 94.401 0.6z"/>
+ </g>
+ <g style="fill: #99cc32">
+ <path d="M47 36.514C40.128 36.514 31.755 32.649 31.755 26.4C31.755 20.152 40.128 13.887 47 13.887C53.874 13.887 59.446 18.952 59.446 25.2C59.446 31.449 53.874 36.514 47 36.514z"/>
+ </g>
+ <g style="fill: #659900">
+ <path d="M43.377 19.83C38.531 20.552 33.442 22.055 33.514 21.839C35.054 17.22 41.415 13.887 47 13.887C51.296 13.887 55.084 15.865 57.32 18.875C57.32 18.875 52.004 18.545 43.377 19.83z"/>
+ </g>
+ <g style="fill: #ffffff">
+ <path d="M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M45.4 27.726C42.901 27.726 40.875 25.7 40.875 23.2C40.875 20.701 42.901 18.675 45.4 18.675C47.9 18.675 49.926 20.701 49.926 23.2C49.926 25.7 47.9 27.726 45.4 27.726z"/>
+ </g>
+ <g style="fill: #cc7226">
+ <path d="M-58.6 14.4C-58.6 14.4 -61.8 -6.8 -59.4 -11.2C-59.4 -11.2 -48.6 -21.2 -49 -24.8C-49 -24.8 -49.4 -42.8 -50.6 -43.6C-51.8 -44.4 -59.4 -50.4 -65.4 -44C-65.4 -44 -75.8 -26 -75 -19.6L-75 -17.6C-75 -17.6 -82.6 -18 -84.2 -16C-84.2 -16 -85.4 -10.8 -86.6 -10.4C-86.6 -10.4 -89.4 -8 -87.4 -5.2C-87.4 -5.2 -89.4 -2.8 -89 1.2L-81.4 5.2C-81.4 5.2 -79.4 19.6 -68.6 24.8C-63.764 27.129 -60.6 20.4 -58.6 14.4z"/>
+ </g>
+ <g style="fill: #ffffff">
+ <path d="M-59.6 12.56C-59.6 12.56 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.48 -40.36 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.96 -59.6 12.56z"/>
+ </g>
+ <g style="fill: #eb955c">
+ <path d="M-51.05 -42.61C-52.14 -43.47 -59.63 -49.24 -65.48 -43C-65.48 -43 -75.62 -25.45 -74.84 -19.21L-74.84 -17.26C-74.84 -17.26 -82.25 -17.65 -83.81 -15.7C-83.81 -15.7 -84.98 -10.63 -86.15 -10.24C-86.15 -10.24 -88.88 -7.9 -86.93 -5.17C-86.93 -5.17 -88.88 -2.83 -88.49 1.07L-81.08 4.97C-81.08 4.97 -79.13 19.01 -68.6 24.08C-63.886 26.35 -60.8 19.79 -58.85 13.94C-58.85 13.94 -61.97 -6.73 -59.63 -11.02C-59.63 -11.02 -49.1 -20.77 -49.49 -24.28C-49.49 -24.28 -49.88 -41.83 -51.05 -42.61z"/>
+ </g>
+ <g style="fill: #f2b892">
+ <path d="M-51.5 -41.62C-52.48 -42.54 -59.86 -48.08 -65.56 -42C-65.56 -42 -75.44 -24.9 -74.68 -18.82L-74.68 -16.92C-74.68 -16.92 -81.9 -17.3 -83.42 -15.4C-83.42 -15.4 -84.56 -10.46 -85.7 -10.08C-85.7 -10.08 -88.36 -7.8 -86.46 -5.14C-86.46 -5.14 -88.36 -2.86 -87.98 0.94L-80.76 4.74C-80.76 4.74 -78.86 18.42 -68.6 23.36C-64.006 25.572 -61 19.18 -59.1 13.48C-59.1 13.48 -62.14 -6.66 -59.86 -10.84C-59.86 -10.84 -49.6 -20.34 -49.98 -23.76C-49.98 -23.76 -50.36 -40.86 -51.5 -41.62z"/>
+ </g>
+ <g style="fill: #f8dcc8">
+ <path d="M-51.95 -40.63C-52.82 -41.61 -60.09 -46.92 -65.64 -41C-65.64 -41 -75.26 -24.35 -74.52 -18.43L-74.52 -16.58C-74.52 -16.58 -81.55 -16.95 -83.03 -15.1C-83.03 -15.1 -84.14 -10.29 -85.25 -9.92C-85.25 -9.92 -87.84 -7.7 -85.99 -5.11C-85.99 -5.11 -87.84 -2.89 -87.47 0.81L-80.44 4.51C-80.44 4.51 -78.59 17.83 -68.6 22.64C-64.127 24.794 -61.2 18.57 -59.35 13.02C-59.35 13.02 -62.31 -6.59 -60.09 -10.66C-60.09 -10.66 -50.1 -19.91 -50.47 -23.24C-50.47 -23.24 -50.84 -39.89 -51.95 -40.63z"/>
+ </g>
+ <g style="fill: #ffffff">
+ <path d="M-59.6 12.46C-59.6 12.46 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.16 -40.68 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.86 -59.6 12.46z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-62.7 6.2C-62.7 6.2 -84.3 -4 -85.2 -4.8C-85.2 -4.8 -76.1 3.4 -75.3 3.4C-74.5 3.4 -62.7 6.2 -62.7 6.2z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-79.8 0C-79.8 0 -61.4 3.6 -61.4 8C-61.4 10.912 -61.643 24.331 -67 22.8C-75.4 20.4 -71.8 6 -79.8 0z"/>
+ </g>
+ <g style="fill: #99cc32">
+ <path d="M-71.4 3.8C-71.4 3.8 -62.422 5.274 -61.4 8C-60.8 9.6 -60.137 17.908 -65.6 19C-70.152 19.911 -72.382 9.69 -71.4 3.8z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M14.595 46.349C14.098 44.607 15.409 44.738 17.2 44.2C19.2 43.6 31.4 39.8 32.2 37.2C33 34.6 46.2 39 46.2 39C48 39.8 52.4 42.4 52.4 42.4C57.2 43.6 63.8 44 63.8 44C66.2 45 69.6 47.8 69.6 47.8C84.2 58 96.601 50.8 96.601 50.8C116.601 44.2 110.601 27 110.601 27C107.601 18 110.801 14.6 110.801 14.6C111.001 10.8 118.201 17.2 118.201 17.2C120.801 21.4 121.601 26.4 121.601 26.4C129.601 37.6 126.201 19.8 126.201 19.8C126.401 18.8 123.601 15.2 123.601 14C123.601 12.8 121.801 9.4 121.801 9.4C118.801 6 121.201 -1 121.201 -1C123.001 -14.8 120.801 -13 120.801 -13C119.601 -14.8 110.401 -4.8 110.401 -4.8C108.201 -1.4 102.201 0.2 102.201 0.2C99.401 2 96.001 0.6 96.001 0.6C93.401 0.2 87.801 7.2 87.801 7.2C90.601 7 93.001 11.4 95.401 11.6C97.801 11.8 99.601 9.2 101.201 8.6C102.801 8 105.601 13.8 105.601 13.8C106.001 16.4 100.401 21.2 100.401 21.2C100.001 25.8 98.401 24.2 98.401 24.2C95.401 23.6 94.201 27.4 93.201 32C92.201 36.6 88.001 37 88.001 37C86.401 44.4 85.2 41.4 85.2 41.4C85 35.8 79 41.6 79 41.6C77.8 43.6 73.2 41.4 73.2 41.4C66.4 39.4 68.8 37.4 68.8 37.4C70.6 35.2 81.8 37.4 81.8 37.4C84 35.8 76 31.8 76 31.8C75.4 30 76.4 25.6 76.4 25.6C77.6 22.4 84.4 16.8 84.4 16.8C93.801 15.6 91.001 14 91.001 14C84.801 8.8 79 16.4 79 16.4C76.8 22.6 59.4 37.6 59.4 37.6C54.6 41 57.2 34.2 53.2 37.6C49.2 41 28.6 32 28.6 32C17.038 30.807 14.306 46.549 10.777 43.429C10.777 43.429 16.195 51.949 14.595 46.349z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M209.401 -120C209.401 -120 183.801 -112 181.001 -93.2C181.001 -93.2 178.601 -70.4 199.001 -52.8C199.001 -52.8 199.401 -46.4 201.401 -43.2C201.401 -43.2 199.801 -38.4 218.601 -46L245.801 -54.4C245.801 -54.4 252.201 -56.8 257.401 -65.6C262.601 -74.4 277.801 -93.2 274.201 -118.4C274.201 -118.4 275.401 -129.6 269.401 -130C269.401 -130 261.001 -131.6 253.801 -124C253.801 -124 247.001 -120.8 244.601 -121.2L209.401 -120z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M264.022 -120.99C264.022 -120.99 266.122 -129.92 261.282 -125.08C261.282 -125.08 254.242 -119.36 246.761 -119.36C246.761 -119.36 232.241 -117.16 227.841 -103.96C227.841 -103.96 223.881 -77.12 231.801 -71.4C231.801 -71.4 236.641 -63.92 243.681 -70.52C250.722 -77.12 266.222 -107.35 264.022 -120.99z"/>
+ </g>
+ <g style="fill: #323232">
+ <path d="M263.648 -120.632C263.648 -120.632 265.738 -129.376 260.986 -124.624C260.986 -124.624 254.074 -119.008 246.729 -119.008C246.729 -119.008 232.473 -116.848 228.153 -103.888C228.153 -103.888 224.265 -77.536 232.041 -71.92C232.041 -71.92 236.793 -64.576 243.705 -71.056C250.618 -77.536 265.808 -107.24 263.648 -120.632z"/>
+ </g>
+ <g style="fill: #666666">
+ <path d="M263.274 -120.274C263.274 -120.274 265.354 -128.832 260.69 -124.168C260.69 -124.168 253.906 -118.656 246.697 -118.656C246.697 -118.656 232.705 -116.536 228.465 -103.816C228.465 -103.816 224.649 -77.952 232.281 -72.44C232.281 -72.44 236.945 -65.232 243.729 -71.592C250.514 -77.952 265.394 -107.13 263.274 -120.274z"/>
+ </g>
+ <g style="fill: #999999">
+ <path d="M262.9 -119.916C262.9 -119.916 264.97 -128.288 260.394 -123.712C260.394 -123.712 253.738 -118.304 246.665 -118.304C246.665 -118.304 232.937 -116.224 228.777 -103.744C228.777 -103.744 225.033 -78.368 232.521 -72.96C232.521 -72.96 237.097 -65.888 243.753 -72.128C250.41 -78.368 264.98 -107.02 262.9 -119.916z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M262.526 -119.558C262.526 -119.558 264.586 -127.744 260.098 -123.256C260.098 -123.256 253.569 -117.952 246.633 -117.952C246.633 -117.952 233.169 -115.912 229.089 -103.672C229.089 -103.672 225.417 -78.784 232.761 -73.48C232.761 -73.48 237.249 -66.544 243.777 -72.664C250.305 -78.784 264.566 -106.91 262.526 -119.558z"/>
+ </g>
+ <g style="fill: #ffffff">
+ <path d="M262.151 -119.2C262.151 -119.2 264.201 -127.2 259.801 -122.8C259.801 -122.8 253.401 -117.6 246.601 -117.6C246.601 -117.6 233.401 -115.6 229.401 -103.6C229.401 -103.6 225.801 -79.2 233.001 -74C233.001 -74 237.401 -67.2 243.801 -73.2C250.201 -79.2 264.151 -106.8 262.151 -119.2z"/>
+ </g>
+ <g style="fill: #992600">
+ <path d="M50.6 84C50.6 84 30.2 64.8 22.2 64C22.2 64 -12.2 60 -27 78C-27 78 -9.4 57.6 18.2 63.2C18.2 63.2 -3.4 58.8 -15.8 62C-15.8 62 -32.6 62 -42.2 76L-45 80.8C-45 80.8 -41 66 -22.6 60C-22.6 60 0.2 55.2 11 60C11 60 -10.6 53.2 -20.6 55.2C-20.6 55.2 -51 52.8 -63.8 79.2C-63.8 79.2 -59.8 64.8 -45 57.6C-45 57.6 -31.4 48.8 -11 51.6C-11 51.6 3.4 54.8 8.6 57.2C13.8 59.6 12.6 56.8 4.2 52C4.2 52 -1.4 42 -15.4 42.4C-15.4 42.4 -58.2 46 -68.6 58C-68.6 58 -55 46.8 -44.6 44C-44.6 44 -22.2 36 -13.8 36.8C-13.8 36.8 11 37.8 18.6 33.8C18.6 33.8 7.4 38.8 10.6 42C13.8 45.2 20.6 52.8 20.6 54C20.6 55.2 44.8 77.3 48.4 81.7L50.6 84z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M189 278C189 278 173.5 241.5 161 232C161 232 187 248 190.5 266C190.5 266 190.5 276 189 278z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M236 285.5C236 285.5 209.5 230.5 191 206.5C191 206.5 234.5 244 239.5 270.5L240 276L237 273.5C237 273.5 236.5 282.5 236 285.5z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M292.5 237C292.5 237 230 177.5 228.5 175C228.5 175 289 241 292 248.5C292 248.5 290 239.5 292.5 237z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M104 280.5C104 280.5 123.5 228.5 142.5 251C142.5 251 157.5 261 157 264C157 264 153 257.5 135 258C135 258 116 255 104 280.5z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M294.5 153C294.5 153 249.5 124.5 242 123C230.193 120.639 291.5 152 296.5 162.5C296.5 162.5 298.5 160 294.5 153z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M143.801 259.601C143.801 259.601 164.201 257.601 171.001 250.801L175.401 254.401L193.001 216.001L196.601 221.201C196.601 221.201 211.001 206.401 210.201 198.401C209.401 190.401 223.001 204.401 223.001 204.401C223.001 204.401 222.201 192.801 229.401 199.601C229.401 199.601 227.001 184.001 235.401 192.001C235.401 192.001 224.864 161.844 247.401 187.601C253.001 194.001 248.601 187.201 248.601 187.201C248.601 187.201 222.601 139.201 244.201 153.601C244.201 153.601 246.201 130.801 245.001 126.401C243.801 122.001 241.801 99.6 237.001 94.4C232.201 89.2 237.401 87.6 243.001 92.8C243.001 92.8 231.801 68.8 245.001 80.8C245.001 80.8 241.401 65.6 237.001 62.8C237.001 62.8 231.401 45.6 246.601 56.4C246.601 56.4 242.201 44 239.001 40.8C239.001 40.8 227.401 13.2 234.601 18L239.001 21.6C239.001 21.6 232.201 7.6 238.601 12C245.001 16.4 245.001 16 245.001 16C245.001 16 223.801 -17.2 244.201 0.4C244.201 0.4 236.042 -13.518 232.601 -20.4C232.601 -20.4 213.801 -40.8 228.201 -34.4L233.001 -32.8C233.001 -32.8 224.201 -42.8 216.201 -44.4C208.201 -46 218.601 -52.4 225.001 -50.4C231.401 -48.4 247.001 -40.8 247.001 -40.8C247.001 -40.8 259.801 -22 263.801 -21.6C263.801 -21.6 243.801 -29.2 249.801 -21.2C249.801 -21.2 264.201 -7.2 257.001 -7.6C257.001 -7.6 251.001 -0.4 255.801 8.4C255.801 8.4 237.342 -9.991 252.201 15.6L259.001 32C259.001 32 234.601 7.2 245.801 29.2C245.801 29.2 263.001 52.8 265.001 53.2C267.001 53.6 271.401 62.4 271.401 62.4L267.001 60.4L272.201 69.2C272.201 69.2 261.001 57.2 267.001 70.4L272.601 84.8C272.601 84.8 252.201 62.8 265.801 92.4C265.801 92.4 249.401 87.2 258.201 104.4C258.201 104.4 256.601 120.401 257.001 125.601C257.401 130.801 258.601 159.201 254.201 167.201C249.801 175.201 260.201 194.401 262.201 198.401C264.201 202.401 267.801 213.201 259.001 204.001C250.201 194.801 254.601 200.401 256.601 209.201C258.601 218.001 264.601 233.601 263.801 239.201C263.801 239.201 262.601 240.401 259.401 236.801C259.401 236.801 244.601 214.001 246.201 228.401C246.201 228.401 245.001 236.401 241.801 245.201C241.801 245.201 238.601 256.001 238.601 247.201C238.601 247.201 235.401 230.401 232.601 238.001C229.801 245.601 226.201 251.601 223.401 254.001C220.601 256.401 215.401 233.601 214.201 244.001C214.201 244.001 202.201 231.601 197.401 248.001L185.801 264.401C185.801 264.401 185.401 252.001 184.201 258.001C184.201 258.001 154.201 264.001 143.801 259.601z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M109.401 -97.2C109.401 -97.2 97.801 -105.2 93.801 -104.8C89.801 -104.4 121.401 -113.6 162.601 -86C162.601 -86 167.401 -83.2 171.001 -83.6C171.001 -83.6 174.201 -81.2 171.401 -77.6C171.401 -77.6 162.601 -68 173.801 -56.8C173.801 -56.8 192.201 -50 186.601 -58.8C186.601 -58.8 197.401 -54.8 199.801 -50.8C202.201 -46.8 201.001 -50.8 201.001 -50.8C201.001 -50.8 194.601 -58 188.601 -63.2C188.601 -63.2 183.401 -65.2 180.601 -73.6C177.801 -82 175.401 -92 179.801 -95.2C179.801 -95.2 175.801 -90.8 176.601 -94.8C177.401 -98.8 181.001 -102.4 182.601 -102.8C184.201 -103.2 200.601 -119 207.401 -119.4C207.401 -119.4 198.201 -118 195.201 -119C192.201 -120 165.601 -131.4 159.601 -132.6C159.601 -132.6 142.801 -139.2 154.801 -137.2C154.801 -137.2 190.601 -133.4 208.801 -120.2C208.801 -120.2 201.601 -128.6 183.201 -135.6C183.201 -135.6 161.001 -148.2 125.801 -143.2C125.801 -143.2 108.001 -140 100.201 -138.2C100.201 -138.2 97.601 -138.8 97.001 -139.2C96.401 -139.6 84.6 -148.6 57 -141.6C57 -141.6 40 -137 31.4 -132.2C31.4 -132.2 16.2 -131 12.6 -127.8C12.6 -127.8 -6 -113.2 -8 -112.4C-10 -111.6 -21.4 -104 -22.2 -103.6C-22.2 -103.6 2.4 -110.2 4.8 -112.6C7.2 -115 24.6 -117.6 27 -116.2C29.4 -114.8 37.8 -115.4 28.2 -114.8C28.2 -114.8 103.801 -100 104.601 -98C105.401 -96 109.401 -97.2 109.401 -97.2z"/>
+ </g>
+ <g style="fill: #cc7226">
+ <path d="M180.801 -106.4C180.801 -106.4 170.601 -113.8 168.601 -113.8C166.601 -113.8 154.201 -124 150.001 -123.6C145.801 -123.2 133.601 -133.2 106.201 -125C106.201 -125 105.601 -127 109.201 -127.8C109.201 -127.8 115.601 -130 116.001 -130.6C116.001 -130.6 136.201 -134.8 143.401 -131.2C143.401 -131.2 152.601 -128.6 158.801 -122.4C158.801 -122.4 170.001 -119.2 173.201 -120.2C173.201 -120.2 182.001 -118 182.401 -116.2C182.401 -116.2 188.201 -113.2 186.401 -110.6C186.401 -110.6 186.801 -109 180.801 -106.4z"/>
+ </g>
+ <g style="fill: #cc7226">
+ <path d="M168.33 -108.509C169.137 -107.877 170.156 -107.779 170.761 -106.97C170.995 -106.656 170.706 -106.33 170.391 -106.233C169.348 -105.916 168.292 -106.486 167.15 -105.898C166.748 -105.691 166.106 -105.873 165.553 -106.022C163.921 -106.463 162.092 -106.488 160.401 -105.8C158.416 -106.929 156.056 -106.345 153.975 -107.346C153.917 -107.373 153.695 -107.027 153.621 -107.054C150.575 -108.199 146.832 -107.916 144.401 -110.2C141.973 -110.612 139.616 -111.074 137.188 -111.754C135.37 -112.263 133.961 -113.252 132.341 -114.084C130.964 -114.792 129.507 -115.314 127.973 -115.686C126.11 -116.138 124.279 -116.026 122.386 -116.546C122.293 -116.571 122.101 -116.227 122.019 -116.254C121.695 -116.362 121.405 -116.945 121.234 -116.892C119.553 -116.37 118.065 -117.342 116.401 -117C115.223 -118.224 113.495 -117.979 111.949 -118.421C108.985 -119.269 105.831 -117.999 102.801 -119C106.914 -120.842 111.601 -119.61 115.663 -121.679C117.991 -122.865 120.653 -121.763 123.223 -122.523C123.71 -122.667 124.401 -122.869 124.801 -122.2C124.935 -122.335 125.117 -122.574 125.175 -122.546C127.625 -121.389 129.94 -120.115 132.422 -119.049C132.763 -118.903 133.295 -119.135 133.547 -118.933C135.067 -117.717 137.01 -117.82 138.401 -116.6C140.099 -117.102 141.892 -116.722 143.621 -117.346C143.698 -117.373 143.932 -117.032 143.965 -117.054C145.095 -117.802 146.25 -117.531 147.142 -117.227C147.48 -117.112 148.143 -116.865 148.448 -116.791C149.574 -116.515 150.43 -116.035 151.609 -115.852C151.723 -115.834 151.908 -116.174 151.98 -116.146C153.103 -115.708 154.145 -115.764 154.801 -114.6C154.936 -114.735 155.101 -114.973 155.183 -114.946C156.21 -114.608 156.859 -113.853 157.96 -113.612C158.445 -113.506 159.057 -112.88 159.633 -112.704C162.025 -111.973 163.868 -110.444 166.062 -109.549C166.821 -109.239 167.697 -109.005 168.33 -108.509z"/>
+ </g>
+ <g style="fill: #cc7226">
+ <path d="M91.696 -122.739C89.178 -124.464 86.81 -125.57 84.368 -127.356C84.187 -127.489 83.827 -127.319 83.625 -127.441C82.618 -128.05 81.73 -128.631 80.748 -129.327C80.209 -129.709 79.388 -129.698 78.88 -129.956C76.336 -131.248 73.707 -131.806 71.2 -133C71.882 -133.638 73.004 -133.394 73.6 -134.2C73.795 -133.92 74.033 -133.636 74.386 -133.827C76.064 -134.731 77.914 -134.884 79.59 -134.794C81.294 -134.702 83.014 -134.397 84.789 -134.125C85.096 -134.078 85.295 -133.555 85.618 -133.458C87.846 -132.795 90.235 -133.32 92.354 -132.482C93.945 -131.853 95.515 -131.03 96.754 -129.755C97.006 -129.495 96.681 -129.194 96.401 -129C96.789 -129.109 97.062 -128.903 97.173 -128.59C97.257 -128.351 97.257 -128.049 97.173 -127.81C97.061 -127.498 96.782 -127.397 96.408 -127.346C95.001 -127.156 96.773 -128.536 96.073 -128.088C94.8 -127.274 95.546 -125.868 94.801 -124.6C94.521 -124.794 94.291 -125.012 94.401 -125.4C94.635 -124.878 94.033 -124.588 93.865 -124.272C93.48 -123.547 92.581 -122.132 91.696 -122.739z"/>
+ </g>
+ <g style="fill: #cc7226">
+ <path d="M59.198 -115.391C56.044 -116.185 52.994 -116.07 49.978 -117.346C49.911 -117.374 49.688 -117.027 49.624 -117.054C48.258 -117.648 47.34 -118.614 46.264 -119.66C45.351 -120.548 43.693 -120.161 42.419 -120.648C42.095 -120.772 41.892 -121.284 41.591 -121.323C40.372 -121.48 39.445 -122.429 38.4 -123C40.736 -123.795 43.147 -123.764 45.609 -124.148C45.722 -124.166 45.867 -123.845 46 -123.845C46.136 -123.845 46.266 -124.066 46.4 -124.2C46.595 -123.92 46.897 -123.594 47.154 -123.848C47.702 -124.388 48.258 -124.198 48.798 -124.158C48.942 -124.148 49.067 -123.845 49.2 -123.845C49.336 -123.845 49.467 -124.156 49.6 -124.156C49.736 -124.155 49.867 -123.845 50 -123.845C50.136 -123.845 50.266 -124.066 50.4 -124.2C51.092 -123.418 51.977 -123.972 52.799 -123.793C53.837 -123.566 54.104 -122.418 55.178 -122.12C59.893 -120.816 64.03 -118.671 68.393 -116.584C68.7 -116.437 68.91 -116.189 68.8 -115.8C69.067 -115.8 69.38 -115.888 69.57 -115.756C70.628 -115.024 71.669 -114.476 72.366 -113.378C72.582 -113.039 72.253 -112.632 72.02 -112.684C67.591 -113.679 63.585 -114.287 59.198 -115.391z"/>
+ </g>
+ <g style="fill: #cc7226">
+ <path d="M45.338 -71.179C43.746 -72.398 43.162 -74.429 42.034 -76.221C41.82 -76.561 42.094 -76.875 42.411 -76.964C42.971 -77.123 43.514 -76.645 43.923 -76.443C45.668 -75.581 47.203 -74.339 49.2 -74.2C51.19 -71.966 55.45 -71.581 55.457 -68.2C55.458 -67.341 54.03 -68.259 53.6 -67.4C51.149 -68.403 48.76 -68.3 46.38 -69.767C45.763 -70.148 46.093 -70.601 45.338 -71.179z"/>
+ </g>
+ <g style="fill: #cc7226">
+ <path d="M17.8 -123.756C17.935 -123.755 24.966 -123.522 24.949 -123.408C24.904 -123.099 17.174 -122.05 16.81 -122.22C16.646 -122.296 9.134 -119.866 9 -120C9.268 -120.135 17.534 -123.756 17.8 -123.756z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M33.2 -114C33.2 -114 18.4 -112.2 14 -111C9.6 -109.8 -9 -102.2 -12 -100.2C-12 -100.2 -25.4 -94.8 -42.4 -74.8C-42.4 -74.8 -34.8 -78.2 -32.6 -81C-32.6 -81 -19 -93.6 -19.2 -91C-19.2 -91 -7 -99.6 -7.6 -97.4C-7.6 -97.4 16.8 -108.6 14.8 -105.4C14.8 -105.4 36.4 -110 35.4 -108C35.4 -108 54.2 -103.6 51.4 -103.4C51.4 -103.4 45.6 -102.2 52 -98.6C52 -98.6 48.6 -94.2 43.2 -98.2C37.8 -102.2 40.8 -100 35.8 -99C35.8 -99 33.2 -98.2 28.6 -102.2C28.6 -102.2 23 -106.8 14.2 -103.2C14.2 -103.2 -16.4 -90.6 -18.4 -90C-18.4 -90 -22 -87.2 -24.4 -83.6C-24.4 -83.6 -30.2 -79.2 -33.2 -77.8C-33.2 -77.8 -46 -66.2 -47.2 -64.8C-47.2 -64.8 -50.6 -59.6 -51.4 -59.2C-51.4 -59.2 -45 -63 -43 -65C-43 -65 -29 -75 -23.6 -75.8C-23.6 -75.8 -19.2 -78.8 -18.4 -80.2C-18.4 -80.2 -4 -89.4 0.2 -89.4C0.2 -89.4 9.4 -84.2 11.8 -91.2C11.8 -91.2 17.6 -93 23.2 -91.8C23.2 -91.8 26.4 -94.4 25.6 -96.6C25.6 -96.6 27.2 -98.4 28.2 -94.6C28.2 -94.6 31.6 -91 36.4 -93C36.4 -93 40.4 -93.2 38.4 -90.8C38.4 -90.8 34 -87 22.2 -86.8C22.2 -86.8 9.8 -86.2 -6.6 -78.6C-6.6 -78.6 -36.4 -68.2 -45.6 -57.8C-45.6 -57.8 -52 -49 -57.4 -47.8C-57.4 -47.8 -63.2 -47 -69.2 -39.6C-69.2 -39.6 -59.4 -45.4 -50.4 -45.4C-50.4 -45.4 -46.4 -47.8 -50.2 -44.2C-50.2 -44.2 -53.8 -36.6 -52.2 -31.2C-52.2 -31.2 -52.8 -26 -53.6 -24.4C-53.6 -24.4 -61.4 -11.6 -61.4 -9.2C-61.4 -6.8 -60.2 3 -59.8 3.6C-59.4 4.2 -60.8 2 -57 4.4C-53.2 6.8 -50.4 8.4 -49.6 11.2C-48.8 14 -51.6 5.8 -51.8 4C-52 2.2 -56.2 -5 -55.4 -7.4C-55.4 -7.4 -54.4 -6.4 -53.6 -5C-53.6 -5 -54.2 -5.6 -53.6 -9.2C-53.6 -9.2 -52.8 -14.4 -51.4 -17.6C-50 -20.8 -48 -24.6 -47.6 -25.4C-47.2 -26.2 -47.2 -32 -45.8 -29.4L-42.4 -26.8C-42.4 -26.8 -45.2 -29.4 -43 -31.6C-43 -31.6 -44 -37.2 -42.2 -39.8C-42.2 -39.8 -35.2 -48.2 -33.6 -49.2C-32 -50.2 -33.4 -49.8 -33.4 -49.8C-33.4 -49.8 -27.4 -54 -33.2 -52.4C-33.2 -52.4 -37.2 -50.8 -40.2 -50.8C-40.2 -50.8 -47.8 -48.8 -43.8 -53C-39.8 -57.2 -29.8 -62.6 -26 -62.4L-25.2 -60.8L-14 -63.2L-15.2 -62.4C-15.2 -62.4 -15.4 -62.6 -11.2 -63C-7 -63.4 -1.2 -62 0.2 -63.8C1.6 -65.6 5 -66.6 4.6 -65.2C4.2 -63.8 4 -61.8 4 -61.8C4 -61.8 9 -67.6 8.4 -65.4C7.8 -63.2 -0.4 -58 -1.8 -51.8L8.6 -60L12.2 -63C12.2 -63 15.8 -60.8 16 -62.4C16.2 -64 20.8 -69.8 22 -69.6C23.2 -69.4 25.2 -72.2 25 -69.6C24.8 -67 32.4 -61.6 32.4 -61.6C32.4 -61.6 35.6 -63.4 37 -62C38.4 -60.6 42.6 -81.8 42.6 -81.8L67.6 -92.4L111.201 -95.8L94.201 -102.6L33.2 -114z"/>
+ </g>
+ <g style="stroke:#4c0000; stroke-width:2">
+ <path d="M51.4 85C51.4 85 36.4 68.2 28 65.6C28 65.6 14.6 58.8 -10 66.6"/>
+ </g>
+ <g style="stroke:#4c0000; stroke-width:2">
+ <path d="M24.8 64.2C24.8 64.2 -0.4 56.2 -15.8 60.4C-15.8 60.4 -34.2 62.4 -42.6 76.2"/>
+ </g>
+ <g style="stroke:#4c0000; stroke-width:2">
+ <path d="M21.2 63C21.2 63 4.2 55.8 -10.6 53.6C-10.6 53.6 -27.2 51 -43.8 58.2C-43.8 58.2 -56 64.2 -61.4 74.4"/>
+ </g>
+ <g style="stroke:#4c0000; stroke-width:2">
+ <path d="M22.2 63.4C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M20.895 54.407C22.437 55.87 49.4 84.8 49.4 84.8C84.6 121.401 56.6 87.2 56.6 87.2C49 82.4 39.8 63.6 39.8 63.6C38.6 60.8 53.8 70.8 53.8 70.8C57.8 71.6 71.4 90.8 71.4 90.8C64.6 88.4 69.4 95.6 69.4 95.6C72.2 97.6 92.601 113.201 92.601 113.201C96.201 117.201 100.201 118.801 100.201 118.801C114.201 113.601 107.801 126.801 107.801 126.801C110.201 133.601 115.801 122.001 115.801 122.001C127.001 105.2 110.601 107.601 110.601 107.601C80.6 110.401 73.8 94.4 73.8 94.4C71.4 92 80.2 94.4 80.2 94.4C88.601 96.4 73 82 73 82C75.4 82 84.6 88.8 84.6 88.8C95.001 98 97.001 96 97.001 96C115.001 87.2 125.401 94.8 125.401 94.8C127.401 96.4 121.801 103.2 123.401 108.401C125.001 113.601 129.801 126.001 129.801 126.001C127.401 127.601 127.801 138.401 127.801 138.401C144.601 161.601 135.001 159.601 135.001 159.601C119.401 159.201 134.201 166.801 134.201 166.801C137.401 168.801 146.201 176.001 146.201 176.001C143.401 174.801 141.801 180.001 141.801 180.001C146.601 184.001 143.801 188.801 143.801 188.801C137.801 190.001 136.601 194.001 136.601 194.001C143.401 202.001 133.401 202.401 133.401 202.401C137.001 206.801 132.201 218.801 132.201 218.801C127.401 218.801 121.001 224.401 121.001 224.401C123.401 229.201 113.001 234.801 113.001 234.801C104.601 236.401 107.401 243.201 107.401 243.201C99.401 249.201 97.001 265.201 97.001 265.201C96.201 275.601 93.801 278.801 99.001 276.801C104.201 274.801 103.401 262.401 103.401 262.401C98.601 246.801 141.401 230.801 141.401 230.801C145.401 229.201 146.201 224.001 146.201 224.001C148.201 224.401 157.001 232.001 157.001 232.001C164.601 243.201 165.001 234.001 165.001 234.001C166.201 230.401 164.601 224.401 164.601 224.401C170.601 202.801 156.601 196.401 156.601 196.401C146.601 162.801 160.601 171.201 160.601 171.201C163.401 176.801 174.201 182.001 174.201 182.001L177.801 179.601C176.201 174.801 184.601 168.801 184.601 168.801C187.401 175.201 193.401 167.201 193.401 167.201C197.001 142.801 209.401 157.201 209.401 157.201C213.401 158.401 214.601 151.601 214.601 151.601C218.201 141.201 214.601 127.601 214.601 127.601C218.201 127.201 227.801 133.201 227.801 133.201C230.601 129.601 221.401 112.801 225.401 115.201C229.401 117.601 233.801 119.201 233.801 119.201C234.601 117.201 224.601 104.801 224.601 104.801C220.201 102 215.001 81.6 215.001 81.6C222.201 85.2 212.201 70 212.201 70C212.201 66.8 218.201 55.6 218.201 55.6C217.401 48.8 218.201 49.2 218.201 49.2C221.001 50.4 229.001 52 222.201 45.6C215.401 39.2 223.001 34.4 223.001 34.4C227.401 31.6 213.801 32 213.801 32C208.601 27.6 209.001 23.6 209.001 23.6C217.001 25.6 202.601 11.2 200.201 7.6C197.801 4 207.401 -1.2 207.401 -1.2C220.601 -4.8 209.001 -8 209.001 -8C189.401 -7.6 200.201 -18.4 200.201 -18.4C206.201 -18 204.601 -20.4 204.601 -20.4C199.401 -21.6 189.801 -28 189.801 -28C185.801 -31.6 189.401 -30.8 189.401 -30.8C206.201 -29.6 177.401 -40.8 177.401 -40.8C185.401 -40.8 167.401 -51.2 167.401 -51.2C165.401 -52.8 162.201 -60.4 162.201 -60.4C156.201 -65.6 151.401 -72.4 151.401 -72.4C151.001 -76.8 146.201 -81.6 146.201 -81.6C134.601 -95.2 129.001 -94.8 129.001 -94.8C114.201 -98.4 109.001 -97.6 109.001 -97.6L56.2 -93.2C29.8 -80.4 37.6 -59.4 37.6 -59.4C44 -51 53.2 -54.8 53.2 -54.8C57.8 -61 69.4 -58.8 69.4 -58.8C89.801 -55.6 87.201 -59.2 87.201 -59.2C84.801 -63.8 68.6 -70 68.4 -70.6C68.2 -71.2 59.4 -74.6 59.4 -74.6C56.4 -75.8 52 -85 52 -85C48.8 -88.4 64.6 -82.6 64.6 -82.6C63.4 -81.6 70.8 -77.6 70.8 -77.6C88.201 -78.6 98.801 -67.8 98.801 -67.8C109.601 -51.2 109.801 -59.4 109.801 -59.4C112.601 -68.8 100.801 -90 100.801 -90C101.201 -92 109.401 -85.4 109.401 -85.4C110.801 -87.4 111.601 -81.6 111.601 -81.6C111.801 -79.2 115.601 -71.2 115.601 -71.2C118.401 -58.2 122.001 -65.6 122.001 -65.6L126.601 -56.2C128.001 -53.6 122.001 -46 122.001 -46C121.801 -43.2 122.601 -43.4 117.001 -35.8C111.401 -28.2 114.801 -23.8 114.801 -23.8C113.401 -17.2 122.201 -17.6 122.201 -17.6C124.801 -15.4 128.201 -15.4 128.201 -15.4C130.001 -13.4 132.401 -14 132.401 -14C134.001 -17.8 140.201 -15.8 140.201 -15.8C141.601 -18.2 149.801 -18.6 149.801 -18.6C150.801 -21.2 151.201 -22.8 154.601 -23.4C158.001 -24 133.401 -67 133.401 -67C139.801 -67.8 131.601 -80.2 131.601 -80.2C129.401 -86.8 140.801 -72.2 143.001 -70.8C145.201 -69.4 146.201 -67.2 144.601 -67.4C143.001 -67.6 141.201 -65.4 142.601 -65.2C144.001 -65 157.001 -50 160.401 -39.8C163.801 -29.6 169.801 -25.6 176.001 -19.6C182.201 -13.6 181.401 10.6 181.401 10.6C181.001 19.4 187.001 30 187.001 30C189.001 33.8 184.801 52 184.801 52C182.801 54.2 184.201 55 184.201 55C185.201 56.2 192.001 69.4 192.001 69.4C190.201 69.2 193.801 72.8 193.801 72.8C199.001 78.8 192.601 75.8 192.601 75.8C186.601 74.2 193.601 84 193.601 84C194.801 85.8 185.801 81.2 185.801 81.2C176.601 80.6 188.201 87.8 188.201 87.8C196.801 95 185.401 90.6 185.401 90.6C180.801 88.8 184.001 95.6 184.001 95.6C187.201 97.2 204.401 104.2 204.401 104.2C204.801 108.001 201.801 113.001 201.801 113.001C202.201 117.001 200.001 120.401 200.001 120.401C198.801 128.601 198.201 129.401 198.201 129.401C194.001 129.601 186.601 143.401 186.601 143.401C184.801 146.001 174.601 158.001 174.601 158.001C172.601 165.001 154.601 157.801 154.601 157.801C148.001 161.201 150.001 157.801 150.001 157.801C149.601 155.601 154.401 149.601 154.401 149.601C161.401 147.001 158.801 136.201 158.801 136.201C162.801 134.801 151.601 132.001 151.801 130.801C152.001 129.601 157.801 128.201 157.801 128.201C165.801 126.201 161.401 123.801 161.401 123.801C160.801 119.801 163.801 114.201 163.801 114.201C175.401 113.401 163.801 97.2 163.801 97.2C153.001 89.6 152.001 83.8 152.001 83.8C164.601 75.6 156.401 63.2 156.601 59.6C156.801 56 158.001 34.4 158.001 34.4C156.001 28.2 153.001 14.6 153.001 14.6C155.201 9.4 162.601 -3.2 162.601 -3.2C165.401 -7.4 174.201 -12.2 172.001 -15.2C169.801 -18.2 162.001 -16.4 162.001 -16.4C154.201 -17.8 154.801 -12.6 154.801 -12.6C153.201 -11.6 152.401 -6.6 152.401 -6.6C151.68 1.333 142.801 7.6 142.801 7.6C131.601 13.8 140.801 17.8 140.801 17.8C146.801 24.4 137.001 24.6 137.001 24.6C126.001 22.8 134.201 33 134.201 33C145.001 45.8 142.001 48.6 142.001 48.6C131.801 49.6 144.401 58.8 144.401 58.8C144.401 58.8 143.601 56.8 143.801 58.6C144.001 60.4 147.001 64.6 147.801 66.6C148.601 68.6 144.601 68.8 144.601 68.8C145.201 78.4 129.801 74.2 129.801 74.2C129.801 74.2 129.801 74.2 128.201 74.4C126.601 74.6 115.401 73.8 109.601 71.6C103.801 69.4 97.001 69.4 97.001 69.4C97.001 69.4 93.001 71.2 85.4 71C77.8 70.8 69.8 73.6 69.8 73.6C65.4 73.2 74 68.8 74.2 69C74.4 69.2 80 63.6 72 64.2C50.203 65.835 39.4 55.6 39.4 55.6C37.4 54.2 34.8 51.4 34.8 51.4C24.8 49.4 36.2 63.8 36.2 63.8C37.4 65.2 36 66.2 36 66.2C35.2 64.6 27.4 59.2 27.4 59.2C24.589 58.227 23.226 56.893 20.895 54.407z"/>
+ </g>
+ <g style="fill: #4c0000">
+ <path d="M-3 42.8C-3 42.8 8.6 48.4 11.2 51.2C13.8 54 27.8 65.4 27.8 65.4C27.8 65.4 22.4 63.4 19.8 61.6C17.2 59.8 6.4 51.6 6.4 51.6C6.4 51.6 2.6 45.6 -3 42.8z"/>
+ </g>
+ <g style="fill: #99cc32">
+ <path d="M-61.009 11.603C-60.672 11.455 -61.196 8.743 -61.4 8.2C-62.422 5.474 -71.4 4 -71.4 4C-71.627 5.365 -71.682 6.961 -71.576 8.599C-71.576 8.599 -66.708 14.118 -61.009 11.603z"/>
+ </g>
+ <g style="fill: #659900">
+ <path d="M-61.009 11.403C-61.458 11.561 -61.024 8.669 -61.2 8.2C-62.222 5.474 -71.4 3.9 -71.4 3.9C-71.627 5.265 -71.682 6.861 -71.576 8.499C-71.576 8.499 -67.308 13.618 -61.009 11.403z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-65.4 11.546C-66.025 11.546 -66.531 10.406 -66.531 9C-66.531 7.595 -66.025 6.455 -65.4 6.455C-64.775 6.455 -64.268 7.595 -64.268 9C-64.268 10.406 -64.775 11.546 -65.4 11.546z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-65.4 9z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-111 109.601C-111 109.601 -116.6 119.601 -91.8 113.601C-91.8 113.601 -77.8 112.401 -75.4 110.001C-74.2 110.801 -65.834 113.734 -63 114.401C-56.2 116.001 -47.8 106 -47.8 106C-47.8 106 -43.2 95.5 -40.4 95.5C-37.6 95.5 -40.8 97.1 -40.8 97.1C-40.8 97.1 -47.4 107.201 -47 108.801C-47 108.801 -52.2 128.801 -68.2 129.601C-68.2 129.601 -84.35 130.551 -83 136.401C-83 136.401 -74.2 134.001 -71.8 136.401C-71.8 136.401 -61 136.001 -69 142.401L-75.8 154.001C-75.8 154.001 -75.66 157.919 -85.8 154.401C-95.6 151.001 -105.9 138.101 -105.9 138.101C-105.9 138.101 -121.85 123.551 -111 109.601z"/>
+ </g>
+ <g style="fill: #e59999">
+ <path d="M-112.2 113.601C-112.2 113.601 -114.2 123.201 -77.4 112.801C-77.4 112.801 -73 112.801 -70.6 113.601C-68.2 114.401 -56.2 117.201 -54.2 116.001C-54.2 116.001 -61.4 129.601 -73 128.001C-73 128.001 -86.2 129.601 -85.8 134.401C-85.8 134.401 -81.8 141.601 -77 144.001C-77 144.001 -74.2 146.401 -74.6 149.601C-75 152.801 -77.8 154.401 -79.8 155.201C-81.8 156.001 -85 152.801 -86.6 152.801C-88.2 152.801 -96.6 146.401 -101 141.601C-105.4 136.801 -113.8 124.801 -113.4 122.001C-113 119.201 -112.2 113.601 -112.2 113.601z"/>
+ </g>
+ <g style="fill: #b26565">
+ <path d="M-109 131.051C-106.4 135.001 -103.2 139.201 -101 141.601C-96.6 146.401 -88.2 152.801 -86.6 152.801C-85 152.801 -81.8 156.001 -79.8 155.201C-77.8 154.401 -75 152.801 -74.6 149.601C-74.2 146.401 -77 144.001 -77 144.001C-80.066 142.468 -82.806 138.976 -84.385 136.653C-84.385 136.653 -84.2 139.201 -89.4 138.401C-94.6 137.601 -99.8 134.801 -101.4 131.601C-103 128.401 -105.4 126.001 -103.8 129.601C-102.2 133.201 -99.8 136.801 -98.2 137.201C-96.6 137.601 -97 138.801 -99.4 138.401C-101.8 138.001 -104.6 137.601 -109 132.401z"/>
+ </g>
+ <g style="fill: #992600">
+ <path d="M-111.6 110.001C-111.6 110.001 -109.8 96.4 -108.6 92.4C-108.6 92.4 -109.4 85.6 -107 81.4C-104.6 77.2 -102.6 71 -99.6 65.6C-96.6 60.2 -96.4 56.2 -92.4 54.6C-88.4 53 -82.4 44.4 -79.6 43.4C-76.8 42.4 -77 43.2 -77 43.2C-77 43.2 -70.2 28.4 -56.6 32.4C-56.6 32.4 -72.8 29.6 -57 20.2C-57 20.2 -61.8 21.3 -58.5 14.3C-56.299 9.632 -56.8 16.4 -67.8 28.2C-67.8 28.2 -72.8 36.8 -78 39.8C-83.2 42.8 -95.2 49.8 -96.4 53.6C-97.6 57.4 -100.8 63.2 -102.8 64.8C-104.8 66.4 -107.6 70.6 -108 74C-108 74 -109.2 78 -110.6 79.2C-112 80.4 -112.2 83.6 -112.2 85.6C-112.2 87.6 -114.2 90.4 -114 92.8C-114 92.8 -113.2 111.801 -113.6 113.801L-111.6 110.001z"/>
+ </g>
+ <g style="fill: #ffffff">
+ <path d="M-120.2 114.601C-120.2 114.601 -122.2 113.201 -126.6 119.201C-126.6 119.201 -119.3 152.201 -119.3 153.601C-119.3 153.601 -118.2 151.501 -119.5 144.301C-120.8 137.101 -121.7 124.401 -121.7 124.401L-120.2 114.601z"/>
+ </g>
+ <g style="fill: #992600">
+ <path d="M-98.6 54C-98.6 54 -116.2 57.2 -115.8 86.4L-116.6 111.201C-116.6 111.201 -117.8 85.6 -119 84C-120.2 82.4 -116.2 71.2 -119.4 77.2C-119.4 77.2 -133.4 91.2 -125.4 112.401C-125.4 112.401 -123.9 115.701 -126.9 111.101C-126.9 111.101 -131.5 98.5 -130.4 92.1C-130.4 92.1 -130.2 89.9 -128.3 87.1C-128.3 87.1 -119.7 75.4 -117 73.1C-117 73.1 -115.2 58.7 -99.8 53.5C-99.8 53.5 -94.1 51.2 -98.6 54z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M40.8 -12.2C41.46 -12.554 41.451 -13.524 42.031 -13.697C43.18 -14.041 43.344 -15.108 43.862 -15.892C44.735 -17.211 44.928 -18.744 45.51 -20.235C45.782 -20.935 45.809 -21.89 45.496 -22.55C44.322 -25.031 43.62 -27.48 42.178 -29.906C41.91 -30.356 41.648 -31.15 41.447 -31.748C40.984 -33.132 39.727 -34.123 38.867 -35.443C38.579 -35.884 39.104 -36.809 38.388 -36.893C37.491 -36.998 36.042 -37.578 35.809 -36.552C35.221 -33.965 36.232 -31.442 37.2 -29C36.418 -28.308 36.752 -27.387 36.904 -26.62C37.614 -23.014 36.416 -19.662 35.655 -16.188C35.632 -16.084 35.974 -15.886 35.946 -15.824C34.724 -13.138 33.272 -10.693 31.453 -8.312C30.695 -7.32 29.823 -6.404 29.326 -5.341C28.958 -4.554 28.55 -3.588 28.8 -2.6C25.365 0.18 23.115 4.025 20.504 7.871C20.042 8.551 20.333 9.76 20.884 10.029C21.697 10.427 22.653 9.403 23.123 8.557C23.512 7.859 23.865 7.209 24.356 6.566C24.489 6.391 24.31 5.972 24.445 5.851C27.078 3.504 28.747 0.568 31.2 -1.8C33.15 -2.129 34.687 -3.127 36.435 -4.14C36.743 -4.319 37.267 -4.07 37.557 -4.265C39.31 -5.442 39.308 -7.478 39.414 -9.388C39.464 -10.272 39.66 -11.589 40.8 -12.2z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M31.959 -16.666C32.083 -16.743 31.928 -17.166 32.037 -17.382C32.199 -17.706 32.602 -17.894 32.764 -18.218C32.873 -18.434 32.71 -18.814 32.846 -18.956C35.179 -21.403 35.436 -24.427 34.4 -27.4C35.424 -28.02 35.485 -29.282 35.06 -30.129C34.207 -31.829 34.014 -33.755 33.039 -35.298C32.237 -36.567 30.659 -37.811 29.288 -36.508C28.867 -36.108 28.546 -35.321 28.824 -34.609C28.888 -34.446 29.173 -34.3 29.146 -34.218C29.039 -33.894 28.493 -33.67 28.487 -33.398C28.457 -31.902 27.503 -30.391 28.133 -29.062C28.905 -27.433 29.724 -25.576 30.4 -23.8C29.166 -21.684 30.199 -19.235 28.446 -17.358C28.31 -17.212 28.319 -16.826 28.441 -16.624C28.733 -16.138 29.139 -15.732 29.625 -15.44C29.827 -15.319 30.175 -15.317 30.375 -15.441C30.953 -15.803 31.351 -16.29 31.959 -16.666z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M94.771 -26.977C96.16 -25.185 96.45 -22.39 94.401 -21C94.951 -17.691 98.302 -19.67 100.401 -20.2C100.292 -20.588 100.519 -20.932 100.802 -20.937C101.859 -20.952 102.539 -21.984 103.601 -21.8C104.035 -23.357 105.673 -24.059 106.317 -25.439C108.043 -29.134 107.452 -33.407 104.868 -36.653C104.666 -36.907 104.883 -37.424 104.759 -37.786C104.003 -39.997 101.935 -40.312 100.001 -41C98.824 -44.875 98.163 -48.906 96.401 -52.6C94.787 -52.85 94.089 -54.589 92.752 -55.309C91.419 -56.028 90.851 -54.449 90.892 -53.403C90.899 -53.198 91.351 -52.974 91.181 -52.609C91.105 -52.445 90.845 -52.334 90.845 -52.2C90.846 -52.065 91.067 -51.934 91.201 -51.8C90.283 -50.98 88.86 -50.503 88.565 -49.358C87.611 -45.648 90.184 -42.523 91.852 -39.322C92.443 -38.187 91.707 -36.916 90.947 -35.708C90.509 -35.013 90.617 -33.886 90.893 -33.03C91.645 -30.699 93.236 -28.96 94.771 -26.977z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M57.611 -8.591C56.124 -6.74 52.712 -4.171 55.629 -2.243C55.823 -2.114 56.193 -2.11 56.366 -2.244C58.387 -3.809 60.39 -4.712 62.826 -5.294C62.95 -5.323 63.224 -4.856 63.593 -5.017C65.206 -5.72 67.216 -5.662 68.4 -7C72.167 -6.776 75.732 -7.892 79.123 -9.2C80.284 -9.648 81.554 -10.207 82.755 -10.709C84.131 -11.285 85.335 -12.213 86.447 -13.354C86.58 -13.49 86.934 -13.4 87.201 -13.4C87.161 -14.263 88.123 -14.39 88.37 -15.012C88.462 -15.244 88.312 -15.64 88.445 -15.742C90.583 -17.372 91.503 -19.39 90.334 -21.767C90.049 -22.345 89.8 -22.963 89.234 -23.439C88.149 -24.35 87.047 -23.496 86 -23.8C85.841 -23.172 85.112 -23.344 84.726 -23.146C83.867 -22.707 82.534 -23.292 81.675 -22.854C80.313 -22.159 79.072 -21.99 77.65 -21.613C77.338 -21.531 76.56 -21.627 76.4 -21C76.266 -21.134 76.118 -21.368 76.012 -21.346C74.104 -20.95 72.844 -20.736 71.543 -19.044C71.44 -18.911 70.998 -19.09 70.839 -18.955C69.882 -18.147 69.477 -16.913 68.376 -16.241C68.175 -16.118 67.823 -16.286 67.629 -16.157C66.983 -15.726 66.616 -15.085 65.974 -14.638C65.645 -14.409 65.245 -14.734 65.277 -14.99C65.522 -16.937 66.175 -18.724 65.6 -20.6C67.677 -23.12 70.194 -25.069 72 -27.8C72.015 -29.966 72.707 -32.112 72.594 -34.189C72.584 -34.382 72.296 -35.115 72.17 -35.462C71.858 -36.316 72.764 -37.382 71.92 -38.106C70.516 -39.309 69.224 -38.433 68.4 -37C66.562 -36.61 64.496 -35.917 62.918 -37.151C61.911 -37.938 61.333 -38.844 60.534 -39.9C59.549 -41.202 59.884 -42.638 59.954 -44.202C59.96 -44.33 59.645 -44.466 59.645 -44.6C59.646 -44.735 59.866 -44.866 60 -45C59.294 -45.626 59.019 -46.684 58 -47C58.305 -48.092 57.629 -48.976 56.758 -49.278C54.763 -49.969 53.086 -48.057 51.194 -47.984C50.68 -47.965 50.213 -49.003 49.564 -49.328C49.132 -49.544 48.428 -49.577 48.066 -49.311C47.378 -48.807 46.789 -48.693 46.031 -48.488C44.414 -48.052 43.136 -46.958 41.656 -46.103C40.171 -45.246 39.216 -43.809 38.136 -42.489C37.195 -41.337 37.059 -38.923 38.479 -38.423C40.322 -37.773 41.626 -40.476 43.592 -40.15C43.904 -40.099 44.11 -39.788 44 -39.4C44.389 -39.291 44.607 -39.52 44.8 -39.8C45.658 -38.781 46.822 -38.444 47.76 -37.571C48.73 -36.667 50.476 -37.085 51.491 -36.088C53.02 -34.586 52.461 -31.905 54.4 -30.6C53.814 -29.287 53.207 -28.01 52.872 -26.583C52.59 -25.377 53.584 -24.18 54.795 -24.271C56.053 -24.365 56.315 -25.124 56.8 -26.2C57.067 -25.933 57.536 -25.636 57.495 -25.42C57.038 -23.033 56.011 -21.04 55.553 -18.609C55.494 -18.292 55.189 -18.09 54.8 -18.2C54.332 -14.051 50.28 -11.657 47.735 -8.492C47.332 -7.99 47.328 -6.741 47.737 -6.338C49.14 -4.951 51.1 -6.497 52.8 -7C53.013 -8.206 53.872 -9.148 55.204 -9.092C55.46 -9.082 55.695 -9.624 56.019 -9.754C56.367 -9.892 56.869 -9.668 57.155 -9.866C58.884 -11.061 60.292 -12.167 62.03 -13.356C62.222 -13.487 62.566 -13.328 62.782 -13.436C63.107 -13.598 63.294 -13.985 63.617 -14.17C63.965 -14.37 64.207 -14.08 64.4 -13.8C63.754 -13.451 63.75 -12.494 63.168 -12.292C62.393 -12.024 61.832 -11.511 61.158 -11.064C60.866 -10.871 60.207 -11.119 60.103 -10.94C59.505 -9.912 58.321 -9.474 57.611 -8.591z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M2.2 -58C2.2 -58 -7.038 -60.872 -18.2 -35.2C-18.2 -35.2 -20.6 -30 -23 -28C-25.4 -26 -36.6 -22.4 -38.6 -18.4L-49 -2.4C-49 -2.4 -34.2 -18.4 -31 -20.8C-31 -20.8 -23 -29.2 -26.2 -22.4C-26.2 -22.4 -40.2 -11.6 -39 -2.4C-39 -2.4 -44.6 12 -45.4 14C-45.4 14 -29.4 -18 -27 -19.2C-24.6 -20.4 -23.4 -20.4 -24.6 -16.8C-25.8 -13.2 -26.2 3.2 -29 5.2C-29 5.2 -21 -15.2 -21.8 -18.4C-21.8 -18.4 -18.6 -22 -16.2 -16.8L-17.4 -0.8L-13 11.2C-13 11.2 -15.4 0 -13.8 -15.6C-13.8 -15.6 -15.8 -26 -11.8 -20.4C-7.8 -14.8 1.8 -8.8 1.8 -4C1.8 -4 -3.4 -21.6 -12.6 -26.4L-16.6 -20.4L-17.8 -22.4C-17.8 -22.4 -21.4 -23.2 -17 -30C-12.6 -36.8 -13 -37.6 -13 -37.6C-13 -37.6 -6.6 -30.4 -5 -30.4C-5 -30.4 8.2 -38 9.4 -13.6C9.4 -13.6 16.2 -28 7 -34.8C7 -34.8 -7.8 -36.8 -6.6 -42L0.6 -54.4C4.2 -59.6 2.6 -56.8 2.6 -56.8z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-17.8 -41.6C-17.8 -41.6 -30.6 -41.6 -33.8 -36.4L-41 -26.8C-41 -26.8 -23.8 -36.8 -19.8 -38C-15.8 -39.2 -17.8 -41.6 -17.8 -41.6z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-57.8 -35.2C-57.8 -35.2 -59.8 -34 -60.2 -31.2C-60.6 -28.4 -63 -28 -62.2 -25.2C-61.4 -22.4 -59.4 -20 -59.4 -24C-59.4 -28 -57.8 -30 -57 -31.2C-56.2 -32.4 -54.6 -36.8 -57.8 -35.2z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-66.6 26C-66.6 26 -75 22 -78.2 18.4C-81.4 14.8 -80.948 19.966 -85.8 19.6C-91.647 19.159 -90.6 3.2 -90.6 3.2L-94.6 10.8C-94.6 10.8 -95.8 25.2 -87.8 22.8C-83.893 21.628 -82.6 23.2 -84.2 24C-85.8 24.8 -78.6 25.2 -81.4 26.8C-84.2 28.4 -69.8 23.2 -72.2 33.6L-66.6 26z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-79.2 40.4C-79.2 40.4 -94.6 44.8 -98.2 35.2C-98.2 35.2 -103 37.6 -100.8 40.6C-98.6 43.6 -97.4 44 -97.4 44C-97.4 44 -92 45.2 -92.6 46C-93.2 46.8 -95.6 50.2 -95.6 50.2C-95.6 50.2 -85.4 44.2 -79.2 40.4z"/>
+ </g>
+ <g style="fill: #ffffff">
+ <path d="M149.201 118.601C148.774 120.735 147.103 121.536 145.201 122.201C143.284 121.243 140.686 118.137 138.801 120.201C138.327 119.721 137.548 119.661 137.204 118.999C136.739 118.101 137.011 117.055 136.669 116.257C136.124 114.985 135.415 113.619 135.601 112.201C137.407 111.489 138.002 109.583 137.528 107.82C137.459 107.563 137.03 107.366 137.23 107.017C137.416 106.694 137.734 106.467 138.001 106.2C137.866 106.335 137.721 106.568 137.61 106.548C137 106.442 137.124 105.805 137.254 105.418C137.839 103.672 139.853 103.408 141.201 104.6C141.457 104.035 141.966 104.229 142.401 104.2C142.351 103.621 142.759 103.094 142.957 102.674C143.475 101.576 145.104 102.682 145.901 102.07C146.977 101.245 148.04 100.546 149.118 101.149C150.927 102.162 152.636 103.374 153.835 105.115C154.41 105.949 154.65 107.23 154.592 108.188C154.554 108.835 153.173 108.483 152.83 109.412C152.185 111.16 154.016 111.679 154.772 113.017C154.97 113.366 154.706 113.67 154.391 113.768C153.98 113.896 153.196 113.707 153.334 114.16C154.306 117.353 151.55 118.031 149.201 118.601z"/>
+ </g>
+ <g style="fill: #ffffff">
+ <path d="M139.6 138.201C139.593 136.463 137.992 134.707 139.201 133.001C139.336 133.135 139.467 133.356 139.601 133.356C139.736 133.356 139.867 133.135 140.001 133.001C141.496 135.217 145.148 136.145 145.006 138.991C144.984 139.438 143.897 140.356 144.801 141.001C142.988 142.349 142.933 144.719 142.001 146.601C140.763 146.315 139.551 145.952 138.401 145.401C138.753 143.915 138.636 142.231 139.456 140.911C139.89 140.213 139.603 139.134 139.6 138.201z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-26.6 129.201C-26.6 129.201 -43.458 139.337 -29.4 124.001C-20.6 114.401 -10.6 108.801 -10.6 108.801C-10.6 108.801 -0.2 104.4 3.4 103.2C7 102 22.2 96.8 25.4 96.4C28.6 96 38.2 92 45 96C51.8 100 59.8 104.4 59.8 104.4C59.8 104.4 43.4 96 39.8 98.4C36.2 100.8 29 100.4 23 103.6C23 103.6 8.2 108.001 5 110.001C1.8 112.001 -8.6 123.601 -10.2 122.801C-11.8 122.001 -9.8 121.601 -8.6 118.801C-7.4 116.001 -9.4 114.401 -17.4 120.801C-25.4 127.201 -26.6 129.201 -26.6 129.201z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-19.195 123.234C-19.195 123.234 -17.785 110.194 -9.307 111.859C-9.307 111.859 -1.081 107.689 1.641 105.721C1.641 105.721 9.78 104.019 11.09 103.402C29.569 94.702 44.288 99.221 44.835 98.101C45.381 96.982 65.006 104.099 68.615 108.185C69.006 108.628 58.384 102.588 48.686 100.697C40.413 99.083 18.811 100.944 7.905 106.48C4.932 107.989 -4.013 113.773 -6.544 113.662C-9.075 113.55 -19.195 123.234 -19.195 123.234z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-23 148.801C-23 148.801 -38.2 146.401 -21.4 144.801C-21.4 144.801 -3.4 142.801 0.6 137.601C0.6 137.601 14.2 128.401 17 128.001C19.8 127.601 49.8 120.401 50.2 118.001C50.6 115.601 56.2 115.601 57.8 116.401C59.4 117.201 58.6 118.401 55.8 119.201C53 120.001 21.8 136.401 15.4 137.601C9 138.801 -2.6 146.401 -7.4 147.601C-12.2 148.801 -23 148.801 -23 148.801z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-3.48 141.403C-3.48 141.403 -12.062 140.574 -3.461 139.755C-3.461 139.755 5.355 136.331 7.403 133.668C7.403 133.668 14.367 128.957 15.8 128.753C17.234 128.548 31.194 124.861 31.399 123.633C31.604 122.404 65.67 109.823 70.09 113.013C73.001 115.114 63.1 113.437 53.466 117.847C52.111 118.467 18.258 133.054 14.981 133.668C11.704 134.283 5.765 138.174 3.307 138.788C0.85 139.403 -3.48 141.403 -3.48 141.403z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-11.4 143.601C-11.4 143.601 -6.2 143.201 -7.4 144.801C-8.6 146.401 -11 145.601 -11 145.601L-11.4 143.601z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-18.6 145.201C-18.6 145.201 -13.4 144.801 -14.6 146.401C-15.8 148.001 -18.2 147.201 -18.2 147.201L-18.6 145.201z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-29 146.801C-29 146.801 -23.8 146.401 -25 148.001C-26.2 149.601 -28.6 148.801 -28.6 148.801L-29 146.801z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-36.6 147.601C-36.6 147.601 -31.4 147.201 -32.6 148.801C-33.8 150.401 -36.2 149.601 -36.2 149.601L-36.6 147.601z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M1.8 108.001C1.8 108.001 6.2 108.001 5 109.601C3.8 111.201 0.6 110.801 0.6 110.801L1.8 108.001z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-8.2 113.601C-8.2 113.601 -1.694 111.46 -4.2 114.801C-5.4 116.401 -7.8 115.601 -7.8 115.601L-8.2 113.601z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-19.4 118.401C-19.4 118.401 -14.2 118.001 -15.4 119.601C-16.6 121.201 -19 120.401 -19 120.401L-19.4 118.401z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-27 124.401C-27 124.401 -21.8 124.001 -23 125.601C-24.2 127.201 -26.6 126.401 -26.6 126.401L-27 124.401z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-33.8 129.201C-33.8 129.201 -28.6 128.801 -29.8 130.401C-31 132.001 -33.4 131.201 -33.4 131.201L-33.8 129.201z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M5.282 135.598C5.282 135.598 12.203 135.066 10.606 137.195C9.009 139.325 5.814 138.26 5.814 138.26L5.282 135.598z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M15.682 130.798C15.682 130.798 22.603 130.266 21.006 132.395C19.409 134.525 16.214 133.46 16.214 133.46L15.682 130.798z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M26.482 126.398C26.482 126.398 33.403 125.866 31.806 127.995C30.209 130.125 27.014 129.06 27.014 129.06L26.482 126.398z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M36.882 121.598C36.882 121.598 43.803 121.066 42.206 123.195C40.609 125.325 37.414 124.26 37.414 124.26L36.882 121.598z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M9.282 103.598C9.282 103.598 16.203 103.066 14.606 105.195C13.009 107.325 9.014 107.06 9.014 107.06L9.282 103.598z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M19.282 100.398C19.282 100.398 26.203 99.866 24.606 101.995C23.009 104.125 18.614 103.86 18.614 103.86L19.282 100.398z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-3.4 140.401C-3.4 140.401 1.8 140.001 0.6 141.601C-0.6 143.201 -3 142.401 -3 142.401L-3.4 140.401z"/>
+ </g>
+ <g style="fill: #992600">
+ <path d="M-76.6 41.2C-76.6 41.2 -81 50 -81.4 53.2C-81.4 53.2 -80.6 44.4 -79.4 42.4C-78.2 40.4 -76.6 41.2 -76.6 41.2z"/>
+ </g>
+ <g style="fill: #992600">
+ <path d="M-95 55.2C-95 55.2 -98.2 69.6 -97.8 72.4C-97.8 72.4 -99 60.8 -98.6 59.6C-98.2 58.4 -95 55.2 -95 55.2z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-74.2 -19.4L-74.4 -16.2L-76.6 -16C-76.6 -16 -62.4 -3.4 -61.8 4.2C-61.8 4.2 -61 -4 -74.2 -19.4z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-70.216 -18.135C-70.647 -18.551 -70.428 -19.296 -70.836 -19.556C-71.645 -20.072 -69.538 -20.129 -69.766 -20.845C-70.149 -22.051 -69.962 -22.072 -70.084 -23.348C-70.141 -23.946 -69.553 -25.486 -69.168 -25.926C-67.722 -27.578 -69.046 -30.51 -67.406 -32.061C-67.102 -32.35 -66.726 -32.902 -66.441 -33.32C-65.782 -34.283 -64.598 -34.771 -63.648 -35.599C-63.33 -35.875 -63.531 -36.702 -62.962 -36.61C-62.248 -36.495 -61.007 -36.625 -61.052 -35.784C-61.165 -33.664 -62.494 -31.944 -63.774 -30.276C-63.323 -29.572 -63.781 -28.937 -64.065 -28.38C-65.4 -25.76 -65.211 -22.919 -65.385 -20.079C-65.39 -19.994 -65.697 -19.916 -65.689 -19.863C-65.336 -17.528 -64.752 -15.329 -63.873 -13.1C-63.507 -12.17 -63.036 -11.275 -62.886 -10.348C-62.775 -9.662 -62.672 -8.829 -63.08 -8.124C-61.045 -5.234 -62.354 -2.583 -61.185 0.948C-60.978 1.573 -59.286 3.487 -59.749 3.326C-62.262 2.455 -62.374 2.057 -62.551 1.304C-62.697 0.681 -63.027 -0.696 -63.264 -1.298C-63.328 -1.462 -63.499 -3.346 -63.577 -3.468C-65.09 -5.85 -63.732 -5.674 -65.102 -8.032C-66.53 -8.712 -67.496 -9.816 -68.619 -10.978C-68.817 -11.182 -67.674 -11.906 -67.855 -12.119C-68.947 -13.408 -70.1 -14.175 -69.764 -15.668C-69.609 -16.358 -69.472 -17.415 -70.216 -18.135z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-73.8 -16.4C-73.8 -16.4 -73.4 -9.6 -71 -8C-68.6 -6.4 -69.8 -7.2 -73 -8.4C-76.2 -9.6 -75 -10.4 -75 -10.4C-75 -10.4 -77.8 -10 -75.4 -8C-73 -6 -69.4 -3.6 -71 -3.6C-72.6 -3.6 -80.2 -7.6 -80.2 -10.4C-80.2 -13.2 -81.2 -17.3 -81.2 -17.3C-81.2 -17.3 -80.1 -18.1 -75.3 -18C-75.3 -18 -73.9 -17.3 -73.8 -16.4z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-74.6 2.2C-74.6 2.2 -83.12 -0.591 -101.6 2.8C-101.6 2.8 -92.569 0.722 -73.8 3C-63.5 4.25 -74.6 2.2 -74.6 2.2z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-72.502 2.129C-72.502 2.129 -80.748 -1.389 -99.453 0.392C-99.453 0.392 -90.275 -0.897 -71.774 2.995C-61.62 5.131 -72.502 2.129 -72.502 2.129z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-70.714 2.222C-70.714 2.222 -78.676 -1.899 -97.461 -1.514C-97.461 -1.514 -88.213 -2.118 -70.052 3.14C-60.086 6.025 -70.714 2.222 -70.714 2.222z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-69.444 2.445C-69.444 2.445 -76.268 -1.862 -93.142 -2.96C-93.142 -2.96 -84.803 -2.79 -68.922 3.319C-60.206 6.672 -69.444 2.445 -69.444 2.445z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M45.84 12.961C45.84 12.961 44.91 13.605 45.124 12.424C45.339 11.243 73.547 -1.927 77.161 -1.677C77.161 -1.677 46.913 11.529 45.84 12.961z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M42.446 13.6C42.446 13.6 41.57 14.315 41.691 13.121C41.812 11.927 68.899 -3.418 72.521 -3.452C72.521 -3.452 43.404 12.089 42.446 13.6z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M39.16 14.975C39.16 14.975 38.332 15.747 38.374 14.547C38.416 13.348 58.233 -2.149 68.045 -4.023C68.045 -4.023 50.015 4.104 39.16 14.975z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M36.284 16.838C36.284 16.838 35.539 17.532 35.577 16.453C35.615 15.373 53.449 1.426 62.28 -0.26C62.28 -0.26 46.054 7.054 36.284 16.838z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M4.6 164.801C4.6 164.801 -10.6 162.401 6.2 160.801C6.2 160.801 24.2 158.801 28.2 153.601C28.2 153.601 41.8 144.401 44.6 144.001C47.4 143.601 63.8 140.001 64.2 137.601C64.6 135.201 70.6 132.801 72.2 133.601C73.8 134.401 73.8 143.601 71 144.401C68.2 145.201 49.4 152.401 43 153.601C36.6 154.801 25 162.401 20.2 163.601C15.4 164.801 4.6 164.801 4.6 164.801z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M77.6 127.401C77.6 127.401 74.6 129.001 73.4 131.601C73.4 131.601 67 142.201 52.8 145.401C52.8 145.401 29.8 154.401 22 156.401C22 156.401 8.6 161.401 1.2 160.601C1.2 160.601 -5.8 160.801 0.4 162.401C0.4 162.401 20.6 160.401 24 158.601C24 158.601 39.6 153.401 42.6 150.801C45.6 148.201 63.8 143.201 66 141.201C68.2 139.201 78 130.801 77.6 127.401z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M18.882 158.911C18.882 158.911 24.111 158.685 22.958 160.234C21.805 161.784 19.357 160.91 19.357 160.91L18.882 158.911z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M11.68 160.263C11.68 160.263 16.908 160.037 15.756 161.586C14.603 163.136 12.155 162.263 12.155 162.263L11.68 160.263z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M1.251 161.511C1.251 161.511 6.48 161.284 5.327 162.834C4.174 164.383 1.726 163.51 1.726 163.51L1.251 161.511z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-6.383 162.055C-6.383 162.055 -1.154 161.829 -2.307 163.378C-3.46 164.928 -5.908 164.054 -5.908 164.054L-6.383 162.055z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M35.415 151.513C35.415 151.513 42.375 151.212 40.84 153.274C39.306 155.336 36.047 154.174 36.047 154.174L35.415 151.513z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M45.73 147.088C45.73 147.088 51.689 143.787 51.155 148.849C50.885 151.405 46.362 149.749 46.362 149.749L45.73 147.088z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M54.862 144.274C54.862 144.274 62.021 140.573 60.287 146.035C59.509 148.485 55.493 146.935 55.493 146.935L54.862 144.274z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M64.376 139.449C64.376 139.449 68.735 134.548 69.801 141.21C70.207 143.748 65.008 142.11 65.008 142.11L64.376 139.449z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M26.834 155.997C26.834 155.997 32.062 155.77 30.91 157.32C29.757 158.869 27.308 157.996 27.308 157.996L26.834 155.997z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M62.434 34.603C62.434 34.603 61.708 35.268 61.707 34.197C61.707 33.127 79.191 19.863 88.034 18.479C88.034 18.479 71.935 25.208 62.434 34.603z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M65.4 98.4C65.4 98.4 87.401 120.801 96.601 124.401C96.601 124.401 105.801 135.601 101.801 161.601C101.801 161.601 98.601 169.201 95.401 148.401C95.401 148.401 98.601 123.201 87.401 139.201C87.401 139.201 79 129.301 85.4 129.601C85.4 129.601 88.601 131.601 89.001 130.001C89.401 128.401 81.4 114.801 64.2 100.4C47 86 65.4 98.4 65.4 98.4z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M7 137.201C7 137.201 6.8 135.401 8.6 136.201C10.4 137.001 104.601 143.201 136.201 167.201C136.201 167.201 91.001 144.001 7 137.201z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M17.4 132.801C17.4 132.801 17.2 131.001 19 131.801C20.8 132.601 157.401 131.601 181.001 164.001C181.001 164.001 159.001 138.801 17.4 132.801z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M29 128.801C29 128.801 28.8 127.001 30.6 127.801C32.4 128.601 205.801 115.601 229.401 148.001C229.401 148.001 219.801 122.401 29 128.801z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M39 124.001C39 124.001 38.8 122.201 40.6 123.001C42.4 123.801 164.601 85.2 188.201 117.601C188.201 117.601 174.801 93 39 124.001z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-19 146.801C-19 146.801 -19.2 145.001 -17.4 145.801C-15.6 146.601 2.2 148.801 4.2 187.601C4.2 187.601 -3 145.601 -19 146.801z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-27.8 148.401C-27.8 148.401 -28 146.601 -26.2 147.401C-24.4 148.201 -10.2 143.601 -13 182.401C-13 182.401 -11.8 147.201 -27.8 148.401z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-35.8 148.801C-35.8 148.801 -36 147.001 -34.2 147.801C-32.4 148.601 -17 149.201 -29.4 171.601C-29.4 171.601 -19.8 147.601 -35.8 148.801z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M11.526 104.465C11.526 104.465 11.082 106.464 12.631 105.247C28.699 92.622 61.141 33.72 116.826 28.086C116.826 28.086 78.518 15.976 11.526 104.465z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M22.726 102.665C22.726 102.665 21.363 101.472 23.231 100.847C25.099 100.222 137.541 27.72 176.826 35.686C176.826 35.686 149.719 28.176 22.726 102.665z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M1.885 108.767C1.885 108.767 1.376 110.366 3.087 109.39C12.062 104.27 15.677 47.059 59.254 45.804C59.254 45.804 26.843 31.09 1.885 108.767z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-18.038 119.793C-18.038 119.793 -19.115 121.079 -17.162 120.825C-6.916 119.493 14.489 78.222 58.928 83.301C58.928 83.301 26.962 68.955 -18.038 119.793z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-6.8 113.667C-6.8 113.667 -7.611 115.136 -5.742 114.511C4.057 111.237 17.141 66.625 61.729 63.078C61.729 63.078 27.603 55.135 -6.8 113.667z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-25.078 124.912C-25.078 124.912 -25.951 125.954 -24.369 125.748C-16.07 124.669 1.268 91.24 37.264 95.354C37.264 95.354 11.371 83.734 -25.078 124.912z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-32.677 130.821C-32.677 130.821 -33.682 131.866 -32.091 131.748C-27.923 131.439 2.715 98.36 21.183 113.862C21.183 113.862 9.168 95.139 -32.677 130.821z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M36.855 98.898C36.855 98.898 35.654 97.543 37.586 97.158C39.518 96.774 160.221 39.061 198.184 51.927C198.184 51.927 172.243 41.053 36.855 98.898z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M3.4 163.201C3.4 163.201 3.2 161.401 5 162.201C6.8 163.001 22.2 163.601 9.8 186.001C9.8 186.001 19.4 162.001 3.4 163.201z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M13.8 161.601C13.8 161.601 13.6 159.801 15.4 160.601C17.2 161.401 35 163.601 37 202.401C37 202.401 29.8 160.401 13.8 161.601z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M20.6 160.001C20.6 160.001 20.4 158.201 22.2 159.001C24 159.801 48.6 163.201 72.2 195.601C72.2 195.601 36.6 158.801 20.6 160.001z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M28.225 157.972C28.225 157.972 27.788 156.214 29.678 156.768C31.568 157.322 52.002 155.423 90.099 189.599C90.099 189.599 43.924 154.656 28.225 157.972z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M38.625 153.572C38.625 153.572 38.188 151.814 40.078 152.368C41.968 152.922 76.802 157.423 128.499 192.399C128.499 192.399 54.324 150.256 38.625 153.572z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-1.8 142.001C-1.8 142.001 -2 140.201 -0.2 141.001C1.6 141.801 55 144.401 85.4 171.201C85.4 171.201 50.499 146.426 -1.8 142.001z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M-11.8 146.001C-11.8 146.001 -12 144.201 -10.2 145.001C-8.4 145.801 16.2 149.201 39.8 181.601C39.8 181.601 4.2 144.801 -11.8 146.001z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M49.503 148.962C49.503 148.962 48.938 147.241 50.864 147.655C52.79 148.068 87.86 150.004 141.981 181.098C141.981 181.098 64.317 146.704 49.503 148.962z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M57.903 146.562C57.903 146.562 57.338 144.841 59.264 145.255C61.19 145.668 96.26 147.604 150.381 178.698C150.381 178.698 73.317 143.904 57.903 146.562z"/>
+ </g>
+ <g style="fill: #ffffff; stroke:#000000; stroke-width:0.1">
+ <path d="M67.503 141.562C67.503 141.562 66.938 139.841 68.864 140.255C70.79 140.668 113.86 145.004 203.582 179.298C203.582 179.298 82.917 138.904 67.503 141.562z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-43.8 148.401C-43.8 148.401 -38.6 148.001 -39.8 149.601C-41 151.201 -43.4 150.401 -43.4 150.401L-43.8 148.401z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-13 162.401C-13 162.401 -7.8 162.001 -9 163.601C-10.2 165.201 -12.6 164.401 -12.6 164.401L-13 162.401z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-21.8 162.001C-21.8 162.001 -16.6 161.601 -17.8 163.201C-19 164.801 -21.4 164.001 -21.4 164.001L-21.8 162.001z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-117.169 150.182C-117.169 150.182 -112.124 151.505 -113.782 152.624C-115.439 153.744 -117.446 152.202 -117.446 152.202L-117.169 150.182z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-115.169 140.582C-115.169 140.582 -110.124 141.905 -111.782 143.024C-113.439 144.144 -115.446 142.602 -115.446 142.602L-115.169 140.582z"/>
+ </g>
+ <g style="fill: #000000">
+ <path d="M-122.369 136.182C-122.369 136.182 -117.324 137.505 -118.982 138.624C-120.639 139.744 -122.646 138.202 -122.646 138.202L-122.369 136.182z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-42.6 211.201C-42.6 211.201 -44.2 211.201 -48.2 213.201C-50.2 213.201 -61.4 216.801 -67 226.801C-67 226.801 -54.6 217.201 -42.6 211.201z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M45.116 303.847C45.257 304.105 45.312 304.525 45.604 304.542C46.262 304.582 47.495 304.883 47.37 304.247C46.522 299.941 45.648 295.004 41.515 293.197C40.876 292.918 39.434 293.331 39.36 294.215C39.233 295.739 39.116 297.088 39.425 298.554C39.725 299.975 41.883 299.985 42.8 298.601C43.736 300.273 44.168 302.116 45.116 303.847z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M34.038 308.581C34.786 309.994 34.659 311.853 36.074 312.416C36.814 312.71 38.664 311.735 38.246 310.661C37.444 308.6 37.056 306.361 35.667 304.55C35.467 304.288 35.707 303.755 35.547 303.427C34.953 302.207 33.808 301.472 32.4 301.801C31.285 304.004 32.433 306.133 33.955 307.842C34.091 307.994 33.925 308.37 34.038 308.581z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-5.564 303.391C-5.672 303.014 -5.71 302.551 -5.545 302.23C-5.014 301.197 -4.221 300.075 -4.558 299.053C-4.906 297.997 -6.022 298.179 -6.672 298.748C-7.807 299.742 -7.856 301.568 -8.547 302.927C-8.743 303.313 -8.692 303.886 -9.133 304.277C-9.607 304.698 -10.047 306.222 -9.951 306.793C-9.898 307.106 -10.081 317.014 -9.859 316.751C-9.24 316.018 -6.19 306.284 -6.121 305.392C-6.064 304.661 -5.332 304.196 -5.564 303.391z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-31.202 296.599C-28.568 294.1 -25.778 291.139 -26.22 287.427C-26.336 286.451 -28.111 286.978 -28.298 287.824C-29.1 291.449 -31.139 294.11 -33.707 296.502C-35.903 298.549 -37.765 304.893 -38 305.401C-34.303 300.145 -32.046 297.399 -31.202 296.599z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-44.776 290.635C-44.253 290.265 -44.555 289.774 -44.338 289.442C-43.385 287.984 -42.084 286.738 -42.066 285C-42.063 284.723 -42.441 284.414 -42.776 284.638C-43.053 284.822 -43.395 284.952 -43.503 285.082C-45.533 287.531 -46.933 290.202 -48.376 293.014C-48.559 293.371 -49.703 297.862 -49.39 297.973C-49.151 298.058 -47.431 293.877 -47.221 293.763C-45.958 293.077 -45.946 291.462 -44.776 290.635z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-28.043 310.179C-27.599 309.31 -26.023 308.108 -26.136 307.219C-26.254 306.291 -25.786 304.848 -26.698 305.536C-27.955 306.484 -31.404 307.833 -31.674 313.641C-31.7 314.212 -28.726 311.519 -28.043 310.179z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-13.6 293.001C-13.2 292.333 -12.492 292.806 -12.033 292.543C-11.385 292.171 -10.774 291.613 -10.482 290.964C-9.512 288.815 -7.743 286.995 -7.6 284.601C-9.091 283.196 -9.77 285.236 -10.4 286.201C-11.723 284.554 -12.722 286.428 -14.022 286.947C-14.092 286.975 -14.305 286.628 -14.38 286.655C-15.557 287.095 -16.237 288.176 -17.235 288.957C-17.406 289.091 -17.811 288.911 -17.958 289.047C-18.61 289.65 -19.583 289.975 -19.863 290.657C-20.973 293.364 -24.113 295.459 -26 303.001C-25.619 303.91 -21.488 296.359 -21.001 295.661C-20.165 294.465 -20.047 297.322 -18.771 296.656C-18.72 296.629 -18.534 296.867 -18.4 297.001C-18.206 296.721 -17.988 296.492 -17.6 296.601C-17.6 296.201 -17.734 295.645 -17.533 295.486C-16.296 294.509 -16.38 293.441 -15.6 292.201C-15.142 292.99 -14.081 292.271 -13.6 293.001z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M46.2 347.401C46.2 347.401 53.6 327.001 49.2 315.801C49.2 315.801 60.6 337.401 56 348.601C56 348.601 55.6 338.201 51.6 333.201C51.6 333.201 47.6 346.001 46.2 347.401z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M31.4 344.801C31.4 344.801 36.8 336.001 28.8 317.601C28.8 317.601 28 338.001 21.2 349.001C21.2 349.001 35.4 328.801 31.4 344.801z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M21.4 342.801C21.4 342.801 21.2 322.801 21.6 319.801C21.6 319.801 17.8 336.401 7.6 346.001C7.6 346.001 22 334.001 21.4 342.801z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M11.8 310.801C11.8 310.801 17.8 324.401 7.8 342.801C7.8 342.801 14.2 330.601 9.4 323.601C9.4 323.601 12 320.201 11.8 310.801z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-7.4 342.401C-7.4 342.401 -8.4 326.801 -6.6 324.601C-6.6 324.601 -6.4 318.201 -6.8 317.201C-6.8 317.201 -2.8 311.001 -2.6 318.401C-2.6 318.401 -1.2 326.201 1.6 330.801C1.6 330.801 5.2 336.201 5 342.601C5 342.601 -5 312.401 -7.4 342.401z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-11 314.801C-11 314.801 -17.6 325.601 -19.4 344.601C-19.4 344.601 -20.8 338.401 -17 324.001C-17 324.001 -12.8 308.601 -11 314.801z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-32.8 334.601C-32.8 334.601 -27.8 329.201 -26.4 324.201C-26.4 324.201 -22.8 308.401 -29.2 317.001C-29.2 317.001 -29 325.001 -37.2 332.401C-37.2 332.401 -32.4 330.001 -32.8 334.601z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-38.6 329.601C-38.6 329.601 -35.2 312.201 -34.4 311.401C-34.4 311.401 -32.6 308.001 -35.4 311.201C-35.4 311.201 -44.2 330.401 -48.2 337.001C-48.2 337.001 -40.2 327.801 -38.6 329.601z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-44.4 313.001C-44.4 313.001 -32.8 290.601 -54.6 316.401C-54.6 316.401 -43.6 306.601 -44.4 313.001z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 287z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M276 265C276 265 255 250 251.5 242.5C251.5 242.5 278 272 278 276.5C278 276.5 278.5 267.5 276 265z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M293 111C293 111 281 103 279.5 105C279.5 105 290 111.5 292.5 120C292.5 120 291 111 293 111z"/>
+ </g>
+ <g style="fill: #cccccc">
+ <path d="M301.5 191.5L284 179.5C284 179.5 303 196.5 303.5 200.5L301.5 191.5z"/>
+ </g>
+ <g style="stroke:#000000">
+ <path d="M-89.25 169L-67.25 173.75"/>
+ </g>
+ <g style="stroke:#000000">
+ <path d="M-39 331C-39 331 -39.5 327.5 -48.5 338"/>
+ </g>
+ <g style="stroke:#000000">
+ <path d="M-33.5 336C-33.5 336 -31.5 329.5 -38 334"/>
+ </g>
+ <g style="stroke:#000000">
+ <path d="M20.5 344.5C20.5 344.5 22 333.5 10.5 346.5"/>
+ </g>
+</g>
+</svg>
+
diff --git a/sources/pyside2/tests/QtTest/CMakeLists.txt b/sources/pyside2/tests/QtTest/CMakeLists.txt
new file mode 100644
index 000000000..9d1e9db39
--- /dev/null
+++ b/sources/pyside2/tests/QtTest/CMakeLists.txt
@@ -0,0 +1,3 @@
+PYSIDE_TEST(click_test.py)
+PYSIDE_TEST(eventfilter_test.py)
+PYSIDE_TEST(touchevent_test.py)
diff --git a/sources/pyside2/tests/QtTest/click_test.py b/sources/pyside2/tests/QtTest/click_test.py
new file mode 100644
index 000000000..e655371ae
--- /dev/null
+++ b/sources/pyside2/tests/QtTest/click_test.py
@@ -0,0 +1,55 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''QtTest mouse click functionalities'''
+
+import unittest
+
+from PySide2.QtCore import Qt, QObject
+from PySide2.QtWidgets import QPushButton, QLineEdit
+from PySide2.QtTest import QTest
+
+from helper import UsesQApplication
+
+class MouseClickTest(UsesQApplication):
+
+ def testBasic(self):
+ '''QTest.mouseClick with QCheckBox'''
+ button = QPushButton()
+ button.setCheckable(True)
+ button.setChecked(False)
+
+ QTest.mouseClick(button, Qt.LeftButton)
+ self.assertTrue(button.isChecked())
+
+ QTest.mouseClick(button, Qt.LeftButton)
+ self.assertFalse(button.isChecked())
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtTest/eventfilter_test.py b/sources/pyside2/tests/QtTest/eventfilter_test.py
new file mode 100644
index 000000000..e94b279b7
--- /dev/null
+++ b/sources/pyside2/tests/QtTest/eventfilter_test.py
@@ -0,0 +1,75 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests for QKeyEvent'''
+
+import unittest
+
+from PySide2.QtCore import Qt, QObject, QEvent
+from PySide2.QtGui import QKeyEvent
+from PySide2.QtWidgets import QLineEdit
+from PySide2.QtTest import QTest
+
+from helper import UsesQApplication
+
+
+class KeyEventFilter(QObject):
+
+ def __init__(self, widget, eventType, key):
+ QObject.__init__(self)
+
+ self.widget = widget
+ self.eventType = eventType
+ self.key = key
+
+ self.processed = False
+
+ def eventFilter(self, obj, event):
+ if self.widget == obj and event.type() == self.eventType and \
+ isinstance(event, QKeyEvent) and event.key() == self.key:
+ self.processed = True
+ return True
+
+ return False
+
+class EventFilterTest(UsesQApplication):
+
+ def testKeyEvent(self):
+ widget = QLineEdit()
+ key = Qt.Key_A
+ eventFilter = KeyEventFilter(widget, QEvent.KeyPress, key)
+ widget.installEventFilter(eventFilter)
+
+ QTest.keyClick(widget, key)
+
+ self.assertTrue(eventFilter.processed)
+
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtTest/touchevent_test.py b/sources/pyside2/tests/QtTest/touchevent_test.py
new file mode 100644
index 000000000..1a4fb94ee
--- /dev/null
+++ b/sources/pyside2/tests/QtTest/touchevent_test.py
@@ -0,0 +1,77 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtWidgets import QWidget
+from PySide2.QtCore import QPoint, QTimer, Qt, QEvent
+from PySide2.QtGui import QTouchDevice
+from PySide2.QtTest import QTest
+
+import unittest
+
+from helper import UsesQApplication
+
+class MyWidget(QWidget):
+ def __init__(self, parent = None):
+ QWidget.__init__(self, parent)
+ self._sequence = []
+ # Fixme (Qt 5): The device needs to be registered (using
+ # QWindowSystemInterface::registerTouchDevice()) for the test to work
+ self._device = QTouchDevice()
+ self.setAttribute(Qt.WA_AcceptTouchEvents)
+ QTimer.singleShot(200, self.generateEvent)
+
+ def event(self, e):
+ self._sequence.append(e.type())
+ return QWidget.event(self, e)
+
+ def generateEvent(self):
+ o = QTest.touchEvent(self, self._device)
+ o.press(0, QPoint(10, 10))
+ o.commit()
+ del o
+
+ QTest.touchEvent(self, self._device).press(0, QPoint(10, 10))
+ QTest.touchEvent(self, self._device).stationary(0).press(1, QPoint(40, 10))
+ QTest.touchEvent(self, self._device).move(0, QPoint(12, 12)).move(1, QPoint(45, 5))
+ QTest.touchEvent(self, self._device).release(0, QPoint(12, 12)).release(1, QPoint(45, 5))
+ QTimer.singleShot(200, self.deleteLater)
+
+
+class TouchEventTest(UsesQApplication):
+ def testCreateEvent(self):
+ w = MyWidget()
+ w.show()
+ self.app.exec_()
+ # same values as C++
+ self.assertEqual(w._sequence.count(QEvent.Type.TouchBegin), 2)
+ self.assertEqual(w._sequence.count(QEvent.Type.TouchUpdate), 2)
+ self.assertEqual(w._sequence.count(QEvent.Type.TouchEnd), 1)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtUiTools/CMakeLists.txt b/sources/pyside2/tests/QtUiTools/CMakeLists.txt
new file mode 100644
index 000000000..68ed7f134
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/CMakeLists.txt
@@ -0,0 +1,13 @@
+PYSIDE_TEST(bug_360.py)
+PYSIDE_TEST(bug_376.py)
+PYSIDE_TEST(bug_392.py)
+PYSIDE_TEST(bug_426.py)
+PYSIDE_TEST(bug_552.py)
+PYSIDE_TEST(bug_797.py)
+PYSIDE_TEST(bug_909.py)
+PYSIDE_TEST(bug_913.py)
+PYSIDE_TEST(bug_958.py)
+PYSIDE_TEST(bug_965.py)
+PYSIDE_TEST(bug_1060.py)
+PYSIDE_TEST(uiloader_test.py)
+PYSIDE_TEST(ui_test.py)
diff --git a/sources/pyside2/tests/QtUiTools/action.ui b/sources/pyside2/tests/QtUiTools/action.ui
new file mode 100644
index 000000000..9eda559de
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/action.ui
@@ -0,0 +1,16 @@
+<ui version="4.0">
+ <class>main_window</class>
+ <widget class="QMainWindow" name="main_window">
+ <widget class="QWidget" name="centralwidget"/>
+ <widget class="QMenuBar" name="menubar"/>
+ <widget class="QStatusBar" name="statusbar">
+ <action name="actionFoo">
+ <property name="text">
+ <string>foo</string>
+ </property>
+ </action>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/bug_1060.py b/sources/pyside2/tests/QtUiTools/bug_1060.py
new file mode 100644
index 000000000..21d79810a
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_1060.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' unit test for BUG #1060 '''
+
+from PySide2.QtWidgets import QApplication
+from PySide2.QtUiTools import QUiLoader
+from helper import adjust_filename
+
+class MyQUiLoader(QUiLoader):
+ def __init__(self):
+ super(MyQUiLoader, self).__init__()
+
+ def createWidget(self, *args):
+ return super(MyQUiLoader, self).createWidget(*args)
+
+if __name__ == "__main__":
+ app = QApplication([])
+
+ ui = MyQUiLoader().load(adjust_filename("bug_1060.ui", __file__))
+ ui.show()
diff --git a/sources/pyside2/tests/QtUiTools/bug_1060.ui b/sources/pyside2/tests/QtUiTools/bug_1060.ui
new file mode 100644
index 000000000..f4044a8c2
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_1060.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>100</width>
+ <height>100</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/bug_360.py b/sources/pyside2/tests/QtUiTools/bug_360.py
new file mode 100644
index 000000000..6d2c2a4e3
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_360.py
@@ -0,0 +1,64 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import os
+from helper import UsesQApplication
+
+from PySide2 import QtCore, QtWidgets
+from PySide2.QtUiTools import QUiLoader
+
+class MyQUiLoader(QUiLoader):
+ def __init__(self, baseinstance):
+ QUiLoader.__init__(self)
+ self.baseinstance = baseinstance
+ self._widgets = []
+
+ def createWidget(self, className, parent=None, name=""):
+ widget = QUiLoader.createWidget(self, className, parent, name)
+ self._widgets.append(widget)
+ if parent is None:
+ return self.baseinstance
+ else:
+ setattr(self.baseinstance, name, widget)
+ return widget
+
+class ButTest(UsesQApplication):
+ def testCase(self):
+ w = QtWidgets.QWidget()
+ loader = MyQUiLoader(w)
+
+ filePath = os.path.join(os.path.dirname(__file__), 'minimal.ui')
+ ui = loader.load(filePath)
+
+ self.assertEqual(len(loader._widgets), 1)
+ self.assertEqual(type(loader._widgets[0]), QtWidgets.QFrame)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtUiTools/bug_376.py b/sources/pyside2/tests/QtUiTools/bug_376.py
new file mode 100644
index 000000000..64b5acbd1
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_376.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import os
+from helper import UsesQApplication
+
+from PySide2 import QtCore, QtWidgets
+from PySide2.QtUiTools import QUiLoader
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ w = QtWidgets.QWidget()
+ loader = QUiLoader()
+
+ filePath = os.path.join(os.path.dirname(__file__), 'test.ui')
+ result = loader.load(filePath, w)
+ self.assertTrue(isinstance(result.child_object, QtWidgets.QFrame))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtUiTools/bug_392.py b/sources/pyside2/tests/QtUiTools/bug_392.py
new file mode 100644
index 000000000..d788b29d6
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_392.py
@@ -0,0 +1,75 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import os
+from helper import UsesQApplication
+
+from PySide2 import QtWidgets
+from PySide2.QtUiTools import QUiLoader
+
+class MyWidget(QtWidgets.QComboBox):
+ def __init__(self, parent=None):
+ QtWidgets.QComboBox.__init__(self, parent)
+
+ def isPython(self):
+ return True
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ w = QtWidgets.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))
+
+ def testPythonCustomWidgets(self):
+ w = QtWidgets.QWidget()
+ loader = QUiLoader()
+ loader.registerCustomWidget(MyWidget)
+
+ filePath = os.path.join(os.path.dirname(__file__), 'pycustomwidget.ui')
+ result = loader.load(filePath, w)
+ self.assertTrue(isinstance(result.custom, MyWidget))
+ self.assertTrue(result.custom.isPython())
+
+ def testPythonCustomWidgetsTwice(self):
+ w = QtWidgets.QWidget()
+ loader = QUiLoader()
+ loader.registerCustomWidget(MyWidget)
+
+ filePath = os.path.join(os.path.dirname(__file__), 'pycustomwidget2.ui')
+ result = loader.load(filePath, w)
+ self.assertTrue(isinstance(result.custom, MyWidget))
+ self.assertTrue(isinstance(result.custom2, MyWidget))
+ self.assertTrue(result.custom.isPython())
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtUiTools/bug_426.py b/sources/pyside2/tests/QtUiTools/bug_426.py
new file mode 100644
index 000000000..eac350a42
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_426.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import os
+from PySide2 import QtCore, QtWidgets
+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.widget.show()
+ QtCore.QTimer.singleShot(0, self.widget.close)
+
+if __name__ == "__main__":
+ app = QtWidgets.QApplication(sys.argv)
+ win = Window()
+ sys.exit(app.exec_())
diff --git a/sources/pyside2/tests/QtUiTools/bug_426.ui b/sources/pyside2/tests/QtUiTools/bug_426.ui
new file mode 100644
index 000000000..99353cd2b
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_426.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/bug_552.py b/sources/pyside2/tests/QtUiTools/bug_552.py
new file mode 100644
index 000000000..34165aa00
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_552.py
@@ -0,0 +1,49 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from helper import adjust_filename
+from PySide2 import QtWidgets, QtCore
+from PySide2.QtUiTools import QUiLoader
+
+class View_1(QtWidgets.QWidget):
+
+ def __init__(self):
+ QtWidgets.QWidget.__init__(self)
+ loader = QUiLoader()
+ widget = loader.load(adjust_filename('bug_552.ui', __file__), self)
+ self.children = []
+ for child in widget.findChildren(QtCore.QObject, None):
+ self.children.append(child)
+ self.t = widget.tabWidget
+ self.t.removeTab(0)
+
+app = QtWidgets.QApplication([])
+window = View_1()
+window.show()
+
+# If it doesn't crash it works :-)
diff --git a/sources/pyside2/tests/QtUiTools/bug_552.ui b/sources/pyside2/tests/QtUiTools/bug_552.ui
new file mode 100644
index 000000000..f98da4421
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_552.ui
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="geometry">
+ <rect>
+ <x>130</x>
+ <y>80</y>
+ <width>139</width>
+ <height>80</height>
+ </rect>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Tab 1</string>
+ </attribute>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Tab 2</string>
+ </attribute>
+ </widget>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/bug_797.py b/sources/pyside2/tests/QtUiTools/bug_797.py
new file mode 100644
index 000000000..476368d2f
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_797.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2 import QtUiTools
+from PySide2 import QtCore
+from PySide2 import QtWidgets
+from helper import adjust_filename
+
+app = QtWidgets.QApplication([])
+loader = QtUiTools.QUiLoader()
+file = QtCore.QFile(adjust_filename('bug_552.ui', __file__))
+w = QtWidgets.QWidget()
+# An exception can't be thrown
+mainWindow = loader.load(file, w)
diff --git a/sources/pyside2/tests/QtUiTools/bug_909.py b/sources/pyside2/tests/QtUiTools/bug_909.py
new file mode 100644
index 000000000..2b6bfbd4e
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_909.py
@@ -0,0 +1,52 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import unittest
+
+from PySide2.QtCore import QFile
+from PySide2.QtWidgets import QTabWidget
+from PySide2.QtUiTools import QUiLoader
+
+from helper import UsesQApplication
+from helper import adjust_filename
+
+class TestDestruction(UsesQApplication):
+ def testBug909(self):
+ fileName = QFile(adjust_filename('bug_909.ui', __file__))
+ loader = QUiLoader()
+ main_win = loader.load(fileName)
+ self.assertEqual(sys.getrefcount(main_win), 2)
+ fileName.close()
+
+ tw = QTabWidget(main_win)
+ main_win.setCentralWidget(tw)
+ main_win.show()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtUiTools/bug_909.ui b/sources/pyside2/tests/QtUiTools/bug_909.ui
new file mode 100644
index 000000000..b07f62d05
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_909.ui
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget"/>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>25</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/bug_913.py b/sources/pyside2/tests/QtUiTools/bug_913.py
new file mode 100644
index 000000000..d249ce958
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_913.py
@@ -0,0 +1,51 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import unittest
+from helper import adjust_filename
+
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+from PySide2.QtUiTools import *
+
+class TestBug913 (unittest.TestCase):
+
+ def testIt(self):
+ app = QApplication([])
+
+ loader = QUiLoader()
+ widget = loader.load(adjust_filename('bug_913.ui', __file__))
+ widget.tabWidget.currentIndex() # direct child is available as member
+ widget.le_first.setText('foo') # child of QTabWidget must also be available!
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtUiTools/bug_913.ui b/sources/pyside2/tests/QtUiTools/bug_913.ui
new file mode 100644
index 000000000..0fc95fd53
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_913.ui
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Tab 1</string>
+ </attribute>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>First name:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="le_first"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Last name:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="le_last"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Tab 2</string>
+ </attribute>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/bug_958.py b/sources/pyside2/tests/QtUiTools/bug_958.py
new file mode 100644
index 000000000..9cae430ea
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_958.py
@@ -0,0 +1,52 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2 import QtWidgets, QtUiTools
+from helper import adjust_filename
+from helper import TimedQApplication
+
+class Gui_Qt(QtWidgets.QMainWindow):
+ def __init__(self, parent=None):
+ super(Gui_Qt, self).__init__(parent)
+
+ lLoader = QtUiTools.QUiLoader()
+
+ # this used to cause a segfault because the old inject code used to destroy the parent layout
+ self._cw = lLoader.load(adjust_filename('bug_958.ui', __file__), self)
+
+ self.setCentralWidget(self._cw)
+
+class BugTest(TimedQApplication):
+ def testCase(self):
+ lMain = Gui_Qt()
+ lMain.show()
+ self.app.exec_()
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtUiTools/bug_958.ui b/sources/pyside2/tests/QtUiTools/bug_958.ui
new file mode 100644
index 000000000..57cdbddba
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_958.ui
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>customWidget</class>
+ <widget class="QWidget" name="customWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>626</width>
+ <height>578</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>500</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTableWidget" name="resultTable"/>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="actionLayout">
+ <item>
+ <widget class="QPushButton" name="processButton">
+ <property name="text">
+ <string>&amp;Berechnen</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/bug_965.py b/sources/pyside2/tests/QtUiTools/bug_965.py
new file mode 100644
index 000000000..96235cd4d
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_965.py
@@ -0,0 +1,48 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtUiTools import QUiLoader
+import unittest
+
+from helper import UsesQApplication
+from helper import adjust_filename
+
+class MyQUiLoader(QUiLoader):
+ def __init__(self):
+ super(MyQUiLoader, self).__init__()
+
+ def createWidget(self, className, parent=None, name=""):
+ return None
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ loader = MyQUiLoader()
+ self.assertRaises(RuntimeError, loader.load, adjust_filename('bug_965.ui', __file__))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtUiTools/bug_965.ui b/sources/pyside2/tests/QtUiTools/bug_965.ui
new file mode 100644
index 000000000..e324db829
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/bug_965.ui
@@ -0,0 +1,27 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow" >
+ <property name="objectName" >
+ <string notr="true" >MainWindow</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>MainWindow</string>
+ </property>
+ <widget class="QMenuBar" name="menubar" />
+ <widget class="QWidget" name="centralwidget" />
+ <widget class="QStatusBar" name="statusbar" />
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/minimal.ui b/sources/pyside2/tests/QtUiTools/minimal.ui
new file mode 100644
index 000000000..c6bb70cda
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/minimal.ui
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QFrame" name="Form">
+ </widget>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/pycustomwidget.ui b/sources/pyside2/tests/QtUiTools/pycustomwidget.ui
new file mode 100644
index 000000000..c066153a0
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/pycustomwidget.ui
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>qwidget</class>
+ <widget class="QWidget" name="qwidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string/>
+ </property>
+ <widget class="MyWidget" name="custom">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>79</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>MyWidget</class>
+ <extends>QComboBox</extends>
+ <header>customwidget</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/pycustomwidget2.ui b/sources/pyside2/tests/QtUiTools/pycustomwidget2.ui
new file mode 100644
index 000000000..8826ac1fb
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/pycustomwidget2.ui
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>qwidget</class>
+ <widget class="QWidget" name="qwidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string/>
+ </property>
+
+ <widget class="MyWidget" name="custom">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>79</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+
+ <widget class="MyWidget" name="custom2">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>79</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>MyWidget</class>
+ <extends>QComboBox</extends>
+ <header>customwidget</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/test.ui b/sources/pyside2/tests/QtUiTools/test.ui
new file mode 100644
index 000000000..60afe22b3
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/test.ui
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>185</width>
+ <height>133</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <widget class="QFrame" name="child_object">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>181</width>
+ <height>131</height>
+ </rect>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QPushButton" name="grandson_object">
+ <property name="geometry">
+ <rect>
+ <x>50</x>
+ <y>60</y>
+ <width>80</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside2/tests/QtUiTools/ui_test.py b/sources/pyside2/tests/QtUiTools/ui_test.py
new file mode 100644
index 000000000..e52d28278
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/ui_test.py
@@ -0,0 +1,41 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtUiTools import QUiLoader
+
+from helper import UsesQApplication
+
+class QUiLoaderCreation(UsesQApplication):
+
+ def testConstructor(self):
+ loader = QUiLoader()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtUiTools/uiloader_test.py b/sources/pyside2/tests/QtUiTools/uiloader_test.py
new file mode 100644
index 000000000..e429f5adc
--- /dev/null
+++ b/sources/pyside2/tests/QtUiTools/uiloader_test.py
@@ -0,0 +1,71 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import os
+from helper import UsesQApplication
+
+from PySide2.QtWidgets import QWidget
+from PySide2.QtUiTools import QUiLoader
+
+def get_file_path():
+ for path in file_path:
+ if os.path.exists(path):
+ return path
+ return ""
+
+class QUioaderTeste(UsesQApplication):
+ def testLoadFile(self):
+ filePath = os.path.join(os.path.dirname(__file__), 'test.ui')
+ loader = QUiLoader()
+ parent = QWidget()
+ w = loader.load(filePath, parent)
+ self.assertNotEqual(w, None)
+
+ self.assertEqual(len(parent.children()), 1)
+
+ child = w.findChild(QWidget, "child_object")
+ self.assertNotEqual(child, None)
+ self.assertEqual(w.findChild(QWidget, "grandson_object"), child.findChild(QWidget, "grandson_object"))
+
+ def testLoadFileUnicodeFilePath(self):
+ filePath = str(os.path.join(os.path.dirname(__file__), 'test.ui'))
+ loader = QUiLoader()
+ parent = QWidget()
+ w = loader.load(filePath, parent)
+ self.assertNotEqual(w, None)
+
+ self.assertEqual(len(parent.children()), 1)
+
+ child = w.findChild(QWidget, "child_object")
+ self.assertNotEqual(child, None)
+ self.assertEqual(w.findChild(QWidget, "grandson_object"), child.findChild(QWidget, "grandson_object"))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWebChannel/CMakeLists.txt b/sources/pyside2/tests/QtWebChannel/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtWebChannel/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtWebChannel/this_module_loads_test.py b/sources/pyside2/tests/QtWebChannel/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtWebChannel/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtWebEngine/CMakeLists.txt b/sources/pyside2/tests/QtWebEngine/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtWebEngine/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtWebEngine/this_module_loads_test.py b/sources/pyside2/tests/QtWebEngine/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtWebEngine/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtWebEngineWidgets/CMakeLists.txt b/sources/pyside2/tests/QtWebEngineWidgets/CMakeLists.txt
new file mode 100644
index 000000000..0276d19a1
--- /dev/null
+++ b/sources/pyside2/tests/QtWebEngineWidgets/CMakeLists.txt
@@ -0,0 +1,29 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+PYSIDE_TEST(pyside-474-qtwebengineview.py)
diff --git a/sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py b/sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py
new file mode 100644
index 000000000..c6114361d
--- /dev/null
+++ b/sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py
@@ -0,0 +1,49 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import unittest
+
+from PySide2 import QtWidgets
+from PySide2 import QtWebEngineWidgets
+
+class MainTest(unittest.TestCase):
+
+ def test_WebEngineView_findText_exists(self):
+ qApp = (QtWidgets.QApplication.instance() or
+ QtWidgets.QApplication([]))
+ view = QtWebEngineWidgets.QWebEngineView()
+ with self.assertRaises(TypeError):
+ view.findText(123)
+ view.findText("nothing")
+ # we are testing only the existence of the function,
+ # after it suddenly showed up.
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWebEngineWidgets/this_module_loads_test.py b/sources/pyside2/tests/QtWebEngineWidgets/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtWebEngineWidgets/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtWebKit/CMakeLists.txt b/sources/pyside2/tests/QtWebKit/CMakeLists.txt
new file mode 100644
index 000000000..7fab64773
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/CMakeLists.txt
@@ -0,0 +1,11 @@
+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
new file mode 100644
index 000000000..2c50bd166
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/bug_448.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for bug: http://bugs.openbossa.org/show_bug.cgi?id=448'''
+
+import unittest
+import sys
+
+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
new file mode 100644
index 000000000..f59c08b04
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/bug_694.py
@@ -0,0 +1,78 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import unittest
+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
new file mode 100644
index 000000000..23b670f9c
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/bug_803.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+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
new file mode 100644
index 000000000..edd705c8e
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/bug_899.py
@@ -0,0 +1,64 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import Property, QObject
+from PySide2.QtWebKit import QWebView
+from helper 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
new file mode 100644
index 000000000..22f217bee
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/bug_959.py
@@ -0,0 +1,128 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import QObject, Slot, QTimer
+from PySide2.QtWebKit import QWebView
+from PySide2.QtWidgets import QApplication
+from PySide2 import QtCore
+
+import sys
+import unittest
+
+from helper 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
new file mode 100644
index 000000000..da873b1cc
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/fox.html
@@ -0,0 +1,7 @@
+<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
new file mode 100644
index 000000000..d7e855ce8
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/qml_plugin_test.py
@@ -0,0 +1,88 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import os
+import sys
+import unittest
+
+from PySide2.QtCore import QUrl, QTimer
+from PySide2.QtWidgets import QApplication, QLabel
+from PySide2.QtWebKit import QWebPluginFactory, QWebView, QWebSettings
+
+from helper 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
new file mode 100644
index 000000000..0b7469da4
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/qmlplugin/dummy.pys
@@ -0,0 +1 @@
+Foobar!
diff --git a/sources/pyside2/tests/QtWebKit/qmlplugin/index.html b/sources/pyside2/tests/QtWebKit/qmlplugin/index.html
new file mode 100644
index 000000000..db0d6b5b2
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/qmlplugin/index.html
@@ -0,0 +1,5 @@
+<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
new file mode 100644
index 000000000..c33b2d1fe
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/qvariantlist_property_test.py
@@ -0,0 +1,71 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import Property, QObject
+from PySide2.QtWebKit import QWebView
+from helper 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
new file mode 100644
index 000000000..7c9763f2e
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/shouldInterruptjavascript_test.py
@@ -0,0 +1,56 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2 import QtCore, QtWebKit
+
+from helper 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/webframe_test.py b/sources/pyside2/tests/QtWebKit/webframe_test.py
new file mode 100644
index 000000000..e82ae5279
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/webframe_test.py
@@ -0,0 +1,62 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+
+from PySide2.QtCore import QObject, SIGNAL, QUrl
+from PySide2.QtWebKit import *
+from PySide2.QtNetwork import QNetworkRequest
+
+from helper import adjust_filename, UsesQApplication
+
+
+
+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()
+
+ 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_()
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWebKit/webpage_test.py b/sources/pyside2/tests/QtWebKit/webpage_test.py
new file mode 100644
index 000000000..1abb6be49
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/webpage_test.py
@@ -0,0 +1,88 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QWebPage'''
+
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL, QUrl
+from PySide2.QtWebKit import QWebPage
+from PySide2.QtNetwork import QNetworkAccessManager
+
+from helper import adjust_filename, 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
new file mode 100644
index 000000000..f6c82e045
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKit/webview_test.py
@@ -0,0 +1,94 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QWebView'''
+
+import unittest
+import py3kcompat as py3k
+import sys
+
+from PySide2.QtCore import QObject, SIGNAL, QUrl
+from PySide2.QtWebKit import QWebPage, QWebView
+from PySide2.QtNetwork import QNetworkRequest
+
+from helper import adjust_filename, 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/QtWebKitWidgets/CMakeLists.txt b/sources/pyside2/tests/QtWebKitWidgets/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKitWidgets/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtWebKitWidgets/this_module_loads_test.py b/sources/pyside2/tests/QtWebKitWidgets/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtWebKitWidgets/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtWebSockets/CMakeLists.txt b/sources/pyside2/tests/QtWebSockets/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtWebSockets/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtWebSockets/this_module_loads_test.py b/sources/pyside2/tests/QtWebSockets/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtWebSockets/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtWidgets/CMakeLists.txt b/sources/pyside2/tests/QtWidgets/CMakeLists.txt
new file mode 100644
index 000000000..3c31b1d7d
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/CMakeLists.txt
@@ -0,0 +1,134 @@
+#Keep this in alphabetical sort
+
+PYSIDE_TEST(action_clear.py)
+PYSIDE_TEST(add_action_test.py)
+PYSIDE_TEST(api2_test.py)
+PYSIDE_TEST(application_test.py)
+PYSIDE_TEST(bug_172.py)
+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)
+PYSIDE_TEST(bug_467.py)
+PYSIDE_TEST(bug_493.py)
+PYSIDE_TEST(bug_512.py)
+PYSIDE_TEST(bug_525.py)
+PYSIDE_TEST(bug_546.py)
+PYSIDE_TEST(bug_547.py)
+PYSIDE_TEST(bug_549.py)
+PYSIDE_TEST(bug_569.py)
+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)
+PYSIDE_TEST(bug_662.py)
+PYSIDE_TEST(bug_667.py)
+PYSIDE_TEST(bug_668.py)
+PYSIDE_TEST(bug_674.py)
+PYSIDE_TEST(bug_675.py)
+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)
+PYSIDE_TEST(bug_750.py)
+PYSIDE_TEST(bug_778.py)
+PYSIDE_TEST(bug_785.py)
+PYSIDE_TEST(bug_793.py)
+PYSIDE_TEST(bug_811.py)
+PYSIDE_TEST(bug_834.py)
+PYSIDE_TEST(bug_836.py)
+PYSIDE_TEST(bug_844.py)
+PYSIDE_TEST(bug_854.py)
+PYSIDE_TEST(bug_860.py)
+PYSIDE_TEST(bug_862.py)
+PYSIDE_TEST(bug_871.py)
+PYSIDE_TEST(bug_879.py)
+PYSIDE_TEST(bug_919.py)
+PYSIDE_TEST(bug_921.py)
+PYSIDE_TEST(bug_941.py)
+PYSIDE_TEST(bug_964.py)
+PYSIDE_TEST(bug_967.py)
+PYSIDE_TEST(bug_972.py)
+PYSIDE_TEST(bug_979.py)
+PYSIDE_TEST(bug_988.py)
+PYSIDE_TEST(bug_998.py)
+PYSIDE_TEST(bug_1002.py)
+PYSIDE_TEST(bug_1006.py)
+PYSIDE_TEST(bug_1048.py)
+PYSIDE_TEST(bug_1077.py)
+PYSIDE_TEST(customproxywidget_test.py)
+PYSIDE_TEST(event_filter_test.py)
+PYSIDE_TEST(grandparent_method_test.py)
+PYSIDE_TEST(hashabletype_test.py)
+PYSIDE_TEST(keep_reference_test.py)
+PYSIDE_TEST(missing_symbols_test.py)
+PYSIDE_TEST(paint_event_test.py)
+PYSIDE_TEST(parent_method_test.py)
+PYSIDE_TEST(python_properties_test.py)
+PYSIDE_TEST(qabstracttextdocumentlayout_test.py)
+PYSIDE_TEST(qaction_test.py)
+PYSIDE_TEST(qapp_test.py)
+PYSIDE_TEST(qapplication_exit_segfault_test.py)
+PYSIDE_TEST(qapplication_singleton_test.py)
+PYSIDE_TEST(qbrush_test.py)
+PYSIDE_TEST(qdynamic_signal.py)
+# TODO: This passes, but requires manual button clicking (at least on mac)
+#PYSIDE_TEST(qfontdialog_test.py)
+PYSIDE_TEST(qformlayout_test.py)
+PYSIDE_TEST(qgraphicsitem_test.py)
+PYSIDE_TEST(qgraphicsitem_isblocked_test.py)
+PYSIDE_TEST(qgraphicsproxywidget_test.py)
+PYSIDE_TEST(qgraphicsscene_test.py)
+PYSIDE_TEST(qimage_test.py)
+PYSIDE_TEST(qinputdialog_get_test.py)
+PYSIDE_TEST(qkeysequenceedit_test.py)
+PYSIDE_TEST(qlayout_ref_test.py)
+PYSIDE_TEST(qlayout_test.py)
+PYSIDE_TEST(qlcdnumber_test.py)
+PYSIDE_TEST(qlistwidget_test.py)
+PYSIDE_TEST(qlistwidgetitem_test.py)
+PYSIDE_TEST(qmainwindow_test.py)
+PYSIDE_TEST(qmenu_test.py)
+PYSIDE_TEST(qmenuadd_test.py)
+PYSIDE_TEST(qobject_mi_test.py)
+PYSIDE_TEST(qpen_test.py)
+PYSIDE_TEST(qpicture_test.py)
+PYSIDE_TEST(qpixmap_constructor.py)
+PYSIDE_TEST(qpushbutton_test.py)
+PYSIDE_TEST(qshortcut_test.py)
+PYSIDE_TEST(qsplitter_test.py)
+PYSIDE_TEST(qstandarditemmodel_test.py)
+PYSIDE_TEST(qstring_qkeysequence_test.py)
+PYSIDE_TEST(qstyle_test.py)
+PYSIDE_TEST(qtableview_test.py)
+PYSIDE_TEST(qtabwidget_test.py)
+PYSIDE_TEST(qtextedit_test.py)
+PYSIDE_TEST(qtextedit_signal_test.py)
+PYSIDE_TEST(qtoolbar_test.py)
+PYSIDE_TEST(qtoolbox_test.py)
+PYSIDE_TEST(qvalidator_test.py)
+PYSIDE_TEST(qvariant_test.py)
+PYSIDE_TEST(qwidget_setlayout_test.py)
+PYSIDE_TEST(qwidget_test.py)
+PYSIDE_TEST(reference_count_test.py)
+PYSIDE_TEST(returnquadruplesofnumbers_test.py)
+PYSIDE_TEST(standardpixmap_test.py)
+PYSIDE_TEST(test_module_template.py)
+PYSIDE_TEST(virtual_protected_inheritance_test.py)
+PYSIDE_TEST(virtual_pure_override_test.py)
+PYSIDE_TEST(wrong_return_test.py)
diff --git a/sources/pyside2/tests/QtWidgets/action_clear.py b/sources/pyside2/tests/QtWidgets/action_clear.py
new file mode 100644
index 000000000..72ea41e08
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/action_clear.py
@@ -0,0 +1,74 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtWidgets import QMenu, QWidget, QMenuBar, QToolBar
+import weakref
+
+import unittest
+from helper import UsesQApplication
+
+
+class TestQActionLifeCycle(UsesQApplication):
+ def actionDestroyed(self, act):
+ self._actionDestroyed = True
+
+ def testMenu(self):
+ self._actionDestroyed = False
+ w = QWidget()
+ menu = QMenu(w)
+ act = menu.addAction("MENU")
+ _ref = weakref.ref(act, self.actionDestroyed)
+ act = None
+ self.assertFalse(self._actionDestroyed)
+ menu.clear()
+ self.assertTrue(self._actionDestroyed)
+
+ def testMenuBar(self):
+ self._actionDestroyed = False
+ w = QWidget()
+ menuBar = QMenuBar(w)
+ act = menuBar.addAction("MENU")
+ _ref = weakref.ref(act, self.actionDestroyed)
+ act = None
+ self.assertFalse(self._actionDestroyed)
+ menuBar.clear()
+ self.assertTrue(self._actionDestroyed)
+
+ def testToolBar(self):
+ self._actionDestroyed = False
+ w = QWidget()
+ toolBar = QToolBar(w)
+ act = toolBar.addAction("MENU")
+ _ref = weakref.ref(act, self.actionDestroyed)
+ act = None
+ self.assertFalse(self._actionDestroyed)
+ toolBar.clear()
+ self.assertTrue(self._actionDestroyed)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/add_action_test.py b/sources/pyside2/tests/QtWidgets/add_action_test.py
new file mode 100644
index 000000000..c6bc7abb5
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/add_action_test.py
@@ -0,0 +1,71 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests for QMenuBar.addAction(identifier, callback) calls'''
+
+import unittest
+
+from PySide2.QtCore import SLOT
+from PySide2.QtWidgets import QMenuBar, QAction, QPushButton
+
+from helper import UsesQApplication
+
+
+class AddActionTest(UsesQApplication):
+ '''QMenuBar addAction'''
+
+ def tearDown(self):
+ try:
+ del self.called
+ except AttributeError:
+ pass
+ super(AddActionTest, self).tearDown()
+
+ def _callback(self):
+ self.called = True
+
+ def testBasic(self):
+ '''QMenuBar.addAction(id, callback)'''
+ menubar = QMenuBar()
+ action = menubar.addAction("Accounts", self._callback)
+ action.activate(QAction.Trigger)
+ self.assertTrue(self.called)
+
+ def testWithCppSlot(self):
+ '''QMenuBar.addAction(id, object, slot)'''
+ menubar = QMenuBar()
+ widget = QPushButton()
+ widget.setCheckable(True)
+ widget.setChecked(False)
+ action = menubar.addAction("Accounts", widget, SLOT("toggle()"))
+ action.activate(QAction.Trigger)
+ self.assertTrue(widget.isChecked())
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/api2_test.py b/sources/pyside2/tests/QtWidgets/api2_test.py
new file mode 100644
index 000000000..ad46567bc
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/api2_test.py
@@ -0,0 +1,89 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for PySide API2 support'''
+
+
+import unittest
+import sys
+
+from PySide2.QtGui import QIntValidator, QValidator
+from PySide2.QtWidgets import QWidget, QSpinBox, QApplication
+
+from helper import UsesQApplication
+
+class WidgetValidatorQInt(QWidget, QIntValidator):
+ def __init__(self, parent=None):
+ QWidget.__init__(self, parent)
+ QIntValidator.__init__(self, parent)
+
+class WidgetValidatorQSpinBox(QSpinBox):
+ def __init__(self, parent=None):
+ QSpinBox.__init__(self, parent)
+
+ def fixup(self, text):
+ print("It was called!")
+
+class DoubleQObjectInheritanceTest(UsesQApplication):
+
+ def testDouble(self):
+ '''Double inheritance from QObject classes'''
+
+ obj = WidgetValidatorQInt()
+
+ #QIntValidator methods
+ state, string, number = obj.validate('Test', 0)
+ self.assertEqual(state, QValidator.Invalid)
+ state, string, number = obj.validate('33', 0)
+ self.assertEqual(state, QValidator.Acceptable)
+
+ def testQSpinBox(self):
+ obj = WidgetValidatorQSpinBox()
+
+ obj.setRange(1, 10)
+ obj.setValue(0)
+ self.assertEqual(obj.value(), 1)
+
+class QClipboardTest(UsesQApplication):
+
+ def testQClipboard(self):
+ #skip this test on MacOS because the clipboard is not available during the ssh session
+ #this cause problems in the buildbot
+ if sys.platform == 'darwin':
+ return
+ clip = QApplication.clipboard()
+ clip.setText("Testing this thing!")
+
+ text, subtype = clip.text("")
+ self.assertEqual(subtype, "plain")
+ self.assertEqual(text, "Testing this thing!")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/application_test.py b/sources/pyside2/tests/QtWidgets/application_test.py
new file mode 100644
index 000000000..78628a556
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/application_test.py
@@ -0,0 +1,51 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from testbinding import TestObject
+from PySide2.QtWidgets import QApplication
+
+class QApplicationInstance(unittest.TestCase):
+
+ def appDestroyed(self):
+ sefl.assertTrue(False)
+
+ def testInstanceObject(self):
+ TestObject.createApp()
+ app1 = QApplication.instance()
+ app2 = QApplication.instance()
+ app1.setObjectName("MyApp")
+ self.assertEqual(app1, app2)
+ self.assertEqual(app2.objectName(), app1.objectName())
+ app1.destroyed.connect(self.appDestroyed)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_1002.py b/sources/pyside2/tests/QtWidgets/bug_1002.py
new file mode 100644
index 000000000..6deadb238
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_1002.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+from PySide2.QtWidgets import QWidget, QPushButton
+
+from helper import UsesQApplication
+
+class TestBug1002 (UsesQApplication):
+ def testReturnWindow(self):
+ widget = QWidget()
+ button = QPushButton(widget)
+ self.assertEqual(sys.getrefcount(widget), 2)
+ window = button.window()
+ self.assertEqual(sys.getrefcount(widget), 3)
+ self.assertEqual(sys.getrefcount(window), 3)
+
+ del widget
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_1006.py b/sources/pyside2/tests/QtWidgets/bug_1006.py
new file mode 100644
index 000000000..6a8ea03b4
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_1006.py
@@ -0,0 +1,111 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import weakref
+import sys
+
+from PySide2.QtCore import Qt
+from PySide2.QtWidgets import QDialog, QLabel, QGridLayout, QHBoxLayout, QWidget
+
+from helper import TimedQApplication
+
+class LabelWindow(QDialog):
+ def __init__(self, parent):
+ super(LabelWindow, self).__init__(parent)
+
+ self.test_layout = QGridLayout()
+ label = QLabel("Label")
+ self.test_layout.addWidget(label, 0, 0)
+ self.setLayout(self.test_layout)
+ self._destroyCalled = False
+
+
+ def replace(self, unit):
+ old_item = self.test_layout.itemAtPosition(0, 0)
+ old_label = old_item.widget()
+ ref = weakref.ref(old_item, self._destroyed)
+
+ self.test_layout.removeWidget(old_label)
+ unit.assertRaises(RuntimeError, old_item.widget)
+ del old_item
+
+ label = QLabel("Label New")
+ old_label.deleteLater()
+ label.setAlignment(Qt.AlignCenter)
+ self.test_layout.addWidget(label, 0, 0)
+
+ def _destroyed(self, obj):
+ self._destroyCalled = True
+
+class TestBug1006 (TimedQApplication):
+
+ def testLayoutItemLifeTime(self):
+ window = LabelWindow(None)
+ window.replace(self)
+ self.assertTrue(window._destroyCalled)
+ self.app.exec_()
+
+ def testParentLayout(self):
+ def createLayout():
+ label = QLabel()
+ layout = QHBoxLayout()
+ layout.addWidget(label)
+
+ widget = QWidget()
+ widget.setLayout(layout)
+ return (layout, widget)
+ (layout, widget) = createLayout()
+ item = layout.itemAt(0)
+ self.assertTrue(isinstance(item.widget(), QWidget))
+
+ def testRemoveOrphanWidget(self):
+ widget = QLabel()
+ layout = QHBoxLayout()
+ layout.addWidget(widget)
+ self.assertEqual(sys.getrefcount(widget), 3)
+
+ layout.removeWidget(widget)
+ widget.setObjectName("MyWidget")
+ self.assertEqual(sys.getrefcount(widget), 2)
+
+ def testRemoveChildWidget(self):
+ parent = QLabel()
+ widget = QLabel(parent)
+ self.assertEqual(sys.getrefcount(widget), 3)
+
+ layout = QHBoxLayout()
+ layout.addWidget(widget)
+ self.assertEqual(sys.getrefcount(widget), 3)
+
+ layout.removeWidget(widget)
+ widget.setObjectName("MyWidget")
+ self.assertEqual(sys.getrefcount(widget), 3)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_1048.py b/sources/pyside2/tests/QtWidgets/bug_1048.py
new file mode 100644
index 000000000..1e09fa66a
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_1048.py
@@ -0,0 +1,36 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2 import QtWidgets
+
+a = QtWidgets.QApplication([])
+
+w = QtWidgets.QWidget()
+l = QtWidgets.QGridLayout(w)
+
+l.itemAtPosition(0, 0)
diff --git a/sources/pyside2/tests/QtWidgets/bug_1077.py b/sources/pyside2/tests/QtWidgets/bug_1077.py
new file mode 100644
index 000000000..68380e42c
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_1077.py
@@ -0,0 +1,45 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' unit test for BUG #1077 '''
+
+from PySide2 import QtCore, QtGui, QtWidgets
+import time
+
+class Highlighter(QtGui.QSyntaxHighlighter):
+ def __init__(self, parent, mode):
+ QtGui.QSyntaxHighlighter.__init__(self, parent)
+ self.tstamp = time.time()
+
+if __name__ == "__main__":
+ app = QtWidgets.QApplication([])
+ python = QtWidgets.QTextEdit()
+ python.setWindowTitle("python")
+ hl = Highlighter(python.document(), "python")
+ python.show()
+ text = hl.document()
diff --git a/sources/pyside2/tests/QtWidgets/bug_172.py b/sources/pyside2/tests/QtWidgets/bug_172.py
new file mode 100644
index 000000000..993b634c3
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_172.py
@@ -0,0 +1,41 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtWidgets import *
+
+if __name__ == '__main__':
+ app = QApplication([])
+
+ wdg = QWidget()
+
+ hbox = QHBoxLayout()
+
+ vbox = QVBoxLayout()
+ vbox.addLayout(hbox)
+
+ wdg.setLayout(vbox)
diff --git a/sources/pyside2/tests/QtWidgets/bug_243.py b/sources/pyside2/tests/QtWidgets/bug_243.py
new file mode 100644
index 000000000..361f02f17
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_243.py
@@ -0,0 +1,45 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 243: http://bugs.openbossa.org/show_bug.cgi?id=243'''
+
+import unittest
+import sys
+
+from PySide2.QtWidgets import QApplication, QMainWindow, QLayout
+
+class QAppPresence(unittest.TestCase):
+
+ def testBug(self):
+ app = QApplication(sys.argv)
+ window = QMainWindow()
+ l = window.layout()
+ self.assertTrue(isinstance(l, QLayout))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_307.py b/sources/pyside2/tests/QtWidgets/bug_307.py
new file mode 100644
index 000000000..4937f9835
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_307.py
@@ -0,0 +1,54 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import colorsys
+
+from PySide2.QtCore import SIGNAL
+from PySide2.QtWidgets import QPushButton, QApplication
+
+
+class Test (QApplication) :
+ def __init__(self, argv) :
+ super(Test, self).__init__(argv)
+ self._called = False
+
+ def called(self):
+ self._called = True
+
+
+class QApplicationSignalsTest(unittest.TestCase):
+ def testQuit(self):
+ app = Test([])
+ button = QPushButton("BUTTON")
+ app.connect(button, SIGNAL("clicked()"), app.called)
+ button.click()
+ self.assertTrue(app._called)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_324.py b/sources/pyside2/tests/QtWidgets/bug_324.py
new file mode 100644
index 000000000..cc1871c7f
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_324.py
@@ -0,0 +1,60 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 324: http://bugs.openbossa.org/show_bug.cgi?id=324'''
+
+import unittest
+import sys
+import signal
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+class QBug( QObject ):
+ def __init__(self, parent = None):
+ QObject.__init__(self, parent)
+
+ def check(self):
+ self.done.emit("abc")
+
+ done = Signal(str)
+
+class Bug324(unittest.TestCase):
+
+ def on_done(self, val):
+ self.value = val
+
+ def testBug(self):
+ app = QApplication([])
+ bug = QBug()
+ self.value = ''
+ bug.done.connect(self.on_done)
+ bug.check()
+ self.assertEqual(self.value, 'abc')
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_338.py b/sources/pyside2/tests/QtWidgets/bug_338.py
new file mode 100644
index 000000000..326c10a4d
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_338.py
@@ -0,0 +1,55 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 338: http://bugs.openbossa.org/show_bug.cgi?id=338'''
+
+import sys
+import unittest
+
+from PySide2 import QtCore, QtWidgets
+
+class DiagramItem(QtWidgets.QGraphicsPolygonItem):
+ def __init__(self, parent=None, scene=None):
+ super(DiagramItem, self).__init__(parent, scene)
+
+ def itemChange(self, change, value):
+ return value
+
+
+class BugTest(unittest.TestCase):
+ def test(self):
+ app = QtWidgets.QApplication(sys.argv)
+ scene = QtWidgets.QGraphicsScene()
+ item = DiagramItem()
+ item2 = DiagramItem()
+ #this cause segfault
+ scene.addItem(item)
+ scene.addItem(item2)
+
+if __name__ == "__main__":
+ unittest.main() \ No newline at end of file
diff --git a/sources/pyside2/tests/QtWidgets/bug_363.py b/sources/pyside2/tests/QtWidgets/bug_363.py
new file mode 100644
index 000000000..7587c45de
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_363.py
@@ -0,0 +1,54 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 363: http://bugs.openbossa.org/show_bug.cgi?id=363'''
+
+import sys
+import unittest
+
+from helper 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_389.py b/sources/pyside2/tests/QtWidgets/bug_389.py
new file mode 100644
index 000000000..1ea8183e3
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_389.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 389: http://bugs.openbossa.org/show_bug.cgi?id=389'''
+
+import sys
+import unittest
+from helper import UsesQApplication
+from PySide2 import QtCore, QtGui, QtWidgets
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ s = QtWidgets.QWidget().style()
+ i = s.standardIcon(QtWidgets.QStyle.SP_TitleBarMinButton)
+ self.assertEqual(type(i), QtGui.QIcon)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_400.py b/sources/pyside2/tests/QtWidgets/bug_400.py
new file mode 100644
index 000000000..ad673704d
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_400.py
@@ -0,0 +1,54 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 400: http://bugs.openbossa.org/show_bug.cgi?id=400'''
+
+import unittest
+from helper import UsesQApplication
+from PySide2.QtWidgets import QTreeWidgetItemIterator, QTreeWidgetItem, QTreeWidget
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ treeWidget = QTreeWidget()
+ treeWidget.setColumnCount(1)
+ items = []
+ for i in range(10):
+ items.append(QTreeWidgetItem(None, ["item: %i" % i]))
+
+ treeWidget.insertTopLevelItems(0, items);
+ _iter = QTreeWidgetItemIterator(treeWidget)
+ index = 0
+ while(_iter.value()):
+ item = _iter.value()
+ self.assertTrue(item is items[index])
+ index += 1
+ _iter += 1
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_416.py b/sources/pyside2/tests/QtWidgets/bug_416.py
new file mode 100644
index 000000000..988f3f83b
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_416.py
@@ -0,0 +1,71 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from helper 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_429.py b/sources/pyside2/tests/QtWidgets/bug_429.py
new file mode 100644
index 000000000..2d9a9fee6
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_429.py
@@ -0,0 +1,38 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+import sys
+
+app = QApplication(sys.argv)
+scene = QGraphicsScene()
+label = QLabel("hello world")
+label.show()
+QTimer.singleShot(0, label.close)
+exit(app.exec_())
diff --git a/sources/pyside2/tests/QtWidgets/bug_430.py b/sources/pyside2/tests/QtWidgets/bug_430.py
new file mode 100644
index 000000000..7c7a5fa7a
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_430.py
@@ -0,0 +1,42 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+class ListModel(QAbstractListModel):
+ def rowCount(self, parent = QModelIndex()):
+ return 0
+
+app = QApplication([])
+model = ListModel()
+v = QListView()
+v.setModel(model)
+QTimer.singleShot(0, v.close)
+app.exec_()
diff --git a/sources/pyside2/tests/QtWidgets/bug_433.py b/sources/pyside2/tests/QtWidgets/bug_433.py
new file mode 100644
index 000000000..798bc28bd
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_433.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+
+from PySide2 import QtCore, QtWidgets
+
+class Test(QtWidgets.QGraphicsView):
+ def __init__(self, parent=None):
+ super(Test, self).__init__(parent)
+ self.s = QtWidgets.QGraphicsScene()
+ self.setScene(self.s)
+
+a = QtWidgets.QApplication(sys.argv)
+t = Test()
+t.show()
+QtCore.QTimer.singleShot(0, t.close)
+sys.exit(a.exec_())
diff --git a/sources/pyside2/tests/QtWidgets/bug_467.py b/sources/pyside2/tests/QtWidgets/bug_467.py
new file mode 100644
index 000000000..0bc5ed80d
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_467.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 367: http://bugs.openbossa.org/show_bug.cgi?id=467'''
+
+import unittest
+from helper import UsesQApplication
+from PySide2.QtWidgets import QMainWindow, QApplication
+
+class MyWidget(QMainWindow):
+ def __init__(self, parent = None):
+ QMainWindow.__init__(self, parent)
+
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ w = MyWidget()
+ widgets = QApplication.allWidgets()
+ self.assertTrue(w in widgets)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_493.py b/sources/pyside2/tests/QtWidgets/bug_493.py
new file mode 100644
index 000000000..5372e28b7
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_493.py
@@ -0,0 +1,51 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import Qt, QEvent
+from PySide2.QtGui import QKeyEvent, QKeySequence
+from PySide2.QtWidgets import QApplication
+import unittest
+
+
+class TestBug569(unittest.TestCase):
+
+ def testIt(self):
+ # We need a qapp otherwise Qt will crash when trying to detect the
+ # current platform
+ app = QApplication([])
+ ev1 = QKeyEvent(QEvent.KeyRelease, Qt.Key_Delete, Qt.NoModifier)
+ ev2 = QKeyEvent(QEvent.KeyRelease, Qt.Key_Copy, Qt.NoModifier)
+ ks = QKeySequence.Delete
+
+ self.assertEqual(ev1, ks)
+ self.assertEqual(ks, ev1)
+ self.assertNotEqual(ev2, ks)
+ self.assertNotEqual(ks, ev2)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_512.py b/sources/pyside2/tests/QtWidgets/bug_512.py
new file mode 100644
index 000000000..37b68c551
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_512.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 512: http://bugs.openbossa.org/show_bug.cgi?id=512'''
+
+import unittest
+from helper import UsesQApplication
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ w = QWidget(None)
+ lbl = QLabel("Hello", w);
+ g = QGridLayout()
+ g.addWidget(lbl, 0, 0)
+ w.setLayout(g)
+ w.show()
+
+ t = g.getItemPosition(0)
+ self.assertEqual(type(t), tuple)
+ self.assertEqual(t, (0,0,1,1))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_525.py b/sources/pyside2/tests/QtWidgets/bug_525.py
new file mode 100644
index 000000000..2a999a3fc
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_525.py
@@ -0,0 +1,49 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtWidgets import QApplication
+from PySide2.QtWidgets import QMenu
+
+class M2(QMenu):
+ def __init__(self,parent=None):
+ super(M2,self).__init__(parent)
+ self.setTitle(self.tr("M2"))
+
+class TestMenuDerivedClass(unittest.TestCase):
+ def aboutToShowHandler(self):
+ pass
+
+ def testConnectSignal(self):
+ app = QApplication([])
+ m2 = M2()
+ # Test if the aboutToShow signal was translated to correct type
+ m2.aboutToShow.connect(self.aboutToShowHandler)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_546.py b/sources/pyside2/tests/QtWidgets/bug_546.py
new file mode 100644
index 000000000..bfcf503e6
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_546.py
@@ -0,0 +1,42 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtWidgets import *
+
+class TestBug546(unittest.TestCase):
+
+ """Test to check a crash at exit"""
+ def testIt(self):
+ app = QApplication([])
+ textEdit = QPlainTextEdit()
+ completer = QCompleter(("foo", "bar"), textEdit)
+ completer.setWidget(textEdit)
+
+if __name__=='__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_547.py b/sources/pyside2/tests/QtWidgets/bug_547.py
new file mode 100644
index 000000000..9b348b61f
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_547.py
@@ -0,0 +1,85 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+""" Unittest for bug #547 """
+""" http://bugs.openbossa.org/show_bug.cgi?id=547 """
+
+import sys
+import unittest
+
+from PySide2 import QtWidgets
+
+class MyMainWindow(unittest.TestCase):
+ app = QtWidgets.QApplication(sys.argv)
+ def testCase1(self):
+ self._tree = QtWidgets.QTreeWidget()
+ self._tree.setColumnCount(2)
+ self._i1 = None
+ self._i11 = None
+
+ self._updateTree()
+ self.assertEqual(sys.getrefcount(self._i1), 3)
+ self.assertEqual(sys.getrefcount(self._i11), 3)
+
+ self._i11.parent().setExpanded(True)
+ self._i11.setExpanded(True)
+
+ self._updateTree()
+ self.assertEqual(sys.getrefcount(self._i1), 3)
+ self.assertEqual(sys.getrefcount(self._i11), 3)
+
+ def testCase2(self):
+ self._tree = QtWidgets.QTreeWidget()
+ self._tree.setColumnCount(2)
+ self._i1 = None
+ self._i11 = None
+
+ self._updateTree()
+ self.assertEqual(sys.getrefcount(self._i1), 3)
+ self.assertEqual(sys.getrefcount(self._i11), 3)
+
+ self._i11.parent().setExpanded(True)
+ self._i11.setExpanded(True)
+
+ self.assertEqual(sys.getrefcount(self._i1), 3)
+ self.assertEqual(sys.getrefcount(self._i11), 3)
+
+ def _updateTree(self):
+ self._tree.clear()
+ if self._i1 and self._i11:
+ self.assertEqual(sys.getrefcount(self._i1), 2)
+ self.assertEqual(sys.getrefcount(self._i11), 2)
+
+ self._i1 = QtWidgets.QTreeWidgetItem(self._tree, ['1', ])
+ self.assertEqual(sys.getrefcount(self._i1), 3)
+ self._i11 = QtWidgets.QTreeWidgetItem(self._i1, ['11', ])
+ self.assertEqual(sys.getrefcount(self._i11), 3)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_549.py b/sources/pyside2/tests/QtWidgets/bug_549.py
new file mode 100644
index 000000000..24159dbc5
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_549.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtWidgets import *
+
+class TestBug549(unittest.TestCase):
+ def testBug(self):
+ app = QApplication([])
+ w = QGraphicsWidget()
+ w.setContentsMargins(1, 2, 3, 4)
+ self.assertEqual(w.getContentsMargins(), (1, 2, 3, 4))
+ w.setWindowFrameMargins(5, 6, 7, 8)
+ self.assertEqual(w.getWindowFrameMargins(), (5, 6, 7, 8))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_569.py b/sources/pyside2/tests/QtWidgets/bug_569.py
new file mode 100644
index 000000000..05a964c18
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_569.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+import unittest
+
+
+class TestBug569(unittest.TestCase):
+
+ def testIt(self):
+ types = (QTableWidgetItem, QListWidgetItem, QTreeWidgetItem)
+ for t in types:
+ a = t()
+ a.__lt__ = lambda other : True
+ b = t()
+ b.__lt__ = lambda other : False
+ self.assertTrue(a < b)
+ self.assertFalse(b < a)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_575.py b/sources/pyside2/tests/QtWidgets/bug_575.py
new file mode 100644
index 000000000..9b0e00e1c
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_575.py
@@ -0,0 +1,48 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+""" Unittest for bug #575 """
+""" http://bugs.openbossa.org/show_bug.cgi?id=575 """
+
+from PySide2.QtWidgets import QApplication, QPlainTextEdit, QTextEdit
+import sys
+import unittest
+
+class Bug575(unittest.TestCase):
+ def testPropertyValues(self):
+ app = QApplication(sys.argv)
+ textEdit = QPlainTextEdit()
+ textEdit.insertPlainText("PySide INdT")
+ selection = QTextEdit.ExtraSelection()
+ selection.cursor = textEdit.textCursor()
+ selection.cursor.setPosition(2)
+ self.assertEqual(selection.cursor.position(), 2)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_576.py b/sources/pyside2/tests/QtWidgets/bug_576.py
new file mode 100644
index 000000000..eefb2cb52
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_576.py
@@ -0,0 +1,62 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+""" Unittest for bug #576 """
+""" http://bugs.openbossa.org/show_bug.cgi?id=576 """
+
+import sys
+import unittest
+
+from PySide2 import QtCore, QtWidgets
+
+class Bug576(unittest.TestCase):
+ def onButtonDestroyed(self, button):
+ self._destroyed = True
+ self.assertTrue(isinstance(button, QtWidgets.QPushButton))
+
+ def testWidgetParent(self):
+ self._destroyed = False
+ app = QtWidgets.QApplication(sys.argv)
+ w = QtWidgets.QWidget()
+
+ b = QtWidgets.QPushButton("test")
+ b.destroyed[QtCore.QObject].connect(self.onButtonDestroyed)
+ self.assertEqual(sys.getrefcount(b), 2)
+ b.setParent(w)
+ self.assertEqual(sys.getrefcount(b), 3)
+ b.parent()
+ self.assertEqual(sys.getrefcount(b), 3)
+ b.setParent(None)
+ self.assertEqual(sys.getrefcount(b), 2)
+ del b
+ self.assertTrue(self._destroyed)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_585.py b/sources/pyside2/tests/QtWidgets/bug_585.py
new file mode 100644
index 000000000..1232d6c0b
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_585.py
@@ -0,0 +1,54 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test bug 585: http://bugs.openbossa.org/show_bug.cgi?id=585'''
+
+import sys
+import unittest
+
+from PySide2 import QtCore, QtWidgets
+
+class Bug585(unittest.TestCase):
+ def testCase(self):
+ app = QtWidgets.QApplication([])
+ self._tree = QtWidgets.QTreeWidget()
+ self._tree.setColumnCount(2)
+ i1 = QtWidgets.QTreeWidgetItem(self._tree, ['1', ])
+ i2 = QtWidgets.QTreeWidgetItem(self._tree, ['2', ])
+ refCount = sys.getrefcount(i1)
+
+ # this function return None
+ # because the topLevelItem does not has a parent item
+ # but still have a TreeWidget as a parent
+ self._tree.topLevelItem(0).parent()
+
+ self.assertEqual(refCount, sys.getrefcount(i1))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_589.py b/sources/pyside2/tests/QtWidgets/bug_589.py
new file mode 100644
index 000000000..25ba10d71
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_589.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# trimmed down diagramscene.py to demonstrate crash in sizeHint()
+
+import sys
+from PySide2 import QtCore, QtWidgets
+import unittest
+
+class CustomWidget(QtWidgets.QGraphicsProxyWidget):
+ def itemChange(self, eventType, value):
+ QtWidgets.QGraphicsProxyWidget.itemChange(self, eventType, value)
+
+class Bug589(unittest.TestCase):
+ def testCase(self):
+ widget = QtWidgets.QGraphicsProxyWidget()
+ custom = CustomWidget()
+ custom.setParentItem(widget)
+
+if __name__ == "__main__":
+ app = QtWidgets.QApplication(sys.argv)
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_632.py b/sources/pyside2/tests/QtWidgets/bug_632.py
new file mode 100644
index 000000000..fa8063412
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_632.py
@@ -0,0 +1,48 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+from PySide2.QtWidgets import QLineEdit, QApplication
+import unittest
+
+
+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_635.py b/sources/pyside2/tests/QtWidgets/bug_635.py
new file mode 100644
index 000000000..f23241d30
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_635.py
@@ -0,0 +1,57 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 635: http://bugs.openbossa.org/show_bug.cgi?id=635'''
+
+import unittest
+from PySide2.QtGui import QIcon
+from PySide2.QtWidgets import QApplication, QToolBar
+import sys
+
+class testQToolBar(unittest.TestCase):
+ def callback(self):
+ self._called = True
+
+ def testAddAction(self):
+ bar = QToolBar()
+ self._called = False
+ a = bar.addAction("act1", self.callback)
+ a.trigger()
+ self.assertTrue(self._called)
+
+ def testAddActionWithIcon(self):
+ bar = QToolBar()
+ self._called = False
+ icon = QIcon()
+ a = bar.addAction(icon, "act1", self.callback)
+ a.trigger()
+ self.assertTrue(self._called)
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_640.py b/sources/pyside2/tests/QtWidgets/bug_640.py
new file mode 100644
index 000000000..b9a9a0e8b
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_640.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+from PySide2.QtWidgets import *
+import unittest
+
+class Bug640(unittest.TestCase):
+ def testIt(self):
+ option = QStyleOptionGraphicsItem()
+ a = option.state # crash!?
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_653.py b/sources/pyside2/tests/QtWidgets/bug_653.py
new file mode 100644
index 000000000..ba7178b98
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_653.py
@@ -0,0 +1,45 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+class TestBug653(unittest.TestCase):
+ """Crash after calling QWizardPage.wizard()"""
+ def testIt(self):
+ app = QApplication([])
+
+ wizard = QWizard()
+ page = QWizardPage()
+ wizard.addPage(page)
+ page.wizard() # crash here if the bug still exists due to a circular dependency
+ wizard.show()
+
+if __name__ == "__main__":
+ unittest.main() \ No newline at end of file
diff --git a/sources/pyside2/tests/QtWidgets/bug_662.py b/sources/pyside2/tests/QtWidgets/bug_662.py
new file mode 100644
index 000000000..369bccfeb
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_662.py
@@ -0,0 +1,57 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 662: http://bugs.openbossa.org/show_bug.cgi?id=662'''
+
+import unittest
+from PySide2.QtGui import QTextCharFormat
+from PySide2.QtWidgets import QTextEdit, QApplication
+import sys
+
+class testQTextBlock(unittest.TestCase):
+ def tesIterator(self):
+ edit = QTextEdit()
+ cursor = edit.textCursor()
+ fmt = QTextCharFormat()
+ frags = []
+ for i in range(10):
+ fmt.setFontPointSize(i+10)
+ frags.append("block%d"%i)
+ cursor.insertText(frags[i], fmt)
+
+ doc = edit.document()
+ block = doc.begin()
+
+ index = 0
+ for i in block:
+ self.assertEqual(i.fragment().text(), frags[index])
+ index += 1
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_667.py b/sources/pyside2/tests/QtWidgets/bug_667.py
new file mode 100644
index 000000000..ad91b5a78
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_667.py
@@ -0,0 +1,53 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+
+from PySide2.QtCore import QTimer, QPointF
+from PySide2.QtWidgets import QApplication, QGraphicsView, QGraphicsScene, QGraphicsEllipseItem
+
+class Ball(QGraphicsEllipseItem):
+ def __init__(self, d, parent=None):
+ super(Ball, self).__init__(0, 0, d, d, parent)
+ self.vel = QPointF(0,0) #commenting this out prevents the crash
+
+class Foo(QGraphicsView):
+ def __init__(self):
+ super(Foo, self).__init__(None)
+ self.scene = QGraphicsScene(self.rect())
+ self.setScene(self.scene)
+ self.scene.addItem(Ball(10))
+
+
+if __name__ == "__main__":
+ app = QApplication(sys.argv)
+ w = Foo()
+ w.show()
+ w.raise_()
+ QTimer.singleShot(0, w.close)
+ sys.exit(app.exec_())
diff --git a/sources/pyside2/tests/QtWidgets/bug_668.py b/sources/pyside2/tests/QtWidgets/bug_668.py
new file mode 100644
index 000000000..02036fae4
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_668.py
@@ -0,0 +1,50 @@
+# 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+import sys
+
+class A(QMainWindow):
+ def __init__(self, parent=None):
+ super(A, self).__init__(parent)
+ a = QFileSystemModel(self)
+ a.setRootPath(QDir.homePath())
+
+ v = QTreeView(self)
+ v.setModel(a)
+ self.setCentralWidget(v)
+
+app = QApplication([])
+m = A()
+m.show()
+QTimer.singleShot(0, m.close)
+app.exec_()
diff --git a/sources/pyside2/tests/QtWidgets/bug_674.py b/sources/pyside2/tests/QtWidgets/bug_674.py
new file mode 100644
index 000000000..c26bd7eee
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_674.py
@@ -0,0 +1,51 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+import unittest
+import sys
+
+class TestBug679(unittest.TestCase):
+ '''QGraphicsScene::clear() is missing'''
+ def testIt(self):
+ app = QApplication([])
+
+ scene = QGraphicsScene()
+ hello = scene.addText("Hello")
+ scene.addText("World")
+
+ self.assertEqual(sys.getrefcount(hello), 3)
+ scene.clear()
+ self.assertEqual(sys.getrefcount(hello), 2)
+ self.assertEqual(len(scene.items()), 0)
+ self.assertRaises(RuntimeError, hello.isVisible) # the C++ object was deleted
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_675.py b/sources/pyside2/tests/QtWidgets/bug_675.py
new file mode 100644
index 000000000..9e1358a8c
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_675.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+app = QApplication([])
+
+scene = QGraphicsScene()
+
+# don't segfault due to lack of keepReferenceCall
+textEdit = scene.addWidget(QTextEdit())
+
+layout = QGraphicsLinearLayout()
+layout.addItem(textEdit)
+
+view = QGraphicsView(scene)
+view.show()
diff --git a/sources/pyside2/tests/QtWidgets/bug_688.py b/sources/pyside2/tests/QtWidgets/bug_688.py
new file mode 100644
index 000000000..d622b33be
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_688.py
@@ -0,0 +1,116 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test bug 688: http://bugs.openbossa.org/show_bug.cgi?id=688'''
+
+import unittest
+from helper import UsesQApplication
+from PySide2.QtGui import QTextFrame, QTextCursor, QTextCharFormat, QFont, QTextFrameFormat
+from PySide2.QtWidgets import QTextEdit
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ editor = QTextEdit()
+ cursor = QTextCursor(editor.textCursor())
+ cursor.movePosition(QTextCursor.Start)
+
+ mainFrame = cursor.currentFrame()
+
+ plainCharFormat = QTextCharFormat()
+ boldCharFormat = QTextCharFormat()
+ boldCharFormat.setFontWeight(QFont.Bold);
+ cursor.insertText("""
+ Text documents are represented by the
+ QTextDocument class, rather than by QString objects.
+ Each QTextDocument object contains information about
+ the document's internal representation, its structure,
+ and keeps track of modifications to provide undo/redo
+ facilities. This approach allows features such as the
+ layout management to be delegated to specialized
+ classes, but also provides a focus for the framework.""",
+ plainCharFormat)
+
+ frameFormat = QTextFrameFormat()
+ frameFormat.setMargin(32)
+ frameFormat.setPadding(8)
+ frameFormat.setBorder(4)
+ cursor.insertFrame(frameFormat)
+
+ cursor.insertText("""
+ Documents are either converted from external sources
+ or created from scratch using Qt. The creation process
+ can done by an editor widget, such as QTextEdit, or by
+ explicit calls to the Scribe API.""",
+ boldCharFormat)
+
+ cursor = mainFrame.lastCursorPosition()
+ cursor.insertText("""
+ There are two complementary ways to visualize the
+ contents of a document: as a linear buffer that is
+ used by editors to modify the contents, and as an
+ object hierarchy containing structural information
+ that is useful to layout engines. In the hierarchical
+ model, the objects generally correspond to visual
+ elements such as frames, tables, and lists. At a lower
+ level, these elements describe properties such as the
+ style of text used and its alignment. The linear
+ representation of the document is used for editing and
+ manipulation of the document's contents.""",
+ plainCharFormat)
+
+
+ frame = cursor.currentFrame()
+
+ items = []
+
+ #test iterator
+ for i in frame:
+ items.append(i)
+
+ #test __iadd__
+ b = frame.begin()
+ i = 0
+ while not b.atEnd():
+ self.assertEqual(b, items[i])
+ self.assertTrue(b.parentFrame(), items[i].parentFrame())
+ b.__iadd__(1)
+ i += 1
+
+ #test __isub__
+ b = frame.end()
+ i = 0
+ while i > 0:
+ self.assertEqual(b, items[i])
+ self.assertTrue(b.parentFrame(), items[i].parentFrame())
+ b.__isub__(1)
+ i -= 1
+
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_693.py b/sources/pyside2/tests/QtWidgets/bug_693.py
new file mode 100644
index 000000000..eecc6b62b
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_693.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+import unittest
+
+class MyModel (QAbstractListModel):
+
+ stupidLine = QLine(0, 0, 10, 10)
+
+ def rowCount(self, parent):
+ return 1
+
+ def data(self, index, role):
+ return self.stupidLine
+
+class TestBug693(unittest.TestCase):
+ def testIt(self):
+ app = QApplication([])
+ model = MyModel()
+ view = QListView()
+ view.setModel(model)
+ view.show()
+
+ # This must NOT throw the exception:
+ # RuntimeError: Internal C++ object (PySide2.QtCore.QLine) already deleted.
+ MyModel.stupidLine.isNull()
+
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_696.py b/sources/pyside2/tests/QtWidgets/bug_696.py
new file mode 100644
index 000000000..60f6f2166
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_696.py
@@ -0,0 +1,55 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import unittest
+
+from helper import UsesQApplication
+from PySide2.QtWidgets import QMainWindow, QMenu, QApplication
+
+class MainWindow(QMainWindow):
+ def __init__(self, *args):
+ self._menu = QMenu(self.dontexist) # attribute called with invalid C++ object
+
+class MainWindow2(QMainWindow):
+ def __init__(self):
+ self.show()
+
+class Bug696(UsesQApplication):
+ def testContructorInitialization(self):
+ self.assertRaises(AttributeError, MainWindow)
+
+ def testContructorInitializationAndCPPFunction(self):
+ self.assertRaises(RuntimeError, MainWindow2)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_711.py b/sources/pyside2/tests/QtWidgets/bug_711.py
new file mode 100644
index 000000000..c56081f9b
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_711.py
@@ -0,0 +1,53 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtWidgets import QToolBar, QApplication, QAction, QToolButton
+
+try:
+ xrange
+except NameError:
+ xrange = range # py3k
+
+class TestLabelPixmap(unittest.TestCase):
+ def testReference(self):
+ toolbar = QToolBar()
+
+ for i in xrange(20):
+ toolbar.addAction(QAction("Action %d" % i, None))
+
+ buttons = toolbar.findChildren(QToolButton, "")
+ toolbar.clear()
+
+ for b in buttons:
+ self.assertRaises(RuntimeError, b.objectName)
+
+if __name__ == '__main__':
+ app = QApplication([])
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_714.py b/sources/pyside2/tests/QtWidgets/bug_714.py
new file mode 100644
index 000000000..6fef26d33
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_714.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+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 increment the reference because this is an internal pointer
+ self.assertEqual(sys.getrefcount(p), 3)
+
+ p2 = l.pixmap()
+ self.assertEqual(p, p2)
+
+if __name__ == '__main__':
+ app = QApplication([])
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_722.py b/sources/pyside2/tests/QtWidgets/bug_722.py
new file mode 100644
index 000000000..20087a088
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_722.py
@@ -0,0 +1,52 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import UsesQApplication
+
+from PySide2.QtWidgets import QDoubleSpinBox, QGraphicsBlurEffect
+
+class TestSignalConnection(UsesQApplication):
+ def testFloatSignal(self):
+ foo1 = QDoubleSpinBox()
+ foo2 = QDoubleSpinBox()
+ foo1.valueChanged[float].connect(foo2.setValue)
+ foo2.valueChanged[float].connect(foo1.setValue)
+ foo1.setValue(0.42)
+ self.assertEqual(foo1.value(), foo2.value())
+
+ def testQRealSignal(self):
+ foo1 = QDoubleSpinBox()
+ effect = QGraphicsBlurEffect()
+ effect.blurRadiusChanged['qreal'].connect(foo1.setValue) # check if qreal is a valid type
+ effect.setBlurRadius(0.42)
+ self.assertAlmostEqual(foo1.value(), effect.blurRadius())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_728.py b/sources/pyside2/tests/QtWidgets/bug_728.py
new file mode 100644
index 000000000..8ef40b374
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_728.py
@@ -0,0 +1,36 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtWidgets import *
+from PySide2.QtCore import *
+
+app = QApplication([])
+QTimer.singleShot(200, app.quit)
+
+# This test for a dead lock in QFileDialog.getOpenFileNames, the test fail with a timeout if the dead lock exists.
+QFileDialog.getOpenFileNames(None, "caption", QDir.homePath(), None, "", QFileDialog.DontUseNativeDialog)
diff --git a/sources/pyside2/tests/QtWidgets/bug_736.py b/sources/pyside2/tests/QtWidgets/bug_736.py
new file mode 100644
index 000000000..2fe80f801
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_736.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+class TestBug736 (unittest.TestCase):
+
+ def testIt(self):
+ app = QApplication([])
+ slider = QSlider(Qt.Horizontal)
+ slider2 = QSlider(Qt.Horizontal)
+
+ slider2.setMaximum(10)
+ slider.valueChanged[int].connect(slider2.setMaximum)
+ slider.valueChanged[int].emit(100)
+ self.assertEqual(slider2.maximum(), 100)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_750.py b/sources/pyside2/tests/QtWidgets/bug_750.py
new file mode 100644
index 000000000..055e982a8
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_750.py
@@ -0,0 +1,54 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import UsesQApplication
+
+from PySide2.QtCore import QTimer
+from PySide2.QtGui import QPainter, QFont, QFontInfo
+from PySide2.QtWidgets import QWidget, qApp
+
+class MyWidget(QWidget):
+ def paintEvent(self, e):
+ p = QPainter(self)
+ self._info = p.fontInfo()
+ self._app.quit()
+
+
+class TestQPainter(UsesQApplication):
+ def testFontInfo(self):
+ w = MyWidget()
+ w._app = self.app
+ w._info = None
+ QTimer.singleShot(300, w.show)
+ self.app.exec_()
+ self.assertTrue(w._info)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_778.py b/sources/pyside2/tests/QtWidgets/bug_778.py
new file mode 100644
index 000000000..270b1a48a
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_778.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import UsesQApplication
+
+from PySide2.QtWidgets import QTreeWidget, QTreeWidgetItem, QTreeWidgetItemIterator
+
+class QTreeWidgetItemIteratorTest(UsesQApplication):
+ def testWidgetIterator(self):
+ treeWidget = QTreeWidget()
+ treeWidget.setColumnCount(1)
+ items = []
+ for i in range(10):
+ items.append(QTreeWidgetItem(None, ['item: %d' % i]))
+ treeWidget.insertTopLevelItems(0, items)
+
+ index = 0
+ for it in QTreeWidgetItemIterator(treeWidget):
+ self.assertEqual(it.value().text(0), 'item: %d' % index)
+ index += 1
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_785.py b/sources/pyside2/tests/QtWidgets/bug_785.py
new file mode 100644
index 000000000..ccd8dfddc
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_785.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+
+import unittest
+from PySide2.QtCore import QItemSelection
+from PySide2.QtGui import QStandardItemModel, QStandardItem
+from PySide2.QtWidgets import QApplication
+class Bug324(unittest.TestCase):
+ def testOperators(self):
+ model = QStandardItemModel()
+ for i in range(100):
+ model.appendRow(QStandardItem("Item: %d"%i))
+
+ first = model.index(0, 0)
+ second = model.index(10, 0)
+ third = model.index(20, 0)
+ fourth = model.index(30, 0)
+
+ sel = QItemSelection(first, second)
+ sel2 = QItemSelection()
+ sel2.select(third, fourth)
+
+ sel3 = sel + sel2 #check operator +
+ self.assertEqual(len(sel3), 2)
+ sel4 = sel
+ sel4 += sel2 #check operator +=
+ self.assertEqual(len(sel4), 2)
+ self.assertEqual(sel4, sel3)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_793.py b/sources/pyside2/tests/QtWidgets/bug_793.py
new file mode 100644
index 000000000..89dc4408c
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_793.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+from PySide2.QtCore import QTimer
+from PySide2.QtWidgets import QWidget, QApplication
+
+class TestW1(QWidget):
+ def __init__(self, parent = None):
+ super(TestW1, self).__init__(parent)
+ TestW2(parent, self)
+
+class TestW2(QWidget):
+ def __init__(self, ancestor, parent = None):
+ super(TestW2, self).__init__(parent)
+ self.ancestor_ref = ancestor
+
+class Test(QWidget):
+ def __init__(self):
+ super(Test, self).__init__()
+ TestW1(self)
+
+class TestQApplicationDestrcutor(unittest.TestCase):
+ def testDestructor(self):
+ w = Test()
+ w.show()
+ QTimer.singleShot(0, w.close)
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ unittest.main()
+ sys.exit(app.exec_())
diff --git a/sources/pyside2/tests/QtWidgets/bug_811.py b/sources/pyside2/tests/QtWidgets/bug_811.py
new file mode 100644
index 000000000..d219ec6c3
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_811.py
@@ -0,0 +1,61 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+import weakref
+
+from helper import UsesQApplication
+
+from PySide2.QtGui import QTextBlockUserData, QTextCursor
+from PySide2.QtWidgets import QTextEdit
+
+class TestUserData(QTextBlockUserData):
+ def __init__(self, data):
+ super(TestUserData, self).__init__()
+ self.data = data
+
+class TestUserDataRefCount(UsesQApplication):
+ def testRefcount(self):
+ textedit = QTextEdit()
+ textedit.setReadOnly(True)
+ doc = textedit.document()
+ cursor = QTextCursor(doc)
+ cursor.insertText("PySide Rocks")
+ ud = TestUserData({"Life": 42})
+ self.assertEqual(sys.getrefcount(ud), 2)
+ cursor.block().setUserData(ud)
+ self.assertEqual(sys.getrefcount(ud), 3)
+ ud2 = cursor.block().userData()
+ self.assertEqual(sys.getrefcount(ud), 4)
+ self.udata = weakref.ref(ud, None)
+ del ud, ud2
+ self.assertEqual(sys.getrefcount(self.udata()), 2)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_834.py b/sources/pyside2/tests/QtWidgets/bug_834.py
new file mode 100644
index 000000000..00fe06510
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_834.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2 import QtCore, QtWidgets
+
+class Window(QtWidgets.QMainWindow):
+ def childEvent(self, event):
+ super(Window, self).childEvent(event)
+
+app = QtWidgets.QApplication([])
+window = Window()
+
+dock1 = QtWidgets.QDockWidget()
+dock2 = QtWidgets.QDockWidget()
+window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock1)
+window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock2)
+window.tabifyDockWidget(dock1, dock2)
+
+window.show()
+QtCore.QTimer.singleShot(0, window.close)
+app.exec_()
diff --git a/sources/pyside2/tests/QtWidgets/bug_836.py b/sources/pyside2/tests/QtWidgets/bug_836.py
new file mode 100644
index 000000000..5aeb94659
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_836.py
@@ -0,0 +1,56 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+class Mixin1(object):
+ pass
+
+class Mixin2(object):
+ pass
+
+class Mixin3(object):
+ pass
+
+class MainWindow(Mixin1, Mixin2, Mixin3, QFrame):
+ def __init__(self):
+ super(MainWindow, self).__init__()
+
+def main():
+ app = QApplication([])
+ # if it doesn't crash it should pass
+ w = MainWindow()
+ w.show()
+ QTimer.singleShot(0, w.close)
+ app.exec_()
+
+if __name__ == "__main__":
+ main()
+
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_844.py b/sources/pyside2/tests/QtWidgets/bug_844.py
new file mode 100644
index 000000000..991abbd13
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_844.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtWidgets import *
+from PySide2.QtCore import *
+
+class QtKeyPressListener(QObject):
+ def __init__(self, obj):
+ QObject.__init__(self)
+ obj.installEventFilter(self)
+
+ def eventFilter(self, obj, event):
+ # This used to crash here due to a misbehaviour of type discovery!
+ return QObject.eventFilter(self, obj, event)
+
+app = QApplication([])
+key_listener = QtKeyPressListener(app)
+w = QLabel('Hello')
+w.show()
+QTimer.singleShot(0, w.close)
+app.exec_()
diff --git a/sources/pyside2/tests/QtWidgets/bug_854.py b/sources/pyside2/tests/QtWidgets/bug_854.py
new file mode 100644
index 000000000..47c368259
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_854.py
@@ -0,0 +1,68 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtWidgets import QTableView, QVBoxLayout, QApplication
+from PySide2.QtCore import QAbstractItemModel
+
+from helper import UsesQApplication
+import unittest
+
+
+class VirtualList(QAbstractItemModel):
+ def __getitem__(self, index):
+ self._getItemCalled = True
+ pass
+
+ def rowCount(self, parent):
+ return 5000
+
+ def columnCount(self, parent):
+ return 3
+
+ def index(self, row, column, parent):
+ return self.createIndex(row, column)
+
+ def parent(self, index):
+ return QModelIndex()
+
+ def data(self, index, role):
+ return "(%i, %i)" % (index.row(), index.column())
+
+
+class TestQAbstractItemModel(UsesQApplication):
+ def testSetModel(self):
+ model = VirtualList()
+ model._getItemCalled = False
+ table = QTableView()
+ table.setModel(model)
+ table.show()
+ self.assertFalse(model._getItemCalled)
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_860.py b/sources/pyside2/tests/QtWidgets/bug_860.py
new file mode 100644
index 000000000..f961a8ff2
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_860.py
@@ -0,0 +1,63 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import unittest
+
+from PySide2.QtCore import QSignalMapper
+from PySide2.QtWidgets import QCheckBox
+
+from helper import UsesQApplication
+
+class MultipleSlotTest(UsesQApplication):
+ def cb_changed(self, i):
+ self._changed = True
+
+ def cb_changedVoid(self):
+ self._changed = True
+
+ def testSignalMapper(self):
+ checkboxMapper = QSignalMapper()
+ box = QCheckBox('check me')
+ box.stateChanged.connect(checkboxMapper.map)
+
+ checkboxMapper.setMapping(box, box.text())
+ checkboxMapper.mapped[str].connect(self.cb_changed)
+ self._changed = False
+ box.setChecked(True)
+ self.assertTrue(self._changed)
+
+ def testSimpleSignal(self):
+ box = QCheckBox('check me')
+ box.stateChanged[int].connect(self.cb_changedVoid)
+ self._changed = False
+ box.setChecked(True)
+ self.assertTrue(self._changed)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_862.py b/sources/pyside2/tests/QtWidgets/bug_862.py
new file mode 100644
index 000000000..fc164bcc4
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_862.py
@@ -0,0 +1,67 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import QObject
+from PySide2.QtWidgets import *
+import PySide2.QtCore
+import unittest
+
+class MyQObject(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+
+class MyQWidget(QWidget):
+ def __init__(self):
+ QWidget.__init__(self)
+
+class MyQGraphicsObject(QGraphicsObject):
+ def __init__(self):
+ QGraphicsObject.__init__(self)
+
+class MyQGraphicsItem(QGraphicsItem):
+ def __init__(self):
+ QGraphicsItem.__init__(self)
+
+class TestRepr (unittest.TestCase):
+
+ def testIt(self):
+
+ app = QApplication([])
+
+ self.assertEqual("<__main__.MyQObject object at ", repr(MyQObject())[:30])
+ self.assertEqual("<__main__.MyQWidget object at ", repr(MyQWidget())[:30])
+ self.assertEqual("<__main__.MyQGraphicsObject(0x", repr(MyQGraphicsObject())[:30])
+ self.assertEqual("<__main__.MyQGraphicsItem(0x", repr(MyQGraphicsItem())[:28])
+
+ self.assertEqual("<PySide2.QtCore.QObject object at ", repr(QObject())[:34])
+ self.assertEqual("<PySide2.QtCore.QObject object at ", repr(PySide2.QtCore.QObject())[:34])
+ self.assertEqual("<PySide2.QtWidgets.QWidget object at ", repr(QWidget())[:37])
+ self.assertEqual("<PySide2.QtWidgets.QGraphicsWidget(0x", repr(QGraphicsWidget())[:37])
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_871.py b/sources/pyside2/tests/QtWidgets/bug_871.py
new file mode 100644
index 000000000..a3ea007a2
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_871.py
@@ -0,0 +1,70 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from helper import UsesQApplication
+from PySide2.QtGui import QValidator, QIntValidator
+from PySide2.QtWidgets import QLineEdit
+
+'''Bug #871 - http://bugs.pyside.org/show_bug.cgi?id=871'''
+
+
+class BlankIntValidator(QIntValidator):
+ def validate(self,input,pos):
+ if input == '':
+ return QValidator.Acceptable, input, pos
+ else:
+ return QIntValidator.validate(self,input,pos)
+
+
+class Bug871Test(UsesQApplication):
+ def testWithoutValidator(self):
+ edit = QLineEdit()
+ self.assertEqual(edit.text(), '')
+ edit.insert('1')
+ self.assertEqual(edit.text(), '1')
+ edit.insert('a')
+ self.assertEqual(edit.text(), '1a')
+ edit.insert('2')
+ self.assertEqual(edit.text(), '1a2')
+
+ def testWithIntValidator(self):
+ edit = QLineEdit()
+ edit.setValidator(BlankIntValidator(edit))
+ self.assertEqual(edit.text(), '')
+ edit.insert('1')
+ self.assertEqual(edit.text(), '1')
+ edit.insert('a')
+ self.assertEqual(edit.text(), '1')
+ edit.insert('2')
+ self.assertEqual(edit.text(), '12')
+
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_879.py b/sources/pyside2/tests/QtWidgets/bug_879.py
new file mode 100644
index 000000000..2a4207aa8
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_879.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QCoreApplication, QTimer, QEvent, Qt
+from PySide2.QtWidgets import QApplication, QSpinBox
+from PySide2.QtGui import QKeyEvent
+
+class MySpinBox(QSpinBox):
+
+ def validate(self,text,pos):
+ return QSpinBox.validate(self,text,pos)
+
+class TestBug879 (unittest.TestCase):
+
+ def testIt(self):
+ app = QApplication([])
+ self.box = MySpinBox()
+ self.box.show()
+
+ QTimer.singleShot(0, self.sendKbdEvent)
+ QTimer.singleShot(100, app.quit)
+ app.exec_()
+
+ self.assertEqual(self.box.text(), '0')
+
+ def sendKbdEvent(self):
+ ev = QKeyEvent(QEvent.KeyPress, Qt.Key_A, Qt.NoModifier, 'a')
+ QCoreApplication.sendEvent(self.box, ev)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_919.py b/sources/pyside2/tests/QtWidgets/bug_919.py
new file mode 100644
index 000000000..c71fd8005
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_919.py
@@ -0,0 +1,66 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import TimedQApplication
+from PySide2.QtCore import Signal, QTimer
+from PySide2.QtGui import QPainter
+from PySide2.QtWidgets import QPushButton, QStyleOptionButton, QApplication, QStyle
+
+class MyWidget(QPushButton):
+ def __init__(self, parent = None):
+ QPushButton.__init__(self, parent)
+ self._painted = False
+
+ def _emitPainted(self):
+ self.paintReceived.emit()
+
+ def paintEvent(self, e):
+ p = QPainter(self)
+ style = QApplication.style()
+ option = QStyleOptionButton()
+ style.drawControl(QStyle.CE_PushButton, option, p)
+ self._painted = True
+ QTimer.singleShot(0, self._emitPainted)
+
+ paintReceived = Signal()
+
+class TestBug919(TimedQApplication):
+ def setUp(self):
+ TimedQApplication.setUp(self, 2000)
+
+ def testFontInfo(self):
+ w = MyWidget()
+ w.paintReceived.connect(self.app.quit)
+ w.show()
+ self.app.exec_()
+ self.assertTrue(w._painted)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_921.py b/sources/pyside2/tests/QtWidgets/bug_921.py
new file mode 100644
index 000000000..1a60b123c
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_921.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2 import QtCore, QtWidgets
+
+from helper import TimedQApplication
+
+class Signaller(QtCore.QObject):
+ s1 = QtCore.Signal()
+ s2 = QtCore.Signal()
+ s3 = QtCore.Signal()
+
+class Window(object):
+
+ def __init__(self, s):
+ self._window = QtWidgets.QMainWindow()
+ self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
+ self._window.setWindowTitle("Demo!")
+
+ self._s = s
+ self._s.s1.connect(self._on_signal)
+ self._s.s2.connect(self._on_signal)
+
+ def show(self):
+ self._window.show()
+
+ def _on_signal(self):
+ self._window.setWindowTitle("Signaled!")
+
+class TestTimedApp(TimedQApplication):
+ def testSignals(self):
+ s = Signaller()
+ w = Window(s)
+ w.show()
+
+ def midleFunction():
+ def internalFunction():
+ pass
+ s.s3.connect(internalFunction)
+
+ midleFunction()
+ self.app.exec_()
+ del w
+
+ s.s1.emit()
+ s.s2.emit()
+ s.s3.emit()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_941.py b/sources/pyside2/tests/QtWidgets/bug_941.py
new file mode 100644
index 000000000..adacd62ac
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_941.py
@@ -0,0 +1,45 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+def foo(a, b):
+ pass
+
+class TestBug941 (unittest.TestCase):
+
+ def testIt(self):
+ app = QApplication([])
+ view = QHeaderView(Qt.Horizontal)
+ self.assertTrue(view.sortIndicatorChanged.connect(foo))
+ view.sortIndicatorChanged.emit(0, Qt.Vertical) # this can't raise an exception!
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_964.py b/sources/pyside2/tests/QtWidgets/bug_964.py
new file mode 100644
index 000000000..c462d2591
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_964.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+from PySide2.QtGui import *
+from PySide2.QtWidgets import *
+
+class TestBug964 (unittest.TestCase):
+
+ def testIt(self):
+ app = QApplication([])
+ model = QStringListModel(["1", "2"])
+ view = QListView()
+ view.setModel(model)
+ view.setCurrentIndex(model.index(0,0))
+ newCursor = view.moveCursor(QAbstractItemView.MoveDown, Qt.NoModifier)
+ self.assertEqual(newCursor.row(), 1)
+ self.assertEqual(newCursor.column(), 0)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_967.py b/sources/pyside2/tests/QtWidgets/bug_967.py
new file mode 100644
index 000000000..7fa360317
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_967.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtWidgets import *
+
+class TestBug967 (unittest.TestCase):
+
+ def callback(self, arg):
+ self.arg = arg
+
+ def testIt(self):
+ self.arg = None
+ app = QApplication([])
+ obj = QComboBox()
+ obj.currentIndexChanged.connect(self.callback)
+ obj.currentIndexChanged.emit(5)
+ self.assertEqual(self.arg, 5)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_972.py b/sources/pyside2/tests/QtWidgets/bug_972.py
new file mode 100644
index 000000000..09d0bee51
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_972.py
@@ -0,0 +1,67 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QSizeF
+from PySide2.QtWidgets import QGraphicsProxyWidget, QSizePolicy, QPushButton, QGraphicsScene, QGraphicsView
+
+from helper import TimedQApplication
+
+def createItem(minimum, preferred, maximum, name):
+ w = QGraphicsProxyWidget()
+
+ w.setWidget(QPushButton(name))
+ w.setMinimumSize(minimum)
+ w.setPreferredSize(preferred)
+ w.setMaximumSize(maximum)
+ w.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
+
+ return w
+
+class TestBug972 (TimedQApplication):
+
+ # Test if the function QGraphicsProxyWidget.setWidget have the correct behavior
+ def testIt(self):
+ scene = QGraphicsScene()
+
+ minSize = QSizeF(30, 100)
+ prefSize = QSizeF(210, 100)
+ maxSize = QSizeF(300, 100)
+
+ a = createItem(minSize, prefSize, maxSize, "A")
+ b = createItem(minSize, prefSize, maxSize, "B")
+ c = createItem(minSize, prefSize, maxSize, "C")
+ d = createItem(minSize, prefSize, maxSize, "D")
+
+ view = QGraphicsView(scene)
+ view.show()
+ self.app.exec_()
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_979.py b/sources/pyside2/tests/QtWidgets/bug_979.py
new file mode 100644
index 000000000..24372fea3
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_979.py
@@ -0,0 +1,37 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtWidgets import QDialog
+from import_test import PysideImportTest2
+
+class PysideImportTest1(QDialog, PysideImportTest2):
+ pass
+
+if __name__ == '__main__':
+ quit()
+
diff --git a/sources/pyside2/tests/QtWidgets/bug_988.py b/sources/pyside2/tests/QtWidgets/bug_988.py
new file mode 100644
index 000000000..613c4df5e
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_988.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtWidgets import *
+
+class TestBug988 (unittest.TestCase):
+
+ def callback(self, arg):
+ self.arg = arg
+
+ def testIt(self):
+ self.arg = None
+ app = QApplication([])
+ obj = QTabWidget()
+ obj.currentChanged.connect(self.callback)
+ obj.currentChanged.emit(5)
+ self.assertEqual(self.arg, 5)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/bug_998.py b/sources/pyside2/tests/QtWidgets/bug_998.py
new file mode 100644
index 000000000..104a726af
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/bug_998.py
@@ -0,0 +1,38 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtWidgets import QApplication
+
+class TestBug998 (unittest.TestCase):
+ def testNoFocusWindow(self):
+ widget = QApplication.focusWidget()
+ self.assertTrue(widget == None)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/customproxywidget_test.py b/sources/pyside2/tests/QtWidgets/customproxywidget_test.py
new file mode 100644
index 000000000..3f4811a21
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/customproxywidget_test.py
@@ -0,0 +1,62 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import UsesQApplication
+from PySide2.QtCore import Qt, QTimer
+from PySide2.QtGui import QPainter
+from PySide2.QtWidgets import QLabel
+from PySide2.QtWidgets import QGraphicsScene, QGraphicsView, QGraphicsItem, QGraphicsProxyWidget
+
+class CustomProxy(QGraphicsProxyWidget):
+ def __init__(self, parent=None, wFlags=0):
+ QGraphicsProxyWidget.__init__(self, parent, wFlags)
+
+class CustomProxyWidgetTest(UsesQApplication):
+ def testCustomProxyWidget(self):
+ scene = QGraphicsScene()
+
+ proxy = CustomProxy(None, Qt.Window)
+ widget = QLabel('Widget')
+ proxy.setWidget(widget)
+ proxy.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
+ scene.addItem(proxy)
+ scene.setSceneRect(scene.itemsBoundingRect())
+
+ view = QGraphicsView(scene)
+ view.setRenderHints(QPainter.Antialiasing|QPainter.SmoothPixmapTransform)
+ view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
+ view.show()
+
+ timer = QTimer.singleShot(100, self.app.quit)
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/event_filter_test.py b/sources/pyside2/tests/QtWidgets/event_filter_test.py
new file mode 100644
index 000000000..e7e525640
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/event_filter_test.py
@@ -0,0 +1,67 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+
+from helper import UsesQApplication
+from PySide2.QtCore import QObject, QEvent
+from PySide2.QtWidgets import QWidget
+
+class MyFilter(QObject):
+ def eventFilter(self, obj, event):
+ if event.type() == QEvent.KeyPress:
+ pass
+ return QObject.eventFilter(self, obj, event)
+
+
+class EventFilter(UsesQApplication):
+ def testRefCount(self):
+ o = QObject()
+ filt = MyFilter()
+ o.installEventFilter(filt)
+ self.assertEqual(sys.getrefcount(o), 2)
+
+ o.installEventFilter(filt)
+ self.assertEqual(sys.getrefcount(o), 2)
+
+ o.removeEventFilter(filt)
+ self.assertEqual(sys.getrefcount(o), 2)
+
+ def testObjectDestructorOrder(self):
+ w = QWidget()
+ filt = MyFilter()
+ filt.app = self.app
+ w.installEventFilter(filt)
+ w.show()
+ w.close()
+ w = None
+ self.assertTrue(True)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/grandparent_method_test.py b/sources/pyside2/tests/QtWidgets/grandparent_method_test.py
new file mode 100644
index 000000000..cbd561f58
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/grandparent_method_test.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests for calling methods further than the direct parent'''
+
+import unittest
+
+from PySide2.QtWidgets import QPushButton, QWidget
+
+from helper import UsesQApplication
+
+class Dummy(QPushButton):
+
+ def show(self):
+ QWidget.show(self)
+ self.called = True
+
+class GrandParentMethod(UsesQApplication):
+ def testMethod(self):
+ obj = Dummy()
+ obj.show()
+ self.assertTrue(obj.called)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/hashabletype_test.py b/sources/pyside2/tests/QtWidgets/hashabletype_test.py
new file mode 100644
index 000000000..21486b28a
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/hashabletype_test.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for __hash__'''
+
+import unittest
+
+from PySide2.QtWidgets import QTreeWidgetItem
+from helper import UsesQApplication
+
+class HashableTest(UsesQApplication):
+
+ def testQTreeWidgetItemHash(self):
+ h = {}
+ obj = QTreeWidgetItem()
+ h[obj] = 2
+ self.assertTrue(h.get(obj), 2)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/import_test.py b/sources/pyside2/tests/QtWidgets/import_test.py
new file mode 100644
index 000000000..0b60241f0
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/import_test.py
@@ -0,0 +1,2 @@
+class PysideImportTest2(object):
+ pass
diff --git a/sources/pyside2/tests/QtWidgets/keep_reference_test.py b/sources/pyside2/tests/QtWidgets/keep_reference_test.py
new file mode 100644
index 000000000..17502c267
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/keep_reference_test.py
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from sys import getrefcount
+from helper import UsesQApplication
+from PySide2.QtCore import *
+from PySide2.QtWidgets import QTableView
+
+class TestModel(QAbstractTableModel):
+ def __init__(self, parent=None):
+ QAbstractTableModel.__init__(self, parent)
+ def rowCount(self, parent):
+ return 0
+ def columnCount(self, parent):
+ return 0
+ def data(self, index, role):
+ return None
+
+class KeepReferenceTest(UsesQApplication):
+
+ def testModelWithoutParent(self):
+ view = QTableView()
+ model = TestModel()
+ view.setModel(model)
+ samemodel = view.model()
+ self.assertEqual(model, samemodel)
+
+ def testModelWithParent(self):
+ view = QTableView()
+ model = TestModel(None)
+ view.setModel(model)
+ samemodel = view.model()
+ self.assertEqual(model, samemodel)
+
+ def testReferenceCounting(self):
+ '''Tests reference count of model object referred by view objects.'''
+ model1 = TestModel()
+ refcount1 = getrefcount(model1)
+ view1 = QTableView()
+ view1.setModel(model1)
+ self.assertEqual(getrefcount(view1.model()), refcount1 + 1)
+
+ view2 = QTableView()
+ view2.setModel(model1)
+ self.assertEqual(getrefcount(view2.model()), refcount1 + 2)
+
+ model2 = TestModel()
+ view2.setModel(model2)
+ self.assertEqual(getrefcount(view1.model()), refcount1 + 1)
+
+ def testReferenceCountingWhenDeletingReferrer(self):
+ '''Tests reference count of model object referred by deceased view object.'''
+ model = TestModel()
+ refcount1 = getrefcount(model)
+ view = QTableView()
+ view.setModel(model)
+ self.assertEqual(getrefcount(view.model()), refcount1 + 1)
+
+ del view
+ self.assertEqual(getrefcount(model), refcount1)
+
+ def testReferreedObjectSurvivalAfterContextEnd(self):
+ '''Model object assigned to a view object must survive after getting out of context.'''
+ def createModelAndSetToView(view):
+ model = TestModel()
+ model.setObjectName('created model')
+ view.setModel(model)
+ view = QTableView()
+ createModelAndSetToView(view)
+ model = view.model()
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/missing_symbols_test.py b/sources/pyside2/tests/QtWidgets/missing_symbols_test.py
new file mode 100644
index 000000000..fedc2859f
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/missing_symbols_test.py
@@ -0,0 +1,57 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''(Very) Simple test case for missing names from QtGui and QtWidgets'''
+
+import unittest
+from PySide2 import QtGui
+from PySide2 import QtWidgets
+
+class MissingClasses(unittest.TestCase):
+ def testQDrag(self): # Bug 222
+ getattr(QtGui, 'QDrag')
+
+ def testQDropEvent(self): # Bug 255
+ getattr(QtGui, 'QDropEvent')
+
+class MissingMembers(unittest.TestCase):
+
+ def testQFontMetricsSize(self): # Bug 223
+ QtGui.QFontMetrics.size
+
+ def testQLayoutSetSpacing(self): # Bug 231
+ QtWidgets.QLayout.setSpacing
+
+ def testQImageLoad(self): # Bug 257
+ QtGui.QImage.load
+
+ def testQStandardItemModelinsertRow(self): # Bug 227
+ QtGui.QStandardItemModel.insertRow
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/paint_event_test.py b/sources/pyside2/tests/QtWidgets/paint_event_test.py
new file mode 100644
index 000000000..cbbe3acb3
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/paint_event_test.py
@@ -0,0 +1,98 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test paint event override in python'''
+
+import unittest
+
+from PySide2.QtCore import QTimerEvent
+from PySide2.QtWidgets import QApplication, QWidget
+
+from helper import UsesQApplication
+
+class MyWidget(QWidget):
+ '''Sample widget'''
+
+ def __init__(self, app=None):
+ #Creates a new widget
+ if app is None:
+ app = QApplication([])
+
+ super(MyWidget, self).__init__()
+ self.app = app
+ self.runs = 0
+ self.max_runs = 5
+ self.paint_event_called = False
+
+ def timerEvent(self, event):
+ #Timer event method
+ self.runs += 1
+
+ if self.runs == self.max_runs:
+ self.app.quit()
+
+ if not isinstance(event, QTimerEvent):
+ raise TypeError('Invalid event type. Must be QTimerEvent')
+
+ def paintEvent(self, event):
+ #Empty paint event method
+ # XXX: should be using super here, but somehow PyQt4
+ # complains about paintEvent not present in super
+ QWidget.paintEvent(self, event)
+ self.paint_event_called = True
+
+
+class PaintEventOverride(UsesQApplication):
+ '''Test case for overriding QWidget.paintEvent'''
+
+ qapplication = True
+
+ def setUp(self):
+ #Acquire resources
+ super(PaintEventOverride, self).setUp()
+ self.widget = MyWidget(self.app)
+
+ def tearDown(self):
+ #Release resources
+ del self.widget
+ super(PaintEventOverride, self).tearDown()
+
+ def testPaintEvent(self):
+ #Test QWidget.paintEvent override
+ timer_id = self.widget.startTimer(100)
+ self.widget.show()
+ self.app.exec_()
+
+ self.widget.killTimer(timer_id)
+
+ self.assertTrue(self.widget.paint_event_called)
+ self.assertEqual(self.widget.runs, 5)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/parent_method_test.py b/sources/pyside2/tests/QtWidgets/parent_method_test.py
new file mode 100644
index 000000000..b3d883362
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/parent_method_test.py
@@ -0,0 +1,52 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject, QTimer, QThread
+from PySide2.QtWidgets import *
+
+class Foo(QTableView):
+ def __init__(self, parent=None):
+ QTableView.__init__(self, parent)
+
+from helper import UsesQApplication
+
+class TestParentType(UsesQApplication):
+
+ def testParentType(self):
+ # Test the problem with calling QObject.parent from a QWidget
+ # when the parent is a python class derived from a QWidget-derived
+ # class. The method was returning the last C++ class in the hierarchy
+ parent = Foo()
+ w2 = QWidget(parent)
+ self.assertTrue(isinstance(w2.parentWidget(), Foo))
+ self.assertTrue(isinstance(w2.parent(), Foo))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/python_properties_test.py b/sources/pyside2/tests/QtWidgets/python_properties_test.py
new file mode 100644
index 000000000..077702964
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/python_properties_test.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2 import QtCore, QtWidgets
+
+class Properties(unittest.TestCase):
+
+ def testStaticProperty(self):
+ self.assertEqual(QtWidgets.QGraphicsItem.UserType, 65536)
+
+ def testInstanceProperty(self):
+ p = QtWidgets.QStyleOptionViewItem()
+ self.assertTrue(isinstance(p.locale, QtCore.QLocale))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qabstracttextdocumentlayout_test.py b/sources/pyside2/tests/QtWidgets/qabstracttextdocumentlayout_test.py
new file mode 100644
index 000000000..70d25295c
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qabstracttextdocumentlayout_test.py
@@ -0,0 +1,75 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import py3kcompat as py3k
+
+from PySide2.QtCore import QSizeF, QTimer
+from PySide2.QtGui import QTextFormat, QTextCharFormat, QPyTextObject
+from PySide2.QtWidgets import QTextEdit
+from helper import UsesQApplication
+
+class Foo(QPyTextObject):
+ called = False
+
+ def intrinsicSize(self, doc, posInDocument, format):
+ Foo.called = True
+ return QSizeF(10, 10)
+
+ def drawObject(self, painter, rect, doc, posInDocument, format):
+ pass
+
+class QAbstractTextDocumentLayoutTest(UsesQApplication):
+
+ objectType = QTextFormat.UserObject + 1
+
+ def foo(self):
+ fmt = QTextCharFormat()
+ fmt.setObjectType(QAbstractTextDocumentLayoutTest.objectType)
+
+ cursor = self.textEdit.textCursor()
+ cursor.insertText(py3k.unichr(0xfffc), fmt)
+ self.textEdit.setTextCursor(cursor)
+ self.textEdit.close()
+
+ def testIt(self):
+
+ self.textEdit = QTextEdit()
+ self.textEdit.show()
+
+ interface = Foo()
+ self.textEdit.document().documentLayout().registerHandler(QAbstractTextDocumentLayoutTest.objectType, interface)
+
+ QTimer.singleShot(0, self.foo)
+ self.app.exec_()
+
+ self.assertTrue(Foo.called)
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qaction_test.py b/sources/pyside2/tests/QtWidgets/qaction_test.py
new file mode 100644
index 000000000..bbc8a5201
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qaction_test.py
@@ -0,0 +1,69 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtWidgets import QAction, QWidget
+from helper import UsesQApplication
+
+class QPainterDrawText(UsesQApplication):
+
+ def _cb(self):
+ self._called = True
+
+ def testSignal(self):
+ o = QWidget()
+ act = QAction(o)
+ self._called = False
+ act.triggered.connect(self._cb)
+ act.trigger()
+ self.assertTrue(self._called)
+
+ def testNewCtor(self):
+ o = QWidget()
+ self._called = False
+ myAction = QAction("&Quit", o, triggered=self._cb)
+ myAction.trigger()
+ self.assertTrue(self._called)
+
+
+class SetShortcutTest(UsesQApplication):
+
+ def testSetShortcut(self):
+ # Somehow an exception was leaking from the constructor
+ # and appearing in setShortcut.
+ o = QWidget()
+ action = QAction('aaaa', o)
+ shortcut = 'Ctrl+N'
+ action.setShortcut(shortcut)
+ s2 = action.shortcut()
+ self.assertEqual(s2, shortcut)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qapp_test.py b/sources/pyside2/tests/QtWidgets/qapp_test.py
new file mode 100644
index 000000000..63496f7dd
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qapp_test.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test the presence of qApp Macro'''
+
+import unittest
+
+from PySide2.QtWidgets import *
+
+class QAppPresence(unittest.TestCase):
+
+ def testQApp(self):
+ #QtGui.qApp variable is instance of QApplication
+ self.assertTrue(isinstance(qApp, QApplication))
+
+def main():
+ app = QApplication([])
+ unittest.main()
+
+if __name__ == '__main__':
+ main()
diff --git a/sources/pyside2/tests/QtWidgets/qapplication_exit_segfault_test.py b/sources/pyside2/tests/QtWidgets/qapplication_exit_segfault_test.py
new file mode 100644
index 000000000..21250c4cb
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qapplication_exit_segfault_test.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+
+from PySide2.QtWidgets import QApplication, QPushButton, QWidget, QSpinBox
+
+class QApplicationDelete(unittest.TestCase):
+ '''Test for segfault when deleting a QApplication before a QWidget'''
+
+ def testQPushButton(self):
+ #QApplication deleted before QPushButton
+ a = QApplication([])
+ b = QPushButton('aaaa')
+ del a
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qapplication_singleton_test.py b/sources/pyside2/tests/QtWidgets/qapplication_singleton_test.py
new file mode 100644
index 000000000..77dca33cf
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qapplication_singleton_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtWidgets import QApplication
+
+class TestSingleton(unittest.TestCase):
+ def testBasic(self):
+ a = QApplication([])
+ self.assertRaises(RuntimeError, QApplication, [])
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qbrush_test.py b/sources/pyside2/tests/QtWidgets/qbrush_test.py
new file mode 100644
index 000000000..88e07f462
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qbrush_test.py
@@ -0,0 +1,52 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QBrush'''
+
+import unittest
+
+from PySide2.QtCore import Qt
+from PySide2.QtGui import QColor, QBrush
+from PySide2.QtWidgets import QApplication
+
+from helper import UsesQApplication
+
+class Constructor(UsesQApplication):
+ '''Test case for constructor of QBrush'''
+
+ def testQColor(self):
+ #QBrush(QColor) constructor
+ color = QColor('black')
+ obj = QBrush(color)
+ self.assertEqual(obj.color(), color)
+
+ obj = QBrush(Qt.blue)
+ self.assertEqual(obj.color(), Qt.blue)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qdynamic_signal.py b/sources/pyside2/tests/QtWidgets/qdynamic_signal.py
new file mode 100644
index 000000000..cba2bc041
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qdynamic_signal.py
@@ -0,0 +1,55 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject
+from PySide2.QtWidgets import QInputDialog
+
+from helper import UsesQApplication
+
+class DynamicSignalTest(UsesQApplication):
+
+ def cb(self, obj):
+ self._called = True
+
+ def testQDialog(self):
+ dlg = QInputDialog()
+ dlg.setInputMode(QInputDialog.TextInput)
+ lst = dlg.children()
+ self.assertTrue(len(lst))
+ obj = lst[0]
+ self._called = False
+ obj.destroyed[QObject].connect(self.cb)
+ obj = None
+ del dlg
+ self.assertTrue(self._called)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qfontdialog_test.py b/sources/pyside2/tests/QtWidgets/qfontdialog_test.py
new file mode 100644
index 000000000..4475190a6
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qfontdialog_test.py
@@ -0,0 +1,51 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+
+from PySide2 import QtCore
+from PySide2 import QtGui
+from PySide2 import QtWidgets
+
+from helper import TimedQApplication
+
+class TestFontDialog(TimedQApplication):
+
+ def testGetFont(self):
+ QtWidgets.QFontDialog.getFont()
+
+ def testGetFontQDialog(self):
+ QtWidgets.QFontDialog.getFont(QtGui.QFont("FreeSans",10))
+
+ def testGetFontQDialogQString(self):
+ QtWidgets.QFontDialog.getFont(QtGui.QFont("FreeSans",10), None, "Select font")
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qformlayout_test.py b/sources/pyside2/tests/QtWidgets/qformlayout_test.py
new file mode 100644
index 000000000..feb4b4114
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qformlayout_test.py
@@ -0,0 +1,84 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtWidgets import QFormLayout, QWidget
+
+from helper import UsesQApplication
+
+class QFormLayoutTest(UsesQApplication):
+
+ def testGetItemPosition(self):
+ formlayout = QFormLayout()
+ row, role = formlayout.getItemPosition(0)
+ self.assertTrue(isinstance(row, int))
+ self.assertTrue(isinstance(role, QFormLayout.ItemRole))
+ self.assertEqual(row, -1)
+
+ widget = QWidget()
+ formlayout.addRow(widget)
+ row, role = formlayout.getItemPosition(0)
+ self.assertTrue(isinstance(row, int))
+ self.assertTrue(isinstance(role, QFormLayout.ItemRole))
+ self.assertEqual(row, 0)
+ self.assertEqual(role, QFormLayout.SpanningRole)
+
+ def testGetWidgetPosition(self):
+ formlayout = QFormLayout()
+ widget = QWidget()
+ row, role = formlayout.getWidgetPosition(widget)
+ self.assertTrue(isinstance(row, int))
+ self.assertTrue(isinstance(role, QFormLayout.ItemRole))
+ self.assertEqual(row, -1)
+
+ formlayout.addRow(widget)
+ row, role = formlayout.getWidgetPosition(widget)
+ self.assertTrue(isinstance(row, int))
+ self.assertTrue(isinstance(role, QFormLayout.ItemRole))
+ self.assertEqual(row, 0)
+ self.assertEqual(role, QFormLayout.SpanningRole)
+
+ def testGetLayoutPosition(self):
+ formlayout = QFormLayout()
+ layout = QFormLayout()
+ row, role = formlayout.getLayoutPosition(layout)
+ self.assertTrue(isinstance(row, int))
+ self.assertTrue(isinstance(role, QFormLayout.ItemRole))
+ self.assertEqual(row, -1)
+
+ formlayout.addRow(layout)
+ row, role = formlayout.getLayoutPosition(layout)
+ self.assertTrue(isinstance(row, int))
+ self.assertTrue(isinstance(role, QFormLayout.ItemRole))
+ self.assertEqual(row, 0)
+ self.assertEqual(role, QFormLayout.SpanningRole)
+
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qgraphicsitem_isblocked_test.py b/sources/pyside2/tests/QtWidgets/qgraphicsitem_isblocked_test.py
new file mode 100644
index 000000000..ec8c046ed
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qgraphicsitem_isblocked_test.py
@@ -0,0 +1,58 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2 import QtCore
+from PySide2 import QtGui
+from PySide2 import QtWidgets
+from helper import UsesQApplication
+
+class Item(QtWidgets.QGraphicsItem):
+
+ def __init__(self):
+ QtWidgets.QGraphicsItem.__init__(self)
+
+ def boundingRect(self):
+ return QtCore.QRectF(0, 0, 100, 100)
+
+ def paint(self, painter, option, widget):
+ painter.setBrush(QtGui.QColor(255, 255, 255))
+ painter.drawRect(0, 0, 100, 100)
+
+
+class QGraphicsViewIsBlockedTest(UsesQApplication):
+
+ def testIsBlockedByModalPanel(self):
+ (first, second) = Item().isBlockedByModalPanel()
+ self.assertFalse(first)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qgraphicsitem_test.py b/sources/pyside2/tests/QtWidgets/qgraphicsitem_test.py
new file mode 100644
index 000000000..1a25fdf31
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qgraphicsitem_test.py
@@ -0,0 +1,63 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test cases related to QGraphicsItem and subclasses'''
+
+import unittest
+
+from PySide2.QtGui import QPolygonF, QColor, QBrush
+from PySide2.QtWidgets import QGraphicsScene
+
+from helper import UsesQApplication
+
+class QColorOnSetBrush(UsesQApplication):
+ '''Test case for passing a QColor directly to setBrush'''
+
+ def setUp(self):
+ #Acquire resources
+ super(QColorOnSetBrush, self).setUp()
+
+ self.scene = QGraphicsScene()
+ poly = QPolygonF()
+ self.item = self.scene.addPolygon(poly)
+ self.color = QColor('black')
+
+ def tearDown(self):
+ #Release resources
+ del self.color
+ del self.item
+ del self.scene
+ super(QColorOnSetBrush, self).tearDown()
+
+ def testQColor(self):
+ #QGraphicsAbstractShapeItem.setBrush(QColor)
+ self.item.setBrush(self.color)
+ self.assertEqual(QBrush(self.color), self.item.brush())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qgraphicsproxywidget_test.py b/sources/pyside2/tests/QtWidgets/qgraphicsproxywidget_test.py
new file mode 100644
index 000000000..7fbdf5467
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qgraphicsproxywidget_test.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import UsesQApplication
+from PySide2.QtCore import Qt, QTimer
+from PySide2.QtGui import QPainter
+from PySide2.QtWidgets import QLabel
+from PySide2.QtWidgets import QGraphicsScene, QGraphicsView, QGraphicsItem, QGraphicsProxyWidget
+
+class QGraphicsProxyWidgetTest(UsesQApplication):
+ def testQGraphicsProxyWidget(self):
+ scene = QGraphicsScene()
+
+ proxy = QGraphicsProxyWidget(None, Qt.Window)
+ widget = QLabel('Widget')
+ proxy.setWidget(widget)
+ proxy.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
+ scene.addItem(proxy)
+ scene.setSceneRect(scene.itemsBoundingRect())
+
+ view = QGraphicsView(scene)
+ view.setRenderHints(QPainter.Antialiasing|QPainter.SmoothPixmapTransform)
+ view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
+ view.show()
+
+ timer = QTimer.singleShot(100, self.app.quit)
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qgraphicsscene_test.py b/sources/pyside2/tests/QtWidgets/qgraphicsscene_test.py
new file mode 100644
index 000000000..8b883aa55
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qgraphicsscene_test.py
@@ -0,0 +1,197 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Basic test cases for QGraphicsScene'''
+
+import unittest
+import gc
+
+from PySide2.QtCore import QPointF
+from PySide2.QtGui import QPolygonF, QPixmap, QPainterPath, QTransform
+from PySide2.QtWidgets import QApplication, QPushButton
+from PySide2.QtWidgets import QGraphicsScene
+from PySide2.QtWidgets import QGraphicsEllipseItem, QGraphicsLineItem
+from PySide2.QtWidgets import QGraphicsPathItem, QGraphicsPixmapItem
+from PySide2.QtWidgets import QGraphicsPolygonItem, QGraphicsRectItem
+from PySide2.QtWidgets import QGraphicsSimpleTextItem, QGraphicsTextItem
+from PySide2.QtWidgets import QGraphicsProxyWidget
+
+from helper import UsesQApplication
+
+class Constructor(unittest.TestCase):
+ '''QGraphicsScene constructor'''
+
+ def testConstructor(self):
+ #QGraphicsScene constructor
+ obj = QGraphicsScene()
+ self.assertTrue(isinstance(obj, QGraphicsScene))
+
+
+class ConstructorWithRect(unittest.TestCase):
+ '''QGraphicsScene qrect constructor and related sizes'''
+
+ def setUp(self):
+ #Acquire resources
+ # PyQt4 doesn't accept a QRect as argument to constructor
+ self.scene = QGraphicsScene(0, 200, 150, 175)
+
+ def tearDown(self):
+ #Release resources
+ del self.scene
+
+ def testHeight(self):
+ #QGraphicsScene.height()
+ self.assertEqual(self.scene.height(), 175)
+
+ def testWidth(self):
+ #QGraphicsScene.width()
+ self.assertEqual(self.scene.width(), 150)
+
+
+class AddItem(UsesQApplication):
+ '''Tests for QGraphicsScene.add*'''
+
+ qapplication = True
+
+ def setUp(self):
+ #Acquire resources
+ super(AddItem, self).setUp()
+ self.scene = QGraphicsScene()
+ # While the scene does not inherits from QWidget, requires
+ # an application to make the internals work.
+
+ def tearDown(self):
+ #Release resources
+ del self.scene
+ super(AddItem, self).tearDown()
+
+ def testEllipse(self):
+ #QGraphicsScene.addEllipse
+ item = self.scene.addEllipse(100, 100, 100, 100)
+ self.assertTrue(isinstance(item, QGraphicsEllipseItem))
+
+ def testLine(self):
+ #QGraphicsScene.addLine
+ item = self.scene.addLine(100, 100, 200, 200)
+ self.assertTrue(isinstance(item, QGraphicsLineItem))
+
+ def testPath(self):
+ #QGraphicsScene.addPath
+ item = self.scene.addPath(QPainterPath())
+ self.assertTrue(isinstance(item, QGraphicsPathItem))
+
+ def testPixmap(self):
+ #QGraphicsScene.addPixmap
+ item = self.scene.addPixmap(QPixmap())
+ self.assertTrue(isinstance(item, QGraphicsPixmapItem))
+
+ def testPolygon(self):
+ #QGraphicsScene.addPolygon
+ points = [QPointF(0, 0), QPointF(100, 100), QPointF(0, 100)]
+ item = self.scene.addPolygon(QPolygonF(points))
+ self.assertTrue(isinstance(item, QGraphicsPolygonItem))
+
+ def testRect(self):
+ #QGraphicsScene.addRect
+ item = self.scene.addRect(100, 100, 100, 100)
+ self.assertTrue(isinstance(item, QGraphicsRectItem))
+
+ def testSimpleText(self):
+ #QGraphicsScene.addSimpleText
+ item = self.scene.addSimpleText('Monty Python 42')
+ self.assertTrue(isinstance(item, QGraphicsSimpleTextItem))
+
+ def testText(self):
+ #QGraphicsScene.addText
+ item = self.scene.addText('Monty Python 42')
+ self.assertTrue(isinstance(item, QGraphicsTextItem))
+
+ def testWidget(self):
+ #QGraphicsScene.addWidget
+ # XXX: printing some X11 error when using under PyQt4
+ item = self.scene.addWidget(QPushButton())
+ self.assertTrue(isinstance(item, QGraphicsProxyWidget))
+
+
+class ItemRetrieve(UsesQApplication):
+ '''Tests for QGraphicsScene item retrieval methods'''
+
+ qapplication = True
+
+ def setUp(self):
+ #Acquire resources
+ super(ItemRetrieve, self).setUp()
+ self.scene = QGraphicsScene()
+
+ self.topleft = QGraphicsRectItem(0, 0, 100, 100)
+ self.topright = QGraphicsRectItem(100, 0, 100, 100)
+ self.bottomleft = QGraphicsRectItem(0, 100, 100, 100)
+ self.bottomright = QGraphicsRectItem(100, 100, 100, 100)
+
+ self.items = [self.topleft, self.topright, self.bottomleft,
+ self.bottomright]
+
+ for item in self.items:
+ self.scene.addItem(item)
+
+ def tearDown(self):
+ #Release resources
+ del self.scene
+ super(ItemRetrieve, self).tearDown()
+
+ def testItems(self):
+ #QGraphicsScene.items()
+ items = self.scene.items()
+ for i in items:
+ self.assertTrue(i in self.items)
+
+ def testItemAt(self):
+ #QGraphicsScene.itemAt()
+ self.assertEqual(self.scene.itemAt(50, 50, QTransform()), self.topleft)
+ self.assertEqual(self.scene.itemAt(150, 50, QTransform()), self.topright)
+ self.assertEqual(self.scene.itemAt(50, 150, QTransform()), self.bottomleft)
+ self.assertEqual(self.scene.itemAt(150, 150, QTransform()), self.bottomright)
+
+class TestGraphicsGroup(UsesQApplication):
+ def testIt(self):
+ scene = QGraphicsScene()
+ i1 = QGraphicsRectItem()
+ scene.addItem(i1)
+ i2 = QGraphicsRectItem(i1)
+ i3 = QGraphicsRectItem()
+ i4 = QGraphicsRectItem()
+ group = scene.createItemGroup((i2, i3, i4))
+ scene.removeItem(i1)
+ del i1 # this shouldn't delete i2
+ self.assertEqual(i2.scene(), scene)
+ scene.destroyItemGroup(group)
+ self.assertRaises(RuntimeError, group.type)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qimage_test.py b/sources/pyside2/tests/QtWidgets/qimage_test.py
new file mode 100644
index 000000000..fab97ddf6
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qimage_test.py
@@ -0,0 +1,308 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QImage'''
+
+import unittest
+import py3kcompat as py3k
+from PySide2.QtGui import *
+from PySide2.QtWidgets import *
+from helper import UsesQApplication, adjust_filename
+
+xpm = [
+ "27 22 206 2",
+ " c None",
+ ". c #FEFEFE",
+ "+ c #FFFFFF",
+ "@ c #F9F9F9",
+ "# c #ECECEC",
+ "$ c #D5D5D5",
+ "% c #A0A0A0",
+ "& c #767676",
+ "* c #525252",
+ "= c #484848",
+ "- c #4E4E4E",
+ "; c #555555",
+ "> c #545454",
+ ", c #5A5A5A",
+ "' c #4B4B4B",
+ ") c #4A4A4A",
+ "! c #4F4F4F",
+ "~ c #585858",
+ "{ c #515151",
+ "] c #4C4C4C",
+ "^ c #B1B1B1",
+ "/ c #FCFCFC",
+ "( c #FDFDFD",
+ "_ c #C1C1C1",
+ ": c #848484",
+ "< c #616161",
+ "[ c #5E5E5E",
+ "} c #CECECE",
+ "| c #E2E2E2",
+ "1 c #E4E4E4",
+ "2 c #DFDFDF",
+ "3 c #D2D2D2",
+ "4 c #D8D8D8",
+ "5 c #D4D4D4",
+ "6 c #E6E6E6",
+ "7 c #F1F1F1",
+ "8 c #838383",
+ "9 c #8E8E8E",
+ "0 c #8F8F8F",
+ "a c #CBCBCB",
+ "b c #CCCCCC",
+ "c c #E9E9E9",
+ "d c #F2F2F2",
+ "e c #EDEDED",
+ "f c #B5B5B5",
+ "g c #A6A6A6",
+ "h c #ABABAB",
+ "i c #BBBBBB",
+ "j c #B0B0B0",
+ "k c #EAEAEA",
+ "l c #6C6C6C",
+ "m c #BCBCBC",
+ "n c #F5F5F5",
+ "o c #FAFAFA",
+ "p c #B6B6B6",
+ "q c #F3F3F3",
+ "r c #CFCFCF",
+ "s c #FBFBFB",
+ "t c #CDCDCD",
+ "u c #DDDDDD",
+ "v c #999999",
+ "w c #F0F0F0",
+ "x c #2B2B2B",
+ "y c #C3C3C3",
+ "z c #A4A4A4",
+ "A c #D7D7D7",
+ "B c #E7E7E7",
+ "C c #6E6E6E",
+ "D c #9D9D9D",
+ "E c #BABABA",
+ "F c #AEAEAE",
+ "G c #898989",
+ "H c #646464",
+ "I c #BDBDBD",
+ "J c #CACACA",
+ "K c #2A2A2A",
+ "L c #212121",
+ "M c #B7B7B7",
+ "N c #F4F4F4",
+ "O c #737373",
+ "P c #828282",
+ "Q c #4D4D4D",
+ "R c #000000",
+ "S c #151515",
+ "T c #B2B2B2",
+ "U c #D6D6D6",
+ "V c #D3D3D3",
+ "W c #2F2F2F",
+ "X c #636363",
+ "Y c #A1A1A1",
+ "Z c #BFBFBF",
+ "` c #E0E0E0",
+ " . c #6A6A6A",
+ ".. c #050505",
+ "+. c #A3A3A3",
+ "@. c #202020",
+ "#. c #5F5F5F",
+ "$. c #B9B9B9",
+ "%. c #C7C7C7",
+ "&. c #D0D0D0",
+ "*. c #3E3E3E",
+ "=. c #666666",
+ "-. c #DBDBDB",
+ ";. c #424242",
+ ">. c #C2C2C2",
+ ",. c #1A1A1A",
+ "'. c #2C2C2C",
+ "). c #F6F6F6",
+ "!. c #AAAAAA",
+ "~. c #DCDCDC",
+ "{. c #2D2D2D",
+ "]. c #2E2E2E",
+ "^. c #A7A7A7",
+ "/. c #656565",
+ "(. c #333333",
+ "_. c #464646",
+ ":. c #C4C4C4",
+ "<. c #B8B8B8",
+ "[. c #292929",
+ "}. c #979797",
+ "|. c #EFEFEF",
+ "1. c #909090",
+ "2. c #8A8A8A",
+ "3. c #575757",
+ "4. c #676767",
+ "5. c #C5C5C5",
+ "6. c #7A7A7A",
+ "7. c #797979",
+ "8. c #989898",
+ "9. c #EEEEEE",
+ "0. c #707070",
+ "a. c #C8C8C8",
+ "b. c #111111",
+ "c. c #AFAFAF",
+ "d. c #474747",
+ "e. c #565656",
+ "f. c #E3E3E3",
+ "g. c #494949",
+ "h. c #5B5B5B",
+ "i. c #222222",
+ "j. c #353535",
+ "k. c #D9D9D9",
+ "l. c #0A0A0A",
+ "m. c #858585",
+ "n. c #E5E5E5",
+ "o. c #0E0E0E",
+ "p. c #9A9A9A",
+ "q. c #6F6F6F",
+ "r. c #868686",
+ "s. c #060606",
+ "t. c #1E1E1E",
+ "u. c #E8E8E8",
+ "v. c #A5A5A5",
+ "w. c #0D0D0D",
+ "x. c #030303",
+ "y. c #272727",
+ "z. c #131313",
+ "A. c #1F1F1F",
+ "B. c #757575",
+ "C. c #F7F7F7",
+ "D. c #414141",
+ "E. c #080808",
+ "F. c #6B6B6B",
+ "G. c #313131",
+ "H. c #C0C0C0",
+ "I. c #C9C9C9",
+ "J. c #0B0B0B",
+ "K. c #232323",
+ "L. c #434343",
+ "M. c #3D3D3D",
+ "N. c #282828",
+ "O. c #7C7C7C",
+ "P. c #252525",
+ "Q. c #3A3A3A",
+ "R. c #F8F8F8",
+ "S. c #1B1B1B",
+ "T. c #949494",
+ "U. c #3B3B3B",
+ "V. c #242424",
+ "W. c #383838",
+ "X. c #6D6D6D",
+ "Y. c #818181",
+ "Z. c #939393",
+ "`. c #9E9E9E",
+ " + c #929292",
+ ".+ c #7D7D7D",
+ "++ c #ADADAD",
+ "@+ c #DADADA",
+ "#+ c #919191",
+ "$+ c #E1E1E1",
+ "%+ c #BEBEBE",
+ "&+ c #ACACAC",
+ "*+ c #9C9C9C",
+ "=+ c #B3B3B3",
+ "-+ c #808080",
+ ";+ c #A8A8A8",
+ ">+ c #393939",
+ ",+ c #747474",
+ "'+ c #7F7F7F",
+ ")+ c #D1D1D1",
+ "!+ c #606060",
+ "~+ c #5C5C5C",
+ "{+ c #686868",
+ "]+ c #7E7E7E",
+ "^+ c #787878",
+ "/+ c #595959",
+ ". . . + @ # $ % & * = - ; > , ' ) ! ~ { ] ^ / . . + + ",
+ ". ( + _ : < [ & } | 1 2 $ 3 4 5 3 6 7 + + 8 9 + . + . ",
+ ". + 0 9 a ( 3 a b c d e c f g h i g j $ k + l m + . + ",
+ "+ 2 8 n o p | ( q r s . # t + + + u ^ v e w + x + + + ",
+ "+ y z . @ A k B 7 n + ( s | p 8 C D 2 E 4 + + F G + . ",
+ "# H I $ J G K L - M N . 2 O P Q R R S T U s s V W j + ",
+ "X Y Z @ o ` _ g ...+.( 4 @.#.m G $.%.7 &.X *.=.-.;.&.",
+ "Q >.C ,.'.} e + ).!.k + . + + . ~.{.> ].x f 7 ^./.k (.",
+ "_.:.4 @ <.[.}.|.1.2.+ + + >.} 4 B + ( @ _ 3.4.5.6.r 7.",
+ "3.8.9.~ 0.+ a.Q b.+ + c.d.#.=.$ |.b #.e.z ^ ; ^. .f.g.",
+ "-.h.+ i.S M + # p j.% n 9.5.k.H l.m.V ^.n.o.M + M p.q.",
+ "7 r.N s.1.R t.<.|.| u.v.~ w.x.E + s y.z.A.B.C.+ 5 D.q ",
+ ").p.2 E.0.9 F.%.O {._ @.+ + i { [ i.G.H.P I.+ s q.} + ",
+ ").p.6 J.R b.K.L.M.A.! b.g.K [.R M k + N.I + + >.O.+ . ",
+ ").8.9.N.P...R R R R E.t.W n.+ Q.R.6 @.| + . + S.+ + . ",
+ "n }.w T.U.B.<.i.@ Y + + U.+ c u V.= B B 7 u.W.c + . + ",
+ "N T.# + }.X.Y.,.8.F.8 Z.[.`. +.+}.4 ++@+O.< ~.+ ( . + ",
+ "d #+1 + _ ~.u.$+b $.y @+| $+%+I.&+k.h W +.9.+ ( . + . ",
+ "w 0 |.*+. >.<.=+++++p a.p -+;+5.k.>+,+@ + . . + . + + ",
+ "q '+9.R.^ I.t b %.I.)+4 $+n.I.,+ .|.+ . . . + . + + + ",
+ ". p !+( + + + + + + E 0. .-+8.f.+ + . . + + . + + + + ",
+ ". ( A ~+{+]+^+l > /+D f.c q . + . . + + . + + + + + + "
+]
+
+class QImageTest(UsesQApplication):
+ '''Test case for calling setPixel with float as argument'''
+
+ def testQImageStringBuffer(self):
+ '''Test if the QImage signatures receiving string buffers exist.'''
+ img0 = QImage(adjust_filename('sample.png', __file__))
+
+ # btw let's test the bits() method
+ img1 = QImage(img0.bits(), img0.width(), img0.height(), img0.format())
+ self.assertEqual(img0, img1)
+ img2 = QImage(img0.bits(), img0.width(), img0.height(), img0.bytesPerLine(), img0.format())
+ self.assertEqual(img0, img2)
+
+ ## test scanLine method
+ data1 = img0.scanLine(0)
+ 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)
+
+ def testEmptyStringAsBuffer(self):
+ img = QImage(py3k.b(''), 100, 100, QImage.Format_ARGB32)
+
+ def testXpmConstructor(self):
+ label = QLabel()
+ img = QImage(xpm)
+ self.assertFalse(img.isNull())
+ self.assertEqual(img.width(), 27)
+ self.assertEqual(img.height(), 22)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qinputdialog_get_test.py b/sources/pyside2/tests/QtWidgets/qinputdialog_get_test.py
new file mode 100644
index 000000000..3f94dcd44
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qinputdialog_get_test.py
@@ -0,0 +1,52 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2 import QtCore, QtWidgets
+from helper import UsesQApplication, TimedQApplication
+
+class TestInputDialog(TimedQApplication):
+
+ def testGetDouble(self):
+ self.assertEqual(QtWidgets.QInputDialog.getDouble(None, "title", "label"), (0.0, False))
+
+ def testGetInt(self):
+ self.assertEqual(QtWidgets.QInputDialog.getInt(None, "title", "label"), (0, False))
+
+ def testGetItem(self):
+ (item, bool) = QtWidgets.QInputDialog.getItem(None, "title", "label", ["1", "2", "3"])
+ self.assertEqual(str(item), "1")
+
+ def testGetText(self):
+ (text, bool) = QtWidgets.QInputDialog.getText(None, "title", "label")
+ self.assertEqual(str(text),"")
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qkeysequenceedit_test.py b/sources/pyside2/tests/QtWidgets/qkeysequenceedit_test.py
new file mode 100644
index 000000000..0591df1ba
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qkeysequenceedit_test.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QKeySequenceEdit.'''
+
+import unittest
+from PySide2.QtCore import QTimer
+from PySide2.QtWidgets import QKeySequenceEdit
+
+from helper import UsesQApplication
+
+class QKeySequenceEditTest(UsesQApplication):
+ def testKeySequence(self):
+ keySequenceEdit = QKeySequenceEdit()
+ keySequenceEdit.show()
+ QTimer.singleShot(0, keySequenceEdit.close)
+ self.app.exec_()
+ print(keySequenceEdit.keySequence())
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qlayout_ref_test.py b/sources/pyside2/tests/QtWidgets/qlayout_ref_test.py
new file mode 100644
index 000000000..f1a9f363f
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qlayout_ref_test.py
@@ -0,0 +1,179 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QLayout handling of child widgets references'''
+
+import unittest
+from sys import getrefcount
+
+from PySide2.QtWidgets import QHBoxLayout, QVBoxLayout, QGridLayout, QWidget
+from PySide2.QtWidgets import QStackedLayout, QFormLayout
+from PySide2.QtWidgets import QApplication, QPushButton, QLabel
+
+from helper import UsesQApplication
+
+class SaveReference(UsesQApplication):
+ '''Test case to check if QLayout-derived classes increment the refcount
+ of widgets passed to addWidget()'''
+
+ # Adding here as nose can't see the qapplication attrib we inherit
+ qapplication = True
+
+ def setUp(self):
+ #Acquire resources
+ super(SaveReference, self).setUp()
+ self.widget1 = QPushButton('click me')
+ self.widget2 = QLabel('aaa')
+
+ def tearDown(self):
+ #Release resources
+ del self.widget2
+ del self.widget1
+ super(SaveReference, self).tearDown()
+
+ def checkLayoutReference(self, layout):
+ #Checks the reference cound handling of layout.addWidget
+ self.assertEqual(getrefcount(self.widget1), 2)
+ layout.addWidget(self.widget1)
+ self.assertEqual(getrefcount(self.widget1), 3)
+
+ self.assertEqual(getrefcount(self.widget2), 2)
+ layout.addWidget(self.widget2)
+ self.assertEqual(getrefcount(self.widget2), 3)
+
+ # Check if doesn't mess around with previous widget refcount
+ self.assertEqual(getrefcount(self.widget1), 3)
+
+ def testMoveLayout(self):
+ l = QHBoxLayout()
+ self.assertEqual(getrefcount(self.widget1), 2)
+ l.addWidget(self.widget1)
+ self.assertEqual(getrefcount(self.widget1), 3)
+
+ w = QWidget()
+ w.setLayout(l)
+ self.assertEqual(getrefcount(self.widget1), 3)
+
+
+ def testHBoxReference(self):
+ #QHBoxLayout.addWidget reference count
+ w = QWidget()
+ self.checkLayoutReference(QHBoxLayout(w))
+
+ def testVBoxReference(self):
+ #QVBoxLayout.addWidget reference count
+ w = QWidget()
+ self.checkLayoutReference(QVBoxLayout(w))
+
+ def testGridReference(self):
+ #QGridLayout.addWidget reference count
+ w = QWidget()
+ self.checkLayoutReference(QGridLayout(w))
+
+ def testFormReference(self):
+ #QFormLayout.addWidget reference count
+ w = QWidget()
+ self.checkLayoutReference(QFormLayout(w))
+
+ def testStackedReference(self):
+ #QStackedLayout.addWidget reference count
+ w = QWidget()
+ self.checkLayoutReference(QStackedLayout(w))
+
+class MultipleAdd(UsesQApplication):
+ '''Test case to check if refcount is incremented only once when multiple
+ calls to addWidget are made with the same widget'''
+
+ qapplication = True
+
+ def setUp(self):
+ #Acquire resources
+ super(MultipleAdd, self).setUp()
+ self.widget = QPushButton('click me')
+ self.win = QWidget()
+ self.layout = QHBoxLayout(self.win)
+
+ def tearDown(self):
+ #Release resources
+ del self.widget
+ del self.layout
+ del self.win
+ super(MultipleAdd, self).tearDown()
+
+ def testRefCount(self):
+ #Multiple QLayout.addWidget calls on the same widget
+ self.assertEqual(getrefcount(self.widget), 2)
+ self.layout.addWidget(self.widget)
+ self.assertEqual(getrefcount(self.widget), 3)
+ self.layout.addWidget(self.widget)
+ self.assertEqual(getrefcount(self.widget), 3)
+ self.layout.addWidget(self.widget)
+ self.assertEqual(getrefcount(self.widget), 3)
+
+class InternalAdd(UsesQApplication):
+ def testInternalRef(self):
+ mw = QWidget()
+ w = QWidget()
+ ow = QWidget()
+
+ topLayout = QGridLayout()
+
+ # unique reference
+ self.assertEqual(getrefcount(w), 2)
+ self.assertEqual(getrefcount(ow), 2)
+
+ topLayout.addWidget(w, 0, 0)
+ topLayout.addWidget(ow, 1, 0)
+
+ # layout keep the referemce
+ self.assertEqual(getrefcount(w), 3)
+ self.assertEqual(getrefcount(ow), 3)
+
+ mainLayout = QGridLayout()
+
+ mainLayout.addLayout(topLayout, 1, 0, 1, 4)
+
+ # the same reference
+ self.assertEqual(getrefcount(w), 3)
+ self.assertEqual(getrefcount(ow), 3)
+
+ mw.setLayout(mainLayout)
+
+ # now trasfer the ownership to mw
+ self.assertEqual(getrefcount(w), 3)
+ self.assertEqual(getrefcount(ow), 3)
+
+ del mw
+
+ # remove the ref and invalidate the widget
+ self.assertEqual(getrefcount(w), 2)
+ self.assertEqual(getrefcount(ow), 2)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qlayout_test.py b/sources/pyside2/tests/QtWidgets/qlayout_test.py
new file mode 100644
index 000000000..684a6c409
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qlayout_test.py
@@ -0,0 +1,140 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+
+from helper import UsesQApplication
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+class MyLayout(QLayout):
+ def __init__(self, parent=None):
+ QLayout.__init__(self, parent)
+ self._list = []
+
+ def addItem(self, item):
+ self.add(item)
+
+ def addWidget(self, widget):
+ self.add(QWidgetItem(widget))
+
+ def itemAt(self, index):
+ if index < len(self._list):
+ return self._list[index]
+
+ return None
+
+ def count(self):
+ return len(self._list)
+
+ def add(self, item):
+ self._list.append(item)
+
+class MissingItemAtLayout(QLayout):
+ def __init__(self, parent=None):
+ QLayout.__init__(self, parent)
+ self._list = []
+
+ def addItem(self, item):
+ self.add(item)
+
+ def addWidget(self, widget):
+ self.add(QWidgetItem(widget))
+
+ def count(self):
+ return len(self._list)
+
+ def add(self, item):
+ self._list.append(item)
+
+#Test if a layout implemented in python, the QWidget.setLayout works
+#fine because this implement som layout functions used in glue code of
+#QWidget, then in c++ when call a virtual function this need call the QLayout
+#function implemented in python
+
+class QLayoutTest(UsesQApplication):
+ def testOwnershipTransfer(self):
+ b = QPushButton("teste")
+ l = MyLayout()
+
+ l.addWidget(b)
+
+ self.assertEqual(sys.getrefcount(b), 2)
+
+ w = QWidget()
+
+ #transfer ref
+ w.setLayout(l)
+
+ self.assertEqual(sys.getrefcount(b), 3)
+
+
+ def testReferenceTransfer(self):
+ b = QPushButton("teste")
+ l = QHBoxLayout()
+
+ # keep ref
+ l.addWidget(b)
+ self.assertEqual(sys.getrefcount(b), 3)
+
+ w = QWidget()
+
+ # transfer ref
+ w.setLayout(l)
+
+ self.assertEqual(sys.getrefcount(b), 3)
+
+ # release ref
+ del w
+
+ self.assertEqual(sys.getrefcount(b), 2)
+
+ def testMissingFunctions(self):
+ w = QWidget()
+ b = QPushButton("test")
+ l = MissingItemAtLayout()
+
+ l.addWidget(b)
+
+ self.assertRaises(RuntimeError, w.setLayout, l)
+
+ def testQFormLayout(self):
+ w = QWidget()
+ formLayout = QFormLayout()
+ spacer = QSpacerItem(100, 30)
+ formLayout.setItem(0, QFormLayout.SpanningRole, spacer)
+ w.setLayout(formLayout)
+ w.show()
+ QTimer.singleShot(10, w.close)
+ self.app.exec_()
+ del w
+ self.assertRaises(RuntimeError, spacer.isEmpty)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qlcdnumber_test.py b/sources/pyside2/tests/QtWidgets/qlcdnumber_test.py
new file mode 100644
index 000000000..56a983d0d
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qlcdnumber_test.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtWidgets import QApplication, QLCDNumber
+
+class QLCDNumberOverflow(unittest.TestCase):
+ '''Test case for unhandled overflow on QLCDNumber() numDigits argument (see bug #215).'''
+
+ def setUp(self):
+ self.app = QApplication([])
+
+ def testnumDigitsOverflow(self):
+ # NOTE: PyQt4 raises TypeError, but boost.python raises OverflowError
+ self.assertRaises(OverflowError, QLCDNumber, 840835495615213080)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qlistwidget_test.py b/sources/pyside2/tests/QtWidgets/qlistwidget_test.py
new file mode 100644
index 000000000..b89d2f77c
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qlistwidget_test.py
@@ -0,0 +1,82 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+import sys
+from PySide2 import QtWidgets, QtCore
+from helper import UsesQApplication
+
+class QListWidgetTest(UsesQApplication):
+
+ def populateList(self, lst):
+ o = QtCore.QObject()
+ o.setObjectName("obj")
+
+ item = QtWidgets.QListWidgetItem("item0")
+ item.setData(QtCore.Qt.UserRole, o)
+ #item._data = o
+ self.assertTrue(sys.getrefcount(o), 3)
+ self.assertTrue(sys.getrefcount(item), 2)
+ lst.addItem(item)
+ self.assertTrue(sys.getrefcount(item), 3)
+
+ def checkCurrentItem(self, lst):
+ item = lst.currentItem()
+ self.assertTrue(sys.getrefcount(item), 3)
+
+ def checkItemData(self, lst):
+ item = lst.currentItem()
+ o = item.data(QtCore.Qt.UserRole)
+ self.assertTrue(sys.getrefcount(o), 4)
+ self.assertEqual(o, item._data)
+ self.assertTrue(sys.getrefcount(o), 2)
+
+ def testConstructorWithParent(self):
+ lst = QtWidgets.QListWidget()
+ self.populateList(lst)
+ self.checkCurrentItem(lst)
+ i = lst.item(0)
+ self.assertTrue(sys.getrefcount(i), 3)
+
+ del lst
+ self.assertTrue(sys.getrefcount(i), 2)
+ del i
+
+ def testIt(self):
+ lst = QtWidgets.QListWidget()
+ lst.show()
+ slot = lambda : lst.removeItemWidget(lst.currentItem())
+ lst.addItem(QtWidgets.QListWidgetItem("foo"))
+ QtCore.QTimer.singleShot(0, slot)
+ QtCore.QTimer.singleShot(0, lst.close)
+ self.app.exec_()
+ self.assertEqual(lst.count(), 1)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qlistwidgetitem_test.py b/sources/pyside2/tests/QtWidgets/qlistwidgetitem_test.py
new file mode 100644
index 000000000..284b5ef83
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qlistwidgetitem_test.py
@@ -0,0 +1,56 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2 import QtWidgets
+
+from helper import UsesQApplication
+
+class QListWidgetItemConstructor(UsesQApplication):
+
+ def setUp(self):
+ super(QListWidgetItemConstructor, self).setUp()
+ self.widgetList = QtWidgets.QListWidget()
+
+ def tearDown(self):
+ del self.widgetList
+ super(QListWidgetItemConstructor, self).tearDown()
+
+ def testConstructorWithParent(self):
+ # Bug 235 - QListWidgetItem constructor not saving ownership
+ QtWidgets.QListWidgetItem(self.widgetList)
+ item = self.widgetList.item(0)
+ self.assertEqual(item.listWidget(), self.widgetList)
+
+ def testConstructorWithNone(self):
+ # Bug 452 - QListWidgetItem() not casting NoneType to null correctly.
+ item = QtWidgets.QListWidgetItem(None, 123)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qmainwindow_test.py b/sources/pyside2/tests/QtWidgets/qmainwindow_test.py
new file mode 100644
index 000000000..ae1129494
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qmainwindow_test.py
@@ -0,0 +1,113 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+import weakref
+
+from PySide2 import QtWidgets
+from PySide2 import QtCore
+
+from helper import UsesQApplication
+
+class MainWindow(QtWidgets.QMainWindow):
+ def __init__(self):
+ QtWidgets.QMainWindow.__init__(self)
+
+ self.createToolbar()
+
+ def createToolbar(self):
+ pointerButton = QtWidgets.QToolButton()
+ pointerToolbar = self.addToolBar("Pointer type")
+ pointerToolbar.addWidget(pointerButton)
+
+class MyButton(QtWidgets.QPushButton):
+ def __init__(self, parent=None):
+ QtWidgets.QPushButton.__init__(self)
+ self._called = False
+
+ def myCallback(self):
+ self._called = True
+
+
+class TestMainWindow(UsesQApplication):
+
+ def testCreateToolbar(self):
+ w = MainWindow()
+ w.show()
+ QtCore.QTimer.singleShot(1000, self.app.quit)
+ self.app.exec_()
+
+ def objDel(self, obj):
+ self.app.quit()
+
+ def testRefCountToNull(self):
+ w = QtWidgets.QMainWindow()
+ c = QtWidgets.QWidget()
+ self.assertEqual(sys.getrefcount(c), 2)
+ w.setCentralWidget(c)
+ self.assertEqual(sys.getrefcount(c), 3)
+ wr = weakref.ref(c, self.objDel)
+ w.setCentralWidget(None)
+ c = None
+ self.app.exec_()
+
+ def testRefCountToAnother(self):
+ w = QtWidgets.QMainWindow()
+ c = QtWidgets.QWidget()
+ self.assertEqual(sys.getrefcount(c), 2)
+ w.setCentralWidget(c)
+ self.assertEqual(sys.getrefcount(c), 3)
+
+ c2 = QtWidgets.QWidget()
+ w.setCentralWidget(c2)
+ self.assertEqual(sys.getrefcount(c2), 3)
+
+ wr = weakref.ref(c, self.objDel)
+ w.setCentralWidget(None)
+ c = None
+
+ self.app.exec_()
+
+ def testSignalDisconect(self):
+ w = QtWidgets.QMainWindow()
+ b = MyButton("button")
+ b.clicked.connect(b.myCallback)
+ w.setCentralWidget(b)
+
+ b = MyButton("button")
+ b.clicked.connect(b.myCallback)
+ w.setCentralWidget(b)
+
+ b.click()
+ self.assertEqual(b._called, True)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qmenu_test.py b/sources/pyside2/tests/QtWidgets/qmenu_test.py
new file mode 100644
index 000000000..f5b9cbd02
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qmenu_test.py
@@ -0,0 +1,86 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtWidgets import QMenu
+from PySide2.QtGui import QKeySequence, QIcon
+from PySide2.QtCore import SLOT
+
+from helper import UsesQApplication
+
+class QMenuAddAction(UsesQApplication):
+
+ def setUp(self):
+ super(QMenuAddAction, self).setUp()
+ self.menu = QMenu()
+
+ def tearDown(self):
+ del self.menu
+ super(QMenuAddAction, self).tearDown()
+
+ def testAddActionWithoutKeySequenceCallable(self):
+ # bug #280
+ action = self.menu.addAction(self.app.tr('aaa'), lambda : 1)
+
+ def testAddActionKeySequenceCallable(self):
+ # bug #228
+ action = self.menu.addAction(self.app.tr('aaa'), lambda : 1,
+ QKeySequence(self.app.tr('Ctrl+O')))
+
+ def testAddActionKeySequenceSlot(self):
+ action = self.menu.addAction('Quit', self.app, SLOT('quit()'),
+ QKeySequence('Ctrl+O'))
+
+class QMenuAddActionWithIcon(UsesQApplication):
+
+ def setUp(self):
+ super(QMenuAddActionWithIcon, self).setUp()
+ self.menu = QMenu()
+ self.icon = QIcon()
+
+ def tearDown(self):
+ del self.menu
+ del self.icon
+ super(QMenuAddActionWithIcon, self).tearDown()
+
+ def testAddActionWithoutKeySequenceCallable(self):
+ # bug #280
+ action = self.menu.addAction(self.icon, self.app.tr('aaa'), lambda : 1)
+
+ def testAddActionKeySequenceCallable(self):
+ # bug #228
+ action = self.menu.addAction(self.icon, self.app.tr('aaa'), lambda : 1,
+ QKeySequence(self.app.tr('Ctrl+O')))
+
+ def testAddActionKeySequenceSlot(self):
+ action = self.menu.addAction(self.icon, 'Quit', self.app, SLOT('quit()'),
+ QKeySequence('Ctrl+O'))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qmenuadd_test.py b/sources/pyside2/tests/QtWidgets/qmenuadd_test.py
new file mode 100644
index 000000000..39fa50a0d
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qmenuadd_test.py
@@ -0,0 +1,53 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test the QMenu.addAction() method'''
+
+import unittest
+import sys
+
+from PySide2 import QtWidgets
+
+from helper import UsesQApplication
+
+class QMenuAddAction(UsesQApplication):
+
+ def openFile(self, *args):
+ self.arg = args
+
+ def testQMenuAddAction(self):
+ fileMenu = QtWidgets.QMenu("&File")
+
+ addNewAction = fileMenu.addAction("&Open...", self.openFile)
+ addNewAction.trigger()
+ self.assertEqual(self.arg, ())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qobject_mi_test.py b/sources/pyside2/tests/QtWidgets/qobject_mi_test.py
new file mode 100644
index 000000000..e0c98b2a7
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qobject_mi_test.py
@@ -0,0 +1,70 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for multiple inheritance from 2 QObjects'''
+
+import unittest
+
+from PySide2.QtCore import QObject
+from PySide2.QtGui import *
+from PySide2.QtWidgets import *
+
+from helper import UsesQApplication
+
+class WidgetValidator(QWidget, QIntValidator):
+ def __init__(self, parent=None):
+ QWidget.__init__(self, parent)
+ QIntValidator.__init__(self, parent)
+
+
+class DoubleQObjectInheritanceTest(UsesQApplication):
+
+ def testDouble(self):
+ '''Double inheritance from QObject classes'''
+
+ obj = WidgetValidator()
+
+ #QObject methods
+ obj.setObjectName('aaaa')
+ self.assertEqual(obj.objectName(), 'aaaa')
+
+ #QWidget methods
+ obj.setVisible(False)
+ self.assertFalse(obj.isVisible())
+
+ #QIntValidator methods
+ state, string, number = obj.validate('aaaa', 0)
+ self.assertEqual(state, QValidator.Invalid)
+ state, string, number = obj.validate('33', 0)
+ self.assertEqual(state, QValidator.Acceptable)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qpen_test.py b/sources/pyside2/tests/QtWidgets/qpen_test.py
new file mode 100644
index 000000000..75c728884
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qpen_test.py
@@ -0,0 +1,72 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from helper import UsesQApplication
+
+from PySide2.QtCore import Qt, QTimer
+from PySide2.QtGui import QPen, QPainter
+from PySide2.QtWidgets import QWidget
+
+class Painting(QWidget):
+ def __init__(self):
+ QWidget.__init__(self)
+ self.penFromEnum = None
+ self.penFromInteger = None
+
+ def paintEvent(self, event):
+ painter = QPainter(self)
+ painter.setPen(Qt.NoPen)
+ self.penFromEnum = painter.pen()
+ painter.setPen(int(Qt.NoPen))
+ self.penFromInteger = painter.pen()
+
+
+class QPenTest(UsesQApplication):
+
+ def testCtorWithCreatedEnums(self):
+ '''A simple case of QPen creation using created enums.'''
+ width = 0
+ style = Qt.PenStyle(0)
+ cap = Qt.PenCapStyle(0)
+ join = Qt.PenJoinStyle(0)
+ pen = QPen(Qt.blue, width, style, cap, join)
+
+ def testSetPenWithPenStyleEnum(self):
+ '''Calls QPainter.setPen with both enum and integer. Bug #511.'''
+ w = Painting()
+ w.show()
+ QTimer.singleShot(1000, self.app.quit)
+ self.app.exec_()
+ self.assertEqual(w.penFromEnum.style(), Qt.NoPen)
+ self.assertEqual(w.penFromInteger.style(), Qt.SolidLine)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qpicture_test.py b/sources/pyside2/tests/QtWidgets/qpicture_test.py
new file mode 100644
index 000000000..15a527f6b
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qpicture_test.py
@@ -0,0 +1,66 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+import os
+from helper import UsesQApplication
+from PySide2.QtCore import QTimer
+from PySide2.QtGui import QPicture, QPainter
+from PySide2.QtWidgets import QWidget
+
+class MyWidget(QWidget):
+ def paintEvent(self, e):
+ p = QPainter(self)
+ p.drawPicture(0, 0, self._picture)
+ self._app.quit()
+
+class QPictureTest(UsesQApplication):
+ def testFromData(self):
+ picture = QPicture()
+ painter = QPainter()
+ painter.begin(picture)
+ painter.drawEllipse(10,20, 80,70)
+ painter.end()
+
+ data = picture.data()
+ picture2 = QPicture()
+ picture2.setData(data)
+
+ self.assertEqual(picture2.data(), picture.data())
+
+ w = MyWidget()
+ w._picture = picture2
+ w._app = self.app
+
+ QTimer.singleShot(300, w.show)
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qpixmap_constructor.py b/sources/pyside2/tests/QtWidgets/qpixmap_constructor.py
new file mode 100644
index 000000000..9ae7d0fcf
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qpixmap_constructor.py
@@ -0,0 +1,279 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtGui import QPixmap
+from PySide2.QtWidgets import QLabel
+
+from helper import UsesQApplication
+
+xpm = [
+ "27 22 206 2",
+ " c None",
+ ". c #FEFEFE",
+ "+ c #FFFFFF",
+ "@ c #F9F9F9",
+ "# c #ECECEC",
+ "$ c #D5D5D5",
+ "% c #A0A0A0",
+ "& c #767676",
+ "* c #525252",
+ "= c #484848",
+ "- c #4E4E4E",
+ "; c #555555",
+ "> c #545454",
+ ", c #5A5A5A",
+ "' c #4B4B4B",
+ ") c #4A4A4A",
+ "! c #4F4F4F",
+ "~ c #585858",
+ "{ c #515151",
+ "] c #4C4C4C",
+ "^ c #B1B1B1",
+ "/ c #FCFCFC",
+ "( c #FDFDFD",
+ "_ c #C1C1C1",
+ ": c #848484",
+ "< c #616161",
+ "[ c #5E5E5E",
+ "} c #CECECE",
+ "| c #E2E2E2",
+ "1 c #E4E4E4",
+ "2 c #DFDFDF",
+ "3 c #D2D2D2",
+ "4 c #D8D8D8",
+ "5 c #D4D4D4",
+ "6 c #E6E6E6",
+ "7 c #F1F1F1",
+ "8 c #838383",
+ "9 c #8E8E8E",
+ "0 c #8F8F8F",
+ "a c #CBCBCB",
+ "b c #CCCCCC",
+ "c c #E9E9E9",
+ "d c #F2F2F2",
+ "e c #EDEDED",
+ "f c #B5B5B5",
+ "g c #A6A6A6",
+ "h c #ABABAB",
+ "i c #BBBBBB",
+ "j c #B0B0B0",
+ "k c #EAEAEA",
+ "l c #6C6C6C",
+ "m c #BCBCBC",
+ "n c #F5F5F5",
+ "o c #FAFAFA",
+ "p c #B6B6B6",
+ "q c #F3F3F3",
+ "r c #CFCFCF",
+ "s c #FBFBFB",
+ "t c #CDCDCD",
+ "u c #DDDDDD",
+ "v c #999999",
+ "w c #F0F0F0",
+ "x c #2B2B2B",
+ "y c #C3C3C3",
+ "z c #A4A4A4",
+ "A c #D7D7D7",
+ "B c #E7E7E7",
+ "C c #6E6E6E",
+ "D c #9D9D9D",
+ "E c #BABABA",
+ "F c #AEAEAE",
+ "G c #898989",
+ "H c #646464",
+ "I c #BDBDBD",
+ "J c #CACACA",
+ "K c #2A2A2A",
+ "L c #212121",
+ "M c #B7B7B7",
+ "N c #F4F4F4",
+ "O c #737373",
+ "P c #828282",
+ "Q c #4D4D4D",
+ "R c #000000",
+ "S c #151515",
+ "T c #B2B2B2",
+ "U c #D6D6D6",
+ "V c #D3D3D3",
+ "W c #2F2F2F",
+ "X c #636363",
+ "Y c #A1A1A1",
+ "Z c #BFBFBF",
+ "` c #E0E0E0",
+ " . c #6A6A6A",
+ ".. c #050505",
+ "+. c #A3A3A3",
+ "@. c #202020",
+ "#. c #5F5F5F",
+ "$. c #B9B9B9",
+ "%. c #C7C7C7",
+ "&. c #D0D0D0",
+ "*. c #3E3E3E",
+ "=. c #666666",
+ "-. c #DBDBDB",
+ ";. c #424242",
+ ">. c #C2C2C2",
+ ",. c #1A1A1A",
+ "'. c #2C2C2C",
+ "). c #F6F6F6",
+ "!. c #AAAAAA",
+ "~. c #DCDCDC",
+ "{. c #2D2D2D",
+ "]. c #2E2E2E",
+ "^. c #A7A7A7",
+ "/. c #656565",
+ "(. c #333333",
+ "_. c #464646",
+ ":. c #C4C4C4",
+ "<. c #B8B8B8",
+ "[. c #292929",
+ "}. c #979797",
+ "|. c #EFEFEF",
+ "1. c #909090",
+ "2. c #8A8A8A",
+ "3. c #575757",
+ "4. c #676767",
+ "5. c #C5C5C5",
+ "6. c #7A7A7A",
+ "7. c #797979",
+ "8. c #989898",
+ "9. c #EEEEEE",
+ "0. c #707070",
+ "a. c #C8C8C8",
+ "b. c #111111",
+ "c. c #AFAFAF",
+ "d. c #474747",
+ "e. c #565656",
+ "f. c #E3E3E3",
+ "g. c #494949",
+ "h. c #5B5B5B",
+ "i. c #222222",
+ "j. c #353535",
+ "k. c #D9D9D9",
+ "l. c #0A0A0A",
+ "m. c #858585",
+ "n. c #E5E5E5",
+ "o. c #0E0E0E",
+ "p. c #9A9A9A",
+ "q. c #6F6F6F",
+ "r. c #868686",
+ "s. c #060606",
+ "t. c #1E1E1E",
+ "u. c #E8E8E8",
+ "v. c #A5A5A5",
+ "w. c #0D0D0D",
+ "x. c #030303",
+ "y. c #272727",
+ "z. c #131313",
+ "A. c #1F1F1F",
+ "B. c #757575",
+ "C. c #F7F7F7",
+ "D. c #414141",
+ "E. c #080808",
+ "F. c #6B6B6B",
+ "G. c #313131",
+ "H. c #C0C0C0",
+ "I. c #C9C9C9",
+ "J. c #0B0B0B",
+ "K. c #232323",
+ "L. c #434343",
+ "M. c #3D3D3D",
+ "N. c #282828",
+ "O. c #7C7C7C",
+ "P. c #252525",
+ "Q. c #3A3A3A",
+ "R. c #F8F8F8",
+ "S. c #1B1B1B",
+ "T. c #949494",
+ "U. c #3B3B3B",
+ "V. c #242424",
+ "W. c #383838",
+ "X. c #6D6D6D",
+ "Y. c #818181",
+ "Z. c #939393",
+ "`. c #9E9E9E",
+ " + c #929292",
+ ".+ c #7D7D7D",
+ "++ c #ADADAD",
+ "@+ c #DADADA",
+ "#+ c #919191",
+ "$+ c #E1E1E1",
+ "%+ c #BEBEBE",
+ "&+ c #ACACAC",
+ "*+ c #9C9C9C",
+ "=+ c #B3B3B3",
+ "-+ c #808080",
+ ";+ c #A8A8A8",
+ ">+ c #393939",
+ ",+ c #747474",
+ "'+ c #7F7F7F",
+ ")+ c #D1D1D1",
+ "!+ c #606060",
+ "~+ c #5C5C5C",
+ "{+ c #686868",
+ "]+ c #7E7E7E",
+ "^+ c #787878",
+ "/+ c #595959",
+ ". . . + @ # $ % & * = - ; > , ' ) ! ~ { ] ^ / . . + + ",
+ ". ( + _ : < [ & } | 1 2 $ 3 4 5 3 6 7 + + 8 9 + . + . ",
+ ". + 0 9 a ( 3 a b c d e c f g h i g j $ k + l m + . + ",
+ "+ 2 8 n o p | ( q r s . # t + + + u ^ v e w + x + + + ",
+ "+ y z . @ A k B 7 n + ( s | p 8 C D 2 E 4 + + F G + . ",
+ "# H I $ J G K L - M N . 2 O P Q R R S T U s s V W j + ",
+ "X Y Z @ o ` _ g ...+.( 4 @.#.m G $.%.7 &.X *.=.-.;.&.",
+ "Q >.C ,.'.} e + ).!.k + . + + . ~.{.> ].x f 7 ^./.k (.",
+ "_.:.4 @ <.[.}.|.1.2.+ + + >.} 4 B + ( @ _ 3.4.5.6.r 7.",
+ "3.8.9.~ 0.+ a.Q b.+ + c.d.#.=.$ |.b #.e.z ^ ; ^. .f.g.",
+ "-.h.+ i.S M + # p j.% n 9.5.k.H l.m.V ^.n.o.M + M p.q.",
+ "7 r.N s.1.R t.<.|.| u.v.~ w.x.E + s y.z.A.B.C.+ 5 D.q ",
+ ").p.2 E.0.9 F.%.O {._ @.+ + i { [ i.G.H.P I.+ s q.} + ",
+ ").p.6 J.R b.K.L.M.A.! b.g.K [.R M k + N.I + + >.O.+ . ",
+ ").8.9.N.P...R R R R E.t.W n.+ Q.R.6 @.| + . + S.+ + . ",
+ "n }.w T.U.B.<.i.@ Y + + U.+ c u V.= B B 7 u.W.c + . + ",
+ "N T.# + }.X.Y.,.8.F.8 Z.[.`. +.+}.4 ++@+O.< ~.+ ( . + ",
+ "d #+1 + _ ~.u.$+b $.y @+| $+%+I.&+k.h W +.9.+ ( . + . ",
+ "w 0 |.*+. >.<.=+++++p a.p -+;+5.k.>+,+@ + . . + . + + ",
+ "q '+9.R.^ I.t b %.I.)+4 $+n.I.,+ .|.+ . . . + . + + + ",
+ ". p !+( + + + + + + E 0. .-+8.f.+ + . . + + . + + + + ",
+ ". ( A ~+{+]+^+l > /+D f.c q . + . . + + . + + + + + + "
+]
+
+class QStringSequenceTest(UsesQApplication):
+ def testQPixmapConstructor(self):
+ label = QLabel()
+ pixmap1 = QPixmap(xpm)
+ self.assertFalse(pixmap1.isNull())
+ self.assertEqual(pixmap1.width(), 27)
+ self.assertEqual(pixmap1.height(), 22)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qpushbutton_test.py b/sources/pyside2/tests/QtWidgets/qpushbutton_test.py
new file mode 100644
index 000000000..7039a8e3f
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qpushbutton_test.py
@@ -0,0 +1,69 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from helper import UsesQApplication
+from PySide2.QtWidgets import QPushButton, QMenu, QWidget
+from PySide2.QtCore import QTimer
+
+class MyWidget(QWidget):
+ def __init__(self):
+ QWidget.__init__(self)
+
+ m = QMenu(self)
+ b = QPushButton("Hello", self)
+ b.setMenu(m)
+
+
+class QPushButtonTest(UsesQApplication):
+ def createMenu(self, button):
+ m = QMenu()
+ button.setMenu(m)
+
+ def testSetMenu(self):
+ w = MyWidget()
+ w.show()
+
+ timer = QTimer.singleShot(100, self.app.quit)
+ self.app.exec_()
+
+ def buttonCb(self, checked):
+ self._clicked = True
+
+ def testBoolinSignal(self):
+ b = QPushButton()
+ b.setCheckable(True)
+ self._clicked = False
+ b.toggled[bool].connect(self.buttonCb)
+ b.toggle()
+ self.assertTrue(self._clicked)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qshortcut_test.py b/sources/pyside2/tests/QtWidgets/qshortcut_test.py
new file mode 100644
index 000000000..0cf749ebd
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qshortcut_test.py
@@ -0,0 +1,76 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test the QShortcut constructor'''
+
+import unittest
+import sys
+
+from PySide2 import QtCore, QtGui, QtWidgets
+
+class Foo(QtWidgets.QWidget):
+ def __init__(self):
+ QtWidgets.QWidget.__init__(self)
+ self.ok = False
+ self.copy = False
+
+ def slot_of_foo(self):
+ self.ok = True
+
+ def slot_of_copy(self):
+ self.copy = True
+
+class MyShortcut(QtWidgets.QShortcut):
+ def __init__(self, keys, wdg, slot):
+ QtWidgets.QShortcut.__init__(self, keys, wdg, slot)
+
+ def emit_signal(self):
+ self.emit(QtCore.SIGNAL("activated()"))
+
+class QAppPresence(unittest.TestCase):
+
+ def testQShortcut(self):
+ self.qapp = QtWidgets.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.qapp.exec_()
+ self.assertEqual(f.ok, True)
+ self.assertEqual(f.copy, True)
+
+ def init(self):
+ self.sc.emit_signal();
+ self.scstd.emit_signal();
+ self.qapp.quit()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qsplitter_test.py b/sources/pyside2/tests/QtWidgets/qsplitter_test.py
new file mode 100644
index 000000000..f90663155
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qsplitter_test.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtWidgets import QSplitter
+
+from helper import UsesQApplication
+
+class QSplitterTest(UsesQApplication):
+
+ def testGetRange(self):
+ splitter = QSplitter()
+ _min, _max = splitter.getRange(0)
+ self.assertTrue(isinstance(_min, int))
+ self.assertTrue(isinstance(_max, int))
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qstandarditemmodel_test.py b/sources/pyside2/tests/QtWidgets/qstandarditemmodel_test.py
new file mode 100644
index 000000000..2e9d260a3
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qstandarditemmodel_test.py
@@ -0,0 +1,112 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+
+from PySide2.QtGui import QStandardItemModel, QStandardItem
+from PySide2.QtWidgets import QWidget
+try:
+ # the normal call with installed PySide2
+ from PySide2 import shiboken2 as shiboken
+except ImportError:
+ try:
+ # When running make test on macOS, shiboken2 is not part of the PySide2 module,
+ # so it needs to be imported as a standalone module.
+ import shiboken2 as shiboken
+ except ImportError:
+ # sys.path is set a bit weird during tests, so we help a little to find shiboken2.
+ sys.path.append("../../..")
+ # the special call with testrunner.py
+ from shiboken2.shibokenmodule import shiboken2 as shiboken
+from helper import UsesQApplication
+
+
+class QStandardItemModelTest(UsesQApplication):
+
+ def setUp(self):
+ super(QStandardItemModelTest, self).setUp()
+ self.window = QWidget()
+ self.model = QStandardItemModel(0, 3, self.window)
+
+ def tearDown(self):
+ del self.window
+ del self.model
+ super(QStandardItemModelTest, self).tearDown()
+
+ def testInsertRow(self):
+ # bug #227
+ self.model.insertRow(0)
+
+ def testClear(self):
+
+ model = QStandardItemModel()
+ root = model.invisibleRootItem()
+ model.clear()
+ self.assertFalse(shiboken.isValid(root))
+
+
+class QStandardItemModelRef(UsesQApplication):
+ def testRefCount(self):
+ model = QStandardItemModel(5, 5)
+ items = []
+ for r in range(5):
+ row = []
+ for c in range(5):
+ row.append(QStandardItem("%d,%d" % (r,c)) )
+ self.assertEqual(sys.getrefcount(row[c]), 2)
+
+ model.insertRow(r, row)
+
+ for c in range(5):
+ ref_after = sys.getrefcount(row[c])
+ # check if the ref count was incremented after insertRow
+ self.assertEqual(ref_after, 3)
+
+ items.append(row)
+ row = None
+
+ for r in range(3):
+ my_row = model.takeRow(0)
+ my_row = None
+ for c in range(5):
+ # only rest 1 reference
+ self.assertEqual(sys.getrefcount(items[r][c]), 2)
+
+ my_i = model.item(0,0)
+ # ref(my_i) + parent_ref + items list ref
+ self.assertEqual(sys.getrefcount(my_i), 4)
+
+ model.clear()
+ # ref(my_i)
+ self.assertEqual(sys.getrefcount(my_i), 3)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qstring_qkeysequence_test.py b/sources/pyside2/tests/QtWidgets/qstring_qkeysequence_test.py
new file mode 100644
index 000000000..ed4c5ad00
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qstring_qkeysequence_test.py
@@ -0,0 +1,61 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests conversions of QString to and from QKeySequence.'''
+
+import unittest
+import py3kcompat as py3k
+from helper import UsesQApplication
+
+from PySide2.QtGui import QKeySequence
+from PySide2.QtWidgets import QAction
+
+class QStringQKeySequenceTest(UsesQApplication):
+ '''Tests conversions of QString to and from QKeySequence.'''
+
+ def testQStringFromQKeySequence(self):
+ '''Creates a QString from a QKeySequence.'''
+ keyseq = 'Ctrl+A'
+ a = QKeySequence(keyseq)
+ self.assertEqual(a, keyseq)
+
+ def testPythonStringAsQKeySequence(self):
+ '''Passes a Python string to an argument expecting a QKeySequence.'''
+ keyseq = py3k.unicode_('Ctrl+A')
+ action = QAction(None)
+ action.setShortcut(keyseq)
+ shortcut = action.shortcut()
+ self.assertTrue(isinstance(shortcut, QKeySequence))
+ self.assertEqual(shortcut.toString(), keyseq)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qstyle_test.py b/sources/pyside2/tests/QtWidgets/qstyle_test.py
new file mode 100644
index 000000000..0650c96e9
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qstyle_test.py
@@ -0,0 +1,59 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from helper import UsesQApplication
+
+from PySide2.QtWidgets import QWidget, QLabel, QFontComboBox, QStyleFactory
+
+class SetStyleTest(UsesQApplication):
+ '''Tests setting the same QStyle for all objects in a UI hierarchy.'''
+
+ def testSetStyle(self):
+ '''All this test have to do is not break with some invalid Python wrapper.'''
+
+ def setStyleHelper(widget, style):
+ widget.setStyle(style)
+ widget.setPalette(style.standardPalette())
+ for child in widget.children():
+ if isinstance(child, QWidget):
+ setStyleHelper(child, style)
+
+ container = QWidget()
+ # QFontComboBox is used because it has an QLineEdit created in C++ inside it,
+ # and if the QWidget.setStyle(style) steals the ownership of the style
+ # for the C++ originated widget everything will break.
+ fontComboBox = QFontComboBox(container)
+ label = QLabel(container)
+ label.setText('Label')
+ style = QStyleFactory.create(QStyleFactory.keys()[0])
+ setStyleHelper(container, style)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qtableview_test.py b/sources/pyside2/tests/QtWidgets/qtableview_test.py
new file mode 100644
index 000000000..f7d0f4c4e
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qtableview_test.py
@@ -0,0 +1,44 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QAbstractTableModel
+from PySide2.QtWidgets import QTableWidget
+from helper import UsesQApplication
+
+class QPenTest(UsesQApplication):
+
+ def testItemModel(self):
+ tv = QTableWidget()
+
+ self.assertEqual(type(tv.model()), QAbstractTableModel)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qtabwidget_test.py b/sources/pyside2/tests/QtWidgets/qtabwidget_test.py
new file mode 100644
index 000000000..b36310ed0
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qtabwidget_test.py
@@ -0,0 +1,56 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtWidgets import *
+from helper import TimedQApplication
+
+def makeBug643(tab):
+ button = QPushButton('Foo')
+ tab.insertTab(0, button, 'Foo')
+
+class RemoveTabMethod(TimedQApplication):
+ def setUp(self):
+ TimedQApplication.setUp(self)
+ self.tab = QTabWidget()
+
+ def tearDown(self):
+ del self.tab
+ TimedQApplication.tearDown(self)
+
+
+ def testRemoveTabPresence(self):
+ self.assertTrue(getattr(self.tab, 'removeTab'))
+
+ def testInsertTab(self):
+ makeBug643(self.tab)
+ self.assertEqual(self.tab.count(), 1)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qtextedit_signal_test.py b/sources/pyside2/tests/QtWidgets/qtextedit_signal_test.py
new file mode 100644
index 000000000..f60102806
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qtextedit_signal_test.py
@@ -0,0 +1,65 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2 import QtCore, QtWidgets
+from helper import UsesQApplication
+
+import unittest
+
+class MyWindow(QtWidgets.QMainWindow):
+ appendText = QtCore.Signal(str)
+
+ @QtCore.Slot()
+ def onButtonPressed(self):
+ self.appendText.emit("PySide")
+
+ def __init__(self, parent=None):
+ super(MyWindow, self).__init__(parent)
+
+ self.textEdit = QtWidgets.QTextEdit()
+ self.btn = QtWidgets.QPushButton("ClickMe")
+ self.btn.clicked.connect(self.onButtonPressed)
+ self.appendText.connect(self.textEdit.append)
+
+ def start(self):
+ self.btn.click()
+
+ def text(self):
+ return self.textEdit.toPlainText()
+
+
+class testSignalWithCPPSlot(UsesQApplication):
+
+ def testEmission(self):
+ w = MyWindow()
+ w.start()
+ self.assertEqual(w.text(), "PySide")
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qtextedit_test.py b/sources/pyside2/tests/QtWidgets/qtextedit_test.py
new file mode 100644
index 000000000..f67f8fbe1
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qtextedit_test.py
@@ -0,0 +1,60 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QTextEdit and ownership problems.'''
+
+import unittest
+from sys import getrefcount
+from PySide2.QtWidgets import QTextEdit
+
+from helper import UsesQApplication
+
+class DontTouchReference(UsesQApplication):
+ '''Check if the QTextTable returned by QTextCursor.insertTable() is not
+ referenced by the QTextCursor that returns it.'''
+
+ def setUp(self):
+ super(DontTouchReference, self).setUp()
+ self.editor = QTextEdit()
+ self.cursor = self.editor.textCursor()
+ self.table = self.cursor.insertTable(1, 1)
+
+ def testQTextTable(self):
+ # methods which return QTextTable should not increment its reference
+ self.assertEqual(getrefcount(self.table), 2)
+ f = self.cursor.currentFrame()
+ del f
+ self.assertEqual(getrefcount(self.table), 2)
+ # destroying the cursor should not raise any "RuntimeError: internal
+ # C++ object already deleted." when accessing the QTextTable
+ del self.cursor
+ self.assertEqual(getrefcount(self.table), 2)
+ cell = self.table.cellAt(0, 0)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qtoolbar_test.py b/sources/pyside2/tests/QtWidgets/qtoolbar_test.py
new file mode 100644
index 000000000..fc55d8bfe
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qtoolbar_test.py
@@ -0,0 +1,62 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QToolbar'''
+
+import unittest
+
+from PySide2.QtWidgets import QToolBar, QMainWindow, QAction
+
+from helper import UsesQApplication
+
+class AddActionText(UsesQApplication):
+ '''Test case for calling QToolbar.addAction passing a text'''
+
+ def setUp(self):
+ #Acquire resources
+ super(AddActionText, self).setUp()
+ self.window = QMainWindow()
+ self.toolbar = QToolBar()
+ self.window.addToolBar(self.toolbar)
+
+ def tearDown(self):
+ #Release resources
+ super(AddActionText, self).tearDown()
+ del self.toolbar
+ del self.window
+
+ def testText(self):
+ #QToolBar.addAction(text) - add a QToolButton
+ self.toolbar.addAction('aaaa')
+ self.assertEqual(len(self.toolbar.actions()), 1)
+ action = self.toolbar.actions()[0]
+ self.assertTrue(isinstance(action, QAction))
+ self.assertEqual(action.text(), 'aaaa')
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qtoolbox_test.py b/sources/pyside2/tests/QtWidgets/qtoolbox_test.py
new file mode 100644
index 000000000..ac6e590d1
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qtoolbox_test.py
@@ -0,0 +1,59 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtGui import QIcon
+from PySide2.QtWidgets import QToolBox, QWidget
+
+from helper import UsesQApplication
+
+class OwnershipControl(UsesQApplication):
+
+ def setUp(self):
+ super(OwnershipControl, self).setUp()
+ self.toolbox = QToolBox()
+
+ def tearDown(self):
+ del self.toolbox
+ super(OwnershipControl, self).tearDown()
+
+ def testAddItem(self):
+ # Was losing ownership of the widget.
+ index = self.toolbox.addItem(QWidget(), 'item')
+ item = self.toolbox.widget(index)
+ self.assertTrue(isinstance(item, QWidget))
+
+ def testAddItemWithIcon(self):
+ index = self.toolbox.addItem(QWidget(), QIcon(), 'item')
+ item = self.toolbox.widget(index)
+ self.assertTrue(isinstance(item, QWidget))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qvalidator_test.py b/sources/pyside2/tests/QtWidgets/qvalidator_test.py
new file mode 100644
index 000000000..951d6b2b0
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qvalidator_test.py
@@ -0,0 +1,114 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtCore import *
+from PySide2.QtGui import *
+from PySide2.QtWidgets import *
+
+import unittest
+from helper import UsesQApplication
+
+class MyValidator1(QValidator):
+ def fixUp(self, input):
+ return "fixed"
+
+ def validate(self, input, pos):
+ return (QValidator.Acceptable, "fixed", 1)
+
+class MyValidator2(QValidator):
+ def fixUp(self, input):
+ return "fixed"
+
+ def validate(self, input, pos):
+ return (QValidator.Acceptable, "fixed")
+
+class MyValidator3(QValidator):
+ def fixUp(self, input):
+ return "fixed"
+
+ def validate(self, input, pos):
+ return (QValidator.Acceptable,)
+
+class MyValidator4(QValidator):
+ def fixUp(self, input):
+ return "fixed"
+
+ def validate(self, input, pos):
+ return QValidator.Acceptable
+
+class QValidatorTest(UsesQApplication):
+ def testValidator1(self):
+ line = QLineEdit()
+ line.setValidator(MyValidator1())
+ line.show()
+ line.setText("foo")
+
+ QTimer.singleShot(0, line.close)
+ self.app.exec_()
+
+ self.assertEqual(line.text(), "fixed")
+ self.assertEqual(line.cursorPosition(), 1)
+
+ def testValidator2(self):
+ line = QLineEdit()
+ line.setValidator(MyValidator2())
+ line.show()
+ line.setText("foo")
+
+ QTimer.singleShot(0, line.close)
+ self.app.exec_()
+
+ self.assertEqual(line.text(), "fixed")
+ self.assertEqual(line.cursorPosition(), 3)
+
+ def testValidator3(self):
+ line = QLineEdit()
+ line.setValidator(MyValidator3())
+ line.show()
+ line.setText("foo")
+
+ QTimer.singleShot(0, line.close)
+ self.app.exec_()
+
+ self.assertEqual(line.text(), "foo")
+ self.assertEqual(line.cursorPosition(), 3)
+
+ def testValidator4(self):
+ line = QLineEdit()
+ line.setValidator(MyValidator4())
+ line.show()
+ line.setText("foo")
+
+ QTimer.singleShot(0, line.close)
+ self.app.exec_()
+
+ self.assertEqual(line.text(), "foo")
+ self.assertEqual(line.cursorPosition(), 3)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qvariant_test.py b/sources/pyside2/tests/QtWidgets/qvariant_test.py
new file mode 100644
index 000000000..f80460697
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qvariant_test.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+class MyDiagram(QGraphicsScene):
+ pass
+
+class MyItem(QGraphicsRectItem):
+ def itemChange(self, change, value):
+ return value;
+
+class QGraphicsSceneOnQVariantTest(unittest.TestCase):
+ """Test storage ot QGraphicsScene into QVariants"""
+ def testIt(self):
+ app = QApplication([])
+ s = MyDiagram()
+ i = MyItem()
+ s.addItem(i)
+ self.assertEqual(len(s.items()), 1)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/qwidget_setlayout_test.py b/sources/pyside2/tests/QtWidgets/qwidget_setlayout_test.py
new file mode 100644
index 000000000..fb5bebb53
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qwidget_setlayout_test.py
@@ -0,0 +1,61 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtWidgets import QWidget, QVBoxLayout, QPushButton, QApplication, QHBoxLayout
+from helper import UsesQApplication
+
+class QWidgetTest(UsesQApplication):
+
+ def test_setLayout(self):
+ layout = QVBoxLayout()
+ btn1 = QPushButton("button_v1")
+ layout.addWidget(btn1)
+
+ btn2 = QPushButton("button_v2")
+ layout.addWidget(btn2)
+
+ layout2 = QHBoxLayout()
+
+ btn1 = QPushButton("button_h1")
+ layout2.addWidget(btn1)
+
+ btn2 = QPushButton("button_h2")
+ layout2.addWidget(btn2)
+
+ layout.addLayout(layout2)
+
+ widget = QWidget()
+ widget.setLayout(layout)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/qwidget_test.py b/sources/pyside2/tests/QtWidgets/qwidget_test.py
new file mode 100644
index 000000000..22ea82cc6
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/qwidget_test.py
@@ -0,0 +1,55 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtWidgets import QWidget, QMainWindow
+from helper import UsesQApplication
+
+class QWidgetInherit(QMainWindow):
+ def __init__(self):
+ QWidget.__init__(self)
+
+class QWidgetTest(UsesQApplication):
+
+ def testInheritance(self):
+ self.assertRaises(TypeError, QWidgetInherit)
+
+class QWidgetVisible(UsesQApplication):
+
+ def testBasic(self):
+ # Also related to bug #244, on existence of setVisible'''
+ widget = QWidget()
+ self.assertTrue(not widget.isVisible())
+ widget.setVisible(True)
+ self.assertTrue(widget.isVisible())
+ self.assertTrue(widget.winId() is not 0)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/reference_count_test.py b/sources/pyside2/tests/QtWidgets/reference_count_test.py
new file mode 100644
index 000000000..9fa51f161
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/reference_count_test.py
@@ -0,0 +1,99 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for Reference count when the object is created in c++ side'''
+
+import unittest
+
+import sys
+import weakref
+import gc
+
+
+from PySide2.QtCore import Qt, QPointF
+from PySide2.QtGui import QPolygonF
+from PySide2.QtWidgets import QApplication, QGraphicsScene, QGraphicsRectItem, QGraphicsPolygonItem, QGraphicsRectItem
+
+from helper import UsesQApplication
+
+destroyedRect = False
+destroyedPol = False
+
+def rect_del(o):
+ global destroyedRect
+ destroyedRect = True
+
+def pol_del(o):
+ global destroyedPol
+ destroyedPol = True
+
+class ReferenceCount(UsesQApplication):
+
+ def setUp(self):
+ super(ReferenceCount, self).setUp()
+ self.scene = QGraphicsScene()
+
+ def tearDown(self):
+ super(ReferenceCount, self).tearDown()
+
+ def beforeTest(self):
+ points = [QPointF(0, 0), QPointF(100, 100), QPointF(0, 100)]
+ pol = self.scene.addPolygon(QPolygonF(points))
+ self.assertTrue(isinstance(pol, QGraphicsPolygonItem))
+ self.wrp = weakref.ref(pol, pol_del)
+
+ #refcount need be 3 because one ref for QGraphicsScene, and one to rect obj
+ self.assertEqual(sys.getrefcount(pol), 3)
+
+ def testReferenceCount(self):
+ global destroyedRect
+ global destroyedPol
+
+ self.beforeTest()
+
+ rect = self.scene.addRect(10.0, 10.0, 10.0, 10.0)
+ self.assertTrue(isinstance(rect, QGraphicsRectItem))
+
+ self.wrr = weakref.ref(rect, rect_del)
+
+ #refcount need be 3 because one ref for QGraphicsScene, and one to rect obj
+ self.assertEqual(sys.getrefcount(rect), 3)
+
+ del rect
+ #not destroyed because one ref continue in QGraphicsScene
+ self.assertEqual(destroyedRect, False)
+ self.assertEqual(destroyedPol, False)
+
+ del self.scene
+
+ #QGraphicsScene was destroyed and this destroy internal ref to rect
+ self.assertEqual(destroyedRect, True)
+ self.assertEqual(destroyedPol, True)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWidgets/returnquadruplesofnumbers_test.py b/sources/pyside2/tests/QtWidgets/returnquadruplesofnumbers_test.py
new file mode 100644
index 000000000..6e4cfeb63
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/returnquadruplesofnumbers_test.py
@@ -0,0 +1,95 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import unittest
+from PySide2.QtGui import QTextCursor
+from PySide2.QtPrintSupport import QPrinter
+from PySide2.QtWidgets import QLayout, QWidget, QGraphicsLayout, QGraphicsLayoutItem
+
+from helper import UsesQApplication
+
+class Layout(QLayout):
+ def __init__(self):
+ QLayout.__init__(self)
+
+class GraphicsLayout(QGraphicsLayout):
+ def __init__(self):
+ QGraphicsLayout.__init__(self)
+
+class GraphicsLayoutItem(QGraphicsLayoutItem):
+ def __init__(self):
+ QGraphicsLayoutItem.__init__(self)
+
+class ReturnsQuadruplesOfNumbers(UsesQApplication):
+ def compareTuples(self, ta, tb):
+ for va,vb in zip(ta, tb):
+ if round(va) != round(vb):
+ return False
+ return True
+
+ def testQGraphicsLayoutGetContentsMargins(self):
+ obj = GraphicsLayout()
+ values = (10.0, 20.0, 30.0, 40.0)
+ obj.setContentsMargins(*values)
+ self.assertTrue(self.compareTuples(obj.getContentsMargins(), values))
+
+ def testQGraphicsLayoutItemGetContentsMargins(self):
+ 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)
+ obj.setContentsMargins(*values)
+ self.assertTrue(self.compareTuples(obj.getContentsMargins(), values))
+
+ def testQTextCursorSelectedTableCells(self):
+ obj = QTextCursor()
+ self.assertEqual(obj.selectedTableCells(), (-1, -1, -1, -1))
+
+ def testQPrinterGetPageMargins(self):
+ # Bug #742
+ obj = QPrinter()
+ # 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)
+ obj.setPageMargins(*values)
+ print(obj.getPageMargins(QPrinter.Point), values[:-1])
+ self.assertTrue(self.compareTuples(obj.getPageMargins(QPrinter.Point), values[:-1]))
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/sample.png b/sources/pyside2/tests/QtWidgets/sample.png
new file mode 100644
index 000000000..60450f0dc
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/sample.png
Binary files differ
diff --git a/sources/pyside2/tests/QtWidgets/standardpixmap_test.py b/sources/pyside2/tests/QtWidgets/standardpixmap_test.py
new file mode 100644
index 000000000..dc93ba354
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/standardpixmap_test.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtGui import QPixmap
+from PySide2.QtWidgets import QStyle
+
+from helper import UsesQApplication
+
+class StandardPixmapTest(UsesQApplication):
+ def testDefaultOptions(self): # Bug 253
+ pixmap = self.app.style().standardPixmap(QStyle.SP_DirClosedIcon)
+ self.assertTrue(isinstance(pixmap, QPixmap))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/test_module_template.py b/sources/pyside2/tests/QtWidgets/test_module_template.py
new file mode 100644
index 000000000..d5e9db0f0
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/test_module_template.py
@@ -0,0 +1,40 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from PySide2.QtWidgets import QWidget
+from PySide2.QtCore import QObject
+
+class MyQObject(QObject):
+ pass
+
+class MyQWidget(QWidget):
+ pass
+
+class Sentinel():
+ value = 10
+
diff --git a/sources/pyside2/tests/QtWidgets/virtual_protected_inheritance_test.py b/sources/pyside2/tests/QtWidgets/virtual_protected_inheritance_test.py
new file mode 100644
index 000000000..b46ca8c88
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/virtual_protected_inheritance_test.py
@@ -0,0 +1,97 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for overriding inherited protected virtual methods'''
+
+import unittest
+
+from PySide2.QtCore import QTimerEvent
+from PySide2.QtWidgets import QApplication, QSpinBox
+
+from helper import UsesQApplication
+
+class MySpinButton(QSpinBox):
+ '''Simple example class of overriding QObject.timerEvent'''
+
+ def __init__(self, max_runs=5, app=None):
+ #Creates a new spinbox that will run <max_runs> and quit <app>
+ super(MySpinButton, self).__init__()
+
+ if app is None:
+ app = QApplication([])
+
+ self.app = app
+ self.max_runs = max_runs
+ self.runs = 0
+
+ def timerEvent(self, event):
+ #Timer event method
+ self.runs += 1
+
+ self.setValue(self.runs)
+
+ if self.runs == self.max_runs:
+ self.app.quit()
+
+ if not isinstance(event, QTimerEvent):
+ raise TypeError('Invalid event type. Must be TimerEvent')
+
+class TimerEventTest(UsesQApplication):
+ '''Test case for running QObject.timerEvent from inherited class'''
+
+ qapplication = True
+
+ def setUp(self):
+ #Acquire resources
+ super(TimerEventTest, self).setUp()
+ self.widget = MySpinButton(app=self.app)
+
+ def tearDown(self):
+ #Release resources
+ del self.widget
+ super(TimerEventTest, self).tearDown()
+
+ def testMethod(self):
+ #QWidget.timerEvent overrinding (protected inherited)
+ timer_id = self.widget.startTimer(0)
+
+ self.app.exec_()
+
+ self.widget.killTimer(timer_id)
+
+ self.assertTrue(self.widget.runs >= self.widget.max_runs)
+
+
+if __name__ == '__main__':
+ unittest.main()
+ #app = QApplication([])
+ #widget = MySpinButton(app=app)
+ #widget.startTimer(500)
+ #widget.show()
+ #app.exec_()
+
diff --git a/sources/pyside2/tests/QtWidgets/virtual_pure_override_test.py b/sources/pyside2/tests/QtWidgets/virtual_pure_override_test.py
new file mode 100644
index 000000000..d7b82d786
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/virtual_pure_override_test.py
@@ -0,0 +1,77 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtWidgets import QGraphicsScene, QGraphicsRectItem, QGraphicsView, QApplication
+from PySide2.QtGui import QBrush, QColor
+from PySide2.QtCore import QTimer
+from helper import UsesQApplication
+
+qgraphics_item_painted = False
+
+class RoundRectItem(QGraphicsRectItem):
+
+ def __init__(self, x, y, w, h):
+ QGraphicsRectItem.__init__(self, x, y, w, h)
+
+ def paint(self, painter, qstyleoptiongraphicsitem, qwidget):
+ global qgraphics_item_painted
+ qgraphics_item_painted = True
+
+
+class QGraphicsItemTest(UsesQApplication):
+
+ def createRoundRect(self, scene):
+ item = RoundRectItem(10, 10, 100, 100)
+ item.setBrush(QBrush(QColor(255, 0, 0)))
+ scene.addItem(item)
+ return item
+
+ def quit_app(self):
+ self.app.quit()
+
+ def test_setParentItem(self):
+ global qgraphics_item_painted
+
+ scene = QGraphicsScene()
+ scene.addText("test")
+ view = QGraphicsView(scene)
+
+ rect = self.createRoundRect(scene)
+ view.show()
+ QTimer.singleShot(1000, self.quit_app)
+ self.app.exec_()
+ self.assertTrue(qgraphics_item_painted)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtWidgets/wrong_return_test.py b/sources/pyside2/tests/QtWidgets/wrong_return_test.py
new file mode 100644
index 000000000..f50420a64
--- /dev/null
+++ b/sources/pyside2/tests/QtWidgets/wrong_return_test.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for Virtual functions with wrong return type'''
+
+import unittest
+import py3kcompat as py3k
+from PySide2 import QtWidgets
+from helper import UsesQApplication
+
+import warnings
+warnings.simplefilter('error')
+
+
+class MyWidget(QtWidgets.QWidget):
+ def __init__(self, parent=None):
+ super(MyWidget, self).__init__(parent)
+
+ def sizeHint(self):
+ pass
+
+class testCase(UsesQApplication):
+
+ def testVirtualReturn(self):
+ w = MyWidget()
+ if py3k.IS_PY3K:
+ self.assertWarns(RuntimeWarning, w.show)
+ else:
+ self.assertRaises(RuntimeWarning, w.show)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/QtWinExtras/CMakeLists.txt b/sources/pyside2/tests/QtWinExtras/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtWinExtras/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtWinExtras/this_module_loads_test.py b/sources/pyside2/tests/QtWinExtras/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtWinExtras/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtX11Extras/CMakeLists.txt b/sources/pyside2/tests/QtX11Extras/CMakeLists.txt
new file mode 100644
index 000000000..79c5c83a9
--- /dev/null
+++ b/sources/pyside2/tests/QtX11Extras/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(this_module_loads_test.py)
diff --git a/sources/pyside2/tests/QtX11Extras/this_module_loads_test.py b/sources/pyside2/tests/QtX11Extras/this_module_loads_test.py
new file mode 100644
index 000000000..0bf673546
--- /dev/null
+++ b/sources/pyside2/tests/QtX11Extras/this_module_loads_test.py
@@ -0,0 +1,39 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import os
+
+modname = os.path.basename(os.path.dirname(__file__))
+try:
+ exec("from PySide2 import {}".format(modname))
+ print("The module {} loads. That is the minimum test, folks :-)".format(modname))
+except ImportError:
+ print("The module {} did not load! Did you include all classes in CMake?".format(modname))
+ raise
diff --git a/sources/pyside2/tests/QtXml/CMakeLists.txt b/sources/pyside2/tests/QtXml/CMakeLists.txt
new file mode 100644
index 000000000..2c21bf87d
--- /dev/null
+++ b/sources/pyside2/tests/QtXml/CMakeLists.txt
@@ -0,0 +1,2 @@
+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
new file mode 100644
index 000000000..ca797445f
--- /dev/null
+++ b/sources/pyside2/tests/QtXml/qdomdocument_test.py
@@ -0,0 +1,96 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QByteArray
+from PySide2.QtXml import QDomDocument, QDomElement
+
+class QDomDocumentTest(unittest.TestCase):
+
+ def setUp(self):
+ self.dom = QDomDocument()
+
+ self.goodXmlData = QByteArray('''
+ <typesystem package="PySide2.QtXml">
+ <value-type name="QDomDocument"/>
+ <value-type name="QDomElement"/>
+ </typesystem>
+ ''')
+
+ self.badXmlData = QByteArray('''
+ <typesystem package="PySide2.QtXml">
+ <value-type name="QDomDocument">
+ </typesystem>
+ ''')
+
+ def tearDown(self):
+ del self.dom
+ del self.goodXmlData
+ del self.badXmlData
+
+ def testQDomDocumentSetContentWithBadXmlData(self):
+ '''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(errorLine, 4)
+ self.assertEqual(errorColumn, 21)
+
+ def testQDomDocumentSetContentWithGoodXmlData(self):
+ '''Sets valid xml as the QDomDocument contents.'''
+ ok, errorStr, errorLine, errorColumn = self.dom.setContent(self.goodXmlData, True)
+ self.assertTrue(ok)
+ self.assertEqual(errorStr, '')
+ self.assertEqual(errorLine, 0)
+ self.assertEqual(errorColumn, 0)
+
+ def testQDomDocumentData(self):
+ '''Checks the QDomDocument elements for the valid xml contents.'''
+
+ def checkAttribute(element, attribute, value):
+ self.assertTrue(isinstance(root, QDomElement))
+ self.assertFalse(element.isNull())
+ self.assertTrue(element.hasAttribute(attribute))
+ self.assertEqual(element.attribute(attribute), value)
+
+ ok, errorStr, errorLine, errorColumn = self.dom.setContent(self.goodXmlData, True)
+ root = self.dom.documentElement()
+ self.assertEqual(root.tagName(), 'typesystem')
+ checkAttribute(root, 'package', 'PySide2.QtXml')
+
+ child = root.firstChildElement('value-type')
+ checkAttribute(child, 'name', 'QDomDocument')
+
+ child = child.nextSiblingElement('value-type')
+ checkAttribute(child, 'name', 'QDomElement')
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtXml/qxmlsimplereader_test.py b/sources/pyside2/tests/QtXml/qxmlsimplereader_test.py
new file mode 100644
index 000000000..d5df57953
--- /dev/null
+++ b/sources/pyside2/tests/QtXml/qxmlsimplereader_test.py
@@ -0,0 +1,64 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+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))
+ reader.setProperty('foo', 'Something')
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/QtXmlPatterns/CMakeLists.txt b/sources/pyside2/tests/QtXmlPatterns/CMakeLists.txt
new file mode 100644
index 000000000..7f570f156
--- /dev/null
+++ b/sources/pyside2/tests/QtXmlPatterns/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(import_test.py)
diff --git a/sources/pyside2/tests/QtXmlPatterns/import_test.py b/sources/pyside2/tests/QtXmlPatterns/import_test.py
new file mode 100644
index 000000000..5c9c3fe5d
--- /dev/null
+++ b/sources/pyside2/tests/QtXmlPatterns/import_test.py
@@ -0,0 +1,58 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+from PySide2.QtXmlPatterns import QXmlSchema
+from helper import UsesQCoreApplication
+
+class QXmlPatternsTest(UsesQCoreApplication):
+
+ def testSchema(self):
+ data = QByteArray('''<?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/mac/CMakeLists.txt b/sources/pyside2/tests/mac/CMakeLists.txt
new file mode 100644
index 000000000..e1eb1a2fd
--- /dev/null
+++ b/sources/pyside2/tests/mac/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(qmacstyle_test.py)
diff --git a/sources/pyside2/tests/mac/qmacstyle_test.py b/sources/pyside2/tests/mac/qmacstyle_test.py
new file mode 100644
index 000000000..47925a435
--- /dev/null
+++ b/sources/pyside2/tests/mac/qmacstyle_test.py
@@ -0,0 +1,45 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# Qt5: this is gone: from PySide2.QtGui import QMacStyle
+from PySide2.QtWidgets import QApplication, QLabel, QStyleFactory
+from PySide2.QtCore import QObject
+
+import unittest
+
+from helper import UsesQApplication
+
+QMacStyle = type(QStyleFactory.create('Macintosh'))
+
+class QMacStyleTest(UsesQApplication):
+ def testWidgetStyle(self):
+ w = QLabel('Hello')
+ self.assertTrue(isinstance(w.style(), QMacStyle))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/manually/README.txt b/sources/pyside2/tests/manually/README.txt
new file mode 100644
index 000000000..da20e3824
--- /dev/null
+++ b/sources/pyside2/tests/manually/README.txt
@@ -0,0 +1,5 @@
+To run these tests is necessary some manuall input (most of then not supported by QTest[1]),
+because of that this is not part of automatic test context.
+
+
+[1]http://bugreports.qt.nokia.com/browse/QTBUG-13397
diff --git a/sources/pyside2/tests/manually/bug_841.py b/sources/pyside2/tests/manually/bug_841.py
new file mode 100644
index 000000000..dce0a3a75
--- /dev/null
+++ b/sources/pyside2/tests/manually/bug_841.py
@@ -0,0 +1,79 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import sys
+
+from PySide2.QtGui import QStandardItem, QStandardItemModel
+from PySide2.QtWidgets import QMainWindow, QTreeView, QAbstractItemView, QApplication, QMessageBox
+
+class Item(QStandardItem):
+ def __init__(self, text):
+ super(Item, self).__init__()
+ self.setText(text)
+ self.setDragEnabled(True)
+ self.setDropEnabled(True)
+
+ def clone(self):
+ ret = Item(self.text())
+ return ret
+
+class Project(QStandardItemModel):
+ def __init__(self):
+ super(Project, self).__init__()
+ self.setItemPrototype(Item("Prototype"))
+ # add some items so we have stuff to move around
+ self.appendRow(Item("ABC"))
+ self.appendRow(Item("DEF"))
+ self.appendRow(Item("GHI"))
+
+class MainWindow(QMainWindow):
+ def __init__(self):
+ super(MainWindow, self).__init__()
+
+ self.model = Project()
+ self.view = QTreeView(self)
+ self.view.setModel(self.model)
+ self.view.setDragEnabled(True)
+ self.view.setDragDropMode(QAbstractItemView.InternalMove)
+ self.setCentralWidget(self.view)
+
+ def mousePressEvent(self, e):
+ print(e.x(), e.y())
+ return QMainWindow.mousePressEvent(self, e)
+
+def main():
+ app = QApplication(sys.argv)
+ w = MainWindow()
+ w.show()
+ QMessageBox.information(None, "Info", "Just drag and drop the items.")
+ sys.exit(app.exec_())
+
+if __name__ == "__main__":
+ main()
diff --git a/sources/pyside2/tests/pysidetest/CMakeLists.txt b/sources/pyside2/tests/pysidetest/CMakeLists.txt
new file mode 100644
index 000000000..3a5437e62
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/CMakeLists.txt
@@ -0,0 +1,120 @@
+project(pysidetest)
+project(testbinding)
+
+cmake_minimum_required(VERSION 2.6)
+
+set(QT_USE_QTCORE 1)
+# no more supported: include(${QT_USE_FILE})
+add_definitions(${Qt5Core_DEFINITIONS})
+add_definitions(-DQT_SHARED)
+add_definitions(-DRXX_ALLOCATOR_INIT_0)
+
+find_package(Qt5Widgets)
+
+set(pysidetest_SRC
+testobject.cpp
+testview.cpp
+hiddenobject.cpp
+)
+
+set(pysidetest_MOC_HEADERS
+testobject.h
+testview.h
+hiddenobject.h
+)
+
+qt5_wrap_cpp(pysidetest_MOC_SRC ${pysidetest_MOC_HEADERS})
+
+set(testbinding_SRC
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/testobject_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/intvalue_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp_testobjectwithnamespace_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp2_testobjectwithoutnamespace_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/testview_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/testbinding_module_wrapper.cpp
+)
+
+make_path(testbinding_include_dirs ${pyside2_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../PySide2
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../libpyside
+ ${QT_INCLUDE_DIR}
+ ${QT_INCLUDE_DIR}/QtCore
+ ${QT_INCLUDE_DIR}/QtGui
+ ${QT_INCLUDE_DIR}/QtWidgets
+ )
+
+make_path(testbinding_typesystem_path ${CMAKE_CURRENT_SOURCE_DIR}
+ ${pyside2_SOURCE_DIR}
+ ${QtCore_SOURCE_DIR} ${QtGui_SOURCE_DIR} ${QtWidgets_SOURCE_DIR}
+ ${QtCore_BINARY_DIR} ${QtGui_BINARY_DIR} ${QtWidgets_BINARY_DIR}
+ )
+
+add_custom_command(OUTPUT ${testbinding_SRC}
+COMMAND ${SHIBOKEN_BINARY} ${GENERATOR_EXTRA_FLAGS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/pysidetest_global.h
+ --include-paths=${testbinding_include_dirs}
+ --typesystem-paths=${testbinding_typesystem_path}
+ --output-directory=${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_pysidetest.xml
+ --api-version=${SUPPORTED_QT_VERSION}
+WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+COMMENT "Running generator for test binding..."
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Gui_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+ ${SHIBOKEN_INCLUDE_DIR}
+ ${pyside2_SOURCE_DIR}
+ ${QtCore_GEN_DIR}
+ ${QtGui_GEN_DIR}
+ ${QtWidgets_GEN_DIR}
+ ${libpyside_SOURCE_DIR}
+ ${SHIBOKEN_PYTHON_INCLUDE_DIR})
+
+add_library(pysidetest SHARED ${pysidetest_SRC} ${pysidetest_MOC_SRC})
+target_link_libraries(pysidetest
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ )
+
+add_library(testbinding MODULE ${testbinding_SRC})
+set_property(TARGET testbinding PROPERTY PREFIX "")
+if(WIN32)
+ set_target_properties(testbinding PROPERTIES SUFFIX ".pyd")
+endif()
+target_link_libraries(testbinding
+ pysidetest
+ pyside2
+ ${PYTHON_LIBRARIES}
+ ${SHIBOKEN_LIBRARY}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ ${Qt5Widgets_LIBRARIES}
+ ${SBK_PYTHON_LIBRARIES})
+
+add_dependencies(testbinding pyside2 QtCore libpyside pysidetest)
+
+PYSIDE_TEST(decoratedslot_test.py)
+PYSIDE_TEST(delegatecreateseditor_test.py)
+PYSIDE_TEST(enum_test.py)
+PYSIDE_TEST(homonymoussignalandmethod_test.py)
+PYSIDE_TEST(list_signal_test.py)
+PYSIDE_TEST(modelview_test.py)
+PYSIDE_TEST(new_inherited_functions_test.py)
+PYSIDE_TEST(notify_id.py)
+PYSIDE_TEST(qvariant_test.py)
+PYSIDE_TEST(signalandnamespace_test.py)
+PYSIDE_TEST(signalwithdefaultvalue_test.py)
+PYSIDE_TEST(signalemissionfrompython_test.py)
+PYSIDE_TEST(version_test.py)
+PYSIDE_TEST(typedef_signal_test.py)
+PYSIDE_TEST(bug_1016.py)
+PYSIDE_TEST(utils_test.py)
+PYSIDE_TEST(mixin_signal_slots_test.py)
+PYSIDE_TEST(signal_slot_warning.py)
diff --git a/sources/pyside2/tests/pysidetest/bug_1016.py b/sources/pyside2/tests/pysidetest/bug_1016.py
new file mode 100644
index 000000000..745012248
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/bug_1016.py
@@ -0,0 +1,40 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from testbinding import *
+import unittest
+
+class TestBug1016 (unittest.TestCase):
+
+ def testIt(self):
+ obj = getHiddenObject()
+ self.assertEqual(obj.callMe(), None)
+ self.assertTrue(obj.wasCalled())
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/pysidetest/curr_errors.txt b/sources/pyside2/tests/pysidetest/curr_errors.txt
new file mode 100644
index 000000000..83b6e6212
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/curr_errors.txt
@@ -0,0 +1,12 @@
+Generating class model... [OK]
+Generating enum model... [OK]
+Generating namespace model... [OK]
+Resolving typedefs... [OK]
+Fixing class inheritance... [OK]
+Detecting inconsistencies in class model... [OK]
+[OK]
+ type 'QPyTextObject' is specified in typesystem, but not defined. This could potentially lead to compilation errors.
+
+
+
+Done, 1 warnings (1051 known issues)
diff --git a/sources/pyside2/tests/pysidetest/decoratedslot_test.py b/sources/pyside2/tests/pysidetest/decoratedslot_test.py
new file mode 100644
index 000000000..6268f331c
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/decoratedslot_test.py
@@ -0,0 +1,67 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QObject
+from testbinding import TestObject
+
+class Receiver(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+ self.called = False
+
+ def ReceiverDecorator(func):
+ def decoratedFunction(self, *args, **kw):
+ func(self, *args, **kw)
+ return decoratedFunction
+
+ # This method with the same name of the internal decorated function
+ # is here to test the binding capabilities.
+ def decoratedFunction(self):
+ pass
+
+ @ReceiverDecorator
+ def slot(self):
+ self.called = True
+
+
+class DecoratedSlotTest(unittest.TestCase):
+
+ def testCallingOfDecoratedSlot(self):
+ obj = TestObject(0)
+ receiver = Receiver()
+ obj.staticMethodDouble.connect(receiver.slot)
+ obj.emitStaticMethodDoubleSignal()
+ self.assertTrue(receiver.called)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/pysidetest/delegatecreateseditor_test.py b/sources/pyside2/tests/pysidetest/delegatecreateseditor_test.py
new file mode 100644
index 000000000..ec557340a
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/delegatecreateseditor_test.py
@@ -0,0 +1,83 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from helper import UsesQApplication
+
+from testbinding import TestView
+from PySide2.QtCore import Qt
+from PySide2.QtWidgets import QAbstractItemDelegate, QComboBox
+
+id_text = 'This is me'
+
+class DelegateDoesntKeepReferenceToEditor(QAbstractItemDelegate):
+ def createEditor(self, parent, option, index):
+ comboBox = QComboBox(parent)
+ comboBox.addItem(id_text)
+ return comboBox
+
+
+class DelegateKeepsReferenceToEditor(QAbstractItemDelegate):
+ def __init__(self, parent=None):
+ QAbstractItemDelegate.__init__(self, parent)
+ self.comboBox = QComboBox()
+ self.comboBox.addItem(id_text)
+
+ def createEditor(self, parent, option, index):
+ self.comboBox.setParent(parent)
+ return self.comboBox
+
+
+class EditorCreatedByDelegateTest(UsesQApplication):
+
+ def testDelegateDoesntKeepReferenceToEditor(self):
+ view = TestView(None)
+ delegate = DelegateDoesntKeepReferenceToEditor()
+ view.setItemDelegate(delegate)
+ editor = view.getEditorWidgetFromItemDelegate()
+ self.assertEqual(type(editor), QComboBox)
+ self.assertEqual(editor.count(), 1)
+ self.assertEqual(editor.itemData(0, Qt.DisplayRole), id_text)
+ editor.metaObject()
+
+ def testDelegateKeepsReferenceToEditor(self):
+ view = TestView(None)
+ delegate = DelegateKeepsReferenceToEditor()
+ view.setItemDelegate(delegate)
+ editor = view.getEditorWidgetFromItemDelegate()
+ self.assertEqual(type(editor), QComboBox)
+ self.assertEqual(editor.count(), 1)
+ self.assertEqual(editor.itemData(0, Qt.DisplayRole), id_text)
+ editor.metaObject()
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/pysidetest/enum_test.py b/sources/pyside2/tests/pysidetest/enum_test.py
new file mode 100644
index 000000000..b3cb4e4d7
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/enum_test.py
@@ -0,0 +1,44 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from testbinding import Enum1, TestObjectWithoutNamespace
+
+class ListConnectionTest(unittest.TestCase):
+
+ def testEnumVisibility(self):
+ self.assertEqual(Enum1.Option1, 1)
+ self.assertEqual(Enum1.Option2, 2)
+ self.assertEqual(TestObjectWithoutNamespace.Enum2.Option3, 3)
+ self.assertEqual(TestObjectWithoutNamespace.Enum2.Option4, 4)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/pysidetest/hiddenobject.cpp b/sources/pyside2/tests/pysidetest/hiddenobject.cpp
new file mode 100644
index 000000000..da6d0434b
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/hiddenobject.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "hiddenobject.h"
+
+void HiddenObject::callMe()
+{
+ m_called = true;
+}
+
+bool HiddenObject::wasCalled()
+{
+ return m_called;
+}
+
+QObject* getHiddenObject()
+{
+ return new HiddenObject();
+}
diff --git a/sources/pyside2/tests/pysidetest/hiddenobject.h b/sources/pyside2/tests/pysidetest/hiddenobject.h
new file mode 100644
index 000000000..ba96cec9c
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/hiddenobject.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HIDDENOBJECT_H
+#define HIDDENOBJECT_H
+
+#ifdef pysidetest_EXPORTS
+#define PYSIDE_EXPORTS 1
+#endif
+#include "pysidemacros.h"
+#include <QObject>
+
+// This class shouldn't be exported!
+class HiddenObject : public QObject
+{
+ Q_OBJECT
+public:
+ HiddenObject() : m_called(false) {}
+ Q_INVOKABLE void callMe();
+public slots:
+ bool wasCalled();
+private:
+ bool m_called;
+};
+
+// Return a instance of HiddenObject
+PYSIDE_API QObject* getHiddenObject();
+
+
+#endif
diff --git a/sources/pyside2/tests/pysidetest/homonymoussignalandmethod_test.py b/sources/pyside2/tests/pysidetest/homonymoussignalandmethod_test.py
new file mode 100644
index 000000000..6be6245f9
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/homonymoussignalandmethod_test.py
@@ -0,0 +1,81 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from testbinding import TestObject
+
+'''Tests the behaviour of homonymous signals and slots.'''
+
+class HomonymousSignalAndMethodTest(unittest.TestCase):
+
+ def setUp(self):
+ self.value = 123
+ self.called = False
+ self.obj = TestObject(self.value)
+
+ def tearDown(self):
+ del self.value
+ del self.called
+ del self.obj
+
+ def testIdValueSignalEmission(self):
+ def callback(idValue):
+ self.assertEqual(idValue, self.value)
+ self.obj.idValue.connect(callback)
+ self.obj.emitIdValueSignal()
+
+ def testStaticMethodDoubleSignalEmission(self):
+ def callback():
+ self.called = True
+ self.obj.staticMethodDouble.connect(callback)
+ self.obj.emitStaticMethodDoubleSignal()
+ self.assertTrue(self.called)
+
+ def testSignalNotCallable(self):
+ self.assertRaises(TypeError, self.obj.justASignal)
+
+ def testCallingInstanceMethodWithArguments(self):
+ self.assertRaises(TypeError, TestObject.idValue, 1)
+
+ def testCallingInstanceMethodWithoutArguments(self):
+ self.assertRaises(TypeError, TestObject.idValue)
+
+ def testHomonymousSignalAndMethod(self):
+ self.assertEqual(self.obj.idValue(), self.value)
+
+ def testHomonymousSignalAndStaticMethod(self):
+ self.assertEqual(TestObject.staticMethodDouble(3), 6)
+
+ def testHomonymousSignalAndStaticMethodFromInstance(self):
+ self.assertEqual(self.obj.staticMethodDouble(4), 8)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/pysidetest/list_signal_test.py b/sources/pyside2/tests/pysidetest/list_signal_test.py
new file mode 100644
index 000000000..1a130070e
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/list_signal_test.py
@@ -0,0 +1,51 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from testbinding import TestObject
+from PySide2.QtCore import QObject
+
+class ListConnectionTest(unittest.TestCase):
+
+ def childrenChanged(self, children):
+ self._child = children[0]
+
+ def testConnection(self):
+ o = TestObject(0)
+ c = QObject()
+ c.setObjectName("child")
+ self._child = None
+ o.childrenChanged.connect(self.childrenChanged)
+ o.addChild(c)
+ self.assertEqual(self._child.objectName(), "child")
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/pysidetest/mixin_signal_slots_test.py b/sources/pyside2/tests/pysidetest/mixin_signal_slots_test.py
new file mode 100644
index 000000000..cdd9ea19a
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/mixin_signal_slots_test.py
@@ -0,0 +1,216 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' PYSIDE-315: https://bugreports.qt.io/browse/PYSIDE-315
+ Test that all signals and slots of a class (including any mixin classes)
+ are registered at type parsing time. Also test that the signal and slot
+ indices do not change after signal connection or emission. '''
+
+import unittest
+from PySide2 import QtCore
+
+class Mixin(object):
+ mixinSignal = QtCore.Signal()
+ def __init__(self, *args, **kwargs):
+ super(Mixin,self).__init__(*args, **kwargs)
+
+class MixinTwo(Mixin):
+ mixinTwoSignal = QtCore.Signal()
+
+ def __init__(self, *args, **kwargs):
+ super(MixinTwo,self).__init__(*args, **kwargs)
+ self.mixinTwoSlotCalled = False
+
+ @QtCore.Slot()
+ def mixinTwoSlot(self):
+ self.mixinTwoSlotCalled = True
+
+class MixinThree(object):
+ mixinThreeSignal = QtCore.Signal()
+
+ def __init__(self, *args, **kwargs):
+ super(MixinThree,self).__init__(*args, **kwargs)
+ self.mixinThreeSlotCalled = False
+
+ @QtCore.Slot()
+ def mixinThreeSlot(self):
+ self.mixinThreeSlotCalled = True
+
+class Derived(Mixin, QtCore.QObject):
+ derivedSignal = QtCore.Signal(str)
+
+ def __init__(self):
+ super(Derived,self).__init__()
+ self.derivedSlotCalled = False
+ self.derivedSlotString = ''
+
+ @QtCore.Slot(str)
+ def derivedSlot(self, theString):
+ self.derivedSlotCalled = True
+ self.derivedSlotString = theString
+
+class MultipleDerived(MixinTwo, MixinThree, Mixin, QtCore.QObject):
+ derivedSignal = QtCore.Signal(str)
+
+ def __init__(self):
+ super(MultipleDerived,self).__init__()
+ self.derivedSlotCalled = False
+ self.derivedSlotString = ''
+
+ @QtCore.Slot(str)
+ def derivedSlot(self, theString):
+ self.derivedSlotCalled = True
+ self.derivedSlotString = theString
+
+
+class MixinTest(unittest.TestCase):
+ def testMixinSignalSlotRegistration(self):
+ obj = Derived()
+ m = obj.metaObject()
+
+ # Should contain 2 signals and 1 slot immediately after type parsing
+ self.assertEqual(m.methodCount() - m.methodOffset(), 3)
+
+ # Save method indices to check that they do not change
+ methodIndices = {}
+ for i in range(m.methodOffset(), m.methodCount()):
+ signature = m.method(i).methodSignature()
+ methodIndices[signature] = i
+
+ # Check derivedSignal emission
+ obj.derivedSignal.connect(obj.derivedSlot)
+ obj.derivedSignal.emit('emit1')
+ self.assertTrue(obj.derivedSlotCalled)
+ obj.derivedSlotCalled = False
+
+ # Check derivedSignal emission after mixingSignal connection
+ self.outsideSlotCalled = False
+ @QtCore.Slot()
+ def outsideSlot():
+ self.outsideSlotCalled = True
+
+ obj.mixinSignal.connect(outsideSlot)
+ obj.derivedSignal.emit('emit2')
+ self.assertTrue(obj.derivedSlotCalled)
+ self.assertFalse(self.outsideSlotCalled)
+ obj.derivedSlotCalled = False
+
+ # Check mixinSignal emission
+ obj.mixinSignal.emit()
+ self.assertTrue(self.outsideSlotCalled)
+ self.assertFalse(obj.derivedSlotCalled)
+ self.outsideSlotCalled = False
+
+ # Check that method indices haven't changed.
+ # Make sure to requery for the meta object, to check that a new one was not
+ # created as a child of the old one.
+ m = obj.metaObject()
+ self.assertEqual(m.methodCount() - m.methodOffset(), 3)
+ for i in range(m.methodOffset(), m.methodCount()):
+ signature = m.method(i).methodSignature()
+ self.assertEqual(methodIndices[signature], i)
+
+
+ def testMixinSignalSlotRegistrationWithMultipleInheritance(self):
+ obj = MultipleDerived()
+ m = obj.metaObject()
+
+ # Should contain 4 signals and 3 slots immediately after type parsing
+ self.assertEqual(m.methodCount() - m.methodOffset(), 7)
+
+ # Save method indices to check that they do not change
+ methodIndices = {}
+ for i in range(m.methodOffset(), m.methodCount()):
+ signature = m.method(i).methodSignature()
+ methodIndices[signature] = i
+
+ # Check derivedSignal emission
+ obj.derivedSignal.connect(obj.derivedSlot)
+ obj.derivedSignal.emit('emit1')
+ self.assertTrue(obj.derivedSlotCalled)
+ self.assertFalse(obj.mixinTwoSlotCalled)
+ self.assertFalse(obj.mixinThreeSlotCalled)
+ obj.derivedSlotCalled = False
+
+ # Check derivedSignal emission after mixinThreeSignal connection
+ self.outsideSlotCalled = False
+ @QtCore.Slot()
+ def outsideSlot():
+ self.outsideSlotCalled = True
+
+ obj.mixinThreeSignal.connect(obj.mixinThreeSlot)
+ obj.mixinThreeSignal.connect(outsideSlot)
+ obj.derivedSignal.emit('emit2')
+ self.assertTrue(obj.derivedSlotCalled)
+ self.assertFalse(obj.mixinTwoSlotCalled)
+ self.assertFalse(obj.mixinThreeSlotCalled)
+ self.assertFalse(self.outsideSlotCalled)
+ obj.derivedSlotCalled = False
+
+ # Check mixinThreeSignal emission
+ obj.mixinThreeSignal.emit()
+ self.assertTrue(self.outsideSlotCalled)
+ self.assertTrue(obj.mixinThreeSlotCalled)
+ self.assertFalse(obj.derivedSlotCalled)
+ self.assertFalse(obj.mixinTwoSlotCalled)
+ self.outsideSlotCalled = False
+ obj.mixinThreeSlotCalled = False
+
+ # Check mixinTwoSignal emission
+ obj.mixinTwoSignal.connect(obj.mixinTwoSlot)
+ obj.mixinTwoSignal.emit()
+ self.assertTrue(obj.mixinTwoSlotCalled)
+ self.assertFalse(obj.mixinThreeSlotCalled)
+ self.assertFalse(obj.derivedSlotCalled)
+ self.assertFalse(self.outsideSlotCalled)
+ obj.mixinTwoSlotCalled = False
+
+ # Check mixinSignal emission
+ obj.mixinSignal.connect(outsideSlot)
+ obj.mixinSignal.emit()
+ self.assertTrue(self.outsideSlotCalled)
+ self.assertFalse(obj.mixinTwoSlotCalled)
+ self.assertFalse(obj.mixinThreeSlotCalled)
+ self.assertFalse(obj.derivedSlotCalled)
+ self.outsideSlotCalled = False
+
+ # Check that method indices haven't changed.
+ # Make sure to requery for the meta object, to check that a new one was not
+ # created as a child of the old one.
+ m = obj.metaObject()
+ self.assertEqual(m.methodCount() - m.methodOffset(), 7)
+ for i in range(m.methodOffset(), m.methodCount()):
+ signature = m.method(i).methodSignature()
+ self.assertEqual(methodIndices[signature], i)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/pysidetest/modelview_test.py b/sources/pyside2/tests/pysidetest/modelview_test.py
new file mode 100644
index 000000000..3a02946dc
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/modelview_test.py
@@ -0,0 +1,99 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import py3kcompat as py3k
+from testbinding import TestView
+from PySide2.QtCore import QAbstractListModel, QObject, QModelIndex
+
+'''Tests model/view relationship.'''
+
+object_name = 'test object'
+
+class MyObject(QObject):
+ pass
+
+class ListModelKeepsReference(QAbstractListModel):
+ def __init__(self, parent=None):
+ QAbstractListModel.__init__(self, parent)
+ self.obj = MyObject()
+ self.obj.setObjectName(object_name)
+
+ def rowCount(self, parent=QModelIndex()):
+ return 1
+
+ def data(self, index, role):
+ return self.obj
+
+class ListModelDoesntKeepsReference(QAbstractListModel):
+ def rowCount(self, parent=QModelIndex()):
+ return 1
+
+ def data(self, index, role):
+ obj = MyObject()
+ obj.setObjectName(object_name)
+ return obj
+
+class ListModelThatReturnsString(QAbstractListModel):
+ def rowCount(self, parent=QModelIndex()):
+ return 1
+
+ def data(self, index, role):
+ self.obj = 'string'
+ return self.obj
+
+
+class ModelViewTest(unittest.TestCase):
+
+ def testListModelDoesntKeepsReference(self):
+ model = ListModelDoesntKeepsReference()
+ view = TestView(model)
+ obj = view.getData()
+ self.assertEqual(type(obj), MyObject)
+ self.assertEqual(obj.objectName(), object_name)
+ obj.metaObject()
+
+ def testListModelKeepsReference(self):
+ model = ListModelKeepsReference()
+ view = TestView(model)
+ obj = view.getData()
+ self.assertEqual(type(obj), MyObject)
+ self.assertEqual(obj.objectName(), object_name)
+
+ def testListModelThatReturnsString(self):
+ model = ListModelThatReturnsString()
+ view = TestView(model)
+ obj = view.getData()
+ self.assertEqual(type(obj), py3k.unicode)
+ self.assertEqual(obj, 'string')
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py b/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py
new file mode 100644
index 000000000..bd5db7661
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py
@@ -0,0 +1,215 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions(). For further
+## information use the contact form at https://www.qt.io/contact-us().
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3().0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+import sys
+import os
+import unittest
+
+import PySide2.QtCore
+
+# This test tests the existence and callability of the newly existing functions,
+# after the inheritance was made complete in the course of PYSIDE-331.
+
+def warn_essential(modname):
+ print(80 * "*")
+ print("*** Warning: '{}' is an essential module! Are you sure to skip it?"
+ .format(modname))
+ print(80 * "*")
+
+new_functions = """
+ PySide2.QtCore.QAbstractItemModel().parent()
+ PySide2.QtCore.QAbstractListModel().parent()
+ PySide2.QtCore.QAbstractTableModel().parent()
+ PySide2.QtCore.QFile().resize(qint64)
+ m = PySide2.QtCore.QMutex(); m.tryLock(); m.unlock() # prevent a message "QMutex: destroying locked mutex"
+ PySide2.QtCore.QSortFilterProxyModel().parent()
+ PySide2.QtCore.QTemporaryFile(tfarg).open(openMode)
+"""
+try:
+ modname = "PySide2.QtGui"
+ exec("import " + modname)
+ 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
+ # PySide2.QtGui.QTextTable(qTextDocument).setFormat(qTextFormat) # Segmentation fault: 11
+ """
+except ImportError:
+ warn_essential(modname)
+try:
+ modname = "PySide2.QtWidgets"
+ exec("import " + modname)
+ new_functions += """
+ PySide2.QtWidgets.QAbstractItemView().update()
+ PySide2.QtWidgets.QApplication.palette()
+ PySide2.QtWidgets.QApplication.setFont(qFont)
+ 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()
+ PySide2.QtWidgets.QFontDialog().open()
+ PySide2.QtWidgets.QGestureEvent([]).accept()
+ PySide2.QtWidgets.QGestureEvent([]).ignore()
+ PySide2.QtWidgets.QGestureEvent([]).isAccepted()
+ PySide2.QtWidgets.QGestureEvent([]).setAccepted(bool)
+ # PySide2.QtWidgets.QGraphicsView().render(qPaintDevice,qPoint,qRegion,renderFlags) # QPaintDevice: NotImplementedError
+ PySide2.QtWidgets.QGridLayout().addWidget(qWidget)
+ PySide2.QtWidgets.QHeaderView(orientation).initStyleOption(qStyleOptionFrame)
+ PySide2.QtWidgets.QInputDialog().open()
+ PySide2.QtWidgets.QLineEdit().addAction(qAction)
+ PySide2.QtWidgets.QListWidget().closePersistentEditor(qModelIndex)
+ PySide2.QtWidgets.QListWidget().openPersistentEditor(qModelIndex)
+ PySide2.QtWidgets.QMessageBox().open()
+ PySide2.QtWidgets.QPlainTextEdit.find(quintptr)
+ PySide2.QtWidgets.QProgressDialog().open()
+ PySide2.QtWidgets.QStackedLayout().widget()
+ # PySide2.QtWidgets.QStylePainter().begin(qPaintDevice) # QPaintDevice: NotImplementedError
+ PySide2.QtWidgets.QTableWidget().closePersistentEditor(qModelIndex)
+ PySide2.QtWidgets.QTableWidget().openPersistentEditor(qModelIndex)
+ PySide2.QtWidgets.QTextEdit.find(quintptr)
+ PySide2.QtWidgets.QTreeWidget().closePersistentEditor(qModelIndex)
+ PySide2.QtWidgets.QTreeWidget().openPersistentEditor(qModelIndex)
+ """
+except ImportError:
+ warn_essential(modname)
+try:
+ modname = "PySide2.QtPrintSupport"
+ exec("import " + modname)
+ new_functions += """
+ # PySide2.QtPrintSupport.QPageSetupDialog().open() # Segmentation fault: 11
+ # PySide2.QtPrintSupport.QPrintDialog().open() # opens the dialog, but works
+ PySide2.QtPrintSupport.QPrintDialog().printer()
+ PySide2.QtPrintSupport.QPrintPreviewDialog().open() # note: this prints something, but really shouldn't ;-)
+ """
+except ImportError:
+ warn_essential(modname)
+try:
+ import PySide2.QtHelp
+ new_functions += """
+ PySide2.QtHelp.QHelpContentModel().parent()
+ # PySide2.QtHelp.QHelpIndexModel().createIndex(int,int,quintptr) # returned NULL without setting an error
+ # PySide2.QtHelp.QHelpIndexModel().createIndex(int,int,object()) # returned NULL without setting an error
+ """
+except ImportError:
+ pass
+try:
+ import PySide2.QtQuick
+ new_functions += """
+ PySide2.QtQuick.QQuickPaintedItem().update()
+ """
+except ImportError:
+ pass
+
+
+class MainTest(unittest.TestCase):
+
+ def testNewInheriedFunctionsExist(self):
+ """
+ Run all new method signarures
+ """
+ for app in "QtWidgets.QApplication", "QtGui.QGuiApplication", "QtCore.QCoreApplication":
+ try:
+ exec("qApp = PySide2.{0}([]) or PySide2.{0}.instance()".format(app))
+ break
+ except AttributeError:
+ continue
+ bool = True
+ int = 42
+ qint64 = 42
+ tfarg = os.path.join(PySide2.QtCore.QDir.tempPath(), "XXXXXX.tmp")
+ orientation = PySide2.QtCore.Qt.Orientation()
+ openMode = PySide2.QtCore.QIODevice.OpenMode(PySide2.QtCore.QIODevice.ReadOnly)
+ qModelIndex = PySide2.QtCore.QModelIndex()
+ transformationMode = PySide2.QtCore.Qt.TransformationMode()
+ qObject = PySide2.QtCore.QObject()
+ qPoint = PySide2.QtCore.QPoint()
+ 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
+ qFont = PySide2.QtGui.QFont()
+ qPalette = PySide2.QtGui.QPalette()
+ except AttributeError:
+ pass
+ try:
+ PySide2.QtWidgets
+ direction = PySide2.QtWidgets.QBoxLayout.Direction()
+ qWidget = PySide2.QtWidgets.QWidget()
+ qStyleOptionFrame = PySide2.QtWidgets.QStyleOptionFrame()
+ qAction = PySide2.QtWidgets.QAction(qObject)
+ renderFlags = PySide2.QtWidgets.QWidget.RenderFlags
+ except AttributeError:
+ pass
+
+ for func in new_functions.splitlines():
+ func = func.strip()
+ if func.startswith("#"):
+ # this is a crashing or otherwise untestable function
+ print(func)
+ continue
+ try:
+ exec(func)
+ except NotImplementedError:
+ print(func, "# raises NotImplementedError")
+ else:
+ print(func)
+
+ def testQAppSignatures(self):
+ """
+ Verify that qApp.palette owns three signatures, especially
+ palette() without argument.
+ """
+ try:
+ qApp = (PySide2.QtWidgets.QApplication.instance() or
+ PySide2.QtWidgets.QApplication([]))
+ except AttributeError:
+ unittest.TestCase().skipTest("this test makes only sense if QtWidgets is available.")
+ try:
+ PySide2.QtWidgets.QApplication.palette(42) # raises
+ except TypeError as e:
+ lines = e.args[0].splitlines()
+ heading_pos = lines.index("Supported signatures:")
+ lines = lines[heading_pos+1:]
+ self.assertEqual(len(lines), 3)
+ txt = '\n'.join(lines)
+ print("Signatures found:")
+ print(txt)
+ self.assertTrue("palette()" in txt)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/pysidetest/notify_id.py b/sources/pyside2/tests/pysidetest/notify_id.py
new file mode 100644
index 000000000..09226e6e2
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/notify_id.py
@@ -0,0 +1,76 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QObject, Signal, Property, Slot
+
+'''Tests that the signal notify id of a property is correct, aka corresponds to the initially set
+notify method.'''
+
+class Foo(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+ self._prop = "Empty"
+
+ def getProp(self):
+ return self._prop
+
+ def setProp(self, value):
+ if value != self._prop:
+ self._prop = value
+ self.propChanged.emit()
+
+ # Inside the dynamic QMetaObject, the methods have to be sorted, so that this slot comes
+ # after any signals. That means the property notify id has to be updated, to have the correct
+ # relative method id.
+ @Slot()
+ def randomSlot():
+ pass
+
+ propChanged = Signal()
+ prop = Property(str, getProp, setProp, notify=propChanged)
+
+class NotifyIdSignal(unittest.TestCase):
+ def setUp(self):
+ self.obj = Foo()
+
+ def tearDown(self):
+ del self.obj
+
+ def testSignalEmission(self):
+ metaObject = self.obj.metaObject()
+ propertyIndex = metaObject.indexOfProperty("prop")
+ property = metaObject.property(propertyIndex)
+
+ signalIndex = property.notifySignalIndex()
+ signal = metaObject.method(signalIndex)
+ signalName = signal.name()
+ self.assertEqual(signalName, "propChanged")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/pysidetest/pysidetest_global.h b/sources/pyside2/tests/pysidetest/pysidetest_global.h
new file mode 100644
index 000000000..9fc1828e1
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/pysidetest_global.h
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// PySide global.h file
+#include "pyside2_global.h"
+#include "testobject.h"
+#include "testview.h"
+#define PYSIDE_API
+#include "hiddenobject.h"
diff --git a/sources/pyside2/tests/pysidetest/qvariant_test.py b/sources/pyside2/tests/pysidetest/qvariant_test.py
new file mode 100644
index 000000000..46c9ddbda
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/qvariant_test.py
@@ -0,0 +1,45 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from testbinding import TestObject
+from PySide2.QtCore import Qt
+from PySide2.QtGui import QKeySequence
+
+from helper import UsesQApplication
+
+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)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/pysidetest/signal_slot_warning.py b/sources/pyside2/tests/pysidetest/signal_slot_warning.py
new file mode 100644
index 000000000..fd3d41b52
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/signal_slot_warning.py
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' PYSIDE-315: https://bugreports.qt.io/browse/PYSIDE-315
+ Test that creating a signal in the wrong order triggers a warning. '''
+
+from __future__ import print_function
+
+import unittest
+import PySide2.QtCore as QtCore
+import sys
+import warnings
+
+
+class Whatever(QtCore.QObject):
+ echoSignal = QtCore.Signal(str)
+
+ def __init__(self):
+ super(Whatever, self).__init__()
+ self.echoSignal.connect(self.mySlot)
+
+ def mySlot(self, v):
+ pass
+
+class WarningTest(unittest.TestCase):
+ def testSignalSlotWarning(self):
+ # we create an object. This gives no warning.
+ obj = Whatever()
+ # then we insert a signal after slots have been created.
+ setattr(Whatever, "foo", QtCore.Signal())
+ with warnings.catch_warnings(record=True) as w:
+ # Cause all warnings to always be triggered.
+ warnings.simplefilter("always")
+ # Trigger a warning.
+ obj.foo.connect(obj.mySlot)
+ # Verify some things
+ assert issubclass(w[-1].category, RuntimeWarning)
+ assert "*** Sort Warning ***" in str(w[-1].message)
+ # note that this warning cannot be turned into an error (too hard)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside2/tests/pysidetest/signalandnamespace_test.py b/sources/pyside2/tests/pysidetest/signalandnamespace_test.py
new file mode 100644
index 000000000..846e5b2b9
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/signalandnamespace_test.py
@@ -0,0 +1,120 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from testbinding import PySideCPP, TestObjectWithoutNamespace
+
+class ModelViewTest(unittest.TestCase):
+
+ def callback(self, o):
+ self._called = o
+
+ def testWithoutNamespace(self):
+ self._called = None
+ o = PySideCPP.TestObjectWithNamespace(None)
+ o.emitSignal.connect(self.callback)
+ o.emitSignal.emit(o)
+ self.assertTrue(o == self._called)
+
+ self._called = None
+ o = PySideCPP.TestObjectWithNamespace(None)
+ o.emitSignal.connect(self.callback)
+ o.callSignal(o)
+ self.assertTrue(o == self._called)
+
+ def testWithNamespace(self):
+ self._called = None
+ o = PySideCPP.TestObjectWithNamespace(None)
+ o.emitSignalWithNamespace.connect(self.callback)
+ o.emitSignalWithNamespace.emit(o)
+ self.assertTrue(o == self._called)
+
+ self._called = None
+ o = PySideCPP.TestObjectWithNamespace(None)
+ o.emitSignalWithNamespace.connect(self.callback)
+ o.callSignalWithNamespace(o)
+ self.assertTrue(o == self._called)
+
+
+ def testWithoutNamespace1(self):
+ self._called = None
+ o = TestObjectWithoutNamespace(None)
+ o.emitSignal.connect(self.callback)
+ o.emitSignal.emit(o)
+ self.assertTrue(o == self._called)
+
+ self._called = None
+ o = TestObjectWithoutNamespace(None)
+ o.emitSignal.connect(self.callback)
+ o.callSignal(o)
+ self.assertTrue(o == self._called)
+
+ def testWithNamespace1(self):
+ self._called = None
+ o = TestObjectWithoutNamespace(None)
+ o.emitSignalWithNamespace.connect(self.callback)
+ o.emitSignalWithNamespace.emit(o)
+ self.assertTrue(o == self._called)
+
+ self._called = None
+ o = TestObjectWithoutNamespace(None)
+ o.emitSignalWithNamespace.connect(self.callback)
+ o.callSignalWithNamespace(o)
+ self.assertTrue(o == self._called)
+
+ def testTypedfWithouNamespace(self):
+ self._called = None
+ o = PySideCPP.TestObjectWithNamespace(None)
+ o.emitSignalWithTypedef.connect(self.callback)
+ o.emitSignalWithTypedef.emit(10)
+ self.assertEqual(10, self._called)
+
+ self._called = None
+ o = PySideCPP.TestObjectWithNamespace(None)
+ o.emitSignalWithTypedef.connect(self.callback)
+ o.callSignalWithTypedef(10)
+ self.assertEqual(10, self._called)
+
+ def testTypedefWithNamespace(self):
+ self._called = None
+ o = TestObjectWithoutNamespace(None)
+ o.emitSignalWithTypedef.connect(self.callback)
+ o.emitSignalWithTypedef.emit(10)
+ self.assertEqual(10, self._called)
+
+ self._called = None
+ o = TestObjectWithoutNamespace(None)
+ o.emitSignalWithTypedef.connect(self.callback)
+ o.callSignalWithTypedef(10)
+ self.assertEqual(10, self._called)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/pysidetest/signalemissionfrompython_test.py b/sources/pyside2/tests/pysidetest/signalemissionfrompython_test.py
new file mode 100644
index 000000000..1bd08c071
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/signalemissionfrompython_test.py
@@ -0,0 +1,107 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from testbinding import TestObject
+from PySide2.QtCore import QObject, SIGNAL
+
+'''Tests the behaviour of signals with default values when emitted from Python.'''
+
+class SignalEmissionFromPython(unittest.TestCase):
+
+ def setUp(self):
+ self.obj1 = TestObject(0)
+ self.obj2 = TestObject(0)
+ self.one_called = 0
+ self.two_called = 0
+
+ def tearDown(self):
+ del self.obj1
+ del self.obj2
+ del self.one_called
+ del self.two_called
+
+ def testConnectNewStyleEmitVoidSignal(self):
+ def callbackOne():
+ self.one_called += 1
+ self.obj2.signalWithDefaultValue.emit()
+ def callbackTwo():
+ self.two_called += 1
+ self.obj1.signalWithDefaultValue.connect(callbackOne)
+ self.obj2.signalWithDefaultValue.connect(callbackTwo)
+ self.obj1.emitSignalWithDefaultValue_void()
+ self.obj2.emitSignalWithDefaultValue_void()
+ self.assertEqual(self.one_called, 1)
+ self.assertEqual(self.two_called, 2)
+
+ def testConnectOldStyleEmitVoidSignal(self):
+ def callbackOne():
+ self.one_called += 1
+ self.obj2.signalWithDefaultValue.emit()
+ def callbackTwo():
+ self.two_called += 1
+ QObject.connect(self.obj1, SIGNAL('signalWithDefaultValue()'), callbackOne)
+ QObject.connect(self.obj2, SIGNAL('signalWithDefaultValue()'), callbackTwo)
+ self.obj1.emitSignalWithDefaultValue_void()
+ self.obj2.emitSignalWithDefaultValue_void()
+ self.assertEqual(self.one_called, 1)
+ self.assertEqual(self.two_called, 2)
+
+ def testConnectNewStyleEmitBoolSignal(self):
+ def callbackOne():
+ self.one_called += 1
+ self.obj2.signalWithDefaultValue[bool].emit(True)
+ def callbackTwo():
+ self.two_called += 1
+ self.obj1.signalWithDefaultValue.connect(callbackOne)
+ self.obj2.signalWithDefaultValue.connect(callbackTwo)
+ self.obj1.emitSignalWithDefaultValue_void()
+ self.obj2.emitSignalWithDefaultValue_void()
+ self.assertEqual(self.one_called, 1)
+ self.assertEqual(self.two_called, 2)
+
+ def testConnectOldStyleEmitBoolSignal(self):
+ def callbackOne():
+ self.one_called += 1
+ self.obj2.signalWithDefaultValue[bool].emit(True)
+ def callbackTwo():
+ self.two_called += 1
+ QObject.connect(self.obj1, SIGNAL('signalWithDefaultValue()'), callbackOne)
+ QObject.connect(self.obj2, SIGNAL('signalWithDefaultValue()'), callbackTwo)
+ self.obj1.emitSignalWithDefaultValue_void()
+ self.obj2.emitSignalWithDefaultValue_void()
+ self.assertEqual(self.one_called, 1)
+ self.assertEqual(self.two_called, 2)
+
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/pysidetest/signalwithdefaultvalue_test.py b/sources/pyside2/tests/pysidetest/signalwithdefaultvalue_test.py
new file mode 100644
index 000000000..8014d4879
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/signalwithdefaultvalue_test.py
@@ -0,0 +1,95 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from testbinding import TestObject
+from PySide2.QtCore import QObject, SIGNAL
+
+'''Tests the behaviour of signals with default values.'''
+
+class SignalWithDefaultValueTest(unittest.TestCase):
+
+ def setUp(self):
+ self.obj = TestObject(0)
+ self.void_called = False
+ self.bool_called = False
+
+ def tearDown(self):
+ del self.obj
+ del self.void_called
+ del self.bool_called
+
+ def testConnectNewStyleEmitVoidSignal(self):
+ def callbackVoid():
+ self.void_called = True
+ def callbackBool(value):
+ self.bool_called = True
+ self.obj.signalWithDefaultValue.connect(callbackVoid)
+ self.obj.signalWithDefaultValue[bool].connect(callbackBool)
+ self.obj.emitSignalWithDefaultValue_void()
+ self.assertTrue(self.void_called)
+ self.assertTrue(self.bool_called)
+
+ def testConnectNewStyleEmitBoolSignal(self):
+ def callbackVoid():
+ self.void_called = True
+ def callbackBool(value):
+ self.bool_called = True
+ self.obj.signalWithDefaultValue.connect(callbackVoid)
+ self.obj.signalWithDefaultValue[bool].connect(callbackBool)
+ self.obj.emitSignalWithDefaultValue_bool()
+ self.assertTrue(self.void_called)
+ self.assertTrue(self.bool_called)
+
+ def testConnectOldStyleEmitVoidSignal(self):
+ def callbackVoid():
+ self.void_called = True
+ def callbackBool(value):
+ self.bool_called = True
+ QObject.connect(self.obj, SIGNAL('signalWithDefaultValue()'), callbackVoid)
+ QObject.connect(self.obj, SIGNAL('signalWithDefaultValue(bool)'), callbackBool)
+ self.obj.emitSignalWithDefaultValue_void()
+ self.assertTrue(self.void_called)
+ self.assertTrue(self.bool_called)
+
+ def testConnectOldStyleEmitBoolSignal(self):
+ def callbackVoid():
+ self.void_called = True
+ def callbackBool(value):
+ self.bool_called = True
+ QObject.connect(self.obj, SIGNAL('signalWithDefaultValue()'), callbackVoid)
+ QObject.connect(self.obj, SIGNAL('signalWithDefaultValue(bool)'), callbackBool)
+ self.obj.emitSignalWithDefaultValue_bool()
+ self.assertTrue(self.void_called)
+ self.assertTrue(self.bool_called)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/pysidetest/symbols.filter b/sources/pyside2/tests/pysidetest/symbols.filter
new file mode 100644
index 000000000..af6c744dd
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/symbols.filter
@@ -0,0 +1,7 @@
+{
+local:
+_ZSt*;
+_ZNSt*;
+_ZNSs*;
+_ZNKSt*;
+};
diff --git a/sources/pyside2/tests/pysidetest/testobject.cpp b/sources/pyside2/tests/pysidetest/testobject.cpp
new file mode 100644
index 000000000..4fe98461c
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/testobject.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testobject.h"
+
+void TestObject::emitIdValueSignal()
+{
+ emit idValue(m_idValue);
+}
+
+void TestObject::emitStaticMethodDoubleSignal()
+{
+ emit staticMethodDouble();
+}
+
+void TestObject::emitSignalWithDefaultValue_void()
+{
+ emit signalWithDefaultValue();
+}
+
+void TestObject::emitSignalWithDefaultValue_bool()
+{
+ emit signalWithDefaultValue(true);
+}
+
+void TestObject::emitSignalWithTypedefValue(int value)
+{
+ emit signalWithTypedefValue(TypedefValue(value));
+}
diff --git a/sources/pyside2/tests/pysidetest/testobject.h b/sources/pyside2/tests/pysidetest/testobject.h
new file mode 100644
index 000000000..7e1f46250
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/testobject.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTOBJECT_H
+#define TESTOBJECT_H
+
+#include <QObject>
+#include <QApplication>
+#include <QMetaType>
+#include <QVariant>
+#ifdef pysidetest_EXPORTS
+#define PYSIDE_EXPORTS 1
+#endif
+#include "pysidemacros.h"
+
+class IntValue
+{
+public:
+
+ IntValue(int val): value(val){};
+ IntValue() : value(0) {};
+ int value;
+};
+
+typedef IntValue TypedefValue;
+
+class PYSIDE_API TestObject : public QObject
+{
+ Q_OBJECT
+public:
+ static void createApp() { int argc=0; new QApplication(argc, 0); };
+ static int checkType(const QVariant& var) { return (int)var.type(); }
+
+ TestObject(int idValue, QObject* parent = 0) : QObject(parent), m_idValue(idValue) {}
+ int idValue() const { return m_idValue; }
+ static int staticMethodDouble(int value) { return value * 2; }
+ void addChild(QObject* c) { m_children.append(c); emit childrenChanged(m_children); }
+
+ void emitIdValueSignal();
+ void emitStaticMethodDoubleSignal();
+
+ void emitSignalWithDefaultValue_void();
+ void emitSignalWithDefaultValue_bool();
+
+ void emitSignalWithTypedefValue(int value);
+
+signals:
+ void idValue(int newValue);
+ void justASignal();
+ void staticMethodDouble();
+ void childrenChanged(const QList<QObject*>&);
+ void signalWithDefaultValue(bool value = false);
+ void signalWithTypedefValue(TypedefValue value);
+
+private:
+ int m_idValue;
+ QList<QObject*> m_children;
+};
+
+
+typedef int PySideInt;
+
+
+namespace PySideCPP {
+
+class PYSIDE_API TestObjectWithNamespace : public QObject
+{
+ Q_OBJECT
+public:
+ TestObjectWithNamespace(QObject* parent) : QObject(parent) {}
+ QString name() { return "TestObjectWithNamespace"; }
+
+ void callSignal(TestObjectWithNamespace* obj) { emitSignal(obj); }
+ void callSignalWithNamespace(TestObjectWithNamespace* obj) { emitSignalWithNamespace(obj); }
+ void callSignalWithTypedef(int val) { emitSignalWithTypedef(val); }
+
+signals:
+ void emitSignal(TestObjectWithNamespace* obj);
+ void emitSignalWithNamespace(PySideCPP::TestObjectWithNamespace* obj);
+ void emitSignalWithTypedef(PySideInt val);
+};
+
+
+} // Namespace PySideCPP
+
+namespace PySideCPP2 {
+
+enum Enum1 { Option1 = 1, Option2 = 2 };
+
+
+typedef long PySideLong;
+
+class PYSIDE_API TestObjectWithoutNamespace : public QObject
+{
+ Q_OBJECT
+public:
+ enum Enum2 { Option3 = 3, Option4 = 4};
+ TestObjectWithoutNamespace(QObject* parent) : QObject(parent) {}
+ QString name() { return "TestObjectWithoutNamespace"; }
+
+ void callSignal(TestObjectWithoutNamespace* obj) { emitSignal(obj); }
+ void callSignalWithNamespace(TestObjectWithoutNamespace* obj) { emitSignalWithNamespace(obj); }
+ void callSignalWithTypedef(long val) { emitSignalWithTypedef(val); }
+
+signals:
+ void emitSignal(TestObjectWithoutNamespace* obj);
+ void emitSignalWithNamespace(PySideCPP2::TestObjectWithoutNamespace* obj);
+ void emitSignalWithTypedef(PySideLong val);
+};
+
+
+} // Namespace PySideCPP2
+
+#endif // TESTOBJECT_H
+
diff --git a/sources/pyside2/tests/pysidetest/testview.cpp b/sources/pyside2/tests/pysidetest/testview.cpp
new file mode 100644
index 000000000..b974f1fc7
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/testview.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testview.h"
+
+#include <QDebug>
+#include <QWidget>
+#include <QAbstractListModel>
+#include <QAbstractItemDelegate>
+
+QVariant
+TestView::getData()
+{
+ QModelIndex index;
+ return m_model->data(index);
+}
+
+QWidget*
+TestView::getEditorWidgetFromItemDelegate() const
+{
+ if (!m_delegate)
+ return 0;
+
+ QModelIndex index;
+ QStyleOptionViewItem options;
+ return m_delegate->createEditor(0, options, index);
+}
diff --git a/sources/pyside2/tests/pysidetest/testview.h b/sources/pyside2/tests/pysidetest/testview.h
new file mode 100644
index 000000000..22caab59f
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/testview.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTVIEW_H
+#define TESTVIEW_H
+
+#include <QObject>
+#ifdef pysidetest_EXPORTS
+#define PYSIDE_EXPORTS 1
+#endif
+#include "pysidemacros.h"
+
+QT_BEGIN_NAMESPACE
+class QWidget;
+class QAbstractListModel;
+class QAbstractItemDelegate;
+QT_END_NAMESPACE
+
+class PYSIDE_API TestView : public QObject
+{
+ Q_OBJECT
+public:
+ TestView(QAbstractListModel* model, QObject* parent = 0) : QObject(parent), m_model(model) {}
+ QAbstractListModel* model() { return m_model; }
+ QVariant getData();
+
+ void setItemDelegate(QAbstractItemDelegate* delegate) { m_delegate = delegate; }
+ QWidget* getEditorWidgetFromItemDelegate() const;
+
+private:
+ QAbstractListModel* m_model;
+ QAbstractItemDelegate* m_delegate;
+};
+
+#endif // TESTVIEW_H
+
diff --git a/sources/pyside2/tests/pysidetest/typedef_signal_test.py b/sources/pyside2/tests/pysidetest/typedef_signal_test.py
new file mode 100644
index 000000000..7f2f47344
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/typedef_signal_test.py
@@ -0,0 +1,54 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject
+from testbinding import TestObject
+
+class Receiver(QObject):
+
+ def __init__(self):
+ QObject.__init__(self)
+ self.received = None
+
+ def slot(self, value):
+ self.received = value
+
+class TypedefSignal(unittest.TestCase):
+
+ def testTypedef(self):
+ obj = TestObject(0)
+ receiver = Receiver()
+
+ obj.signalWithTypedefValue.connect(receiver.slot)
+ obj.emitSignalWithTypedefValue(2)
+ self.assertEqual(receiver.received.value, 2)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/pysidetest/typesystem_pysidetest.xml b/sources/pyside2/tests/pysidetest/typesystem_pysidetest.xml
new file mode 100644
index 000000000..4053b7b77
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/typesystem_pysidetest.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<typesystem package="testbinding">
+ <load-typesystem name="typesystem_core.xml" generate="no" />
+ <value-type name="IntValue"/>
+ <primitive-type name="TypedefValue">
+ <!--
+ A conversion rule is used here because ApiExtractor can't associate
+ a primitive typedef to a non-primitive type. That would be a good
+ improvement to ApiExtractor.
+ -->
+ <conversion-rule>
+ <native-to-target>
+ return %CONVERTTOPYTHON[IntValue](%in);
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="IntValue">
+ IntValue value = %CONVERTTOCPP[IntValue](%in);
+ %out = %OUTTYPE(value);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+ <object-type name="TestObject" />
+
+ <primitive-type name="PySideInt"/>
+ <primitive-type name="PySideCPP2::PySideLong"/>
+ <!--<primitive-type name="PySideLong"/>-->
+
+ <function signature="getHiddenObject()" />
+
+ <inject-code position="end">
+ Shiboken::Conversions::registerConverterName(Shiboken::Conversions::PrimitiveTypeConverter&lt;long&gt;(), "PySideLong");
+ Shiboken::Conversions::registerConverterName(Shiboken::Conversions::PrimitiveTypeConverter&lt;long&gt;(), "PySideCPP2::PySideLong");
+ qRegisterMetaType&lt;PySideInt>("PySideInt");
+ qRegisterMetaType&lt;PySideCPP2::PySideLong>("PySideLong");
+ </inject-code>
+
+ <namespace-type name="PySideCPP">
+ <object-type name="TestObjectWithNamespace"/>
+ </namespace-type>
+
+ <namespace-type name="PySideCPP2" generate="no">
+ <enum-type name="Enum1" />
+ <object-type name="TestObjectWithoutNamespace">
+ <enum-type name="Enum2" />
+ </object-type>
+ </namespace-type>
+
+ <object-type name="TestView" >
+ <modify-function signature="TestView(QAbstractListModel*,QObject*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <suppress-warning text="type 'QPyTextObject' is specified in typesystem, but not defined. This could potentially lead to compilation errors." />
+ <!-- Qt5: I never really understood this warning. Probably it is because there
+ is no way to instantiate the class. Anyway, why must this class emit this warning?
+ I am not a C++ warrior, so I'd prefer if it would say "it is ok if you see this warning!".
+ Well, maybe somebody will enlighten me, and I'll change this comment.
+ I'd actually prefer an implementation that avoids generating this message, but I still failed
+ doing so :-(
+ -->
+</typesystem>
diff --git a/sources/pyside2/tests/pysidetest/utils_test.py b/sources/pyside2/tests/pysidetest/utils_test.py
new file mode 100644
index 000000000..30f283312
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/utils_test.py
@@ -0,0 +1,51 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+import os
+
+
+if sys.platform == 'win32':
+ from PySide2._utils import _get_win32_case_sensitive_name
+
+ class Win32UtilsTest(unittest.TestCase):
+ def testWin32CaseSensitiveName(self):
+ from tempfile import mkdtemp
+ caseSensitiveName = 'CaseSensitiveName'
+ tmpdir = mkdtemp(caseSensitiveName)
+ try:
+ path = _get_win32_case_sensitive_name(tmpdir.lower())
+ self.assertTrue(path.endswith(caseSensitiveName))
+ finally:
+ if os.path.exists(tmpdir):
+ os.rmdir(tmpdir)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/pysidetest/version_test.py b/sources/pyside2/tests/pysidetest/version_test.py
new file mode 100644
index 000000000..5901a56c1
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/version_test.py
@@ -0,0 +1,45 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2 import __version_info__, __version__, QtCore
+
+class CheckForVariablesTest(unittest.TestCase):
+ def testVesions(self):
+ self.assertTrue(__version_info__ >= (1, 0, 0))
+ self.assertTrue(__version_info__ < (99, 99, 99))
+ self.assertTrue(__version__)
+
+ self.assertTrue(QtCore.__version_info__ >= (4, 5, 0))
+ self.assertTrue(QtCore.__version__)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/run_test.sh b/sources/pyside2/tests/run_test.sh
new file mode 100755
index 000000000..a961653a5
--- /dev/null
+++ b/sources/pyside2/tests/run_test.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# This is a nasty workaround of a CTest limitation
+# of setting the environment variables for the test.
+
+# $1: LD_LIBRARY_PATH
+# $2: $PYTHONPATH
+# $3: python executable
+# $4: test file
+
+export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
+export PYTHONPATH=$2:$PYTHONPATH
+$3 $4
diff --git a/sources/pyside2/tests/signals/CMakeLists.txt b/sources/pyside2/tests/signals/CMakeLists.txt
new file mode 100644
index 000000000..fe06a3430
--- /dev/null
+++ b/sources/pyside2/tests/signals/CMakeLists.txt
@@ -0,0 +1,40 @@
+PYSIDE_TEST(args_dont_match_test.py)
+PYSIDE_TEST(bug_79.py)
+PYSIDE_TEST(bug_189.py)
+PYSIDE_TEST(bug_311.py)
+PYSIDE_TEST(bug_312.py)
+PYSIDE_TEST(bug_319.py)
+PYSIDE_TEST(decorators_test.py)
+PYSIDE_TEST(disconnect_test.py)
+PYSIDE_TEST(invalid_callback_test.py)
+PYSIDE_TEST(lambda_gui_test.py)
+PYSIDE_TEST(lambda_test.py)
+PYSIDE_TEST(leaking_signal_test.py)
+PYSIDE_TEST(multiple_connections_gui_test.py)
+PYSIDE_TEST(multiple_connections_test.py)
+PYSIDE_TEST(pysignal_test.py)
+PYSIDE_TEST(qobject_destroyed_test.py)
+PYSIDE_TEST(qobject_receivers_test.py)
+PYSIDE_TEST(qobject_sender_test.py)
+PYSIDE_TEST(ref01_test.py)
+PYSIDE_TEST(ref02_test.py)
+PYSIDE_TEST(ref03_test.py)
+PYSIDE_TEST(ref04_test.py)
+PYSIDE_TEST(ref05_test.py)
+PYSIDE_TEST(ref06_test.py)
+PYSIDE_TEST(segfault_proxyparent_test.py)
+PYSIDE_TEST(self_connect_test.py)
+PYSIDE_TEST(short_circuit_test.py)
+PYSIDE_TEST(signal2signal_connect_test.py)
+PYSIDE_TEST(signal_autoconnect_test.py)
+PYSIDE_TEST(signal_connectiontype_support_test.py)
+PYSIDE_TEST(signal_emission_gui_test.py)
+PYSIDE_TEST(signal_emission_test.py)
+PYSIDE_TEST(signal_func_test.py)
+PYSIDE_TEST(signal_manager_refcount_test.py)
+PYSIDE_TEST(signal_number_limit_test.py)
+PYSIDE_TEST(signal_object_test.py)
+PYSIDE_TEST(signal_signature_test.py)
+PYSIDE_TEST(signal_with_primitive_type_test.py)
+PYSIDE_TEST(slot_reference_count_test.py)
+PYSIDE_TEST(static_metaobject_test.py)
diff --git a/sources/pyside2/tests/signals/args_dont_match_test.py b/sources/pyside2/tests/signals/args_dont_match_test.py
new file mode 100644
index 000000000..03d2ec324
--- /dev/null
+++ b/sources/pyside2/tests/signals/args_dont_match_test.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+
+class ArgsDontMatch(unittest.TestCase):
+
+ def callback(self, arg1):
+ self.ok = True
+
+ def testConnectSignalToSlotWithLessArgs(self):
+ self.ok = False
+ obj1 = QObject()
+ QObject.connect(obj1, SIGNAL('the_signal(int, int, int)'), self.callback)
+ obj1.emit(SIGNAL('the_signal(int, int, int)'), 1, 2, 3)
+
+ self.assertTrue(self.ok)
+
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/bug_189.py b/sources/pyside2/tests/signals/bug_189.py
new file mode 100644
index 000000000..dc2c314aa
--- /dev/null
+++ b/sources/pyside2/tests/signals/bug_189.py
@@ -0,0 +1,54 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2 import QtCore, QtWidgets
+from helper import UsesQApplication
+
+class TestBugPYSIDE189(UsesQApplication):
+
+ def testDisconnect(self):
+ # Disconnecting from a signal owned by a destroyed object
+ # should raise an exception, not segfault.
+ def onValueChanged(self, value):
+ pass
+
+ sld = QtWidgets.QSlider()
+ sld.valueChanged.connect(onValueChanged)
+
+ sld.deleteLater()
+
+ QtCore.QTimer.singleShot(0, self.app.quit)
+ self.app.exec_()
+
+ self.assertRaises(RuntimeError, sld.valueChanged.disconnect, onValueChanged)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/bug_311.py b/sources/pyside2/tests/signals/bug_311.py
new file mode 100644
index 000000000..0ea066b49
--- /dev/null
+++ b/sources/pyside2/tests/signals/bug_311.py
@@ -0,0 +1,70 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2 import QtCore
+from helper import UsesQCoreApplication
+
+class DerivedDate(QtCore.QDate):
+ def __init__(self,y,m,d):
+ super(DerivedDate,self).__init__(y,m,d)
+
+class Emitter(QtCore.QObject):
+ dateSignal1 = QtCore.Signal(QtCore.QDate)
+ dateSignal2 = QtCore.Signal(DerivedDate)
+ tupleSignal = QtCore.Signal(tuple)
+
+class SignaltoSignalTest(UsesQCoreApplication):
+ def myCb(self, dt):
+ self._dt = dt
+
+ def testBug(self):
+ e = Emitter()
+ d = DerivedDate(2010,8,24)
+ self._dt = None
+ e.dateSignal1.connect(self.myCb)
+ e.dateSignal1.emit(d)
+ self.assertEqual(self._dt, d)
+
+ self._dt = None
+ e.dateSignal2.connect(self.myCb)
+ e.dateSignal2.emit(d)
+ self.assertEqual(self._dt, d)
+
+ myTuple = (5, 6, 7)
+ self._dt = None
+ e.tupleSignal.connect(self.myCb)
+ e.tupleSignal.emit(myTuple)
+ self.assertEqual(myTuple, self._dt)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/bug_312.py b/sources/pyside2/tests/signals/bug_312.py
new file mode 100644
index 000000000..631e224b3
--- /dev/null
+++ b/sources/pyside2/tests/signals/bug_312.py
@@ -0,0 +1,79 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sys
+from PySide2.QtCore import QObject, SIGNAL
+
+MAX_LOOPS = 5
+MAX_OBJECTS = 200
+
+class Dummy(object):
+ def __init__(self, parent):
+ self._parent = parent
+
+ def callback(self):
+ self._called = True
+
+class MultipleSlots(unittest.TestCase):
+ def myCB(self):
+ self._count += 1
+
+ """
+ def testUnboundSignal(self):
+ o = QObject()
+ self._count = 0
+ for i in range(MAX_OBJECTS):
+ QObject.connect(o, SIGNAL("fire()"), lambda: self.myCB())
+
+ o.emit(SIGNAL("fire()"))
+ self.assertEqual(self._count, MAX_OBJECTS)
+
+ """
+ def testDisconnectCleanup(self):
+ for c in range(MAX_LOOPS):
+ self._count = 0
+ self._senders = []
+ for i in range(MAX_OBJECTS):
+ o = QObject()
+ QObject.connect(o, SIGNAL("fire()"), lambda: self.myCB())
+ self._senders.append(o)
+ o.emit(SIGNAL("fire()"))
+
+ self.assertEqual(self._count, MAX_OBJECTS)
+
+ #delete all senders will disconnect the signals
+ self._senders = []
+
+if __name__ == '__main__':
+ unittest.main()
+
+
diff --git a/sources/pyside2/tests/signals/bug_319.py b/sources/pyside2/tests/signals/bug_319.py
new file mode 100644
index 000000000..637f36bb4
--- /dev/null
+++ b/sources/pyside2/tests/signals/bug_319.py
@@ -0,0 +1,63 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2 import QtCore
+from helper import UsesQCoreApplication
+
+class Listener(QtCore.QObject):
+ def __init__(self):
+ QtCore.QObject.__init__(self, None)
+ self._phrase = []
+
+ @QtCore.Slot(tuple)
+ def listen(self, words):
+ for w in words:
+ self._phrase.append(w)
+
+class Communicate(QtCore.QObject):
+ # create a new signal on the fly and name it 'speak'
+ speak = QtCore.Signal(tuple)
+
+class SignaltoSignalTest(UsesQCoreApplication):
+ def testBug(self):
+ someone = Communicate()
+ someone2 = Listener()
+ # connect signal and slot
+ someone.speak.connect(someone2.listen)
+ # emit 'speak' signal
+ talk = ("one","two","three")
+ someone.speak.emit(talk)
+ self.assertEqual(someone2._phrase, list(talk))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/bug_79.py b/sources/pyside2/tests/signals/bug_79.py
new file mode 100644
index 000000000..d0a6515f3
--- /dev/null
+++ b/sources/pyside2/tests/signals/bug_79.py
@@ -0,0 +1,69 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+import unittest
+import sys
+import gc
+
+from PySide2 import QtGui, QtWidgets
+
+try:
+ from sys import gettotalrefcount
+ skiptest = False
+except ImportError:
+ skiptest = True
+
+class ConnectTest(unittest.TestCase):
+
+ def callback(self, o):
+ print("callback")
+ self._called = o
+
+ def testNoLeaks_ConnectAndDisconnect(self):
+ self._called = None
+ app = QtWidgets.QApplication([])
+ o = QtWidgets.QTreeView()
+ o.setModel(QtGui.QStandardItemModel())
+ o.selectionModel().destroyed.connect(self.callback)
+ o.selectionModel().destroyed.disconnect(self.callback)
+ gc.collect()
+ # if this is no debug build, then we check at least that
+ # we do not crash any longer.
+ if not skiptest:
+ total = sys.gettotalrefcount()
+ for idx in range(1000):
+ o.selectionModel().destroyed.connect(self.callback)
+ o.selectionModel().destroyed.disconnect(self.callback)
+ gc.collect()
+ if not skiptest:
+ self.assertTrue(abs(gettotalrefcount() - total) < 10)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/decorators_test.py b/sources/pyside2/tests/signals/decorators_test.py
new file mode 100644
index 000000000..ec43ac825
--- /dev/null
+++ b/sources/pyside2/tests/signals/decorators_test.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject, Slot, SIGNAL, SLOT
+
+class MyObject(QObject):
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+ self._slotCalledCount = 0
+
+ @Slot()
+ def mySlot(self):
+ self._slotCalledCount = self._slotCalledCount + 1
+
+ @Slot(int)
+ @Slot('QString')
+ def mySlot2(self, arg0):
+ self._slotCalledCount = self._slotCalledCount + 1
+
+ @Slot(name='mySlot3')
+ def foo(self):
+ self._slotCalledCount = self._slotCalledCount + 1
+
+ @Slot(str, int)
+ def mySlot4(self, a, b):
+ self._slotCalledCount = self._slotCalledCount + 1
+
+ @Slot(result=int)
+ def mySlot5(self):
+ self._slotCalledCount = self._slotCalledCount + 1
+
+ @Slot(result=QObject)
+ def mySlot6(self):
+ self._slotCalledCount = self._slotCalledCount + 1
+
+class StaticMetaObjectTest(unittest.TestCase):
+
+ def testSignalPropagation(self):
+ o = MyObject()
+ m = o.metaObject()
+ self.assertTrue(m.indexOfSlot('mySlot()') > 0)
+ self.assertTrue(m.indexOfSlot('mySlot2(int)') > 0)
+ self.assertTrue(m.indexOfSlot('mySlot2(QString)') > 0)
+ self.assertTrue(m.indexOfSlot('mySlot3()') > 0)
+ self.assertTrue(m.indexOfSlot('mySlot4(QString,int)') > 0)
+
+ def testEmission(self):
+ o = MyObject()
+ o.connect(SIGNAL("mySignal()"), o, SLOT("mySlot()"))
+ o.emit(SIGNAL("mySignal()"))
+ self.assertTrue(o._slotCalledCount == 1)
+
+ def testResult(self):
+ o = MyObject()
+ mo = o.metaObject()
+ i = mo.indexOfSlot('mySlot5()')
+ m = mo.method(i)
+ self.assertEqual(m.typeName(), "int")
+
+ def testResultObject(self):
+ o = MyObject()
+ mo = o.metaObject()
+ i = mo.indexOfSlot('mySlot6()')
+ m = mo.method(i)
+ self.assertEqual(m.typeName(), "QObject*")
+
+class SlotWithoutArgs(unittest.TestCase):
+
+ def testError(self):
+ # It should be an error to call the slot without the
+ # arguments, as just @Slot would end up in a slot
+ # accepting argument functions
+ self.assertRaises(TypeError, Slot, lambda: 3)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/disconnect_test.py b/sources/pyside2/tests/signals/disconnect_test.py
new file mode 100644
index 000000000..b17caa8e6
--- /dev/null
+++ b/sources/pyside2/tests/signals/disconnect_test.py
@@ -0,0 +1,88 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import os, sys
+sys.path.insert(0, os.path.join("..", "pysidetest"))
+
+import unittest
+from PySide2.QtCore import *
+from testbinding import TestObject
+
+
+class Foo(QObject):
+ bar = Signal()
+
+class TestDisconnect(unittest.TestCase):
+ def theSlot1(self):
+ self.called1 = True
+
+ def theSlot2(self):
+ self.called2 = True
+
+ def testIt(self):
+ self.called1 = False
+ self.called2 = False
+ f = Foo()
+ f.bar.connect(self.theSlot1)
+ f.bar.connect(self.theSlot2)
+ f.bar.emit()
+ self.assertTrue(self.called1)
+ self.assertTrue(self.called2)
+
+ self.called1 = False
+ self.called2 = False
+ f.bar.disconnect()
+ f.bar.emit()
+ self.assertFalse(self.called1)
+ self.assertFalse(self.called2)
+
+ def testDuringCallback(self):
+ """ Test to see if the C++ object for a connection is accessed after the
+ method returns. This causes a segfault if the memory that was used by the
+ C++ object has been reused. """
+
+ self.called = False
+ obj = TestObject(0)
+ def callback():
+ obj.signalWithDefaultValue.disconnect(callback)
+
+ # Connect more callbacks to try to overwrite memory
+ for i in range(1000):
+ obj.signalWithDefaultValue.connect(lambda: None)
+
+ self.called = True
+
+ # A non-None return value is needed
+ return True
+ obj.signalWithDefaultValue.connect(callback)
+ obj.signalWithDefaultValue.emit()
+ self.assertTrue(self.called)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/invalid_callback_test.py b/sources/pyside2/tests/signals/invalid_callback_test.py
new file mode 100644
index 000000000..a6ed2456f
--- /dev/null
+++ b/sources/pyside2/tests/signals/invalid_callback_test.py
@@ -0,0 +1,56 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for passing invalid callbacks to QObject.connect'''
+
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL
+
+class InvalidCallback(unittest.TestCase):
+ '''Test case for passing an invalid callback to QObject.connect'''
+
+ def setUp(self):
+ #Acquire resources
+ self.obj = QObject()
+
+ def tearDown(self):
+ #Release resources
+ try:
+ del self.obj
+ except AttributeError:
+ pass
+
+ def testIntegerCb(self):
+ #Test passing an int as callback to QObject.connect
+ self.assertRaises(TypeError, QObject.connect, self.obj,
+ SIGNAL('destroyed()'), 42)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/lambda_gui_test.py b/sources/pyside2/tests/signals/lambda_gui_test.py
new file mode 100644
index 000000000..dc6ef0296
--- /dev/null
+++ b/sources/pyside2/tests/signals/lambda_gui_test.py
@@ -0,0 +1,73 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Connecting lambda to gui signals'''
+
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL
+
+try:
+ from PySide2.QtWidgets import QSpinBox, QPushButton
+ hasQtGui = True
+except ImportError:
+ hasQtGui = False
+
+from helper import UsesQApplication
+
+if hasQtGui:
+ class Control:
+ def __init__(self):
+ self.arg = False
+
+ class QtGuiSigLambda(UsesQApplication):
+
+ def testButton(self):
+ #Connecting a lambda to a QPushButton.clicked()
+ obj = QPushButton('label')
+ ctr = Control()
+ func = lambda: setattr(ctr, 'arg', True)
+ QObject.connect(obj, SIGNAL('clicked()'), func)
+ obj.click()
+ self.assertTrue(ctr.arg)
+ QObject.disconnect(obj, SIGNAL('clicked()'), func)
+
+
+ def testSpinButton(self):
+ #Connecting a lambda to a QPushButton.clicked()
+ obj = QSpinBox()
+ ctr = Control()
+ arg = 444
+ func = lambda x: setattr(ctr, 'arg', 444)
+ QObject.connect(obj, SIGNAL('valueChanged(int)'), func)
+ obj.setValue(444)
+ self.assertEqual(ctr.arg, arg)
+ QObject.disconnect(obj, SIGNAL('valueChanged(int)'), func)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/lambda_test.py b/sources/pyside2/tests/signals/lambda_test.py
new file mode 100644
index 000000000..9e602e72f
--- /dev/null
+++ b/sources/pyside2/tests/signals/lambda_test.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Connecting lambda to signals'''
+
+import sys
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL, QProcess
+
+from helper import UsesQCoreApplication
+
+
+class Dummy(QObject):
+
+ def __init__(self, *args):
+ super(Dummy, self).__init__(*args)
+
+
+class BasicCase(unittest.TestCase):
+
+ def testSimplePythonSignalNoArgs(self):
+ #Connecting a lambda to a simple python signal without arguments
+ obj = Dummy()
+ QObject.connect(obj, SIGNAL('foo()'),
+ lambda: setattr(obj, 'called', True))
+ obj.emit(SIGNAL('foo()'))
+ self.assertTrue(obj.called)
+
+ def testSimplePythonSignal(self):
+ #Connecting a lambda to a simple python signal witharguments
+ obj = Dummy()
+ arg = 42
+ QObject.connect(obj, SIGNAL('foo(int)'),
+ lambda x: setattr(obj, 'arg', 42))
+ obj.emit(SIGNAL('foo(int)'), arg)
+ self.assertEqual(obj.arg, arg)
+
+
+class QtSigLambda(UsesQCoreApplication):
+
+ qapplication = True
+
+ def testNoArgs(self):
+ '''Connecting a lambda to a signal without arguments'''
+ proc = QProcess()
+ dummy = Dummy()
+ QObject.connect(proc, SIGNAL('started()'),
+ lambda: setattr(dummy, 'called', True))
+ proc.start(sys.executable, ['-c', '""'])
+ proc.waitForFinished()
+ self.assertTrue(dummy.called)
+
+ def testWithArgs(self):
+ '''Connecting a lambda to a signal with arguments'''
+ proc = QProcess()
+ dummy = Dummy()
+ QObject.connect(proc, SIGNAL('finished(int)'),
+ lambda x: setattr(dummy, 'called', x))
+ proc.start(sys.executable, ['-c', '""'])
+ proc.waitForFinished()
+ self.assertEqual(dummy.called, proc.exitCode())
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/leaking_signal_test.py b/sources/pyside2/tests/signals/leaking_signal_test.py
new file mode 100644
index 000000000..770e59556
--- /dev/null
+++ b/sources/pyside2/tests/signals/leaking_signal_test.py
@@ -0,0 +1,43 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2 import QtCore
+import weakref
+
+class LeakingSignal(unittest.TestCase):
+
+ def testLeakingSignal(self):
+ # Was segfaulting when the signal was garbage collected.
+ class Emitter(QtCore.QObject):
+ my_signal = QtCore.Signal(object)
+
+ emitter = Emitter()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/multiple_connections_gui_test.py b/sources/pyside2/tests/signals/multiple_connections_gui_test.py
new file mode 100644
index 000000000..28e7867cc
--- /dev/null
+++ b/sources/pyside2/tests/signals/multiple_connections_gui_test.py
@@ -0,0 +1,88 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import random
+from functools import partial
+
+from PySide2.QtCore import QObject, SIGNAL
+
+try:
+ from PySide2.QtWidgets import QPushButton, QSpinBox
+ hasQtGui = True
+except ImportError:
+ hasQtGui = False
+
+from helper import BasicPySlotCase, UsesQApplication
+
+class MultipleSignalConnections(unittest.TestCase):
+ '''Base class for multiple signal connection testing'''
+
+ def run_many(self, sender, signal, emitter, receivers, args=None):
+ """Utility method to connect a list of receivers to a signal.
+ sender - QObject that will emit the signal
+ signal - string with the signal signature
+ emitter - the callable that will trigger the signal
+ receivers - list of BasicPySlotCase instances
+ args - tuple with the arguments to be sent.
+ """
+
+ if args is None:
+ args = tuple()
+
+ for rec in receivers:
+ rec.setUp()
+ QObject.connect(sender, SIGNAL(signal), rec.cb)
+ rec.args = tuple(args)
+
+ emitter(*args)
+
+ for rec in receivers:
+ self.assertTrue(rec.called)
+
+
+if hasQtGui:
+ class QtGuiMultipleSlots(UsesQApplication, MultipleSignalConnections):
+ '''Multiple connections to QtGui signals'''
+
+ def testButtonClick(self):
+ """Multiple connections to QPushButton.clicked()"""
+ sender = QPushButton('button')
+ receivers = [BasicPySlotCase() for x in range(30)]
+ self.run_many(sender, 'clicked()', sender.click, receivers)
+
+ def testSpinBoxValueChanged(self):
+ """Multiple connections to QSpinBox.valueChanged(int)"""
+ sender = QSpinBox()
+ #FIXME if number of receivers if higher than 50, segfaults
+ receivers = [BasicPySlotCase() for x in range(10)]
+ self.run_many(sender, 'valueChanged(int)', sender.setValue,
+ receivers, (1,))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/multiple_connections_test.py b/sources/pyside2/tests/signals/multiple_connections_test.py
new file mode 100644
index 000000000..39950da5d
--- /dev/null
+++ b/sources/pyside2/tests/signals/multiple_connections_test.py
@@ -0,0 +1,103 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+import unittest
+from functools import partial
+
+from PySide2.QtCore import QObject, SIGNAL, QProcess
+
+from helper import BasicPySlotCase, UsesQCoreApplication
+
+
+class MultipleSignalConnections(unittest.TestCase):
+ '''Base class for multiple signal connection testing'''
+
+ def run_many(self, sender, signal, emitter, receivers, args=None):
+ """Utility method to connect a list of receivers to a signal.
+ sender - QObject that will emit the signal
+ signal - string with the signal signature
+ emitter - the callable that will trigger the signal
+ receivers - list of BasicPySlotCase instances
+ args - tuple with the arguments to be sent.
+ """
+
+ if args is None:
+ args = tuple()
+ for rec in receivers:
+ rec.setUp()
+ self.assertTrue(QObject.connect(sender, SIGNAL(signal), rec.cb))
+ rec.args = tuple(args)
+
+ emitter(*args)
+
+ for rec in receivers:
+ self.assertTrue(rec.called)
+
+
+class PythonMultipleSlots(UsesQCoreApplication, MultipleSignalConnections):
+ '''Multiple connections to python signals'''
+
+ def testPythonSignal(self):
+ """Multiple connections to a python signal (short-circuit)"""
+
+ class Dummy(QObject):
+ pass
+
+ sender = Dummy()
+ receivers = [BasicPySlotCase() for x in range(10)]
+ self.run_many(sender, 'foobar(int)', partial(sender.emit,SIGNAL('foobar(int)')), receivers, (0, ))
+
+
+class QProcessMultipleSlots(UsesQCoreApplication, MultipleSignalConnections):
+ '''Multiple connections to QProcess signals'''
+
+ def testQProcessStarted(self):
+ '''Multiple connections to QProcess.started()'''
+ sender = QProcess()
+ receivers = [BasicPySlotCase() for x in range(10)]
+
+ def start_proc(*args):
+ sender.start(sys.executable, ['-c', '""'])
+ sender.waitForFinished()
+
+ self.run_many(sender, 'started()', start_proc, receivers)
+
+ def testQProcessFinished(self):
+ '''Multiple connections to QProcess.finished(int)'''
+ sender = QProcess()
+ receivers = [BasicPySlotCase() for x in range(10)]
+
+ def start_proc(*args):
+ sender.start(sys.executable, ['-c', '""'])
+ sender.waitForFinished()
+
+ self.run_many(sender, 'finished(int)', start_proc, receivers, (0,))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/pysignal_test.py b/sources/pyside2/tests/signals/pysignal_test.py
new file mode 100644
index 000000000..a42793b02
--- /dev/null
+++ b/sources/pyside2/tests/signals/pysignal_test.py
@@ -0,0 +1,214 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QObject, SIGNAL, SLOT, Qt
+
+try:
+ from PySide2.QtWidgets import QSpinBox, QApplication, QWidget
+ hasQtGui = True
+except ImportError:
+ hasQtGui = False
+
+from helper import UsesQApplication
+
+class Dummy(QObject):
+ """Dummy class used in this test."""
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+
+ def callDummy(self):
+ self.emit(SIGNAL("dummy(PyObject)"), "PyObject")
+
+ def callDummy2(self):
+ lst = []
+ lst.append("item1")
+ lst.append("item2")
+ lst.append("item3")
+ self.emit(SIGNAL("dummy2(PyObject, PyObject)"), "PyObject0", lst)
+
+
+class PyObjectType(UsesQApplication):
+ def mySlot(self, arg):
+ self.assertEqual(arg, "PyObject")
+ self.called = True
+ self.callCount += 1
+
+ def mySlot2(self, arg0, arg1):
+ self.assertEqual(arg0, "PyObject0")
+ self.assertEqual(arg1[0], "item1")
+ self.assertEqual(arg1[1], "item2")
+ self.assertEqual(arg1[2], "item3")
+ self.callCount += 1
+ if self.running:
+ self.app.quit()
+
+ def setUp(self):
+ super(PyObjectType, self).setUp()
+ self.callCount = 0
+ self.running = False
+
+ def testWithOneArg(self):
+ o = Dummy()
+ o.connect(SIGNAL("dummy(PyObject)"), self.mySlot)
+ o.callDummy()
+ self.assertEqual(self.callCount, 1)
+
+ def testWithTwoArg(self):
+ o = Dummy()
+ o.connect(SIGNAL("dummy2(PyObject,PyObject)"), self.mySlot2)
+ o.callDummy2()
+ self.assertEqual(self.callCount, 1)
+
+ def testAsyncSignal(self):
+ self.called = False
+ self.running = True
+ o = Dummy()
+ o.connect(SIGNAL("dummy2(PyObject,PyObject)"), self.mySlot2, Qt.QueuedConnection)
+ o.callDummy2()
+ self.app.exec_()
+ self.assertEqual(self.callCount, 1)
+
+ def testTwice(self):
+ self.called = False
+ self.running = True
+ o = Dummy()
+ o.connect(SIGNAL("dummy2(PyObject,PyObject)"), self.mySlot2, Qt.QueuedConnection)
+ o.callDummy2()
+ o.callDummy2()
+ self.app.exec_()
+ self.assertEqual(self.callCount, 2)
+
+class PythonSigSlot(unittest.TestCase):
+ def setUp(self):
+ self.called = False
+
+ def tearDown(self):
+ try:
+ del self.args
+ except:
+ pass
+
+ def callback(self, *args):
+ if tuple(self.args) == args:
+ self.called = True
+
+ def testNoArgs(self):
+ """Python signal and slots without arguments"""
+ obj1 = Dummy()
+
+ QObject.connect(obj1, SIGNAL('foo()'), self.callback)
+ self.args = tuple()
+ obj1.emit(SIGNAL('foo()'), *self.args)
+
+ self.assertTrue(self.called)
+
+ def testWithArgs(self):
+ """Python signal and slots with integer arguments"""
+ obj1 = Dummy()
+
+ QObject.connect(obj1, SIGNAL('foo(int)'), self.callback)
+ self.args = (42,)
+ obj1.emit(SIGNAL('foo(int)'), *self.args)
+
+ self.assertTrue(self.called)
+
+
+ def testDisconnect(self):
+ obj1 = Dummy()
+
+ QObject.connect(obj1, SIGNAL('foo(int)'), self.callback)
+ QObject.disconnect(obj1, SIGNAL('foo(int)'), self.callback)
+
+ self.args = (42, )
+ obj1.emit(SIGNAL('foo(int)'), *self.args)
+
+ self.assertTrue(not self.called)
+
+
+if hasQtGui:
+ class SpinBoxPySignal(UsesQApplication):
+ """Tests the connection of python signals to QSpinBox qt slots."""
+
+ def setUp(self):
+ super(SpinBoxPySignal, self).setUp()
+ self.obj = Dummy()
+ self.spin = QSpinBox()
+ self.spin.setValue(0)
+
+ def tearDown(self):
+ super(SpinBoxPySignal, self).tearDown()
+ del self.obj
+ del self.spin
+
+ def testValueChanged(self):
+ """Emission of a python signal to QSpinBox setValue(int)"""
+ QObject.connect(self.obj, SIGNAL('dummy(int)'), self.spin, SLOT('setValue(int)'))
+ self.assertEqual(self.spin.value(), 0)
+
+ self.obj.emit(SIGNAL('dummy(int)'), 4)
+ self.assertEqual(self.spin.value(), 4)
+
+ def testValueChangedMultiple(self):
+ """Multiple emissions of a python signal to QSpinBox setValue(int)"""
+ QObject.connect(self.obj, SIGNAL('dummy(int)'), self.spin, SLOT('setValue(int)'))
+ self.assertEqual(self.spin.value(), 0)
+
+ self.obj.emit(SIGNAL('dummy(int)'), 4)
+ self.assertEqual(self.spin.value(), 4)
+
+ self.obj.emit(SIGNAL('dummy(int)'), 77)
+ self.assertEqual(self.spin.value(), 77)
+
+
+if hasQtGui:
+ class WidgetPySignal(UsesQApplication):
+ """Tests the connection of python signals to QWidget qt slots."""
+
+ def setUp(self):
+ super(WidgetPySignal, self).setUp()
+ self.obj = Dummy()
+ self.widget = QWidget()
+
+ def tearDown(self):
+ super(WidgetPySignal, self).tearDown()
+ del self.obj
+ del self.widget
+
+ def testShow(self):
+ """Emission of a python signal to QWidget slot show()"""
+ self.widget.hide()
+
+ QObject.connect(self.obj, SIGNAL('dummy()'), self.widget, SLOT('show()'))
+ self.assertTrue(not self.widget.isVisible())
+
+ self.obj.emit(SIGNAL('dummy()'))
+ self.assertTrue(self.widget.isVisible())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/qobject_destroyed_test.py b/sources/pyside2/tests/signals/qobject_destroyed_test.py
new file mode 100644
index 000000000..776702ee1
--- /dev/null
+++ b/sources/pyside2/tests/signals/qobject_destroyed_test.py
@@ -0,0 +1,50 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL
+
+class QObjectDestroyed(unittest.TestCase):
+ """Very simple test case for the destroyed() signal of QObject"""
+
+ def setUp(self):
+ self.called = False
+
+ def destroyed_cb(self):
+ self.called = True
+
+ def testDestroyed(self):
+ """Emission of QObject.destroyed() to a python slot"""
+ obj = QObject()
+ QObject.connect(obj, SIGNAL('destroyed()'), self.destroyed_cb)
+ del obj
+ self.assertTrue(self.called)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/qobject_receivers_test.py b/sources/pyside2/tests/signals/qobject_receivers_test.py
new file mode 100644
index 000000000..8caaa7edb
--- /dev/null
+++ b/sources/pyside2/tests/signals/qobject_receivers_test.py
@@ -0,0 +1,76 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test case for QObject.receivers()'''
+
+import unittest
+from PySide2.QtCore import *
+
+def cute_slot():
+ pass
+
+class TestQObjectReceivers(unittest.TestCase):
+ '''Test case for QObject::receivers'''
+
+ def testBasic(self):
+ sender = QObject()
+ receiver1 = QObject()
+ receiver2 = QObject()
+ self.assertEqual(sender.receivers(SIGNAL("")), 0)
+ sender.connect(sender, SIGNAL("destroyed()"), receiver1, SLOT("deleteLater()"))
+ self.assertEqual(sender.receivers(SIGNAL("destroyed()")), 1)
+ sender.connect(sender, SIGNAL("destroyed()"), receiver2, SLOT("deleteLater()"))
+ self.assertEqual(sender.receivers(SIGNAL("destroyed()")), 2)
+ sender.disconnect(sender, SIGNAL("destroyed()"), receiver2, SLOT("deleteLater()"))
+ self.assertEqual(sender.receivers(SIGNAL("destroyed()")), 1)
+ del receiver2
+ del receiver1
+ del sender
+
+ def testPySlots(self):
+ sender = QObject()
+ receiver = QObject()
+ sender.connect(sender, SIGNAL("destroyed()"), cute_slot)
+ self.assertEqual(sender.receivers(SIGNAL("destroyed( )")), 1)
+ sender.connect(sender, SIGNAL("destroyed()"), receiver, SLOT("deleteLater()"))
+ self.assertEqual(sender.receivers(SIGNAL("destroyed()")), 2)
+ del sender
+ del receiver
+
+ def testPySignals(self):
+ sender = QObject()
+ receiver = QObject()
+ sender.connect(sender, SIGNAL("some_dynamic_signal()"), cute_slot)
+ self.assertEqual(sender.receivers(SIGNAL("some_dynamic_signal( )")), 1)
+ sender.connect(sender, SIGNAL("some_dynamic_signal()"), receiver, SLOT("deleteLater()"))
+ self.assertEqual(sender.receivers(SIGNAL("some_dynamic_signal( )")), 2)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/qobject_sender_test.py b/sources/pyside2/tests/signals/qobject_sender_test.py
new file mode 100644
index 000000000..dfc8fac83
--- /dev/null
+++ b/sources/pyside2/tests/signals/qobject_sender_test.py
@@ -0,0 +1,120 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QObject.sender()'''
+
+import unittest
+from PySide2.QtCore import *
+from helper import UsesQCoreApplication
+
+class ExtQTimer(QTimer):
+ def __init__(self):
+ QTimer.__init__(self)
+
+class Receiver(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+ self.the_sender = None
+
+ def callback(self):
+ self.the_sender = self.sender()
+ if QCoreApplication.instance():
+ QCoreApplication.instance().exit()
+
+class ObjectSenderTest(unittest.TestCase):
+ '''Test case for QObject.sender() method.'''
+
+ def testSenderPythonSignal(self):
+ sender = QObject()
+ recv = Receiver()
+ QObject.connect(sender, SIGNAL('foo()'), recv.callback)
+ sender.emit(SIGNAL('foo()'))
+ self.assertEqual(sender, recv.the_sender)
+
+class ObjectSenderCheckOnReceiverTest(unittest.TestCase):
+ '''Test case for QObject.sender() method, this one tests the equality on the Receiver object.'''
+
+ def testSenderPythonSignal(self):
+ sender = QObject()
+ recv = Receiver()
+ QObject.connect(sender, SIGNAL('foo()'), recv.callback)
+ sender.emit(SIGNAL('foo()'))
+ self.assertEqual(sender, recv.the_sender)
+
+class ObjectSenderWithQAppTest(UsesQCoreApplication):
+ '''Test case for QObject.sender() method with QApplication.'''
+
+ def testSenderCppSignal(self):
+ sender = QTimer()
+ sender.setObjectName('foo')
+ recv = Receiver()
+ QObject.connect(sender, SIGNAL('timeout()'), recv.callback)
+ sender.start(10)
+ self.app.exec_()
+ self.assertEqual(sender, recv.the_sender)
+
+ def testSenderCppSignalSingleShotTimer(self):
+ recv = Receiver()
+ QTimer.singleShot(10, recv.callback)
+ self.app.exec_()
+ self.assertTrue(isinstance(recv.the_sender, QObject))
+
+ def testSenderCppSignalWithPythonExtendedClass(self):
+ sender = ExtQTimer()
+ recv = Receiver()
+ QObject.connect(sender, SIGNAL('timeout()'), recv.callback)
+ sender.start(10)
+ self.app.exec_()
+ self.assertEqual(sender, recv.the_sender)
+
+class ObjectSenderWithQAppCheckOnReceiverTest(UsesQCoreApplication):
+ '''Test case for QObject.sender() method with QApplication.'''
+
+ def testSenderCppSignal(self):
+ sender = QTimer()
+ sender.setObjectName('foo')
+ recv = Receiver()
+ QObject.connect(sender, SIGNAL('timeout()'), recv.callback)
+ sender.start(10)
+ self.app.exec_()
+ self.assertEqual(sender, recv.the_sender)
+
+ def testSenderCppSignalWithPythonExtendedClass(self):
+ sender = ExtQTimer()
+ recv = Receiver()
+ QObject.connect(sender, SIGNAL('timeout()'), recv.callback)
+ sender.start(10)
+ self.app.exec_()
+ self.assertEqual(sender, recv.the_sender)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/ref01_test.py b/sources/pyside2/tests/signals/ref01_test.py
new file mode 100644
index 000000000..ad56ca45f
--- /dev/null
+++ b/sources/pyside2/tests/signals/ref01_test.py
@@ -0,0 +1,55 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QObject, Signal
+
+class BoundAndUnboundSignalsTest(unittest.TestCase):
+
+ def setUp(self):
+ self.methods = set(('connect', 'disconnect', 'emit'))
+
+ def tearDown(self):
+ del self.methods
+
+ def testUnboundSignal(self):
+ self.assertEqual(type(QObject.destroyed), Signal)
+ self.assertFalse(self.methods.issubset(dir(QObject.destroyed)))
+
+ def testBoundSignal(self):
+ obj = QObject()
+ self.assertNotEqual(type(obj.destroyed), Signal)
+ self.assertTrue(self.methods.issubset(dir(obj.destroyed)))
+
+if __name__ == '__main__':
+ unittest.main()
+
+
diff --git a/sources/pyside2/tests/signals/ref02_test.py b/sources/pyside2/tests/signals/ref02_test.py
new file mode 100644
index 000000000..7c16b2c64
--- /dev/null
+++ b/sources/pyside2/tests/signals/ref02_test.py
@@ -0,0 +1,75 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QCoreApplication, QTimeLine
+from helper import UsesQCoreApplication
+
+class NativeSignalsTest(UsesQCoreApplication):
+
+ def setUp(self):
+ UsesQCoreApplication.setUp(self)
+ self.called = False
+ self.timeline = QTimeLine(100)
+
+ def tearDown(self):
+ del self.called
+ del self.timeline
+ UsesQCoreApplication.tearDown(self)
+
+ def testSignalWithIntArgument(self):
+
+ def valueChangedSlot(value):
+ self.called = True
+ self.assertEqual(type(value), float)
+ self.app.quit()
+
+ self.timeline.valueChanged.connect(valueChangedSlot)
+ self.timeline.start()
+
+ self.app.exec_()
+ self.assertTrue(self.called)
+
+ def testSignalWithoutArguments(self):
+
+ def finishedSlot():
+ self.called = True
+ self.app.quit()
+
+ self.timeline.finished.connect(finishedSlot)
+ self.timeline.start()
+
+ self.app.exec_()
+ self.assertTrue(self.called)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/ref03_test.py b/sources/pyside2/tests/signals/ref03_test.py
new file mode 100644
index 000000000..1f2d7a055
--- /dev/null
+++ b/sources/pyside2/tests/signals/ref03_test.py
@@ -0,0 +1,57 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sys import getrefcount
+from PySide2.QtCore import QObject
+
+class DisconnectSignalsTest(unittest.TestCase):
+
+ def setUp(self):
+ self.emitter = QObject()
+
+ def tearDown(self):
+ del self.emitter
+
+ def testConnectionRefCount(self):
+
+ def destroyedSlot():
+ pass
+
+ self.assertEqual(getrefcount(destroyedSlot), 2)
+ self.emitter.destroyed.connect(destroyedSlot)
+ self.assertEqual(getrefcount(destroyedSlot), 3)
+ self.emitter.destroyed.disconnect(destroyedSlot)
+ self.assertEqual(getrefcount(destroyedSlot), 2)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/ref04_test.py b/sources/pyside2/tests/signals/ref04_test.py
new file mode 100644
index 000000000..73ae92124
--- /dev/null
+++ b/sources/pyside2/tests/signals/ref04_test.py
@@ -0,0 +1,84 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QObject, Signal
+
+class ExtQObject(QObject):
+
+ mySignal = Signal()
+
+ def __init__(self):
+ QObject.__init__(self)
+
+
+class UserSignalTest(unittest.TestCase):
+
+ def setUp(self):
+ self.emitter = ExtQObject()
+ self.counter = 0
+
+ def tearDown(self):
+ del self.emitter
+ del self.counter
+
+ def testConnectEmitDisconnect(self):
+
+ def slot():
+ self.counter += 1
+
+ self.emitter.mySignal.connect(slot)
+
+ self.assertEqual(self.counter, 0)
+ self.emitter.mySignal.emit()
+ self.assertEqual(self.counter, 1)
+ self.emitter.mySignal.emit()
+ self.assertEqual(self.counter, 2)
+
+ self.emitter.mySignal.disconnect(slot)
+
+ self.emitter.mySignal.emit()
+ self.assertEqual(self.counter, 2)
+
+# def testConnectWithConfigureMethod(self):
+#
+# def slot():
+# self.counter += 1
+#
+# self.emitter.pyqtConfigure(mySignal=slot)
+# self.assertEqual(self.counter, 0)
+# self.emitter.mySignal.emit()
+# self.assertEqual(self.counter, 1)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/ref05_test.py b/sources/pyside2/tests/signals/ref05_test.py
new file mode 100644
index 000000000..2bd7d79c6
--- /dev/null
+++ b/sources/pyside2/tests/signals/ref05_test.py
@@ -0,0 +1,74 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QObject, QCoreApplication, QTimeLine, Slot
+from helper import UsesQCoreApplication
+
+class ExtQObject(QObject):
+
+ def __init__(self):
+ QObject.__init__(self)
+ self.counter = 0
+
+ @Slot('qreal')
+ def foo(self, value):
+ self.counter += 1
+
+
+class UserSlotTest(UsesQCoreApplication):
+
+ def setUp(self):
+ UsesQCoreApplication.setUp(self)
+ self.receiver = ExtQObject()
+ self.timeline = QTimeLine(100)
+
+ def tearDown(self):
+ del self.timeline
+ del self.receiver
+ UsesQCoreApplication.tearDown(self)
+
+ def testUserSlot(self):
+ self.timeline.setUpdateInterval(10)
+
+ self.timeline.finished.connect(self.app.quit)
+
+ self.timeline.valueChanged.connect(self.receiver.foo)
+ self.timeline.start()
+
+ self.app.exec_()
+
+ self.assertTrue(self.receiver.counter > 1)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/ref06_test.py b/sources/pyside2/tests/signals/ref06_test.py
new file mode 100644
index 000000000..ee2aa5700
--- /dev/null
+++ b/sources/pyside2/tests/signals/ref06_test.py
@@ -0,0 +1,77 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import QObject, QCoreApplication, QTimeLine, Signal, Slot
+from helper import UsesQCoreApplication
+
+class ExtQObject(QObject):
+ signalbetween = Signal('qreal')
+
+ def __init__(self):
+ QObject.__init__(self)
+ self.counter = 0
+
+ @Slot('qreal')
+ def foo(self, value):
+ self.counter += 1
+
+
+class SignaltoSignalTest(UsesQCoreApplication):
+
+ def setUp(self):
+ UsesQCoreApplication.setUp(self)
+ self.receiver = ExtQObject()
+ self.timeline = QTimeLine(100)
+
+ def tearDown(self):
+ del self.timeline
+ del self.receiver
+ UsesQCoreApplication.tearDown(self)
+
+ def testSignaltoSignal(self):
+ self.timeline.setUpdateInterval(10)
+
+ self.timeline.finished.connect(self.app.quit)
+
+ self.timeline.valueChanged.connect(self.receiver.signalbetween)
+ self.receiver.signalbetween.connect(self.receiver.foo)
+
+ self.timeline.start()
+
+ self.app.exec_()
+
+ self.assertTrue(self.receiver.counter > 1)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/segfault_proxyparent_test.py b/sources/pyside2/tests/signals/segfault_proxyparent_test.py
new file mode 100644
index 000000000..b45e53579
--- /dev/null
+++ b/sources/pyside2/tests/signals/segfault_proxyparent_test.py
@@ -0,0 +1,86 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL
+
+# Description of the problem
+# After creating an PyObject that inherits from QObject, connecting it,
+# deleting it and later creating another Python QObject-based object, this
+# new object will point to the same memory position as the first one.
+
+# Somehow the underlying QObject also points to the same position.
+
+# In PyQt4, the connection works fine with the same memory behavior,
+# so it looks like specific to SIP.
+
+class Dummy(QObject):
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+
+class Joe(QObject):
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+
+class SegfaultCase(unittest.TestCase):
+ """Test case for the segfault happening when parent() is called inside
+ ProxyObject"""
+
+ def setUp(self):
+ self.called = False
+
+ def tearDown(self):
+ try:
+ del self.args
+ except:
+ pass
+
+ def callback(self, *args):
+ if tuple(self.args) == args:
+ self.called = True
+
+ def testSegfault(self):
+ """Regression: Segfault for qobjects in the same memory position."""
+ obj = Dummy()
+ QObject.connect(obj, SIGNAL('bar(int)'), self.callback)
+ self.args = (33,)
+ obj.emit(SIGNAL('bar(int)'), self.args[0])
+ self.assertTrue(self.called)
+ del obj
+
+ obj = Joe()
+ QObject.connect(obj, SIGNAL('bar(int)'), self.callback)
+ self.args = (33,)
+ obj.emit(SIGNAL('bar(int)'), self.args[0])
+ self.assertTrue(self.called)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/self_connect_test.py b/sources/pyside2/tests/signals/self_connect_test.py
new file mode 100644
index 000000000..fde5fa885
--- /dev/null
+++ b/sources/pyside2/tests/signals/self_connect_test.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Using self.connect(signal, method)'''
+
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL, SLOT
+from PySide2.QtWidgets import QPushButton, QWidget
+
+from helper import UsesQApplication
+
+
+class SelfConnect(UsesQApplication):
+
+ def testButtonClickClose(self):
+ button = QPushButton()
+ button.connect(button, SIGNAL('clicked()'), SLOT('close()'))
+
+ button.show()
+ self.assertTrue(button.isVisible())
+ button.click()
+ self.assertTrue(not button.isVisible())
+
+ def testWindowButtonClickClose(self):
+ button = QPushButton()
+ window = QWidget()
+ window.connect(button, SIGNAL('clicked()'), SLOT('close()'))
+
+ window.show()
+ self.assertTrue(window.isVisible())
+ button.click()
+ self.assertTrue(not window.isVisible())
+
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/short_circuit_test.py b/sources/pyside2/tests/signals/short_circuit_test.py
new file mode 100644
index 000000000..a47385f5c
--- /dev/null
+++ b/sources/pyside2/tests/signals/short_circuit_test.py
@@ -0,0 +1,91 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL, SLOT
+
+class Dummy(QObject):
+ """Dummy class used in this test."""
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+
+class ShortCircuitSignals(unittest.TestCase):
+ def setUp(self):
+ self.called = False
+
+ def tearDown(self):
+ try:
+ del self.args
+ except:
+ pass
+
+ def callback(self, *args):
+ if tuple(self.args) == args:
+ self.called = True
+
+ def testNoArgs(self):
+ """Short circuit signal without arguments"""
+ obj1 = Dummy()
+ QObject.connect(obj1, SIGNAL('foo()'), self.callback)
+ self.args = tuple()
+ obj1.emit(SIGNAL('foo()'), *self.args)
+ self.assertTrue(self.called)
+
+ def testWithArgs(self):
+ """Short circuit signal with integer arguments"""
+ obj1 = Dummy()
+
+ QObject.connect(obj1, SIGNAL('foo(int)'), self.callback)
+ self.args = (42,)
+ obj1.emit(SIGNAL('foo(int)'), *self.args)
+
+ self.assertTrue(self.called)
+
+ def testMultipleArgs(self):
+ """Short circuit signal with multiple arguments"""
+ obj1 = Dummy()
+
+ QObject.connect(obj1, SIGNAL('foo(int,int,QString)'), self.callback)
+ self.args = (42,33,'char')
+ obj1.emit(SIGNAL('foo(int,int,QString)'), *self.args)
+
+ self.assertTrue(self.called)
+
+ def testComplexArgs(self):
+ """Short circuit signal with complex arguments"""
+ obj1 = Dummy()
+
+ QObject.connect(obj1, SIGNAL('foo(int,QObject*)'), self.callback)
+ self.args = (42, obj1)
+ obj1.emit(SIGNAL('foo(int,QObject*)'), *self.args)
+
+ self.assertTrue(self.called)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/signal2signal_connect_test.py b/sources/pyside2/tests/signals/signal2signal_connect_test.py
new file mode 100644
index 000000000..f088212de
--- /dev/null
+++ b/sources/pyside2/tests/signals/signal2signal_connect_test.py
@@ -0,0 +1,135 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test case for signal to signal connections.'''
+
+import unittest
+from PySide2.QtCore import *
+
+def cute_slot():
+ pass
+
+class TestSignal2SignalConnect(unittest.TestCase):
+ '''Test case for signal to signal connections'''
+
+ def setUp(self):
+ #Set up the basic resources needed
+ self.sender = QObject()
+ self.forwarder = QObject()
+ self.args = None
+ self.called = False
+
+ def tearDown(self):
+ #Delete used resources
+ try:
+ del self.sender
+ except:
+ pass
+ try:
+ del self.forwarder
+ except:
+ pass
+ del self.args
+
+ def callback_noargs(self):
+ #Default callback without arguments
+ self.called = True
+
+ def callback_args(self, *args):
+ #Default callback with arguments
+ if args == self.args:
+ self.called = True
+ else:
+ raise TypeError("Invalid arguments")
+
+ def callback_qobject(self, *args):
+ #Default callback for QObject as argument
+ if args[0].objectName() == self.args[0]:
+ self.called = True
+ else:
+ raise TypeError("Invalid arguments")
+
+
+ def testSignalWithoutArguments(self):
+ QObject.connect(self.sender, SIGNAL("destroyed()"),
+ self.forwarder, SIGNAL("forward()"))
+ QObject.connect(self.forwarder, SIGNAL("forward()"),
+ self.callback_noargs)
+ del self.sender
+ self.assertTrue(self.called)
+
+
+ def testSignalWithOnePrimitiveTypeArgument(self):
+ QObject.connect(self.sender, SIGNAL("mysignal(int)"),
+ self.forwarder, SIGNAL("mysignal(int)"))
+ QObject.connect(self.forwarder, SIGNAL("mysignal(int)"),
+ self.callback_args)
+ self.args = (19,)
+ self.sender.emit(SIGNAL('mysignal(int)'), *self.args)
+ self.assertTrue(self.called)
+
+
+ def testSignalWithMultiplePrimitiveTypeArguments(self):
+ QObject.connect(self.sender, SIGNAL("mysignal(int,int)"),
+ self.forwarder, SIGNAL("mysignal(int,int)"))
+ QObject.connect(self.forwarder, SIGNAL("mysignal(int,int)"),
+ self.callback_args)
+ self.args = (23, 29)
+ self.sender.emit(SIGNAL('mysignal(int,int)'), *self.args)
+ self.assertTrue(self.called)
+
+
+ def testSignalWithOneStringArgument(self):
+ QObject.connect(self.sender, SIGNAL("mysignal(QString)"),
+ self.forwarder, SIGNAL("mysignal(QString)"))
+ QObject.connect(self.forwarder, SIGNAL("mysignal(QString)"),
+ self.callback_args)
+ self.args = ('myargument',)
+ self.sender.emit(SIGNAL('mysignal(QString)'), *self.args)
+ self.assertTrue(self.called)
+
+
+ def testSignalWithOneQObjectArgument(self):
+ QObject.connect(self.sender, SIGNAL('destroyed(QObject*)'),
+ self.forwarder, SIGNAL('forward(QObject*)'))
+ QObject.connect(self.forwarder, SIGNAL('forward(QObject*)'),
+ self.callback_qobject)
+
+ obj_name = 'sender'
+ self.sender.setObjectName(obj_name)
+ self.args = (obj_name, )
+ del self.sender
+ self.assertTrue(self.called)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
+
diff --git a/sources/pyside2/tests/signals/signal_autoconnect_test.py b/sources/pyside2/tests/signals/signal_autoconnect_test.py
new file mode 100644
index 000000000..e8ff6200e
--- /dev/null
+++ b/sources/pyside2/tests/signals/signal_autoconnect_test.py
@@ -0,0 +1,59 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import *
+from PySide2.QtWidgets import *
+
+class MyObject(QWidget):
+ def __init__(self, parent=None):
+ QWidget.__init__(self, parent)
+ self._method_called = False
+
+ @Slot()
+ def on_button_clicked(self):
+ self._method_called = True
+
+
+class AutoConnectionTest(unittest.TestCase):
+
+ def testConnection(self):
+ app = QApplication([])
+
+ win = MyObject()
+ btn = QPushButton("click", win)
+ btn.setObjectName("button")
+ QMetaObject.connectSlotsByName(win)
+ btn.click()
+ self.assertTrue(win._method_called)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/signal_connectiontype_support_test.py b/sources/pyside2/tests/signals/signal_connectiontype_support_test.py
new file mode 100644
index 000000000..50a24084e
--- /dev/null
+++ b/sources/pyside2/tests/signals/signal_connectiontype_support_test.py
@@ -0,0 +1,55 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL, Qt
+
+class Dummy(QObject):
+ """Dummy class used in this test."""
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+
+class TestConnectionTypeSupport(unittest.TestCase):
+ def callback(self, *args):
+ if tuple(self.args) == args:
+ self.called = True
+
+ def testNoArgs(self):
+ """Connect signal using a Qt.ConnectionType as argument"""
+ obj1 = Dummy()
+
+ QObject.connect(obj1, SIGNAL('foo()'), self.callback, Qt.DirectConnection)
+ self.args = tuple()
+ obj1.emit(SIGNAL('foo()'), *self.args)
+
+ self.assertTrue(self.called)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/signal_emission_gui_test.py b/sources/pyside2/tests/signals/signal_emission_gui_test.py
new file mode 100644
index 000000000..b114351c2
--- /dev/null
+++ b/sources/pyside2/tests/signals/signal_emission_gui_test.py
@@ -0,0 +1,141 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+"""Tests covering signal emission and receiving to python slots"""
+
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL, SLOT
+
+try:
+ from PySide2.QtWidgets import QSpinBox, QPushButton
+ hasQtGui = True
+except ImportError:
+ hasQtGui = False
+
+from helper import BasicPySlotCase, UsesQApplication
+
+if hasQtGui:
+ class ButtonPySlot(UsesQApplication, BasicPySlotCase):
+ """Tests the connection of python slots to QPushButton signals"""
+
+ def testButtonClicked(self):
+ """Connection of a python slot to QPushButton.clicked()"""
+ button = QPushButton('Mylabel')
+ QObject.connect(button, SIGNAL('clicked()'), self.cb)
+ self.args = tuple()
+ button.emit(SIGNAL('clicked(bool)'), False)
+ self.assertTrue(self.called)
+
+ def testButtonClick(self):
+ """Indirect qt signal emission using the QPushButton.click() method """
+ button = QPushButton('label')
+ QObject.connect(button, SIGNAL('clicked()'), self.cb)
+ self.args = tuple()
+ button.click()
+ self.assertTrue(self.called)
+
+
+if hasQtGui:
+ class SpinBoxPySlot(UsesQApplication, BasicPySlotCase):
+ """Tests the connection of python slots to QSpinBox signals"""
+
+ def setUp(self):
+ super(SpinBoxPySlot, self).setUp()
+ self.spin = QSpinBox()
+
+ def tearDown(self):
+ del self.spin
+ super(SpinBoxPySlot, self).tearDown()
+
+ def testSpinBoxValueChanged(self):
+ """Connection of a python slot to QSpinBox.valueChanged(int)"""
+ QObject.connect(self.spin, SIGNAL('valueChanged(int)'), self.cb)
+ self.args = [3]
+ self.spin.emit(SIGNAL('valueChanged(int)'), *self.args)
+ self.assertTrue(self.called)
+
+ def testSpinBoxValueChangedImplicit(self):
+ """Indirect qt signal emission using QSpinBox.setValue(int)"""
+ QObject.connect(self.spin, SIGNAL('valueChanged(int)'), self.cb)
+ self.args = [42]
+ self.spin.setValue(self.args[0])
+ self.assertTrue(self.called)
+
+ def atestSpinBoxValueChangedFewArgs(self):
+ """Emission of signals with fewer arguments than needed"""
+ # XXX: PyQt4 crashes on the assertRaises
+ QObject.connect(self.spin, SIGNAL('valueChanged(int)'), self.cb)
+ self.args = (554,)
+ self.assertRaises(TypeError, self.spin.emit, SIGNAL('valueChanged(int)'))
+
+if hasQtGui:
+ class QSpinBoxQtSlots(UsesQApplication):
+ """Tests the connection to QSpinBox qt slots"""
+
+ qapplication = True
+
+ def testSetValueIndirect(self):
+ """Indirect signal emission: QSpinBox using valueChanged(int)/setValue(int)"""
+ spinSend = QSpinBox()
+ spinRec = QSpinBox()
+
+ spinRec.setValue(5)
+
+ QObject.connect(spinSend, SIGNAL('valueChanged(int)'), spinRec, SLOT('setValue(int)'))
+ self.assertEqual(spinRec.value(), 5)
+ spinSend.setValue(3)
+ self.assertEqual(spinRec.value(), 3)
+ self.assertEqual(spinSend.value(), 3)
+
+ def testSetValue(self):
+ """Direct signal emission: QSpinBox using valueChanged(int)/setValue(int)"""
+ spinSend = QSpinBox()
+ spinRec = QSpinBox()
+
+ spinRec.setValue(5)
+ spinSend.setValue(42)
+
+ QObject.connect(spinSend, SIGNAL('valueChanged(int)'), spinRec, SLOT('setValue(int)'))
+ self.assertEqual(spinRec.value(), 5)
+ self.assertEqual(spinSend.value(), 42)
+ spinSend.emit(SIGNAL('valueChanged(int)'), 3)
+
+ self.assertEqual(spinRec.value(), 3)
+ #Direct emission shouldn't change the value of the emitter
+ self.assertEqual(spinSend.value(), 42)
+
+ spinSend.emit(SIGNAL('valueChanged(int)'), 66)
+ self.assertEqual(spinRec.value(), 66)
+ self.assertEqual(spinSend.value(), 42)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/signal_emission_test.py b/sources/pyside2/tests/signals/signal_emission_test.py
new file mode 100644
index 000000000..8e36d9826
--- /dev/null
+++ b/sources/pyside2/tests/signals/signal_emission_test.py
@@ -0,0 +1,152 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+"""Tests covering signal emission and receiving to python slots"""
+
+import sys
+import unittest
+import functools
+
+from PySide2.QtCore import QObject, SIGNAL, SLOT, QProcess, QTimeLine
+
+from helper import BasicPySlotCase, UsesQCoreApplication
+
+
+class ArgsOnEmptySignal(UsesQCoreApplication):
+ '''Trying to emit a signal without arguments passing some arguments'''
+
+ def testArgsToNoArgsSignal(self):
+ '''Passing arguments to a signal without arguments'''
+ process = QProcess()
+ self.assertRaises(TypeError, process.emit, SIGNAL('started()'), 42)
+
+
+class MoreArgsOnEmit(UsesQCoreApplication):
+ '''Trying to pass more args than needed to emit (signals with args)'''
+
+ def testMoreArgs(self):
+ '''Passing more arguments than needed'''
+ process = QProcess()
+ self.assertRaises(TypeError, process.emit, SIGNAL('finished(int)'), 55, 55)
+
+class Dummy(QObject):
+ '''Dummy class'''
+ pass
+
+class PythonSignalToCppSlots(UsesQCoreApplication):
+ '''Connect python signals to C++ slots'''
+
+ def testWithoutArgs(self):
+ '''Connect python signal to QTimeLine.toggleDirection()'''
+ timeline = QTimeLine()
+ dummy = Dummy()
+ QObject.connect(dummy, SIGNAL('dummy()'),
+ timeline, SLOT('toggleDirection()'))
+
+ orig_dir = timeline.direction()
+ dummy.emit(SIGNAL('dummy()'))
+ new_dir = timeline.direction()
+
+ if orig_dir == QTimeLine.Forward:
+ self.assertEqual(new_dir, QTimeLine.Backward)
+ else:
+ self.assertEqual(new_dir, QTimeLine.Forward)
+
+ def testWithArgs(self):
+ '''Connect python signals to QTimeLine.setCurrentTime(int)'''
+ timeline = QTimeLine()
+ dummy = Dummy()
+
+ QObject.connect(dummy, SIGNAL('dummy(int)'),
+ timeline, SLOT('setCurrentTime(int)'))
+
+ current = timeline.currentTime()
+ dummy.emit(SIGNAL('dummy(int)'), current+42)
+ self.assertEqual(timeline.currentTime(), current+42)
+
+class CppSignalsToCppSlots(UsesQCoreApplication):
+ '''Connection between C++ slots and signals'''
+
+ def testWithoutArgs(self):
+ '''Connect QProcess.started() to QTimeLine.togglePaused()'''
+ process = QProcess()
+ timeline = QTimeLine()
+
+ QObject.connect(process, SIGNAL('finished(int, QProcess::ExitStatus)'),
+ timeline, SLOT('toggleDirection()'))
+
+ orig_dir = timeline.direction()
+
+ process.start(sys.executable, ['-c', '"print 42"'])
+ process.waitForFinished()
+
+ new_dir = timeline.direction()
+
+ if orig_dir == QTimeLine.Forward:
+ self.assertEqual(new_dir, QTimeLine.Backward)
+ else:
+ self.assertEqual(new_dir, QTimeLine.Forward)
+
+called = False
+def someSlot(args=None):
+ global called
+ called = True
+
+class DynamicSignalsToFuncPartial(UsesQCoreApplication):
+
+ def testIt(self):
+ global called
+ called = False
+ o = QObject()
+ o.connect(o, SIGNAL("ASignal()"), functools.partial(someSlot, "partial .."))
+ o.emit(SIGNAL("ASignal()"))
+ self.assertTrue(called)
+
+class EmitUnknownType(UsesQCoreApplication):
+ def testIt(self):
+ a = QObject()
+ a.connect(SIGNAL('foobar(Dummy)'), lambda x: 42) # Just connect with an unknown type
+ self.assertRaises(TypeError, a.emit, SIGNAL('foobar(Dummy)'), 22)
+
+class EmitEnum(UsesQCoreApplication):
+ """Test emission of enum arguments"""
+
+ def slot(self, arg):
+ self.arg = arg
+
+ def testIt(self):
+ self.arg = None
+ p = QProcess()
+ p.stateChanged.connect(self.slot)
+ p.stateChanged.emit(QProcess.NotRunning)
+ self.assertEqual(self.arg, QProcess.NotRunning)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/signal_func_test.py b/sources/pyside2/tests/signals/signal_func_test.py
new file mode 100644
index 000000000..80e05a76f
--- /dev/null
+++ b/sources/pyside2/tests/signals/signal_func_test.py
@@ -0,0 +1,49 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import SIGNAL, SLOT
+
+class SIGNALSLOTTests(unittest.TestCase):
+ '''Test the output of SIGNAL and SLOT.'''
+
+ def testSIGNAL(self):
+ #SIGNAL function
+ a = "foobar"
+ self.assertEqual(str(SIGNAL(a)), "2foobar")
+
+ def testSLOT(self):
+ #SLOT function
+ a = "foobar"
+ self.assertEqual(str(SLOT(a)), "1foobar")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/signal_manager_refcount_test.py b/sources/pyside2/tests/signals/signal_manager_refcount_test.py
new file mode 100644
index 000000000..3a1939cc6
--- /dev/null
+++ b/sources/pyside2/tests/signals/signal_manager_refcount_test.py
@@ -0,0 +1,51 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from sys import getrefcount
+import unittest
+from PySide2.QtCore import QObject, SIGNAL
+
+class SignalManagerRefCount(unittest.TestCase):
+ """Simple test case to check if the signal_manager is erroneously incrementing the object refcounter"""
+
+ def testObjectRefcount(self):
+ """Emission of QObject.destroyed() to a python slot"""
+ def callback():
+ pass
+ obj = QObject()
+ refcount = getrefcount(obj)
+ QObject.connect(obj, SIGNAL('destroyed()'), callback)
+ self.assertEqual(refcount, getrefcount(obj))
+ QObject.disconnect(obj, SIGNAL('destroyed()'), callback)
+ self.assertEqual(refcount, getrefcount(obj))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/signal_number_limit_test.py b/sources/pyside2/tests/signals/signal_number_limit_test.py
new file mode 100644
index 000000000..9850f17ba
--- /dev/null
+++ b/sources/pyside2/tests/signals/signal_number_limit_test.py
@@ -0,0 +1,90 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2 import QtCore
+
+class Emitter(QtCore.QObject):
+ s1 = QtCore.Signal()
+ s2 = QtCore.Signal()
+ s3 = QtCore.Signal()
+ s4 = QtCore.Signal()
+ s5 = QtCore.Signal()
+ s6 = QtCore.Signal()
+ s7 = QtCore.Signal()
+ s8 = QtCore.Signal()
+ s9 = QtCore.Signal()
+ s10 = QtCore.Signal()
+ s11 = QtCore.Signal()
+ s12 = QtCore.Signal()
+ s13 = QtCore.Signal()
+ s14 = QtCore.Signal()
+
+class SignalNumberLimitTest(unittest.TestCase):
+ def myCb(self):
+ self._count += 1
+
+ def testBug(self):
+ e = Emitter()
+ e.s1.connect(self.myCb)
+ e.s2.connect(self.myCb)
+ e.s3.connect(self.myCb)
+ e.s4.connect(self.myCb)
+ e.s5.connect(self.myCb)
+ e.s6.connect(self.myCb)
+ e.s7.connect(self.myCb)
+ e.s8.connect(self.myCb)
+ e.s9.connect(self.myCb)
+ e.s10.connect(self.myCb)
+ e.s11.connect(self.myCb)
+ e.s12.connect(self.myCb)
+ e.s13.connect(self.myCb)
+ e.s14.connect(self.myCb)
+
+ self._count = 0
+ e.s1.emit()
+ e.s2.emit()
+ e.s3.emit()
+ e.s4.emit()
+ e.s5.emit()
+ e.s6.emit()
+ e.s7.emit()
+ e.s8.emit()
+ e.s9.emit()
+ e.s10.emit()
+ e.s11.emit()
+ e.s12.emit()
+ e.s13.emit()
+ e.s14.emit()
+ self.assertEqual(self._count, 14)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/signal_object_test.py b/sources/pyside2/tests/signals/signal_object_test.py
new file mode 100644
index 000000000..3247f7c46
--- /dev/null
+++ b/sources/pyside2/tests/signals/signal_object_test.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtCore import QTimer, Signal, QObject, Slot, Qt
+from helper import UsesQCoreApplication
+
+class MyObject(QTimer):
+ sig1 = Signal()
+ sig2 = Signal(int, name='rangeChanged')
+ sig3 = Signal(int)
+ sig4 = Signal((int,), (str,))
+ sig5 = Signal((str,), (int,))
+ sig6 = Signal(QObject)
+
+ @Slot(int)
+ def myRange(self, r):
+ self._range = r
+
+ def slot1(self):
+ self._called = True
+
+ def slotString(self, s):
+ self._s = s
+
+ def slotObject(self, o):
+ self._o = o
+
+
+class SignalObjectTest(UsesQCoreApplication):
+ def cb(self):
+ self._cb_called = True
+ self.app.exit()
+
+ def testsingleConnect(self):
+ o = MyObject()
+ o.sig1.connect(o.slot1)
+ o.sig1.emit()
+ self.assertTrue(o._called)
+
+ def testSignalWithArgs(self):
+ o = MyObject()
+ o.sig3.connect(o.myRange)
+ o.sig3.emit(10)
+ self.assertEqual(o._range, 10)
+
+ def testSignatureParse(self):
+ o = MyObject()
+ o.sig2.connect(o.myRange)
+ o.sig2.emit(10)
+
+ def testDictOperator(self):
+ o = MyObject()
+ o.sig4[str].connect(o.slotString)
+ o.sig4[str].emit("PySide")
+ self.assertEqual(o._s, "PySide")
+
+ def testGeneretedSignal(self):
+ o = MyObject()
+ o.timeout.connect(self.cb)
+ o.start(100)
+ self.app.exec_()
+ self.assertTrue(self._cb_called)
+
+ def testConnectionType(self):
+ o = MyObject()
+ o.timeout.connect(self.cb, type=Qt.DirectConnection)
+ o.start(100)
+ self.app.exec_()
+ self.assertTrue(self._cb_called)
+
+ def testSignalWithSignal(self):
+ o = MyObject()
+ o.sig2.connect(o.myRange)
+ o.sig5.connect(o.sig2)
+ o.sig5[int].emit(10)
+ self.assertEqual(o._range, 10)
+
+ def testSignalWithObject(self):
+ o = MyObject()
+ o.sig6.connect(o.slotObject)
+ arg = QObject()
+ o.sig6.emit(arg)
+ self.assertEqual(arg, o._o)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/signal_signature_test.py b/sources/pyside2/tests/signals/signal_signature_test.py
new file mode 100644
index 000000000..349619aac
--- /dev/null
+++ b/sources/pyside2/tests/signals/signal_signature_test.py
@@ -0,0 +1,76 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for signal signature received by QObject::connectNotify().'''
+
+import unittest
+from PySide2.QtCore import *
+from helper import UsesQCoreApplication
+
+class Obj(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+ self.signal = ''
+
+ def connectNotify(self, signal):
+ self.signal = signal
+
+def callback(arg=None):
+ pass
+
+class TestConnectNotifyWithNewStyleSignals(UsesQCoreApplication):
+ '''Test case for signal signature received by QObject::connectNotify().'''
+
+ def testOldStyle(self):
+ sender = Obj()
+ receiver = QObject()
+ sender.connect(SIGNAL('destroyed()'), receiver, SLOT('deleteLater()'))
+ # When connecting to a regular slot, and not a python callback function, QObject::connect
+ # will use the non-cloned method signature, so connectinc to destroyed() will actually
+ # connect to destroyed(QObject*).
+ self.assertEqual(sender.signal.methodSignature(), 'destroyed(QObject*)')
+
+ def testOldStyleWithPythonCallback(self):
+ sender = Obj()
+ sender.connect(SIGNAL('destroyed()'), callback)
+ self.assertEqual(sender.signal.methodSignature(), 'destroyed()')
+
+ def testNewStyle(self):
+ sender = Obj()
+
+ sender.destroyed.connect(callback)
+ self.assertEqual(sender.signal.methodSignature(), 'destroyed()')
+
+ sender.destroyed[QObject].connect(callback)
+ self.assertEqual(sender.signal.methodSignature(), 'destroyed(QObject*)')
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/signals/signal_with_primitive_type_test.py b/sources/pyside2/tests/signals/signal_with_primitive_type_test.py
new file mode 100644
index 000000000..cf1075051
--- /dev/null
+++ b/sources/pyside2/tests/signals/signal_with_primitive_type_test.py
@@ -0,0 +1,58 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2.QtCore import *
+
+
+class SignalPrimitiveTypeTest(unittest.TestCase):
+
+ def signalValueChanged(self, v):
+ self.called = True
+ self._app.quit()
+
+ def createTimeLine(self):
+ self.called = False
+ tl = QTimeLine(10000)
+ QObject.connect(tl, SIGNAL("valueChanged(qreal)"), self.signalValueChanged)
+ return tl
+
+ def testTimeLine(self):
+ self._valueChangedCount = 0
+ self._app = QCoreApplication([])
+ tl = self.createTimeLine()
+ tl.start()
+ self._app.exec_()
+ self.assertTrue(self.called)
+
+if __name__ == '__main__':
+ unittest.main()
+
+
diff --git a/sources/pyside2/tests/signals/slot_reference_count_test.py b/sources/pyside2/tests/signals/slot_reference_count_test.py
new file mode 100644
index 000000000..246c3a5b8
--- /dev/null
+++ b/sources/pyside2/tests/signals/slot_reference_count_test.py
@@ -0,0 +1,81 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Forced disconnection: Delete one end of the signal connection'''
+
+import unittest
+from sys import getrefcount
+
+from PySide2.QtCore import QObject, SIGNAL, SLOT
+
+class Dummy(QObject):
+ def dispatch(self):
+ self.emit(SIGNAL('foo()'))
+
+class PythonSignalRefCount(unittest.TestCase):
+
+ def setUp(self):
+ self.emitter = Dummy()
+
+ def tearDown(self):
+ self.emitter
+
+ def testRefCount(self):
+ def cb(*args):
+ pass
+
+ self.assertEqual(getrefcount(cb), 2)
+
+ QObject.connect(self.emitter, SIGNAL('foo()'), cb)
+ self.assertEqual(getrefcount(cb), 3)
+
+ QObject.disconnect(self.emitter, SIGNAL('foo()'), cb)
+ self.assertEqual(getrefcount(cb), 2)
+
+class CppSignalRefCount(unittest.TestCase):
+
+ def setUp(self):
+ self.emitter = QObject()
+
+ def tearDown(self):
+ self.emitter
+
+ def testRefCount(self):
+ def cb(*args):
+ pass
+
+ self.assertEqual(getrefcount(cb), 2)
+
+ QObject.connect(self.emitter, SIGNAL('destroyed()'), cb)
+ self.assertEqual(getrefcount(cb), 3)
+
+ QObject.disconnect(self.emitter, SIGNAL('destroyed()'), cb)
+ self.assertEqual(getrefcount(cb), 2)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/signals/static_metaobject_test.py b/sources/pyside2/tests/signals/static_metaobject_test.py
new file mode 100644
index 000000000..e0575bc3e
--- /dev/null
+++ b/sources/pyside2/tests/signals/static_metaobject_test.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+"""Tests covering signal emission and receiving to python slots"""
+
+import unittest
+
+from PySide2.QtCore import QObject, SIGNAL, Slot
+from helper import UsesQCoreApplication
+
+class MyObject(QObject):
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+ self._slotCalledCount = 0
+
+ # this '@Slot()' is needed to get the right sort order in testSharedSignalEmission.
+ # For some reason, it also makes the tests actually work!
+ @Slot()
+ def mySlot(self):
+ self._slotCalledCount = self._slotCalledCount + 1
+
+
+class StaticMetaObjectTest(UsesQCoreApplication):
+
+ def testSignalPropagation(self):
+ o = MyObject()
+ o2 = MyObject()
+
+ # SIGNAL foo not created yet
+ self.assertEqual(o.metaObject().indexOfSignal("foo()"), -1)
+
+ o.connect(SIGNAL("foo()"), o2.mySlot)
+ # SIGNAL foo create after connect
+ self.assertTrue(o.metaObject().indexOfSignal("foo()") > 0)
+
+ # SIGNAL does not propagate to others objects of the same type
+ self.assertEqual(o2.metaObject().indexOfSignal("foo()"), -1)
+
+ del o
+ del o2
+ o = MyObject()
+ # The SIGNAL was destroyed with old objects
+ self.assertEqual(o.metaObject().indexOfSignal("foo()"), -1)
+
+
+ def testSharedSignalEmission(self):
+ o = QObject()
+ m = MyObject()
+
+ o.connect(SIGNAL("foo2()"), m.mySlot)
+ m.connect(SIGNAL("foo2()"), m.mySlot)
+ o.emit(SIGNAL("foo2()"))
+ self.assertEqual(m._slotCalledCount, 1)
+ del o
+ m.emit(SIGNAL("foo2()"))
+ self.assertEqual(m._slotCalledCount, 2)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/tools/list-class-hierarchy.py b/sources/pyside2/tests/tools/list-class-hierarchy.py
new file mode 100755
index 000000000..742cd4fa7
--- /dev/null
+++ b/sources/pyside2/tests/tools/list-class-hierarchy.py
@@ -0,0 +1,117 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+
+# This is a small script printing out Qt binding class hierarchies
+# for comparison purposes.
+#
+# Usage:
+#
+# ./list-class-hierarchy.py PySide2 > pyside2.list
+# ./list-class-hierarchy.py PyQt5 > pyqt5.list
+#
+# meld pyside.list pyqt5.list
+
+from __future__ import print_function
+
+import sys
+import pdb
+from inspect import isclass
+
+ignore = ["staticMetaObject",
+ "pyqtConfigure",
+ "registerUserData",
+ "thread",
+ ]
+
+def recurse_into(el,obj):
+ #s = el.split('.')[-1]
+ #pdb.set_trace()
+ symbols = []
+ for item in sorted(dir(obj)):
+ if item[0]=='_':
+ continue
+ mel = el + '.' + item
+ try:
+ mobj = eval(mel)
+ except Exception:
+ continue
+
+ if item in ignore:
+ continue
+ else:
+ symbols.append(mel)
+
+ if isclass(mobj):
+ symbols += recurse_into(mel,mobj)
+
+ return symbols
+
+if __name__=='__main__':
+ modules = [ 'QtCore',
+ 'QtGui',
+ 'QtHelp',
+ #'QtMultimedia',
+ 'QtNetwork',
+ #'QtOpenGL',
+ 'QtScript',
+ 'QtScriptTools',
+ 'QtSql',
+ 'QtSvg',
+ 'QtTest',
+ #'QtUiTools',
+ 'QtWebKit',
+ 'QtXml',
+ 'QtXmlPatterns' ]
+
+ libraries = ["PySide2", "PyQt5"]
+ librarySymbols = {}
+ for l in libraries:
+ dictionary = []
+ if l =="PyQt5":
+ import sip
+ sip.setapi('QDate',2)
+ sip.setapi('QDateTime',2)
+ sip.setapi('QString',2)
+ sip.setapi('QTextStream',2)
+ sip.setapi('QTime',2)
+ sip.setapi('QUrl',2)
+ sip.setapi('QVariant',2)
+
+ for m in modules:
+ exec("from %s import %s" % (l,m), globals(), locals())
+ dictionary += recurse_into(m, eval(m))
+ librarySymbols[l] = dictionary
+
+ print("PyQt5: ", len(librarySymbols["PyQt5"]), " PySide2: ", len(librarySymbols["PySide2"]))
+
+ for symbol in librarySymbols["PyQt5"]:
+ if not (symbol in librarySymbols["PySide2"]):
+ print("Symbol not found in PySide2:", symbol)
diff --git a/sources/pyside2/tests/util/color.py b/sources/pyside2/tests/util/color.py
new file mode 100644
index 000000000..e7ab84d0e
--- /dev/null
+++ b/sources/pyside2/tests/util/color.py
@@ -0,0 +1,41 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+'''Function to print a colored line to terminal'''
+
+RED='\033[0;31m%s\033[m'
+
+def print_colored(message, color=RED):
+ print(color % message)
+
+if __name__ == '__main__':
+ print('42 - the answer')
+ print_colored("But what's the question?")
+ print('Hum?')
diff --git a/sources/pyside2/tests/util/helper/__init__.py b/sources/pyside2/tests/util/helper/__init__.py
new file mode 100644
index 000000000..ff7af6999
--- /dev/null
+++ b/sources/pyside2/tests/util/helper/__init__.py
@@ -0,0 +1,160 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Helper classes and functions'''
+
+import os
+import unittest
+
+from random import randint
+
+from PySide2.QtCore import QCoreApplication, QTimer
+
+try:
+ from PySide2.QtWidgets import QApplication
+except ImportError:
+ has_gui = False
+else:
+ has_gui = True
+
+def adjust_filename(filename, orig_mod_filename):
+ dirpath = os.path.dirname(os.path.abspath(orig_mod_filename))
+ return os.path.join(dirpath, filename)
+
+class NoQtGuiError(Exception):
+ def __init__(self):
+ Exception.__init__(self, 'No QtGui found')
+
+class BasicPySlotCase(object):
+ '''Base class that tests python slots and signal emissions.
+
+ Python slots are defined as any callable passed to QObject.connect().
+ '''
+ def setUp(self):
+ self.called = False
+
+ def tearDown(self):
+ try:
+ del self.args
+ except:
+ pass
+
+ def cb(self, *args):
+ '''Simple callback with arbitrary arguments.
+
+ The test function must setup the 'args' attribute with a sequence
+ containing the arguments expected to be received by this slot.
+ Currently only a single connection is supported.
+ '''
+ if tuple(self.args) == args:
+ self.called = True
+ else:
+ raise ValueError('Invalid arguments for callback')
+
+
+_instance = None
+_timed_instance = None
+
+if has_gui:
+ class UsesQApplication(unittest.TestCase):
+ '''Helper class to provide QApplication instances'''
+
+ qapplication = True
+
+ def setUp(self):
+ '''Creates the QApplication instance'''
+
+ # Simple way of making instance a singleton
+ super(UsesQApplication, self).setUp()
+ global _instance
+ if _instance is None:
+ _instance = QApplication([])
+
+ self.app = _instance
+
+ def tearDown(self):
+ '''Deletes the reference owned by self'''
+ del self.app
+ super(UsesQApplication, self).tearDown()
+
+
+ class TimedQApplication(unittest.TestCase):
+ '''Helper class with timed QApplication exec loop'''
+
+ def setUp(self, timeout=100):
+ '''Setups this Application.
+
+ timeout - timeout in milisseconds'''
+ global _timed_instance
+ if _timed_instance is None:
+ _timed_instance = QApplication([])
+
+ self.app = _timed_instance
+ QTimer.singleShot(timeout, self.app.quit)
+
+ def tearDown(self):
+ '''Delete resources'''
+ del self.app
+else:
+ class UsesQApplication(unittest.TestCase):
+ def setUp(self):
+ raise NoQtGuiError()
+ class TimedQapplication(unittest.TestCase):
+ def setUp(self):
+ raise NoQtGuiError()
+
+
+_core_instance = None
+
+class UsesQCoreApplication(unittest.TestCase):
+ '''Helper class for test cases that require an QCoreApplication
+ Just connect or call self.exit_app_cb. When called, will ask
+ self.app to exit.
+ '''
+
+ def setUp(self):
+ '''Set up resources'''
+
+ global _core_instance
+ if _core_instance is None:
+ _core_instance = QCoreApplication([])
+
+ self.app = _core_instance
+
+ def tearDown(self):
+ '''Release resources'''
+ del self.app
+
+ def exit_app_cb(self):
+ '''Quits the application'''
+ self.app.exit(0)
+
+
+def random_string(size=5):
+ '''Generate random string with the given size'''
+ return ''.join(map(chr, [randint(33, 126) for x in range(size)]))
diff --git a/sources/pyside2/tests/util/helper/docmodifier.py b/sources/pyside2/tests/util/helper/docmodifier.py
new file mode 100644
index 000000000..16d3e28ad
--- /dev/null
+++ b/sources/pyside2/tests/util/helper/docmodifier.py
@@ -0,0 +1,116 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Helper metaclass do 'decorate' docstrings from base test case classes'''
+
+import types
+
+
+def copy_func(func):
+ '''Helper function to copy a function object (except docstring)'''
+ return types.FunctionType(func.func_code, func.func_globals, func.func_name,
+ func.func_defaults, func.func_closure)
+
+
+class DocModifier(type):
+ '''Metaclass for modifiying method documentation.
+
+ It allows the managed class to modify the method documentation, adding
+ prefixes and suffixes to a given set of methods.
+
+ For example, you have some unittest.TestCases that run on different set
+ of data. These methods could be written once in a base class and the
+ inheriting class just setup different setUp/tearDown methods with the
+ proper data. To differentiate the methods when using docstrings, you
+ can add a suffix or prefix to the docstring.
+
+ Variables in the implementing class:
+
+ doc_prefix - The prefix to the docstring
+ doc_suffix - The suffix to the docstring
+ doc_filter - The function to filter the methods. If not provided, this
+ no docstrings are changed.'''
+
+ def __new__(mcs, name, bases, dct):
+
+ # FIXME currently we have to define doc_filter on each subclass
+ filter_function = dct.get('doc_filter')
+ if not filter_function:
+ filter_function = lambda x: False
+
+ for base in bases:
+ for attr in [x for x in base.__dict__ if filter_function(x)]:
+ original = getattr(base, attr)
+
+ if original.__doc__:
+ copy = copy_func(original)
+ copy.__doc__ = (dct.get('doc_prefix', '') +
+ original.__doc__ +
+ dct.get('doc_suffix', ''))
+ dct[attr] = copy
+
+ return type.__new__(mcs, name, bases, dct)
+
+ def __init__(mcs, name, bases, dct):
+ super(DocModifier, mcs).__init__(name, bases, dct)
+
+
+if __name__ == '__main__':
+
+ # tests
+ class BaseTest(object):
+ __metaclass__ = DocModifier
+
+ def testBase(self):
+ '''base'''
+
+ def testWithoutDoc(self):
+ pass
+
+ class Implementing(BaseTest):
+
+ doc_filter = lambda x: x.startswith('test')
+ doc_prefix = 'prefix'
+ doc_suffix = 'suffix'
+
+ class OnlyPrefix(BaseTest):
+
+ doc_filter = lambda x: x.startswith('test')
+ doc_prefix = 'prefix'
+
+ class OnlySuffix(BaseTest):
+
+ doc_filter = lambda x: x.startswith('test')
+ doc_suffix = 'suffix'
+
+ assert(Implementing.testBase.__doc__ == 'prefixbasesuffix')
+ assert(Implementing.testWithoutDoc.__doc__ == None)
+ assert(OnlySuffix.testBase.__doc__ == 'basesuffix')
+ assert(OnlySuffix.testWithoutDoc.__doc__ == None)
+ assert(OnlyPrefix.testBase.__doc__ == 'prefixbase')
+ assert(OnlyPrefix.testWithoutDoc.__doc__ == None)
diff --git a/sources/pyside2/tests/util/httpd.py b/sources/pyside2/tests/util/httpd.py
new file mode 100644
index 000000000..8214cf033
--- /dev/null
+++ b/sources/pyside2/tests/util/httpd.py
@@ -0,0 +1,177 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import os
+import sys
+import threading
+import select
+import random
+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"
+ allow_reuse_address = True
+
+ def do_GET(self):
+ self.send_head()
+ self.wfile.write(TestHandler.DATA)
+
+ def do_HEAD(self):
+ self.send_head()
+
+ def send_head(self):
+ self.send_response(200)
+ self.send_header("Content-type", "text/plain")
+ self.send_header("Content-Length", str(len(TestHandler.DATA)))
+ self.end_headers()
+
+class TestSecureHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+ DATA = "PySide"
+ allow_reuse_address = True
+
+ def do_GET(self):
+ self.send_head()
+ self.wfile.write(py3k.b(TestHandler.DATA))
+
+ def do_HEAD(self):
+ self.send_head()
+
+ def send_head(self):
+ try:
+ handler = self.marshall_handler()
+ handler.do_request(self)
+ except:
+ self.send_response(401)
+ self.send_header("WWW-Authenticate", "Basic realm='Secure Area'")
+ self.send_header("Content-type", "text/plain")
+ self.send_header("Content-Length", str(len(TestHandler.DATA)))
+ self.end_headers()
+
+# Workaround for the missing shutdown method in python2.5
+class CompatTCPServer(SocketServer.TCPServer):
+ def __init__(self, server_address, RequestHandlerClass):
+ SocketServer.TCPServer.__init__(self, server_address, RequestHandlerClass)
+
+ self.isPy25 = sys.version_info[0] == 2 and sys.version_info[1] == 5
+ if self.isPy25:
+ self.__is_shut_down = threading.Event()
+ self.__serving = False
+
+ def serve_forever(self, poll_interval=0.5):
+ """Handle one request at a time until shutdown.
+
+ Polls for shutdown every poll_interval seconds. Ignores
+ self.timeout. If you need to do periodic tasks, do them in
+ another thread.
+ """
+ if self.isPy25:
+ self.__serving = True
+ self.__is_shut_down.clear()
+ while self.__serving:
+ # XXX: Consider using another file descriptor or
+ # connecting to the socket to wake this up instead of
+ # polling. Polling reduces our responsiveness to a
+ # shutdown request and wastes cpu at all other times.
+ r, w, e = select.select([self], [], [], poll_interval)
+ if r:
+ self.py25_handle_request_noblock()
+ self.__is_shut_down.set()
+ else:
+ SocketServer.TCPServer.serve_forever(self, poll_interval)
+
+ def py25_handle_request_noblock(self):
+ """Handle one request, without blocking.
+
+ I assume that select.select has returned that the socket is
+ readable before this function was called, so there should be
+ no risk of blocking in get_request().
+ """
+ if self.isPy25:
+ try:
+ request, client_address = self.get_request()
+ except socket.error:
+ return
+ if self.verify_request(request, client_address):
+ try:
+ self.process_request(request, client_address)
+ except:
+ self.handle_error(request, client_address)
+ self.close_request(request)
+
+ def shutdown(self):
+ """Stops the serve_forever loop.
+
+ Blocks until the loop has finished. This must be called while
+ serve_forever() is running in another thread, or it will
+ deadlock.
+ """
+ if self.isPy25:
+ self.__serving = False
+ if not self.__is_shut_down:
+ self.__is_shut_down.wait()
+ else:
+ SocketServer.TCPServer.shutdown(self)
+
+
+class TestServer(threading.Thread):
+
+ def __init__(self, secure=False):
+ threading.Thread.__init__(self)
+
+ self._port = int(os.getenv("PYSIDE_TESTSERVER_PORT") or 12321)
+ self.keep_running = True
+
+ if secure:
+ handle = TestSecureHandler
+ else:
+ handle = TestHandler
+
+ while True:
+ try:
+ self.httpd = CompatTCPServer(('' , self._port), handle)
+ break
+ except:
+ self._port = self._port + random.randint(1, 100)
+
+ def port(self):
+ return self._port
+
+ def run(self):
+ self.httpd.serve_forever()
+
+ def shutdown(self):
+ self.httpd.shutdown()
+ self.join()
+
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtAssistant.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtAssistant.py
new file mode 100644
index 000000000..d0975d51e
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtAssistant.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtAssistant import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtCore.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtCore.py
new file mode 100644
index 000000000..a6a225649
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtCore.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtCore import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtDesigner.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtDesigner.py
new file mode 100644
index 000000000..5cf9d5f6d
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtDesigner.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtDesigner import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtGui.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtGui.py
new file mode 100644
index 000000000..0b8b4e957
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtGui.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtGui import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtHelp.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtHelp.py
new file mode 100644
index 000000000..dd3fd6cd8
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtHelp.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtHelp import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtNetwork.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtNetwork.py
new file mode 100644
index 000000000..1a669a421
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtNetwork.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtNetwork import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtScript.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtScript.py
new file mode 100644
index 000000000..4f6b30e8e
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtScript.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtScript import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtSql.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtSql.py
new file mode 100644
index 000000000..35dd0a106
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtSql.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtSql import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtSvg.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtSvg.py
new file mode 100644
index 000000000..f308222b9
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtSvg.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtSvg import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtTest.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtTest.py
new file mode 100644
index 000000000..95f64006b
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtTest.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtTest import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtWebKit.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtWebKit.py
new file mode 100644
index 000000000..bffc79968
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtWebKit.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtWebKit import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtXml.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtXml.py
new file mode 100644
index 000000000..2888a4e49
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtXml.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtXml import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/QtXmlPatterns.py b/sources/pyside2/tests/util/module_wrapper/PySide/QtXmlPatterns.py
new file mode 100644
index 000000000..6de76d830
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/QtXmlPatterns.py
@@ -0,0 +1,2 @@
+
+from PyQt4.QtXmlPatterns import *
diff --git a/sources/pyside2/tests/util/module_wrapper/PySide/__init__.py b/sources/pyside2/tests/util/module_wrapper/PySide/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/sources/pyside2/tests/util/module_wrapper/PySide/__init__.py
diff --git a/sources/pyside2/tests/util/processtimer.py b/sources/pyside2/tests/util/processtimer.py
new file mode 100644
index 000000000..19206472e
--- /dev/null
+++ b/sources/pyside2/tests/util/processtimer.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import time,os
+
+class TimeoutException(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+
+ def __str__(self):
+ return repr(self.msg)
+
+class ProcessTimer(object):
+ '''Timeout function for controlling a subprocess.Popen instance.
+
+ Naive implementation using busy loop, see later other means
+ of doing this.
+ '''
+
+ def __init__(self, proc, timeout):
+ self.proc = proc
+ self.timeout = timeout
+
+ def waitfor(self):
+ time_passed = 0
+ while(self.proc.poll() is None and time_passed < self.timeout):
+ time_passed = time_passed + 1
+ time.sleep(1)
+
+ if time_passed >= self.timeout:
+ raise TimeoutException("Timeout expired, possible deadlock")
+
+if __name__ == "__main__":
+ #simple example
+
+ from subprocess import Popen
+
+ proc = Popen(['sleep','10'])
+ t = ProcessTimer(proc,5)
+ try:
+ t.waitfor()
+ except TimeoutException:
+ print "timeout - PID: %d" % (t.proc.pid)
+ #TODO: detect SO and kill accordingly
+ #Linux
+ os.kill(t.proc.pid, 9)
+ #Windows (not tested)
+ #subprocess.Popen("taskkill /F /T /PID %i"%handle.pid , shell=True)
+ print "exit code: %d" % (t.proc.poll())
+
diff --git a/sources/pyside2/tests/util/py2xfunctions.py b/sources/pyside2/tests/util/py2xfunctions.py
new file mode 100644
index 000000000..d848c2c61
--- /dev/null
+++ b/sources/pyside2/tests/util/py2xfunctions.py
@@ -0,0 +1,46 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+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/pyside2/tests/util/py3kcompat.py b/sources/pyside2/tests/util/py3kcompat.py
new file mode 100644
index 000000000..19e50dc71
--- /dev/null
+++ b/sources/pyside2/tests/util/py3kcompat.py
@@ -0,0 +1,38 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+
+IS_PY3K = sys.version_info[0] == 3
+
+if IS_PY3K:
+ from py3xfunctions import b, l, unicode_, unicode, unichr, long, unichr, buffer
+else:
+ from py2xfunctions import b, l, unicode_, unicode, unichr, long, unichr, buffer
+
diff --git a/sources/pyside2/tests/util/py3xfunctions.py b/sources/pyside2/tests/util/py3xfunctions.py
new file mode 100644
index 000000000..e7014e56a
--- /dev/null
+++ b/sources/pyside2/tests/util/py3xfunctions.py
@@ -0,0 +1,54 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+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_
diff --git a/sources/pyside2/tests/util/pyqt_diff.py b/sources/pyside2/tests/util/pyqt_diff.py
new file mode 100644
index 000000000..04e873556
--- /dev/null
+++ b/sources/pyside2/tests/util/pyqt_diff.py
@@ -0,0 +1,64 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import print_function
+
+'''Script to show the difference between PyQt5 and ours'''
+
+import sys
+
+from color import print_colored
+
+def check_module_diff(module_name):
+ '''Difference between PySide2 and PyQt5 versions of qt bindings.
+ Returns a tuple with the members present only on PySide2 and only on PyQt5'''
+ shiboken_module = getattr(__import__('PySide2.' + module_name), module_name)
+ orig_module = getattr(__import__('PyQt5.' + module_name), module_name)
+
+ shiboken_set = set(dir(shiboken_module))
+ orig_set = set(dir(orig_module))
+
+ return sorted(shiboken_set - orig_set), sorted(orig_set - shiboken_set)
+
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv
+
+ module_name = argv[1] if len(argv) >= 2 else 'QtCore'
+
+ only_shiboken, only_orig = check_module_diff(module_name)
+
+ print_colored('Only on Shiboken version')
+ print(only_shiboken)
+
+ print_colored('Only on SIP version')
+ print(only_orig)
+
+if __name__ == '__main__':
+ main()
diff --git a/sources/pyside2/tests/util/pyqtcheck.py b/sources/pyside2/tests/util/pyqtcheck.py
new file mode 100644
index 000000000..7734ea6a7
--- /dev/null
+++ b/sources/pyside2/tests/util/pyqtcheck.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+from optparse import OptionParser
+
+import PyQt4
+from PyQt4 import QtCore, QtGui, QtNetwork
+
+modules = [QtCore, QtGui, QtNetwork]
+
+def search(klass, method=None):
+ for module in modules:
+ try:
+ klass_obj = getattr(module, klass)
+ print "%s *found* on module %s" % (klass, module.__name__)
+ except AttributeError:
+ print "%s not found on module %s" % (klass, module.__name__)
+ continue
+
+ if method is None:
+ continue
+
+ try:
+ meth_obj = getattr(klass_obj, method)
+
+ meth_name = ".".join([klass, method])
+ klass_name = ".".join([module.__name__, klass])
+ print "\"%s\" *found* on class %s" % (meth_name, klass_name)
+ except AttributeError:
+ print "\"%s\" not found on class %s" % (method, klass)
+
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv[1:]
+
+ try:
+ klass, method = argv[0].split(".")
+ except:
+ klass = argv[0]
+ method = None
+
+ search(klass, method)
+
+if __name__ == '__main__':
+ main()
diff --git a/sources/pyside2/tests/util/rename_imports.sh b/sources/pyside2/tests/util/rename_imports.sh
new file mode 100755
index 000000000..e985a9100
--- /dev/null
+++ b/sources/pyside2/tests/util/rename_imports.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# Rename import statements from .py script to use a specific module name
+set -e
+
+if [ $# -lt 3 ]; then
+ echo "Usage: $0 <old_name> <new_name> <directories...>"
+ exit 1
+fi
+
+old_name=$1; shift
+new_name=$1; shift
+
+find "$@" -name "*.py" -exec sed -ri "s/(import|from) $old_name/\1 $new_name/" '{}' \;
diff --git a/sources/pyside2/tests/util/test_processtimer.py b/sources/pyside2/tests/util/test_processtimer.py
new file mode 100644
index 000000000..66a2a57db
--- /dev/null
+++ b/sources/pyside2/tests/util/test_processtimer.py
@@ -0,0 +1,93 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'Tests for processtimer.py'
+
+import unittest
+import os
+
+from subprocess import Popen, PIPE
+from processtimer import TimeoutException, ProcessTimer
+
+class TimeoutTest(unittest.TestCase):
+
+ def tearDown(self):
+ try:
+ os.kill(self.proc.pid, 9)
+ except OSError:
+ pass
+
+ def testRaise(self):
+ self.proc = Popen(['python2.5', '-c', 'while True: pass' ], stdout=PIPE, stderr=PIPE)
+ timer = ProcessTimer(self.proc, 1)
+ self.assertRaises(TimeoutException, timer.waitfor)
+
+class SimpleTest(unittest.TestCase):
+
+ def tearDown(self):
+ try:
+ os.kill(self.proc.pid, 9)
+ except OSError:
+ pass
+ def testSimple(self):
+ self.proc = Popen(['python2.5', '-c', '"print"'], stdout=PIPE, stderr=PIPE)
+ timer = ProcessTimer(self.proc, 10)
+ timer.waitfor()
+
+class TestEchoOutput(unittest.TestCase):
+
+ def tearDown(self):
+ try:
+ os.kill(self.proc.pid, 9)
+ except OSError:
+ pass
+
+ def testOutput(self):
+ self.proc = Popen(['python2.5', '-c', 'print 1',], stdout=PIPE, stderr=PIPE)
+ timer = ProcessTimer(self.proc, 1)
+ timer.waitfor()
+ self.assertEqual(self.proc.stdout.read().strip(), '1')
+
+class TestRetCode(unittest.TestCase):
+
+ def tearDown(self):
+ try:
+ os.kill(self.proc.pid, 9)
+ except OSError:
+ pass
+
+ def testSimple(self):
+ self.proc = Popen(['python2.5', '-c', 'print 1'], stdout=PIPE, stderr=PIPE)
+ timer = ProcessTimer(self.proc, 10)
+ timer.waitfor()
+
+ self.assertEqual(self.proc.poll(), 0)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside2/tests/util/use_pyqt4.sh b/sources/pyside2/tests/util/use_pyqt4.sh
new file mode 100644
index 000000000..5b88fa5c7
--- /dev/null
+++ b/sources/pyside2/tests/util/use_pyqt4.sh
@@ -0,0 +1,3 @@
+
+OLD_PYTHONPATH=$PYTHONPATH
+PYTHONPATH=`pwd`/util/module_wrapper:$PYTHONPATH
diff --git a/sources/pyside2/tests/util/use_pyside.sh b/sources/pyside2/tests/util/use_pyside.sh
new file mode 100644
index 000000000..516207473
--- /dev/null
+++ b/sources/pyside2/tests/util/use_pyside.sh
@@ -0,0 +1,3 @@
+
+PYTHONPATH=$OLD_PYTHONPATH
+unset OLD_PYTHONPATH
diff --git a/sources/pyside2/tests/util/valgrind-python.supp b/sources/pyside2/tests/util/valgrind-python.supp
new file mode 100644
index 000000000..a54b451b3
--- /dev/null
+++ b/sources/pyside2/tests/util/valgrind-python.supp
@@ -0,0 +1,349 @@
+#
+# This is a valgrind suppression file that should be used when using valgrind.
+#
+# Here's an example of running valgrind:
+#
+# cd python/dist/src
+# valgrind --tool=memcheck --suppressions=Misc/valgrind-python.supp \
+# ./python -E -tt ./Lib/test/regrtest.py -u bsddb,network
+#
+# You must edit Objects/obmalloc.c and uncomment Py_USING_MEMORY_DEBUGGER
+# to use the preferred suppressions with Py_ADDRESS_IN_RANGE.
+#
+# If you do not want to recompile Python, you can uncomment
+# suppressions for PyObject_Free and PyObject_Realloc.
+#
+# See Misc/README.valgrind for more information.
+
+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Addr4
+ fun:Py_ADDRESS_IN_RANGE
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Value4
+ fun:Py_ADDRESS_IN_RANGE
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
+ Memcheck:Value8
+ fun:Py_ADDRESS_IN_RANGE
+}
+
+{
+ ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
+ Memcheck:Cond
+ fun:Py_ADDRESS_IN_RANGE
+}
+
+#
+# Leaks (including possible leaks)
+# Hmmm, I wonder if this masks some real leaks. I think it does.
+# Will need to fix that.
+#
+
+{
+ Handle PyMalloc confusing valgrind (possibly leaked)
+ Memcheck:Leak
+ fun:realloc
+ fun:_PyObject_GC_Resize
+ fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
+}
+
+{
+ Handle PyMalloc confusing valgrind (possibly leaked)
+ Memcheck:Leak
+ fun:malloc
+ fun:_PyObject_GC_New
+ fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
+}
+
+{
+ Handle PyMalloc confusing valgrind (possibly leaked)
+ Memcheck:Leak
+ fun:malloc
+ fun:_PyObject_GC_NewVar
+ fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
+}
+
+#
+# Non-python specific leaks
+#
+
+{
+ Handle pthread issue (possibly leaked)
+ Memcheck:Leak
+ fun:calloc
+ fun:allocate_dtv
+ fun:_dl_allocate_tls_storage
+ fun:_dl_allocate_tls
+}
+
+{
+ Handle pthread issue (possibly leaked)
+ Memcheck:Leak
+ fun:memalign
+ fun:_dl_allocate_tls_storage
+ fun:_dl_allocate_tls
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Addr4
+ fun:PyObject_Free
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Value4
+ fun:PyObject_Free
+}
+
+{
+ ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
+ Memcheck:Cond
+ fun:PyObject_Free
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Addr4
+ fun:PyObject_Realloc
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Value4
+ fun:PyObject_Realloc
+}
+
+{
+ ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
+ Memcheck:Cond
+ fun:PyObject_Realloc
+}
+
+###
+### All the suppressions below are for errors that occur within libraries
+### that Python uses. The problems to not appear to be related to Python's
+### use of the libraries.
+###
+
+{
+ Generic gentoo ld problems
+ Memcheck:Cond
+ obj:/lib/ld-2.3.4.so
+ obj:/lib/ld-2.3.4.so
+ obj:/lib/ld-2.3.4.so
+ obj:/lib/ld-2.3.4.so
+}
+
+{
+ DBM problems, see test_dbm
+ Memcheck:Param
+ write(buf)
+ fun:write
+ obj:/usr/lib/libdb1.so.2
+ obj:/usr/lib/libdb1.so.2
+ obj:/usr/lib/libdb1.so.2
+ obj:/usr/lib/libdb1.so.2
+ fun:dbm_close
+}
+
+{
+ DBM problems, see test_dbm
+ Memcheck:Value8
+ fun:memmove
+ obj:/usr/lib/libdb1.so.2
+ obj:/usr/lib/libdb1.so.2
+ obj:/usr/lib/libdb1.so.2
+ obj:/usr/lib/libdb1.so.2
+ fun:dbm_store
+ fun:dbm_ass_sub
+}
+
+{
+ DBM problems, see test_dbm
+ Memcheck:Cond
+ obj:/usr/lib/libdb1.so.2
+ obj:/usr/lib/libdb1.so.2
+ obj:/usr/lib/libdb1.so.2
+ fun:dbm_store
+ fun:dbm_ass_sub
+}
+
+{
+ DBM problems, see test_dbm
+ Memcheck:Cond
+ fun:memmove
+ obj:/usr/lib/libdb1.so.2
+ obj:/usr/lib/libdb1.so.2
+ obj:/usr/lib/libdb1.so.2
+ obj:/usr/lib/libdb1.so.2
+ fun:dbm_store
+ fun:dbm_ass_sub
+}
+
+{
+ GDBM problems, see test_gdbm
+ Memcheck:Param
+ write(buf)
+ fun:write
+ fun:gdbm_open
+
+}
+
+{
+ ZLIB problems, see test_gzip
+ Memcheck:Cond
+ obj:/lib/libz.so.1.2.3
+ obj:/lib/libz.so.1.2.3
+ fun:deflate
+}
+
+{
+ Avoid problems w/readline doing a putenv and leaking on exit
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ fun:sh_set_lines_and_columns
+ fun:_rl_get_screen_size
+ fun:_rl_init_terminal_io
+ obj:/lib/libreadline.so.4.3
+ fun:rl_initialize
+}
+
+###
+### These occur from somewhere within the SSL, when running
+### test_socket_sll. They are too general to leave on by default.
+###
+###{
+### somewhere in SSL stuff
+### Memcheck:Cond
+### fun:memset
+###}
+###{
+### somewhere in SSL stuff
+### Memcheck:Value4
+### fun:memset
+###}
+###
+###{
+### somewhere in SSL stuff
+### Memcheck:Cond
+### fun:MD5_Update
+###}
+###
+###{
+### somewhere in SSL stuff
+### Memcheck:Value4
+### fun:MD5_Update
+###}
+
+#
+# All of these problems come from using test_socket_ssl
+#
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:BN_bin2bn
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:BN_num_bits_word
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ fun:BN_num_bits_word
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:BN_mod_exp_mont_word
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:BN_mod_exp_mont
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Param
+ write(buf)
+ fun:write
+ obj:/usr/lib/libcrypto.so.0.9.7
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:RSA_verify
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ fun:RSA_verify
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ fun:DES_set_key_unchecked
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ fun:DES_encrypt2
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ obj:/usr/lib/libssl.so.0.9.7
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ obj:/usr/lib/libssl.so.0.9.7
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:BUF_MEM_grow_clean
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:memcpy
+ fun:ssl3_read_bytes
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:SHA1_Update
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ fun:SHA1_Update
+}
+
+
diff --git a/sources/shiboken2/.gitattributes b/sources/shiboken2/.gitattributes
new file mode 100644
index 000000000..adbe833c1
--- /dev/null
+++ b/sources/shiboken2/.gitattributes
@@ -0,0 +1,2 @@
+.gitignore export-ignore
+.gitattributes export-ignore
diff --git a/sources/shiboken2/.gitignore b/sources/shiboken2/.gitignore
new file mode 100644
index 000000000..adb1e4594
--- /dev/null
+++ b/sources/shiboken2/.gitignore
@@ -0,0 +1,8 @@
+build
+.kdev4
+*.log
+*.pyc
+*.o
+*.so
+.*.swp
+*.kdev4
diff --git a/sources/shiboken2/AUTHORS b/sources/shiboken2/AUTHORS
new file mode 100644
index 000000000..4bb16b2dd
--- /dev/null
+++ b/sources/shiboken2/AUTHORS
@@ -0,0 +1,12 @@
+John Cummings <jcummings2@users.sf.net>
+John Ehresman <jpe@wingware.com>
+Roman Lacko <backup.rlacko@gmail.com>
+Matthew Woehlke <matthew.woehlke@kitware.com>
+Anderson Lizardo <anderson.lizardo@openbossa.org>
+Bruno Araujo <bruno.araujo@openbossa.org>
+Hugo Parente Lima <hugo.lima@openbossa.org>
+Lauro Moura <lauro.neto@openbossa.org>
+Luciano Wolf <luciano.wolf@openbossa.org>
+Marcelo Lira <marcelo.lira@openbossa.org>
+Renato Araujo Oliveira Filho <renato.filho@openbossa.org>
+
diff --git a/sources/shiboken2/ApiExtractor/AUTHORS b/sources/shiboken2/ApiExtractor/AUTHORS
new file mode 100644
index 000000000..6e802fb53
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/AUTHORS
@@ -0,0 +1,8 @@
+Anderson Lizardo <anderson.lizardo@openbossa.org>
+Bruno Araujo <bruno.araujo@openbossa.org>
+Hugo Parente Lima <hugo.lima@openbossa.org>
+Lauro Moura <lauro.neto@openbossa.org>
+Luciano Wolf <luciano.wolf@openbossa.org>
+Marcelo Lira <marcelo.lira@openbossa.org>
+Renato Araujo Oliveira Filho <renato.filho@openbossa.org>
+
diff --git a/sources/shiboken2/ApiExtractor/CMakeLists.txt b/sources/shiboken2/ApiExtractor/CMakeLists.txt
new file mode 100644
index 000000000..26ae03173
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/CMakeLists.txt
@@ -0,0 +1,102 @@
+project(apiextractor)
+
+find_package(LibXml2 2.6.32)
+find_package(LibXslt 1.1.19)
+
+option(DISABLE_DOCSTRINGS "Disable documentation extraction." FALSE)
+
+if (NOT DISABLE_DOCSTRINGS)
+ if (NOT LIBXSLT_FOUND OR NOT LIBXML2_FOUND)
+ set(DISABLE_DOCSTRINGS TRUE CACHE BOOL "Disable doc strings" PARENT_SCOPE)
+ set(DISABLE_DOCSTRINGS TRUE)
+ message(WARNING "libxslt and/or libxml not found, disabling support for doc strings!")
+ endif()
+endif()
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release)
+endif()
+
+if(BUILD_TESTS)
+ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tests)
+endif ()
+
+set(QT_USE_QTCORE 1)
+set(QT_USE_QTXML 1)
+add_definitions(-DQT_PLUGIN)
+add_definitions(-DQT_SHARED)
+add_definitions(-DRXX_ALLOCATOR_INIT_0)
+
+set(apiextractor_SRC
+apiextractor.cpp
+abstractmetabuilder.cpp
+abstractmetalang.cpp
+asttoxml.cpp
+fileout.cpp
+graph.cpp
+reporthandler.cpp
+typeparser.cpp
+typesystem.cpp
+include.cpp
+typedatabase.cpp
+parser/ast.cpp
+parser/binder.cpp
+parser/class_compiler.cpp
+parser/codemodel.cpp
+parser/codemodel_finder.cpp
+parser/compiler_utils.cpp
+parser/control.cpp
+parser/declarator_compiler.cpp
+parser/default_visitor.cpp
+parser/dumptree.cpp
+parser/lexer.cpp
+parser/list.cpp
+parser/name_compiler.cpp
+parser/parser.cpp
+parser/smallobject.cpp
+parser/tokens.cpp
+parser/type_compiler.cpp
+parser/visitor.cpp
+parser/rpp/builtin-macros.cpp
+parser/rpp/preprocessor.cpp
+)
+
+if (NOT DISABLE_DOCSTRINGS)
+ set(apiextractor_SRC
+ ${apiextractor_SRC}
+ docparser.cpp
+ doxygenparser.cpp
+ qtdocparser.cpp
+ )
+ set(APIEXTRACTOR_EXTRA_INCLUDES ${LIBXSLT_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR})
+ set(APIEXTRACTOR_EXTRA_LIBRARIES ${LIBXSLT_LIBRARIES} ${LIBXML2_LIBRARIES})
+else()
+ set(APIEXTRACTOR_EXTRA_INCLUDES "")
+ set(APIEXTRACTOR_EXTRA_LIBRARIES "")
+endif()
+
+set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE)
+
+qt5_add_resources(apiextractor_RCCS_SRC generator.qrc)
+set(CMAKE_AUTOMOC ON)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/parser
+ ${CMAKE_CURRENT_SOURCE_DIR}/parser/rpp
+ ${APIEXTRACTOR_EXTRA_INCLUDES}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Xml_INCLUDE_DIRS}
+ )
+
+add_library(apiextractor STATIC ${apiextractor_SRC} ${apiextractor_RCCS_SRC})
+target_link_libraries(apiextractor
+ ${Qt5Xml_LIBRARIES}
+ ${Qt5XmlPatterns_LIBRARIES}
+ ${APIEXTRACTOR_EXTRA_LIBRARIES}
+ )
+
+if (BUILD_TESTS)
+ enable_testing()
+ add_subdirectory(tests)
+endif()
diff --git a/sources/shiboken2/ApiExtractor/COPYING b/sources/shiboken2/ApiExtractor/COPYING
new file mode 100644
index 000000000..4ccd71466
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/COPYING
@@ -0,0 +1,342 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
+-------------------------------------------------------------------------
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
new file mode 100644
index 000000000..e71841ec3
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -0,0 +1,3381 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "abstractmetabuilder_p.h"
+#include "reporthandler.h"
+#include "typedatabase.h"
+
+#include "parser/ast.h"
+#include "parser/binder.h"
+#include "parser/control.h"
+#include "parser/default_visitor.h"
+#include "parser/dumptree.h"
+#include "parser/lexer.h"
+#include "parser/parser.h"
+#include "parser/tokens.h"
+
+#include <QDebug>
+#include <QFile>
+#include <QFileInfo>
+#include <QTextCodec>
+#include <QTextStream>
+#include <QVariant>
+#include <QTime>
+#include <QQueue>
+#include <QDir>
+
+#include <cstdio>
+#include <algorithm>
+#include "graph.h"
+#include <QTemporaryFile>
+
+static inline QString colonColon() { return QStringLiteral("::"); }
+
+static QString stripTemplateArgs(const QString &name)
+{
+ int pos = name.indexOf(QLatin1Char('<'));
+ return pos < 0 ? name : name.left(pos);
+}
+
+static QStringList parseTemplateType(const QString& name) {
+ int n = name.indexOf(QLatin1Char('<'));
+ if (n <= 0) {
+ // If name starts with '<' or contains an unmatched (i.e. any) '>', we
+ // reject it
+ if (n == 0 || name.count(QLatin1Char('>')))
+ return QStringList();
+ // Doesn't look like a template instantiation; just return the name
+ return QStringList() << name;
+ }
+
+ // Split the type name into the template name and template arguments; the
+ // part before the opening '<' is the template name
+ //
+ // Example:
+ // "foo<A, bar<B, C>, D>" -> ( "foo", "A", "bar<B, C>", "D" )
+ QStringList result;
+ result << name.left(n).trimmed();
+
+ // Extract template arguments
+ int i, depth = 1;
+ const int l = name.length();
+ for (i = n + 1; i < l; ++i) {
+ // Consume balanced '<'/'>' within a single argument so that we won't
+ // split on ',' as part of a single argument which is itself a
+ // multi-argument template type
+ if (name[i] == QLatin1Char('<')) {
+ ++depth;
+ } else if (name[i] == QLatin1Char('>')) {
+ if (--depth == 0)
+ break;
+ } else if (name[i] == QLatin1Char(',') && depth == 1) {
+ // Encountered ',' in template argument list that is not within
+ // another template name; add current argument to result and start
+ // working on the next argument
+ result << name.mid(n + 1, i - n - 1).trimmed();
+ n = i;
+ }
+ }
+ if (i >= l) // arg list not closed
+ return QStringList();
+ if (i + 1 < l) // arg list closed before end of name
+ return QStringList();
+
+ // Add final argument and return result
+ result << name.mid(n + 1, i - n - 1).trimmed();
+ return result;
+}
+
+AbstractMetaBuilderPrivate::AbstractMetaBuilderPrivate() : m_currentClass(0),
+ m_logDirectory(QLatin1String(".") + QDir::separator())
+{
+}
+
+AbstractMetaBuilderPrivate::~AbstractMetaBuilderPrivate()
+{
+ qDeleteAll(m_globalEnums);
+ qDeleteAll(m_globalFunctions);
+ qDeleteAll(m_templates);
+ qDeleteAll(m_smartPointers);
+ qDeleteAll(m_metaClasses);
+}
+
+AbstractMetaBuilder::AbstractMetaBuilder() : d(new AbstractMetaBuilderPrivate)
+{
+ d->q = this;
+}
+
+AbstractMetaBuilder::~AbstractMetaBuilder()
+{
+ delete d;
+}
+
+AbstractMetaClassList AbstractMetaBuilder::classes() const
+{
+ return d->m_metaClasses;
+}
+
+AbstractMetaClassList AbstractMetaBuilder::templates() const
+{
+ return d->m_templates;
+}
+
+AbstractMetaClassList AbstractMetaBuilder::smartPointers() const
+{
+ return d->m_smartPointers;
+}
+
+AbstractMetaFunctionList AbstractMetaBuilder::globalFunctions() const
+{
+ return d->m_globalFunctions;
+}
+
+AbstractMetaEnumList AbstractMetaBuilder::globalEnums() const
+{
+ return d->m_globalEnums;
+}
+
+QSet<QString> AbstractMetaBuilder::qtMetaTypeDeclaredTypeNames() const
+{
+ return d->m_qmetatypeDeclaredTypenames;
+}
+
+void AbstractMetaBuilderPrivate::checkFunctionModifications()
+{
+ TypeDatabase *types = TypeDatabase::instance();
+ SingleTypeEntryHash entryHash = types->entries();
+ QList<TypeEntry*> entries = entryHash.values();
+
+ foreach (TypeEntry* entry, entries) {
+ if (!entry)
+ continue;
+ if (!entry->isComplex() || entry->codeGeneration() == TypeEntry::GenerateNothing)
+ continue;
+
+ ComplexTypeEntry* centry = static_cast<ComplexTypeEntry*>(entry);
+ FunctionModificationList modifications = centry->functionModifications();
+
+ foreach (const FunctionModification &modification, modifications) {
+ QString signature = modification.signature;
+
+ QString name = signature.trimmed();
+ name.truncate(name.indexOf(QLatin1Char('(')));
+
+ AbstractMetaClass *clazz = AbstractMetaClass::findClass(m_metaClasses, centry->qualifiedCppName());
+ if (!clazz)
+ continue;
+
+ AbstractMetaFunctionList functions = clazz->functions();
+ bool found = false;
+ QStringList possibleSignatures;
+ foreach (AbstractMetaFunction *function, functions) {
+ if (function->minimalSignature() == signature && function->implementingClass() == clazz) {
+ found = true;
+ break;
+ }
+
+ if (function->originalName() == name) {
+ possibleSignatures.append(function->minimalSignature() + QLatin1String(" in ")
+ + function->implementingClass()->name());
+ }
+ }
+
+ if (!found) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("signature '%1' for function modification in '%2' not found. Possible candidates: %3")
+ .arg(signature, clazz->qualifiedCppName(), possibleSignatures.join(QLatin1String(", ")));
+ }
+ }
+ }
+}
+
+AbstractMetaClass *AbstractMetaBuilderPrivate::argumentToClass(ArgumentModelItem argument)
+{
+ AbstractMetaClass* returned = 0;
+ bool ok = false;
+ AbstractMetaType* type = translateType(argument->type(), &ok);
+ if (ok && type && type->typeEntry() && type->typeEntry()->isComplex()) {
+ const TypeEntry *entry = type->typeEntry();
+ returned = AbstractMetaClass::findClass(m_metaClasses, entry->name());
+ }
+ delete type;
+ return returned;
+}
+
+AbstractMetaClass *AbstractMetaBuilder::createMetaClass()
+{
+ return new AbstractMetaClass();
+}
+
+AbstractMetaEnum *AbstractMetaBuilder::createMetaEnum()
+{
+ return new AbstractMetaEnum();
+}
+
+AbstractMetaEnumValue *AbstractMetaBuilder::createMetaEnumValue()
+{
+ return new AbstractMetaEnumValue();
+}
+
+AbstractMetaField *AbstractMetaBuilder::createMetaField()
+{
+ return new AbstractMetaField();
+}
+
+AbstractMetaFunction *AbstractMetaBuilder::createMetaFunction()
+{
+ return new AbstractMetaFunction();
+}
+
+AbstractMetaArgument *AbstractMetaBuilder::createMetaArgument()
+{
+ return new AbstractMetaArgument();
+}
+
+AbstractMetaType *AbstractMetaBuilder::createMetaType()
+{
+ return new AbstractMetaType();
+}
+
+/**
+ * Checks the argument of a hash function and flags the type if it is a complex type
+ */
+void AbstractMetaBuilderPrivate::registerHashFunction(FunctionModelItem function_item)
+{
+ ArgumentList arguments = function_item->arguments();
+ if (arguments.size() == 1) {
+ if (AbstractMetaClass *cls = argumentToClass(arguments.at(0)))
+ cls->setHasHashFunction(true);
+ }
+}
+
+/**
+ * Check if a class has a debug stream operator that can be used as toString
+ */
+
+void AbstractMetaBuilderPrivate::registerToStringCapability(FunctionModelItem function_item)
+{
+ ArgumentList arguments = function_item->arguments();
+ if (arguments.size() == 2) {
+ if (arguments.at(0)->type().toString() == QLatin1String("QDebug")) {
+ ArgumentModelItem arg = arguments.at(1);
+ if (AbstractMetaClass *cls = argumentToClass(arg)) {
+ if (arg->type().indirections() < 2)
+ cls->setToStringCapability(true);
+ }
+ }
+ }
+}
+
+void AbstractMetaBuilderPrivate::traverseOperatorFunction(FunctionModelItem item)
+{
+ if (item->accessPolicy() != CodeModel::Public)
+ return;
+
+ ArgumentList arguments = item->arguments();
+ AbstractMetaClass* baseoperandClass;
+ bool firstArgumentIsSelf = true;
+ bool unaryOperator = false;
+
+ baseoperandClass = argumentToClass(arguments.at(0));
+
+ if (arguments.size() == 1) {
+ unaryOperator = true;
+ } else if (!baseoperandClass
+ || !(baseoperandClass->typeEntry()->codeGeneration() & TypeEntry::GenerateTargetLang)) {
+ baseoperandClass = argumentToClass(arguments.at(1));
+ firstArgumentIsSelf = false;
+ } else {
+ bool ok;
+ AbstractMetaType* type = translateType(item->type(), &ok);
+ const TypeEntry* retType = ok ? type->typeEntry() : 0;
+ AbstractMetaClass* otherArgClass = argumentToClass(arguments.at(1));
+ if (otherArgClass && retType
+ && (retType->isValue() || retType->isObject())
+ && retType != baseoperandClass->typeEntry()
+ && retType == otherArgClass->typeEntry()) {
+ baseoperandClass = AbstractMetaClass::findClass(m_metaClasses, retType);
+ firstArgumentIsSelf = false;
+ }
+ delete type;
+ }
+
+ if (baseoperandClass) {
+ AbstractMetaClass* oldCurrentClass = m_currentClass;
+ m_currentClass = baseoperandClass;
+ AbstractMetaFunction *metaFunction = traverseFunction(item);
+ if (metaFunction && !metaFunction->isInvalid()) {
+ // Strip away first argument, since that is the containing object
+ AbstractMetaArgumentList arguments = metaFunction->arguments();
+ if (firstArgumentIsSelf || unaryOperator) {
+ AbstractMetaArgument* first = arguments.takeFirst();
+ if (!unaryOperator && first->type()->indirections())
+ metaFunction->setPointerOperator(true);
+ delete first;
+ metaFunction->setArguments(arguments);
+ } else {
+ // If the operator method is not unary and the first operator is
+ // not of the same type of its owning class we suppose that it
+ // must be an reverse operator (e.g. CLASS::operator(TYPE, CLASS)).
+ // All operator overloads that operate over a class are already
+ // being added as member functions of that class by the API Extractor.
+ AbstractMetaArgument* last = arguments.takeLast();
+ if (last->type()->indirections())
+ metaFunction->setPointerOperator(true);
+ delete last;
+
+ metaFunction->setArguments(arguments);
+ metaFunction->setReverseOperator(true);
+ }
+ metaFunction->setFunctionType(AbstractMetaFunction::NormalFunction);
+ metaFunction->setVisibility(AbstractMetaFunction::Public);
+ metaFunction->setOriginalAttributes(metaFunction->attributes());
+ setupFunctionDefaults(metaFunction, baseoperandClass);
+ baseoperandClass->addFunction(metaFunction);
+ Q_ASSERT(!metaFunction->wasPrivate());
+ } else if (metaFunction) {
+ delete metaFunction;
+ }
+
+ m_currentClass = oldCurrentClass;
+ }
+}
+
+void AbstractMetaBuilderPrivate::traverseStreamOperator(FunctionModelItem item)
+{
+ ArgumentList arguments = item->arguments();
+ if (arguments.size() == 2 && item->accessPolicy() == CodeModel::Public) {
+ AbstractMetaClass* streamClass = argumentToClass(arguments.at(0));
+ AbstractMetaClass* streamedClass = argumentToClass(arguments.at(1));
+
+ if (streamClass && streamedClass && (streamClass->isStream())) {
+ AbstractMetaClass *oldCurrentClass = m_currentClass;
+ m_currentClass = streamedClass;
+ AbstractMetaFunction *streamFunction = traverseFunction(item);
+
+ if (streamFunction && !streamFunction->isInvalid()) {
+ QString name = item->name();
+ streamFunction->setFunctionType(AbstractMetaFunction::GlobalScopeFunction);
+ // Strip first argument, since that is the containing object
+ AbstractMetaArgumentList arguments = streamFunction->arguments();
+ if (!streamClass->typeEntry()->generateCode())
+ delete arguments.takeLast();
+ else
+ delete arguments.takeFirst();
+
+ streamFunction->setArguments(arguments);
+
+ *streamFunction += AbstractMetaAttributes::Final;
+ *streamFunction += AbstractMetaAttributes::Public;
+ streamFunction->setOriginalAttributes(streamFunction->attributes());
+
+// streamFunction->setType(0);
+
+ AbstractMetaClass *funcClass;
+
+ if (!streamClass->typeEntry()->generateCode()) {
+ AbstractMetaArgumentList reverseArgs = reverseList(streamFunction->arguments());
+ streamFunction->setArguments(reverseArgs);
+ streamFunction->setReverseOperator(true);
+ funcClass = streamedClass;
+ } else {
+ funcClass = streamClass;
+ }
+
+ setupFunctionDefaults(streamFunction, funcClass);
+ funcClass->addFunction(streamFunction);
+ if (funcClass == streamClass)
+ funcClass->typeEntry()->addExtraInclude(streamedClass->typeEntry()->include());
+ else
+ funcClass->typeEntry()->addExtraInclude(streamClass->typeEntry()->include());
+
+ m_currentClass = oldCurrentClass;
+ } else if (streamFunction) {
+ delete streamFunction;
+ }
+
+ }
+ }
+}
+
+void AbstractMetaBuilderPrivate::fixQObjectForScope(const FileModelItem &dom,
+ const TypeDatabase *types,
+ const NamespaceModelItem &scope)
+{
+ foreach (const ClassModelItem &item, scope->classes()) {
+ QString qualifiedName = item->qualifiedName().join(colonColon());
+ TypeEntry* entry = types->findType(qualifiedName);
+ if (entry) {
+ if (isQObject(dom, qualifiedName) && entry->isComplex())
+ ((ComplexTypeEntry*) entry)->setQObject(true);
+ }
+ }
+
+ const NamespaceList &namespaces = scope->namespaces();
+ foreach (const NamespaceModelItem &n, namespaces) {
+ if (scope != n)
+ fixQObjectForScope(dom, types, n);
+ }
+}
+
+void AbstractMetaBuilderPrivate::sortLists()
+{
+ foreach (AbstractMetaClass *cls, m_metaClasses)
+ cls->sortFunctions();
+}
+
+FileModelItem AbstractMetaBuilderPrivate::buildDom(QIODevice *input)
+{
+ Q_ASSERT(input);
+
+ if (!input->isOpen() && !input->open(QIODevice::ReadOnly))
+ return FileModelItem();
+
+ QByteArray contents = input->readAll();
+ input->close();
+
+ Control control;
+ Parser p(&control);
+ pool __pool;
+
+ TranslationUnitAST* ast = p.parse(contents, contents.size(), &__pool);
+
+ CodeModel model;
+ Binder binder(&model, p.location());
+ return binder.run(ast);
+}
+
+void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom)
+{
+ const TypeDatabase *types = TypeDatabase::instance();
+
+ pushScope(dom);
+
+ // fix up QObject's in the type system..
+ fixQObjectForScope(dom, types, dom);
+
+ // Start the generation...
+ const ClassList &typeValues = dom->classes();
+ ReportHandler::setProgressReference(typeValues);
+ foreach (const ClassModelItem &item, typeValues) {
+ ReportHandler::progress(QLatin1String("Generating class model..."));
+ AbstractMetaClass *cls = traverseClass(dom, item);
+ if (!cls)
+ continue;
+
+ addAbstractMetaClass(cls);
+ }
+
+ // We need to know all global enums
+ ReportHandler::setProgressReference(dom->enums());
+ foreach (const EnumModelItem &item, dom->enums()) {
+ ReportHandler::progress(QLatin1String("Generating enum model..."));
+ AbstractMetaEnum *metaEnum = traverseEnum(item, 0, QSet<QString>());
+ if (metaEnum) {
+ if (metaEnum->typeEntry()->generateCode())
+ m_globalEnums << metaEnum;
+ }
+ }
+
+ const QSet<NamespaceModelItem> &namespaceTypeValues = dom->uniqueNamespaces();
+ ReportHandler::setProgressReference(namespaceTypeValues);
+ foreach (NamespaceModelItem item, namespaceTypeValues) {
+ ReportHandler::progress(QLatin1String("Generating namespace model..."));
+ AbstractMetaClass *metaClass = traverseNamespace(dom, item);
+ if (metaClass)
+ m_metaClasses << metaClass;
+ }
+
+ // Go through all typedefs to see if we have defined any
+ // specific typedefs to be used as classes.
+ TypeDefList typeDefs = dom->typeDefs();
+ ReportHandler::setProgressReference(typeDefs);
+ foreach (const TypeDefModelItem &typeDef, typeDefs) {
+ ReportHandler::progress(QLatin1String("Resolving typedefs..."));
+ AbstractMetaClass* cls = traverseTypeDef(dom, typeDef);
+ addAbstractMetaClass(cls);
+ }
+
+ figureOutEnumValues();
+
+ foreach (const ClassModelItem &item, typeValues)
+ traverseClassMembers(item);
+
+ foreach (const NamespaceModelItem &item, namespaceTypeValues)
+ traverseNamespaceMembers(item);
+
+ // Global functions
+ foreach (const FunctionModelItem &func, dom->functions()) {
+ if (func->accessPolicy() != CodeModel::Public || func->name().startsWith(QLatin1String("operator")))
+ continue;
+
+ FunctionTypeEntry* funcEntry = types->findFunctionType(func->name());
+ if (!funcEntry || !funcEntry->generateCode())
+ continue;
+
+ AbstractMetaFunction* metaFunc = traverseFunction(func);
+ if (!metaFunc)
+ continue;
+
+ if (!funcEntry->hasSignature(metaFunc->minimalSignature())) {
+ delete metaFunc;
+ continue;
+ }
+
+ applyFunctionModifications(metaFunc);
+
+ setInclude(funcEntry, func->fileName());
+ if (metaFunc->typeEntry())
+ delete metaFunc->typeEntry();
+
+ metaFunc->setTypeEntry(funcEntry);
+ m_globalFunctions << metaFunc;
+ }
+
+ ReportHandler::setProgressReference(m_metaClasses);
+ foreach (AbstractMetaClass* cls, m_metaClasses) {
+ ReportHandler::progress(QLatin1String("Fixing class inheritance..."));
+ if (!cls->isInterface() && !cls->isNamespace())
+ setupInheritance(cls);
+ }
+
+ ReportHandler::setProgressReference(m_metaClasses);
+ foreach (AbstractMetaClass* cls, m_metaClasses) {
+ ReportHandler::progress(QLatin1String("Detecting inconsistencies in class model..."));
+ cls->fixFunctions();
+
+ if (!cls->typeEntry()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("class '%1' does not have an entry in the type system")
+ .arg(cls->name());
+ } else {
+ bool couldAddDefaultCtors = !cls->isFinalInCpp() && !cls->isInterface() && !cls->isNamespace();
+ if (couldAddDefaultCtors) {
+ if (!cls->hasConstructors())
+ cls->addDefaultConstructor();
+ if (cls->typeEntry()->isValue() && !cls->isAbstract() && !cls->hasCopyConstructor())
+ cls->addDefaultCopyConstructor(ancestorHasPrivateCopyConstructor(cls));
+ }
+ }
+
+ if (cls->isAbstract() && !cls->isInterface())
+ cls->typeEntry()->setLookupName(cls->typeEntry()->targetLangName() + QLatin1String("$ConcreteWrapper"));
+ }
+ TypeEntryHash allEntries = types->allEntries();
+ ReportHandler::progress(QLatin1String("Detecting inconsistencies in typesystem..."));
+ foreach (QList<TypeEntry*> entries, allEntries) {
+ foreach (TypeEntry* entry, entries) {
+
+ if (entry->isPrimitive())
+ continue;
+
+ if ((entry->isValue() || entry->isObject())
+ && !entry->isString()
+ && !entry->isChar()
+ && !entry->isContainer()
+ && !entry->isCustom()
+ && !entry->isVariant()
+ && !AbstractMetaClass::findClass(m_metaClasses, entry->qualifiedCppName())) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("type '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.")
+ .arg(entry->qualifiedCppName());
+ } else if (entry->generateCode() && entry->type() == TypeEntry::FunctionType) {
+ const FunctionTypeEntry* fte = static_cast<const FunctionTypeEntry*>(entry);
+ foreach (const QString &signature, fte->signatures()) {
+ bool ok = false;
+ foreach (AbstractMetaFunction* func, m_globalFunctions) {
+ if (signature == func->minimalSignature()) {
+ ok = true;
+ break;
+ }
+ }
+ if (!ok) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Global function '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.")
+ .arg(signature);
+ }
+ }
+ } else if (entry->isEnum()) {
+ const QString name = ((EnumTypeEntry*) entry)->targetLangQualifier();
+ AbstractMetaClass *cls = AbstractMetaClass::findClass(m_metaClasses, name);
+
+ bool enumFound = false;
+ if (cls) {
+ enumFound = cls->findEnum(entry->targetLangName());
+ } else { // Global enum
+ foreach (AbstractMetaEnum* metaEnum, m_enums) {
+ if (metaEnum->typeEntry() == entry) {
+ enumFound = true;
+ break;
+ }
+ }
+ }
+ if (!enumFound) {
+ entry->setCodeGeneration(TypeEntry::GenerateNothing);
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("enum '%1' is specified in typesystem, but not declared")
+ .arg(entry->qualifiedCppName());
+ }
+
+ }
+ }
+ }
+
+ {
+ FunctionList hashFunctions = dom->findFunctions(QLatin1String("qHash"));
+ foreach (const FunctionModelItem &item, hashFunctions)
+ registerHashFunction(item);
+ }
+
+ {
+ FunctionList hashFunctions = dom->findFunctions(QLatin1String("operator<<"));
+ foreach (const FunctionModelItem &item, hashFunctions)
+ registerToStringCapability(item);
+ }
+
+ {
+ FunctionList binaryOperators = dom->findFunctions(QStringLiteral("operator=="));
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator!=")));
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator<=")));
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator>=")));
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator<")));
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator+")));
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator/")));
+ // Filter binary operators, skipping for example
+ // class Iterator { ... Value *operator*() ... };
+ const FunctionList potentiallyBinaryOperators =
+ dom->findFunctions(QStringLiteral("operator*"))
+ + dom->findFunctions(QStringLiteral("operator&"));
+ foreach (const FunctionModelItem &item, potentiallyBinaryOperators) {
+ if (!item->arguments().isEmpty())
+ binaryOperators.append(item);
+ }
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator-")));
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator&")));
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator|")));
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator^")));
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator~")));
+ binaryOperators.append(dom->findFunctions(QStringLiteral("operator>")));
+
+ foreach (const FunctionModelItem &item, binaryOperators)
+ traverseOperatorFunction(item);
+ }
+
+ {
+ FunctionList streamOperators = dom->findFunctions(QLatin1String("operator<<"))
+ + dom->findFunctions(QLatin1String("operator>>"));
+ foreach (const FunctionModelItem &item, streamOperators)
+ traverseStreamOperator(item);
+ }
+
+ figureOutDefaultEnumArguments();
+ checkFunctionModifications();
+
+ // sort all classes topologically
+ m_metaClasses = classesTopologicalSorted();
+
+ foreach (AbstractMetaClass* cls, m_metaClasses) {
+// setupEquals(cls);
+// setupComparable(cls);
+ setupClonable(cls);
+ setupExternalConversion(cls);
+
+ // sort all inner classes topologically
+ if (!cls->typeEntry()->codeGeneration() || cls->innerClasses().size() < 2)
+ continue;
+
+ cls->setInnerClasses(classesTopologicalSorted(cls));
+ }
+
+ dumpLog();
+
+ sortLists();
+
+ m_currentClass = 0;
+
+ // Functions added to the module on the type system.
+ foreach (const AddedFunction &addedFunc, types->globalUserFunctions()) {
+ AbstractMetaFunction* metaFunc = traverseFunction(addedFunc);
+ metaFunc->setFunctionType(AbstractMetaFunction::NormalFunction);
+ m_globalFunctions << metaFunc;
+ }
+
+ std::puts("");
+}
+
+bool AbstractMetaBuilder::build(QIODevice *input)
+{
+ FileModelItem dom = d->buildDom(input);
+ const bool result = dom.data() != Q_NULLPTR;
+ if (result)
+ d->traverseDom(dom);
+ return result;
+}
+
+void AbstractMetaBuilder::setLogDirectory(const QString& logDir)
+{
+ d->m_logDirectory = logDir;
+ if (!d->m_logDirectory.endsWith(QDir::separator()))
+ d->m_logDirectory.append(QDir::separator());
+}
+
+void AbstractMetaBuilderPrivate::addAbstractMetaClass(AbstractMetaClass *cls)
+{
+ if (!cls)
+ return;
+
+ cls->setOriginalAttributes(cls->attributes());
+ if (cls->typeEntry()->isContainer()) {
+ m_templates << cls;
+ } else if (cls->typeEntry()->isSmartPointer()) {
+ m_smartPointers << cls;
+ } else {
+ m_metaClasses << cls;
+ if (cls->typeEntry()->designatedInterface()) {
+ AbstractMetaClass* interface = cls->extractInterface();
+ m_metaClasses << interface;
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug))
+ qCDebug(lcShiboken) << QStringLiteral(" -> interface '%1'").arg(interface->name());
+ }
+ }
+}
+
+AbstractMetaClass *AbstractMetaBuilderPrivate::traverseNamespace(const FileModelItem &dom,
+ const NamespaceModelItem &namespaceItem)
+{
+ QString namespaceName =
+ (!m_namespacePrefix.isEmpty() ? m_namespacePrefix + colonColon() : QString())
+ + namespaceItem->name();
+ NamespaceTypeEntry *type = TypeDatabase::instance()->findNamespaceType(namespaceName);
+
+ if (TypeDatabase::instance()->isClassRejected(namespaceName)) {
+ m_rejectedClasses.insert(namespaceName, AbstractMetaBuilder::GenerationDisabled);
+ return 0;
+ }
+
+ if (!type) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("namespace '%1' does not have a type entry").arg(namespaceName);
+ return 0;
+ }
+
+ AbstractMetaClass* metaClass = q->createMetaClass();
+ metaClass->setTypeEntry(type);
+
+ *metaClass += AbstractMetaAttributes::Public;
+
+ m_currentClass = metaClass;
+
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug)) {
+ qCDebug(lcShiboken)
+ << QStringLiteral("namespace '%1.%2'").arg(metaClass->package(), namespaceItem->name());
+ }
+
+ traverseEnums(namespaceItem, metaClass, namespaceItem->enumsDeclarations());
+
+ pushScope(namespaceItem);
+ m_namespacePrefix = currentScope()->qualifiedName().join(colonColon());
+
+ ClassList classes = namespaceItem->classes();
+ foreach (const ClassModelItem &cls, classes) {
+ AbstractMetaClass* mjc = traverseClass(dom, cls);
+ if (mjc) {
+ metaClass->addInnerClass(mjc);
+ mjc->setEnclosingClass(metaClass);
+ addAbstractMetaClass(mjc);
+ }
+ }
+
+ // Go through all typedefs to see if we have defined any
+ // specific typedefs to be used as classes.
+ const TypeDefList typeDefs = namespaceItem->typeDefs();
+ foreach (const TypeDefModelItem &typeDef, typeDefs) {
+ AbstractMetaClass *cls = traverseTypeDef(dom, typeDef);
+ if (cls) {
+ metaClass->addInnerClass(cls);
+ cls->setEnclosingClass(metaClass);
+ addAbstractMetaClass(cls);
+ }
+ }
+
+ // Traverse namespaces recursively
+ const QSet<NamespaceModelItem> &innerNamespaces = namespaceItem->uniqueNamespaces();
+ foreach (const NamespaceModelItem &ni, innerNamespaces) {
+ AbstractMetaClass* mjc = traverseNamespace(dom, ni);
+ if (mjc) {
+ metaClass->addInnerClass(mjc);
+ mjc->setEnclosingClass(metaClass);
+ addAbstractMetaClass(mjc);
+ }
+ }
+
+ m_currentClass = 0;
+
+ popScope();
+ m_namespacePrefix = currentScope()->qualifiedName().join(colonColon());
+
+ if (!type->include().isValid())
+ setInclude(type, namespaceItem->fileName());
+
+ return metaClass;
+}
+
+struct Operator
+{
+ enum Type { Complement, Plus, ShiftRight, ShiftLeft, None };
+
+ Operator() : type(None) {}
+
+ int calculate(int x)
+ {
+ switch (type) {
+ case Complement: return ~value;
+ case Plus: return x + value;
+ case ShiftRight: return x >> value;
+ case ShiftLeft: return x << value;
+ case None: return x;
+ }
+ return x;
+ }
+
+ Type type;
+ int value;
+};
+
+
+
+Operator findOperator(QString* s)
+{
+ const char *names[] = {
+ "~",
+ "+",
+ ">>",
+ "<<"
+ };
+
+ for (int i = 0; i < Operator::None; ++i) {
+ QString name = QLatin1String(names[i]);
+ QString str = *s;
+ int splitPoint = str.indexOf(name);
+ if (splitPoint > -1) {
+ bool ok;
+ QString right = str.mid(splitPoint + name.length());
+ Operator op;
+
+ op.value = right.toInt(&ok);
+ if (!ok && right.length() > 0 && right.at(right.length() - 1).toLower() == QLatin1Char('u'))
+ op.value = right.left(right.length() - 1).toUInt(&ok, 0);
+
+ if (ok) {
+ op.type = Operator::Type(i);
+ if (splitPoint > 0)
+ *s = str.left(splitPoint).trimmed();
+ else
+ *s = QString();
+ return op;
+ }
+ }
+ }
+ return Operator();
+}
+
+int AbstractMetaBuilderPrivate::figureOutEnumValue(const QString &stringValue,
+ int oldValuevalue,
+ AbstractMetaEnum *metaEnum,
+ AbstractMetaFunction *metaFunction)
+{
+ if (stringValue.isEmpty())
+ return oldValuevalue;
+
+ QStringList stringValues = stringValue.split(QLatin1Char('|'));
+
+ int returnValue = 0;
+
+ bool matched = false;
+
+ for (int i = 0; i < stringValues.size(); ++i) {
+ QString s = stringValues.at(i).trimmed();
+
+ bool ok;
+ int v;
+
+ Operator op = findOperator(&s);
+
+ if (s.length() > 0 && s.at(0) == QLatin1Char('0'))
+ v = s.toUInt(&ok, 0);
+ else if (s.length() > 0 && s.at(s.length() - 1).toLower() == QLatin1Char('u'))
+ v = s.left(s.length() - 1).toUInt(&ok, 0);
+ else
+ v = s.toInt(&ok);
+
+ if (ok || s.isEmpty()) {
+ matched = true;
+ } else if (m_enumValues.contains(s)) {
+ v = m_enumValues[s]->value();
+ matched = true;
+ } else {
+ if (metaEnum) {
+ v = findOutValueFromString(s, matched);
+ if (!matched) {
+ QString enclosingClass = QString(metaEnum->enclosingClass() ? metaEnum->enclosingClass()->name() + colonColon() : QString());
+ qCWarning(lcShiboken).noquote().nospace()
+ << "unhandled enum value: " << s << " in "
+ << enclosingClass << metaEnum->name() << " from header '"
+ << metaEnum->typeEntry()->include().name() << '\'';
+ }
+ } else {
+ qCWarning(lcShiboken) << "unhandled enum value: Unknown enum";
+ }
+ }
+
+ if (matched)
+ returnValue |= op.calculate(v);
+ }
+
+ if (!matched) {
+ QString warn = QStringLiteral("unmatched enum %1").arg(stringValue);
+
+ if (metaFunction) {
+ warn += QStringLiteral(" when parsing default value of '%1' in class '%2'")
+ .arg(metaFunction->name(), metaFunction->implementingClass()->name());
+ }
+ warn += QLatin1String(" from header '") + metaEnum->typeEntry()->include().name()
+ + QLatin1Char('\'');
+
+ qCWarning(lcShiboken).noquote().nospace() << warn;
+ returnValue = oldValuevalue;
+ }
+
+ return returnValue;
+}
+
+void AbstractMetaBuilderPrivate::figureOutEnumValuesForClass(AbstractMetaClass *metaClass,
+ QSet<AbstractMetaClass *> *classes)
+{
+ AbstractMetaClass* base = metaClass->baseClass();
+
+ if (base && !classes->contains(base))
+ figureOutEnumValuesForClass(base, classes);
+
+ if (classes->contains(metaClass))
+ return;
+
+ AbstractMetaEnumList enums = metaClass->enums();
+ foreach (AbstractMetaEnum* e, enums) {
+ if (!e) {
+ qCWarning(lcShiboken).noquote().nospace() << "bad enum in class " << metaClass->name();
+ continue;
+ }
+ AbstractMetaEnumValueList lst = e->values();
+ int value = 0;
+ for (int i = 0; i < lst.size(); ++i) {
+ value = figureOutEnumValue(lst.at(i)->stringValue(), value, e);
+ lst.at(i)->setValue(value);
+ value++;
+ }
+ }
+
+ *classes += metaClass;
+}
+
+
+void AbstractMetaBuilderPrivate::figureOutEnumValues()
+{
+ // Keep a set of classes that we already traversed. We use this to
+ // enforce that we traverse base classes prior to subclasses.
+ QSet<AbstractMetaClass*> classes;
+ foreach (AbstractMetaClass *c, m_metaClasses)
+ figureOutEnumValuesForClass(c, &classes);
+
+ foreach (AbstractMetaEnum* metaEnum, m_globalEnums) {
+ AbstractMetaEnumValueList enumValues = metaEnum->values();
+ int value = 0;
+ for (int i = 0; i < enumValues.size(); ++i) {
+ value = figureOutEnumValue(enumValues.at(i)->stringValue(), value, metaEnum);
+ enumValues.at(i)->setValue(value);
+ value++;
+ }
+ }
+}
+
+void AbstractMetaBuilderPrivate::figureOutDefaultEnumArguments()
+{
+ foreach (AbstractMetaClass* metaClass, m_metaClasses) {
+ foreach (AbstractMetaFunction* metaFunction, metaClass->functions()) {
+ foreach (AbstractMetaArgument *arg, metaFunction->arguments()) {
+ QString expr = arg->defaultValueExpression();
+ if (expr.isEmpty())
+ continue;
+
+ if (!metaFunction->replacedDefaultExpression(metaFunction->implementingClass(),
+ arg->argumentIndex() + 1).isEmpty()) {
+ continue;
+ }
+
+ arg->setDefaultValueExpression(expr);
+ }
+ }
+ }
+}
+
+
+AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(EnumModelItem enumItem,
+ AbstractMetaClass *enclosing,
+ const QSet<QString> &enumsDeclarations)
+{
+ QString qualifiedName = enumItem->qualifiedName().join(colonColon());
+
+ TypeEntry* typeEntry = 0;
+ if (enumItem->accessPolicy() == CodeModel::Private) {
+ QStringList names = enumItem->qualifiedName();
+ QString enumName = names.last();
+ QString nspace;
+ if (names.size() > 1)
+ nspace = QStringList(names.mid(0, names.size() - 1)).join(colonColon());
+ typeEntry = new EnumTypeEntry(nspace, enumName, 0);
+ TypeDatabase::instance()->addType(typeEntry);
+ } else if (!enumItem->isAnonymous()) {
+ typeEntry = TypeDatabase::instance()->findType(qualifiedName);
+ } else {
+ QStringList tmpQualifiedName = enumItem->qualifiedName();
+ foreach (const EnumeratorModelItem& enumValue, enumItem->enumerators()) {
+ tmpQualifiedName.removeLast();
+ tmpQualifiedName << enumValue->name();
+ qualifiedName = tmpQualifiedName.join(colonColon());
+ typeEntry = TypeDatabase::instance()->findType(qualifiedName);
+ if (typeEntry)
+ break;
+ }
+ }
+
+ QString enumName = enumItem->name();
+
+ QString className;
+ if (m_currentClass)
+ className = m_currentClass->typeEntry()->qualifiedCppName();
+
+ if (TypeDatabase::instance()->isEnumRejected(className, enumName)) {
+ if (typeEntry)
+ typeEntry->setCodeGeneration(TypeEntry::GenerateNothing);
+ m_rejectedEnums.insert(qualifiedName, AbstractMetaBuilder::GenerationDisabled);
+ return 0;
+ }
+
+ if (!typeEntry || !typeEntry->isEnum()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("enum '%1' does not have a type entry or is not an enum")
+ .arg(qualifiedName);
+ m_rejectedEnums.insert(qualifiedName, AbstractMetaBuilder::NotInTypeSystem);
+ return 0;
+ }
+
+ AbstractMetaEnum *metaEnum = q->createMetaEnum();
+ if (enumsDeclarations.contains(qualifiedName)
+ || enumsDeclarations.contains(enumName)) {
+ metaEnum->setHasQEnumsDeclaration(true);
+ }
+
+ metaEnum->setTypeEntry((EnumTypeEntry*) typeEntry);
+ switch (enumItem->accessPolicy()) {
+ case CodeModel::Public:
+ *metaEnum += AbstractMetaAttributes::Public;
+ break;
+ case CodeModel::Protected:
+ *metaEnum += AbstractMetaAttributes::Protected;
+ break;
+ case CodeModel::Private:
+ *metaEnum += AbstractMetaAttributes::Private;
+ typeEntry->setCodeGeneration(TypeEntry::GenerateNothing);
+ break;
+ default:
+ break;
+ }
+
+ if (ReportHandler::isDebug(ReportHandler::MediumDebug))
+ qCDebug(lcShiboken) << " - traversing enum " << metaEnum->fullName();
+
+ foreach (const EnumeratorModelItem &value, enumItem->enumerators()) {
+
+ AbstractMetaEnumValue *metaEnumValue = q->createMetaEnumValue();
+ metaEnumValue->setName(value->name());
+ // Deciding the enum value...
+
+ metaEnumValue->setStringValue(value->value());
+ metaEnum->addEnumValue(metaEnumValue);
+
+ if (ReportHandler::isDebug(ReportHandler::FullDebug)) {
+ qCDebug(lcShiboken) << " - " << metaEnumValue->name() << " = "
+ << metaEnumValue->value() << " = " << metaEnumValue->value();
+ }
+
+ // Add into global register...
+ if (enclosing)
+ m_enumValues[enclosing->name() + colonColon() + metaEnumValue->name()] = metaEnumValue;
+ else
+ m_enumValues[metaEnumValue->name()] = metaEnumValue;
+ }
+
+ m_enums << metaEnum;
+
+ if (!metaEnum->typeEntry()->include().isValid())
+ setInclude(metaEnum->typeEntry(), enumItem->fileName());
+
+ metaEnum->setOriginalAttributes(metaEnum->attributes());
+
+ // Register all enum values on Type database
+ foreach(EnumeratorModelItem e, enumItem->enumerators()) {
+ QString name;
+ if (enclosing) {
+ name += enclosing->name();
+ name += colonColon();
+ }
+ name += e->name();
+ EnumValueTypeEntry* enumValue = new EnumValueTypeEntry(name, e->value(), static_cast<EnumTypeEntry*>(typeEntry), typeEntry->version());
+ TypeDatabase::instance()->addType(enumValue);
+ }
+
+ return metaEnum;
+}
+
+AbstractMetaClass* AbstractMetaBuilderPrivate::traverseTypeDef(const FileModelItem &dom,
+ const TypeDefModelItem &typeDef)
+{
+ TypeDatabase* types = TypeDatabase::instance();
+ QString className = stripTemplateArgs(typeDef->name());
+
+ QString fullClassName = className;
+ // we have an inner class
+ if (m_currentClass) {
+ fullClassName = stripTemplateArgs(m_currentClass->typeEntry()->qualifiedCppName())
+ + colonColon() + fullClassName;
+ }
+
+ // If this is the alias for a primitive type
+ // we store the aliased type on the alias
+ // TypeEntry
+ PrimitiveTypeEntry* ptype = types->findPrimitiveType(className);
+ if (ptype) {
+ QString typeDefName = typeDef->type().qualifiedName()[0];
+ ptype->setReferencedTypeEntry(types->findPrimitiveType(typeDefName));
+ return 0;
+ }
+
+
+ // If we haven't specified anything for the typedef, then we don't care
+ ComplexTypeEntry* type = types->findComplexType(fullClassName);
+ if (!type)
+ return 0;
+
+ if (type->isObject())
+ static_cast<ObjectTypeEntry *>(type)->setQObject(isQObject(dom, stripTemplateArgs(typeDef->type().qualifiedName().join(colonColon()))));
+
+ AbstractMetaClass *metaClass = q->createMetaClass();
+ metaClass->setTypeDef(true);
+ metaClass->setTypeEntry(type);
+ metaClass->setBaseClassNames(QStringList() << typeDef->type().qualifiedName().join(colonColon()));
+ *metaClass += AbstractMetaAttributes::Public;
+
+ // Set the default include file name
+ if (!type->include().isValid())
+ setInclude(type, typeDef->fileName());
+
+ fillAddedFunctions(metaClass);
+
+ return metaClass;
+}
+
+AbstractMetaClass *AbstractMetaBuilderPrivate::traverseClass(const FileModelItem &dom,
+ const ClassModelItem &classItem)
+{
+ QString className = stripTemplateArgs(classItem->name());
+ QString fullClassName = className;
+
+ // we have inner an class
+ if (m_currentClass) {
+ fullClassName = stripTemplateArgs(m_currentClass->typeEntry()->qualifiedCppName())
+ + colonColon() + fullClassName;
+ }
+
+ ComplexTypeEntry* type = TypeDatabase::instance()->findComplexType(fullClassName);
+ AbstractMetaBuilder::RejectReason reason = AbstractMetaBuilder::NoReason;
+
+ if (fullClassName == QLatin1String("QMetaTypeId")) {
+ // QtScript: record which types have been declared
+ int lpos = classItem->name().indexOf(QLatin1Char('<'));
+ int rpos = classItem->name().lastIndexOf(QLatin1Char('>'));
+ if ((lpos != -1) && (rpos != -1)) {
+ QString declaredTypename = classItem->name().mid(lpos + 1, rpos - lpos - 1);
+ m_qmetatypeDeclaredTypenames.insert(declaredTypename);
+ }
+ }
+
+ if (TypeDatabase::instance()->isClassRejected(fullClassName)) {
+ reason = AbstractMetaBuilder::GenerationDisabled;
+ } else if (!type) {
+ TypeEntry *te = TypeDatabase::instance()->findType(fullClassName);
+ if (te && !te->isComplex())
+ reason = AbstractMetaBuilder::RedefinedToNotClass;
+ else
+ reason = AbstractMetaBuilder::NotInTypeSystem;
+ } else if (type->codeGeneration() == TypeEntry::GenerateNothing) {
+ reason = AbstractMetaBuilder::GenerationDisabled;
+ }
+ if (reason != AbstractMetaBuilder::NoReason) {
+ m_rejectedClasses.insert(fullClassName, reason);
+ return 0;
+ }
+
+ if (type->isObject())
+ ((ObjectTypeEntry*)type)->setQObject(isQObject(dom, fullClassName));
+
+ AbstractMetaClass *metaClass = q->createMetaClass();
+ metaClass->setTypeEntry(type);
+ metaClass->setBaseClassNames(classItem->baseClasses());
+ *metaClass += AbstractMetaAttributes::Public;
+ if (type->stream())
+ metaClass->setStream(true);
+
+ AbstractMetaClass* oldCurrentClass = m_currentClass;
+ m_currentClass = metaClass;
+
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug)) {
+ const QString message = type->isContainer()
+ ? QStringLiteral("container: '%1'").arg(fullClassName)
+ : QStringLiteral("class: '%1'").arg(metaClass->fullName());
+ qCDebug(lcShiboken) << message;
+ }
+
+ TemplateParameterList template_parameters = classItem->templateParameters();
+ QList<TypeEntry *> template_args;
+ template_args.clear();
+ for (int i = 0; i < template_parameters.size(); ++i) {
+ const TemplateParameterModelItem &param = template_parameters.at(i);
+ TemplateArgumentEntry *param_type = new TemplateArgumentEntry(param->name(), type->version());
+ param_type->setOrdinal(i);
+ template_args.append(param_type);
+ }
+ metaClass->setTemplateArguments(template_args);
+
+ parseQ_Property(metaClass, classItem->propertyDeclarations());
+
+ traverseEnums(classItem, metaClass, classItem->enumsDeclarations());
+
+ // Inner classes
+ {
+ const ClassList &innerClasses = classItem->classes();
+ foreach (const ClassModelItem &ci, innerClasses) {
+ AbstractMetaClass *cl = traverseClass(dom, ci);
+ if (cl) {
+ cl->setEnclosingClass(metaClass);
+ metaClass->addInnerClass(cl);
+ m_metaClasses << cl;
+ }
+ }
+
+ }
+
+ // Go through all typedefs to see if we have defined any
+ // specific typedefs to be used as classes.
+ const TypeDefList typeDefs = classItem->typeDefs();
+ foreach (const TypeDefModelItem &typeDef, typeDefs) {
+ AbstractMetaClass *cls = traverseTypeDef(dom, typeDef);
+ if (cls) {
+ cls->setEnclosingClass(metaClass);
+ addAbstractMetaClass(cls);
+ }
+ }
+
+
+ m_currentClass = oldCurrentClass;
+
+ // Set the default include file name
+ if (!type->include().isValid())
+ setInclude(type, classItem->fileName());
+
+ return metaClass;
+}
+
+void AbstractMetaBuilderPrivate::traverseScopeMembers(ScopeModelItem item,
+ AbstractMetaClass *metaClass)
+{
+ // Classes/Namespace members
+ traverseFields(item, metaClass);
+ traverseFunctions(item, metaClass);
+
+ // Inner classes
+ const ClassList &innerClasses = item->classes();
+ foreach (const ClassModelItem& ci, innerClasses)
+ traverseClassMembers(ci);
+}
+
+AbstractMetaClass* AbstractMetaBuilderPrivate::currentTraversedClass(ScopeModelItem item)
+{
+ QString className = stripTemplateArgs(item->name());
+ QString fullClassName = className;
+
+ // This is an inner class
+ if (m_currentClass)
+ fullClassName = stripTemplateArgs(m_currentClass->typeEntry()->qualifiedCppName()) + colonColon() + fullClassName;
+
+ AbstractMetaClass *metaClass = AbstractMetaClass::findClass(m_metaClasses, fullClassName);
+ if (!metaClass)
+ metaClass = AbstractMetaClass::findClass(m_templates, fullClassName);
+
+ if (!metaClass)
+ metaClass = AbstractMetaClass::findClass(m_smartPointers, fullClassName);
+ return metaClass;
+}
+
+void AbstractMetaBuilderPrivate::traverseClassMembers(ClassModelItem item)
+{
+ AbstractMetaClass* metaClass = currentTraversedClass(item);
+ if (!metaClass)
+ return;
+
+ AbstractMetaClass* oldCurrentClass = m_currentClass;
+ m_currentClass = metaClass;
+
+ // Class members
+ traverseScopeMembers(item, metaClass);
+
+ m_currentClass = oldCurrentClass;
+}
+
+void AbstractMetaBuilderPrivate::traverseNamespaceMembers(NamespaceModelItem item)
+{
+ AbstractMetaClass* metaClass = currentTraversedClass(item);
+ if (!metaClass)
+ return;
+
+ AbstractMetaClass* oldCurrentClass = m_currentClass;
+ m_currentClass = metaClass;
+
+ // Namespace members
+ traverseScopeMembers(item, metaClass);
+
+ // Inner namespaces
+ const QSet<NamespaceModelItem> &innerNamespaces = item->uniqueNamespaces();
+ foreach (const NamespaceModelItem &ni, innerNamespaces)
+ traverseNamespaceMembers(ni);
+
+ m_currentClass = oldCurrentClass;
+}
+
+static inline QString fieldSignatureWithType(VariableModelItem field)
+{
+ return field->name() + QStringLiteral(" -> ") + field->type().toString();
+}
+
+static inline QString qualifiedFieldSignatureWithType(const QString &className,
+ VariableModelItem field)
+{
+ return className + colonColon() + fieldSignatureWithType(field);
+}
+
+AbstractMetaField *AbstractMetaBuilderPrivate::traverseField(VariableModelItem field,
+ const AbstractMetaClass *cls)
+{
+ QString fieldName = field->name();
+ QString className = m_currentClass->typeEntry()->qualifiedCppName();
+
+ // Ignore friend decl.
+ if (field->isFriend())
+ return 0;
+
+ if (field->accessPolicy() == CodeModel::Private)
+ return 0;
+
+ if (TypeDatabase::instance()->isFieldRejected(className, fieldName)) {
+ m_rejectedFields.insert(qualifiedFieldSignatureWithType(className, field),
+ AbstractMetaBuilder::GenerationDisabled);
+ return 0;
+ }
+
+
+ AbstractMetaField *metaField = q->createMetaField();
+ metaField->setName(fieldName);
+ metaField->setEnclosingClass(cls);
+
+ bool ok;
+ TypeInfo fieldType = field->type();
+ AbstractMetaType *metaType = translateType(fieldType, &ok);
+
+ if (!metaType || !ok) {
+ const QString type = TypeInfo::resolveType(fieldType, currentScope()).qualifiedName().join(colonColon());
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("skipping field '%1::%2' with unmatched type '%3'")
+ .arg(m_currentClass->name(), fieldName, type);
+ delete metaField;
+ return 0;
+ }
+
+ metaField->setType(metaType);
+
+ AbstractMetaAttributes::Attributes attr = 0;
+ if (field->isStatic())
+ attr |= AbstractMetaAttributes::Static;
+
+ CodeModel::AccessPolicy policy = field->accessPolicy();
+ if (policy == CodeModel::Public)
+ attr |= AbstractMetaAttributes::Public;
+ else if (policy == CodeModel::Protected)
+ attr |= AbstractMetaAttributes::Protected;
+ else
+ attr |= AbstractMetaAttributes::Private;
+ metaField->setAttributes(attr);
+
+ return metaField;
+}
+
+void AbstractMetaBuilderPrivate::traverseFields(ScopeModelItem scope_item,
+ AbstractMetaClass *metaClass)
+{
+ foreach (const VariableModelItem &field, scope_item->variables()) {
+ AbstractMetaField* metaField = traverseField(field, metaClass);
+
+ if (metaField && !metaField->isModifiedRemoved()) {
+ metaField->setOriginalAttributes(metaField->attributes());
+ metaClass->addField(metaField);
+ }
+ }
+}
+
+void AbstractMetaBuilderPrivate::setupFunctionDefaults(AbstractMetaFunction *metaFunction,
+ AbstractMetaClass *metaClass)
+{
+ // Set the default value of the declaring class. This may be changed
+ // in fixFunctions later on
+ metaFunction->setDeclaringClass(metaClass);
+
+ // Some of the queries below depend on the implementing class being set
+ // to function properly. Such as function modifications
+ metaFunction->setImplementingClass(metaClass);
+
+ if (metaFunction->name() == QLatin1String("operator_equal"))
+ metaClass->setHasEqualsOperator(true);
+
+ if (!metaFunction->isFinalInTargetLang()
+ && metaFunction->isRemovedFrom(metaClass, TypeSystem::TargetLangCode)) {
+ *metaFunction += AbstractMetaAttributes::FinalInCpp;
+ }
+}
+
+void AbstractMetaBuilderPrivate::fixReturnTypeOfConversionOperator(AbstractMetaFunction *metaFunction)
+{
+ if (!metaFunction->isConversionOperator())
+ return;
+
+ TypeDatabase* types = TypeDatabase::instance();
+ QString castTo = metaFunction->name().remove(QRegExp(QLatin1String("^operator "))).trimmed();
+
+ if (castTo.endsWith(QLatin1Char('&')))
+ castTo.chop(1);
+ if (castTo.startsWith(QLatin1String("const ")))
+ castTo.remove(0, 6);
+
+ TypeEntry* retType = types->findType(castTo);
+ if (!retType)
+ return;
+
+ AbstractMetaType* metaType = q->createMetaType();
+ metaType->setTypeEntry(retType);
+ metaFunction->replaceType(metaType);
+}
+
+static bool _compareAbstractMetaTypes(const AbstractMetaType* type, const AbstractMetaType* other)
+{
+ if (!type && !other)
+ return true;
+ if (!type || !other)
+ return false;
+ return type->typeEntry() == other->typeEntry()
+ && type->isConstant() == other->isConstant()
+ && type->referenceType() == other->referenceType()
+ && type->indirections() == other->indirections();
+}
+
+static bool _compareAbstractMetaFunctions(const AbstractMetaFunction* func, const AbstractMetaFunction* other)
+{
+ if (!func && !other)
+ return true;
+ if (!func || !other)
+ return false;
+ if (func->arguments().count() != other->arguments().count()
+ || func->isConstant() != other->isConstant()
+ || func->isStatic() != other->isStatic()
+ || !_compareAbstractMetaTypes(func->type(), other->type())) {
+ return false;
+ }
+ for (int i = 0; i < func->arguments().count(); ++i) {
+ if (!_compareAbstractMetaTypes(func->arguments().at(i)->type(), other->arguments().at(i)->type()))
+ return false;
+ }
+ return true;
+}
+
+// Fix the arguments of template classes that take the class itself, for example:
+// "QList(const QList &)" to "QList(const QList<T> &)".
+static bool _fixFunctionModelItemTypes(FunctionModelItem& function, const AbstractMetaClass* metaClass)
+{
+ const QList<TypeEntry *> &templateTypes = metaClass->templateArguments();
+ if (templateTypes.isEmpty())
+ return false;
+
+ const QStringList classType = metaClass->typeEntry()->qualifiedCppName().split(colonColon());
+ QStringList fixedClassType = classType;
+ fixedClassType.last().append(QLatin1Char('<'));
+ for (int i = 0, count = templateTypes.size(); i < count; ++i) {
+ if (i)
+ fixedClassType.last().append(QLatin1String(", "));
+ fixedClassType.last().append(templateTypes.at(i)->qualifiedCppName());
+ }
+ fixedClassType.last().append(QLatin1String(" >"));
+
+ bool templateTypeFixed = false;
+ TypeInfo functionType = function->type();
+ if (functionType.qualifiedName() == classType) {
+ templateTypeFixed = true;
+ functionType.setQualifiedName(fixedClassType);
+ function->setType(functionType);
+ }
+
+ ArgumentList arguments = function->arguments();
+ for (int i = 0; i < arguments.size(); ++i) {
+ ArgumentModelItem arg = arguments.at(i);
+ TypeInfo type = arg->type();
+ if (type.qualifiedName() == classType) {
+ type.setQualifiedName(fixedClassType);
+ arg->setType(type);
+ templateTypeFixed = true;
+ }
+ }
+ return templateTypeFixed;
+}
+
+AbstractMetaFunctionList AbstractMetaBuilderPrivate::classFunctionList(const ScopeModelItem &scopeItem)
+{
+ AbstractMetaFunctionList result;
+ const FunctionList &scopeFunctionList = scopeItem->functions();
+ result.reserve(scopeFunctionList.size());
+ foreach (const FunctionModelItem &function, scopeItem->functions()) {
+ if (AbstractMetaFunction *metaFunction = traverseFunction(function))
+ result.append(metaFunction);
+ }
+ return result;
+}
+
+// For template classes, entries with more specific types may exist from out-of-
+// line definitions. If there is a declaration which matches it after fixing
+// the parameters, remove it as duplicate. For example:
+// template class<T> Vector { public:
+// Vector(const Vector &rhs);
+// };
+// template class<T>
+// Vector<T>::Vector(const Vector<T>&) {} // More specific, remove declaration.
+
+class DuplicatingFunctionPredicate : public std::unary_function<bool, const AbstractMetaFunction *> {
+public:
+ explicit DuplicatingFunctionPredicate(const AbstractMetaFunction *f) : m_function(f) {}
+
+ bool operator()(const AbstractMetaFunction *rhs) const
+ {
+ return rhs != m_function && rhs->name() == m_function->name()
+ && _compareAbstractMetaFunctions(m_function, rhs);
+ }
+
+private:
+ const AbstractMetaFunction *m_function;
+};
+
+AbstractMetaFunctionList AbstractMetaBuilderPrivate::templateClassFunctionList(const ScopeModelItem &scopeItem,
+ AbstractMetaClass *metaClass)
+{
+ AbstractMetaFunctionList result;
+ AbstractMetaFunctionList unchangedFunctions;
+
+ const FunctionList &scopeFunctionList = scopeItem->functions();
+ result.reserve(scopeFunctionList.size());
+ unchangedFunctions.reserve(scopeFunctionList.size());
+ foreach (FunctionModelItem function, scopeItem->functions()) {
+ // This fixes method's arguments and return types that are templates
+ // but the template variable wasn't declared in the C++ header.
+ const bool templateTypeFixed =_fixFunctionModelItemTypes(function, metaClass);
+ if (AbstractMetaFunction *metaFunction = traverseFunction(function)) {
+ result.append(metaFunction);
+ if (!templateTypeFixed)
+ unchangedFunctions.append(metaFunction);
+ }
+ }
+
+ const AbstractMetaFunctionList::ConstIterator unchangedBegin = unchangedFunctions.begin();
+ const AbstractMetaFunctionList::ConstIterator unchangedEnd = unchangedFunctions.end();
+ for (int i = result.size() - 1; i >= 0; --i) {
+ AbstractMetaFunction *function = result.at(i);
+ if (!unchangedFunctions.contains(function)
+ && unchangedEnd != std::find_if(unchangedBegin, unchangedEnd, DuplicatingFunctionPredicate(function))) {
+ delete result.takeAt(i);
+ }
+ }
+ return result;
+}
+
+void AbstractMetaBuilderPrivate::traverseFunctions(ScopeModelItem scopeItem,
+ AbstractMetaClass *metaClass)
+{
+
+ const AbstractMetaFunctionList functions = metaClass->templateArguments().isEmpty()
+ ? classFunctionList(scopeItem)
+ : templateClassFunctionList(scopeItem, metaClass);
+
+ foreach (AbstractMetaFunction *metaFunction, functions) {
+ metaFunction->setOriginalAttributes(metaFunction->attributes());
+ if (metaClass->isNamespace())
+ *metaFunction += AbstractMetaAttributes::Static;
+
+ QPropertySpec *read = 0;
+ if (!metaFunction->isSignal() && (read = metaClass->propertySpecForRead(metaFunction->name()))) {
+ // Property reader must be in the form "<type> name()"
+ if (metaFunction->type() && (read->type() == metaFunction->type()->typeEntry()) && (metaFunction->arguments().size() == 0)) {
+ *metaFunction += AbstractMetaAttributes::PropertyReader;
+ metaFunction->setPropertySpec(read);
+ }
+ } else if (QPropertySpec* write = metaClass->propertySpecForWrite(metaFunction->name())) {
+ // Property setter must be in the form "void name(<type>)"
+ // make sure the function was created with all aguments, some argument can be missing during the pareser because of errors on typesystem
+ if ((!metaFunction->type()) && (metaFunction->arguments().size() == 1) && (write->type() == metaFunction->arguments().at(0)->type()->typeEntry())) {
+ *metaFunction += AbstractMetaAttributes::PropertyWriter;
+ metaFunction->setPropertySpec(write);
+ }
+ } else if (QPropertySpec* reset = metaClass->propertySpecForReset(metaFunction->name())) {
+ // Property resetter must be in the form "void name()"
+ if ((!metaFunction->type()) && (metaFunction->arguments().size() == 0)) {
+ *metaFunction += AbstractMetaAttributes::PropertyResetter;
+ metaFunction->setPropertySpec(reset);
+ }
+ }
+
+ const bool isInvalidDestructor = metaFunction->isDestructor() && metaFunction->isPrivate();
+ const bool isInvalidConstructor = metaFunction->isConstructor()
+ && ((metaFunction->isPrivate() && metaFunction->functionType() == AbstractMetaFunction::ConstructorFunction)
+ || metaFunction->isInvalid());
+ if ((isInvalidDestructor || isInvalidConstructor)
+ && !metaClass->hasNonPrivateConstructor()) {
+ *metaClass += AbstractMetaAttributes::Final;
+ } else if (metaFunction->isConstructor() && !metaFunction->isPrivate()) {
+ *metaClass -= AbstractMetaAttributes::Final;
+ metaClass->setHasNonPrivateConstructor(true);
+ }
+
+ // Classes with virtual destructors should always have a shell class
+ // (since we aren't registering the destructors, we need this extra check)
+ if (metaFunction->isDestructor() && !metaFunction->isFinal())
+ metaClass->setForceShellClass(true);
+
+ if (!metaFunction->isDestructor()
+ && !metaFunction->isInvalid()
+ && !(metaFunction->isPrivate() && metaFunction->functionType() == AbstractMetaFunction::ConstructorFunction)) {
+
+ setupFunctionDefaults(metaFunction, metaClass);
+
+ if (metaFunction->isSignal() && metaClass->hasSignal(metaFunction)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("signal '%1' in class '%2' is overloaded.")
+ .arg(metaFunction->name(), metaClass->name());
+ }
+
+ if (metaFunction->isSignal() && !metaClass->isQObject()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("signal '%1' in non-QObject class '%2'")
+ .arg(metaFunction->name(), metaClass->name());
+ }
+
+ if (metaFunction->isConversionOperator())
+ fixReturnTypeOfConversionOperator(metaFunction);
+
+ metaClass->addFunction(metaFunction);
+ applyFunctionModifications(metaFunction);
+ } else if (metaFunction->isDestructor()) {
+ metaClass->setHasPrivateDestructor(metaFunction->isPrivate());
+ metaClass->setHasProtectedDestructor(metaFunction->isProtected());
+ metaClass->setHasVirtualDestructor(metaFunction->isVirtual());
+ }
+ if (!metaFunction->ownerClass()) {
+ delete metaFunction;
+ metaFunction = 0;
+ }
+ }
+
+ fillAddedFunctions(metaClass);
+}
+
+void AbstractMetaBuilderPrivate::fillAddedFunctions(AbstractMetaClass *metaClass)
+{
+ // Add the functions added by the typesystem
+ foreach (const AddedFunction &addedFunc, metaClass->typeEntry()->addedFunctions())
+ traverseFunction(addedFunc, metaClass);
+}
+
+void AbstractMetaBuilderPrivate::applyFunctionModifications(AbstractMetaFunction *func)
+{
+ FunctionModificationList mods = func->modifications(func->implementingClass());
+ AbstractMetaFunction& funcRef = *func;
+ foreach (const FunctionModification &mod, mods) {
+ if (mod.isRenameModifier()) {
+ func->setOriginalName(func->name());
+ func->setName(mod.renamedTo());
+ } else if (mod.isAccessModifier()) {
+ funcRef -= AbstractMetaAttributes::Public;
+ funcRef -= AbstractMetaAttributes::Protected;
+ funcRef -= AbstractMetaAttributes::Private;
+ funcRef -= AbstractMetaAttributes::Friendly;
+
+ if (mod.isPublic())
+ funcRef += AbstractMetaAttributes::Public;
+ else if (mod.isProtected())
+ funcRef += AbstractMetaAttributes::Protected;
+ else if (mod.isPrivate())
+ funcRef += AbstractMetaAttributes::Private;
+ else if (mod.isFriendly())
+ funcRef += AbstractMetaAttributes::Friendly;
+ }
+
+ if (mod.isFinal())
+ funcRef += AbstractMetaAttributes::FinalInTargetLang;
+ else if (mod.isNonFinal())
+ funcRef -= AbstractMetaAttributes::FinalInTargetLang;
+ }
+}
+
+bool AbstractMetaBuilderPrivate::setupInheritance(AbstractMetaClass *metaClass)
+{
+ Q_ASSERT(!metaClass->isInterface());
+
+ if (m_setupInheritanceDone.contains(metaClass))
+ return true;
+
+ m_setupInheritanceDone.insert(metaClass);
+
+ QStringList baseClasses = metaClass->baseClassNames();
+
+ // we only support our own containers and ONLY if there is only one baseclass
+ if (baseClasses.size() == 1 && baseClasses.first().contains(QLatin1Char('<'))) {
+ TypeParser::Info info;
+ ComplexTypeEntry* baseContainerType;
+ AbstractMetaClass* templ = findTemplateClass(baseClasses.first(), metaClass, &info, &baseContainerType);
+ if (templ) {
+ setupInheritance(templ);
+ inheritTemplate(metaClass, templ, info);
+ metaClass->typeEntry()->setBaseContainerType(templ->typeEntry());
+ return true;
+ }
+
+ if (baseContainerType) {
+ // Container types are not necessarily wrapped as 'real' classes,
+ // but there may still be classes derived from them. In such case,
+ // we still need to set the base container type in order to
+ // generate correct code for type conversion checking.
+ //
+ // Additionally, we consider this case as successfully setting up
+ // inheritance.
+ metaClass->typeEntry()->setBaseContainerType(baseContainerType);
+ return true;
+ }
+
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("template baseclass '%1' of '%2' is not known")
+ .arg(baseClasses.first(), metaClass->name());
+ return false;
+ }
+
+ TypeDatabase* types = TypeDatabase::instance();
+
+ int primary = -1;
+ int primaries = 0;
+ for (int i = 0; i < baseClasses.size(); ++i) {
+
+ if (types->isClassRejected(baseClasses.at(i)))
+ continue;
+
+ TypeEntry* baseClassEntry = types->findType(baseClasses.at(i));
+ if (!baseClassEntry) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("class '%1' inherits from unknown base class '%2'")
+ .arg(metaClass->name(), baseClasses.at(i));
+ } else if (!baseClassEntry->designatedInterface()) { // true for primary base class
+ primaries++;
+ primary = i;
+ }
+ }
+
+ if (primary >= 0) {
+ AbstractMetaClass *baseClass = AbstractMetaClass::findClass(m_metaClasses, baseClasses.at(primary));
+ if (!baseClass) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("unknown baseclass for '%1': '%2'")
+ .arg(metaClass->name(), baseClasses.at(primary));
+ return false;
+ }
+ metaClass->setBaseClass(baseClass);
+ }
+
+ for (int i = 0; i < baseClasses.size(); ++i) {
+ if (types->isClassRejected(baseClasses.at(i)))
+ continue;
+
+ if (i != primary) {
+ AbstractMetaClass *baseClass = AbstractMetaClass::findClass(m_metaClasses, baseClasses.at(i));
+ if (!baseClass) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("class not found for setup inheritance '%1'").arg(baseClasses.at(i));
+ return false;
+ }
+
+ setupInheritance(baseClass);
+
+ QString interfaceName = baseClass->isInterface() ? InterfaceTypeEntry::interfaceName(baseClass->name()) : baseClass->name();
+ AbstractMetaClass *iface = AbstractMetaClass::findClass(m_metaClasses, interfaceName);
+ if (!iface) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("unknown interface for '%1': '%2'").arg(metaClass->name(), interfaceName);
+ return false;
+ }
+ metaClass->addInterface(iface);
+
+ AbstractMetaClassList interfaces = iface->interfaces();
+ foreach (AbstractMetaClass* iface, interfaces)
+ metaClass->addInterface(iface);
+ }
+ }
+
+ return true;
+}
+
+void AbstractMetaBuilderPrivate::traverseEnums(ScopeModelItem scopeItem,
+ AbstractMetaClass *metaClass,
+ const QStringList &enumsDeclarations)
+{
+ EnumList enums = scopeItem->enums();
+ foreach (const EnumModelItem &enumItem, enums) {
+ AbstractMetaEnum* metaEnum = traverseEnum(enumItem, metaClass, QSet<QString>::fromList(enumsDeclarations));
+ if (metaEnum) {
+ metaClass->addEnum(metaEnum);
+ metaEnum->setEnclosingClass(metaClass);
+ }
+ }
+}
+
+AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFunction& addedFunc)
+{
+ return traverseFunction(addedFunc, 0);
+}
+
+AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFunction& addedFunc,
+ AbstractMetaClass *metaClass)
+{
+ AbstractMetaFunction *metaFunction = q->createMetaFunction();
+ metaFunction->setConstant(addedFunc.isConstant());
+ metaFunction->setName(addedFunc.name());
+ metaFunction->setOriginalName(addedFunc.name());
+ AbstractMetaClass::Attributes visibility =
+ addedFunc.access() == AddedFunction::Public
+ ? AbstractMetaAttributes::Public : AbstractMetaAttributes::Protected;
+ metaFunction->setVisibility(visibility);
+ metaFunction->setUserAdded(true);
+ AbstractMetaAttributes::Attribute isStatic = addedFunc.isStatic() ? AbstractMetaFunction::Static : AbstractMetaFunction::None;
+ metaFunction->setAttributes(metaFunction->attributes() | AbstractMetaAttributes::Final | isStatic);
+ metaFunction->setType(translateType(addedFunc.version(), addedFunc.returnType()));
+
+
+ QList<AddedFunction::TypeInfo> args = addedFunc.arguments();
+ AbstractMetaArgumentList metaArguments;
+
+ for (int i = 0; i < args.count(); ++i) {
+ AddedFunction::TypeInfo& typeInfo = args[i];
+ AbstractMetaArgument *metaArg = q->createMetaArgument();
+ AbstractMetaType* type = translateType(addedFunc.version(), typeInfo);
+ decideUsagePattern(type);
+ metaArg->setType(type);
+ metaArg->setArgumentIndex(i);
+ metaArg->setDefaultValueExpression(typeInfo.defaultValue);
+ metaArg->setOriginalDefaultValueExpression(typeInfo.defaultValue);
+ metaArguments.append(metaArg);
+ }
+
+ metaFunction->setArguments(metaArguments);
+ if (metaFunction->isOperatorOverload() && !metaFunction->isCallOperator()) {
+ if (metaArguments.size() > 2) {
+ qCWarning(lcShiboken) << "An operator overload need to have 0, 1 or 2 arguments if it's reverse.";
+ } else if (metaArguments.size() == 2) {
+ // Check if it's a reverse operator
+ if (metaArguments[1]->type()->typeEntry() == metaClass->typeEntry()) {
+ metaFunction->setReverseOperator(true);
+ // we need to call these two function to cache the old signature (with two args)
+ // we do this buggy behaviour to comply with the original apiextractor buggy behaviour.
+ metaFunction->signature();
+ metaFunction->minimalSignature();
+ metaArguments.removeLast();
+ metaFunction->setArguments(metaArguments);
+ } else {
+ qCWarning(lcShiboken) << "Operator overload can have two arguments only if it's a reverse operator!";
+ }
+ }
+ }
+
+
+ // Find the correct default values
+ for (int i = 0; i < metaArguments.size(); ++i) {
+ AbstractMetaArgument* metaArg = metaArguments.at(i);
+
+ //use relace-default-expression for set default value
+ QString replacedExpression;
+ if (m_currentClass)
+ replacedExpression = metaFunction->replacedDefaultExpression(m_currentClass, i + 1);
+
+ if (!replacedExpression.isEmpty()) {
+ QString expr = replacedExpression;
+ if (!metaFunction->removedDefaultExpression(m_currentClass, i + 1)) {
+ metaArg->setDefaultValueExpression(expr);
+ metaArg->setOriginalDefaultValueExpression(expr);
+
+ if (metaArg->type()->isEnum() || metaArg->type()->isFlags())
+ m_enumDefaultArguments << QPair<AbstractMetaArgument*, AbstractMetaFunction*>(metaArg, metaFunction);
+ }
+ }
+ }
+
+ metaFunction->setOriginalAttributes(metaFunction->attributes());
+ fixArgumentNames(metaFunction);
+
+ if (metaClass) {
+ const AbstractMetaArgumentList fargs = metaFunction->arguments();
+ if (metaClass->isNamespace())
+ *metaFunction += AbstractMetaFunction::Static;
+ if (metaFunction->name() == metaClass->name()) {
+ metaFunction->setFunctionType(AbstractMetaFunction::ConstructorFunction);
+ if (fargs.size() == 1) {
+ const TypeEntry *te = fargs.first()->type()->typeEntry();
+ if (te->isCustom())
+ metaFunction->setExplicit(true);
+ if (te->name() == metaFunction->name())
+ metaFunction->setFunctionType(AbstractMetaFunction::CopyConstructorFunction);
+ }
+ } else {
+ metaFunction->setFunctionType(AbstractMetaFunction::NormalFunction);
+ }
+
+ metaFunction->setDeclaringClass(metaClass);
+ metaFunction->setImplementingClass(metaClass);
+ metaClass->addFunction(metaFunction);
+ metaClass->setHasNonPrivateConstructor(true);
+ }
+
+ return metaFunction;
+}
+
+void AbstractMetaBuilderPrivate::fixArgumentNames(AbstractMetaFunction *func)
+{
+ if (func->arguments().isEmpty())
+ return;
+ foreach (const FunctionModification &mod, func->modifications(m_currentClass)) {
+ foreach (const ArgumentModification &argMod, mod.argument_mods) {
+ if (!argMod.renamed_to.isEmpty()) {
+ AbstractMetaArgument* arg = func->arguments().at(argMod.index - 1);
+ arg->setOriginalName(arg->name());
+ arg->setName(argMod.renamed_to, false);
+ }
+ }
+ }
+
+ int i = 1;
+ foreach (AbstractMetaArgument* arg, func->arguments()) {
+ if (arg->name().isEmpty())
+ arg->setName(QLatin1String("arg__") + QString::number(i), false);
+ ++i;
+ }
+}
+
+static QString functionSignature(FunctionModelItem functionItem)
+{
+ QStringList args;
+ foreach (const ArgumentModelItem &arg, functionItem->arguments())
+ args << arg->type().toString();
+ return functionItem->name() + QLatin1Char('(') + args.join(QLatin1Char(',')) + QLatin1Char(')');
+}
+
+static inline QString functionSignatureWithReturnType(FunctionModelItem functionItem)
+{
+ return functionSignature(functionItem)
+ + QStringLiteral(" -> ") + functionItem->type().toString();
+}
+
+static inline QString qualifiedFunctionSignatureWithType(const QString &className,
+ FunctionModelItem functionItem)
+{
+ return className + colonColon() + functionSignatureWithReturnType(functionItem);
+}
+
+AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(FunctionModelItem functionItem)
+{
+ QString functionName = functionItem->name();
+ QString className;
+ QString rejectedFunctionSignature;
+ if (m_currentClass)
+ className = m_currentClass->typeEntry()->qualifiedCppName();
+
+ if (TypeDatabase::instance()->isFunctionRejected(className, functionName)) {
+ rejectedFunctionSignature = qualifiedFunctionSignatureWithType(className, functionItem);
+ m_rejectedFunctions.insert(rejectedFunctionSignature, AbstractMetaBuilder::GenerationDisabled);
+ return 0;
+ }
+ else if (TypeDatabase::instance()->isFunctionRejected(className,
+ functionSignature(functionItem))) {
+ rejectedFunctionSignature = qualifiedFunctionSignatureWithType(className, functionItem);
+ m_rejectedFunctions.insert(rejectedFunctionSignature, AbstractMetaBuilder::GenerationDisabled);
+ return 0;
+ }
+
+ Q_ASSERT(functionItem->functionType() == CodeModel::Normal
+ || functionItem->functionType() == CodeModel::Signal
+ || functionItem->functionType() == CodeModel::Slot);
+
+ if (functionItem->isFriend())
+ return 0;
+
+ AbstractMetaFunction *metaFunction = q->createMetaFunction();
+ metaFunction->setConstant(functionItem->isConstant());
+
+ if (ReportHandler::isDebug(ReportHandler::MediumDebug))
+ qCDebug(lcShiboken).noquote().nospace() << " - " << functionName << "()";
+
+ metaFunction->setName(functionName);
+ metaFunction->setOriginalName(functionItem->name());
+
+ if (functionItem->isAbstract())
+ *metaFunction += AbstractMetaAttributes::Abstract;
+
+ if (!metaFunction->isAbstract())
+ *metaFunction += AbstractMetaAttributes::Native;
+
+ if (!functionItem->isVirtual())
+ *metaFunction += AbstractMetaAttributes::Final;
+
+ if (functionItem->isInvokable())
+ *metaFunction += AbstractMetaAttributes::Invokable;
+
+ if (functionItem->isStatic()) {
+ *metaFunction += AbstractMetaAttributes::Static;
+ *metaFunction += AbstractMetaAttributes::Final;
+ }
+
+ // Access rights
+ if (functionItem->accessPolicy() == CodeModel::Public)
+ *metaFunction += AbstractMetaAttributes::Public;
+ else if (functionItem->accessPolicy() == CodeModel::Private)
+ *metaFunction += AbstractMetaAttributes::Private;
+ else
+ *metaFunction += AbstractMetaAttributes::Protected;
+
+
+ QString strippedClassName = className;
+ int cc_pos = strippedClassName.lastIndexOf(colonColon());
+ if (cc_pos > 0)
+ strippedClassName = strippedClassName.mid(cc_pos + 2);
+
+ TypeInfo functionType = functionItem->type();
+ if (functionName.startsWith(QLatin1Char('~'))) {
+ metaFunction->setFunctionType(AbstractMetaFunction::DestructorFunction);
+ metaFunction->setInvalid(true);
+ } else if (stripTemplateArgs(functionName) == strippedClassName) {
+ metaFunction->setFunctionType(AbstractMetaFunction::ConstructorFunction);
+ // Check for Copy/Move down below
+ metaFunction->setExplicit(functionItem->isExplicit());
+ metaFunction->setName(m_currentClass->name());
+ } else {
+ bool ok;
+ AbstractMetaType* type = translateType(functionType, &ok);
+
+ if (!ok) {
+ Q_ASSERT(type == 0);
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("skipping function '%1::%2', unmatched return type '%3'")
+ .arg(className, functionItem->name(),
+ functionItem->type().toString());
+ rejectedFunctionSignature = qualifiedFunctionSignatureWithType(className, functionItem);
+ m_rejectedFunctions.insert(rejectedFunctionSignature, AbstractMetaBuilder::UnmatchedReturnType);
+ metaFunction->setInvalid(true);
+ return metaFunction;
+ }
+
+ metaFunction->setType(type);
+
+ if (functionItem->functionType() == CodeModel::Signal)
+ metaFunction->setFunctionType(AbstractMetaFunction::SignalFunction);
+ else if (functionItem->functionType() == CodeModel::Slot)
+ metaFunction->setFunctionType(AbstractMetaFunction::SlotFunction);
+ }
+
+ ArgumentList arguments = functionItem->arguments();
+
+ if (arguments.size() == 1) {
+ ArgumentModelItem arg = arguments.at(0);
+ TypeInfo type = arg->type();
+ if (type.qualifiedName().first() == QLatin1String("void") && type.indirections() == 0)
+ arguments.pop_front();
+ }
+
+ AbstractMetaArgumentList metaArguments;
+
+ for (int i = 0; i < arguments.size(); ++i) {
+ ArgumentModelItem arg = arguments.at(i);
+
+ bool ok;
+ AbstractMetaType* metaType = translateType(arg->type(), &ok);
+ if (!ok) {
+ Q_ASSERT(metaType == 0);
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("skipping function '%1::%2', unmatched parameter type '%3'")
+ .arg(className, functionItem->name(), arg->type().toString());
+ rejectedFunctionSignature = qualifiedFunctionSignatureWithType(className, functionItem);
+ m_rejectedFunctions.insert(rejectedFunctionSignature, AbstractMetaBuilder::UnmatchedArgumentType);
+ metaFunction->setInvalid(true);
+ return metaFunction;
+ }
+
+ if (metaType == Q_NULLPTR) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QString::fromLatin1("skipping function '%1::%2', 'void' encountered at parameter "
+ "position %3, but it can only be the the first and only "
+ "parameter")
+ .arg(className, functionItem->name()).arg(i);
+ rejectedFunctionSignature = qualifiedFunctionSignatureWithType(className, functionItem);
+ m_rejectedFunctions.insert(rejectedFunctionSignature, AbstractMetaBuilder::UnmatchedArgumentType);
+ metaFunction->setInvalid(true);
+ return metaFunction;
+ }
+
+ AbstractMetaArgument *metaArgument = q->createMetaArgument();
+
+ metaArgument->setType(metaType);
+ metaArgument->setName(arg->name());
+ metaArgument->setArgumentIndex(i);
+ metaArguments << metaArgument;
+ }
+
+ metaFunction->setArguments(metaArguments);
+
+ // Find the correct default values
+ for (int i = 0; i < arguments.size(); ++i) {
+ ArgumentModelItem arg = arguments.at(i);
+ AbstractMetaArgument* metaArg = metaArguments.at(i);
+
+ //use relace-default-expression for set default value
+ QString replacedExpression;
+ if (m_currentClass) {
+ replacedExpression = metaFunction->replacedDefaultExpression(m_currentClass, i + 1);
+ } else {
+ FunctionModificationList mods = TypeDatabase::instance()->functionModifications(metaFunction->minimalSignature());
+ if (!mods.isEmpty()) {
+ QList<ArgumentModification> argMods = mods.first().argument_mods;
+ if (!argMods.isEmpty())
+ replacedExpression = argMods.first().replacedDefaultExpression;
+ }
+ }
+
+ bool hasDefaultValue = false;
+ if (arg->defaultValue() || !replacedExpression.isEmpty()) {
+ QString expr = arg->defaultValueExpression();
+ expr = fixDefaultValue(arg, metaArg->type(), metaFunction, m_currentClass, i);
+ metaArg->setOriginalDefaultValueExpression(expr);
+
+ if (metaFunction->removedDefaultExpression(m_currentClass, i + 1)) {
+ expr.clear();
+ } else if (!replacedExpression.isEmpty()) {
+ expr = replacedExpression;
+ }
+ metaArg->setDefaultValueExpression(expr);
+
+ if (metaArg->type()->isEnum() || metaArg->type()->isFlags())
+ m_enumDefaultArguments << QPair<AbstractMetaArgument *, AbstractMetaFunction *>(metaArg, metaFunction);
+
+ hasDefaultValue = !expr.isEmpty();
+ }
+
+ //Check for missing argument name
+ if (hasDefaultValue
+ && !metaArg->hasName()
+ && !metaFunction->isOperatorOverload()
+ && !metaFunction->isSignal()
+ && metaFunction->argumentName(i+1, false, m_currentClass).isEmpty()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Argument %1 on function '%2::%3' has default expression but does not have name.")
+ .arg(i+1).arg(className, metaFunction->minimalSignature());
+ }
+
+ }
+
+ fixArgumentNames(metaFunction);
+
+ // Determine class special functions
+ if (m_currentClass && metaFunction->arguments().size() == 1) {
+ const AbstractMetaType *argType = metaFunction->arguments().first()->type();
+ if (argType->typeEntry() == m_currentClass->typeEntry() && argType->indirections() == 0) {
+ if (metaFunction->isConstructor()) {
+ switch (argType->referenceType()) {
+ case NoReference:
+ metaFunction->setFunctionType(AbstractMetaFunction::CopyConstructorFunction);
+ break;
+ case LValueReference:
+ if (argType->isConstant())
+ metaFunction->setFunctionType(AbstractMetaFunction::CopyConstructorFunction);
+ break;
+ case RValueReference:
+ metaFunction->setFunctionType(AbstractMetaFunction::MoveConstructorFunction);
+ break;
+ }
+ } else if (metaFunction->name() == QLatin1String("operator=")) {
+ switch (argType->referenceType()) {
+ case NoReference:
+ metaFunction->setFunctionType(AbstractMetaFunction::AssignmentOperatorFunction);
+ break;
+ case LValueReference:
+ if (argType->isConstant())
+ metaFunction->setFunctionType(AbstractMetaFunction::AssignmentOperatorFunction);
+ break;
+ case RValueReference:
+ metaFunction->setFunctionType(AbstractMetaFunction::MoveAssignmentOperatorFunction);
+ break;
+ }
+ }
+ }
+ }
+ return metaFunction;
+}
+
+AbstractMetaType *AbstractMetaBuilderPrivate::translateType(double vr,
+ const AddedFunction::TypeInfo &typeInfo)
+{
+ Q_ASSERT(!typeInfo.name.isEmpty());
+ TypeDatabase* typeDb = TypeDatabase::instance();
+ TypeEntry* type;
+
+ QString typeName = typeInfo.name;
+
+ if (typeName == QLatin1String("void"))
+ return 0;
+
+ type = typeDb->findType(typeName);
+
+ // test if the type is a template, like a container
+ bool isTemplate = false;
+ QStringList templateArgs;
+ if (!type && typeInfo.name.contains(QLatin1Char('<'))) {
+ const QStringList& parsedType = parseTemplateType(typeInfo.name);
+ if (parsedType.isEmpty()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Template type parsing failed for '%1'").arg(typeInfo.name);
+ } else {
+ templateArgs = parsedType.mid(1);
+ isTemplate = (type = typeDb->findContainerType(parsedType[0]));
+ }
+ }
+
+ if (!type) {
+ QStringList candidates;
+ SingleTypeEntryHash entries = typeDb->entries();
+ for (SingleTypeEntryHash::const_iterator it = entries.cbegin(), end = entries.cend(); it != end; ++it) {
+ // Let's try to find the type in different scopes.
+ if (it.key().endsWith(colonColon() + typeName))
+ candidates.append(it.key());
+ }
+
+ QString msg = QStringLiteral("Type '%1' wasn't found in the type database.\n").arg(typeName);
+
+ if (candidates.isEmpty())
+ qFatal(qPrintable(QString(msg + QLatin1String("Declare it in the type system using the proper <*-type> tag."))), NULL);
+
+ msg += QLatin1String("Remember to inform the full qualified name for the type you want to use.\nCandidates are:\n");
+ candidates.sort();
+ foreach (const QString& candidate, candidates) {
+ msg += QLatin1String(" ") + candidate + QLatin1Char('\n');
+ }
+ qFatal(qPrintable(msg), NULL);
+ }
+
+ AbstractMetaType *metaType = q->createMetaType();
+ metaType->setTypeEntry(type);
+ metaType->setIndirections(typeInfo.indirections);
+ if (typeInfo.isReference)
+ metaType->setReferenceType(LValueReference);
+ metaType->setConstant(typeInfo.isConstant);
+ if (isTemplate) {
+ foreach (const QString& templateArg, templateArgs) {
+ AbstractMetaType* metaArgType = translateType(vr, AddedFunction::TypeInfo::fromSignature(templateArg));
+ metaType->addInstantiation(metaArgType);
+ }
+ metaType->setTypeUsagePattern(AbstractMetaType::ContainerPattern);
+ }
+
+ return metaType;
+}
+
+static const TypeEntry* findTypeEntryUsingContext(const AbstractMetaClass* metaClass, const QString& qualifiedName)
+{
+ const TypeEntry* type = 0;
+ QStringList context = metaClass->qualifiedCppName().split(colonColon());
+ while(!type && (context.size() > 0) ) {
+ type = TypeDatabase::instance()->findType(context.join(colonColon()) + colonColon() + qualifiedName);
+ context.removeLast();
+ }
+ return type;
+}
+
+AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const TypeInfo &_typei,
+ bool *ok, bool resolveType,
+ bool resolveScope)
+{
+ Q_ASSERT(ok);
+ *ok = true;
+
+ // 1. Test the type info without resolving typedefs in case this is present in the
+ // type system
+ TypeInfo typei;
+ if (resolveType) {
+ bool ok;
+ AbstractMetaType* t = translateType(_typei, &ok, false, resolveScope);
+ if (t && ok)
+ return t;
+ Q_ASSERT(t == 0);
+ }
+
+ if (!resolveType) {
+ typei = _typei;
+ } else {
+ // Go through all parts of the current scope (including global namespace)
+ // to resolve typedefs. The parser does not properly resolve typedefs in
+ // the global scope when they are referenced from inside a namespace.
+ // This is a work around to fix this bug since fixing it in resolveType
+ // seemed non-trivial
+ int i = m_scopes.size() - 1;
+ while (i >= 0) {
+ typei = TypeInfo::resolveType(_typei, m_scopes.at(i--));
+ if (typei.qualifiedName().join(colonColon()) != _typei.qualifiedName().join(colonColon()))
+ break;
+ }
+
+ }
+
+ if (typei.isFunctionPointer()) {
+ *ok = false;
+ return 0;
+ }
+
+ QString errorMessage;
+ TypeParser::Info typeInfo = TypeParser::parse(typei.toString(), &errorMessage);
+ if (typeInfo.is_busted) {
+ qWarning().noquote().nospace() << "Unable to translate type \"" << _typei.toString()
+ << "\": " << errorMessage;
+ *ok = false;
+ return 0;
+ }
+
+ // 2. Handle pointers specified as arrays with unspecified size
+ bool arrayOfUnspecifiedSize = false;
+ if (typeInfo.arrays.size() > 0) {
+ arrayOfUnspecifiedSize = true;
+ for (int i = 0; i < typeInfo.arrays.size(); ++i)
+ arrayOfUnspecifiedSize = arrayOfUnspecifiedSize && typeInfo.arrays.at(i).isEmpty();
+
+ if (!arrayOfUnspecifiedSize) {
+ TypeInfo newInfo;
+ //newInfo.setArguments(typei.arguments());
+ newInfo.setIndirections(typei.indirections());
+ newInfo.setConstant(typei.isConstant());
+ newInfo.setFunctionPointer(typei.isFunctionPointer());
+ newInfo.setQualifiedName(typei.qualifiedName());
+ newInfo.setReferenceType(typei.referenceType());
+ newInfo.setVolatile(typei.isVolatile());
+
+ AbstractMetaType* elementType = translateType(newInfo, ok);
+ if (!(*ok))
+ return 0;
+
+ for (int i = typeInfo.arrays.size() - 1; i >= 0; --i) {
+ QString s = typeInfo.arrays.at(i);
+ bool _ok;
+ int elems = findOutValueFromString(s, _ok);
+
+ AbstractMetaType *arrayType = q->createMetaType();
+ arrayType->setArrayElementCount(elems);
+ arrayType->setArrayElementType(elementType);
+ arrayType->setTypeEntry(new ArrayTypeEntry(elementType->typeEntry() , elementType->typeEntry()->version()));
+ decideUsagePattern(arrayType);
+
+ elementType = arrayType;
+ }
+
+ return elementType;
+ } else {
+ typeInfo.indirections += typeInfo.arrays.size();
+ }
+ }
+
+ QStringList qualifierList = typeInfo.qualified_name;
+ if (qualifierList.isEmpty()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("horribly broken type '%1'").arg(_typei.toString());
+ *ok = false;
+ return 0;
+ }
+
+ QString qualifiedName = qualifierList.join(colonColon());
+ QString name = qualifierList.takeLast();
+
+ // 3. Special case 'void' type
+ if (name == QLatin1String("void") && !typeInfo.indirections)
+ return 0;
+
+ // 4. Special case QFlags (include instantiation in name)
+ if (qualifiedName == QLatin1String("QFlags"))
+ qualifiedName = typeInfo.toString();
+
+ const TypeEntry *type = 0;
+ // 5. Try to find the type
+
+ // 5.1 - Try first using the current scope
+ if (m_currentClass) {
+ type = findTypeEntryUsingContext(m_currentClass, qualifiedName);
+
+ // 5.1.1 - Try using the class parents' scopes
+ if (!type && !m_currentClass->baseClassNames().isEmpty()) {
+ foreach (const AbstractMetaClass* cls, getBaseClasses(m_currentClass)) {
+ type = findTypeEntryUsingContext(cls, qualifiedName);
+ if (type)
+ break;
+ }
+ }
+ }
+
+ // 5.2 - Try without scope
+ if (!type)
+ type = TypeDatabase::instance()->findType(qualifiedName);
+
+ // 6. No? Try looking it up as a flags type
+ if (!type)
+ type = TypeDatabase::instance()->findFlagsType(qualifiedName);
+
+ // 7. No? Try looking it up as a container type
+ if (!type)
+ type = TypeDatabase::instance()->findContainerType(name);
+
+ // 8. No? Check if the current class is a template and this type is one
+ // of the parameters.
+ if (!type && m_currentClass) {
+ QList<TypeEntry *> template_args = m_currentClass->templateArguments();
+ foreach (TypeEntry *te, template_args) {
+ if (te->name() == qualifiedName)
+ type = te;
+ }
+ }
+
+ // 9. Try finding the type by prefixing it with the current
+ // context and all baseclasses of the current context
+ if (!type && !TypeDatabase::instance()->isClassRejected(qualifiedName) && m_currentClass && resolveScope) {
+ QStringList contexts;
+ contexts.append(m_currentClass->qualifiedCppName());
+ contexts.append(currentScope()->qualifiedName().join(colonColon()));
+
+
+ TypeInfo info = typei;
+ bool subclassesDone = false;
+ while (!contexts.isEmpty() && !type) {
+ type = TypeDatabase::instance()->findType(contexts.at(0) + colonColon() + qualifiedName);
+ contexts.pop_front();
+
+ // 10. Last resort: Special cased prefix of Qt namespace since the meta object implicitly inherits this, so
+ // enum types from there may be addressed without any scope resolution in properties.
+ if (!contexts.size() && !subclassesDone) {
+ contexts << QLatin1String("Qt");
+ subclassesDone = true;
+ }
+ }
+
+ }
+
+ if (!type) {
+ *ok = false;
+ return 0;
+ }
+
+ // Used to for diagnostics later...
+ m_usedTypes << type;
+
+ // These are only implicit and should not appear in code...
+ Q_ASSERT(!type->isInterface());
+
+ AbstractMetaType *metaType = q->createMetaType();
+ metaType->setTypeEntry(type);
+ metaType->setIndirections(typeInfo.indirections);
+ metaType->setReferenceType(typeInfo.referenceType);
+ metaType->setConstant(typeInfo.is_constant);
+ metaType->setOriginalTypeDescription(_typei.toString());
+
+ foreach (const TypeParser::Info &ta, typeInfo.template_instantiations) {
+ TypeInfo info;
+ info.setConstant(ta.is_constant);
+ info.setReferenceType(ta.referenceType);
+ info.setIndirections(ta.indirections);
+
+ info.setFunctionPointer(false);
+ info.setQualifiedName(ta.instantiationName().split(colonColon()));
+
+ AbstractMetaType* targType = translateType(info, ok);
+ if (!(*ok)) {
+ delete metaType;
+ return 0;
+ }
+
+ metaType->addInstantiation(targType, true);
+ }
+
+ // The usage pattern *must* be decided *after* the possible template
+ // instantiations have been determined, or else the absence of
+ // such instantiations will break the caching scheme of
+ // AbstractMetaType::cppSignature().
+ decideUsagePattern(metaType);
+
+ return metaType;
+}
+
+
+int AbstractMetaBuilderPrivate::findOutValueFromString(const QString &stringValue, bool &ok)
+{
+ int value = stringValue.toInt(&ok);
+ if (ok)
+ return value;
+
+ if (stringValue == QLatin1String("true") || stringValue == QLatin1String("false")) {
+ ok = true;
+ return (stringValue == QLatin1String("true"));
+ }
+
+ // This is a very lame way to handle expression evaluation,
+ // but it is not critical and will do for the time being.
+ static QRegExp variableNameRegExp(QLatin1String("^[a-zA-Z_][a-zA-Z0-9_]*$"));
+ if (!variableNameRegExp.exactMatch(stringValue)) {
+ ok = true;
+ return 0;
+ }
+
+ AbstractMetaEnumValue *enumValue = AbstractMetaClass::findEnumValue(m_metaClasses, stringValue);
+ if (enumValue) {
+ ok = true;
+ return enumValue->value();
+ }
+
+ foreach (AbstractMetaEnum* metaEnum, m_globalEnums) {
+ foreach (AbstractMetaEnumValue* ev, metaEnum->values()) {
+ if (ev->name() == stringValue) {
+ ok = true;
+ return ev->value();
+ }
+ }
+ }
+
+ ok = false;
+ return 0;
+}
+
+void AbstractMetaBuilderPrivate::decideUsagePattern(AbstractMetaType *metaType)
+{
+ metaType->decideUsagePattern();
+}
+
+QString AbstractMetaBuilderPrivate::fixDefaultValue(ArgumentModelItem item,
+ AbstractMetaType *type,
+ AbstractMetaFunction *fnc,
+ AbstractMetaClass *implementingClass,
+ int /* argumentIndex */)
+{
+ QString functionName = fnc->name();
+ QString className = implementingClass ? implementingClass->qualifiedCppName() : QString();
+
+ QString expr = item->defaultValueExpression();
+ if (type) {
+ if (type->isPrimitive()) {
+ if (type->name() == QLatin1String("boolean")) {
+ if (expr != QLatin1String("false") && expr != QLatin1String("true")) {
+ bool ok = false;
+ int number = expr.toInt(&ok);
+ if (ok && number)
+ expr = QLatin1String("true");
+ else
+ expr = QLatin1String("false");
+ }
+ } else {
+ // This can be an enum or flag so I need to delay the
+ // translation untill all namespaces are completly
+ // processed. This is done in figureOutEnumValues()
+ }
+ } else if (type->isFlags() || type->isEnum()) {
+ bool isNumber;
+ expr.toInt(&isNumber);
+ if (!isNumber && expr.indexOf(colonColon()) < 0) {
+ // Add the enum/flag scope to default value, making it usable
+ // from other contexts beside its owner class hierarchy
+ QRegExp typeRegEx(QLatin1String("[^<]*[<]([^:]*::).*"));
+ typeRegEx.indexIn(type->minimalSignature());
+ expr = typeRegEx.cap(1) + expr;
+ }
+ } else if (type->isContainer() && expr.contains(QLatin1Char('<'))) {
+ QRegExp typeRegEx(QLatin1String("[^<]*<(.*)>"));
+ typeRegEx.indexIn(type->minimalSignature());
+ QRegExp defaultRegEx(QLatin1String("([^<]*<).*(>[^>]*)"));
+ defaultRegEx.indexIn(expr);
+ expr = defaultRegEx.cap(1) + typeRegEx.cap(1) + defaultRegEx.cap(2);
+ } else {
+ // Here the default value is supposed to be a constructor,
+ // a class field, or a constructor receiving a class field
+ QRegExp defaultRegEx(QLatin1String("([^\\(]*\\(|)([^\\)]*)(\\)|)"));
+ defaultRegEx.indexIn(expr);
+
+ QString defaultValueCtorName = defaultRegEx.cap(1);
+ if (defaultValueCtorName.endsWith(QLatin1Char('(')))
+ defaultValueCtorName.chop(1);
+
+ // Fix the scope for constructor using the already
+ // resolved argument type as a reference.
+ // The following regular expression extracts any
+ // use of namespaces/scopes from the type string.
+ QRegExp typeRegEx(QLatin1String("^(?:const[\\s]+|)([\\w:]*::|)([A-Za-z_]\\w*)\\s*[&\\*]?$"));
+ typeRegEx.indexIn(type->minimalSignature());
+
+ QString typeNamespace = typeRegEx.cap(1);
+ QString typeCtorName = typeRegEx.cap(2);
+ if (!typeNamespace.isEmpty() && defaultValueCtorName == typeCtorName)
+ expr.prepend(typeNamespace);
+
+ // Fix scope if the parameter is a field of the current class
+ if (implementingClass) {
+ foreach (const AbstractMetaField* field, implementingClass->fields()) {
+ if (defaultRegEx.cap(2) == field->name()) {
+ expr = defaultRegEx.cap(1) + implementingClass->name()
+ + colonColon() + defaultRegEx.cap(2) + defaultRegEx.cap(3);
+ break;
+ }
+ }
+ }
+ }
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("undefined type for default value '%3' of argument in function '%1', class '%2'")
+ .arg(functionName, className, item->defaultValueExpression());
+
+ expr = QString();
+ }
+
+ return expr;
+}
+
+bool AbstractMetaBuilderPrivate::isQObject(const FileModelItem &dom, const QString &qualifiedName)
+{
+ if (qualifiedName == QLatin1String("QObject"))
+ return true;
+
+ ClassModelItem classItem = dom->findClass(qualifiedName);
+
+ if (!classItem) {
+ QStringList names = qualifiedName.split(colonColon());
+ NamespaceModelItem ns = dom;
+ for (int i = 0; i < names.size() - 1 && ns; ++i)
+ ns = ns->findNamespace(names.at(i));
+ if (ns && names.size() >= 2)
+ classItem = ns->findClass(names.at(names.size() - 1));
+ }
+
+ bool isqobject = classItem && classItem->extendsClass(QLatin1String("QObject"));
+
+ if (classItem && !isqobject) {
+ QStringList baseClasses = classItem->baseClasses();
+ for (int i = 0; i < baseClasses.count(); ++i) {
+
+ isqobject = isQObject(dom, baseClasses.at(i));
+ if (isqobject)
+ break;
+ }
+ }
+
+ return isqobject;
+}
+
+
+bool AbstractMetaBuilderPrivate::isEnum(const FileModelItem &dom, const QStringList& qualified_name)
+{
+ CodeModelItem item = dom->model()->findItem(qualified_name, dom);
+ return item && item->kind() == _EnumModelItem::__node_kind;
+}
+
+AbstractMetaClass* AbstractMetaBuilderPrivate::findTemplateClass(const QString &name,
+ const AbstractMetaClass *context,
+ TypeParser::Info *info,
+ ComplexTypeEntry **baseContainerType) const
+{
+ TypeParser::Info localInfo;
+ if (!info)
+ info = &localInfo;
+
+ TypeDatabase* types = TypeDatabase::instance();
+
+ QStringList scope = context->typeEntry()->qualifiedCppName().split(colonColon());
+ QString errorMessage;
+ scope.removeLast();
+ for (int i = scope.size(); i >= 0; --i) {
+ QString prefix = i > 0 ? QStringList(scope.mid(0, i)).join(colonColon()) + colonColon() : QString();
+ QString completeName = prefix + name;
+ const TypeParser::Info parsed = TypeParser::parse(completeName, &errorMessage);
+ if (parsed.is_busted) {
+ qWarning().noquote().nospace() << "Unable to parse type \"" << completeName
+ << "\" while looking for template \"" << name << "\": " << errorMessage;
+ continue;
+ }
+ *info = parsed;
+ QString qualifiedName = info->qualified_name.join(colonColon());
+
+ AbstractMetaClass* templ = 0;
+ foreach (AbstractMetaClass *c, m_templates) {
+ if (c->typeEntry()->name() == qualifiedName) {
+ templ = c;
+ break;
+ }
+ }
+
+ if (!templ)
+ templ = AbstractMetaClass::findClass(m_metaClasses, qualifiedName);
+
+ if (templ)
+ return templ;
+
+ if (baseContainerType)
+ *baseContainerType = types->findContainerType(qualifiedName);
+ }
+
+ return 0;
+}
+
+AbstractMetaClassList AbstractMetaBuilderPrivate::getBaseClasses(const AbstractMetaClass *metaClass) const
+{
+ AbstractMetaClassList baseClasses;
+ foreach (const QString& parent, metaClass->baseClassNames()) {
+ AbstractMetaClass* cls = 0;
+ if (parent.contains(QLatin1Char('<')))
+ cls = findTemplateClass(parent, metaClass);
+ else
+ cls = AbstractMetaClass::findClass(m_metaClasses, parent);
+
+ if (cls)
+ baseClasses << cls;
+ }
+ return baseClasses;
+}
+
+bool AbstractMetaBuilderPrivate::ancestorHasPrivateCopyConstructor(const AbstractMetaClass *metaClass) const
+{
+ if (metaClass->hasPrivateCopyConstructor())
+ return true;
+ foreach (const AbstractMetaClass* cls, getBaseClasses(metaClass)) {
+ if (ancestorHasPrivateCopyConstructor(cls))
+ return true;
+ }
+ return false;
+}
+
+AbstractMetaType* AbstractMetaBuilderPrivate::inheritTemplateType(const QList<AbstractMetaType *> &templateTypes,
+ const AbstractMetaType *metaType,
+ bool *ok)
+{
+ if (ok)
+ *ok = true;
+ if (!metaType || (!metaType->typeEntry()->isTemplateArgument() && !metaType->hasInstantiations()))
+ return metaType ? metaType->copy() : 0;
+
+ AbstractMetaType *returned = metaType->copy();
+ returned->setOriginalTemplateType(metaType->copy());
+
+ if (returned->typeEntry()->isTemplateArgument()) {
+ const TemplateArgumentEntry* tae = static_cast<const TemplateArgumentEntry*>(returned->typeEntry());
+
+ // If the template is intantiated with void we special case this as rejecting the functions that use this
+ // parameter from the instantiation.
+ if (templateTypes.size() <= tae->ordinal() || templateTypes.at(tae->ordinal())->typeEntry()->name() == QLatin1String("void")) {
+ if (ok)
+ *ok = false;
+ return 0;
+ }
+
+ AbstractMetaType* t = returned->copy();
+ t->setTypeEntry(templateTypes.at(tae->ordinal())->typeEntry());
+ t->setIndirections(templateTypes.at(tae->ordinal())->indirections() + t->indirections() ? 1 : 0);
+ decideUsagePattern(t);
+
+ delete returned;
+ returned = inheritTemplateType(templateTypes, t, ok);
+ if (ok && !(*ok))
+ return 0;
+ }
+
+ if (returned->hasInstantiations()) {
+ AbstractMetaTypeList instantiations = returned->instantiations();
+ for (int i = 0; i < instantiations.count(); ++i) {
+ AbstractMetaType *type = instantiations[i];
+ instantiations[i] = inheritTemplateType(templateTypes, type, ok);
+ if (ok && !(*ok))
+ return 0;
+ }
+ returned->setInstantiations(instantiations, true);
+ }
+
+ return returned;
+}
+
+bool AbstractMetaBuilderPrivate::inheritTemplate(AbstractMetaClass *subclass,
+ const AbstractMetaClass *templateClass,
+ const TypeParser::Info &info)
+{
+ QList<TypeParser::Info> targs = info.template_instantiations;
+ QList<AbstractMetaType*> templateTypes;
+
+ if (subclass->isTypeDef()) {
+ subclass->setHasCloneOperator(templateClass->hasCloneOperator());
+ subclass->setHasEqualsOperator(templateClass->hasEqualsOperator());
+ subclass->setHasHashFunction(templateClass->hasHashFunction());
+ subclass->setHasNonPrivateConstructor(templateClass->hasNonPrivateConstructor());
+ subclass->setHasPrivateDestructor(templateClass->hasPrivateDestructor());
+ subclass->setHasProtectedDestructor(templateClass->hasProtectedDestructor());
+ subclass->setHasVirtualDestructor(templateClass->hasVirtualDestructor());
+ }
+
+ foreach (const TypeParser::Info &i, targs) {
+ QString typeName = i.qualified_name.join(colonColon());
+ QStringList possibleNames;
+ possibleNames << subclass->qualifiedCppName() + colonColon() + typeName;
+ possibleNames << templateClass->qualifiedCppName() + colonColon() + typeName;
+ if (subclass->enclosingClass())
+ possibleNames << subclass->enclosingClass()->qualifiedCppName() + colonColon() + typeName;
+ possibleNames << typeName;
+
+ TypeDatabase* typeDb = TypeDatabase::instance();
+ TypeEntry* t = 0;
+ QString templateParamName;
+ foreach (const QString &possibleName, possibleNames) {
+ t = typeDb->findType(possibleName);
+ if (t) {
+ QString templateParamName = possibleName;
+ break;
+ }
+ }
+
+ if (t) {
+ AbstractMetaType *temporaryType = q->createMetaType();
+ temporaryType->setTypeEntry(t);
+ temporaryType->setConstant(i.is_constant);
+ temporaryType->setReferenceType(i.referenceType);
+ temporaryType->setIndirections(i.indirections);
+ temporaryType->decideUsagePattern();
+ templateTypes << temporaryType;
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Ignoring template parameter " << templateParamName << " from "
+ << info.instantiationName() << ", because I don't know what it is.";
+ }
+ }
+
+ AbstractMetaFunctionList funcs = subclass->functions();
+ foreach (const AbstractMetaFunction* function, templateClass->functions()) {
+ if (function->isModifiedRemoved(TypeSystem::All))
+ continue;
+
+ AbstractMetaFunction *f = function->copy();
+ f->setArguments(AbstractMetaArgumentList());
+
+ bool ok = true;
+ AbstractMetaType *ftype = function->type();
+ f->replaceType(inheritTemplateType(templateTypes, ftype, &ok));
+ if (!ok) {
+ delete f;
+ continue;
+ }
+
+ foreach (AbstractMetaArgument* argument, function->arguments()) {
+ AbstractMetaType* atype = argument->type();
+
+ AbstractMetaArgument *arg = argument->copy();
+ arg->replaceType(inheritTemplateType(templateTypes, atype, &ok));
+ if (!ok)
+ break;
+ f->addArgument(arg);
+ }
+
+ if (!ok) {
+ delete f;
+ continue;
+ }
+
+ // There is no base class in the target language to inherit from here, so
+ // the template instantiation is the class that implements the function.
+ f->setImplementingClass(subclass);
+
+ // We also set it as the declaring class, since the superclass is
+ // supposed to disappear. This allows us to make certain function modifications
+ // on the inherited functions.
+ f->setDeclaringClass(subclass);
+
+
+ if (f->isConstructor() && subclass->isTypeDef()) {
+ f->setName(subclass->name());
+ f->setOriginalName(subclass->name());
+ } else if (f->isConstructor()) {
+ delete f;
+ continue;
+ }
+
+ // if the instantiation has a function named the same as an existing
+ // function we have shadowing so we need to skip it.
+ bool found = false;
+ for (int i = 0; i < funcs.size(); ++i) {
+ if (funcs.at(i)->name() == f->name()) {
+ found = true;
+ continue;
+ }
+ }
+ if (found) {
+ delete f;
+ continue;
+ }
+
+ ComplexTypeEntry* te = subclass->typeEntry();
+ FunctionModificationList mods = function->modifications(templateClass);
+ for (int i = 0; i < mods.size(); ++i) {
+ FunctionModification mod = mods.at(i);
+ mod.signature = f->minimalSignature();
+
+ // If we ever need it... Below is the code to do
+ // substitution of the template instantation type inside
+ // injected code..
+#if 0
+ if (mod.modifiers & Modification::CodeInjection) {
+ for (int j = 0; j < template_types.size(); ++j) {
+ CodeSnip &snip = mod.snips.last();
+ QString code = snip.code();
+ code.replace(QString::fromLatin1("$$QT_TEMPLATE_%1$$").arg(j),
+ template_types.at(j)->typeEntry()->qualifiedCppName());
+ snip.codeList.clear();
+ snip.addCode(code);
+ }
+ }
+#endif
+ te->addFunctionModification(mod);
+ }
+
+ subclass->addFunction(f);
+ }
+
+ subclass->setTemplateBaseClass(templateClass);
+ subclass->setTemplateBaseClassInstantiations(templateTypes);
+ subclass->setInterfaces(templateClass->interfaces());
+ subclass->setBaseClass(templateClass->baseClass());
+
+ return true;
+}
+
+void AbstractMetaBuilderPrivate::parseQ_Property(AbstractMetaClass *metaClass,
+ const QStringList &declarations)
+{
+ for (int i = 0; i < declarations.size(); ++i) {
+ QString p = declarations.at(i);
+
+ QStringList l = p.split(QLatin1String(" "));
+
+
+ QStringList qualifiedScopeName = currentScope()->qualifiedName();
+ bool ok = false;
+ AbstractMetaType* type = 0;
+ QString scope;
+ for (int j = qualifiedScopeName.size(); j >= 0; --j) {
+ scope = j > 0 ? QStringList(qualifiedScopeName.mid(0, j)).join(colonColon()) + colonColon() : QString();
+ TypeInfo info;
+ info.setQualifiedName((scope + l.at(0)).split(colonColon()));
+
+ type = translateType(info, &ok);
+ if (type && ok)
+ break;
+ }
+
+ if (!type || !ok) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Unable to decide type of property: '%1' in class '%2'")
+ .arg(l.at(0), metaClass->name());
+ continue;
+ }
+
+ QString typeName = scope + l.at(0);
+
+ QPropertySpec* spec = new QPropertySpec(type->typeEntry());
+ spec->setName(l.at(1));
+ spec->setIndex(i);
+
+ for (int pos = 2; pos + 1 < l.size(); pos += 2) {
+ if (l.at(pos) == QLatin1String("READ"))
+ spec->setRead(l.at(pos + 1));
+ else if (l.at(pos) == QLatin1String("WRITE"))
+ spec->setWrite(l.at(pos + 1));
+ else if (l.at(pos) == QLatin1String("DESIGNABLE"))
+ spec->setDesignable(l.at(pos + 1));
+ else if (l.at(pos) == QLatin1String("RESET"))
+ spec->setReset(l.at(pos + 1));
+ }
+
+ metaClass->addPropertySpec(spec);
+ delete type;
+ }
+}
+
+static AbstractMetaFunction* findCopyCtor(AbstractMetaClass* cls)
+{
+ AbstractMetaFunctionList functions = cls->queryFunctions(AbstractMetaClass::Invisible);
+ functions << cls->queryFunctions(AbstractMetaClass::Visible);
+
+ foreach (AbstractMetaFunction* f, functions) {
+ const AbstractMetaFunction::FunctionType t = f->functionType();
+ if (t == AbstractMetaFunction::CopyConstructorFunction || t == AbstractMetaFunction::AssignmentOperatorFunction)
+ return f;
+ }
+ return 0;
+}
+
+void AbstractMetaBuilderPrivate::setupClonable(AbstractMetaClass *cls)
+{
+ bool result = true;
+
+ // find copy ctor for the current class
+ AbstractMetaFunction* copyCtor = findCopyCtor(cls);
+ if (copyCtor) { // if exists a copy ctor in this class
+ result = copyCtor->isPublic();
+ } else { // else... lets find one in the parent class
+ QQueue<AbstractMetaClass*> baseClasses;
+ if (cls->baseClass())
+ baseClasses.enqueue(cls->baseClass());
+ baseClasses << cls->interfaces();
+
+ while (!baseClasses.isEmpty()) {
+ AbstractMetaClass* currentClass = baseClasses.dequeue();
+ baseClasses << currentClass->interfaces();
+ if (currentClass->baseClass())
+ baseClasses.enqueue(currentClass->baseClass());
+
+ copyCtor = findCopyCtor(currentClass);
+ if (copyCtor) {
+ result = copyCtor->isPublic();
+ break;
+ }
+ }
+ }
+ cls->setHasCloneOperator(result);
+}
+
+void AbstractMetaBuilderPrivate::setupExternalConversion(AbstractMetaClass *cls)
+{
+ AbstractMetaFunctionList convOps = cls->operatorOverloads(AbstractMetaClass::ConversionOp);
+ foreach (AbstractMetaFunction* func, convOps) {
+ if (func->isModifiedRemoved())
+ continue;
+ AbstractMetaClass *metaClass = AbstractMetaClass::findClass(m_metaClasses, func->type()->typeEntry());
+ if (!metaClass)
+ continue;
+ metaClass->addExternalConversionOperator(func);
+ }
+ foreach (AbstractMetaClass* innerClass, cls->innerClasses())
+ setupExternalConversion(innerClass);
+}
+
+static void writeRejectLogFile(const QString &name,
+ const QMap<QString, AbstractMetaBuilder::RejectReason> &rejects)
+{
+ QFile f(name);
+ if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("failed to write log file: '%1'")
+ .arg(QDir::toNativeSeparators(f.fileName()));
+ return;
+ }
+
+ QTextStream s(&f);
+
+
+ for (int reason = 0; reason < AbstractMetaBuilder::NoReason; ++reason) {
+ s << QString(72, QLatin1Char('*')) << endl;
+ switch (reason) {
+ case AbstractMetaBuilder::NotInTypeSystem:
+ s << "Not in type system";
+ break;
+ case AbstractMetaBuilder::GenerationDisabled:
+ s << "Generation disabled by type system";
+ break;
+ case AbstractMetaBuilder::RedefinedToNotClass:
+ s << "Type redefined to not be a class";
+ break;
+
+ case AbstractMetaBuilder::UnmatchedReturnType:
+ s << "Unmatched return type";
+ break;
+
+ case AbstractMetaBuilder::UnmatchedArgumentType:
+ s << "Unmatched argument type";
+ break;
+
+ case AbstractMetaBuilder::ApiIncompatible:
+ s << "Incompatible API";
+ break;
+
+ default:
+ s << "unknown reason";
+ break;
+ }
+
+ s << endl;
+
+ for (QMap<QString, AbstractMetaBuilder::RejectReason>::const_iterator it = rejects.constBegin();
+ it != rejects.constEnd(); ++it) {
+ if (it.value() != reason)
+ continue;
+ s << " - " << it.key() << endl;
+ }
+
+ s << QString(72, QLatin1Char('*')) << endl << endl;
+ }
+
+}
+
+void AbstractMetaBuilderPrivate::dumpLog() const
+{
+ writeRejectLogFile(m_logDirectory + QLatin1String("mjb_rejected_classes.log"), m_rejectedClasses);
+ writeRejectLogFile(m_logDirectory + QLatin1String("mjb_rejected_enums.log"), m_rejectedEnums);
+ writeRejectLogFile(m_logDirectory + QLatin1String("mjb_rejected_functions.log"), m_rejectedFunctions);
+ writeRejectLogFile(m_logDirectory + QLatin1String("mjb_rejected_fields.log"), m_rejectedFields);
+}
+
+AbstractMetaClassList AbstractMetaBuilderPrivate::classesTopologicalSorted(const AbstractMetaClass *cppClass,
+ const Dependencies &additionalDependencies) const
+{
+ QLinkedList<int> unmappedResult;
+ QHash<QString, int> map;
+ QHash<int, AbstractMetaClass*> reverseMap;
+
+ const AbstractMetaClassList& classList = cppClass ? cppClass->innerClasses() : m_metaClasses;
+
+ int i = 0;
+ foreach (AbstractMetaClass* clazz, classList) {
+ if (map.contains(clazz->qualifiedCppName()))
+ continue;
+ map[clazz->qualifiedCppName()] = i;
+ reverseMap[i] = clazz;
+ i++;
+ }
+
+ Graph graph(map.count());
+
+ foreach (const Dependency &dep, additionalDependencies) {
+ const int parentIndex = map.value(dep.parent, -1);
+ const int childIndex = map.value(dep.child, -1);
+ if (parentIndex >= 0 && childIndex >= 0) {
+ graph.addEdge(parentIndex, childIndex);
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "AbstractMetaBuilder::classesTopologicalSorted(): Invalid additional dependency: "
+ << dep.child << " -> " << dep.parent << '.';
+ }
+ }
+
+ // TODO choose a better name to these regexs
+ QRegExp regex1(QLatin1String("\\(.*\\)"));
+ QRegExp regex2(QLatin1String("::.*"));
+ foreach (AbstractMetaClass* clazz, classList) {
+ if (clazz->enclosingClass() && map.contains(clazz->enclosingClass()->qualifiedCppName()))
+ graph.addEdge(map[clazz->enclosingClass()->qualifiedCppName()], map[clazz->qualifiedCppName()]);
+
+ AbstractMetaClassList bases = getBaseClasses(clazz);
+ foreach(AbstractMetaClass* baseClass, bases) {
+ // Fix polymorphic expression
+ if (clazz->baseClass() == baseClass)
+ clazz->setBaseClass(baseClass);
+
+ if (map.contains(baseClass->qualifiedCppName()))
+ graph.addEdge(map[baseClass->qualifiedCppName()], map[clazz->qualifiedCppName()]);
+ }
+
+ foreach (AbstractMetaFunction* func, clazz->functions()) {
+ foreach (AbstractMetaArgument* arg, func->arguments()) {
+ // check methods with default args
+ QString defaultExpression = arg->originalDefaultValueExpression();
+ if (!defaultExpression.isEmpty()) {
+ if (defaultExpression == QLatin1String("0") && arg->type()->isValue())
+ defaultExpression = arg->type()->name();
+
+ defaultExpression.remove(regex1);
+ defaultExpression.remove(regex2);
+ }
+ if (!defaultExpression.isEmpty()) {
+ QString exprClassName = clazz->qualifiedCppName() + colonColon() + defaultExpression;
+ if (!map.contains(exprClassName)) {
+ bool found = false;
+ foreach(AbstractMetaClass* baseClass, bases) {
+ exprClassName = baseClass->qualifiedCppName() + colonColon() + defaultExpression;
+ if (map.contains(exprClassName)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ if (map.contains(defaultExpression))
+ exprClassName = defaultExpression;
+ else
+ exprClassName.clear();
+ }
+ }
+ if (!exprClassName.isEmpty() && exprClassName != clazz->qualifiedCppName())
+ graph.addEdge(map[exprClassName], map[clazz->qualifiedCppName()]);
+ }
+ }
+ }
+ }
+
+ AbstractMetaClassList result;
+ unmappedResult = graph.topologicalSort();
+ if (unmappedResult.isEmpty() && graph.nodeCount()) {
+ QTemporaryFile tempFile;
+ tempFile.setAutoRemove(false);
+ tempFile.open();
+ QHash<int, QString> hash;
+ QHash<QString, int>::iterator it = map.begin();
+ for (; it != map.end(); ++it)
+ hash[it.value()] = it.key();
+ graph.dumpDot(hash, tempFile.fileName());
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Cyclic dependency found! Graph can be found at "
+ << QDir::toNativeSeparators(tempFile.fileName());
+ } else {
+ foreach (int i, unmappedResult) {
+ Q_ASSERT(reverseMap.contains(i));
+ if (!reverseMap[i]->isInterface())
+ result << reverseMap[i];
+ }
+ }
+
+ return result;
+}
+
+AbstractMetaClassList AbstractMetaBuilder::classesTopologicalSorted(const AbstractMetaClass *cppClass,
+ const Dependencies &additionalDependencies) const
+{
+ return d->classesTopologicalSorted(cppClass, additionalDependencies);
+}
+
+AbstractMetaArgumentList AbstractMetaBuilderPrivate::reverseList(const AbstractMetaArgumentList &list)
+{
+ AbstractMetaArgumentList ret;
+
+ int index = list.size();
+ foreach (AbstractMetaArgument* arg, list) {
+ arg->setArgumentIndex(index);
+ ret.prepend(arg);
+ index--;
+ }
+
+ return ret;
+}
+
+void AbstractMetaBuilder::setGlobalHeader(const QString& globalHeader)
+{
+ d->m_globalHeader = QFileInfo(globalHeader);
+}
+
+void AbstractMetaBuilderPrivate::setInclude(TypeEntry *te, const QString &fileName) const
+{
+ QFileInfo info(fileName);
+ if (m_globalHeader.fileName() != info.fileName())
+ te->setInclude(Include(Include::IncludePath, info.fileName()));
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+template <class Container>
+static void debugFormatSequence(QDebug &d, const char *key, const Container& c,
+ const char *separator = ", ")
+{
+ typedef typename Container::const_iterator ConstIt;
+ if (c.isEmpty())
+ return;
+ const ConstIt begin = c.begin();
+ const ConstIt end = c.end();
+ d << "\n " << key << '[' << c.size() << "]=(";
+ for (ConstIt it = begin; it != end; ++it) {
+ if (it != begin)
+ d << separator;
+ d << *it;
+ }
+ d << ')';
+}
+
+void AbstractMetaBuilder::formatDebug(QDebug &debug) const
+{
+ debug << "m_globalHeader=" << d->m_globalHeader.absoluteFilePath();
+ debugFormatSequence(debug, "qtMetaTypeDeclaredTypeNames", d->m_qmetatypeDeclaredTypenames);
+ debugFormatSequence(debug, "globalEnums", d->m_globalEnums, "\n");
+ debugFormatSequence(debug, "globalFunctions", d->m_globalFunctions, "\n");
+ if (const int scopeCount = d->m_scopes.size()) {
+ debug << "\n scopes[" << scopeCount << "]=(";
+ for (int i = 0; i < scopeCount; ++i) {
+ if (i)
+ debug << ", ";
+ _CodeModelItem::formatKind(debug, d->m_scopes.at(i)->kind());
+ debug << " \"" << d->m_scopes.at(i)->name() << '"';
+ }
+ debug << ')';
+ }
+ debugFormatSequence(debug, "classes", d->m_metaClasses, "\n");
+ debugFormatSequence(debug, "templates", d->m_templates, "\n");
+}
+
+QDebug operator<<(QDebug d, const AbstractMetaBuilder &ab)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AbstractMetaBuilder(";
+ ab.formatDebug(d);
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder.h
new file mode 100644
index 000000000..b4a36a1b6
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTMETABUILDER_H
+#define ABSTRACTMETABUILDER_H
+
+#include "abstractmetalang_typedefs.h"
+#include "dependency.h"
+
+QT_FORWARD_DECLARE_CLASS(QIODevice)
+
+class AbstractMetaBuilderPrivate;
+class AbstractMetaClass;
+class AbstractMetaEnumValue;
+
+class AbstractMetaBuilder
+{
+public:
+ enum RejectReason {
+ NotInTypeSystem,
+ GenerationDisabled,
+ RedefinedToNotClass,
+ UnmatchedArgumentType,
+ UnmatchedReturnType,
+ ApiIncompatible,
+ NoReason
+ };
+
+ AbstractMetaBuilder();
+ virtual ~AbstractMetaBuilder();
+
+ AbstractMetaClassList classes() const;
+ AbstractMetaClassList templates() const;
+ AbstractMetaClassList smartPointers() const;
+ AbstractMetaFunctionList globalFunctions() const;
+ AbstractMetaEnumList globalEnums() const;
+ // QtScript
+ QSet<QString> qtMetaTypeDeclaredTypeNames() const;
+
+ /**
+ * Sorts a list of classes topologically, if an AbstractMetaClass object
+ * is passed the list of classes will be its inner classes, otherwise
+ * the list will be the module global classes.
+ * \return a list of classes sorted topologically
+ */
+ AbstractMetaClassList classesTopologicalSorted(const AbstractMetaClass *cppClass = Q_NULLPTR,
+ const Dependencies &additionalDependencies = Dependencies()) const;
+
+ bool build(QIODevice* input);
+ void setLogDirectory(const QString& logDir);
+
+ /**
+ * AbstractMetaBuilder should know what's the global header being used,
+ * so any class declared under this header wont have the include file
+ * filled.
+ */
+ void setGlobalHeader(const QString& globalHeader);
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const;
+#endif
+
+protected:
+ virtual AbstractMetaClass *createMetaClass();
+ virtual AbstractMetaEnum *createMetaEnum();
+ virtual AbstractMetaEnumValue *createMetaEnumValue();
+ virtual AbstractMetaField *createMetaField();
+ virtual AbstractMetaFunction *createMetaFunction();
+ virtual AbstractMetaArgument *createMetaArgument();
+ virtual AbstractMetaType *createMetaType();
+
+private:
+ friend class AbstractMetaBuilderPrivate;
+ AbstractMetaBuilderPrivate *d;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaBuilder &ab);
+#endif
+
+#endif // ABSTRACTMETBUILDER_H
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
new file mode 100644
index 000000000..f9eb4bb46
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
@@ -0,0 +1,194 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTMETABUILDER_P_H
+#define ABSTRACTMETABUILDER_P_H
+
+#include "abstractmetabuilder.h"
+#include "parser/codemodel_fwd.h"
+#include "abstractmetalang.h"
+#include "typesystem.h"
+#include "typeparser.h"
+
+#include <QSet>
+#include <QFileInfo>
+
+class TypeDatabase;
+
+class AbstractMetaBuilderPrivate
+{
+public:
+ AbstractMetaBuilderPrivate();
+ ~AbstractMetaBuilderPrivate();
+
+ static FileModelItem buildDom(QIODevice *input);
+ void traverseDom(const FileModelItem &dom);
+
+ void dumpLog() const;
+ AbstractMetaClassList classesTopologicalSorted(const AbstractMetaClass *cppClass = Q_NULLPTR,
+ const Dependencies &additionalDependencies = Dependencies()) const;
+ ScopeModelItem popScope() { return m_scopes.takeLast(); }
+
+ void pushScope(ScopeModelItem item) { m_scopes << item; }
+
+ ScopeModelItem currentScope() const { return m_scopes.last(); }
+
+ AbstractMetaClass *argumentToClass(ArgumentModelItem);
+
+ void figureOutEnumValuesForClass(AbstractMetaClass *metaClass, QSet<AbstractMetaClass *> *classes);
+ int figureOutEnumValue(const QString &name, int value, AbstractMetaEnum *meta_enum, AbstractMetaFunction *metaFunction = 0);
+ void figureOutEnumValues();
+ void figureOutDefaultEnumArguments();
+
+ void addAbstractMetaClass(AbstractMetaClass *cls);
+ AbstractMetaClass *traverseTypeDef(const FileModelItem &dom,
+ const TypeDefModelItem &typeDef);
+ AbstractMetaClass *traverseClass(const FileModelItem &dom,
+ const ClassModelItem &item);
+ AbstractMetaClass *currentTraversedClass(ScopeModelItem item);
+ void traverseScopeMembers(ScopeModelItem item, AbstractMetaClass *metaClass);
+ void traverseClassMembers(ClassModelItem scopeItem);
+ void traverseNamespaceMembers(NamespaceModelItem scopeItem);
+ bool setupInheritance(AbstractMetaClass *metaClass);
+ AbstractMetaClass *traverseNamespace(const FileModelItem &dom,
+ const NamespaceModelItem &item);
+ AbstractMetaEnum *traverseEnum(EnumModelItem item, AbstractMetaClass *enclosing,
+ const QSet<QString> &enumsDeclarations);
+ void traverseEnums(ScopeModelItem item, AbstractMetaClass *parent,
+ const QStringList &enumsDeclarations);
+ AbstractMetaFunctionList classFunctionList(const ScopeModelItem &scopeItem);
+ AbstractMetaFunctionList templateClassFunctionList(const ScopeModelItem &scopeItem,
+ AbstractMetaClass *metaClass);
+ void traverseFunctions(ScopeModelItem item, AbstractMetaClass *parent);
+ void applyFunctionModifications(AbstractMetaFunction* func);
+ void traverseFields(ScopeModelItem item, AbstractMetaClass *parent);
+ void traverseStreamOperator(FunctionModelItem functionItem);
+ void traverseOperatorFunction(FunctionModelItem item);
+ AbstractMetaFunction* traverseFunction(const AddedFunction &addedFunc);
+ AbstractMetaFunction* traverseFunction(const AddedFunction &addedFunc,
+ AbstractMetaClass *metaClass);
+ AbstractMetaFunction *traverseFunction(FunctionModelItem function);
+ AbstractMetaField *traverseField(VariableModelItem field,
+ const AbstractMetaClass *cls);
+ void checkFunctionModifications();
+ void registerHashFunction(FunctionModelItem functionItem);
+ void registerToStringCapability(FunctionModelItem functionItem);
+
+ /**
+ * A conversion operator function should not have its owner class as
+ * its return type, but unfortunately it does. This function fixes the
+ * return type of operator functions of this kind making the return type
+ * be the same as it is supposed to generate when used in C++.
+ * If the returned type is a wrapped C++ class, this method also adds the
+ * conversion operator to the collection of external conversions of the
+ * said class.
+ * \param metaFunction conversion operator function to be fixed.
+ */
+ void fixReturnTypeOfConversionOperator(AbstractMetaFunction *metaFunction);
+
+ void parseQ_Property(AbstractMetaClass *metaClass, const QStringList &declarations);
+ void setupEquals(AbstractMetaClass *metaClass);
+ void setupComparable(AbstractMetaClass *metaClass);
+ void setupClonable(AbstractMetaClass *cls);
+ void setupExternalConversion(AbstractMetaClass *cls);
+ void setupFunctionDefaults(AbstractMetaFunction *metaFunction,
+ AbstractMetaClass *metaClass);
+
+ QString fixDefaultValue(ArgumentModelItem item, AbstractMetaType *type,
+ AbstractMetaFunction *fnc, AbstractMetaClass *,
+ int argumentIndex);
+ AbstractMetaType* translateType(double vr, const AddedFunction::TypeInfo &typeInfo);
+ AbstractMetaType *translateType(const TypeInfo &type, bool *ok,
+ bool resolveType = true,
+ bool resolveScope = true);
+
+ int findOutValueFromString(const QString &stringValue, bool &ok);
+
+ void decideUsagePattern(AbstractMetaType *type);
+
+ AbstractMetaClass *findTemplateClass(const QString& name, const AbstractMetaClass *context,
+ TypeParser::Info *info = Q_NULLPTR,
+ ComplexTypeEntry **baseContainerType = Q_NULLPTR) const;
+ AbstractMetaClassList getBaseClasses(const AbstractMetaClass *metaClass) const;
+ bool ancestorHasPrivateCopyConstructor(const AbstractMetaClass *metaClass) const;
+
+ bool inheritTemplate(AbstractMetaClass *subclass,
+ const AbstractMetaClass *templateClass,
+ const TypeParser::Info &info);
+ AbstractMetaType *inheritTemplateType(const QList<AbstractMetaType *> &templateTypes,
+ const AbstractMetaType *metaType,
+ bool *ok = Q_NULLPTR);
+
+ bool isQObject(const FileModelItem &dom, const QString &qualifiedName);
+ bool isEnum(const FileModelItem &dom, const QStringList &qualifiedName);
+
+ void fixQObjectForScope(const FileModelItem &dom, const TypeDatabase *types,
+ const NamespaceModelItem &item);
+
+ void sortLists();
+ AbstractMetaArgumentList reverseList(const AbstractMetaArgumentList &list);
+ void setInclude(TypeEntry *te, const QString &fileName) const;
+ void fixArgumentNames(AbstractMetaFunction *func);
+ void fillAddedFunctions(AbstractMetaClass *metaClass);
+
+ AbstractMetaBuilder *q;
+ AbstractMetaClassList m_metaClasses;
+ AbstractMetaClassList m_templates;
+ AbstractMetaClassList m_smartPointers;
+ AbstractMetaFunctionList m_globalFunctions;
+ AbstractMetaEnumList m_globalEnums;
+
+ QSet<const TypeEntry *> m_usedTypes;
+
+ typedef QMap<QString, AbstractMetaBuilder::RejectReason> RejectMap;
+
+ RejectMap m_rejectedClasses;
+ RejectMap m_rejectedEnums;
+ RejectMap m_rejectedFunctions;
+ RejectMap m_rejectedFields;
+
+ QList<AbstractMetaEnum *> m_enums;
+
+ QList<QPair<AbstractMetaArgument *, AbstractMetaFunction *> > m_enumDefaultArguments;
+
+ QHash<QString, AbstractMetaEnumValue *> m_enumValues;
+
+ AbstractMetaClass *m_currentClass;
+ QList<ScopeModelItem> m_scopes;
+ QString m_namespacePrefix;
+
+ QSet<AbstractMetaClass *> m_setupInheritanceDone;
+
+ // QtScript
+ QSet<QString> m_qmetatypeDeclaredTypenames;
+
+ QString m_logDirectory;
+ QFileInfo m_globalHeader;
+};
+
+#endif // ABSTRACTMETBUILDER_P_H
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
new file mode 100644
index 000000000..b861f1b2f
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
@@ -0,0 +1,2786 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QStack>
+
+#include "abstractmetalang.h"
+#include "reporthandler.h"
+#include "typedatabase.h"
+#include "typesystem.h"
+
+#ifndef QT_NO_DEBUG_STREAM
+# include <QtCore/QMetaEnum>
+# include <QtCore/QMetaObject>
+#endif
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaAttributes *aa)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AbstractMetaAttributes(";
+ if (aa)
+ d << aa->attributes();
+ else
+ d << '0';
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+/*******************************************************************************
+ * AbstractMetaVariable
+ */
+
+AbstractMetaVariable::AbstractMetaVariable(const AbstractMetaVariable &other)
+{
+ m_originalName = other.m_originalName;
+ m_name = other.m_name;
+ m_type = other.m_type->copy();
+ m_hasName = other.m_hasName;
+ m_doc = other.m_doc;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaVariable *av)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AbstractMetaVariable(";
+ if (av) {
+ d << av->type()->name() << ' ' << av->name();
+ } else {
+ d << '0';
+ }
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+/*******************************************************************************
+ * AbstractMetaType
+ */
+
+AbstractMetaType::AbstractMetaType()
+ :m_typeEntry(0),
+ m_arrayElementCount(0),
+ m_arrayElementType(0),
+ m_originalTemplateType(0),
+ m_pattern(InvalidPattern),
+ m_constant(false),
+ m_cppInstantiation(true),
+ m_indirections(0),
+ m_reserved(0),
+ m_referenceType(NoReference)
+{
+}
+
+AbstractMetaType::~AbstractMetaType()
+{
+ qDeleteAll(m_children);
+ m_instantiations.clear();
+}
+
+QString AbstractMetaType::package() const
+{
+ return m_typeEntry->targetLangPackage();
+}
+
+QString AbstractMetaType::name() const
+{
+ if (m_name.isNull())
+ // avoid constLast to stay Qt 5.5 compatible
+ m_name = m_typeEntry->targetLangName().split(QLatin1String("::")).last();
+ return m_name;
+}
+
+QString AbstractMetaType::fullName() const
+{
+ return m_typeEntry->qualifiedTargetLangName();
+}
+
+AbstractMetaType *AbstractMetaType::copy() const
+{
+ AbstractMetaType *cpy = new AbstractMetaType;
+
+ cpy->setTypeUsagePattern(typeUsagePattern());
+ cpy->setConstant(isConstant());
+ cpy->setReferenceType(referenceType());
+ cpy->setIndirections(indirections());
+ cpy->setInstantiations(instantiations());
+ cpy->setArrayElementCount(arrayElementCount());
+ cpy->setOriginalTypeDescription(originalTypeDescription());
+ cpy->setOriginalTemplateType(originalTemplateType() ? originalTemplateType()->copy() : 0);
+
+ cpy->setArrayElementType(arrayElementType() ? arrayElementType()->copy() : 0);
+
+ cpy->setTypeEntry(typeEntry());
+
+ return cpy;
+}
+
+QString AbstractMetaType::cppSignature() const
+{
+ if (m_cachedCppSignature.isEmpty()) {
+ if (isConstant())
+ m_cachedCppSignature += QLatin1String("const ");
+
+ m_cachedCppSignature += typeEntry()->qualifiedCppName();
+
+ if (hasInstantiationInCpp()) {
+ AbstractMetaTypeList types = instantiations();
+ m_cachedCppSignature += QLatin1Char('<');
+ for (int i = 0; i < types.count(); ++i) {
+ if (i > 0)
+ m_cachedCppSignature += QLatin1String(", ");
+ m_cachedCppSignature += types[i]->cppSignature();
+ }
+ m_cachedCppSignature += QLatin1String(" >");
+ }
+
+ if (indirections() || m_referenceType != NoReference) {
+ m_cachedCppSignature += QLatin1Char(' ');
+ if (indirections())
+ m_cachedCppSignature += QString(indirections(), QLatin1Char('*'));
+ switch (referenceType()) {
+ case NoReference:
+ break;
+ case LValueReference:
+ m_cachedCppSignature += QLatin1Char('&');
+ break;
+ case RValueReference:
+ m_cachedCppSignature += QLatin1String("&&");
+ break;
+ }
+ }
+ }
+ return m_cachedCppSignature;
+}
+
+AbstractMetaType::TypeUsagePattern AbstractMetaType::determineUsagePattern() const
+{
+ if (m_typeEntry->isTemplateArgument() || m_referenceType == RValueReference)
+ return InvalidPattern;
+
+ if (m_typeEntry->isPrimitive() && (!actualIndirections()
+ || (isConstant() && m_referenceType == LValueReference && !indirections()))) {
+ return PrimitivePattern;
+ }
+
+ if (m_typeEntry->isVoid())
+ return NativePointerPattern;
+
+ if (m_typeEntry->isVarargs())
+ return VarargsPattern;
+
+ if (m_typeEntry->isString() && indirections() == 0
+ && (isConstant() == (m_referenceType == LValueReference)
+ || isConstant())) {
+ return StringPattern;
+ }
+
+ if (m_typeEntry->isChar()
+ && indirections() == 0
+ && isConstant() == (m_referenceType == LValueReference)) {
+ return CharPattern;
+ }
+
+ if (m_typeEntry->isJObjectWrapper()
+ && indirections() == 0
+ && isConstant() == (m_referenceType == LValueReference)) {
+ return JObjectWrapperPattern;
+ }
+
+ if (m_typeEntry->isVariant()
+ && indirections() == 0
+ && isConstant() == (m_referenceType == LValueReference)) {
+ return VariantPattern;
+ }
+
+ if (m_typeEntry->isEnum() && actualIndirections() == 0)
+ return EnumPattern;
+
+ if (m_typeEntry->isObject()) {
+ if (indirections() == 0 && m_referenceType == NoReference)
+ return ValuePattern;
+ return static_cast<const ComplexTypeEntry *>(m_typeEntry)->isQObject()
+ ? QObjectPattern : ObjectPattern;
+ }
+
+ if (m_typeEntry->isContainer() && indirections() == 0)
+ return ContainerPattern;
+
+ if (m_typeEntry->isSmartPointer() && indirections() == 0)
+ return SmartPointerPattern;
+
+ if (m_typeEntry->isFlags() && indirections() == 0
+ && (isConstant() == (m_referenceType == LValueReference)))
+ return FlagsPattern;
+
+ if (m_typeEntry->isArray())
+ return ArrayPattern;
+
+ if (m_typeEntry->isThread()) {
+ Q_ASSERT(indirections() == 1);
+ return ThreadPattern;
+ }
+
+ if (m_typeEntry->isValue())
+ return indirections() == 1 ? ValuePointerPattern : ValuePattern;
+
+ if (ReportHandler::isDebug(ReportHandler::FullDebug)) {
+ qCDebug(lcShiboken)
+ << QStringLiteral("native pointer pattern for '%1'").arg(cppSignature());
+ }
+ return NativePointerPattern;
+}
+
+void AbstractMetaType::decideUsagePattern()
+{
+ TypeUsagePattern pattern = determineUsagePattern();
+ if (m_typeEntry->isObject() && indirections() == 1
+ && m_referenceType == LValueReference && isConstant()) {
+ // const-references to pointers can be passed as pointers
+ setReferenceType(NoReference);
+ setConstant(false);
+ pattern = static_cast<const ComplexTypeEntry *>(m_typeEntry)->isQObject()
+ ? QObjectPattern : ObjectPattern;
+ }
+ setTypeUsagePattern(pattern);
+}
+
+bool AbstractMetaType::hasTemplateChildren() const
+{
+ QStack<AbstractMetaType *> children;
+ children << m_children.toVector();
+
+ // Recursively iterate over the children / descendants of the type, to check if any of them
+ // corresponds to a template argument type.
+ while (!children.isEmpty()) {
+ AbstractMetaType *child = children.pop();
+ if (child->typeEntry()->isTemplateArgument())
+ return true;
+ children << child->m_children.toVector();
+ }
+
+ return false;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaType *at)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AbstractMetaType(";
+ if (at)
+ d << at->name();
+ else
+ d << '0';
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+/*******************************************************************************
+ * AbstractMetaArgument
+ */
+AbstractMetaArgument *AbstractMetaArgument::copy() const
+{
+ return new AbstractMetaArgument(*this);
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaArgument *aa)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AbstractMetaArgument(";
+ if (aa)
+ d << aa->toString();
+ else
+ d << '0';
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+/*******************************************************************************
+ * AbstractMetaFunction
+ */
+AbstractMetaFunction::~AbstractMetaFunction()
+{
+ qDeleteAll(m_arguments);
+ delete m_type;
+}
+
+/*******************************************************************************
+ * Indicates that this function has a modification that removes it
+ */
+bool AbstractMetaFunction::isModifiedRemoved(int types) const
+{
+ FunctionModificationList mods = modifications(implementingClass());
+ foreach (const FunctionModification &mod, mods) {
+ if (!mod.isRemoveModifier())
+ continue;
+
+ if ((mod.removal & types) == types)
+ return true;
+ }
+
+ return false;
+}
+
+bool AbstractMetaFunction::needsCallThrough() const
+{
+ if (ownerClass()->isInterface())
+ return false;
+ if (referenceCounts(implementingClass()).size() > 0)
+ return true;
+ if (argumentsHaveNativeId() || !isStatic())
+ return true;
+
+ foreach (const AbstractMetaArgument *arg, arguments()) {
+ if (arg->type()->isArray() || arg->type()->isTargetLangEnum() || arg->type()->isTargetLangFlags())
+ return true;
+ }
+
+ if (type() && (type()->isArray() || type()->isTargetLangEnum() || type()->isTargetLangFlags()))
+ return true;
+
+ for (int i = -1; i <= arguments().size(); ++i) {
+ TypeSystem::Ownership owner = this->ownership(implementingClass(), TypeSystem::TargetLangCode, i);
+ if (owner != TypeSystem::InvalidOwnership)
+ return true;
+ }
+
+ return false;
+}
+
+bool AbstractMetaFunction::needsSuppressUncheckedWarning() const
+{
+ for (int i = -1; i <= arguments().size(); ++i) {
+ QList<ReferenceCount> referenceCounts = this->referenceCounts(implementingClass(), i);
+ foreach (const ReferenceCount &referenceCount, referenceCounts) {
+ if (referenceCount.action != ReferenceCount::Set)
+ return true;
+ }
+ }
+ return false;
+}
+
+QString AbstractMetaFunction::marshalledName() const
+{
+ QString returned = QLatin1String("__qt_") + name();
+ AbstractMetaArgumentList arguments = this->arguments();
+ foreach (const AbstractMetaArgument *arg, arguments) {
+ returned += QLatin1Char('_');
+ if (arg->type()->isNativePointer()) {
+ returned += QLatin1String("nativepointer");
+ } else if (arg->type()->isIntegerEnum() || arg->type()->isIntegerFlags()) {
+ returned += QLatin1String("int");
+ } else {
+ QString a = arg->type()->name();
+ a.replace(QLatin1String("[]"), QLatin1String("_3"));
+ a.replace(QLatin1Char('.'), QLatin1Char('_'));
+ returned += a;
+ }
+ }
+ return returned;
+}
+
+bool AbstractMetaFunction::operator<(const AbstractMetaFunction &other) const
+{
+ return compareTo(&other) & NameLessThan;
+}
+
+
+/*!
+ Returns a mask of CompareResult describing how this function is
+ compares to another function
+*/
+AbstractMetaFunction::CompareResult AbstractMetaFunction::compareTo(const AbstractMetaFunction *other) const
+{
+ CompareResult result = 0;
+
+ // Enclosing class...
+ if (ownerClass() == other->ownerClass())
+ result |= EqualImplementor;
+
+ // Attributes
+ if (attributes() == other->attributes())
+ result |= EqualAttributes;
+
+ // Compare types
+ AbstractMetaType *t = type();
+ AbstractMetaType *ot = other->type();
+ if ((!t && !ot) || ((t && ot && t->name() == ot->name())))
+ result |= EqualReturnType;
+
+ // Compare names
+ int cmp = originalName().compare(other->originalName());
+
+ if (cmp < 0)
+ result |= NameLessThan;
+ else if (!cmp)
+ result |= EqualName;
+
+ // compare name after modification...
+ cmp = modifiedName().compare(other->modifiedName());
+ if (!cmp)
+ result |= EqualModifiedName;
+
+ // Compare arguments...
+ AbstractMetaArgumentList minArguments;
+ AbstractMetaArgumentList maxArguments;
+ if (arguments().size() < other->arguments().size()) {
+ minArguments = arguments();
+ maxArguments = other->arguments();
+ } else {
+ minArguments = other->arguments();
+ maxArguments = arguments();
+ }
+
+ int minCount = minArguments.size();
+ int maxCount = maxArguments.size();
+ bool same = true;
+ for (int i = 0; i < maxCount; ++i) {
+ if (i < minCount) {
+ const AbstractMetaArgument *min_arg = minArguments.at(i);
+ const AbstractMetaArgument *max_arg = maxArguments.at(i);
+ if (min_arg->type()->name() != max_arg->type()->name()
+ && (min_arg->defaultValueExpression().isEmpty() || max_arg->defaultValueExpression().isEmpty())) {
+ same = false;
+ break;
+ }
+ } else {
+ if (maxArguments.at(i)->defaultValueExpression().isEmpty()) {
+ same = false;
+ break;
+ }
+ }
+ }
+
+ if (same)
+ result |= minCount == maxCount ? EqualArguments : EqualDefaultValueOverload;
+
+ return result;
+}
+
+AbstractMetaFunction *AbstractMetaFunction::copy() const
+{
+ AbstractMetaFunction *cpy = new AbstractMetaFunction;
+ cpy->setName(name());
+ cpy->setOriginalName(originalName());
+ cpy->setOwnerClass(ownerClass());
+ cpy->setImplementingClass(implementingClass());
+ cpy->setFunctionType(functionType());
+ cpy->setAttributes(attributes());
+ cpy->setDeclaringClass(declaringClass());
+ if (type())
+ cpy->setType(type()->copy());
+ cpy->setConstant(isConstant());
+ cpy->setOriginalAttributes(originalAttributes());
+
+ foreach (AbstractMetaArgument *arg, arguments())
+ cpy->addArgument(arg->copy());
+
+ Q_ASSERT((!type() && !cpy->type())
+ || (type()->instantiations() == cpy->type()->instantiations()));
+
+ return cpy;
+}
+
+bool AbstractMetaFunction::usesRValueReferences() const
+{
+ if (m_functionType == MoveConstructorFunction || m_functionType == MoveAssignmentOperatorFunction)
+ return true;
+ if (m_type && m_type->referenceType() == RValueReference)
+ return true;
+ foreach (const AbstractMetaArgument *a, m_arguments) {
+ if (a->type()->referenceType() == RValueReference)
+ return true;
+ }
+ return false;
+}
+
+QStringList AbstractMetaFunction::introspectionCompatibleSignatures(const QStringList &resolvedArguments) const
+{
+ AbstractMetaArgumentList arguments = this->arguments();
+ if (arguments.size() == resolvedArguments.size()) {
+ QString signature = name() + QLatin1Char('(') + resolvedArguments.join(QLatin1Char(',')) + QLatin1Char(')');
+ return QStringList(TypeDatabase::normalizedSignature(signature));
+ } else {
+ QStringList returned;
+
+ AbstractMetaArgument *argument = arguments.at(resolvedArguments.size());
+ QStringList minimalTypeSignature = argument->type()->minimalSignature().split(QLatin1String("::"));
+ for (int i = 0; i < minimalTypeSignature.size(); ++i) {
+ returned += introspectionCompatibleSignatures(QStringList(resolvedArguments)
+ << QStringList(minimalTypeSignature.mid(minimalTypeSignature.size() - i - 1)).join(QLatin1String("::")));
+ }
+
+ return returned;
+ }
+}
+
+QString AbstractMetaFunction::signature() const
+{
+ if (m_cachedSignature.isEmpty()) {
+ m_cachedSignature = m_originalName;
+
+ m_cachedSignature += QLatin1Char('(');
+
+ for (int i = 0; i < m_arguments.count(); ++i) {
+ AbstractMetaArgument *a = m_arguments.at(i);
+ AbstractMetaType *t = a->type();
+ if (t) {
+ if (i > 0)
+ m_cachedSignature += QLatin1String(", ");
+ m_cachedSignature += t->cppSignature();
+ // We need to have the argument names in the qdoc files
+ m_cachedSignature += QLatin1Char(' ');
+ m_cachedSignature += a->name();
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QString::fromLatin1("No abstract meta type found for argument '%1' while"
+ "constructing signature for function '%2'.")
+ .arg(a->name(), name());
+ }
+ }
+ m_cachedSignature += QLatin1Char(')');
+
+ if (isConstant())
+ m_cachedSignature += QLatin1String(" const");
+ }
+ return m_cachedSignature;
+}
+
+int AbstractMetaFunction::actualMinimumArgumentCount() const
+{
+ AbstractMetaArgumentList arguments = this->arguments();
+
+ int count = 0;
+ for (int i = 0; i < arguments.size(); ++i && ++count) {
+ if (argumentRemoved(i + 1))
+ --count;
+ else if (!arguments.at(i)->defaultValueExpression().isEmpty())
+ break;
+ }
+
+ return count;
+}
+
+// Returns reference counts for argument at idx, or all arguments if idx == -2
+QList<ReferenceCount> AbstractMetaFunction::referenceCounts(const AbstractMetaClass *cls, int idx) const
+{
+ QList<ReferenceCount> returned;
+
+ FunctionModificationList mods = this->modifications(cls);
+ foreach (const FunctionModification &mod, mods) {
+ foreach (const ArgumentModification &argumentMod, mod.argument_mods) {
+ if (argumentMod.index != idx && idx != -2)
+ continue;
+ returned += argumentMod.referenceCounts;
+ }
+ }
+
+ return returned;
+}
+
+
+ArgumentOwner AbstractMetaFunction::argumentOwner(const AbstractMetaClass *cls, int idx) const
+{
+ FunctionModificationList mods = this->modifications(cls);
+ foreach (const FunctionModification &mod, mods) {
+ foreach (const ArgumentModification &argumentMod, mod.argument_mods) {
+ if (argumentMod.index != idx)
+ continue;
+ return argumentMod.owner;
+ }
+ }
+ return ArgumentOwner();
+}
+
+
+QString AbstractMetaFunction::replacedDefaultExpression(const AbstractMetaClass *cls, int key) const
+{
+ FunctionModificationList modifications = this->modifications(cls);
+ foreach (const FunctionModification &modification, modifications) {
+ foreach (const ArgumentModification &argumentModification, modification.argument_mods) {
+ if (argumentModification.index == key
+ && !argumentModification.replacedDefaultExpression.isEmpty()) {
+ return argumentModification.replacedDefaultExpression;
+ }
+ }
+ }
+
+ return QString();
+}
+
+bool AbstractMetaFunction::removedDefaultExpression(const AbstractMetaClass *cls, int key) const
+{
+ FunctionModificationList modifications = this->modifications(cls);
+ foreach (const FunctionModification &modification, modifications) {
+ foreach (const ArgumentModification &argumentModification, modification.argument_mods) {
+ if (argumentModification.index == key
+ && argumentModification.removedDefaultExpression) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool AbstractMetaFunction::resetObjectAfterUse(int argumentIdx) const
+{
+ const AbstractMetaClass *cls = declaringClass();
+ FunctionModificationList modifications = this->modifications(cls);
+ foreach (const FunctionModification &modification, modifications) {
+ foreach (const ArgumentModification &argumentModification, modification.argument_mods) {
+ if (argumentModification.index == argumentIdx && argumentModification.resetAfterUse)
+ return true;
+ }
+ }
+
+ return false;
+}
+
+QString AbstractMetaFunction::nullPointerDefaultValue(const AbstractMetaClass *mainClass, int argumentIdx) const
+{
+ Q_ASSERT(nullPointersDisabled(mainClass, argumentIdx));
+
+ const AbstractMetaClass *cls = mainClass;
+ if (!cls)
+ cls = implementingClass();
+
+ do {
+ FunctionModificationList modifications = this->modifications(cls);
+ foreach (const FunctionModification &modification, modifications) {
+ foreach (const ArgumentModification &argumentModification, modification.argument_mods) {
+ if (argumentModification.index == argumentIdx
+ && argumentModification.noNullPointers) {
+ return argumentModification.nullPointerDefaultValue;
+ }
+ }
+ }
+ cls = cls->baseClass();
+ } while (cls && !mainClass); // Once when mainClass, or once for all base classes of implementing class
+
+ return QString();
+
+}
+
+bool AbstractMetaFunction::nullPointersDisabled(const AbstractMetaClass *mainClass, int argumentIdx) const
+{
+ const AbstractMetaClass *cls = mainClass;
+ if (!cls)
+ cls = implementingClass();
+
+ do {
+ FunctionModificationList modifications = this->modifications(cls);
+ foreach (const FunctionModification &modification, modifications) {
+ foreach (const ArgumentModification &argumentModification, modification.argument_mods) {
+ if (argumentModification.index == argumentIdx
+ && argumentModification.noNullPointers) {
+ return true;
+ }
+ }
+ }
+
+ cls = cls->baseClass();
+ } while (cls && !mainClass); // Once when mainClass, or once for all base classes of implementing class
+
+ return false;
+}
+
+QString AbstractMetaFunction::conversionRule(TypeSystem::Language language, int key) const
+{
+ FunctionModificationList modifications = this->modifications(declaringClass());
+ foreach (const FunctionModification &modification, modifications) {
+ foreach (const ArgumentModification &argumentModification, modification.argument_mods) {
+ if (argumentModification.index != key)
+ continue;
+
+ foreach (const CodeSnip &snip, argumentModification.conversion_rules) {
+ if (snip.language == language && !snip.code().isEmpty())
+ return snip.code();
+ }
+ }
+ }
+
+ return QString();
+}
+
+QString AbstractMetaFunction::argumentReplaced(int key) const
+{
+ FunctionModificationList modifications = this->modifications(declaringClass());
+ foreach (const FunctionModification &modification, modifications) {
+ foreach (const ArgumentModification &argumentModification, modification.argument_mods) {
+ if (argumentModification.index == key && !argumentModification.replace_value.isEmpty())
+ return argumentModification.replace_value;
+ }
+ }
+
+ return QString();
+}
+
+// FIXME If we remove a arg. in the method at the base class, it will not reflect here.
+bool AbstractMetaFunction::argumentRemoved(int key) const
+{
+ FunctionModificationList modifications = this->modifications(declaringClass());
+ foreach (const FunctionModification &modification, modifications) {
+ foreach (const ArgumentModification &argumentModification, modification.argument_mods) {
+ if (argumentModification.index == key) {
+ if (argumentModification.removed)
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool AbstractMetaFunction::isVirtualSlot() const
+{
+ FunctionModificationList modifications = this->modifications(declaringClass());
+ foreach (const FunctionModification &modification, modifications) {
+ if (modification.isVirtualSlot())
+ return true;
+ }
+
+ return false;
+}
+
+bool AbstractMetaFunction::disabledGarbageCollection(const AbstractMetaClass *cls, int key) const
+{
+ typedef QHash<TypeSystem::Language, TypeSystem::Ownership>::const_iterator OwnershipMapIt;
+
+ FunctionModificationList modifications = this->modifications(cls);
+ foreach (const FunctionModification &modification, modifications) {
+ foreach (const ArgumentModification &argumentModification, modification.argument_mods) {
+ if (argumentModification.index != key)
+ continue;
+
+ for (OwnershipMapIt it = argumentModification.ownerships.cbegin(), end = argumentModification.ownerships.cend(); it != end; ++it) {
+ if (it.value() == TypeSystem::CppOwnership)
+ return true;
+ }
+
+ }
+ }
+
+ return false;
+}
+
+bool AbstractMetaFunction::isDeprecated() const
+{
+ FunctionModificationList modifications = this->modifications(declaringClass());
+ foreach (const FunctionModification &modification, modifications) {
+ if (modification.isDeprecated())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaFunction::isThread() const
+{
+ FunctionModificationList modifications = this->modifications(declaringClass());
+ foreach (const FunctionModification &modification, modifications) {
+ if (modification.isThread())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaFunction::allowThread() const
+{
+ FunctionModificationList modifications = this->modifications(declaringClass());
+ foreach (const FunctionModification &modification, modifications) {
+ if (modification.allowThread())
+ return true;
+ }
+ return false;
+}
+
+
+TypeSystem::Ownership AbstractMetaFunction::ownership(const AbstractMetaClass *cls, TypeSystem::Language language, int key) const
+{
+ FunctionModificationList modifications = this->modifications(cls);
+ foreach (const FunctionModification &modification, modifications) {
+ foreach (const ArgumentModification &argumentModification, modification.argument_mods) {
+ if (argumentModification.index == key)
+ return argumentModification.ownerships.value(language, TypeSystem::InvalidOwnership);
+ }
+ }
+
+ return TypeSystem::InvalidOwnership;
+}
+
+bool AbstractMetaFunction::isRemovedFromAllLanguages(const AbstractMetaClass *cls) const
+{
+ return isRemovedFrom(cls, TypeSystem::All);
+}
+
+bool AbstractMetaFunction::isRemovedFrom(const AbstractMetaClass *cls, TypeSystem::Language language) const
+{
+ FunctionModificationList modifications = this->modifications(cls);
+ foreach (const FunctionModification &modification, modifications) {
+ if ((modification.removal & language) == language)
+ return true;
+ }
+
+ return false;
+
+}
+
+QString AbstractMetaFunction::typeReplaced(int key) const
+{
+ FunctionModificationList modifications = this->modifications(declaringClass());
+ foreach (const FunctionModification &modification, modifications) {
+ foreach (const ArgumentModification &argumentModification, modification.argument_mods) {
+ if (argumentModification.index == key
+ && !argumentModification.modified_type.isEmpty()) {
+ return argumentModification.modified_type;
+ }
+ }
+ }
+
+ return QString();
+}
+
+QString AbstractMetaFunction::minimalSignature() const
+{
+ if (!m_cachedMinimalSignature.isEmpty())
+ return m_cachedMinimalSignature;
+
+ QString minimalSignature = originalName() + QLatin1Char('(');
+ AbstractMetaArgumentList arguments = this->arguments();
+
+ for (int i = 0; i < arguments.count(); ++i) {
+ AbstractMetaType *t = arguments.at(i)->type();
+ if (t) {
+ if (i > 0)
+ minimalSignature += QLatin1Char(',');
+ minimalSignature += t->minimalSignature();
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QString::fromLatin1("No abstract meta type found for argument '%1' while constructing"
+ " minimal signature for function '%2'.")
+ .arg(arguments.at(i)->name(), name());
+ }
+ }
+ minimalSignature += QLatin1Char(')');
+ if (isConstant())
+ minimalSignature += QLatin1String("const");
+
+ minimalSignature = TypeDatabase::normalizedSignature(minimalSignature);
+ m_cachedMinimalSignature = minimalSignature;
+
+ return minimalSignature;
+}
+
+FunctionModificationList AbstractMetaFunction::modifications(const AbstractMetaClass* implementor) const
+{
+ if (!implementor)
+ implementor = ownerClass();
+
+ if (!implementor)
+ return TypeDatabase::instance()->functionModifications(minimalSignature());
+
+ FunctionModificationList mods;
+ while (implementor) {
+ mods += implementor->typeEntry()->functionModifications(minimalSignature());
+ if ((implementor == implementor->baseClass()) ||
+ (implementor == implementingClass() && (mods.size() > 0)))
+ break;
+ foreach (const AbstractMetaClass* interface, implementor->interfaces()) {
+ mods += this->modifications(interface);
+ }
+ implementor = implementor->baseClass();
+ }
+ return mods;
+}
+
+bool AbstractMetaFunction::hasModifications(const AbstractMetaClass *implementor) const
+{
+ return !modifications(implementor).isEmpty();
+}
+
+QString AbstractMetaFunction::argumentName(int index,
+ bool /* create */,
+ const AbstractMetaClass * /* implementor */) const
+{
+ return m_arguments[--index]->name();
+}
+
+bool AbstractMetaFunction::isCallOperator() const
+{
+ return m_name == QLatin1String("operator()");
+}
+
+bool AbstractMetaFunction::hasInjectedCode() const
+{
+ foreach (const FunctionModification &mod, modifications(ownerClass())) {
+ if (mod.isCodeInjection())
+ return true;
+ }
+ return false;
+}
+
+CodeSnipList AbstractMetaFunction::injectedCodeSnips(TypeSystem::CodeSnipPosition position, TypeSystem::Language language) const
+{
+ CodeSnipList result;
+ foreach (const FunctionModification &mod, modifications(ownerClass())) {
+ if (mod.isCodeInjection()) {
+ QList<CodeSnip>::const_iterator it = mod.snips.constBegin();
+ for (;it != mod.snips.constEnd(); ++it) {
+ if ((it->language & language) && (it->position == position || position == TypeSystem::CodeSnipPositionAny))
+ result << *it;
+ }
+ }
+ }
+ return result;
+}
+
+bool AbstractMetaFunction::hasSignatureModifications() const
+{
+ foreach (const FunctionModification &mod, modifications()) {
+ if (mod.isRenameModifier())
+ return true;
+ foreach (const ArgumentModification &argmod, mod.argument_mods) {
+ // since zero represents the return type and we're
+ // interested only in checking the function arguments,
+ // it will be ignored.
+ if (argmod.index > 0)
+ return true;
+ }
+ }
+ return false;
+}
+
+bool AbstractMetaFunction::isConversionOperator(QString funcName)
+{
+ static QRegExp opRegEx(QLatin1String("^operator(?:\\s+(?:const|volatile))?\\s+(\\w+\\s*)&?$"));
+ return opRegEx.indexIn(funcName) > -1;
+}
+
+bool AbstractMetaFunction::isOperatorOverload(QString funcName)
+{
+ if (isConversionOperator(funcName))
+ return true;
+
+ static QRegExp opRegEx(QLatin1String("^operator([+\\-\\*/%=&\\|\\^\\<>!][=]?"
+ "|\\+\\+|\\-\\-|&&|\\|\\||<<[=]?|>>[=]?|~"
+ "|\\[\\]|\\s+delete\\[?\\]?"
+ "|\\(\\)"
+ "|\\s+new\\[?\\]?)$"));
+ return opRegEx.indexIn(funcName) > -1;
+}
+
+bool AbstractMetaFunction::isCastOperator() const
+{
+ return originalName().startsWith(QLatin1String("operator "));
+}
+
+bool AbstractMetaFunction::isArithmeticOperator() const
+{
+ if (!isOperatorOverload())
+ return false;
+
+ QString name = originalName();
+
+ // It's a dereference operator!
+ if (name == QLatin1String("operator*") && m_arguments.isEmpty())
+ return false;
+
+ return name == QLatin1String("operator+") || name == QLatin1String("operator+=")
+ || name == QLatin1String("operator-") || name == QLatin1String("operator-=")
+ || name == QLatin1String("operator*") || name == QLatin1String("operator*=")
+ || name == QLatin1String("operator/") || name == QLatin1String("operator/=")
+ || name == QLatin1String("operator%") || name == QLatin1String("operator%=")
+ || name == QLatin1String("operator++") || name == QLatin1String("operator--");
+}
+
+bool AbstractMetaFunction::isBitwiseOperator() const
+{
+ if (!isOperatorOverload())
+ return false;
+
+ QString name = originalName();
+ return name == QLatin1String("operator<<") || name == QLatin1String("operator<<=")
+ || name == QLatin1String("operator>>") || name == QLatin1String("operator>>=")
+ || name == QLatin1String("operator&") || name == QLatin1String("operator&=")
+ || name == QLatin1String("operator|") || name == QLatin1String("operator|=")
+ || name == QLatin1String("operator^") || name == QLatin1String("operator^=")
+ || name == QLatin1String("operator~");
+}
+
+bool AbstractMetaFunction::isComparisonOperator() const
+{
+ if (!isOperatorOverload())
+ return false;
+
+ QString name = originalName();
+ return name == QLatin1String("operator<") || name == QLatin1String("operator<=")
+ || name == QLatin1String("operator>") || name == QLatin1String("operator>=")
+ || name == QLatin1String("operator==") || name == QLatin1String("operator!=");
+}
+
+bool AbstractMetaFunction::isLogicalOperator() const
+{
+ if (!isOperatorOverload())
+ return false;
+
+ QString name = originalName();
+ return name == QLatin1String("operator!")
+ || name == QLatin1String("operator&&")
+ || name == QLatin1String("operator||");
+}
+
+bool AbstractMetaFunction::isSubscriptOperator() const
+{
+ if (!isOperatorOverload())
+ return false;
+
+ return originalName() == QLatin1String("operator[]");
+}
+
+bool AbstractMetaFunction::isAssignmentOperator() const
+{
+ return m_functionType == AssignmentOperatorFunction
+ || m_functionType == MoveAssignmentOperatorFunction;
+}
+
+bool AbstractMetaFunction::isOtherOperator() const
+{
+ if (!isOperatorOverload())
+ return false;
+
+ return !isArithmeticOperator()
+ && !isBitwiseOperator()
+ && !isComparisonOperator()
+ && !isLogicalOperator()
+ && !isConversionOperator()
+ && !isSubscriptOperator()
+ && !isAssignmentOperator();
+}
+
+int AbstractMetaFunction::arityOfOperator() const
+{
+ if (!isOperatorOverload() || isCallOperator())
+ return -1;
+
+ int arity = m_arguments.size();
+
+ // Operator overloads that are class members
+ // implicitly includes the instance and have
+ // one parameter less than their arity,
+ // so we increment it.
+ if (ownerClass() && arity < 2)
+ arity++;
+
+ return arity;
+}
+
+bool AbstractMetaFunction::isInplaceOperator() const
+{
+ if (!isOperatorOverload())
+ return false;
+
+ QString name = originalName();
+ return name == QLatin1String("operator+=") || name == QLatin1String("operator&=")
+ || name == QLatin1String("operator-=") || name == QLatin1String("operator|=")
+ || name == QLatin1String("operator*=") || name == QLatin1String("operator^=")
+ || name == QLatin1String("operator/=") || name == QLatin1String("operator<<=")
+ || name == QLatin1String("operator%=") || name == QLatin1String("operator>>=");
+}
+
+bool AbstractMetaFunction::isVirtual() const
+{
+ return !isFinal() && !isSignal() && !isStatic() && !isFinalInCpp() && !isConstructor();
+}
+
+QString AbstractMetaFunction::modifiedName() const
+{
+ if (m_cachedModifiedName.isEmpty()) {
+ FunctionModificationList mods = modifications(implementingClass());
+ foreach (const FunctionModification &mod, mods) {
+ if (mod.isRenameModifier()) {
+ m_cachedModifiedName = mod.renamedToName;
+ break;
+ }
+ }
+ if (m_cachedModifiedName.isEmpty())
+ m_cachedModifiedName = name();
+ }
+ return m_cachedModifiedName;
+}
+
+QString AbstractMetaFunction::targetLangSignature(bool minimal) const
+{
+ QString s;
+
+ // Attributes...
+ if (!minimal) {
+ // Return type
+ if (type())
+ s += type()->name() + QLatin1Char(' ');
+ else
+ s += QLatin1String("void ");
+ }
+
+ s += modifiedName();
+ s += QLatin1Char('(');
+
+ int j = 0;
+ for (int i = 0; i < m_arguments.size(); ++i) {
+ if (argumentRemoved(i + 1))
+ continue;
+ if (j) {
+ s += QLatin1Char(',');
+ if (!minimal)
+ s += QLatin1Char(' ');
+ }
+ s += m_arguments.at(i)->type()->name();
+
+ if (!minimal) {
+ s += QLatin1Char(' ');
+ s += m_arguments.at(i)->name();
+ }
+ ++j;
+ }
+
+ s += QLatin1Char(')');
+
+ return s;
+}
+
+
+bool function_sorter(AbstractMetaFunction *a, AbstractMetaFunction *b)
+{
+ return a->signature() < b->signature();
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+static inline void formatMetaFunctionBrief(QDebug &d, const AbstractMetaFunction *af)
+{
+ d << '"' << af->minimalSignature() << '"';
+}
+
+void AbstractMetaFunction::formatDebugVerbose(QDebug &d) const
+{
+ d << m_functionType << ' ' << m_type << ' ' << m_name << '(';
+ for (int i = 0, count = m_arguments.size(); i < count; ++i) {
+ if (i)
+ d << ", ";
+ d << m_arguments.at(i);
+ }
+ d << "), signature=\"" << minimalSignature() << '"';
+ if (m_constant)
+ d << " [const]";
+ if (m_invalid)
+ d << " [invalid]";
+ if (m_reverse)
+ d << " [reverse]";
+ if (m_userAdded)
+ d << " [userAdded]";
+ if (m_explicit)
+ d << " [explicit]";
+ if (m_pointerOperator)
+ d << " [operator->]";
+ if (m_isCallOperator)
+ d << " [operator()]";
+ if (m_class)
+ d << " class: " << m_class->name();
+ if (m_implementingClass)
+ d << " implementing class: " << m_implementingClass->name();
+ if (m_declaringClass)
+ d << " declaring class: " << m_declaringClass->name();
+}
+
+QDebug operator<<(QDebug d, const AbstractMetaFunction *af)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ 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';
+ }
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+/*******************************************************************************
+ * AbstractMetaClass
+ */
+AbstractMetaClass::~AbstractMetaClass()
+{
+ qDeleteAll(m_functions);
+ qDeleteAll(m_fields);
+ qDeleteAll(m_enums);
+ if (hasTemplateBaseClassInstantiations()) {
+ foreach (AbstractMetaType* inst, templateBaseClassInstantiations())
+ delete inst;
+ }
+}
+
+/*******************************************************************************
+ * Returns true if this class is a subclass of the given class
+ */
+bool AbstractMetaClass::inheritsFrom(const AbstractMetaClass *cls) const
+{
+ Q_ASSERT(cls);
+
+ const AbstractMetaClass *clazz = this;
+ while (clazz) {
+ if (clazz == cls)
+ return true;
+
+ clazz = clazz->baseClass();
+ }
+
+ return false;
+}
+
+/*******************************************************************************
+ * Constructs an interface based on the functions and enums in this
+ * class and returns it...
+ */
+AbstractMetaClass *AbstractMetaClass::extractInterface()
+{
+ Q_ASSERT(typeEntry()->designatedInterface());
+
+ if (!m_extractedInterface) {
+ AbstractMetaClass *iface = new AbstractMetaClass;
+ iface->setAttributes(attributes());
+ iface->setBaseClass(0);
+
+ iface->setTypeEntry(typeEntry()->designatedInterface());
+
+ foreach (AbstractMetaFunction *function, functions()) {
+ if (!function->isConstructor())
+ iface->addFunction(function->copy());
+ }
+
+// iface->setEnums(enums());
+// setEnums(AbstractMetaEnumList());
+
+ foreach (const AbstractMetaField *field, fields()) {
+ if (field->isPublic()) {
+ AbstractMetaField *new_field = field->copy();
+ new_field->setEnclosingClass(iface);
+ iface->addField(new_field);
+ }
+ }
+
+ m_extractedInterface = iface;
+ addInterface(iface);
+ }
+
+ return m_extractedInterface;
+}
+
+/*******************************************************************************
+ * Returns a list of all the functions with a given name
+ */
+AbstractMetaFunctionList AbstractMetaClass::queryFunctionsByName(const QString &name) const
+{
+ AbstractMetaFunctionList returned;
+ AbstractMetaFunctionList functions = this->functions();
+ foreach (AbstractMetaFunction *function, functions) {
+ if (function->name() == name)
+ returned.append(function);
+ }
+
+ return returned;
+}
+
+/*******************************************************************************
+ * Returns a list of all the functions retrieved during parsing which should
+ * be added to the API.
+ */
+AbstractMetaFunctionList AbstractMetaClass::functionsInTargetLang() const
+{
+ FunctionQueryOptions default_flags = NormalFunctions | Visible | NotRemovedFromTargetLang;
+
+ // Interfaces don't implement functions
+ if (isInterface())
+ default_flags |= ClassImplements;
+
+ // Only public functions in final classes
+ // default_flags |= isFinal() ? WasPublic : 0;
+ FunctionQueryOptions public_flags;
+ if (isFinal())
+ public_flags |= WasPublic;
+
+ // Constructors
+ AbstractMetaFunctionList returned = queryFunctions(Constructors | default_flags | public_flags);
+
+ // Final functions
+ returned += queryFunctions(FinalInTargetLangFunctions | NonStaticFunctions | default_flags | public_flags);
+
+ // Virtual functions
+ returned += queryFunctions(VirtualInTargetLangFunctions | NonStaticFunctions | default_flags | public_flags);
+
+ // Static functions
+ returned += queryFunctions(StaticFunctions | default_flags | public_flags);
+
+ // Empty, private functions, since they aren't caught by the other ones
+ returned += queryFunctions(Empty | Invisible);
+
+ return returned;
+}
+
+AbstractMetaFunctionList AbstractMetaClass::virtualFunctions() const
+{
+ AbstractMetaFunctionList list = functionsInShellClass();
+
+ AbstractMetaFunctionList returned;
+ foreach (AbstractMetaFunction *f, list) {
+ if (!f->isFinalInCpp() || f->isVirtualSlot())
+ returned += f;
+ }
+
+ return returned;
+}
+
+AbstractMetaFunctionList AbstractMetaClass::implicitConversions() const
+{
+ if (!hasCloneOperator() && !hasExternalConversionOperators())
+ return AbstractMetaFunctionList();
+
+ AbstractMetaFunctionList returned;
+ AbstractMetaFunctionList list = queryFunctions(Constructors);
+
+ list.append(externalConversionOperators());
+
+ // Exclude anything that uses rvalue references, be it a move
+ // constructor "QPolygon(QPolygon &&)" or something else like
+ // "QPolygon(QVector<QPoint> &&)".
+ foreach (AbstractMetaFunction *f, list) {
+ if ((f->actualMinimumArgumentCount() == 1 || f->arguments().size() == 1 || f->isConversionOperator())
+ && !f->isExplicit()
+ && f->functionType() != AbstractMetaFunction::CopyConstructorFunction
+ && !f->usesRValueReferences()
+ && !f->isModifiedRemoved()
+ && (f->originalAttributes() & Public)) {
+ returned += f;
+ }
+ }
+ return returned;
+}
+
+AbstractMetaFunctionList AbstractMetaClass::operatorOverloads(OperatorQueryOptions query) const
+{
+ AbstractMetaFunctionList list = queryFunctions(OperatorOverloads | Visible);
+ AbstractMetaFunctionList returned;
+ foreach (AbstractMetaFunction *f, list) {
+ if (((query & ArithmeticOp) && f->isArithmeticOperator())
+ || ((query & BitwiseOp) && f->isBitwiseOperator())
+ || ((query & ComparisonOp) && f->isComparisonOperator())
+ || ((query & LogicalOp) && f->isLogicalOperator())
+ || ((query & SubscriptionOp) && f->isSubscriptOperator())
+ || ((query & AssignmentOp) && f->isAssignmentOperator())
+ || ((query & ConversionOp) && f->isConversionOperator())
+ || ((query & OtherOp) && f->isOtherOperator()))
+ returned += f;
+ }
+
+ return returned;
+}
+
+bool AbstractMetaClass::hasOperatorOverload() const
+{
+ foreach (const AbstractMetaFunction *f, m_functions) {
+ if (f->ownerClass() == f->implementingClass() && f->isOperatorOverload() && !f->isPrivate())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaClass::hasArithmeticOperatorOverload() const
+{
+ foreach (const AbstractMetaFunction *f, m_functions) {
+ if (f->ownerClass() == f->implementingClass() && f->isArithmeticOperator() && !f->isPrivate())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaClass::hasBitwiseOperatorOverload() const
+{
+ foreach (const AbstractMetaFunction *f, m_functions) {
+ if (f->ownerClass() == f->implementingClass() && f->isBitwiseOperator() && !f->isPrivate())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaClass::hasComparisonOperatorOverload() const
+{
+ foreach (const AbstractMetaFunction *f, m_functions) {
+ if (f->ownerClass() == f->implementingClass() && f->isComparisonOperator() && !f->isPrivate())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaClass::hasLogicalOperatorOverload() const
+{
+ foreach (const AbstractMetaFunction *f, m_functions) {
+ if (f->ownerClass() == f->implementingClass() && f->isLogicalOperator() && !f->isPrivate())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaClass::hasSubscriptOperatorOverload() const
+{
+ foreach (const AbstractMetaFunction *f, m_functions) {
+ if (f->ownerClass() == f->implementingClass() && f->isSubscriptOperator() && !f->isPrivate())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaClass::hasAssignmentOperatorOverload() const
+{
+ foreach (const AbstractMetaFunction *f, m_functions) {
+ if (f->ownerClass() == f->implementingClass() && f->isAssignmentOperator() && !f->isPrivate())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaClass::hasConversionOperatorOverload() const
+{
+ foreach (const AbstractMetaFunction *f, m_functions) {
+ if (f->ownerClass() == f->implementingClass() && f->isConversionOperator() && !f->isPrivate())
+ return true;
+ }
+ return false;
+}
+
+/*******************************************************************************
+ * Returns a list of all functions that should be declared and implemented in
+ * the shell class which is generated as a wrapper on top of the actual C++ class
+ */
+AbstractMetaFunctionList AbstractMetaClass::functionsInShellClass() const
+{
+ // Only functions and only protected and public functions
+ FunctionQueryOptions default_flags = NormalFunctions | Visible | WasVisible | NotRemovedFromShell;
+
+ // All virtual functions
+ AbstractMetaFunctionList returned = queryFunctions(VirtualFunctions | default_flags);
+
+ // All functions explicitly set to be implemented by the shell class
+ // (mainly superclass functions that are hidden by other declarations)
+ returned += queryFunctions(ForcedShellFunctions | default_flags);
+
+ // All functions explicitly set to be virtual slots
+ returned += queryFunctions(VirtualSlots | default_flags);
+
+ return returned;
+}
+
+/*******************************************************************************
+ * Returns a list of all functions that require a public override function to
+ * be generated in the shell class. This includes all functions that were originally
+ * protected in the superclass.
+ */
+AbstractMetaFunctionList AbstractMetaClass::publicOverrideFunctions() const
+{
+ return queryFunctions(NormalFunctions | WasProtected | FinalInCppFunctions | NotRemovedFromTargetLang)
+ + queryFunctions(Signals | WasProtected | FinalInCppFunctions | NotRemovedFromTargetLang);
+}
+
+AbstractMetaFunctionList AbstractMetaClass::virtualOverrideFunctions() const
+{
+ return queryFunctions(NormalFunctions | NonEmptyFunctions | Visible | VirtualInCppFunctions | NotRemovedFromShell) +
+ queryFunctions(Signals | NonEmptyFunctions | Visible | VirtualInCppFunctions | NotRemovedFromShell);
+}
+
+void AbstractMetaClass::sortFunctions()
+{
+ qSort(m_functions.begin(), m_functions.end(), function_sorter);
+}
+
+void AbstractMetaClass::setFunctions(const AbstractMetaFunctionList &functions)
+{
+ m_functions = functions;
+
+ // Functions must be sorted by name before next loop
+ sortFunctions();
+
+ QString currentName;
+ bool hasVirtuals = false;
+ AbstractMetaFunctionList finalFunctions;
+ foreach (AbstractMetaFunction *f, m_functions) {
+ f->setOwnerClass(this);
+
+ m_hasVirtualSlots = m_hasVirtualSlots || f->isVirtualSlot();
+ m_hasVirtuals = m_hasVirtuals || f->isVirtualSlot() || hasVirtualDestructor();
+ m_isPolymorphic = m_isPolymorphic || m_hasVirtuals;
+ m_hasNonpublic = m_hasNonpublic || !f->isPublic();
+
+ // If we have non-virtual overloads of a virtual function, we have to implement
+ // all the overloads in the shell class to override the hiding rule
+ if (currentName == f->name()) {
+ hasVirtuals = hasVirtuals || !f->isFinal();
+ if (f->isFinal())
+ finalFunctions += f;
+ } else {
+ if (hasVirtuals && finalFunctions.size() > 0) {
+ foreach (AbstractMetaFunction *final_function, finalFunctions) {
+ *final_function += AbstractMetaAttributes::ForceShellImplementation;
+
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("hiding of function '%1' in class '%2'")
+ .arg(final_function->name(), name());
+ }
+ }
+
+ hasVirtuals = !f->isFinal();
+ finalFunctions.clear();
+ if (f->isFinal())
+ finalFunctions += f;
+ currentName = f->name();
+ }
+ }
+}
+
+bool AbstractMetaClass::hasFieldAccessors() const
+{
+ foreach (const AbstractMetaField *field, fields()) {
+ if (field->getter() || field->setter())
+ return true;
+ }
+
+ return false;
+}
+
+bool AbstractMetaClass::hasDefaultToStringFunction() const
+{
+ foreach (AbstractMetaFunction *f, queryFunctionsByName(QLatin1String("toString"))) {
+ if (!f->actualMinimumArgumentCount())
+ return true;
+ }
+ return false;
+}
+
+void AbstractMetaClass::addFunction(AbstractMetaFunction *function)
+{
+ Q_ASSERT(!function->signature().startsWith(QLatin1Char('(')));
+ function->setOwnerClass(this);
+
+ if (!function->isDestructor())
+ m_functions << function;
+ else
+ Q_ASSERT(false); //memory leak
+
+ m_hasVirtualSlots |= function->isVirtualSlot();
+ m_hasVirtuals |= !function->isFinal() || function->isVirtualSlot() || hasVirtualDestructor();
+ m_isPolymorphic |= m_hasVirtuals;
+ m_hasNonpublic |= !function->isPublic();
+}
+
+bool AbstractMetaClass::hasSignal(const AbstractMetaFunction *other) const
+{
+ if (!other->isSignal())
+ return false;
+
+ foreach (const AbstractMetaFunction *f, functions()) {
+ if (f->isSignal() && f->compareTo(other) & AbstractMetaFunction::EqualName)
+ return other->modifiedName() == f->modifiedName();
+ }
+
+ return false;
+}
+
+
+QString AbstractMetaClass::name() const
+{
+ return QString(m_typeEntry->targetLangName()).split(QLatin1String("::")).last();
+}
+
+void AbstractMetaClass::setBaseClass(AbstractMetaClass *baseClass)
+{
+ m_baseClass = baseClass;
+ if (baseClass)
+ m_isPolymorphic |= baseClass->isPolymorphic();
+}
+
+QString AbstractMetaClass::package() const
+{
+ return m_typeEntry->targetLangPackage();
+}
+
+bool AbstractMetaClass::isInterface() const
+{
+ return m_typeEntry->isInterface();
+}
+
+bool AbstractMetaClass::isNamespace() const
+{
+ return m_typeEntry->isNamespace();
+}
+
+bool AbstractMetaClass::isQObject() const
+{
+ return m_typeEntry->isQObject();
+}
+
+QString AbstractMetaClass::qualifiedCppName() const
+{
+ return m_typeEntry->qualifiedCppName();
+}
+
+bool AbstractMetaClass::hasFunction(const QString &str) const
+{
+ return findFunction(str);
+}
+
+const AbstractMetaFunction* AbstractMetaClass::findFunction(const QString& functionName) const
+{
+ foreach (const AbstractMetaFunction *f, functions()) {
+ if (f->name() == functionName)
+ return f;
+ }
+ return 0;
+}
+
+bool AbstractMetaClass::hasProtectedFunctions() const
+{
+ foreach (AbstractMetaFunction *func, m_functions) {
+ if (func->isProtected())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaClass::hasProtectedFields() const
+{
+ foreach (const AbstractMetaField *field, fields()) {
+ if (field->isProtected())
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaClass::hasProtectedMembers() const
+{
+ return hasProtectedFields() || hasProtectedFunctions();
+}
+
+bool AbstractMetaClass::generateShellClass() const
+{
+ return m_forceShellClass ||
+ (!isFinal()
+ && (hasVirtualFunctions()
+ || hasProtectedFunctions()
+ || hasFieldAccessors()));
+}
+
+QPropertySpec *AbstractMetaClass::propertySpecForRead(const QString &name) const
+{
+ for (int i = 0; i < m_propertySpecs.size(); ++i)
+ if (name == m_propertySpecs.at(i)->read())
+ return m_propertySpecs.at(i);
+ return 0;
+}
+
+QPropertySpec *AbstractMetaClass::propertySpecForWrite(const QString &name) const
+{
+ for (int i = 0; i < m_propertySpecs.size(); ++i)
+ if (name == m_propertySpecs.at(i)->write())
+ return m_propertySpecs.at(i);
+ return 0;
+}
+
+QPropertySpec *AbstractMetaClass::propertySpecForReset(const QString &name) const
+{
+ for (int i = 0; i < m_propertySpecs.size(); ++i) {
+ if (name == m_propertySpecs.at(i)->reset())
+ return m_propertySpecs.at(i);
+ }
+ return 0;
+}
+
+typedef QHash<const AbstractMetaClass*, AbstractMetaTypeList> AbstractMetaClassBaseTemplateInstantiationsMap;
+Q_GLOBAL_STATIC(AbstractMetaClassBaseTemplateInstantiationsMap, metaClassBaseTemplateInstantiations);
+
+bool AbstractMetaClass::hasTemplateBaseClassInstantiations() const
+{
+ if (!templateBaseClass())
+ return false;
+ return metaClassBaseTemplateInstantiations()->contains(this);
+}
+
+AbstractMetaTypeList AbstractMetaClass::templateBaseClassInstantiations() const
+{
+ if (!templateBaseClass())
+ return AbstractMetaTypeList();
+ return metaClassBaseTemplateInstantiations()->value(this);
+}
+
+void AbstractMetaClass::setTemplateBaseClassInstantiations(AbstractMetaTypeList& instantiations)
+{
+ if (!templateBaseClass())
+ return;
+ metaClassBaseTemplateInstantiations()->insert(this, instantiations);
+}
+
+static bool functions_contains(const AbstractMetaFunctionList &l, const AbstractMetaFunction *func)
+{
+ foreach (const AbstractMetaFunction *f, l) {
+ if ((f->compareTo(func) & AbstractMetaFunction::PrettySimilar) == AbstractMetaFunction::PrettySimilar)
+ return true;
+ }
+ return false;
+}
+
+AbstractMetaField::AbstractMetaField() : m_getter(0), m_setter(0), m_class(0)
+{
+}
+
+AbstractMetaField::~AbstractMetaField()
+{
+ delete m_setter;
+ delete m_getter;
+}
+
+AbstractMetaField *AbstractMetaField::copy() const
+{
+ AbstractMetaField *returned = new AbstractMetaField;
+ returned->setEnclosingClass(0);
+ returned->setAttributes(attributes());
+ returned->setName(name());
+ returned->setType(type()->copy());
+ returned->setOriginalAttributes(originalAttributes());
+
+ return returned;
+}
+
+/*******************************************************************************
+ * Indicates that this field has a modification that removes it
+ */
+bool AbstractMetaField::isModifiedRemoved(int types) const
+{
+ FieldModificationList mods = modifications();
+ foreach (const FieldModification &mod, mods) {
+ if (!mod.isRemoveModifier())
+ continue;
+
+ if ((mod.removal & types) == types)
+ return true;
+ }
+
+ return false;
+}
+
+static QString upCaseFirst(const QString &str)
+{
+ Q_ASSERT(!str.isEmpty());
+ QString s = str;
+ s[0] = s.at(0).toUpper();
+ return s;
+}
+
+static AbstractMetaFunction *createXetter(const AbstractMetaField *g, const QString &name,
+ AbstractMetaAttributes::Attributes type)
+{
+ AbstractMetaFunction *f = new AbstractMetaFunction;
+
+ f->setName(name);
+ f->setOriginalName(name);
+ f->setOwnerClass(g->enclosingClass());
+ f->setImplementingClass(g->enclosingClass());
+ f->setDeclaringClass(g->enclosingClass());
+
+ AbstractMetaAttributes::Attributes attr = AbstractMetaAttributes::Native
+ | AbstractMetaAttributes::Final
+ | type;
+ if (g->isStatic())
+ attr |= AbstractMetaAttributes::Static;
+ if (g->isPublic())
+ attr |= AbstractMetaAttributes::Public;
+ else if (g->isProtected())
+ attr |= AbstractMetaAttributes::Protected;
+ else
+ attr |= AbstractMetaAttributes::Private;
+ f->setAttributes(attr);
+ f->setOriginalAttributes(attr);
+
+ FieldModificationList mods = g->modifications();
+ foreach (const FieldModification &mod, mods) {
+ if (mod.isRenameModifier())
+ f->setName(mod.renamedTo());
+ if (mod.isAccessModifier()) {
+ if (mod.isPrivate())
+ f->setVisibility(AbstractMetaAttributes::Private);
+ else if (mod.isProtected())
+ f->setVisibility(AbstractMetaAttributes::Protected);
+ else if (mod.isPublic())
+ f->setVisibility(AbstractMetaAttributes::Public);
+ else if (mod.isFriendly())
+ f->setVisibility(AbstractMetaAttributes::Friendly);
+ }
+ }
+ return f;
+}
+
+FieldModificationList AbstractMetaField::modifications() const
+{
+ FieldModificationList mods = enclosingClass()->typeEntry()->fieldModifications();
+ FieldModificationList returned;
+
+ foreach (const FieldModification &mod, mods) {
+ if (mod.name == name())
+ returned += mod;
+ }
+
+ return returned;
+}
+
+const AbstractMetaFunction *AbstractMetaField::setter() const
+{
+ if (!m_setter) {
+ m_setter = createXetter(this,
+ QLatin1String("set") + upCaseFirst(name()),
+ AbstractMetaAttributes::SetterFunction);
+ AbstractMetaArgumentList arguments;
+ AbstractMetaArgument *argument = new AbstractMetaArgument;
+ argument->setType(type()->copy());
+ argument->setName(name());
+ arguments.append(argument);
+ m_setter->setArguments(arguments);
+ }
+ return m_setter;
+}
+
+const AbstractMetaFunction *AbstractMetaField::getter() const
+{
+ if (!m_getter) {
+ m_getter = createXetter(this,
+ name(),
+ AbstractMetaAttributes::GetterFunction);
+ m_getter->setType(type());
+ }
+
+ return m_getter;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+static void formatMetaAttributes(QDebug &d, AbstractMetaAttributes::Attributes value)
+{
+ static const int meIndex = AbstractMetaAttributes::staticMetaObject.indexOfEnumerator("Attribute");
+ Q_ASSERT(meIndex >= 0);
+ const QMetaEnum me = AbstractMetaAttributes::staticMetaObject.enumerator(meIndex);
+ d << me.valueToKeys(value);
+}
+
+static void formatMetaField(QDebug &d, const AbstractMetaField *af)
+{
+ formatMetaAttributes(d, af->attributes());
+ d << ' ' << af->type()->name() << " \"" << af->name() << '"';
+}
+
+QDebug operator<<(QDebug d, const AbstractMetaField *af)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AbstractMetaField(";
+ if (af)
+ formatMetaField(d, af);
+ else
+ d << '0';
+ d << ')';
+ return d;
+}
+
+static void formatMetaEnumValue(QDebug &d, const AbstractMetaEnumValue *v)
+{
+ const QString &name = v->stringValue();
+ if (!name.isEmpty())
+ d << name << '=';
+ d << v->value();
+}
+
+QDebug operator<<(QDebug d, const AbstractMetaEnumValue *v)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AbstractMetaEnumValue(";
+ if (v)
+ formatMetaEnumValue(d, v);
+ else
+ d << '0';
+ d << ')';
+ return d;
+}
+
+QDebug operator<<(QDebug d, const AbstractMetaEnum *ae)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AbstractMetaEnum(";
+ if (ae) {
+ d << ae->fullName() << '[';
+ const AbstractMetaEnumValueList &values = ae->values();
+ for (int i = 0, count = values.size(); i < count; ++i) {
+ if (i)
+ d << ' ';
+ formatMetaEnumValue(d, values.at(i));
+ }
+ d << ']';
+ } else {
+ d << '0';
+ }
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+bool AbstractMetaClass::hasConstructors() const
+{
+ return queryFunctions(Constructors).size();
+}
+
+bool AbstractMetaClass::hasCopyConstructor() const
+{
+ foreach (const AbstractMetaFunction* ctor, queryFunctions(Constructors)) {
+ if (ctor->functionType() == AbstractMetaFunction::CopyConstructorFunction)
+ return true;
+ }
+ return false;
+}
+
+bool AbstractMetaClass::hasPrivateCopyConstructor() const
+{
+ foreach (const AbstractMetaFunction* ctor, queryFunctions(Constructors)) {
+ if (ctor->functionType() == AbstractMetaFunction::CopyConstructorFunction && ctor->isPrivate())
+ return true;
+ }
+ return false;
+}
+
+void AbstractMetaClass::addDefaultConstructor()
+{
+ AbstractMetaFunction *f = new AbstractMetaFunction;
+ f->setOriginalName(name());
+ f->setName(name());
+ f->setOwnerClass(this);
+ f->setFunctionType(AbstractMetaFunction::ConstructorFunction);
+ f->setArguments(AbstractMetaArgumentList());
+ f->setDeclaringClass(this);
+
+ AbstractMetaAttributes::Attributes attr = AbstractMetaAttributes::Native;
+ attr |= AbstractMetaAttributes::Public;
+ attr |= AbstractMetaAttributes::Final;
+ f->setAttributes(attr);
+ f->setImplementingClass(this);
+ f->setOriginalAttributes(f->attributes());
+
+ addFunction(f);
+ this->setHasNonPrivateConstructor(true);
+}
+
+void AbstractMetaClass::addDefaultCopyConstructor(bool isPrivate)
+{
+ AbstractMetaFunction* f = new AbstractMetaFunction;
+ f->setOriginalName(name());
+ f->setName(name());
+ f->setOwnerClass(this);
+ f->setFunctionType(AbstractMetaFunction::CopyConstructorFunction);
+ f->setDeclaringClass(this);
+
+ AbstractMetaType* argType = new AbstractMetaType;
+ argType->setTypeEntry(typeEntry());
+ argType->setReferenceType(LValueReference);
+ argType->setConstant(true);
+ argType->setTypeUsagePattern(AbstractMetaType::ValuePattern);
+
+ AbstractMetaArgument* arg = new AbstractMetaArgument;
+ arg->setType(argType);
+ arg->setName(name());
+ f->addArgument(arg);
+
+ AbstractMetaAttributes::Attributes attr = AbstractMetaAttributes::Native;
+ attr |= AbstractMetaAttributes::Final;
+ if (isPrivate)
+ attr |= AbstractMetaAttributes::Private;
+ else
+ attr |= AbstractMetaAttributes::Public;
+ f->setAttributes(attr);
+ f->setImplementingClass(this);
+ f->setOriginalAttributes(f->attributes());
+
+ addFunction(f);
+}
+
+bool AbstractMetaClass::hasFunction(const AbstractMetaFunction *f) const
+{
+ return functions_contains(m_functions, f);
+}
+
+/* Goes through the list of functions and returns a list of all
+ functions matching all of the criteria in \a query.
+ */
+
+AbstractMetaFunctionList AbstractMetaClass::queryFunctions(FunctionQueryOptions query) const
+{
+ AbstractMetaFunctionList functions;
+
+ foreach (AbstractMetaFunction *f, m_functions) {
+
+ if ((query & VirtualSlots) && !f->isVirtualSlot())
+ continue;
+
+ if ((query & NotRemovedFromTargetLang) && f->isRemovedFrom(f->implementingClass(), TypeSystem::TargetLangCode))
+ continue;
+
+ if ((query & NotRemovedFromTargetLang) && !f->isFinal() && f->isRemovedFrom(f->declaringClass(), TypeSystem::TargetLangCode))
+ continue;
+
+ if ((query & NotRemovedFromShell) && f->isRemovedFrom(f->implementingClass(), TypeSystem::ShellCode))
+ continue;
+
+ if ((query & NotRemovedFromShell) && !f->isFinal() && f->isRemovedFrom(f->declaringClass(), TypeSystem::ShellCode))
+ continue;
+
+ if ((query & Visible) && f->isPrivate())
+ continue;
+
+ if ((query & VirtualInTargetLangFunctions) && f->isFinalInTargetLang())
+ continue;
+
+ if ((query & Invisible) && !f->isPrivate())
+ continue;
+
+ if ((query & Empty) && !f->isEmptyFunction())
+ continue;
+
+ if ((query & WasPublic) && !f->wasPublic())
+ continue;
+
+ if ((query & WasVisible) && f->wasPrivate())
+ continue;
+
+ if ((query & WasProtected) && !f->wasProtected())
+ continue;
+
+ if ((query & ClassImplements) && f->ownerClass() != f->implementingClass())
+ continue;
+
+ if ((query & Inconsistent) && (f->isFinalInTargetLang() || !f->isFinalInCpp() || f->isStatic()))
+ continue;
+
+ if ((query & FinalInTargetLangFunctions) && !f->isFinalInTargetLang())
+ continue;
+
+ if ((query & FinalInCppFunctions) && !f->isFinalInCpp())
+ continue;
+
+ if ((query & VirtualInCppFunctions) && f->isFinalInCpp())
+ continue;
+
+ if ((query & Signals) && (!f->isSignal()))
+ continue;
+
+ if ((query & ForcedShellFunctions) &&
+ (!f->isForcedShellImplementation() || !f->isFinal())) {
+ continue;
+ }
+
+ if ((query & Constructors) && (!f->isConstructor() || f->ownerClass() != f->implementingClass()))
+ continue;
+
+ if (!(query & Constructors) && f->isConstructor())
+ continue;
+
+ // Destructors are never included in the functions of a class currently
+ /*
+ if ((query & Destructors) && (!f->isDestructor()
+ || f->ownerClass() != f->implementingClass())
+ || f->isDestructor() && (query & Destructors) == 0) {
+ continue;
+ }*/
+
+ if ((query & VirtualFunctions) && (f->isFinal() || f->isSignal() || f->isStatic()))
+ continue;
+
+ if ((query & StaticFunctions) && (!f->isStatic() || f->isSignal()))
+ continue;
+
+ if ((query & NonStaticFunctions) && (f->isStatic()))
+ continue;
+
+ if ((query & NonEmptyFunctions) && (f->isEmptyFunction()))
+ continue;
+
+ if ((query & NormalFunctions) && (f->isSignal()))
+ continue;
+
+ if ((query & AbstractFunctions) && !f->isAbstract())
+ continue;
+
+ if ((query & OperatorOverloads) && !f->isOperatorOverload())
+ continue;
+
+ functions << f;
+ }
+
+ return functions;
+}
+
+bool AbstractMetaClass::hasSignals() const
+{
+ return cppSignalFunctions().size() > 0;
+}
+
+
+/**
+ * Adds the specified interface to this class by adding all the
+ * functions in the interface to this class.
+ */
+void AbstractMetaClass::addInterface(AbstractMetaClass *interface)
+{
+ Q_ASSERT(!m_interfaces.contains(interface));
+ m_interfaces << interface;
+
+ m_isPolymorphic |= interface->isPolymorphic();
+
+ if (m_extractedInterface && m_extractedInterface != interface)
+ m_extractedInterface->addInterface(interface);
+
+#if 0
+ foreach (AbstractMetaFunction *function, interface->functions())
+ if (!hasFunction(function) && !function->isConstructor()) {
+ AbstractMetaFunction *cpy = function->copy();
+ cpy->setImplementingClass(this);
+
+ // Setup that this function is an interface class.
+ cpy->setInterfaceClass(interface);
+ *cpy += AbstractMetaAttributes::InterfaceFunction;
+
+ // Copy the modifications in interface into the implementing classes.
+ FunctionModificationList mods = function->modifications(interface);
+ foreach (const FunctionModification &mod, mods)
+ m_typeEntry->addFunctionModification(mod);
+
+ // It should be mostly safe to assume that when we implement an interface
+ // we don't "pass on" pure virtual functions to our sublcasses...
+// *cpy -= AbstractMetaAttributes::Abstract;
+
+ addFunction(cpy);
+ }
+#endif
+
+}
+
+
+void AbstractMetaClass::setInterfaces(const AbstractMetaClassList &interfaces)
+{
+ m_interfaces = interfaces;
+ foreach (const AbstractMetaClass* interface, interfaces) {
+ if (interface)
+ m_isPolymorphic |= interface->isPolymorphic();
+ }
+}
+
+
+AbstractMetaEnum *AbstractMetaClass::findEnum(const QString &enumName)
+{
+ foreach (AbstractMetaEnum *e, m_enums) {
+ if (e->name() == enumName)
+ return e;
+ }
+
+ if (typeEntry()->designatedInterface())
+ return extractInterface()->findEnum(enumName);
+
+ return 0;
+}
+
+
+
+
+/*! Recursivly searches for the enum value named \a enumValueName in
+ this class and its superclasses and interfaces. Values belonging to
+ \a meta_enum are excluded from the search.
+*/
+AbstractMetaEnumValue *AbstractMetaClass::findEnumValue(const QString &enumValueName, AbstractMetaEnum *meta_enum)
+{
+ foreach (AbstractMetaEnum *e, m_enums) {
+ if (e != meta_enum)
+ continue;
+ foreach (AbstractMetaEnumValue *v, e->values()) {
+ if (v->name() == enumValueName)
+ return v;
+ }
+ }
+
+ if (typeEntry()->designatedInterface())
+ return extractInterface()->findEnumValue(enumValueName, meta_enum);
+
+ if (baseClass())
+ return baseClass()->findEnumValue(enumValueName, meta_enum);
+
+ return 0;
+}
+
+
+/*!
+ * Searches through all of this class' enums for a value matching the
+ * name \a enumValueName. The name is excluding the class/namespace
+ * prefix. The function recursivly searches interfaces and baseclasses
+ * of this class.
+ */
+AbstractMetaEnum *AbstractMetaClass::findEnumForValue(const QString &enumValueName)
+{
+ foreach (AbstractMetaEnum *e, m_enums) {
+ foreach (AbstractMetaEnumValue *v, e->values()) {
+ if (v->name() == enumValueName)
+ return e;
+ }
+ }
+
+ if (typeEntry()->designatedInterface())
+ return extractInterface()->findEnumForValue(enumValueName);
+
+ if (baseClass())
+ return baseClass()->findEnumForValue(enumValueName);
+
+ return 0;
+}
+
+
+static void addExtraIncludeForType(AbstractMetaClass *metaClass, const AbstractMetaType *type)
+{
+ if (!type)
+ return;
+
+ Q_ASSERT(metaClass);
+ const TypeEntry *entry = (type ? type->typeEntry() : 0);
+ if (entry && entry->isComplex()) {
+ const ComplexTypeEntry *centry = static_cast<const ComplexTypeEntry *>(entry);
+ ComplexTypeEntry *class_entry = metaClass->typeEntry();
+ if (class_entry && centry->include().isValid())
+ class_entry->addExtraInclude(centry->include());
+ }
+
+ if (type->hasInstantiations()) {
+ AbstractMetaTypeList instantiations = type->instantiations();
+ foreach (const AbstractMetaType *instantiation, instantiations)
+ addExtraIncludeForType(metaClass, instantiation);
+ }
+}
+
+static void addExtraIncludesForFunction(AbstractMetaClass *metaClass, const AbstractMetaFunction *meta_function)
+{
+ Q_ASSERT(metaClass);
+ Q_ASSERT(meta_function);
+ addExtraIncludeForType(metaClass, meta_function->type());
+
+ AbstractMetaArgumentList arguments = meta_function->arguments();
+ foreach (AbstractMetaArgument *argument, arguments)
+ addExtraIncludeForType(metaClass, argument->type());
+}
+
+void AbstractMetaClass::fixFunctions()
+{
+ if (m_functionsFixed)
+ return;
+ else
+ m_functionsFixed = true;
+
+ AbstractMetaClass *superClass = baseClass();
+ AbstractMetaFunctionList funcs = functions();
+
+ if (superClass)
+ superClass->fixFunctions();
+ int iface_idx = 0;
+ while (superClass || iface_idx < interfaces().size()) {
+ // Since we always traverse the complete hierarchy we are only
+ // interrested in what each super class implements, not what
+ // we may have propagated from their base classes again.
+ AbstractMetaFunctionList superFuncs;
+ if (superClass) {
+ // Super classes can never be final
+ if (superClass->isFinalInTargetLang()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Final class '" << superClass->name() << "' set to non-final, as it is extended by other classes";
+ *superClass -= AbstractMetaAttributes::FinalInTargetLang;
+ }
+ superFuncs = superClass->queryFunctions(AbstractMetaClass::ClassImplements);
+ AbstractMetaFunctionList virtuals = superClass->queryFunctions(AbstractMetaClass::VirtualInCppFunctions);
+ superFuncs += virtuals;
+ } else {
+ superFuncs = interfaces().at(iface_idx)->queryFunctions(AbstractMetaClass::NormalFunctions);
+ AbstractMetaFunctionList virtuals = interfaces().at(iface_idx)->queryFunctions(AbstractMetaClass::VirtualInCppFunctions);
+ superFuncs += virtuals;
+ }
+
+ QSet<AbstractMetaFunction *> funcsToAdd;
+ for (int sfi = 0; sfi < superFuncs.size(); ++sfi) {
+ AbstractMetaFunction *sf = superFuncs.at(sfi);
+
+ if (sf->isRemovedFromAllLanguages(sf->implementingClass()))
+ continue;
+
+ // skip functions added in base classes
+ if (sf->isUserAdded() && sf->declaringClass() != this)
+ continue;
+
+ // we generally don't care about private functions, but we have to get the ones that are
+ // virtual in case they override abstract functions.
+ bool add = (sf->isNormal() || sf->isSignal() || sf->isEmptyFunction());
+ for (int fi = 0; fi < funcs.size(); ++fi) {
+ AbstractMetaFunction *f = funcs.at(fi);
+ if (f->isRemovedFromAllLanguages(f->implementingClass()))
+ continue;
+
+
+ const AbstractMetaFunction::CompareResult cmp = f->compareTo(sf);
+
+ if (cmp & AbstractMetaFunction::EqualModifiedName) {
+ add = false;
+ if (cmp & AbstractMetaFunction::EqualArguments) {
+ // Same function, propegate virtual...
+ if (!(cmp & AbstractMetaFunction::EqualAttributes)) {
+ if (!f->isEmptyFunction()) {
+ if (!sf->isFinalInCpp() && f->isFinalInCpp()) {
+ *f -= AbstractMetaAttributes::FinalInCpp;
+ }
+ if (!sf->isFinalInTargetLang() && f->isFinalInTargetLang()) {
+ *f -= AbstractMetaAttributes::FinalInTargetLang;
+ }
+#if 0
+ if (!f->isFinalInTargetLang() && f->isPrivate()) {
+ f->setFunctionType(AbstractMetaFunction::EmptyFunction);
+ f->setVisibility(AbstractMetaAttributes::Protected);
+ *f += AbstractMetaAttributes::FinalInTargetLang;
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("private virtual function '%1' in '%2'")
+ .arg(f->signature(), f->implementingClass()->name());
+ }
+#endif
+ }
+ }
+
+ if (f->visibility() != sf->visibility()) {
+ QString warn = QStringLiteral("visibility of function '%1' modified in class '%2'")
+ .arg(f->name(), name());
+ qCWarning(lcShiboken).noquote().nospace() << warn;
+#if 0
+ // If new visibility is private, we can't
+ // do anything. If it isn't, then we
+ // prefer the parent class's visibility
+ // setting for the function.
+ if (!f->isPrivate() && !sf->isPrivate())
+ f->setVisibility(sf->visibility());
+#endif
+ // Private overrides of abstract functions have to go into the class or
+ // the subclasses will not compile as non-abstract classes.
+ // But they don't need to be implemented, since they can never be called.
+ if (f->isPrivate()) {
+ f->setFunctionType(AbstractMetaFunction::EmptyFunction);
+ *f += AbstractMetaAttributes::FinalInTargetLang;
+ *f += AbstractMetaAttributes::FinalInCpp;
+ }
+ }
+
+ // Set the class which first declares this function, afawk
+ f->setDeclaringClass(sf->declaringClass());
+
+ if (sf->isFinalInTargetLang() && !sf->isPrivate() && !f->isPrivate() && !sf->isStatic() && !f->isStatic()) {
+ // Shadowed funcion, need to make base class
+ // function non-virtual
+ if (f->implementingClass() != sf->implementingClass() && f->implementingClass()->inheritsFrom(sf->implementingClass())) {
+
+ // Check whether the superclass method has been redefined to non-final
+
+ bool hasNonFinalModifier = false;
+ bool isBaseImplPrivate = false;
+ FunctionModificationList mods = sf->modifications(sf->implementingClass());
+ foreach (const FunctionModification &mod, mods) {
+ if (mod.isNonFinal()) {
+ hasNonFinalModifier = true;
+ break;
+ } else if (mod.isPrivate()) {
+ isBaseImplPrivate = true;
+ break;
+ }
+ }
+
+ if (!hasNonFinalModifier && !isBaseImplPrivate) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Shadowing: %1::%2 and %3::%4")
+ .arg(sf->implementingClass()->name(), sf->signature(),
+ f->implementingClass()->name(), f->signature());
+ }
+ }
+ }
+
+ }
+
+ if (cmp & AbstractMetaFunction::EqualDefaultValueOverload) {
+ AbstractMetaArgumentList arguments;
+ if (f->arguments().size() < sf->arguments().size())
+ arguments = sf->arguments();
+ else
+ arguments = f->arguments();
+ //TODO: fix this
+ //for (int i=0; i<arguments.size(); ++i)
+ // arguments[i]->setDefaultValueExpression("<#>" + QString());
+ }
+
+
+ // Otherwise we have function shadowing and we can
+ // skip the thing...
+ } else if (cmp & AbstractMetaFunction::EqualName && !sf->isSignal()) {
+ // In the case of function shadowing where the function name has been altered to
+ // avoid conflict, we don't copy in the original.
+ add = false;
+ }
+ }
+
+ if (add)
+ funcsToAdd << sf;
+ }
+
+ foreach (AbstractMetaFunction *f, funcsToAdd)
+ funcs << f->copy();
+
+ if (superClass)
+ superClass = superClass->baseClass();
+ else
+ iface_idx++;
+ }
+
+ bool hasPrivateConstructors = false;
+ bool hasPublicConstructors = false;
+ foreach (AbstractMetaFunction *func, funcs) {
+ FunctionModificationList mods = func->modifications(this);
+ foreach (const FunctionModification &mod, mods) {
+ if (mod.isRenameModifier()) {
+ func->setName(mod.renamedTo());
+ }
+ }
+
+ // Make sure class is abstract if one of the functions is
+ if (func->isAbstract()) {
+ (*this) += AbstractMetaAttributes::Abstract;
+ (*this) -= AbstractMetaAttributes::Final;
+ }
+
+ if (func->isConstructor()) {
+ if (func->isPrivate())
+ hasPrivateConstructors = true;
+ else
+ hasPublicConstructors = true;
+ }
+
+
+
+ // Make sure that we include files for all classes that are in use
+
+ if (!func->isRemovedFrom(this, TypeSystem::ShellCode))
+ addExtraIncludesForFunction(this, func);
+ }
+
+ if (hasPrivateConstructors && !hasPublicConstructors) {
+ (*this) += AbstractMetaAttributes::Abstract;
+ (*this) -= AbstractMetaAttributes::Final;
+ }
+
+ foreach (AbstractMetaFunction *f1, funcs) {
+ foreach (AbstractMetaFunction *f2, funcs) {
+ if (f1 != f2) {
+ const AbstractMetaFunction::CompareResult cmp = f1->compareTo(f2);
+ if ((cmp & AbstractMetaFunction::EqualName)
+ && !f1->isFinalInCpp()
+ && f2->isFinalInCpp()) {
+ *f2 += AbstractMetaAttributes::FinalOverload;
+ }
+ }
+ }
+ }
+
+ setFunctions(funcs);
+}
+
+
+QString AbstractMetaType::minimalSignature() const
+{
+ QString minimalSignature;
+ if (isConstant())
+ minimalSignature += QLatin1String("const ");
+ minimalSignature += typeEntry()->qualifiedCppName();
+ if (hasInstantiations()) {
+ AbstractMetaTypeList instantiations = this->instantiations();
+ minimalSignature += QLatin1String("< ");
+ for (int i = 0; i < instantiations.size(); ++i) {
+ if (i > 0)
+ minimalSignature += QLatin1Char(',');
+ minimalSignature += instantiations[i]->minimalSignature();
+ }
+ minimalSignature += QLatin1String(" >");
+ }
+
+ for (int j = 0; j < indirections(); ++j)
+ minimalSignature += QLatin1Char('*');
+ switch (referenceType()) {
+ case NoReference:
+ break;
+ case LValueReference:
+ minimalSignature += QLatin1Char('&');
+ break;
+ case RValueReference:
+ minimalSignature += QLatin1String("&&");
+ break;
+ }
+
+ return minimalSignature;
+}
+
+bool AbstractMetaType::hasNativeId() const
+{
+ return (isQObject() || isValue() || isObject()) && typeEntry()->isNativeIdBased();
+}
+
+bool AbstractMetaType::isTargetLangEnum() const
+{
+ return isEnum() && !static_cast<const EnumTypeEntry *>(typeEntry())->forceInteger();
+}
+
+bool AbstractMetaType::isTargetLangFlags() const
+{
+ return isFlags() && !static_cast<const FlagsTypeEntry *>(typeEntry())->forceInteger();
+}
+
+
+/*******************************************************************************
+ * Other stuff...
+ */
+
+
+AbstractMetaEnum *AbstractMetaClass::findEnum(const AbstractMetaClassList &classes,
+ const EnumTypeEntry *entry)
+{
+ Q_ASSERT(entry->isEnum());
+
+ QString qualifiedName = entry->qualifiedCppName();
+ int pos = qualifiedName.lastIndexOf(QLatin1String("::"));
+
+ QString enumName;
+ QString className;
+
+ if (pos > 0) {
+ enumName = qualifiedName.mid(pos + 2);
+ className = qualifiedName.mid(0, pos);
+ } else {
+ enumName = qualifiedName;
+ className = TypeDatabase::globalNamespaceClassName(entry);
+ }
+
+ AbstractMetaClass *metaClass = AbstractMetaClass::findClass(classes, className);
+ if (!metaClass) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("AbstractMeta::findEnum(), unknown class '%1' in '%2'")
+ .arg(className, entry->qualifiedCppName());
+ return 0;
+ }
+
+ return metaClass->findEnum(enumName);
+}
+
+AbstractMetaEnumValue *AbstractMetaEnumValueList::find(const QString &name) const
+{
+ for (int i = 0; i < size(); ++i) {
+ if (name == at(i)->name())
+ return at(i);
+ }
+ return 0;
+}
+
+AbstractMetaEnumValue *AbstractMetaClass::findEnumValue(const AbstractMetaClassList &classes,
+ const QString &name)
+{
+ QStringList lst = name.split(QLatin1String("::"));
+
+ if (lst.size() > 1) {
+ QString prefixName = lst.at(0);
+ QString enumName = lst.at(1);
+
+ AbstractMetaClass* cl = findClass(classes, prefixName);
+ if (cl)
+ return cl->findEnumValue(enumName, 0);
+ }
+
+ foreach (AbstractMetaClass* metaClass, classes) {
+ foreach(AbstractMetaEnum* metaEnum, metaClass->enums()) {
+ AbstractMetaEnumValue* enumValue = metaClass->findEnumValue(name, metaEnum);
+ if (enumValue)
+ return enumValue;
+ }
+ }
+
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("no matching enum '%1'").arg(name);
+ return 0;
+}
+
+/*!
+ * Searches the list after a class that mathces \a name; either as
+ * C++, Target language base name or complete Target language package.class name.
+ */
+
+AbstractMetaClass *AbstractMetaClass::findClass(const AbstractMetaClassList &classes,
+ const QString &name)
+{
+ if (name.isEmpty())
+ return 0;
+
+ foreach (AbstractMetaClass *c, classes) {
+ if (c->qualifiedCppName() == name)
+ return c;
+ }
+
+ foreach (AbstractMetaClass *c, classes) {
+ if (c->fullName() == name)
+ return c;
+ }
+
+ foreach (AbstractMetaClass *c, classes) {
+ if (c->name() == name)
+ return c;
+ }
+
+ return 0;
+}
+
+AbstractMetaClass *AbstractMetaClass::findClass(const AbstractMetaClassList &classes,
+ const TypeEntry* typeEntry)
+{
+ foreach (AbstractMetaClass* c, classes) {
+ if (c->typeEntry() == typeEntry)
+ return c;
+ }
+ return 0;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaClass *ac)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AbstractMetaClass(";
+ if (ac) {
+ d << '"' << ac->fullName() << '"';
+ if (ac->m_baseClass)
+ d << ", inherits \"" << ac->m_baseClass->name() << '"';
+ const AbstractMetaEnumList &enums = ac->enums();
+ if (!enums.isEmpty())
+ d << ", enums[" << enums.size() << "]=" << enums;
+ const AbstractMetaFunctionList &functions = ac->functions();
+ if (!functions.isEmpty()) {
+ const int count = functions.size();
+ d << ", functions=[" << count << "](";
+ for (int i = 0; i < count; ++i) {
+ if (i)
+ d << ", ";
+#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
+ if (d.verbosity() > 2)
+ d << functions.at(i);
+ else
+#endif
+ formatMetaFunctionBrief(d, functions.at(i));
+ }
+ d << ')';
+ }
+ const AbstractMetaFieldList &fields = ac->fields();
+ if (!fields.isEmpty()) {
+ const int count = fields.size();
+ d << ", fields=[" << count << "](";
+ for (int i = 0; i < count; ++i) {
+ if (i)
+ d << ", ";
+ formatMetaField(d, fields.at(i));
+ }
+ d << ')';
+ }
+ } else {
+ d << '0';
+ }
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+QString AbstractMetaEnum::name() const
+{
+ return m_typeEntry->targetLangName();
+}
+
+QString AbstractMetaEnum::qualifier() const
+{
+ return m_typeEntry->targetLangQualifier();
+}
+
+QString AbstractMetaEnum::package() const
+{
+ return m_typeEntry->targetLangPackage();
+}
+
+bool AbstractMetaEnum::isAnonymous() const
+{
+ return m_typeEntry->isAnonymous();
+}
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h
new file mode 100644
index 000000000..26702d3a2
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h
@@ -0,0 +1,1983 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTMETALANG_H
+#define ABSTRACTMETALANG_H
+
+#include "abstractmetalang_typedefs.h"
+#include "typesystem_enums.h"
+#include "typesystem_typedefs.h"
+
+#include "parser/codemodel_enums.h"
+
+#include <QtCore/qobjectdefs.h>
+#include <QtCore/QStringList>
+
+QT_FORWARD_DECLARE_CLASS(QDebug)
+
+class AbstractMeta;
+class AbstractMetaClass;
+class AbstractMetaField;
+class AbstractMetaFunction;
+class AbstractMetaType;
+class AbstractMetaVariable;
+class AbstractMetaArgument;
+class AbstractMetaEnumValue;
+class AbstractMetaEnum;
+class QPropertySpec;
+
+class CodeSnip;
+class ComplexTypeEntry;
+class EnumTypeEntry;
+class FlagsTypeEntry;
+class FunctionTypeEntry;
+class TypeEntry;
+
+struct ArgumentOwner;
+struct FieldModification;
+struct FunctionModification;
+struct ReferenceCount;
+
+class Documentation
+{
+public:
+ enum Format {
+ Native,
+ Target
+ };
+
+ Documentation()
+ : m_format(Documentation::Native) {}
+
+ Documentation(const QString& value, Format fmt = Documentation::Native)
+ : m_data(value), m_format(fmt) {}
+
+ QString value() const
+ {
+ return m_data;
+ }
+
+ void setValue(const QString& value, Format fmt = Documentation::Native)
+ {
+ m_data = value; m_format = fmt;
+ }
+
+ Documentation::Format format() const
+ {
+ return m_format;
+ }
+
+private:
+ QString m_data;
+ Format m_format;
+
+};
+
+class AbstractMetaAttributes
+{
+ Q_GADGET
+public:
+ AbstractMetaAttributes() : m_attributes(0), m_originalAttributes(0) {};
+
+ enum Attribute {
+ None = 0x00000000,
+
+ Private = 0x00000001,
+ Protected = 0x00000002,
+ Public = 0x00000004,
+ Friendly = 0x00000008,
+ Visibility = 0x0000000f,
+
+ Native = 0x00000010,
+ Abstract = 0x00000020,
+ Static = 0x00000040,
+
+ FinalInTargetLang = 0x00000080,
+ FinalInCpp = 0x00000100,
+ ForceShellImplementation = 0x00000200,
+
+ GetterFunction = 0x00000400,
+ SetterFunction = 0x00000800,
+
+ FinalOverload = 0x00001000,
+ InterfaceFunction = 0x00002000,
+
+ PropertyReader = 0x00004000,
+ PropertyWriter = 0x00008000,
+ PropertyResetter = 0x00010000,
+
+ Fake = 0x00020000,
+
+ Invokable = 0x00040000,
+
+ Final = FinalInTargetLang | FinalInCpp
+ };
+ Q_DECLARE_FLAGS(Attributes, Attribute)
+ Q_FLAG(Attribute)
+
+ Attributes attributes() const
+ {
+ return m_attributes;
+ }
+
+ void setAttributes(Attributes attributes)
+ {
+ m_attributes = attributes;
+ }
+
+ Attributes originalAttributes() const
+ {
+ return m_originalAttributes;
+ }
+
+ void setOriginalAttributes(Attributes attributes)
+ {
+ m_originalAttributes = attributes;
+ }
+
+ Attributes visibility() const
+ {
+ return m_attributes & Visibility;
+ }
+
+ void setVisibility(Attributes visi)
+ {
+ m_attributes = (m_attributes & ~Visibility) | visi;
+ }
+
+ void operator+=(Attribute attribute)
+ {
+ m_attributes |= attribute;
+ }
+
+ void operator-=(Attribute attribute)
+ {
+ m_attributes &= ~attribute;
+ }
+
+ bool isNative() const
+ {
+ return m_attributes & Native;
+ }
+
+ bool isFinal() const
+ {
+ return (m_attributes & Final) == Final;
+ }
+
+ bool isFinalInTargetLang() const
+ {
+ return m_attributes & FinalInTargetLang;
+ }
+
+ bool isFinalInCpp() const
+ {
+ return m_attributes & FinalInCpp;
+ }
+
+ bool isAbstract() const
+ {
+ return m_attributes & Abstract;
+ }
+
+ bool isStatic() const
+ {
+ return m_attributes & Static;
+ }
+
+ bool isForcedShellImplementation() const
+ {
+ return m_attributes & ForceShellImplementation;
+ }
+
+ bool isInterfaceFunction() const
+ {
+ return m_attributes & InterfaceFunction;
+ }
+
+ bool isFinalOverload() const
+ {
+ return m_attributes & FinalOverload;
+ }
+
+ bool isInvokable() const
+ {
+ return m_attributes & Invokable;
+ }
+
+ bool isPropertyReader() const
+ {
+ return m_attributes & PropertyReader;
+ }
+
+ bool isPropertyWriter() const
+ {
+ return m_attributes & PropertyWriter;
+ }
+
+ bool isPropertyResetter() const
+ {
+ return m_attributes & PropertyResetter;
+ }
+
+ bool isPrivate() const
+ {
+ return m_attributes & Private;
+ }
+
+ bool isProtected() const
+ {
+ return m_attributes & Protected;
+ }
+
+ bool isPublic() const
+ {
+ return m_attributes & Public;
+ }
+
+ bool isFriendly() const
+ {
+ return m_attributes & Friendly;
+ }
+
+ bool wasPrivate() const
+ {
+ return m_originalAttributes & Private;
+ }
+
+ bool wasProtected() const
+ {
+ return m_originalAttributes & Protected;
+ }
+
+ bool wasPublic() const
+ {
+ return m_originalAttributes & Public;
+ }
+
+ bool wasFriendly() const
+ {
+ return m_originalAttributes & Friendly;
+ }
+
+ void setDocumentation(const Documentation& doc)
+ {
+ m_doc = doc;
+ }
+
+ Documentation documentation() const
+ {
+ return m_doc;
+ }
+
+private:
+ Attributes m_attributes;
+ Attributes m_originalAttributes;
+ Documentation m_doc;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaAttributes::Attributes)
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaAttributes *aa);
+#endif
+
+class AbstractMetaType
+{
+ Q_GADGET
+public:
+
+ enum TypeUsagePattern {
+ InvalidPattern,
+ PrimitivePattern,
+ FlagsPattern,
+ EnumPattern,
+ ValuePattern,
+ StringPattern,
+ CharPattern,
+ ObjectPattern,
+ QObjectPattern,
+ ValuePointerPattern,
+ NativePointerPattern,
+ ContainerPattern,
+ SmartPointerPattern,
+ VariantPattern,
+ VarargsPattern,
+ JObjectWrapperPattern,
+ ArrayPattern,
+ ThreadPattern
+ };
+ Q_ENUM(TypeUsagePattern)
+
+ AbstractMetaType();
+ ~AbstractMetaType();
+
+ QString package() const;
+ QString name() const;
+ QString fullName() const;
+
+ void setTypeUsagePattern(TypeUsagePattern pattern)
+ {
+ m_pattern = pattern;
+ }
+ TypeUsagePattern typeUsagePattern() const
+ {
+ return m_pattern;
+ }
+
+ // true when use pattern is container
+ bool hasInstantiations() const
+ {
+ return !m_instantiations.isEmpty();
+ }
+
+ void addInstantiation(AbstractMetaType* inst, bool owner = false)
+ {
+ if (owner)
+ m_children << inst;
+ m_instantiations << inst;
+ }
+
+ void setInstantiations(const AbstractMetaTypeList &insts, bool owner = false)
+ {
+ m_instantiations = insts;
+ if (owner) {
+ m_children.clear();
+ m_children = insts;
+ }
+ }
+
+ AbstractMetaTypeList instantiations() const
+ {
+ return m_instantiations;
+ }
+
+ void setInstantiationInCpp(bool incpp)
+ {
+ m_cppInstantiation = incpp;
+ }
+ bool hasInstantiationInCpp() const
+ {
+ return hasInstantiations() && m_cppInstantiation;
+ }
+
+ QString minimalSignature() const;
+
+ // true when the type is a QtJambiObject subclass
+ bool hasNativeId() const;
+
+ // returns true if the typs is used as a non complex primitive, no & or *'s
+ bool isPrimitive() const
+ {
+ return m_pattern == PrimitivePattern;
+ }
+
+ // returns true if the type is used as an enum
+ bool isEnum() const
+ {
+ return m_pattern == EnumPattern;
+ }
+
+ // returns true if the type is used as a QObject *
+ bool isQObject() const
+ {
+ return m_pattern == QObjectPattern;
+ }
+
+ // returns true if the type is used as an object, e.g. Xxx *
+ bool isObject() const
+ {
+ return m_pattern == ObjectPattern;
+ }
+
+ // returns true if the type is used as an array, e.g. Xxx[42]
+ bool isArray() const
+ {
+ return m_pattern == ArrayPattern;
+ }
+
+ // returns true if the type is used as a value type (X or const X &)
+ bool isValue() const
+ {
+ return m_pattern == ValuePattern;
+ }
+
+ bool isValuePointer() const
+ {
+ return m_pattern == ValuePointerPattern;
+ }
+
+ // returns true for more complex types...
+ bool isNativePointer() const
+ {
+ return m_pattern == NativePointerPattern;
+ }
+
+ // returns true if the type was originally a QString or const QString & or equivalent for QLatin1String
+ bool isTargetLangString() const
+ {
+ return m_pattern == StringPattern;
+ }
+
+ // returns true if the type was originally a QChar or const QChar &
+ bool isTargetLangChar() const
+ {
+ return m_pattern == CharPattern;
+ }
+
+ // return true if the type was originally a QVariant or const QVariant &
+ bool isVariant() const
+ {
+ return m_pattern == VariantPattern;
+ }
+
+ // return true if the type was originally a varargs
+ bool isVarargs() const
+ {
+ return m_pattern == VarargsPattern;
+ }
+
+ // return true if the type was originally a JObjectWrapper or const JObjectWrapper &
+ bool isJObjectWrapper() const
+ {
+ return m_pattern == JObjectWrapperPattern;
+ }
+
+ // returns true if the type was used as a container
+ bool isContainer() const
+ {
+ return m_pattern == ContainerPattern;
+ }
+
+ // returns true if the type was used as a smart pointer
+ bool isSmartPointer() const { return m_pattern == SmartPointerPattern; }
+
+ // returns true if the type was used as a flag
+ bool isFlags() const
+ {
+ return m_pattern == FlagsPattern;
+ }
+
+ // returns true if the type was used as a thread
+ bool isThread() const
+ {
+ return m_pattern == ThreadPattern;
+ }
+
+ bool isConstant() const
+ {
+ return m_constant;
+ }
+ void setConstant(bool constant)
+ {
+ m_constant = constant;
+ }
+
+ ReferenceType referenceType() const { return m_referenceType; }
+ void setReferenceType(ReferenceType ref) { m_referenceType = ref; }
+
+ /**
+ * Says if the type is to be implemented using target language
+ * equivalent of C++ enums, i.e. not plain ints.
+ * /return true if the type is to be implemented using target
+ * language enums
+ */
+ bool isTargetLangEnum() const;
+ bool isIntegerEnum() const
+ {
+ return isEnum() && !isTargetLangEnum();
+ }
+
+ /**
+ * Says if the type is to be implemented using target language
+ * equivalent of Qt's QFlags, i.e. not plain ints.
+ * /return true if the type is to be implemented using target
+ * language QFlags
+ */
+ bool isTargetLangFlags() const;
+ bool isIntegerFlags() const
+ {
+ return isFlags() && !isTargetLangFlags();
+ }
+
+ int actualIndirections() const
+ {
+ return m_indirections + (m_referenceType == LValueReference ? 1 : 0);
+ }
+ int indirections() const
+ {
+ return m_indirections;
+ }
+ void setIndirections(int indirections)
+ {
+ m_indirections = indirections;
+ }
+
+ void setArrayElementCount(int n)
+ {
+ m_arrayElementCount = n;
+ }
+ int arrayElementCount() const
+ {
+ return m_arrayElementCount;
+ }
+
+ const AbstractMetaType *arrayElementType() const
+ {
+ return m_arrayElementType;
+ }
+ void setArrayElementType(const AbstractMetaType *t)
+ {
+ m_arrayElementType = t;
+ }
+
+ QString cppSignature() const;
+
+ AbstractMetaType *copy() const;
+
+ const TypeEntry *typeEntry() const
+ {
+ return m_typeEntry;
+ }
+ void setTypeEntry(const TypeEntry *type)
+ {
+ m_typeEntry = type;
+ }
+
+ void setOriginalTypeDescription(const QString &otd)
+ {
+ m_originalTypeDescription = otd;
+ }
+ QString originalTypeDescription() const
+ {
+ return m_originalTypeDescription;
+ }
+
+ void setOriginalTemplateType(const AbstractMetaType *type)
+ {
+ m_originalTemplateType = type;
+ }
+ const AbstractMetaType *originalTemplateType() const
+ {
+ return m_originalTemplateType;
+ }
+
+ AbstractMetaType *getSmartPointerInnerType() const
+ {
+ Q_ASSERT(isSmartPointer());
+ AbstractMetaTypeList instantiations = this->instantiations();
+ Q_ASSERT(!instantiations.isEmpty());
+ AbstractMetaType *innerType = instantiations.at(0);
+ return innerType;
+ }
+
+ QString getSmartPointerInnerTypeName() const
+ {
+ Q_ASSERT(isSmartPointer());
+ AbstractMetaType *innerType = getSmartPointerInnerType();
+ Q_ASSERT(innerType);
+ return innerType->name();
+ }
+
+ /// Decides and sets the proper usage patter for the current meta type.
+ void decideUsagePattern();
+
+ bool hasTemplateChildren() const;
+
+private:
+ TypeUsagePattern determineUsagePattern() const;
+
+ const TypeEntry *m_typeEntry;
+ AbstractMetaTypeList m_instantiations;
+ QString m_package;
+ mutable QString m_name;
+ mutable QString m_cachedCppSignature;
+ QString m_originalTypeDescription;
+
+ int m_arrayElementCount;
+ const AbstractMetaType *m_arrayElementType;
+ const AbstractMetaType *m_originalTemplateType;
+
+ TypeUsagePattern m_pattern;
+ uint m_constant : 1;
+ uint m_cppInstantiation : 1;
+ int m_indirections : 4;
+ uint m_reserved : 26; // unused
+ ReferenceType m_referenceType;
+ AbstractMetaTypeList m_children;
+
+ Q_DISABLE_COPY(AbstractMetaType);
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaType *at);
+#endif
+
+class AbstractMetaVariable
+{
+public:
+ AbstractMetaVariable() : m_type(0), m_hasName(false) {}
+ AbstractMetaVariable(const AbstractMetaVariable &other);
+
+ virtual ~AbstractMetaVariable()
+ {
+ delete m_type;
+ }
+
+ AbstractMetaType *type() const
+ {
+ return m_type;
+ }
+ void setType(AbstractMetaType *type)
+ {
+ Q_ASSERT(m_type == 0);
+ m_type = type;
+ }
+ void replaceType(AbstractMetaType *type)
+ {
+ if (m_type)
+ delete m_type;
+ m_type = type;
+ }
+
+ QString name() const
+ {
+ return m_name;
+ }
+ void setName(const QString &name, bool realName = true)
+ {
+ m_name = name;
+ m_hasName = realName;
+ }
+ bool hasName() const
+ {
+ return m_hasName;
+ }
+ QString originalName() const
+ {
+ return m_originalName;
+ }
+ void setOriginalName(const QString& name)
+ {
+ m_originalName = name;
+ }
+ void setDocumentation(const Documentation& doc)
+ {
+ m_doc = doc;
+ }
+ Documentation documentation() const
+ {
+ return m_doc;
+ }
+
+private:
+ QString m_originalName;
+ QString m_name;
+ AbstractMetaType *m_type;
+ bool m_hasName;
+
+ Documentation m_doc;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaVariable *av);
+#endif
+
+class AbstractMetaArgument : public AbstractMetaVariable
+{
+public:
+ AbstractMetaArgument() : m_argumentIndex(0) {};
+
+ QString defaultValueExpression() const
+ {
+ return m_expression;
+ }
+ void setDefaultValueExpression(const QString &expr)
+ {
+ m_expression = expr;
+ }
+
+ QString originalDefaultValueExpression() const
+ {
+ return m_originalExpression;
+ }
+ void setOriginalDefaultValueExpression(const QString &expr)
+ {
+ m_originalExpression = expr;
+ }
+
+ QString toString() const
+ {
+ return type()->name() + QLatin1Char(' ') + AbstractMetaVariable::name() +
+ (m_expression.isEmpty() ? QString() : QLatin1String(" = ") + m_expression);
+ }
+
+ int argumentIndex() const
+ {
+ return m_argumentIndex;
+ }
+ void setArgumentIndex(int argIndex)
+ {
+ m_argumentIndex = argIndex;
+ }
+
+ AbstractMetaArgument *copy() const;
+private:
+ QString m_expression;
+ QString m_originalExpression;
+ int m_argumentIndex;
+
+ friend class AbstractMetaClass;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaArgument *aa);
+#endif
+
+class AbstractMetaField : public AbstractMetaVariable, public AbstractMetaAttributes
+{
+public:
+ AbstractMetaField();
+ ~AbstractMetaField();
+
+ const AbstractMetaClass *enclosingClass() const
+ {
+ return m_class;
+ }
+ void setEnclosingClass(const AbstractMetaClass *cls)
+ {
+ m_class = cls;
+ }
+
+ const AbstractMetaFunction *getter() const;
+ const AbstractMetaFunction *setter() const;
+
+ FieldModificationList modifications() const;
+
+ bool isModifiedRemoved(int types = TypeSystem::All) const;
+
+ using AbstractMetaVariable::setDocumentation;
+ using AbstractMetaVariable::documentation;
+
+ AbstractMetaField *copy() const;
+
+private:
+ mutable AbstractMetaFunction *m_getter;
+ mutable AbstractMetaFunction *m_setter;
+ const AbstractMetaClass *m_class;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaField *af);
+#endif
+
+class AbstractMetaFunction : public AbstractMetaAttributes
+{
+ Q_GADGET
+public:
+ enum FunctionType {
+ ConstructorFunction,
+ CopyConstructorFunction,
+ MoveConstructorFunction,
+ AssignmentOperatorFunction,
+ MoveAssignmentOperatorFunction,
+ DestructorFunction,
+ NormalFunction,
+ SignalFunction,
+ EmptyFunction,
+ SlotFunction,
+ GlobalScopeFunction
+ };
+ Q_ENUM(FunctionType)
+
+ enum CompareResultFlag {
+ EqualName = 0x00000001,
+ EqualArguments = 0x00000002,
+ EqualAttributes = 0x00000004,
+ EqualImplementor = 0x00000008,
+ EqualReturnType = 0x00000010,
+ EqualDefaultValueOverload = 0x00000020,
+ EqualModifiedName = 0x00000040,
+
+ NameLessThan = 0x00001000,
+
+ PrettySimilar = EqualName | EqualArguments,
+ Equal = 0x0000001f,
+ NotEqual = 0x00001000
+ };
+ Q_DECLARE_FLAGS(CompareResult, CompareResultFlag)
+ Q_FLAG(CompareResultFlag)
+
+ AbstractMetaFunction()
+ : m_typeEntry(0),
+ m_functionType(NormalFunction),
+ m_type(0),
+ m_class(0),
+ m_implementingClass(0),
+ m_declaringClass(0),
+ m_propertySpec(0),
+ m_constant(false),
+ m_invalid(false),
+ m_reverse(false),
+ m_userAdded(false),
+ m_explicit(false),
+ m_pointerOperator(false),
+ m_isCallOperator(false)
+ {
+ }
+
+ ~AbstractMetaFunction();
+
+ QString name() const
+ {
+ return m_name;
+ }
+
+ void setName(const QString &name)
+ {
+ m_name = name;
+ }
+
+ QString originalName() const
+ {
+ return m_originalName.isEmpty() ? name() : m_originalName;
+ }
+
+ void setOriginalName(const QString &name)
+ {
+ m_originalName = name;
+ }
+
+ void setReverseOperator(bool reverse)
+ {
+ m_reverse = reverse;
+ }
+
+ bool isReverseOperator() const
+ {
+ return m_reverse;
+ }
+
+ /**
+ * Returns true if this is a operator and the "self" operand is a pointer.
+ * e.g. class Foo {}; operator+(SomeEnum, Foo*);
+ */
+ bool isPointerOperator() const
+ {
+ return m_pointerOperator;
+ }
+
+ void setPointerOperator(bool value)
+ {
+ m_pointerOperator = value;
+ }
+
+ void setExplicit(bool isExplicit)
+ {
+ m_explicit = isExplicit;
+ }
+ /**
+ * Says if the function (a constructor) was declared as explicit in C++.
+ * \return true if the function was declared as explicit in C++
+ */
+ bool isExplicit() const
+ {
+ return m_explicit;
+ }
+
+ static bool isConversionOperator(QString funcName);
+ bool isConversionOperator() const
+ {
+ return isConversionOperator(originalName());
+ }
+
+ static bool isOperatorOverload(QString funcName);
+ bool isOperatorOverload() const
+ {
+ return isOperatorOverload(originalName());
+ }
+ bool isCastOperator() const;
+
+ bool isArithmeticOperator() const;
+ bool isBitwiseOperator() const;
+ bool isComparisonOperator() const;
+ bool isLogicalOperator() const;
+ bool isSubscriptOperator() const;
+ bool isAssignmentOperator() const; // Assignment or move assignment
+ bool isOtherOperator() const;
+
+ /**
+ * Informs the arity of the operator or -1 if the function is not
+ * an operator overload.
+ * /return the arity of the operator or -1
+ */
+ int arityOfOperator() const;
+ bool isUnaryOperator() const { return arityOfOperator() == 1; }
+ bool isBinaryOperator() const { return arityOfOperator() == 2; }
+ bool isInplaceOperator() const;
+
+ // TODO: ths function *should* know if it is virtual
+ // instead of asking to your implementing class.
+ bool isVirtual() const;
+ bool isThread() const;
+ bool allowThread() const;
+ QString modifiedName() const;
+
+ QString minimalSignature() const;
+ QStringList possibleIntrospectionCompatibleSignatures() const;
+
+ QString marshalledName() const;
+
+ // true if one or more of the arguments are of QtJambiObject subclasses
+ bool argumentsHaveNativeId() const
+ {
+ foreach (const AbstractMetaArgument *arg, m_arguments) {
+ if (arg->type()->hasNativeId())
+ return true;
+ }
+
+ return false;
+ }
+
+ bool isModifiedRemoved(int types = TypeSystem::All) const;
+
+ AbstractMetaType *type() const
+ {
+ return m_type;
+ }
+ void setType(AbstractMetaType *type)
+ {
+ Q_ASSERT(m_type == 0);
+ m_type = type;
+ }
+
+ void replaceType(AbstractMetaType *type)
+ {
+ if (m_type)
+ delete m_type;
+ m_type = type;
+ }
+
+ // The class that has this function as a member.
+ const AbstractMetaClass *ownerClass() const
+ {
+ return m_class;
+ }
+ void setOwnerClass(const AbstractMetaClass *cls)
+ {
+ m_class = cls;
+ }
+
+ // The first class in a hierarchy that declares the function
+ const AbstractMetaClass *declaringClass() const
+ {
+ return m_declaringClass;
+ }
+ void setDeclaringClass(const AbstractMetaClass *cls)
+ {
+ m_declaringClass = cls;
+ }
+
+ // The class that actually implements this function
+ const AbstractMetaClass *implementingClass() const
+ {
+ return m_implementingClass;
+ }
+ void setImplementingClass(const AbstractMetaClass *cls)
+ {
+ m_implementingClass = cls;
+ }
+
+ bool needsCallThrough() const;
+
+ AbstractMetaArgumentList arguments() const
+ {
+ return m_arguments;
+ }
+ void setArguments(const AbstractMetaArgumentList &arguments)
+ {
+ m_arguments = arguments;
+ }
+ void addArgument(AbstractMetaArgument *argument)
+ {
+ m_arguments << argument;
+ }
+ int actualMinimumArgumentCount() const;
+
+ void setInvalid(bool on)
+ {
+ m_invalid = on;
+ }
+ bool isInvalid() const
+ {
+ return m_invalid;
+ }
+ bool isDeprecated() const;
+ bool isDestructor() const
+ {
+ return functionType() == DestructorFunction;
+ }
+ bool isConstructor() const
+ {
+ return m_functionType == ConstructorFunction || m_functionType == CopyConstructorFunction
+ || m_functionType == MoveConstructorFunction;
+ }
+ bool isNormal() const
+ {
+ return functionType() == NormalFunction || isSlot() || isInGlobalScope();
+ }
+ bool isInGlobalScope() const
+ {
+ return functionType() == GlobalScopeFunction;
+ }
+ bool isSignal() const
+ {
+ return functionType() == SignalFunction;
+ }
+ bool isSlot() const
+ {
+ return functionType() == SlotFunction;
+ }
+ bool isEmptyFunction() const
+ {
+ return functionType() == EmptyFunction;
+ }
+ FunctionType functionType() const
+ {
+ return m_functionType;
+ }
+ void setFunctionType(FunctionType type)
+ {
+ m_functionType = type;
+ }
+
+ bool usesRValueReferences() const;
+ QStringList introspectionCompatibleSignatures(const QStringList &resolvedArguments = QStringList()) const;
+ QString signature() const;
+ QString targetLangSignature(bool minimal = false) const;
+ bool shouldReturnThisObject() const
+ {
+ return QLatin1String("this") == argumentReplaced(0);
+ }
+ bool shouldIgnoreReturnValue() const
+ {
+ return QLatin1String("void") == argumentReplaced(0);
+ }
+
+ bool isConstant() const
+ {
+ return m_constant;
+ }
+ void setConstant(bool constant)
+ {
+ m_constant = constant;
+ }
+
+ /// Returns true if the AbstractMetaFunction was added by the user via the type system description.
+ bool isUserAdded() const
+ {
+ return m_userAdded;
+ }
+ void setUserAdded(bool userAdded)
+ {
+ m_userAdded = userAdded;
+ }
+
+ QString toString() const
+ {
+ return m_name;
+ }
+
+ CompareResult compareTo(const AbstractMetaFunction *other) const;
+
+ bool operator <(const AbstractMetaFunction &a) const;
+
+ AbstractMetaFunction *copy() const;
+
+ QString replacedDefaultExpression(const AbstractMetaClass *cls, int idx) const;
+ bool removedDefaultExpression(const AbstractMetaClass *cls, int idx) const;
+ QString conversionRule(TypeSystem::Language language, int idx) const;
+ QList<ReferenceCount> referenceCounts(const AbstractMetaClass *cls, int idx = -2) const;
+ ArgumentOwner argumentOwner(const AbstractMetaClass *cls, int idx) const;
+
+ bool nullPointersDisabled(const AbstractMetaClass *cls = 0, int argument_idx = 0) const;
+ QString nullPointerDefaultValue(const AbstractMetaClass *cls = 0, int argument_idx = 0) const;
+
+ bool resetObjectAfterUse(int argument_idx) const;
+
+ // Returns whether garbage collection is disabled for the argument in any context
+ bool disabledGarbageCollection(const AbstractMetaClass *cls, int key) const;
+
+ // Returns the ownership rules for the given argument in the given context
+ TypeSystem::Ownership ownership(const AbstractMetaClass *cls, TypeSystem::Language language, int idx) const;
+
+ bool isVirtualSlot() const;
+
+ QString typeReplaced(int argument_index) const;
+ bool isRemovedFromAllLanguages(const AbstractMetaClass *) const;
+ bool isRemovedFrom(const AbstractMetaClass *, TypeSystem::Language language) const;
+ bool argumentRemoved(int) const;
+
+ QString argumentReplaced(int key) const;
+ bool needsSuppressUncheckedWarning() const;
+
+ bool hasModifications(const AbstractMetaClass *implementor) const;
+ /**
+ * Verifies if any modification to the function is an inject code.
+ * \return true if there is inject code modifications to the function.
+ */
+ bool hasInjectedCode() const;
+ /**
+ * Returns a list of code snips for this function.
+ * The code snips can be filtered by position and language.
+ * \return list of code snips
+ */
+ CodeSnipList injectedCodeSnips(TypeSystem::CodeSnipPosition position = TypeSystem::CodeSnipPositionAny,
+ TypeSystem::Language language = TypeSystem::All) const;
+
+ /**
+ * Verifies if any modification to the function alters/removes its
+ * arguments types or default values.
+ * \return true if there is some modification to function signature
+ */
+ bool hasSignatureModifications() const;
+ FunctionModificationList modifications(const AbstractMetaClass* implementor = 0) const;
+
+ /**
+ * Return the argument name if there is a modification the renamed value will be returned
+ */
+ QString argumentName(int index, bool create = true, const AbstractMetaClass *cl = 0) const;
+
+ void setPropertySpec(QPropertySpec *spec)
+ {
+ m_propertySpec = spec;
+ }
+
+ QPropertySpec *propertySpec() const
+ {
+ return m_propertySpec;
+ }
+
+ FunctionTypeEntry* typeEntry() const
+ {
+ return m_typeEntry;
+ }
+
+ void setTypeEntry(FunctionTypeEntry* typeEntry)
+ {
+ m_typeEntry = typeEntry;
+ }
+
+ bool isCallOperator() const;
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebugVerbose(QDebug &d) const;
+#endif
+
+private:
+ QString m_name;
+ QString m_originalName;
+ mutable QString m_cachedMinimalSignature;
+ mutable QString m_cachedSignature;
+ mutable QString m_cachedModifiedName;
+
+ FunctionTypeEntry* m_typeEntry;
+ FunctionType m_functionType;
+ AbstractMetaType *m_type;
+ const AbstractMetaClass *m_class;
+ const AbstractMetaClass *m_implementingClass;
+ const AbstractMetaClass *m_declaringClass;
+ QPropertySpec *m_propertySpec;
+ AbstractMetaArgumentList m_arguments;
+ uint m_constant : 1;
+ uint m_invalid : 1;
+ uint m_reverse : 1;
+ uint m_userAdded : 1;
+ uint m_explicit : 1;
+ uint m_pointerOperator : 1;
+ uint m_isCallOperator : 1;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaFunction::CompareResult)
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaFunction *af);
+#endif
+
+class AbstractMetaEnumValue
+{
+public:
+ AbstractMetaEnumValue()
+ : m_valueSet(false), m_value(0)
+ {
+ }
+
+ int value() const
+ {
+ return m_value;
+ }
+
+ void setValue(int value)
+ {
+ m_valueSet = true;
+ m_value = value;
+ }
+
+ QString stringValue() const
+ {
+ return m_stringValue;
+ }
+
+ void setStringValue(const QString &v)
+ {
+ m_stringValue = v;
+ }
+
+ QString name() const
+ {
+ return m_name;
+ }
+
+ void setName(const QString &name)
+ {
+ m_name = name;
+ }
+
+ bool isValueSet() const
+ {
+ return m_valueSet;
+ }
+
+ void setDocumentation(const Documentation& doc)
+ {
+ m_doc = doc;
+ }
+
+ Documentation documentation() const
+ {
+ return m_doc;
+ }
+
+private:
+ QString m_name;
+ QString m_stringValue;
+
+ bool m_valueSet;
+ int m_value;
+
+ Documentation m_doc;
+};
+
+
+class AbstractMetaEnumValueList : public QList<AbstractMetaEnumValue *>
+{
+public:
+ AbstractMetaEnumValue *find(const QString &name) const;
+};
+
+class AbstractMetaEnum : public AbstractMetaAttributes
+{
+public:
+ AbstractMetaEnum() : m_typeEntry(0), m_class(0), m_hasQenumsDeclaration(false) {}
+ ~AbstractMetaEnum()
+ {
+ qDeleteAll(m_enumValues);
+ }
+
+ AbstractMetaEnumValueList values() const
+ {
+ return m_enumValues;
+ }
+
+ void addEnumValue(AbstractMetaEnumValue *enumValue)
+ {
+ m_enumValues << enumValue;
+ }
+
+ QString name() const;
+
+ QString qualifier() const;
+
+ QString package() const;
+
+ QString fullName() const
+ {
+ return package() + QLatin1Char('.') + qualifier() + QLatin1Char('.') + name();
+ }
+
+ // Has the enum been declared inside a Q_ENUMS() macro in its enclosing class?
+ void setHasQEnumsDeclaration(bool on)
+ {
+ m_hasQenumsDeclaration = on;
+ }
+
+ bool hasQEnumsDeclaration() const
+ {
+ return m_hasQenumsDeclaration;
+ }
+
+ EnumTypeEntry *typeEntry() const
+ {
+ return m_typeEntry;
+ }
+
+ void setTypeEntry(EnumTypeEntry *entry)
+ {
+ m_typeEntry = entry;
+ }
+
+ AbstractMetaClass *enclosingClass() const
+ {
+ return m_class;
+ }
+
+ void setEnclosingClass(AbstractMetaClass *c)
+ {
+ m_class = c;
+ }
+
+ bool isAnonymous() const;
+
+private:
+ AbstractMetaEnumValueList m_enumValues;
+ EnumTypeEntry *m_typeEntry;
+ AbstractMetaClass *m_class;
+
+ uint m_hasQenumsDeclaration : 1;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AbstractMetaEnum *ae);
+#endif
+
+class AbstractMetaClass : public AbstractMetaAttributes
+{
+ Q_GADGET
+public:
+ enum FunctionQueryOption {
+ Constructors = 0x0000001, // Only constructors
+ //Destructors = 0x0000002, // Only destructors. Not included in class.
+ VirtualFunctions = 0x0000004, // Only virtual functions (virtual in both TargetLang and C++)
+ FinalInTargetLangFunctions = 0x0000008, // Only functions that are non-virtual in TargetLang
+ FinalInCppFunctions = 0x0000010, // Only functions that are non-virtual in C++
+ ClassImplements = 0x0000020, // Only functions implemented by the current class
+ Inconsistent = 0x0000040, // Only inconsistent functions (inconsistent virtualness in TargetLang/C++)
+ StaticFunctions = 0x0000080, // Only static functions
+ Signals = 0x0000100, // Only signals
+ NormalFunctions = 0x0000200, // Only functions that aren't signals
+ Visible = 0x0000400, // Only public and protected functions
+ ForcedShellFunctions = 0x0000800, // Only functions that are overridden to be implemented in the shell class
+ WasPublic = 0x0001000, // Only functions that were originally public
+ WasProtected = 0x0002000, // Only functions that were originally protected
+ NonStaticFunctions = 0x0004000, // No static functions
+ Empty = 0x0008000, // Empty overrides of abstract functions
+ Invisible = 0x0010000, // Only private functions
+ VirtualInCppFunctions = 0x0020000, // Only functions that are virtual in C++
+ NonEmptyFunctions = 0x0040000, // Only functions with target language API implementations
+ VirtualInTargetLangFunctions = 0x0080000, // Only functions which are virtual in TargetLang
+ AbstractFunctions = 0x0100000, // Only abstract functions
+ WasVisible = 0x0200000, // Only functions that were public or protected in the original code
+ NotRemovedFromTargetLang = 0x0400000, // Only functions that have not been removed from TargetLang
+ NotRemovedFromShell = 0x0800000, // Only functions that have not been removed from the shell class
+ VirtualSlots = 0x1000000, // Only functions that are set as virtual slots in the type system
+ OperatorOverloads = 0x2000000 // Only functions that are operator overloads
+ };
+ Q_DECLARE_FLAGS(FunctionQueryOptions, FunctionQueryOption)
+ Q_FLAG(FunctionQueryOption)
+
+ enum OperatorQueryOption {
+ ArithmeticOp = 0x01, // Arithmetic: +, -, *, /, %, +=, -=, *=, /=, %=, ++, --, unary+, unary-
+ BitwiseOp = 0x02, // Bitwise: <<, <<=, >>, >>=, ~, &, &=, |, |=, ^, ^=
+ ComparisonOp = 0x04, // Comparison: <, <=, >, >=, !=, ==
+ LogicalOp = 0x08, // Logical: !, &&, ||
+ ConversionOp = 0x10, // Conversion: operator [const] TYPE()
+ SubscriptionOp = 0x20, // Subscription: []
+ AssignmentOp = 0x40, // Assignment: =
+ OtherOp = 0x80, // The remaining operators: call(), etc
+ AllOperators = ArithmeticOp | BitwiseOp | ComparisonOp
+ | LogicalOp | ConversionOp | SubscriptionOp
+ | AssignmentOp | OtherOp
+ };
+ Q_DECLARE_FLAGS(OperatorQueryOptions, OperatorQueryOption)
+ Q_FLAG(OperatorQueryOption)
+
+ AbstractMetaClass()
+ : m_hasVirtuals(false),
+ m_isPolymorphic(false),
+ m_hasNonpublic(false),
+ m_hasVirtualSlots(false),
+ m_hasNonPrivateConstructor(false),
+ m_functionsFixed(false),
+ m_hasPrivateDestructor(false),
+ m_hasProtectedDestructor(false),
+ m_hasVirtualDestructor(false),
+ m_forceShellClass(false),
+ m_hasHashFunction(false),
+ m_hasEqualsOperator(false),
+ m_hasCloneOperator(false),
+ m_isTypeDef(false),
+ m_hasToStringCapability(false),
+ m_enclosingClass(0),
+ m_baseClass(0),
+ m_templateBaseClass(0),
+ m_extractedInterface(0),
+ m_typeEntry(0),
+ m_stream(false)
+ {
+ }
+
+ virtual ~AbstractMetaClass();
+
+ AbstractMetaClass *extractInterface();
+ void fixFunctions();
+
+ AbstractMetaFunctionList functions() const
+ {
+ return m_functions;
+ }
+
+ void setFunctions(const AbstractMetaFunctionList &functions);
+ void addFunction(AbstractMetaFunction *function);
+ bool hasFunction(const AbstractMetaFunction *f) const;
+ bool hasFunction(const QString &str) const;
+ const AbstractMetaFunction* findFunction(const QString& functionName) const;
+ bool hasSignal(const AbstractMetaFunction *f) const;
+
+ bool hasConstructors() const;
+ bool hasCopyConstructor() const;
+ bool hasPrivateCopyConstructor() const;
+
+ void addDefaultConstructor();
+ void addDefaultCopyConstructor(bool isPrivate = false);
+
+ bool hasNonPrivateConstructor() const
+ {
+ return m_hasNonPrivateConstructor;
+ }
+
+ void setHasNonPrivateConstructor(bool value)
+ {
+ m_hasNonPrivateConstructor = value;
+ }
+
+ bool hasPrivateDestructor() const
+ {
+ return m_hasPrivateDestructor;
+ }
+
+ void setHasPrivateDestructor(bool value)
+ {
+ m_hasPrivateDestructor = value;
+ }
+
+ bool hasProtectedDestructor() const
+ {
+ return m_hasProtectedDestructor;
+ }
+
+ void setHasProtectedDestructor(bool value)
+ {
+ m_hasProtectedDestructor = value;
+ }
+
+ bool hasVirtualDestructor() const
+ {
+ return m_hasVirtualDestructor;
+ }
+
+ void setHasVirtualDestructor(bool value)
+ {
+ m_hasVirtualDestructor = value;
+ }
+
+ AbstractMetaFunctionList queryFunctionsByName(const QString &name) const;
+ AbstractMetaFunctionList queryFunctions(FunctionQueryOptions query) const;
+ AbstractMetaFunctionList functionsInTargetLang() const;
+ AbstractMetaFunctionList functionsInShellClass() const;
+ inline AbstractMetaFunctionList cppSignalFunctions() const;
+ AbstractMetaFunctionList publicOverrideFunctions() const;
+ AbstractMetaFunctionList virtualOverrideFunctions() const;
+ AbstractMetaFunctionList virtualFunctions() const;
+ AbstractMetaFunctionList implicitConversions() const;
+
+ /**
+ * Retrieves all class' operator overloads that meet
+ * query criteria defined with the OperatorQueryOption
+ * enum.
+ * /param query composition of OperatorQueryOption enum values
+ * /return list of operator overload methods that meet the
+ * query criteria
+ */
+ AbstractMetaFunctionList operatorOverloads(OperatorQueryOptions query = AllOperators) const;
+
+ bool hasOperatorOverload() const;
+ bool hasArithmeticOperatorOverload() const;
+ bool hasBitwiseOperatorOverload() const;
+ bool hasComparisonOperatorOverload() const;
+ bool hasLogicalOperatorOverload() const;
+ bool hasSubscriptOperatorOverload() const;
+ bool hasAssignmentOperatorOverload() const;
+ bool hasConversionOperatorOverload() const;
+
+ AbstractMetaFieldList fields() const
+ {
+ return m_fields;
+ }
+
+ void setFields(const AbstractMetaFieldList &fields)
+ {
+ m_fields = fields;
+ }
+
+ void addField(AbstractMetaField *field)
+ {
+ m_fields << field;
+ }
+
+ AbstractMetaEnumList enums() const
+ {
+ return m_enums;
+ }
+ void setEnums(const AbstractMetaEnumList &enums)
+ {
+ m_enums = enums;
+ }
+
+ void addEnum(AbstractMetaEnum *e)
+ {
+ m_enums << e;
+ }
+
+ AbstractMetaEnum *findEnum(const QString &enumName);
+ AbstractMetaEnum *findEnumForValue(const QString &enumName);
+ AbstractMetaEnumValue *findEnumValue(const QString &enumName, AbstractMetaEnum *meta_enum);
+
+ AbstractMetaClassList interfaces() const
+ {
+ return m_interfaces;
+ }
+ void addInterface(AbstractMetaClass *interface);
+ void setInterfaces(const AbstractMetaClassList &interface);
+
+ QString fullName() const
+ {
+ return package() + QLatin1Char('.') + name();
+ }
+
+ /**
+ * Retrieves the class name without any namespace/scope information.
+ * /return the class name without scope information
+ */
+ QString name() const;
+
+ QString baseClassName() const
+ {
+ return m_baseClass ? m_baseClass->name() : QString();
+ }
+
+ AbstractMetaClass *baseClass() const
+ {
+ return m_baseClass;
+ }
+
+ void setBaseClass(AbstractMetaClass *base_class);
+
+ const AbstractMetaClass *enclosingClass() const
+ {
+ return m_enclosingClass;
+ }
+
+ void setEnclosingClass(AbstractMetaClass *cl)
+ {
+ m_enclosingClass = cl;
+ }
+
+ const AbstractMetaClassList& innerClasses() const
+ {
+ return m_innerClasses;
+ }
+
+ void addInnerClass(AbstractMetaClass* cl)
+ {
+ m_innerClasses << cl;
+ }
+
+ void setInnerClasses(AbstractMetaClassList innerClasses)
+ {
+ m_innerClasses = innerClasses;
+ }
+
+ QString package() const;
+
+ bool isInterface() const;
+
+ bool isNamespace() const;
+
+ bool isQObject() const;
+
+ bool isQtNamespace() const
+ {
+ return isNamespace() && name() == QLatin1String("Qt");
+ }
+
+ QString qualifiedCppName() const;
+
+ bool hasSignals() const;
+ bool inheritsFrom(const AbstractMetaClass *other) const;
+
+ void setForceShellClass(bool on)
+ {
+ m_forceShellClass = on;
+ }
+
+ bool generateShellClass() const;
+
+ bool hasVirtualSlots() const
+ {
+ return m_hasVirtualSlots;
+ }
+
+ /**
+ * Says if a class has any virtual functions of its own.
+ * \return true if the class implements any virtual methods
+ */
+ bool hasVirtualFunctions() const
+ {
+ return !isFinal() && m_hasVirtuals;
+ }
+ /**
+ * Says if the class that declares or inherits a virtual function.
+ * \return true if the class implements or inherits any virtual methods
+ */
+ bool isPolymorphic() const
+ {
+ return m_isPolymorphic;
+ }
+
+ /**
+ * Tells if this class has one or more functions that are protected.
+ * \return true if the class has protected functions.
+ */
+ bool hasProtectedFunctions() const;
+
+ /**
+ * Tells if this class has one or more fields (member variables) that are protected.
+ * \return true if the class has protected fields.
+ */
+ bool hasProtectedFields() const;
+
+ /**
+ * Tells if this class has one or more members (functions or fields) that are protected.
+ * \return true if the class has protected members.
+ */
+ bool hasProtectedMembers() const;
+
+
+ QList<TypeEntry *> templateArguments() const
+ {
+ return m_templateArgs;
+ }
+
+ void setTemplateArguments(const QList<TypeEntry *> &args)
+ {
+ m_templateArgs = args;
+ }
+
+ bool hasFieldAccessors() const;
+
+ // only valid during metabuilder's run
+ QStringList baseClassNames() const
+ {
+ return m_baseClassNames;
+ }
+
+ void setBaseClassNames(const QStringList &names)
+ {
+ m_baseClassNames = names;
+ }
+
+ const ComplexTypeEntry *typeEntry() const
+ {
+ return m_typeEntry;
+ }
+
+ ComplexTypeEntry *typeEntry()
+ {
+ return m_typeEntry;
+ }
+
+ void setTypeEntry(ComplexTypeEntry *type)
+ {
+ m_typeEntry = type;
+ }
+
+ void setHasHashFunction(bool on)
+ {
+ m_hasHashFunction = on;
+ }
+
+ bool hasHashFunction() const
+ {
+ return m_hasHashFunction;
+ }
+ virtual bool hasDefaultToStringFunction() const;
+
+ void setHasEqualsOperator(bool on)
+ {
+ m_hasEqualsOperator = on;
+ }
+
+ bool hasEqualsOperator() const
+ {
+ return m_hasEqualsOperator;
+ }
+
+ void setHasCloneOperator(bool on)
+ {
+ m_hasCloneOperator = on;
+ }
+
+ bool hasCloneOperator() const
+ {
+ return m_hasCloneOperator;
+ }
+
+ void addPropertySpec(QPropertySpec *spec)
+ {
+ m_propertySpecs << spec;
+ }
+
+ QList<QPropertySpec *> propertySpecs() const
+ {
+ return m_propertySpecs;
+ }
+
+ QPropertySpec *propertySpecForRead(const QString &name) const;
+ QPropertySpec *propertySpecForWrite(const QString &name) const;
+ QPropertySpec *propertySpecForReset(const QString &name) const;
+
+ /// Returns a list of conversion operators for this class. The conversion operators are defined in other classes of the same module.
+ AbstractMetaFunctionList externalConversionOperators() const
+ {
+ return m_externalConversionOperators;
+ }
+ /// Adds a converter operator for this class.
+ void addExternalConversionOperator(AbstractMetaFunction* conversionOp)
+ {
+ if (!m_externalConversionOperators.contains(conversionOp))
+ m_externalConversionOperators.append(conversionOp);
+ }
+ /// Returns true if this class has any converter operators defined elsewhere.
+ bool hasExternalConversionOperators() const
+ {
+ return !m_externalConversionOperators.isEmpty();
+ }
+
+ void sortFunctions();
+
+ const AbstractMetaClass *templateBaseClass() const
+ {
+ return m_templateBaseClass;
+ }
+
+ void setTemplateBaseClass(const AbstractMetaClass *cls)
+ {
+ m_templateBaseClass = cls;
+ }
+
+ bool hasTemplateBaseClassInstantiations() const;
+ AbstractMetaTypeList templateBaseClassInstantiations() const;
+ void setTemplateBaseClassInstantiations(AbstractMetaTypeList& instantiations);
+
+ void setTypeDef(bool typeDef) { m_isTypeDef = typeDef; }
+ bool isTypeDef() const { return m_isTypeDef; }
+
+ void setStream(bool stream)
+ {
+ m_stream = stream;
+ }
+
+ bool isStream() const
+ {
+ return m_stream;
+ }
+
+ void setToStringCapability(bool value)
+ {
+ m_hasToStringCapability = value;
+ }
+
+ bool hasToStringCapability() const
+ {
+ return m_hasToStringCapability;
+ }
+
+ static AbstractMetaClass *findClass(const AbstractMetaClassList &classes,
+ const QString &name);
+ static AbstractMetaClass *findClass(const AbstractMetaClassList &classes,
+ const TypeEntry* typeEntry);
+ static AbstractMetaEnumValue *findEnumValue(const AbstractMetaClassList &classes,
+ const QString &string);
+ static AbstractMetaEnum *findEnum(const AbstractMetaClassList &classes,
+ const EnumTypeEntry *entry);
+
+private:
+#ifndef QT_NO_DEBUG_STREAM
+ friend QDebug operator<<(QDebug d, const AbstractMetaClass *ac);
+#endif
+ uint m_hasVirtuals : 1;
+ uint m_isPolymorphic : 1;
+ uint m_hasNonpublic : 1;
+ uint m_hasVirtualSlots : 1;
+ uint m_hasNonPrivateConstructor : 1;
+ uint m_functionsFixed : 1;
+ uint m_hasPrivateDestructor : 1;
+ uint m_hasProtectedDestructor : 1;
+ uint m_hasVirtualDestructor : 1;
+ uint m_forceShellClass : 1;
+ uint m_hasHashFunction : 1;
+ uint m_hasEqualsOperator : 1;
+ uint m_hasCloneOperator : 1;
+ uint m_isTypeDef : 1;
+ uint m_hasToStringCapability : 1;
+
+ const AbstractMetaClass *m_enclosingClass;
+ AbstractMetaClass *m_baseClass;
+ const AbstractMetaClass *m_templateBaseClass;
+ AbstractMetaFunctionList m_functions;
+ AbstractMetaFieldList m_fields;
+ AbstractMetaEnumList m_enums;
+ AbstractMetaClassList m_interfaces;
+ AbstractMetaClass *m_extractedInterface;
+ QList<QPropertySpec *> m_propertySpecs;
+ AbstractMetaClassList m_innerClasses;
+
+ AbstractMetaFunctionList m_externalConversionOperators;
+
+ QStringList m_baseClassNames;
+ QList<TypeEntry *> m_templateArgs;
+ ComplexTypeEntry *m_typeEntry;
+// FunctionModelItem m_qDebugStreamFunction;
+
+ bool m_stream;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaClass::FunctionQueryOptions)
+Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaClass::OperatorQueryOptions)
+
+class QPropertySpec
+{
+public:
+ QPropertySpec(const TypeEntry *type)
+ : m_type(type),
+ m_index(-1)
+ {}
+
+ const TypeEntry *type() const
+ {
+ return m_type;
+ }
+
+ QString name() const
+ {
+ return m_name;
+ }
+
+ void setName(const QString &name)
+ {
+ m_name = name;
+ }
+
+ QString read() const
+ {
+ return m_read;
+ }
+
+ void setRead(const QString &read)
+ {
+ m_read = read;
+ }
+
+ QString write() const
+ {
+ return m_write;
+ }
+
+ void setWrite(const QString &write)
+ {
+ m_write = write;
+ }
+
+ QString designable() const
+ {
+ return m_designable;
+ }
+
+ void setDesignable(const QString &designable)
+ {
+ m_designable = designable;
+ }
+
+ QString reset() const
+ {
+ return m_reset;
+ }
+
+ void setReset(const QString &reset)
+ {
+ m_reset = reset;
+ }
+
+ int index() const
+ {
+ return m_index;
+ }
+
+ void setIndex(int index)
+ {
+ m_index = index;
+ }
+
+private:
+ QString m_name;
+ QString m_read;
+ QString m_write;
+ QString m_designable;
+ QString m_reset;
+ const TypeEntry *m_type;
+ int m_index;
+};
+
+inline AbstractMetaFunctionList AbstractMetaClass::cppSignalFunctions() const
+{
+ return queryFunctions(Signals
+ | Visible
+ | NotRemovedFromTargetLang);
+}
+
+#endif // ABSTRACTMETALANG_H
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h b/sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h
new file mode 100644
index 000000000..dd6573b78
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTMETALANG_TYPEDEFS_H
+#define ABSTRACTMETALANG_TYPEDEFS_H
+
+#include <QtCore/QList>
+
+class AbstractMetaClass;
+class AbstractMetaField;
+class AbstractMetaArgument;
+class AbstractMetaEnum;
+class AbstractMetaEnumValueList;
+class AbstractMetaFunction;
+class AbstractMetaType;
+
+typedef QList<AbstractMetaArgument *> AbstractMetaArgumentList;
+typedef QList<AbstractMetaClass *> AbstractMetaClassList;
+typedef QList<AbstractMetaEnum *> AbstractMetaEnumList;
+typedef QList<AbstractMetaField *> AbstractMetaFieldList;
+typedef QList<AbstractMetaFunction *> AbstractMetaFunctionList;
+typedef QList<AbstractMetaType *> AbstractMetaTypeList;
+
+#endif // ABSTRACTMETALANG_TYPEDEFS_H
diff --git a/sources/shiboken2/ApiExtractor/apiextractor.cpp b/sources/shiboken2/ApiExtractor/apiextractor.cpp
new file mode 100644
index 000000000..371ccf559
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/apiextractor.cpp
@@ -0,0 +1,356 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "apiextractor.h"
+#include "abstractmetalang.h"
+
+#include <QDir>
+#include <QDebug>
+#include <QTemporaryFile>
+#include <iostream>
+
+#include "reporthandler.h"
+#include "typesystem.h"
+#include "fileout.h"
+#include "parser/rpp/pp.h"
+#include "abstractmetabuilder.h"
+#include "typedatabase.h"
+#include "typesystem.h"
+
+static bool preprocess(const QString& sourceFile,
+ QFile& targetFile,
+ const QStringList& includes);
+
+ApiExtractor::ApiExtractor() : m_builder(0)
+{
+ static bool qrcInitialized = false;
+ if (!qrcInitialized)
+ Q_INIT_RESOURCE(generator);
+ // Environment TYPESYSTEMPATH
+ QString envTypesystemPaths = QFile::decodeName(getenv("TYPESYSTEMPATH"));
+ if (!envTypesystemPaths.isEmpty())
+ TypeDatabase::instance()->addTypesystemPath(envTypesystemPaths);
+}
+
+ApiExtractor::~ApiExtractor()
+{
+ delete m_builder;
+}
+
+void ApiExtractor::addTypesystemSearchPath (const QString& path)
+{
+ TypeDatabase::instance()->addTypesystemPath(path);
+}
+
+void ApiExtractor::addTypesystemSearchPath(const QStringList& paths)
+{
+ foreach (const QString &path, paths)
+ addTypesystemSearchPath(path);
+}
+
+void ApiExtractor::addIncludePath(const QString& path)
+{
+ m_includePaths << path;
+}
+
+void ApiExtractor::addIncludePath(const QStringList& paths)
+{
+ m_includePaths << paths;
+}
+
+void ApiExtractor::setLogDirectory(const QString& logDir)
+{
+ m_logDirectory = logDir;
+}
+
+void ApiExtractor::setCppFileName(const QString& cppFileName)
+{
+ m_cppFileName = cppFileName;
+}
+
+void ApiExtractor::setTypeSystem(const QString& typeSystemFileName)
+{
+ m_typeSystemFileName = typeSystemFileName;
+}
+
+void ApiExtractor::setDebugLevel(ReportHandler::DebugLevel debugLevel)
+{
+ ReportHandler::setDebugLevel(debugLevel);
+}
+
+void ApiExtractor::setSuppressWarnings ( bool value )
+{
+ TypeDatabase::instance()->setSuppressWarnings(value);
+}
+
+void ApiExtractor::setSilent ( bool value )
+{
+ ReportHandler::setSilent(value);
+}
+
+bool ApiExtractor::setApiVersion(const QString& package, const QString &version)
+{
+ return TypeDatabase::instance()->setApiVersion(package, version);
+}
+
+void ApiExtractor::setDropTypeEntries(QString dropEntries)
+{
+ dropEntries.remove(QLatin1Char(' '));
+ QStringList entries = dropEntries.split(QLatin1Char(';'));
+ TypeDatabase::instance()->setDropTypeEntries(entries);
+}
+
+AbstractMetaEnumList ApiExtractor::globalEnums() const
+{
+ Q_ASSERT(m_builder);
+ return m_builder->globalEnums();
+}
+
+AbstractMetaFunctionList ApiExtractor::globalFunctions() const
+{
+ Q_ASSERT(m_builder);
+ return m_builder->globalFunctions();
+}
+
+AbstractMetaClassList ApiExtractor::classes() const
+{
+ Q_ASSERT(m_builder);
+ return m_builder->classes();
+}
+
+AbstractMetaClassList ApiExtractor::smartPointers() const
+{
+ Q_ASSERT(m_builder);
+ return m_builder->smartPointers();
+}
+
+AbstractMetaClassList ApiExtractor::classesTopologicalSorted(const Dependencies &additionalDependencies) const
+{
+ Q_ASSERT(m_builder);
+ return m_builder->classesTopologicalSorted(Q_NULLPTR, additionalDependencies);
+}
+
+PrimitiveTypeEntryList ApiExtractor::primitiveTypes() const
+{
+ return TypeDatabase::instance()->primitiveTypes();
+}
+
+ContainerTypeEntryList ApiExtractor::containerTypes() const
+{
+ return TypeDatabase::instance()->containerTypes();
+}
+
+QSet<QString> ApiExtractor::qtMetaTypeDeclaredTypeNames() const
+{
+ Q_ASSERT(m_builder);
+ return m_builder->qtMetaTypeDeclaredTypeNames();
+}
+
+static const AbstractMetaEnum* findEnumOnClasses(AbstractMetaClassList metaClasses, const EnumTypeEntry* typeEntry)
+{
+ const AbstractMetaEnum* result = 0;
+ foreach (const AbstractMetaClass* metaClass, metaClasses) {
+ foreach (const AbstractMetaEnum* metaEnum, metaClass->enums()) {
+ if (metaEnum->typeEntry() == typeEntry) {
+ result = metaEnum;
+ break;
+ }
+ }
+ if (result)
+ break;
+ result = findEnumOnClasses(metaClass->innerClasses(), typeEntry);
+ }
+ return result;
+}
+
+const AbstractMetaEnum* ApiExtractor::findAbstractMetaEnum(const EnumTypeEntry* typeEntry) const
+{
+ if (!typeEntry)
+ return 0;
+ foreach (AbstractMetaEnum* metaEnum, m_builder->globalEnums()) {
+ if (metaEnum->typeEntry() == typeEntry)
+ return metaEnum;
+ }
+ return findEnumOnClasses(m_builder->classes(), typeEntry);
+}
+
+const AbstractMetaEnum* ApiExtractor::findAbstractMetaEnum(const TypeEntry* typeEntry) const
+{
+ if (!typeEntry)
+ return 0;
+ if (typeEntry->isFlags())
+ return findAbstractMetaEnum(reinterpret_cast<const FlagsTypeEntry*>(typeEntry));
+ if (typeEntry->isEnum())
+ return findAbstractMetaEnum(reinterpret_cast<const EnumTypeEntry*>(typeEntry));
+ return 0;
+}
+
+const AbstractMetaEnum* ApiExtractor::findAbstractMetaEnum(const FlagsTypeEntry* typeEntry) const
+{
+ if (!typeEntry)
+ return 0;
+ return findAbstractMetaEnum(typeEntry->originator());
+}
+
+const AbstractMetaEnum* ApiExtractor::findAbstractMetaEnum(const AbstractMetaType* metaType) const
+{
+ if (!metaType)
+ return 0;
+ return findAbstractMetaEnum(metaType->typeEntry());
+}
+
+int ApiExtractor::classCount() const
+{
+ Q_ASSERT(m_builder);
+ return m_builder->classes().count();
+}
+
+bool ApiExtractor::run()
+{
+ if (m_builder)
+ return false;
+
+ if (m_typeSystemFileName.isEmpty()) {
+ std::cerr << "You must specify a Type System file." << std::endl;
+ return false;
+ } else if (!TypeDatabase::instance()->parseFile(m_typeSystemFileName)) {
+ std::cerr << "Cannot parse file: " << qPrintable(m_typeSystemFileName);
+ return false;
+ }
+
+ QTemporaryFile ppFile;
+#ifndef NDEBUG
+ ppFile.setAutoRemove(false);
+#endif
+ // make sure that a tempfile can be written
+ if (!ppFile.open()) {
+ std::cerr << "could not create tempfile in " << qPrintable(QDir::tempPath());
+ return false;
+ }
+
+ // run rpp pre-processor
+ if (!preprocess(m_cppFileName, ppFile, m_includePaths)) {
+ std::cerr << "Preprocessor failed on file: " << qPrintable(m_cppFileName);
+ return false;
+ }
+ ppFile.seek(0);
+ m_builder = new AbstractMetaBuilder;
+ m_builder->setLogDirectory(m_logDirectory);
+ m_builder->setGlobalHeader(m_cppFileName);
+ m_builder->build(&ppFile);
+
+ return true;
+}
+
+static bool preprocess(const QString& sourceFile,
+ QFile& targetFile,
+ const QStringList& includes)
+{
+ rpp::pp_environment env;
+ rpp::pp preprocess(env);
+
+ rpp::pp_null_output_iterator null_out;
+
+ const char *ppconfig = ":/trolltech/generator/pp-qt-configuration";
+
+ const QString fileName = QLatin1String(ppconfig);
+ QFile file(fileName);
+ if (!file.open(QFile::ReadOnly)) {
+ std::cerr << "Preprocessor configuration file not found " << ppconfig << std::endl;
+ return false;
+ }
+
+ QByteArray ba = file.readAll();
+ file.close();
+ preprocess.operator()(ba.constData(), ba.constData() + ba.size(), null_out);
+
+ preprocess.push_include_path(".");
+ foreach (const QString &include, includes)
+ preprocess.push_include_path(QDir::toNativeSeparators(include).toStdString());
+ preprocess.push_include_path("/usr/include");
+
+ QString currentDir = QDir::current().absolutePath();
+ QFileInfo sourceInfo(sourceFile);
+ if (!sourceInfo.exists()) {
+ std::cerr << "File not found " << qPrintable(sourceFile) << std::endl;
+ return false;
+ }
+ QDir::setCurrent(sourceInfo.absolutePath());
+
+ std::string result;
+ result.reserve(20 * 1024); // 20K
+
+ result += "# 1 \"builtins\"\n";
+ result += "# 1 \"";
+ result += sourceFile.toStdString();
+ result += "\"\n";
+
+ preprocess.file(sourceInfo.fileName().toStdString(),
+ rpp::pp_output_iterator<std::string> (result));
+
+ QDir::setCurrent(currentDir);
+
+ if (!targetFile.open(QIODevice::ReadWrite | QIODevice::Text)) {
+ std::cerr << "Failed to write preprocessed file: " << qPrintable(targetFile.fileName()) << std::endl;
+ return false;
+ }
+
+ targetFile.write(result.c_str(), result.length());
+ return true;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+template <class Container>
+static void debugFormatSequence(QDebug &d, const char *key, const Container& c)
+{
+ typedef typename Container::const_iterator ConstIt;
+ if (c.isEmpty())
+ return;
+ const ConstIt begin = c.begin();
+ const ConstIt end = c.end();
+ d << "\n " << key << '[' << c.size() << "]=(";
+ for (ConstIt it = begin; it != end; ++it) {
+ if (it != begin)
+ d << ", ";
+ d << *it;
+ }
+ d << ')';
+}
+
+QDebug operator<<(QDebug d, const ApiExtractor &ae)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "ApiExtractor(typeSystem=\"" << ae.typeSystem() << "\", cppFileName=\""
+ << ae.cppFileName() << ", ";
+ ae.m_builder->formatDebug(d);
+ d << ')';
+ return d;
+}
+#endif // QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/ApiExtractor/apiextractor.h b/sources/shiboken2/ApiExtractor/apiextractor.h
new file mode 100644
index 000000000..1080ff507
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/apiextractor.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef APIEXTRACTOR_H
+#define APIEXTRACTOR_H
+
+#include "reporthandler.h"
+#include "dependency.h"
+#include "abstractmetalang_typedefs.h"
+#include "apiextractormacros.h"
+#include "typesystem_typedefs.h"
+#include <QStringList>
+
+class AbstractMetaBuilder;
+class AbstractMetaClass;
+class AbstractMetaEnum;
+class AbstractMetaFunction;
+class AbstractMetaType;
+class ContainerTypeEntry;
+class EnumTypeEntry;
+class FlagsTypeEntry;
+class PrimitiveTypeEntry;
+class TypeEntry;
+
+QT_BEGIN_NAMESPACE
+class QDebug;
+class QIODevice;
+QT_END_NAMESPACE
+
+class ApiExtractor
+{
+public:
+ ApiExtractor();
+ ~ApiExtractor();
+
+ void setTypeSystem(const QString& typeSystemFileName);
+ QString typeSystem() const { return m_typeSystemFileName; }
+ void setCppFileName(const QString& cppFileName);
+ QString cppFileName() const { return m_cppFileName; }
+ void setDebugLevel(ReportHandler::DebugLevel debugLevel);
+ void setSuppressWarnings(bool value);
+ void setSilent(bool value);
+ void addTypesystemSearchPath(const QString& path);
+ void addTypesystemSearchPath(const QStringList& paths);
+ void addIncludePath(const QString& path);
+ void addIncludePath(const QStringList& paths);
+ QStringList includePaths() const { return m_includePaths; }
+ void setLogDirectory(const QString& logDir);
+ bool setApiVersion(const QString& package, const QString& version);
+ void setDropTypeEntries(QString dropEntries);
+
+ AbstractMetaEnumList globalEnums() const;
+ AbstractMetaFunctionList globalFunctions() const;
+ AbstractMetaClassList classes() const;
+ AbstractMetaClassList smartPointers() const;
+ AbstractMetaClassList classesTopologicalSorted(const Dependencies &additionalDependencies = Dependencies()) const;
+ PrimitiveTypeEntryList primitiveTypes() const;
+ ContainerTypeEntryList containerTypes() const;
+ QSet<QString> qtMetaTypeDeclaredTypeNames() const;
+
+ const AbstractMetaEnum* findAbstractMetaEnum(const EnumTypeEntry* typeEntry) const;
+ const AbstractMetaEnum* findAbstractMetaEnum(const TypeEntry* typeEntry) const;
+ const AbstractMetaEnum* findAbstractMetaEnum(const FlagsTypeEntry* typeEntry) const;
+ const AbstractMetaEnum* findAbstractMetaEnum(const AbstractMetaType* metaType) const;
+
+ int classCount() const;
+
+ bool run();
+private:
+ QString m_typeSystemFileName;
+ QString m_cppFileName;
+ QStringList m_includePaths;
+ AbstractMetaBuilder* m_builder;
+ QString m_logDirectory;
+
+ // disable copy
+ ApiExtractor(const ApiExtractor&);
+ ApiExtractor& operator=(const ApiExtractor&);
+#ifndef QT_NO_DEBUG_STREAM
+ friend QDebug operator<<(QDebug d, const ApiExtractor &ae);
+#endif
+};
+
+#endif // APIEXTRACTOR_H
diff --git a/sources/shiboken2/ApiExtractor/apiextractormacros.h b/sources/shiboken2/ApiExtractor/apiextractormacros.h
new file mode 100644
index 000000000..41a710773
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/apiextractormacros.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef APIEXTRACTORMACROS_H
+#define APIEXTRACTORMACROS_H
+
+
+// APIEXTRACTOR_API is used for the public API symbols.
+#if defined _WIN32
+ #define APIEXTRACTOR_DEPRECATED(func) __declspec(deprecated) func
+#elif __GNUC__ >= 4
+ #define APIEXTRACTOR_DEPRECATED(func) func __attribute__ ((deprecated))
+#else
+ #define APIEXTRACTOR_DEPRECATED(func) func
+#endif
+#endif
diff --git a/sources/shiboken2/ApiExtractor/asttoxml.cpp b/sources/shiboken2/ApiExtractor/asttoxml.cpp
new file mode 100644
index 000000000..7a2f1261e
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/asttoxml.cpp
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "asttoxml.h"
+#include "parser/control.h"
+#include "parser/parser.h"
+#include "parser/binder.h"
+
+
+#include <QtCore/QXmlStreamWriter>
+#include <QtCore/QTextStream>
+#include <QtCore/QTextCodec>
+#include <QtCore/QFile>
+
+typedef QHash<QString, EnumModelItem> EnumMap;
+typedef QHash<QString, FunctionModelItem> FunctionModelItemMap;
+typedef QHash<QString, ClassModelItem> ClassModelItemMap;
+typedef QHash<QString, NamespaceModelItem> NamespaceModelItemMap;
+
+void astToXML(QString name)
+{
+ QFile file(name);
+
+ if (!file.open(QFile::ReadOnly))
+ return;
+
+ QTextStream stream(&file);
+ stream.setCodec(QTextCodec::codecForName("UTF-8"));
+ QByteArray contents = stream.readAll().toUtf8();
+ file.close();
+
+ Control control;
+ Parser p(&control);
+ pool __pool;
+
+ TranslationUnitAST *ast = p.parse(contents, contents.size(), &__pool);
+
+ CodeModel model;
+ Binder binder(&model, p.location());
+ FileModelItem dom = binder.run(ast);
+
+ QFile outputFile;
+ if (!outputFile.open(stdout, QIODevice::WriteOnly))
+ return;
+
+ QXmlStreamWriter s(&outputFile);
+ s.setAutoFormatting(true);
+
+ s.writeStartElement(QLatin1String("code"));
+
+ const NamespaceList &namespaces = dom->namespaces();
+ foreach (const NamespaceModelItem &n, namespaces)
+ writeOutNamespace(s, n);
+
+ const ClassList &classList = dom->classes();
+ foreach (const ClassModelItem &c, classList)
+ writeOutClass(s, c);
+
+ s.writeEndElement();
+}
+
+void writeOutNamespace(QXmlStreamWriter &s, const NamespaceModelItem &item)
+{
+ s.writeStartElement(QLatin1String("namespace"));
+ s.writeAttribute(QLatin1String("name"), item->name());
+
+ const NamespaceList &namespaces = item->namespaces();
+ foreach (const NamespaceModelItem &n, namespaces)
+ writeOutNamespace(s, n);
+
+ const ClassList &classList = item->classes();
+ foreach (const ClassModelItem &c, classList)
+ writeOutClass(s, c);
+
+ const EnumList &enums = item->enums();
+ foreach (const EnumModelItem &e, enums)
+ writeOutEnum(s, e);
+
+ s.writeEndElement();
+}
+
+void writeOutEnum(QXmlStreamWriter &s, const EnumModelItem &item)
+{
+ QString qualifiedName = item->qualifiedName().join(QLatin1String("::"));
+ s.writeStartElement(QLatin1String("enum"));
+ s.writeAttribute(QLatin1String("name"), qualifiedName);
+
+ EnumeratorList enumList = item->enumerators();
+ for (int i = 0; i < enumList.size() ; i++) {
+ s.writeStartElement(QLatin1String("enumerator"));
+ if (!enumList[i]->value().isEmpty())
+ s.writeAttribute(QLatin1String("value"), enumList[i]->value());
+ s.writeCharacters(enumList[i]->name());
+
+ s.writeEndElement();
+ }
+ s.writeEndElement();
+}
+
+void writeOutFunction(QXmlStreamWriter &s, const FunctionModelItem &item)
+{
+ QString qualifiedName = item->qualifiedName().join(QLatin1String("::"));
+ s.writeStartElement(QLatin1String("function"));
+ s.writeAttribute(QLatin1String("name"), qualifiedName);
+
+ ArgumentList arguments = item->arguments();
+ for (int i = 0; i < arguments.size() ; i++) {
+ s.writeStartElement(QLatin1String("argument"));
+ s.writeAttribute(QLatin1String("type"), arguments[i]->type().qualifiedName().join(QLatin1String("::")));
+ s.writeEndElement();
+ }
+ s.writeEndElement();
+}
+
+void writeOutClass(QXmlStreamWriter &s, const ClassModelItem &item)
+{
+ QString qualifiedName = item->qualifiedName().join(QLatin1String("::"));
+ s.writeStartElement(QLatin1String("class"));
+ s.writeAttribute(QLatin1String("name"), qualifiedName);
+
+ const EnumList &enums = item->enums();
+ foreach (const EnumModelItem &e, enums)
+ writeOutEnum(s, e);
+
+ const FunctionList &functionList = item->functions();
+ foreach (const FunctionModelItem &func, functionList)
+ writeOutFunction(s, func);
+
+ const ClassList &classList = item->classes();
+ foreach (const ClassModelItem &c, classList)
+ writeOutClass(s, c);
+
+ s.writeEndElement();
+}
+
diff --git a/sources/shiboken2/ApiExtractor/asttoxml.h b/sources/shiboken2/ApiExtractor/asttoxml.h
new file mode 100644
index 000000000..ed2a04833
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/asttoxml.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef ASTTOXML
+#define ASTTOXML
+
+#include "parser/codemodel_fwd.h"
+
+#include <QtCore/QString>
+
+QT_FORWARD_DECLARE_CLASS(QXmlStreamWriter)
+
+void astToXML(const QString name);
+void writeOutNamespace(QXmlStreamWriter &s, const NamespaceModelItem &item);
+void writeOutEnum(QXmlStreamWriter &s, const EnumModelItem &item);
+void writeOutFunction(QXmlStreamWriter &s, const FunctionModelItem &item);
+void writeOutClass(QXmlStreamWriter &s, const ClassModelItem &item);
+
+
+#endif // ASTTOXML
diff --git a/sources/shiboken2/ApiExtractor/cmake_uninstall.cmake b/sources/shiboken2/ApiExtractor/cmake_uninstall.cmake
new file mode 100644
index 000000000..df95fb9d8
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/cmake_uninstall.cmake
@@ -0,0 +1,21 @@
+IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
+ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+STRING(REGEX REPLACE "\n" ";" files "${files}")
+FOREACH(file ${files})
+ MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
+ IF(EXISTS "$ENV{DESTDIR}${file}")
+ EXEC_PROGRAM(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ IF(NOT "${rm_retval}" STREQUAL 0)
+ MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
+ ENDIF(NOT "${rm_retval}" STREQUAL 0)
+ ELSE(EXISTS "$ENV{DESTDIR}${file}")
+ MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
+ ENDIF(EXISTS "$ENV{DESTDIR}${file}")
+ENDFOREACH(file)
diff --git a/sources/shiboken2/ApiExtractor/dependency.h b/sources/shiboken2/ApiExtractor/dependency.h
new file mode 100644
index 000000000..17fbffcce
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/dependency.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DEPENDENCY_H
+#define DEPENDENCY_H
+
+#include <QtCore/QString>
+#include <QtCore/QVector>
+
+// Dependencies for topologically sorting classes
+struct Dependency {
+ QString parent;
+ QString child;
+};
+
+typedef QVector<Dependency> Dependencies;
+
+#endif // DEPENDENCY_H
diff --git a/sources/shiboken2/ApiExtractor/doc/CMakeLists.txt b/sources/shiboken2/ApiExtractor/doc/CMakeLists.txt
new file mode 100644
index 000000000..d78844dc8
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/CMakeLists.txt
@@ -0,0 +1,10 @@
+
+find_program(SPHINX sphinx-build DOC "Path to sphinx-build binary.")
+
+if (SPHINX)
+ message("-- sphinx-build - found")
+ configure_file(conf.py.in conf.py @ONLY)
+ add_custom_target(doc ${SPHINX} -b html -c . ${CMAKE_CURRENT_SOURCE_DIR} html )
+else()
+ message("-- sphinx-build - not found! doc target disabled")
+endif() \ No newline at end of file
diff --git a/sources/shiboken2/ApiExtractor/doc/_templates/index.html b/sources/shiboken2/ApiExtractor/doc/_templates/index.html
new file mode 100644
index 000000000..4aa14ede5
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_templates/index.html
@@ -0,0 +1,27 @@
+{% extends "layout.html" %}
+{% set title = 'Overview' %}
+{% block body %}
+<div class="section">
+ <h1>API Extractor {{ version }}</h1>
+
+ <p>API Extractor is a tool that eases the development of bindings of Qt-based libraries for high
+ level languages by automating most of the process.
+
+ <p>API Extractor is based on the
+ <a href="http://labs.trolltech.com/page/Projects/QtScript/Generator">QtScriptGenerator</a> project.</p>
+
+ <h2>Documentation</h2>
+ <table class="contentstable"><tr>
+ <td width="50%">
+ <p class="biglink"><a href="{{ pathto("overview") }}">Overview</a><br/>
+ <span class="linkdescr">how API Extractor works</span></p>
+ <p class="biglink"><a href="{{ pathto("typesystem") }}">Typesystem reference</a><br/>
+ <span class="linkdescr">reference for all typesystem tags</span></p>
+ </td>
+ <td width="50%">
+ <p class="biglink"><a href="{{ pathto("contents") }}">Contents</a><br/>
+ <span class="linkdescr">for a complete overview</span></p>
+ </td></tr>
+ </table>
+</div>
+{% endblock %}
diff --git a/sources/shiboken2/ApiExtractor/doc/_templates/layout.html b/sources/shiboken2/ApiExtractor/doc/_templates/layout.html
new file mode 100644
index 000000000..9dc53722d
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_templates/layout.html
@@ -0,0 +1,41 @@
+{% extends "!layout.html" %}
+
+# Invert sidebars
+{%- block sidebar1 %}{{ sidebar() }}{%- endblock %}
+{%- block sidebar2 %}{%- endblock %}
+
+{%- block header %}
+<div id="container">
+<div class="header">
+ <div class="header_container">
+ <div class="logo"><a href="http://www.pyside.org"><img alt="PySide" src="{{ pathto('_static/pysidelogo.png', 1) }}" width="199" height="102" /></a></div>
+ <div class="related">
+ <ul>
+ {%- block rootrellink %}
+ <li><a href="{{ pathto( 'index' ) }}">{{ shorttitle|e }}</a></li>
+ {%- endblock %}
+ {%- for parent in parents %}
+ <li>{{ reldelim1 }} <a href="{{ parent.link|e }}" {% if loop.last %}{{ accesskey("U") }}{% endif %}>{{ parent.title }}</a></li>
+ {%- endfor %}
+ {%- block relbaritems %} {% endblock %}
+ </ul>
+ </div>
+ </div>
+</div>
+{%- endblock -%}
+
+{%- block footer %}
+ <div class="footer">
+ <a href="http://www.indt.org.br"><img src="{{ pathto('_static/logo_indt.jpg', 1) }}" alt="Indt" border="0" /></a>
+ <a href="http://www.openbossa.org"><img src="{{ pathto('_static/logo_openbossa.png', 1) }}" alt="Openbossa" border="0" /></a>
+ <a href="http://qt.nokia.com/"><img src="{{ pathto('_static/logo_qt.png', 1) }}" alt="Qt" border="0" /></a>
+ <a href="http://www.python.org"><img src="{{ pathto('_static/logo_python.jpg', 1) }}" alt="Python" border="0" /></a>
+ </div>
+</div>
+{%- endblock %}
+
+# No top relbar.
+{%- block relbar1 %}{%- endblock %}
+
+# No bottom relbar.
+{%- block relbar2 %}{%- endblock %}
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/searchbox.html b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/searchbox.html
new file mode 100644
index 000000000..55a972156
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/searchbox.html
@@ -0,0 +1,12 @@
+{%- if pagename != "search" %}
+<div id="searchbox" style="display: none">
+ <h3>{{ _('Quick search') }}</h3>
+ <form class="search" action="{{ pathto('search') }}" method="get">
+ <input type="text" name="q" id="q" size="18" />
+ <input type="submit" value="{{ _('Go') }}" id="search_button" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+{%- endif %}
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/bg_header.png b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/bg_header.png
new file mode 100644
index 000000000..843e7e2c5
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/bg_header.png
Binary files differ
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/bg_topo.jpg b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/bg_topo.jpg
new file mode 100644
index 000000000..4229ae8db
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/bg_topo.jpg
Binary files differ
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/fakebar.png b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/fakebar.png
new file mode 100644
index 000000000..b45830e00
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/fakebar.png
Binary files differ
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_indt.jpg b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_indt.jpg
new file mode 100644
index 000000000..2a1fbe7a1
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_indt.jpg
Binary files differ
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_openbossa.png b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_openbossa.png
new file mode 100644
index 000000000..51e868d6e
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_openbossa.png
Binary files differ
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_python.jpg b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_python.jpg
new file mode 100644
index 000000000..cd474efba
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_python.jpg
Binary files differ
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_qt.png b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_qt.png
new file mode 100644
index 000000000..37800f454
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/logo_qt.png
Binary files differ
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/pysidedocs.css b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/pysidedocs.css
new file mode 100644
index 000000000..fd81f4379
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/pysidedocs.css
@@ -0,0 +1,409 @@
+* {
+ font: 100% Verdana, Arial, Helvetica, sans-serif;
+ font-size:12px;
+}
+
+html {
+ height: 100%;
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ text-align: center;
+ background-color: #EBEBEB;
+ height: 100%;
+ color: #333;
+}
+
+strong {
+ font-weight:bold;
+}
+
+.document {
+ padding-bottom: 90px;
+}
+
+#container {
+ position: relative;
+ min-height: 100%;
+ background-image: url(fakebar.png);
+ background-repeat: repeat-y;
+ background-color: white;
+}
+
+.footer {
+ position: absolute;
+ bottom: 0px;
+ margin-top: 50px;
+ text-align:center;
+ background-color: white;
+ border-top: 2px solid #e0e0e0;
+ white-space: nowrap;
+ height: 90px;
+ width: 100%;
+}
+
+.footer img {
+ margin-left: 8px;
+ margin-right: 8px;
+}
+
+.sphinxsidebar {
+ float: left;
+ width: 250px;
+ padding: 0px 10px 0px 10px;
+ text-align: left;
+}
+
+.sphinxsidebar ul {
+ padding: 0px;
+ margin: 0px;
+ list-style-position: inside;
+}
+
+.sphinxsidebar > ul {
+ padding: 0px;
+ margin: 0px;
+}
+
+.sphinxsidebar ul li {
+ margin-left: 10px;
+ padding: 0px;
+}
+
+.sphinxsidebar h3, .sphinxsidebar h3 a {
+ font-weight: bold;
+ color: #333;
+}
+
+.documentwrapper {
+ margin-left: 270px;
+ text-align: left;
+ background-color: #ffffff;
+ border-left: 1px solid #989898;
+ font-size:18px;
+ padding: 10px 50px 15px 50px;
+ height: 100%;
+}
+
+h1 {
+ font-size:18px;
+ padding-left: 50px;
+ padding-bottom: 15px;
+ padding-top: 15px;
+ border-bottom: 1px solid #c2c2c2;
+ text-transform:uppercase;
+ margin-right: -100px;
+ position: relative;
+ left: -50px;
+ top: -10px;
+}
+
+h2 {
+ font-size:12px;
+ font-weight:bold;
+ border-left-width: 1px;
+ border-right-width: 1px;
+ border-top-width: 1px;
+ border-bottom-width: 2px;
+ border-style: solid;
+ border-left-color: #b1b1b1;
+ border-right-color: #b1b1b1;
+ border-top-color: #b1b1b1;
+ border-bottom-color: #009491;
+ background-color: #e0e0e0;
+ padding:5px;
+ margin-top: 20px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ -khtml-border-radius:5px;
+}
+
+h3, h4 {
+ font-weight: bolder;
+}
+
+pre {
+ border-top: 1px solid #e0e0e0;
+ border-bottom: 1px solid #e0e0e0;
+ background-color: #fafafa;
+ padding: 5px;
+ font: 100% monospace;
+ overflow: auto;
+}
+
+pre * {
+ font: 100% monospace;
+}
+
+.headerlink {
+ font-size: 100%;
+ color: inherit;
+ float: right;
+ visibility: Hidden;
+}
+
+h1 .headerlink {
+ padding-right: 50px;
+}
+
+h1:hover .headerlink, h2:hover .headerlink, h3:hover .headerlink {
+ visibility: Visible;
+}
+
+a, a:visited {
+ color: #009491;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+/* -- admonitions ----------------------------------------------------------- */
+
+div.admonition {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ padding: 7px;
+}
+
+div.admonition dt {
+ font-weight: bold;
+}
+
+div.admonition dl {
+ margin-bottom: 0;
+}
+
+p.admonition-title {
+ margin: 0px 10px 5px 0px;
+ font-weight: bold;
+}
+
+div.body p.centered {
+ text-align: center;
+ margin-top: 25px;
+}
+
+div.warning {
+ background-color: #ffe4e4;
+ border: 1px solid #f66;
+}
+
+div.note {
+ border: 1px solid #e3e3e3;
+}
+
+table.docutils {
+ margin-left: auto;
+ margin-right: auto;
+ margin-bottom: 10px;
+ border: none;
+}
+
+table.docutils td {
+ border: none;
+}
+
+table.docutils th {
+ border: none;
+ font-weight: bold;
+ vertical-align: top;
+}
+
+h2 em {
+ float: right;
+ font-size: 10px;
+ position: relative;
+ top: -20px;
+}
+
+/* Table of pymaemo components */
+
+#development table.docutils td {
+ border-bottom: 1px solid #EBEBEB;
+}
+
+#development th {
+ background-color: #EBEBEB;
+ color: #FC7E00;
+ padding: 5px;
+}
+
+#development th:first-child {
+ -moz-border-radius: 20px 0px 0px 0px;
+ -webkit-border-radius: 20px 0px 0px 0px;
+ -khtml-border-radius: 20px 0px 0px 0px;
+ padding-left: 10px;
+}
+#development th:last-child {
+ -moz-border-radius: 0px 20px 0px 0px;
+ -webkit-border-radius: 0px 20px 0px 0px;
+ -khtml-border-radius: 0px 20px 0px 0px;
+ padding-right: 10px;
+ width: 100px;
+}
+
+hr {
+ border: none;
+ border-bottom: 1px dashed #EBEBEB;
+ width: 70%
+}
+
+.oldnews {
+ text-align: right;
+}
+
+/******************* TOPO *****************************/
+.header {
+ background-image: url(bg_topo.jpg);
+ background-repeat: repeat-x;
+ height: 147px;
+}
+
+.header_container {
+ background-image: url(bg_header.png);
+ background-repeat: no-repeat;
+ background-position: 100px 0px;
+}
+
+.logo {
+ text-align: left;
+ margin-bottom: 10px;
+}
+
+#searchbox {
+ border-top: 1px solid #989898;
+ padding-top: 10px;
+ margin-left: -10px;
+ margin-right: -10px;
+ padding-left: 10px;
+ padding-right: 10px;
+}
+
+#search_button {
+ border: 1px solid #3A393A;
+ background-color: #3A393A;
+ color: white;
+ cursor: pointer;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -khtml-border-radius: 5px;
+
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+}
+
+/* search field */
+form #q {
+ width: 136px;
+/* height: 22px; */
+ border: none;
+ margin: 0px;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -khtml-border-radius: 5px;
+ margin-top: 2px;
+ padding: 4px;
+ line-height: 22px
+}
+
+#search-results h2 {
+ display: none;
+}
+
+#search-results h2 {
+ display: none;
+}
+
+#search-results ul.search {
+ margin: 0px;
+ padding: 0px;
+}
+
+ul.search div.context {
+ padding-left: 40px;
+}
+
+#installation td {
+ text-align: center;
+ font-weight: bold;
+}
+
+em {
+ color: inherit;
+ font-style:italic;
+}
+
+/******** REL bar *********/
+
+.related {
+ display: inline;
+}
+
+.related ul {
+ padding: 0px 0px 0px 10px;
+ margin: 0px;
+ text-align: left;
+ background-image: url(relbar_bg.png);
+}
+
+.related li {
+ display: inline;
+ color: white;
+ font-weight: bold;
+}
+
+.related li a {
+ color: inherit;
+ line-height: 35px;
+ font-weight: bold;
+ vertical-align: middle;
+}
+
+.related li.right {
+ float: right;
+ margin-right: 5px;
+}
+
+.related h3 {
+ display: none;
+}
+
+.align-center {
+ text-align: center;
+}
+
+.contentstable {
+ width: 100%;
+}
+
+.contentstable td {
+ padding-left: 30px;
+ vertical-align: top;
+}
+
+p.biglink a {
+ font-size: 20px;
+}
+
+dt:target, .highlight {
+ background-color: #fbe54e;
+}
+
+img {
+ border: 0px;
+}
+
+.figure .caption {
+ font-style:italic;
+}
+
+table.footnote {
+ margin: 0px;
+}
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/pysidelogo.png b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/pysidelogo.png
new file mode 100644
index 000000000..076c1057c
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/pysidelogo.png
Binary files differ
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/relbar_bg.png b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/relbar_bg.png
new file mode 100644
index 000000000..4036733a7
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/static/relbar_bg.png
Binary files differ
diff --git a/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/theme.conf b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/theme.conf
new file mode 100644
index 000000000..e0a652a5d
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/_themes/pysidedocs/theme.conf
@@ -0,0 +1,7 @@
+[theme]
+inherit = default
+stylesheet = pysidedocs.css
+pygments_style = none
+
+[options]
+nosidebar = false
diff --git a/sources/shiboken2/ApiExtractor/doc/conf.py.in b/sources/shiboken2/ApiExtractor/doc/conf.py.in
new file mode 100644
index 000000000..70750c899
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/conf.py.in
@@ -0,0 +1,163 @@
+# -*- coding: utf-8 -*-
+#
+# ApiExtractor documentation build configuration file, created by
+# sphinx-quickstart on Wed Apr 22 15:04:20 2009.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.append(os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.ifconfig', 'sphinx.ext.refcounting', 'sphinx.ext.coverage']
+
+rst_epilog = """
+.. |project| replace:: API Extractor
+"""
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+source_encoding = 'utf-8'
+
+# The master toctree document.
+#master_doc = 'contents'
+
+# General information about the project.
+project = u'API Extractor'
+copyright = u'2009-2010, Nokia Corporation'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '@apiextractor_MAJOR_VERSION@.@apiextractor_MINOR_VERSION@'
+# The full version, including alpha/beta/rc tags.
+release = '@apiextractor_VERSION@'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'pysidedocs'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {
+#}
+
+# Add any paths that contain custom themes here, relative to this directory.
+html_theme_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_themes']
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+#html_static_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = { '' : ''}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+html_additional_pages = { 'index' : 'index.html'}
+
+# If false, no index is generated.
+html_use_index = False
+
+# If true, the index is split into individual pages for each letter.
+html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+html_show_sourcelink = False
+
+html_add_permalinks = True;
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
diff --git a/sources/shiboken2/ApiExtractor/doc/contents.rst b/sources/shiboken2/ApiExtractor/doc/contents.rst
new file mode 100644
index 000000000..83a4889fe
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/contents.rst
@@ -0,0 +1,9 @@
+Table of contents
+*****************
+.. toctree::
+ :numbered:
+ :maxdepth: 3
+
+ overview.rst
+ ownership.rst
+ typesystem.rst
diff --git a/sources/shiboken2/ApiExtractor/doc/dependency-apiextractor.svg b/sources/shiboken2/ApiExtractor/doc/dependency-apiextractor.svg
new file mode 100644
index 000000000..6bec8b5a8
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/dependency-apiextractor.svg
@@ -0,0 +1,360 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="750"
+ height="230"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="dependency-apiextractor.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="/tmp/dependency-pyside.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="Arrow1Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lstart"
+ style="overflow:visible">
+ <path
+ id="path3270"
+ d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(0.8,0,0,0.8,10,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend"
+ style="overflow:visible">
+ <path
+ id="path3679"
+ d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.6315754"
+ inkscape:cx="375"
+ inkscape:cy="115"
+ inkscape:document-units="px"
+ inkscape:current-layer="svg2"
+ showgrid="false"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1278"
+ inkscape:window-height="949"
+ inkscape:window-x="1330"
+ inkscape:window-y="25">
+ <sodipodi:guide
+ orientation="1,0"
+ position="384.28571,590"
+ id="guide2601" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="678.57143,491.42857"
+ id="guide2603" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="78.571429,257.14286"
+ id="guide2605" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="93.571429,280.71429"
+ id="guide7565" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="148.57143,216.42857"
+ id="guide7567" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-250.44576,-308.53365)" />
+ <g
+ id="g2664"
+ transform="translate(-162.03535,-115.53321)">
+ <path
+ inkscape:connector-type="polyline"
+ id="path2869"
+ d="M 439.27375,270.21407 L 594.99083,193.03351"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-end:none;stroke-opacity:1" />
+ <g
+ transform="translate(166.24286,-190.07976)"
+ id="g2606">
+ <rect
+ style="fill:#e3e2db;stroke:#000000;stroke-opacity:1"
+ id="rect7541"
+ width="211.42857"
+ height="124.28571"
+ x="6.6142678"
+ y="308.16089"
+ ry="17.142857" />
+ <text
+ xml:space="preserve"
+ style="font-size:20.61732101px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="76.614265"
+ y="339.74512"
+ id="text7543"><tspan
+ sodipodi:role="line"
+ id="tspan7545"
+ x="76.614265"
+ y="339.74512">Boost</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:20.61732101px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="76.614265"
+ y="372.67505"
+ id="text7547"><tspan
+ sodipodi:role="line"
+ id="tspan7549"
+ x="76.614265"
+ y="372.67505">Qt Software</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:20.61732101px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="76.614265"
+ y="408.38055"
+ id="text7551"><tspan
+ sodipodi:role="line"
+ id="tspan7553"
+ x="76.614265"
+ y="408.38055">INdT/Nokia</tspan></text>
+ <rect
+ style="fill:#aaeeff;fill-opacity:1;stroke:#000000;stroke-width:0.64285713;stroke-opacity:1"
+ id="rect7555"
+ width="43.163269"
+ height="22.5"
+ x="21.614267"
+ y="321.55374"
+ ry="6.4285707" />
+ <rect
+ style="fill:#b3ff80;fill-opacity:1;stroke:#000000;stroke-width:0.64285713;stroke-opacity:1"
+ id="rect7561"
+ width="43.163269"
+ height="22.5"
+ x="21.614267"
+ y="355.4823"
+ ry="6.4285707" />
+ <rect
+ style="fill:#e9ddaf;fill-opacity:1;stroke:#000000;stroke-width:0.64285713;stroke-opacity:1"
+ id="rect7563"
+ width="43.163269"
+ height="22.5"
+ x="21.614267"
+ y="390.4823"
+ ry="6.4285707" />
+ </g>
+ <path
+ inkscape:connector-type="polyline"
+ id="path2604"
+ d="M 782.79015,270.0418 L 627.07307,192.86124"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-end:none;stroke-opacity:1" />
+ <g
+ transform="translate(234.84929,-73.143707)"
+ id="g5193">
+ <rect
+ ry="9.2689295"
+ style="fill:#b3ff80;fill-rule:evenodd;stroke:#2a7800;stroke-width:0.96558368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="rect2417"
+ width="274.18781"
+ height="73.282379"
+ x="78.571426"
+ y="342.86383"
+ rx="8.3239012" />
+ <text
+ xml:space="preserve"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="88.822823"
+ y="359.67014"
+ id="text2419"><tspan
+ sodipodi:role="line"
+ id="tspan2421"
+ x="88.822823"
+ y="359.67014">Qt 4.5</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="88.822823"
+ y="375.33484"
+ id="text2423"><tspan
+ sodipodi:role="line"
+ id="tspan2425"
+ x="88.822823"
+ y="375.33484">4.5</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="88.822823"
+ y="390.87479"
+ id="text2427"><tspan
+ sodipodi:role="line"
+ id="tspan2429"
+ x="88.822823"
+ y="390.87479">headers and libraries - compile-time and run-time</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="88.822823"
+ y="400.84058"
+ id="text2431"><tspan
+ sodipodi:role="line"
+ id="tspan2433"
+ x="88.822823"
+ y="400.84058">GNU General Public License v3 /</tspan><tspan
+ id="tspan2472"
+ sodipodi:role="line"
+ x="88.822823"
+ y="411.1687">GNU Lesser General Public Licence v2.1</tspan></text>
+ </g>
+ <g
+ transform="translate(101.41581,-378.37135)"
+ id="g5120">
+ <rect
+ rx="10.404889"
+ ry="13.104635"
+ style="fill:#e9ddaf;fill-rule:evenodd;stroke:#5f5019;stroke-width:0.96620417px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="rect2441"
+ width="274.54263"
+ height="73.281754"
+ x="384.28571"
+ y="496.43558" />
+ <text
+ xml:space="preserve"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="389.17969"
+ y="513.59869"
+ id="text2443"><tspan
+ sodipodi:role="line"
+ id="tspan2445"
+ x="389.17969"
+ y="513.59869">libapiextractor</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="389.17969"
+ y="529.26337"
+ id="text2447"><tspan
+ sodipodi:role="line"
+ id="tspan2449"
+ x="389.17969"
+ y="529.26337">0.2</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="389.17969"
+ y="544.80334"
+ id="text2451"><tspan
+ sodipodi:role="line"
+ x="389.17969"
+ y="544.80334"
+ id="tspan2453">headers and libraries - compile-time and run-time</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="389.17969"
+ y="560.12628"
+ id="text2455"><tspan
+ sodipodi:role="line"
+ id="tspan2457"
+ x="389.17969"
+ y="560.12628">LGPL version 2.1</tspan></text>
+ </g>
+ <g
+ transform="translate(242.40213,-378.858)"
+ id="g5182">
+ <rect
+ ry="11.287985"
+ style="fill:#aaeeff;fill-rule:evenodd;stroke:#006078;stroke-width:0.96620417px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="rect2563"
+ width="274.54263"
+ height="73.281754"
+ x="384.28571"
+ y="648.57843"
+ rx="10.404877" />
+ <text
+ xml:space="preserve"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="389.17969"
+ y="665.74158"
+ id="text2565"><tspan
+ sodipodi:role="line"
+ id="tspan2567"
+ x="389.17969"
+ y="665.74158">boost::graph</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="389.17969"
+ y="681.40625"
+ id="text2569"><tspan
+ sodipodi:role="line"
+ id="tspan2571"
+ x="389.17969"
+ y="681.40625">1.38.0</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="389.17969"
+ y="696.94623"
+ id="text2573"><tspan
+ sodipodi:role="line"
+ x="389.17969"
+ y="696.94623"
+ id="tspan2575">headers and libraries - compile-time and run-time</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="389.17969"
+ y="712.26917"
+ id="text2577"><tspan
+ sodipodi:role="line"
+ id="tspan2579"
+ x="389.17969"
+ y="712.26917">Boost Software License 1.0</tspan></text>
+ </g>
+ </g>
+</svg>
diff --git a/sources/shiboken2/ApiExtractor/doc/overview.rst b/sources/shiboken2/ApiExtractor/doc/overview.rst
new file mode 100644
index 000000000..471e2439b
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/overview.rst
@@ -0,0 +1,15 @@
+.. _gen-overview:
+
+**********************
+API Extractor Overview
+**********************
+
+The **API Extractor** library is used by the binding generator to parse headers
+of a given library and merge this data with information provided by
+typesystem (XML) files, resulting in a representation of how the API should be
+exported to the chosen target language. The generation of source code for the
+bindings is performed by specific generators using the API Extractor library.
+
+The API Extractor is based on QtScriptGenerator_ codebase.
+
+.. _QtScriptGenerator: http://labs.trolltech.com/page/Projects/QtScript/Generator
diff --git a/sources/shiboken2/ApiExtractor/doc/ownership.rst b/sources/shiboken2/ApiExtractor/doc/ownership.rst
new file mode 100644
index 000000000..760967da6
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/ownership.rst
@@ -0,0 +1,85 @@
+Ownership Management
+********************
+
+Among the various types of instances interactions, sometimes an object
+may be *owned* by another object, so that the owner is responsible for
+destroying the owned object, like in Qt's object system [#]_.
+This kind of relationship has a big role on interfacing with the target language, like
+with Python's reference counting.
+
+
+Ownership transfers
+-------------------
+
+From C++ to target
+^^^^^^^^^^^^^^^^^^
+
+ When an object that is currently owned by C++ has its ownership transfered
+ back to the target language, the binding can know for sure when the object will be deleted and
+ tie the C++ instance existence to the wrapper, calling the C++ destructor normally when the
+ wrapper is deleted.
+
+ .. code-block:: xml
+
+ <modify-argument index="1">
+ <define-ownership class="target" owner="target" />
+ </modify-argument>
+
+
+From target to C++
+^^^^^^^^^^^^^^^^^^
+
+ In the opposite direction,when an object ownership is transfered from the target language
+ to C++, the native code takes full control of the object life and you don't
+ know when that object will be deleted, rendering the wrapper object invalid,
+ unless you're wrapping an object with a virtual destructor,
+ so you can override it and be notified of its destruction.
+
+ By default it's safer to just render the wrapper
+ object invalid and raise some error if the user tries to access
+ one of this objects members or pass it as argument to some function, to avoid unpleasant segfaults.
+ Also you should avoid calling the C++ destructor when deleting the wrapper.
+
+ .. code-block:: xml
+
+ <modify-argument index="1">
+ <define-ownership class="target" owner="c++" />
+ </modify-argument>
+
+
+Parent-child relationship
+-------------------------
+
+One special type of relationship is the parent-child. When an object is called
+the parent of another object (the child), the former is in charge of deleting its
+child when deleted and the target language can trust that the child will be alive
+as long as the parent is, unless some other method can take the C++ ownership away from the parent.
+
+One of the main uses of this scheme is Qt's object system, with ownership among QObject-derived
+classes, creating "trees" of instances.
+
+ .. code-block:: xml
+
+ <modify-argument index="this">
+ <parent index="1" action="add">
+ </modify-argument>
+
+In this example, the instance with the method that is being invoked (indicated by 'index="this"' on
+modify-argument) will be marked as a child
+of the first argument using the `parent` tag. To remove ownership, just use "remove" in the action attribute. **Removing
+parentship also transfers the ownership back to python.**
+
+Invalidation after use
+----------------------
+
+Sometimes an object is created as a virtual method call argument and destroyed after the
+call returned. In this case, you should use the ``invalidate-after-use`` attribute in the
+``modify-argument`` tag to mark the wrapper as invalid right after the virtual method returns.
+
+ .. code-block:: xml
+
+ <modify-argument index="2" invalidate-after-use="yes"/>
+
+In this example the second argument will be invalidated after this method call.
+
+.. [#] See *Object Trees and Object Ownership* http://doc.trolltech.com/4.5/objecttrees.html
diff --git a/sources/shiboken2/ApiExtractor/doc/typesystem.rst b/sources/shiboken2/ApiExtractor/doc/typesystem.rst
new file mode 100644
index 000000000..69dda43a0
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/typesystem.rst
@@ -0,0 +1,29 @@
+The API Extractor Type System
+*****************************
+
+The typesystem is used by a binding generator or any other software using the APIExtractor library
+to map a C++ library API onto a higher level language.
+
+The typesystem specification is a handwritten XML document listing the types
+that will be available in the generated target language API; types that are not
+declared in the specification will be ignored along with everything depending on
+them. In addition, it is possible to manipulate and modify types and functions.
+It is even possible to use the typesystem specification to inject arbitrary
+code into the source files, such as an extra member function.
+
+Below there is a complete reference guide to the various nodes (XML tags) of the typesystem.
+For usage examples, take a look at the typesystem files used to generate PySide. These files
+can be found in the PySide/<QT_MODULE_NAME> directory of the PySide package.
+
+.. toctree::
+
+ typesystem_specifying_types
+ typesystem_manipulating_objects
+ typesystem_modify_function
+ typesystem_arguments
+ typesystem_solving_compilation
+ typesystem_templates
+ typesystem_conversionrule
+ typesystem_documentation
+
+
diff --git a/sources/shiboken2/ApiExtractor/doc/typesystem_arguments.rst b/sources/shiboken2/ApiExtractor/doc/typesystem_arguments.rst
new file mode 100644
index 000000000..16e0678d3
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/typesystem_arguments.rst
@@ -0,0 +1,192 @@
+.. _modifying-arguments:
+
+Modifying Arguments
+-------------------
+
+.. _conversion-rule:
+
+conversion-rule
+^^^^^^^^^^^^^^^
+
+ The conversion-rule node allows you to write customized code to convert
+ the given argument between the target language and C++, and it is a child of the modify-argument node.
+
+ .. code-block:: xml
+
+ <modify-argument ...>
+ <conversion-rule class="target | native">
+ // the code
+ </conversion-rule>
+ </modify-argument>
+
+ This node is typically used in combination with the replace-type and
+ remove-argument nodes. The given code is used instead of the generator's
+ conversion code.
+
+ Writing %N in the code (where N is a number), will insert the name of the
+ nth argument. Alternatively, %in and %out which will be replaced with the
+ name of the conversion's input and output variable, respectively. Note the
+ output variable must be declared explicitly, for example:
+
+ .. code-block:: xml
+
+ <conversion-rule class="native">
+ bool %out = (bool) %in;
+ </conversion-rule>
+
+ .. note:: You can also use the conversion-rule node to specify :ref:`a conversion code which will be used instead of the generator's conversion code everywhere for a given type <conversion-rule-on-types>`.
+
+remove-argument
+^^^^^^^^^^^^^^^
+
+ The remove-argument node removes the given argument from the function's
+ signature, and it is a child of the modify-argument node.
+
+ .. code-block:: xml
+
+ <modify-argument>
+ <remove-argument />
+ </modify-argument>
+
+rename to
+^^^^^^^^^
+
+ The 'rename to' node is used to rename a argument and use this new name in the generated code.
+
+ .. code-block:: xml
+
+ <modify-argument>
+ <rename to='...' />
+ </modify-argument>
+
+
+remove-default-expression
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+ The remove-default-expression node disables the use of the default expression
+ for the given argument, and it is a child of the modify-argument node.
+
+ .. code-block:: xml
+
+ <modify-argument...>
+ <remove-default-expression />
+ </modify-argument>
+
+replace-default-expression
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+ The replace-default-expression node replaces the specified argument with the
+ expression specified by the ``with`` attribute, and it is a child of the
+ modify-argument node.
+
+ .. code-block:: xml
+
+ <modify-argument>
+ <replace-default-expression with="..." />
+ </modify-argument>
+
+
+replace-type
+^^^^^^^^^^^^
+
+ The replace-type node replaces the type of the given argument to the one
+ specified by the ``modified-type`` attribute, and it is a child of the
+ modify-argument node.
+
+ .. code-block:: xml
+
+ <modify-argument>
+ <replace-type modified-type="..." />
+ </modify-argument>
+
+ If the new type is a class, the ``modified-type`` attribute must be set to
+ the fully qualified name (including name of the package as well as the class
+ name).
+
+define-ownership
+^^^^^^^^^^^^^^^^
+
+ The define-ownership tag indicates that the function changes the ownership
+ rules of the argument object. The ``class`` attribute specifies the class of
+ function where to inject the ownership altering code. The ``owner`` attribute
+ specifies the new ownership of the object. It accepts the following values:
+
+ * target: the target language will assume full ownership of the object.
+ The native resources will be deleted when the target language
+ object is finalized.
+ * c++: The native code assumes full ownership of the object. The target
+ language object will not be garbage collected.
+ * default: The object will get default ownership, depending on how it
+ was created.
+
+ .. code-block:: xml
+
+ <modify-argument>
+ <define-ownership class="target | native"
+ owner="target | c++ | default" />
+ </modify-argument>
+
+
+reference-count
+^^^^^^^^^^^^^^^
+
+ The reference-count tag dictates how an argument should be handled by the
+ target language reference counting system (if there is any), it also indicates
+ the kind of relationship the class owning the function being modified has with
+ the argument. For instance, in a model/view relation a view receiving a model
+ as argument for a **setModel** method should increment the model's reference
+ counting, since the model should be kept alive as much as the view lives.
+ Remember that out hypothetical view could not become parent of the model,
+ since the said model could be used by other views as well.
+ The ``action`` attribute specifies what should be done to the argument
+ reference counting when the modified method is called. It accepts the
+ following values:
+
+ * add: increments the argument reference counter.
+ * add-all: increments the reference counter for each item in a collection.
+ * remove: decrements the argument reference counter.
+ * set: will assign the argument to the variable containing the reference.
+ * ignore: does nothing with the argument reference counter
+ (sounds worthless, but could be used in situations
+ where the reference counter increase is mandatory
+ by default).
+
+ .. code-block:: xml
+
+ <modify-argument>
+ <reference-count action="add|add-all|remove|set|ignore" variable-name="..." />
+ </modify-argument>
+
+
+ The variable-name attribute specifies the name used for the variable that
+ holds the reference(s).
+
+
+replace-value
+^^^^^^^^^^^^^
+
+ The ``replace-value`` attribute lets you replace the return statement of a
+ function with a fixed string. This attribute can only be used for the
+ argument at ``index`` 0, which is always the function's return value.
+
+ .. code-block:: xml
+
+ <modify-argument index="0" replace-value="this"/>
+
+
+parent
+^^^^^^
+
+ The parent node lets you define the argument parent which will
+ take ownership of argument and will destroy the C++ child object when the
+ parent is destroyed.
+
+ .. code-block:: xml
+
+ <modify-argument index="1">
+ <parent index="this" action="add | remove" />
+ </modify-argument>
+
+ In the ``index`` argument you must specify the parent argument. The action
+ *add* creates a parent link between objects, while *remove* will undo the
+ parentage relationship.
diff --git a/sources/shiboken2/ApiExtractor/doc/typesystem_conversionrule.rst b/sources/shiboken2/ApiExtractor/doc/typesystem_conversionrule.rst
new file mode 100644
index 000000000..c62d5bbf6
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/typesystem_conversionrule.rst
@@ -0,0 +1,113 @@
+.. _conversion-rule-tag:
+
+Conversion Rule Tag
+-------------------
+
+.. _conversion-rule:
+
+conversion-rule
+^^^^^^^^^^^^^^^
+
+ The **conversion-rule** tag specifies how a **primitive-type**, a **container-type**,
+ or a **value-type** may be converted to and from the native C++ language types to the
+ target language types.
+
+ .. code-block:: xml
+
+ <value-type>
+ <conversion-rule>
+ <native-to-target>
+ // Code to convert a native value to a target language object.
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type='TARGETTYPEA' check='TARGETTYPEA_CHECK(%in)'>
+ // Code to convert target language type object of type TARGETTYPEA
+ // to the C++ native type represented by the value/primitive/container-type.
+ </add-conversion>
+ <add-conversion type='TARGETTYPEB' check='TARGETTYPEB_CHECK(%in)'>
+ // Code to convert target language type object of type TARGETTYPEB
+ // to the C++ native type represented by the value/primitive/container-type.
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </value-type>
+
+ The example above show the structure of a complete conversion rule. Each of the
+ child tags comprising the conversion rule are described in their own sections
+ below.
+
+
+.. _native-to-target:
+
+native-to-target
+^^^^^^^^^^^^^^^^
+
+ The **native-to-target** tag tells how to convert a native C++ value to its
+ target language equivalent. The text inside the tag is a C++ code the takes
+ an input value an does what's needed to convert it to the output value.
+ ``insert-template`` tags may be used to insert commonly repeating code.
+
+ .. code-block:: xml
+
+ <conversion-rule>
+ <native-to-target>
+ // Code to convert a native value to a target language object.
+ </native-to-target>
+ </conversion-rule>
+
+ Use the replace node to modify the template code.
+ Notice that the generator must provide type system variables for the input
+ and output values and types, namely **%in**, **%out**, **%INTYPE** and
+ **%OUTTYPE**. In the case of container types, **%INTYPE** refers to the
+ full container type (e.g. **"list<int>"**) and **%INTYPE_0**, **%INTYPE_1**,
+ **%INTYPE_#**, should be replaced by the types used in the container template
+ (e.g. **%INTYPE_0** correspondes to **"int"** for **"list<int>"**).
+
+
+.. _target-to-native:
+
+target-to-native
+^^^^^^^^^^^^^^^^
+
+ The **target-to-native** tag encloses at least one, but usually many, conversions
+ from target language values to C++ native values. The *optional* attribute
+ ``replace`` tells if the target language to C++ conversions will be added to, or if
+ they will replace the implicit conversions collected by *ApiExtractor*. The default
+ value for it is *yes*.
+
+
+ .. code-block:: xml
+
+ <conversion-rule>
+ <target-to-native replace='yes|no'>\
+ // List of target to native conversions meant to replace or expand
+ // the already existing implicit conversions.
+ </target-to-native>
+ </conversion-rule>
+
+
+.. _add-conversion:
+
+add-conversion
+^^^^^^^^^^^^^^
+
+ Each **add-conversion** tag adds a rule for conversion of a target language type,
+ indicated by the ``type`` attribute, to the C++ native type represented by the
+ **primitive-type**, a **container-type**, or **value-type**, to which the parent
+ **conversion-rule** belongs.
+
+ .. code-block:: xml
+
+ <target-to-native>
+ <add-conversion type='TARGETTYPE' check='TARGETTYPECHECK(%in)'>
+ // Code to convert target language type object of type TARGETTYPE_A
+ // to the C++ native type represented by the value/primitive/container-type.
+ </add-conversion>
+ <target-to-native>
+
+ The ``check`` attribute tells how a target value should be checked to see if it belongs to
+ the type expected. This attribute is *optional*, for it can be derived from the ``type``
+ attribute, but it isn't unusual that some special check is needed. The variables
+ **%in**, **%out**, **%INTYPE**, **%INTYPE_#**, and **%OUTTYPE**, must be provided by
+ the generator as in the ``native-to-target`` tag.
+
diff --git a/sources/shiboken2/ApiExtractor/doc/typesystem_documentation.rst b/sources/shiboken2/ApiExtractor/doc/typesystem_documentation.rst
new file mode 100644
index 000000000..43f72a1ba
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/typesystem_documentation.rst
@@ -0,0 +1,43 @@
+Manipulating Documentation
+--------------------------
+
+inject-documentation
+^^^^^^^^^^^^^^^^^^^^
+
+ The inject-documentation node inserts the documentation into the generated
+ documentation. This node is a child of the object-type, value-type and
+ modify-function nodes.
+
+ .. code-block:: xml
+
+ <value-type>
+ <inject-documentation mode="append | prepend | replace" format="native | target" >
+ // the documentation
+ </inject-code>
+ </value-type>
+
+ The **mode** attribute default value is *replace*.
+
+ The **format** attribute specifies when the documentation injection will
+ occur and it accepts the following values:
+
+ * native: Before XML<->Backend transformation occur, so the injected code *must* be a valid XML.
+ * target: After XML<->Backend transformation occur, so the injected code *must* be a valid backend format.
+
+ At the moment the only supported backend is Sphinx.
+
+modify-documentation
+^^^^^^^^^^^^^^^^^^^^
+
+ The modify-documentation node allows you to change the auto-generated
+ documentation. API Extractor transforms XML's from qdoc3 (the Qt documentation
+ tool) into .rst files to be processed later using Sphinx. So you can modify
+ the XML before the transformation occur.
+
+ .. code-block:: xml
+
+ <modify-documentation xpath="...">
+ <!-- new documentation -->
+ </modify-documentation>
+
+ The **xpath** attribute is the XPath to the node that you want to modify.
diff --git a/sources/shiboken2/ApiExtractor/doc/typesystem_manipulating_objects.rst b/sources/shiboken2/ApiExtractor/doc/typesystem_manipulating_objects.rst
new file mode 100644
index 000000000..2838c95e1
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/typesystem_manipulating_objects.rst
@@ -0,0 +1,132 @@
+.. _manipulating-object-and-value-types:
+
+Manipulating Object and Value Types
+-----------------------------------
+
+.. _inject-code:
+
+inject-code
+^^^^^^^^^^^
+ The inject-code node inserts the given code into the generated code for the
+ given type or function, and it is a child of the :ref:`object-type`, :ref:`value-type`,
+ :ref:`modify-function` and :ref:`add-function` nodes.
+
+ .. code-block:: xml
+
+ <value-type>
+ <inject-code class="native | target | target-declaration"
+ position="beginning | end" since="...">
+ // the code
+ </inject-code>
+ </value-type>
+
+ The ``class`` attribute specifies which module of the generated code that
+ will be affected by the code injection. The ``class`` attribute accepts the
+ following values:
+
+ * native: The c++ code
+ * target: The binding code
+ * target-declaration: The code will be injected into the generated header
+ file containing the c++ wrapper class definition.
+
+ If the ``position`` attribute is set to *beginning* (the default), the code
+ is inserted at the beginning of the function. If it is set to *end*, the code
+ is inserted at the end of the function.
+
+ The ``since`` attribute specify the API version where this code was injected.
+
+modify-field
+^^^^^^^^^^^^
+
+ The modify-field node allows you to alter the access privileges for a given
+ C++ field when mapping it onto the target language, and it is a child of an
+ :ref:`object-type` or a :ref:`value-type` node.
+
+ .. code-block:: xml
+
+ <object-type>
+ <modify-field name="..."
+ write="true | false"
+ read="true | false" />
+ </object-type>
+
+ The ``name`` attribute is the name of the field, the *optional* ``write``
+ and ``read`` attributes specify the field's access privileges in the target
+ language API (both are set to true by default).
+ The ``remove`` attribute is an *optional* attribute, which can mark the field
+ to be discarded on generation; it has the same purpose of the deprecated tag
+ :ref:`remove`.
+
+.. _modify-function:
+
+modify-function
+^^^^^^^^^^^^^^^
+
+ The modify-function node allows you to modify a given C++ function when mapping
+ it onto the target language, and it is a child of an :ref:`object-type` or a :ref:`value-type`
+ node. Use the :ref:`modify-argument` node to specify which argument the modification
+ affects.
+
+ .. code-block:: xml
+
+ <object-type>
+ <modify-function signature="..."
+ since="..."
+ remove="all | c++"
+ access="public | private | protected"
+ rename="..." />
+ </object-type>
+
+ The ``signature`` attribute is a normalized C++ signature, excluding return
+ values but including potential const declarations.
+
+ The ``since`` attribute specify the API version when this function was modified.
+
+ The ``remove``, ``access`` and ``rename`` attributes are *optional* attributes
+ for added convenience; they serve the same purpose as the deprecated tags :ref:`remove`, :ref:`access` and :ref:`rename`.
+
+.. _add-function:
+
+add-function
+^^^^^^^^^^^^
+
+ The add-function node allows you to add a given function onto the target language,
+ and it is a child of an :ref:`object-type` or :ref:`value-type` nodes if the
+ function is suposed to be a method, or :ref:`namespace` and :ref:`typesystem` if
+ the function is suposed to be a function inside a namespace or a global function.
+
+ Typically when adding a function some code must be injected to provide the function
+ logic. This can be done using the :ref:`inject-code` node.
+
+ .. code-block:: xml
+
+ <object-type>
+ <add-function signature="..." return-type="..." access="public | protected" static="yes | no" since="..."/>
+ </object-type>
+
+ The ``return-type`` attribute defaults to *void*, the ``access`` to *public* and the ``static`` one to *no*.
+
+ The ``since`` attribute specify the API version when this function was added.
+
+.. _conversion-rule-on-types:
+
+conversion-rule
+^^^^^^^^^^^^^^^
+
+ The conversion-rule node allows you to write customized code to convert the given argument between the target
+ language and C++, and is a child of the :ref:`value-type`, :ref:`object-type`, :ref:`primitive-type` and
+ :ref:`container-type` nodes.
+
+ The code pointed by the file attribute is very tied to the generator using APIExtractor, so it don't follow any
+ rules, but the generator rules..
+
+ .. code-block:: xml
+
+ <value-type name="Foo">
+ <convertion-rule file="my_converter_implementation.h" since="..."/>
+ </value-type>
+
+ The ``since`` attribute specify the API version when this conversion rule became valid.
+
+ .. note:: You can also use the conversion-rule node to specify :ref:`how the conversion of a single function argument should be done in a function <conversion-rule>`.
+
diff --git a/sources/shiboken2/ApiExtractor/doc/typesystem_modify_function.rst b/sources/shiboken2/ApiExtractor/doc/typesystem_modify_function.rst
new file mode 100644
index 000000000..071cea4f5
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/typesystem_modify_function.rst
@@ -0,0 +1,78 @@
+.. _modifying-functions:
+
+Modifying Functions
+-------------------
+
+.. _modify-argument:
+
+modify-argument
+^^^^^^^^^^^^^^^
+
+ The modify-argument node specifies which of the given function's arguments the
+ modification affects, and is a child of the modify-function node. Use the
+ remove-argument, replace-default-expression, remove-default-expression,
+ replace-type, reference-count and define-ownership nodes to specify the details
+ of the modification.
+
+ .. code-block:: xml
+
+ <modify-function>
+ <modify-argument index="return | this | 1 ..." >
+ // modifications
+ </modify-argument>
+ </modify-function>
+
+ Set the ``index`` attribute to "1" for the first argument, "2" for the second
+ one and so on. Alternatively, set it to "return" or "this" if you want to
+ modify the function's return value or the object the function is called upon,
+ respectively.
+
+.. _remove:
+
+remove
+^^^^^^
+
+ The remove node removes the given method from the generated target language
+ API, and it is a child of the modify-function node.
+
+ .. code-block:: xml
+
+ <modify-function>
+ <remove class="all" />
+ </modify-function>
+
+ .. warning:: This tag is deprecated, use the ``remove`` attribute from :ref:`modify-function` tag instead.
+
+.. _access:
+
+access
+^^^^^^
+
+ The access node changes the access privileges of the given function in the
+ generated target language API, and it is a child of the modify-function node.
+
+ .. code-block:: xml
+
+ <modify-function>
+ <access modifier="public | protected | private"/>
+ </modify-function>
+
+ .. warning:: This tag is deprecated, use the ``access`` attribute from :ref:`modify-function` tag instead.
+
+.. _rename:
+
+rename
+^^^^^^
+
+ The rename node changes the name of the given function in the generated target
+ language API, and it is a child of the modify-function node.
+
+ .. code-block:: xml
+
+ <modify-function>
+ <rename to="..." />
+ </modify-function>
+
+ The ``to`` attribute is the new name of the function.
+
+ .. warning:: This tag is deprecated, use the ``rename`` attribute from :ref:`modify-function` tag instead.
diff --git a/sources/shiboken2/ApiExtractor/doc/typesystem_solving_compilation.rst b/sources/shiboken2/ApiExtractor/doc/typesystem_solving_compilation.rst
new file mode 100644
index 000000000..81d14a187
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/typesystem_solving_compilation.rst
@@ -0,0 +1,70 @@
+Solving compilation problems
+----------------------------
+
+suppress-warning
+^^^^^^^^^^^^^^^^
+
+ The generator will generate several warnings which may be irrelevant to the
+ user. The suppress-warning node suppresses the specified warning, and it is
+ a child of the typesystem node.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <suppress-warning text="..." />
+ </typesystem>
+
+ The **text** attribute is the warning text to suppress, and may contain the *
+ wildcard (use "" to escape regular expression matching if the warning contain
+ a regular "*").
+
+extra-includes
+^^^^^^^^^^^^^^
+
+ The extra-includes node contains declarations of additional include files,
+ and it can be a child of the interface-type, namespace-type, value-type and
+ object-type nodes.
+
+ The generator automatically tries to read the global header for each type but
+ sometimes it is required to include extra files in the generated C++ code to
+ make sure that the code compiles. These files must be listed using include
+ nodes witin the extra-include node:
+
+ .. code-block:: xml
+
+ <value-type>
+ <extra-includes>
+ <include file-name="..." location="global | local"/>
+ </extra-includes>
+ </value-type>
+
+ The **file-name** attribute is the file to include, such as "QStringList".
+ The **location** attribute is where the file is located: *global* means that
+ the file is located in $INCLUDEPATH and will be included using #include <...>,
+ *local* means that the file is in a local directory and will be included
+ using #include "...".
+
+
+include
+^^^^^^^
+
+ The include node specifies the name and location of a file that must be
+ included, and it is a child of the interface-type, namespace-type, value-type,
+ object-type or extra-includes nodes
+
+ The generator automatically tries to read the global header for each type. Use
+ the include node to override this behavior, providing an alternative file. The
+ include node can also be used to specify extra include files.
+
+ .. code-block:: xml
+
+ <value-type>
+ <include file-name="..."
+ location="global | local"/>
+ </value-type>
+
+ The **file-name** attribute is the file to include, such as "QStringList".
+ The **location** attribute is where the file is located: *global* means that
+ the file is located in $INCLUDEPATH and will be included using #include <...>,
+ *local* means that the file is in a local directory and will be included
+ using #include "...".
diff --git a/sources/shiboken2/ApiExtractor/doc/typesystem_specifying_types.rst b/sources/shiboken2/ApiExtractor/doc/typesystem_specifying_types.rst
new file mode 100644
index 000000000..0d24a6d52
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/typesystem_specifying_types.rst
@@ -0,0 +1,371 @@
+Specifying Types
+----------------
+
+.. _typesystem:
+
+typesystem
+^^^^^^^^^^
+
+ This is the root node containing all the type system information. It can
+ have a number of attributes, described below.
+
+ .. code-block:: xml
+
+ <typesystem package="..." default-superclass="...">
+ </typesystem>
+
+ The **package** attribute is a string describing the package to be used,
+ e.g. "QtCore".
+ The *optional* **default-superclass** attribute is the canonical C++ base class
+ name of all objects, e.g., "object".
+
+load-typesystem
+^^^^^^^^^^^^^^^
+
+ The load-typesystem node specifies which type systems to load when mapping
+ multiple libraries to another language or basing one library on another, and
+ it is a child of the typesystem node.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <load-typesystem name="..." generate="yes | no" />
+ </typesystem>
+
+ The **name** attribute is the filename of the typesystem to load, the
+ **generate** attribute specifies whether code should be generated or not. The
+ later must be specified when basing one library on another, making the generator
+ able to understand inheritance hierarchies, primitive mapping, parameter types
+ in functions, etc.
+
+ Most libraries will be based on both the QtCore and QtGui modules, in which
+ case code generation for these libraries will be disabled.
+
+
+rejection
+^^^^^^^^^
+
+ The rejection node rejects the given class, or the specified function or
+ field, and it is a child of the typesystem node.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <rejection class="..."
+ function-name="..."
+ field-name="..." />
+ </typesystem>
+
+ The **class** attribute is the C++ class name of the class to reject. Use the
+ *optional* **function-name** or **field-name** attributes to reject a particular
+ function or field. Note that the **field-name** and **function-name** cannot
+ be specified at the same time. To remove all occurrences of a given field or
+ function, set the class attribute to \*.
+
+.. _primitive-type:
+
+primitive-type
+^^^^^^^^^^^^^^
+
+ The primitive-type node describes how a primitive type is mapped from C++ to
+ the target language, and is a child of the typesystem node. Note that most
+ primitives are already specified in the QtCore typesystem.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <primitive-type name="..."
+ since="..."
+ target-name="..."
+ default-constructor="..."
+ preferred-conversion="yes | no" />
+ </typesystem>
+
+ The **name** attribute is the name of the primitive in C++, the optional,
+ **target-name** attribute is the name of the primitive type in the target
+ language. If the later two attributes are not specified their default value
+ will be the same as the **name** attribute.
+
+ The *optional* **since** value is used to specify the API version of this type.
+
+ If the *optional* **preferred-conversion** attribute is set to *no*, it
+ indicates that this version of the primitive type is not the preferred C++
+ equivalent of the target language type. For example, in Python both "qint64"
+ and "long long" become "long" but we should prefer the "qint64" version. For
+ this reason we mark "long long" with preferred-conversion="no".
+
+ The *optional* **default-constructor** specifies the minimal constructor
+ call to build one value of the primitive-type. This is not needed when the
+ primitive-type may be built with a default constructor (the one without
+ arguments).
+
+ The *optional* **preferred-conversion** attribute tells how to build a default
+ instance of the primitive type. It should be a constructor call capable of
+ creating a instance of the primitive type. Example: a class "Foo" could have
+ a **preferred-conversion** value set to "Foo()". Usually this attribute is
+ used only for classes declared as primitive types and not for primitive C++
+ types, but that depends on the application using *ApiExtractor*.
+
+
+.. _namespace:
+
+namespace-type
+^^^^^^^^^^^^^^
+
+ The namespace-type node maps the given C++ namespace to the target language,
+ and it is a child of the typesystem node. Note that within namespaces, the
+ generator only supports enums (i.e., no functions or classes).
+
+ .. code-block:: xml
+
+ <typesystem>
+ <namespace-type name="..."
+ generate="yes | no"
+ package="..."
+ since="..."
+ revision="..." />
+ </typesystem>
+
+ The **name** attribute is the name of the namespace, e.g., "Qt".
+
+ The *optional* **generate** attribute is used to inform if you need to prepend
+ the given namespace into each generated class. Its default value is **yes**.
+
+ The **package** attribute can be used to override the package of the type system.
+
+ The *optional* **since** value is used to specify the API version of this type.
+
+ The **revision** attribute can be used to specify a revision for each type, easing the
+ production of ABI compatible bindings.
+
+enum-type
+^^^^^^^^^
+
+ The enum-type node maps the given enum from C++ to the target language,
+ and it is a child of the typesystem node. Use the reject-enum-value to
+ reject values.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <enum-type name="..."
+ identified-by-value="..."
+ since="..."
+ flags="yes | no"
+ flags-revision="..."
+ lower-bound="..."
+ upper-bound="..."
+ force-integer="yes | no"
+ extensible="yes | no"
+ revision="..." />
+ </typesystem>
+
+ The **name** attribute is the fully qualified C++ name of the enum
+ (e.g.,"Qt::FillRule"). If the *optional* **flags** attribute is set to *yes*
+ (the default is *no*), the generator will expect an existing QFlags<T> for the
+ given enum type. The **lower-bound** and **upper-bound** attributes are used
+ to specify runtime bounds checking for the enum value. The value must be a
+ compilable target language statement, such as "QGradient.Spread.PadSpread"
+ (taking again Python as an example). If the **force-integer** attribute is
+ set to *yes* (the default is *no*), the generated target language code will
+ use the target language integers instead of enums. And finally, the
+ **extensible** attribute specifies whether the given enum can be extended
+ with user values (the default is *no*).
+
+ The *optional* **since** value is used to specify the API version of this type.
+
+ The attribute **identified-by-value** helps to specify anonymous enums using the
+ name of one of their values, which is unique for the anonymous enum scope.
+ Notice that the **enum-type** tag can either have **name** or **identified-by-value**
+ but not both.
+
+ The **revision** attribute can be used to specify a revision for each type, easing the
+ production of ABI compatible bindings.
+
+ The **flags-revision** attribute has the same purposes of **revision** attribute but
+ is used for the QFlag related to this enum.
+
+
+reject-enum-value
+^^^^^^^^^^^^^^^^^
+
+ The reject-enum-value node rejects the enum value specified by the **name**
+ attribute, and it is a child of the enum-type node.
+
+ .. code-block:: xml
+
+ <enum-type>
+ <reject-enum-value name="..."/>
+ </enum-type>
+
+ This node is used when a C++ enum implementation has several identical numeric
+ values, some of which are typically obsolete.
+
+.. _value-type:
+
+value-type
+^^^^^^^^^^
+
+ The value-type node indicates that the given C++ type is mapped onto the target
+ language as a value type. This means that it is an object passed by value on C++,
+ i.e. it is stored in the function call stack. It is a child of the :ref:`typesystem` node.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <value-type name="..." since="..."
+ copyable="yes | no"
+ hash-function="..."
+ stream="yes | no"
+ default-constructor="..."
+ revision="..." />
+ </typesystem>
+
+ The **name** attribute is the fully qualified C++ class name, such as
+ "QMatrix" or "QPainterPath::Element". The **copyable** attribute is used to
+ force or not specify if this type is copyable. The *optional* **hash-function**
+ attribute informs the function name of a hash function for the type.
+
+ The *optional* attribute **stream** specifies whether this type will be able to
+ use externally defined operators, like QDataStream << and >>. If equals to **yes**,
+ these operators will be called as normal methods within the current class.
+
+ The *optional* **since** value is used to specify the API version of this type.
+
+ The *optional* **default-constructor** specifies the minimal constructor
+ call to build one instance of the value-type. This is not needed when the
+ value-type may be built with a default constructor (the one without arguments).
+ Usually a code generator may guess a minimal constructor for a value-type based
+ on its constructor signatures, thus **default-constructor** is used only in
+ very odd cases.
+
+ The **revision** attribute can be used to specify a revision for each type, easing the
+ production of ABI compatible bindings.
+
+.. _object-type:
+
+object-type
+^^^^^^^^^^^
+
+ The object-type node indicates that the given C++ type is mapped onto the target
+ language as an object type. This means that it is an object passed by pointer on
+ C++ and it is stored on the heap. It is a child of the :ref:`typesystem` node.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <object-type name="..."
+ since="..."
+ copyable="yes | no"
+ hash-function="..."
+ stream="yes | no"
+ revision="..." />
+ </typesystem>
+
+ The **name** attribute is the fully qualified C++ class name. If there is no
+ C++ base class, the default-superclass attribute can be used to specify a
+ superclass for the given type, in the generated target language API. The
+ **copyable** and **hash-function** attributes are the same as described for
+ :ref:`value-type`.
+
+ The *optional* attribute **stream** specifies whether this type will be able to
+ use externally defined operators, like QDataStream << and >>. If equals to **yes**,
+ these operators will be called as normal methods within the current class.
+
+ The *optional* **since** value is used to specify the API version of this type.
+
+ The **revision** attribute can be used to specify a revision for each type, easing the
+ production of ABI compatible bindings.
+
+interface-type
+^^^^^^^^^^^^^^
+
+ The interface-type node indicates that the given class is replaced by an
+ interface pattern when mapping from C++ to the target language. Using the
+ interface-type node implicitly makes the given type an :ref:`object-type`.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <interface-type name="..."
+ since="..."
+ package ="..."
+ default-superclass ="..."
+ revision="..." />
+ </typesystem>
+
+ The **name** attribute is the fully qualified C++ class name. The *optional*
+ **package** attribute can be used to override the package of the type system.
+ If there is no C++ base class, the *optional* **default-superclass** attribute
+ can be used to specify a superclass in the generated target language API, for
+ the given class.
+
+ The *optional* **since** value is used to specify the API version of this interface.
+
+ The **revision** attribute can be used to specify a revision for each type, easing the
+ production of ABI compatible bindings.
+
+.. _container-type:
+
+container-type
+^^^^^^^^^^^^^^
+
+ The container-type node indicates that the given class is a container and
+ must be handled using one of the conversion helpers provided by attribute **type**.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <container-type name="..."
+ since="..."
+ type ="..." />
+ </typesystem>
+
+ The **name** attribute is the fully qualified C++ class name. The **type**
+ attribute is used to indicate what conversion rule will be applied to the
+ container. It can be: *list*, *string-list*, *linked-list*, *vector*, *stack*,
+ *queue*, *set*, *map*, *multi-map*, *hash*, *multi-hash* or *pair*.
+
+ The *optional* **since** value is used to specify the API version of this container.
+
+
+.. _custom-type:
+
+custom-type
+^^^^^^^^^^^
+
+ The custom-type node simply makes the parser aware of the existence of a target
+ language type, thus avoiding errors when trying to find a type used in function
+ signatures and other places. The proper handling of the custom type is meant to
+ be done by a generator using the APIExractor.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <custom-type name="..." />
+ </typesystem>
+
+ The **name** attribute is the name of the custom type, e.g., "PyObject".
+
+
+.. _function:
+
+function
+^^^^^^^^
+
+ The function node indicates that the given C++ global function is mapped onto
+ the target language.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <function signature="..." rename="..." since="..."/>
+ </typesystem>
+
+ This tag has some limitations, it doesn't support function modifications, besides you
+ can't add a function overload using :ref:`add-function` tag to an existent function.
+ These limitation will be addressed in future versions of ApiExtractor.
+
+ The function tag has two *optional* attributes: **since**, whose value is used to specify
+ the API version of this function, and **rename**, to modify the function name.
+
diff --git a/sources/shiboken2/ApiExtractor/doc/typesystem_templates.rst b/sources/shiboken2/ApiExtractor/doc/typesystem_templates.rst
new file mode 100644
index 000000000..31b155c5a
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doc/typesystem_templates.rst
@@ -0,0 +1,55 @@
+.. _using-code-templates:
+
+Using Code Templates
+--------------------
+
+template
+^^^^^^^^
+
+ The template node registers a template that can be used to avoid duplicate
+ code when extending the generated code, and it is a child of the typesystem
+ node.
+
+ .. code-block:: xml
+
+ <typesystem>
+ <template name="my_template">
+ // the code
+ </template>
+ </typesystem>
+
+ Use the insert-template node to insert the template code (identified by the
+ template's ``name`` attribute) into the generated code base.
+
+
+insert-template
+^^^^^^^^^^^^^^^
+
+ The insert-template node includes the code template identified by the name
+ attribute, and it can be a child of the inject-code, conversion-rule, template,
+ custom-constructor and custom-destructor nodes.
+
+ .. code-block:: xml
+
+ <inject-code class="target" position="beginning">
+ <insert-template name="my_template" />
+ </inject-code>
+
+ Use the replace node to modify the template code.
+
+
+replace
+^^^^^^^
+
+ The replace node allows you to modify template code before inserting it into
+ the generated code, and it can be a child of the insert-template node.
+
+ .. code-block:: xml
+
+ <insert-template name="my_template">
+ <replace from="..." to="..." />
+ </insert-template>
+
+ This node will replace the attribute ``from`` with the value pointed by
+ ``to``.
+
diff --git a/sources/shiboken2/ApiExtractor/docparser.cpp b/sources/shiboken2/ApiExtractor/docparser.cpp
new file mode 100644
index 000000000..4ec1da299
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/docparser.cpp
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "docparser.h"
+#include "abstractmetalang.h"
+#include "typesystem.h"
+#include <QtCore/QDebug>
+#include <QtXmlPatterns/QXmlQuery>
+#include <QBuffer>
+
+#include <cstdlib>
+#include <libxslt/xsltutils.h>
+#include <libxslt/transform.h>
+
+DocParser::DocParser()
+{
+ xmlSubstituteEntitiesDefault(1);
+}
+
+DocParser::~DocParser()
+{
+}
+
+QString DocParser::getDocumentation(QXmlQuery& xquery, const QString& query,
+ const DocModificationList& mods) const
+{
+ QString doc = execXQuery(xquery, query);
+ return applyDocModifications(mods, doc);
+}
+
+QString DocParser::execXQuery(QXmlQuery& xquery, const QString& query) const
+{
+ QString escapedQuery(query);
+ // XQuery can't have invalid XML characters
+ escapedQuery.replace(QLatin1Char('&'), QLatin1String("&amp;"));
+ escapedQuery.replace(QLatin1Char('<'), QLatin1String("&lt;"));
+ xquery.setQuery(escapedQuery);
+ if (!xquery.isValid()) {
+ qWarning() << "Bad XQuery: " << escapedQuery;
+ return QString();
+ }
+
+ QString result;
+ xquery.evaluateTo(&result);
+ return result;
+}
+
+namespace
+{
+
+struct XslResources
+{
+ xmlDocPtr xmlDoc;
+ xsltStylesheetPtr xslt;
+ xmlDocPtr xslResult;
+
+ XslResources() : xmlDoc(0), xslt(0), xslResult(0) {}
+
+ ~XslResources()
+ {
+ if (xslt)
+ xsltFreeStylesheet(xslt);
+
+ if (xslResult)
+ xmlFreeDoc(xslResult);
+
+ if (xmlDoc)
+ xmlFreeDoc(xmlDoc);
+
+ xsltCleanupGlobals();
+ xmlCleanupParser();
+ }
+};
+
+} // namespace
+
+QString DocParser::applyDocModifications(const DocModificationList& mods, const QString& xml) const
+{
+ if (mods.isEmpty())
+ return xml;
+
+ bool hasXPathBasedModification = false;
+ foreach (DocModification mod, mods) {
+ if (mod.mode() == TypeSystem::DocModificationXPathReplace) {
+ hasXPathBasedModification = true;
+ break;
+ }
+ }
+
+ if (!hasXPathBasedModification)
+ return xml;
+
+ QString xsl = QLatin1String("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
+ "<xsl:transform version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n"
+ "<xsl:template match=\"/\">\n"
+ " <xsl:apply-templates />\n"
+ "</xsl:template>\n"
+ "<xsl:template match=\"*\">\n"
+ "<xsl:copy>\n"
+ " <xsl:copy-of select=\"@*\"/>\n"
+ " <xsl:apply-templates/>\n"
+ "</xsl:copy>\n"
+ "</xsl:template>\n"
+ );
+ foreach (DocModification mod, mods) {
+ if (mod.mode() == TypeSystem::DocModificationXPathReplace) {
+ QString xpath = mod.xpath();
+ xpath.replace(QLatin1Char('"'), QLatin1String("&quot;"));
+ xsl += QLatin1String("<xsl:template match=\"")
+ + xpath + QLatin1String("\">")
+ + mod.code() + QLatin1String("</xsl:template>\n");
+ }
+ }
+ xsl += QLatin1String("</xsl:transform>");
+
+ XslResources res;
+ // Read XML data
+ QByteArray xmlData = xml.toUtf8();
+ res.xmlDoc = xmlParseMemory(xmlData.constData(), xmlData.size());
+ if (!res.xmlDoc)
+ return xml;
+
+ // Read XSL data as a XML file
+ QByteArray xslData = xsl.toUtf8();
+ // xsltFreeStylesheet will delete this pointer
+ xmlDocPtr xslDoc = xmlParseMemory(xslData.constData(), xslData.size());
+ if (!xslDoc)
+ return xml;
+
+ // Parse XSL data
+ res.xslt = xsltParseStylesheetDoc(xslDoc);
+ if (!res.xslt)
+ return xml;
+
+ // Apply XSL
+ res.xslResult = xsltApplyStylesheet(res.xslt, res.xmlDoc, 0);
+ xmlChar* buffer = 0;
+ int bufferSize;
+ QString result;
+ if (!xsltSaveResultToString(&buffer, &bufferSize, res.xslResult, res.xslt)) {
+ result = QString::fromUtf8(reinterpret_cast<char*>(buffer), bufferSize);
+ std::free(buffer);
+ } else {
+ result = xml;
+ }
+
+ Q_ASSERT(result != xml);
+ return result;
+}
+
diff --git a/sources/shiboken2/ApiExtractor/docparser.h b/sources/shiboken2/ApiExtractor/docparser.h
new file mode 100644
index 000000000..5573f6851
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/docparser.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef DOCPARSER_H
+#define DOCPARSER_H
+
+#include "typesystem_typedefs.h"
+
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+class QDomDocument;
+class QDomNode;
+class QXmlQuery;
+QT_END_NAMESPACE
+
+class AbstractMetaClass;
+class DocModification;
+class Documentation;
+
+class DocParser
+{
+public:
+ DocParser();
+ virtual ~DocParser();
+ virtual void fillDocumentation(AbstractMetaClass* metaClass) = 0;
+
+ /**
+ * Process and retrieves documentation concerning the entire
+ * module or library.
+ * \return object containing module/library documentation information
+ */
+ virtual Documentation retrieveModuleDocumentation() = 0;
+
+ void setDocumentationDataDirectory(const QString& dir)
+ {
+ m_docDataDir = dir;
+ }
+
+ /**
+ * Informs the location of the XML data generated by the tool
+ * (e.g.: DoxyGen, qdoc) used to extract the library's documentation
+ * comment.
+ * \return the path for the directory containing the XML data created
+ * from the library's documentation beign parsed.
+ */
+ QString documentationDataDirectory() const
+ {
+ return m_docDataDir;
+ }
+
+ void setLibrarySourceDirectory(const QString& dir)
+ {
+ m_libSourceDir = dir;
+ }
+ /**
+ * Informs the location of the library being parsed. The library
+ * source code is parsed for the documentation comments.
+ * \return the path for the directory containing the source code of
+ * the library beign parsed.
+ */
+ QString librarySourceDirectory() const
+ {
+ return m_libSourceDir;
+ }
+
+ void setPackageName(const QString& packageName)
+ {
+ m_packageName = packageName;
+ }
+ /**
+ * Retrieves the name of the package (or module or library) being parsed.
+ * \return the name of the package (module/library) being parsed
+ */
+ QString packageName() const
+ {
+ return m_packageName;
+ }
+
+ /**
+ * Process and retrieves documentation concerning the entire
+ * module or library.
+ * \param name module name
+ * \return object containing module/library documentation information
+ * \todo Merge with retrieveModuleDocumentation() on next ABI change.
+ */
+ virtual Documentation retrieveModuleDocumentation(const QString& name) = 0;
+
+protected:
+ QString getDocumentation(QXmlQuery& xquery, const QString& query,
+ const DocModificationList& mods) const;
+
+private:
+ QString m_packageName;
+ QString m_docDataDir;
+ QString m_libSourceDir;
+
+ QString execXQuery(QXmlQuery& xquery, const QString& query) const;
+ QString applyDocModifications(const DocModificationList& mods, const QString& xml) const;
+};
+
+#endif // DOCPARSER_H
+
diff --git a/sources/shiboken2/ApiExtractor/doxygenparser.cpp b/sources/shiboken2/ApiExtractor/doxygenparser.cpp
new file mode 100644
index 000000000..f7d868f8d
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doxygenparser.cpp
@@ -0,0 +1,198 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "doxygenparser.h"
+#include "abstractmetalang.h"
+#include "reporthandler.h"
+#include "typesystem.h"
+
+#include <QtXmlPatterns/QXmlQuery>
+#include <QtCore/QFile>
+#include <QtCore/QDir>
+
+namespace
+{
+
+QString getSectionKindAttr(const AbstractMetaFunction* func)
+{
+ if (func->isSignal()) {
+ return QLatin1String("signal");
+ } else {
+ QString kind = func->isPublic() ? QLatin1String("public") : QLatin1String("protected");
+ if (func->isStatic())
+ kind += QLatin1String("-static");
+ else if (func->isSlot())
+ kind += QLatin1String("-slot");
+ return kind;
+ }
+}
+
+}
+
+Documentation DoxygenParser::retrieveModuleDocumentation()
+{
+ return retrieveModuleDocumentation(packageName());
+}
+
+void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
+{
+ if (!metaClass)
+ return;
+
+ QString doxyFileSuffix;
+ if (metaClass->enclosingClass()) {
+ doxyFileSuffix += metaClass->enclosingClass()->name();
+ doxyFileSuffix += QLatin1String("_1_1"); // FIXME: Check why _1_1!!
+ }
+ doxyFileSuffix += metaClass->name();
+ doxyFileSuffix += QLatin1String(".xml");
+
+ const char* prefixes[] = { "class", "struct", "namespace" };
+ const int numPrefixes = sizeof(prefixes) / sizeof(const char*);
+ bool isProperty = false;
+
+ QString doxyFilePath;
+ for (int i = 0; i < numPrefixes; ++i) {
+ doxyFilePath = documentationDataDirectory() + QLatin1Char('/')
+ + QLatin1String(prefixes[i]) + doxyFileSuffix;
+ if (QFile::exists(doxyFilePath))
+ break;
+ doxyFilePath.clear();
+ }
+
+ if (doxyFilePath.isEmpty()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Can't find doxygen file for class " << metaClass->name() << ", tried: "
+ << QDir::toNativeSeparators(documentationDataDirectory())
+ << "/{struct|class|namespace}"<< doxyFileSuffix;
+ return;
+ }
+ QXmlQuery xquery;
+ xquery.setFocus(QUrl(doxyFilePath));
+
+ // Get class documentation
+ QString classDoc = getDocumentation(xquery, QLatin1String("/doxygen/compounddef/detaileddescription"),
+ metaClass->typeEntry()->docModifications());
+ if (classDoc.isEmpty()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Can't find documentation for class \"" << metaClass->name() << "\".";
+ }
+ metaClass->setDocumentation(classDoc);
+
+ //Functions Documentation
+ AbstractMetaFunctionList funcs = metaClass->functionsInTargetLang();
+ foreach (AbstractMetaFunction *func, funcs) {
+ if (!func || func->isPrivate())
+ continue;
+
+ QString query = QLatin1String("/doxygen/compounddef/sectiondef");
+ // properties
+ if (func->isPropertyReader() || func->isPropertyWriter()
+ || func->isPropertyResetter()) {
+ query += QLatin1String("[@kind=\"property\"]/memberdef/name[text()=\"")
+ + func->propertySpec()->name() + QLatin1String("\"]");
+ isProperty = true;
+ } else { // normal methods
+ QString kind = getSectionKindAttr(func);
+ query += QLatin1String("[@kind=\"") + kind
+ + QLatin1String("-func\"]/memberdef/name[text()=\"")
+ + func->originalName() + QLatin1String("\"]");
+
+ if (func->arguments().isEmpty()) {
+ QString args = func->isConstant() ? QLatin1String("() const ") : QLatin1String("()");
+ query += QLatin1String("/../argsstring[text()=\"") + args + QLatin1String("\"]");
+ } else {
+ int i = 1;
+ foreach (AbstractMetaArgument* arg, func->arguments()) {
+ QString type;
+ if (!arg->type()->isPrimitive()) {
+ query += QLatin1String("/../param[") + QString::number(i)
+ + QLatin1String("]/type/ref[text()=\"")
+ + arg->type()->name() + QLatin1String("\"]/../..");
+ } else {
+ query += QLatin1String("/../param[") + QString::number(i)
+ + QLatin1String("]/type[text()=\"")
+ + arg->type()->name() + QLatin1String("\"]/..");
+ }
+ ++i;
+ }
+ }
+ }
+ if (!isProperty) {
+ query += QLatin1String("/../detaileddescription");
+ } else {
+ query = QLatin1Char('(') + query;
+ query += QLatin1String("/../detaileddescription)[1]");
+ }
+ QString doc = getDocumentation(xquery, query, DocModificationList());
+ func->setDocumentation(doc);
+ isProperty = false;
+ }
+
+ //Fields
+ AbstractMetaFieldList fields = metaClass->fields();
+ foreach (AbstractMetaField *field, fields) {
+ if (field->isPrivate())
+ return;
+
+ QString query = QLatin1String("/doxygen/compounddef/sectiondef/memberdef/name[text()=\"")
+ + field->name() + QLatin1String("\"]/../detaileddescription");
+ QString doc = getDocumentation(xquery, query, DocModificationList());
+ field->setDocumentation(doc);
+ }
+
+ //Enums
+ AbstractMetaEnumList enums = metaClass->enums();
+ foreach (AbstractMetaEnum *meta_enum, enums) {
+ QString query = QLatin1String("/doxygen/compounddef/sectiondef/memberdef[@kind=\"enum\"]/name[text()=\"")
+ + meta_enum->name() + QLatin1String("\"]/..");
+ QString doc = getDocumentation(xquery, query, DocModificationList());
+ meta_enum->setDocumentation(doc);
+ }
+
+}
+
+Documentation DoxygenParser::retrieveModuleDocumentation(const QString& name){
+
+ QString sourceFile = documentationDataDirectory() + QLatin1String("/indexpage.xml");
+
+ if (!QFile::exists(sourceFile)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Can't find doxygen XML file for module " << name << ", tried: "
+ << QDir::toNativeSeparators(sourceFile);
+ return Documentation();
+ }
+
+ QXmlQuery xquery;
+ xquery.setFocus(QUrl(sourceFile));
+
+ // Module documentation
+ QString query = QLatin1String("/doxygen/compounddef/detaileddescription");
+ return Documentation(getDocumentation(xquery, query, DocModificationList()));
+}
+
diff --git a/sources/shiboken2/ApiExtractor/doxygenparser.h b/sources/shiboken2/ApiExtractor/doxygenparser.h
new file mode 100644
index 000000000..7314cfe3b
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/doxygenparser.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DOXYGENPARSER_H
+#define DOXYGENPARSER_H
+
+#include "docparser.h"
+
+class DoxygenParser : public DocParser
+{
+public:
+ DoxygenParser() {}
+ virtual void fillDocumentation(AbstractMetaClass *metaClass);
+ virtual Documentation retrieveModuleDocumentation();
+ virtual Documentation retrieveModuleDocumentation(const QString& name);
+};
+
+#endif // DOXYGENPARSER_H
diff --git a/sources/shiboken2/ApiExtractor/fileout.cpp b/sources/shiboken2/ApiExtractor/fileout.cpp
new file mode 100644
index 000000000..c97347fe1
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/fileout.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "fileout.h"
+#include "reporthandler.h"
+
+#include <QtCore/QTextCodec>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDir>
+
+#include <cstdio>
+
+bool FileOut::dummy = false;
+bool FileOut::diff = false;
+
+#ifdef Q_OS_LINUX
+const char* colorDelete = "\033[31m";
+const char* colorAdd = "\033[32m";
+const char* colorInfo = "\033[36m";
+const char* colorReset = "\033[0m";
+#else
+const char* colorDelete = "";
+const char* colorAdd = "";
+const char* colorInfo = "";
+const char* colorReset = "";
+#endif
+
+FileOut::FileOut(QString n):
+ name(n),
+ stream(&tmp),
+ isDone(false)
+{}
+
+static int* lcsLength(QList<QByteArray> a, QList<QByteArray> b)
+{
+ const int height = a.size() + 1;
+ const int width = b.size() + 1;
+
+ int *res = new int[width * height];
+
+ for (int row = 0; row < height; row++)
+ res[width * row] = 0;
+
+ for (int col = 0; col < width; col++)
+ res[col] = 0;
+
+ for (int row = 1; row < height; row++) {
+ for (int col = 1; col < width; col++) {
+ if (a[row-1] == b[col-1])
+ res[width * row + col] = res[width * (row-1) + col-1] + 1;
+ else
+ res[width * row + col] = qMax(res[width * row + col-1],
+ res[width * (row-1) + col]);
+ }
+ }
+ return res;
+}
+
+enum Type {
+ Add,
+ Delete,
+ Unchanged
+};
+
+struct Unit
+{
+ Unit(Type type, int pos) :
+ type(type),
+ start(pos),
+ end(pos) {}
+
+ Type type;
+ int start;
+ int end;
+
+ void print(QList<QByteArray> a, QList<QByteArray> b)
+ {
+ if (type == Unchanged) {
+ if ((end - start) > 9) {
+ for (int i = start; i <= start + 2; i++)
+ std::printf(" %s\n", a[i].data());
+ std::printf("%s=\n= %d more lines\n=%s\n", colorInfo, end - start - 6, colorReset);
+ for (int i = end - 2; i <= end; i++)
+ std::printf(" %s\n", a[i].data());
+ } else {
+ for (int i = start; i <= end; i++)
+ std::printf(" %s\n", a[i].data());
+ }
+ } else if (type == Add) {
+ std::printf("%s", colorAdd);
+ for (int i = start; i <= end; i++)
+ std::printf("+ %s\n", b[i].data());
+ std::printf("%s", colorReset);
+ } else if (type == Delete) {
+ std::printf("%s", colorDelete);
+ for (int i = start; i <= end; i++)
+ std::printf("- %s\n", a[i].data());
+ std::printf("%s", colorReset);
+ }
+ }
+};
+
+static QList<Unit*> *unitAppend(QList<Unit*> *res, Type type, int pos)
+{
+ if (!res) {
+ res = new QList<Unit*>;
+ res->append(new Unit(type, pos));
+ return res;
+ }
+
+ Unit *last = res->last();
+ if (last->type == type)
+ last->end = pos;
+ else
+ res->append(new Unit(type, pos));
+
+ return res;
+}
+
+static QList<Unit*> *diffHelper(int *lcs, QList<QByteArray> a, QList<QByteArray> b, int row, int col)
+{
+ if (row > 0 && col > 0 && (a[row-1] == b[col-1])) {
+ return unitAppend(diffHelper(lcs, a, b, row - 1, col - 1), Unchanged, row - 1);
+ } else {
+ int width = b.size() + 1;
+ if ((col > 0)
+ && (row == 0 || lcs[width * row + col-1] >= lcs[width *(row-1) + col])) {
+ return unitAppend(diffHelper(lcs, a, b, row, col - 1), Add, col - 1);
+ } else if ((row > 0)
+ && (col == 0 || lcs[width * row + col-1] < lcs[width *(row-1) + col])) {
+ return unitAppend(diffHelper(lcs, a, b, row - 1, col), Delete, row - 1);
+ }
+ }
+ delete lcs;
+ return 0;
+}
+
+static void diff(QList<QByteArray> a, QList<QByteArray> b)
+{
+ QList<Unit*> *res = diffHelper(lcsLength(a, b), a, b, a.size(), b.size());
+ for (int i = 0; i < res->size(); i++) {
+ Unit *unit = res->at(i);
+ unit->print(a, b);
+ delete(unit);
+ }
+ delete(res);
+}
+
+
+FileOut::State FileOut::done()
+{
+ Q_ASSERT(!isDone);
+ if (name.isEmpty())
+ return Failure;
+
+ isDone = true;
+ bool fileEqual = false;
+ QFile fileRead(name);
+ QFileInfo info(fileRead);
+ stream.flush();
+ QByteArray original;
+ if (info.exists() && (diff || (info.size() == tmp.size()))) {
+ if (!fileRead.open(QIODevice::ReadOnly)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("failed to open file '%1' for reading")
+ .arg(QDir::toNativeSeparators(fileRead.fileName()));
+ return Failure;
+ }
+
+ original = fileRead.readAll();
+ fileRead.close();
+ fileEqual = (original == tmp);
+ }
+
+ if (fileEqual)
+ return Unchanged;
+
+ if (!FileOut::dummy) {
+ QDir dir(info.absolutePath());
+ if (!dir.mkpath(dir.absolutePath())) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("unable to create directory '%1'")
+ .arg(QDir::toNativeSeparators(dir.absolutePath()));
+ return Failure;
+ }
+
+ QFile fileWrite(name);
+ if (!fileWrite.open(QIODevice::WriteOnly)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("failed to open file '%1' for writing")
+ .arg(QDir::toNativeSeparators(fileWrite.fileName()));
+ return Failure;
+ }
+ QTextCodec *codec = QTextCodec::codecForName("UTF-8");
+ stream.setCodec(codec);
+ stream.setDevice(&fileWrite);
+ stream << tmp;
+ }
+ if (diff) {
+ std::printf("%sFile: %s%s\n", colorInfo, qPrintable(name), colorReset);
+ ::diff(original.split('\n'), tmp.split('\n'));
+ std::printf("\n");
+ }
+
+ return Success;
+}
diff --git a/sources/shiboken2/ApiExtractor/fileout.h b/sources/shiboken2/ApiExtractor/fileout.h
new file mode 100644
index 000000000..14ce3a251
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/fileout.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FILEOUT_H
+#define FILEOUT_H
+
+#include <QtCore/QObject>
+#include <QtCore/QTextStream>
+
+class FileOut : public QObject
+{
+private:
+ QByteArray tmp;
+ QString name;
+
+public:
+ enum State { Failure, Unchanged, Success };
+
+ FileOut(QString name);
+ ~FileOut()
+ {
+ if (!isDone)
+ done();
+ }
+
+ State done();
+
+ QTextStream stream;
+
+ static bool dummy;
+ static bool diff;
+
+private:
+ bool isDone;
+};
+
+#endif // FILEOUT_H
diff --git a/sources/shiboken2/ApiExtractor/generator.qrc b/sources/shiboken2/ApiExtractor/generator.qrc
new file mode 100644
index 000000000..2d82b37cb
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/generator.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/trolltech/generator/">
+<file alias="pp-qt-configuration">parser/rpp/pp-qt-configuration</file>
+</qresource>
+</RCC>
diff --git a/sources/shiboken2/ApiExtractor/graph.cpp b/sources/shiboken2/ApiExtractor/graph.cpp
new file mode 100644
index 000000000..e6ee660dc
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/graph.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "graph.h"
+#include <QVector>
+#include <QDebug>
+#include <QLinkedList>
+#include <QSet>
+#include <iterator>
+#include <algorithm>
+#include <iostream>
+#include <QFile>
+
+struct Graph::GraphPrivate
+{
+ enum Color { WHITE, GRAY, BLACK };
+ typedef QVector<QSet<int> > Edges;
+ typedef QSet<int>::const_iterator EdgeIterator;
+
+ Edges edges;
+
+ GraphPrivate(int numNodes) : edges(numNodes)
+ {
+ }
+
+ void dfsVisit(int node, QLinkedList<int>& result, QVector<Color>& colors) const
+ {
+ colors[node] = GRAY;
+ EdgeIterator it = edges[node].begin();
+ for (; it != edges[node].end(); ++it) {
+ if (colors[*it] == WHITE)
+ dfsVisit(*it, result, colors);
+ else if (colors[*it] == GRAY) // This is not a DAG!
+ return;
+ }
+ colors[node] = BLACK;
+ result.push_front(node);
+ }
+};
+
+Graph::Graph(int numNodes) : m_d(new GraphPrivate(numNodes))
+{
+}
+
+Graph::~Graph()
+{
+ delete m_d;
+}
+
+int Graph::nodeCount() const
+{
+ return m_d->edges.size();
+}
+
+QLinkedList<int> Graph::topologicalSort() const
+{
+ int nodeCount = Graph::nodeCount();
+ QLinkedList<int> result;
+ QVector<GraphPrivate::Color> colors(nodeCount, GraphPrivate::WHITE);
+
+ for (int i = 0; i < nodeCount; ++i) {
+ if (colors[i] == GraphPrivate::WHITE)
+ m_d->dfsVisit(i, result, colors);
+ }
+
+ // Not a DAG!
+ if (result.size() != nodeCount)
+ return QLinkedList<int>();
+ return result;
+}
+
+bool Graph::containsEdge(int from, int to)
+{
+ return m_d->edges[from].contains(to);
+}
+
+void Graph::addEdge(int from, int to)
+{
+ Q_ASSERT(to < (int)m_d->edges.size());
+ m_d->edges[from].insert(to);
+}
+
+void Graph::removeEdge(int from, int to)
+{
+ m_d->edges[from].remove(to);
+}
+
+void Graph::dump() const
+{
+ for (int i = 0; i < m_d->edges.size(); ++i) {
+ std::cout << i << " -> ";
+ std::copy(m_d->edges[i].begin(), m_d->edges[i].end(), std::ostream_iterator<int>(std::cout, " "));
+ std::cout << std::endl;
+ }
+}
+
+void Graph::dumpDot(const QHash< int, QString >& nodeNames, const QString& fileName) const
+{
+ QFile output(fileName);
+ if (!output.open(QIODevice::WriteOnly))
+ return;
+ QTextStream s(&output);
+ s << "digraph D {\n";
+ for (int i = 0; i < m_d->edges.size(); ++i) {
+ GraphPrivate::EdgeIterator it = m_d->edges[i].begin();
+ for (;it != m_d->edges[i].end(); ++it)
+ s << '"' << nodeNames[i] << "\" -> \"" << nodeNames[*it] << "\"\n";
+ }
+ s << "}\n";
+}
diff --git a/sources/shiboken2/ApiExtractor/graph.h b/sources/shiboken2/ApiExtractor/graph.h
new file mode 100644
index 000000000..78b931320
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/graph.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GRAPH_H
+#define GRAPH_H
+
+#include <QLinkedList>
+#include <QHash>
+#include <QString>
+
+/// A graph that can have their nodes topologically sorted.
+class Graph
+{
+public:
+ /// Create a new graph with \p numNodes nodes.
+ Graph(int numNodes);
+ ~Graph();
+
+ /// Returns the numbed of nodes in this graph.
+ int nodeCount() const;
+ /// Returns true if the graph contains the edge from -> to
+ bool containsEdge(int from, int to);
+ /// Adds an edge to this graph.
+ void addEdge(int from, int to);
+ /// Removes an edge out of this graph.
+ void removeEdge(int from, int to);
+ /// Print this graph to stdout.
+ void dump() const;
+ /**
+ * Dumps a dot graph to a file named \p filename.
+ * \param nodeNames map used to translate node ids to human readable text.
+ * \param fileName file name where the output should be written.
+ */
+ void dumpDot(const QHash<int, QString>& nodeNames, const QString& fileName) const;
+
+ /**
+ * Topologically sort this graph.
+ * \return A collection with all nodes topologically sorted or an empty collection if a ciclic dependency was found.
+ */
+ QLinkedList<int> topologicalSort() const;
+private:
+
+ struct GraphPrivate;
+ GraphPrivate* m_d;
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/icecc.cmake b/sources/shiboken2/ApiExtractor/icecc.cmake
new file mode 100644
index 000000000..b2bf071aa
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/icecc.cmake
@@ -0,0 +1,11 @@
+include (CMakeForceCompiler)
+option(ENABLE_ICECC "Enable icecc checking, for distributed compilation")
+if (ENABLE_ICECC)
+ find_program(ICECC icecc)
+ if (ICECC)
+ message(STATUS "icecc found! Distributed compilation for all!! huhuhu.")
+ cmake_force_cxx_compiler(${ICECC} icecc)
+ else(ICECC)
+ message(FATAL_ERROR "icecc NOT found! re-run cmake without -DENABLE_ICECC")
+ endif(ICECC)
+endif(ENABLE_ICECC)
diff --git a/sources/shiboken2/ApiExtractor/include.cpp b/sources/shiboken2/ApiExtractor/include.cpp
new file mode 100644
index 000000000..deae2d2ac
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/include.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "include.h"
+#include <QDebug>
+#include <QDir>
+#include <QTextStream>
+#include <QHash>
+
+QString Include::toString() const
+{
+ if (m_type == IncludePath)
+ return QLatin1String("#include <") + m_name + QLatin1Char('>');
+ else if (m_type == LocalPath)
+ return QLatin1String("#include \"") + m_name + QLatin1Char('"');
+ else
+ return QLatin1String("import ") + m_name + QLatin1Char(';');
+}
+
+uint qHash(const Include& inc)
+{
+ return qHash(inc.m_name);
+}
+
+QTextStream& operator<<(QTextStream& out, const Include& include)
+{
+ if (include.isValid())
+ out << include.toString() << endl;
+ return out;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const Include &i)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "Include(";
+ if (i.isValid())
+ d << "type=" << i.type() << ", file=\"" << QDir::toNativeSeparators(i.name()) << '"';
+ else
+ d << "invalid";
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/ApiExtractor/include.h b/sources/shiboken2/ApiExtractor/include.h
new file mode 100644
index 000000000..e4ff5b309
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/include.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef INCLUDE_H
+#define INCLUDE_H
+
+#include <QString>
+#include <QList>
+
+QT_BEGIN_NAMESPACE
+class QTextStream;
+QT_END_NAMESPACE
+
+class Include
+{
+public:
+ enum IncludeType {
+ IncludePath,
+ LocalPath,
+ TargetLangImport
+ };
+
+ Include() : m_type(IncludePath) {}
+ Include(IncludeType t, const QString &nam) : m_type(t), m_name(nam) {};
+
+ bool isValid() const
+ {
+ return !m_name.isEmpty();
+ }
+
+ IncludeType type() const
+ {
+ return m_type;
+ }
+
+ QString name() const
+ {
+ return m_name;
+ }
+
+ QString toString() const;
+
+ bool operator<(const Include& other) const
+ {
+ return m_name < other.m_name;
+ }
+
+ bool operator==(const Include& other) const
+ {
+ return m_type == other.m_type && m_name == other.m_name;
+ }
+
+ friend uint qHash(const Include&);
+ private:
+ IncludeType m_type;
+ QString m_name;
+};
+
+uint qHash(const Include& inc);
+QTextStream& operator<<(QTextStream& out, const Include& include);
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const Include &i);
+#endif
+
+typedef QList<Include> IncludeList;
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/merge.xsl b/sources/shiboken2/ApiExtractor/merge.xsl
new file mode 100644
index 000000000..d0b7eafa5
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/merge.xsl
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+ <xsl:output method="xml" indent="yes"/>
+ <xsl:param name="lang" />
+ <xsl:param name="source" />
+
+ <xsl:template match="processing-instruction()" />
+
+ <xsl:template match="/typesystem">
+ <xsl:copy>
+ <xsl:for-each select="@*">
+ <xsl:copy>
+ <xsl:value-of select="." />
+ </xsl:copy>
+ </xsl:for-each>
+
+ <xsl:for-each select="document($source)/typesystem/@*">
+ <xsl:copy>
+ <xsl:value-of select="." />
+ </xsl:copy>
+ </xsl:for-each>
+
+ <xsl:variable name="other" select="document($source)/typesystem/*[not(self::object-type | self::value-type | self::interface-type | self::namespace-type)]" />
+ <xsl:if test="$other">
+ <xsl:choose>
+ <xsl:when test="$lang != ''">
+ <xsl:element name="language">
+ <xsl:attribute name="name" ><xsl:value-of select="$lang" /></xsl:attribute>
+ <xsl:copy-of select="$other" />
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$other" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:apply-templates select="node()" />
+
+ </xsl:copy>
+ </xsl:template>
+
+
+
+ <xsl:template match="/typesystem/*[self::object-type | self::value-type | self::interface-type | self::namespace-type]">
+ <xsl:variable name="name" select="name()" />
+ <xsl:copy>
+ <xsl:for-each select="@*">
+ <xsl:copy>
+ <xsl:value-of select="." />
+ </xsl:copy>
+ </xsl:for-each>
+
+ <xsl:apply-templates select="node()" />
+
+ <xsl:variable name="other" select="document($source)/typesystem/*[name() = $name][@name = current()/@name]" />
+ <xsl:if test="$other">
+ <xsl:choose>
+ <xsl:when test="$lang != ''">
+ <xsl:element name="language">
+ <xsl:attribute name="name" ><xsl:value-of select="$lang" /></xsl:attribute>
+ <xsl:copy-of select="$other/node()" />
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$other/node()" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:copy>
+ </xsl:template>
+
+ <!-- Plain identity transform. -->
+ <xsl:template match="@*|node()">
+ <xsl:copy>
+ <xsl:apply-templates select="@*"/>
+ <xsl:apply-templates select="node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/sources/shiboken2/ApiExtractor/parser/ast.cpp b/sources/shiboken2/ApiExtractor/parser/ast.cpp
new file mode 100644
index 000000000..a744704fe
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/ast.cpp
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ast.h"
+#include "lexer.h"
+
+QString AST::toString(TokenStream *stream) const
+{
+ const Token &tk = stream->token((int) start_token);
+ const Token &end_tk = stream->token((int) end_token);
+ return QString::fromLatin1(tk.text + tk.position, end_tk.position - tk.position);
+}
diff --git a/sources/shiboken2/ApiExtractor/parser/ast.h b/sources/shiboken2/ApiExtractor/parser/ast.h
new file mode 100644
index 000000000..7640b7c38
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/ast.h
@@ -0,0 +1,884 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef AST_H
+#define AST_H
+
+#include "smallobject.h"
+#include "list.h"
+
+#include <QString>
+
+#define DECLARE_AST_NODE(k) \
+ enum { __node_kind = Kind_##k };
+
+class TokenStream;
+
+struct AccessSpecifierAST;
+struct AsmDefinitionAST;
+struct BaseClauseAST;
+struct BaseSpecifierAST;
+struct BinaryExpressionAST;
+struct CastExpressionAST;
+struct ClassMemberAccessAST;
+struct ClassSpecifierAST;
+struct CompoundStatementAST;
+struct ConditionAST;
+struct ConditionalExpressionAST;
+struct CppCastExpressionAST;
+struct CtorInitializerAST;
+struct DeclarationAST;
+struct DeclarationStatementAST;
+struct DeclaratorAST;
+struct DeleteExpressionAST;
+struct DoStatementAST;
+struct ElaboratedTypeSpecifierAST;
+struct EnumSpecifierAST;
+struct EnumeratorAST;
+struct ExceptionSpecificationAST;
+struct ExpressionAST;
+struct ExpressionOrDeclarationStatementAST;
+struct ExpressionStatementAST;
+struct ForStatementAST;
+struct FunctionCallAST;
+struct FunctionDefinitionAST;
+struct IfStatementAST;
+struct IncrDecrExpressionAST;
+struct InitDeclaratorAST;
+struct InitializerAST;
+struct InitializerClauseAST;
+struct LabeledStatementAST;
+struct LinkageBodyAST;
+struct LinkageSpecificationAST;
+struct MemInitializerAST;
+struct NameAST;
+struct NamespaceAST;
+struct NamespaceAliasDefinitionAST;
+struct NewDeclaratorAST;
+struct NewExpressionAST;
+struct NewInitializerAST;
+struct NewTypeIdAST;
+struct OperatorAST;
+struct OperatorFunctionIdAST;
+struct ParameterDeclarationAST;
+struct ParameterDeclarationClauseAST;
+struct PostfixExpressionAST;
+struct PrimaryExpressionAST;
+struct PtrOperatorAST;
+struct PtrToMemberAST;
+struct ReturnStatementAST;
+struct SimpleDeclarationAST;
+struct SimpleTypeSpecifierAST;
+struct SizeofExpressionAST;
+struct StatementAST;
+struct StringLiteralAST;
+struct SubscriptExpressionAST;
+struct SwitchStatementAST;
+struct TemplateArgumentAST;
+struct TemplateDeclarationAST;
+struct TemplateParameterAST;
+struct ThrowExpressionAST;
+struct TranslationUnitAST;
+struct TryBlockStatementAST;
+struct TypeIdAST;
+struct TypeIdentificationAST;
+struct TypeParameterAST;
+struct TypeSpecifierAST;
+struct TypedefAST;
+struct UnaryExpressionAST;
+struct UnqualifiedNameAST;
+struct UsingAST;
+struct UsingDirectiveAST;
+struct WhileStatementAST;
+struct WinDeclSpecAST;
+struct QPropertyAST;
+struct QEnumsAST;
+
+struct AST
+{
+ enum NODE_KIND {
+ Kind_UNKNOWN = 0,
+
+ Kind_AccessSpecifier,
+ Kind_AsmDefinition,
+ Kind_BaseClause,
+ Kind_BaseSpecifier,
+ Kind_BinaryExpression,
+ Kind_CastExpression,
+ Kind_ClassMemberAccess,
+ Kind_ClassSpecifier,
+ Kind_CompoundStatement,
+ Kind_Condition,
+ Kind_ConditionalExpression,
+ Kind_CppCastExpression,
+ Kind_CtorInitializer,
+ Kind_DeclarationStatement,
+ Kind_Declarator,
+ Kind_DeleteExpression,
+ Kind_DoStatement,
+ Kind_ElaboratedTypeSpecifier,
+ Kind_EnumSpecifier,
+ Kind_Enumerator,
+ Kind_ExceptionSpecification,
+ Kind_ExpressionOrDeclarationStatement,
+ Kind_ExpressionStatement,
+ Kind_ForStatement,
+ Kind_FunctionCall,
+ Kind_FunctionDefinition,
+ Kind_IfStatement,
+ Kind_IncrDecrExpression,
+ Kind_InitDeclarator,
+ Kind_Initializer,
+ Kind_InitializerClause,
+ Kind_LabeledStatement,
+ Kind_LinkageBody,
+ Kind_LinkageSpecification,
+ Kind_MemInitializer,
+ Kind_Name,
+ Kind_Namespace,
+ Kind_NamespaceAliasDefinition,
+ Kind_NewDeclarator,
+ Kind_NewExpression,
+ Kind_NewInitializer,
+ Kind_NewTypeId,
+ Kind_Operator,
+ Kind_OperatorFunctionId,
+ Kind_ParameterDeclaration,
+ Kind_ParameterDeclarationClause,
+ Kind_PostfixExpression,
+ Kind_PrimaryExpression,
+ Kind_PtrOperator,
+ Kind_PtrToMember,
+ Kind_ReturnStatement,
+ Kind_SimpleDeclaration,
+ Kind_SimpleTypeSpecifier,
+ Kind_SizeofExpression,
+ Kind_StringLiteral,
+ Kind_SubscriptExpression,
+ Kind_SwitchStatement,
+ Kind_TemplateArgument,
+ Kind_TemplateDeclaration,
+ Kind_TemplateParameter,
+ Kind_ThrowExpression,
+ Kind_TranslationUnit,
+ Kind_TryBlockStatement,
+ Kind_TypeId,
+ Kind_TypeIdentification,
+ Kind_TypeParameter,
+ Kind_Typedef,
+ Kind_UnaryExpression,
+ Kind_UnqualifiedName,
+ Kind_Using,
+ Kind_UsingDirective,
+ Kind_WhileStatement,
+ Kind_WinDeclSpec,
+ Kind_QPropertyAST,
+ Kind_ForwardDeclarationSpecifier,
+ Kind_QEnumsAST,
+
+ NODE_KIND_COUNT
+ };
+
+ QString toString(TokenStream *stream) const;
+
+ int kind;
+
+ std::size_t start_token;
+ std::size_t end_token;
+};
+
+struct TypeSpecifierAST: public AST
+{
+ const ListNode<std::size_t> *cv;
+};
+
+struct StatementAST: public AST
+{
+};
+
+struct ExpressionAST: public AST
+{
+};
+
+struct DeclarationAST: public AST
+{
+};
+
+struct AccessSpecifierAST: public DeclarationAST
+{
+ DECLARE_AST_NODE(AccessSpecifier)
+
+ const ListNode<std::size_t> *specs;
+};
+
+struct AsmDefinitionAST: public DeclarationAST
+{
+ DECLARE_AST_NODE(AsmDefinition)
+
+ const ListNode<std::size_t> *cv;
+};
+
+struct BaseClauseAST: public AST
+{ // ### kill me
+ DECLARE_AST_NODE(BaseClause)
+
+ const ListNode<BaseSpecifierAST*> *base_specifiers;
+};
+
+struct BaseSpecifierAST: public AST
+{
+ DECLARE_AST_NODE(BaseSpecifier)
+
+ std::size_t virt;
+ std::size_t access_specifier;
+ NameAST *name;
+};
+
+struct BinaryExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(BinaryExpression)
+
+ std::size_t op;
+ ExpressionAST *left_expression;
+ ExpressionAST *right_expression;
+};
+
+struct CastExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(CastExpression)
+
+ TypeIdAST *type_id;
+ ExpressionAST *expression;
+};
+
+struct ClassMemberAccessAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(ClassMemberAccess)
+
+ std::size_t op;
+ NameAST *name;
+};
+
+struct ClassSpecifierAST: public TypeSpecifierAST
+{
+ DECLARE_AST_NODE(ClassSpecifier)
+
+ WinDeclSpecAST *win_decl_specifiers;
+ std::size_t class_key;
+ NameAST *name;
+ BaseClauseAST *base_clause;
+ const ListNode<DeclarationAST*> *member_specs;
+};
+
+struct ForwardDeclarationSpecifierAST: public TypeSpecifierAST
+{
+ DECLARE_AST_NODE(ForwardDeclarationSpecifier)
+
+ std::size_t class_key;
+ NameAST *name;
+ BaseClauseAST *base_clause;
+};
+
+struct CompoundStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(CompoundStatement)
+
+ const ListNode<StatementAST*> *statements;
+};
+
+struct ConditionAST: public AST
+{
+ DECLARE_AST_NODE(Condition)
+
+ TypeSpecifierAST *type_specifier;
+ DeclaratorAST *declarator;
+ ExpressionAST *expression;
+};
+
+struct ConditionalExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(ConditionalExpression)
+
+ ExpressionAST *condition;
+ ExpressionAST *left_expression;
+ ExpressionAST *right_expression;
+};
+
+struct CppCastExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(CppCastExpression)
+
+ std::size_t op;
+ TypeIdAST *type_id;
+ ExpressionAST *expression;
+ const ListNode<ExpressionAST*> *sub_expressions;
+};
+
+struct CtorInitializerAST: public AST
+{
+ DECLARE_AST_NODE(CtorInitializer)
+
+ std::size_t colon;
+ const ListNode<MemInitializerAST*> *member_initializers;
+};
+
+struct DeclarationStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(DeclarationStatement)
+
+ DeclarationAST *declaration;
+};
+
+struct DeclaratorAST: public AST
+{
+ DECLARE_AST_NODE(Declarator)
+
+ const ListNode<PtrOperatorAST*> *ptr_ops;
+ DeclaratorAST *sub_declarator;
+ NameAST *id;
+ ExpressionAST *bit_expression;
+ const ListNode<ExpressionAST*> *array_dimensions;
+ ParameterDeclarationClauseAST *parameter_declaration_clause;
+ const ListNode<std::size_t> *fun_cv;
+ ExceptionSpecificationAST *exception_spec;
+};
+
+struct DeleteExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(DeleteExpression)
+
+ std::size_t scope_token;
+ std::size_t delete_token;
+ std::size_t lbracket_token;
+ std::size_t rbracket_token;
+ ExpressionAST *expression;
+};
+
+struct DoStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(DoStatement)
+
+ StatementAST *statement;
+ ExpressionAST *expression;
+};
+
+struct ElaboratedTypeSpecifierAST: public TypeSpecifierAST
+{
+ DECLARE_AST_NODE(ElaboratedTypeSpecifier)
+
+ std::size_t type;
+ NameAST *name;
+};
+
+struct EnumSpecifierAST: public TypeSpecifierAST
+{
+ DECLARE_AST_NODE(EnumSpecifier)
+
+ NameAST *name;
+ const ListNode<EnumeratorAST*> *enumerators;
+};
+
+struct EnumeratorAST: public AST
+{
+ DECLARE_AST_NODE(Enumerator)
+
+ std::size_t id;
+ ExpressionAST *expression;
+};
+
+struct ExceptionSpecificationAST: public AST
+{
+ DECLARE_AST_NODE(ExceptionSpecification)
+
+ std::size_t ellipsis;
+ const ListNode<TypeIdAST*> *type_ids;
+};
+
+struct ExpressionOrDeclarationStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(ExpressionOrDeclarationStatement)
+
+ StatementAST *expression;
+ StatementAST *declaration;
+};
+
+struct ExpressionStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(ExpressionStatement)
+
+ ExpressionAST *expression;
+};
+
+struct FunctionCallAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(FunctionCall)
+
+ ExpressionAST *arguments;
+};
+
+struct FunctionDefinitionAST: public DeclarationAST
+{
+ DECLARE_AST_NODE(FunctionDefinition)
+
+ const ListNode<std::size_t> *storage_specifiers;
+ const ListNode<std::size_t> *function_specifiers;
+ TypeSpecifierAST *type_specifier;
+ InitDeclaratorAST *init_declarator;
+ StatementAST *function_body;
+ WinDeclSpecAST *win_decl_specifiers;
+};
+
+struct ForStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(ForStatement)
+
+ StatementAST *init_statement;
+ ConditionAST *condition;
+ ExpressionAST *expression;
+ StatementAST *statement;
+};
+
+struct IfStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(IfStatement)
+
+ ConditionAST *condition;
+ StatementAST *statement;
+ StatementAST *else_statement;
+};
+
+struct IncrDecrExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(IncrDecrExpression)
+
+ std::size_t op;
+};
+
+struct InitDeclaratorAST: public AST
+{
+ DECLARE_AST_NODE(InitDeclarator)
+
+ DeclaratorAST *declarator;
+ InitializerAST *initializer;
+};
+
+struct InitializerAST: public AST
+{
+ DECLARE_AST_NODE(Initializer)
+
+ InitializerClauseAST *initializer_clause;
+ ExpressionAST *expression;
+};
+
+struct InitializerClauseAST: public AST
+{
+ DECLARE_AST_NODE(InitializerClause)
+
+ ExpressionAST *expression;
+};
+
+struct LabeledStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(LabeledStatement)
+};
+
+struct LinkageBodyAST: public AST
+{
+ DECLARE_AST_NODE(LinkageBody)
+
+ const ListNode<DeclarationAST*> *declarations;
+};
+
+struct LinkageSpecificationAST: public DeclarationAST
+{
+ DECLARE_AST_NODE(LinkageSpecification)
+
+ std::size_t extern_type;
+ LinkageBodyAST *linkage_body;
+ DeclarationAST *declaration;
+};
+
+struct MemInitializerAST: public AST
+{
+ DECLARE_AST_NODE(MemInitializer)
+
+ NameAST *initializer_id;
+ ExpressionAST *expression;
+};
+
+struct NameAST: public AST
+{
+ DECLARE_AST_NODE(Name)
+
+ bool global;
+ const ListNode<UnqualifiedNameAST*> *qualified_names;
+ UnqualifiedNameAST *unqualified_name;
+};
+
+struct NamespaceAST: public DeclarationAST
+{
+ DECLARE_AST_NODE(Namespace)
+
+ std::size_t namespace_name;
+ LinkageBodyAST *linkage_body;
+};
+
+struct NamespaceAliasDefinitionAST: public DeclarationAST
+{
+ DECLARE_AST_NODE(NamespaceAliasDefinition)
+
+ std::size_t namespace_name;
+ NameAST *alias_name;
+};
+
+struct NewDeclaratorAST: public AST
+{
+ DECLARE_AST_NODE(NewDeclarator)
+
+ PtrOperatorAST *ptr_op;
+ NewDeclaratorAST *sub_declarator;
+ const ListNode<ExpressionAST*> *expressions;
+};
+
+struct NewExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(NewExpression)
+
+ std::size_t scope_token;
+ std::size_t new_token;
+ ExpressionAST *expression;
+ TypeIdAST *type_id;
+ NewTypeIdAST *new_type_id;
+ NewInitializerAST *new_initializer;
+};
+
+struct NewInitializerAST: public AST
+{
+ DECLARE_AST_NODE(NewInitializer)
+
+ ExpressionAST *expression;
+};
+
+struct NewTypeIdAST: public AST
+{
+ DECLARE_AST_NODE(NewTypeId)
+
+ TypeSpecifierAST *type_specifier;
+ NewInitializerAST *new_initializer;
+ NewDeclaratorAST *new_declarator;
+};
+
+struct OperatorAST: public AST
+{
+ DECLARE_AST_NODE(Operator)
+
+ std::size_t op;
+ std::size_t open;
+ std::size_t close;
+};
+
+struct OperatorFunctionIdAST: public AST
+{
+ DECLARE_AST_NODE(OperatorFunctionId)
+
+ OperatorAST *op;
+ TypeSpecifierAST *type_specifier;
+ const ListNode<PtrOperatorAST*> *ptr_ops;
+};
+
+struct ParameterDeclarationAST: public AST
+{
+ DECLARE_AST_NODE(ParameterDeclaration)
+
+ TypeSpecifierAST *type_specifier;
+ DeclaratorAST *declarator;
+ ExpressionAST *expression;
+};
+
+struct ParameterDeclarationClauseAST: public AST
+{
+ DECLARE_AST_NODE(ParameterDeclarationClause)
+
+ const ListNode<ParameterDeclarationAST*> *parameter_declarations;
+ std::size_t ellipsis;
+};
+
+struct PostfixExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(PostfixExpression)
+
+ TypeSpecifierAST *type_specifier;
+ ExpressionAST *expression;
+ const ListNode<ExpressionAST*> *sub_expressions;
+};
+
+struct PrimaryExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(PrimaryExpression)
+
+ StringLiteralAST *literal;
+ std::size_t token;
+ StatementAST *expression_statement;
+ ExpressionAST *sub_expression;
+ NameAST *name;
+};
+
+struct PtrOperatorAST: public AST
+{
+ DECLARE_AST_NODE(PtrOperator)
+
+ const ListNode<std::size_t> *cv;
+ std::size_t op;
+ PtrToMemberAST *mem_ptr;
+};
+
+struct PtrToMemberAST: public AST
+{
+ DECLARE_AST_NODE(PtrToMember)
+};
+
+struct ReturnStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(ReturnStatement)
+
+ ExpressionAST *expression;
+};
+
+struct SimpleDeclarationAST: public DeclarationAST
+{
+ DECLARE_AST_NODE(SimpleDeclaration)
+
+ const ListNode<std::size_t> *storage_specifiers;
+ const ListNode<std::size_t> *function_specifiers;
+ TypeSpecifierAST *type_specifier;
+ const ListNode<InitDeclaratorAST*> *init_declarators;
+ WinDeclSpecAST *win_decl_specifiers;
+};
+
+struct SimpleTypeSpecifierAST: public TypeSpecifierAST
+{
+ DECLARE_AST_NODE(SimpleTypeSpecifier)
+
+ const ListNode<std::size_t> *integrals;
+ std::size_t type_of;
+ TypeIdAST *type_id;
+ ExpressionAST *expression;
+ NameAST *name;
+};
+
+struct SizeofExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(SizeofExpression)
+
+ std::size_t sizeof_token;
+ TypeIdAST *type_id;
+ ExpressionAST *expression;
+};
+
+struct StringLiteralAST: public AST
+{
+ DECLARE_AST_NODE(StringLiteral)
+
+ const ListNode<std::size_t> *literals;
+};
+
+struct SubscriptExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(SubscriptExpression)
+
+ ExpressionAST *subscript;
+};
+
+struct SwitchStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(SwitchStatement)
+
+ ConditionAST *condition;
+ StatementAST *statement;
+};
+
+struct TemplateArgumentAST: public AST
+{
+ DECLARE_AST_NODE(TemplateArgument)
+
+ TypeIdAST *type_id;
+ ExpressionAST *expression;
+};
+
+struct TemplateDeclarationAST: public DeclarationAST
+{
+ DECLARE_AST_NODE(TemplateDeclaration)
+
+ std::size_t exported;
+ const ListNode<TemplateParameterAST*> *template_parameters;
+ DeclarationAST* declaration;
+};
+
+struct TemplateParameterAST: public AST
+{
+ DECLARE_AST_NODE(TemplateParameter)
+
+ TypeParameterAST *type_parameter;
+ ParameterDeclarationAST *parameter_declaration;
+};
+
+struct ThrowExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(ThrowExpression)
+
+ std::size_t throw_token;
+ ExpressionAST *expression;
+};
+
+struct TranslationUnitAST: public AST
+{
+ DECLARE_AST_NODE(TranslationUnit)
+
+ const ListNode<DeclarationAST*> *declarations;
+};
+
+struct TryBlockStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(TryBlockStatement)
+};
+
+struct TypeIdAST: public AST
+{
+ DECLARE_AST_NODE(TypeId)
+
+ TypeSpecifierAST *type_specifier;
+ DeclaratorAST *declarator;
+};
+
+struct TypeIdentificationAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(TypeIdentification)
+
+ std::size_t typename_token;
+ NameAST *name;
+ ExpressionAST *expression;
+};
+
+struct TypeParameterAST: public AST
+{
+ DECLARE_AST_NODE(TypeParameter)
+
+ std::size_t type;
+ NameAST *name;
+ TypeIdAST *type_id;
+ const ListNode<TemplateParameterAST*> *template_parameters;
+ NameAST *template_name;
+};
+
+struct TypedefAST: public DeclarationAST
+{
+ DECLARE_AST_NODE(Typedef)
+
+ TypeSpecifierAST *type_specifier;
+ const ListNode<InitDeclaratorAST*> *init_declarators;
+};
+
+struct UnaryExpressionAST: public ExpressionAST
+{
+ DECLARE_AST_NODE(UnaryExpression)
+
+ std::size_t op;
+ ExpressionAST *expression;
+};
+
+struct UnqualifiedNameAST: public AST
+{
+ DECLARE_AST_NODE(UnqualifiedName)
+
+ std::size_t tilde;
+ std::size_t id;
+ OperatorFunctionIdAST *operator_id;
+ const ListNode<TemplateArgumentAST*> *template_arguments;
+};
+
+struct UsingAST: public DeclarationAST
+{
+ DECLARE_AST_NODE(Using)
+
+ std::size_t type_name;
+ NameAST *name;
+};
+
+struct UsingDirectiveAST: public DeclarationAST
+{
+ DECLARE_AST_NODE(UsingDirective)
+
+ NameAST *name;
+};
+
+struct WhileStatementAST: public StatementAST
+{
+ DECLARE_AST_NODE(WhileStatement)
+
+ ConditionAST *condition;
+ StatementAST *statement;
+};
+
+struct WinDeclSpecAST: public AST
+{
+ DECLARE_AST_NODE(WinDeclSpec)
+
+ std::size_t specifier;
+ std::size_t modifier;
+};
+
+struct QPropertyAST : public DeclarationAST
+{
+ DECLARE_AST_NODE(QPropertyAST)
+};
+
+struct QEnumsAST : public DeclarationAST
+{
+ DECLARE_AST_NODE(QEnumsAST)
+};
+
+template <class _Tp>
+_Tp *CreateNode(pool *memory_pool)
+{
+ _Tp *node = reinterpret_cast<_Tp*>(memory_pool->allocate(sizeof(_Tp), strideof(_Tp)));
+ node->kind = _Tp::__node_kind;
+ return node;
+}
+
+template <class _Tp>
+_Tp ast_cast(AST *item)
+{
+ if (item && static_cast<_Tp>(0)->__node_kind == item->kind)
+ return static_cast<_Tp>(item);
+
+ return 0;
+}
+
+#endif // AST_H
diff --git a/sources/shiboken2/ApiExtractor/parser/binder.cpp b/sources/shiboken2/ApiExtractor/parser/binder.cpp
new file mode 100644
index 000000000..709f86c56
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/binder.cpp
@@ -0,0 +1,866 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "binder.h"
+#include "lexer.h"
+#include "control.h"
+#include "symbol.h"
+#include "codemodel_finder.h"
+#include "class_compiler.h"
+#include "compiler_utils.h"
+#include "tokens.h"
+#include "dumptree.h"
+
+#include <iostream>
+#include <QDebug>
+
+Binder::Binder(CodeModel *__model, LocationManager &__location, Control *__control)
+ : _M_model(__model),
+ _M_location(__location),
+ _M_token_stream(&_M_location.token_stream),
+ _M_control(__control),
+ _M_current_function_type(CodeModel::Normal),
+ type_cc(this),
+ name_cc(this),
+ decl_cc(this)
+{
+ _M_qualified_types.insert(QLatin1String("char"), QString());
+ _M_qualified_types.insert(QLatin1String("double"), QString());
+ _M_qualified_types.insert(QLatin1String("float"), QString());
+ _M_qualified_types.insert(QLatin1String("int"), QString());
+ _M_qualified_types.insert(QLatin1String("long"), QString());
+ _M_qualified_types.insert(QLatin1String("short"), QString());
+ _M_qualified_types.insert(QLatin1String("void"), QString());
+}
+
+Binder::~Binder()
+{
+}
+
+FileModelItem Binder::run(AST *node)
+{
+ FileModelItem old = _M_current_file;
+ _M_current_access = CodeModel::Public;
+
+ _M_current_file.reset(new _FileModelItem(model()));
+ updateItemPosition(_M_current_file, node);
+ visit(node);
+ FileModelItem result = _M_current_file;
+
+ _M_current_file = old; // restore
+
+ return result;
+}
+
+ScopeModelItem Binder::currentScope()
+{
+ if (_M_current_class)
+ return _M_current_class;
+ else if (_M_current_namespace)
+ return _M_current_namespace;
+
+ return _M_current_file;
+}
+
+TemplateParameterList Binder::changeTemplateParameters(TemplateParameterList templateParameters)
+{
+ TemplateParameterList old = _M_current_template_parameters;
+ _M_current_template_parameters = templateParameters;
+ return old;
+}
+
+CodeModel::FunctionType Binder::changeCurrentFunctionType(CodeModel::FunctionType functionType)
+{
+ CodeModel::FunctionType old = _M_current_function_type;
+ _M_current_function_type = functionType;
+ return old;
+}
+
+CodeModel::AccessPolicy Binder::changeCurrentAccess(CodeModel::AccessPolicy accessPolicy)
+{
+ CodeModel::AccessPolicy old = _M_current_access;
+ _M_current_access = accessPolicy;
+ return old;
+}
+
+NamespaceModelItem Binder::changeCurrentNamespace(NamespaceModelItem item)
+{
+ NamespaceModelItem old = _M_current_namespace;
+ _M_current_namespace = item;
+ return old;
+}
+
+ClassModelItem Binder::changeCurrentClass(ClassModelItem item)
+{
+ ClassModelItem old = _M_current_class;
+ _M_current_class = item;
+ return old;
+}
+
+FunctionModelItem Binder::changeCurrentFunction(FunctionModelItem item)
+{
+ FunctionModelItem old = _M_current_function;
+ _M_current_function = item;
+ return old;
+}
+
+int Binder::decode_token(std::size_t index) const
+{
+ return _M_token_stream->kind(index);
+}
+
+CodeModel::AccessPolicy Binder::decode_access_policy(std::size_t index) const
+{
+ switch (decode_token(index)) {
+ case Token_class:
+ return CodeModel::Private;
+
+ case Token_struct:
+ case Token_union:
+ return CodeModel::Public;
+
+ default:
+ return CodeModel::Public;
+ }
+}
+
+CodeModel::ClassType Binder::decode_class_type(std::size_t index) const
+{
+ switch (decode_token(index)) {
+ case Token_class:
+ return CodeModel::Class;
+ case Token_struct:
+ return CodeModel::Struct;
+ case Token_union:
+ return CodeModel::Union;
+ default:
+ std::cerr << "** WARNING unrecognized class type" << std::endl;
+ }
+ return CodeModel::Class;
+}
+
+const NameSymbol *Binder::decode_symbol(std::size_t index) const
+{
+ return _M_token_stream->symbol(index);
+}
+
+void Binder::visitAccessSpecifier(AccessSpecifierAST *node)
+{
+ const ListNode<std::size_t> *it = node->specs;
+ if (!it)
+ return;
+
+ it = it->toFront();
+ const ListNode<std::size_t> *end = it;
+
+ do {
+ switch (decode_token(it->element)) {
+ default:
+ break;
+
+ case Token_public:
+ changeCurrentAccess(CodeModel::Public);
+ changeCurrentFunctionType(CodeModel::Normal);
+ break;
+ case Token_protected:
+ changeCurrentAccess(CodeModel::Protected);
+ changeCurrentFunctionType(CodeModel::Normal);
+ break;
+ case Token_private:
+ changeCurrentAccess(CodeModel::Private);
+ changeCurrentFunctionType(CodeModel::Normal);
+ break;
+ case Token_signals:
+ changeCurrentAccess(CodeModel::Protected);
+ changeCurrentFunctionType(CodeModel::Signal);
+ break;
+ case Token_slots:
+ changeCurrentFunctionType(CodeModel::Slot);
+ break;
+ }
+ it = it->next;
+ } while (it != end);
+}
+
+void Binder::visitSimpleDeclaration(SimpleDeclarationAST *node)
+{
+ visit(node->type_specifier);
+
+ if (const ListNode<InitDeclaratorAST*> *it = node->init_declarators) {
+ it = it->toFront();
+ const ListNode<InitDeclaratorAST*> *end = it;
+ do {
+ InitDeclaratorAST *init_declarator = it->element;
+ declare_symbol(node, init_declarator);
+ it = it->next;
+ } while (it != end);
+ }
+}
+
+void Binder::declare_symbol(SimpleDeclarationAST *node, InitDeclaratorAST *init_declarator)
+{
+ DeclaratorAST *declarator = init_declarator->declarator;
+
+ while (declarator && declarator->sub_declarator)
+ declarator = declarator->sub_declarator;
+
+ NameAST *id = declarator->id;
+ if (!declarator->id) {
+ std::cerr << "** WARNING expected a declarator id" << std::endl;
+ return;
+ }
+
+ CodeModelFinder finder(model(), this);
+ ScopeModelItem symbolScope = finder.resolveScope(id, currentScope());
+ if (!symbolScope) {
+ name_cc.run(id);
+ std::cerr << "** WARNING scope not found for symbol:"
+ << qPrintable(name_cc.name()) << std::endl;
+ return;
+ }
+
+ decl_cc.run(declarator);
+
+ if (decl_cc.isFunction()) {
+ name_cc.run(id->unqualified_name);
+
+ FunctionModelItem fun(new _FunctionModelItem(model(), name_cc.name()));
+ updateItemPosition(fun, node);
+ fun->setAccessPolicy(_M_current_access);
+ fun->setFunctionType(_M_current_function_type);
+ fun->setAbstract(init_declarator->initializer != 0);
+ fun->setConstant(declarator->fun_cv != 0);
+ fun->setTemplateParameters(_M_current_template_parameters);
+ applyStorageSpecifiers(node->storage_specifiers, fun);
+ applyFunctionSpecifiers(node->function_specifiers, fun);
+
+ // build the type
+ TypeInfo typeInfo = CompilerUtils::typeDescription(node->type_specifier,
+ declarator,
+ this);
+
+ fun->setType(qualifyType(typeInfo, symbolScope->qualifiedName()));
+
+
+ fun->setVariadics(decl_cc.isVariadics());
+
+ // ... and the signature
+ foreach (const DeclaratorCompiler::Parameter &p, decl_cc.parameters()) {
+ ArgumentModelItem arg(new _ArgumentModelItem(model(), p.name));
+ arg->setType(qualifyType(p.type, _M_context));
+ arg->setDefaultValue(p.defaultValue);
+ if (p.defaultValue)
+ arg->setDefaultValueExpression(p.defaultValueExpression);
+ fun->addArgument(arg);
+ }
+
+ fun->setScope(symbolScope->qualifiedName());
+ symbolScope->addFunction(fun);
+ } else {
+ VariableModelItem var(new _VariableModelItem(model()));
+ updateItemPosition(var, node);
+ var->setTemplateParameters(_M_current_template_parameters);
+ var->setAccessPolicy(_M_current_access);
+ name_cc.run(id->unqualified_name);
+ var->setName(name_cc.name());
+ // Possible bug, because second parameter uses declarator instead of
+ // init_declarator->declarator like in DeclaratorCompiler::visitParameterDeclaration,
+ // but it doesn't seem to affect anything because the generator doesn't currently use
+ // variable declarations, only function declarations (because it cares about the API only,
+ // variable declarations are not exposed to the target language).
+ // See PYSIDE-455.
+ TypeInfo typeInfo = CompilerUtils::typeDescription(node->type_specifier,
+ declarator,
+ this);
+ if (declarator != init_declarator->declarator
+ && init_declarator->declarator->parameter_declaration_clause) {
+ typeInfo.setFunctionPointer(true);
+ decl_cc.run(init_declarator->declarator);
+ foreach (const DeclaratorCompiler::Parameter &p, decl_cc.parameters())
+ typeInfo.addArgument(p.type);
+ }
+
+ var->setType(qualifyType(typeInfo, _M_context));
+ applyStorageSpecifiers(node->storage_specifiers, var);
+
+ var->setScope(symbolScope->qualifiedName());
+ symbolScope->addVariable(var);
+ }
+}
+
+void Binder::visitFunctionDefinition(FunctionDefinitionAST *node)
+{
+ Q_ASSERT(node->init_declarator);
+
+ ScopeModelItem scope = currentScope();
+
+ InitDeclaratorAST *init_declarator = node->init_declarator;
+ DeclaratorAST *declarator = init_declarator->declarator;
+
+ // in the case of "void (func)()" or "void ((func))()" we need to
+ // skip to the inner most. This is in line with how the declarator
+ // node is generated in 'parser.cpp'
+ while (declarator && declarator->sub_declarator)
+ declarator = declarator->sub_declarator;
+ if (!declarator->id) {
+ std::cerr << "** WARNING temp hack for Qt 5.6.0: "
+ << "skipped a class that inherits from a private class"
+ << std::endl;
+ return;
+ }
+ Q_ASSERT(declarator->id);
+
+ CodeModelFinder finder(model(), this);
+
+ ScopeModelItem functionScope = finder.resolveScope(declarator->id, scope);
+ if (!functionScope) {
+ name_cc.run(declarator->id);
+ std::cerr << "** WARNING scope not found for function definition:"
+ << qPrintable(name_cc.name()) << std::endl
+ << "\tdefinition *ignored*"
+ << std::endl;
+ return;
+ }
+
+ decl_cc.run(declarator);
+
+ Q_ASSERT(!decl_cc.id().isEmpty());
+
+ FunctionModelItem
+ old = changeCurrentFunction(FunctionModelItem(new _FunctionModelItem(_M_model)));
+ _M_current_function->setScope(functionScope->qualifiedName());
+ updateItemPosition(_M_current_function, node);
+
+ Q_ASSERT(declarator->id->unqualified_name);
+ name_cc.run(declarator->id->unqualified_name);
+ QString unqualified_name = name_cc.name();
+
+ _M_current_function->setName(unqualified_name);
+ TypeInfo tmp_type = CompilerUtils::typeDescription(node->type_specifier,
+ declarator, this);
+
+ _M_current_function->setType(qualifyType(tmp_type, _M_context));
+ _M_current_function->setAccessPolicy(_M_current_access);
+ _M_current_function->setFunctionType(_M_current_function_type);
+ _M_current_function->setConstant(declarator->fun_cv);
+ _M_current_function->setTemplateParameters(_M_current_template_parameters);
+
+ applyStorageSpecifiers(node->storage_specifiers,
+ _M_current_function);
+ applyFunctionSpecifiers(node->function_specifiers,
+ _M_current_function);
+
+ _M_current_function->setVariadics(decl_cc.isVariadics());
+
+ foreach (const DeclaratorCompiler::Parameter &p, decl_cc.parameters()) {
+ ArgumentModelItem arg(new _ArgumentModelItem(model(), p.name));
+ arg->setType(qualifyType(p.type, functionScope->qualifiedName()));
+ arg->setDefaultValue(p.defaultValue);
+ if (p.defaultValue)
+ arg->setDefaultValueExpression(p.defaultValueExpression);
+ _M_current_function->addArgument(arg);
+ }
+
+ FunctionModelItem prototype = _M_current_function;
+ FunctionModelItem declared = functionScope->declaredFunction(prototype);
+
+ // try to find a function declaration for this definition..
+ if (!declared) {
+ functionScope->addFunction(prototype);
+ } else {
+ applyFunctionSpecifiers(node->function_specifiers, declared);
+
+ // fix the function type and the access policy
+ _M_current_function->setAccessPolicy(declared->accessPolicy());
+ _M_current_function->setFunctionType(declared->functionType());
+ }
+
+ changeCurrentFunction(old);
+}
+
+void Binder::visitTemplateDeclaration(TemplateDeclarationAST *node)
+{
+ const ListNode<TemplateParameterAST*> *it = node->template_parameters;
+ if (!it) {
+ // QtScript: we want to visit the declaration still, so that
+ // e.g. QMetaTypeId<Foo> is added to the code model
+ visit(node->declaration);
+ return;
+ }
+
+ TemplateParameterList savedTemplateParameters = changeTemplateParameters(TemplateParameterList());
+
+ it = it->toFront();
+ const ListNode<TemplateParameterAST*> *end = it;
+
+ TemplateParameterList templateParameters;
+ do {
+ TemplateParameterAST *parameter = it->element;
+ TypeParameterAST *type_parameter = parameter->type_parameter;
+
+ NameAST *name;
+ if (!type_parameter) {
+ // A hacky hack to work around missing support for parameter declarations in
+ // templates. We just need the to get the name of the variable, since we
+ // aren't actually compiling these anyway. We are still not supporting much
+ // more, but we are refusing to fail for a few more declarations
+ if (!parameter->parameter_declaration ||
+ !parameter->parameter_declaration->declarator ||
+ !parameter->parameter_declaration->declarator->id) {
+
+ /*std::cerr << "** WARNING template declaration not supported ``";
+ Token const &tk = _M_token_stream->token ((int) node->start_token);
+ Token const &end_tk = _M_token_stream->token ((int) node->declaration->start_token);
+
+ std::cerr << std::string (&tk.text[tk.position], (end_tk.position) - tk.position) << "''"
+ << std::endl << std::endl;*/
+
+ changeTemplateParameters(savedTemplateParameters);
+ return;
+
+ }
+
+ name = parameter->parameter_declaration->declarator->id;
+ } else {
+ int tk = decode_token(type_parameter->type);
+ if (tk != Token_typename && tk != Token_class) {
+ /*std::cerr << "** WARNING template declaration not supported ``";
+ Token const &tk = _M_token_stream->token ((int) node->start_token);
+ Token const &end_tk = _M_token_stream->token ((int) node->declaration->start_token);
+
+ std::cerr << std::string (&tk.text[tk.position], (end_tk.position) - tk.position) << "''"
+ << std::endl << std::endl;*/
+
+ changeTemplateParameters(savedTemplateParameters);
+ return;
+ }
+ assert(tk == Token_typename || tk == Token_class);
+
+ name = type_parameter->name;
+ }
+
+
+ name_cc.run(name);
+ const TemplateParameterModelItem p(new _TemplateParameterModelItem(model(), name_cc.name()));
+ _M_current_template_parameters.append(p);
+ it = it->next;
+ } while (it != end);
+
+ visit(node->declaration);
+
+ changeTemplateParameters(savedTemplateParameters);
+}
+
+void Binder::visitTypedef(TypedefAST *node)
+{
+ const ListNode<InitDeclaratorAST*> *it = node->init_declarators;
+ if (!it)
+ return;
+
+ it = it->toFront();
+ const ListNode<InitDeclaratorAST*> *end = it;
+
+ do {
+ InitDeclaratorAST *init_declarator = it->element;
+ it = it->next;
+
+ Q_ASSERT(init_declarator->declarator);
+
+ // the name
+ decl_cc.run(init_declarator->declarator);
+ QString alias_name = decl_cc.id();
+
+ if (alias_name.isEmpty()) {
+ std::cerr << "** WARNING anonymous typedef not supported! ``";
+ Token const &tk = _M_token_stream->token((int) node->start_token);
+ Token const &end_tk = _M_token_stream->token((int) node->end_token);
+
+ std::cerr << std::string(&tk.text[tk.position], end_tk.position - tk.position) << "''"
+ << std::endl << std::endl;
+ continue;
+ }
+
+ // build the type
+ TypeInfo typeInfo = CompilerUtils::typeDescription(node->type_specifier,
+ init_declarator->declarator,
+ this);
+ DeclaratorAST *decl = init_declarator->declarator;
+ while (decl && decl->sub_declarator)
+ decl = decl->sub_declarator;
+
+ if (decl != init_declarator->declarator
+ && init_declarator->declarator->parameter_declaration_clause) {
+ typeInfo.setFunctionPointer(true);
+ decl_cc.run(init_declarator->declarator);
+ foreach (const DeclaratorCompiler::Parameter &p, decl_cc.parameters())
+ typeInfo.addArgument(p.type);
+ }
+
+ ScopeModelItem scope = currentScope();
+ DeclaratorAST *declarator = init_declarator->declarator;
+ CodeModelFinder finder(model(), this);
+ ScopeModelItem typedefScope = finder.resolveScope(declarator->id, scope);
+
+ TypeDefModelItem typeDef(new _TypeDefModelItem(model()));
+ updateItemPosition(typeDef, node);
+ typeDef->setName(alias_name);
+ typeDef->setType(qualifyType(typeInfo, currentScope()->qualifiedName()));
+ typeDef->setScope(typedefScope->qualifiedName());
+ _M_qualified_types[typeDef->qualifiedName().join(QLatin1Char('.'))] = QString();
+ currentScope()->addTypeDef(typeDef);
+ } while (it != end);
+}
+
+void Binder::visitNamespace(NamespaceAST *node)
+{
+ bool anonymous = (node->namespace_name == 0);
+
+ ScopeModelItem scope = currentScope();
+
+ NamespaceModelItem old;
+ if (!anonymous) {
+ QString name = decode_symbol(node->namespace_name)->as_string();
+
+ QStringList qualified_name = scope->qualifiedName();
+ qualified_name += name;
+ const CodeModelItem nsI = _M_model->findItem(qualified_name, _M_current_file);
+ NamespaceModelItem ns = qSharedPointerDynamicCast<_NamespaceModelItem>(nsI);
+ if (!ns) {
+ ns.reset(new _NamespaceModelItem(_M_model));
+ updateItemPosition(ns, node);
+ ns->setName(name);
+ ns->setScope(scope->qualifiedName());
+ }
+ old = changeCurrentNamespace(ns);
+
+ _M_context.append(name);
+ }
+
+ DefaultVisitor::visitNamespace(node);
+
+ if (!anonymous) {
+ Q_ASSERT(scope->kind() == _CodeModelItem::Kind_Namespace
+ || scope->kind() == _CodeModelItem::Kind_File);
+
+ _M_context.removeLast();
+
+ if (const NamespaceModelItem ns = qSharedPointerDynamicCast<_NamespaceModelItem>(scope))
+ ns->addNamespace(_M_current_namespace);
+
+ changeCurrentNamespace(old);
+ }
+}
+
+void Binder::visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST *node)
+{
+ name_cc.run(node->name);
+ if (name_cc.name().isEmpty())
+ return;
+
+ ScopeModelItem scope = currentScope();
+ _M_qualified_types[(scope->qualifiedName() + name_cc.qualifiedName()).join(QLatin1Char('.'))] = QString();
+}
+
+void Binder::visitClassSpecifier(ClassSpecifierAST *node)
+{
+ ClassCompiler class_cc(this);
+ class_cc.run(node);
+
+ if (class_cc.name().isEmpty()) {
+ // anonymous not supported
+ return;
+ }
+
+ Q_ASSERT(node->name && node->name->unqualified_name);
+
+ ScopeModelItem scope = currentScope();
+
+ ClassModelItem old = changeCurrentClass(ClassModelItem(new _ClassModelItem(_M_model)));
+ updateItemPosition(_M_current_class, node);
+ _M_current_class->setName(class_cc.name());
+
+ QStringList baseClasses = class_cc.baseClasses();
+ TypeInfo info;
+ for (int i = 0; i < baseClasses.size(); ++i) {
+ info.setQualifiedName(baseClasses.at(i).split(QLatin1String("::")));
+ baseClasses[i] = qualifyType(info, scope->qualifiedName()).qualifiedName().join(QLatin1String("::"));
+ }
+
+ _M_current_class->setBaseClasses(baseClasses);
+ _M_current_class->setClassType(decode_class_type(node->class_key));
+ _M_current_class->setTemplateParameters(_M_current_template_parameters);
+
+ if (!_M_current_template_parameters.isEmpty()) {
+ QString name = _M_current_class->name();
+ name += QLatin1Char('<');
+ for (int i = 0; i < _M_current_template_parameters.size(); ++i) {
+ if (i > 0)
+ name += QLatin1Char(',');
+
+ name += _M_current_template_parameters.at(i)->name();
+ }
+
+ name += QLatin1Char('>');
+ _M_current_class->setName(name);
+ }
+
+ CodeModel::AccessPolicy oldAccessPolicy = changeCurrentAccess(decode_access_policy(node->class_key));
+ CodeModel::FunctionType oldFunctionType = changeCurrentFunctionType(CodeModel::Normal);
+
+ _M_current_class->setScope(scope->qualifiedName());
+ _M_qualified_types[_M_current_class->qualifiedName().join(QLatin1Char('.'))] = QString();
+
+ scope->addClass(_M_current_class);
+
+ name_cc.run(node->name->unqualified_name);
+ _M_context.append(name_cc.name());
+ visitNodes(this, node->member_specs);
+ _M_context.removeLast();
+
+ changeCurrentClass(old);
+ changeCurrentAccess(oldAccessPolicy);
+ changeCurrentFunctionType(oldFunctionType);
+}
+
+void Binder::visitLinkageSpecification(LinkageSpecificationAST *node)
+{
+ DefaultVisitor::visitLinkageSpecification(node);
+}
+
+void Binder::visitUsing(UsingAST *node)
+{
+ DefaultVisitor::visitUsing(node);
+}
+
+void Binder::visitEnumSpecifier(EnumSpecifierAST *node)
+{
+ CodeModelFinder finder(model(), this);
+ ScopeModelItem scope = currentScope();
+ ScopeModelItem enumScope = finder.resolveScope(node->name, scope);
+
+ name_cc.run(node->name);
+ QString name = name_cc.name();
+
+ bool isAnonymous = name.isEmpty();
+ if (isAnonymous) {
+ // anonymous enum
+ QString key = _M_context.join(QLatin1String("::"));
+ int current = ++_M_anonymous_enums[key];
+ name += QLatin1String("enum_");
+ name += QString::number(current);
+ }
+
+ _M_current_enum.reset(new _EnumModelItem(model()));
+ _M_current_enum->setAccessPolicy(_M_current_access);
+ updateItemPosition(_M_current_enum, node);
+ _M_current_enum->setName(name);
+ _M_current_enum->setAnonymous(isAnonymous);
+ _M_current_enum->setScope(enumScope->qualifiedName());
+
+ _M_qualified_types[_M_current_enum->qualifiedName().join(QLatin1Char('.'))] = QString();
+
+ enumScope->addEnum(_M_current_enum);
+
+ DefaultVisitor::visitEnumSpecifier(node);
+
+ _M_current_enum.clear();
+}
+
+static QString strip_preprocessor_lines(const QString &name)
+{
+ QStringList lst = name.split(QLatin1Char('\n'));
+ QString s;
+ for (int i = 0; i < lst.size(); ++i) {
+ if (!lst.at(i).startsWith(QLatin1Char('#')))
+ s += lst.at(i);
+ }
+ return s.trimmed();
+}
+
+void Binder::visitEnumerator(EnumeratorAST *node)
+{
+ Q_ASSERT(_M_current_enum);
+ EnumeratorModelItem e(new _EnumeratorModelItem(model()));
+ updateItemPosition(e, node);
+ e->setName(decode_symbol(node->id)->as_string());
+
+ if (ExpressionAST *expr = node->expression) {
+ const Token &start_token = _M_token_stream->token((int) expr->start_token);
+ const Token &end_token = _M_token_stream->token((int) expr->end_token);
+ const QString token = QString::fromUtf8(&start_token.text[start_token.position],
+ (int)(end_token.position - start_token.position));
+ QString lines = strip_preprocessor_lines(token.trimmed());
+ lines.remove(QLatin1Char(' '));
+ e->setValue(lines);
+ }
+
+ _M_current_enum->addEnumerator(e);
+}
+
+void Binder::visitUsingDirective(UsingDirectiveAST *node)
+{
+ DefaultVisitor::visitUsingDirective(node);
+}
+
+void Binder::visitQEnums(QEnumsAST *node)
+{
+ const Token &start = _M_token_stream->token((int) node->start_token);
+ const Token &end = _M_token_stream->token((int) node->end_token);
+ QStringList enum_list = QString::fromLatin1(start.text + start.position,
+ end.position - start.position).split(QLatin1Char(' '));
+
+ ScopeModelItem scope = currentScope();
+ for (int i = 0; i < enum_list.size(); ++i)
+ scope->addEnumsDeclaration(enum_list.at(i));
+}
+
+void Binder::visitQProperty(QPropertyAST *node)
+{
+ const Token &start = _M_token_stream->token((int) node->start_token);
+ const Token &end = _M_token_stream->token((int) node->end_token);
+ QString property = QString::fromLatin1(start.text + start.position,
+ end.position - start.position);
+ _M_current_class->addPropertyDeclaration(property);
+}
+
+void Binder::applyStorageSpecifiers(const ListNode<std::size_t> *it, MemberModelItem item)
+{
+ if (!it)
+ return;
+
+ it = it->toFront();
+ const ListNode<std::size_t> *end = it;
+
+ do {
+ switch (decode_token(it->element)) {
+ default:
+ break;
+
+ case Token_friend:
+ item->setFriend(true);
+ break;
+ case Token_auto:
+ item->setAuto(true);
+ break;
+ case Token_register:
+ item->setRegister(true);
+ break;
+ case Token_static:
+ item->setStatic(true);
+ break;
+ case Token_extern:
+ item->setExtern(true);
+ break;
+ case Token_mutable:
+ item->setMutable(true);
+ break;
+ }
+ it = it->next;
+ } while (it != end);
+}
+
+void Binder::applyFunctionSpecifiers(const ListNode<std::size_t> *it, FunctionModelItem item)
+{
+ if (!it)
+ return;
+
+ it = it->toFront();
+ const ListNode<std::size_t> *end = it;
+
+ do {
+ switch (decode_token(it->element)) {
+ default:
+ break;
+
+ case Token_inline:
+ item->setInline(true);
+ break;
+
+ case Token_virtual:
+ item->setVirtual(true);
+ break;
+
+ case Token_explicit:
+ item->setExplicit(true);
+ break;
+
+ case Token_Q_INVOKABLE:
+ item->setInvokable(true);
+ break;
+ }
+ it = it->next;
+ } while (it != end);
+}
+
+TypeInfo Binder::qualifyType(const TypeInfo &type, const QStringList &context) const
+{
+ // ### Potentially improve to use string list in the name table to
+ if (!context.size()) {
+ // ### We can assume that this means global namespace for now...
+ return type;
+ } else if (_M_qualified_types.contains(type.qualifiedName().join(QLatin1Char('.')))) {
+ return type;
+ } else {
+ QStringList expanded = context;
+ expanded << type.qualifiedName();
+ if (_M_qualified_types.contains(expanded.join(QLatin1Char('.')))) {
+ TypeInfo modified_type = type;
+ modified_type.setQualifiedName(expanded);
+ return modified_type;
+ } else {
+ CodeModelItem scope = model()->findItem(context, _M_current_file);
+
+ if (ClassModelItem klass = qSharedPointerDynamicCast<_ClassModelItem>(scope)) {
+ foreach (const QString &base, klass->baseClasses()) {
+ QStringList ctx = context;
+ ctx.removeLast();
+ ctx.append(base);
+
+ TypeInfo qualified = qualifyType(type, ctx);
+ if (qualified != type)
+ return qualified;
+ }
+ }
+
+ QStringList copy = context;
+ copy.removeLast();
+ return qualifyType(type, copy);
+ }
+ }
+}
+
+void Binder::updateItemPosition(CodeModelItem item, AST *node)
+{
+ QString filename;
+ int line, column;
+
+ assert(node);
+ _M_location.positionAt(_M_token_stream->position(node->start_token), &line, &column, &filename);
+ item->setFileName(filename);
+}
diff --git a/sources/shiboken2/ApiExtractor/parser/binder.h b/sources/shiboken2/ApiExtractor/parser/binder.h
new file mode 100644
index 000000000..cd8d93a95
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/binder.h
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef BINDER_H
+#define BINDER_H
+
+#include "default_visitor.h"
+#include "codemodel.h"
+#include "type_compiler.h"
+#include "name_compiler.h"
+#include "declarator_compiler.h"
+
+class TokenStream;
+class LocationManager;
+class Control;
+struct NameSymbol;
+
+class Binder: protected DefaultVisitor
+{
+public:
+ Binder(CodeModel *__model, LocationManager &__location, Control *__control = 0);
+ virtual ~Binder();
+
+ inline TokenStream *tokenStream() const
+ {
+ return _M_token_stream;
+ }
+
+ inline CodeModel *model() const
+ {
+ return _M_model;
+ }
+
+ ScopeModelItem currentScope();
+
+ FileModelItem run(AST *node);
+
+// utils
+ TypeInfo qualifyType(const TypeInfo &type, const QStringList &context) const;
+
+protected:
+ virtual void visitAccessSpecifier(AccessSpecifierAST *);
+ virtual void visitClassSpecifier(ClassSpecifierAST *);
+ virtual void visitEnumSpecifier(EnumSpecifierAST *);
+ virtual void visitEnumerator(EnumeratorAST *);
+ virtual void visitFunctionDefinition(FunctionDefinitionAST *);
+ virtual void visitLinkageSpecification(LinkageSpecificationAST *);
+ virtual void visitNamespace(NamespaceAST *);
+ virtual void visitSimpleDeclaration(SimpleDeclarationAST *);
+ virtual void visitTemplateDeclaration(TemplateDeclarationAST *);
+ virtual void visitTypedef(TypedefAST *);
+ virtual void visitUsing(UsingAST *);
+ virtual void visitUsingDirective(UsingDirectiveAST *);
+ virtual void visitQProperty(QPropertyAST *);
+ virtual void visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST *);
+ virtual void visitQEnums(QEnumsAST *);
+
+private:
+
+ int decode_token(std::size_t index) const;
+ const NameSymbol *decode_symbol(std::size_t index) const;
+ CodeModel::AccessPolicy decode_access_policy(std::size_t index) const;
+ CodeModel::ClassType decode_class_type(std::size_t index) const;
+
+ CodeModel::FunctionType changeCurrentFunctionType(CodeModel::FunctionType functionType);
+ CodeModel::AccessPolicy changeCurrentAccess(CodeModel::AccessPolicy accessPolicy);
+ NamespaceModelItem changeCurrentNamespace(NamespaceModelItem item);
+ ClassModelItem changeCurrentClass(ClassModelItem item);
+ FunctionModelItem changeCurrentFunction(FunctionModelItem item);
+ TemplateParameterList changeTemplateParameters(TemplateParameterList templateParameters);
+
+ void declare_symbol(SimpleDeclarationAST *node, InitDeclaratorAST *init_declarator);
+
+ void applyStorageSpecifiers(const ListNode<std::size_t> *storage_specifiers, MemberModelItem item);
+ void applyFunctionSpecifiers(const ListNode<std::size_t> *it, FunctionModelItem item);
+
+ void updateItemPosition(CodeModelItem item, AST *node);
+
+private:
+ CodeModel *_M_model;
+ LocationManager &_M_location;
+ TokenStream *_M_token_stream;
+ Control *_M_control;
+
+ CodeModel::FunctionType _M_current_function_type;
+ CodeModel::AccessPolicy _M_current_access;
+ FileModelItem _M_current_file;
+ NamespaceModelItem _M_current_namespace;
+ ClassModelItem _M_current_class;
+ FunctionModelItem _M_current_function;
+ EnumModelItem _M_current_enum;
+ QStringList _M_context;
+ TemplateParameterList _M_current_template_parameters; // ### check me
+ QHash<QString, QString> _M_qualified_types;
+ QHash<QString, int> _M_anonymous_enums;
+ void dummy() {
+ _M_control=0;
+ }
+
+protected:
+ TypeCompiler type_cc;
+ NameCompiler name_cc;
+ DeclaratorCompiler decl_cc;
+};
+
+#endif // BINDER_H
diff --git a/sources/shiboken2/ApiExtractor/parser/class_compiler.cpp b/sources/shiboken2/ApiExtractor/parser/class_compiler.cpp
new file mode 100644
index 000000000..3387412ff
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/class_compiler.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "class_compiler.h"
+#include "lexer.h"
+#include "binder.h"
+
+ClassCompiler::ClassCompiler(Binder *binder)
+ : _M_binder(binder),
+ _M_token_stream(binder->tokenStream()),
+ name_cc(_M_binder),
+ type_cc(_M_binder)
+{
+}
+
+ClassCompiler::~ClassCompiler()
+{
+}
+
+void ClassCompiler::run(ClassSpecifierAST *node)
+{
+ name_cc.run(node->name);
+ _M_name = name_cc.name();
+ _M_base_classes.clear();
+
+ visit(node);
+}
+
+void ClassCompiler::visitClassSpecifier(ClassSpecifierAST *node)
+{
+ visit(node->base_clause);
+}
+
+void ClassCompiler::visitBaseSpecifier(BaseSpecifierAST *node)
+{
+ name_cc.run(node->name);
+ QString name = name_cc.name();
+
+ if (!name.isEmpty())
+ _M_base_classes.append(name);
+}
+
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/class_compiler.h b/sources/shiboken2/ApiExtractor/parser/class_compiler.h
new file mode 100644
index 000000000..09b727fe6
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/class_compiler.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef CLASS_COMPILER_H
+#define CLASS_COMPILER_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/QStringList>
+
+#include <default_visitor.h>
+#include <name_compiler.h>
+#include <type_compiler.h>
+
+class TokenStream;
+class Binder;
+
+class ClassCompiler: protected DefaultVisitor
+{
+public:
+ ClassCompiler(Binder *binder);
+ virtual ~ClassCompiler();
+
+ inline QString name() const
+ {
+ return _M_name;
+ }
+
+ inline QStringList baseClasses() const
+ {
+ return _M_base_classes;
+ }
+
+ void run(ClassSpecifierAST *node);
+
+protected:
+ virtual void visitClassSpecifier(ClassSpecifierAST *node);
+ virtual void visitBaseSpecifier(BaseSpecifierAST *node);
+
+private:
+ Binder *_M_binder;
+ TokenStream *_M_token_stream;
+ QString _M_name;
+ QStringList _M_base_classes;
+ NameCompiler name_cc;
+ TypeCompiler type_cc;
+};
+
+#endif // CLASS_COMPILER_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
new file mode 100644
index 000000000..a5024c4a3
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
@@ -0,0 +1,1199 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "codemodel.h"
+#include <algorithm>
+#include <functional>
+#include <iostream>
+#include <QDebug>
+#include <QDir>
+
+// Predicate to find an item by name in a list of QSharedPointer<Item>
+template <class T> class ModelItemNamePredicate : public std::unary_function<bool, QSharedPointer<T> >
+{
+public:
+ explicit ModelItemNamePredicate(const QString &name) : m_name(name) {}
+ bool operator()(const QSharedPointer<T> &item) const { return item->name() == m_name; }
+
+private:
+ const QString m_name;
+};
+
+template <class T>
+static QSharedPointer<T> findModelItem(const QList<QSharedPointer<T> > &list, const QString &name)
+{
+ typedef typename QList<QSharedPointer<T> >::const_iterator It;
+ const It it = std::find_if(list.begin(), list.end(), ModelItemNamePredicate<T>(name));
+ return it != list.end() ? *it : QSharedPointer<T>();
+}
+
+// ---------------------------------------------------------------------------
+
+CodeModel::CodeModel() : m_globalNamespace(new _NamespaceModelItem(this))
+{
+}
+
+CodeModel::~CodeModel()
+{
+}
+
+NamespaceModelItem CodeModel::globalNamespace() const
+{
+ return m_globalNamespace;
+}
+
+void CodeModel::addFile(FileModelItem item)
+{
+ m_files.append(item);
+}
+
+FileModelItem CodeModel::findFile(const QString &name) const
+{
+ return findModelItem(m_files, name);
+}
+
+CodeModelItem CodeModel::findItem(const QStringList &qualifiedName, CodeModelItem scope) const
+{
+ for (int i = 0; i < qualifiedName.size(); ++i) {
+ // ### Extend to look for members etc too.
+ const QString &name = qualifiedName.at(i);
+
+ if (NamespaceModelItem ns = qSharedPointerDynamicCast<_NamespaceModelItem>(scope)) {
+ if (NamespaceModelItem tmp_ns = ns->findNamespace(name)) {
+ scope = tmp_ns;
+ continue;
+ }
+ }
+
+ if (ScopeModelItem ss = qSharedPointerDynamicCast<_ScopeModelItem>(scope)) {
+ if (ClassModelItem cs = ss->findClass(name)) {
+ scope = cs;
+ } else if (EnumModelItem es = ss->findEnum(name)) {
+ if (i == qualifiedName.size() - 1)
+ return es;
+ } else if (TypeDefModelItem tp = ss->findTypeDef(name)) {
+ if (i == qualifiedName.size() - 1)
+ return tp;
+ } else {
+ // If we don't find the name in the scope chain we
+ // need to return an empty item to indicate failure...
+ return CodeModelItem();
+ }
+ }
+ }
+
+ return scope;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const CodeModel *m)
+{
+ QDebugStateSaver s(d);
+ d.noquote();
+ d.nospace();
+ d << "CodeModel(";
+ if (m) {
+ const NamespaceModelItem globalNamespaceP = m->globalNamespace();
+ if (globalNamespaceP.data())
+ globalNamespaceP->formatDebug(d);
+ } else {
+ d << '0';
+ }
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+// ---------------------------------------------------------------------------
+TypeInfo TypeInfo::combine(const TypeInfo &__lhs, const TypeInfo &__rhs)
+{
+ TypeInfo __result = __lhs;
+
+ __result.setConstant(__result.isConstant() || __rhs.isConstant());
+ __result.setVolatile(__result.isVolatile() || __rhs.isVolatile());
+ if (__rhs.referenceType() > __result.referenceType())
+ __result.setReferenceType(__rhs.referenceType());
+ __result.setIndirections(__result.indirections() + __rhs.indirections());
+ __result.setArrayElements(__result.arrayElements() + __rhs.arrayElements());
+
+ return __result;
+}
+
+TypeInfo TypeInfo::resolveType(TypeInfo const &__type, CodeModelItem __scope)
+{
+ CodeModel *__model = __scope->model();
+ Q_ASSERT(__model != 0);
+
+ return TypeInfo::resolveType(__model->findItem(__type.qualifiedName(), __scope), __type, __scope);
+}
+
+TypeInfo TypeInfo::resolveType(CodeModelItem __item, TypeInfo const &__type, CodeModelItem __scope)
+{
+ // Copy the type and replace with the proper qualified name. This
+ // only makes sence to do if we're actually getting a resolved
+ // type with a namespace. We only get this if the returned type
+ // has more than 2 entries in the qualified name... This test
+ // could be improved by returning if the type was found or not.
+ TypeInfo otherType(__type);
+ if (__item && __item->qualifiedName().size() > 1) {
+ otherType.setQualifiedName(__item->qualifiedName());
+ }
+
+ if (TypeDefModelItem __typedef = qSharedPointerDynamicCast<_TypeDefModelItem>(__item)) {
+ const TypeInfo combined = TypeInfo::combine(__typedef->type(), otherType);
+ const CodeModelItem nextItem = __scope->model()->findItem(combined.qualifiedName(), __scope);
+ if (!nextItem)
+ return combined;
+ // PYSIDE-362, prevent recursion on opaque structs like
+ // typedef struct xcb_connection_t xcb_connection_t;
+ if (nextItem.data() ==__item.data()) {
+ std::cerr << "** WARNING Bailing out recursion of " << __FUNCTION__
+ << "() on " << qPrintable(__type.qualifiedName().join(QLatin1String("::")))
+ << std::endl;
+ return otherType;
+ }
+ return resolveType(nextItem, combined, __scope);
+ }
+
+ return otherType;
+}
+
+QString TypeInfo::toString() const
+{
+ QString tmp;
+
+ tmp += m_qualifiedName.join(QLatin1String("::"));
+ if (isConstant())
+ tmp += QLatin1String(" const");
+
+ if (isVolatile())
+ tmp += QLatin1String(" volatile");
+
+ if (indirections())
+ tmp += QString(indirections(), QLatin1Char('*'));
+
+ switch (referenceType()) {
+ case NoReference:
+ break;
+ case LValueReference:
+ tmp += QLatin1Char('&');
+ break;
+ case RValueReference:
+ tmp += QLatin1String("&&");
+ break;
+ }
+
+ if (isFunctionPointer()) {
+ tmp += QLatin1String(" (*)(");
+ for (int i = 0; i < m_arguments.count(); ++i) {
+ if (i != 0)
+ tmp += QLatin1String(", ");
+
+ tmp += m_arguments.at(i).toString();
+ }
+ tmp += QLatin1Char(')');
+ }
+
+ foreach(QString elt, arrayElements()) {
+ tmp += QLatin1Char('[');
+ tmp += elt;
+ tmp += QLatin1Char(']');
+ }
+
+ return tmp;
+}
+
+bool TypeInfo::operator==(const TypeInfo &other)
+{
+ if (arrayElements().count() != other.arrayElements().count())
+ return false;
+
+#if defined (RXX_CHECK_ARRAY_ELEMENTS) // ### it'll break
+ for (int i = 0; i < arrayElements().count(); ++i) {
+ QString elt1 = arrayElements().at(i).trimmed();
+ QString elt2 = other.arrayElements().at(i).trimmed();
+
+ if (elt1 != elt2)
+ return false;
+ }
+#endif
+
+ return flags == other.flags
+ && m_qualifiedName == other.m_qualifiedName
+ && (!m_functionPointer || m_arguments == other.m_arguments);
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+template <class It>
+void formatSequence(QDebug &d, It i1, It i2, const char *separator=", ")
+{
+ for (It i = i1; i != i2; ++i) {
+ if (i != i1)
+ d << separator;
+ d << *i;
+ }
+}
+
+void TypeInfo::formatDebug(QDebug &d) const
+{
+ d << '"';
+ formatSequence(d, m_qualifiedName.begin(), m_qualifiedName.end(), "\", \"");
+ d << '"';
+ if (m_constant)
+ d << ", [const]";
+ if (m_volatile)
+ d << ", [volatile]";
+ if (m_indirections)
+ d << ", indirections=" << m_indirections;
+ switch (m_referenceType) {
+ case NoReference:
+ break;
+ case LValueReference:
+ d << ", [ref]";
+ break;
+ case RValueReference:
+ d << ", [rvalref]";
+ break;
+ }
+ if (m_functionPointer) {
+ d << ", function ptr(";
+ formatSequence(d, m_arguments.begin(), m_arguments.end());
+ d << ')';
+ }
+ if (!m_arrayElements.isEmpty()) {
+ d << ", array[" << m_arrayElements.size() << "][";
+ formatSequence(d, m_arrayElements.begin(), m_arrayElements.end());
+ d << ']';
+ }
+}
+
+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(";
+ if (verbosity > 2)
+ t.formatDebug(d);
+ else
+ d << t.toString();
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+// ---------------------------------------------------------------------------
+_CodeModelItem::_CodeModelItem(CodeModel *model, int kind)
+ : m_model(model),
+ m_kind(kind),
+ m_startLine(0),
+ m_startColumn(0),
+ m_endLine(0),
+ m_endColumn(0)
+{
+}
+
+_CodeModelItem::_CodeModelItem(CodeModel *model, const QString &name, int kind)
+ : m_model(model),
+ m_kind(kind),
+ m_startLine(0),
+ m_startColumn(0),
+ m_endLine(0),
+ m_endColumn(0),
+ m_name(name)
+{
+}
+
+_CodeModelItem::~_CodeModelItem()
+{
+}
+
+int _CodeModelItem::kind() const
+{
+ return m_kind;
+}
+
+QStringList _CodeModelItem::qualifiedName() const
+{
+ QStringList q = scope();
+
+ if (!name().isEmpty())
+ q += name();
+
+ return q;
+}
+
+QString _CodeModelItem::name() const
+{
+ return m_name;
+}
+
+void _CodeModelItem::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QStringList _CodeModelItem::scope() const
+{
+ return m_scope;
+}
+
+void _CodeModelItem::setScope(const QStringList &scope)
+{
+ m_scope = scope;
+}
+
+QString _CodeModelItem::fileName() const
+{
+ return m_fileName;
+}
+
+void _CodeModelItem::setFileName(const QString &fileName)
+{
+ m_fileName = fileName;
+}
+
+FileModelItem _CodeModelItem::file() const
+{
+ return model()->findFile(fileName());
+}
+
+void _CodeModelItem::getStartPosition(int *line, int *column)
+{
+ *line = m_startLine;
+ *column = m_startColumn;
+}
+
+void _CodeModelItem::setStartPosition(int line, int column)
+{
+ m_startLine = line;
+ m_startColumn = column;
+}
+
+void _CodeModelItem::getEndPosition(int *line, int *column)
+{
+ *line = m_endLine;
+ *column = m_endColumn;
+}
+
+void _CodeModelItem::setEndPosition(int line, int column)
+{
+ m_endLine = line;
+ m_endColumn = column;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+template <class It>
+static void formatPtrSequence(QDebug &d, It i1, It i2, const char *separator=", ")
+{
+ for (It i = i1; i != i2; ++i) {
+ if (i != i1)
+ d << separator;
+ d << i->data();
+ }
+}
+
+void _CodeModelItem::formatKind(QDebug &d, int k)
+{
+ switch (k) {
+ case Kind_Argument:
+ d << "ArgumentModelItem";
+ break;
+ case Kind_Class:
+ d << "ClassModelItem";
+ break;
+ case Kind_Enum:
+ d << "EnumModelItem";
+ break;
+ case Kind_Enumerator:
+ d << "EnumeratorModelItem";
+ break;
+ case Kind_File:
+ d << "FileModelItem";
+ break;
+ case Kind_Function:
+ d << "FunctionModelItem";
+ break;
+ case Kind_Member:
+ d << "MemberModelItem";
+ break;
+ case Kind_Namespace:
+ d << "NamespaceModelItem";
+ break;
+ case Kind_Variable:
+ d << "VariableModelItem";
+ break;
+ case Kind_Scope:
+ d << "ScopeModelItem";
+ break;
+ case Kind_TemplateParameter:
+ d << "TemplateParameter";
+ break;
+ case Kind_TypeDef:
+ d << "TypeDefModelItem";
+ break;
+ default:
+ d << "CodeModelItem";
+ break;
+ }
+}
+
+void _CodeModelItem::formatDebug(QDebug &d) const
+{
+ d << "(\"" << name() << '"';
+ if (!m_scope.isEmpty()) {
+ d << ", scope=";
+ formatSequence(d, m_scope.cbegin(), m_scope.cend(), "::");
+ }
+ if (!m_fileName.isEmpty()) {
+ d << ", file=\"" << QDir::toNativeSeparators(m_fileName);
+ if (m_startLine > 0)
+ d << ':' << m_startLine;
+ d << '"';
+ }
+}
+
+QDebug operator<<(QDebug d, const _CodeModelItem *t)
+{
+ QDebugStateSaver s(d);
+ d.noquote();
+ d.nospace();
+ if (!t) {
+ d << "CodeModelItem(0)";
+ return d;
+ }
+ _CodeModelItem::formatKind(d, t->kind());
+ t->formatDebug(d);
+ switch (t->kind()) {
+ case _CodeModelItem::Kind_Class:
+ d << " /* class " << t->name() << " */";
+ break;
+ case _CodeModelItem::Kind_Namespace:
+ d << " /* namespace " << t->name() << " */";
+ break;
+ }
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+// ---------------------------------------------------------------------------
+_ClassModelItem::~_ClassModelItem()
+{
+}
+
+QStringList _ClassModelItem::baseClasses() const
+{
+ return m_baseClasses;
+}
+
+void _ClassModelItem::setBaseClasses(const QStringList &baseClasses)
+{
+ m_baseClasses = baseClasses;
+}
+
+TemplateParameterList _ClassModelItem::templateParameters() const
+{
+ return m_templateParameters;
+}
+
+void _ClassModelItem::setTemplateParameters(const TemplateParameterList &templateParameters)
+{
+ m_templateParameters = templateParameters;
+}
+
+void _ClassModelItem::addBaseClass(const QString &baseClass)
+{
+ m_baseClasses.append(baseClass);
+}
+
+bool _ClassModelItem::extendsClass(const QString &name) const
+{
+ return m_baseClasses.contains(name);
+}
+
+void _ClassModelItem::setClassType(CodeModel::ClassType type)
+{
+ m_classType = type;
+}
+
+CodeModel::ClassType _ClassModelItem::classType() const
+{
+ return m_classType;
+}
+
+void _ClassModelItem::addPropertyDeclaration(const QString &propertyDeclaration)
+{
+ m_propertyDeclarations << propertyDeclaration;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+template <class List>
+static void formatModelItemList(QDebug &d, const char *prefix, const List &l,
+ const char *separator = ", ")
+{
+ if (const int size = l.size()) {
+ d << prefix << '[' << size << "](";
+ for (int i = 0; i < size; ++i) {
+ if (i)
+ d << separator;
+ l.at(i)->formatDebug(d);
+ }
+ d << ')';
+ }
+}
+
+void _ClassModelItem::formatDebug(QDebug &d) const
+{
+ _CodeModelItem::formatDebug(d);
+ if (!m_baseClasses.isEmpty())
+ d << ", inherits=" << m_baseClasses;
+ formatModelItemList(d, ", templateParameters=", m_templateParameters);
+ formatScopeItemsDebug(d);
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+// ---------------------------------------------------------------------------
+FunctionModelItem _ScopeModelItem::declaredFunction(FunctionModelItem item)
+{
+ foreach (const FunctionModelItem &fun, m_functions) {
+ if (fun->name() == item->name() && fun->isSimilar(item))
+ return fun;
+
+ }
+ return FunctionModelItem();
+}
+
+_ScopeModelItem::~_ScopeModelItem()
+{
+}
+
+void _ScopeModelItem::addEnumsDeclaration(const QString &enumsDeclaration)
+{
+ m_enumsDeclarations << enumsDeclaration;
+}
+
+void _ScopeModelItem::addClass(ClassModelItem item)
+{
+ m_classes.append(item);
+}
+
+void _ScopeModelItem::addFunction(FunctionModelItem item)
+{
+ m_functions.append(item);
+}
+
+void _ScopeModelItem::addVariable(VariableModelItem item)
+{
+ m_variables.append(item);
+}
+
+void _ScopeModelItem::addTypeDef(TypeDefModelItem item)
+{
+ m_typeDefs.append(item);
+}
+
+void _ScopeModelItem::addEnum(EnumModelItem item)
+{
+ m_enums.append(item);
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+template <class Hash>
+static void formatScopeHash(QDebug &d, const char *prefix, const Hash &h,
+ const char *separator = ", ",
+ bool trailingNewLine = false)
+{
+ typedef typename Hash::ConstIterator HashIterator;
+ if (!h.isEmpty()) {
+ d << prefix << '[' << h.size() << "](";
+ const HashIterator begin = h.begin();
+ const HashIterator end = h.end();
+ for (HashIterator it = begin; it != end; ++it) { // Omit the names as they are repeated
+ if (it != begin)
+ d << separator;
+ d << it.value().data();
+ }
+ d << ')';
+ if (trailingNewLine)
+ d << '\n';
+ }
+}
+
+template <class List>
+static void formatScopeList(QDebug &d, const char *prefix, const List &l,
+ const char *separator = ", ",
+ bool trailingNewLine = false)
+{
+ if (!l.isEmpty()) {
+ d << prefix << '[' << l.size() << "](";
+ formatPtrSequence(d, l.begin(), l.end(), separator);
+ d << ')';
+ if (trailingNewLine)
+ d << '\n';
+ }
+}
+
+void _ScopeModelItem::formatScopeItemsDebug(QDebug &d) const
+{
+ formatScopeList(d, ", classes=", m_classes, "\n", true);
+ formatScopeList(d, ", enums=", m_enums, "\n", true);
+ formatScopeList(d, ", aliases=", m_typeDefs, "\n", true);
+ formatScopeList(d, ", functions=", m_functions, "\n", true);
+ formatScopeList(d, ", variables=", m_variables);
+}
+
+void _ScopeModelItem::formatDebug(QDebug &d) const
+{
+ _CodeModelItem::formatDebug(d);
+ formatScopeItemsDebug(d);
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+namespace {
+// Predicate to match a non-template class name against the class list.
+// "Vector" should match "Vector" as well as "Vector<T>" (as seen for methods
+// from within the class "Vector").
+class ClassNamePredicate : public std::unary_function<bool, ClassModelItem>
+{
+public:
+ explicit ClassNamePredicate(const QString &name) : m_name(name) {}
+ bool operator()(const ClassModelItem &item) const
+ {
+ const QString &itemName = item->name();
+ if (!itemName.startsWith(m_name))
+ return false;
+ return itemName.size() == m_name.size() || itemName.at(m_name.size()) == QLatin1Char('<');
+ }
+
+private:
+ const QString m_name;
+};
+} // namespace
+
+ClassModelItem _ScopeModelItem::findClass(const QString &name) const
+{
+ // A fully qualified template is matched by name only
+ const ClassList::const_iterator it = name.contains(QLatin1Char('<'))
+ ? std::find_if(m_classes.begin(), m_classes.end(), ModelItemNamePredicate<_ClassModelItem>(name))
+ : std::find_if(m_classes.begin(), m_classes.end(), ClassNamePredicate(name));
+ return it != m_classes.end() ? *it : ClassModelItem();
+}
+
+VariableModelItem _ScopeModelItem::findVariable(const QString &name) const
+{
+ return findModelItem(m_variables, name);
+}
+
+TypeDefModelItem _ScopeModelItem::findTypeDef(const QString &name) const
+{
+ return findModelItem(m_typeDefs, name);
+}
+
+EnumModelItem _ScopeModelItem::findEnum(const QString &name) const
+{
+ return findModelItem(m_enums, name);
+}
+
+FunctionList _ScopeModelItem::findFunctions(const QString &name) const
+{
+ FunctionList result;
+ foreach (const FunctionModelItem &func, m_functions) {
+ if (func->name() == name)
+ result.append(func);
+ }
+ return result;
+}
+
+// ---------------------------------------------------------------------------
+_NamespaceModelItem::~_NamespaceModelItem()
+{
+}
+
+void _NamespaceModelItem::addNamespace(NamespaceModelItem item)
+{
+ m_namespaces.append(item);
+}
+
+NamespaceModelItem _NamespaceModelItem::findNamespace(const QString &name) const
+{
+ return findModelItem(m_namespaces, name);
+}
+
+_FileModelItem::~_FileModelItem()
+{
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+void _NamespaceModelItem::formatDebug(QDebug &d) const
+{
+ _ScopeModelItem::formatDebug(d);
+ formatScopeList(d, ", namespaces=", m_namespaces);
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+// ---------------------------------------------------------------------------
+_ArgumentModelItem::~_ArgumentModelItem()
+{
+}
+
+TypeInfo _ArgumentModelItem::type() const
+{
+ return m_type;
+}
+
+void _ArgumentModelItem::setType(const TypeInfo &type)
+{
+ m_type = type;
+}
+
+bool _ArgumentModelItem::defaultValue() const
+{
+ return m_defaultValue;
+}
+
+void _ArgumentModelItem::setDefaultValue(bool defaultValue)
+{
+ m_defaultValue = defaultValue;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+void _ArgumentModelItem::formatDebug(QDebug &d) const
+{
+ _CodeModelItem::formatDebug(d);
+ d << ", type=" << m_type;
+ if (m_defaultValue)
+ d << ", defaultValue=\"" << m_defaultValueExpression << '"';
+}
+#endif // !QT_NO_DEBUG_STREAM
+// ---------------------------------------------------------------------------
+_FunctionModelItem::~_FunctionModelItem()
+{
+}
+
+bool _FunctionModelItem::isSimilar(FunctionModelItem other) const
+{
+ if (name() != other->name())
+ return false;
+
+ if (isConstant() != other->isConstant())
+ return false;
+
+ if (isVariadics() != other->isVariadics())
+ return false;
+
+ if (arguments().count() != other->arguments().count())
+ return false;
+
+ // ### check the template parameters
+
+ for (int i = 0; i < arguments().count(); ++i) {
+ ArgumentModelItem arg1 = arguments().at(i);
+ ArgumentModelItem arg2 = other->arguments().at(i);
+
+ if (arg1->type() != arg2->type())
+ return false;
+ }
+
+ return true;
+}
+
+ArgumentList _FunctionModelItem::arguments() const
+{
+ return m_arguments;
+}
+
+void _FunctionModelItem::addArgument(ArgumentModelItem item)
+{
+ m_arguments.append(item);
+}
+
+CodeModel::FunctionType _FunctionModelItem::functionType() const
+{
+ return m_functionType;
+}
+
+void _FunctionModelItem::setFunctionType(CodeModel::FunctionType functionType)
+{
+ m_functionType = functionType;
+}
+
+bool _FunctionModelItem::isVariadics() const
+{
+ return m_isVariadics;
+}
+
+void _FunctionModelItem::setVariadics(bool isVariadics)
+{
+ m_isVariadics = isVariadics;
+}
+
+bool _FunctionModelItem::isVirtual() const
+{
+ return m_isVirtual;
+}
+
+void _FunctionModelItem::setVirtual(bool isVirtual)
+{
+ m_isVirtual = isVirtual;
+}
+
+bool _FunctionModelItem::isInline() const
+{
+ return m_isInline;
+}
+
+void _FunctionModelItem::setInline(bool isInline)
+{
+ m_isInline = isInline;
+}
+
+bool _FunctionModelItem::isExplicit() const
+{
+ return m_isExplicit;
+}
+
+void _FunctionModelItem::setExplicit(bool isExplicit)
+{
+ m_isExplicit = isExplicit;
+}
+
+bool _FunctionModelItem::isAbstract() const
+{
+ return m_isAbstract;
+}
+
+void _FunctionModelItem::setAbstract(bool isAbstract)
+{
+ m_isAbstract = isAbstract;
+}
+
+// Qt
+bool _FunctionModelItem::isInvokable() const
+{
+ return m_isInvokable;
+}
+
+void _FunctionModelItem::setInvokable(bool isInvokable)
+{
+ m_isInvokable = isInvokable;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+void _FunctionModelItem::formatDebug(QDebug &d) const
+{
+ _MemberModelItem::formatDebug(d);
+ d << ", type=" << m_functionType;
+ if (m_isInline)
+ d << " [inline]";
+ if (m_isAbstract)
+ d << " [abstract]";
+ if (m_isExplicit)
+ d << " [explicit]";
+ if (m_isInvokable)
+ d << " [invokable]";
+ formatModelItemList(d, ", arguments=", m_arguments);
+ if (m_isVariadics)
+ d << ",...";
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+// ---------------------------------------------------------------------------
+TypeInfo _TypeDefModelItem::type() const
+{
+ return m_type;
+}
+
+void _TypeDefModelItem::setType(const TypeInfo &type)
+{
+ m_type = type;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+void _TypeDefModelItem::formatDebug(QDebug &d) const
+{
+ _CodeModelItem::formatDebug(d);
+ d << ", type=" << m_type;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+// ---------------------------------------------------------------------------
+CodeModel::AccessPolicy _EnumModelItem::accessPolicy() const
+{
+ return m_accessPolicy;
+}
+
+_EnumModelItem::~_EnumModelItem()
+{
+}
+
+void _EnumModelItem::setAccessPolicy(CodeModel::AccessPolicy accessPolicy)
+{
+ m_accessPolicy = accessPolicy;
+}
+
+EnumeratorList _EnumModelItem::enumerators() const
+{
+ return m_enumerators;
+}
+
+void _EnumModelItem::addEnumerator(EnumeratorModelItem item)
+{
+ m_enumerators.append(item);
+}
+
+bool _EnumModelItem::isAnonymous() const
+{
+ return m_anonymous;
+}
+
+void _EnumModelItem::setAnonymous(bool anonymous)
+{
+ m_anonymous = anonymous;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+void _EnumModelItem::formatDebug(QDebug &d) const
+{
+ _CodeModelItem::formatDebug(d);
+ if (m_anonymous)
+ d << " (anonymous)";
+ formatModelItemList(d, ", enumerators=", m_enumerators);
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+// ---------------------------------------------------------------------------
+_EnumeratorModelItem::~_EnumeratorModelItem()
+{
+}
+
+QString _EnumeratorModelItem::value() const
+{
+ return m_value;
+}
+
+void _EnumeratorModelItem::setValue(const QString &value)
+{
+ m_value = value;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+void _EnumeratorModelItem::formatDebug(QDebug &d) const
+{
+ _CodeModelItem::formatDebug(d);
+ if (!m_value.isEmpty())
+ d << ", value=\"" << m_value << '"';
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+// ---------------------------------------------------------------------------
+_TemplateParameterModelItem::~_TemplateParameterModelItem()
+{
+}
+
+TypeInfo _TemplateParameterModelItem::type() const
+{
+ return m_type;
+}
+
+void _TemplateParameterModelItem::setType(const TypeInfo &type)
+{
+ m_type = type;
+}
+
+bool _TemplateParameterModelItem::defaultValue() const
+{
+ return m_defaultValue;
+}
+
+void _TemplateParameterModelItem::setDefaultValue(bool defaultValue)
+{
+ m_defaultValue = defaultValue;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+void _TemplateParameterModelItem::formatDebug(QDebug &d) const
+{
+ _CodeModelItem::formatDebug(d);
+ d << ", type=" << m_type;
+ if (m_defaultValue)
+ d << " [defaultValue]";
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+// ---------------------------------------------------------------------------
+TypeInfo _MemberModelItem::type() const
+{
+ return m_type;
+}
+
+void _MemberModelItem::setType(const TypeInfo &type)
+{
+ m_type = type;
+}
+
+CodeModel::AccessPolicy _MemberModelItem::accessPolicy() const
+{
+ return m_accessPolicy;
+}
+
+_MemberModelItem::~_MemberModelItem()
+{
+}
+
+void _MemberModelItem::setAccessPolicy(CodeModel::AccessPolicy accessPolicy)
+{
+ m_accessPolicy = accessPolicy;
+}
+
+bool _MemberModelItem::isStatic() const
+{
+ return m_isStatic;
+}
+
+void _MemberModelItem::setStatic(bool isStatic)
+{
+ m_isStatic = isStatic;
+}
+
+bool _MemberModelItem::isConstant() const
+{
+ return m_isConstant;
+}
+
+void _MemberModelItem::setConstant(bool isConstant)
+{
+ m_isConstant = isConstant;
+}
+
+bool _MemberModelItem::isVolatile() const
+{
+ return m_isVolatile;
+}
+
+void _MemberModelItem::setVolatile(bool isVolatile)
+{
+ m_isVolatile = isVolatile;
+}
+
+bool _MemberModelItem::isAuto() const
+{
+ return m_isAuto;
+}
+
+void _MemberModelItem::setAuto(bool isAuto)
+{
+ m_isAuto = isAuto;
+}
+
+bool _MemberModelItem::isFriend() const
+{
+ return m_isFriend;
+}
+
+void _MemberModelItem::setFriend(bool isFriend)
+{
+ m_isFriend = isFriend;
+}
+
+bool _MemberModelItem::isRegister() const
+{
+ return m_isRegister;
+}
+
+void _MemberModelItem::setRegister(bool isRegister)
+{
+ m_isRegister = isRegister;
+}
+
+bool _MemberModelItem::isExtern() const
+{
+ return m_isExtern;
+}
+
+void _MemberModelItem::setExtern(bool isExtern)
+{
+ m_isExtern = isExtern;
+}
+
+bool _MemberModelItem::isMutable() const
+{
+ return m_isMutable;
+}
+
+void _MemberModelItem::setMutable(bool isMutable)
+{
+ m_isMutable = isMutable;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+void _MemberModelItem::formatDebug(QDebug &d) const
+{
+ _CodeModelItem::formatDebug(d);
+ switch (m_accessPolicy) {
+ case CodeModel::Public:
+ d << ", public";
+ break;
+ case CodeModel::Protected:
+ d << ", protected";
+ break;
+ case CodeModel::Private:
+ d << ", private";
+ break;
+ }
+ d << ", type=";
+ if (m_isConstant)
+ d << "const ";
+ if (m_isVolatile)
+ d << "volatile ";
+ if (m_isStatic)
+ d << "static ";
+ if (m_isAuto)
+ d << "auto ";
+ if (m_isFriend)
+ d << "friend ";
+ if (m_isRegister)
+ d << "register ";
+ if (m_isExtern)
+ d << "extern ";
+ if (m_isMutable)
+ d << "mutable ";
+ d << m_type;
+ formatScopeList(d, ", templateParameters", m_templateParameters);
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
+
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.h b/sources/shiboken2/ApiExtractor/parser/codemodel.h
new file mode 100644
index 000000000..811cfec3e
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel.h
@@ -0,0 +1,691 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef CODEMODEL_H
+#define CODEMODEL_H
+
+#include "codemodel_fwd.h"
+#include "codemodel_enums.h"
+
+#include <QtCore/QHash>
+#include <QtCore/QList>
+#include <QtCore/QSet>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVector>
+
+QT_FORWARD_DECLARE_CLASS(QDebug)
+
+#define DECLARE_MODEL_NODE(k) \
+ enum { __node_kind = Kind_##k };
+
+class CodeModel
+{
+public:
+ enum AccessPolicy {
+ Public,
+ Protected,
+ Private
+ };
+
+ enum FunctionType {
+ Normal,
+ Signal,
+ Slot
+ };
+
+ enum ClassType {
+ Class,
+ Struct,
+ Union
+ };
+
+public:
+ CodeModel();
+ virtual ~CodeModel();
+
+ FileList files() const { return m_files; }
+ NamespaceModelItem globalNamespace() const;
+
+ void addFile(FileModelItem item);
+ FileModelItem findFile(const QString &name) const;
+
+ CodeModelItem findItem(const QStringList &qualifiedName, CodeModelItem scope) const;
+
+private:
+ FileList m_files;
+ NamespaceModelItem m_globalNamespace;
+
+private:
+ CodeModel(const CodeModel &other);
+ void operator = (const CodeModel &other);
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const CodeModel *m);
+#endif
+
+class TypeInfo
+{
+public:
+ TypeInfo() : flags(0), m_referenceType(NoReference) {}
+
+ QStringList qualifiedName() const
+ {
+ return m_qualifiedName;
+ }
+
+ void setQualifiedName(const QStringList &qualified_name)
+ {
+ m_qualifiedName = qualified_name;
+ }
+
+ bool isConstant() const
+ {
+ return m_constant;
+ }
+
+ void setConstant(bool is)
+ {
+ m_constant = is;
+ }
+
+ bool isVolatile() const
+ {
+ return m_volatile;
+ }
+
+ void setVolatile(bool is)
+ {
+ m_volatile = is;
+ }
+
+ ReferenceType referenceType() const { return m_referenceType; }
+ void setReferenceType(ReferenceType r) { m_referenceType = r; }
+
+ int indirections() const
+ {
+ return m_indirections;
+ }
+
+ void setIndirections(int indirections)
+ {
+ m_indirections = indirections;
+ }
+
+ bool isFunctionPointer() const
+ {
+ return m_functionPointer;
+ }
+ void setFunctionPointer(bool is)
+ {
+ m_functionPointer = is;
+ }
+
+ QStringList arrayElements() const
+ {
+ return m_arrayElements;
+ }
+ void setArrayElements(const QStringList &arrayElements)
+ {
+ m_arrayElements = arrayElements;
+ }
+
+ QList<TypeInfo> arguments() const
+ {
+ return m_arguments;
+ }
+
+ void setArguments(const QList<TypeInfo> &arguments);
+
+ void addArgument(const TypeInfo &arg)
+ {
+ m_arguments.append(arg);
+ }
+
+ bool operator==(const TypeInfo &other);
+
+ bool operator!=(const TypeInfo &other)
+ {
+ return !(*this == other);
+ }
+
+ // ### arrays and templates??
+
+ QString toString() const;
+
+ static TypeInfo combine(const TypeInfo &__lhs, const TypeInfo &__rhs);
+ static TypeInfo resolveType(TypeInfo const &__type, CodeModelItem __scope);
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const;
+#endif
+
+private:
+ static TypeInfo resolveType(CodeModelItem item, TypeInfo const &__type, CodeModelItem __scope);
+
+ QStringList m_qualifiedName;
+ QStringList m_arrayElements;
+ QList<TypeInfo> m_arguments;
+
+ union {
+ uint flags;
+
+ struct {
+ uint m_constant: 1;
+ uint m_volatile: 1;
+ uint m_functionPointer: 1;
+ uint m_indirections: 6;
+ uint m_padding: 23;
+ };
+ };
+
+ ReferenceType m_referenceType;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const TypeInfo &t);
+#endif
+
+class _CodeModelItem
+{
+ Q_DISABLE_COPY(_CodeModelItem)
+public:
+ enum Kind {
+ /* These are bit-flags resembling inheritance */
+ Kind_Scope = 0x1,
+ Kind_Namespace = 0x2 | Kind_Scope,
+ Kind_Member = 0x4,
+ Kind_Function = 0x8 | Kind_Member,
+ KindMask = 0xf,
+
+ /* These are for classes that are not inherited from */
+ FirstKind = 0x8,
+ Kind_Argument = 1 << FirstKind,
+ Kind_Class = 2 << FirstKind | Kind_Scope,
+ Kind_Enum = 3 << FirstKind,
+ Kind_Enumerator = 4 << FirstKind,
+ Kind_File = 5 << FirstKind | Kind_Namespace,
+ Kind_TemplateParameter = 7 << FirstKind,
+ Kind_TypeDef = 8 << FirstKind,
+ Kind_Variable = 9 << FirstKind | Kind_Member
+ };
+
+public:
+ virtual ~_CodeModelItem();
+
+ int kind() const;
+
+ QStringList qualifiedName() const;
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QStringList scope() const;
+ void setScope(const QStringList &scope);
+
+ QString fileName() const;
+ void setFileName(const QString &fileName);
+
+ FileModelItem file() const;
+
+ void getStartPosition(int *line, int *column);
+ void setStartPosition(int line, int column);
+
+ void getEndPosition(int *line, int *column);
+ void setEndPosition(int line, int column);
+
+ inline CodeModel *model() const { return m_model; }
+
+#ifndef QT_NO_DEBUG_STREAM
+ static void formatKind(QDebug &d, int k);
+ virtual void formatDebug(QDebug &d) const;
+#endif
+
+protected:
+ explicit _CodeModelItem(CodeModel *model, int kind);
+ explicit _CodeModelItem(CodeModel *model, const QString &name, int kind);
+
+private:
+ CodeModel *m_model;
+ int m_kind;
+ int m_startLine;
+ int m_startColumn;
+ int m_endLine;
+ int m_endColumn;
+ QString m_name;
+ QString m_fileName;
+ QStringList m_scope;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const _CodeModelItem *t);
+#endif
+
+class _ScopeModelItem: public _CodeModelItem
+{
+public:
+ DECLARE_MODEL_NODE(Scope)
+
+ ~_ScopeModelItem();
+
+ ClassList classes() const { return m_classes; }
+ EnumList enums() const { return m_enums; }
+ inline FunctionList functions() const { return m_functions; }
+ TypeDefList typeDefs() const { return m_typeDefs; }
+ VariableList variables() const { return m_variables; }
+
+ void addClass(ClassModelItem item);
+ void addEnum(EnumModelItem item);
+ void addFunction(FunctionModelItem item);
+ void addTypeDef(TypeDefModelItem item);
+ void addVariable(VariableModelItem item);
+
+ ClassModelItem findClass(const QString &name) const;
+ EnumModelItem findEnum(const QString &name) const;
+ FunctionList findFunctions(const QString &name) const;
+ TypeDefModelItem findTypeDef(const QString &name) const;
+ VariableModelItem findVariable(const QString &name) const;
+
+ void addEnumsDeclaration(const QString &enumsDeclaration);
+ QStringList enumsDeclarations() const { return m_enumsDeclarations; }
+
+ FunctionModelItem declaredFunction(FunctionModelItem item);
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const Q_DECL_OVERRIDE;
+#endif
+
+protected:
+ explicit _ScopeModelItem(CodeModel *model, int kind = __node_kind)
+ : _CodeModelItem(model, kind) {}
+ explicit _ScopeModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _CodeModelItem(model, name, kind) {}
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatScopeItemsDebug(QDebug &d) const;
+#endif
+
+private:
+ ClassList m_classes;
+ EnumList m_enums;
+ TypeDefList m_typeDefs;
+ VariableList m_variables;
+ FunctionList m_functions;
+
+private:
+ QStringList m_enumsDeclarations;
+};
+
+class _ClassModelItem: public _ScopeModelItem
+{
+public:
+ DECLARE_MODEL_NODE(Class)
+
+ explicit _ClassModelItem(CodeModel *model, int kind = __node_kind)
+ : _ScopeModelItem(model, kind), m_classType(CodeModel::Class) {}
+ explicit _ClassModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _ScopeModelItem(model, name, kind), m_classType(CodeModel::Class) {}
+ ~_ClassModelItem();
+
+ QStringList baseClasses() const;
+
+ void setBaseClasses(const QStringList &baseClasses);
+ void addBaseClass(const QString &baseClass);
+
+ TemplateParameterList templateParameters() const;
+ void setTemplateParameters(const TemplateParameterList &templateParameters);
+
+ bool extendsClass(const QString &name) const;
+
+ void setClassType(CodeModel::ClassType type);
+ CodeModel::ClassType classType() const;
+
+ void addPropertyDeclaration(const QString &propertyDeclaration);
+ QStringList propertyDeclarations() const { return m_propertyDeclarations; }
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const Q_DECL_OVERRIDE;
+#endif
+
+private:
+ QStringList m_baseClasses;
+ TemplateParameterList m_templateParameters;
+ CodeModel::ClassType m_classType;
+
+ QStringList m_propertyDeclarations;
+};
+
+class _NamespaceModelItem: public _ScopeModelItem
+{
+public:
+ DECLARE_MODEL_NODE(Namespace)
+
+ explicit _NamespaceModelItem(CodeModel *model, int kind = __node_kind)
+ : _ScopeModelItem(model, kind) {}
+ explicit _NamespaceModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _ScopeModelItem(model, name, kind) {}
+ ~_NamespaceModelItem();
+
+ NamespaceList namespaces() const { return m_namespaces; }
+ QSet<NamespaceModelItem> uniqueNamespaces() const { return m_namespaces.toSet(); }
+
+ void addNamespace(NamespaceModelItem item);
+
+ NamespaceModelItem findNamespace(const QString &name) const;
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const Q_DECL_OVERRIDE;
+#endif
+
+private:
+ NamespaceList m_namespaces;
+};
+
+class _FileModelItem: public _NamespaceModelItem
+{
+public:
+ DECLARE_MODEL_NODE(File)
+
+ explicit _FileModelItem(CodeModel *model, int kind = __node_kind)
+ : _NamespaceModelItem(model, kind) {}
+ explicit _FileModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _NamespaceModelItem(model, name, kind) {}
+ ~_FileModelItem();
+};
+
+class _ArgumentModelItem: public _CodeModelItem
+{
+public:
+ DECLARE_MODEL_NODE(Argument)
+
+ explicit _ArgumentModelItem(CodeModel *model, int kind = __node_kind)
+ : _CodeModelItem(model, kind), m_defaultValue(false) {}
+ explicit _ArgumentModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _CodeModelItem(model, name, kind), m_defaultValue(false) {}
+ ~_ArgumentModelItem();
+
+ TypeInfo type() const;
+ void setType(const TypeInfo &type);
+
+ bool defaultValue() const;
+ void setDefaultValue(bool defaultValue);
+
+ QString defaultValueExpression() const { return m_defaultValueExpression; }
+ void setDefaultValueExpression(const QString &expr) { m_defaultValueExpression = expr; }
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const Q_DECL_OVERRIDE;
+#endif
+
+private:
+ TypeInfo m_type;
+ QString m_defaultValueExpression;
+ bool m_defaultValue;
+};
+
+class _MemberModelItem: public _CodeModelItem
+{
+public:
+ DECLARE_MODEL_NODE(Member)
+
+ explicit _MemberModelItem(CodeModel *model, int kind = __node_kind)
+ : _CodeModelItem(model, kind), m_accessPolicy(CodeModel::Public), m_flags(0) {}
+ explicit _MemberModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _CodeModelItem(model, name, kind), m_accessPolicy(CodeModel::Public), m_flags(0) {}
+ ~_MemberModelItem();
+
+ bool isConstant() const;
+ void setConstant(bool isConstant);
+
+ bool isVolatile() const;
+ void setVolatile(bool isVolatile);
+
+ bool isStatic() const;
+ void setStatic(bool isStatic);
+
+ bool isAuto() const;
+ void setAuto(bool isAuto);
+
+ bool isFriend() const;
+ void setFriend(bool isFriend);
+
+ bool isRegister() const;
+ void setRegister(bool isRegister);
+
+ bool isExtern() const;
+ void setExtern(bool isExtern);
+
+ bool isMutable() const;
+ void setMutable(bool isMutable);
+
+ CodeModel::AccessPolicy accessPolicy() const;
+ void setAccessPolicy(CodeModel::AccessPolicy accessPolicy);
+
+ TemplateParameterList templateParameters() const { return m_templateParameters; }
+ void setTemplateParameters(const TemplateParameterList &templateParameters) { m_templateParameters = templateParameters; }
+
+ TypeInfo type() const;
+ void setType(const TypeInfo &type);
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const Q_DECL_OVERRIDE;
+#endif
+
+private:
+ TemplateParameterList m_templateParameters;
+ TypeInfo m_type;
+ CodeModel::AccessPolicy m_accessPolicy;
+ union {
+ struct {
+ uint m_isConstant: 1;
+ uint m_isVolatile: 1;
+ uint m_isStatic: 1;
+ uint m_isAuto: 1;
+ uint m_isFriend: 1;
+ uint m_isRegister: 1;
+ uint m_isExtern: 1;
+ uint m_isMutable: 1;
+ };
+ uint m_flags;
+ };
+
+};
+
+class _FunctionModelItem: public _MemberModelItem
+{
+public:
+ DECLARE_MODEL_NODE(Function)
+
+ explicit _FunctionModelItem(CodeModel *model, int kind = __node_kind)
+ : _MemberModelItem(model, kind), m_functionType(CodeModel::Normal), m_flags(0) {}
+ explicit _FunctionModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _MemberModelItem(model, name, kind), m_functionType(CodeModel::Normal), m_flags(0) {}
+ ~_FunctionModelItem();
+
+ ArgumentList arguments() const;
+
+ void addArgument(ArgumentModelItem item);
+
+ CodeModel::FunctionType functionType() const;
+ void setFunctionType(CodeModel::FunctionType functionType);
+
+ bool isVirtual() const;
+ void setVirtual(bool isVirtual);
+
+ bool isInline() const;
+ void setInline(bool isInline);
+
+ bool isExplicit() const;
+ void setExplicit(bool isExplicit);
+
+ bool isInvokable() const; // Qt
+ void setInvokable(bool isInvokable); // Qt
+
+ bool isAbstract() const;
+ void setAbstract(bool isAbstract);
+
+ bool isVariadics() const;
+ void setVariadics(bool isVariadics);
+
+ bool isSimilar(FunctionModelItem other) const;
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const Q_DECL_OVERRIDE;
+#endif
+
+private:
+ ArgumentList m_arguments;
+ CodeModel::FunctionType m_functionType;
+ union {
+ struct {
+ uint m_isVirtual: 1;
+ uint m_isInline: 1;
+ uint m_isAbstract: 1;
+ uint m_isExplicit: 1;
+ uint m_isVariadics: 1;
+ uint m_isInvokable : 1; // Qt
+ };
+ uint m_flags;
+ };
+};
+
+class _VariableModelItem: public _MemberModelItem
+{
+public:
+ DECLARE_MODEL_NODE(Variable)
+
+ explicit _VariableModelItem(CodeModel *model, int kind = __node_kind)
+ : _MemberModelItem(model, kind) {}
+ explicit _VariableModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _MemberModelItem(model, name, kind) {}
+};
+
+class _TypeDefModelItem: public _CodeModelItem
+{
+public:
+ DECLARE_MODEL_NODE(TypeDef)
+
+ explicit _TypeDefModelItem(CodeModel *model, int kind = __node_kind)
+ : _CodeModelItem(model, kind) {}
+ explicit _TypeDefModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _CodeModelItem(model, name, kind) {}
+
+ TypeInfo type() const;
+ void setType(const TypeInfo &type);
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const Q_DECL_OVERRIDE;
+#endif
+
+private:
+ TypeInfo m_type;
+};
+
+class _EnumModelItem: public _CodeModelItem
+{
+public:
+ DECLARE_MODEL_NODE(Enum)
+
+ explicit _EnumModelItem(CodeModel *model, int kind = __node_kind)
+ : _CodeModelItem(model, kind), m_accessPolicy(CodeModel::Public), m_anonymous(false) {}
+ explicit _EnumModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _CodeModelItem(model, name, kind), m_accessPolicy(CodeModel::Public), m_anonymous(false) {}
+ ~_EnumModelItem();
+
+ CodeModel::AccessPolicy accessPolicy() const;
+ void setAccessPolicy(CodeModel::AccessPolicy accessPolicy);
+
+ EnumeratorList enumerators() const;
+ void addEnumerator(EnumeratorModelItem item);
+ bool isAnonymous() const;
+ void setAnonymous(bool anonymous);
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const Q_DECL_OVERRIDE;
+#endif
+
+private:
+ CodeModel::AccessPolicy m_accessPolicy;
+ EnumeratorList m_enumerators;
+ bool m_anonymous;
+};
+
+class _EnumeratorModelItem: public _CodeModelItem
+{
+public:
+ DECLARE_MODEL_NODE(Enumerator)
+
+ explicit _EnumeratorModelItem(CodeModel *model, int kind = __node_kind)
+ : _CodeModelItem(model, kind) {}
+ explicit _EnumeratorModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _CodeModelItem(model, name, kind) {}
+ ~_EnumeratorModelItem();
+
+ QString value() const;
+ void setValue(const QString &value);
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const Q_DECL_OVERRIDE;
+#endif
+
+private:
+ QString m_value;
+};
+
+class _TemplateParameterModelItem: public _CodeModelItem
+{
+public:
+ DECLARE_MODEL_NODE(TemplateParameter)
+
+ explicit _TemplateParameterModelItem(CodeModel *model, int kind = __node_kind)
+ : _CodeModelItem(model, kind), m_defaultValue(false) {}
+ explicit _TemplateParameterModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
+ : _CodeModelItem(model, name, kind), m_defaultValue(false) {}
+ ~_TemplateParameterModelItem();
+
+ TypeInfo type() const;
+ void setType(const TypeInfo &type);
+
+ bool defaultValue() const;
+ void setDefaultValue(bool defaultValue);
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const Q_DECL_OVERRIDE;
+#endif
+
+private:
+ TypeInfo m_type;
+ bool m_defaultValue;
+};
+
+#endif // CODEMODEL_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel_enums.h b/sources/shiboken2/ApiExtractor/parser/codemodel_enums.h
new file mode 100644
index 000000000..aa8b051d8
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel_enums.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CODEMODEL_ENUMS_H
+#define CODEMODEL_ENUMS_H
+
+enum ReferenceType {
+ NoReference,
+ LValueReference,
+ RValueReference
+};
+
+#endif // CODEMODEL_ENUMS_H
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel_finder.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel_finder.cpp
new file mode 100644
index 000000000..57f8ae0cf
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel_finder.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "codemodel_finder.h"
+#include "codemodel.h"
+#include "binder.h"
+
+CodeModelFinder::CodeModelFinder(CodeModel *model, Binder *binder)
+ : _M_model(model),
+ _M_binder(binder),
+ _M_token_stream(binder->tokenStream()),
+ name_cc(_M_binder),
+ _M_resolve_policy(ResolveItem)
+{
+}
+
+CodeModelFinder::~CodeModelFinder()
+{
+}
+
+ScopeModelItem CodeModelFinder::resolveScope(NameAST *name, ScopeModelItem scope)
+{
+ Q_ASSERT(scope);
+
+ ResolvePolicy saved_resolve_policy = _M_resolve_policy;
+ _M_resolve_policy = ResolveScope;
+
+ ScopeModelItem old = changeCurrentScope(scope);
+
+ visit(name);
+ ScopeModelItem result = _M_current_scope;
+
+ changeCurrentScope(old); // restore
+
+ _M_resolve_policy = saved_resolve_policy;
+
+ return result;
+}
+
+ScopeModelItem CodeModelFinder::changeCurrentScope(ScopeModelItem scope)
+{
+ ScopeModelItem old = _M_current_scope;
+ _M_current_scope = scope;
+ return old;
+}
+
+void CodeModelFinder::visitName(NameAST *node)
+{
+ visitNodes(this, node->qualified_names);
+
+ if (_M_resolve_policy == ResolveItem)
+ visit(node->unqualified_name);
+}
+
+void CodeModelFinder::visitUnqualifiedName(UnqualifiedNameAST *node)
+{
+ if (!_M_current_scope) {
+ // nothing to do
+ return;
+ }
+
+ name_cc.run(node);
+ QString id = name_cc.name();
+
+ if (ClassModelItem klass = _M_current_scope->findClass(id)) {
+ _M_current_scope = klass;
+ } else if (NamespaceModelItem parentNamespace = qSharedPointerDynamicCast<_NamespaceModelItem>(_M_current_scope)) {
+ NamespaceModelItem ns = parentNamespace->findNamespace(id);
+ _M_current_scope = ns;
+ } else if (FileModelItem file = qSharedPointerDynamicCast<_FileModelItem>(_M_current_scope)) {
+ NamespaceModelItem ns = file->findNamespace(id);
+ _M_current_scope = ns;
+ }
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
+
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel_finder.h b/sources/shiboken2/ApiExtractor/parser/codemodel_finder.h
new file mode 100644
index 000000000..0217cbac6
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel_finder.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef CODEMODEL_FINDER_H
+#define CODEMODEL_FINDER_H
+
+#include <default_visitor.h>
+#include <codemodel_fwd.h>
+#include <name_compiler.h>
+
+class TokenStream;
+class Binder;
+
+class CodeModelFinder: protected DefaultVisitor
+{
+ enum ResolvePolicy {
+ ResolveScope,
+ ResolveItem
+ };
+
+public:
+ CodeModelFinder(CodeModel *model, Binder *binder);
+ virtual ~CodeModelFinder();
+
+ ScopeModelItem resolveScope(NameAST *name, ScopeModelItem scope);
+
+ inline CodeModel *model() const
+ {
+ return _M_model;
+ }
+
+protected:
+ virtual void visitName(NameAST *node);
+ virtual void visitUnqualifiedName(UnqualifiedNameAST *node);
+
+ ScopeModelItem changeCurrentScope(ScopeModelItem scope);
+
+private:
+ CodeModel *_M_model;
+ Binder *_M_binder;
+ TokenStream *_M_token_stream;
+ NameCompiler name_cc;
+
+ ScopeModelItem _M_current_scope;
+ ResolvePolicy _M_resolve_policy;
+};
+
+#endif // CODEMODEL_FINDER_H
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel_fwd.h b/sources/shiboken2/ApiExtractor/parser/codemodel_fwd.h
new file mode 100644
index 000000000..676bda872
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel_fwd.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef CODEMODEL_FWD_H
+#define CODEMODEL_FWD_H
+
+#include <QtCore/QList>
+#include <QtCore/QSharedPointer>
+
+// forward declarations
+class CodeModel;
+class _ArgumentModelItem;
+class _ClassModelItem;
+class _CodeModelItem;
+class _EnumModelItem;
+class _EnumeratorModelItem;
+class _FileModelItem;
+class _FunctionModelItem;
+class _NamespaceModelItem;
+class _ScopeModelItem;
+class _TemplateParameterModelItem;
+class _TypeDefModelItem;
+class _VariableModelItem;
+class _MemberModelItem;
+class TypeInfo;
+
+typedef QSharedPointer<_ArgumentModelItem> ArgumentModelItem;
+typedef QSharedPointer<_ClassModelItem> ClassModelItem;
+typedef QSharedPointer<_CodeModelItem> CodeModelItem;
+typedef QSharedPointer<_EnumModelItem> EnumModelItem;
+typedef QSharedPointer<_EnumeratorModelItem> EnumeratorModelItem;
+typedef QSharedPointer<_FileModelItem> FileModelItem;
+typedef QSharedPointer<_FunctionModelItem> FunctionModelItem;
+typedef QSharedPointer<_NamespaceModelItem> NamespaceModelItem;
+typedef QSharedPointer<_ScopeModelItem> ScopeModelItem;
+typedef QSharedPointer<_TemplateParameterModelItem> TemplateParameterModelItem;
+typedef QSharedPointer<_TypeDefModelItem> TypeDefModelItem;
+typedef QSharedPointer<_VariableModelItem> VariableModelItem;
+typedef QSharedPointer<_MemberModelItem> MemberModelItem;
+
+typedef QList<ArgumentModelItem> ArgumentList;
+typedef QList<ClassModelItem> ClassList;
+typedef QList<CodeModelItem> ItemList;
+typedef QList<EnumModelItem> EnumList;
+typedef QList<EnumeratorModelItem> EnumeratorList;
+typedef QList<FileModelItem> FileList;
+typedef QList<FunctionModelItem> FunctionList;
+typedef QList<NamespaceModelItem> NamespaceList;
+typedef QList<ScopeModelItem> ScopeList;
+typedef QList<TemplateParameterModelItem> TemplateParameterList;
+typedef QList<TypeDefModelItem> TypeDefList;
+typedef QList<VariableModelItem> VariableList;
+typedef QList<MemberModelItem> MemberList;
+
+#endif // CODEMODEL_FWD_H
diff --git a/sources/shiboken2/ApiExtractor/parser/compiler_utils.cpp b/sources/shiboken2/ApiExtractor/parser/compiler_utils.cpp
new file mode 100644
index 000000000..95a9db6c3
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/compiler_utils.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "compiler_utils.h"
+#include "type_compiler.h"
+#include "name_compiler.h"
+#include "declarator_compiler.h"
+#include "ast.h"
+#include "binder.h"
+
+TypeInfo CompilerUtils::typeDescription(TypeSpecifierAST *type_specifier, DeclaratorAST *declarator, Binder *binder)
+{
+ TypeCompiler type_cc(binder);
+ DeclaratorCompiler decl_cc(binder);
+
+ type_cc.run(type_specifier);
+ decl_cc.run(declarator);
+
+ TypeInfo typeInfo;
+ typeInfo.setQualifiedName(type_cc.qualifiedName());
+ typeInfo.setConstant(type_cc.isConstant());
+ typeInfo.setVolatile(type_cc.isVolatile());
+ typeInfo.setReferenceType(decl_cc.isReference() ? LValueReference : NoReference);
+ typeInfo.setIndirections(decl_cc.indirection());
+ typeInfo.setArrayElements(decl_cc.arrayElements());
+
+ return typeInfo;
+}
diff --git a/sources/shiboken2/ApiExtractor/parser/compiler_utils.h b/sources/shiboken2/ApiExtractor/parser/compiler_utils.h
new file mode 100644
index 000000000..849baf5aa
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/compiler_utils.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef COMPILER_UTILS_H
+#define COMPILER_UTILS_H
+
+#include <utility>
+
+#include "codemodel.h"
+
+struct TypeSpecifierAST;
+struct DeclaratorAST;
+class TokenStream;
+class Binder;
+
+namespace CompilerUtils
+{
+
+TypeInfo typeDescription(TypeSpecifierAST *type_specifier, DeclaratorAST *declarator, Binder *binder);
+
+} // namespace CompilerUtils
+
+#endif // COMPILER_UTILS_H
diff --git a/sources/shiboken2/ApiExtractor/parser/control.cpp b/sources/shiboken2/ApiExtractor/parser/control.cpp
new file mode 100644
index 000000000..f86fa16bb
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/control.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "control.h"
+#include "lexer.h"
+
+Control::Control()
+ : current_context(0),
+ _M_skipFunctionBody(false),
+ _M_lexer(0),
+ _M_parser(0)
+{
+ pushContext();
+
+ declareTypedef(findOrInsertName("__builtin_va_list",
+ strlen("__builtin_va_list")), 0);
+}
+
+Control::~Control()
+{
+ popContext();
+
+ Q_ASSERT(current_context == 0);
+}
+
+Lexer *Control::changeLexer(Lexer *lexer)
+{
+ Lexer *old = _M_lexer;
+ _M_lexer = lexer;
+ return old;
+}
+
+Parser *Control::changeParser(Parser *parser)
+{
+ Parser *old = _M_parser;
+ _M_parser = parser;
+ return old;
+}
+
+Type *Control::lookupType(const NameSymbol *name) const
+{
+ Q_ASSERT(current_context != 0);
+
+ return current_context->resolve(name);
+}
+
+void Control::declare(const NameSymbol *name, Type *type)
+{
+ //printf("*** Declare:");
+ //printSymbol(name);
+ //putchar('\n');
+ Q_ASSERT(current_context != 0);
+
+ current_context->bind(name, type);
+}
+
+void Control::pushContext()
+{
+ // printf("+Context\n");
+ Context *new_context = new Context;
+ new_context->parent = current_context;
+ current_context = new_context;
+}
+
+void Control::popContext()
+{
+ // printf("-Context\n");
+ Q_ASSERT(current_context != 0);
+
+ Context *old_context = current_context;
+ current_context = current_context->parent;
+
+ delete old_context;
+}
+
+void Control::declareTypedef(const NameSymbol *name, Declarator *d)
+{
+ // printf("declared typedef:");
+ // printSymbol(name);
+ // printf("\n");
+ stl_typedef_table.insert(name, d);
+}
+
+bool Control::isTypedef(const NameSymbol *name) const
+{
+ // printf("is typedef:");
+ // printSymbol(name);
+ // printf("= %d\n", (stl_typedef_table.find(name) != stl_typedef_table.end()));
+
+ return stl_typedef_table.contains(name);
+}
+
+QList<Control::ErrorMessage> Control::errorMessages() const
+{
+ return _M_error_messages;
+}
+
+void Control::clearErrorMessages()
+{
+ _M_error_messages.clear();
+}
+
+void Control::reportError(const ErrorMessage &errmsg)
+{
+ _M_error_messages.append(errmsg);
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/control.h b/sources/shiboken2/ApiExtractor/parser/control.h
new file mode 100644
index 000000000..92635299e
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/control.h
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef CONTROL_H
+#define CONTROL_H
+
+#include "symbol.h"
+#include "smallobject.h"
+
+#include <QtCore/QHash>
+
+struct Declarator;
+struct Type;
+class Lexer;
+class Parser;
+
+struct Context {
+ Context *parent;
+
+ inline void bind(const NameSymbol *name, Type *type) {
+ symbol_table.insert(name, type);
+ }
+
+ inline Type *resolve(const NameSymbol *name) const {
+ if (Type *type = symbol_table.value(name))
+ return type;
+ else if (parent)
+ return parent->resolve(name);
+
+ return 0;
+ }
+
+ typedef QHash<const NameSymbol*, Type*> symbol_table_t;
+
+ symbol_table_t symbol_table;
+};
+
+class Control
+{
+public:
+ class ErrorMessage
+ {
+ public:
+ ErrorMessage():
+ _M_line(0),
+ _M_column(0) {}
+
+ inline int line() const {
+ return _M_line;
+ }
+ inline void setLine(int line) {
+ _M_line = line;
+ }
+
+ inline int column() const {
+ return _M_column;
+ }
+ inline void setColumn(int column) {
+ _M_column = column;
+ }
+
+ inline QString fileName() const {
+ return _M_fileName;
+ }
+ inline void setFileName(const QString &fileName) {
+ _M_fileName = fileName;
+ }
+
+ inline QString message() const {
+ return _M_message;
+ }
+ inline void setMessage(const QString &message) {
+ _M_message = message;
+ }
+
+ private:
+ int _M_line;
+ int _M_column;
+ QString _M_fileName;
+ QString _M_message;
+ };
+
+ Control();
+ ~Control();
+
+ inline bool skipFunctionBody() const {
+ return _M_skipFunctionBody;
+ }
+ inline void setSkipFunctionBody(bool skip) {
+ _M_skipFunctionBody = skip;
+ }
+
+ Lexer *changeLexer(Lexer *lexer);
+ Parser *changeParser(Parser *parser);
+
+ Lexer *currentLexer() const {
+ return _M_lexer;
+ }
+ Parser *currentParser() const {
+ return _M_parser;
+ }
+
+ Context *current_context;
+
+ inline Context *currentContext() const {
+ return current_context;
+ }
+
+ void pushContext();
+ void popContext();
+
+ Type *lookupType(const NameSymbol *name) const;
+ void declare(const NameSymbol *name, Type *type);
+
+ inline const NameSymbol *findOrInsertName(const char *data, size_t count) {
+ return name_table.findOrInsert(data, count);
+ }
+
+ void declareTypedef(const NameSymbol *name, Declarator *d);
+ bool isTypedef(const NameSymbol *name) const;
+
+ void reportError(const ErrorMessage &errmsg);
+ QList<ErrorMessage> errorMessages() const;
+ void clearErrorMessages();
+
+private:
+ NameTable name_table;
+ QHash<const NameSymbol*, Declarator*> stl_typedef_table;
+ bool _M_skipFunctionBody;
+ Lexer *_M_lexer;
+ Parser *_M_parser;
+
+ QList<ErrorMessage> _M_error_messages;
+};
+
+#endif // CONTROL_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/declarator_compiler.cpp b/sources/shiboken2/ApiExtractor/parser/declarator_compiler.cpp
new file mode 100644
index 000000000..e27ea5842
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/declarator_compiler.cpp
@@ -0,0 +1,167 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "declarator_compiler.h"
+#include "name_compiler.h"
+#include "type_compiler.h"
+#include "compiler_utils.h"
+#include "lexer.h"
+#include "binder.h"
+#include "tokens.h"
+
+#include <qdebug.h>
+
+DeclaratorCompiler::DeclaratorCompiler(Binder *binder)
+ : _M_binder(binder), _M_token_stream(binder->tokenStream())
+{
+}
+
+void DeclaratorCompiler::run(DeclaratorAST *node)
+{
+ _M_id.clear();
+ _M_parameters.clear();
+ _M_array.clear();
+ _M_function = false;
+ _M_reference = false;
+ _M_variadics = false;
+ _M_indirection = 0;
+
+ if (node) {
+ NameCompiler name_cc(_M_binder);
+
+ DeclaratorAST *decl = node;
+ while (decl && decl->sub_declarator)
+ decl = decl->sub_declarator;
+
+ Q_ASSERT(decl != 0);
+
+ name_cc.run(decl->id);
+ _M_id = name_cc.name();
+ _M_function = (node->parameter_declaration_clause != 0);
+ if (node->parameter_declaration_clause && node->parameter_declaration_clause->ellipsis)
+ _M_variadics = true;
+
+ visitNodes(this, node->ptr_ops);
+ visit(node->parameter_declaration_clause);
+
+ if (const ListNode<ExpressionAST*> *it = node->array_dimensions) {
+ it->toFront();
+ const ListNode<ExpressionAST*> *end = it;
+
+ do {
+ QString elt;
+ if (ExpressionAST *expr = it->element) {
+ const Token &start_token = _M_token_stream->token((int) expr->start_token);
+ const Token &end_token = _M_token_stream->token((int) expr->end_token);
+
+ elt += QString::fromUtf8(&start_token.text[start_token.position],
+ (int)(end_token.position - start_token.position)).trimmed();
+ }
+
+ _M_array.append(elt);
+
+ it = it->next;
+ } while (it != end);
+ }
+ }
+}
+
+void DeclaratorCompiler::visitPtrOperator(PtrOperatorAST *node)
+{
+ std::size_t op = _M_token_stream->kind(node->op);
+
+ switch (op) {
+ case '&':
+ _M_reference = true;
+ break;
+ case '*':
+ ++_M_indirection;
+ break;
+
+ default:
+ break;
+ }
+
+ if (node->mem_ptr) {
+#if defined(__GNUC__)
+#warning "ptr to mem -- not implemented"
+#endif
+ }
+}
+
+void DeclaratorCompiler::visitParameterDeclaration(ParameterDeclarationAST *node)
+{
+ Parameter p;
+ DeclaratorCompiler decl_cc(_M_binder);
+
+ // Find the innermost declarator, to extract the name / id of the declaration.
+ DeclaratorAST *declarator = node->declarator;
+ while (declarator && declarator->sub_declarator)
+ declarator = declarator->sub_declarator;
+ decl_cc.run(declarator);
+ p.name = decl_cc.id();
+
+ // Use the original declarator to extract the type.
+ p.type = CompilerUtils::typeDescription(node->type_specifier, node->declarator, _M_binder);
+
+ // In case if the declarator is a function pointer, extract the arguments of the declarator
+ // parameter clause. This only works for top-declarator function pointers, it will fail to
+ // determine nested function pointers.
+ if (declarator != node->declarator
+ && node->declarator->parameter_declaration_clause) {
+ p.type.setFunctionPointer(true);
+ decl_cc.run(node->declarator);
+ foreach (const DeclaratorCompiler::Parameter &innerParam, decl_cc.parameters())
+ p.type.addArgument(innerParam.type);
+ }
+
+ if (node->expression != 0) {
+ const Token &start = _M_token_stream->token((int) node->expression->start_token);
+ const Token &end = _M_token_stream->token((int) node->expression->end_token);
+ int length = (int)(end.position - start.position);
+
+ p.defaultValueExpression = QString();
+ QString source = QString::fromUtf8(&start.text[start.position], length).trimmed();
+ QStringList list = source.split(QLatin1Char('\n'));
+
+
+ for (int i = 0; i < list.size(); ++i) {
+ if (!list.at(i).startsWith(QLatin1Char('#')))
+ p.defaultValueExpression += list.at(i).trimmed();
+ }
+
+ p.defaultValue = p.defaultValueExpression.size() > 0;
+
+ }
+
+ _M_parameters.append(p);
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/declarator_compiler.h b/sources/shiboken2/ApiExtractor/parser/declarator_compiler.h
new file mode 100644
index 000000000..f67bd4672
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/declarator_compiler.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef DECLARATOR_COMPILER_H
+#define DECLARATOR_COMPILER_H
+
+#include "default_visitor.h"
+#include "codemodel.h"
+
+#include <QtCore/QString>
+#include <QtCore/QList>
+
+class TokenStream;
+class Binder;
+
+class DeclaratorCompiler: protected DefaultVisitor
+{
+public:
+ struct Parameter {
+ TypeInfo type;
+ QString name;
+ QString defaultValueExpression;
+ bool defaultValue;
+
+ Parameter(): defaultValue(false) {}
+ };
+
+public:
+ DeclaratorCompiler(Binder *binder);
+
+ void run(DeclaratorAST *node);
+
+ inline QString id() const {
+ return _M_id;
+ }
+ inline QStringList arrayElements() const {
+ return _M_array;
+ }
+ inline bool isFunction() const {
+ return _M_function;
+ }
+ inline bool isVariadics() const {
+ return _M_variadics;
+ }
+ inline bool isReference() const {
+ return _M_reference;
+ }
+ inline int indirection() const {
+ return _M_indirection;
+ }
+ inline QList<Parameter> parameters() const {
+ return _M_parameters;
+ }
+
+protected:
+ virtual void visitPtrOperator(PtrOperatorAST *node);
+ virtual void visitParameterDeclaration(ParameterDeclarationAST *node);
+
+private:
+ Binder *_M_binder;
+ TokenStream *_M_token_stream;
+
+ bool _M_function;
+ bool _M_reference;
+ bool _M_variadics;
+ int _M_indirection;
+ QString _M_id;
+ QStringList _M_array;
+ QList<Parameter> _M_parameters;
+};
+
+#endif // DECLARATOR_COMPILER_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/default_visitor.cpp b/sources/shiboken2/ApiExtractor/parser/default_visitor.cpp
new file mode 100644
index 000000000..e330abcbb
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/default_visitor.cpp
@@ -0,0 +1,464 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "default_visitor.h"
+
+void DefaultVisitor::visitAccessSpecifier(AccessSpecifierAST *)
+{
+ // nothing to do
+}
+
+void DefaultVisitor::visitAsmDefinition(AsmDefinitionAST *)
+{
+ // nothing to do
+}
+
+void DefaultVisitor::visitBaseClause(BaseClauseAST *node)
+{
+ visitNodes(this, node->base_specifiers);
+}
+
+void DefaultVisitor::visitBaseSpecifier(BaseSpecifierAST *node)
+{
+ visit(node->name);
+}
+
+void DefaultVisitor::visitBinaryExpression(BinaryExpressionAST *node)
+{
+ visit(node->left_expression);
+ visit(node->right_expression);
+}
+
+void DefaultVisitor::visitCastExpression(CastExpressionAST *node)
+{
+ visit(node->type_id);
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitClassMemberAccess(ClassMemberAccessAST *node)
+{
+ visit(node->name);
+}
+
+void DefaultVisitor::visitClassSpecifier(ClassSpecifierAST *node)
+{
+ visit(node->win_decl_specifiers);
+ visit(node->name);
+ visit(node->base_clause);
+ visitNodes(this, node->member_specs);
+}
+
+void DefaultVisitor::visitCompoundStatement(CompoundStatementAST *node)
+{
+ visitNodes(this, node->statements);
+}
+
+void DefaultVisitor::visitCondition(ConditionAST *node)
+{
+ visit(node->type_specifier);
+ visit(node->declarator);
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitConditionalExpression(ConditionalExpressionAST *node)
+{
+ visit(node->condition);
+ visit(node->left_expression);
+ visit(node->right_expression);
+}
+
+void DefaultVisitor::visitCppCastExpression(CppCastExpressionAST *node)
+{
+ visit(node->type_id);
+ visit(node->expression);
+ visitNodes(this, node->sub_expressions);
+}
+
+void DefaultVisitor::visitCtorInitializer(CtorInitializerAST *node)
+{
+ visitNodes(this, node->member_initializers);
+}
+
+void DefaultVisitor::visitDeclarationStatement(DeclarationStatementAST *node)
+{
+ visit(node->declaration);
+}
+
+void DefaultVisitor::visitDeclarator(DeclaratorAST *node)
+{
+ visit(node->sub_declarator);
+ visitNodes(this, node->ptr_ops);
+ visit(node->id);
+ visit(node->bit_expression);
+ visitNodes(this, node->array_dimensions);
+ visit(node->parameter_declaration_clause);
+ visit(node->exception_spec);
+}
+
+void DefaultVisitor::visitDeleteExpression(DeleteExpressionAST *node)
+{
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitDoStatement(DoStatementAST *node)
+{
+ visit(node->statement);
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *node)
+{
+ visit(node->name);
+}
+
+void DefaultVisitor::visitEnumSpecifier(EnumSpecifierAST *node)
+{
+ visit(node->name);
+ visitNodes(this, node->enumerators);
+}
+
+void DefaultVisitor::visitEnumerator(EnumeratorAST *node)
+{
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitExceptionSpecification(ExceptionSpecificationAST *node)
+{
+ visitNodes(this, node->type_ids);
+}
+
+void DefaultVisitor::visitExpressionOrDeclarationStatement(ExpressionOrDeclarationStatementAST *node)
+{
+ visit(node->expression);
+ visit(node->declaration);
+}
+
+void DefaultVisitor::visitExpressionStatement(ExpressionStatementAST *node)
+{
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitForStatement(ForStatementAST *node)
+{
+ visit(node->init_statement);
+ visit(node->condition);
+ visit(node->expression);
+ visit(node->statement);
+}
+
+void DefaultVisitor::visitFunctionCall(FunctionCallAST *node)
+{
+ visit(node->arguments);
+}
+
+void DefaultVisitor::visitFunctionDefinition(FunctionDefinitionAST *node)
+{
+ visit(node->type_specifier);
+ visit(node->init_declarator);
+ visit(node->function_body);
+ visit(node->win_decl_specifiers);
+}
+
+void DefaultVisitor::visitIfStatement(IfStatementAST *node)
+{
+ visit(node->condition);
+ visit(node->statement);
+ visit(node->else_statement);
+}
+
+void DefaultVisitor::visitIncrDecrExpression(IncrDecrExpressionAST *)
+{
+ // nothing to do
+}
+
+void DefaultVisitor::visitInitDeclarator(InitDeclaratorAST *node)
+{
+ visit(node->declarator);
+ visit(node->initializer);
+}
+
+void DefaultVisitor::visitInitializer(InitializerAST *node)
+{
+ visit(node->initializer_clause);
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitInitializerClause(InitializerClauseAST *node)
+{
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitLabeledStatement(LabeledStatementAST *)
+{
+ // nothing to do
+}
+
+void DefaultVisitor::visitLinkageBody(LinkageBodyAST *node)
+{
+ visitNodes(this, node->declarations);
+}
+
+void DefaultVisitor::visitLinkageSpecification(LinkageSpecificationAST *node)
+{
+ visit(node->linkage_body);
+ visit(node->declaration);
+}
+
+void DefaultVisitor::visitMemInitializer(MemInitializerAST *node)
+{
+ visit(node->initializer_id);
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitName(NameAST *node)
+{
+ visitNodes(this, node->qualified_names);
+ visit(node->unqualified_name);
+}
+
+void DefaultVisitor::visitNamespace(NamespaceAST *node)
+{
+ visit(node->linkage_body);
+}
+
+void DefaultVisitor::visitNamespaceAliasDefinition(NamespaceAliasDefinitionAST *node)
+{
+ visit(node->alias_name);
+}
+
+void DefaultVisitor::visitNewDeclarator(NewDeclaratorAST *node)
+{
+ visit(node->ptr_op);
+ visit(node->sub_declarator);
+ visitNodes(this, node->expressions);
+}
+
+void DefaultVisitor::visitNewExpression(NewExpressionAST *node)
+{
+ visit(node->expression);
+ visit(node->type_id);
+ visit(node->new_type_id);
+ visit(node->new_initializer);
+}
+
+void DefaultVisitor::visitNewInitializer(NewInitializerAST *node)
+{
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitNewTypeId(NewTypeIdAST *node)
+{
+ visit(node->type_specifier);
+ visit(node->new_initializer);
+ visit(node->new_declarator);
+}
+
+void DefaultVisitor::visitOperator(OperatorAST *)
+{
+ // nothing to do
+}
+
+void DefaultVisitor::visitOperatorFunctionId(OperatorFunctionIdAST *node)
+{
+ visit(node->op);
+ visit(node->type_specifier);
+ visitNodes(this, node->ptr_ops);
+}
+
+void DefaultVisitor::visitParameterDeclaration(ParameterDeclarationAST *node)
+{
+ visit(node->type_specifier);
+ visit(node->declarator);
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitParameterDeclarationClause(ParameterDeclarationClauseAST *node)
+{
+ visitNodes(this, node->parameter_declarations);
+}
+
+void DefaultVisitor::visitPostfixExpression(PostfixExpressionAST *node)
+{
+ visit(node->type_specifier);
+ visit(node->expression);
+ visitNodes(this, node->sub_expressions);
+}
+
+void DefaultVisitor::visitPrimaryExpression(PrimaryExpressionAST *node)
+{
+ visit(node->literal);
+ visit(node->expression_statement);
+ visit(node->sub_expression);
+ visit(node->name);
+}
+
+void DefaultVisitor::visitPtrOperator(PtrOperatorAST *node)
+{
+ visit(node->mem_ptr);
+}
+
+void DefaultVisitor::visitPtrToMember(PtrToMemberAST *)
+{
+ // nothing to do
+}
+
+void DefaultVisitor::visitReturnStatement(ReturnStatementAST *node)
+{
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitSimpleDeclaration(SimpleDeclarationAST *node)
+{
+ visit(node->type_specifier);
+ visitNodes(this, node->init_declarators);
+ visit(node->win_decl_specifiers);
+}
+
+void DefaultVisitor::visitSimpleTypeSpecifier(SimpleTypeSpecifierAST *node)
+{
+ visit(node->name);
+ visit(node->type_id);
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitSizeofExpression(SizeofExpressionAST *node)
+{
+ visit(node->type_id);
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitStringLiteral(StringLiteralAST *)
+{
+ // nothing to do
+}
+
+void DefaultVisitor::visitSubscriptExpression(SubscriptExpressionAST *node)
+{
+ visit(node->subscript);
+}
+
+void DefaultVisitor::visitSwitchStatement(SwitchStatementAST *node)
+{
+ visit(node->condition);
+ visit(node->statement);
+}
+
+void DefaultVisitor::visitTemplateArgument(TemplateArgumentAST *node)
+{
+ visit(node->type_id);
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitTemplateDeclaration(TemplateDeclarationAST *node)
+{
+ visitNodes(this, node->template_parameters);
+ visit(node->declaration);
+}
+
+void DefaultVisitor::visitTemplateParameter(TemplateParameterAST *node)
+{
+ visit(node->type_parameter);
+ visit(node->parameter_declaration);
+}
+
+void DefaultVisitor::visitThrowExpression(ThrowExpressionAST *node)
+{
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitTranslationUnit(TranslationUnitAST *node)
+{
+ visitNodes(this, node->declarations);
+}
+
+void DefaultVisitor::visitTryBlockStatement(TryBlockStatementAST *)
+{
+ // nothing to do
+}
+
+void DefaultVisitor::visitTypeId(TypeIdAST *node)
+{
+ visit(node->type_specifier);
+ visit(node->declarator);
+}
+
+void DefaultVisitor::visitTypeIdentification(TypeIdentificationAST *node)
+{
+ visit(node->name);
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitTypeParameter(TypeParameterAST *node)
+{
+ visit(node->name);
+ visit(node->type_id);
+ visitNodes(this, node->template_parameters);
+ visit(node->template_name);
+}
+
+void DefaultVisitor::visitTypedef(TypedefAST *node)
+{
+ visit(node->type_specifier);
+ visitNodes(this, node->init_declarators);
+}
+
+void DefaultVisitor::visitUnaryExpression(UnaryExpressionAST *node)
+{
+ visit(node->expression);
+}
+
+void DefaultVisitor::visitUnqualifiedName(UnqualifiedNameAST *node)
+{
+ visit(node->operator_id);
+ visitNodes(this, node->template_arguments);
+}
+
+void DefaultVisitor::visitUsing(UsingAST *node)
+{
+ visit(node->name);
+}
+
+void DefaultVisitor::visitUsingDirective(UsingDirectiveAST *node)
+{
+ visit(node->name);
+}
+
+void DefaultVisitor::visitWhileStatement(WhileStatementAST *node)
+{
+ visit(node->condition);
+ visit(node->statement);
+}
+
+void DefaultVisitor::visitWinDeclSpec(WinDeclSpecAST *)
+{
+ // nothing to do
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/default_visitor.h b/sources/shiboken2/ApiExtractor/parser/default_visitor.h
new file mode 100644
index 000000000..1eef8cc85
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/default_visitor.h
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef DEFAULT_VISITOR_H
+#define DEFAULT_VISITOR_H
+
+#include "visitor.h"
+
+class DefaultVisitor: public Visitor
+{
+public:
+ DefaultVisitor() {}
+
+protected:
+ virtual void visitAccessSpecifier(AccessSpecifierAST *);
+ virtual void visitAsmDefinition(AsmDefinitionAST *);
+ virtual void visitBaseClause(BaseClauseAST *);
+ virtual void visitBaseSpecifier(BaseSpecifierAST *);
+ virtual void visitBinaryExpression(BinaryExpressionAST *);
+ virtual void visitCastExpression(CastExpressionAST *);
+ virtual void visitClassMemberAccess(ClassMemberAccessAST *);
+ virtual void visitClassSpecifier(ClassSpecifierAST *);
+ virtual void visitCompoundStatement(CompoundStatementAST *);
+ virtual void visitCondition(ConditionAST *);
+ virtual void visitConditionalExpression(ConditionalExpressionAST *);
+ virtual void visitCppCastExpression(CppCastExpressionAST *);
+ virtual void visitCtorInitializer(CtorInitializerAST *);
+ virtual void visitDeclarationStatement(DeclarationStatementAST *);
+ virtual void visitDeclarator(DeclaratorAST *);
+ virtual void visitDeleteExpression(DeleteExpressionAST *);
+ virtual void visitDoStatement(DoStatementAST *);
+ virtual void visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *);
+ virtual void visitEnumSpecifier(EnumSpecifierAST *);
+ virtual void visitEnumerator(EnumeratorAST *);
+ virtual void visitExceptionSpecification(ExceptionSpecificationAST *);
+ virtual void visitExpressionOrDeclarationStatement(ExpressionOrDeclarationStatementAST *);
+ virtual void visitExpressionStatement(ExpressionStatementAST *);
+ virtual void visitForStatement(ForStatementAST *);
+ virtual void visitFunctionCall(FunctionCallAST *);
+ virtual void visitFunctionDefinition(FunctionDefinitionAST *);
+ virtual void visitIfStatement(IfStatementAST *);
+ virtual void visitIncrDecrExpression(IncrDecrExpressionAST *);
+ virtual void visitInitDeclarator(InitDeclaratorAST *);
+ virtual void visitInitializer(InitializerAST *);
+ virtual void visitInitializerClause(InitializerClauseAST *);
+ virtual void visitLabeledStatement(LabeledStatementAST *);
+ virtual void visitLinkageBody(LinkageBodyAST *);
+ virtual void visitLinkageSpecification(LinkageSpecificationAST *);
+ virtual void visitMemInitializer(MemInitializerAST *);
+ virtual void visitName(NameAST *);
+ virtual void visitNamespace(NamespaceAST *);
+ virtual void visitNamespaceAliasDefinition(NamespaceAliasDefinitionAST *);
+ virtual void visitNewDeclarator(NewDeclaratorAST *);
+ virtual void visitNewExpression(NewExpressionAST *);
+ virtual void visitNewInitializer(NewInitializerAST *);
+ virtual void visitNewTypeId(NewTypeIdAST *);
+ virtual void visitOperator(OperatorAST *);
+ virtual void visitOperatorFunctionId(OperatorFunctionIdAST *);
+ virtual void visitParameterDeclaration(ParameterDeclarationAST *);
+ virtual void visitParameterDeclarationClause(ParameterDeclarationClauseAST *);
+ virtual void visitPostfixExpression(PostfixExpressionAST *);
+ virtual void visitPrimaryExpression(PrimaryExpressionAST *);
+ virtual void visitPtrOperator(PtrOperatorAST *);
+ virtual void visitPtrToMember(PtrToMemberAST *);
+ virtual void visitReturnStatement(ReturnStatementAST *);
+ virtual void visitSimpleDeclaration(SimpleDeclarationAST *);
+ virtual void visitSimpleTypeSpecifier(SimpleTypeSpecifierAST *);
+ virtual void visitSizeofExpression(SizeofExpressionAST *);
+ virtual void visitStringLiteral(StringLiteralAST *);
+ virtual void visitSubscriptExpression(SubscriptExpressionAST *);
+ virtual void visitSwitchStatement(SwitchStatementAST *);
+ virtual void visitTemplateArgument(TemplateArgumentAST *);
+ virtual void visitTemplateDeclaration(TemplateDeclarationAST *);
+ virtual void visitTemplateParameter(TemplateParameterAST *);
+ virtual void visitThrowExpression(ThrowExpressionAST *);
+ virtual void visitTranslationUnit(TranslationUnitAST *);
+ virtual void visitTryBlockStatement(TryBlockStatementAST *);
+ virtual void visitTypeId(TypeIdAST *);
+ virtual void visitTypeIdentification(TypeIdentificationAST *);
+ virtual void visitTypeParameter(TypeParameterAST *);
+ virtual void visitTypedef(TypedefAST *);
+ virtual void visitUnaryExpression(UnaryExpressionAST *);
+ virtual void visitUnqualifiedName(UnqualifiedNameAST *);
+ virtual void visitUsing(UsingAST *);
+ virtual void visitUsingDirective(UsingDirectiveAST *);
+ virtual void visitWhileStatement(WhileStatementAST *);
+ virtual void visitWinDeclSpec(WinDeclSpecAST *);
+
+private:
+ typedef void (Visitor::*visitor_fun_ptr)(AST *);
+ static visitor_fun_ptr _S_table[];
+};
+
+#endif // VISITOR_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/dumptree.cpp b/sources/shiboken2/ApiExtractor/parser/dumptree.cpp
new file mode 100644
index 000000000..0a7444c14
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/dumptree.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "dumptree.h"
+
+#include <QtCore/QString>
+#include <QtCore/qdebug.h>
+
+static char const * const names[] = {
+ 0,
+ "AccessSpecifier",
+ "AsmDefinition",
+ "BaseClause",
+ "BaseSpecifier",
+ "BinaryExpression",
+ "CastExpression",
+ "ClassMemberAccess",
+ "ClassSpecifier",
+ "CompoundStatement",
+ "Condition",
+ "ConditionalExpression",
+ "CppCastExpression",
+ "CtorInitializer",
+ "DeclarationStatement",
+ "Declarator",
+ "DeleteExpression",
+ "DoStatement",
+ "ElaboratedTypeSpecifier",
+ "EnumSpecifier",
+ "Enumerator",
+ "ExceptionSpecification",
+ "ExpressionOrDeclarationStatement",
+ "ExpressionStatement",
+ "ForStatement",
+ "FunctionCall",
+ "FunctionDefinition",
+ "IfStatement",
+ "IncrDecrExpression",
+ "InitDeclarator",
+ "Initializer",
+ "InitializerClause",
+ "LabeledStatement",
+ "LinkageBody",
+ "LinkageSpecification",
+ "MemInitializer",
+ "Name",
+ "Namespace",
+ "NamespaceAliasDefinition",
+ "NewDeclarator",
+ "NewExpression",
+ "NewInitializer",
+ "NewTypeId",
+ "Operator",
+ "OperatorFunctionId",
+ "ParameterDeclaration",
+ "ParameterDeclarationClause",
+ "PostfixExpression",
+ "PrimaryExpression",
+ "PtrOperator",
+ "PtrToMember",
+ "ReturnStatement",
+ "SimpleDeclaration",
+ "SimpleTypeSpecifier",
+ "SizeofExpression",
+ "StringLiteral",
+ "SubscriptExpression",
+ "SwitchStatement",
+ "TemplateArgument",
+ "TemplateDeclaration",
+ "TemplateParameter",
+ "ThrowExpression",
+ "TranslationUnit",
+ "TryBlockStatement",
+ "TypeId",
+ "TypeIdentification",
+ "TypeParameter",
+ "Typedef",
+ "UnaryExpression",
+ "UnqualifiedName",
+ "Using",
+ "UsingDirective",
+ "WhileStatement",
+ "WinDeclSpec"
+};
+
+DumpTree::DumpTree()
+{
+}
+
+void DumpTree::visit(AST *node)
+{
+ static int indent = 0;
+
+
+ if (node)
+ qDebug() << QByteArray(indent * 2, ' ').constData() << names[node->kind]
+ << '[' << node->start_token << ", " << node->end_token << ']';
+
+ ++indent;
+ DefaultVisitor::visit(node);
+ --indent;
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/dumptree.h b/sources/shiboken2/ApiExtractor/parser/dumptree.h
new file mode 100644
index 000000000..5d91c6ef1
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/dumptree.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef DUMPTREE_H
+#define DUMPTREE_H
+
+#include "default_visitor.h"
+
+class DumpTree: protected DefaultVisitor
+{
+public:
+ DumpTree();
+
+ void dump(AST *node) {
+ visit(node);
+ }
+
+protected:
+ virtual void visit(AST *node);
+};
+
+#endif // DUMPTREE_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/lexer.cpp b/sources/shiboken2/ApiExtractor/parser/lexer.cpp
new file mode 100644
index 000000000..3fcf3b561
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/lexer.cpp
@@ -0,0 +1,1726 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "lexer.h"
+#include "tokens.h"
+#include "control.h"
+
+#include <cctype>
+#include <iostream>
+
+scan_fun_ptr Lexer::s_scan_keyword_table[] = {
+ &Lexer::scanKeyword0, &Lexer::scanKeyword0,
+ &Lexer::scanKeyword2, &Lexer::scanKeyword3,
+ &Lexer::scanKeyword4, &Lexer::scanKeyword5,
+ &Lexer::scanKeyword6, &Lexer::scanKeyword7,
+ &Lexer::scanKeyword8, &Lexer::scanKeyword9,
+ &Lexer::scanKeyword10, &Lexer::scanKeyword11,
+ &Lexer::scanKeyword12, &Lexer::scanKeyword13,
+ &Lexer::scanKeyword14, &Lexer::scanKeyword0,
+ &Lexer::scanKeyword16
+};
+
+void LocationManager::extract_line(int offset, int *line, QString *filename) const
+{
+ *line = 0;
+ if (token_stream.size() < 1)
+ return;
+
+ const unsigned char *begin_buffer = reinterpret_cast<const unsigned char *>(token_stream[0].text);
+ const unsigned char *cursor = begin_buffer + offset;
+
+ ++cursor; // skip '#'
+ if (std::isspace(*cursor) && std::isdigit(*(cursor + 1))) {
+ ++cursor;
+ char buffer[1024], *cp = buffer;
+ do {
+ *cp++ = *cursor++;
+ } while (std::isdigit(*cursor));
+ *cp = '\0';
+ int l = strtol(buffer, 0, 0);
+
+ Q_ASSERT(std::isspace(*cursor));
+ ++cursor;
+
+ Q_ASSERT(*cursor == '"');
+ ++cursor;
+
+ cp = buffer;
+ while (*cursor && *cursor != '"') {
+ *cp++ = *cursor++;
+ }
+ *cp = '\0';
+ Q_ASSERT(*cursor == '"');
+ ++cursor;
+
+ *filename = QLatin1String(buffer);
+ *line = l;
+ // printf("filename: %s line: %d\n", buffer, line);
+ }
+}
+
+void LocationManager::positionAt(std::size_t offset, int *line, int *column,
+ QString *filename) const
+{
+ int ppline = 0;
+ int ppcolumn = 0;
+ line_table.positionAt(offset, &ppline, &ppcolumn);
+
+ int base_line = 0;
+ extract_line((int) line_table[ppline-1], &base_line, filename);
+
+ int line2 = 0;
+ int column2 = 0;
+ location_table.positionAt((int) line_table[ppline-1], &line2, &column2);
+
+ location_table.positionAt(offset, line, column);
+ *line = base_line + *line - line2 - 1;
+}
+
+scan_fun_ptr Lexer::s_scan_table[256];
+bool Lexer::s_initialized = false;
+
+void Lexer::tokenize(const char *contents, std::size_t size)
+{
+ if (!s_initialized)
+ initialize_scan_table();
+
+ token_stream.resize(1024);
+ token_stream[0].kind = Token_EOF;
+ token_stream[0].text = contents;
+
+ index = 1;
+
+ cursor = (const unsigned char *) contents;
+ begin_buffer = (const unsigned char *) contents;
+ end_buffer = cursor + size;
+
+ location_table.resize(1024);
+ location_table[0] = 0;
+ location_table.current_line = 1;
+
+ line_table.resize(1024);
+ line_table[0] = 0;
+ line_table.current_line = 1;
+
+ do {
+ if (index == token_stream.size())
+ token_stream.resize(token_stream.size() * 2);
+
+ Token *current_token = &token_stream[(int) index];
+ current_token->text = reinterpret_cast<const char*>(begin_buffer);
+ current_token->position = cursor - begin_buffer;
+ (this->*s_scan_table[*cursor])();
+ current_token->size = cursor - begin_buffer - current_token->position;
+ } while (cursor < end_buffer);
+
+ if (index == token_stream.size())
+ token_stream.resize(token_stream.size() * 2);
+
+ Q_ASSERT(index < token_stream.size());
+ token_stream[(int) index].position = cursor - begin_buffer;
+ token_stream[(int) index].kind = Token_EOF;
+}
+
+void Lexer::reportError(const QString& msg)
+{
+ int line = 0;
+ int column = 0;
+ QString fileName;
+
+ std::size_t tok = token_stream.cursor();
+ _M_location.positionAt(token_stream.position(tok),
+ &line, &column, &fileName);
+
+ Control::ErrorMessage errmsg;
+ errmsg.setLine(line + 1);
+ errmsg.setColumn(column);
+ errmsg.setFileName(fileName);
+ errmsg.setMessage(QLatin1String("** LEXER ERROR ") + msg);
+ control->reportError(errmsg);
+}
+
+void Lexer::initialize_scan_table()
+{
+ s_initialized = true;
+
+ for (int i = 0; i < 256; ++i) {
+ if (isspace(i))
+ s_scan_table[i] = &Lexer::scan_white_spaces;
+ else if (isalpha(i) || i == '_')
+ s_scan_table[i] = &Lexer::scan_identifier_or_keyword;
+ else if (isdigit(i))
+ s_scan_table[i] = &Lexer::scan_int_constant;
+ else
+ s_scan_table[i] = &Lexer::scan_invalid_input;
+ }
+
+ s_scan_table[int('L')] = &Lexer::scan_identifier_or_literal;
+ s_scan_table[int('\n')] = &Lexer::scan_newline;
+ s_scan_table[int('#')] = &Lexer::scan_preprocessor;
+
+ s_scan_table[int('\'')] = &Lexer::scan_char_constant;
+ s_scan_table[int('"')] = &Lexer::scan_string_constant;
+
+ s_scan_table[int('.')] = &Lexer::scan_int_constant;
+
+ s_scan_table[int('!')] = &Lexer::scan_not;
+ s_scan_table[int('%')] = &Lexer::scan_remainder;
+ s_scan_table[int('&')] = &Lexer::scan_and;
+ s_scan_table[int('(')] = &Lexer::scan_left_paren;
+ s_scan_table[int(')')] = &Lexer::scan_right_paren;
+ s_scan_table[int('*')] = &Lexer::scan_star;
+ s_scan_table[int('+')] = &Lexer::scan_plus;
+ s_scan_table[int(',')] = &Lexer::scan_comma;
+ s_scan_table[int('-')] = &Lexer::scan_minus;
+ s_scan_table[int('/')] = &Lexer::scan_divide;
+ s_scan_table[int(':')] = &Lexer::scan_colon;
+ s_scan_table[int(';')] = &Lexer::scan_semicolon;
+ s_scan_table[int('<')] = &Lexer::scan_less;
+ s_scan_table[int('=')] = &Lexer::scan_equal;
+ s_scan_table[int('>')] = &Lexer::scan_greater;
+ s_scan_table[int('?')] = &Lexer::scan_question;
+ s_scan_table[int('[')] = &Lexer::scan_left_bracket;
+ s_scan_table[int(']')] = &Lexer::scan_right_bracket;
+ s_scan_table[int('^')] = &Lexer::scan_xor;
+ s_scan_table[int('{')] = &Lexer::scan_left_brace;
+ s_scan_table[int('|')] = &Lexer::scan_or;
+ s_scan_table[int('}')] = &Lexer::scan_right_brace;
+ s_scan_table[int('~')] = &Lexer::scan_tilde;
+
+ s_scan_table[0] = &Lexer::scan_EOF;
+}
+
+void Lexer::scan_preprocessor()
+{
+ if (line_table.current_line == line_table.size())
+ line_table.resize(line_table.current_line * 2);
+
+ line_table[(int) line_table.current_line++] = (cursor - begin_buffer);
+
+ while (*cursor && *cursor != '\n')
+ ++cursor;
+
+ if (*cursor != '\n')
+ reportError(QLatin1String("expected newline"));
+}
+
+void Lexer::scan_char_constant()
+{
+ const unsigned char *begin = cursor;
+
+ ++cursor;
+ while (*cursor && *cursor != '\'') {
+ if (*cursor == '\n')
+ reportError(QLatin1String("did not expect newline"));
+
+ if (*cursor == '\\')
+ ++cursor;
+ ++cursor;
+ }
+
+ if (*cursor != '\'')
+ reportError(QLatin1String("expected \'"));
+
+ ++cursor;
+
+ token_stream[(int) index].extra.symbol =
+ control->findOrInsertName((const char*) begin, cursor - begin);
+
+ token_stream[(int) index++].kind = Token_char_literal;
+}
+
+void Lexer::scan_string_constant()
+{
+ const unsigned char *begin = cursor;
+
+ ++cursor;
+ while (*cursor && *cursor != '"') {
+ if (*cursor == '\n')
+ reportError(QLatin1String("did not expect newline"));
+
+ if (*cursor == '\\')
+ ++cursor;
+ ++cursor;
+ }
+
+ if (*cursor != '"')
+ reportError(QLatin1String("expected \""));
+
+ ++cursor;
+
+ token_stream[(int) index].extra.symbol =
+ control->findOrInsertName((const char*) begin, cursor - begin);
+
+ token_stream[(int) index++].kind = Token_string_literal;
+}
+
+void Lexer::scan_newline()
+{
+ if (location_table.current_line == location_table.size())
+ location_table.resize(location_table.current_line * 2);
+
+ location_table[(int) location_table.current_line++] = (cursor - begin_buffer);
+ ++cursor;
+}
+
+void Lexer::scan_white_spaces()
+{
+ while (isspace(*cursor)) {
+ if (*cursor == '\n')
+ scan_newline();
+ else
+ ++cursor;
+ }
+}
+
+void Lexer::scan_identifier_or_literal()
+{
+ switch (*(cursor + 1)) {
+ case '\'':
+ ++cursor;
+ scan_char_constant();
+ break;
+
+ case '\"':
+ ++cursor;
+ scan_string_constant();
+ break;
+
+ default:
+ scan_identifier_or_keyword();
+ break;
+ }
+}
+
+void Lexer::scan_identifier_or_keyword()
+{
+ const unsigned char *skip = cursor;
+ while (isalnum(*skip) || *skip == '_')
+ ++skip;
+
+ int n = skip - cursor;
+ Token *current_token = &token_stream[(int) index];
+ (this->*s_scan_keyword_table[n < 17 ? n : 0])();
+
+ if (current_token->kind == Token_identifier) {
+ current_token->extra.symbol =
+ control->findOrInsertName((const char*) cursor, n);
+ }
+
+ cursor = skip;
+}
+
+void Lexer::scan_int_constant()
+{
+ if (*cursor == '.' && !std::isdigit(*(cursor + 1))) {
+ scan_dot();
+ return;
+ }
+
+ const unsigned char *begin = cursor;
+
+ while (isalnum(*cursor) || *cursor == '.')
+ ++cursor;
+
+ token_stream[(int) index].extra.symbol =
+ control->findOrInsertName((const char*) begin, cursor - begin);
+
+ token_stream[(int) index++].kind = Token_number_literal;
+}
+
+void Lexer::scan_not()
+{
+ /*
+ '!' ::= not
+ '!=' ::= not_equal
+ */
+
+ ++cursor;
+
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_not_eq;
+ } else {
+ token_stream[(int) index++].kind = '!';
+ }
+}
+
+void Lexer::scan_remainder()
+{
+ /*
+ '%' ::= remainder
+ '%=' ::= remainder_equal
+ */
+
+ ++cursor;
+
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_assign;
+ } else {
+ token_stream[(int) index++].kind = '%';
+ }
+}
+
+void Lexer::scan_and()
+{
+ /*
+ '&&' ::= and_and
+ '&' ::= and
+ '&=' ::= and_equal
+ */
+
+ ++cursor;
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_assign;
+ } else if (*cursor == '&') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_and;
+ } else {
+ token_stream[(int) index++].kind = '&';
+ }
+}
+
+void Lexer::scan_left_paren()
+{
+ ++cursor;
+ token_stream[(int) index++].kind = '(';
+}
+
+void Lexer::scan_right_paren()
+{
+ ++cursor;
+ token_stream[(int) index++].kind = ')';
+}
+
+void Lexer::scan_star()
+{
+ /*
+ '*' ::= star
+ '*=' ::= star_equal
+ */
+
+ ++cursor;
+
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_assign;
+ } else {
+ token_stream[(int) index++].kind = '*';
+ }
+}
+
+void Lexer::scan_plus()
+{
+ /*
+ '+' ::= plus
+ '++' ::= incr
+ '+=' ::= plus_equal
+ */
+
+ ++cursor;
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_assign;
+ } else if (*cursor == '+') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_incr;
+ } else {
+ token_stream[(int) index++].kind = '+';
+ }
+}
+
+void Lexer::scan_comma()
+{
+ ++cursor;
+ token_stream[(int) index++].kind = ',';
+}
+
+void Lexer::scan_minus()
+{
+ /*
+ '-' ::= minus
+ '--' ::= decr
+ '-=' ::= minus_equal
+ '->' ::= left_arrow
+ */
+
+ ++cursor;
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_assign;
+ } else if (*cursor == '-') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_decr;
+ } else if (*cursor == '>') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_arrow;
+ if (*cursor == '*') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_ptrmem;
+ }
+ } else {
+ token_stream[(int) index++].kind = '-';
+ }
+}
+
+void Lexer::scan_dot()
+{
+ /*
+ '.' ::= dot
+ '...' ::= ellipsis
+ */
+
+ ++cursor;
+ if (*cursor == '.' && *(cursor + 1) == '.') {
+ cursor += 2;
+ token_stream[(int) index++].kind = Token_ellipsis;
+ } else if (*cursor == '.' && *(cursor + 1) == '*') {
+ cursor += 2;
+ token_stream[(int) index++].kind = Token_ptrmem;
+ } else
+ token_stream[(int) index++].kind = '.';
+}
+
+void Lexer::scan_divide()
+{
+ /*
+ '/' ::= divide
+ '/=' ::= divide_equal
+ */
+
+ ++cursor;
+
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_assign;
+ } else {
+ token_stream[(int) index++].kind = '/';
+ }
+}
+
+void Lexer::scan_colon()
+{
+ ++cursor;
+ if (*cursor == ':') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_scope;
+ } else {
+ token_stream[(int) index++].kind = ':';
+ }
+}
+
+void Lexer::scan_semicolon()
+{
+ ++cursor;
+ token_stream[(int) index++].kind = ';';
+}
+
+void Lexer::scan_less()
+{
+ /*
+ '<' ::= less
+ '<<' ::= left_shift
+ '<<=' ::= left_shift_equal
+ '<=' ::= less_equal
+ */
+
+ ++cursor;
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_leq;
+ } else if (*cursor == '<') {
+ ++cursor;
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_assign;
+ } else {
+ token_stream[(int) index++].kind = Token_shift;
+ }
+ } else {
+ token_stream[(int) index++].kind = '<';
+ }
+}
+
+void Lexer::scan_equal()
+{
+ /*
+ '=' ::= equal
+ '==' ::= equal_equal
+ */
+ ++cursor;
+
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_eq;
+ } else {
+ token_stream[(int) index++].kind = '=';
+ }
+}
+
+void Lexer::scan_greater()
+{
+ /*
+ '>' ::= greater
+ '>=' ::= greater_equal
+ '>>' ::= right_shift
+ '>>=' ::= right_shift_equal
+ */
+
+ ++cursor;
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_geq;
+ } else if (*cursor == '>') {
+ ++cursor;
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_assign;
+ } else {
+ token_stream[(int) index++].kind = Token_shift;
+ }
+ } else {
+ token_stream[(int) index++].kind = '>';
+ }
+}
+
+void Lexer::scan_question()
+{
+ ++cursor;
+ token_stream[(int) index++].kind = '?';
+}
+
+void Lexer::scan_left_bracket()
+{
+ ++cursor;
+ token_stream[(int) index++].kind = '[';
+}
+
+void Lexer::scan_right_bracket()
+{
+ ++cursor;
+ token_stream[(int) index++].kind = ']';
+}
+
+void Lexer::scan_xor()
+{
+ /*
+ '^' ::= xor
+ '^=' ::= xor_equal
+ */
+ ++cursor;
+
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_assign;
+ } else {
+ token_stream[(int) index++].kind = '^';
+ }
+}
+
+void Lexer::scan_left_brace()
+{
+ ++cursor;
+ token_stream[(int) index++].kind = '{';
+}
+
+void Lexer::scan_or()
+{
+ /*
+ '|' ::= or
+ '|=' ::= or_equal
+ '||' ::= or_or
+ */
+ ++cursor;
+ if (*cursor == '=') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_assign;
+ } else if (*cursor == '|') {
+ ++cursor;
+ token_stream[(int) index++].kind = Token_or;
+ } else {
+ token_stream[(int) index++].kind = '|';
+ }
+}
+
+void Lexer::scan_right_brace()
+{
+ ++cursor;
+ token_stream[(int) index++].kind = '}';
+}
+
+void Lexer::scan_tilde()
+{
+ ++cursor;
+ token_stream[(int) index++].kind = '~';
+}
+
+void Lexer::scan_EOF()
+{
+ ++cursor;
+ token_stream[(int) index++].kind = Token_EOF;
+}
+
+void Lexer::scan_invalid_input()
+{
+ QString errmsg(QLatin1String("invalid input: %1"));
+ reportError(errmsg);
+ ++cursor;
+}
+
+void LocationTable::positionAt(std::size_t offset, int max_line,
+ int *line, int *column) const
+{
+ if (!(line && column && max_line != 0))
+ return;
+
+ int first = 0;
+ int len = max_line;
+ int half;
+ int middle;
+
+ while (len > 0) {
+ half = len >> 1;
+ middle = first;
+
+ middle += half;
+
+ if (lines[middle] < offset) {
+ first = middle;
+ ++first;
+ len = len - half - 1;
+ } else
+ len = half;
+ }
+
+ *line = std::max(first, 1);
+ *column = (int)(offset - lines[*line - 1] - 1);
+
+ if (*column < 0) {
+ *column = 0;
+ }
+}
+
+void Lexer::scanKeyword0()
+{
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword2()
+{
+ switch (*cursor) {
+ case 'i':
+ if (*(cursor + 1) == 'f') {
+ token_stream[(int) index++].kind = Token_if;
+ return;
+ }
+ break;
+
+ case 'd':
+ if (*(cursor + 1) == 'o') {
+ token_stream[(int) index++].kind = Token_do;
+ return;
+ }
+ break;
+
+ case 'o':
+ if (*(cursor + 1) == 'r') {
+ token_stream[(int) index++].kind = Token_or;
+ return;
+ }
+ break;
+
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword3()
+{
+ switch (*cursor) {
+ case 'a':
+ if (*(cursor + 1) == 'n' &&
+ *(cursor + 2) == 'd') {
+ token_stream[(int) index++].kind = Token_and;
+ return;
+ }
+ if (*(cursor + 1) == 's' &&
+ *(cursor + 2) == 'm') {
+ token_stream[(int) index++].kind = Token_asm;
+ return;
+ }
+ break;
+
+ case 'f':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'r') {
+ token_stream[(int) index++].kind = Token_for;
+ return;
+ }
+ break;
+
+ case 'i':
+ if (*(cursor + 1) == 'n' &&
+ *(cursor + 2) == 't') {
+ token_stream[(int) index++].kind = Token_int;
+ return;
+ }
+ break;
+
+ case 'n':
+ if (*(cursor + 1) == 'e' &&
+ *(cursor + 2) == 'w') {
+ token_stream[(int) index++].kind = Token_new;
+ return;
+ }
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 't') {
+ token_stream[(int) index++].kind = Token_not;
+ return;
+ }
+ break;
+
+ case 't':
+ if (*(cursor + 1) == 'r' &&
+ *(cursor + 2) == 'y') {
+ token_stream[(int) index++].kind = Token_try;
+ return;
+ }
+ break;
+
+ case 'x':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'r') {
+ token_stream[(int) index++].kind = Token_xor;
+ return;
+ }
+ break;
+
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword4()
+{
+ switch (*cursor) {
+ case 'a':
+ if (*(cursor + 1) == 'u' &&
+ *(cursor + 2) == 't' &&
+ *(cursor + 3) == 'o') {
+ token_stream[(int) index++].kind = Token_auto;
+ return;
+ }
+ break;
+
+ case 'c':
+ if (*(cursor + 1) == 'a' &&
+ *(cursor + 2) == 's' &&
+ *(cursor + 3) == 'e') {
+ token_stream[(int) index++].kind = Token_case;
+ return;
+ }
+ if (*(cursor + 1) == 'h' &&
+ *(cursor + 2) == 'a' &&
+ *(cursor + 3) == 'r') {
+ token_stream[(int) index++].kind = Token_char;
+ return;
+ }
+ break;
+
+ case 'b':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'o' &&
+ *(cursor + 3) == 'l') {
+ token_stream[(int) index++].kind = Token_bool;
+ return;
+ }
+ break;
+
+ case 'e':
+ if (*(cursor + 1) == 'l' &&
+ *(cursor + 2) == 's' &&
+ *(cursor + 3) == 'e') {
+ token_stream[(int) index++].kind = Token_else;
+ return;
+ }
+ if (*(cursor + 1) == 'm' &&
+ *(cursor + 2) == 'i' &&
+ *(cursor + 3) == 't') {
+ token_stream[(int) index++].kind = Token_emit;
+ return;
+ }
+ if (*(cursor + 1) == 'n' &&
+ *(cursor + 2) == 'u' &&
+ *(cursor + 3) == 'm') {
+ token_stream[(int) index++].kind = Token_enum;
+ return;
+ }
+ break;
+
+ case 'g':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 't' &&
+ *(cursor + 3) == 'o') {
+ token_stream[(int) index++].kind = Token_goto;
+ return;
+ }
+ break;
+
+ case 'l':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'n' &&
+ *(cursor + 3) == 'g') {
+ token_stream[(int) index++].kind = Token_long;
+ return;
+ }
+ break;
+
+ case 't':
+ if (*(cursor + 1) == 'h' &&
+ *(cursor + 2) == 'i' &&
+ *(cursor + 3) == 's') {
+ token_stream[(int) index++].kind = Token_this;
+ return;
+ }
+ break;
+
+ case 'v':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'i' &&
+ *(cursor + 3) == 'd') {
+ token_stream[(int) index++].kind = Token_void;
+ return;
+ }
+ break;
+
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword5()
+{
+ switch (*cursor) {
+ case 'c':
+ if (*(cursor + 1) == 'a' &&
+ *(cursor + 2) == 't' &&
+ *(cursor + 3) == 'c' &&
+ *(cursor + 4) == 'h') {
+ token_stream[(int) index++].kind = Token_catch;
+ return;
+ }
+ if (*(cursor + 1) == 'l' &&
+ *(cursor + 2) == 'a' &&
+ *(cursor + 3) == 's' &&
+ *(cursor + 4) == 's') {
+ token_stream[(int) index++].kind = Token_class;
+ return;
+ }
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'm' &&
+ *(cursor + 3) == 'p' &&
+ *(cursor + 4) == 'l') {
+ token_stream[(int) index++].kind = Token_compl;
+ return;
+ }
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'n' &&
+ *(cursor + 3) == 's' &&
+ *(cursor + 4) == 't') {
+ token_stream[(int) index++].kind = Token_const;
+ return;
+ }
+ break;
+
+ case 'b':
+ if (*(cursor + 1) == 'i' &&
+ *(cursor + 2) == 't' &&
+ *(cursor + 3) == 'o' &&
+ *(cursor + 4) == 'r') {
+ token_stream[(int) index++].kind = Token_bitor;
+ return;
+ }
+ if (*(cursor + 1) == 'r' &&
+ *(cursor + 2) == 'e' &&
+ *(cursor + 3) == 'a' &&
+ *(cursor + 4) == 'k') {
+ token_stream[(int) index++].kind = Token_break;
+ return;
+ }
+ break;
+
+ case 'f':
+ if (*(cursor + 1) == 'l' &&
+ *(cursor + 2) == 'o' &&
+ *(cursor + 3) == 'a' &&
+ *(cursor + 4) == 't') {
+ token_stream[(int) index++].kind = Token_float;
+ return;
+ }
+ break;
+
+ case 'o':
+ if (*(cursor + 1) == 'r' &&
+ *(cursor + 2) == '_' &&
+ *(cursor + 3) == 'e' &&
+ *(cursor + 4) == 'q') {
+ token_stream[(int) index++].kind = Token_or_eq;
+ return;
+ }
+ break;
+
+ case 's':
+ if (*(cursor + 1) == 'h' &&
+ *(cursor + 2) == 'o' &&
+ *(cursor + 3) == 'r' &&
+ *(cursor + 4) == 't') {
+ token_stream[(int) index++].kind = Token_short;
+ return;
+ }
+ if (*(cursor + 1) == 'l' &&
+ *(cursor + 2) == 'o' &&
+ *(cursor + 3) == 't' &&
+ *(cursor + 4) == 's') {
+ token_stream[(int) index++].kind = Token_slots;
+ return;
+ }
+ break;
+
+ case 'u':
+ if (*(cursor + 1) == 'n' &&
+ *(cursor + 2) == 'i' &&
+ *(cursor + 3) == 'o' &&
+ *(cursor + 4) == 'n') {
+ token_stream[(int) index++].kind = Token_union;
+ return;
+ }
+ if (*(cursor + 1) == 's' &&
+ *(cursor + 2) == 'i' &&
+ *(cursor + 3) == 'n' &&
+ *(cursor + 4) == 'g') {
+ token_stream[(int) index++].kind = Token_using;
+ return;
+ }
+ break;
+
+ case 't':
+ if (*(cursor + 1) == 'h' &&
+ *(cursor + 2) == 'r' &&
+ *(cursor + 3) == 'o' &&
+ *(cursor + 4) == 'w') {
+ token_stream[(int) index++].kind = Token_throw;
+ return;
+ }
+ break;
+
+ case 'w':
+ if (*(cursor + 1) == 'h' &&
+ *(cursor + 2) == 'i' &&
+ *(cursor + 3) == 'l' &&
+ *(cursor + 4) == 'e') {
+ token_stream[(int) index++].kind = Token_while;
+ return;
+ }
+ break;
+
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword6()
+{
+ switch (*cursor) {
+ case 'a':
+ if (*(cursor + 1) == 'n' &&
+ *(cursor + 2) == 'd' &&
+ *(cursor + 3) == '_' &&
+ *(cursor + 4) == 'e' &&
+ *(cursor + 5) == 'q') {
+ token_stream[(int) index++].kind = Token_and_eq;
+ return;
+ }
+ break;
+
+ case 'b':
+ if (*(cursor + 1) == 'i' &&
+ *(cursor + 2) == 't' &&
+ *(cursor + 3) == 'a' &&
+ *(cursor + 4) == 'n' &&
+ *(cursor + 5) == 'd') {
+ token_stream[(int) index++].kind = Token_bitand;
+ return;
+ }
+ break;
+
+ case 'e':
+ if (*(cursor + 1) == 'x' &&
+ *(cursor + 2) == 'p' &&
+ *(cursor + 3) == 'o' &&
+ *(cursor + 4) == 'r' &&
+ *(cursor + 5) == 't') {
+ token_stream[(int) index++].kind = Token_export;
+ return;
+ }
+ if (*(cursor + 1) == 'x' &&
+ *(cursor + 2) == 't' &&
+ *(cursor + 3) == 'e' &&
+ *(cursor + 4) == 'r' &&
+ *(cursor + 5) == 'n') {
+ token_stream[(int) index++].kind = Token_extern;
+ return;
+ }
+ break;
+
+ case 'd':
+ if (*(cursor + 1) == 'e' &&
+ *(cursor + 2) == 'l' &&
+ *(cursor + 3) == 'e' &&
+ *(cursor + 4) == 't' &&
+ *(cursor + 5) == 'e') {
+ token_stream[(int) index++].kind = Token_delete;
+ return;
+ }
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'u' &&
+ *(cursor + 3) == 'b' &&
+ *(cursor + 4) == 'l' &&
+ *(cursor + 5) == 'e') {
+ token_stream[(int) index++].kind = Token_double;
+ return;
+ }
+ break;
+
+ case 'f':
+ if (*(cursor + 1) == 'r' &&
+ *(cursor + 2) == 'i' &&
+ *(cursor + 3) == 'e' &&
+ *(cursor + 4) == 'n' &&
+ *(cursor + 5) == 'd') {
+ token_stream[(int) index++].kind = Token_friend;
+ return;
+ }
+ break;
+
+ case 'i':
+ if (*(cursor + 1) == 'n' &&
+ *(cursor + 2) == 'l' &&
+ *(cursor + 3) == 'i' &&
+ *(cursor + 4) == 'n' &&
+ *(cursor + 5) == 'e') {
+ token_stream[(int) index++].kind = Token_inline;
+ return;
+ }
+ break;
+
+ case 'K':
+ if (*(cursor + 1) == '_' &&
+ *(cursor + 2) == 'D' &&
+ *(cursor + 3) == 'C' &&
+ *(cursor + 4) == 'O' &&
+ *(cursor + 5) == 'P') {
+ token_stream[(int) index++].kind = Token_K_DCOP;
+ return;
+ }
+ break;
+
+ case 'n':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 't' &&
+ *(cursor + 3) == '_' &&
+ *(cursor + 4) == 'e' &&
+ *(cursor + 5) == 'q') {
+ token_stream[(int) index++].kind = Token_not_eq;
+ return;
+ }
+ break;
+
+ case 'p':
+ if (*(cursor + 1) == 'u' &&
+ *(cursor + 2) == 'b' &&
+ *(cursor + 3) == 'l' &&
+ *(cursor + 4) == 'i' &&
+ *(cursor + 5) == 'c') {
+ token_stream[(int) index++].kind = Token_public;
+ return;
+ }
+ break;
+
+ case 's':
+ if (*(cursor + 1) == 'i' &&
+ *(cursor + 2) == 'g' &&
+ *(cursor + 3) == 'n' &&
+ *(cursor + 4) == 'e' &&
+ *(cursor + 5) == 'd') {
+ token_stream[(int) index++].kind = Token_signed;
+ return;
+ }
+ if (*(cursor + 1) == 'i' &&
+ *(cursor + 2) == 'z' &&
+ *(cursor + 3) == 'e' &&
+ *(cursor + 4) == 'o' &&
+ *(cursor + 5) == 'f') {
+ token_stream[(int) index++].kind = Token_sizeof;
+ return;
+ }
+ if (*(cursor + 1) == 't' &&
+ *(cursor + 2) == 'a' &&
+ *(cursor + 3) == 't' &&
+ *(cursor + 4) == 'i' &&
+ *(cursor + 5) == 'c') {
+ token_stream[(int) index++].kind = Token_static;
+ return;
+ }
+ if (*(cursor + 1) == 't' &&
+ *(cursor + 2) == 'r' &&
+ *(cursor + 3) == 'u' &&
+ *(cursor + 4) == 'c' &&
+ *(cursor + 5) == 't') {
+ token_stream[(int) index++].kind = Token_struct;
+ return;
+ }
+ if (*(cursor + 1) == 'w' &&
+ *(cursor + 2) == 'i' &&
+ *(cursor + 3) == 't' &&
+ *(cursor + 4) == 'c' &&
+ *(cursor + 5) == 'h') {
+ token_stream[(int) index++].kind = Token_switch;
+ return;
+ }
+ break;
+
+ case 'r':
+ if (*(cursor + 1) == 'e' &&
+ *(cursor + 2) == 't' &&
+ *(cursor + 3) == 'u' &&
+ *(cursor + 4) == 'r' &&
+ *(cursor + 5) == 'n') {
+ token_stream[(int) index++].kind = Token_return;
+ return;
+ }
+ break;
+
+ case 't':
+ if (*(cursor + 1) == 'y' &&
+ *(cursor + 2) == 'p' &&
+ *(cursor + 3) == 'e' &&
+ *(cursor + 4) == 'i' &&
+ *(cursor + 5) == 'd') {
+ token_stream[(int) index++].kind = Token_typeid;
+ return;
+ }
+ break;
+
+ case 'x':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'r' &&
+ *(cursor + 3) == '_' &&
+ *(cursor + 4) == 'e' &&
+ *(cursor + 5) == 'q') {
+ token_stream[(int) index++].kind = Token_xor_eq;
+ return;
+ }
+ break;
+
+ case 'k':
+ if (*(cursor + 1) == '_' &&
+ *(cursor + 2) == 'd' &&
+ *(cursor + 3) == 'c' &&
+ *(cursor + 4) == 'o' &&
+ *(cursor + 5) == 'p') {
+ token_stream[(int) index++].kind = Token_k_dcop;
+ return;
+ }
+ break;
+
+ case 'Q':
+ if (*(cursor + 1) == '_' &&
+ *(cursor + 2) == 'E' &&
+ *(cursor + 3) == 'N' &&
+ *(cursor + 4) == 'U' &&
+ *(cursor + 5) == 'M') { // Qt5.5
+ token_stream[(int) index++].kind = Token_Q_ENUM;
+ return;
+ }
+ break;
+
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword7()
+{
+ switch (*cursor) {
+ case 'd':
+ if (*(cursor + 1) == 'e' &&
+ *(cursor + 2) == 'f' &&
+ *(cursor + 3) == 'a' &&
+ *(cursor + 4) == 'u' &&
+ *(cursor + 5) == 'l' &&
+ *(cursor + 6) == 't') {
+ token_stream[(int) index++].kind = Token_default;
+ return;
+ }
+ break;
+
+ case 'm':
+ if (*(cursor + 1) == 'u' &&
+ *(cursor + 2) == 't' &&
+ *(cursor + 3) == 'a' &&
+ *(cursor + 4) == 'b' &&
+ *(cursor + 5) == 'l' &&
+ *(cursor + 6) == 'e') {
+ token_stream[(int) index++].kind = Token_mutable;
+ return;
+ }
+ break;
+
+ case 'p':
+ if (*(cursor + 1) == 'r' &&
+ *(cursor + 2) == 'i' &&
+ *(cursor + 3) == 'v' &&
+ *(cursor + 4) == 'a' &&
+ *(cursor + 5) == 't' &&
+ *(cursor + 6) == 'e') {
+ token_stream[(int) index++].kind = Token_private;
+ return;
+ }
+ break;
+ case 's':
+ if (*(cursor + 1) == 'i' &&
+ *(cursor + 2) == 'g' &&
+ *(cursor + 3) == 'n' &&
+ *(cursor + 4) == 'a' &&
+ *(cursor + 5) == 'l' &&
+ *(cursor + 6) == 's') {
+ token_stream[(int) index++].kind = Token_signals;
+ return;
+ }
+ break;
+ case 't':
+ if (*(cursor + 1) == 'y' &&
+ *(cursor + 2) == 'p' &&
+ *(cursor + 3) == 'e' &&
+ *(cursor + 4) == 'd' &&
+ *(cursor + 5) == 'e' &&
+ *(cursor + 6) == 'f') {
+ token_stream[(int) index++].kind = Token_typedef;
+ return;
+ }
+ break;
+
+ case 'v':
+ if (*(cursor + 1) == 'i' &&
+ *(cursor + 2) == 'r' &&
+ *(cursor + 3) == 't' &&
+ *(cursor + 4) == 'u' &&
+ *(cursor + 5) == 'a' &&
+ *(cursor + 6) == 'l') {
+ token_stream[(int) index++].kind = Token_virtual;
+ return;
+ }
+ break;
+
+ case 'Q':
+ if (*(cursor + 1) == '_' &&
+ *(cursor + 2) == 'E' &&
+ *(cursor + 3) == 'N' &&
+ *(cursor + 4) == 'U' &&
+ *(cursor + 5) == 'M' &&
+ *(cursor + 6) == 'S') {
+ token_stream[(int) index++].kind = Token_Q_ENUMS;
+ return;
+ }
+ break;
+
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword8()
+{
+ switch (*cursor) {
+ case '_':
+ if (*(cursor + 1) == '_' &&
+ *(cursor + 2) == 't' &&
+ *(cursor + 3) == 'y' &&
+ *(cursor + 4) == 'p' &&
+ *(cursor + 5) == 'e' &&
+ *(cursor + 6) == 'o' &&
+ *(cursor + 7) == 'f') {
+ token_stream[(int) index++].kind = Token___typeof;
+ return;
+ }
+ break;
+
+ case 'c':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'n' &&
+ *(cursor + 3) == 't' &&
+ *(cursor + 4) == 'i' &&
+ *(cursor + 5) == 'n' &&
+ *(cursor + 6) == 'u' &&
+ *(cursor + 7) == 'e') {
+ token_stream[(int) index++].kind = Token_continue;
+ return;
+ }
+ break;
+
+ case 'e':
+ if (*(cursor + 1) == 'x' &&
+ *(cursor + 2) == 'p' &&
+ *(cursor + 3) == 'l' &&
+ *(cursor + 4) == 'i' &&
+ *(cursor + 5) == 'c' &&
+ *(cursor + 6) == 'i' &&
+ *(cursor + 7) == 't') {
+ token_stream[(int) index++].kind = Token_explicit;
+ return;
+ }
+ break;
+
+ case 'n':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'e' &&
+ *(cursor + 3) == 'x' &&
+ *(cursor + 4) == 'c' &&
+ *(cursor + 5) == 'e' &&
+ *(cursor + 6) == 'p' &&
+ *(cursor + 7) == 't') {
+ token_stream[(int) index++].kind = Token_noexcept;
+ return;
+ }
+ break;
+
+ case 'o':
+ if (*(cursor + 1) == 'p' &&
+ *(cursor + 2) == 'e' &&
+ *(cursor + 3) == 'r' &&
+ *(cursor + 4) == 'a' &&
+ *(cursor + 5) == 't' &&
+ *(cursor + 6) == 'o' &&
+ *(cursor + 7) == 'r') {
+ token_stream[(int) index++].kind = Token_operator;
+ return;
+ }
+ break;
+
+ case 'Q':
+ if (*(cursor + 1) == '_' &&
+ *(cursor + 2) == 'O' &&
+ *(cursor + 3) == 'B' &&
+ *(cursor + 4) == 'J' &&
+ *(cursor + 5) == 'E' &&
+ *(cursor + 6) == 'C' &&
+ *(cursor + 7) == 'T') {
+ token_stream[(int) index++].kind = Token_Q_OBJECT;
+ return;
+ }
+ break;
+
+ case 'r':
+ if (*(cursor + 1) == 'e' &&
+ *(cursor + 2) == 'g' &&
+ *(cursor + 3) == 'i' &&
+ *(cursor + 4) == 's' &&
+ *(cursor + 5) == 't' &&
+ *(cursor + 6) == 'e' &&
+ *(cursor + 7) == 'r') {
+ token_stream[(int) index++].kind = Token_register;
+ return;
+ }
+ break;
+
+ case 'u':
+ if (*(cursor + 1) == 'n' &&
+ *(cursor + 2) == 's' &&
+ *(cursor + 3) == 'i' &&
+ *(cursor + 4) == 'g' &&
+ *(cursor + 5) == 'n' &&
+ *(cursor + 6) == 'e' &&
+ *(cursor + 7) == 'd') {
+ token_stream[(int) index++].kind = Token_unsigned;
+ return;
+ }
+ break;
+
+ case 't':
+ if (*(cursor + 1) == 'e' &&
+ *(cursor + 2) == 'm' &&
+ *(cursor + 3) == 'p' &&
+ *(cursor + 4) == 'l' &&
+ *(cursor + 5) == 'a' &&
+ *(cursor + 6) == 't' &&
+ *(cursor + 7) == 'e') {
+ token_stream[(int) index++].kind = Token_template;
+ return;
+ }
+ if (*(cursor + 1) == 'y' &&
+ *(cursor + 2) == 'p' &&
+ *(cursor + 3) == 'e' &&
+ *(cursor + 4) == 'n' &&
+ *(cursor + 5) == 'a' &&
+ *(cursor + 6) == 'm' &&
+ *(cursor + 7) == 'e') {
+ token_stream[(int) index++].kind = Token_typename;
+ return;
+ }
+ break;
+
+ case 'v':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'l' &&
+ *(cursor + 3) == 'a' &&
+ *(cursor + 4) == 't' &&
+ *(cursor + 5) == 'i' &&
+ *(cursor + 6) == 'l' &&
+ *(cursor + 7) == 'e') {
+ token_stream[(int) index++].kind = Token_volatile;
+ return;
+ }
+ break;
+
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword9()
+{
+ switch (*cursor) {
+ case 'p':
+ if (*(cursor + 1) == 'r' &&
+ *(cursor + 2) == 'o' &&
+ *(cursor + 3) == 't' &&
+ *(cursor + 4) == 'e' &&
+ *(cursor + 5) == 'c' &&
+ *(cursor + 6) == 't' &&
+ *(cursor + 7) == 'e' &&
+ *(cursor + 8) == 'd') {
+ token_stream[(int) index++].kind = Token_protected;
+ return;
+ }
+ break;
+
+ case 'n':
+ if (*(cursor + 1) == 'a' &&
+ *(cursor + 2) == 'm' &&
+ *(cursor + 3) == 'e' &&
+ *(cursor + 4) == 's' &&
+ *(cursor + 5) == 'p' &&
+ *(cursor + 6) == 'a' &&
+ *(cursor + 7) == 'c' &&
+ *(cursor + 8) == 'e') {
+ token_stream[(int) index++].kind = Token_namespace;
+ return;
+ }
+ break;
+
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword10()
+{
+ switch (*cursor) {
+ case 'c':
+ if (*(cursor + 1) == 'o' &&
+ *(cursor + 2) == 'n' &&
+ *(cursor + 3) == 's' &&
+ *(cursor + 4) == 't' &&
+ *(cursor + 5) == '_' &&
+ *(cursor + 6) == 'c' &&
+ *(cursor + 7) == 'a' &&
+ *(cursor + 8) == 's' &&
+ *(cursor + 9) == 't') {
+ token_stream[(int) index++].kind = Token_const_cast;
+ return;
+ }
+ break;
+
+ case 'Q':
+ if (*(cursor + 1) == '_' &&
+ *(cursor + 2) == 'P' &&
+ *(cursor + 3) == 'R' &&
+ *(cursor + 4) == 'O' &&
+ *(cursor + 5) == 'P' &&
+ *(cursor + 6) == 'E' &&
+ *(cursor + 7) == 'R' &&
+ *(cursor + 8) == 'T' &&
+ *(cursor + 9) == 'Y') {
+ token_stream[(int) index++].kind = Token_Q_PROPERTY;
+ return;
+ }
+
+ break;
+ }
+
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword11()
+{
+ switch (*cursor) {
+ case 'Q':
+ if (*(cursor + 1) == '_' &&
+ *(cursor + 2) == 'I' &&
+ *(cursor + 3) == 'N' &&
+ *(cursor + 4) == 'V' &&
+ *(cursor + 5) == 'O' &&
+ *(cursor + 6) == 'K' &&
+ *(cursor + 7) == 'A' &&
+ *(cursor + 8) == 'B' &&
+ *(cursor + 9) == 'L' &&
+ *(cursor + 10) == 'E') {
+ token_stream[(int) index++].kind = Token_Q_INVOKABLE;
+ return;
+ }
+ break;
+
+ case 's':
+ if (*(cursor + 1) == 't' &&
+ *(cursor + 2) == 'a' &&
+ *(cursor + 3) == 't' &&
+ *(cursor + 4) == 'i' &&
+ *(cursor + 5) == 'c' &&
+ *(cursor + 6) == '_' &&
+ *(cursor + 7) == 'c' &&
+ *(cursor + 8) == 'a' &&
+ *(cursor + 9) == 's' &&
+ *(cursor + 10) == 't') {
+ token_stream[(int) index++].kind = Token_static_cast;
+ return;
+ }
+ break;
+
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword12()
+{
+ switch (*cursor) {
+ case 'd':
+ if (*(cursor + 1) == 'y' &&
+ *(cursor + 2) == 'n' &&
+ *(cursor + 3) == 'a' &&
+ *(cursor + 4) == 'm' &&
+ *(cursor + 5) == 'i' &&
+ *(cursor + 6) == 'c' &&
+ *(cursor + 7) == '_' &&
+ *(cursor + 8) == 'c' &&
+ *(cursor + 9) == 'a' &&
+ *(cursor + 10) == 's' &&
+ *(cursor + 11) == 't') {
+ token_stream[(int) index++].kind = Token_dynamic_cast;
+ return;
+ }
+ break;
+
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword13()
+{
+ switch (*cursor) {
+ case '_':
+ if (*(cursor + 1) == '_' &&
+ *(cursor + 2) == 'a' &&
+ *(cursor + 3) == 't' &&
+ *(cursor + 4) == 't' &&
+ *(cursor + 5) == 'r' &&
+ *(cursor + 6) == 'i' &&
+ *(cursor + 7) == 'b' &&
+ *(cursor + 8) == 'u' &&
+ *(cursor + 9) == 't' &&
+ *(cursor + 10) == 'e' &&
+ *(cursor + 11) == '_' &&
+ *(cursor + 12) == '_') {
+ token_stream[(int) index++].kind = Token___attribute__;
+ return;
+ }
+ break;
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword14()
+{
+ switch (*cursor) {
+ case 'k':
+ if (*(cursor + 1) == '_' &&
+ *(cursor + 2) == 'd' &&
+ *(cursor + 3) == 'c' &&
+ *(cursor + 4) == 'o' &&
+ *(cursor + 5) == 'p' &&
+ *(cursor + 6) == '_' &&
+ *(cursor + 7) == 's' &&
+ *(cursor + 8) == 'i' &&
+ *(cursor + 9) == 'g' &&
+ *(cursor + 10) == 'n' &&
+ *(cursor + 11) == 'a' &&
+ *(cursor + 12) == 'l' &&
+ *(cursor + 13) == 's') {
+ token_stream[(int) index++].kind = Token_k_dcop_signals;
+ return;
+ }
+ break;
+ }
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+void Lexer::scanKeyword16()
+{
+ switch (*cursor) {
+ case 'r':
+ if (*(cursor + 1) == 'e' &&
+ *(cursor + 2) == 'i' &&
+ *(cursor + 3) == 'n' &&
+ *(cursor + 4) == 't' &&
+ *(cursor + 5) == 'e' &&
+ *(cursor + 6) == 'r' &&
+ *(cursor + 7) == 'p' &&
+ *(cursor + 8) == 'r' &&
+ *(cursor + 9) == 'e' &&
+ *(cursor + 10) == 't' &&
+ *(cursor + 11) == '_' &&
+ *(cursor + 12) == 'c' &&
+ *(cursor + 13) == 'a' &&
+ *(cursor + 14) == 's' &&
+ *(cursor + 15) == 't') {
+ token_stream[(int) index++].kind = Token_reinterpret_cast;
+ return;
+ }
+ break;
+ }
+
+ token_stream[(int) index++].kind = Token_identifier;
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/lexer.h b/sources/shiboken2/ApiExtractor/parser/lexer.h
new file mode 100644
index 000000000..7144355e4
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/lexer.h
@@ -0,0 +1,295 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef LEXER_H
+#define LEXER_H
+
+#include "symbol.h"
+
+#include <QtCore/QString>
+#include <cstdlib>
+#include <cassert>
+
+struct NameSymbol;
+class Lexer;
+class Control;
+
+typedef void (Lexer::*scan_fun_ptr)();
+
+class Token
+{
+public:
+ int kind;
+ std::size_t position;
+ std::size_t size;
+ char const *text;
+
+ union {
+ const NameSymbol *symbol;
+ std::size_t right_brace;
+ } extra;
+};
+
+class LocationTable
+{
+private:
+ LocationTable(const LocationTable &source);
+ void operator = (const LocationTable &source);
+
+public:
+ inline LocationTable(std::size_t size = 1024)
+ : lines(0),
+ line_count(0),
+ current_line(0) {
+ resize(size);
+ }
+
+ inline ~LocationTable() {
+ free(lines);
+ }
+
+ inline std::size_t size() const {
+ return line_count;
+ }
+
+ void resize(std::size_t size) {
+ Q_ASSERT(size > 0);
+ lines = (std::size_t*) ::realloc(lines, sizeof(std::size_t) * size);
+ line_count = size;
+ }
+
+ void positionAt(std::size_t offset, int *line, int *column) const {
+ positionAt(offset, (int) current_line, line, column);
+ }
+
+ void positionAt(std::size_t offset, int max_line, int *line, int *column) const;
+
+ inline std::size_t &operator[](int index) {
+ return lines[index];
+ }
+
+private:
+ std::size_t *lines;
+ std::size_t line_count;
+ std::size_t current_line;
+
+ friend class Lexer;
+};
+
+class TokenStream
+{
+private:
+ TokenStream(const TokenStream &);
+ void operator = (const TokenStream &);
+
+public:
+ inline TokenStream(std::size_t size = 1024)
+ : tokens(0),
+ index(0),
+ token_count(0) {
+ resize(size);
+ }
+
+ inline ~TokenStream() {
+ ::free(tokens);
+ }
+
+ inline std::size_t size() const {
+ return token_count;
+ }
+
+ inline std::size_t cursor() const {
+ return index;
+ }
+
+ inline void rewind(int i) {
+ index = i;
+ }
+
+ void resize(std::size_t size) {
+ Q_ASSERT(size > 0);
+ tokens = (Token*) ::realloc(tokens, sizeof(Token) * size);
+ token_count = size;
+ }
+
+ inline std::size_t nextToken() {
+ return index++;
+ }
+
+ inline int lookAhead(std::size_t i = 0) const {
+ return tokens[index + i].kind;
+ }
+
+ inline int kind(std::size_t i) const {
+ return tokens[i].kind;
+ }
+
+ inline std::size_t position(std::size_t i) const {
+ return tokens[i].position;
+ }
+
+ inline const NameSymbol *symbol(std::size_t i) const {
+ return tokens[i].extra.symbol;
+ }
+
+ inline std::size_t matchingBrace(std::size_t i) const {
+ return tokens[i].extra.right_brace;
+ }
+
+ inline Token &operator[](int index) {
+ return tokens[index];
+ }
+
+ inline const Token &token(int index) const {
+ return tokens[index];
+ }
+
+private:
+ Token *tokens;
+ std::size_t index;
+ std::size_t token_count;
+
+private:
+ friend class Lexer;
+};
+
+class LocationManager
+{
+ LocationManager(LocationManager const &__other);
+ void operator = (LocationManager const &__other);
+
+public:
+ LocationManager(TokenStream &__token_stream,
+ LocationTable &__location_table,
+ LocationTable &__line_table):
+ token_stream(__token_stream),
+ location_table(__location_table),
+ line_table(__line_table) {}
+
+ void positionAt(std::size_t offset, int *line, int *column,
+ QString *filename) const;
+
+ void extract_line(int offset, int *line, QString *filename) const;
+
+ TokenStream &token_stream;
+ LocationTable &location_table;
+ LocationTable &line_table;
+};
+
+class Lexer
+{
+public:
+ Lexer(LocationManager &__location, Control *__control):
+ _M_location(__location),
+ token_stream(_M_location.token_stream),
+ location_table(_M_location.location_table),
+ line_table(_M_location.line_table),
+ control(__control) {}
+
+ void tokenize(const char *contents, std::size_t size);
+
+ LocationManager &_M_location;
+ TokenStream &token_stream;
+ LocationTable &location_table;
+ LocationTable &line_table;
+
+private:
+ void reportError(const QString& msg);
+
+ void initialize_scan_table();
+ void scan_newline();
+ void scan_white_spaces();
+ void scan_identifier_or_keyword();
+ void scan_identifier_or_literal();
+ void scan_int_constant();
+ void scan_char_constant();
+ void scan_string_constant();
+ void scan_invalid_input();
+ void scan_preprocessor();
+
+ // keywords
+ void scanKeyword0();
+ void scanKeyword2();
+ void scanKeyword3();
+ void scanKeyword4();
+ void scanKeyword5();
+ void scanKeyword6();
+ void scanKeyword7();
+ void scanKeyword8();
+ void scanKeyword9();
+ void scanKeyword10();
+ void scanKeyword11();
+ void scanKeyword12();
+ void scanKeyword13();
+ void scanKeyword14();
+ void scanKeyword16();
+
+ // operators
+ void scan_not();
+ void scan_remainder();
+ void scan_and();
+ void scan_left_paren();
+ void scan_right_paren();
+ void scan_star();
+ void scan_plus();
+ void scan_comma();
+ void scan_minus();
+ void scan_dot();
+ void scan_divide();
+ void scan_colon();
+ void scan_semicolon();
+ void scan_less();
+ void scan_equal();
+ void scan_greater();
+ void scan_question();
+ void scan_left_bracket();
+ void scan_right_bracket();
+ void scan_xor();
+ void scan_left_brace();
+ void scan_or();
+ void scan_right_brace();
+ void scan_tilde();
+ void scan_EOF();
+
+private:
+ Control *control;
+ const unsigned char *cursor;
+ const unsigned char *begin_buffer;
+ const unsigned char *end_buffer;
+ std::size_t index;
+
+ static scan_fun_ptr s_scan_table[];
+ static scan_fun_ptr s_scan_keyword_table[];
+ static bool s_initialized;
+};
+
+#endif // LEXER_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/list.cpp b/sources/shiboken2/ApiExtractor/parser/list.cpp
new file mode 100644
index 000000000..2d2a78700
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/list.cpp
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "list.h"
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/list.h b/sources/shiboken2/ApiExtractor/parser/list.h
new file mode 100644
index 000000000..764fafffd
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/list.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef FASTLIST_H
+#define FASTLIST_H
+
+#include "smallobject.h"
+
+template <typename Tp>
+struct ListNode {
+ Tp element;
+ int index;
+ mutable const ListNode<Tp> *next;
+
+ static ListNode *create(const Tp &element, pool *p) {
+ ListNode<Tp> *node = new(p->allocate(sizeof(ListNode), strideof(ListNode))) ListNode();
+ node->element = element;
+ node->index = 0;
+ node->next = node;
+
+ return node;
+ }
+
+ static ListNode *create(const ListNode *n1, const Tp &element, pool *p) {
+ ListNode<Tp> *n2 = ListNode::create(element, p);
+
+ n2->index = n1->index + 1;
+ n2->next = n1->next;
+ n1->next = n2;
+
+ return n2;
+ }
+
+ inline ListNode<Tp>() { }
+
+ inline const ListNode<Tp> *at(int index) const {
+ const ListNode<Tp> *node = this;
+ while (index != node->index)
+ node = node->next;
+
+ return node;
+ }
+
+ inline bool hasNext() const {
+ return index < next->index;
+ }
+
+ inline int count() const {
+ return 1 + toBack()->index;
+ }
+
+ inline const ListNode<Tp> *toFront() const {
+ return toBack()->next;
+ }
+
+ inline const ListNode<Tp> *toBack() const {
+ const ListNode<Tp> *node = this;
+ while (node->hasNext())
+ node = node->next;
+
+ return node;
+ }
+};
+
+template <class Tp>
+inline const ListNode<Tp> *snoc(const ListNode<Tp> *list,
+ const Tp &element, pool *p)
+{
+ if (!list)
+ return ListNode<Tp>::create(element, p);
+
+ return ListNode<Tp>::create(list->toBack(), element, p);
+}
+
+#endif // FASTLIST_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
+
diff --git a/sources/shiboken2/ApiExtractor/parser/name_compiler.cpp b/sources/shiboken2/ApiExtractor/parser/name_compiler.cpp
new file mode 100644
index 000000000..338d81c25
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/name_compiler.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "name_compiler.h"
+#include "type_compiler.h"
+#include "declarator_compiler.h"
+#include "lexer.h"
+#include "symbol.h"
+#include "binder.h"
+
+#include <QtCore/qdebug.h>
+
+NameCompiler::NameCompiler(Binder *binder)
+ : _M_binder(binder), _M_token_stream(binder->tokenStream())
+{
+}
+
+QString NameCompiler::decode_operator(std::size_t index) const
+{
+ const Token &tk = _M_token_stream->token((int) index);
+ return QString::fromUtf8(&tk.text[tk.position], (int) tk.size);
+}
+
+QString NameCompiler::internal_run(AST *node)
+{
+ _M_name.clear();
+ visit(node);
+ return name();
+}
+
+void NameCompiler::visitUnqualifiedName(UnqualifiedNameAST *node)
+{
+ QString tmp_name;
+
+ if (node->tilde)
+ tmp_name += QLatin1String("~");
+
+ if (node->id)
+ tmp_name += _M_token_stream->symbol(node->id)->as_string();
+
+ if (OperatorFunctionIdAST *op_id = node->operator_id) {
+#if defined(__GNUC__)
+#warning "NameCompiler::visitUnqualifiedName() -- implement me"
+#endif
+
+ if (op_id->op && op_id->op->op) {
+ tmp_name += QLatin1String("operator");
+ tmp_name += decode_operator(op_id->op->op);
+ if (op_id->op->close)
+ tmp_name += decode_operator(op_id->op->close);
+ } else if (op_id->type_specifier) {
+#if defined(__GNUC__)
+#warning "don't use an hardcoded string as cast' name"
+#endif
+ Token const &tk = _M_token_stream->token((int) op_id->start_token);
+ Token const &end_tk = _M_token_stream->token((int) op_id->end_token);
+ tmp_name += QString::fromLatin1(&tk.text[tk.position],
+ (int)(end_tk.position - tk.position)).trimmed();
+ }
+ }
+
+ _M_name += tmp_name;
+ if (node->template_arguments) {
+ // ### cleanup
+ _M_name.last() += QLatin1String("<");
+ visitNodes(this, node->template_arguments);
+ _M_name.last().truncate(_M_name.last().count() - 1); // remove the last ','
+ _M_name.last() += QLatin1String(">");
+ }
+
+}
+
+void NameCompiler::visitTemplateArgument(TemplateArgumentAST *node)
+{
+ if (node->type_id && node->type_id->type_specifier) {
+ TypeCompiler type_cc(_M_binder);
+ type_cc.run(node->type_id->type_specifier);
+
+ DeclaratorCompiler decl_cc(_M_binder);
+ decl_cc.run(node->type_id->declarator);
+
+ if (type_cc.isConstant())
+ _M_name.last() += QLatin1String("const ");
+
+ QStringList q = type_cc.qualifiedName();
+
+ if (q.count() == 1) {
+#if defined (RXX_RESOLVE_TYPEDEF) // ### it'll break :(
+ TypeInfo tp;
+ tp.setQualifiedName(q);
+ tp = TypeInfo::resolveType(tp, _M_binder->currentScope()->toItem());
+ q = tp.qualifiedName();
+#endif
+
+ if (CodeModelItem item = _M_binder->model()->findItem(q, _M_binder->currentScope())) {
+ if (item->name() == q.last())
+ q = item->qualifiedName();
+ }
+ }
+
+ _M_name.last() += q.join(QLatin1String("::"));
+
+ if (decl_cc.isReference())
+ _M_name.last() += QLatin1Char('&');
+ if (decl_cc.indirection())
+ _M_name.last() += QString(decl_cc.indirection(), QLatin1Char('*'));
+
+ _M_name.last() += QLatin1Char(',');
+ }
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/name_compiler.h b/sources/shiboken2/ApiExtractor/parser/name_compiler.h
new file mode 100644
index 000000000..431d401f8
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/name_compiler.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef NAME_COMPILER_H
+#define NAME_COMPILER_H
+
+#include "default_visitor.h"
+#include <QtCore/QStringList>
+
+class TokenStream;
+class Binder;
+
+class NameCompiler: protected DefaultVisitor
+{
+public:
+ NameCompiler(Binder *binder);
+
+ void run(NameAST *node) {
+ internal_run(node);
+ }
+ void run(UnqualifiedNameAST *node) {
+ internal_run(node);
+ }
+
+ QString name() const {
+ return _M_name.join(QLatin1String("::"));
+ }
+ QStringList qualifiedName() const {
+ return _M_name;
+ }
+
+protected:
+ virtual void visitUnqualifiedName(UnqualifiedNameAST *node);
+ virtual void visitTemplateArgument(TemplateArgumentAST *node);
+
+ QString internal_run(AST *node);
+ QString decode_operator(std::size_t index) const;
+
+private:
+ Binder *_M_binder;
+ TokenStream *_M_token_stream;
+ QStringList _M_name;
+};
+
+#endif // NAME_COMPILER_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/parser.cpp b/sources/shiboken2/ApiExtractor/parser/parser.cpp
new file mode 100644
index 000000000..60d034e83
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/parser.cpp
@@ -0,0 +1,4075 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+
+// c++ support
+#include "parser.h"
+#include "tokens.h"
+#include "lexer.h"
+#include "control.h"
+
+#include <cstdlib>
+
+#define ADVANCE(tk, descr) \
+ { \
+ if (token_stream.lookAhead() != tk) { \
+ tokenRequiredError(tk); \
+ return false; \
+ } \
+ token_stream.nextToken(); \
+ }
+
+#define ADVANCE_NR(tk, descr) \
+ do { \
+ if (token_stream.lookAhead() != tk) { \
+ tokenRequiredError(tk); \
+ } \
+ else \
+ token_stream.nextToken(); \
+ } while (0)
+
+#define CHECK(tk) \
+ do { \
+ if (token_stream.lookAhead() != tk) { \
+ return false; \
+ } \
+ token_stream.nextToken(); \
+ } while (0)
+
+#define UPDATE_POS(_node, start, end) \
+ do { \
+ (_node)->start_token = start; \
+ (_node)->end_token = end; \
+ } while (0)
+
+Parser::Parser(Control *c)
+ : _M_location(token_stream, location_table, line_table),
+ control(c),
+ lexer(_M_location, control)
+{
+ _M_block_errors = false;
+}
+
+Parser::~Parser()
+{
+}
+
+void Parser::advance()
+{
+ token_stream.nextToken();
+}
+
+TranslationUnitAST *Parser::parse(const char *contents,
+ std::size_t size, pool *p)
+{
+ _M_block_errors = false;
+ _M_pool = p;
+ lexer.tokenize(contents, size);
+ token_stream.nextToken(); // skip the first token
+
+ Lexer *oldLexer = control->changeLexer(&lexer);
+ Parser *oldParser = control->changeParser(this);
+
+ TranslationUnitAST *ast = 0;
+ parseTranslationUnit(ast);
+
+ control->changeLexer(oldLexer);
+ control->changeParser(oldParser);
+
+ return ast;
+}
+
+bool Parser::parseWinDeclSpec(WinDeclSpecAST *&node)
+{
+ if (token_stream.lookAhead() != Token_identifier)
+ return false;
+
+ std::size_t start = token_stream.cursor();
+
+ const NameSymbol *name_symbol = token_stream.symbol(token_stream.cursor());
+ QString name = name_symbol->as_string();
+ if (name != QLatin1String("__declspec"))
+ return false;
+ std::size_t specifier = token_stream.cursor();
+
+ token_stream.nextToken();
+ if (token_stream.lookAhead() != '(')
+ return false;
+
+ token_stream.nextToken();
+ if (token_stream.lookAhead() != Token_identifier)
+ return false;
+ std::size_t modifier = token_stream.cursor();
+
+ token_stream.nextToken();
+ if (token_stream.lookAhead() != ')')
+ return false;
+
+ token_stream.nextToken();
+
+ node = CreateNode<WinDeclSpecAST>(_M_pool);
+ node->specifier = specifier;
+ node->modifier = modifier;
+
+ UPDATE_POS(node, start, token_stream.cursor());
+
+ return true;
+}
+
+void Parser::tokenRequiredError(int token)
+{
+ QString err;
+
+ err += QLatin1String("expected token ");
+ err += QLatin1String("``");
+ err += QLatin1String(token_name(token));
+ err += QLatin1String("'' found ``");
+ err += QLatin1String(token_name(token_stream.lookAhead()));
+ err += QLatin1String("''");
+
+ reportError(err);
+}
+
+void Parser::syntaxError()
+{
+ QString err;
+
+ err += QLatin1String("unexpected token ");
+ err += QLatin1String("``");
+ err += QLatin1String(token_name(token_stream.lookAhead()));
+ err += QLatin1String("''");
+
+ reportError(err);
+}
+
+void Parser::reportError(const QString& msg)
+{
+ if (!_M_block_errors) {
+ int line, column;
+ QString fileName;
+
+ std::size_t tok = token_stream.cursor();
+ location().positionAt(token_stream.position(tok),
+ &line, &column, &fileName);
+
+ Control::ErrorMessage errmsg;
+ errmsg.setLine(line + 1);
+ errmsg.setColumn(column);
+ errmsg.setFileName(fileName);
+ errmsg.setMessage(QLatin1String("** PARSER ERROR ") + msg);
+ control->reportError(errmsg);
+ }
+}
+
+bool Parser::skipUntil(int token)
+{
+ while (token_stream.lookAhead()) {
+ if (token_stream.lookAhead() == token)
+ return true;
+
+ token_stream.nextToken();
+ }
+
+ return false;
+}
+
+bool Parser::skipUntilDeclaration()
+{
+ while (token_stream.lookAhead()) {
+
+ switch (token_stream.lookAhead()) {
+ case ';':
+ case '~':
+ case Token_scope:
+ case Token_identifier:
+ case Token_operator:
+ case Token_char:
+ case Token_wchar_t:
+ case Token_bool:
+ case Token_short:
+ case Token_int:
+ case Token_long:
+ case Token_signed:
+ case Token_unsigned:
+ case Token_float:
+ case Token_double:
+ case Token_void:
+ case Token_extern:
+ case Token_namespace:
+ case Token_using:
+ case Token_typedef:
+ case Token_asm:
+ case Token_template:
+ case Token_export:
+
+ case Token_const: // cv
+ case Token_volatile: // cv
+
+ case Token_public:
+ case Token_protected:
+ case Token_private:
+ case Token_signals: // Qt
+ case Token_slots: // Qt
+ return true;
+
+ default:
+ token_stream.nextToken();
+ }
+ }
+
+ return false;
+}
+
+bool Parser::skipUntilStatement()
+{
+ while (token_stream.lookAhead()) {
+ switch (token_stream.lookAhead()) {
+ case ';':
+ case '{':
+ case '}':
+ case Token_const:
+ case Token_volatile:
+ case Token_identifier:
+ case Token_case:
+ case Token_default:
+ case Token_if:
+ case Token_switch:
+ case Token_while:
+ case Token_do:
+ case Token_for:
+ case Token_break:
+ case Token_continue:
+ case Token_return:
+ case Token_goto:
+ case Token_try:
+ case Token_catch:
+ case Token_throw:
+ case Token_char:
+ case Token_wchar_t:
+ case Token_bool:
+ case Token_short:
+ case Token_int:
+ case Token_long:
+ case Token_signed:
+ case Token_unsigned:
+ case Token_float:
+ case Token_double:
+ case Token_void:
+ case Token_class:
+ case Token_struct:
+ case Token_union:
+ case Token_enum:
+ case Token_scope:
+ case Token_template:
+ case Token_using:
+ return true;
+
+ default:
+ token_stream.nextToken();
+ }
+ }
+
+ return false;
+}
+
+bool Parser::skip(int l, int r)
+{
+ int count = 0;
+ while (token_stream.lookAhead()) {
+ int tk = token_stream.lookAhead();
+
+ if (tk == l)
+ ++count;
+ else if (tk == r)
+ --count;
+ else if (l != '{' && (tk == '{' || tk == '}' || tk == ';'))
+ return false;
+
+ if (!count)
+ return true;
+
+ token_stream.nextToken();
+ }
+
+ return false;
+}
+
+bool Parser::parseName(NameAST *&node, bool acceptTemplateId)
+{
+ std::size_t start = token_stream.cursor();
+
+ WinDeclSpecAST *winDeclSpec = 0;
+ parseWinDeclSpec(winDeclSpec);
+
+ NameAST *ast = CreateNode<NameAST>(_M_pool);
+
+ if (token_stream.lookAhead() == Token_scope) {
+ ast->global = true;
+ token_stream.nextToken();
+ }
+
+ std::size_t idx = token_stream.cursor();
+
+ while (true) {
+ UnqualifiedNameAST *n = 0;
+ if (!parseUnqualifiedName(n))
+ return false;
+
+ if (token_stream.lookAhead() == Token_scope) {
+ token_stream.nextToken();
+
+ ast->qualified_names
+ = snoc(ast->qualified_names, n, _M_pool);
+
+ if (token_stream.lookAhead() == Token_template) {
+ /// skip optional template #### @todo CHECK
+ token_stream.nextToken();
+ }
+ } else {
+ Q_ASSERT(n);
+ if (!acceptTemplateId) {
+ token_stream.rewind((int) n->start_token);
+ parseUnqualifiedName(n, false);
+ }
+
+ ast->unqualified_name = n;
+ break;
+ }
+ }
+
+ if (idx == token_stream.cursor())
+ return false;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseTranslationUnit(TranslationUnitAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+ TranslationUnitAST *ast = CreateNode<TranslationUnitAST>(_M_pool);
+
+ while (token_stream.lookAhead()) {
+ std::size_t startDecl = token_stream.cursor();
+
+ DeclarationAST *declaration = 0;
+ if (parseDeclaration(declaration)) {
+ ast->declarations =
+ snoc(ast->declarations, declaration, _M_pool);
+ } else {
+ // error recovery
+ if (startDecl == token_stream.cursor()) {
+ // skip at least one token
+ token_stream.nextToken();
+ }
+
+ skipUntilDeclaration();
+ }
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseDeclaration(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ switch (token_stream.lookAhead()) {
+ case ';':
+ token_stream.nextToken();
+ return true;
+
+ case Token_extern:
+ return parseLinkageSpecification(node);
+
+ case Token_namespace:
+ return parseNamespace(node);
+
+ case Token_using:
+ return parseUsing(node);
+
+ case Token_typedef:
+ return parseTypedef(node);
+
+ case Token_asm:
+ return parseAsmDefinition(node);
+
+ case Token_Q_ENUMS:
+ case Token_Q_ENUM:
+ // Qt5:
+ // These two Q_ENUM tokens map to the same handler.
+ // If that turns out to be wrong, then write a new one
+ // named parseQ_ENUM
+ return parseQ_ENUMS(node);
+
+ case Token_template:
+ case Token_export:
+ return parseTemplateDeclaration(node);
+
+ default: {
+ const ListNode<std::size_t> *cv = 0;
+ parseCvQualify(cv);
+
+ const ListNode<std::size_t> *storageSpec = 0;
+ parseStorageClassSpecifier(storageSpec);
+
+ parseCvQualify(cv);
+
+ TypeSpecifierAST *spec = 0;
+ if (parseEnumSpecifier(spec)
+ || parseClassSpecifier(spec)
+ || parseForwardDeclarationSpecifier(spec)) {
+ parseCvQualify(cv);
+
+ spec->cv = cv;
+
+ const ListNode<InitDeclaratorAST*> *declarators = 0;
+ parseInitDeclaratorList(declarators);
+ ADVANCE(';', ";");
+
+ SimpleDeclarationAST *ast =
+ CreateNode<SimpleDeclarationAST>(_M_pool);
+
+ ast->storage_specifiers = storageSpec;
+ ast->type_specifier = spec;
+ ast->init_declarators = declarators;
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+ }
+ }
+ } // end switch
+
+ token_stream.rewind((int) start);
+ return parseDeclarationInternal(node);
+}
+
+bool Parser::parseLinkageSpecification(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(Token_extern);
+
+ LinkageSpecificationAST *ast = CreateNode<LinkageSpecificationAST>(_M_pool);
+
+ if (token_stream.lookAhead() == Token_string_literal) {
+ ast->extern_type = token_stream.cursor();
+ token_stream.nextToken();
+ }
+
+ if (token_stream.lookAhead() == '{')
+ parseLinkageBody(ast->linkage_body);
+ else if (!parseDeclaration(ast->declaration))
+ reportError(QLatin1String("Declaration syntax error"));
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseLinkageBody(LinkageBodyAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK('{');
+
+ LinkageBodyAST *ast = CreateNode<LinkageBodyAST>(_M_pool);
+
+ while (token_stream.lookAhead()) {
+ int tk = token_stream.lookAhead();
+
+ if (tk == '}')
+ break;
+
+ std::size_t startDecl = token_stream.cursor();
+
+ DeclarationAST *declaration = 0;
+ if (parseDeclaration(declaration)) {
+ ast->declarations = snoc(ast->declarations, declaration, _M_pool);
+ } else {
+ // error recovery
+ if (startDecl == token_stream.cursor()) {
+ // skip at least one token
+ token_stream.nextToken();
+ }
+
+ skipUntilDeclaration();
+ }
+ }
+
+ if (token_stream.lookAhead() != '}')
+ reportError(QLatin1String("} expected"));
+ else
+ token_stream.nextToken();
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseNamespace(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(Token_namespace);
+
+ std::size_t namespace_name = 0;
+ if (token_stream.lookAhead() == Token_identifier) {
+ namespace_name = token_stream.cursor();
+ token_stream.nextToken();
+ }
+
+ if (token_stream.lookAhead() == '=') {
+ // namespace alias
+ token_stream.nextToken();
+
+ NameAST *name = 0;
+ if (parseName(name)) {
+ ADVANCE(';', ";");
+
+ NamespaceAliasDefinitionAST *ast
+ = CreateNode<NamespaceAliasDefinitionAST>(_M_pool);
+ ast->namespace_name = namespace_name;
+ ast->alias_name = name;
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ return true;
+ } else {
+ reportError(QLatin1String("namespace expected"));
+ return false;
+ }
+ } else if (token_stream.lookAhead() != '{') {
+ reportError(QLatin1String("{ expected"));
+ return false;
+ }
+
+ NamespaceAST *ast = CreateNode<NamespaceAST>(_M_pool);
+ ast->namespace_name = namespace_name;
+ parseLinkageBody(ast->linkage_body);
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseUsing(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(Token_using);
+
+ if (token_stream.lookAhead() == Token_namespace)
+ return parseUsingDirective(node);
+
+ UsingAST *ast = CreateNode<UsingAST>(_M_pool);
+
+ if (token_stream.lookAhead() == Token_typename) {
+ ast->type_name = token_stream.cursor();
+ token_stream.nextToken();
+ }
+
+ if (!parseName(ast->name))
+ return false;
+
+ ADVANCE(';', ";");
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseUsingDirective(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(Token_namespace);
+
+ NameAST *name = 0;
+ if (!parseName(name)) {
+ reportError(QLatin1String("Namespace name expected"));
+ return false;
+ }
+
+ ADVANCE(';', ";");
+
+ UsingDirectiveAST *ast = CreateNode<UsingDirectiveAST>(_M_pool);
+ ast->name = name;
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+
+bool Parser::parseOperatorFunctionId(OperatorFunctionIdAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(Token_operator);
+
+ OperatorFunctionIdAST *ast = CreateNode<OperatorFunctionIdAST>(_M_pool);
+
+ if (!parseOperator(ast->op)) {
+ ast->op = 0;
+
+ // parse cast operator
+ const ListNode<std::size_t> *cv = 0;
+ parseCvQualify(cv);
+
+ if (!parseSimpleTypeSpecifier(ast->type_specifier)) {
+ syntaxError();
+ return false;
+ }
+
+ parseCvQualify(cv);
+ ast->type_specifier->cv = cv;
+
+ PtrOperatorAST *ptr_op = 0;
+ while (parsePtrOperator(ptr_op))
+ ast->ptr_ops = snoc(ast->ptr_ops, ptr_op, _M_pool);
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ return true;
+}
+
+bool Parser::parseTemplateArgumentList(const ListNode<TemplateArgumentAST*> *&node,
+ bool reportError)
+{
+ TemplateArgumentAST *templArg = 0;
+ if (!parseTemplateArgument(templArg))
+ return false;
+
+ node = snoc(node, templArg, _M_pool);
+
+ while (token_stream.lookAhead() == ',') {
+ token_stream.nextToken();
+
+ if (!parseTemplateArgument(templArg)) {
+ if (reportError) {
+ syntaxError();
+ break;
+ }
+
+ node = 0;
+ return false;
+ }
+
+ node = snoc(node, templArg, _M_pool);
+ }
+
+ return true;
+}
+
+bool Parser::parseTypedef(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(Token_typedef);
+
+ TypeSpecifierAST *spec = 0;
+ if (!parseTypeSpecifierOrClassSpec(spec)) {
+ reportError(QLatin1String("Need a type specifier to declare"));
+ return false;
+ }
+
+ const ListNode<InitDeclaratorAST*> *declarators = 0;
+ if (!parseInitDeclaratorList(declarators)) {
+ //reportError(("Need an identifier to declare"));
+ //return false;
+ }
+
+ ADVANCE(';', ";");
+
+ TypedefAST *ast = CreateNode<TypedefAST>(_M_pool);
+ ast->type_specifier = spec;
+ ast->init_declarators = declarators;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseAsmDefinition(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ ADVANCE(Token_asm, "asm");
+
+ const ListNode<std::size_t> *cv = 0;
+ parseCvQualify(cv);
+
+#if defined(__GNUC__)
+#warning "implement me"
+#endif
+ skip('(', ')');
+ token_stream.nextToken();
+ ADVANCE(';', ";");
+
+ AsmDefinitionAST *ast = CreateNode<AsmDefinitionAST>(_M_pool);
+ ast->cv = cv;
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseTemplateDeclaration(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ std::size_t exported = 0;
+ if (token_stream.lookAhead() == Token_export) {
+ exported = token_stream.cursor();
+ token_stream.nextToken();
+ }
+
+ CHECK(Token_template);
+
+ const ListNode<TemplateParameterAST*> *params = 0;
+ if (token_stream.lookAhead() == '<') {
+ token_stream.nextToken();
+ parseTemplateParameterList(params);
+
+ ADVANCE('>', ">");
+ }
+
+ DeclarationAST *declaration = 0;
+ if (!parseDeclaration(declaration))
+ reportError(QLatin1String("expected a declaration"));
+
+ TemplateDeclarationAST *ast = CreateNode<TemplateDeclarationAST>(_M_pool);
+ ast->exported = exported;
+ ast->template_parameters = params;
+ ast->declaration = declaration;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseOperator(OperatorAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ OperatorAST *ast = CreateNode<OperatorAST>(_M_pool);
+
+ switch (token_stream.lookAhead()) {
+ case Token_new:
+ case Token_delete: {
+ ast->op = token_stream.cursor();
+ token_stream.nextToken();
+
+ if (token_stream.lookAhead() == '['
+ && token_stream.lookAhead(1) == ']') {
+ ast->open = token_stream.cursor();
+ token_stream.nextToken();
+
+ ast->close = token_stream.cursor();
+ token_stream.nextToken();
+ }
+ }
+ break;
+
+ case '+':
+ case '-':
+ case '*':
+ case '/':
+ case '%':
+ case '^':
+ case '&':
+ case '|':
+ case '~':
+ case '!':
+ case '=':
+ case '<':
+ case '>':
+ case ',':
+ case Token_assign:
+ case Token_shift:
+ case Token_eq:
+ case Token_not_eq:
+ case Token_leq:
+ case Token_geq:
+ case Token_and:
+ case Token_or:
+ case Token_incr:
+ case Token_decr:
+ case Token_ptrmem:
+ case Token_arrow:
+ ast->op = token_stream.cursor();
+ token_stream.nextToken();
+ break;
+
+ default:
+ if (token_stream.lookAhead() == '('
+ && token_stream.lookAhead(1) == ')') {
+ ast->op = ast->open = token_stream.cursor();
+ token_stream.nextToken();
+ ast->close = token_stream.cursor();
+ token_stream.nextToken();
+ } else if (token_stream.lookAhead() == '['
+ && token_stream.lookAhead(1) == ']') {
+ ast->op = ast->open = token_stream.cursor();
+ token_stream.nextToken();
+ ast->close = token_stream.cursor();
+ token_stream.nextToken();
+ } else {
+ return false;
+ }
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseCvQualify(const ListNode<std::size_t> *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ int tk;
+ while (0 != (tk = token_stream.lookAhead())
+ && (tk == Token_const || tk == Token_volatile)) {
+ node = snoc(node, token_stream.cursor(), _M_pool);
+ token_stream.nextToken();
+ }
+
+ return start != token_stream.cursor();
+}
+
+bool Parser::parseSimpleTypeSpecifier(TypeSpecifierAST *&node,
+ bool onlyIntegral)
+{
+ std::size_t start = token_stream.cursor();
+ bool isIntegral = false;
+ bool done = false;
+
+ const ListNode<std::size_t> *integrals = 0;
+
+ while (!done) {
+ switch (token_stream.lookAhead()) {
+ case Token_char:
+ case Token_wchar_t:
+ case Token_bool:
+ case Token_short:
+ case Token_int:
+ case Token_long:
+ case Token_signed:
+ case Token_unsigned:
+ case Token_float:
+ case Token_double:
+ case Token_void:
+ integrals = snoc(integrals, token_stream.cursor(), _M_pool);
+ isIntegral = true;
+ token_stream.nextToken();
+ break;
+
+ default:
+ done = true;
+ }
+ }
+
+ SimpleTypeSpecifierAST *ast = CreateNode<SimpleTypeSpecifierAST>(_M_pool);
+ if (isIntegral) {
+ ast->integrals = integrals;
+ } else if (token_stream.lookAhead() == Token___typeof) {
+ ast->type_of = token_stream.cursor();
+ token_stream.nextToken();
+
+ if (token_stream.lookAhead() == '(') {
+ token_stream.nextToken();
+
+ std::size_t saved = token_stream.cursor();
+ parseTypeId(ast->type_id);
+ if (token_stream.lookAhead() != ')') {
+ ast->type_id = 0;
+ token_stream.rewind((int) saved);
+ parseUnaryExpression(ast->expression);
+ }
+ ADVANCE(')', ")");
+ } else {
+ parseUnaryExpression(ast->expression);
+ }
+ } else if (onlyIntegral) {
+ token_stream.rewind((int) start);
+ return false;
+ } else {
+ if (!parseName(ast->name, true)) {
+ ast->name = 0;
+ token_stream.rewind((int) start);
+ return false;
+ }
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parsePtrOperator(PtrOperatorAST *&node)
+{
+ int tk = token_stream.lookAhead();
+
+ if (tk != '&' && tk != '*'
+ && tk != Token_scope && tk != Token_identifier) {
+ return false;
+ }
+
+ std::size_t start = token_stream.cursor();
+
+ PtrOperatorAST *ast = CreateNode<PtrOperatorAST>(_M_pool);
+
+ switch (token_stream.lookAhead()) {
+ case '&':
+ case '*':
+ ast->op = token_stream.cursor();
+ token_stream.nextToken();
+ break;
+
+ case Token_scope:
+ case Token_identifier: {
+ if (!parsePtrToMember(ast->mem_ptr)) {
+ token_stream.rewind((int) start);
+ return false;
+ }
+ }
+ break;
+
+ default:
+ Q_ASSERT(0);
+ break;
+ }
+
+ parseCvQualify(ast->cv);
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseTemplateArgument(TemplateArgumentAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ TypeIdAST *typeId = 0;
+ ExpressionAST *expr = 0;
+
+ if (!parseTypeId(typeId) || (token_stream.lookAhead() != ','
+ && token_stream.lookAhead() != '>')) {
+ token_stream.rewind((int) start);
+
+ if (!parseLogicalOrExpression(expr, true))
+ return false;
+ }
+
+ TemplateArgumentAST *ast = CreateNode<TemplateArgumentAST>(_M_pool);
+ ast->type_id = typeId;
+ ast->expression = expr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseTypeSpecifier(TypeSpecifierAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ const ListNode<std::size_t> *cv = 0;
+ parseCvQualify(cv);
+
+ TypeSpecifierAST *ast = 0;
+ if (!parseElaboratedTypeSpecifier(ast) && !parseSimpleTypeSpecifier(ast)) {
+ token_stream.rewind((int) start);
+ return false;
+ }
+
+ parseCvQualify(cv);
+ ast->cv = cv;
+
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseDeclarator(DeclaratorAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ DeclaratorAST *ast = CreateNode<DeclaratorAST>(_M_pool);
+
+ //fprintf(stderr, "[%s-%s] ast->ptr_ops: %p\n", __FILE__, __FUNCTION__, ast->ptr_ops);
+
+ DeclaratorAST *decl = 0;
+ NameAST *declId = 0;
+
+ PtrOperatorAST *ptrOp = 0;
+ while (parsePtrOperator(ptrOp))
+ ast->ptr_ops = snoc(ast->ptr_ops, ptrOp, _M_pool);
+
+ if (token_stream.lookAhead() == '(') {
+ token_stream.nextToken();
+
+ if (!parseDeclarator(decl))
+ return false;
+
+ ast->sub_declarator = decl;
+
+ CHECK(')');
+ } else {
+ if (token_stream.lookAhead() == ':') {
+ // unnamed bitfield
+ } else if (parseName(declId, true)) {
+ ast->id = declId;
+ } else {
+ token_stream.rewind((int) start);
+ return false;
+ }
+
+ if (token_stream.lookAhead() == ':') {
+ token_stream.nextToken();
+
+ if (!parseConstantExpression(ast->bit_expression))
+ reportError(QLatin1String("Constant expression expected"));
+
+ goto update_pos;
+ }
+ }
+
+ {
+ bool isVector = true;
+
+ while (token_stream.lookAhead() == '[') {
+ token_stream.nextToken();
+
+ ExpressionAST *expr = 0;
+ parseCommaExpression(expr);
+
+ ADVANCE(']', "]");
+
+ ast->array_dimensions = snoc(ast->array_dimensions, expr, _M_pool);
+ isVector = true;
+ }
+
+ bool skipParen = false;
+ if (token_stream.lookAhead() == Token_identifier
+ && token_stream.lookAhead(1) == '('
+ && token_stream.lookAhead(2) == '(') {
+ token_stream.nextToken();
+ token_stream.nextToken();
+ skipParen = true;
+ }
+
+ int tok = token_stream.lookAhead();
+ if (ast->sub_declarator
+ && !(isVector || tok == '(' || tok == ','
+ || tok == ';' || tok == '=')) {
+ token_stream.rewind((int) start);
+ return false;
+ }
+
+ std::size_t index = token_stream.cursor();
+ if (token_stream.lookAhead() == '(') {
+ token_stream.nextToken();
+
+ ParameterDeclarationClauseAST *params = 0;
+ if (!parseParameterDeclarationClause(params)) {
+ token_stream.rewind((int) index);
+ goto update_pos;
+ }
+
+ ast->parameter_declaration_clause = params;
+
+ if (token_stream.lookAhead() != ')') {
+ token_stream.rewind((int) index);
+ goto update_pos;
+ }
+
+ token_stream.nextToken(); // skip ')'
+
+ parseCvQualify(ast->fun_cv);
+ parseNoExcept();
+ parseExceptionSpecification(ast->exception_spec);
+
+ if (token_stream.lookAhead() == Token___attribute__)
+ parse_Attribute__();
+ }
+
+ if (skipParen) {
+ if (token_stream.lookAhead() != ')')
+ reportError(QLatin1String("')' expected"));
+ else
+ token_stream.nextToken();
+ }
+ }
+
+update_pos:
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseAbstractDeclarator(DeclaratorAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ DeclaratorAST *ast = CreateNode<DeclaratorAST>(_M_pool);
+ DeclaratorAST *decl = 0;
+
+ PtrOperatorAST *ptrOp = 0;
+ while (parsePtrOperator(ptrOp))
+ ast->ptr_ops = snoc(ast->ptr_ops, ptrOp, _M_pool);
+
+ int index = (int) token_stream.cursor();
+ if (token_stream.lookAhead() == '(') {
+ token_stream.nextToken();
+
+ if (!parseAbstractDeclarator(decl)) {
+ token_stream.rewind((int) index);
+ goto label1;
+ }
+
+ ast->sub_declarator = decl;
+
+ if (token_stream.lookAhead() != ')') {
+ token_stream.rewind((int) start);
+ return false;
+ }
+ token_stream.nextToken();
+ } else if (token_stream.lookAhead() == ':') {
+ token_stream.nextToken();
+ if (!parseConstantExpression(ast->bit_expression)) {
+ ast->bit_expression = 0;
+ reportError(QLatin1String("Constant expression expected"));
+ }
+ goto update_pos;
+ }
+
+label1: {
+ bool isVector = true;
+
+ while (token_stream.lookAhead() == '[') {
+ token_stream.nextToken();
+
+ ExpressionAST *expr = 0;
+ parseCommaExpression(expr);
+
+ ADVANCE(']', "]");
+
+ ast->array_dimensions = snoc(ast->array_dimensions, expr, _M_pool);
+ isVector = true;
+ }
+
+ int tok = token_stream.lookAhead();
+ if (ast->sub_declarator
+ && !(isVector || tok == '(' || tok == ','
+ || tok == ';' || tok == '=')) {
+ token_stream.rewind((int) start);
+ return false;
+ }
+
+ int index = (int) token_stream.cursor();
+ if (token_stream.lookAhead() == '(') {
+ token_stream.nextToken();
+
+ ParameterDeclarationClauseAST *params = 0;
+ if (!parseParameterDeclarationClause(params)) {
+ token_stream.rewind((int) index);
+ goto update_pos;
+ }
+
+ ast->parameter_declaration_clause = params;
+
+ if (token_stream.lookAhead() != ')') {
+ token_stream.rewind((int) index);
+ goto update_pos;
+ }
+
+ token_stream.nextToken(); // skip ')'
+
+ parseCvQualify(ast->fun_cv);
+ parseExceptionSpecification(ast->exception_spec);
+ }
+ }
+
+update_pos:
+ if (token_stream.cursor() == start)
+ return false;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseEnumSpecifier(TypeSpecifierAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(Token_enum);
+
+ NameAST *name = 0;
+ parseName(name);
+
+ if (token_stream.lookAhead() != '{') {
+ token_stream.rewind((int) start);
+ return false;
+ }
+ token_stream.nextToken();
+
+ EnumSpecifierAST *ast = CreateNode<EnumSpecifierAST>(_M_pool);
+ ast->name = name;
+
+ EnumeratorAST *enumerator = 0;
+ if (parseEnumerator(enumerator)) {
+ ast->enumerators = snoc(ast->enumerators, enumerator, _M_pool);
+
+ while (token_stream.lookAhead() == ',') {
+ token_stream.nextToken();
+
+ if (!parseEnumerator(enumerator)) {
+ //reportError(("Enumerator expected"));
+ break;
+ }
+
+ ast->enumerators = snoc(ast->enumerators, enumerator, _M_pool);
+ }
+ }
+
+ ADVANCE_NR('}', "}");
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseTemplateParameterList(const ListNode<TemplateParameterAST*> *&node)
+{
+ TemplateParameterAST *param = 0;
+ if (!parseTemplateParameter(param))
+ return false;
+
+ node = snoc(node, param, _M_pool);
+
+ while (token_stream.lookAhead() == ',') {
+ token_stream.nextToken();
+
+ if (!parseTemplateParameter(param)) {
+ syntaxError();
+ break;
+ } else {
+ node = snoc(node, param, _M_pool);
+ }
+ }
+
+ return true;
+}
+
+bool Parser::parseTemplateParameter(TemplateParameterAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+ TemplateParameterAST *ast = CreateNode<TemplateParameterAST>(_M_pool);
+
+ int tk = token_stream.lookAhead();
+
+ if ((tk == Token_class || tk == Token_typename || tk == Token_template)
+ && parseTypeParameter(ast->type_parameter)) {
+ // nothing to do
+ } else if (!parseParameterDeclaration(ast->parameter_declaration))
+ return false;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseTypeParameter(TypeParameterAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ TypeParameterAST *ast = CreateNode<TypeParameterAST>(_M_pool);
+ ast->type = start;
+
+ switch (token_stream.lookAhead()) {
+ case Token_class:
+ case Token_typename: {
+ token_stream.nextToken(); // skip class
+
+ // parse optional name
+ if (parseName(ast->name, true)) {
+ if (token_stream.lookAhead() == '=') {
+ token_stream.nextToken();
+
+ if (!parseTypeId(ast->type_id)) {
+ //syntaxError();
+ token_stream.rewind((int) start);
+ return false;
+ }
+ } else if (token_stream.lookAhead() != ','
+ && token_stream.lookAhead() != '>') {
+ token_stream.rewind((int) start);
+ return false;
+ }
+ }
+ }
+ break;
+
+ case Token_template: {
+ token_stream.nextToken(); // skip template
+ ADVANCE('<', "<");
+
+ if (!parseTemplateParameterList(ast->template_parameters))
+ return false;
+
+ ADVANCE('>', ">");
+
+ if (token_stream.lookAhead() == Token_class)
+ token_stream.nextToken();
+
+ // parse optional name
+ if (parseName(ast->name, true)) {
+ if (token_stream.lookAhead() == '=') {
+ token_stream.nextToken();
+
+ if (!parseTypeId(ast->type_id)) {
+ syntaxError();
+ return false;
+ }
+ }
+ }
+
+ if (token_stream.lookAhead() == '=') {
+ token_stream.nextToken();
+
+ parseName(ast->template_name, true);
+ }
+ }
+ break;
+
+ default:
+ return false;
+
+ } // end switch
+
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ return true;
+}
+
+bool Parser::parseStorageClassSpecifier(const ListNode<std::size_t> *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ int tk;
+ while (0 != (tk = token_stream.lookAhead())
+ && (tk == Token_friend || tk == Token_auto
+ || tk == Token_register || tk == Token_static
+ || tk == Token_extern || tk == Token_mutable)) {
+ node = snoc(node, token_stream.cursor(), _M_pool);
+ token_stream.nextToken();
+ }
+
+ return start != token_stream.cursor();
+}
+
+bool Parser::parseFunctionSpecifier(const ListNode<std::size_t> *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ int tk;
+ while (0 != (tk = token_stream.lookAhead())
+ && (tk == Token_inline || tk == Token_virtual
+ || tk == Token_explicit || tk == Token_Q_INVOKABLE)) {
+ node = snoc(node, token_stream.cursor(), _M_pool);
+ token_stream.nextToken();
+ }
+
+ return start != token_stream.cursor();
+}
+
+bool Parser::parseTypeId(TypeIdAST *&node)
+{
+ /// @todo implement the AST for typeId
+ std::size_t start = token_stream.cursor();
+
+ TypeSpecifierAST *spec = 0;
+ if (!parseTypeSpecifier(spec)) {
+ token_stream.rewind((int) start);
+ return false;
+ }
+
+ DeclaratorAST *decl = 0;
+ parseAbstractDeclarator(decl);
+
+ TypeIdAST *ast = CreateNode<TypeIdAST>(_M_pool);
+ ast->type_specifier = spec;
+ ast->declarator = decl;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseInitDeclaratorList(const ListNode<InitDeclaratorAST*> *&node)
+{
+ InitDeclaratorAST *decl = 0;
+ if (!parseInitDeclarator(decl))
+ return false;
+
+ node = snoc(node, decl, _M_pool);
+
+ while (token_stream.lookAhead() == ',') {
+ token_stream.nextToken();
+
+ if (!parseInitDeclarator(decl)) {
+ syntaxError();
+ break;
+ }
+ node = snoc(node, decl, _M_pool);
+ }
+
+ return true;
+}
+
+bool Parser::parseParameterDeclarationClause(ParameterDeclarationClauseAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ ParameterDeclarationClauseAST *ast
+ = CreateNode<ParameterDeclarationClauseAST>(_M_pool);
+
+ if (!parseParameterDeclarationList(ast->parameter_declarations)) {
+ if (token_stream.lookAhead() == ')')
+ goto good;
+
+ if (token_stream.lookAhead() == Token_ellipsis
+ && token_stream.lookAhead(1) == ')') {
+ ast->ellipsis = token_stream.cursor();
+ goto good;
+ }
+
+ return false;
+ }
+
+good:
+
+ if (token_stream.lookAhead() == Token_ellipsis) {
+ ast->ellipsis = token_stream.cursor();
+ token_stream.nextToken();
+ }
+
+ /// @todo add ellipsis
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseParameterDeclarationList(const ListNode<ParameterDeclarationAST*> *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ ParameterDeclarationAST *param = 0;
+ if (!parseParameterDeclaration(param)) {
+ token_stream.rewind((int) start);
+ return false;
+ }
+
+ node = snoc(node, param, _M_pool);
+
+ while (token_stream.lookAhead() == ',') {
+ token_stream.nextToken();
+
+ if (token_stream.lookAhead() == Token_ellipsis)
+ break;
+
+ if (!parseParameterDeclaration(param)) {
+ token_stream.rewind((int) start);
+ return false;
+ }
+ node = snoc(node, param, _M_pool);
+ }
+
+ return true;
+}
+
+bool Parser::parseParameterDeclaration(ParameterDeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ const ListNode<std::size_t> *storage = 0;
+ parseStorageClassSpecifier(storage);
+
+ // parse decl spec
+ TypeSpecifierAST *spec = 0;
+ if (!parseTypeSpecifier(spec)) {
+ token_stream.rewind((int) start);
+ return false;
+ }
+
+ int index = (int) token_stream.cursor();
+
+ DeclaratorAST *decl = 0;
+ if (!parseDeclarator(decl)) {
+ token_stream.rewind((int) index);
+
+ // try with abstract declarator
+ parseAbstractDeclarator(decl);
+ }
+
+ ExpressionAST *expr = 0;
+ if (token_stream.lookAhead() == '=') {
+ token_stream.nextToken();
+ if (!parseLogicalOrExpression(expr, true))
+ reportError(QLatin1String("Expression expected"));
+ }
+
+ ParameterDeclarationAST *ast = CreateNode<ParameterDeclarationAST>(_M_pool);
+ ast->type_specifier = spec;
+ ast->declarator = decl;
+ ast->expression = expr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parse_Attribute__()
+{
+ token_stream.nextToken();
+
+ ADVANCE('(', "(");
+
+ ExpressionAST *expr = 0;
+ parseExpression(expr);
+
+ if (token_stream.lookAhead() != ')') {
+ reportError(QLatin1String("')' expected"));
+ return false;
+ } else {
+ token_stream.nextToken();
+ }
+ return true;
+}
+
+QString Parser::tokenText(AST *ast) const
+{
+ if (!ast)
+ return QString();
+
+ int start_token = ast->start_token;
+ int end_token = ast->end_token;
+
+ Token const &tk = token_stream.token(start_token);
+ Token const &end_tk = token_stream.token(end_token);
+
+ return QString::fromLatin1(&tk.text[tk.position],
+ (int)(end_tk.position - tk.position)).trimmed();
+}
+
+bool Parser::parseForwardDeclarationSpecifier(TypeSpecifierAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ int kind = token_stream.lookAhead();
+ if (kind != Token_class && kind != Token_struct && kind != Token_union)
+ return false;
+
+ std::size_t class_key = token_stream.cursor();
+ token_stream.nextToken();
+
+ NameAST *name = 0;
+ if (!parseName(name, false)) {
+ token_stream.rewind((int) start);
+ return false;
+ }
+
+ BaseClauseAST *bases = 0;
+ if (token_stream.lookAhead() == ':') {
+ if (!parseBaseClause(bases)) {
+ token_stream.rewind((int) start);
+ return false;
+ }
+ }
+
+ if (token_stream.lookAhead() != ';') {
+ token_stream.rewind((int) start);
+ return false;
+ }
+
+ ForwardDeclarationSpecifierAST *ast = CreateNode<ForwardDeclarationSpecifierAST>(_M_pool);
+ ast->class_key = class_key;
+ ast->name = name;
+ ast->base_clause = bases;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseClassSpecifier(TypeSpecifierAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ int kind = token_stream.lookAhead();
+ if (kind != Token_class && kind != Token_struct && kind != Token_union)
+ return false;
+
+ std::size_t class_key = token_stream.cursor();
+ token_stream.nextToken();
+
+ WinDeclSpecAST *winDeclSpec = 0;
+ parseWinDeclSpec(winDeclSpec);
+
+ if (token_stream.lookAhead() == Token___attribute__)
+ parse_Attribute__();
+
+ while (token_stream.lookAhead() == Token_identifier
+ && token_stream.lookAhead(1) == Token_identifier)
+ token_stream.nextToken();
+
+ NameAST *name = 0;
+ parseName(name, true);
+
+ BaseClauseAST *bases = 0;
+
+ if (token_stream.lookAhead() == ':') {
+ if (!parseBaseClause(bases))
+ skipUntil('{');
+ }
+
+ if (token_stream.lookAhead() != '{') {
+
+ token_stream.rewind((int) start);
+ return false;
+ }
+
+ ADVANCE('{', "{");
+
+ ClassSpecifierAST *ast = CreateNode<ClassSpecifierAST>(_M_pool);
+ ast->win_decl_specifiers = winDeclSpec;
+ ast->class_key = class_key;
+ ast->name = name;
+ ast->base_clause = bases;
+
+ while (token_stream.lookAhead()) {
+ if (token_stream.lookAhead() == '}')
+ break;
+
+ std::size_t startDecl = token_stream.cursor();
+
+ DeclarationAST *memSpec = 0;
+ if (!parseMemberSpecification(memSpec)) {
+ if (startDecl == token_stream.cursor())
+ token_stream.nextToken(); // skip at least one token
+ skipUntilDeclaration();
+ } else
+ ast->member_specs = snoc(ast->member_specs, memSpec, _M_pool);
+ }
+
+ ADVANCE_NR('}', "}");
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseAccessSpecifier(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ const ListNode<std::size_t> *specs = 0;
+
+ bool done = false;
+ while (!done) {
+ switch (token_stream.lookAhead()) {
+ case Token_signals:
+ case Token_slots:
+ case Token_k_dcop:
+ case Token_k_dcop_signals:
+ case Token_public:
+ case Token_protected:
+ case Token_private:
+ specs = snoc(specs, token_stream.cursor(), _M_pool);
+ token_stream.nextToken();
+ break;
+
+ default:
+ done = true;
+ break;
+ }
+ }
+
+ if (!specs)
+ return false;
+
+ ADVANCE(':', ":");
+
+ AccessSpecifierAST *ast = CreateNode<AccessSpecifierAST>(_M_pool);
+ ast->specs = specs;
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseMemberSpecification(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (token_stream.lookAhead() == ';') {
+ token_stream.nextToken();
+ return true;
+ } else if (token_stream.lookAhead() == Token_Q_OBJECT
+ || token_stream.lookAhead() == Token_K_DCOP) {
+ token_stream.nextToken();
+ return true;
+ } else if (parseTypedef(node)) {
+ return true;
+ } else if (parseUsing(node)) {
+ return true;
+ } else if (parseTemplateDeclaration(node)) {
+ return true;
+ } else if (parseAccessSpecifier(node)) {
+ return true;
+ } else if (parseQ_PROPERTY(node)) {
+ return true;
+ } else if (parseQ_ENUMS(node)) {
+ return true;
+ }
+
+ token_stream.rewind((int) start);
+
+ const ListNode<std::size_t> *cv = 0;
+ parseCvQualify(cv);
+
+ const ListNode<std::size_t> *storageSpec = 0;
+ parseStorageClassSpecifier(storageSpec);
+
+ parseCvQualify(cv);
+
+ TypeSpecifierAST *spec = 0;
+ if (parseEnumSpecifier(spec) || parseClassSpecifier(spec)) {
+ parseCvQualify(cv);
+ spec->cv = cv;
+
+ const ListNode<InitDeclaratorAST*> *declarators = 0;
+ parseInitDeclaratorList(declarators);
+ ADVANCE(';', ";");
+
+ SimpleDeclarationAST *ast = CreateNode<SimpleDeclarationAST>(_M_pool);
+ ast->type_specifier = spec;
+ ast->init_declarators = declarators;
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+ }
+
+ token_stream.rewind((int) start);
+ return parseDeclarationInternal(node);
+}
+
+bool Parser::parseCtorInitializer(CtorInitializerAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(':');
+
+ CtorInitializerAST *ast = CreateNode<CtorInitializerAST>(_M_pool);
+ ast->colon = start;
+
+ if (!parseMemInitializerList(ast->member_initializers))
+ reportError(QLatin1String("Member initializers expected"));
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseElaboratedTypeSpecifier(TypeSpecifierAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ int tk = token_stream.lookAhead();
+ if (tk == Token_class
+ || tk == Token_struct
+ || tk == Token_union
+ || tk == Token_enum
+ || tk == Token_typename) {
+ std::size_t type = token_stream.cursor();
+ token_stream.nextToken();
+
+ NameAST *name = 0;
+ if (parseName(name, true)) {
+ ElaboratedTypeSpecifierAST *ast
+ = CreateNode<ElaboratedTypeSpecifierAST>(_M_pool);
+
+ ast->type = type;
+ ast->name = name;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+ }
+ }
+
+ token_stream.rewind((int) start);
+ return false;
+}
+
+bool Parser::parseNoExcept()
+{
+ // right now we only accept 'noexcept' with no conditional
+ CHECK(Token_noexcept);
+
+ return true;
+}
+
+bool Parser::parseExceptionSpecification(ExceptionSpecificationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(Token_throw);
+ ADVANCE('(', "(");
+
+ ExceptionSpecificationAST *ast = CreateNode<ExceptionSpecificationAST>(_M_pool);
+
+ if (token_stream.lookAhead() == Token_ellipsis) {
+ ast->ellipsis = token_stream.cursor();
+ token_stream.nextToken();
+ } else {
+ parseTypeIdList(ast->type_ids);
+ }
+
+ ADVANCE(')', ")");
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseEnumerator(EnumeratorAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(Token_identifier);
+ std::size_t id = token_stream.cursor() - 1;
+
+ EnumeratorAST *ast = CreateNode<EnumeratorAST>(_M_pool);
+ ast->id = id;
+
+ if (token_stream.lookAhead() == '=') {
+ token_stream.nextToken();
+
+ if (!parseConstantExpression(ast->expression))
+ reportError(QLatin1String("Constant expression expected"));
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseInitDeclarator(InitDeclaratorAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ DeclaratorAST *decl = 0;
+ if (!parseDeclarator(decl))
+ return false;
+
+ if (token_stream.lookAhead(0) == Token_asm) {
+ token_stream.nextToken();
+ skip('(', ')');
+ token_stream.nextToken();
+ }
+
+ InitializerAST *init = 0;
+ parseInitializer(init);
+
+ InitDeclaratorAST *ast = CreateNode<InitDeclaratorAST>(_M_pool);
+ ast->declarator = decl;
+ ast->initializer = init;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseBaseClause(BaseClauseAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(':');
+
+ BaseSpecifierAST *baseSpec = 0;
+ if (!parseBaseSpecifier(baseSpec))
+ return false;
+
+ BaseClauseAST *ast = CreateNode<BaseClauseAST>(_M_pool);
+ ast->base_specifiers = snoc(ast->base_specifiers, baseSpec, _M_pool);
+
+ while (token_stream.lookAhead() == ',') {
+ token_stream.nextToken();
+
+ if (!parseBaseSpecifier(baseSpec)) {
+ reportError(QLatin1String("Base class specifier expected"));
+ break;
+ }
+ ast->base_specifiers = snoc(ast->base_specifiers, baseSpec, _M_pool);
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseInitializer(InitializerAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ int tk = token_stream.lookAhead();
+ if (tk != '=' && tk != '(')
+ return false;
+
+ InitializerAST *ast = CreateNode<InitializerAST>(_M_pool);
+
+ if (tk == '=') {
+ token_stream.nextToken();
+
+ if (!parseInitializerClause(ast->initializer_clause))
+ reportError(QLatin1String("Initializer clause expected"));
+
+ } else if (tk == '(') {
+ token_stream.nextToken();
+ parseCommaExpression(ast->expression);
+ CHECK(')');
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseMemInitializerList(const ListNode<MemInitializerAST*> *&node)
+{
+ MemInitializerAST *init = 0;
+
+ if (!parseMemInitializer(init))
+ return false;
+
+ node = snoc(node, init, _M_pool);
+
+ while (token_stream.lookAhead() == ',') {
+ token_stream.nextToken();
+
+ if (!parseMemInitializer(init))
+ break;
+
+ node = snoc(node, init, _M_pool);
+ }
+
+ return true;
+}
+
+bool Parser::parseMemInitializer(MemInitializerAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ NameAST *initId = 0;
+ if (!parseName(initId, true)) {
+ reportError(QLatin1String("Identifier expected"));
+ return false;
+ }
+
+ ADVANCE('(', "(");
+ ExpressionAST *expr = 0;
+ parseCommaExpression(expr);
+ ADVANCE(')', ")");
+
+ MemInitializerAST *ast = CreateNode<MemInitializerAST>(_M_pool);
+ ast->initializer_id = initId;
+ ast->expression = expr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseTypeIdList(const ListNode<TypeIdAST*> *&node)
+{
+ TypeIdAST *typeId = 0;
+ if (!parseTypeId(typeId))
+ return false;
+
+ node = snoc(node, typeId, _M_pool);
+
+ while (token_stream.lookAhead() == ',') {
+ token_stream.nextToken();
+ if (parseTypeId(typeId)) {
+ node = snoc(node, typeId, _M_pool);
+ } else {
+ reportError(QLatin1String("Type id expected"));
+ break;
+ }
+ }
+
+ return true;
+}
+
+bool Parser::parseBaseSpecifier(BaseSpecifierAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ BaseSpecifierAST *ast = CreateNode<BaseSpecifierAST>(_M_pool);
+
+ if (token_stream.lookAhead() == Token_virtual) {
+ ast->virt = token_stream.cursor();
+ token_stream.nextToken();
+
+ int tk = token_stream.lookAhead();
+ if (tk == Token_public || tk == Token_protected
+ || tk == Token_private) {
+ ast->access_specifier = token_stream.cursor();
+ token_stream.nextToken();
+ }
+ } else {
+ int tk = token_stream.lookAhead();
+ if (tk == Token_public || tk == Token_protected
+ || tk == Token_private) {
+ ast->access_specifier = token_stream.cursor();
+ token_stream.nextToken();
+ }
+
+ if (token_stream.lookAhead() == Token_virtual) {
+ ast->virt = token_stream.cursor();
+ token_stream.nextToken();
+ }
+ }
+
+ if (!parseName(ast->name, true))
+ reportError(QLatin1String("Class name expected"));
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseInitializerClause(InitializerClauseAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ InitializerClauseAST *ast = CreateNode<InitializerClauseAST>(_M_pool);
+
+ if (token_stream.lookAhead() == '{') {
+#if defined(__GNUC__)
+#warning "implement me"
+#endif
+ if (skip('{', '}'))
+ token_stream.nextToken();
+ else
+ reportError(QLatin1String("} missing"));
+ } else {
+ if (!parseAssignmentExpression(ast->expression))
+ reportError(QLatin1String("Expression expected"));
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parsePtrToMember(PtrToMemberAST *&node)
+{
+#if defined(__GNUC__)
+#warning "implemente me (AST)"
+#endif
+
+ std::size_t start = token_stream.cursor();
+
+ if (token_stream.lookAhead() == Token_scope) {
+ token_stream.nextToken();
+ }
+
+ UnqualifiedNameAST *name = 0;
+ while (token_stream.lookAhead() == Token_identifier) {
+ if (!parseUnqualifiedName(name))
+ break;
+
+ if (token_stream.lookAhead() == Token_scope
+ && token_stream.lookAhead(1) == '*') {
+ token_stream.nextToken();
+ token_stream.nextToken();
+
+ PtrToMemberAST *ast = CreateNode<PtrToMemberAST>(_M_pool);
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+ }
+
+ if (token_stream.lookAhead() == Token_scope)
+ token_stream.nextToken();
+ }
+
+ token_stream.rewind((int) start);
+ return false;
+}
+
+bool Parser::parseUnqualifiedName(UnqualifiedNameAST *&node,
+ bool parseTemplateId)
+{
+ std::size_t start = token_stream.cursor();
+
+ std::size_t tilde = 0;
+ std::size_t id = 0;
+ OperatorFunctionIdAST *operator_id = 0;
+
+ if (token_stream.lookAhead() == Token_identifier) {
+ id = token_stream.cursor();
+ token_stream.nextToken();
+ } else if (token_stream.lookAhead() == '~'
+ && token_stream.lookAhead(1) == Token_identifier) {
+ tilde = token_stream.cursor();
+ token_stream.nextToken(); // skip ~
+
+ id = token_stream.cursor();
+ token_stream.nextToken(); // skip classname
+ } else if (token_stream.lookAhead() == Token_operator) {
+ if (!parseOperatorFunctionId(operator_id))
+ return false;
+ } else {
+ return false;
+ }
+
+ UnqualifiedNameAST *ast = CreateNode<UnqualifiedNameAST>(_M_pool);
+ ast->tilde = tilde;
+ ast->id = id;
+ ast->operator_id = operator_id;
+
+ if (parseTemplateId && !tilde) {
+ std::size_t index = token_stream.cursor();
+
+ if (token_stream.lookAhead() == '<') {
+ token_stream.nextToken();
+
+ // optional template arguments
+ parseTemplateArgumentList(ast->template_arguments);
+
+ if (token_stream.lookAhead() == '>') {
+ token_stream.nextToken();
+ } else {
+ ast->template_arguments = 0;
+ token_stream.rewind((int) index);
+ }
+ }
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseStringLiteral(StringLiteralAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (token_stream.lookAhead() != Token_string_literal)
+ return false;
+
+ StringLiteralAST *ast = CreateNode<StringLiteralAST>(_M_pool);
+
+ while (token_stream.lookAhead() == Token_string_literal) {
+ ast->literals = snoc(ast->literals, token_stream.cursor(), _M_pool);
+ token_stream.nextToken();
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseExpressionStatement(StatementAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ ExpressionAST *expr = 0;
+ parseCommaExpression(expr);
+
+ ADVANCE(';', ";");
+
+ ExpressionStatementAST *ast = CreateNode<ExpressionStatementAST>(_M_pool);
+ ast->expression = expr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseStatement(StatementAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ switch (token_stream.lookAhead()) {
+ case Token_while:
+ return parseWhileStatement(node);
+
+ case Token_do:
+ return parseDoStatement(node);
+
+ case Token_for:
+ return parseForStatement(node);
+
+ case Token_if:
+ return parseIfStatement(node);
+
+ case Token_switch:
+ return parseSwitchStatement(node);
+
+ case Token_try:
+ return parseTryBlockStatement(node);
+
+ case Token_case:
+ case Token_default:
+ return parseLabeledStatement(node);
+
+ case Token_break:
+ case Token_continue:
+#if defined(__GNUC__)
+#warning "implement me"
+#endif
+ token_stream.nextToken();
+ ADVANCE(';', ";");
+ return true;
+
+ case Token_goto:
+#if defined(__GNUC__)
+#warning "implement me"
+#endif
+ token_stream.nextToken();
+ ADVANCE(Token_identifier, "identifier");
+ ADVANCE(';', ";");
+ return true;
+
+ case Token_return: {
+ token_stream.nextToken();
+ ExpressionAST *expr = 0;
+ parseCommaExpression(expr);
+
+ ADVANCE(';', ";");
+
+ ReturnStatementAST *ast = CreateNode<ReturnStatementAST>(_M_pool);
+ ast->expression = expr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+ return true;
+
+ case '{':
+ return parseCompoundStatement(node);
+
+ case Token_identifier:
+ if (parseLabeledStatement(node))
+ return true;
+ break;
+ }
+
+ return parseExpressionOrDeclarationStatement(node);
+}
+
+bool Parser::parseExpressionOrDeclarationStatement(StatementAST *&node)
+{
+ bool blocked = block_errors(true);
+
+ std::size_t start = token_stream.cursor();
+
+ StatementAST *decl_ast = 0;
+ bool maybe_amb = parseDeclarationStatement(decl_ast);
+ maybe_amb &= token_stream.kind(token_stream.cursor() - 1) == ';';
+
+ std::size_t end = token_stream.cursor();
+
+ token_stream.rewind((int) start);
+ StatementAST *expr_ast = 0;
+ maybe_amb &= parseExpressionStatement(expr_ast);
+ maybe_amb &= token_stream.kind(token_stream.cursor() - 1) == ';';
+
+ if (maybe_amb) {
+ Q_ASSERT(decl_ast && expr_ast);
+ ExpressionOrDeclarationStatementAST *ast =
+ CreateNode<ExpressionOrDeclarationStatementAST>(_M_pool);
+ ast->declaration = decl_ast;
+ ast->expression = expr_ast;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ } else {
+ token_stream.rewind((int) std::max(end, token_stream.cursor()));
+
+ node = decl_ast;
+ if (!node)
+ node = expr_ast;
+ }
+
+ block_errors(blocked);
+
+ if (!node)
+ syntaxError();
+
+ return node != 0;
+}
+
+bool Parser::parseCondition(ConditionAST *&node, bool initRequired)
+{
+ std::size_t start = token_stream.cursor();
+
+ ConditionAST *ast = CreateNode<ConditionAST>(_M_pool);
+ TypeSpecifierAST *spec = 0;
+
+ if (parseTypeSpecifier(spec)) {
+ ast->type_specifier = spec;
+
+ std::size_t declarator_start = token_stream.cursor();
+
+ DeclaratorAST *decl = 0;
+ if (!parseDeclarator(decl)) {
+ token_stream.rewind((int) declarator_start);
+ if (!initRequired && !parseAbstractDeclarator(decl))
+ decl = 0;
+ }
+
+ if (decl && (!initRequired || token_stream.lookAhead() == '=')) {
+ ast->declarator = decl;
+
+ if (token_stream.lookAhead() == '=') {
+ token_stream.nextToken();
+
+ parseExpression(ast->expression);
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+ }
+ }
+
+ token_stream.rewind((int) start);
+
+ if (!parseCommaExpression(ast->expression))
+ return false;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+
+bool Parser::parseWhileStatement(StatementAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ ADVANCE(Token_while, "while");
+ ADVANCE('(' , "(");
+
+ ConditionAST *cond = 0;
+ if (!parseCondition(cond)) {
+ reportError(QLatin1String("condition expected"));
+ return false;
+ }
+ ADVANCE(')', ")");
+
+ StatementAST *body = 0;
+ if (!parseStatement(body)) {
+ reportError(QLatin1String("statement expected"));
+ return false;
+ }
+
+ WhileStatementAST *ast = CreateNode<WhileStatementAST>(_M_pool);
+ ast->condition = cond;
+ ast->statement = body;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseDoStatement(StatementAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ ADVANCE(Token_do, "do");
+
+ StatementAST *body = 0;
+ if (!parseStatement(body)) {
+ reportError(QLatin1String("statement expected"));
+ //return false;
+ }
+
+ ADVANCE_NR(Token_while, "while");
+ ADVANCE_NR('(' , "(");
+
+ ExpressionAST *expr = 0;
+ if (!parseCommaExpression(expr)) {
+ reportError(QLatin1String("expression expected"));
+ //return false;
+ }
+
+ ADVANCE_NR(')', ")");
+ ADVANCE_NR(';', ";");
+
+ DoStatementAST *ast = CreateNode<DoStatementAST>(_M_pool);
+ ast->statement = body;
+ ast->expression = expr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseForStatement(StatementAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ ADVANCE(Token_for, "for");
+ ADVANCE('(', "(");
+
+ StatementAST *init = 0;
+ if (!parseForInitStatement(init)) {
+ reportError(QLatin1String("for initialization expected"));
+ return false;
+ }
+
+ ConditionAST *cond = 0;
+ parseCondition(cond);
+ ADVANCE(';', ";");
+
+ ExpressionAST *expr = 0;
+ parseCommaExpression(expr);
+ ADVANCE(')', ")");
+
+ StatementAST *body = 0;
+ if (!parseStatement(body))
+ return false;
+
+ ForStatementAST *ast = CreateNode<ForStatementAST>(_M_pool);
+ ast->init_statement = init;
+ ast->condition = cond;
+ ast->expression = expr;
+ ast->statement = body;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseForInitStatement(StatementAST *&node)
+{
+ if (parseDeclarationStatement(node))
+ return true;
+
+ return parseExpressionStatement(node);
+}
+
+bool Parser::parseCompoundStatement(StatementAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK('{');
+
+ CompoundStatementAST *ast = CreateNode<CompoundStatementAST>(_M_pool);
+
+ while (token_stream.lookAhead()) {
+ if (token_stream.lookAhead() == '}')
+ break;
+
+ std::size_t startStmt = token_stream.cursor();
+
+ StatementAST *stmt = 0;
+ if (!parseStatement(stmt)) {
+ if (startStmt == token_stream.cursor())
+ token_stream.nextToken();
+
+ skipUntilStatement();
+ } else {
+ ast->statements = snoc(ast->statements, stmt, _M_pool);
+ }
+ }
+
+ ADVANCE_NR('}', "}");
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseIfStatement(StatementAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ ADVANCE(Token_if, "if");
+
+ ADVANCE('(' , "(");
+
+ IfStatementAST *ast = CreateNode<IfStatementAST>(_M_pool);
+
+ ConditionAST *cond = 0;
+ if (!parseCondition(cond)) {
+ reportError(QLatin1String("condition expected"));
+ return false;
+ }
+ ADVANCE(')', ")");
+
+ StatementAST *stmt = 0;
+ if (!parseStatement(stmt)) {
+ reportError(QLatin1String("statement expected"));
+ return false;
+ }
+
+ ast->condition = cond;
+ ast->statement = stmt;
+
+ if (token_stream.lookAhead() == Token_else) {
+ token_stream.nextToken();
+
+ if (!parseStatement(ast->else_statement)) {
+ reportError(QLatin1String("statement expected"));
+ return false;
+ }
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseSwitchStatement(StatementAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+ ADVANCE(Token_switch, "switch");
+
+ ADVANCE('(' , "(");
+
+ ConditionAST *cond = 0;
+ if (!parseCondition(cond)) {
+ reportError(QLatin1String("condition expected"));
+ return false;
+ }
+ ADVANCE(')', ")");
+
+ StatementAST *stmt = 0;
+ if (!parseCompoundStatement(stmt)) {
+ syntaxError();
+ return false;
+ }
+
+ SwitchStatementAST *ast = CreateNode<SwitchStatementAST>(_M_pool);
+ ast->condition = cond;
+ ast->statement = stmt;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseLabeledStatement(StatementAST *&node)
+{
+ switch (token_stream.lookAhead()) {
+ case Token_identifier:
+ case Token_default:
+ if (token_stream.lookAhead(1) == ':') {
+ token_stream.nextToken();
+ token_stream.nextToken();
+
+ StatementAST *stmt = 0;
+ if (parseStatement(stmt)) {
+ node = stmt;
+ return true;
+ }
+ }
+ break;
+
+ case Token_case: {
+ token_stream.nextToken();
+ ExpressionAST *expr = 0;
+ if (!parseConstantExpression(expr)) {
+ reportError(QLatin1String("expression expected"));
+ } else if (token_stream.lookAhead() == Token_ellipsis) {
+ token_stream.nextToken();
+
+ ExpressionAST *expr2 = 0;
+ if (!parseConstantExpression(expr2))
+ reportError(QLatin1String("expression expected"));
+ }
+ ADVANCE(':', ":");
+
+ StatementAST *stmt = 0;
+ if (parseStatement(stmt)) {
+ node = stmt;
+ return true;
+ }
+ }
+ break;
+
+ }
+
+ return false;
+}
+
+bool Parser::parseBlockDeclaration(DeclarationAST *&node)
+{
+ switch (token_stream.lookAhead()) {
+ case Token_typedef:
+ return parseTypedef(node);
+ case Token_using:
+ return parseUsing(node);
+ case Token_asm:
+ return parseAsmDefinition(node);
+ case Token_namespace:
+ return parseNamespaceAliasDefinition(node);
+ }
+
+ std::size_t start = token_stream.cursor();
+
+ const ListNode<std::size_t> *cv = 0;
+ parseCvQualify(cv);
+
+ const ListNode<std::size_t> *storageSpec = 0;
+ parseStorageClassSpecifier(storageSpec);
+
+ parseCvQualify(cv);
+
+ TypeSpecifierAST *spec = 0;
+ if (!parseTypeSpecifierOrClassSpec(spec)) { // replace with simpleTypeSpecifier?!?!
+ token_stream.rewind((int) start);
+ return false;
+ }
+
+ parseCvQualify(cv);
+ spec->cv = cv;
+
+ const ListNode<InitDeclaratorAST*> *declarators = 0;
+ parseInitDeclaratorList(declarators);
+
+ if (token_stream.lookAhead() != ';') {
+ token_stream.rewind((int) start);
+ return false;
+ }
+ token_stream.nextToken();
+
+ SimpleDeclarationAST *ast = CreateNode<SimpleDeclarationAST>(_M_pool);
+ ast->type_specifier = spec;
+ ast->init_declarators = declarators;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseNamespaceAliasDefinition(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(Token_namespace);
+
+ NamespaceAliasDefinitionAST *ast
+ = CreateNode<NamespaceAliasDefinitionAST>(_M_pool);
+
+ ADVANCE(Token_identifier, "identifier");
+ ast->namespace_name = token_stream.cursor() - 1;
+
+ ADVANCE('=', "=");
+
+ if (!parseName(ast->alias_name))
+ reportError(QLatin1String("Namespace name expected"));
+
+ ADVANCE(';', ";");
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseDeclarationStatement(StatementAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ DeclarationAST *decl = 0;
+ if (!parseBlockDeclaration(decl))
+ return false;
+
+ DeclarationStatementAST *ast = CreateNode<DeclarationStatementAST>(_M_pool);
+ ast->declaration = decl;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseDeclarationInternal(DeclarationAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ // that is for the case '__declspec(dllexport) int ...' or
+ // '__declspec(dllexport) inline int ...', etc.
+ WinDeclSpecAST *winDeclSpec = 0;
+ parseWinDeclSpec(winDeclSpec);
+
+ const ListNode<std::size_t> *funSpec = 0;
+ bool hasFunSpec = parseFunctionSpecifier(funSpec);
+
+ const ListNode<std::size_t> *cv = 0;
+ parseCvQualify(cv);
+
+ const ListNode<std::size_t> *storageSpec = 0;
+ bool hasStorageSpec = parseStorageClassSpecifier(storageSpec);
+
+ if (hasStorageSpec && !hasFunSpec)
+ hasFunSpec = parseFunctionSpecifier(funSpec);
+
+ // that is for the case 'friend __declspec(dllexport) ....'
+ parseWinDeclSpec(winDeclSpec);
+
+ if (!cv)
+ parseCvQualify(cv);
+
+ int index = (int) token_stream.cursor();
+ NameAST *name = 0;
+ if (parseName(name, true) && token_stream.lookAhead() == '(') {
+ // no type specifier, maybe a constructor or a cast operator??
+
+ token_stream.rewind((int) index);
+
+ InitDeclaratorAST *declarator = 0;
+ if (parseInitDeclarator(declarator)) {
+ switch (token_stream.lookAhead()) {
+ case ';': {
+ token_stream.nextToken();
+
+ SimpleDeclarationAST *ast
+ = CreateNode<SimpleDeclarationAST>(_M_pool);
+
+ ast->storage_specifiers = storageSpec;
+ ast->function_specifiers = funSpec;
+ ast->init_declarators = snoc(ast->init_declarators,
+ declarator, _M_pool);
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+ return true;
+
+ case ':': {
+ CtorInitializerAST *ctorInit = 0;
+ StatementAST *funBody = 0;
+
+ if (parseCtorInitializer(ctorInit)
+ && parseFunctionBody(funBody)) {
+ FunctionDefinitionAST *ast
+ = CreateNode<FunctionDefinitionAST>(_M_pool);
+
+ ast->storage_specifiers = storageSpec;
+ ast->function_specifiers = funSpec;
+ ast->init_declarator = declarator;
+ ast->function_body = funBody;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+ }
+ }
+ break;
+
+ case '{': {
+ StatementAST *funBody = 0;
+ if (parseFunctionBody(funBody)) {
+ FunctionDefinitionAST *ast
+ = CreateNode<FunctionDefinitionAST>(_M_pool);
+
+ ast->storage_specifiers = storageSpec;
+ ast->function_specifiers = funSpec;
+ ast->init_declarator = declarator;
+ ast->function_body = funBody;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+ }
+ }
+ break;
+
+ case '(':
+ case '[':
+ // ops!! it seems a declarator
+ goto start_decl;
+ break;
+ }
+
+ }
+ }
+
+start_decl:
+ token_stream.rewind((int) index);
+
+ if (token_stream.lookAhead() == Token_const
+ && token_stream.lookAhead(1) == Token_identifier
+ && token_stream.lookAhead(2) == '=') {
+ // constant definition
+ token_stream.nextToken(); // skip const
+
+ const ListNode<InitDeclaratorAST*> *declarators = 0;
+ if (!parseInitDeclaratorList(declarators)) {
+ syntaxError();
+ return false;
+ }
+
+ ADVANCE(';', ";");
+
+#if defined(__GNUC__)
+#warning "mark the ast as constant"
+#endif
+ SimpleDeclarationAST *ast = CreateNode<SimpleDeclarationAST>(_M_pool);
+ ast->init_declarators = declarators;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+ }
+
+ TypeSpecifierAST *spec = 0;
+ if (parseTypeSpecifier(spec)) {
+ Q_ASSERT(spec);
+
+ if (!hasFunSpec)
+ parseFunctionSpecifier(funSpec); // e.g. "void inline"
+
+ spec->cv = cv;
+
+ const ListNode<InitDeclaratorAST*> *declarators = 0;
+ InitDeclaratorAST *decl = 0;
+ int startDeclarator = (int) token_stream.cursor();
+ bool maybeFunctionDefinition = false;
+
+ if (token_stream.lookAhead() != ';') {
+ if (parseInitDeclarator(decl) && token_stream.lookAhead() == '{') {
+ // function definition
+ maybeFunctionDefinition = true;
+ } else {
+ token_stream.rewind((int) startDeclarator);
+ if (!parseInitDeclaratorList(declarators)) {
+ syntaxError();
+ return false;
+ }
+ }
+ }
+
+ switch (token_stream.lookAhead()) {
+ case ';': {
+ token_stream.nextToken();
+ SimpleDeclarationAST *ast
+ = CreateNode<SimpleDeclarationAST>(_M_pool);
+
+ ast->storage_specifiers = storageSpec;
+ ast->function_specifiers = funSpec;
+ ast->type_specifier = spec;
+ ast->win_decl_specifiers = winDeclSpec;
+ ast->init_declarators = declarators;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+ return true;
+
+ case '{': {
+ if (!maybeFunctionDefinition) {
+ syntaxError();
+ return false;
+ }
+
+ StatementAST *funBody = 0;
+ if (parseFunctionBody(funBody)) {
+ FunctionDefinitionAST *ast
+ = CreateNode<FunctionDefinitionAST>(_M_pool);
+
+ ast->win_decl_specifiers = winDeclSpec;
+ ast->storage_specifiers = storageSpec;
+ ast->function_specifiers = funSpec;
+ ast->type_specifier = spec;
+ ast->init_declarator = decl;
+ ast->function_body = funBody;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+ }
+ }
+ break;
+ } // end switch
+ }
+
+ syntaxError();
+ return false;
+}
+
+bool Parser::skipFunctionBody(StatementAST *&)
+{
+#if defined(__GNUC__)
+#warning "Parser::skipFunctionBody() -- implement me"
+#endif
+ Q_ASSERT(0); // ### not implemented
+ return 0;
+}
+
+bool Parser::parseFunctionBody(StatementAST *&node)
+{
+ if (control->skipFunctionBody())
+ return skipFunctionBody(node);
+
+ return parseCompoundStatement(node);
+}
+
+bool Parser::parseTypeSpecifierOrClassSpec(TypeSpecifierAST *&node)
+{
+ if (parseClassSpecifier(node))
+ return true;
+ else if (parseEnumSpecifier(node))
+ return true;
+ else if (parseTypeSpecifier(node))
+ return true;
+
+ return false;
+}
+
+bool Parser::parseTryBlockStatement(StatementAST *&node)
+{
+#if defined(__GNUC__)
+#warning "implement me"
+#endif
+ CHECK(Token_try);
+
+ StatementAST *stmt = 0;
+ if (!parseCompoundStatement(stmt)) {
+ syntaxError();
+ return false;
+ }
+
+ if (token_stream.lookAhead() != Token_catch) {
+ reportError(QLatin1String("catch expected"));
+ return false;
+ }
+
+ while (token_stream.lookAhead() == Token_catch) {
+ token_stream.nextToken();
+ ADVANCE('(', "(");
+ ConditionAST *cond = 0;
+ if (token_stream.lookAhead() == Token_ellipsis) {
+ token_stream.nextToken();
+ } else if (!parseCondition(cond, false)) {
+ reportError(QLatin1String("condition expected"));
+ return false;
+ }
+ ADVANCE(')', ")");
+
+ StatementAST *body = 0;
+ if (!parseCompoundStatement(body)) {
+ syntaxError();
+ return false;
+ }
+ }
+
+ node = stmt;
+ return true;
+}
+
+bool Parser::parsePrimaryExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ PrimaryExpressionAST *ast = CreateNode<PrimaryExpressionAST>(_M_pool);
+
+ switch (token_stream.lookAhead()) {
+ case Token_string_literal:
+ parseStringLiteral(ast->literal);
+ break;
+
+ case Token_number_literal:
+ case Token_char_literal:
+ case Token_true:
+ case Token_false:
+ case Token_this:
+ ast->token = token_stream.cursor();
+ token_stream.nextToken();
+ break;
+
+ case '(':
+ token_stream.nextToken();
+
+ if (token_stream.lookAhead() == '{') {
+ if (!parseCompoundStatement(ast->expression_statement))
+ return false;
+ } else {
+ if (!parseExpression(ast->sub_expression))
+ return false;
+ }
+
+ CHECK(')');
+ break;
+
+ default:
+ if (!parseName(ast->name))
+ return false;
+
+ break;
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+
+/*
+ postfix-expression-internal:
+ [ expression ]
+ ( expression-list [opt] )
+ (.|->) template [opt] id-expression
+ (.|->) pseudo-destructor-name
+ ++
+ --
+*/
+bool Parser::parsePostfixExpressionInternal(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ switch (token_stream.lookAhead()) {
+ case '[': {
+ token_stream.nextToken();
+ ExpressionAST *expr = 0;
+ parseExpression(expr);
+ CHECK(']');
+
+ SubscriptExpressionAST *ast
+ = CreateNode<SubscriptExpressionAST>(_M_pool);
+
+ ast->subscript = expr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+ return true;
+
+ case '(': {
+ token_stream.nextToken();
+ ExpressionAST *expr = 0;
+ parseExpression(expr);
+ CHECK(')');
+
+ FunctionCallAST *ast = CreateNode<FunctionCallAST>(_M_pool);
+ ast->arguments = expr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+ return true;
+
+ case '.':
+ case Token_arrow: {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ std::size_t templ = 0;
+ if (token_stream.lookAhead() == Token_template) {
+ templ = token_stream.cursor();
+ token_stream.nextToken();
+ }
+
+ int saved = int(token_stream.cursor());
+ NameAST *name = 0;
+
+ if (parseName(name, true) && name->unqualified_name
+ && name->unqualified_name->template_arguments
+ && token_stream.lookAhead() == '(') {
+ // a template method call
+ // ### reverse the logic
+ } else {
+ token_stream.rewind(saved);
+ name = 0;
+
+ if (!parseName(name, templ != 0))
+ return false;
+ }
+
+ ClassMemberAccessAST *ast = CreateNode<ClassMemberAccessAST>(_M_pool);
+ ast->op = op;
+ ast->name = name;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+ return true;
+
+ case Token_incr:
+ case Token_decr: {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ IncrDecrExpressionAST *ast = CreateNode<IncrDecrExpressionAST>(_M_pool);
+ ast->op = op;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+/*
+ postfix-expression:
+ simple-type-specifier ( expression-list [opt] )
+ primary-expression postfix-expression-internal*
+*/
+bool Parser::parsePostfixExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ switch (token_stream.lookAhead()) {
+ case Token_dynamic_cast:
+ case Token_static_cast:
+ case Token_reinterpret_cast:
+ case Token_const_cast: {
+ std::size_t castOp = token_stream.cursor();
+ token_stream.nextToken();
+
+ CHECK('<');
+ TypeIdAST *typeId = 0;
+ parseTypeId(typeId);
+ CHECK('>');
+
+ CHECK('(');
+ ExpressionAST *expr = 0;
+ parseCommaExpression(expr);
+ CHECK(')');
+
+ CppCastExpressionAST *ast = CreateNode<CppCastExpressionAST>(_M_pool);
+ ast->op = castOp;
+ ast->type_id = typeId;
+ ast->expression = expr;
+
+ ExpressionAST *e = 0;
+ while (parsePostfixExpressionInternal(e))
+ ast->sub_expressions = snoc(ast->sub_expressions, e, _M_pool);
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+ return true;
+
+ case Token_typename: {
+ std::size_t token = token_stream.cursor();
+ token_stream.nextToken();
+
+ NameAST* name = 0;
+ if (!parseName(name, true))
+ return false;
+
+ CHECK('(');
+ ExpressionAST *expr = 0;
+ parseCommaExpression(expr);
+ CHECK(')');
+
+ TypeIdentificationAST *ast = CreateNode<TypeIdentificationAST>(_M_pool);
+ ast->typename_token = token;
+ ast->name = name;
+ ast->expression = expr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+ return true;
+
+ case Token_typeid: {
+ token_stream.nextToken();
+
+ CHECK('(');
+ TypeIdAST *typeId = 0;
+ parseTypeId(typeId);
+ CHECK(')');
+
+ TypeIdentificationAST *ast = CreateNode<TypeIdentificationAST>(_M_pool);
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+ return true;
+
+ default:
+ break;
+ }
+
+ std::size_t saved_pos = token_stream.cursor();
+
+ TypeSpecifierAST *typeSpec = 0;
+ ExpressionAST *expr = 0;
+
+ // let's try to parse a type
+ NameAST *name = 0;
+ if (parseName(name, true)) {
+ Q_ASSERT(name->unqualified_name);
+
+ bool has_template_args = name->unqualified_name->template_arguments != 0;
+
+ if (has_template_args && token_stream.lookAhead() == '(') {
+ ExpressionAST *cast_expr = 0;
+ if (parseCastExpression(cast_expr)
+ && cast_expr->kind == AST::Kind_CastExpression) {
+ token_stream.rewind((int) saved_pos);
+ parsePrimaryExpression(expr);
+ goto L_no_rewind;
+ }
+ }
+ }
+
+ token_stream.rewind((int) saved_pos);
+
+L_no_rewind:
+ if (!expr && parseSimpleTypeSpecifier(typeSpec)
+ && token_stream.lookAhead() == '(') {
+ token_stream.nextToken(); // skip '('
+ parseCommaExpression(expr);
+ CHECK(')');
+ } else if (expr) {
+ typeSpec = 0;
+ } else {
+ typeSpec = 0;
+ token_stream.rewind((int) start);
+
+ if (!parsePrimaryExpression(expr))
+ return false;
+ }
+
+ const ListNode<ExpressionAST*> *sub_expressions = 0;
+ ExpressionAST *sub_expression = 0;
+
+ while (parsePostfixExpressionInternal(sub_expression))
+ sub_expressions = snoc(sub_expressions, sub_expression, _M_pool);
+
+ if (sub_expressions || !expr || (typeSpec && expr)) {
+ PostfixExpressionAST *ast = CreateNode<PostfixExpressionAST>(_M_pool);
+ ast->type_specifier = typeSpec;
+ ast->expression = expr;
+ ast->sub_expressions = sub_expressions;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ } else
+ node = expr;
+
+ return true;
+}
+
+bool Parser::parseUnaryExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ switch (token_stream.lookAhead()) {
+ case Token_incr:
+ case Token_decr:
+ case '*':
+ case '&':
+ case '+':
+ case '-':
+ case '!':
+ case '~': {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *expr = 0;
+ if (!parseCastExpression(expr))
+ return false;
+
+ UnaryExpressionAST *ast = CreateNode<UnaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->expression = expr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+ return true;
+
+ case Token_sizeof: {
+ std::size_t sizeof_token = token_stream.cursor();
+ token_stream.nextToken();
+
+ SizeofExpressionAST *ast = CreateNode<SizeofExpressionAST>(_M_pool);
+ ast->sizeof_token = sizeof_token;
+
+ std::size_t index = token_stream.cursor();
+ if (token_stream.lookAhead() == '(') {
+ token_stream.nextToken();
+ if (parseTypeId(ast->type_id) && token_stream.lookAhead() == ')') {
+ token_stream.nextToken(); // skip )
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ return true;
+ }
+
+ ast->type_id = 0;
+ token_stream.rewind((int) index);
+ }
+
+ if (!parseUnaryExpression(ast->expression))
+ return false;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ return true;
+ }
+
+ default:
+ break;
+ }
+
+ int token = token_stream.lookAhead();
+
+ if (token == Token_new
+ || (token == Token_scope && token_stream.lookAhead(1) == Token_new))
+ return parseNewExpression(node);
+
+ if (token == Token_delete
+ || (token == Token_scope && token_stream.lookAhead(1) == Token_delete))
+ return parseDeleteExpression(node);
+
+ return parsePostfixExpression(node);
+}
+
+bool Parser::parseNewExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ NewExpressionAST *ast = CreateNode<NewExpressionAST>(_M_pool);
+
+ if (token_stream.lookAhead() == Token_scope
+ && token_stream.lookAhead(1) == Token_new) {
+ ast->scope_token = token_stream.cursor();
+ token_stream.nextToken();
+ }
+
+ CHECK(Token_new);
+ ast->new_token = token_stream.cursor() - 1;
+
+ if (token_stream.lookAhead() == '(') {
+ token_stream.nextToken();
+ parseCommaExpression(ast->expression);
+ CHECK(')');
+ }
+
+ if (token_stream.lookAhead() == '(') {
+ token_stream.nextToken();
+ parseTypeId(ast->type_id);
+ CHECK(')');
+ } else {
+ parseNewTypeId(ast->new_type_id);
+ }
+
+ parseNewInitializer(ast->new_initializer);
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseNewTypeId(NewTypeIdAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ TypeSpecifierAST *typeSpec = 0;
+ if (!parseTypeSpecifier(typeSpec))
+ return false;
+
+ NewTypeIdAST *ast = CreateNode<NewTypeIdAST>(_M_pool);
+ ast->type_specifier = typeSpec;
+
+ parseNewDeclarator(ast->new_declarator);
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseNewDeclarator(NewDeclaratorAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ NewDeclaratorAST *ast = CreateNode<NewDeclaratorAST>(_M_pool);
+
+ PtrOperatorAST *ptrOp = 0;
+ if (parsePtrOperator(ptrOp)) {
+ ast->ptr_op = ptrOp;
+ parseNewDeclarator(ast->sub_declarator);
+ }
+
+ while (token_stream.lookAhead() == '[') {
+ token_stream.nextToken();
+ ExpressionAST *expr = 0;
+ parseExpression(expr);
+ ast->expressions = snoc(ast->expressions, expr, _M_pool);
+ ADVANCE(']', "]");
+ }
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseNewInitializer(NewInitializerAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK('(');
+
+ NewInitializerAST *ast = CreateNode<NewInitializerAST>(_M_pool);
+
+ parseCommaExpression(ast->expression);
+
+ CHECK(')');
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseDeleteExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ DeleteExpressionAST *ast = CreateNode<DeleteExpressionAST>(_M_pool);
+
+ if (token_stream.lookAhead() == Token_scope
+ && token_stream.lookAhead(1) == Token_delete) {
+ ast->scope_token = token_stream.cursor();
+ token_stream.nextToken();
+ }
+
+ CHECK(Token_delete);
+ ast->delete_token = token_stream.cursor() - 1;
+
+ if (token_stream.lookAhead() == '[') {
+ ast->lbracket_token = token_stream.cursor();
+ token_stream.nextToken();
+ CHECK(']');
+ ast->rbracket_token = token_stream.cursor() - 1;
+ }
+
+ if (!parseCastExpression(ast->expression))
+ return false;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseCastExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (token_stream.lookAhead() == '(') {
+ token_stream.nextToken();
+
+ CastExpressionAST *ast = CreateNode<CastExpressionAST>(_M_pool);
+
+ if (parseTypeId(ast->type_id)) {
+ if (token_stream.lookAhead() == ')') {
+ token_stream.nextToken();
+
+ if (parseCastExpression(ast->expression)) {
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+ }
+ }
+ }
+ }
+
+ token_stream.rewind((int) start);
+ return parseUnaryExpression(node);
+}
+
+bool Parser::parsePmExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseCastExpression(node) || !node) // ### fixme
+ return false;
+
+ while (token_stream.lookAhead() == Token_ptrmem) {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseCastExpression(rightExpr))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseMultiplicativeExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parsePmExpression(node))
+ return false;
+
+ while (token_stream.lookAhead() == '*'
+ || token_stream.lookAhead() == '/'
+ || token_stream.lookAhead() == '%') {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parsePmExpression(rightExpr))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+
+bool Parser::parseAdditiveExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseMultiplicativeExpression(node))
+ return false;
+
+ while (token_stream.lookAhead() == '+' || token_stream.lookAhead() == '-') {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseMultiplicativeExpression(rightExpr))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseShiftExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseAdditiveExpression(node))
+ return false;
+
+ while (token_stream.lookAhead() == Token_shift) {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseAdditiveExpression(rightExpr))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseRelationalExpression(ExpressionAST *&node, bool templArgs)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseShiftExpression(node))
+ return false;
+
+ while (token_stream.lookAhead() == '<'
+ || (token_stream.lookAhead() == '>' && !templArgs)
+ || token_stream.lookAhead() == Token_leq
+ || token_stream.lookAhead() == Token_geq) {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseShiftExpression(rightExpr))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseEqualityExpression(ExpressionAST *&node, bool templArgs)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseRelationalExpression(node, templArgs))
+ return false;
+
+ while (token_stream.lookAhead() == Token_eq
+ || token_stream.lookAhead() == Token_not_eq) {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseRelationalExpression(rightExpr, templArgs))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseAndExpression(ExpressionAST *&node, bool templArgs)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseEqualityExpression(node, templArgs))
+ return false;
+
+ while (token_stream.lookAhead() == '&') {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseEqualityExpression(rightExpr, templArgs))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseExclusiveOrExpression(ExpressionAST *&node, bool templArgs)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseAndExpression(node, templArgs))
+ return false;
+
+ while (token_stream.lookAhead() == '^') {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseAndExpression(rightExpr, templArgs))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseInclusiveOrExpression(ExpressionAST *&node, bool templArgs)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseExclusiveOrExpression(node, templArgs))
+ return false;
+
+ while (token_stream.lookAhead() == '|') {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseExclusiveOrExpression(rightExpr, templArgs))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseLogicalAndExpression(ExpressionAST *&node, bool templArgs)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseInclusiveOrExpression(node, templArgs))
+ return false;
+
+ while (token_stream.lookAhead() == Token_and) {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseInclusiveOrExpression(rightExpr, templArgs))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseLogicalOrExpression(ExpressionAST *&node, bool templArgs)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseLogicalAndExpression(node, templArgs))
+ return false;
+
+ while (token_stream.lookAhead() == Token_or) {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseLogicalAndExpression(rightExpr, templArgs))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseConditionalExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseLogicalOrExpression(node))
+ return false;
+
+ if (token_stream.lookAhead() == '?') {
+ token_stream.nextToken();
+
+ ExpressionAST *leftExpr = 0;
+ if (!parseExpression(leftExpr))
+ return false;
+
+ CHECK(':');
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseAssignmentExpression(rightExpr))
+ return false;
+
+ ConditionalExpressionAST *ast
+ = CreateNode<ConditionalExpressionAST>(_M_pool);
+
+ ast->condition = node;
+ ast->left_expression = leftExpr;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseAssignmentExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (token_stream.lookAhead() == Token_throw && !parseThrowExpression(node))
+ return false;
+ else if (!parseConditionalExpression(node))
+ return false;
+
+ while (token_stream.lookAhead() == Token_assign
+ || token_stream.lookAhead() == '=') {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseConditionalExpression(rightExpr))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseConstantExpression(ExpressionAST *&node)
+{
+ return parseConditionalExpression(node);
+}
+
+bool Parser::parseExpression(ExpressionAST *&node)
+{
+ return parseCommaExpression(node);
+}
+
+bool Parser::parseCommaExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ if (!parseAssignmentExpression(node))
+ return false;
+
+ while (token_stream.lookAhead() == ',') {
+ std::size_t op = token_stream.cursor();
+ token_stream.nextToken();
+
+ ExpressionAST *rightExpr = 0;
+ if (!parseAssignmentExpression(rightExpr))
+ return false;
+
+ BinaryExpressionAST *ast = CreateNode<BinaryExpressionAST>(_M_pool);
+ ast->op = op;
+ ast->left_expression = node;
+ ast->right_expression = rightExpr;
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+ }
+
+ return true;
+}
+
+bool Parser::parseThrowExpression(ExpressionAST *&node)
+{
+ std::size_t start = token_stream.cursor();
+
+ CHECK(Token_throw);
+
+ ThrowExpressionAST *ast = CreateNode<ThrowExpressionAST>(_M_pool);
+ ast->throw_token = token_stream.cursor() - 1;
+
+ parseAssignmentExpression(ast->expression);
+
+ UPDATE_POS(ast, start, token_stream.cursor());
+ node = ast;
+
+ return true;
+}
+
+bool Parser::parseQ_ENUMS(DeclarationAST *&node)
+{
+
+ if ((token_stream.lookAhead() != Token_Q_ENUMS) &&
+ (token_stream.lookAhead() != Token_Q_ENUM))
+ return false;
+
+ if (token_stream.lookAhead(1) != '(')
+ return false;
+
+ token_stream.nextToken();
+ token_stream.nextToken();
+
+ int firstToken = token_stream.cursor();
+ while (token_stream.lookAhead() != ')')
+ token_stream.nextToken();
+
+ QEnumsAST *ast = CreateNode<QEnumsAST>(_M_pool);
+ UPDATE_POS(ast, firstToken, token_stream.cursor());
+ node = ast;
+
+ token_stream.nextToken();
+
+ return true;
+}
+
+bool Parser::parseQ_PROPERTY(DeclarationAST *&node)
+{
+ if (token_stream.lookAhead() != Token_Q_PROPERTY)
+ return false;
+
+ if (token_stream.lookAhead(1) != '(')
+ return false;
+
+ token_stream.nextToken();
+ token_stream.nextToken();
+
+ int firstToken = token_stream.cursor();
+ while (token_stream.lookAhead() != ')')
+ token_stream.nextToken();
+
+ QPropertyAST *ast = CreateNode<QPropertyAST>(_M_pool);
+ UPDATE_POS(ast, firstToken, token_stream.cursor());
+ node = ast;
+
+// const Token &t1 = token_stream[firstToken];
+// const Token &t2 = token_stream[token_stream.cursor()];
+// printf("property: %s\n",
+// qPrintable(QString::fromLatin1(t1.text + t1.position, t2.position - t1.position)));
+
+ token_stream.nextToken();
+
+ return true;
+}
+
+bool Parser::block_errors(bool block)
+{
+ bool current = _M_block_errors;
+ _M_block_errors = block;
+ return current;
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
+
diff --git a/sources/shiboken2/ApiExtractor/parser/parser.h b/sources/shiboken2/ApiExtractor/parser/parser.h
new file mode 100644
index 000000000..7aa5b9ad7
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/parser.h
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef PARSER_H
+#define PARSER_H
+
+#include "ast.h"
+#include "lexer.h"
+
+#include <QtCore/QString>
+
+class FileSymbol;
+class Control;
+
+class Parser
+{
+public:
+ Parser(Control *control);
+ ~Parser();
+
+ LocationManager &location() { return _M_location; }
+
+ TranslationUnitAST *parse(const char *contents, std::size_t size, pool *p);
+
+private:
+ void reportError(const QString& msg);
+ void syntaxError();
+ void tokenRequiredError(int expected);
+
+public:
+ bool skipFunctionBody(StatementAST *&node);
+
+public:
+ bool parse_Attribute__();
+ bool parseAbstractDeclarator(DeclaratorAST *&node);
+ bool parseAccessSpecifier(DeclarationAST *&node);
+ bool parseAdditiveExpression(ExpressionAST *&node);
+ bool parseAndExpression(ExpressionAST *&node, bool templArgs = false);
+ bool parseAsmDefinition(DeclarationAST *&node);
+ bool parseAssignmentExpression(ExpressionAST *&node);
+ bool parseBaseClause(BaseClauseAST *&node);
+ bool parseBaseSpecifier(BaseSpecifierAST *&node);
+ bool parseBlockDeclaration(DeclarationAST *&node);
+ bool parseCastExpression(ExpressionAST *&node);
+ bool parseClassSpecifier(TypeSpecifierAST *&node);
+ bool parseForwardDeclarationSpecifier(TypeSpecifierAST *&node);
+ bool parseCommaExpression(ExpressionAST *&node);
+ bool parseCompoundStatement(StatementAST *&node);
+ bool parseCondition(ConditionAST *&node, bool initRequired = true);
+ bool parseConditionalExpression(ExpressionAST *&node);
+ bool parseConstantExpression(ExpressionAST *&node);
+ bool parseCtorInitializer(CtorInitializerAST *&node);
+ bool parseCvQualify(const ListNode<std::size_t> *&node);
+ bool parseDeclaration(DeclarationAST *&node);
+ bool parseDeclarationInternal(DeclarationAST *&node);
+ bool parseDeclarationStatement(StatementAST *&node);
+ bool parseDeclarator(DeclaratorAST *&node);
+ bool parseDeleteExpression(ExpressionAST *&node);
+ bool parseDoStatement(StatementAST *&node);
+ bool parseElaboratedTypeSpecifier(TypeSpecifierAST *&node);
+ bool parseEnumSpecifier(TypeSpecifierAST *&node);
+ bool parseEnumerator(EnumeratorAST *&node);
+ bool parseEqualityExpression(ExpressionAST *&node,
+ bool templArgs = false);
+ bool parseExceptionSpecification(ExceptionSpecificationAST *&node);
+ bool parseExclusiveOrExpression(ExpressionAST *&node,
+ bool templArgs = false);
+ bool parseExpression(ExpressionAST *&node);
+ bool parseExpressionOrDeclarationStatement(StatementAST *&node);
+ bool parseExpressionStatement(StatementAST *&node);
+ bool parseForInitStatement(StatementAST *&node);
+ bool parseForStatement(StatementAST *&node);
+ bool parseFunctionBody(StatementAST *&node);
+ bool parseFunctionSpecifier(const ListNode<std::size_t> *&node);
+ bool parseIfStatement(StatementAST *&node);
+ bool parseInclusiveOrExpression(ExpressionAST *&node,
+ bool templArgs = false);
+ bool parseInitDeclarator(InitDeclaratorAST *&node);
+ bool parseInitDeclaratorList(const ListNode<InitDeclaratorAST*> *&node);
+ bool parseInitializer(InitializerAST *&node);
+ bool parseInitializerClause(InitializerClauseAST *&node);
+ bool parseLabeledStatement(StatementAST *&node);
+ bool parseLinkageBody(LinkageBodyAST *&node);
+ bool parseLinkageSpecification(DeclarationAST *&node);
+ bool parseLogicalAndExpression(ExpressionAST *&node,
+ bool templArgs = false);
+ bool parseLogicalOrExpression(ExpressionAST *&node,
+ bool templArgs = false);
+ bool parseMemInitializer(MemInitializerAST *&node);
+ bool parseMemInitializerList(const ListNode<MemInitializerAST*> *&node);
+ bool parseMemberSpecification(DeclarationAST *&node);
+ bool parseMultiplicativeExpression(ExpressionAST *&node);
+ bool parseName(NameAST *&node, bool acceptTemplateId = false);
+ bool parseNamespace(DeclarationAST *&node);
+ bool parseNamespaceAliasDefinition(DeclarationAST *&node);
+ bool parseNewDeclarator(NewDeclaratorAST *&node);
+ bool parseNewExpression(ExpressionAST *&node);
+ bool parseNewInitializer(NewInitializerAST *&node);
+ bool parseNewTypeId(NewTypeIdAST *&node);
+ bool parseNoExcept();
+ bool parseOperator(OperatorAST *&node);
+ bool parseOperatorFunctionId(OperatorFunctionIdAST *&node);
+ bool parseParameterDeclaration(ParameterDeclarationAST *&node);
+ bool parseParameterDeclarationClause(ParameterDeclarationClauseAST *&node);
+ bool parseParameterDeclarationList(const ListNode<ParameterDeclarationAST*> *&node);
+ bool parsePmExpression(ExpressionAST *&node);
+ bool parsePostfixExpression(ExpressionAST *&node);
+ bool parsePostfixExpressionInternal(ExpressionAST *&node);
+ bool parsePrimaryExpression(ExpressionAST *&node);
+ bool parsePtrOperator(PtrOperatorAST *&node);
+ bool parsePtrToMember(PtrToMemberAST *&node);
+ bool parseRelationalExpression(ExpressionAST *&node,
+ bool templArgs = false);
+ bool parseShiftExpression(ExpressionAST *&node);
+ bool parseSimpleTypeSpecifier(TypeSpecifierAST *&node,
+ bool onlyIntegral = false);
+ bool parseStatement(StatementAST *&node);
+ bool parseStorageClassSpecifier(const ListNode<std::size_t> *&node);
+ bool parseStringLiteral(StringLiteralAST *&node);
+ bool parseSwitchStatement(StatementAST *&node);
+ bool parseTemplateArgument(TemplateArgumentAST *&node);
+ bool parseTemplateArgumentList(const ListNode<TemplateArgumentAST*> *&node,
+ bool reportError = true);
+ bool parseTemplateDeclaration(DeclarationAST *&node);
+ bool parseTemplateParameter(TemplateParameterAST *&node);
+ bool parseTemplateParameterList(const ListNode<TemplateParameterAST*> *&node);
+ bool parseThrowExpression(ExpressionAST *&node);
+ bool parseTranslationUnit(TranslationUnitAST *&node);
+ bool parseTryBlockStatement(StatementAST *&node);
+ bool parseTypeId(TypeIdAST *&node);
+ bool parseTypeIdList(const ListNode<TypeIdAST*> *&node);
+ bool parseTypeParameter(TypeParameterAST *&node);
+ bool parseTypeSpecifier(TypeSpecifierAST *&node);
+ bool parseTypeSpecifierOrClassSpec(TypeSpecifierAST *&node);
+ bool parseTypedef(DeclarationAST *&node);
+ bool parseUnaryExpression(ExpressionAST *&node);
+ bool parseUnqualifiedName(UnqualifiedNameAST *&node,
+ bool parseTemplateId = true);
+ bool parseUsing(DeclarationAST *&node);
+ bool parseUsingDirective(DeclarationAST *&node);
+ bool parseWhileStatement(StatementAST *&node);
+ bool parseWinDeclSpec(WinDeclSpecAST *&node);
+
+ bool parseQ_PROPERTY(DeclarationAST *&node);
+ bool parseQ_ENUMS(DeclarationAST *&node);
+
+ bool skipUntil(int token);
+ bool skipUntilDeclaration();
+ bool skipUntilStatement();
+ bool skip(int l, int r);
+
+ void advance();
+
+ // private:
+ TokenStream token_stream;
+ LocationTable location_table;
+ LocationTable line_table;
+
+ bool block_errors(bool block);
+
+private:
+ QString tokenText(AST *) const;
+
+ LocationManager _M_location;
+ Control *control;
+ Lexer lexer;
+ pool *_M_pool;
+ bool _M_block_errors;
+
+private:
+ Parser(const Parser& source);
+ void operator = (const Parser& source);
+};
+
+#endif
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/r++.macros b/sources/shiboken2/ApiExtractor/parser/r++.macros
new file mode 100644
index 000000000..455276c84
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/r++.macros
@@ -0,0 +1,28 @@
+
+#define __attribute__(a...)
+#define __typeof__ __typeof
+
+#define __extension
+#define __extension__
+
+#define __restrict
+#define __restrict__
+
+#define __volatile volatile
+#define __volatile__ volatile
+
+#define __inline inline
+#define __inline__ inline
+
+#define __const const
+#define __const__ const
+
+#define __asm asm
+#define __asm__ asm
+
+#define __GNUC__ 3
+//#define __GNUC_MINOR__ 4
+
+#define __ROBC__ 0
+#define __ROBC_MINOR__ 1
+
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp-allocator.h b/sources/shiboken2/ApiExtractor/parser/rpp-allocator.h
new file mode 100644
index 000000000..4331ef7d4
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp-allocator.h
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "parser/rxx_allocator.h"
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/builtin-macros.cpp b/sources/shiboken2/ApiExtractor/parser/rpp/builtin-macros.cpp
new file mode 100644
index 000000000..ccc150339
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/builtin-macros.cpp
@@ -0,0 +1,28 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-cctype.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-cctype.h
new file mode 100644
index 000000000..d2e16b994
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-cctype.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_CCTYPE_H
+#define PP_CCTYPE_H
+
+#include <cctype>
+
+namespace rpp
+{
+
+inline bool pp_isalpha(int __ch)
+{
+ return std::isalpha((unsigned char) __ch) != 0;
+}
+
+inline bool pp_isalnum(int __ch)
+{
+ return std::isalnum((unsigned char) __ch) != 0;
+}
+
+inline bool pp_isdigit(int __ch)
+{
+ return std::isdigit((unsigned char) __ch) != 0;
+}
+
+inline bool pp_isspace(int __ch)
+{
+ return std::isspace((unsigned char) __ch) != 0;
+}
+
+} // namespace rpp
+
+#endif // PP_CCTYPE_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-configuration b/sources/shiboken2/ApiExtractor/parser/rpp/pp-configuration
new file mode 100644
index 000000000..15586dd88
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-configuration
@@ -0,0 +1,86 @@
+#define __DBL_MIN_EXP__ (-1021)
+#define __FLT_MIN__ 1.17549435e-38F
+#define __CHAR_BIT__ 8
+#define __WCHAR_MAX__ 2147483647
+#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+#define __FLT_EVAL_METHOD__ 2
+#define __DBL_MIN_10_EXP__ (-307)
+#define __FINITE_MATH_ONLY__ 0
+#define __GNUC_PATCHLEVEL__ 2
+#define __SHRT_MAX__ 32767
+#define __LDBL_MAX__ 1.18973149535723176502e+4932L
+#define __UINTMAX_TYPE__ long long unsigned int
+#define __linux 1
+#define __unix 1
+#define __LDBL_MAX_EXP__ 16384
+#define __linux__ 1
+#define __SCHAR_MAX__ 127
+#define __USER_LABEL_PREFIX__
+#define __STDC_HOSTED__ 1
+#define __LDBL_HAS_INFINITY__ 1
+#define __DBL_DIG__ 15
+#define __FLT_EPSILON__ 1.19209290e-7F
+#define __GXX_WEAK__ 1
+#define __LDBL_MIN__ 3.36210314311209350626e-4932L
+#define __unix__ 1
+#define __DECIMAL_DIG__ 21
+#define __gnu_linux__ 1
+#define __LDBL_HAS_QUIET_NAN__ 1
+#define __GNUC__ 4
+#define __DBL_MAX__ 1.7976931348623157e+308
+#define __DBL_HAS_INFINITY__ 1
+#define __cplusplus 1
+#define __DEPRECATED 1
+#define __DBL_MAX_EXP__ 1024
+#define __GNUG__ 4
+#define __LONG_LONG_MAX__ 9223372036854775807LL
+#define __GXX_ABI_VERSION 1002
+#define __FLT_MIN_EXP__ (-125)
+#define __DBL_MIN__ 2.2250738585072014e-308
+#define __FLT_MIN_10_EXP__ (-37)
+#define __DBL_HAS_QUIET_NAN__ 1
+#define __REGISTER_PREFIX__
+#define __NO_INLINE__ 1
+#define __i386 1
+#define __FLT_MANT_DIG__ 24
+#define __VERSION__ "4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)"
+#define i386 1
+#define __i486__ 1
+#define unix 1
+#define __i386__ 1
+#define __SIZE_TYPE__ unsigned int
+#define __ELF__ 1
+#define __FLT_RADIX__ 2
+#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
+#define __FLT_HAS_QUIET_NAN__ 1
+#define __FLT_MAX_10_EXP__ 38
+#define __LONG_MAX__ 2147483647L
+#define __FLT_HAS_INFINITY__ 1
+#define linux 1
+#define __EXCEPTIONS 1
+#define __LDBL_MANT_DIG__ 64
+#define __WCHAR_TYPE__ int
+#define __FLT_DIG__ 6
+#define __INT_MAX__ 2147483647
+#define __i486 1
+#define __FLT_MAX_EXP__ 128
+#define __DBL_MANT_DIG__ 53
+#define __WINT_TYPE__ unsigned int
+#define __LDBL_MIN_EXP__ (-16381)
+#define __LDBL_MAX_10_EXP__ 4932
+#define __DBL_EPSILON__ 2.2204460492503131e-16
+#define __tune_i486__ 1
+#define __INTMAX_MAX__ 9223372036854775807LL
+#define __FLT_DENORM_MIN__ 1.40129846e-45F
+#define __FLT_MAX__ 3.40282347e+38F
+#define __INTMAX_TYPE__ long long int
+#define __GNUC_MINOR__ 0
+#define __DBL_MAX_10_EXP__ 308
+#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+#define __PTRDIFF_TYPE__ int
+#define __LDBL_MIN_10_EXP__ (-4931)
+#define __LDBL_DIG__ 18
+#define _GNU_SOURCE 1
+
+
+#define __STDC__
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-engine-bits.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-engine-bits.h
new file mode 100644
index 000000000..3d8aee029
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-engine-bits.h
@@ -0,0 +1,1300 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_ENGINE_BITS_H
+#define PP_ENGINE_BITS_H
+
+#include "pp.h"
+#include <sys/stat.h>
+#include <cstdio>
+#include <iostream>
+
+namespace rpp
+{
+
+inline std::string pp::fix_file_path(std::string const &filename) const
+{
+#if defined (PP_OS_WIN)
+ std::string s = filename;
+ for (std::string::iterator it = s.begin(); it != s.end(); ++it) {
+ if (*it == '/')
+ *it = '\\';
+ }
+ return s;
+#else
+ return filename;
+#endif
+}
+
+inline bool pp::is_absolute(std::string const &filename) const
+{
+#if defined(PP_OS_WIN)
+ return filename.length() >= 3
+ && filename.at(1) == ':'
+ && (filename.at(2) == '\\' || filename.at(2) == '/');
+#else
+ return filename.length() >= 1
+ && filename.at(0) == '/';
+#endif
+}
+
+template <typename _OutputIterator>
+void pp::file(std::string const &filename, _OutputIterator __result)
+{
+ FILE *fp = std::fopen(filename.c_str(), "rb");
+ if (fp != 0) {
+ std::string was = env.current_file;
+ env.current_file = filename;
+ file(fp, __result);
+ env.current_file = was;
+ }
+ //else
+ //std::cerr << "** WARNING file ``" << filename << " not found!" << std::endl;
+}
+
+template <typename _OutputIterator>
+void pp::file(FILE *fp, _OutputIterator __result)
+{
+ assert(fp != 0);
+
+#if defined (HAVE_MMAP)
+ struct stat st;
+ fstat(FILENO(fp), &st);
+ std::size_t size = st.st_size;
+ char *buffer = 0;
+ buffer = (char *) ::mmap(0, size, PROT_READ, MAP_SHARED, FILENO(fp), 0);
+ fclose(fp);
+ if (!buffer || buffer == (char*) - 1)
+ return;
+ this->operator()(buffer, buffer + size, __result);
+ ::munmap(buffer, size);
+#else
+ std::string buffer;
+ while (!feof(fp)) {
+ char tmp[1024];
+ int read = (int) fread(tmp, sizeof(char), 1023, fp);
+ tmp[read] = '\0';
+ buffer += tmp;
+ }
+ fclose(fp);
+ this->operator()(buffer.c_str(), buffer.c_str() + buffer.size(), __result);
+#endif
+}
+
+template <typename _InputIterator>
+bool pp::find_header_protection(_InputIterator __first, _InputIterator __last, std::string *__prot)
+{
+ int was = env.current_line;
+
+ while (__first != __last) {
+ if (pp_isspace(*__first)) {
+ if (*__first == '\n')
+ ++env.current_line;
+
+ ++__first;
+ } else if (_PP_internal::comment_p(__first, __last)) {
+ __first = skip_comment_or_divop(__first, __last);
+ env.current_line += skip_comment_or_divop.lines;
+ } else if (*__first == '#') {
+ __first = skip_blanks(++__first, __last);
+ env.current_line += skip_blanks.lines;
+
+ if (__first != __last && *__first == 'i') {
+ _InputIterator __begin = __first;
+ __first = skip_identifier(__begin, __last);
+ env.current_line += skip_identifier.lines;
+
+ std::string __directive(__begin, __first);
+
+ if (__directive == "ifndef") {
+ __first = skip_blanks(__first, __last);
+ env.current_line += skip_blanks.lines;
+
+ __begin = __first;
+ __first = skip_identifier(__first, __last);
+ env.current_line += skip_identifier.lines;
+
+ if (__begin != __first && __first != __last) {
+ __prot->assign(__begin, __first);
+ return true;
+ }
+ }
+ }
+ break;
+ } else
+ break;
+ }
+
+ env.current_line = was;
+ return false;
+}
+
+inline pp::PP_DIRECTIVE_TYPE pp::find_directive(char const *__directive, std::size_t __size) const
+{
+ switch (__size) {
+ case 0:
+ return PP_UNNAMED_DIRECTIVE;
+ case 2:
+ if (__directive[0] == 'i'
+ && __directive[1] == 'f')
+ return PP_IF;
+ break;
+
+ case 4:
+ if (__directive[0] == 'e' && !strcmp(__directive, "elif"))
+ return PP_ELIF;
+ else if (__directive[0] == 'e' && !strcmp(__directive, "else"))
+ return PP_ELSE;
+ break;
+
+ case 5:
+ if (__directive[0] == 'i' && !strcmp(__directive, "ifdef"))
+ return PP_IFDEF;
+ else if (__directive[0] == 'u' && !strcmp(__directive, "undef"))
+ return PP_UNDEF;
+ else if (__directive[0] == 'e') {
+ if (!strcmp(__directive, "endif"))
+ return PP_ENDIF;
+ else if (!strcmp(__directive, "error"))
+ return PP_ERROR;
+ }
+ break;
+
+ case 6:
+ if (__directive[0] == 'i' && !strcmp(__directive, "ifndef"))
+ return PP_IFNDEF;
+ else if (__directive[0] == 'd' && !strcmp(__directive, "define"))
+ return PP_DEFINE;
+ else if (__directive[0] == 'p' && !strcmp(__directive, "pragma"))
+ return PP_PRAGMA;
+ break;
+
+ case 7:
+ if (__directive[0] == 'i' && !strcmp(__directive, "include"))
+ return PP_INCLUDE;
+ else if (!strcmp(__directive, "warning"))
+ return PP_WARNING;
+ break;
+
+ case 12:
+ if (__directive[0] == 'i' && !strcmp(__directive, "include_next"))
+ return PP_INCLUDE_NEXT;
+ break;
+
+ default:
+ break;
+ }
+ std::cerr << "** WARNING unknown directive '#" << __directive << "' at " << env.current_file << ":" << env.current_line << std::endl;
+ return PP_UNKNOWN_DIRECTIVE;
+}
+
+inline bool pp::file_isdir(std::string const &__filename) const
+{
+ struct stat __st;
+ if (stat(__filename.c_str(), &__st) == 0)
+#if defined(PP_OS_WIN)
+ return (__st.st_mode & _S_IFDIR) == _S_IFDIR;
+#else
+ return (__st.st_mode & S_IFDIR) == S_IFDIR;
+#endif
+ else
+ return false;
+}
+
+inline bool pp::file_exists(std::string const &__filename) const
+{
+ struct stat __st;
+ return stat(__filename.c_str(), &__st) == 0;
+}
+
+inline FILE *pp::find_include_file(std::string const &__input_filename, std::string *__filepath,
+ INCLUDE_POLICY __include_policy, bool __skip_current_path) const
+{
+ assert(__filepath != 0);
+ assert(! __input_filename.empty());
+
+ __filepath->assign(__input_filename);
+
+ if (is_absolute(*__filepath) && !file_isdir(*__filepath))
+ return std::fopen(__filepath->c_str(), "r");
+
+ if (! env.current_file.empty())
+ _PP_internal::extract_file_path(env.current_file, __filepath);
+
+ if (__include_policy == INCLUDE_LOCAL && ! __skip_current_path) {
+ std::string __tmp(*__filepath);
+ __tmp += __input_filename;
+
+ if (file_exists(__tmp) && !file_isdir(__tmp)) {
+ __filepath->append(__input_filename);
+ return std::fopen(__filepath->c_str(), "r");
+ }
+ }
+
+ std::vector<std::string>::const_iterator it = include_paths.begin();
+
+ if (__skip_current_path) {
+ it = std::find(include_paths.begin(), include_paths.end(), *__filepath);
+
+ if (it != include_paths.end())
+ ++it;
+
+ else
+ it = include_paths.begin();
+ }
+
+ for (; it != include_paths.end(); ++it) {
+ if (__skip_current_path && it == include_paths.begin())
+ continue;
+
+ __filepath->assign(*it);
+ __filepath->append(__input_filename);
+
+ if (file_exists(*__filepath) && !file_isdir(*__filepath))
+ return std::fopen(__filepath->c_str(), "r");
+
+#ifdef Q_OS_MAC
+ // try in Framework path on Mac, if there is a path in front
+ // ### what about escaped slashes?
+ size_t slashPos = __input_filename.find('/');
+ if (slashPos != std::string::npos) {
+ __filepath->assign(*it);
+ __filepath->append(__input_filename.substr(0, slashPos));
+ __filepath->append(".framework/Headers/");
+ __filepath->append(__input_filename.substr(slashPos + 1, std::string::npos));
+
+ if (file_exists(*__filepath) && !file_isdir(*__filepath)) {
+ return fopen(__filepath->c_str(), "r");
+ }
+ }
+#endif // Q_OS_MAC
+ }
+
+ return 0;
+}
+
+template <typename _InputIterator, typename _OutputIterator>
+_InputIterator pp::handle_directive(char const *__directive, std::size_t __size,
+ _InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ __first = skip_blanks(__first, __last);
+
+ PP_DIRECTIVE_TYPE d = find_directive(__directive, __size);
+ switch (d) {
+ case PP_UNNAMED_DIRECTIVE:
+ /* There are many boost headers that include the character '#'
+ * at the beginning of any line and just do nothing else with
+ * that unnamed directive. Well, as that's not an error so
+ * we'll just ignore this unnamed directive for now.
+ */
+ ++__last;
+ return ++__first;
+ case PP_DEFINE:
+ if (! skipping())
+ return handle_define(__first, __last);
+ break;
+
+ case PP_INCLUDE:
+ case PP_INCLUDE_NEXT:
+ if (! skipping())
+ return handle_include(d == PP_INCLUDE_NEXT, __first, __last, __result);
+ break;
+
+ case PP_UNDEF:
+ if (! skipping())
+ return handle_undef(__first, __last);
+ break;
+
+ case PP_ELIF:
+ return handle_elif(__first, __last);
+
+ case PP_ELSE:
+ return handle_else(__first, __last);
+
+ case PP_ENDIF:
+ return handle_endif(__first, __last);
+
+ case PP_IF:
+ return handle_if(__first, __last);
+
+ case PP_IFDEF:
+ return handle_ifdef(false, __first, __last);
+
+ case PP_IFNDEF:
+ return handle_ifdef(true, __first, __last);
+
+ default:
+ break;
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator, typename _OutputIterator>
+_InputIterator pp::handle_include(bool __skip_current_path, _InputIterator __first, _InputIterator __last,
+ _OutputIterator __result)
+{
+ if (pp_isalpha(*__first) || *__first == '_') {
+ pp_macro_expander expand_include(env);
+ std::string name;
+ name.reserve(255);
+ expand_include(__first, __last, std::back_inserter(name));
+ std::string::iterator it = skip_blanks(name.begin(), name.end());
+ if (it != name.end() && !(*it == '<' || *it == '"')) {
+ std::cerr << "** WARNING APIExtractor does not support the use "
+ "of #include directives without passing either "
+ "\"<path/to/header.h>\" or \"./path/to/header.h\", "
+ "for example. Invalid use at " << env.current_file
+ << ":" << env.current_line << "." << std::endl;
+ return __last;
+ }
+
+ handle_include(__skip_current_path, it, name.end(), __result);
+ return __first;
+ }
+
+ assert(*__first == '<' || *__first == '"');
+ int quote = (*__first == '"') ? '"' : '>';
+ ++__first;
+
+ _InputIterator end_name = __first;
+ for (; end_name != __last; ++end_name) {
+ assert(*end_name != '\n');
+
+ if (*end_name == quote)
+ break;
+ }
+
+ std::string filename(__first, end_name);
+
+#ifdef PP_OS_WIN
+ std::replace(filename.begin(), filename.end(), '/', '\\');
+#endif
+
+ std::string filepath;
+ FILE *fp = find_include_file(filename, &filepath, quote == '>' ? INCLUDE_GLOBAL : INCLUDE_LOCAL, __skip_current_path);
+
+#if defined (PP_HOOK_ON_FILE_INCLUDED)
+ PP_HOOK_ON_FILE_INCLUDED(env.current_file, fp ? filepath : filename, fp);
+#endif
+
+ if (fp != 0) {
+ std::string old_file = env.current_file;
+ env.current_file = filepath;
+ int __saved_lines = env.current_line;
+
+ env.current_line = 1;
+ //output_line (env.current_file, 1, __result);
+
+ file(fp, __result);
+
+ // restore the file name and the line position
+ env.current_file = old_file;
+ env.current_line = __saved_lines;
+
+ // sync the buffer
+ _PP_internal::output_line(env.current_file, env.current_line, __result);
+ }
+#ifndef RPP_JAMBI
+// else
+// std::cerr << "*** WARNING " << filename << ": No such file or directory" << std::endl;
+#endif
+
+ return __first;
+}
+
+template <typename _InputIterator, typename _OutputIterator>
+void pp::operator()(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+#ifndef PP_NO_SMART_HEADER_PROTECTION
+ std::string __prot;
+ __prot.reserve(255);
+ pp_fast_string __tmp(__prot.c_str(), __prot.size());
+
+ if (find_header_protection(__first, __last, &__prot)
+ && env.resolve(&__tmp) != 0) {
+ // std::cerr << "** DEBUG found header protection:" << __prot << std::endl;
+ return;
+ }
+#endif
+
+ env.current_line = 1;
+ char __buffer[512];
+
+ while (true) {
+ __first = skip_blanks(__first, __last);
+ env.current_line += skip_blanks.lines;
+
+ if (__first == __last)
+ break;
+ else if (*__first == '#') {
+ assert(*__first == '#');
+ __first = skip_blanks(++__first, __last);
+ env.current_line += skip_blanks.lines;
+
+ _InputIterator end_id = skip_identifier(__first, __last);
+ env.current_line += skip_identifier.lines;
+ std::size_t __size = end_id - __first;
+
+ assert(__size < 512);
+ char *__cp = __buffer;
+ std::copy(__first, end_id, __cp);
+ __cp[__size] = '\0';
+
+ end_id = skip_blanks(end_id, __last);
+ __first = skip(end_id, __last);
+
+ int was = env.current_line;
+ (void) handle_directive(__buffer, __size, end_id, __first, __result);
+
+ if (env.current_line != was) {
+ env.current_line = was;
+ _PP_internal::output_line(env.current_file, env.current_line, __result);
+ }
+ } else if (*__first == '\n') {
+ // ### compress the line
+ *__result++ = *__first++;
+ ++env.current_line;
+ } else if (skipping())
+ __first = skip(__first, __last);
+ else {
+ _PP_internal::output_line(env.current_file, env.current_line, __result);
+ __first = expand(__first, __last, __result);
+ env.current_line += expand.lines;
+
+ if (expand.generated_lines)
+ _PP_internal::output_line(env.current_file, env.current_line, __result);
+ }
+ }
+}
+
+inline pp::pp(pp_environment &__env):
+ env(__env), expand(env)
+{
+ iflevel = 0;
+ _M_skipping[iflevel] = 0;
+ _M_true_test[iflevel] = 0;
+}
+
+inline std::back_insert_iterator<std::vector<std::string> > pp::include_paths_inserter()
+{
+ return std::back_inserter(include_paths);
+}
+
+inline std::vector<std::string>::iterator pp::include_paths_begin()
+{
+ return include_paths.begin();
+}
+
+inline std::vector<std::string>::iterator pp::include_paths_end()
+{
+ return include_paths.end();
+}
+
+inline std::vector<std::string>::const_iterator pp::include_paths_begin() const
+{
+ return include_paths.begin();
+}
+
+inline std::vector<std::string>::const_iterator pp::include_paths_end() const
+{
+ return include_paths.end();
+}
+
+inline void pp::push_include_path(std::string const &__path)
+{
+ if (__path.empty() || __path [__path.size() - 1] != PATH_SEPARATOR) {
+ std::string __tmp(__path);
+ __tmp += PATH_SEPARATOR;
+ include_paths.push_back(__tmp);
+ }
+
+ else
+ include_paths.push_back(__path);
+}
+
+template <typename _InputIterator>
+_InputIterator pp::handle_define(_InputIterator __first, _InputIterator __last)
+{
+ pp_macro macro;
+#if defined (PP_WITH_MACRO_POSITION)
+ macro.file = pp_symbol::get(env.current_file);
+#endif
+ std::string definition;
+
+ __first = skip_blanks(__first, __last);
+ _InputIterator end_macro_name = skip_identifier(__first, __last);
+ pp_fast_string const *macro_name = pp_symbol::get(__first, end_macro_name);
+ __first = end_macro_name;
+
+ if (__first != __last && *__first == '(') {
+ macro.function_like = true;
+ macro.formals.reserve(5);
+
+ __first = skip_blanks(++__first, __last); // skip '('
+ _InputIterator arg_end = skip_identifier(__first, __last);
+ if (__first != arg_end)
+ macro.formals.push_back(pp_symbol::get(__first, arg_end));
+
+ __first = skip_blanks(arg_end, __last);
+
+ if (*__first == '.') {
+ macro.variadics = true;
+ while (*__first == '.')
+ ++__first;
+ }
+
+ while (__first != __last && *__first == ',') {
+ __first = skip_blanks(++__first, __last);
+
+ arg_end = skip_identifier(__first, __last);
+ if (__first != arg_end)
+ macro.formals.push_back(pp_symbol::get(__first, arg_end));
+
+ __first = skip_blanks(arg_end, __last);
+
+ if (*__first == '.') {
+ macro.variadics = true;
+ while (*__first == '.')
+ ++__first;
+ }
+ }
+
+ assert(*__first == ')');
+ ++__first;
+ }
+
+ __first = skip_blanks(__first, __last);
+
+ /* Note: Sometimes one can include a path between brackets (for
+ * e.g., when defining a macro or so) so that we cannot simply
+ * ignore that. The in_path variable will handle this situation.
+ */
+ bool in_path = false;
+ while (__first != __last && *__first != '\n') {
+ if ((*__first == '<' || *__first == '"') &&
+ (*(__first + 1) != '*' && *(__first + 1) != '/')) {
+ in_path = true;
+ goto skip_path;
+ }
+
+ if (in_path) {
+ if (*__first == '>' || *__first == '"') {
+ in_path = false;
+ goto skip_path;
+ } else if (*__first == ',' || *__first == ' ' || *__first == '\\') {
+ in_path = false;
+ continue;
+ }
+ }
+
+ if (*__first == '/') {
+ if (*(__first + 1) != '*' && *(__first + 1) != '/') {
+ in_path = true;
+ goto skip_path;
+ } else {
+ __first = skip_comment_or_divop(__first, __last);
+ env.current_line += skip_comment_or_divop.lines;
+ if (__first == __last)
+ break;
+ }
+ }
+
+ if (*__first == '\\') {
+ _InputIterator __begin = __first;
+ __begin = skip_blanks(++__begin, __last);
+
+ if (__begin != __last && *__begin == '\n') {
+ ++macro.lines;
+ __first = skip_blanks(++__begin, __last);
+ definition += ' ';
+ continue;
+ }
+ }
+
+skip_path:
+ definition += *__first++;
+ }
+
+ macro.definition = pp_symbol::get(definition);
+ env.bind(macro_name, macro);
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::skip(_InputIterator __first, _InputIterator __last)
+{
+ pp_skip_string_literal skip_string_literal;
+ pp_skip_char_literal skip_char_literal;
+
+ while (__first != __last && *__first != '\n') {
+ if (*__first == '/') {
+ __first = skip_comment_or_divop(__first, __last);
+ env.current_line += skip_comment_or_divop.lines;
+ } else if (*__first == '"') {
+ __first = skip_string_literal(__first, __last);
+ env.current_line += skip_string_literal.lines;
+ } else if (*__first == '\'') {
+ __first = skip_char_literal(__first, __last);
+ env.current_line += skip_char_literal.lines;
+ } else if (*__first == '\\') {
+ __first = skip_blanks(++__first, __last);
+ env.current_line += skip_blanks.lines;
+
+ if (__first != __last && *__first == '\n') {
+ ++__first;
+ ++env.current_line;
+ }
+ } else
+ ++__first;
+ }
+
+ return __first;
+}
+
+inline bool pp::test_if_level()
+{
+ bool result = !_M_skipping[iflevel++];
+ _M_skipping[iflevel] = _M_skipping[iflevel - 1];
+ _M_true_test[iflevel] = false;
+ return result;
+}
+
+inline int pp::skipping() const
+{
+ return _M_skipping[iflevel];
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_primary(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ bool expect_paren = false;
+ int token;
+ __first = next_token(__first, __last, &token);
+
+ switch (token) {
+ case TOKEN_NUMBER:
+ result->set_long(token_value);
+ break;
+
+ case TOKEN_UNUMBER:
+ result->set_ulong(token_uvalue);
+ break;
+
+ case TOKEN_DEFINED:
+ __first = next_token(__first, __last, &token);
+
+ if (token == '(') {
+ expect_paren = true;
+ __first = next_token(__first, __last, &token);
+ }
+
+ if (token != TOKEN_IDENTIFIER) {
+ std::cerr << "** WARNING expected ``identifier'' found:" << char(token) << std::endl;
+ result->set_long(0);
+ break;
+ }
+
+ result->set_long(env.resolve(token_text->c_str(), token_text->size()) != 0);
+
+ next_token(__first, __last, &token); // skip '('
+
+ if (expect_paren) {
+ _InputIterator next = next_token(__first, __last, &token);
+ if (token != ')')
+ std::cerr << "** WARNING expected ``)''" << std::endl;
+ else
+ __first = next;
+ }
+ break;
+
+ case TOKEN_IDENTIFIER:
+ result->set_long(0);
+ break;
+
+ case '-':
+ __first = eval_primary(__first, __last, result);
+ result->set_long(- result->l);
+ return __first;
+
+ case '+':
+ __first = eval_primary(__first, __last, result);
+ return __first;
+
+ case '!':
+ __first = eval_primary(__first, __last, result);
+ result->set_long(result->is_zero());
+ return __first;
+
+ case '(':
+ __first = eval_constant_expression(__first, __last, result);
+ next_token(__first, __last, &token);
+
+ if (token != ')') {
+ std::cerr << "** WARNING expected ``)'' = " << token << " (at "
+ << env.current_file << ":" << env.current_line
+ << ")." << std::endl;
+ } else {
+ __first = next_token(__first, __last, &token);
+ }
+ break;
+
+ default:
+ result->set_long(0);
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_multiplicative(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ __first = eval_primary(__first, __last, result);
+
+ int token;
+ _InputIterator next = next_token(__first, __last, &token);
+
+ while (token == '*' || token == '/' || token == '%') {
+ Value value;
+ __first = eval_primary(next, __last, &value);
+
+ if (token == '*')
+ result->op_mult(value);
+ else if (token == '/') {
+ if (value.is_zero()) {
+ std::cerr << "** WARNING division by zero" << std::endl;
+ result->set_long(0);
+ } else
+ result->op_div(value);
+ } else {
+ if (value.is_zero()) {
+ std::cerr << "** WARNING division by zero" << std::endl;
+ result->set_long(0);
+ } else
+ result->op_mod(value);
+ }
+ next = next_token(__first, __last, &token);
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_additive(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ __first = eval_multiplicative(__first, __last, result);
+
+ int token;
+ _InputIterator next = next_token(__first, __last, &token);
+
+ while (token == '+' || token == '-') {
+ Value value;
+ __first = eval_multiplicative(next, __last, &value);
+
+ if (token == '+')
+ result->op_add(value);
+ else
+ result->op_sub(value);
+ next = next_token(__first, __last, &token);
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_shift(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ __first = eval_additive(__first, __last, result);
+
+ int token;
+ _InputIterator next = next_token(__first, __last, &token);
+
+ while (token == TOKEN_LT_LT || token == TOKEN_GT_GT) {
+ Value value;
+ __first = eval_additive(next, __last, &value);
+
+ if (token == TOKEN_LT_LT)
+ result->op_lhs(value);
+ else
+ result->op_rhs(value);
+ next = next_token(__first, __last, &token);
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_relational(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ __first = eval_shift(__first, __last, result);
+
+ int token;
+ _InputIterator next = next_token(__first, __last, &token);
+
+ while (token == '<'
+ || token == '>'
+ || token == TOKEN_LT_EQ
+ || token == TOKEN_GT_EQ) {
+ Value value;
+ __first = eval_shift(next, __last, &value);
+
+ switch (token) {
+ default:
+ assert(0);
+ break;
+
+ case '<':
+ result->op_lt(value);
+ break;
+
+ case '>':
+ result->op_gt(value);
+ break;
+
+ case TOKEN_LT_EQ:
+ result->op_le(value);
+ break;
+
+ case TOKEN_GT_EQ:
+ result->op_ge(value);
+ break;
+ }
+ next = next_token(__first, __last, &token);
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_equality(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ __first = eval_relational(__first, __last, result);
+
+ int token;
+ _InputIterator next = next_token(__first, __last, &token);
+
+ while (token == TOKEN_EQ_EQ || token == TOKEN_NOT_EQ) {
+ Value value;
+ __first = eval_relational(next, __last, &value);
+
+ if (token == TOKEN_EQ_EQ)
+ result->op_eq(value);
+ else
+ result->op_ne(value);
+ next = next_token(__first, __last, &token);
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_and(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ __first = eval_equality(__first, __last, result);
+
+ int token;
+ _InputIterator next = next_token(__first, __last, &token);
+
+ while (token == '&') {
+ Value value;
+ __first = eval_equality(next, __last, &value);
+ result->op_bit_and(value);
+ next = next_token(__first, __last, &token);
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_xor(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ __first = eval_and(__first, __last, result);
+
+ int token;
+ _InputIterator next = next_token(__first, __last, &token);
+
+ while (token == '^') {
+ Value value;
+ __first = eval_and(next, __last, &value);
+ result->op_bit_xor(value);
+ next = next_token(__first, __last, &token);
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_or(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ __first = eval_xor(__first, __last, result);
+
+ int token;
+ _InputIterator next = next_token(__first, __last, &token);
+
+ while (token == '|') {
+ Value value;
+ __first = eval_xor(next, __last, &value);
+ result->op_bit_or(value);
+ next = next_token(__first, __last, &token);
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_logical_and(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ __first = eval_or(__first, __last, result);
+
+ int token;
+ _InputIterator next = next_token(__first, __last, &token);
+
+ while (token == TOKEN_AND_AND) {
+ Value value;
+ __first = eval_or(next, __last, &value);
+ result->op_and(value);
+ next = next_token(__first, __last, &token);
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_logical_or(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ __first = eval_logical_and(__first, __last, result);
+
+ int token;
+ _InputIterator next = next_token(__first, __last, &token);
+
+ while (token == TOKEN_OR_OR) {
+ Value value;
+ __first = eval_logical_and(next, __last, &value);
+ result->op_or(value);
+ next = next_token(__first, __last, &token);
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_constant_expression(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ __first = eval_logical_or(__first, __last, result);
+
+ int token;
+ _InputIterator next = next_token(__first, __last, &token);
+
+ if (token == '?') {
+ Value left_value;
+ __first = eval_constant_expression(next, __last, &left_value);
+ __first = skip_blanks(__first, __last);
+
+ __first = next_token(__first, __last, &token);
+ if (token == ':') {
+ Value right_value;
+ __first = eval_constant_expression(__first, __last, &right_value);
+
+ *result = !result->is_zero() ? left_value : right_value;
+ } else {
+ std::cerr << "** WARNING expected ``:'' = " << int (token) << std::endl;
+ *result = left_value;
+ }
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::eval_expression(_InputIterator __first, _InputIterator __last, Value *result)
+{
+ return __first = eval_constant_expression(skip_blanks(__first, __last), __last, result);
+}
+
+template <typename _InputIterator>
+_InputIterator pp::handle_if(_InputIterator __first, _InputIterator __last)
+{
+ if (test_if_level()) {
+ pp_macro_expander expand_condition(env);
+ std::string condition;
+ condition.reserve(255);
+ expand_condition(skip_blanks(__first, __last), __last, std::back_inserter(condition));
+
+ Value result;
+ result.set_long(0);
+ eval_expression(condition.c_str(), condition.c_str() + condition.size(), &result);
+
+ _M_true_test[iflevel] = !result.is_zero();
+ _M_skipping[iflevel] = result.is_zero();
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::handle_else(_InputIterator __first, _InputIterator /*__last*/)
+{
+ if (iflevel == 0 && !skipping()) {
+ std::cerr << "** WARNING #else without #if" << std::endl;
+ } else if (iflevel > 0 && _M_skipping[iflevel - 1]) {
+ _M_skipping[iflevel] = true;
+ } else {
+ _M_skipping[iflevel] = _M_true_test[iflevel];
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::handle_elif(_InputIterator __first, _InputIterator __last)
+{
+ assert(iflevel > 0);
+
+ if (iflevel == 0 && !skipping()) {
+ std::cerr << "** WARNING #else without #if" << std::endl;
+ } else if (!_M_true_test[iflevel] && !_M_skipping[iflevel - 1]) {
+ Value result;
+ __first = eval_expression(__first, __last, &result);
+ _M_true_test[iflevel] = !result.is_zero();
+ _M_skipping[iflevel] = result.is_zero();
+ } else {
+ _M_skipping[iflevel] = true;
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::handle_endif(_InputIterator __first, _InputIterator /*__last*/)
+{
+ if (iflevel == 0 && !skipping()) {
+ std::cerr << "** WARNING #endif without #if" << std::endl;
+ } else {
+ _M_skipping[iflevel] = 0;
+ _M_true_test[iflevel] = 0;
+
+ --iflevel;
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::handle_ifdef(bool check_undefined, _InputIterator __first, _InputIterator __last)
+{
+ if (test_if_level()) {
+ _InputIterator end_macro_name = skip_identifier(__first, __last);
+
+ std::size_t __size;
+#if defined(__SUNPRO_CC)
+ std::distance(__first, end_macro_name, __size);
+#else
+ __size = std::distance(__first, end_macro_name);
+#endif
+ assert(__size < 256);
+
+ char __buffer [256];
+ std::copy(__first, end_macro_name, __buffer);
+
+ bool value = env.resolve(__buffer, __size) != 0;
+
+ __first = end_macro_name;
+
+ if (check_undefined)
+ value = !value;
+
+ _M_true_test[iflevel] = value;
+ _M_skipping[iflevel] = !value;
+ }
+
+ return __first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::handle_undef(_InputIterator __first, _InputIterator __last)
+{
+ __first = skip_blanks(__first, __last);
+ _InputIterator end_macro_name = skip_identifier(__first, __last);
+ assert(end_macro_name != __first);
+
+ std::size_t __size;
+#if defined(__SUNPRO_CC)
+ std::distance(__first, end_macro_name, __size);
+#else
+ __size = std::distance(__first, end_macro_name);
+#endif
+
+ assert(__size < 256);
+
+ char __buffer [256];
+ std::copy(__first, end_macro_name, __buffer);
+
+ pp_fast_string const __tmp(__buffer, __size);
+ env.unbind(&__tmp);
+
+ __first = end_macro_name;
+
+ return __first;
+}
+
+template <typename _InputIterator>
+char pp::peek_char(_InputIterator __first, _InputIterator __last)
+{
+ if (__first == __last)
+ return 0;
+
+ return *++__first;
+}
+
+template <typename _InputIterator>
+_InputIterator pp::next_token(_InputIterator __first, _InputIterator __last, int *kind)
+{
+ __first = skip_blanks(__first, __last);
+
+ if (__first == __last) {
+ *kind = 0;
+ return __first;
+ }
+
+ char ch = *__first;
+ char ch2 = peek_char(__first, __last);
+
+ switch (ch) {
+ case '/':
+ if (ch2 == '/' || ch2 == '*') {
+ __first = skip_comment_or_divop(__first, __last);
+ return next_token(__first, __last, kind);
+ }
+ ++__first;
+ *kind = '/';
+ break;
+
+ case '<':
+ ++__first;
+ if (ch2 == '<') {
+ ++__first;
+ *kind = TOKEN_LT_LT;
+ } else if (ch2 == '=') {
+ ++__first;
+ *kind = TOKEN_LT_EQ;
+ } else
+ *kind = '<';
+
+ return __first;
+
+ case '>':
+ ++__first;
+ if (ch2 == '>') {
+ ++__first;
+ *kind = TOKEN_GT_GT;
+ } else if (ch2 == '=') {
+ ++__first;
+ *kind = TOKEN_GT_EQ;
+ } else
+ *kind = '>';
+
+ return __first;
+
+ case '!':
+ ++__first;
+ if (ch2 == '=') {
+ ++__first;
+ *kind = TOKEN_NOT_EQ;
+ } else
+ *kind = '!';
+
+ return __first;
+
+ case '=':
+ ++__first;
+ if (ch2 == '=') {
+ ++__first;
+ *kind = TOKEN_EQ_EQ;
+ } else
+ *kind = '=';
+
+ return __first;
+
+ case '|':
+ ++__first;
+ if (ch2 == '|') {
+ ++__first;
+ *kind = TOKEN_OR_OR;
+ } else
+ *kind = '|';
+
+ return __first;
+
+ case '&':
+ ++__first;
+ if (ch2 == '&') {
+ ++__first;
+ *kind = TOKEN_AND_AND;
+ } else
+ *kind = '&';
+
+ return __first;
+
+ default:
+ if (pp_isalpha(ch) || ch == '_') {
+ _InputIterator end = skip_identifier(__first, __last);
+ _M_current_text.assign(__first, end);
+
+ token_text = &_M_current_text;
+ __first = end;
+
+ if (*token_text == "defined")
+ *kind = TOKEN_DEFINED;
+ else
+ *kind = TOKEN_IDENTIFIER;
+ } else if (pp_isdigit(ch)) {
+ _InputIterator end = skip_number(__first, __last);
+ std::string __str(__first, __last);
+ char ch = __str [__str.size() - 1];
+ if (ch == 'u' || ch == 'U') {
+ token_uvalue = strtoul(__str.c_str(), 0, 0);
+ *kind = TOKEN_UNUMBER;
+ } else {
+ token_value = strtol(__str.c_str(), 0, 0);
+ *kind = TOKEN_NUMBER;
+ }
+ __first = end;
+ } else
+ *kind = *__first++;
+ }
+
+ return __first;
+}
+
+} // namespace rpp
+
+#endif // PP_ENGINE_BITS_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-engine.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-engine.h
new file mode 100644
index 000000000..689d7720e
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-engine.h
@@ -0,0 +1,288 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_ENGINE_H
+#define PP_ENGINE_H
+
+#include <string>
+#include <vector>
+#include "pp-scanner.h"
+#include "pp-macro-expander.h"
+#include "pp-environment.h"
+
+namespace rpp
+{
+
+struct Value {
+ Value() : kind(Kind_Long), l(0) {}
+
+ enum Kind {
+ Kind_Long,
+ Kind_ULong,
+ };
+
+ Kind kind;
+
+ union {
+ long l;
+ unsigned long ul;
+ };
+
+ inline bool is_ulong() const {
+ return kind == Kind_ULong;
+ }
+
+ inline void set_ulong(unsigned long v) {
+ ul = v;
+ kind = Kind_ULong;
+ }
+
+ inline void set_long(long v) {
+ l = v;
+ kind = Kind_Long;
+ }
+
+ inline bool is_zero() const {
+ return l == 0;
+ }
+
+#define PP_DEFINE_BIN_OP(name, op) \
+ inline Value &name (const Value &other) \
+ { \
+ if (is_ulong () || other.is_ulong ()) \
+ set_ulong (ul op other.ul); \
+ else \
+ set_long (l op other.l); \
+ return *this; \
+ }
+
+ PP_DEFINE_BIN_OP(op_add, +)
+ PP_DEFINE_BIN_OP(op_sub, -)
+ PP_DEFINE_BIN_OP(op_mult, *)
+ PP_DEFINE_BIN_OP(op_div, /)
+ PP_DEFINE_BIN_OP(op_mod, %)
+ PP_DEFINE_BIN_OP(op_lhs, <<)
+ PP_DEFINE_BIN_OP(op_rhs, >>)
+ PP_DEFINE_BIN_OP(op_lt, <)
+ PP_DEFINE_BIN_OP(op_gt, >)
+ PP_DEFINE_BIN_OP(op_le, <=)
+ PP_DEFINE_BIN_OP(op_ge, >=)
+ PP_DEFINE_BIN_OP(op_eq, ==)
+ PP_DEFINE_BIN_OP(op_ne, !=)
+ PP_DEFINE_BIN_OP(op_bit_and, &)
+ PP_DEFINE_BIN_OP(op_bit_or, |)
+ PP_DEFINE_BIN_OP(op_bit_xor, ^)
+ PP_DEFINE_BIN_OP(op_and, &&)
+ PP_DEFINE_BIN_OP(op_or, ||)
+
+#undef PP_DEFINE_BIN_OP
+};
+
+class pp
+{
+ pp_environment &env;
+ pp_macro_expander expand;
+ pp_skip_identifier skip_identifier;
+ pp_skip_comment_or_divop skip_comment_or_divop;
+ pp_skip_blanks skip_blanks;
+ pp_skip_number skip_number;
+ std::vector<std::string> include_paths;
+ std::string _M_current_text;
+
+ enum { MAX_LEVEL = 512 };
+ int _M_skipping[MAX_LEVEL];
+ int _M_true_test[MAX_LEVEL];
+ int iflevel;
+
+ union {
+ long token_value;
+ unsigned long token_uvalue;
+ std::string *token_text;
+ };
+
+ enum INCLUDE_POLICY {
+ INCLUDE_GLOBAL,
+ INCLUDE_LOCAL
+ };
+
+ enum TOKEN_TYPE {
+ TOKEN_NUMBER = 1000,
+ TOKEN_UNUMBER,
+ TOKEN_IDENTIFIER,
+ TOKEN_DEFINED,
+ TOKEN_LT_LT,
+ TOKEN_LT_EQ,
+ TOKEN_GT_GT,
+ TOKEN_GT_EQ,
+ TOKEN_EQ_EQ,
+ TOKEN_NOT_EQ,
+ TOKEN_OR_OR,
+ TOKEN_AND_AND,
+ };
+
+ enum PP_DIRECTIVE_TYPE {
+ PP_UNKNOWN_DIRECTIVE,
+ PP_UNNAMED_DIRECTIVE,
+ PP_DEFINE,
+ PP_INCLUDE,
+ PP_INCLUDE_NEXT,
+ PP_ELIF,
+ PP_ELSE,
+ PP_ENDIF,
+ PP_IF,
+ PP_IFDEF,
+ PP_IFNDEF,
+ PP_UNDEF,
+ PP_PRAGMA,
+ PP_ERROR,
+ PP_WARNING
+ };
+
+public:
+ pp(pp_environment &__env);
+
+ inline std::back_insert_iterator<std::vector<std::string> > include_paths_inserter();
+
+ inline void push_include_path(std::string const &__path);
+
+ inline std::vector<std::string>::iterator include_paths_begin();
+ inline std::vector<std::string>::iterator include_paths_end();
+
+ inline std::vector<std::string>::const_iterator include_paths_begin() const;
+ inline std::vector<std::string>::const_iterator include_paths_end() const;
+
+ template <typename _InputIterator>
+ inline _InputIterator eval_expression(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _OutputIterator>
+ void file(std::string const &filename, _OutputIterator __result);
+
+ template <typename _OutputIterator>
+ void file(FILE *fp, _OutputIterator __result);
+
+ template <typename _InputIterator, typename _OutputIterator>
+ void operator()(_InputIterator __first, _InputIterator __last, _OutputIterator __result);
+
+private:
+ inline bool file_isdir(std::string const &__filename) const;
+ inline bool file_exists(std::string const &__filename) const;
+ FILE *find_include_file(std::string const &__filename, std::string *__filepath,
+ INCLUDE_POLICY __include_policy, bool __skip_current_path = false) const;
+
+ inline int skipping() const;
+ bool test_if_level();
+
+ inline std::string fix_file_path(std::string const &filename) const;
+ inline bool is_absolute(std::string const &filename) const;
+
+ PP_DIRECTIVE_TYPE find_directive(char const *__directive, std::size_t __size) const;
+
+ template <typename _InputIterator>
+ bool find_header_protection(_InputIterator __first, _InputIterator __last, std::string *__prot);
+
+ template <typename _InputIterator>
+ _InputIterator skip(_InputIterator __first, _InputIterator __last);
+
+ template <typename _InputIterator>
+ _InputIterator eval_primary(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator>
+ _InputIterator eval_multiplicative(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator>
+ _InputIterator eval_additive(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator>
+ _InputIterator eval_shift(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator>
+ _InputIterator eval_relational(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator>
+ _InputIterator eval_equality(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator>
+ _InputIterator eval_and(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator>
+ _InputIterator eval_xor(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator>
+ _InputIterator eval_or(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator>
+ _InputIterator eval_logical_and(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator>
+ _InputIterator eval_logical_or(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator>
+ _InputIterator eval_constant_expression(_InputIterator __first, _InputIterator __last, Value *result);
+
+ template <typename _InputIterator, typename _OutputIterator>
+ _InputIterator handle_directive(char const *__directive, std::size_t __size,
+ _InputIterator __first, _InputIterator __last, _OutputIterator __result);
+
+ template <typename _InputIterator, typename _OutputIterator>
+ _InputIterator handle_include(bool skip_current_path, _InputIterator __first, _InputIterator __last,
+ _OutputIterator __result);
+
+ template <typename _InputIterator>
+ _InputIterator handle_define(_InputIterator __first, _InputIterator __last);
+
+ template <typename _InputIterator>
+ _InputIterator handle_if(_InputIterator __first, _InputIterator __last);
+
+ template <typename _InputIterator>
+ _InputIterator handle_else(_InputIterator __first, _InputIterator __last);
+
+ template <typename _InputIterator>
+ _InputIterator handle_elif(_InputIterator __first, _InputIterator __last);
+
+ template <typename _InputIterator>
+ _InputIterator handle_endif(_InputIterator __first, _InputIterator __last);
+
+ template <typename _InputIterator>
+ _InputIterator handle_ifdef(bool check_undefined, _InputIterator __first, _InputIterator __last);
+
+ template <typename _InputIterator>
+ _InputIterator handle_undef(_InputIterator __first, _InputIterator __last);
+
+ template <typename _InputIterator>
+ inline char peek_char(_InputIterator __first, _InputIterator __last);
+
+ template <typename _InputIterator>
+ _InputIterator next_token(_InputIterator __first, _InputIterator __last, int *kind);
+};
+
+} // namespace rpp
+
+#endif // PP_ENGINE_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-environment.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-environment.h
new file mode 100644
index 000000000..23f22e483
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-environment.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_ENVIRONMENT_H
+#define PP_ENVIRONMENT_H
+
+#include <vector>
+#include <string>
+#include <cstring>
+#include "pp-macro.h"
+
+namespace rpp
+{
+
+class pp_environment
+{
+public:
+ typedef std::vector<pp_macro*>::const_iterator const_iterator;
+
+public:
+ pp_environment():
+ current_line(0),
+ _M_hash_size(4093) {
+ _M_base = (pp_macro **) memset(new pp_macro* [_M_hash_size], 0, _M_hash_size * sizeof(pp_macro*));
+ }
+
+ ~pp_environment() {
+ for (std::size_t i = 0; i < _M_macros.size(); ++i)
+ delete _M_macros [i];
+
+ delete [] _M_base;
+ }
+
+ const_iterator first_macro() const {
+ return _M_macros.begin();
+ }
+ const_iterator last_macro() const {
+ return _M_macros.end();
+ }
+
+ inline void bind(pp_fast_string const *__name, pp_macro const &__macro) {
+ std::size_t h = hash_code(*__name) % _M_hash_size;
+ pp_macro *m = new pp_macro(__macro);
+ m->name = __name;
+ m->next = _M_base [h];
+ m->hash_code = h;
+ _M_base [h] = m;
+
+ _M_macros.push_back(m);
+
+ if (_M_macros.size() == _M_hash_size)
+ rehash();
+ }
+
+ inline void unbind(pp_fast_string const *__name) {
+ if (pp_macro *m = resolve(__name))
+ m->hidden = true;
+ }
+
+ inline void unbind(char const *__s, std::size_t __size) {
+ pp_fast_string __tmp(__s, __size);
+ unbind(&__tmp);
+ }
+
+ inline pp_macro *resolve(pp_fast_string const *__name) const {
+ std::size_t h = hash_code(*__name) % _M_hash_size;
+ pp_macro *it = _M_base [h];
+
+ while (it && it->name && it->hash_code == h && (*it->name != *__name || it->hidden))
+ it = it->next;
+
+ return it;
+ }
+
+ inline pp_macro *resolve(char const *__data, std::size_t __size) const {
+ pp_fast_string const __tmp(__data, __size);
+ return resolve(&__tmp);
+ }
+
+ std::string current_file;
+ int current_line;
+
+private:
+ inline std::size_t hash_code(pp_fast_string const &s) const {
+ std::size_t hash_value = 0;
+
+ for (std::size_t i = 0; i < s.size(); ++i)
+ hash_value = (hash_value << 5) - hash_value + s.at(i);
+
+ return hash_value;
+ }
+
+ void rehash() {
+ delete[] _M_base;
+
+ _M_hash_size <<= 1;
+
+ _M_base = (pp_macro **) memset(new pp_macro* [_M_hash_size], 0, _M_hash_size * sizeof(pp_macro*));
+ for (std::size_t index = 0; index < _M_macros.size(); ++index) {
+ pp_macro *elt = _M_macros [index];
+ std::size_t h = hash_code(*elt->name) % _M_hash_size;
+ elt->next = _M_base [h];
+ elt->hash_code = h;
+ _M_base [h] = elt;
+ }
+ }
+
+private:
+ std::vector<pp_macro*> _M_macros;
+ pp_macro **_M_base;
+ std::size_t _M_hash_size;
+};
+
+} // namespace rpp
+
+#endif // PP_ENVIRONMENT_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-fwd.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-fwd.h
new file mode 100644
index 000000000..2814b6d44
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-fwd.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_FWD_H
+#define PP_FWD_H
+
+namespace rpp
+{
+
+template <typename _CharT> class pp_string;
+
+typedef pp_string<char> pp_fast_string;
+
+} // namespace rpp
+
+#endif // PP_FWD_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-internal.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-internal.h
new file mode 100644
index 000000000..33efa0c27
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-internal.h
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_INTERNAL_H
+#define PP_INTERNAL_H
+
+#include <algorithm>
+#include <string>
+#include "pp.h"
+
+namespace rpp
+{
+
+namespace _PP_internal
+{
+
+inline void extract_file_path(const std::string &__filename, std::string *__filepath)
+{
+ std::size_t __index = __filename.rfind(PATH_SEPARATOR);
+
+ if (__index == std::string::npos)
+ *__filepath = "/";
+
+ else
+ __filepath->assign(__filename, 0, __index + 1);
+}
+
+template <typename _OutputIterator>
+void output_line(const std::string &__filename, int __line, _OutputIterator __result)
+{
+ std::string __msg;
+
+ __msg += "# ";
+
+ char __line_descr[16];
+ pp_snprintf(__line_descr, 16, "%d", __line);
+ __msg += __line_descr;
+
+ __msg += " \"";
+
+ if (__filename.empty())
+ __msg += "<internal>";
+ else
+ __msg += __filename;
+
+ __msg += "\"\n";
+ std::copy(__msg.begin(), __msg.end(), __result);
+}
+
+template <typename _InputIterator>
+inline bool comment_p(_InputIterator __first, _InputIterator __last) /*const*/
+{
+ if (__first == __last)
+ return false;
+
+ if (*__first != '/')
+ return false;
+
+ if (++__first == __last)
+ return false;
+
+ return (*__first == '/' || *__first == '*');
+}
+
+struct _Compare_string: public std::binary_function<bool, pp_fast_string const *, pp_fast_string const *> {
+ inline bool operator()(pp_fast_string const *__lhs, pp_fast_string const *__rhs) const {
+ return *__lhs < *__rhs;
+ }
+};
+
+struct _Equal_to_string: public std::binary_function<bool, pp_fast_string const *, pp_fast_string const *> {
+ inline bool operator()(pp_fast_string const *__lhs, pp_fast_string const *__rhs) const {
+ return *__lhs == *__rhs;
+ }
+};
+
+struct _Hash_string: public std::unary_function<std::size_t, pp_fast_string const *> {
+ inline std::size_t operator()(pp_fast_string const *__s) const {
+ char const *__ptr = __s->begin();
+ std::size_t __size = __s->size();
+ std::size_t __h = 0;
+
+ for (std::size_t i = 0; i < __size; ++i)
+ __h = (__h << 5) - __h + __ptr [i];
+
+ return __h;
+ }
+};
+
+} // _PP_internal
+
+} // namespace rpp
+
+#endif // PP_INTERNAL_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-iterator.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-iterator.h
new file mode 100644
index 000000000..35964fea4
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-iterator.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_ITERATOR_H
+#define PP_ITERATOR_H
+
+#include <iterator>
+
+namespace rpp
+{
+
+class pp_null_output_iterator
+ : public std::iterator<std::output_iterator_tag, void, void, void, void>
+{
+public:
+ pp_null_output_iterator() {}
+
+ template <typename _Tp>
+ pp_null_output_iterator &operator=(_Tp const &) {
+ return *this;
+ }
+
+ inline pp_null_output_iterator &operator *() {
+ return *this;
+ }
+ inline pp_null_output_iterator &operator ++ () {
+ return *this;
+ }
+ inline pp_null_output_iterator operator ++ (int) {
+ return *this;
+ }
+};
+
+template <typename _Container>
+class pp_output_iterator
+ : public std::iterator<std::output_iterator_tag, void, void, void, void>
+{
+ std::string &_M_result;
+
+public:
+ explicit pp_output_iterator(std::string &__result):
+ _M_result(__result) {}
+
+ inline pp_output_iterator<_Container>& operator=(const pp_output_iterator<_Container>& other)
+ {
+ _M_result = other._M_result;
+ return *this;
+ }
+
+ inline pp_output_iterator &operator=(typename _Container::const_reference __v) {
+ if (_M_result.capacity() == _M_result.size())
+ _M_result.reserve(_M_result.capacity() << 2);
+
+ _M_result.push_back(__v);
+ return *this;
+ }
+
+ inline pp_output_iterator &operator *() {
+ return *this;
+ }
+ inline pp_output_iterator &operator ++ () {
+ return *this;
+ }
+ inline pp_output_iterator operator ++ (int) {
+ return *this;
+ }
+};
+
+} // namespace rpp
+
+#endif // PP_ITERATOR_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-macro-expander.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-macro-expander.h
new file mode 100644
index 000000000..db93c3214
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-macro-expander.h
@@ -0,0 +1,356 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_MACRO_EXPANDER_H
+#define PP_MACRO_EXPANDER_H
+
+namespace rpp
+{
+
+struct pp_frame {
+ pp_macro *expanding_macro;
+ std::vector<std::string> *actuals;
+
+ pp_frame(pp_macro *__expanding_macro, std::vector<std::string> *__actuals):
+ expanding_macro(__expanding_macro), actuals(__actuals) {}
+};
+
+class pp_macro_expander
+{
+ pp_environment &env;
+ pp_frame *frame;
+
+ pp_skip_number skip_number;
+ pp_skip_identifier skip_identifier;
+ pp_skip_string_literal skip_string_literal;
+ pp_skip_char_literal skip_char_literal;
+ pp_skip_argument skip_argument;
+ pp_skip_comment_or_divop skip_comment_or_divop;
+ pp_skip_blanks skip_blanks;
+ pp_skip_whitespaces skip_whitespaces;
+
+ std::string const *resolve_formal(pp_fast_string const *__name) {
+ assert(__name != 0);
+
+ if (! frame)
+ return 0;
+
+ assert(frame->expanding_macro != 0);
+
+ std::vector<pp_fast_string const *> const formals = frame->expanding_macro->formals;
+ for (std::size_t index = 0; index < formals.size(); ++index) {
+ pp_fast_string const *formal = formals[index];
+
+ if (*formal != *__name)
+ continue;
+
+ else if (frame->actuals && index < frame->actuals->size())
+ return &(*frame->actuals)[index];
+
+ else
+ assert(0); // internal error?
+ }
+
+ return 0;
+ }
+
+public: // attributes
+ int lines;
+ int generated_lines;
+
+public:
+ pp_macro_expander(pp_environment &__env, pp_frame *__frame = 0):
+ env(__env), frame(__frame), lines(0), generated_lines(0) {}
+
+ template <typename _InputIterator, typename _OutputIterator>
+ _InputIterator operator()(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+ generated_lines = 0;
+ __first = skip_blanks(__first, __last);
+ lines = skip_blanks.lines;
+
+ while (__first != __last) {
+ if (*__first == '\n') {
+ *__result++ = *__first;
+ ++lines;
+
+ __first = skip_blanks(++__first, __last);
+ lines += skip_blanks.lines;
+
+ if (__first != __last && *__first == '#')
+ break;
+ } else if (*__first == '#') {
+ __first = skip_blanks(++__first, __last);
+ lines += skip_blanks.lines;
+
+ _InputIterator end_id = skip_identifier(__first, __last);
+
+ // ### rewrite: not safe
+ char name_buffer[512], *cp = name_buffer;
+ std::copy(__first, end_id, cp);
+ std::size_t name_size = end_id - __first;
+ name_buffer[name_size] = '\0';
+
+ pp_fast_string fast_name(name_buffer, name_size);
+
+ if (std::string const *actual = resolve_formal(&fast_name)) {
+ *__result++ = '\"';
+
+ for (std::string::const_iterator it = skip_whitespaces(actual->begin(), actual->end());
+ it != actual->end(); ++it) {
+ if (*it == '"') {
+ *__result++ = '\\';
+ *__result++ = *it;
+ }
+
+ else if (*it == '\n') {
+ *__result++ = '"';
+ *__result++ = '\n';
+ *__result++ = '"';
+ }
+
+ else
+ *__result++ = *it;
+ }
+
+ *__result++ = '\"';
+ __first = end_id;
+ } else
+ *__result++ = '#'; // ### warning message?
+ } else if (*__first == '\"') {
+ _InputIterator next_pos = skip_string_literal(__first, __last);
+ lines += skip_string_literal.lines;
+ std::copy(__first, next_pos, __result);
+ __first = next_pos;
+ } else if (*__first == '\'') {
+ _InputIterator next_pos = skip_char_literal(__first, __last);
+ lines += skip_char_literal.lines;
+ std::copy(__first, next_pos, __result);
+ __first = next_pos;
+ } else if (_PP_internal::comment_p(__first, __last)) {
+ __first = skip_comment_or_divop(__first, __last);
+ int n = skip_comment_or_divop.lines;
+ lines += n;
+
+ while (n-- > 0)
+ *__result++ = '\n';
+ } else if (pp_isspace(*__first)) {
+ for (; __first != __last; ++__first) {
+ if (*__first == '\n' || !pp_isspace(*__first))
+ break;
+ }
+
+ *__result = ' ';
+ } else if (pp_isdigit(*__first)) {
+ _InputIterator next_pos = skip_number(__first, __last);
+ lines += skip_number.lines;
+ std::copy(__first, next_pos, __result);
+ __first = next_pos;
+ } else if (pp_isalpha(*__first) || *__first == '_') {
+ _InputIterator name_begin = __first;
+ _InputIterator name_end = skip_identifier(__first, __last);
+ __first = name_end; // advance
+
+ // search for the paste token
+ _InputIterator next = skip_blanks(__first, __last);
+ if (next != __last && *next == '#') {
+ ++next;
+ if (next != __last && *next == '#')
+ __first = skip_blanks(++next, __last);
+ }
+
+ // ### rewrite: not safe
+
+ std::ptrdiff_t name_size;
+#if defined(__SUNPRO_CC)
+ std::distance(name_begin, name_end, name_size);
+#else
+ name_size = std::distance(name_begin, name_end);
+#endif
+ assert(name_size >= 0 && name_size < 512);
+
+ char name_buffer[512], *cp = name_buffer;
+ std::size_t __size = name_end - name_begin;
+ std::copy(name_begin, name_end, cp);
+ name_buffer[__size] = '\0';
+
+ pp_fast_string fast_name(name_buffer, name_size);
+
+ if (std::string const *actual = resolve_formal(&fast_name)) {
+ std::copy(actual->begin(), actual->end(), __result);
+ continue;
+ }
+
+ static bool hide_next = false; // ### remove me
+
+ pp_macro *macro = env.resolve(name_buffer, name_size);
+ if (! macro || macro->hidden || hide_next) {
+ hide_next = ! strcmp(name_buffer, "defined");
+
+ if (__size == 8 && name_buffer [0] == '_' && name_buffer [1] == '_') {
+ if (! strcmp(name_buffer, "__LINE__")) {
+ char buf [16];
+ char *end = buf + pp_snprintf(buf, 16, "%d", env.current_line + lines);
+
+ std::copy(&buf [0], end, __result);
+ continue;
+ }
+
+ else if (! strcmp(name_buffer, "__FILE__")) {
+ __result++ = '"';
+ std::copy(env.current_file.begin(), env.current_file.end(), __result); // ### quote
+ __result++ = '"';
+ continue;
+ }
+ }
+
+ std::copy(name_begin, name_end, __result);
+ continue;
+ }
+
+ if (! macro->function_like) {
+ pp_macro *m = 0;
+
+ if (macro->definition) {
+ macro->hidden = true;
+
+ std::string __tmp;
+ __tmp.reserve(256);
+
+ pp_macro_expander expand_macro(env);
+ expand_macro(macro->definition->begin(), macro->definition->end(), std::back_inserter(__tmp));
+ generated_lines += expand_macro.lines;
+
+ if (! __tmp.empty()) {
+ std::string::iterator __begin_id = skip_whitespaces(__tmp.begin(), __tmp.end());
+ std::string::iterator __end_id = skip_identifier(__begin_id, __tmp.end());
+
+ if (__end_id == __tmp.end()) {
+ std::string __id;
+ __id.assign(__begin_id, __end_id);
+
+ std::size_t x;
+#if defined(__SUNPRO_CC)
+ std::distance(__begin_id, __end_id, x);
+#else
+ x = std::distance(__begin_id, __end_id);
+#endif
+ m = env.resolve(__id.c_str(), x);
+ }
+
+ if (! m)
+ std::copy(__tmp.begin(), __tmp.end(), __result);
+ }
+
+ macro->hidden = false;
+ }
+
+ if (! m)
+ continue;
+
+ macro = m;
+ }
+
+ // function like macro
+ _InputIterator arg_it = skip_whitespaces(__first, __last);
+
+ if (arg_it == __last || *arg_it != '(') {
+ std::copy(name_begin, name_end, __result);
+ lines += skip_whitespaces.lines;
+ __first = arg_it;
+ continue;
+ }
+
+ std::vector<std::string> actuals;
+ actuals.reserve(5);
+ ++arg_it; // skip '('
+
+ pp_macro_expander expand_actual(env, frame);
+
+ _InputIterator arg_end = skip_argument_variadics(actuals, macro, arg_it, __last);
+ if (arg_it != arg_end) {
+ std::string actual(arg_it, arg_end);
+ actuals.resize(actuals.size() + 1);
+ actuals.back().reserve(255);
+ expand_actual(actual.begin(), actual.end(), std::back_inserter(actuals.back()));
+ arg_it = arg_end;
+ }
+
+ while (arg_it != __last && *arg_end == ',') {
+ ++arg_it; // skip ','
+
+ arg_end = skip_argument_variadics(actuals, macro, arg_it, __last);
+ std::string actual(arg_it, arg_end);
+ actuals.resize(actuals.size() + 1);
+ actuals.back().reserve(255);
+ expand_actual(actual.begin(), actual.end(), std::back_inserter(actuals.back()));
+ arg_it = arg_end;
+ }
+
+ assert(arg_it != __last && *arg_it == ')');
+
+ ++arg_it; // skip ')'
+ __first = arg_it;
+
+#if 0 // ### enable me
+ assert((macro->variadics && macro->formals.size() >= actuals.size())
+ || macro->formals.size() == actuals.size());
+#endif
+
+ pp_frame frame(macro, &actuals);
+ pp_macro_expander expand_macro(env, &frame);
+ macro->hidden = true;
+ expand_macro(macro->definition->begin(), macro->definition->end(), __result);
+ macro->hidden = false;
+ generated_lines += expand_macro.lines;
+ } else
+ *__result++ = *__first++;
+ }
+
+ return __first;
+ }
+
+ template <typename _InputIterator>
+ _InputIterator skip_argument_variadics(std::vector<std::string> const &__actuals, pp_macro *__macro,
+ _InputIterator __first, _InputIterator __last) {
+ _InputIterator arg_end = skip_argument(__first, __last);
+
+ while (__macro->variadics && __first != arg_end && arg_end != __last && *arg_end == ','
+ && (__actuals.size() + 1) == __macro->formals.size()) {
+ arg_end = skip_argument(++arg_end, __last);
+ }
+
+ return arg_end;
+ }
+};
+
+} // namespace rpp
+
+#endif // PP_MACRO_EXPANDER_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-macro.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-macro.h
new file mode 100644
index 000000000..9e95840a1
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-macro.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_MACRO_H
+#define PP_MACRO_H
+
+#include <vector>
+#include "pp-fwd.h"
+
+namespace rpp
+{
+
+struct pp_macro {
+#if defined (PP_WITH_MACRO_POSITION)
+ pp_fast_string const *file;
+#endif
+ pp_fast_string const *name;
+ pp_fast_string const *definition;
+ std::vector<pp_fast_string const *> formals;
+
+ union {
+ int unsigned state;
+
+ struct {
+ int unsigned hidden: 1;
+ int unsigned function_like: 1;
+ int unsigned variadics: 1;
+ };
+ };
+
+ int lines;
+ pp_macro *next;
+ std::size_t hash_code;
+
+ inline pp_macro():
+#if defined (PP_WITH_MACRO_POSITION)
+ file(0),
+#endif
+ name(0),
+ definition(0),
+ state(0),
+ lines(0),
+ next(0),
+ hash_code(0) {}
+};
+
+} // namespace rpp
+
+#endif // PP_MACRO_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-qt-configuration b/sources/shiboken2/ApiExtractor/parser/rpp/pp-qt-configuration
new file mode 100644
index 000000000..ba356c323
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-qt-configuration
@@ -0,0 +1,24 @@
+#define __cplusplus 1
+
+#define __STDC__ 1
+
+// Qt
+#define QOBJECTDEFS_H
+
+// not yet supported
+#define Q_SLOTS slots
+#define Q_SIGNALS signals
+#define Q_FLAGS(a)
+#define Q_PRIVATE_SLOT(a, b)
+#define Q_DECLARE_INTERFACE(a,b)
+#define Q_INTERFACES(a)
+#define Q_GADGET
+#define Q_OVERRIDE(a)
+#define Q_OS_OS2
+#define Q_NO_USING_KEYWORD
+#define QT_NO_QOBJECT_CHECK
+#define QT_NO_MEMBER_TEMPLATES
+// There are symbols in Qt that exist in Debug but
+// not in release
+#define QT_NO_DEBUG
+
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-scanner.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-scanner.h
new file mode 100644
index 000000000..0c5007e0f
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-scanner.h
@@ -0,0 +1,318 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_SCANNER_H
+#define PP_SCANNER_H
+
+#include "pp-cctype.h"
+#include <cassert>
+
+namespace rpp
+{
+
+struct pp_skip_blanks {
+ int lines;
+
+ template <typename _InputIterator>
+ _InputIterator operator()(_InputIterator __first, _InputIterator __last) {
+ lines = 0;
+
+ for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
+ if (*__first == '\\') {
+ _InputIterator __begin = __first;
+ ++__begin;
+
+ if (__begin != __last && *__begin == '\n')
+ ++__first;
+ else
+ break;
+ } else if (*__first == '\n' || !pp_isspace(*__first))
+ break;
+ }
+
+ return __first;
+ }
+};
+
+struct pp_skip_whitespaces {
+ int lines;
+
+ template <typename _InputIterator>
+ _InputIterator operator()(_InputIterator __first, _InputIterator __last) {
+ lines = 0;
+
+ for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
+ if (! pp_isspace(*__first))
+ break;
+ }
+
+ return __first;
+ }
+};
+
+struct pp_skip_comment_or_divop {
+ int lines;
+
+ template <typename _InputIterator>
+ _InputIterator operator()(_InputIterator __first, _InputIterator __last) {
+ enum {
+ MAYBE_BEGIN,
+ BEGIN,
+ MAYBE_END,
+ END,
+ IN_COMMENT,
+ IN_CXX_COMMENT
+ } state(MAYBE_BEGIN);
+
+ lines = 0;
+
+ for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
+ switch (state) {
+ default:
+ assert(0);
+ break;
+
+ case MAYBE_BEGIN:
+ if (*__first != '/')
+ return __first;
+
+ state = BEGIN;
+ break;
+
+ case BEGIN:
+ if (*__first == '*')
+ state = IN_COMMENT;
+ else if (*__first == '/')
+ state = IN_CXX_COMMENT;
+ else
+ return __first;
+ break;
+
+ case IN_COMMENT:
+ if (*__first == '*')
+ state = MAYBE_END;
+ break;
+
+ case IN_CXX_COMMENT:
+ if (*__first == '\n')
+ return __first;
+ break;
+
+ case MAYBE_END:
+ if (*__first == '/')
+ state = END;
+ else if (*__first != '*')
+ state = IN_COMMENT;
+ break;
+
+ case END:
+ return __first;
+ }
+ }
+
+ return __first;
+ }
+};
+
+struct pp_skip_identifier {
+ int lines;
+
+ template <typename _InputIterator>
+ _InputIterator operator()(_InputIterator __first, _InputIterator __last) {
+ lines = 0;
+
+ for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
+ if (! pp_isalnum(*__first) && *__first != '_')
+ break;
+ }
+
+ return __first;
+ }
+};
+
+struct pp_skip_number {
+ int lines;
+
+ template <typename _InputIterator>
+ _InputIterator operator()(_InputIterator __first, _InputIterator __last) {
+ lines = 0;
+
+ for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
+ if (! pp_isalnum(*__first) && *__first != '.')
+ break;
+ }
+
+ return __first;
+ }
+};
+
+struct pp_skip_string_literal {
+ int lines;
+
+ template <typename _InputIterator>
+ _InputIterator operator()(_InputIterator __first, _InputIterator __last) {
+ enum {
+ BEGIN,
+ IN_STRING,
+ QUOTE,
+ END
+ } state(BEGIN);
+
+ lines = 0;
+
+ for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
+ switch (state) {
+ default:
+ assert(0);
+ break;
+
+ case BEGIN:
+ if (*__first != '\"')
+ return __first;
+ state = IN_STRING;
+ break;
+
+ case IN_STRING:
+ assert(*__first != '\n');
+
+ if (*__first == '\"')
+ state = END;
+ else if (*__first == '\\')
+ state = QUOTE;
+ break;
+
+ case QUOTE:
+ state = IN_STRING;
+ break;
+
+ case END:
+ return __first;
+ }
+ }
+
+ return __first;
+ }
+};
+
+struct pp_skip_char_literal {
+ int lines;
+
+ template <typename _InputIterator>
+ _InputIterator operator()(_InputIterator __first, _InputIterator __last) {
+ enum {
+ BEGIN,
+ IN_STRING,
+ QUOTE,
+ END
+ } state(BEGIN);
+
+ lines = 0;
+
+ for (; state != END && __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
+ switch (state) {
+ default:
+ assert(0);
+ break;
+
+ case BEGIN:
+ if (*__first != '\'')
+ return __first;
+ state = IN_STRING;
+ break;
+
+ case IN_STRING:
+ assert(*__first != '\n');
+
+ if (*__first == '\'')
+ state = END;
+ else if (*__first == '\\')
+ state = QUOTE;
+ break;
+
+ case QUOTE:
+ state = IN_STRING;
+ break;
+ }
+ }
+
+ return __first;
+ }
+};
+
+struct pp_skip_argument {
+ pp_skip_identifier skip_number;
+ pp_skip_identifier skip_identifier;
+ pp_skip_string_literal skip_string_literal;
+ pp_skip_char_literal skip_char_literal;
+ pp_skip_comment_or_divop skip_comment_or_divop;
+ int lines;
+
+ template <typename _InputIterator>
+ _InputIterator operator()(_InputIterator __first, _InputIterator __last) {
+ int depth = 0;
+ lines = 0;
+
+ while (__first != __last) {
+ if (!depth && (*__first == ')' || *__first == ','))
+ break;
+ else if (*__first == '(')
+ ++depth, ++__first;
+ else if (*__first == ')')
+ --depth, ++__first;
+ else if (*__first == '\"') {
+ __first = skip_string_literal(__first, __last);
+ lines += skip_string_literal.lines;
+ } else if (*__first == '\'') {
+ __first = skip_char_literal(__first, __last);
+ lines += skip_char_literal.lines;
+ } else if (*__first == '/') {
+ __first = skip_comment_or_divop(__first, __last);
+ lines += skip_comment_or_divop.lines;
+ } else if (pp_isalpha(*__first) || *__first == '_') {
+ __first = skip_identifier(__first, __last);
+ lines += skip_identifier.lines;
+ } else if (pp_isdigit(*__first)) {
+ __first = skip_number(__first, __last);
+ lines += skip_number.lines;
+ } else if (*__first == '\n') {
+ ++__first;
+ ++lines;
+ } else
+ ++__first;
+ }
+
+ return __first;
+ }
+};
+
+} // namespace rpp
+
+#endif // PP_SCANNER_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-string.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-string.h
new file mode 100644
index 000000000..25db0389a
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-string.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_STRING_H
+#define PP_STRING_H
+
+namespace rpp
+{
+
+template <typename _CharT>
+class pp_string
+{
+ typedef std::char_traits<_CharT> traits_type;
+ typedef std::size_t size_type;
+
+ _CharT const *_M_begin;
+ std::size_t _M_size;
+
+public:
+ inline pp_string():
+ _M_begin(0), _M_size(0) {}
+
+ explicit pp_string(std::string const &__s):
+ _M_begin(__s.c_str()), _M_size(__s.size()) {}
+
+ inline pp_string(_CharT const *__begin, std::size_t __size):
+ _M_begin(__begin), _M_size(__size) {}
+
+ inline _CharT const *begin() const {
+ return _M_begin;
+ }
+ inline _CharT const *end() const {
+ return _M_begin + _M_size;
+ }
+
+ inline _CharT at(std::size_t index) const {
+ return _M_begin [index];
+ }
+
+ inline std::size_t size() const {
+ return _M_size;
+ }
+
+ inline int compare(pp_string const &__other) const {
+ size_type const __size = this->size();
+ size_type const __osize = __other.size();
+ size_type const __len = std::min(__size, __osize);
+
+ int __r = traits_type::compare(_M_begin, __other._M_begin, __len);
+ if (!__r)
+ __r = (int)(__size - __osize);
+
+ return __r;
+ }
+
+ inline bool operator == (pp_string const &__other) const {
+ return compare(__other) == 0;
+ }
+
+ inline bool operator != (pp_string const &__other) const {
+ return compare(__other) != 0;
+ }
+
+ inline bool operator < (pp_string const &__other) const {
+ return compare(__other) < 0;
+ }
+
+ inline bool operator == (char const *s) const {
+ std::size_t n = strlen(s);
+
+ if (n != _M_size)
+ return false;
+
+ return ! strncmp(_M_begin, s, n);
+ }
+
+ inline bool operator != (char const *s) const {
+ return ! operator == (s);
+ }
+};
+
+} // namespace rpp
+
+#endif // PP_STRING_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp-symbol.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp-symbol.h
new file mode 100644
index 000000000..9b06d2643
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp-symbol.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_SYMBOL_H
+#define PP_SYMBOL_H
+
+#include <cassert>
+#include <iterator>
+#include "pp-fwd.h"
+#include "parser/rxx_allocator.h"
+
+namespace rpp
+{
+
+class pp_symbol
+{
+ static rxx_allocator<char> &allocator_instance() {
+ static rxx_allocator<char>__allocator;
+ return __allocator;
+ }
+ static rxx_allocator<pp_fast_string> &ppfs_allocator_instance ()
+ {
+ static rxx_allocator<pp_fast_string>__ppfs_allocator;
+ return __ppfs_allocator;
+ }
+
+public:
+ static int &N() {
+ static int __N;
+ return __N;
+ }
+
+ static pp_fast_string const *get(char const *__data, std::size_t __size) {
+ ++N();
+ char *data = allocator_instance().allocate(__size + 1);
+ memcpy(data, __data, __size);
+ data[__size] = '\0';
+
+ pp_fast_string *where = ppfs_allocator_instance ().allocate (sizeof (pp_fast_string));
+ return new(where) pp_fast_string(data, __size);
+ }
+
+ template <typename _InputIterator>
+ static pp_fast_string const *get(_InputIterator __first, _InputIterator __last) {
+ ++N();
+ std::ptrdiff_t __size;
+#if defined(__SUNPRO_CC)
+ std::distance(__first, __last, __size);
+#else
+ __size = std::distance(__first, __last);
+#endif
+ assert(__size >= 0 && __size < 512);
+
+ char *data = allocator_instance().allocate(__size + 1);
+ std::copy(__first, __last, data);
+ data[__size] = '\0';
+
+ pp_fast_string *where = ppfs_allocator_instance ().allocate (sizeof (pp_fast_string));
+ return new(where) pp_fast_string(data, __size);
+ }
+
+ static pp_fast_string const *get(std::string const &__s) {
+ return get(__s.c_str(), __s.size());
+ }
+};
+
+} // namespace rpp
+
+#endif // PP_SYMBOL_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/pp.h b/sources/shiboken2/ApiExtractor/parser/rpp/pp.h
new file mode 100644
index 000000000..dfeeac432
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/pp.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PP_H
+#define PP_H
+
+#if defined(_WIN64) || defined(WIN64) || defined(__WIN64__) \
+ || defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+# define PP_OS_WIN
+#endif
+
+#include <set>
+#include <map>
+#include <vector>
+#include <string>
+#include <iterator>
+#include <iostream>
+#include <cassert>
+#include <cctype>
+#include <cstdio>
+
+#include <fcntl.h>
+
+#ifdef HAVE_MMAP
+# include <sys/mman.h>
+#endif
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#if (_MSC_VER >= 1400)
+# define FILENO _fileno
+#else
+# define FILENO fileno
+#endif
+
+#if defined (PP_OS_WIN)
+# define PATH_SEPARATOR '\\'
+#else
+# define PATH_SEPARATOR '/'
+#endif
+
+#if defined (RPP_JAMBI)
+# include "parser/rxx_allocator.h"
+#else
+# include "parser/rpp-allocator.h"
+#endif
+
+#if defined (_MSC_VER)
+# define pp_snprintf _snprintf
+#else
+# define pp_snprintf snprintf
+#endif
+
+#include "pp-fwd.h"
+#include "pp-cctype.h"
+#include "pp-string.h"
+#include "pp-symbol.h"
+#include "pp-internal.h"
+#include "pp-iterator.h"
+#include "pp-macro.h"
+#include "pp-environment.h"
+#include "pp-scanner.h"
+#include "pp-macro-expander.h"
+#include "pp-engine.h"
+#include "pp-engine-bits.h"
+
+#endif // PP_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/preprocessor.cpp b/sources/shiboken2/ApiExtractor/parser/rpp/preprocessor.cpp
new file mode 100644
index 000000000..315343321
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/preprocessor.cpp
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2005 Harald Fernengel <harry@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "preprocessor.h"
+
+#include <string>
+#include <cstdio>
+
+// register callback for include hooks
+static void includeFileHook(const std::string &, const std::string &, FILE *);
+
+#define PP_HOOK_ON_FILE_INCLUDED(A, B, C) includeFileHook(A, B, C)
+#include "pp.h"
+
+using namespace rpp;
+
+#include <QtCore/QtCore>
+
+class PreprocessorPrivate
+{
+public:
+ QByteArray result;
+ pp_environment env;
+ QStringList includePaths;
+
+ void initPP(pp &proc) {
+ foreach(QString path, includePaths)
+ proc.push_include_path(path.toStdString());
+ }
+};
+
+QHash<QString, QStringList> includedFiles;
+
+void includeFileHook(const std::string &fileName, const std::string &filePath, FILE *)
+{
+ includedFiles[QString::fromStdString(fileName)].append(QString::fromStdString(filePath));
+}
+
+Preprocessor::Preprocessor()
+{
+ d = new PreprocessorPrivate;
+ includedFiles.clear();
+}
+
+Preprocessor::~Preprocessor()
+{
+ delete d;
+}
+
+void Preprocessor::processFile(const QString &fileName)
+{
+ pp proc(d->env);
+ d->initPP(proc);
+
+ d->result.reserve(d->result.size() + 20 * 1024);
+
+ d->result += "# 1 \"" + fileName.toLatin1() + "\"\n"; // ### REMOVE ME
+ proc.file(fileName.toLocal8Bit().constData(), std::back_inserter(d->result));
+}
+
+void Preprocessor::processString(const QByteArray &str)
+{
+ pp proc(d->env);
+ d->initPP(proc);
+
+ proc(str.begin(), str.end(), std::back_inserter(d->result));
+}
+
+QByteArray Preprocessor::result() const
+{
+ return d->result;
+}
+
+void Preprocessor::addIncludePaths(const QStringList &includePaths)
+{
+ d->includePaths += includePaths;
+}
+
+QStringList Preprocessor::macroNames() const
+{
+ QStringList macros;
+
+ pp_environment::const_iterator it = d->env.first_macro();
+ while (it != d->env.last_macro()) {
+ const pp_macro *m = *it;
+ macros += QString::fromLatin1(m->name->begin(), m->name->size());
+ ++it;
+ }
+
+ return macros;
+}
+
+QList<Preprocessor::MacroItem> Preprocessor::macros() const
+{
+ QList<MacroItem> items;
+
+ pp_environment::const_iterator it = d->env.first_macro();
+ while (it != d->env.last_macro()) {
+ const pp_macro *m = *it;
+ MacroItem item;
+ item.name = QString::fromLatin1(m->name->begin(), m->name->size());
+ item.definition = QString::fromLatin1(m->definition->begin(),
+ m->definition->size());
+ for (size_t i = 0; i < m->formals.size(); ++i) {
+ item.parameters += QString::fromLatin1(m->formals[i]->begin(),
+ m->formals[i]->size());
+ }
+ item.isFunctionLike = m->function_like;
+
+#ifdef PP_WITH_MACRO_POSITION
+ item.fileName = QString::fromLatin1(m->file->begin(), m->file->size());
+#endif
+ items += item;
+
+ ++it;
+ }
+
+ return items;
+}
+
+/*
+int main()
+{
+ Preprocessor pp;
+
+ QStringList paths;
+ paths << "/usr/include";
+ pp.addIncludePaths(paths);
+
+ pp.processFile("pp-configuration");
+ pp.processFile("/usr/include/stdio.h");
+
+ qDebug() << pp.result();
+
+ return 0;
+}
+*/
+
diff --git a/sources/shiboken2/ApiExtractor/parser/rpp/preprocessor.h b/sources/shiboken2/ApiExtractor/parser/rpp/preprocessor.h
new file mode 100644
index 000000000..7d00a5d09
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rpp/preprocessor.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2005 Harald Fernengel <harry@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PREPROCESSOR_H
+#define PREPROCESSOR_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qstringlist.h>
+
+class PreprocessorPrivate;
+
+class Preprocessor
+{
+public:
+ Preprocessor();
+ ~Preprocessor();
+
+ void processFile(const QString &fileName);
+ void processString(const QByteArray &str);
+
+ void addIncludePaths(const QStringList &includePaths);
+
+ QByteArray result() const;
+
+ QStringList macroNames() const;
+
+ struct MacroItem {
+ QString name;
+ QStringList parameters;
+ QString definition;
+ bool isFunctionLike;
+#ifdef PP_WITH_MACRO_POSITION
+ QString fileName;
+#endif
+ };
+ QList<MacroItem> macros() const;
+
+private:
+ Q_DISABLE_COPY(Preprocessor)
+ PreprocessorPrivate *d;
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/parser/rxx_allocator.h b/sources/shiboken2/ApiExtractor/parser/rxx_allocator.h
new file mode 100644
index 000000000..8325edbdf
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/rxx_allocator.h
@@ -0,0 +1,146 @@
+/* This file is part of KDevelop
+ Copyright 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ 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.
+*/
+
+#ifndef RXX_ALLOCATOR_H
+#define RXX_ALLOCATOR_H
+
+#include <cstddef>
+#include <cstdlib>
+#include <string.h>
+#include <memory>
+
+// Stride calculation
+template <typename T>
+struct Tchar {
+ T t;
+ char c;
+};
+
+#define strideof(T) \
+ ((sizeof(Tchar<T>) > sizeof(T)) ? \
+ sizeof(Tchar<T>)-sizeof(T) : sizeof(T))
+
+
+/**The allocator which uses fixed size blocks for allocation of its elements.
+Block size is currently 64k, allocated space is not reclaimed,
+if the size of the element being allocated extends the amount of free
+memory in the block then a new block is allocated.
+
+The allocator supports standard c++ library interface but does not
+make use of allocation hints.
+*/
+template <class _Tp> class rxx_allocator {
+public:
+ typedef _Tp value_type;
+ typedef _Tp* pointer;
+ typedef const _Tp* const_pointer;
+ typedef _Tp& reference;
+ typedef const _Tp& const_reference;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ static const size_type max_block_count = size_type(-1);
+ static const size_type _S_block_size = 1 << 16; // 64K
+
+ rxx_allocator() {
+ init();
+ }
+
+ rxx_allocator(const rxx_allocator &/*__o*/) {
+ init();
+ }
+
+ ~rxx_allocator() {
+ for (size_type index = 0; index < _M_block_index + 1; ++index)
+ delete[] _M_storage[index];
+
+ ::free(_M_storage);
+ }
+
+ pointer address(reference __val) { return &__val; }
+ const_pointer address(const_reference __val) const { return &__val; }
+
+ /**Allocates @p __n elements continuosly in the pool. Warning! no
+ check is done to check if the size of those @p __n elements
+ fit into the block. You should assure you do not allocate more
+ than the size of a block.*/
+ pointer allocate(size_type __n, const void* = 0) {
+ const size_type bytes = __n * sizeof(_Tp);
+
+ if (_M_current_block == 0
+ || _S_block_size < _M_current_index + bytes)
+ {
+ ++_M_block_index;
+
+ _M_storage = reinterpret_cast<char**>
+ (::realloc(_M_storage, sizeof(char*) * (1 + _M_block_index)));
+
+ _M_current_block = _M_storage[_M_block_index] = reinterpret_cast<char*>
+ (new char[_S_block_size]);
+
+ ::memset(_M_current_block, 0, _S_block_size);
+ _M_current_index = 0;
+ }
+
+ pointer p = reinterpret_cast<pointer>
+ (_M_current_block + _M_current_index);
+
+ _M_current_index += bytes;
+
+ return p;
+ }
+
+ pointer allocate(size_type __n, size_type stride, const void* = 0) {
+ if (reinterpret_cast<size_type>(_M_current_block + _M_current_index) % stride > 0)
+ _M_current_index += stride - reinterpret_cast<size_type>(_M_current_block + _M_current_index) % stride;
+ return allocate(__n);
+ }
+
+ /**Deallocate does nothing in this implementation.*/
+ void deallocate(pointer /*__p*/, size_type /*__n*/) {}
+
+ size_type max_size() const { return size_type(-1) / sizeof(_Tp); }
+
+ void construct(pointer __p, const_reference __val) { new (__p) _Tp(__val); }
+ void destroy(pointer __p) { __p->~_Tp(); }
+
+ template <class _Tp1> struct rebind {
+ typedef rxx_allocator<_Tp1> other;
+ };
+
+private:
+
+ void init()
+ {
+ _M_block_index = max_block_count;
+ _M_current_index = 0;
+ _M_storage = 0;
+ _M_current_block = 0;
+ }
+
+ template <class _Tp1> rxx_allocator(const rxx_allocator<_Tp1> &__o) {}
+
+private:
+ size_type _M_block_index;
+ size_type _M_current_index;
+ char *_M_current_block;
+ char **_M_storage;
+};
+
+#endif // RXX_ALLOCATOR_H
+
diff --git a/sources/shiboken2/ApiExtractor/parser/smallobject.cpp b/sources/shiboken2/ApiExtractor/parser/smallobject.cpp
new file mode 100644
index 000000000..9cee247e0
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/smallobject.cpp
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "smallobject.h"
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/smallobject.h b/sources/shiboken2/ApiExtractor/parser/smallobject.h
new file mode 100644
index 000000000..99e4ea44a
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/smallobject.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef SMALLOBJECT_H
+#define SMALLOBJECT_H
+
+#include "rxx_allocator.h"
+#include <cstring>
+
+class pool
+{
+ rxx_allocator<char> __alloc;
+
+public:
+ inline void *allocate(std::size_t __size);
+ inline void *allocate(std::size_t __size, std::size_t __stride);
+};
+
+inline void *pool::allocate(std::size_t __size)
+{
+ return __alloc.allocate(__size);
+}
+
+inline void *pool::allocate(std::size_t __size, std::size_t __stride)
+{
+ return __alloc.allocate(__size, __stride);
+}
+
+#endif
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/symbol.h b/sources/shiboken2/ApiExtractor/parser/symbol.h
new file mode 100644
index 000000000..588653846
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/symbol.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef SYMBOL_H
+#define SYMBOL_H
+
+#include <QtCore/QString>
+#include <cstring>
+
+#include <QtCore/QHash>
+#include <QtCore/QPair>
+
+struct NameSymbol
+{
+ const char *data;
+ std::size_t count;
+
+ inline QString as_string() const
+ {
+ return QString::fromUtf8(data, (int) count);
+ }
+
+ inline bool operator == (const NameSymbol &other) const
+ {
+ return count == other.count
+ && !std::strncmp(data, other.data, count);
+ }
+
+protected:
+ inline NameSymbol() {}
+ inline NameSymbol(const char *d, std::size_t c)
+ : data(d), count(c) {}
+
+private:
+ void operator = (const NameSymbol &);
+
+ friend class NameTable;
+};
+
+inline uint qHash(const NameSymbol &r)
+{
+ uint hash_value = 0;
+
+ for (std::size_t i = 0; i < r.count; ++i)
+ hash_value = (hash_value << 5) - hash_value + r.data[i];
+
+ return hash_value;
+}
+
+inline uint qHash(const QPair<const char*, std::size_t> &r)
+{
+ uint hash_value = 0;
+
+ for (std::size_t i = 0; i < r.second; ++i)
+ hash_value = (hash_value << 5) - hash_value + r.first[i];
+
+ return hash_value;
+}
+
+class NameTable
+{
+public:
+ typedef QPair<const char *, std::size_t> KeyType;
+ typedef QHash<KeyType, NameSymbol*> ContainerType;
+
+public:
+ NameTable() {}
+
+ ~NameTable()
+ {
+ qDeleteAll(_M_storage);
+ }
+
+ inline const NameSymbol *findOrInsert(const char *str, std::size_t len)
+ {
+ KeyType key(str, len);
+
+ NameSymbol *name = _M_storage.value(key);
+ if (!name) {
+ name = new NameSymbol(str, len);
+ _M_storage.insert(key, name);
+ }
+
+ return name;
+ }
+
+ inline std::size_t count() const { return _M_storage.size(); }
+
+private:
+ ContainerType _M_storage;
+
+private:
+ NameTable(const NameTable &other);
+ void operator=(const NameTable &other);
+};
+
+#endif // SYMBOL_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
+
diff --git a/sources/shiboken2/ApiExtractor/parser/tokens.cpp b/sources/shiboken2/ApiExtractor/parser/tokens.cpp
new file mode 100644
index 000000000..eace3c9fa
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/tokens.cpp
@@ -0,0 +1,256 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtCore/qglobal.h>
+
+#include "tokens.h"
+
+static char const * const _S_token_names[] = {
+ "K_DCOP",
+ "Q_OBJECT",
+ "Q_PROPERTY",
+ "__attribute__",
+ "__typeof",
+ "and",
+ "and_eq",
+ "arrow",
+ "asm",
+ "assign",
+ "auto",
+ "bitand",
+ "bitor",
+ "bool",
+ "break",
+ "case",
+ "catch",
+ "char",
+ "char_literal",
+ "class",
+ "comment",
+ "compl",
+ "concat",
+ "const",
+ "const_cast",
+ "continue",
+ "decr",
+ "default",
+ "delete",
+ "do",
+ "double",
+ "dynamic_cast",
+ "ellipsis",
+ "else",
+ "emit",
+ "enum",
+ "eq",
+ "explicit",
+ "export",
+ "extern",
+ "false",
+ "float",
+ "for",
+ "friend",
+ "geq",
+ "goto",
+ "identifier",
+ "if",
+ "incr",
+ "inline",
+ "int",
+ "k_dcop",
+ "k_dcop_signals",
+ "leq",
+ "long",
+ "mutable",
+ "namespace",
+ "new",
+ "noexcept",
+ "not",
+ "not_eq",
+ "number_literal",
+ "operator",
+ "or",
+ "or_eq",
+ "preproc",
+ "private",
+ "protected",
+ "ptrmem",
+ "public",
+ "register",
+ "reinterpret_cast",
+ "return",
+ "scope",
+ "shift",
+ "short",
+ "signals",
+ "signed",
+ "sizeof",
+ "slots",
+ "static",
+ "static_cast",
+ "string_literal",
+ "struct",
+ "switch",
+ "template",
+ "this",
+ "throw",
+ "true",
+ "try",
+ "typedef",
+ "typeid",
+ "typename",
+ "union",
+ "unsigned",
+ "using",
+ "virtual",
+ "void",
+ "volatile",
+ "wchar_t",
+ "while",
+ "whitespaces",
+ "xor",
+ "xor_eq",
+ "Q_ENUMS",
+ "Q_ENUM"
+};
+
+static char _S_printable[][2] = {
+ { char(32), '\0' },
+ { char(33), '\0' },
+ { char(34), '\0' },
+ { char(35), '\0' },
+ { char(36), '\0' },
+ { char(37), '\0' },
+ { char(38), '\0' },
+ { char(39), '\0' },
+ { char(40), '\0' },
+ { char(41), '\0' },
+ { char(42), '\0' },
+ { char(43), '\0' },
+ { char(44), '\0' },
+ { char(45), '\0' },
+ { char(46), '\0' },
+ { char(47), '\0' },
+ { char(48), '\0' },
+ { char(49), '\0' },
+ { char(50), '\0' },
+ { char(51), '\0' },
+ { char(52), '\0' },
+ { char(53), '\0' },
+ { char(54), '\0' },
+ { char(55), '\0' },
+ { char(56), '\0' },
+ { char(57), '\0' },
+ { char(58), '\0' },
+ { char(59), '\0' },
+ { char(60), '\0' },
+ { char(61), '\0' },
+ { char(62), '\0' },
+ { char(63), '\0' },
+ { char(64), '\0' },
+ { char(65), '\0' },
+ { char(66), '\0' },
+ { char(67), '\0' },
+ { char(68), '\0' },
+ { char(69), '\0' },
+ { char(70), '\0' },
+ { char(71), '\0' },
+ { char(72), '\0' },
+ { char(73), '\0' },
+ { char(74), '\0' },
+ { char(75), '\0' },
+ { char(76), '\0' },
+ { char(77), '\0' },
+ { char(78), '\0' },
+ { char(79), '\0' },
+ { char(80), '\0' },
+ { char(81), '\0' },
+ { char(82), '\0' },
+ { char(83), '\0' },
+ { char(84), '\0' },
+ { char(85), '\0' },
+ { char(86), '\0' },
+ { char(87), '\0' },
+ { char(88), '\0' },
+ { char(89), '\0' },
+ { char(90), '\0' },
+ { char(91), '\0' },
+ { char(92), '\0' },
+ { char(93), '\0' },
+ { char(94), '\0' },
+ { char(95), '\0' },
+ { char(96), '\0' },
+ { char(97), '\0' },
+ { char(98), '\0' },
+ { char(99), '\0' },
+ { char(100), '\0' },
+ { char(101), '\0' },
+ { char(102), '\0' },
+ { char(103), '\0' },
+ { char(104), '\0' },
+ { char(105), '\0' },
+ { char(106), '\0' },
+ { char(107), '\0' },
+ { char(108), '\0' },
+ { char(109), '\0' },
+ { char(110), '\0' },
+ { char(111), '\0' },
+ { char(112), '\0' },
+ { char(113), '\0' },
+ { char(114), '\0' },
+ { char(115), '\0' },
+ { char(116), '\0' },
+ { char(117), '\0' },
+ { char(118), '\0' },
+ { char(119), '\0' },
+ { char(120), '\0' },
+ { char(121), '\0' },
+ { char(122), '\0' },
+ { char(123), '\0' },
+ { char(124), '\0' },
+ { char(125), '\0' },
+ { char(126), '\0' },
+ { char(127), '\0' },
+};
+
+char const *token_name(int token)
+{
+ if (token == 0)
+ return "eof";
+ else if (token >= 32 && token <= 127)
+ return _S_printable[token - 32];
+ else if (token >= 1000)
+ return _S_token_names[token - 1000];
+
+ Q_ASSERT(0);
+ return 0;
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/tokens.h b/sources/shiboken2/ApiExtractor/parser/tokens.h
new file mode 100644
index 000000000..46ec96e74
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/tokens.h
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef TOKENS_H
+#define TOKENS_H
+
+enum TOKEN_KIND {
+ Token_EOF = 0,
+
+ Token_K_DCOP = 1000,
+ Token_Q_OBJECT,
+ Token_Q_PROPERTY,
+ Token___attribute__,
+ Token___typeof,
+ Token_and,
+ Token_and_eq,
+ Token_arrow,
+ Token_asm,
+ Token_assign,
+ Token_auto,
+ Token_bitand,
+ Token_bitor,
+ Token_bool,
+ Token_break,
+ Token_case,
+ Token_catch,
+ Token_char,
+ Token_char_literal,
+ Token_class,
+ Token_comment,
+ Token_compl,
+ Token_concat,
+ Token_const,
+ Token_const_cast,
+ Token_continue,
+ Token_decr,
+ Token_default,
+ Token_delete,
+ Token_do,
+ Token_double,
+ Token_dynamic_cast,
+ Token_ellipsis,
+ Token_else,
+ Token_emit,
+ Token_enum,
+ Token_eq,
+ Token_explicit,
+ Token_export,
+ Token_extern,
+ Token_false,
+ Token_float,
+ Token_for,
+ Token_friend,
+ Token_geq,
+ Token_goto,
+ Token_identifier,
+ Token_if,
+ Token_incr,
+ Token_inline,
+ Token_int,
+ Token_k_dcop,
+ Token_k_dcop_signals,
+ Token_leq,
+ Token_long,
+ Token_mutable,
+ Token_namespace,
+ Token_new,
+ Token_noexcept,
+ Token_not,
+ Token_not_eq,
+ Token_number_literal,
+ Token_operator,
+ Token_or,
+ Token_or_eq,
+ Token_preproc,
+ Token_private,
+ Token_protected,
+ Token_ptrmem,
+ Token_public,
+ Token_register,
+ Token_reinterpret_cast,
+ Token_return,
+ Token_scope,
+ Token_shift,
+ Token_short,
+ Token_signals,
+ Token_signed,
+ Token_sizeof,
+ Token_slots,
+ Token_static,
+ Token_static_cast,
+ Token_string_literal,
+ Token_struct,
+ Token_switch,
+ Token_template,
+ Token_this,
+ Token_throw,
+ Token_true,
+ Token_try,
+ Token_typedef,
+ Token_typeid,
+ Token_typename,
+ Token_union,
+ Token_unsigned,
+ Token_using,
+ Token_virtual,
+ Token_void,
+ Token_volatile,
+ Token_wchar_t,
+ Token_while,
+ Token_whitespaces,
+ Token_xor,
+ Token_xor_eq,
+ Token_Q_ENUMS,
+ Token_Q_ENUM,
+ Token_Q_INVOKABLE,
+
+ TOKEN_KIND_COUNT
+};
+
+char const *token_name(int token);
+
+#endif
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/type_compiler.cpp b/sources/shiboken2/ApiExtractor/parser/type_compiler.cpp
new file mode 100644
index 000000000..c08f210fa
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/type_compiler.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+
+#include "type_compiler.h"
+#include "name_compiler.h"
+#include "lexer.h"
+#include "symbol.h"
+#include "tokens.h"
+#include "binder.h"
+
+#include <QtCore/QString>
+
+TypeCompiler::TypeCompiler(Binder *binder)
+ : _M_binder(binder), _M_token_stream(binder->tokenStream())
+{
+}
+
+void TypeCompiler::run(TypeSpecifierAST *node)
+{
+ _M_type.clear();
+ _M_cv.clear();
+
+ visit(node);
+
+ if (node && node->cv) {
+ const ListNode<std::size_t> *it = node->cv->toFront();
+ const ListNode<std::size_t> *end = it;
+ do {
+ int kind = _M_token_stream->kind(it->element);
+ if (!_M_cv.contains(kind))
+ _M_cv.append(kind);
+
+ it = it->next;
+ } while (it != end);
+ }
+}
+
+void TypeCompiler::visitClassSpecifier(ClassSpecifierAST *node)
+{
+ visit(node->name);
+}
+
+void TypeCompiler::visitEnumSpecifier(EnumSpecifierAST *node)
+{
+ visit(node->name);
+}
+
+void TypeCompiler::visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *node)
+{
+ visit(node->name);
+}
+
+void TypeCompiler::visitSimpleTypeSpecifier(SimpleTypeSpecifierAST *node)
+{
+ if (const ListNode<std::size_t> *it = node->integrals) {
+ it = it->toFront();
+ const ListNode<std::size_t> *end = it;
+ QString current_item;
+ do {
+ std::size_t token = it->element;
+ current_item += QLatin1String(token_name(_M_token_stream->kind(token)));
+ current_item += QLatin1Char(' ');
+ it = it->next;
+ } while (it != end);
+ _M_type += current_item.trimmed();
+ } else if (node->type_of) {
+ // ### implement me
+ _M_type += QLatin1String("typeof<...>");
+ }
+
+ visit(node->name);
+}
+
+void TypeCompiler::visitName(NameAST *node)
+{
+ NameCompiler name_cc(_M_binder);
+ name_cc.run(node);
+ _M_type = name_cc.qualifiedName();
+}
+
+QStringList TypeCompiler::cvString() const
+{
+ QStringList lst;
+
+ foreach (int q, cv()) {
+ if (q == Token_const)
+ lst.append(QLatin1String("const"));
+ else if (q == Token_volatile)
+ lst.append(QLatin1String("volatile"));
+ }
+
+ return lst;
+}
+
+bool TypeCompiler::isConstant() const
+{
+ return _M_cv.contains(Token_const);
+}
+
+bool TypeCompiler::isVolatile() const
+{
+ return _M_cv.contains(Token_volatile);
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/type_compiler.h b/sources/shiboken2/ApiExtractor/parser/type_compiler.h
new file mode 100644
index 000000000..6755b30c3
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/type_compiler.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef TYPE_COMPILER_H
+#define TYPE_COMPILER_H
+
+#include "default_visitor.h"
+
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QList>
+
+class TokenStream;
+class Binder;
+
+class TypeCompiler: protected DefaultVisitor
+{
+public:
+ TypeCompiler(Binder *binder);
+
+ inline QStringList qualifiedName() const { return _M_type; }
+ inline QList<int> cv() const { return _M_cv; }
+
+ bool isConstant() const;
+ bool isVolatile() const;
+
+ QStringList cvString() const;
+
+ void run(TypeSpecifierAST *node);
+
+protected:
+ virtual void visitClassSpecifier(ClassSpecifierAST *node);
+ virtual void visitEnumSpecifier(EnumSpecifierAST *node);
+ virtual void visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *node);
+ virtual void visitSimpleTypeSpecifier(SimpleTypeSpecifierAST *node);
+
+ virtual void visitName(NameAST *node);
+
+private:
+ Binder *_M_binder;
+ TokenStream *_M_token_stream;
+ QStringList _M_type;
+ QList<int> _M_cv;
+};
+
+#endif // TYPE_COMPILER_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
+
diff --git a/sources/shiboken2/ApiExtractor/parser/visitor.cpp b/sources/shiboken2/ApiExtractor/parser/visitor.cpp
new file mode 100644
index 000000000..e13e4acb3
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/visitor.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "visitor.h"
+
+Visitor::visitor_fun_ptr Visitor::_S_table[AST::NODE_KIND_COUNT] = {
+ 0,
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitAccessSpecifier),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitAsmDefinition),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitBaseClause),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitBaseSpecifier),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitBinaryExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitCastExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitClassMemberAccess),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitClassSpecifier),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitCompoundStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitCondition),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitConditionalExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitCppCastExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitCtorInitializer),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitDeclarationStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitDeclarator),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitDeleteExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitDoStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitElaboratedTypeSpecifier),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitEnumSpecifier),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitEnumerator),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitExceptionSpecification),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitExpressionOrDeclarationStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitExpressionStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitForStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitFunctionCall),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitFunctionDefinition),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitIfStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitIncrDecrExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitInitDeclarator),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitInitializer),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitInitializerClause),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitLabeledStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitLinkageBody),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitLinkageSpecification),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitMemInitializer),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitName),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitNamespace),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitNamespaceAliasDefinition),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitNewDeclarator),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitNewExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitNewInitializer),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitNewTypeId),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitOperator),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitOperatorFunctionId),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitParameterDeclaration),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitParameterDeclarationClause),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitPostfixExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitPrimaryExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitPtrOperator),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitPtrToMember),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitReturnStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitSimpleDeclaration),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitSimpleTypeSpecifier),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitSizeofExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitStringLiteral),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitSubscriptExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitSwitchStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitTemplateArgument),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitTemplateDeclaration),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitTemplateParameter),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitThrowExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitTranslationUnit),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitTryBlockStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitTypeId),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitTypeIdentification),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitTypeParameter),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitTypedef),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitUnaryExpression),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitUnqualifiedName),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitUsing),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitUsingDirective),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitWhileStatement),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitWinDeclSpec),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitQProperty),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitForwardDeclarationSpecifier),
+ reinterpret_cast<Visitor::visitor_fun_ptr>(&Visitor::visitQEnums)
+};
+
+Visitor::Visitor()
+{
+}
+
+Visitor::~Visitor()
+{
+}
+
+void Visitor::visit(AST *node)
+{
+ if (node)
+ (this->*_S_table[node->kind])(node);
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/parser/visitor.h b/sources/shiboken2/ApiExtractor/parser/visitor.h
new file mode 100644
index 000000000..b1fbf8763
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/parser/visitor.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef VISITOR_H
+#define VISITOR_H
+
+#include "ast.h"
+
+class Visitor
+{
+public:
+ Visitor();
+ virtual ~Visitor();
+
+ virtual void visit(AST *node);
+
+protected:
+ virtual void visitAccessSpecifier(AccessSpecifierAST *) {}
+ virtual void visitAsmDefinition(AsmDefinitionAST *) {}
+ virtual void visitBaseClause(BaseClauseAST *) {}
+ virtual void visitBaseSpecifier(BaseSpecifierAST *) {}
+ virtual void visitBinaryExpression(BinaryExpressionAST *) {}
+ virtual void visitCastExpression(CastExpressionAST *) {}
+ virtual void visitClassMemberAccess(ClassMemberAccessAST *) {}
+ virtual void visitClassSpecifier(ClassSpecifierAST *) {}
+ virtual void visitCompoundStatement(CompoundStatementAST *) {}
+ virtual void visitCondition(ConditionAST *) {}
+ virtual void visitConditionalExpression(ConditionalExpressionAST *) {}
+ virtual void visitCppCastExpression(CppCastExpressionAST *) {}
+ virtual void visitCtorInitializer(CtorInitializerAST *) {}
+ virtual void visitDeclarationStatement(DeclarationStatementAST *) {}
+ virtual void visitDeclarator(DeclaratorAST *) {}
+ virtual void visitDeleteExpression(DeleteExpressionAST *) {}
+ virtual void visitDoStatement(DoStatementAST *) {}
+ virtual void visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *) {}
+ virtual void visitEnumSpecifier(EnumSpecifierAST *) {}
+ virtual void visitEnumerator(EnumeratorAST *) {}
+ virtual void visitExceptionSpecification(ExceptionSpecificationAST *) {}
+ virtual void visitExpressionOrDeclarationStatement(ExpressionOrDeclarationStatementAST *) {}
+ virtual void visitExpressionStatement(ExpressionStatementAST *) {}
+ virtual void visitForStatement(ForStatementAST *) {}
+ virtual void visitFunctionCall(FunctionCallAST *) {}
+ virtual void visitFunctionDefinition(FunctionDefinitionAST *) {}
+ virtual void visitIfStatement(IfStatementAST *) {}
+ virtual void visitIncrDecrExpression(IncrDecrExpressionAST *) {}
+ virtual void visitInitDeclarator(InitDeclaratorAST *) {}
+ virtual void visitInitializer(InitializerAST *) {}
+ virtual void visitInitializerClause(InitializerClauseAST *) {}
+ virtual void visitLabeledStatement(LabeledStatementAST *) {}
+ virtual void visitLinkageBody(LinkageBodyAST *) {}
+ virtual void visitLinkageSpecification(LinkageSpecificationAST *) {}
+ virtual void visitMemInitializer(MemInitializerAST *) {}
+ virtual void visitName(NameAST *) {}
+ virtual void visitNamespace(NamespaceAST *) {}
+ virtual void visitNamespaceAliasDefinition(NamespaceAliasDefinitionAST *) {}
+ virtual void visitNewDeclarator(NewDeclaratorAST *) {}
+ virtual void visitNewExpression(NewExpressionAST *) {}
+ virtual void visitNewInitializer(NewInitializerAST *) {}
+ virtual void visitNewTypeId(NewTypeIdAST *) {}
+ virtual void visitOperator(OperatorAST *) {}
+ virtual void visitOperatorFunctionId(OperatorFunctionIdAST *) {}
+ virtual void visitParameterDeclaration(ParameterDeclarationAST *) {}
+ virtual void visitParameterDeclarationClause(ParameterDeclarationClauseAST *) {}
+ virtual void visitPostfixExpression(PostfixExpressionAST *) {}
+ virtual void visitPrimaryExpression(PrimaryExpressionAST *) {}
+ virtual void visitPtrOperator(PtrOperatorAST *) {}
+ virtual void visitPtrToMember(PtrToMemberAST *) {}
+ virtual void visitReturnStatement(ReturnStatementAST *) {}
+ virtual void visitSimpleDeclaration(SimpleDeclarationAST *) {}
+ virtual void visitSimpleTypeSpecifier(SimpleTypeSpecifierAST *) {}
+ virtual void visitSizeofExpression(SizeofExpressionAST *) {}
+ virtual void visitStringLiteral(StringLiteralAST *) {}
+ virtual void visitSubscriptExpression(SubscriptExpressionAST *) {}
+ virtual void visitSwitchStatement(SwitchStatementAST *) {}
+ virtual void visitTemplateArgument(TemplateArgumentAST *) {}
+ virtual void visitTemplateDeclaration(TemplateDeclarationAST *) {}
+ virtual void visitTemplateParameter(TemplateParameterAST *) {}
+ virtual void visitThrowExpression(ThrowExpressionAST *) {}
+ virtual void visitTranslationUnit(TranslationUnitAST *) {}
+ virtual void visitTryBlockStatement(TryBlockStatementAST *) {}
+ virtual void visitTypeId(TypeIdAST *) {}
+ virtual void visitTypeIdentification(TypeIdentificationAST *) {}
+ virtual void visitTypeParameter(TypeParameterAST *) {}
+ virtual void visitTypedef(TypedefAST *) {}
+ virtual void visitUnaryExpression(UnaryExpressionAST *) {}
+ virtual void visitUnqualifiedName(UnqualifiedNameAST *) {}
+ virtual void visitUsing(UsingAST *) {}
+ virtual void visitUsingDirective(UsingDirectiveAST *) {}
+ virtual void visitWhileStatement(WhileStatementAST *) {}
+ virtual void visitWinDeclSpec(WinDeclSpecAST *) {}
+ virtual void visitQProperty(QPropertyAST *) {}
+ virtual void visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST *) {}
+ virtual void visitQEnums(QEnumsAST *) {}
+
+private:
+ typedef void (Visitor::*visitor_fun_ptr)(AST *);
+ static visitor_fun_ptr _S_table[];
+};
+
+template <class _Tp>
+void visitNodes(Visitor *v, const ListNode<_Tp> *nodes)
+{
+ if (!nodes)
+ return;
+
+ const ListNode<_Tp>
+ *it = nodes->toFront(),
+ *end = it;
+
+ do {
+ v->visit(it->element);
+ it = it->next;
+ } while (it != end);
+}
+
+#endif // VISITOR_H
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/sources/shiboken2/ApiExtractor/qtdocparser.cpp b/sources/shiboken2/ApiExtractor/qtdocparser.cpp
new file mode 100644
index 000000000..f1421ff91
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/qtdocparser.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtdocparser.h"
+#include "abstractmetalang.h"
+#include "reporthandler.h"
+#include "typesystem.h"
+
+#include <QtXmlPatterns/QXmlQuery>
+#include <QtCore/QDir>
+#include <QtCore/QFile>
+#include <QUrl>
+
+Documentation QtDocParser::retrieveModuleDocumentation()
+{
+ return retrieveModuleDocumentation(packageName());
+}
+
+void QtDocParser::fillDocumentation(AbstractMetaClass* metaClass)
+{
+ if (!metaClass)
+ return;
+
+ QString scope = metaClass->name();
+ const AbstractMetaClass* context = metaClass->enclosingClass();
+ while(context) {
+ if (context->enclosingClass() == 0)
+ break;
+ context = context->enclosingClass();
+ }
+
+ QString filename = metaClass->qualifiedCppName().toLower();
+ filename.replace(QLatin1String("::"), QLatin1String("-"));
+ QString sourceFile = documentationDataDirectory() + QLatin1Char('/')
+ + filename + QLatin1String(".xml");
+ if (metaClass->enclosingClass())
+ sourceFile.replace(QLatin1String("::"), QLatin1String("-"));
+
+ if (!QFile::exists(sourceFile)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Can't find qdoc3 file for class " << metaClass->name() << ", tried: "
+ << QDir::toNativeSeparators(sourceFile);
+ return;
+ }
+
+ QXmlQuery xquery;
+ xquery.setFocus(QUrl(sourceFile));
+
+ QString className = metaClass->name();
+
+ // Class/Namespace documentation
+ QString type = metaClass->isNamespace() ? QLatin1String("namespace") : QLatin1String("class");
+ QString query = QLatin1String("/WebXML/document/") + type + QLatin1String("[@name=\"")
+ + className + QLatin1String("\"]/description");
+
+ DocModificationList signedModifs, classModifs;
+ foreach (DocModification docModif, metaClass->typeEntry()->docModifications()) {
+ if (docModif.signature().isEmpty())
+ classModifs.append(docModif);
+ else
+ signedModifs.append(docModif);
+ }
+
+ Documentation doc(getDocumentation(xquery, query, classModifs));
+ metaClass->setDocumentation(doc);
+
+
+ //Functions Documentation
+ AbstractMetaFunctionList funcs = metaClass->functionsInTargetLang();
+ foreach (AbstractMetaFunction *func, funcs) {
+ if (!func || func->isPrivate())
+ continue;
+
+ QString query = QLatin1String("/WebXML/document/") + type
+ + QLatin1String("[@name=\"") + className + QLatin1String("\"]");
+ // properties
+ if (func->isPropertyReader() || func->isPropertyWriter() || func->isPropertyResetter()) {
+ query += QLatin1String("/property[@name=\"") + func->propertySpec()->name()
+ + QLatin1String("\"]");
+ } else { // normal methods
+ QString isConst = func->isConstant() ? QLatin1String("true") : QLatin1String("false");
+ query += QLatin1String("/function[@name=\"") + func->originalName()
+ + QLatin1String("\" and count(parameter)=")
+ + QString::number(func->arguments().count())
+ + QLatin1String(" and @const=\"") + isConst + QLatin1String("\"]");
+
+ int i = 1;
+ foreach (AbstractMetaArgument* arg, func->arguments()) {
+ QString type = arg->type()->name();
+
+ if (arg->type()->isConstant())
+ type.prepend(QLatin1String("const "));
+
+ if (arg->type()->referenceType() == LValueReference) {
+ type += QLatin1String(" &");
+ } else if (arg->type()->referenceType() == RValueReference) {
+ type += QLatin1String(" &&");
+ } else if (arg->type()->indirections()) {
+ type += QLatin1Char(' ');
+ for (int j = 0, max = arg->type()->indirections(); j < max; ++j)
+ type += QLatin1Char('*');
+ }
+ query += QLatin1String("/parameter[") + QString::number(i)
+ + QLatin1String("][@left=\"") + type + QLatin1String("\"]/..");
+ ++i;
+ }
+ }
+ query += QLatin1String("/description");
+ DocModificationList funcModifs;
+ foreach (DocModification funcModif, signedModifs) {
+ if (funcModif.signature() == func->minimalSignature())
+ funcModifs.append(funcModif);
+ }
+ doc.setValue(getDocumentation(xquery, query, funcModifs));
+ func->setDocumentation(doc);
+ }
+#if 0
+ // Fields
+ AbstractMetaFieldList fields = metaClass->fields();
+ foreach (AbstractMetaField *field, fields) {
+ if (field->isPrivate())
+ return;
+
+ QString query = "/doxygen/compounddef/sectiondef/memberdef/name[text()=\"" + field->name() + "\"]/..";
+ Documentation doc = getDocumentation(DocModificationList(), xquery, query);
+ field->setDocumentation(doc);
+ }
+#endif
+ // Enums
+ AbstractMetaEnumList enums = metaClass->enums();
+ foreach (AbstractMetaEnum *meta_enum, enums) {
+ QString query = QLatin1String("/WebXML/document/") + type
+ + QLatin1String("[@name=\"")
+ + className + QLatin1String("\"]/enum[@name=\"")
+ + meta_enum->name() + QLatin1String("\"]/description");
+ doc.setValue(getDocumentation(xquery, query, DocModificationList()));
+ meta_enum->setDocumentation(doc);
+ }
+}
+
+Documentation QtDocParser::retrieveModuleDocumentation(const QString& name)
+{
+ // TODO: This method of acquiring the module name supposes that the target language uses
+ // dots as module separators in package names. Improve this.
+ QString moduleName = name;
+ moduleName.remove(0, name.lastIndexOf(QLatin1Char('.')) + 1);
+ QString sourceFile = documentationDataDirectory() + QLatin1Char('/')
+ + moduleName.toLower() + QLatin1String(".xml");
+
+ if (!QFile::exists(sourceFile)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Can't find qdoc3 file for module " << name << ", tried: "
+ << QDir::toNativeSeparators(sourceFile);
+ return Documentation();
+ }
+
+ QXmlQuery xquery;
+ xquery.setFocus(QUrl(sourceFile));
+
+ // Module documentation
+ QString query = QLatin1String("/WebXML/document/page[@name=\"") + moduleName + QLatin1String("\"]/description");
+ return Documentation(getDocumentation(xquery, query, DocModificationList()));
+}
diff --git a/sources/shiboken2/ApiExtractor/qtdocparser.h b/sources/shiboken2/ApiExtractor/qtdocparser.h
new file mode 100644
index 000000000..04c491853
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/qtdocparser.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTDOCPARSER_H
+#define QTDOCPARSER_H
+
+#include "docparser.h"
+
+class QtDocParser : public DocParser
+{
+public:
+ QtDocParser() {}
+ virtual void fillDocumentation(AbstractMetaClass* metaClass);
+ virtual Documentation retrieveModuleDocumentation();
+ virtual Documentation retrieveModuleDocumentation(const QString& name);
+};
+
+#endif // QTDOCPARSER_H
+
diff --git a/sources/shiboken2/ApiExtractor/reporthandler.cpp b/sources/shiboken2/ApiExtractor/reporthandler.cpp
new file mode 100644
index 000000000..8abea42c6
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/reporthandler.cpp
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "reporthandler.h"
+#include "typesystem.h"
+#include "typedatabase.h"
+#include <QtCore/QSet>
+#include <cstring>
+#include <cstdarg>
+#include <cstdio>
+
+#if _WINDOWS || NOCOLOR
+ #define COLOR_END ""
+ #define COLOR_WHITE ""
+ #define COLOR_YELLOW ""
+ #define COLOR_GREEN ""
+#else
+ #define COLOR_END "\033[0m"
+ #define COLOR_WHITE "\033[1;37m"
+ #define COLOR_YELLOW "\033[1;33m"
+ #define COLOR_GREEN "\033[0;32m"
+#endif
+
+static bool m_silent = false;
+static int m_warningCount = 0;
+static int m_suppressedCount = 0;
+static ReportHandler::DebugLevel m_debugLevel = ReportHandler::NoDebug;
+static QSet<QString> m_reportedWarnings;
+static QString m_progressBuffer;
+static int m_step_size = 0;
+static int m_step = -1;
+static int m_step_warning = 0;
+
+Q_LOGGING_CATEGORY(lcShiboken, "qt.shiboken")
+
+static void printProgress()
+{
+ std::printf("%s", m_progressBuffer.toUtf8().data());
+ std::fflush(stdout);
+ m_progressBuffer.clear();
+}
+
+void ReportHandler::install()
+{
+ qInstallMessageHandler(ReportHandler::messageOutput);
+}
+
+ReportHandler::DebugLevel ReportHandler::debugLevel()
+{
+ return m_debugLevel;
+}
+
+void ReportHandler::setDebugLevel(ReportHandler::DebugLevel level)
+{
+ m_debugLevel = level;
+}
+
+int ReportHandler::suppressedCount()
+{
+ return m_suppressedCount;
+}
+
+int ReportHandler::warningCount()
+{
+ return m_warningCount;
+}
+
+void ReportHandler::setProgressReference(int max)
+{
+ m_step_size = max;
+ m_step = -1;
+}
+
+bool ReportHandler::isSilent()
+{
+ return m_silent;
+}
+
+void ReportHandler::setSilent(bool silent)
+{
+ m_silent = silent;
+}
+
+void ReportHandler::messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &text)
+{
+ if (type == QtWarningMsg) {
+ if (m_silent || m_reportedWarnings.contains(text))
+ return;
+ const TypeDatabase *db = TypeDatabase::instance();
+ if (db && db->isSuppressedWarning(text)) {
+ ++m_suppressedCount;
+ return;
+ }
+ ++m_warningCount;
+ ++m_step_warning;
+ m_reportedWarnings.insert(text);
+ }
+ fprintf(stderr, "%s\n", qPrintable(qFormatLogMessage(type, context, text)));
+}
+
+void ReportHandler::progress(const QString& str, ...)
+{
+ if (m_silent)
+ return;
+
+ if (m_step == -1) {
+ QTextStream buf(&m_progressBuffer);
+ buf.setFieldWidth(45);
+ buf.setFieldAlignment(QTextStream::AlignLeft);
+ buf << str;
+ printProgress();
+ m_step = 0;
+ }
+ m_step++;
+ if (m_step >= m_step_size) {
+ if (m_step_warning == 0) {
+ m_progressBuffer = QLatin1String("[" COLOR_GREEN "OK" COLOR_END "]\n");
+ } else {
+ m_progressBuffer = QLatin1String("[" COLOR_YELLOW "WARNING" COLOR_END "]\n");
+ }
+ printProgress();
+ m_step_warning = 0;
+ }
+}
diff --git a/sources/shiboken2/ApiExtractor/reporthandler.h b/sources/shiboken2/ApiExtractor/reporthandler.h
new file mode 100644
index 000000000..6896d6e86
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/reporthandler.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef REPORTHANDLER_H
+#define REPORTHANDLER_H
+
+#include <QLoggingCategory>
+#include <QString>
+
+Q_DECLARE_LOGGING_CATEGORY(lcShiboken)
+
+class ReportHandler
+{
+public:
+ enum DebugLevel { NoDebug, SparseDebug, MediumDebug, FullDebug };
+
+ static void install();
+
+ static DebugLevel debugLevel();
+ static void setDebugLevel(DebugLevel level);
+
+ static int warningCount();
+
+ static int suppressedCount();
+
+ template <typename T>
+ static void setProgressReference(T collection)
+ {
+ setProgressReference(collection.count());
+ }
+
+ static void setProgressReference(int max);
+
+ static void progress(const QString &str, ...);
+
+ static bool isDebug(DebugLevel level)
+ { return debugLevel() >= level; }
+
+ static bool isSilent();
+ static void setSilent(bool silent);
+
+private:
+ static void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg);
+};
+
+#endif // REPORTHANDLER_H
diff --git a/sources/shiboken2/ApiExtractor/symbols.filter b/sources/shiboken2/ApiExtractor/symbols.filter
new file mode 100644
index 000000000..af6c744dd
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/symbols.filter
@@ -0,0 +1,7 @@
+{
+local:
+_ZSt*;
+_ZNSt*;
+_ZNSs*;
+_ZNKSt*;
+};
diff --git a/sources/shiboken2/ApiExtractor/tests/CMakeLists.txt b/sources/shiboken2/ApiExtractor/tests/CMakeLists.txt
new file mode 100644
index 000000000..5429c1cb8
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/CMakeLists.txt
@@ -0,0 +1,73 @@
+find_package(Qt5Core)
+find_package(Qt5Gui)
+find_package(Qt5Test)
+find_package(Qt5Xml)
+find_package(Qt5XmlPatterns)
+
+macro(declare_test testname)
+ # gone: qt4_automoc("${testname}.cpp")
+ if (EXISTS "${testname}.h")
+ add_executable(${testname} "${testname}.h ${testname}.cpp")
+ else ()
+ add_executable(${testname} "${testname}.cpp")
+ endif ()
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${apiextractor_SOURCE_DIR}
+ ${Qt5Test_INCLUDE_DIRS}
+ )
+ target_link_libraries(${testname}
+ ${Qt5XmlPatterns_LIBRARIES}
+ ${Qt5Test_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ ${Qt5Gui_LIBRARIES}
+ apiextractor)
+ add_test(${testname} ${testname})
+ if (INSTALL_TESTS)
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${testname}
+ DESTINATION share/apiextractor${apiextractor_SUFFIX}/tests)
+ endif()
+endmacro(declare_test testname)
+
+declare_test(testabstractmetaclass)
+declare_test(testabstractmetatype)
+declare_test(testaddfunction)
+declare_test(testarrayargument)
+declare_test(testcodeinjection)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/utf8code.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/utf8code.txt" COPYONLY)
+declare_test(testcontainer)
+declare_test(testconversionoperator)
+declare_test(testconversionruletag)
+declare_test(testctorinformation)
+declare_test(testdroptypeentries)
+declare_test(testdtorinformation)
+declare_test(testenum)
+declare_test(testextrainclude)
+declare_test(testfunctiontag)
+declare_test(testimplicitconversions)
+declare_test(testinserttemplate)
+declare_test(testmodifyfunction)
+declare_test(testmultipleinheritance)
+declare_test(testnamespace)
+declare_test(testnestedtypes)
+declare_test(testnumericaltypedef)
+declare_test(testprimitivetypetag)
+declare_test(testrefcounttag)
+declare_test(testreferencetopointer)
+declare_test(testremovefield)
+declare_test(testremoveimplconv)
+declare_test(testremoveoperatormethod)
+declare_test(testresolvetype)
+declare_test(testreverseoperators)
+declare_test(testtemplates)
+declare_test(testtoposort)
+declare_test(testvaluetypedefaultctortag)
+declare_test(testvoidarg)
+declare_test(testtyperevision)
+if (NOT DISABLE_DOCSTRINGS)
+ declare_test(testmodifydocumentation)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/a.xml"
+ "${CMAKE_CURRENT_BINARY_DIR}/a.xml" COPYONLY)
+endif()
+
diff --git a/sources/shiboken2/ApiExtractor/tests/a.xml b/sources/shiboken2/ApiExtractor/tests/a.xml
new file mode 100644
index 000000000..1c6d62a17
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/a.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" ?>
+
+<WebXML>
+ <document>
+ <class name="A">
+ <description>oi
+ <para>Paragraph number 1</para>
+ <para>Paragraph number 2</para>
+ <para>Paragraph number 3</para>
+ </description>
+ </class>
+ </document>
+</WebXML>
diff --git a/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp b/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp
new file mode 100644
index 000000000..028522159
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp
@@ -0,0 +1,527 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testabstractmetaclass.h"
+#include "abstractmetabuilder.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestAbstractMetaClass::testClassName()
+{
+ const char* cppCode ="class ClassName {};";
+ const char* xmlCode = "<typesystem package=\"Foo\"><value-type name=\"ClassName\"/></typesystem>";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 1);
+ QCOMPARE(classes[0]->name(), QLatin1String("ClassName"));
+}
+
+void TestAbstractMetaClass::testClassNameUnderNamespace()
+{
+ const char* cppCode ="namespace Namespace { class ClassName {}; }\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <namespace-type name=\"Namespace\"/>\n\
+ <value-type name=\"Namespace::ClassName\"/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2); // 1 namespace + 1 class
+ if (classes.first()->name() != QLatin1String("ClassName"))
+ classes.swap(0, 1);
+
+ QCOMPARE(classes[0]->name(), QLatin1String("ClassName"));
+ QCOMPARE(classes[0]->qualifiedCppName(), QLatin1String("Namespace::ClassName"));
+ QCOMPARE(classes[1]->name(), QLatin1String("Namespace"));
+ QVERIFY(classes[1]->isNamespace());
+
+ // Check ctors info
+ QVERIFY(classes[0]->hasConstructors());
+ QCOMPARE(classes[0]->functions().size(), 2); // default ctor + copy ctor
+
+ AbstractMetaFunctionList ctors = classes[0]->queryFunctions(AbstractMetaClass::Constructors);
+ QCOMPARE(ctors.size(), 2);
+ if (ctors.first()->minimalSignature() != QLatin1String("ClassName()"))
+ ctors.swap(0, 1);
+
+ QCOMPARE(ctors[0]->arguments().size(), 0);
+ QCOMPARE(ctors[0]->minimalSignature(), QLatin1String("ClassName()"));
+ QCOMPARE(ctors[1]->arguments().size(), 1);
+ QCOMPARE(ctors[1]->minimalSignature(), QLatin1String("ClassName(Namespace::ClassName)"));
+
+ QVERIFY(!classes[0]->hasPrivateDestructor());
+ QVERIFY(classes[0]->hasCloneOperator()); // implicit default copy ctor
+ QVERIFY(!classes[0]->hasHashFunction());
+
+ // This method is buggy and nobody wants to fix it or needs it fixed :-/
+ // QVERIFY(classes[0]->hasNonPrivateConstructor());
+}
+
+void TestAbstractMetaClass::testVirtualMethods()
+{
+ const char* cppCode ="\
+ class A {\n\
+ public:\n\
+ virtual int pureVirtual() const = 0;\n\
+ };\n\
+ class B : public A {};\n\
+ class C : public B {\n\
+ public:\n\
+ int pureVirtual() const { return 0; }\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <primitive-type name='int'/>\n\
+ <object-type name='A'/>\n\
+ <object-type name='B'/>\n\
+ <object-type name='C'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 3);
+ AbstractMetaClass* a = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ AbstractMetaClass* b = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ AbstractMetaClass* c = AbstractMetaClass::findClass(classes, QLatin1String("C"));
+
+ AbstractMetaClass* no_class = 0;
+
+ QCOMPARE(a->baseClass(), no_class);
+ QCOMPARE(b->baseClass(), a);
+ QCOMPARE(c->baseClass(), b);
+
+ QCOMPARE(a->functions().size(), 2); // default ctor + the pure virtual method
+ QCOMPARE(b->functions().size(), 2);
+ QCOMPARE(c->functions().size(), 2);
+
+ // implementing class, ownclass, declaringclass
+ AbstractMetaFunction* ctorA = a->queryFunctions(AbstractMetaClass::Constructors).first();
+ AbstractMetaFunction* ctorB = b->queryFunctions(AbstractMetaClass::Constructors).first();
+ AbstractMetaFunction* ctorC = c->queryFunctions(AbstractMetaClass::Constructors).first();
+ QVERIFY(ctorA->isConstructor());
+ QVERIFY(!ctorA->isVirtual());
+ QVERIFY(ctorB->isConstructor());
+ QVERIFY(!ctorB->isVirtual());
+ QVERIFY(ctorC->isConstructor());
+ QVERIFY(!ctorC->isVirtual());
+ QCOMPARE(ctorA->implementingClass(), a);
+ QCOMPARE(ctorA->ownerClass(), a);
+ QCOMPARE(ctorA->declaringClass(), a);
+
+ QCOMPARE(a->virtualFunctions().size(), 1); // Add a pureVirtualMethods method !?
+ QCOMPARE(b->virtualFunctions().size(), 1);
+ QCOMPARE(c->virtualFunctions().size(), 1);
+
+ AbstractMetaFunction* funcA = a->virtualFunctions().first();
+ AbstractMetaFunction* funcB = b->virtualFunctions().first();
+ AbstractMetaFunction* funcC = c->virtualFunctions().first();
+
+ QCOMPARE(funcA->ownerClass(), a);
+ QCOMPARE(funcB->ownerClass(), b);
+ QCOMPARE(funcC->ownerClass(), c);
+
+ QCOMPARE(funcA->declaringClass(), a);
+ QCOMPARE(funcB->declaringClass(), a);
+ QCOMPARE(funcC->declaringClass(), a);
+
+ // The next two tests could return null, because it makes more sense.
+ // But we have too many code written relying on this behaviour where
+ // implementingClass is equals to declaringClass on pure virtual functions
+ QCOMPARE(funcA->implementingClass(), a);
+ QCOMPARE(funcB->implementingClass(), a);
+ QCOMPARE(funcC->implementingClass(), c);
+}
+
+void TestAbstractMetaClass::testDefaultValues()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ class B {};\n\
+ void method(B b = B());\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A'/>\n\
+ <value-type name='A::B'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QCOMPARE(classA->queryFunctionsByName(QLatin1String("method")).count(), 1);
+ AbstractMetaFunction* method = classA->queryFunctionsByName(QLatin1String("method")).first();
+ AbstractMetaArgument* arg = method->arguments().first();
+ QCOMPARE(arg->defaultValueExpression(), arg->originalDefaultValueExpression());
+}
+
+void TestAbstractMetaClass::testModifiedDefaultValues()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ class B {};\n\
+ void method(B b = B());\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A'>\n\
+ <modify-function signature='method(A::B)'>\n\
+ <modify-argument index='1'>\n\
+ <replace-default-expression with='Hello'/>\n\
+ </modify-argument>\n\
+ </modify-function>\n\
+ </value-type>\n\
+ <value-type name='A::B'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QCOMPARE(classA->queryFunctionsByName(QLatin1String("method")).count(), 1);
+ AbstractMetaFunction* method = classA->queryFunctionsByName(QLatin1String("method")).first();
+ AbstractMetaArgument* arg = method->arguments().first();
+ QCOMPARE(arg->defaultValueExpression(), QLatin1String("Hello"));
+ QCOMPARE(arg->originalDefaultValueExpression(), QLatin1String("A::B()"));
+}
+
+void TestAbstractMetaClass::testInnerClassOfAPolymorphicOne()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ class B {};\n\
+ virtual void method();\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <object-type name='A'/>\n\
+ <value-type name='A::B'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QVERIFY(classA->isPolymorphic());
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("A::B"));
+ QVERIFY(classB);
+ QVERIFY(!classB->isPolymorphic());
+}
+
+void TestAbstractMetaClass::testForwardDeclaredInnerClass()
+{
+ const char cppCode[] ="\
+ class A {\n\
+ class B;\n\
+ };\n\
+ class A::B {\n\
+ public:\n\
+ void foo();\n\
+ };\n";
+ const char xmlCode[] = "\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A'/>\n\
+ <value-type name='A::B'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("A::B"));
+ QVERIFY(classB);
+ const AbstractMetaFunction *fooF = classB->findFunction(QLatin1String("foo"));
+ QVERIFY(fooF);
+}
+
+void TestAbstractMetaClass::testSpecialFunctions()
+{
+ const char cppCode[] ="\
+ struct A {\n\
+ A();\n\
+ A(const A&);\n\
+ A &operator=(const A&);\n\
+ };\n\
+ struct B {\n\
+ B();\n\
+ B(const B &);\n\
+ B &operator=(B);\n\
+ };\n";
+ const char xmlCode[] = "\
+ <typesystem package=\"Foo\">\n\
+ <object-type name='A'/>\n\
+ <object-type name='B'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ AbstractMetaFunctionList ctors = classA->queryFunctions(AbstractMetaClass::Constructors);
+ QCOMPARE(ctors.size(), 2);
+ QCOMPARE(ctors.first()->functionType(), AbstractMetaFunction::ConstructorFunction);
+ QCOMPARE(ctors.at(1)->functionType(), AbstractMetaFunction::CopyConstructorFunction);
+ AbstractMetaFunctionList assigmentOps = classA->queryFunctionsByName(QLatin1String("operator="));
+ QCOMPARE(assigmentOps.size(), 1);
+ QCOMPARE(assigmentOps.first()->functionType(), AbstractMetaFunction::AssignmentOperatorFunction);
+
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classB);
+ ctors = classB->queryFunctions(AbstractMetaClass::Constructors);
+ QCOMPARE(ctors.size(), 2);
+ QCOMPARE(ctors.first()->functionType(), AbstractMetaFunction::ConstructorFunction);
+ QCOMPARE(ctors.at(1)->functionType(), AbstractMetaFunction::CopyConstructorFunction);
+ assigmentOps = classA->queryFunctionsByName(QLatin1String("operator="));
+ QCOMPARE(assigmentOps.size(), 1);
+ QCOMPARE(assigmentOps.first()->functionType(), AbstractMetaFunction::AssignmentOperatorFunction);
+}
+
+void TestAbstractMetaClass::testClassDefaultConstructors()
+{
+ const char* cppCode ="\
+ struct A {};\n\
+ \n\
+ struct B {\n\
+ B();\n\
+ private: \n\
+ B(const B&);\n\
+ };\n\
+ \n\
+ struct C {\n\
+ C(const C&);\n\
+ };\n\
+ \n\
+ struct D {\n\
+ private: \n\
+ D(const D&);\n\
+ };\n\
+ \n\
+ struct E {\n\
+ private: \n\
+ ~E();\n\
+ };\n\
+ \n\
+ struct F {\n\
+ F(int, int);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <value-type name='A'/>\n\
+ <object-type name='B'/>\n\
+ <value-type name='C'/>\n\
+ <object-type name='D'/>\n\
+ <object-type name='E'/>\n\
+ <value-type name='F'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 6);
+
+ AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->functions().size(), 2);
+
+ AbstractMetaFunctionList ctors = classA->queryFunctions(AbstractMetaClass::Constructors);
+ QCOMPARE(ctors.size(), 2);
+ if (ctors.first()->minimalSignature() != QLatin1String("A()"))
+ ctors.swap(0, 1);
+
+ QCOMPARE(ctors[0]->arguments().size(), 0);
+ QCOMPARE(ctors[0]->minimalSignature(), QLatin1String("A()"));
+ QCOMPARE(ctors[1]->arguments().size(), 1);
+ QCOMPARE(ctors[1]->minimalSignature(), QLatin1String("A(A)"));
+
+ AbstractMetaClass* classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classB);
+ QCOMPARE(classB->functions().size(), 2);
+ QCOMPARE(classB->functions().first()->minimalSignature(), QLatin1String("B()"));
+
+ AbstractMetaClass* classC = AbstractMetaClass::findClass(classes, QLatin1String("C"));
+ QVERIFY(classC);
+ QCOMPARE(classC->functions().size(), 1);
+ QCOMPARE(classC->functions().first()->minimalSignature(), QLatin1String("C(C)"));
+
+ AbstractMetaClass* classD = AbstractMetaClass::findClass(classes, QLatin1String("D"));
+ QVERIFY(classD);
+ QCOMPARE(classD->functions().size(), 1);
+ QCOMPARE(classD->functions().first()->minimalSignature(), QLatin1String("D(D)"));
+ QVERIFY(classD->functions().first()->isPrivate());
+
+ AbstractMetaClass* classE = AbstractMetaClass::findClass(classes, QLatin1String("E"));
+ QVERIFY(classE);
+ QVERIFY(classE->hasPrivateDestructor());
+ QCOMPARE(classE->functions().size(), 0);
+
+ AbstractMetaClass* classF = AbstractMetaClass::findClass(classes, QLatin1String("F"));
+ QVERIFY(classF);
+
+ ctors = classF->queryFunctions(AbstractMetaClass::Constructors);
+ QCOMPARE(ctors.size(), 2);
+ if (ctors.first()->minimalSignature() != QLatin1String("F(int,int)"))
+ ctors.swap(0, 1);
+
+ QCOMPARE(ctors[0]->arguments().size(), 2);
+ QCOMPARE(ctors[0]->minimalSignature(), QLatin1String("F(int,int)"));
+ QCOMPARE(ctors[1]->arguments().size(), 1);
+ QCOMPARE(ctors[1]->minimalSignature(), QLatin1String("F(F)"));
+}
+
+void TestAbstractMetaClass::testClassInheritedDefaultConstructors()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ A();\n\
+ private: \n\
+ A(const A&);\n\
+ };\n\
+ struct B : public A {};\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <object-type name='A'/>\n\
+ <object-type name='B'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+
+ AbstractMetaFunctionList ctors = classA->queryFunctions(AbstractMetaClass::Constructors);
+ QCOMPARE(ctors.size(), 2);
+ if (ctors.first()->minimalSignature() != QLatin1String("A()"))
+ ctors.swap(0, 1);
+
+ QCOMPARE(ctors[0]->arguments().size(), 0);
+ QCOMPARE(ctors[0]->minimalSignature(), QLatin1String("A()"));
+ QCOMPARE(ctors[1]->arguments().size(), 1);
+ QCOMPARE(ctors[1]->minimalSignature(), QLatin1String("A(A)"));
+ QVERIFY(ctors[1]->isPrivate());
+
+ AbstractMetaClass* classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classB);
+
+ ctors = classB->queryFunctions(AbstractMetaClass::Constructors);
+ QCOMPARE(ctors.size(), 1);
+ QCOMPARE(ctors.first()->arguments().size(), 0);
+ QCOMPARE(ctors.first()->minimalSignature(), QLatin1String("B()"));
+}
+
+void TestAbstractMetaClass::testAbstractClassDefaultConstructors()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ virtual void method() = 0;\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <object-type name='A'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 1);
+ AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+
+ AbstractMetaFunctionList ctors = classA->queryFunctions(AbstractMetaClass::Constructors);
+ QCOMPARE(ctors.size(), 1);
+ QCOMPARE(ctors.first()->arguments().size(), 0);
+ QCOMPARE(ctors.first()->minimalSignature(), QLatin1String("A()"));
+}
+
+void TestAbstractMetaClass::testObjectTypesMustNotHaveCopyConstructors()
+{
+ const char* cppCode ="struct A {};\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <object-type name='A'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 1);
+ AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+
+ AbstractMetaFunctionList ctors = classA->queryFunctions(AbstractMetaClass::Constructors);
+ QCOMPARE(ctors.size(), 1);
+ QCOMPARE(ctors.first()->arguments().size(), 0);
+ QCOMPARE(ctors.first()->minimalSignature(), QLatin1String("A()"));
+}
+
+void TestAbstractMetaClass::testIsPolymorphic()
+{
+ const char* cppCode = "\
+ class A\n\
+ {\n\
+ public:\n\
+ A();\n\
+ inline bool abc() const {}\n\
+ };\n\
+ \n\
+ class B : public A\n\
+ {\n\
+ public:\n\
+ B();\n\
+ inline bool abc() const {}\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='bool'/>\n\
+ <value-type name='A'/>\n\
+ <value-type name='B'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ AbstractMetaClass* b = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+
+ QVERIFY(!b->isPolymorphic());
+ AbstractMetaClass* a = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(!a->isPolymorphic());
+}
+
+QTEST_APPLESS_MAIN(TestAbstractMetaClass)
diff --git a/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.h b/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.h
new file mode 100644
index 000000000..811bf5a10
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTABSTRACTMETACLASS_H
+#define TESTABSTRACTMETACLASS_H
+
+#include <QObject>
+
+class AbstractMetaBuilder;
+
+class TestAbstractMetaClass : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testClassName();
+ void testClassNameUnderNamespace();
+ void testVirtualMethods();
+ void testDefaultValues();
+ void testModifiedDefaultValues();
+ void testInnerClassOfAPolymorphicOne();
+ void testForwardDeclaredInnerClass();
+ void testSpecialFunctions();
+ void testClassDefaultConstructors();
+ void testClassInheritedDefaultConstructors();
+ void testAbstractClassDefaultConstructors();
+ void testObjectTypesMustNotHaveCopyConstructors();
+ void testIsPolymorphic();
+};
+
+#endif // TESTABSTRACTMETACLASS_H
diff --git a/sources/shiboken2/ApiExtractor/tests/testabstractmetatype.cpp b/sources/shiboken2/ApiExtractor/tests/testabstractmetatype.cpp
new file mode 100644
index 000000000..1d52c1e41
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testabstractmetatype.cpp
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testabstractmetatype.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestAbstractMetaType::testConstCharPtrType()
+{
+ const char* cppCode ="const char* justAtest();\n";
+ const char* xmlCode = "<typesystem package=\"Foo\">\n\
+ <primitive-type name='char'/>\n\
+ <function signature='justAtest()' />\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ QCOMPARE(builder->globalFunctions().size(), 1);
+ AbstractMetaFunction* func = builder->globalFunctions().first();
+ AbstractMetaType* rtype = func->type();
+ // Test properties of const char*
+ QVERIFY(rtype);
+ QCOMPARE(rtype->package(), QLatin1String("Foo"));
+ QCOMPARE(rtype->name(), QLatin1String("char"));
+ QVERIFY(rtype->isConstant());
+ QVERIFY(!rtype->isArray());
+ QVERIFY(!rtype->isContainer());
+ QVERIFY(!rtype->isObject());
+ QVERIFY(!rtype->isPrimitive()); // const char* differs from char, so it's not considered a primitive type by apiextractor
+ QVERIFY(rtype->isNativePointer());
+ QVERIFY(!rtype->isQObject());
+ QCOMPARE(rtype->referenceType(), NoReference);
+ QVERIFY(!rtype->isValue());
+ QVERIFY(!rtype->isValuePointer());
+}
+
+void TestAbstractMetaType::testApiVersionSupported()
+{
+ const char* cppCode ="class foo {}; class foo2 {};\n\
+ void justAtest(); void justAtest3();\n";
+ const char* xmlCode = "<typesystem package='Foo'>\n\
+ <value-type name='foo' since='0.1'/>\n\
+ <value-type name='foo2' since='1.0'/>\n\
+ <value-type name='foo3' since='1.1'/>\n\
+ <function signature='justAtest()' since='0.1'/>\n\
+ <function signature='justAtest2()' since='1.1'/>\n\
+ <function signature='justAtest3()'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false, "1.0"));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.size(), 2);
+
+
+ AbstractMetaFunctionList functions = builder->globalFunctions();
+ QCOMPARE(functions.size(), 2);
+}
+
+
+void TestAbstractMetaType::testApiVersionNotSupported()
+{
+ const char* cppCode ="class object {};\n";
+ const char* xmlCode = "<typesystem package='Foo'>\n\
+ <value-type name='object' since='0.1'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, true, "0.1"));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.size(), 1);
+}
+
+void TestAbstractMetaType::testCharType()
+{
+ const char* cppCode ="char justAtest(); class A {};\n";
+ const char* xmlCode = "<typesystem package=\"Foo\">\n\
+ <primitive-type name='char'/>\n\
+ <value-type name='A'/>\n\
+ <function signature='justAtest()'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.size(), 1);
+ QCOMPARE(classes.first()->package(), QLatin1String("Foo"));
+
+ AbstractMetaFunctionList functions = builder->globalFunctions();
+ QCOMPARE(functions.size(), 1);
+ AbstractMetaFunction* func = functions.first();
+ AbstractMetaType* rtype = func->type();
+ // Test properties of const char*
+ QVERIFY(rtype);
+ QCOMPARE(rtype->package(), QLatin1String("Foo"));
+ QCOMPARE(rtype->name(), QLatin1String("char"));
+ QVERIFY(!rtype->isConstant());
+ QVERIFY(!rtype->isArray());
+ QVERIFY(!rtype->isContainer());
+ QVERIFY(!rtype->isObject());
+ QVERIFY(rtype->isPrimitive());
+ QVERIFY(!rtype->isNativePointer());
+ QVERIFY(!rtype->isQObject());
+ QCOMPARE(rtype->referenceType(), NoReference);
+ QVERIFY(!rtype->isValue());
+ QVERIFY(!rtype->isValuePointer());
+}
+
+void TestAbstractMetaType::testTypedef()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ void someMethod();\n\
+ };\n\
+ typedef A B;\n\
+ typedef B C;\n";
+ const char* xmlCode = "<typesystem package=\"Foo\">\n\
+ <value-type name='C' />\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.size(), 1);
+ const AbstractMetaClass *c = AbstractMetaClass::findClass(classes, QLatin1String("C"));
+ QVERIFY(c);
+ QVERIFY(c->isTypeDef());
+}
+
+void TestAbstractMetaType::testTypedefWithTemplates()
+{
+ const char* cppCode ="\
+ template<typename T>\n\
+ class A {};\n\
+ \n\
+ class B {};\n\
+ typedef A<B> C;\n\
+ \n\
+ void func(C c);\n";
+ const char* xmlCode = "<typesystem package=\"Foo\">\n\
+ <container-type name='A' type='list'/>\n\
+ <value-type name='B' />\n\
+ <function signature='func(A&lt;B&gt;)'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.size(), 1);
+ AbstractMetaFunctionList functions = builder->globalFunctions();
+ QCOMPARE(functions.count(), 1);
+ AbstractMetaFunction* function = functions.first();
+ AbstractMetaArgumentList args = function->arguments();
+ QCOMPARE(args.count(), 1);
+ AbstractMetaArgument* arg = args.first();
+ AbstractMetaType* metaType = arg->type();
+ QCOMPARE(metaType->cppSignature(), QLatin1String("A<B >"));
+}
+
+
+void TestAbstractMetaType::testObjectTypeUsedAsValue()
+{
+ const char* cppCode ="\
+ class A {\n\
+ void method(A);\n\
+ };\n";
+ const char* xmlCode = "<typesystem package='Foo'>\n\
+ <object-type name='A'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.size(), 1);
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ AbstractMetaFunctionList overloads = classA->queryFunctionsByName(QLatin1String("method"));
+ QCOMPARE(overloads.count(), 1);
+ AbstractMetaFunction* method = overloads.first();
+ QVERIFY(method);
+ AbstractMetaArgumentList args = method->arguments();
+ QCOMPARE(args.count(), 1);
+ AbstractMetaArgument* arg = args.first();
+ AbstractMetaType* metaType = arg->type();
+ QCOMPARE(metaType->cppSignature(), QLatin1String("A"));
+ QVERIFY(metaType->isValue());
+ QVERIFY(metaType->typeEntry()->isObject());
+}
+
+QTEST_APPLESS_MAIN(TestAbstractMetaType)
diff --git a/sources/shiboken2/ApiExtractor/tests/testabstractmetatype.h b/sources/shiboken2/ApiExtractor/tests/testabstractmetatype.h
new file mode 100644
index 000000000..a806d36e3
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testabstractmetatype.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTABSTRACTMETATYPE_H
+#define TESTABSTRACTMETATYPE_H
+
+#include <QObject>
+
+class TestAbstractMetaType : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testConstCharPtrType();
+ void testCharType();
+ void testTypedef();
+ void testTypedefWithTemplates();
+ void testApiVersionSupported();
+ void testApiVersionNotSupported();
+ void testObjectTypeUsedAsValue();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp b/sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp
new file mode 100644
index 000000000..6e1da17ae
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp
@@ -0,0 +1,453 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testaddfunction.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestAddFunction::testParsingFuncNameAndConstness()
+{
+ // generic test...
+ const char sig1[] = "func(type1, const type2, const type3* const)";
+ AddedFunction f1(QLatin1String(sig1), QLatin1String("void"), 0);
+ QCOMPARE(f1.name(), QLatin1String("func"));
+ QCOMPARE(f1.arguments().count(), 3);
+ AddedFunction::TypeInfo retval = f1.returnType();
+ QCOMPARE(retval.name, QLatin1String("void"));
+ QCOMPARE(retval.indirections, 0);
+ QCOMPARE(retval.isConstant, false);
+ QCOMPARE(retval.isReference, false);
+
+ // test with a ugly template as argument and other ugly stuff
+ const char sig2[] = " _fu__nc_ ( type1, const type2, const Abc<int& , C<char*> * > * *, const type3* const ) const ";
+ AddedFunction f2(QLatin1String(sig2), QLatin1String("const Abc<int& , C<char*> * > * *"), 0);
+ QCOMPARE(f2.name(), QLatin1String("_fu__nc_"));
+ QList< AddedFunction::TypeInfo > args = f2.arguments();
+ QCOMPARE(args.count(), 4);
+ retval = f2.returnType();
+ QCOMPARE(retval.name, QLatin1String("Abc<int& , C<char*> * >"));
+ QCOMPARE(retval.indirections, 2);
+ QCOMPARE(retval.isConstant, true);
+ QCOMPARE(retval.isReference, false);
+ retval = args[2];
+ QCOMPARE(retval.name, QLatin1String("Abc<int& , C<char*> * >"));
+ QCOMPARE(retval.indirections, 2);
+ QCOMPARE(retval.isConstant, true);
+ QCOMPARE(retval.isReference, false);
+
+ // function with no args.
+ const char sig3[] = "func()";
+ AddedFunction f3(QLatin1String(sig3), QLatin1String("void"), 0);
+ QCOMPARE(f3.name(), QLatin1String("func"));
+ QCOMPARE(f3.arguments().count(), 0);
+}
+
+void TestAddFunction::testAddFunction()
+{
+ const char cppCode[] = "struct B {}; struct A { void a(int); };\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <primitive-type name='float'/>\n\
+ <value-type name='B'/>\n\
+ <value-type name='A'>\n\
+ <add-function signature='b(int, float = 4.6, const B&amp;)' return-type='int' access='protected'>\n\
+ </add-function>\n\
+ </value-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ TypeDatabase* typeDb = TypeDatabase::instance();
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->functions().count(), 4); // default ctor, default copy ctor, func a() and the added function
+
+ AbstractMetaFunction* addedFunc = classA->functions().last();
+ QCOMPARE(addedFunc->visibility(), AbstractMetaFunction::Protected);
+ QCOMPARE(addedFunc->functionType(), AbstractMetaFunction::NormalFunction);
+ QVERIFY(addedFunc->isUserAdded());
+ QCOMPARE(addedFunc->ownerClass(), classA);
+ QCOMPARE(addedFunc->implementingClass(), classA);
+ QCOMPARE(addedFunc->declaringClass(), classA);
+ QVERIFY(!addedFunc->isVirtual());
+ QVERIFY(!addedFunc->isSignal());
+ QVERIFY(!addedFunc->isSlot());
+ QVERIFY(!addedFunc->isStatic());
+
+ AbstractMetaType* returnType = addedFunc->type();
+ QCOMPARE(returnType->typeEntry(), typeDb->findPrimitiveType(QLatin1String("int")));
+ AbstractMetaArgumentList args = addedFunc->arguments();
+ QCOMPARE(args.count(), 3);
+ QCOMPARE(args[0]->type()->typeEntry(), returnType->typeEntry());
+ QCOMPARE(args[1]->defaultValueExpression(), QLatin1String("4.6"));
+ QCOMPARE(args[2]->type()->typeEntry(), typeDb->findType(QLatin1String("B")));
+}
+
+void TestAddFunction::testAddFunctionConstructor()
+{
+ const char cppCode[] = "struct A { A() {} };\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <value-type name='A'>\n\
+ <add-function signature='A(int)'/>\n\
+ </value-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->functions().count(), 3); // default and added ctors
+ AbstractMetaFunction* addedFunc = classA->functions().last();
+ QCOMPARE(addedFunc->visibility(), AbstractMetaFunction::Public);
+ QCOMPARE(addedFunc->functionType(), AbstractMetaFunction::ConstructorFunction);
+ QCOMPARE(addedFunc->arguments().size(), 1);
+ QVERIFY(addedFunc->isUserAdded());
+ QVERIFY(!addedFunc->type());
+}
+
+void TestAddFunction::testAddFunctionTagDefaultValues()
+{
+ const char cppCode[] = "struct A {};\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <value-type name='A'>\n\
+ <add-function signature='func()'/>\n\
+ </value-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->functions().count(), 3); // default ctor, default copy ctor and the added function
+ AbstractMetaFunction* addedFunc = classA->functions().last();
+ QCOMPARE(addedFunc->visibility(), AbstractMetaFunction::Public);
+ QCOMPARE(addedFunc->functionType(), AbstractMetaFunction::NormalFunction);
+ QVERIFY(addedFunc->isUserAdded());
+ QVERIFY(!addedFunc->type());
+}
+
+void TestAddFunction::testAddFunctionCodeSnippets()
+{
+ const char cppCode[] = "struct A {};\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <value-type name='A'>\n\
+ <add-function signature='func()'>\n\
+ <inject-code class='target' position='end'>Hi!, I am the code.</inject-code>\n\
+ </add-function>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ AbstractMetaFunction* addedFunc = classA->functions().last();
+ QVERIFY(addedFunc->hasInjectedCode());
+}
+
+void TestAddFunction::testAddFunctionWithoutParenteses()
+{
+ const char sig1[] = "func";
+ AddedFunction f1(QLatin1String(sig1), QLatin1String("void"), 0);
+
+ QCOMPARE(f1.name(), QLatin1String("func"));
+ QCOMPARE(f1.arguments().count(), 0);
+ QCOMPARE(f1.isConstant(), false);
+
+ const char cppCode[] = "struct A {};\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <value-type name='A'>\n\
+ <add-function signature='func'>\n\
+ <inject-code class='target' position='end'>Hi!, I am the code.</inject-code>\n\
+ </add-function>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ const AbstractMetaFunction* addedFunc = classA->findFunction(QLatin1String("func"));
+ QVERIFY(addedFunc);
+ QVERIFY(addedFunc->hasInjectedCode());
+ QCOMPARE(addedFunc->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode).count(), 1);
+}
+
+void TestAddFunction::testAddFunctionWithDefaultArgs()
+{
+ const char sig1[] = "func";
+ AddedFunction f1(QLatin1String(sig1), QLatin1String("void"), 0);
+
+ QCOMPARE(f1.name(), QLatin1String("func"));
+ QCOMPARE(f1.arguments().count(), 0);
+ QCOMPARE(f1.isConstant(), false);
+
+ const char cppCode[] = "struct A { };\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <value-type name='A'>\n\
+ <add-function signature='func(int, int)'>\n\
+ <modify-argument index='2'>\n\
+ <replace-default-expression with='2'/>\n\
+ </modify-argument>\n\
+ </add-function>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ const AbstractMetaFunction* addedFunc = classA->findFunction(QLatin1String("func"));
+ QVERIFY(addedFunc);
+ AbstractMetaArgument *arg = addedFunc->arguments()[1];
+ QCOMPARE(arg->defaultValueExpression(), QLatin1String("2"));
+}
+
+void TestAddFunction::testAddFunctionAtModuleLevel()
+{
+ const char cppCode[] = "struct A { };\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <value-type name='A'/>\n\
+ <add-function signature='func(int, int)'>\n\
+ <inject-code class='target' position='beginning'>custom_code();</inject-code>\n\
+ </add-function>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+
+ TypeDatabase* typeDb = TypeDatabase::instance();
+
+ AddedFunctionList addedFuncs = typeDb->findGlobalUserFunctions(QLatin1String("func"));
+
+ QCOMPARE(addedFuncs.size(), 1);
+
+ FunctionModificationList mods = typeDb->functionModifications(QLatin1String("func(int,int)"));
+
+ QCOMPARE(mods.size(), 1);
+ QVERIFY(mods.first().isCodeInjection());
+ CodeSnip snip = mods.first().snips.first();
+ QCOMPARE(snip.code(), QLatin1String("custom_code();"));
+}
+
+void TestAddFunction::testAddFunctionWithVarargs()
+{
+ const char sig1[] = "func(int,char,...)";
+ AddedFunction f1( QLatin1String(sig1), QLatin1String("void"), 0);
+
+ QCOMPARE(f1.name(), QLatin1String("func"));
+ QCOMPARE(f1.arguments().count(), 3);
+ QVERIFY(!f1.isConstant());
+
+ const char cppCode[] = "struct A {};\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <primitive-type name='char'/>\n\
+ <value-type name='A'>\n\
+ <add-function signature='func(int,char,...)'/>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ const AbstractMetaFunction* addedFunc = classA->findFunction(QLatin1String("func"));
+ QVERIFY(addedFunc);
+ const AbstractMetaArgument* arg = addedFunc->arguments().last();
+ QVERIFY(arg->type()->isVarargs());
+ QVERIFY(arg->type()->typeEntry()->isVarargs());
+}
+
+void TestAddFunction::testAddStaticFunction()
+{
+ const char cppCode[] = "struct A { };\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <value-type name='A'>\n\
+ <add-function signature='func(int, int)' static='yes'>\n\
+ <inject-code class='target' position='beginning'>custom_code();</inject-code>\n\
+ </add-function>\n\
+ </value-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ const AbstractMetaFunction* addedFunc = classA->findFunction(QLatin1String("func"));
+ QVERIFY(addedFunc);
+ QVERIFY(addedFunc->isStatic());
+}
+
+void TestAddFunction::testAddGlobalFunction()
+{
+ const char cppCode[] = "struct A { };struct B {};\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <value-type name='A'/>\n\
+ <add-function signature='globalFunc(int, int)' static='yes'>\n\
+ <inject-code class='target' position='beginning'>custom_code();</inject-code>\n\
+ </add-function>\n\
+ <add-function signature='globalFunc2(int, int)' static='yes'>\n\
+ <inject-code class='target' position='beginning'>custom_code();</inject-code>\n\
+ </add-function>\n\
+ <value-type name='B'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaFunctionList globalFuncs = builder->globalFunctions();
+ QCOMPARE(globalFuncs.count(), 2);
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(builder->classes(), QLatin1String("B"));
+ QVERIFY(classB);
+ QVERIFY(!classB->findFunction(QLatin1String("globalFunc")));
+ QVERIFY(!classB->findFunction(QLatin1String("globalFunc2")));
+ QVERIFY(!globalFuncs[0]->injectedCodeSnips().isEmpty());
+ QVERIFY(!globalFuncs[1]->injectedCodeSnips().isEmpty());
+}
+
+void TestAddFunction::testAddFunctionWithApiVersion()
+{
+ const char cppCode[] = "";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <add-function signature='globalFunc(int, int)' static='yes' since='1.3'>\n\
+ <inject-code class='target' position='beginning'>custom_code();</inject-code>\n\
+ </add-function>\n\
+ <add-function signature='globalFunc2(int, int)' static='yes' since='0.1'>\n\
+ <inject-code class='target' position='beginning'>custom_code();</inject-code>\n\
+ </add-function>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, true, "0.1"));
+ QVERIFY(!builder.isNull());
+ AbstractMetaFunctionList globalFuncs = builder->globalFunctions();
+ QCOMPARE(globalFuncs.count(), 1);
+}
+
+void TestAddFunction::testModifyAddedFunction()
+{
+ const char cppCode[] = "class Foo { };\n";
+ const char xmlCode[] = "\
+ <typesystem package='Package'>\n\
+ <primitive-type name='float'/>\n\
+ <primitive-type name='int'/>\n\
+ <value-type name='Foo'>\n\
+ <add-function signature='method(float, int)'>\n\
+ <inject-code class='target' position='beginning'>custom_code();</inject-code>\n\
+ <modify-argument index='2'>\n\
+ <replace-default-expression with='0'/>\n\
+ <rename to='varName'/>\n\
+ </modify-argument>\n\
+ </add-function>\n\
+ </value-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ AbstractMetaClass* foo = AbstractMetaClass::findClass(classes, QLatin1String("Foo"));
+ const AbstractMetaFunction* method = foo->findFunction(QLatin1String("method"));
+ QCOMPARE(method->arguments().size(), 2);
+ AbstractMetaArgument* arg = method->arguments().at(1);
+ QCOMPARE(arg->defaultValueExpression(), QLatin1String("0"));
+ QCOMPARE(arg->name(), QLatin1String("varName"));
+ QCOMPARE(method->argumentName(2), QLatin1String("varName"));
+}
+
+void TestAddFunction::testAddFunctionOnTypedef()
+{
+ const char cppCode[] = "template<class T> class Foo { }; typedef Foo<int> FooInt;\n";
+ const char xmlCode[] = "\
+ <typesystem package='Package'>\n\
+ <custom-type name='PySequence'/>\n\
+ <primitive-type name='int'/>\n\
+ <value-type name='FooInt'>\n\
+ <add-function signature='FooInt(PySequence)'>\n\
+ <inject-code class='target' position='beginning'>custom_code();</inject-code>\n\
+ </add-function>\n\
+ <add-function signature='method()'>\n\
+ <inject-code class='target' position='beginning'>custom_code();</inject-code>\n\
+ </add-function>\n\
+ </value-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ AbstractMetaClass* foo = AbstractMetaClass::findClass(classes, QLatin1String("FooInt"));
+ QVERIFY(foo);
+ QVERIFY(foo->hasNonPrivateConstructor());
+ AbstractMetaFunctionList lst = foo->queryFunctions(AbstractMetaClass::Constructors);
+ foreach(AbstractMetaFunction* f, lst)
+ QVERIFY(f->signature().startsWith(f->name()));
+ QCOMPARE(lst.size(), 2);
+ const AbstractMetaFunction* method = foo->findFunction(QLatin1String("method"));
+ QVERIFY(method);
+}
+
+void TestAddFunction::testAddFunctionWithTemplateArg()
+{
+ const char cppCode[] = "template<class T> class Foo { };\n";
+ const char xmlCode[] = "\
+ <typesystem package='Package'>\n\
+ <primitive-type name='int'/>\n\
+ <container-type name='Foo' type='list'/>\n\
+ <add-function signature='func(Foo&lt;int>)'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ QCOMPARE(builder->globalFunctions().size(), 1);
+ AbstractMetaFunction* func = builder->globalFunctions().first();
+ AbstractMetaArgument* arg = func->arguments().first();
+ QCOMPARE(arg->type()->instantiations().count(), 1);
+}
+
+QTEST_APPLESS_MAIN(TestAddFunction)
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testaddfunction.h b/sources/shiboken2/ApiExtractor/tests/testaddfunction.h
new file mode 100644
index 000000000..16a4ede09
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testaddfunction.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTADDFUNCTION_H
+#define TESTADDFUNCTION_H
+#include <QObject>
+
+class TestAddFunction : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testParsingFuncNameAndConstness();
+ void testAddFunction();
+ void testAddFunctionConstructor();
+ void testAddFunctionTagDefaultValues();
+ void testAddFunctionCodeSnippets();
+ void testAddFunctionWithoutParenteses();
+ void testAddFunctionWithDefaultArgs();
+ void testAddFunctionAtModuleLevel();
+ void testAddFunctionWithVarargs();
+ void testAddStaticFunction();
+ void testAddGlobalFunction();
+ void testAddFunctionWithApiVersion();
+ void testModifyAddedFunction();
+ void testAddFunctionOnTypedef();
+ void testAddFunctionWithTemplateArg();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp
new file mode 100644
index 000000000..5385c9140
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testarrayargument.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestArrayArgument::testArrayArgumentWithSizeDefinedByInteger()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ enum SomeEnum { Value0, Value1, NValues };\n\
+ void method(double[3]);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='double'/>\n\
+ <object-type name='A'>\n\
+ <enum-type name='SomeEnum'/>\n\
+ </object-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), QLatin1String("A"));
+ QVERIFY(classA);
+
+ const AbstractMetaArgument* arg = classA->functions().last()->arguments().first();
+ QVERIFY(arg->type()->isArray());
+ QCOMPARE(arg->type()->arrayElementCount(), 3);
+ QCOMPARE(arg->type()->arrayElementType()->name(), QLatin1String("double"));
+}
+
+void TestArrayArgument::testArrayArgumentWithSizeDefinedByEnumValue()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ enum SomeEnum { Value0, Value1, NValues };\n\
+ void method(double[NValues]);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='double'/>\n\
+ <object-type name='A'>\n\
+ <enum-type name='SomeEnum'/>\n\
+ </object-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), QLatin1String("A"));
+ QVERIFY(classA);
+
+ AbstractMetaEnum* someEnum = classA->findEnum(QLatin1String("SomeEnum"));
+ QVERIFY(someEnum);
+ AbstractMetaEnumValue* nvalues = classA->findEnumValue(QLatin1String("NValues"), someEnum);
+ QVERIFY(nvalues);
+
+ const AbstractMetaArgument* arg = classA->functions().last()->arguments().first();
+ QVERIFY(arg->type()->isArray());
+ QCOMPARE(arg->type()->arrayElementCount(), nvalues->value());
+ QCOMPARE(arg->type()->arrayElementType()->name(), QLatin1String("double"));
+};
+
+void TestArrayArgument::testArrayArgumentWithSizeDefinedByEnumValueFromGlobalEnum()
+{
+ const char* cppCode ="\
+ enum SomeEnum { Value0, Value1, NValues };\n\
+ struct A {\n\
+ void method(double[NValues]);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='double'/>\n\
+ <enum-type name='SomeEnum'/>\n\
+ <object-type name='A'>\n\
+ </object-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), QLatin1String("A"));
+ QVERIFY(classA);
+
+ AbstractMetaEnum* someEnum = builder->globalEnums().first();
+ QVERIFY(someEnum);
+ AbstractMetaEnumValue* nvalues = 0;
+ foreach (AbstractMetaEnumValue* enumValue, someEnum->values()) {
+ if (enumValue->name() == QLatin1String("NValues")) {
+ nvalues = enumValue;
+ break;
+ }
+ }
+ QVERIFY(nvalues);
+
+ const AbstractMetaArgument* arg = classA->functions().last()->arguments().first();
+ QVERIFY(arg->type()->isArray());
+ QCOMPARE(arg->type()->arrayElementCount(), nvalues->value());
+ QCOMPARE(arg->type()->arrayElementType()->name(), QLatin1String("double"));
+};
+
+QTEST_APPLESS_MAIN(TestArrayArgument)
diff --git a/sources/shiboken2/ApiExtractor/tests/testarrayargument.h b/sources/shiboken2/ApiExtractor/tests/testarrayargument.h
new file mode 100644
index 000000000..b50232ef4
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testarrayargument.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTARRAYARGUMENT_H
+#define TESTARRAYARGUMENT_H
+#include <QObject>
+
+class TestArrayArgument : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testArrayArgumentWithSizeDefinedByInteger();
+ void testArrayArgumentWithSizeDefinedByEnumValue();
+ void testArrayArgumentWithSizeDefinedByEnumValueFromGlobalEnum();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testcodeinjection.cpp b/sources/shiboken2/ApiExtractor/tests/testcodeinjection.cpp
new file mode 100644
index 000000000..ad245633e
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testcodeinjection.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testcodeinjection.h"
+#include <QFileInfo>
+#include <QDir>
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestCodeInjections::testReadFileUtf8()
+{
+ const char* cppCode ="struct A {};\n";
+ int argc = 0;
+ char *argv[] = {NULL};
+ QCoreApplication app(argc, argv);
+ QString filePath = QDir::currentPath();
+ QString xmlCode = QLatin1String("\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A'>\n\
+ <conversion-rule file='") + filePath + QLatin1String("/utf8code.txt'/>\n\
+ <inject-code class='target' file='") + filePath
+ + QLatin1String("/utf8code.txt'/>\n\
+ </value-type>\n\
+ <value-type name='A::B'/>\n\
+ </typesystem>\n");
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode.toLocal8Bit().constData()));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QCOMPARE(classA->typeEntry()->codeSnips().count(), 1);
+ QString code = classA->typeEntry()->codeSnips().first().code();
+ QString utf8Data = QString::fromUtf8("\xC3\xA1\xC3\xA9\xC3\xAD\xC3\xB3\xC3\xBA");
+ QVERIFY(code.indexOf(utf8Data) != -1);
+ code = classA->typeEntry()->conversionRule();
+ QVERIFY(code.indexOf(utf8Data) != -1);
+}
+
+void TestCodeInjections::testInjectWithValidApiVersion()
+{
+ const char* cppCode ="struct A {};\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <value-type name='A'>\n\
+ <inject-code class='target' since='1.0'>\n\
+ test Inject code\n\
+ </inject-code>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, true, "1.0"));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QCOMPARE(classA->typeEntry()->codeSnips().count(), 1);
+}
+
+void TestCodeInjections::testInjectWithInvalidApiVersion()
+{
+ const char* cppCode ="struct A {};\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A'>\n\
+ <inject-code class='target' since='1.0'>\n\
+ test Inject code\n\
+ </inject-code>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, true, "0.1"));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QCOMPARE(classA->typeEntry()->codeSnips().count(), 0);
+}
+
+
+
+QTEST_APPLESS_MAIN(TestCodeInjections)
diff --git a/sources/shiboken2/ApiExtractor/tests/testcodeinjection.h b/sources/shiboken2/ApiExtractor/tests/testcodeinjection.h
new file mode 100644
index 000000000..56c1c7cba
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testcodeinjection.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTCODEINJECTIONS_H
+#define TESTCODEINJECTIONS_H
+
+#include <QObject>
+
+class AbstractMetaBuilder;
+
+class TestCodeInjections : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testReadFileUtf8();
+ void testInjectWithValidApiVersion();
+ void testInjectWithInvalidApiVersion();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testcontainer.cpp b/sources/shiboken2/ApiExtractor/tests/testcontainer.cpp
new file mode 100644
index 000000000..1c79a5a7a
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testcontainer.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testcontainer.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestContainer::testContainerType()
+{
+ const char* cppCode ="\
+ namespace std {\n\
+ template<class T>\n\
+ class list {\n\
+ T get(int x) { return 0; }\n\
+ };\n\
+ }\n\
+ class A : public std::list<int> {\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <namespace-type name='std' generate='no' />\n\
+ <container-type name='std::list' type='list' />\n\
+ <object-type name='A'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, true));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ //search for class A
+ AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QVERIFY(classA->typeEntry()->baseContainerType());
+ QCOMPARE(reinterpret_cast<const ContainerTypeEntry*>(classA->typeEntry()->baseContainerType())->type(), ContainerTypeEntry::ListContainer);
+}
+
+void TestContainer::testListOfValueType()
+{
+ const char* cppCode ="\
+ namespace std {\n\
+ template<class T>\n\
+ class list {\n\
+ T get(int x) { return 0; }\n\
+ };\n\
+ }\n\
+ class ValueType {};\n\
+ class A : public std::list<ValueType> {\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <namespace-type name='std' generate='no'/>\n\
+ <container-type name='std::list' type='list'/>\n\
+ <value-type name='ValueType'/>\n\
+ <value-type name='A'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, true));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 3);
+
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->templateBaseClassInstantiations().count(), 1);
+ const AbstractMetaType* templateInstanceType = classA->templateBaseClassInstantiations().first();
+ QVERIFY(templateInstanceType);
+
+ QCOMPARE(templateInstanceType->indirections(), 0);
+ QVERIFY(!templateInstanceType->typeEntry()->isObject());
+ QVERIFY(templateInstanceType->typeEntry()->isValue());
+ QCOMPARE(templateInstanceType->referenceType(), NoReference);
+ QVERIFY(!templateInstanceType->isObject());
+ QVERIFY(!templateInstanceType->isValuePointer());
+ QVERIFY(templateInstanceType->isValue());
+}
+
+QTEST_APPLESS_MAIN(TestContainer)
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testcontainer.h b/sources/shiboken2/ApiExtractor/tests/testcontainer.h
new file mode 100644
index 000000000..f154ea212
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testcontainer.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTCONTAINER_H
+#define TESTCONTAINER_H
+#include <QObject>
+
+class TestContainer : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testContainerType();
+ void testListOfValueType();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testconversionoperator.cpp b/sources/shiboken2/ApiExtractor/tests/testconversionoperator.cpp
new file mode 100644
index 000000000..cae4a3a62
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testconversionoperator.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testconversionoperator.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestConversionOperator::testConversionOperator()
+{
+ const char cppCode[] = "\
+ struct A {\n\
+ };\n\
+ struct B {\n\
+ operator A() const;\n\
+ };\n\
+ struct C {\n\
+ operator A() const;\n\
+ };\n";
+ const char xmlCode[] = "\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A'/>\n\
+ <value-type name='B'/>\n\
+ <value-type name='C'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ const AbstractMetaClass *classC = AbstractMetaClass::findClass(classes, QLatin1String("C"));
+ QVERIFY(classA);
+ QVERIFY(classB);
+ QVERIFY(classC);
+ QCOMPARE(classA->functions().count(), 2);
+ QCOMPARE(classB->functions().count(), 3);
+ QCOMPARE(classC->functions().count(), 3);
+ QCOMPARE(classA->externalConversionOperators().count(), 2);
+
+ AbstractMetaFunction* convOp = 0;
+ foreach(AbstractMetaFunction* func, classB->functions()) {
+ if (func->isConversionOperator()) {
+ convOp = func;
+ break;
+ }
+ }
+ QVERIFY(convOp);
+ QVERIFY(classA->externalConversionOperators().contains(convOp));
+}
+
+void TestConversionOperator::testConversionOperatorOfDiscardedClass()
+{
+ const char cppCode[] = "\
+ struct A {\n\
+ };\n\
+ struct B {\n\
+ operator A() const;\n\
+ };\n";
+ const char xmlCode[] = "\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A' />\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->externalConversionOperators().count(), 0);
+}
+
+void TestConversionOperator::testRemovedConversionOperator()
+{
+ const char cppCode[] = "\
+ struct A {\n\
+ };\n\
+ struct B {\n\
+ operator A() const;\n\
+ };\n";
+ const char xmlCode[] = "\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A' />\n\
+ <value-type name='B'>\n\
+ <modify-function signature='operator A() const' remove='all'/>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classA);
+ QVERIFY(classB);
+ QCOMPARE(classA->functions().count(), 2);
+ QCOMPARE(classB->functions().count(), 3);
+ QCOMPARE(classA->externalConversionOperators().count(), 0);
+ QCOMPARE(classA->implicitConversions().count(), 0);
+}
+
+void TestConversionOperator::testConversionOperatorReturningReference()
+{
+ const char cppCode[] = "\
+ struct A {};\n\
+ struct B {\n\
+ operator A&() const;\n\
+ };\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <value-type name='A'/>\n\
+ <value-type name='B'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classA);
+ QVERIFY(classB);
+ QCOMPARE(classA->functions().count(), 2);
+ QCOMPARE(classB->functions().count(), 3);
+ QCOMPARE(classA->externalConversionOperators().count(), 1);
+ QCOMPARE(classA->externalConversionOperators().first()->type()->cppSignature(), QLatin1String("A"));
+ QCOMPARE(classA->externalConversionOperators().first()->ownerClass()->name(), QLatin1String("B"));
+ QCOMPARE(classA->implicitConversions().count(), 1);
+ QCOMPARE(classA->implicitConversions().first()->type()->cppSignature(), QLatin1String("A"));
+ QCOMPARE(classA->implicitConversions().first()->ownerClass()->name(), QLatin1String("B"));
+}
+
+void TestConversionOperator::testConversionOperatorReturningConstReference()
+{
+ const char cppCode[] = "\
+ struct A {};\n\
+ struct B {\n\
+ operator const A&() const;\n\
+ };\n";
+ const char xmlCode[] = "\
+ <typesystem package='Foo'>\n\
+ <value-type name='A'/>\n\
+ <value-type name='B'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classA);
+ QVERIFY(classB);
+ QCOMPARE(classA->functions().count(), 2);
+ QCOMPARE(classB->functions().count(), 3);
+ QCOMPARE(classA->externalConversionOperators().count(), 1);
+ QCOMPARE(classA->externalConversionOperators().first()->type()->cppSignature(), QLatin1String("A"));
+ QCOMPARE(classA->externalConversionOperators().first()->ownerClass()->name(), QLatin1String("B"));
+ QCOMPARE(classA->implicitConversions().count(), 1);
+ QCOMPARE(classA->implicitConversions().first()->type()->cppSignature(), QLatin1String("A"));
+ QCOMPARE(classA->implicitConversions().first()->ownerClass()->name(), QLatin1String("B"));
+}
+
+QTEST_APPLESS_MAIN(TestConversionOperator)
diff --git a/sources/shiboken2/ApiExtractor/tests/testconversionoperator.h b/sources/shiboken2/ApiExtractor/tests/testconversionoperator.h
new file mode 100644
index 000000000..f28747ab5
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testconversionoperator.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTCONVERSIONOPERATOR_H
+#define TESTCONVERSIONOPERATOR_H
+#include <QObject>
+
+class TestConversionOperator : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testConversionOperator();
+ void testConversionOperatorOfDiscardedClass();
+ void testRemovedConversionOperator();
+ void testConversionOperatorReturningReference();
+ void testConversionOperatorReturningConstReference();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testconversionruletag.cpp b/sources/shiboken2/ApiExtractor/tests/testconversionruletag.cpp
new file mode 100644
index 000000000..fb9290795
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testconversionruletag.cpp
@@ -0,0 +1,250 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testconversionruletag.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+#include <QFile>
+#include <QTemporaryFile>
+
+void TestConversionRuleTag::testConversionRuleTagWithFile()
+{
+ // temp file used later
+ const char conversionData[] = "Hi! I'm a conversion rule.";
+ QTemporaryFile file;
+ file.open();
+ QCOMPARE(file.write(conversionData), qint64(sizeof(conversionData)-1));
+ file.close();
+
+ const char cppCode[] = "struct A {};\n";
+ QString xmlCode = QLatin1String("\
+ <typesystem package='Foo'>\n\
+ <value-type name='A'>\n\
+ <conversion-rule file='") + file.fileName() + QLatin1String("'/>\n\
+ </value-type>\n\
+ </typesystem>\n");
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode.toLocal8Bit().data()));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ const ComplexTypeEntry* typeEntry = classA->typeEntry();
+ QVERIFY(typeEntry->hasConversionRule());
+ QCOMPARE(typeEntry->conversionRule(), QLatin1String(conversionData));
+}
+
+void TestConversionRuleTag::testConversionRuleTagReplace()
+{
+ const char cppCode[] = "\
+ struct A {\n\
+ A();\n\
+ A(const char*, int);\n\
+ };\n\
+ struct B {\n\
+ A createA();\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <primitive-type name='char'/>\n\
+ <primitive-type name='A'>\n\
+ <conversion-rule>\n\
+ <native-to-target>\n\
+ DoThis();\n\
+ return ConvertFromCppToPython(%IN);\n\
+ </native-to-target>\n\
+ <target-to-native>\n\
+ <add-conversion type='TargetNone' check='%IN == Target_None'>\n\
+ DoThat();\n\
+ DoSomething();\n\
+ %OUT = A();\n\
+ </add-conversion>\n\
+ <add-conversion type='B' check='CheckIfInputObjectIsB(%IN)'>\n\
+ %OUT = %IN.createA();\n\
+ </add-conversion>\n\
+ <add-conversion type='String' check='String_Check(%IN)'>\n\
+ %OUT = new A(String_AsString(%IN), String_GetSize(%IN));\n\
+ </add-conversion>\n\
+ </target-to-native>\n\
+ </conversion-rule>\n\
+ </primitive-type>\n\
+ <value-type name='B'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ TypeDatabase* typeDb = TypeDatabase::instance();
+ PrimitiveTypeEntry* typeA = typeDb->findPrimitiveType(QLatin1String("A"));
+ QVERIFY(typeA);
+
+ CustomConversion* conversion = typeA->customConversion();
+ QVERIFY(conversion);
+
+ QCOMPARE(typeA, conversion->ownerType());
+ QCOMPARE(conversion->nativeToTargetConversion().simplified(),
+ QLatin1String("DoThis(); return ConvertFromCppToPython(%IN);"));
+
+ QVERIFY(conversion->replaceOriginalTargetToNativeConversions());
+ QVERIFY(conversion->hasTargetToNativeConversions());
+ QCOMPARE(conversion->targetToNativeConversions().size(), 3);
+
+ CustomConversion::TargetToNativeConversion* toNative = conversion->targetToNativeConversions().at(0);
+ QVERIFY(toNative);
+ QCOMPARE(toNative->sourceTypeName(), QLatin1String("TargetNone"));
+ QVERIFY(toNative->isCustomType());
+ QCOMPARE(toNative->sourceType(), (const TypeEntry*)0);
+ QCOMPARE(toNative->sourceTypeCheck(), QLatin1String("%IN == Target_None"));
+ QCOMPARE(toNative->conversion().simplified(),
+ QLatin1String("DoThat(); DoSomething(); %OUT = A();"));
+
+ toNative = conversion->targetToNativeConversions().at(1);
+ QVERIFY(toNative);
+ QCOMPARE(toNative->sourceTypeName(), QLatin1String("B"));
+ QVERIFY(!toNative->isCustomType());
+ TypeEntry* typeB = typeDb->findType(QLatin1String("B"));
+ QVERIFY(typeB);
+ QCOMPARE(toNative->sourceType(), typeB);
+ QCOMPARE(toNative->sourceTypeCheck(), QLatin1String("CheckIfInputObjectIsB(%IN)"));
+ QCOMPARE(toNative->conversion().trimmed(), QLatin1String("%OUT = %IN.createA();"));
+
+ toNative = conversion->targetToNativeConversions().at(2);
+ QVERIFY(toNative);
+ QCOMPARE(toNative->sourceTypeName(), QLatin1String("String"));
+ QVERIFY(toNative->isCustomType());
+ QCOMPARE(toNative->sourceType(), (const TypeEntry*)0);
+ QCOMPARE(toNative->sourceTypeCheck(), QLatin1String("String_Check(%IN)"));
+ QCOMPARE(toNative->conversion().trimmed(), QLatin1String("%OUT = new A(String_AsString(%IN), String_GetSize(%IN));"));
+}
+
+void TestConversionRuleTag::testConversionRuleTagAdd()
+{
+ const char cppCode[] = "\
+ struct Date {\n\
+ Date();\n\
+ Date(int, int, int);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <value-type name='Date'>\n\
+ <conversion-rule>\n\
+ <target-to-native replace='no'>\n\
+ <add-conversion type='TargetDate' check='TargetDate_Check(%IN)'>\n\
+if (!TargetDateTimeAPI) TargetDateTime_IMPORT;\n\
+%OUT = new Date(TargetDate_Day(%IN), TargetDate_Month(%IN), TargetDate_Year(%IN));\n\
+ </add-conversion>\n\
+ </target-to-native>\n\
+ </conversion-rule>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), QLatin1String("Date"));
+ QVERIFY(classA);
+
+ CustomConversion* conversion = classA->typeEntry()->customConversion();
+ QVERIFY(conversion);
+
+ QCOMPARE(conversion->nativeToTargetConversion(), QString());
+
+ QVERIFY(!conversion->replaceOriginalTargetToNativeConversions());
+ QVERIFY(conversion->hasTargetToNativeConversions());
+ QCOMPARE(conversion->targetToNativeConversions().size(), 1);
+
+ CustomConversion::TargetToNativeConversion* toNative = conversion->targetToNativeConversions().first();
+ QVERIFY(toNative);
+ QCOMPARE(toNative->sourceTypeName(), QLatin1String("TargetDate"));
+ QVERIFY(toNative->isCustomType());
+ QCOMPARE(toNative->sourceType(), (const TypeEntry*)0);
+ QCOMPARE(toNative->sourceTypeCheck(), QLatin1String("TargetDate_Check(%IN)"));
+ QCOMPARE(toNative->conversion().trimmed(),
+ QLatin1String("if (!TargetDateTimeAPI) TargetDateTime_IMPORT;\n%OUT = new Date(TargetDate_Day(%IN), TargetDate_Month(%IN), TargetDate_Year(%IN));"));
+}
+
+void TestConversionRuleTag::testConversionRuleTagWithInsertTemplate()
+{
+ const char cppCode[] = "struct A {};";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <!-- single line -->\n\
+ <template name='native_to_target'>return ConvertFromCppToPython(%IN);</template>\n\
+ <!-- multi-line -->\n\
+ <template name='target_to_native'>\n\
+%OUT = %IN.createA();\n\
+ </template>\n\
+ <primitive-type name='A'>\n\
+ <conversion-rule>\n\
+ <native-to-target>\n\
+ <insert-template name='native_to_target'/>\n\
+ </native-to-target>\n\
+ <target-to-native>\n\
+ <add-conversion type='TargetType'>\n\
+ <insert-template name='target_to_native'/>\n\
+ </add-conversion>\n\
+ </target-to-native>\n\
+ </conversion-rule>\n\
+ </primitive-type>\n\
+ </typesystem>\n";
+
+ const char nativeToTargetExpected[] =
+ "// TEMPLATE - native_to_target - START\n"
+ "return ConvertFromCppToPython(%IN);\n"
+ "// TEMPLATE - native_to_target - END";
+
+ const char targetToNativeExpected[] =
+ "// TEMPLATE - target_to_native - START\n"
+ "%OUT = %IN.createA();\n"
+ "// TEMPLATE - target_to_native - END";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ TypeDatabase* typeDb = TypeDatabase::instance();
+ PrimitiveTypeEntry* typeA = typeDb->findPrimitiveType(QLatin1String("A"));
+ QVERIFY(typeA);
+
+ CustomConversion* conversion = typeA->customConversion();
+ QVERIFY(conversion);
+
+ QCOMPARE(typeA, conversion->ownerType());
+ QCOMPARE(conversion->nativeToTargetConversion().trimmed(),
+ QLatin1String(nativeToTargetExpected));
+
+ QVERIFY(conversion->hasTargetToNativeConversions());
+ QCOMPARE(conversion->targetToNativeConversions().size(), 1);
+
+ CustomConversion::TargetToNativeConversion* toNative = conversion->targetToNativeConversions().first();
+ QVERIFY(toNative);
+ QCOMPARE(toNative->conversion().trimmed(),
+ QLatin1String(targetToNativeExpected));
+}
+
+QTEST_APPLESS_MAIN(TestConversionRuleTag)
diff --git a/sources/shiboken2/ApiExtractor/tests/testconversionruletag.h b/sources/shiboken2/ApiExtractor/tests/testconversionruletag.h
new file mode 100644
index 000000000..c02a9708b
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testconversionruletag.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTCONVERSIONRULE_H
+#define TESTCONVERSIONRULE_H
+#include <QObject>
+
+class TestConversionRuleTag : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testConversionRuleTagWithFile();
+ void testConversionRuleTagReplace();
+ void testConversionRuleTagAdd();
+ void testConversionRuleTagWithInsertTemplate();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testctorinformation.cpp b/sources/shiboken2/ApiExtractor/tests/testctorinformation.cpp
new file mode 100644
index 000000000..a4b4c2388
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testctorinformation.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testctorinformation.h"
+#include "abstractmetabuilder.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestCtorInformation::testCtorIsPrivate()
+{
+ const char* cppCode = "class Control { public: Control() {} };\n\
+ class Subject { private: Subject() {} };\n\
+ class CtorLess { };\n";
+ const char* xmlCode = "<typesystem package='Foo'>\n\
+ <value-type name='Control'/>\n\
+ <object-type name='Subject'/>\n\
+ <value-type name='CtorLess'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 3);
+ QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("Control"))->hasNonPrivateConstructor(), true);
+ QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("Subject"))->hasNonPrivateConstructor(), false);
+ QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("CtorLess"))->hasNonPrivateConstructor(), true);
+}
+
+void TestCtorInformation::testHasNonPrivateCtor()
+{
+ const char* cppCode = "template<typename T>\n\
+ struct Base { Base(double) {} };\n\
+ typedef Base<int> Derived;\n";
+ const char* xmlCode = "<typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <primitive-type name='double'/>\n\
+ <object-type name='Base' generate='no'/>\n\
+ <object-type name='Derived'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ const AbstractMetaClass *base = AbstractMetaClass::findClass(classes, QLatin1String("Base"));
+ QCOMPARE(base->hasNonPrivateConstructor(), true);
+ const AbstractMetaClass *derived = AbstractMetaClass::findClass(classes, QLatin1String("Derived"));
+ QCOMPARE(derived->hasNonPrivateConstructor(), true);
+}
+
+QTEST_APPLESS_MAIN(TestCtorInformation)
diff --git a/sources/shiboken2/ApiExtractor/tests/testctorinformation.h b/sources/shiboken2/ApiExtractor/tests/testctorinformation.h
new file mode 100644
index 000000000..f5ffe5501
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testctorinformation.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTCTORINFORMATION_H
+#define TESTCTORINFORMATION_H
+
+#include <QObject>
+
+class AbstractMetaBuilder;
+
+class TestCtorInformation: public QObject
+{
+ Q_OBJECT
+private slots:
+ void testCtorIsPrivate();
+ void testHasNonPrivateCtor();
+};
+
+#endif // TESTCTORINFORMATION_H
diff --git a/sources/shiboken2/ApiExtractor/tests/testdroptypeentries.cpp b/sources/shiboken2/ApiExtractor/tests/testdroptypeentries.cpp
new file mode 100644
index 000000000..6b6c5d011
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testdroptypeentries.cpp
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdroptypeentries.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+static const char* cppCode ="\
+ struct ValueA {};\n\
+ struct ValueB {};\n\
+ struct ObjectA {};\n\
+ struct ObjectB {};\n\
+ namespace NamespaceA {\n\
+ struct InnerClassA {};\n\
+ namespace InnerNamespaceA {}\n\
+ }\n\
+ namespace NamespaceB {}\n\
+ enum EnumA { Value0 };\n\
+ enum EnumB { Value1 };\n\
+ void funcA();\n\
+ void funcB();\n";
+
+static const char* xmlCode = "\
+<typesystem package='Foo'>\n\
+ <value-type name='ValueA'/>\n\
+ <value-type name='ValueB'/>\n\
+ <object-type name='ObjectA'/>\n\
+ <object-type name='ObjectB'/>\n\
+ <namespace-type name='NamespaceA'>\n\
+ <value-type name='InnerClassA'/>\n\
+ <namespace-type name='InnerNamespaceA'/>\n\
+ </namespace-type>\n\
+ <namespace-type name='NamespaceB'/>\n\
+ <enum-type name='EnumA'/>\n\
+ <enum-type name='EnumB'/>\n\
+ <function signature='funcA()'/>\n\
+ <function signature='funcB()'/>\n\
+</typesystem>\n";
+
+void TestDropTypeEntries::testDropEntries()
+{
+ QStringList droppedEntries(QLatin1String("Foo.ValueB"));
+ droppedEntries << QLatin1String("Foo.ObjectB") << QLatin1String("Foo.NamespaceA.InnerClassA");
+ droppedEntries << QLatin1String("Foo.NamespaceB") << QLatin1String("Foo.EnumB") << QLatin1String("Foo.funcB()");
+ droppedEntries << QLatin1String("Foo.NamespaceA.InnerNamespaceA");
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false, Q_NULLPTR, droppedEntries));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+ QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ValueA")));
+ QVERIFY(!AbstractMetaClass::findClass(classes, QLatin1String("ValueB")));
+ QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ObjectA")));
+ QVERIFY(!AbstractMetaClass::findClass(classes, QLatin1String("ObjectB")));
+ QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("NamespaceA")));
+ QVERIFY(!AbstractMetaClass::findClass(classes, QLatin1String("NamespaceA::InnerClassA")));
+ QVERIFY(!AbstractMetaClass::findClass(classes, QLatin1String("NamespaceB")));
+
+ AbstractMetaEnumList globalEnums = builder->globalEnums();
+ QCOMPARE(globalEnums.count(), 1);
+ QCOMPARE(globalEnums.first()->name(), QLatin1String("EnumA"));
+
+ TypeDatabase* td = TypeDatabase::instance();
+ QVERIFY(td->findType(QLatin1String("funcA")));
+ QVERIFY(!td->findType(QLatin1String("funcB")));
+}
+
+void TestDropTypeEntries::testDontDropEntries()
+{
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+ QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ValueA")));
+ QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ValueB")));
+ QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ObjectA")));
+ QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ObjectB")));
+ QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("NamespaceA")));
+ QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("NamespaceA::InnerClassA")));
+ QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("NamespaceB")));
+
+ QCOMPARE(builder->globalEnums().size(), 2);
+
+ TypeDatabase* td = TypeDatabase::instance();
+ QVERIFY(td->findType(QLatin1String("funcA")));
+ QVERIFY(td->findType(QLatin1String("funcB")));
+}
+
+static const char* cppCode2 ="\
+ struct ValueA {\n\
+ void func();\n\
+ };\n";
+
+static const char* xmlCode2 = "\
+<typesystem package='Foo'>\n\
+ <value-type name='ValueA'>\n\
+ <modify-function signature='func()'>\n\
+ <remove class='all'/>\n\
+ </modify-function>\n\
+ </value-type>\n\
+</typesystem>\n";
+
+void TestDropTypeEntries::testDropEntryWithChildTags()
+{
+ QStringList droppedEntries(QLatin1String("Foo.ValueA"));
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode2, xmlCode2, false, Q_NULLPTR, droppedEntries));
+ QVERIFY(!builder.isNull());
+ QVERIFY(!AbstractMetaClass::findClass(builder->classes(), QLatin1String("ValueA")));
+}
+
+
+void TestDropTypeEntries::testDontDropEntryWithChildTags()
+{
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode2, xmlCode2, false));
+ QVERIFY(!builder.isNull());
+ QVERIFY(AbstractMetaClass::findClass(builder->classes(), QLatin1String("ValueA")));
+}
+
+QTEST_APPLESS_MAIN(TestDropTypeEntries)
diff --git a/sources/shiboken2/ApiExtractor/tests/testdroptypeentries.h b/sources/shiboken2/ApiExtractor/tests/testdroptypeentries.h
new file mode 100644
index 000000000..d04c6dc92
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testdroptypeentries.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTDROPTYPEENTRIES_H
+#define TESTDROPTYPEENTRIES_H
+
+#include <QObject>
+
+class TestDropTypeEntries : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testDropEntries();
+ void testDontDropEntries();
+ void testDropEntryWithChildTags();
+ void testDontDropEntryWithChildTags();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testdtorinformation.cpp b/sources/shiboken2/ApiExtractor/tests/testdtorinformation.cpp
new file mode 100644
index 000000000..63b745c12
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testdtorinformation.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testdtorinformation.h"
+#include "abstractmetabuilder.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestDtorInformation::testDtorIsPrivate()
+{
+ const char* cppCode ="class Control { public: ~Control() {} }; class Subject { private: ~Subject() {} };";
+ const char* xmlCode = "<typesystem package=\"Foo\"><value-type name=\"Control\"/><value-type name=\"Subject\"/></typesystem>";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("Control"))->hasPrivateDestructor(), false);
+ QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("Subject"))->hasPrivateDestructor(), true);
+}
+
+void TestDtorInformation::testDtorIsProtected()
+{
+ const char* cppCode ="class Control { public: ~Control() {} }; class Subject { protected: ~Subject() {} };";
+ const char* xmlCode = "<typesystem package=\"Foo\"><value-type name=\"Control\"/><value-type name=\"Subject\"/></typesystem>";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("Control"))->hasProtectedDestructor(), false);
+ QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("Subject"))->hasProtectedDestructor(), true);
+}
+
+void TestDtorInformation::testDtorIsVirtual()
+{
+ const char* cppCode ="class Control { public: ~Control() {} }; class Subject { protected: virtual ~Subject() {} };";
+ const char* xmlCode = "<typesystem package=\"Foo\"><value-type name=\"Control\"/><value-type name=\"Subject\"/></typesystem>";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("Control"))->hasVirtualDestructor(), false);
+ QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("Subject"))->hasVirtualDestructor(), true);
+}
+
+void TestDtorInformation::testClassWithVirtualDtorIsPolymorphic()
+{
+ const char* cppCode ="class Control { public: virtual ~Control() {} }; class Subject { protected: virtual ~Subject() {} };";
+ const char* xmlCode = "<typesystem package=\"Foo\"><value-type name=\"Control\"/><value-type name=\"Subject\"/></typesystem>";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("Control"))->isPolymorphic(), true);
+ QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("Subject"))->isPolymorphic(), true);
+}
+
+QTEST_APPLESS_MAIN(TestDtorInformation)
+
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testdtorinformation.h b/sources/shiboken2/ApiExtractor/tests/testdtorinformation.h
new file mode 100644
index 000000000..21a3b1822
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testdtorinformation.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTDTORINFORMATION_H
+#define TESTDTORINFORMATION_H
+
+#include <QObject>
+
+class AbstractMetaBuilder;
+
+class TestDtorInformation: public QObject
+{
+ Q_OBJECT
+private slots:
+ void testDtorIsPrivate();
+ void testDtorIsProtected();
+ void testDtorIsVirtual();
+ void testClassWithVirtualDtorIsPolymorphic();
+};
+
+#endif // TESTDTORINFORMATION_H
diff --git a/sources/shiboken2/ApiExtractor/tests/testenum.cpp b/sources/shiboken2/ApiExtractor/tests/testenum.cpp
new file mode 100644
index 000000000..6700239d6
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testenum.cpp
@@ -0,0 +1,416 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testenum.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestEnum::testEnumCppSignature()
+{
+ const char* cppCode ="\
+ enum GlobalEnum { A, B };\n\
+ \n\
+ struct A {\n\
+ enum ClassEnum { CA, CB };\n\
+ void method(ClassEnum);\n\
+ };\n\
+ void func(A::ClassEnum);\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <enum-type name='GlobalEnum'/>\n\
+ <value-type name='A'>\n\
+ <enum-type name='ClassEnum'/>\n\
+ </value-type>\n\
+ <function signature='func(A::ClassEnum)'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 1);
+
+ AbstractMetaEnumList globalEnums = builder->globalEnums();
+ QCOMPARE(globalEnums.count(), 1);
+ QCOMPARE(globalEnums.first()->name(), QLatin1String("GlobalEnum"));
+
+ // enum as parameter of a function
+ AbstractMetaFunctionList functions = builder->globalFunctions();
+ QCOMPARE(functions.count(), 1);
+ QCOMPARE(functions.first()->arguments().count(), 1);
+ QCOMPARE(functions.first()->arguments().first()->type()->cppSignature(), QLatin1String("A::ClassEnum"));
+
+ // enum as parameter of a method
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QCOMPARE(classA->enums().count(), 1);
+ AbstractMetaFunctionList funcs = classA->queryFunctionsByName(QLatin1String("method"));
+ QVERIFY(!funcs.isEmpty());
+ AbstractMetaFunction* method = funcs.first();
+ QVERIFY(method);
+ AbstractMetaArgument* arg = method->arguments().first();
+ QCOMPARE(arg->type()->name(), QLatin1String("ClassEnum"));
+ QCOMPARE(arg->type()->cppSignature(), QLatin1String("A::ClassEnum"));
+ QCOMPARE(functions.first()->arguments().count(), 1);
+ arg = functions.first()->arguments().first();
+ QCOMPARE(arg->type()->name(), QLatin1String("ClassEnum"));
+ QCOMPARE(arg->type()->cppSignature(), QLatin1String("A::ClassEnum"));
+
+ AbstractMetaEnumList classEnums = classA->enums();
+ QCOMPARE(classEnums.first()->name(), QLatin1String("ClassEnum"));
+}
+
+void TestEnum::testEnumWithApiVersion()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ enum ClassEnum { EnumA, EnumB };\n\
+ enum ClassEnum2 { EnumC, EnumD };\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A'>\n\
+ <enum-type name='ClassEnum' since='0.1'/>\n\
+ <enum-type name='ClassEnum2' since='0.2'/>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, true, "0.1"));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 1);
+ QCOMPARE(classes[0]->enums().count(), 1);
+}
+
+void TestEnum::testAnonymousEnum()
+{
+ const char* cppCode ="\
+ enum { Global0, Global1 };\n\
+ struct A {\n\
+ enum { A0, A1 };\n\
+ enum { isThis = true, isThat = false };\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <!-- Uses the first value of the enum to identify it. -->\n\
+ <enum-type identified-by-value='Global0'/>\n\
+ <value-type name='A'>\n\
+ <!-- Uses the second value of the enum to identify it. -->\n\
+ <enum-type identified-by-value='A1'/>\n\
+ <enum-type identified-by-value='isThis'/>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaEnumList globalEnums = builder->globalEnums();
+ QCOMPARE(globalEnums.count(), 1);
+ QCOMPARE(globalEnums.first()->typeEntry()->qualifiedCppName(), QLatin1String("Global0"));
+ QVERIFY(globalEnums.first()->isAnonymous());
+
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 1);
+ QCOMPARE(classes[0]->enums().count(), 2);
+
+ AbstractMetaEnum* anonEnumA1 = classes[0]->findEnum(QLatin1String("A1"));
+ QVERIFY(anonEnumA1);
+ QVERIFY(anonEnumA1->isAnonymous());
+ QCOMPARE(anonEnumA1->typeEntry()->qualifiedCppName(), QLatin1String("A::A1"));
+
+ AbstractMetaEnumValue* enumValueA0 = anonEnumA1->values().first();
+ QCOMPARE(enumValueA0->name(), QLatin1String("A0"));
+ QCOMPARE(enumValueA0->value(), 0);
+ QCOMPARE(enumValueA0->stringValue(), QString());
+
+ AbstractMetaEnumValue* enumValueA1 = anonEnumA1->values().last();
+ QCOMPARE(enumValueA1->name(), QLatin1String("A1"));
+ QCOMPARE(enumValueA1->value(), 1);
+ QCOMPARE(enumValueA1->stringValue(), QString());
+
+ AbstractMetaEnum* anonEnumIsThis = classes[0]->findEnum(QLatin1String("isThis"));
+ QVERIFY(anonEnumIsThis);
+ QVERIFY(anonEnumIsThis->isAnonymous());
+ QCOMPARE(anonEnumIsThis->typeEntry()->qualifiedCppName(), QLatin1String("A::isThis"));
+
+ AbstractMetaEnumValue* enumValueIsThis = anonEnumIsThis->values().first();
+ QCOMPARE(enumValueIsThis->name(), QLatin1String("isThis"));
+ QCOMPARE(enumValueIsThis->value(), static_cast<int>(true));
+ QCOMPARE(enumValueIsThis->stringValue(), QLatin1String("true"));
+
+ AbstractMetaEnumValue* enumValueIsThat = anonEnumIsThis->values().last();
+ QCOMPARE(enumValueIsThat->name(), QLatin1String("isThat"));
+ QCOMPARE(enumValueIsThat->value(), static_cast<int>(false));
+ QCOMPARE(enumValueIsThat->stringValue(), QLatin1String("false"));
+}
+
+void TestEnum::testGlobalEnums()
+{
+ const char* cppCode ="\
+ enum EnumA { A0, A1 };\n\
+ enum EnumB { B0 = 2, B1 = 0x4 };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <enum-type name='EnumA'/>\n\
+ <enum-type name='EnumB'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaEnumList globalEnums = builder->globalEnums();
+ QCOMPARE(globalEnums.count(), 2);
+
+ AbstractMetaEnum* enumA = globalEnums.first();
+ QCOMPARE(enumA->typeEntry()->qualifiedCppName(), QLatin1String("EnumA"));
+
+ AbstractMetaEnumValue* enumValueA0 = enumA->values().first();
+ QCOMPARE(enumValueA0->name(), QLatin1String("A0"));
+ QCOMPARE(enumValueA0->value(), 0);
+ QCOMPARE(enumValueA0->stringValue(), QString());
+
+ AbstractMetaEnumValue* enumValueA1 = enumA->values().last();
+ QCOMPARE(enumValueA1->name(), QLatin1String("A1"));
+ QCOMPARE(enumValueA1->value(), 1);
+ QCOMPARE(enumValueA1->stringValue(), QString());
+
+ AbstractMetaEnum* enumB = globalEnums.last();
+ QCOMPARE(enumB->typeEntry()->qualifiedCppName(), QLatin1String("EnumB"));
+
+ AbstractMetaEnumValue* enumValueB0 = enumB->values().first();
+ QCOMPARE(enumValueB0->name(), QLatin1String("B0"));
+ QCOMPARE(enumValueB0->value(), 2);
+ QCOMPARE(enumValueB0->stringValue(), QLatin1String("2"));
+
+ AbstractMetaEnumValue* enumValueB1 = enumB->values().last();
+ QCOMPARE(enumValueB1->name(), QLatin1String("B1"));
+ QCOMPARE(enumValueB1->value(), 4);
+ QCOMPARE(enumValueB1->stringValue(), QLatin1String("0x4"));
+}
+
+void TestEnum::testEnumValueFromNeighbourEnum()
+{
+ const char* cppCode ="\
+ namespace A {\n\
+ enum EnumA { ValueA0, ValueA1 };\n\
+ enum EnumB { ValueB0 = A::ValueA1, ValueB1 = ValueA0 };\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <namespace-type name='A'>\n\
+ <enum-type name='EnumA'/>\n\
+ <enum-type name='EnumB'/>\n\
+ </namespace-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 1);
+ QCOMPARE(classes[0]->enums().count(), 2);
+
+ AbstractMetaEnum* enumA = classes[0]->findEnum(QLatin1String("EnumA"));
+ QVERIFY(enumA);
+ QCOMPARE(enumA->typeEntry()->qualifiedCppName(), QLatin1String("A::EnumA"));
+
+ AbstractMetaEnumValue* enumValueA0 = enumA->values().first();
+ QCOMPARE(enumValueA0->name(), QLatin1String("ValueA0"));
+ QCOMPARE(enumValueA0->value(), 0);
+ QCOMPARE(enumValueA0->stringValue(), QString());
+
+ AbstractMetaEnumValue* enumValueA1 = enumA->values().last();
+ QCOMPARE(enumValueA1->name(), QLatin1String("ValueA1"));
+ QCOMPARE(enumValueA1->value(), 1);
+ QCOMPARE(enumValueA1->stringValue(), QString());
+
+ AbstractMetaEnum* enumB = classes[0]->findEnum(QLatin1String("EnumB"));
+ QVERIFY(enumB);
+ QCOMPARE(enumB->typeEntry()->qualifiedCppName(), QLatin1String("A::EnumB"));
+
+ AbstractMetaEnumValue* enumValueB0 = enumB->values().first();
+ QCOMPARE(enumValueB0->name(), QLatin1String("ValueB0"));
+ QCOMPARE(enumValueB0->value(), 1);
+ QCOMPARE(enumValueB0->stringValue(), QLatin1String("A::ValueA1"));
+
+ AbstractMetaEnumValue* enumValueB1 = enumB->values().last();
+ QCOMPARE(enumValueB1->name(), QLatin1String("ValueB1"));
+ QCOMPARE(enumValueB1->value(), 0);
+ QCOMPARE(enumValueB1->stringValue(), QLatin1String("ValueA0"));
+}
+
+void TestEnum::testEnumValueFromExpression()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ enum EnumA {\n\
+ ValueA0 = 3u,\n\
+ ValueA1 = ~3u,\n\
+ ValueA2 = ~3,\n\
+ ValueA3 = 0xf0,\n\
+ ValueA4 = 8 |ValueA3,\n\
+ ValueA5 = ValueA3|32,\n\
+ ValueA6 = ValueA3 >> 1,\n\
+ ValueA7 = ValueA3 << 1\n\
+ };\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A'>\n\
+ <enum-type name='EnumA'/>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), QLatin1String("A"));
+ QVERIFY(classA);
+
+ AbstractMetaEnum* enumA = classA->findEnum(QLatin1String("EnumA"));
+ QVERIFY(enumA);
+ QCOMPARE(enumA->typeEntry()->qualifiedCppName(), QLatin1String("A::EnumA"));
+
+ AbstractMetaEnumValue* valueA0 = enumA->values().at(0);
+ QCOMPARE(valueA0->name(), QLatin1String("ValueA0"));
+ QCOMPARE(valueA0->stringValue(), QLatin1String("3u"));
+ QCOMPARE(valueA0->value(), (int) 3u);
+
+ AbstractMetaEnumValue* valueA1 = enumA->values().at(1);
+ QCOMPARE(valueA1->name(), QLatin1String("ValueA1"));
+ QCOMPARE(valueA1->stringValue(), QLatin1String("~3u"));
+ QCOMPARE(valueA1->value(), (int) ~3u);
+
+ AbstractMetaEnumValue* valueA2 = enumA->values().at(2);
+ QCOMPARE(valueA2->name(), QLatin1String("ValueA2"));
+ QCOMPARE(valueA2->stringValue(), QLatin1String("~3"));
+ QCOMPARE(valueA2->value(), ~3);
+
+ AbstractMetaEnumValue* valueA3 = enumA->values().at(3);
+ QCOMPARE(valueA3->name(), QLatin1String("ValueA3"));
+ QCOMPARE(valueA3->stringValue(), QLatin1String("0xf0"));
+ QCOMPARE(valueA3->value(), 0xf0);
+
+ AbstractMetaEnumValue* valueA4 = enumA->values().at(4);
+ QCOMPARE(valueA4->name(), QLatin1String("ValueA4"));
+ QCOMPARE(valueA4->stringValue(), QLatin1String("8|ValueA3"));
+ QCOMPARE(valueA4->value(), 8|0xf0);
+
+ AbstractMetaEnumValue* valueA5 = enumA->values().at(5);
+ QCOMPARE(valueA5->name(), QLatin1String("ValueA5"));
+ QCOMPARE(valueA5->stringValue(), QLatin1String("ValueA3|32"));
+ QCOMPARE(valueA5->value(), 0xf0|32);
+
+ AbstractMetaEnumValue* valueA6 = enumA->values().at(6);
+ QCOMPARE(valueA6->name(), QLatin1String("ValueA6"));
+ QCOMPARE(valueA6->stringValue(), QLatin1String("ValueA3>>1"));
+ QCOMPARE(valueA6->value(), 0xf0 >> 1);
+
+ AbstractMetaEnumValue* valueA7 = enumA->values().at(7);
+ QCOMPARE(valueA7->name(), QLatin1String("ValueA7"));
+ QCOMPARE(valueA7->stringValue(), QLatin1String("ValueA3<<1"));
+ QCOMPARE(valueA7->value(), 0xf0 << 1);
+}
+
+void TestEnum::testPrivateEnum()
+{
+ const char* cppCode ="\
+ class A {\n\
+ private:\n\
+ enum PrivateEnum { Priv0 = 0x0f, Priv1 = 0xf0 };\n\
+ public:\n\
+ enum PublicEnum { Pub0 = Priv0, Pub1 = A::Priv1 };\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A'>\n\
+ <enum-type name='PublicEnum'/>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->enums().count(), 2);
+
+ AbstractMetaEnum* privateEnum = classA->findEnum(QLatin1String("PrivateEnum"));
+ QVERIFY(privateEnum);
+ QVERIFY(privateEnum->isPrivate());
+ QCOMPARE(privateEnum->typeEntry()->qualifiedCppName(), QLatin1String("A::PrivateEnum"));
+
+ AbstractMetaEnum* publicEnum = classA->findEnum(QLatin1String("PublicEnum"));
+ QVERIFY(publicEnum);
+ QCOMPARE(publicEnum->typeEntry()->qualifiedCppName(), QLatin1String("A::PublicEnum"));
+
+ AbstractMetaEnumValue* pub0 = publicEnum->values().first();
+ QCOMPARE(pub0->name(), QLatin1String("Pub0"));
+ QCOMPARE(pub0->value(), 0x0f);
+ QCOMPARE(pub0->stringValue(), QLatin1String("Priv0"));
+
+ AbstractMetaEnumValue* pub1 = publicEnum->values().last();
+ QCOMPARE(pub1->name(), QLatin1String("Pub1"));
+ QCOMPARE(pub1->value(), 0xf0);
+ QCOMPARE(pub1->stringValue(), QLatin1String("A::Priv1"));
+}
+
+void TestEnum::testTypedefEnum()
+{
+ const char* cppCode ="\
+ typedef enum EnumA {\n\
+ A0,\n\
+ A1,\n\
+ } EnumA;\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <enum-type name='EnumA'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaEnumList globalEnums = builder->globalEnums();
+ QEXPECT_FAIL("", "APIExtractor does not handle typedef enum correctly yet", Abort);
+ QCOMPARE(globalEnums.count(), 1);
+
+ AbstractMetaEnum* enumA = globalEnums.first();
+ QCOMPARE(enumA->typeEntry()->qualifiedCppName(), QLatin1String("EnumA"));
+
+ AbstractMetaEnumValue* enumValueA0 = enumA->values().first();
+ QCOMPARE(enumValueA0->name(), QLatin1String("A0"));
+ QCOMPARE(enumValueA0->value(), 0);
+ QCOMPARE(enumValueA0->stringValue(), QLatin1String(""));
+
+ AbstractMetaEnumValue* enumValueA1 = enumA->values().last();
+ QCOMPARE(enumValueA1->name(), QLatin1String("A1"));
+ QCOMPARE(enumValueA1->value(), 1);
+ QCOMPARE(enumValueA1->stringValue(), QString());
+}
+
+QTEST_APPLESS_MAIN(TestEnum)
diff --git a/sources/shiboken2/ApiExtractor/tests/testenum.h b/sources/shiboken2/ApiExtractor/tests/testenum.h
new file mode 100644
index 000000000..8b46b1bd6
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testenum.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTENUM_H
+#define TESTENUM_H
+#include <QObject>
+
+class TestEnum : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testEnumCppSignature();
+ void testEnumWithApiVersion();
+ void testAnonymousEnum();
+ void testGlobalEnums();
+ void testEnumValueFromNeighbourEnum();
+ void testEnumValueFromExpression();
+ void testPrivateEnum();
+ void testTypedefEnum();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testextrainclude.cpp b/sources/shiboken2/ApiExtractor/tests/testextrainclude.cpp
new file mode 100644
index 000000000..94158377e
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testextrainclude.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testextrainclude.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestExtraInclude::testClassExtraInclude()
+{
+ const char* cppCode ="struct A {};\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <value-type name='A'>\n\
+ <extra-includes>\n\
+ <include file-name='header.h' location='global'/>\n\
+ </extra-includes>\n\
+ </value-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+
+ QList<Include> includes = classA->typeEntry()->extraIncludes();
+ QCOMPARE(includes.count(), 1);
+ QCOMPARE(includes.first().name(), QLatin1String("header.h"));
+}
+
+void TestExtraInclude::testGlobalExtraIncludes()
+{
+ const char* cppCode ="struct A {};\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <extra-includes>\n\
+ <include file-name='header1.h' location='global'/>\n\
+ <include file-name='header2.h' location='global'/>\n\
+ </extra-includes>\n\
+ <value-type name='A'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("A")));
+
+ TypeDatabase* td = TypeDatabase::instance();
+ TypeEntry* module = td->findType(QLatin1String("Foo"));
+ QVERIFY(module);
+
+ QList<Include> includes = module->extraIncludes();
+ QCOMPARE(includes.count(), 2);
+ QCOMPARE(includes.first().name(), QLatin1String("header1.h"));
+ QCOMPARE(includes.last().name(), QLatin1String("header2.h"));
+}
+
+QTEST_APPLESS_MAIN(TestExtraInclude)
diff --git a/sources/shiboken2/ApiExtractor/tests/testextrainclude.h b/sources/shiboken2/ApiExtractor/tests/testextrainclude.h
new file mode 100644
index 000000000..c569901e1
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testextrainclude.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTEXTRAINCLUDE_H
+#define TESTEXTRAINCLUDE_H
+
+#include <QObject>
+
+class TestExtraInclude : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testClassExtraInclude();
+ void testGlobalExtraIncludes();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testfunctiontag.cpp b/sources/shiboken2/ApiExtractor/tests/testfunctiontag.cpp
new file mode 100644
index 000000000..a29d740bf
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testfunctiontag.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testfunctiontag.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestFunctionTag::testFunctionTagForSpecificSignature()
+{
+ const char cppCode[] = "void globalFunction(int); void globalFunction(float); void dummy();\n";
+ const char xmlCode[] = "\
+ <typesystem package=\"Foo\">\n\
+ <primitive-type name='int'/>\n\
+ <primitive-type name='float'/>\n\
+ <function signature='globalFunction(int)'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ const TypeEntry *func = TypeDatabase::instance()->findType(QLatin1String("globalFunction"));
+ QVERIFY(func);
+ QCOMPARE(builder->globalFunctions().size(), 1);
+}
+
+void TestFunctionTag::testFunctionTagForAllSignatures()
+{
+ const char cppCode[] = "void globalFunction(int); void globalFunction(float); void dummy();\n";
+ const char xmlCode[] = "\
+ <typesystem package=\"Foo\">\n\
+ <primitive-type name='int'/>\n\
+ <primitive-type name='float'/>\n\
+ <function signature='globalFunction(int)'/>\n\
+ <function signature='globalFunction(float)'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ const TypeEntry *func = TypeDatabase::instance()->findType(QLatin1String("globalFunction"));
+ QVERIFY(func);
+ QCOMPARE(builder->globalFunctions().size(), 2);
+}
+
+void TestFunctionTag::testRenameGlobalFunction()
+{
+ const char* cppCode ="void global_function_with_ugly_name();\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <function signature='global_function_with_ugly_name()' rename='smooth'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ const TypeEntry *func = TypeDatabase::instance()->findType(QLatin1String("global_function_with_ugly_name"));
+ QVERIFY(func);
+
+ QCOMPARE(builder->globalFunctions().size(), 1);
+ const AbstractMetaFunction* metaFunc = builder->globalFunctions().first();
+
+ QVERIFY(metaFunc);
+ QCOMPARE(metaFunc->modifications().size(), 1);
+ QVERIFY(metaFunc->modifications().first().isRenameModifier());
+ QCOMPARE(metaFunc->modifications().first().renamedTo(), QLatin1String("smooth"));
+
+ QCOMPARE(metaFunc->name(), QLatin1String("smooth"));
+ QCOMPARE(metaFunc->originalName(), QLatin1String("global_function_with_ugly_name"));
+ QCOMPARE(metaFunc->minimalSignature(), QLatin1String("global_function_with_ugly_name()"));
+}
+
+QTEST_APPLESS_MAIN(TestFunctionTag)
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testfunctiontag.h b/sources/shiboken2/ApiExtractor/tests/testfunctiontag.h
new file mode 100644
index 000000000..d4b6c7d2c
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testfunctiontag.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTFUNCTIONTAG_H
+#define TESTFUNCTIONTAG_H
+#include <QObject>
+
+class TestFunctionTag : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testFunctionTagForSpecificSignature();
+ void testFunctionTagForAllSignatures();
+ void testRenameGlobalFunction();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp b/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp
new file mode 100644
index 000000000..4438550b2
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testimplicitconversions.h"
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+#include <QtTest/QTest>
+
+void TestImplicitConversions::testWithPrivateCtors()
+{
+ const char* cppCode ="\
+ class B;\n\
+ class C;\n\
+ class A {\n\
+ A(const B&);\n\
+ public:\n\
+ A(const C&);\n\
+ };\n\
+ class B {};\n\
+ class C {};\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <value-type name='A'/>\n\
+ <value-type name='B'/>\n\
+ <value-type name='C'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 3);
+
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const AbstractMetaClass *classC = AbstractMetaClass::findClass(classes, QLatin1String("C"));
+ AbstractMetaFunctionList implicitConvs = classA->implicitConversions();
+ QCOMPARE(implicitConvs.count(), 1);
+ QCOMPARE(implicitConvs.first()->arguments().first()->type()->typeEntry(), classC->typeEntry());
+}
+
+void TestImplicitConversions::testWithModifiedVisibility()
+{
+ const char* cppCode ="\
+ class B;\n\
+ class A {\n\
+ public:\n\
+ A(const B&);\n\
+ };\n\
+ class B {};\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <value-type name='A'>\n\
+ <modify-function signature='A(const B&amp;)'>\n\
+ <access modifier='private'/>\n\
+ </modify-function>\n\
+ </value-type>\n\
+ <value-type name='B'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ AbstractMetaFunctionList implicitConvs = classA->implicitConversions();
+ QCOMPARE(implicitConvs.count(), 1);
+ QCOMPARE(implicitConvs.first()->arguments().first()->type()->typeEntry(), classB->typeEntry());
+}
+
+
+void TestImplicitConversions::testWithAddedCtor()
+{
+ const char* cppCode ="\
+ class B;\n\
+ class A {\n\
+ public:\n\
+ A(const B&);\n\
+ };\n\
+ class B {};\n\
+ class C {};\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <custom-type name='TARGETLANGTYPE'/>\n\
+ <value-type name='A'>\n\
+ <add-function signature='A(const C&amp;)'/>\n\
+ </value-type>\n\
+ <value-type name='B'>\n\
+ <add-function signature='B(TARGETLANGTYPE*)'/>\n\
+ </value-type>\n\
+ <value-type name='C'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 3);
+
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ AbstractMetaFunctionList implicitConvs = classA->implicitConversions();
+ QCOMPARE(implicitConvs.count(), 2);
+
+ // Added constructors with custom types should never result in implicit converters.
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ implicitConvs = classB->implicitConversions();
+ QCOMPARE(implicitConvs.count(), 0);
+}
+
+void TestImplicitConversions::testWithExternalConversionOperator()
+{
+ const char* cppCode ="\
+ class A {};\n\
+ struct B {\n\
+ operator A() const;\n\
+ };\n";
+ const char* xmlCode = "\n\
+ <typesystem package='Foo'>\n\
+ <value-type name='A'/>\n\
+ <value-type name='B'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ AbstractMetaClass* classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ AbstractMetaFunctionList implicitConvs = classA->implicitConversions();
+ QCOMPARE(implicitConvs.count(), 1);
+ AbstractMetaFunctionList externalConvOps = classA->externalConversionOperators();
+ QCOMPARE(externalConvOps.count(), 1);
+
+ const AbstractMetaFunction* convOp = 0;
+ foreach(const AbstractMetaFunction* func, classB->functions()) {
+ if (func->isConversionOperator())
+ convOp = func;
+ }
+ QVERIFY(convOp);
+ QCOMPARE(implicitConvs.first(), convOp);
+}
+
+QTEST_APPLESS_MAIN(TestImplicitConversions)
diff --git a/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.h b/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.h
new file mode 100644
index 000000000..657c1a558
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTIMPLICITCONVERSIONS_H
+#define TESTIMPLICITCONVERSIONS_H
+
+#include <QObject>
+
+class AbstractMetaBuilder;
+
+class TestImplicitConversions : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testWithPrivateCtors();
+ void testWithModifiedVisibility();
+ void testWithAddedCtor();
+ void testWithExternalConversionOperator();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testinserttemplate.cpp b/sources/shiboken2/ApiExtractor/tests/testinserttemplate.cpp
new file mode 100644
index 000000000..ecadf311b
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testinserttemplate.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testinserttemplate.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestInsertTemplate::testInsertTemplateOnClassInjectCode()
+{
+ const char* cppCode ="struct A{};\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <template name='code_template'>\n\
+ code template content\n\
+ </template>\n\
+ <value-type name='A'>\n\
+ <inject-code class='native'>\n\
+ <insert-template name='code_template'/>\n\
+ </inject-code>\n\
+ </value-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 1);
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->typeEntry()->codeSnips().count(), 1);
+ QString code = classA->typeEntry()->codeSnips().first().code();
+ QVERIFY(code.contains(QLatin1String("code template content")));
+}
+
+void TestInsertTemplate::testInsertTemplateOnModuleInjectCode()
+{
+ const char* cppCode ="";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <template name='code_template'>\n\
+ code template content\n\
+ </template>\n\
+ <inject-code class='native'>\n\
+ <insert-template name='code_template'/>\n\
+ </inject-code>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QVERIFY(classes.isEmpty());
+
+ TypeEntry* module = TypeDatabase::instance()->findType(QLatin1String("Foo"));
+ QVERIFY(module);
+ QCOMPARE(module->codeSnips().count(), 1);
+ QString code = module->codeSnips().first().code().trimmed();
+ QVERIFY(code.contains(QLatin1String("code template content")));
+}
+
+void TestInsertTemplate::testInvalidTypeSystemTemplate()
+{
+ const char* cppCode ="";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <inject-code class='native'>\n\
+ <insert-template name='this_code_template_does_not_exists'/>\n\
+ </inject-code>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QVERIFY(classes.isEmpty());
+
+ TypeEntry* module = TypeDatabase::instance()->findType(QLatin1String("Foo"));
+ QVERIFY(module);
+ QCOMPARE(module->codeSnips().count(), 1);
+ QString code = module->codeSnips().first().code().trimmed();
+ QVERIFY(code.isEmpty());
+}
+
+void TestInsertTemplate::testValidAndInvalidTypeSystemTemplate()
+{
+ const char* cppCode ="";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <template name='code_template'>\n\
+ code template content\n\
+ </template>\n\
+ <inject-code class='native'>\n\
+ <insert-template name='this_code_template_does_not_exists'/>\n\
+ <insert-template name='code_template'/>\n\
+ </inject-code>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QVERIFY(classes.isEmpty());
+
+ TypeEntry* module = TypeDatabase::instance()->findType(QLatin1String("Foo"));
+ QVERIFY(module);
+ QCOMPARE(module->codeSnips().count(), 1);
+ QString code = module->codeSnips().first().code().trimmed();
+ QVERIFY(code.contains(QLatin1String("code template content")));
+}
+
+QTEST_APPLESS_MAIN(TestInsertTemplate)
diff --git a/sources/shiboken2/ApiExtractor/tests/testinserttemplate.h b/sources/shiboken2/ApiExtractor/tests/testinserttemplate.h
new file mode 100644
index 000000000..0e2a882fe
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testinserttemplate.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTINSERTTEMPLATE_H
+#define TESTINSERTTEMPLATE_H
+
+#include <QObject>
+
+class TestInsertTemplate : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testInsertTemplateOnClassInjectCode();
+ void testInsertTemplateOnModuleInjectCode();
+ void testInvalidTypeSystemTemplate();
+ void testValidAndInvalidTypeSystemTemplate();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.cpp b/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.cpp
new file mode 100644
index 000000000..96bd0251b
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testmodifydocumentation.h"
+
+#include <QCoreApplication>
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+#include <qtdocparser.h>
+
+void TestModifyDocumentation::testModifyDocumentation()
+{
+ const char* cppCode ="struct B { void b(); }; class A {};\n";
+ const char* xmlCode = "<typesystem package=\"Foo\">\n\
+ <value-type name='B'>\n\
+ <modify-function signature='b()' remove='all'/>\n\
+ </value-type>\n\
+ <value-type name='A'>\n\
+ <modify-documentation xpath='description/para[3]'>\n\
+ &lt;para>Some changed contents here&lt;/para>\n\
+ </modify-documentation>\n\
+ </value-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), QLatin1String("A"));
+ QVERIFY(classA);
+ DocModificationList docMods = classA->typeEntry()->docModifications();
+ QCOMPARE(docMods.count(), 1);
+ QCOMPARE(docMods[0].code().trimmed(), QLatin1String("<para>Some changed contents here</para>"));
+ QCOMPARE(docMods[0].signature(), QString());
+ QtDocParser docParser;
+ docParser.setDocumentationDataDirectory(QDir::currentPath());
+ docParser.fillDocumentation(classA);
+
+ QVERIFY(!classA->documentation().value().trimmed().isEmpty());
+ QCOMPARE(classA->documentation().value(), QLatin1String("<?xml version=\"1.0\"?>\n\
+<description>oi\n\
+ <para>Paragraph number 1</para>\n\
+ <para>Paragraph number 2</para>\n\
+ <para>Some changed contents here</para>\n\
+</description>\n"));
+}
+
+// We expand QTEST_MAIN macro but using QCoreApplication instead of QApplication
+// because this test needs an event loop but can't use QApplication to avoid a crash
+// on our ARMEL/FRAMANTLE buildbot
+int main(int argc, char** argv)
+{
+ QCoreApplication app(argc, argv);
+ TestModifyDocumentation tc;
+ return QTest::qExec(&tc, argc, argv);
+}
diff --git a/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.h b/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.h
new file mode 100644
index 000000000..fb8f6fc01
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTMODIFYDOCUMENTATION_H
+#define TESTMODIFYDOCUMENTATION_H
+
+#include <QObject>
+
+class TestModifyDocumentation : public QObject
+{
+Q_OBJECT
+private slots:
+ void testModifyDocumentation();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp
new file mode 100644
index 000000000..0e6bdc248
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp
@@ -0,0 +1,249 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testmodifyfunction.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestModifyFunction::testRenameArgument()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ void method(int=0);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <object-type name='A'>\n\
+ <modify-function signature='method(int)'>\n\
+ <modify-argument index='1'>\n\
+ <rename to='otherArg'/>\n\
+ </modify-argument>\n\
+ </modify-function>\n\
+ </object-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const AbstractMetaFunction* func = classA->findFunction(QLatin1String("method"));
+ Q_ASSERT(func);
+
+ QCOMPARE(func->argumentName(1), QLatin1String("otherArg"));
+}
+
+void TestModifyFunction::testOwnershipTransfer()
+{
+ const char* cppCode ="\
+ struct A {};\n\
+ struct B {\n\
+ virtual A* method();\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <object-type name='A' />\n\
+ <object-type name='B'>\n\
+ <modify-function signature='method()'>\n\
+ <modify-argument index='return'>\n\
+ <define-ownership owner='c++'/>\n\
+ </modify-argument>\n\
+ </modify-function>\n\
+ </object-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ const AbstractMetaFunction* func = classB->findFunction(QLatin1String("method"));
+
+ QCOMPARE(func->ownership(func->ownerClass(), TypeSystem::TargetLangCode, 0), TypeSystem::CppOwnership);
+}
+
+
+void TestModifyFunction::invalidateAfterUse()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ virtual void call(int *a);\n\
+ };\n\
+ struct B : A {\n\
+ };\n\
+ struct C : B {\n\
+ virtual void call2(int *a);\n\
+ };\n\
+ struct D : C {\n\
+ virtual void call2(int *a);\n\
+ };\n\
+ struct E : D {\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <object-type name='A'>\n\
+ <modify-function signature='call(int*)'>\n\
+ <modify-argument index='1' invalidate-after-use='true'/>\n\
+ </modify-function>\n\
+ </object-type>\n\
+ <object-type name='B' />\n\
+ <object-type name='C'>\n\
+ <modify-function signature='call2(int*)'>\n\
+ <modify-argument index='1' invalidate-after-use='true'/>\n\
+ </modify-function>\n\
+ </object-type>\n\
+ <object-type name='D'>\n\
+ <modify-function signature='call2(int*)'>\n\
+ <modify-argument index='1' invalidate-after-use='true'/>\n\
+ </modify-function>\n\
+ </object-type>\n\
+ <object-type name='E' />\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false, "0.1"));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ const AbstractMetaFunction* func = classB->findFunction(QLatin1String("call"));
+ QCOMPARE(func->modifications().size(), 1);
+ QCOMPARE(func->modifications().at(0).argument_mods.size(), 1);
+ QVERIFY(func->modifications().at(0).argument_mods.at(0).resetAfterUse);
+
+ const AbstractMetaClass *classC = AbstractMetaClass::findClass(classes, QLatin1String("C"));
+ QVERIFY(classC);
+ func = classC->findFunction(QLatin1String("call"));
+ QCOMPARE(func->modifications().size(), 1);
+ QCOMPARE(func->modifications().at(0).argument_mods.size(), 1);
+ QVERIFY(func->modifications().at(0).argument_mods.at(0).resetAfterUse);
+
+ func = classC->findFunction(QLatin1String("call2"));
+ QCOMPARE(func->modifications().size(), 1);
+ QCOMPARE(func->modifications().at(0).argument_mods.size(), 1);
+ QVERIFY(func->modifications().at(0).argument_mods.at(0).resetAfterUse);
+
+ const AbstractMetaClass *classD = AbstractMetaClass::findClass(classes, QLatin1String("D"));
+ QVERIFY(classD);
+ func = classD->findFunction(QLatin1String("call"));
+ QCOMPARE(func->modifications().size(), 1);
+ QCOMPARE(func->modifications().at(0).argument_mods.size(), 1);
+ QVERIFY(func->modifications().at(0).argument_mods.at(0).resetAfterUse);
+
+ func = classD->findFunction(QLatin1String("call2"));
+ QCOMPARE(func->modifications().size(), 1);
+ QCOMPARE(func->modifications().at(0).argument_mods.size(), 1);
+ QVERIFY(func->modifications().at(0).argument_mods.at(0).resetAfterUse);
+
+ const AbstractMetaClass *classE = AbstractMetaClass::findClass(classes, QLatin1String("E"));
+ QVERIFY(classE);
+ func = classE->findFunction(QLatin1String("call"));
+ QVERIFY(func);
+ QCOMPARE(func->modifications().size(), 1);
+ QCOMPARE(func->modifications().at(0).argument_mods.size(), 1);
+ QVERIFY(func->modifications().at(0).argument_mods.at(0).resetAfterUse);
+
+ func = classE->findFunction(QLatin1String("call2"));
+ QVERIFY(func);
+ QCOMPARE(func->modifications().size(), 1);
+ QCOMPARE(func->modifications().at(0).argument_mods.size(), 1);
+ QVERIFY(func->modifications().at(0).argument_mods.at(0).resetAfterUse);
+}
+
+void TestModifyFunction::testWithApiVersion()
+{
+ const char* cppCode ="\
+ struct A {};\n\
+ struct B {\n\
+ virtual A* method();\n\
+ virtual B* methodB();\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <object-type name='A' />\n\
+ <object-type name='B'>\n\
+ <modify-function signature='method()' since='0.1'>\n\
+ <modify-argument index='return'>\n\
+ <define-ownership owner='c++'/>\n\
+ </modify-argument>\n\
+ </modify-function>\n\
+ <modify-function signature='methodB()' since='0.2'>\n\
+ <modify-argument index='return'>\n\
+ <define-ownership owner='c++'/>\n\
+ </modify-argument>\n\
+ </modify-function>\n\
+ </object-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false, "0.1"));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ AbstractMetaClass* classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ const AbstractMetaFunction* func = classB->findFunction(QLatin1String("method"));
+
+ QCOMPARE(func->ownership(func->ownerClass(), TypeSystem::TargetLangCode, 0), TypeSystem::CppOwnership);
+
+ func = classB->findFunction(QLatin1String("methodB"));
+ QVERIFY(func->ownership(func->ownerClass(), TypeSystem::TargetLangCode, 0) != TypeSystem::CppOwnership);
+}
+
+void TestModifyFunction::testGlobalFunctionModification()
+{
+ const char* cppCode ="\
+ struct A {};\n\
+ void function(A* a = 0);\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='A'/>\n\
+ <function signature='function(A*)'>\n\
+ <modify-function signature='function(A*)'>\n\
+ <modify-argument index='1'>\n\
+ <replace-type modified-type='A'/>\n\
+ <replace-default-expression with='A()'/>\n\
+ </modify-argument>\n\
+ </modify-function>\n\
+ </function>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ QCOMPARE(builder->globalFunctions().size(), 1);
+
+ FunctionModificationList mods = TypeDatabase::instance()->functionModifications(QLatin1String("function(A*)"));
+ QCOMPARE(mods.count(), 1);
+ QList<ArgumentModification> argMods = mods.first().argument_mods;
+ QCOMPARE(argMods.count(), 1);
+ ArgumentModification argMod = argMods.first();
+ QCOMPARE(argMod.replacedDefaultExpression, QLatin1String("A()"));
+
+ const AbstractMetaFunction* func = builder->globalFunctions().first();
+ QVERIFY(func);
+ QCOMPARE(func->arguments().count(), 1);
+ const AbstractMetaArgument* arg = func->arguments().first();
+ QCOMPARE(arg->type()->cppSignature(), QLatin1String("A *"));
+ QCOMPARE(arg->originalDefaultValueExpression(), QLatin1String("0"));
+ QCOMPARE(arg->defaultValueExpression(), QLatin1String("A()"));
+}
+
+QTEST_APPLESS_MAIN(TestModifyFunction)
diff --git a/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.h b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.h
new file mode 100644
index 000000000..fcaa0f9db
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTABSTRACTMETACLASS_H
+#define TESTABSTRACTMETACLASS_H
+
+#include <QObject>
+
+class TestModifyFunction : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testOwnershipTransfer();
+ void testWithApiVersion();
+ void testRenameArgument();
+ void invalidateAfterUse();
+ void testGlobalFunctionModification();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testmultipleinheritance.cpp b/sources/shiboken2/ApiExtractor/tests/testmultipleinheritance.cpp
new file mode 100644
index 000000000..67c9089ce
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testmultipleinheritance.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testmultipleinheritance.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestMultipleInheritance::testVirtualClass()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ virtual ~A();\n\
+ virtual void theBug();\n\
+ };\n\
+ struct B {\n\
+ virtual ~B();\n\
+ };\n\
+ struct C : A, B {\n\
+ };\n\
+ struct D : C {\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <object-type name='A' />\n\
+ <object-type name='B' />\n\
+ <object-type name='C' />\n\
+ <object-type name='D' />\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 4);
+
+ const AbstractMetaClass *classD = AbstractMetaClass::findClass(classes, QLatin1String("D"));
+ bool functionFound = false;
+ foreach (AbstractMetaFunction* f, classD->functions()) {
+ if (f->name() == QLatin1String("theBug")) {
+ functionFound = true;
+ break;
+ }
+ }
+ QVERIFY(functionFound);
+
+}
+
+QTEST_APPLESS_MAIN(TestMultipleInheritance)
diff --git a/sources/shiboken2/ApiExtractor/tests/testmultipleinheritance.h b/sources/shiboken2/ApiExtractor/tests/testmultipleinheritance.h
new file mode 100644
index 000000000..2313073bb
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testmultipleinheritance.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTMULTIPLEINHERITANCE_H
+#define TESTMULTIPLEINHERITANCE_H
+
+#include <QObject>
+
+class AbstractMetaBuilder;
+
+class TestMultipleInheritance : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testVirtualClass();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testnamespace.cpp b/sources/shiboken2/ApiExtractor/tests/testnamespace.cpp
new file mode 100644
index 000000000..ca6ce0589
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testnamespace.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testnamespace.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void NamespaceTest::testNamespaceMembers()
+{
+ const char* cppCode = "\
+ namespace Namespace\n\
+ {\n\
+ enum Option {\n\
+ OpZero,\n\
+ OpOne\n\
+ };\n\
+ void foo(Option opt);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <namespace-type name='Namespace'>\n\
+ <enum-type name='Option' />\n\
+ </namespace-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ AbstractMetaClass *ns = AbstractMetaClass::findClass(classes, QLatin1String("Namespace"));
+ QVERIFY(ns);
+ const AbstractMetaEnum* metaEnum = ns->findEnum(QLatin1String("Option"));
+ QVERIFY(metaEnum);
+ const AbstractMetaFunction* func = ns->findFunction(QLatin1String("foo"));
+ QVERIFY(func);
+}
+
+void NamespaceTest::testNamespaceInnerClassMembers()
+{
+ const char* cppCode = "\
+ namespace OuterNamespace\n\
+ {\n\
+ namespace InnerNamespace {\n\
+ struct SomeClass {\n\
+ void method();\n\
+ };\n\
+ };\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <namespace-type name='OuterNamespace'>\n\
+ <namespace-type name='InnerNamespace'>\n\
+ <value-type name='SomeClass'/>\n\
+ </namespace-type>\n\
+ </namespace-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *ons = AbstractMetaClass::findClass(classes, QLatin1String("OuterNamespace"));
+ QVERIFY(ons);
+ const AbstractMetaClass *ins = AbstractMetaClass::findClass(classes, QLatin1String("OuterNamespace::InnerNamespace"));
+ QVERIFY(ins);
+ const AbstractMetaClass *sc = AbstractMetaClass::findClass(classes, QLatin1String("OuterNamespace::InnerNamespace::SomeClass"));
+ QVERIFY(sc);
+ const AbstractMetaFunction* meth = sc->findFunction(QLatin1String("method"));
+ QVERIFY(meth);
+}
+
+QTEST_APPLESS_MAIN(NamespaceTest)
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testnamespace.h b/sources/shiboken2/ApiExtractor/tests/testnamespace.h
new file mode 100644
index 000000000..d4451a938
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testnamespace.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTNAMESPACE_H
+#define TESTNAMESPACE_H
+
+#include <QObject>
+
+// The class is named 'NamespaceTest' to avoid clashes with Qt COIN using
+// '-qtnamespace TestNamespace'.
+class NamespaceTest : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testNamespaceMembers();
+ void testNamespaceInnerClassMembers();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testnestedtypes.cpp b/sources/shiboken2/ApiExtractor/tests/testnestedtypes.cpp
new file mode 100644
index 000000000..296aa4385
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testnestedtypes.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testnestedtypes.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestNestedTypes::testNestedTypesModifications()
+{
+ const char* cppCode ="\
+ namespace OuterNamespace {\n\
+ namespace InnerNamespace {\n\
+ struct SomeClass {\n\
+ void method() {}\n\
+ };\n\
+ };\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <namespace-type name='OuterNamespace'>\n\
+ <namespace-type name='InnerNamespace'>\n\
+ <inject-code class='native'>custom_code1();</inject-code>\n\
+ <add-function signature='method()' return-type='OuterNamespace::InnerNamespace::SomeClass'>\n\
+ <inject-code class='target'>custom_code2();</inject-code>\n\
+ </add-function>\n\
+ <object-type name='SomeClass' target-lang-name='RenamedSomeClass'>\n\
+ <modify-function signature='method()' remove='all'/>\n\
+ </object-type>\n\
+ </namespace-type>\n\
+ </namespace-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+
+ const AbstractMetaClass *ons = AbstractMetaClass::findClass(classes, QLatin1String("OuterNamespace"));
+ QVERIFY(ons);
+
+ const AbstractMetaClass *ins = AbstractMetaClass::findClass(classes, QLatin1String("OuterNamespace::InnerNamespace"));
+ QVERIFY(ins);
+ QCOMPARE(ins->functions().count(), 1);
+ QCOMPARE(ins->typeEntry()->codeSnips().count(), 1);
+ CodeSnip snip = ins->typeEntry()->codeSnips().first();
+ QCOMPARE(snip.code(), QLatin1String("custom_code1();"));
+
+ AbstractMetaFunction* addedFunc = ins->functions().first();
+ QVERIFY(addedFunc->isUserAdded());
+ QCOMPARE(addedFunc->visibility(), AbstractMetaFunction::Public);
+ QCOMPARE(addedFunc->functionType(), AbstractMetaFunction::NormalFunction);
+ QCOMPARE(addedFunc->type()->minimalSignature(), QLatin1String("OuterNamespace::InnerNamespace::SomeClass"));
+
+ QCOMPARE(addedFunc->modifications().size(), 1);
+ QVERIFY(addedFunc->modifications().first().isCodeInjection());
+ snip = addedFunc->modifications().first().snips.first();
+ QCOMPARE(snip.code(), QLatin1String("custom_code2();"));
+
+ const AbstractMetaClass *sc = AbstractMetaClass::findClass(classes, QLatin1String("OuterNamespace::InnerNamespace::SomeClass"));
+ QVERIFY(ins);
+ QCOMPARE(sc->functions().count(), 2); // default constructor and removed method
+ AbstractMetaFunction* removedFunc = sc->functions().last();
+ QVERIFY(removedFunc->isModifiedRemoved());
+}
+
+
+void TestNestedTypes::testDuplicationOfNestedTypes()
+{
+ const char* cppCode ="\
+ namespace Namespace {\n\
+ class SomeClass {};\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <namespace-type name='Namespace'>\n\
+ <value-type name='SomeClass'>\n\
+ <add-function signature='createSomeClass(Namespace::SomeClass)'/>\n\
+ </value-type>\n\
+ </namespace-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 2);
+ const AbstractMetaClass *nspace = AbstractMetaClass::findClass(classes, QLatin1String("Namespace"));
+ QVERIFY(nspace);
+ const AbstractMetaClass *cls1 = AbstractMetaClass::findClass(classes, QLatin1String("SomeClass"));
+ QVERIFY(cls1);
+ const AbstractMetaClass *cls2 = AbstractMetaClass::findClass(classes, QLatin1String("Namespace::SomeClass"));
+ QVERIFY(cls2);
+ QCOMPARE(cls1, cls2);
+ QCOMPARE(cls1->name(), QLatin1String("SomeClass"));
+ QCOMPARE(cls1->qualifiedCppName(), QLatin1String("Namespace::SomeClass"));
+
+ TypeEntry* t1 = TypeDatabase::instance()->findType(QLatin1String("Namespace::SomeClass"));
+ QVERIFY(t1);
+ TypeEntry* t2 = TypeDatabase::instance()->findType(QLatin1String("SomeClass"));
+ QVERIFY(!t2);
+}
+
+QTEST_APPLESS_MAIN(TestNestedTypes)
diff --git a/sources/shiboken2/ApiExtractor/tests/testnestedtypes.h b/sources/shiboken2/ApiExtractor/tests/testnestedtypes.h
new file mode 100644
index 000000000..737e81fab
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testnestedtypes.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTNESTEDTYPES_H
+#define TESTNESTEDTYPES_H
+#include <QObject>
+
+class TestNestedTypes : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testNestedTypesModifications();
+ void testDuplicationOfNestedTypes();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.cpp b/sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.cpp
new file mode 100644
index 000000000..3491d5cb4
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testnumericaltypedef.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestNumericalTypedef::testNumericalTypedef()
+{
+ const char* cppCode ="\
+ typedef double real;\n\
+ void funcDouble(double);\n\
+ void funcReal(real);\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='double'/>\n\
+ <primitive-type name='real'/>\n\
+ <function signature='funcDouble(double)'/>\n\
+ <function signature='funcReal(real)'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ QCOMPARE(builder->globalFunctions().size(), 2);
+ const AbstractMetaFunction* funcDouble = builder->globalFunctions().first();
+ QVERIFY(funcDouble);
+ const AbstractMetaFunction* funcReal = builder->globalFunctions().last();
+ QVERIFY(funcReal);
+
+ if (funcDouble->name() == QLatin1String("funcReal"))
+ std::swap(funcDouble, funcReal);
+
+ QCOMPARE(funcDouble->minimalSignature(), QLatin1String("funcDouble(double)"));
+ QCOMPARE(funcReal->minimalSignature(), QLatin1String("funcReal(real)"));
+
+ const AbstractMetaType* doubleType = funcDouble->arguments().first()->type();
+ QVERIFY(doubleType);
+ QCOMPARE(doubleType->cppSignature(), QLatin1String("double"));
+ QVERIFY(doubleType->isPrimitive());
+ QVERIFY(doubleType->typeEntry()->isCppPrimitive());
+
+ const AbstractMetaType* realType = funcReal->arguments().first()->type();
+ QVERIFY(realType);
+ QCOMPARE(realType->cppSignature(), QLatin1String("real"));
+ QVERIFY(realType->isPrimitive());
+ QVERIFY(realType->typeEntry()->isCppPrimitive());
+}
+
+void TestNumericalTypedef::testUnsignedNumericalTypedef()
+{
+ const char* cppCode ="\
+ typedef unsigned short ushort;\n\
+ void funcUnsignedShort(unsigned short);\n\
+ void funcUShort(ushort);\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='short'/>\n\
+ <primitive-type name='unsigned short'/>\n\
+ <primitive-type name='ushort'/>\n\
+ <function signature='funcUnsignedShort(unsigned short)'/>\n\
+ <function signature='funcUShort(ushort)'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ QCOMPARE(builder->globalFunctions().size(), 2);
+ const AbstractMetaFunction* funcUnsignedShort = builder->globalFunctions().first();
+ QVERIFY(funcUnsignedShort);
+ const AbstractMetaFunction* funcUShort = builder->globalFunctions().last();
+ QVERIFY(funcUShort);
+
+ if (funcUnsignedShort->name() == QLatin1String("funcUShort"))
+ std::swap(funcUnsignedShort, funcUShort);
+
+ QCOMPARE(funcUnsignedShort->minimalSignature(), QLatin1String("funcUnsignedShort(unsigned short)"));
+ QCOMPARE(funcUShort->minimalSignature(), QLatin1String("funcUShort(ushort)"));
+
+ const AbstractMetaType* unsignedShortType = funcUnsignedShort->arguments().first()->type();
+ QVERIFY(unsignedShortType);
+ QCOMPARE(unsignedShortType->cppSignature(), QLatin1String("unsigned short"));
+ QVERIFY(unsignedShortType->isPrimitive());
+ QVERIFY(unsignedShortType->typeEntry()->isCppPrimitive());
+
+ const AbstractMetaType* ushortType = funcUShort->arguments().first()->type();
+ QVERIFY(ushortType);
+ QCOMPARE(ushortType->cppSignature(), QLatin1String("ushort"));
+ QVERIFY(ushortType->isPrimitive());
+ QVERIFY(ushortType->typeEntry()->isCppPrimitive());
+}
+
+QTEST_APPLESS_MAIN(TestNumericalTypedef)
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.h b/sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.h
new file mode 100644
index 000000000..e8af1fa8e
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testnumericaltypedef.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTNUMERICALTYPEDEF_H
+#define TESTNUMERICALTYPEDEF_H
+
+#include <QObject>
+
+class TestNumericalTypedef : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testNumericalTypedef();
+ void testUnsignedNumericalTypedef();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testprimitivetypetag.cpp b/sources/shiboken2/ApiExtractor/tests/testprimitivetypetag.cpp
new file mode 100644
index 000000000..7646dd23a
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testprimitivetypetag.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testprimitivetypetag.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestPrimitiveTypeTag::testPrimitiveTypeDefaultConstructor()
+{
+ const char* cppCode ="\
+ struct A {};\n\
+ struct B {};\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <primitive-type name='A' default-constructor='A()'/>\n\
+ <object-type name='B'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 1);
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classB);
+
+ PrimitiveTypeEntry* typeEntry = TypeDatabase::instance()->findPrimitiveType(QLatin1String("A"));
+ QVERIFY(typeEntry);
+ QVERIFY(typeEntry->hasDefaultConstructor());
+ QCOMPARE(typeEntry->defaultConstructor(), QLatin1String("A()"));
+}
+
+QTEST_APPLESS_MAIN(TestPrimitiveTypeTag)
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testprimitivetypetag.h b/sources/shiboken2/ApiExtractor/tests/testprimitivetypetag.h
new file mode 100644
index 000000000..ea9276de3
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testprimitivetypetag.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTPRIMITIVETYPETAG_H
+#define TESTPRIMITIVETYPETAG_H
+
+#include <QObject>
+
+class TestPrimitiveTypeTag : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testPrimitiveTypeDefaultConstructor();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testrefcounttag.cpp b/sources/shiboken2/ApiExtractor/tests/testrefcounttag.cpp
new file mode 100644
index 000000000..e9f9f0ab7
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testrefcounttag.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testrefcounttag.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestRefCountTag::testReferenceCountTag()
+{
+ const char* cppCode ="\
+ struct A {};\n\
+ struct B {\n\
+ void keepObject(B* b);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <object-type name='A'/>\n\
+ <object-type name='B'>\n\
+ <modify-function signature='keepObject(B*)'>\n\
+ <modify-argument index='1'>\n\
+ <reference-count action='add'/>\n\
+ </modify-argument>\n\
+ </modify-function>\n\
+ </object-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ const AbstractMetaFunction* func = classB->findFunction(QLatin1String("keepObject"));
+ QVERIFY(func);
+ ReferenceCount refCount = func->modifications().first().argument_mods.first().referenceCounts.first();
+ QCOMPARE(refCount.action, ReferenceCount::Add);
+}
+
+void TestRefCountTag::testWithApiVersion()
+{
+ const char* cppCode ="\
+ struct A {};\n\
+ struct B {\n\
+ void keepObject(B*, B*);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <object-type name='A'/>\n\
+ <object-type name='B'>\n\
+ <modify-function signature='keepObject(B*, B*)'>\n\
+ <modify-argument index='1' since='0.1'>\n\
+ <reference-count action='add'/>\n\
+ </modify-argument>\n\
+ <modify-argument index='2' since='0.2'>\n\
+ <reference-count action='add'/>\n\
+ </modify-argument>\n\
+ </modify-function>\n\
+ </object-type>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false, "0.1"));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ const AbstractMetaFunction* func = classB->findFunction(QLatin1String("keepObject"));
+ QVERIFY(func);
+ ReferenceCount refCount = func->modifications().first().argument_mods.first().referenceCounts.first();
+ QCOMPARE(refCount.action, ReferenceCount::Add);
+
+ QCOMPARE(func->modifications().size(), 1);
+}
+
+
+QTEST_APPLESS_MAIN(TestRefCountTag)
+
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testrefcounttag.h b/sources/shiboken2/ApiExtractor/tests/testrefcounttag.h
new file mode 100644
index 000000000..a95661293
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testrefcounttag.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTREFCOUNTTAG_H
+#define TESTREFCOUNTTAG_H
+
+#include <QObject>
+
+class TestRefCountTag : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testReferenceCountTag();
+ void testWithApiVersion();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testreferencetopointer.cpp b/sources/shiboken2/ApiExtractor/tests/testreferencetopointer.cpp
new file mode 100644
index 000000000..f594cdd25
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testreferencetopointer.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testreferencetopointer.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestReferenceToPointer::testReferenceToPointerArgument()
+{
+ const char* cppCode ="\
+ struct A {};\n\
+ struct B {\n\
+ void dummy(A*&);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <object-type name='A'/>\n\
+ <object-type name='B'/>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classB);
+ const AbstractMetaFunction* func = classB->findFunction(QLatin1String("dummy"));
+ QVERIFY(func);
+ QCOMPARE(func->arguments().first()->type()->minimalSignature(), QLatin1String("A*&"));
+}
+
+QTEST_APPLESS_MAIN(TestReferenceToPointer)
+
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testreferencetopointer.h b/sources/shiboken2/ApiExtractor/tests/testreferencetopointer.h
new file mode 100644
index 000000000..83b0b6fad
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testreferencetopointer.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTREFERENCETOPOINTER_H
+#define TESTREFERENCETOPOINTER_H
+
+#include <QObject>
+
+class TestReferenceToPointer : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testReferenceToPointerArgument();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testremovefield.cpp b/sources/shiboken2/ApiExtractor/tests/testremovefield.cpp
new file mode 100644
index 000000000..7ebe49160
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testremovefield.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testremovefield.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestRemoveField::testRemoveField()
+{
+ const char* cppCode ="\
+ struct A {\n\
+ int fieldA;\n\
+ int fieldB;\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <primitive-type name='int'/>\n\
+ <value-type name='A'>\n\
+ <modify-field name='fieldB' remove='all'/>\n\
+ </value-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->fields().size(), 1);
+ const AbstractMetaField* fieldA = classA->fields().first();
+ QVERIFY(fieldA);
+ QCOMPARE(fieldA->name(), QLatin1String("fieldA"));
+}
+
+QTEST_APPLESS_MAIN(TestRemoveField)
+
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testremovefield.h b/sources/shiboken2/ApiExtractor/tests/testremovefield.h
new file mode 100644
index 000000000..ea103e0cc
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testremovefield.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTREMOVEFIELD_H
+#define TESTREMOVEFIELD_H
+
+#include <QObject>
+
+class TestRemoveField : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testRemoveField();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testremoveimplconv.cpp b/sources/shiboken2/ApiExtractor/tests/testremoveimplconv.cpp
new file mode 100644
index 000000000..a81380873
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testremoveimplconv.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testremoveimplconv.h"
+#include "testutil.h"
+#include <QtTest/QTest>
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+// When a constructor able to trigger implicity conversions is removed
+// it should not appear in the implicity conversion list.
+void TestRemoveImplConv::testRemoveImplConv()
+{
+ const char* cppCode ="\
+ struct A {};\n\
+ struct B {};\n\
+ struct C {\n\
+ C(const A&);\n\
+ C(const B&);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A'/>\n\
+ <value-type name='B'/>\n\
+ <value-type name='C'>\n\
+ <modify-function signature='C(const A&amp;)' remove='all'/>\n\
+ </value-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 3);
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classB);
+ const AbstractMetaClass *classC = AbstractMetaClass::findClass(classes, QLatin1String("C"));
+ QVERIFY(classC);
+ AbstractMetaFunctionList implConv = classC->implicitConversions();
+ QCOMPARE(implConv.count(), 1);
+ QCOMPARE(implConv.first()->arguments().first()->type()->typeEntry(), classB->typeEntry());
+}
+
+QTEST_APPLESS_MAIN(TestRemoveImplConv)
diff --git a/sources/shiboken2/ApiExtractor/tests/testremoveimplconv.h b/sources/shiboken2/ApiExtractor/tests/testremoveimplconv.h
new file mode 100644
index 000000000..62d5f74e6
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testremoveimplconv.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTREMOVEIMPLCONV_H
+#define TESTREMOVEIMPLCONV_H
+
+#include <QObject>
+
+class TestRemoveImplConv : public QObject
+{
+Q_OBJECT
+private slots:
+ void testRemoveImplConv();
+};
+
+#endif // TESTREMOVEIMPLCONV_H
diff --git a/sources/shiboken2/ApiExtractor/tests/testremoveoperatormethod.cpp b/sources/shiboken2/ApiExtractor/tests/testremoveoperatormethod.cpp
new file mode 100644
index 000000000..6b27227d6
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testremoveoperatormethod.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testremoveoperatormethod.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestRemoveOperatorMethod::testRemoveOperatorMethod()
+{
+ const char* cppCode ="\
+ #include <stdint.h>\n\
+ \n\
+ struct Char {};\n\
+ struct ByteArray {};\n\
+ struct String {};\n\
+ \n\
+ struct A {\n\
+ A& operator>>(char&);\n\
+ A& operator>>(char*);\n\
+ A& operator>>(short&);\n\
+ A& operator>>(unsigned short&);\n\
+ A& operator>>(int&);\n\
+ A& operator>>(unsigned int&);\n\
+ A& operator>>(int64_t&);\n\
+ A& operator>>(uint64_t&);\n\
+ A& operator>>(float&);\n\
+ A& operator>>(double&);\n\
+ A& operator>>(Char&);\n\
+ A& operator>>(ByteArray&);\n\
+ A& operator>>(String&);\n\
+ };\n";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='char'/>\n\
+ <primitive-type name='short'/>\n\
+ <primitive-type name='unsigned short'/>\n\
+ <primitive-type name='int'/>\n\
+ <primitive-type name='unsigned int'/>\n\
+ <primitive-type name='int64_t'/>\n\
+ <primitive-type name='uint64_t'/>\n\
+ <primitive-type name='float'/>\n\
+ <primitive-type name='double'/>\n\
+ <primitive-type name='Char'/>\n\
+ <primitive-type name='String'/>\n\
+ <value-type name='ByteArray'/>\n\
+ <object-type name='A'>\n\
+ <modify-function signature='operator&gt;&gt;(char&amp;)' remove='all'/>\n\
+ <modify-function signature='operator&gt;&gt;(char*)' remove='all'/>\n\
+ <modify-function signature='operator&gt;&gt;(short&amp;)' remove='all'/>\n\
+ <modify-function signature='operator&gt;&gt;(unsigned short&amp;)' remove='all'/>\n\
+ <modify-function signature='operator&gt;&gt;(int&amp;)' remove='all'/>\n\
+ <modify-function signature='operator&gt;&gt;(unsigned int&amp;)' remove='all'/>\n\
+ <modify-function signature='operator&gt;&gt;(int64_t&amp;)' remove='all'/>\n\
+ <modify-function signature='operator&gt;&gt;(uint64_t&amp;)' remove='all'/>\n\
+ <modify-function signature='operator&gt;&gt;(float&amp;)' remove='all'/>\n\
+ <modify-function signature='operator&gt;&gt;(double&amp;)' remove='all'/>\n\
+ <modify-function signature='operator&gt;&gt;(Char&amp;)' remove='all'/>\n\
+ <modify-function signature='operator&gt;&gt;(String&amp;)' remove='all'/>\n\
+ </object-type>\n\
+ </typesystem>\n";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->functions().size(), 14);
+ QStringList removedSignatures;
+ removedSignatures.append(QLatin1String("operator>>(char&)"));
+ removedSignatures.append(QLatin1String("operator>>(char*)"));
+ removedSignatures.append(QLatin1String("operator>>(short&)"));
+ removedSignatures.append(QLatin1String("operator>>(unsigned short&)"));
+ removedSignatures.append(QLatin1String("operator>>(int&)"));
+ removedSignatures.append(QLatin1String("operator>>(unsigned int&)"));
+ removedSignatures.append(QLatin1String("operator>>(int64_t&)"));
+ removedSignatures.append(QLatin1String("operator>>(uint64_t&)"));
+ removedSignatures.append(QLatin1String("operator>>(float&)"));
+ removedSignatures.append(QLatin1String("operator>>(double&)"));
+ removedSignatures.append(QLatin1String("operator>>(Char&)"));
+ removedSignatures.append(QLatin1String("operator>>(String&)"));
+ int notRemoved = classA->functions().size();
+ foreach (const AbstractMetaFunction* f, classA->functions()) {
+ QCOMPARE(f->isModifiedRemoved(), bool(removedSignatures.contains(f->minimalSignature())));
+ notRemoved -= int(f->isModifiedRemoved());
+ }
+ QCOMPARE(notRemoved, 2);
+}
+
+QTEST_APPLESS_MAIN(TestRemoveOperatorMethod)
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testremoveoperatormethod.h b/sources/shiboken2/ApiExtractor/tests/testremoveoperatormethod.h
new file mode 100644
index 000000000..17ff75d74
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testremoveoperatormethod.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTREMOVEOPERATORMETHOD_H
+#define TESTREMOVEOPERATORMETHOD_H
+
+#include <QObject>
+
+class TestRemoveOperatorMethod : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testRemoveOperatorMethod();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testresolvetype.cpp b/sources/shiboken2/ApiExtractor/tests/testresolvetype.cpp
new file mode 100644
index 000000000..69691e860
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testresolvetype.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testresolvetype.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestResolveType::testResolveReturnTypeFromParentScope()
+{
+ const char* cppCode = "\n\
+ namespace A {\n\
+ struct B {\n\
+ struct C {};\n\
+ };\n\
+ struct D : public B::C {\n\
+ C* foo = 0;\n\
+ C* method();\n\
+ };\n\
+ };";
+ const char* xmlCode = "\n\
+ <typesystem package='Foo'>\n\
+ <namespace-type name='A'/>\n\
+ <value-type name='A::B'/>\n\
+ <value-type name='A::B::C'/>\n\
+ <value-type name='A::D'/>\n\
+ </typesystem>";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classD = AbstractMetaClass::findClass(classes, QLatin1String("A::D"));
+ QVERIFY(classD);
+ const AbstractMetaFunction* meth = classD->findFunction(QLatin1String("method"));
+ QVERIFY(meth);
+}
+
+QTEST_APPLESS_MAIN(TestResolveType)
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testresolvetype.h b/sources/shiboken2/ApiExtractor/tests/testresolvetype.h
new file mode 100644
index 000000000..6164d0074
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testresolvetype.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTRESOLVETYPE_H
+#define TESTRESOLVETYPE_H
+
+#include <QObject>
+
+class TestResolveType : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testResolveReturnTypeFromParentScope();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testreverseoperators.cpp b/sources/shiboken2/ApiExtractor/tests/testreverseoperators.cpp
new file mode 100644
index 000000000..76ba7d3b4
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testreverseoperators.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testreverseoperators.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestReverseOperators::testReverseSum()
+{
+ const char cppCode[] = "struct A {\n\
+ A& operator+(int);\n\
+ };\n\
+ A& operator+(int, const A&);";
+ const char xmlCode[] = "\n\
+ <typesystem package=\"Foo\">\n\
+ <primitive-type name='int' />\n\
+ <value-type name='A' />\n\
+ </typesystem>";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->functions().count(), 4);
+
+ const AbstractMetaFunction* reverseOp = 0;
+ const AbstractMetaFunction* normalOp = 0;
+ foreach(const AbstractMetaFunction* func, classA->functions()) {
+ if (func->name() == QLatin1String("operator+")) {
+ if (func->isReverseOperator())
+ reverseOp = func;
+ else
+ normalOp = func;
+ }
+ }
+
+ QVERIFY(normalOp);
+ QVERIFY(!normalOp->isReverseOperator());
+ QCOMPARE(normalOp->arguments().count(), 1);
+ QVERIFY(reverseOp);
+ QVERIFY(reverseOp->isReverseOperator());
+ QCOMPARE(reverseOp->arguments().count(), 1);
+}
+
+void TestReverseOperators::testReverseSumWithAmbiguity()
+{
+ const char cppCode[] = "\n\
+ struct A { A operator+(int); };\n\
+ A operator+(int, const A&);\n\
+ struct B {};\n\
+ B operator+(const A&, const B&);\n\
+ B operator+(const B&, const A&);\n\
+ int operator-(int, const A*);\n\
+ int operator/(const A*, int);\n\
+ ";
+ const char xmlCode[] = "\n\
+ <typesystem package=\"Foo\">\n\
+ <primitive-type name='int' />\n\
+ <value-type name='A' />\n\
+ <value-type name='B' />\n\
+ </typesystem>";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QCOMPARE(classA->functions().count(), 6);
+
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classB);
+ QCOMPARE(classB->functions().count(), 4);
+
+ const AbstractMetaFunction* reverseOp = 0;
+ const AbstractMetaFunction* normalOp = 0;
+ foreach(const AbstractMetaFunction* func, classB->functions()) {
+ if (func->name() == QLatin1String("operator+")) {
+ if (func->isReverseOperator())
+ reverseOp = func;
+ else
+ normalOp = func;
+ }
+ }
+ QVERIFY(normalOp);
+ QVERIFY(!normalOp->isReverseOperator());
+ QCOMPARE(normalOp->arguments().count(), 1);
+ QCOMPARE(normalOp->minimalSignature(), QLatin1String("operator+(B,A)"));
+ QVERIFY(reverseOp);
+ QVERIFY(reverseOp->isReverseOperator());
+ QCOMPARE(reverseOp->arguments().count(), 1);
+ QCOMPARE(reverseOp->minimalSignature(), QLatin1String("operator+(A,B)"));
+
+ reverseOp = classA->findFunction(QLatin1String("operator-"));
+ QVERIFY(reverseOp);
+ QCOMPARE(reverseOp->arguments().count(), 1);
+ QVERIFY(reverseOp->isPointerOperator());
+ QVERIFY(reverseOp->isReverseOperator());
+
+ normalOp = classA->findFunction(QLatin1String("operator/"));
+ QVERIFY(normalOp);
+ QCOMPARE(normalOp->arguments().count(), 1);
+ QVERIFY(normalOp->isPointerOperator());
+ QVERIFY(!normalOp->isReverseOperator());
+
+}
+
+
+
+QTEST_APPLESS_MAIN(TestReverseOperators)
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testreverseoperators.h b/sources/shiboken2/ApiExtractor/tests/testreverseoperators.h
new file mode 100644
index 000000000..3bd65fb85
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testreverseoperators.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTREVERSEOPERATORS_H
+#define TESTREVERSEOPERATORS_H
+#include <QObject>
+
+class TestReverseOperators : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testReverseSum();
+ void testReverseSumWithAmbiguity();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testtemplates.cpp b/sources/shiboken2/ApiExtractor/tests/testtemplates.cpp
new file mode 100644
index 000000000..cb90383db
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testtemplates.cpp
@@ -0,0 +1,438 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtemplates.h"
+#include <QtTest/QTest>
+#include <QTemporaryFile>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestTemplates::testTemplateWithNamespace()
+{
+ const char cppCode[] = "\n\
+ template<typename T> struct QList {}; \n\
+ struct Url {\n\
+ void name();\n\
+ };\n\
+ namespace Internet {\n\
+ struct Url{};\n\
+ struct Bookmarks {\n\
+ QList<Url> list();\n\
+ };\n\
+ }";
+ const char xmlCode0[] = "\n\
+ <typesystem package='Pakcage.Network'>\n\
+ <value-type name='Url'/>\n\
+ </typesystem>";
+
+ QTemporaryFile file;
+ QVERIFY(file.open());
+ file.write(xmlCode0);
+ file.close();
+
+ QString xmlCode1 = QString::fromLatin1("\n\
+ <typesystem package='Package.Internet'>\n\
+ <load-typesystem name='%1' generate='no'/>\n\
+ <container-type name='QList' type='list'/>\n\
+ <namespace-type name='Internet' generate='no'/>\n\
+ <value-type name='Internet::Url'/>\n\
+ <value-type name='Internet::Bookmarks'/>\n\
+ </typesystem>").arg(file.fileName());
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, qPrintable(xmlCode1), false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+
+ AbstractMetaClass* classB = AbstractMetaClass::findClass(classes, QLatin1String("Bookmarks"));
+ QVERIFY(classB);
+ const AbstractMetaFunction* func = classB->findFunction(QLatin1String("list"));
+ AbstractMetaType* funcType = func->type();
+ QVERIFY(funcType);
+ QCOMPARE(funcType->cppSignature(), QLatin1String("QList<Internet::Url >"));
+}
+
+void TestTemplates::testTemplateOnContainers()
+{
+ const char cppCode[] = "\n\
+ struct Base {};\n\
+ template<typename T> struct QList {}; \n\
+ namespace Namespace {\n\
+ enum SomeEnum { E1, E2 };\n\
+ template<SomeEnum type> struct A {\n\
+ A<type> foo(const QList<A<type> >& a);\n\
+ };\n\
+ typedef A<E1> B;\n\
+ }\n\
+ ";
+ const char xmlCode[] = "\n\
+ <typesystem package=\"Package\">\n\
+ <container-type name='QList' type='list'/>\n\
+ <namespace-type name='Namespace'/>\n\
+ <enum-type name='Namespace::SomeEnum'/>\n\
+ <object-type name='Base'/>\n\
+ <object-type name='Namespace::A' generate='no'/>\n\
+ <object-type name='Namespace::B'/>\n\
+ </typesystem>";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+
+ AbstractMetaClass* classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classB);
+ QVERIFY(!classB->baseClass());
+ QVERIFY(classB->baseClassName().isNull());
+ const AbstractMetaFunction* func = classB->findFunction(QLatin1String("foo"));
+ AbstractMetaType* argType = func->arguments().first()->type();
+ QCOMPARE(argType->instantiations().count(), 1);
+ QCOMPARE(argType->typeEntry()->qualifiedCppName(), QLatin1String("QList"));
+
+ const AbstractMetaType* instance1 = argType->instantiations().first();
+ QCOMPARE(instance1->instantiations().count(), 1);
+ QCOMPARE(instance1->typeEntry()->qualifiedCppName(), QLatin1String("Namespace::A"));
+
+ const AbstractMetaType* instance2 = instance1->instantiations().first();
+ QCOMPARE(instance2->instantiations().count(), 0);
+ QCOMPARE(instance2->typeEntry()->qualifiedCppName(), QLatin1String("Namespace::E1"));
+}
+
+void TestTemplates::testTemplateValueAsArgument()
+{
+ const char cppCode[] = "\n\
+ template<typename T> struct List {};\n\
+ void func(List<int> arg) {}\n\
+ ";
+
+ const char xmlCode[] = "\n\
+ <typesystem package='Package'>\n\
+ <primitive-type name='int'/>\n\
+ <container-type name='List' type='list'/>\n\
+ <function signature='func(List&lt;int&gt;)'/>\n\
+ </typesystem>\n\
+ ";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaFunctionList globalFuncs = builder->globalFunctions();
+ QCOMPARE(globalFuncs.count(), 1);
+
+ AbstractMetaFunction* func = globalFuncs.first();
+ QCOMPARE(func->minimalSignature(), QLatin1String("func(List<int>)"));
+ QCOMPARE(func->arguments().first()->type()->cppSignature(), QLatin1String("List<int >"));
+}
+
+void TestTemplates::testTemplatePointerAsArgument()
+{
+ const char cppCode[] = "\n\
+ template<typename T> struct List {};\n\
+ void func(List<int>* arg) {}\n\
+ ";
+
+ const char xmlCode[] = "\n\
+ <typesystem package='Package'>\n\
+ <primitive-type name='int'/>\n\
+ <container-type name='List' type='list'/>\n\
+ <function signature='func(List&lt;int&gt;*)'/>\n\
+ </typesystem>\n\
+ ";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaFunctionList globalFuncs = builder->globalFunctions();
+ QCOMPARE(globalFuncs.count(), 1);
+
+ AbstractMetaFunction* func = globalFuncs.first();
+ QCOMPARE(func->minimalSignature(), QLatin1String("func(List<int>*)"));
+ QCOMPARE(func->arguments().first()->type()->cppSignature(), QLatin1String("List<int > *"));
+}
+
+void TestTemplates::testTemplateReferenceAsArgument()
+{
+ const char cppCode[] = "\n\
+ template<typename T> struct List {};\n\
+ void func(List<int>& arg) {}\n\
+ ";
+
+ const char xmlCode[] = "\n\
+ <typesystem package='Package'>\n\
+ <primitive-type name='int'/>\n\
+ <container-type name='List' type='list'/>\n\
+ <function signature='func(List&lt;int&gt;&amp;)'/>\n\
+ </typesystem>\n\
+ ";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaFunctionList globalFuncs = builder->globalFunctions();
+ QCOMPARE(globalFuncs.count(), 1);
+
+ AbstractMetaFunction* func = globalFuncs.first();
+ QCOMPARE(func->minimalSignature(), QLatin1String("func(List<int>&)"));
+ QCOMPARE(func->arguments().first()->type()->cppSignature(), QLatin1String("List<int > &"));
+}
+
+void TestTemplates::testTemplateParameterFixup()
+{
+ const char cppCode[] = "\n\
+ template<typename T>\n\
+ struct List {\n\
+ struct Iterator {};\n\
+ void append(List l);\n\
+ void erase(List::Iterator it);\n\
+ };\n";
+
+ const char xmlCode[] = "\n\
+ <typesystem package='Package'>\n\
+ <container-type name='List' type='list'/>\n\
+ <value-type name='List::Iterator'/>\n\
+ </typesystem>\n";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ const AbstractMetaClassList templates = builder->templates();
+
+ QCOMPARE(templates.count(), 1);
+ const AbstractMetaClass *list = templates.first();
+ // Verify that the parameter of "void append(List l)" gets fixed to "List<T >"
+ const AbstractMetaFunction *append = list->findFunction(QStringLiteral("append"));
+ QVERIFY(append);
+ QCOMPARE(append->arguments().size(), 1);
+ QCOMPARE(append->arguments().at(0)->type()->cppSignature(), QLatin1String("List<T >"));
+ // Verify that the parameter of "void erase(Iterator)" is not modified
+ const AbstractMetaFunction *erase = list->findFunction(QStringLiteral("erase"));
+ QVERIFY(erase);
+ QCOMPARE(erase->arguments().size(), 1);
+ QCOMPARE(erase->arguments().at(0)->type()->cppSignature(), QLatin1String("List::Iterator"));
+}
+
+void TestTemplates::testInheritanceFromContainterTemplate()
+{
+ const char cppCode[] = "\n\
+ template<typename T>\n\
+ struct ListContainer {\n\
+ inline void push_front(const T& t);\n\
+ inline T& front();\n\
+ };\n\
+ struct FooBar {};\n\
+ struct FooBars : public ListContainer<FooBar> {};\n\
+ ";
+
+ const char xmlCode[] = "\n\
+ <typesystem package='Package'>\n\
+ <container-type name='ListContainer' type='list'/>\n\
+ <value-type name='FooBar'/>\n\
+ <value-type name='FooBars'>\n\
+ <modify-function signature='push_front(FooBar)' remove='all'/>\n\
+ <modify-function signature='front()' remove='all'/>\n\
+ </value-type>\n\
+ </typesystem>\n\
+ ";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ AbstractMetaClassList templates = builder->templates();
+ QCOMPARE(classes.count(), 2);
+ QCOMPARE(templates.count(), 1);
+
+ const AbstractMetaClass* foobars = AbstractMetaClass::findClass(classes, QLatin1String("FooBars"));
+ QCOMPARE(foobars->functions().count(), 4);
+
+ const AbstractMetaClass* lc = templates.first();
+ QCOMPARE(lc->functions().count(), 2);
+}
+
+void TestTemplates::testTemplateInheritanceMixedWithForwardDeclaration()
+{
+ const char cppCode[] = "\n\
+ enum SomeEnum { E1, E2 };\n\
+ template<SomeEnum type> struct Future;\n\
+ template<SomeEnum type>\n\
+ struct A {\n\
+ A();\n\
+ void method();\n\
+ friend struct Future<type>;\n\
+ };\n\
+ typedef A<E1> B;\n\
+ template<SomeEnum type> struct Future {};\n\
+ ";
+ const char xmlCode[] = "\n\
+ <typesystem package='Package'>\n\
+ <enum-type name='SomeEnum'/>\n\
+ <value-type name='A' generate='no'/>\n\
+ <value-type name='B'/>\n\
+ <value-type name='Future' generate='no'/>\n\
+ </typesystem>";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+
+ AbstractMetaClass* classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classB);
+ QVERIFY(!classB->baseClass());
+ QVERIFY(classB->baseClassName().isNull());
+ // 3 functions: simple constructor, copy constructor and "method()".
+ QCOMPARE(classB->functions().count(), 3);
+}
+
+void TestTemplates::testTemplateInheritanceMixedWithNamespaceAndForwardDeclaration()
+{
+ const char cppCode[] = "\n\
+ namespace Namespace {\n\
+ enum SomeEnum { E1, E2 };\n\
+ template<SomeEnum type> struct Future;\n\
+ template<SomeEnum type>\n\
+ struct A {\n\
+ A();\n\
+ void method();\n\
+ friend struct Future<type>;\n\
+ };\n\
+ typedef A<E1> B;\n\
+ template<SomeEnum type> struct Future {};\n\
+ };\n\
+ ";
+ const char xmlCode[] = "\n\
+ <typesystem package='Package'>\n\
+ <namespace-type name='Namespace'/>\n\
+ <enum-type name='Namespace::SomeEnum'/>\n\
+ <value-type name='Namespace::A' generate='no'/>\n\
+ <value-type name='Namespace::B'/>\n\
+ <value-type name='Namespace::Future' generate='no'/>\n\
+ </typesystem>";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+
+ AbstractMetaClass* classB = AbstractMetaClass::findClass(classes, QLatin1String("Namespace::B"));
+ QVERIFY(classB);
+ QVERIFY(!classB->baseClass());
+ QVERIFY(classB->baseClassName().isNull());
+ // 3 functions: simple constructor, copy constructor and "method()".
+ QCOMPARE(classB->functions().count(), 3);
+}
+
+void TestTemplates::testTypedefOfInstantiationOfTemplateClass()
+{
+ const char cppCode[] = "\n\
+ namespace NSpace {\n\
+ enum ClassType {\n\
+ TypeOne\n\
+ };\n\
+ template<ClassType CLASS_TYPE>\n\
+ struct BaseTemplateClass {\n\
+ inline ClassType getClassType() const { CLASS_TYPE; }\n\
+ };\n\
+ typedef BaseTemplateClass<TypeOne> TypeOneClass;\n\
+ }\n\
+ ";
+
+ const char xmlCode[] = "\n\
+ <typesystem package='Package'>\n\
+ <namespace-type name='NSpace'>\n\
+ <enum-type name='ClassType'/>\n\
+ <object-type name='BaseTemplateClass' generate='no'/>\n\
+ <object-type name='TypeOneClass'/>\n\
+ </namespace-type>\n\
+ </typesystem>\n\
+ ";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 3);
+
+ const AbstractMetaClass* base = AbstractMetaClass::findClass(classes, QLatin1String("BaseTemplateClass"));
+ QVERIFY(base);
+ const AbstractMetaClass* one = AbstractMetaClass::findClass(classes, QLatin1String("TypeOneClass"));
+ QVERIFY(one);
+ QCOMPARE(one->templateBaseClass(), base);
+ QCOMPARE(one->functions().count(), base->functions().count());
+ QVERIFY(one->isTypeDef());
+ const ComplexTypeEntry* oneType = one->typeEntry();
+ const ComplexTypeEntry* baseType = base->typeEntry();
+ QCOMPARE(oneType->baseContainerType(), baseType);
+ QCOMPARE(one->baseClassNames(), QStringList(QLatin1String("BaseTemplateClass<TypeOne>")));
+
+ QVERIFY(one->hasTemplateBaseClassInstantiations());
+ AbstractMetaTypeList instantiations = one->templateBaseClassInstantiations();
+ QCOMPARE(instantiations.count(), 1);
+ const AbstractMetaType* inst = instantiations.first();
+ QVERIFY(inst);
+ QVERIFY(!inst->isEnum());
+ QVERIFY(!inst->typeEntry()->isEnum());
+ QVERIFY(inst->typeEntry()->isEnumValue());
+ QCOMPARE(inst->cppSignature(), QLatin1String("NSpace::TypeOne"));
+}
+
+void TestTemplates::testContainerTypeIncompleteArgument()
+{
+ const char* cppCode ="\n\
+ template<typename T>\n\
+ class Vector {\n\
+ void method(const Vector& vector);\n\
+ Vector otherMethod();\n\
+ };\n\
+ template <typename T>\n\
+ void Vector<T>::method(const Vector<T>& vector) {}\n\
+ template <typename T>\n\
+ Vector<T> Vector<T>::otherMethod() { return Vector<T>(); }\n\
+ typedef Vector<int> IntVector;\n\
+ ";
+ const char* xmlCode = "\n\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int'/>\n\
+ <container-type name='Vector' type='vector'/>\n\
+ <value-type name='IntVector'/>\n\
+ </typesystem>";
+
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, true));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 1);
+
+ AbstractMetaClass* vector = AbstractMetaClass::findClass(classes, QLatin1String("IntVector"));
+ QVERIFY(vector);
+ QVERIFY(vector->typeEntry()->baseContainerType());
+ QCOMPARE(reinterpret_cast<const ContainerTypeEntry*>(vector->typeEntry()->baseContainerType())->type(), ContainerTypeEntry::VectorContainer);
+ QCOMPARE(vector->functions().count(), 4);
+
+ const AbstractMetaFunction* method = vector->findFunction(QLatin1String("method"));
+ QVERIFY(method);
+ QCOMPARE(method->signature(), QLatin1String("method(const Vector<int > & vector)"));
+
+ const AbstractMetaFunction* otherMethod = vector->findFunction(QLatin1String("otherMethod"));
+ QVERIFY(otherMethod);
+ QCOMPARE(otherMethod->signature(), QLatin1String("otherMethod()"));
+ QVERIFY(otherMethod->type());
+ QCOMPARE(otherMethod->type()->cppSignature(), QLatin1String("Vector<int >"));
+}
+
+QTEST_APPLESS_MAIN(TestTemplates)
diff --git a/sources/shiboken2/ApiExtractor/tests/testtemplates.h b/sources/shiboken2/ApiExtractor/tests/testtemplates.h
new file mode 100644
index 000000000..7b0d0f3b3
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testtemplates.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTTEMPLATES_H
+#define TESTTEMPLATES_H
+
+#include <QObject>
+
+class TestTemplates : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testTemplateOnContainers();
+ void testTemplateWithNamespace();
+ void testTemplateValueAsArgument();
+ void testTemplatePointerAsArgument();
+ void testTemplateReferenceAsArgument();
+ void testTemplateParameterFixup();
+ void testInheritanceFromContainterTemplate();
+ void testTemplateInheritanceMixedWithForwardDeclaration();
+ void testTemplateInheritanceMixedWithNamespaceAndForwardDeclaration();
+ void testTypedefOfInstantiationOfTemplateClass();
+ void testContainerTypeIncompleteArgument();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testtoposort.cpp b/sources/shiboken2/ApiExtractor/tests/testtoposort.cpp
new file mode 100644
index 000000000..30d368a8a
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testtoposort.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtoposort.h"
+#include <QtTest/QTest>
+#include "graph.h"
+#include <QDebug>
+
+void TestTopoSort::testTopoSort()
+{
+ QLinkedList<int> result;
+ {
+ Graph g(3);
+ g.addEdge(1, 2);
+ g.addEdge(0, 1);
+ result = g.topologicalSort();
+ QCOMPARE(result.size(), 3);
+ QLinkedList<int>::iterator it = result.begin();
+ QCOMPARE(*it, 0);
+ QCOMPARE(*(++it), 1);
+ QCOMPARE(*(++it), 2);
+ }
+ {
+ Graph g(2);
+ result = g.topologicalSort();
+ QCOMPARE(result.size(), 2);
+ QLinkedList<int>::iterator it = result.begin();
+ QCOMPARE(*it, 1);
+ QCOMPARE(*(++it), 0);
+ }
+}
+
+void TestTopoSort::testCiclicGraph()
+{
+ Graph g(3);
+ g.addEdge(0, 1);
+ g.addEdge(1, 2);
+ g.addEdge(2, 0);
+ QLinkedList<int> result = g.topologicalSort();
+ QVERIFY(result.isEmpty());
+}
+
+QTEST_APPLESS_MAIN(TestTopoSort)
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testtoposort.h b/sources/shiboken2/ApiExtractor/tests/testtoposort.h
new file mode 100644
index 000000000..ae8a2bab8
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testtoposort.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTTOPOSORT_H
+#define TESTTOPOSORT_H
+
+#include <QObject>
+
+class TestTopoSort : public QObject
+{
+Q_OBJECT
+private slots:
+ void testTopoSort();
+ void testCiclicGraph();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testtyperevision.cpp b/sources/shiboken2/ApiExtractor/tests/testtyperevision.cpp
new file mode 100644
index 000000000..804683140
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testtyperevision.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testtyperevision.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestTypeRevision::testRevisionAttr()
+{
+ const char* cppCode = "class Rev_0 {};"
+ "class Rev_1 {};"
+ "class Rev_2 { public: enum Rev_3 { X }; enum Rev_5 { Y }; };";
+ const char* xmlCode = "<typesystem package=\"Foo\">"
+ "<value-type name=\"Rev_0\"/>"
+ "<value-type name=\"Rev_1\" revision=\"1\"/>"
+ "<object-type name=\"Rev_2\" revision=\"2\">"
+ " <enum-type name=\"Rev_3\" revision=\"3\" flags=\"Flag_4\" flags-revision=\"4\" />"
+ " <enum-type name=\"Rev_5\" revision=\"5\" flags=\"Flag_5\" />"
+ "</object-type>"
+ "</typesystem>";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *rev0 = AbstractMetaClass::findClass(classes, QLatin1String("Rev_0"));
+ QCOMPARE(getTypeRevision(rev0->typeEntry()), 0);
+
+ const AbstractMetaClass *rev1 = AbstractMetaClass::findClass(classes, QLatin1String("Rev_1"));
+ QCOMPARE(getTypeRevision(rev1->typeEntry()), 1);
+
+ AbstractMetaClass *rev2 = AbstractMetaClass::findClass(classes, QLatin1String("Rev_2"));
+ QCOMPARE(getTypeRevision(rev2->typeEntry()), 2);
+
+ AbstractMetaEnum* rev3 = rev2->findEnum(QLatin1String("Rev_3"));
+ QCOMPARE(getTypeRevision(rev3->typeEntry()), 3);
+ FlagsTypeEntry* rev4 = rev3->typeEntry()->flags();
+ QCOMPARE(getTypeRevision(rev4), 4);
+ AbstractMetaEnum* rev5 = rev2->findEnum(QLatin1String("Rev_5"));
+ QCOMPARE(getTypeRevision(rev5->typeEntry()), 5);
+ QCOMPARE(getTypeRevision(rev5->typeEntry()->flags()), 5);
+}
+
+QTEST_APPLESS_MAIN(TestTypeRevision)
+
+
diff --git a/sources/shiboken2/ApiExtractor/tests/testtyperevision.h b/sources/shiboken2/ApiExtractor/tests/testtyperevision.h
new file mode 100644
index 000000000..dcb2d8794
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testtyperevision.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTTYPEREVISION_H
+#define TESTTYPEREVISION_H
+
+#include <QObject>
+
+class TestTypeRevision : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testRevisionAttr();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testutil.h b/sources/shiboken2/ApiExtractor/tests/testutil.h
new file mode 100644
index 000000000..d4eb2fdf6
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testutil.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTUTIL_H
+#define TESTUTIL_H
+#include <QtCore/QBuffer>
+#include "abstractmetabuilder.h"
+#include "reporthandler.h"
+#include "typedatabase.h"
+
+namespace TestUtil
+{
+ static AbstractMetaBuilder *parse(const char *cppCode, const char *xmlCode,
+ bool silent = true,
+ const char *apiVersion = Q_NULLPTR,
+ const QStringList &dropTypeEntries = QStringList())
+ {
+ ReportHandler::setSilent(silent);
+ TypeDatabase* td = TypeDatabase::instance(true);
+ if (apiVersion && !td->setApiVersion(QLatin1String("*"), QLatin1String(apiVersion)))
+ return Q_NULLPTR;
+ td->setDropTypeEntries(dropTypeEntries);
+ QBuffer buffer;
+ // parse typesystem
+ buffer.setData(xmlCode);
+ if (!buffer.open(QIODevice::ReadOnly))
+ return Q_NULLPTR;
+ td->parseFile(&buffer);
+ buffer.close();
+ // parse C++ code
+ buffer.setData(cppCode);
+ AbstractMetaBuilder *builder = new AbstractMetaBuilder;
+ if (!builder->build(&buffer)) {
+ delete builder;
+ return Q_NULLPTR;
+ }
+ return builder;
+ }
+} // namespace TestUtil
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testvaluetypedefaultctortag.cpp b/sources/shiboken2/ApiExtractor/tests/testvaluetypedefaultctortag.cpp
new file mode 100644
index 000000000..627255d37
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testvaluetypedefaultctortag.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testvaluetypedefaultctortag.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestValueTypeDefaultCtorTag::testValueTypeDefaultCtorTagArgument()
+{
+ const char* cppCode ="\n\
+ struct A {\n\
+ A(int,int);\n\
+ };\n\
+ struct B {};\n\
+ ";
+ const char* xmlCode = "\n\
+ <typesystem package='Foo'>\n\
+ <primitive-type name='int' />\n\
+ <value-type name='A' default-constructor='A(0, 0)' />\n\
+ <value-type name='B' />\n\
+ </typesystem>";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
+ QVERIFY(!builder.isNull());
+
+ AbstractMetaClassList classes = builder->classes();
+
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ QVERIFY(classA->typeEntry()->hasDefaultConstructor());
+ QCOMPARE(classA->typeEntry()->defaultConstructor(), QLatin1String("A(0, 0)"));
+
+ const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, QLatin1String("B"));
+ QVERIFY(classB);
+ QVERIFY(!classB->typeEntry()->hasDefaultConstructor());
+}
+
+QTEST_APPLESS_MAIN(TestValueTypeDefaultCtorTag)
diff --git a/sources/shiboken2/ApiExtractor/tests/testvaluetypedefaultctortag.h b/sources/shiboken2/ApiExtractor/tests/testvaluetypedefaultctortag.h
new file mode 100644
index 000000000..2d2efe79d
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testvaluetypedefaultctortag.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTVALUETYPEDEFAULTCTORTAG_H
+#define TESTVALUETYPEDEFAULTCTORTAG_H
+
+#include <QObject>
+
+class TestValueTypeDefaultCtorTag : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testValueTypeDefaultCtorTagArgument();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/testvoidarg.cpp b/sources/shiboken2/ApiExtractor/tests/testvoidarg.cpp
new file mode 100644
index 000000000..5f0b47389
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testvoidarg.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testvoidarg.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+#include <abstractmetalang.h>
+#include <typesystem.h>
+
+void TestVoidArg::testVoidParsedFunction()
+{
+ const char cppCode[] = "struct A { void a(void); };";
+ const char xmlCode[] = "\n\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A'/>\n\
+ </typesystem>";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ const AbstractMetaFunction* addedFunc = classA->findFunction(QLatin1String("a"));
+ QCOMPARE(addedFunc->arguments().count(), 0);
+}
+
+void TestVoidArg::testVoidAddedFunction()
+{
+ const char cppCode[] = "struct A { };";
+ const char xmlCode[] = "\n\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A' >\n\
+ <add-function signature=\"a(void)\"/>\n\
+ </value-type>\n\
+ </typesystem>";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ const AbstractMetaFunction* addedFunc = classA->findFunction(QLatin1String("a"));
+ QCOMPARE(addedFunc->arguments().count(), 0);
+
+}
+
+void TestVoidArg::testVoidPointerParsedFunction()
+{
+ const char cppCode[] = "struct A { void a(void*); };";
+ const char xmlCode[] = "\n\
+ <typesystem package=\"Foo\">\n\
+ <value-type name='A' />\n\
+ </typesystem>";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ QVERIFY(classA);
+ const AbstractMetaFunction* addedFunc = classA->findFunction(QLatin1String("a"));
+ QCOMPARE(addedFunc->arguments().count(), 1);
+
+}
+
+QTEST_APPLESS_MAIN(TestVoidArg)
diff --git a/sources/shiboken2/ApiExtractor/tests/testvoidarg.h b/sources/shiboken2/ApiExtractor/tests/testvoidarg.h
new file mode 100644
index 000000000..40d96a4ff
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testvoidarg.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTVOIDARG_H
+#define TESTVOIDARG_H
+#include <QObject>
+
+class TestVoidArg : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testVoidParsedFunction();
+ void testVoidPointerParsedFunction();
+ void testVoidAddedFunction();
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/tests/utf8code.txt b/sources/shiboken2/ApiExtractor/tests/utf8code.txt
new file mode 100644
index 000000000..6d5fa9dcf
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/utf8code.txt
@@ -0,0 +1 @@
+áéíóú \ No newline at end of file
diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp
new file mode 100644
index 000000000..55170d7c1
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp
@@ -0,0 +1,699 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "typedatabase.h"
+#include "typesystem.h"
+#include "typesystem_p.h"
+
+#include <QtCore/QFile>
+#include <QtCore/QDir>
+#include <QtCore/QPair>
+#include <QtCore/QVector>
+#include <QtCore/QRegularExpression>
+#include <QtCore/QVersionNumber>
+#include <QtCore/QXmlStreamReader>
+#include "reporthandler.h"
+// #include <tr1/tuple>
+#include <algorithm>
+
+// package -> api-version
+
+static QString wildcardToRegExp(QString w)
+{
+ w.replace(QLatin1Char('?'), QLatin1Char('.'));
+ w.replace(QLatin1Char('*'), QStringLiteral(".*"));
+ return w;
+}
+
+typedef QPair<QRegularExpression, QVersionNumber> ApiVersion;
+typedef QVector<ApiVersion> ApiVersions;
+
+Q_GLOBAL_STATIC(ApiVersions, apiVersions)
+
+TypeDatabase::TypeDatabase() : m_suppressWarnings(true)
+{
+ addType(new VoidTypeEntry());
+ addType(new VarargsTypeEntry());
+}
+
+TypeDatabase::~TypeDatabase()
+{
+}
+
+TypeDatabase* TypeDatabase::instance(bool newInstance)
+{
+ static TypeDatabase* db = 0;
+ if (!db || newInstance) {
+ if (db)
+ delete db;
+ db = new TypeDatabase;
+ }
+ return db;
+}
+
+// A list of regex/replacements to fix int types like "ushort" to "unsigned short"
+// unless present in TypeDatabase
+struct IntTypeNormalizationEntry
+{
+ QRegularExpression regex;
+ QString replacement;
+};
+
+typedef QVector<IntTypeNormalizationEntry> IntTypeNormalizationEntries;
+
+static const IntTypeNormalizationEntries &intTypeNormalizationEntries()
+{
+ static IntTypeNormalizationEntries result;
+ static bool firstTime = true;
+ if (firstTime) {
+ firstTime = false;
+ static const char *intTypes[] = {"char", "short", "int", "long"};
+ const size_t size = sizeof(intTypes) / sizeof(intTypes[0]);
+ for (size_t i = 0; i < size; ++i) {
+ const QString intType = QLatin1String(intTypes[i]);
+ if (!TypeDatabase::instance()->findType(QLatin1Char('u') + intType)) {
+ IntTypeNormalizationEntry entry;
+ entry.replacement = QStringLiteral("unsigned ") + intType;
+ entry.regex.setPattern(QStringLiteral("\\bu") + intType + QStringLiteral("\\b"));
+ Q_ASSERT(entry.regex.isValid());
+ result.append(entry);
+ }
+ }
+ }
+ return result;
+}
+
+QString TypeDatabase::normalizedSignature(const QString &signature)
+{
+ QString normalized = QLatin1String(QMetaObject::normalizedSignature(signature.toUtf8().constData()));
+
+ if (instance() && signature.contains(QLatin1String("unsigned"))) {
+ const IntTypeNormalizationEntries &entries = intTypeNormalizationEntries();
+ for (int i = 0, size = entries.size(); i < size; ++i)
+ normalized.replace(entries.at(i).regex, entries.at(i).replacement);
+ }
+
+ return normalized;
+}
+
+QStringList TypeDatabase::requiredTargetImports() const
+{
+ return m_requiredTargetImports;
+}
+
+void TypeDatabase::addRequiredTargetImport(const QString& moduleName)
+{
+ if (!m_requiredTargetImports.contains(moduleName))
+ m_requiredTargetImports << moduleName;
+}
+
+void TypeDatabase::addTypesystemPath(const QString& typesystem_paths)
+{
+ #if defined(Q_OS_WIN32)
+ const char path_splitter = ';';
+ #else
+ const char path_splitter = ':';
+ #endif
+ m_typesystemPaths += typesystem_paths.split(QLatin1Char(path_splitter));
+}
+
+IncludeList TypeDatabase::extraIncludes(const QString& className) const
+{
+ ComplexTypeEntry* typeEntry = findComplexType(className);
+ if (typeEntry)
+ return typeEntry->extraIncludes();
+ else
+ return IncludeList();
+}
+
+ContainerTypeEntry* TypeDatabase::findContainerType(const QString &name) const
+{
+ QString template_name = name;
+
+ int pos = name.indexOf(QLatin1Char('<'));
+ if (pos > 0)
+ template_name = name.left(pos);
+
+ TypeEntry* type_entry = findType(template_name);
+ if (type_entry && type_entry->isContainer())
+ return static_cast<ContainerTypeEntry*>(type_entry);
+ return 0;
+}
+
+FunctionTypeEntry* TypeDatabase::findFunctionType(const QString& name) const
+{
+ TypeEntry* entry = findType(name);
+ if (entry && entry->type() == TypeEntry::FunctionType)
+ return static_cast<FunctionTypeEntry*>(entry);
+ return 0;
+}
+
+TypeEntry* TypeDatabase::findType(const QString& name) const
+{
+ QList<TypeEntry *> entries = findTypes(name);
+ foreach (TypeEntry *entry, entries) {
+ if (entry &&
+ (!entry->isPrimitive() || static_cast<PrimitiveTypeEntry *>(entry)->preferredTargetLangType())) {
+ return entry;
+ }
+ }
+ return 0;
+}
+
+QList<TypeEntry *> TypeDatabase::findTypes(const QString &name) const
+{
+ return m_entries.value(name);
+}
+
+SingleTypeEntryHash TypeDatabase::entries() const
+{
+ TypeEntryHash entries = allEntries();
+
+ SingleTypeEntryHash returned;
+ for (TypeEntryHash::const_iterator it = entries.cbegin(), end = entries.cend(); it != end; ++it)
+ returned.insert(it.key(), findType(it.key()));
+
+ return returned;
+}
+
+QList<const PrimitiveTypeEntry*> TypeDatabase::primitiveTypes() const
+{
+ TypeEntryHash entries = allEntries();
+ QList<const PrimitiveTypeEntry*> returned;
+ for (TypeEntryHash::const_iterator it = entries.cbegin(), end = entries.cend(); it != end; ++it) {
+ foreach (TypeEntry *typeEntry, it.value()) {
+ if (typeEntry->isPrimitive())
+ returned.append(static_cast<PrimitiveTypeEntry *>(typeEntry));
+ }
+ }
+ return returned;
+}
+
+QList<const ContainerTypeEntry*> TypeDatabase::containerTypes() const
+{
+ TypeEntryHash entries = allEntries();
+ QList<const ContainerTypeEntry*> returned;
+ for (TypeEntryHash::const_iterator it = entries.cbegin(), end = entries.cend(); it != end; ++it) {
+ foreach (TypeEntry *typeEntry, it.value()) {
+ if (typeEntry->isContainer())
+ returned.append(static_cast<ContainerTypeEntry *>(typeEntry));
+ }
+ }
+ return returned;
+}
+void TypeDatabase::addRejection(const QString& className, const QString& functionName,
+ const QString& fieldName, const QString& enumName)
+{
+ TypeRejection r;
+ r.class_name = className;
+ r.function_name = functionName;
+ r.field_name = fieldName;
+ r.enum_name = enumName;
+
+ m_rejections << r;
+}
+
+bool TypeDatabase::isClassRejected(const QString& className) const
+{
+ foreach (const TypeRejection& r, m_rejections) {
+ if (r.class_name == className && r.function_name == QLatin1String("*")
+ && r.field_name == QLatin1String("*") && r.enum_name == QLatin1String("*")) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool TypeDatabase::isEnumRejected(const QString& className, const QString& enumName) const
+{
+ foreach (const TypeRejection& r, m_rejections) {
+ if (r.enum_name == enumName
+ && (r.class_name == className || r.class_name == QLatin1String("*"))) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void TypeDatabase::addType(TypeEntry *e)
+{
+ m_entries[e->qualifiedCppName()].append(e);
+}
+
+bool TypeDatabase::isFunctionRejected(const QString& className, const QString& functionName) const
+{
+ foreach (const TypeRejection& r, m_rejections)
+ if (r.function_name == functionName &&
+ (r.class_name == className || r.class_name == QLatin1String("*")))
+ return true;
+ return false;
+}
+
+
+bool TypeDatabase::isFieldRejected(const QString& className, const QString& fieldName) const
+{
+ foreach (const TypeRejection& r, m_rejections)
+ if (r.field_name == fieldName &&
+ (r.class_name == className || r.class_name == QLatin1String("*")))
+ return true;
+ return false;
+}
+
+FlagsTypeEntry* TypeDatabase::findFlagsType(const QString &name) const
+{
+ TypeEntry *fte = findType(name);
+ if (!fte) {
+ fte = m_flagsEntries.value(name);
+ if (!fte) {
+ //last hope, search for flag without scope inside of flags hash
+ for (SingleTypeEntryHash::const_iterator it = m_flagsEntries.cbegin(), end = m_flagsEntries.cend(); it != end; ++it) {
+ if (it.key().endsWith(name)) {
+ fte = it.value();
+ break;
+ }
+ }
+ }
+ }
+ return static_cast<FlagsTypeEntry *>(fte);
+}
+
+void TypeDatabase::addFlagsType(FlagsTypeEntry *fte)
+{
+ m_flagsEntries[fte->originalName()] = fte;
+}
+
+void TypeDatabase::addTemplate(TemplateEntry *t)
+{
+ m_templates[t->name()] = t;
+}
+
+void TypeDatabase::addGlobalUserFunctions(const AddedFunctionList &functions)
+{
+ m_globalUserFunctions << functions;
+}
+
+AddedFunctionList TypeDatabase::findGlobalUserFunctions(const QString& name) const
+{
+ AddedFunctionList addedFunctions;
+ foreach (const AddedFunction &func, m_globalUserFunctions) {
+ if (func.name() == name)
+ addedFunctions.append(func);
+ }
+ return addedFunctions;
+}
+
+void TypeDatabase::addGlobalUserFunctionModifications(const FunctionModificationList &functionModifications)
+{
+ m_functionMods << functionModifications;
+}
+
+QString TypeDatabase::globalNamespaceClassName(const TypeEntry * /*entry*/)
+{
+ return QLatin1String("Global");
+}
+
+FunctionModificationList TypeDatabase::functionModifications(const QString& signature) const
+{
+ FunctionModificationList lst;
+ for (int i = 0; i < m_functionMods.count(); ++i) {
+ const FunctionModification& mod = m_functionMods.at(i);
+ if (mod.signature == signature)
+ lst << mod;
+ }
+
+ return lst;
+}
+
+void TypeDatabase::addSuppressedWarning(const QString &s)
+{
+ m_suppressedWarnings.append(s);
+}
+
+bool TypeDatabase::isSuppressedWarning(const QString& s) const
+{
+ if (!m_suppressWarnings)
+ return false;
+
+ foreach (const QString &_warning, m_suppressedWarnings) {
+ QString warning = _warning;
+ warning.replace(QLatin1String("\\*"), QLatin1String("&place_holder_for_asterisk;"));
+
+ QStringList segs = warning.split(QLatin1Char('*'), QString::SkipEmptyParts);
+ if (!segs.size())
+ continue;
+
+ int i = 0;
+ int pos = s.indexOf(QString(segs.at(i++)).replace(QLatin1String("&place_holder_for_asterisk;"), QLatin1String("*")));
+ //qDebug() << "s == " << s << ", warning == " << segs;
+ while (pos != -1) {
+ if (i == segs.size())
+ return true;
+ pos = s.indexOf(QString(segs.at(i++)).replace(QLatin1String("&place_holder_for_asterisk;"), QLatin1String("*")), pos);
+ }
+ }
+
+ return false;
+}
+
+QString TypeDatabase::modifiedTypesystemFilepath(const QString& tsFile) const
+{
+ const QFileInfo tsFi(tsFile);
+ if (tsFi.isAbsolute()) // No point in further lookups
+ return tsFi.absoluteFilePath();
+ if (tsFi.isFile()) // Make path absolute
+ return tsFi.absoluteFilePath();
+ const QString fileName = tsFi.fileName();
+ foreach (const QString &path, m_typesystemPaths) {
+ const QFileInfo fi(path + QLatin1Char('/') + fileName);
+ if (fi.isFile())
+ return fi.absoluteFilePath();
+ }
+ return tsFile;
+}
+
+bool TypeDatabase::parseFile(const QString &filename, bool generate)
+{
+ QString filepath = modifiedTypesystemFilepath(filename);
+ if (m_parsedTypesystemFiles.contains(filepath))
+ return m_parsedTypesystemFiles[filepath];
+
+ m_parsedTypesystemFiles[filepath] = true; // Prevent recursion when including self.
+
+ QFile file(filepath);
+ if (!file.exists()) {
+ m_parsedTypesystemFiles[filepath] = false;
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Can't find " << filename << ", typesystem paths: " << m_typesystemPaths.join(QLatin1String(", "));
+ return false;
+ }
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ m_parsedTypesystemFiles[filepath] = false;
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Can't open " << QDir::toNativeSeparators(filename) << ": " << file.errorString();
+ return false;
+ }
+
+ int count = m_entries.size();
+ bool ok = parseFile(&file, generate);
+ m_parsedTypesystemFiles[filepath] = ok;
+ int newCount = m_entries.size();
+
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug)) {
+ qCDebug(lcShiboken)
+ << QStringLiteral("Parsed: '%1', %2 new entries").arg(filename).arg(newCount - count);
+ }
+ return ok;
+}
+
+bool TypeDatabase::parseFile(QIODevice* device, bool generate)
+{
+ QXmlStreamReader reader(device);
+ Handler handler(this, generate);
+ return handler.parse(reader);
+}
+
+PrimitiveTypeEntry *TypeDatabase::findPrimitiveType(const QString& name) const
+{
+ QList<TypeEntry*> entries = findTypes(name);
+
+ foreach (TypeEntry* entry, entries) {
+ if (entry && entry->isPrimitive() && static_cast<PrimitiveTypeEntry*>(entry)->preferredTargetLangType())
+ return static_cast<PrimitiveTypeEntry*>(entry);
+ }
+
+ return 0;
+}
+
+ComplexTypeEntry* TypeDatabase::findComplexType(const QString& name) const
+{
+ QList<TypeEntry*> entries = findTypes(name);
+ foreach (TypeEntry* entry, entries) {
+ if (entry && entry->isComplex())
+ return static_cast<ComplexTypeEntry*>(entry);
+ }
+ return 0;
+}
+
+ObjectTypeEntry* TypeDatabase::findObjectType(const QString& name) const
+{
+ QList<TypeEntry*> entries = findTypes(name);
+ foreach (TypeEntry* entry, entries) {
+ if (entry && entry->isObject())
+ return static_cast<ObjectTypeEntry*>(entry);
+ }
+ return 0;
+}
+
+NamespaceTypeEntry* TypeDatabase::findNamespaceType(const QString& name) const
+{
+ QList<TypeEntry*> entries = findTypes(name);
+ foreach (TypeEntry* entry, entries) {
+ if (entry && entry->isNamespace())
+ return static_cast<NamespaceTypeEntry*>(entry);
+ }
+ return 0;
+}
+
+bool TypeDatabase::shouldDropTypeEntry(const QString& fullTypeName) const
+{
+ return m_dropTypeEntries.contains(fullTypeName);
+}
+
+void TypeDatabase::setDropTypeEntries(QStringList dropTypeEntries)
+{
+ m_dropTypeEntries = dropTypeEntries;
+ m_dropTypeEntries.sort();
+}
+
+// Using std::pair to save some memory
+// the pair means (revision, typeIndex)
+// This global variable exists only because we can't break the ABI
+typedef QHash<const TypeEntry*, std::pair<int, int> > TypeRevisionMap;
+Q_GLOBAL_STATIC(TypeRevisionMap, typeEntryFields);
+static bool computeTypeIndexes = true;
+static int maxTypeIndex;
+
+int getTypeRevision(const TypeEntry* typeEntry)
+{
+ return typeEntryFields()->value(typeEntry).first;
+}
+
+void setTypeRevision(TypeEntry* typeEntry, int revision)
+{
+ (*typeEntryFields())[typeEntry].first = revision;
+ computeTypeIndexes = true;
+}
+
+static bool compareTypeEntriesByName(const TypeEntry* t1, const TypeEntry* t2)
+{
+ return t1->qualifiedCppName() < t2->qualifiedCppName();
+}
+
+static void _computeTypeIndexes()
+{
+ TypeDatabase* tdb = TypeDatabase::instance();
+ typedef QMap<int, QList<TypeEntry*> > GroupedTypeEntries;
+ GroupedTypeEntries groupedEntries;
+
+ // Group type entries by revision numbers
+ TypeEntryHash allEntries = tdb->allEntries();
+ foreach (QList<TypeEntry*> entryList, allEntries) {
+ foreach (TypeEntry* entry, entryList) {
+ if (entry->isPrimitive()
+ || entry->isContainer()
+ || entry->isFunction()
+ || !entry->generateCode()
+ || entry->isEnumValue()
+ || entry->isVarargs()
+ || entry->isTypeSystem()
+ || entry->isVoid()
+ || entry->isCustom())
+ continue;
+ groupedEntries[getTypeRevision(entry)] << entry;
+ }
+ }
+
+ maxTypeIndex = 0;
+ GroupedTypeEntries::iterator it = groupedEntries.begin();
+ for (; it != groupedEntries.end(); ++it) {
+ // Remove duplicates
+ QList<TypeEntry*>::iterator newEnd = std::unique(it.value().begin(), it.value().end());
+ it.value().erase(newEnd, it.value().end());
+ // Sort the type entries by name
+ qSort(it.value().begin(), newEnd, compareTypeEntriesByName);
+
+ foreach (TypeEntry* entry, it.value()) {
+ (*typeEntryFields())[entry].second = maxTypeIndex++;
+ }
+ }
+ computeTypeIndexes = false;
+}
+
+int getTypeIndex(const TypeEntry* typeEntry)
+{
+ if (computeTypeIndexes)
+ _computeTypeIndexes();
+ return typeEntryFields()->value(typeEntry).second;
+}
+
+int getMaxTypeIndex()
+{
+ if (computeTypeIndexes)
+ _computeTypeIndexes();
+ return maxTypeIndex;
+}
+
+bool TypeDatabase::setApiVersion(const QString& packageWildcardPattern, const QString &version)
+{
+ const QString packagePattern = wildcardToRegExp(packageWildcardPattern.trimmed());
+ const QVersionNumber versionNumber = QVersionNumber::fromString(version);
+ if (versionNumber.isNull())
+ return false;
+ ApiVersions &versions = *apiVersions();
+ for (int i = 0, size = versions.size(); i < size; ++i) {
+ if (versions.at(i).first.pattern() == packagePattern) {
+ versions[i].second = versionNumber;
+ return true;
+ }
+ }
+ const QRegularExpression packageRegex(packagePattern);
+ if (!packageRegex.isValid())
+ return false;
+ versions.append(qMakePair(packageRegex, versionNumber));
+ return true;
+}
+
+bool TypeDatabase::checkApiVersion(const QString& package, const QString& version) const
+{
+ const QVersionNumber versionNumber = QVersionNumber::fromString(version);
+ if (versionNumber.isNull()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "checkApiVersion: Invalid version \"" << version << "\" specified for package "
+ << package << '.';
+ return false;
+ }
+ const ApiVersions &versions = *apiVersions();
+ for (int i = 0, size = versions.size(); i < size; ++i) {
+ if (versions.at(i).first.match(package).hasMatch())
+ return versions.at(i).second >= versionNumber;
+ }
+ return false;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const TypeEntry *te)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "TypeEntry(";
+ if (te) {
+ d << '"' << te->qualifiedCppName() << "\", type=" << te->type();
+ if (te->include().isValid())
+ d << ", include=" << te->include();
+ const IncludeList &extraIncludes = te->extraIncludes();
+ if (const int count = extraIncludes.size()) {
+ d << ", extraIncludes[" << count << "]=";
+ for (int i = 0; i < count; ++i) {
+ if (i)
+ d << ", ";
+ d << extraIncludes.at(i);
+ }
+ }
+ } else {
+ d << '0';
+ }
+ d << ')';
+ return d;
+}
+
+QDebug operator<<(QDebug d, const TemplateEntry *te)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "TemplateEntry(";
+ if (te) {
+ d << '"' << te->name() << "\", version=" << te->version();
+ } else {
+ d << '0';
+ }
+ d << ')';
+ return d;
+}
+
+void TypeDatabase::formatDebug(QDebug &d) const
+{
+ typedef TypeEntryHash::ConstIterator Eit;
+ typedef SingleTypeEntryHash::ConstIterator Sit;
+ typedef TemplateEntryHash::ConstIterator TplIt;
+ d << "TypeDatabase("
+ << "entries[" << m_entries.size() << "]=";
+ for (Eit it = m_entries.cbegin(), end = m_entries.cend(); it != end; ++it) {
+ const int count = it.value().size();
+ d << '"' << it.key() << "\" [" << count << "]: (";
+ for (int t = 0; t < count; ++t) {
+ if (t)
+ d << ", ";
+ d << it.value().at(t);
+ }
+ d << ")\n";
+ }
+ if (!m_templates.isEmpty()) {
+ d << "templates[" << m_templates.size() << "]=(";
+ const TplIt begin = m_templates.cbegin();
+ for (TplIt it = begin, end = m_templates.cend(); it != end; ++it) {
+ if (it != begin)
+ d << ", ";
+ d << it.value();
+ }
+ d << ")\n";
+ }
+ if (!m_flagsEntries.isEmpty()) {
+ d << "flags[" << m_flagsEntries.size() << "]=(";
+ const Sit begin = m_flagsEntries.cbegin();
+ for (Sit it = begin, end = m_flagsEntries.cend(); it != end; ++it) {
+ if (it != begin)
+ d << ", ";
+ d << it.value();
+ }
+ d << ")\n";
+ }
+ d <<"\nglobalUserFunctions=" << m_globalUserFunctions << ')';
+}
+
+QDebug operator<<(QDebug d, const TypeDatabase &db)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ db.formatDebug(d);
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/ApiExtractor/typedatabase.h b/sources/shiboken2/ApiExtractor/typedatabase.h
new file mode 100644
index 000000000..4255cf458
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/typedatabase.h
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TYPEDATABASE_H
+#define TYPEDATABASE_H
+
+#include "apiextractormacros.h"
+#include "include.h"
+#include "typesystem_enums.h"
+#include "typesystem_typedefs.h"
+
+#include <QtCore/QStringList>
+
+QT_FORWARD_DECLARE_CLASS(QIODevice)
+
+class ComplexTypeEntry;
+class ContainerTypeEntry;
+class FlagsTypeEntry;
+class FunctionTypeEntry;
+class NamespaceTypeEntry;
+class ObjectTypeEntry;
+class TemplateEntry;
+class TypeEntry;
+
+struct TypeRejection;
+
+QT_FORWARD_DECLARE_CLASS(QDebug)
+
+void setTypeRevision(TypeEntry* typeEntry, int revision);
+int getTypeRevision(const TypeEntry* typeEntry);
+int getTypeIndex(const TypeEntry* typeEntry);
+int getMaxTypeIndex();
+
+class ContainerTypeEntry;
+class PrimitiveTypeEntry;
+class TypeDatabase
+{
+ TypeDatabase();
+ Q_DISABLE_COPY(TypeDatabase)
+public:
+ ~TypeDatabase();
+
+ /**
+ * Return the type system instance.
+ * \param newInstance This parameter is useful just for unit testing, because singletons causes
+ * too many side effects on unit testing.
+ */
+ static TypeDatabase* instance(bool newInstance = false);
+
+ static QString normalizedSignature(const QString &signature);
+
+ QStringList requiredTargetImports() const;
+
+ void addRequiredTargetImport(const QString& moduleName);
+
+ void addTypesystemPath(const QString& typesystem_paths);
+
+ IncludeList extraIncludes(const QString& className) const;
+
+ PrimitiveTypeEntry* findPrimitiveType(const QString& name) const;
+ ComplexTypeEntry* findComplexType(const QString& name) const;
+ ObjectTypeEntry* findObjectType(const QString& name) const;
+ NamespaceTypeEntry* findNamespaceType(const QString& name) const;
+ ContainerTypeEntry* findContainerType(const QString& name) const;
+ FunctionTypeEntry* findFunctionType(const QString& name) const;
+
+ TypeEntry* findType(const QString& name) const;
+
+ TypeEntryHash allEntries() const { return m_entries; }
+
+ SingleTypeEntryHash entries() const;
+
+ QList<const PrimitiveTypeEntry*> primitiveTypes() const;
+
+ QList<const ContainerTypeEntry*> containerTypes() const;
+
+ void addRejection(const QString& className, const QString& functionName,
+ const QString& fieldName, const QString& enumName);
+ bool isClassRejected(const QString& className) const;
+ bool isFunctionRejected(const QString& className, const QString& functionName) const;
+ bool isFieldRejected(const QString& className, const QString& fieldName) const;
+ bool isEnumRejected(const QString& className, const QString& enumName) const;
+
+ void addType(TypeEntry* e);
+
+ FlagsTypeEntry* findFlagsType(const QString& name) const;
+ void addFlagsType(FlagsTypeEntry* fte);
+
+ TemplateEntry *findTemplate(const QString& name) const { return m_templates[name]; }
+
+ void addTemplate(TemplateEntry* t);
+
+ AddedFunctionList globalUserFunctions() const { return m_globalUserFunctions; }
+
+ void addGlobalUserFunctions(const AddedFunctionList &functions);
+
+ AddedFunctionList findGlobalUserFunctions(const QString& name) const;
+
+ void addGlobalUserFunctionModifications(const FunctionModificationList &functionModifications);
+
+ FunctionModificationList functionModifications(const QString& signature) const;
+
+ void setSuppressWarnings(bool on) { m_suppressWarnings = on; }
+
+ void addSuppressedWarning(const QString &s);
+
+ bool isSuppressedWarning(const QString& s) const;
+
+ static QString globalNamespaceClassName(const TypeEntry *te);
+
+ bool parseFile(const QString &filename, bool generate = true);
+ bool parseFile(QIODevice* device, bool generate = true);
+
+ bool setApiVersion(const QString& package, const QString& version);
+
+ bool checkApiVersion(const QString& package, const QString &version) const;
+
+ bool hasDroppedTypeEntries() const { return !m_dropTypeEntries.isEmpty(); }
+
+ bool shouldDropTypeEntry(const QString& fullTypeName) const;
+
+ void setDropTypeEntries(QStringList dropTypeEntries);
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const;
+#endif
+private:
+ QList<TypeEntry *> findTypes(const QString &name) const;
+ QString modifiedTypesystemFilepath(const QString &tsFile) const;
+
+ bool m_suppressWarnings;
+ TypeEntryHash m_entries;
+ SingleTypeEntryHash m_flagsEntries;
+ TemplateEntryHash m_templates;
+ QStringList m_suppressedWarnings;
+
+ AddedFunctionList m_globalUserFunctions;
+ FunctionModificationList m_functionMods;
+
+ QStringList m_requiredTargetImports;
+
+ QStringList m_typesystemPaths;
+ QHash<QString, bool> m_parsedTypesystemFiles;
+
+ QList<TypeRejection> m_rejections;
+
+ QStringList m_dropTypeEntries;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const TypeEntry *te);
+QDebug operator<<(QDebug d, const TypeDatabase &db);
+#endif
+#endif // TYPEDATABASE_H
diff --git a/sources/shiboken2/ApiExtractor/typeparser.cpp b/sources/shiboken2/ApiExtractor/typeparser.cpp
new file mode 100644
index 000000000..67120a1ac
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/typeparser.cpp
@@ -0,0 +1,318 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "typeparser.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QStack>
+#include <QtCore/QTextStream>
+
+class Scanner
+{
+public:
+ enum Token {
+ StarToken,
+ AmpersandToken,
+ LessThanToken,
+ ColonToken,
+ CommaToken,
+ OpenParenToken,
+ CloseParenToken,
+ SquareBegin,
+ SquareEnd,
+ GreaterThanToken,
+
+ ConstToken,
+ Identifier,
+ NoToken,
+ InvalidToken
+ };
+
+ Scanner(const QString &s)
+ : m_pos(0), m_length(s.length()), m_chars(s.constData())
+ {
+ }
+
+ Token nextToken(QString *errorMessage = Q_NULLPTR);
+ QString identifier() const;
+
+ QString msgParseError(const QString &why) const;
+
+private:
+ int m_pos;
+ int m_length;
+ int m_tokenStart;
+ const QChar *m_chars;
+};
+
+QString Scanner::identifier() const
+{
+ return QString(m_chars + m_tokenStart, m_pos - m_tokenStart);
+}
+
+Scanner::Token Scanner::nextToken(QString *errorMessage)
+{
+ Token tok = NoToken;
+
+ // remove whitespace
+ while (m_pos < m_length && m_chars[m_pos] == QLatin1Char(' '))
+ ++m_pos;
+
+ m_tokenStart = m_pos;
+
+ while (m_pos < m_length) {
+
+ const QChar &c = m_chars[m_pos];
+
+ if (tok == NoToken) {
+ switch (c.toLatin1()) {
+ case '*': tok = StarToken; break;
+ case '&': tok = AmpersandToken; break;
+ case '<': tok = LessThanToken; break;
+ case '>': tok = GreaterThanToken; break;
+ case ',': tok = CommaToken; break;
+ case '(': tok = OpenParenToken; break;
+ case ')': tok = CloseParenToken; break;
+ case '[': tok = SquareBegin; break;
+ case ']' : tok = SquareEnd; break;
+ case ':':
+ tok = ColonToken;
+ Q_ASSERT(m_pos + 1 < m_length);
+ ++m_pos;
+ break;
+ default:
+ if (c.isLetterOrNumber() || c == QLatin1Char('_')) {
+ tok = Identifier;
+ } else {
+ QString message;
+ QTextStream (&message) << ": Unrecognized character in lexer at "
+ << m_pos << " : '" << c << '\'';
+ message = msgParseError(message);
+ if (errorMessage)
+ *errorMessage = message;
+ else
+ qWarning().noquote().nospace() << message;
+ return InvalidToken;
+ }
+ break;
+ }
+ }
+
+ if (tok <= GreaterThanToken) {
+ ++m_pos;
+ break;
+ }
+
+ if (tok == Identifier) {
+ if (c.isLetterOrNumber() || c == QLatin1Char('_'))
+ ++m_pos;
+ else
+ break;
+ }
+ }
+
+ if (tok == Identifier && m_pos - m_tokenStart == 5) {
+ if (m_chars[m_tokenStart] == QLatin1Char('c')
+ && m_chars[m_tokenStart + 1] == QLatin1Char('o')
+ && m_chars[m_tokenStart + 2] == QLatin1Char('n')
+ && m_chars[m_tokenStart + 3] == QLatin1Char('s')
+ && m_chars[m_tokenStart + 4] == QLatin1Char('t'))
+ tok = ConstToken;
+ }
+
+ return tok;
+
+}
+
+QString Scanner::msgParseError(const QString &why) const
+{
+ return QStringLiteral("TypeParser: Unable to parse \"")
+ + QString(m_chars, m_length) + QStringLiteral("\": ") + why;
+}
+
+static TypeParser::Info invalidInfo()
+{
+ TypeParser::Info result;
+ result.is_busted = true;
+ return result;
+}
+
+TypeParser::Info TypeParser::parse(const QString &str, QString *errorMessage)
+{
+ Scanner scanner(str);
+
+ Info info;
+ QStack<Info *> stack;
+ stack.push(&info);
+
+ bool colon_prefix = false;
+ bool in_array = false;
+ QString array;
+
+ Scanner::Token tok = scanner.nextToken(errorMessage);
+ while (tok != Scanner::NoToken) {
+ if (tok == Scanner::InvalidToken)
+ return invalidInfo();
+
+// switch (tok) {
+// case Scanner::StarToken: printf(" - *\n"); break;
+// case Scanner::AmpersandToken: printf(" - &\n"); break;
+// case Scanner::LessThanToken: printf(" - <\n"); break;
+// case Scanner::GreaterThanToken: printf(" - >\n"); break;
+// case Scanner::ColonToken: printf(" - ::\n"); break;
+// case Scanner::CommaToken: printf(" - ,\n"); break;
+// case Scanner::ConstToken: printf(" - const\n"); break;
+// case Scanner::SquareBegin: printf(" - [\n"); break;
+// case Scanner::SquareEnd: printf(" - ]\n"); break;
+// case Scanner::Identifier: printf(" - '%s'\n", qPrintable(scanner.identifier())); break;
+// default:
+// break;
+// }
+
+ switch (tok) {
+
+ case Scanner::StarToken:
+ ++stack.top()->indirections;
+ break;
+
+ case Scanner::AmpersandToken:
+ switch (stack.top()->referenceType) {
+ case NoReference:
+ stack.top()->referenceType = LValueReference;
+ break;
+ case LValueReference:
+ stack.top()->referenceType = RValueReference;
+ break;
+ case RValueReference:
+ const QString message = scanner.msgParseError(QStringLiteral("Too many '&' qualifiers"));
+ if (errorMessage)
+ *errorMessage = message;
+ else
+ qWarning().noquote().nospace() << message;
+ return invalidInfo();
+ }
+ break;
+ case Scanner::LessThanToken:
+ stack.top()->template_instantiations << Info();
+ stack.push(&stack.top()->template_instantiations.last());
+ break;
+
+ case Scanner::CommaToken:
+ stack.pop();
+ stack.top()->template_instantiations << Info();
+ stack.push(&stack.top()->template_instantiations.last());
+ break;
+
+ case Scanner::GreaterThanToken:
+ stack.pop();
+ break;
+
+ case Scanner::ColonToken:
+ colon_prefix = true;
+ break;
+
+ case Scanner::ConstToken:
+ stack.top()->is_constant = true;
+ break;
+
+ case Scanner::OpenParenToken: // function pointers not supported
+ case Scanner::CloseParenToken: {
+ const QString message = scanner.msgParseError(QStringLiteral("Function pointers are not supported"));
+ if (errorMessage)
+ *errorMessage = message;
+ else
+ qWarning().noquote().nospace() << message;
+ return invalidInfo();
+ }
+
+ case Scanner::Identifier:
+ if (in_array) {
+ array = scanner.identifier();
+ } else if (colon_prefix || stack.top()->qualified_name.isEmpty()) {
+ stack.top()->qualified_name << scanner.identifier();
+ colon_prefix = false;
+ } else {
+ stack.top()->qualified_name.last().append(QLatin1Char(' ') + scanner.identifier());
+ }
+ break;
+
+ case Scanner::SquareBegin:
+ in_array = true;
+ break;
+
+ case Scanner::SquareEnd:
+ in_array = false;
+ stack.top()->arrays += array;
+ break;
+
+
+ default:
+ break;
+ }
+
+ tok = scanner.nextToken();
+ }
+
+ return info;
+}
+
+QString TypeParser::Info::instantiationName() const
+{
+ QString s(qualified_name.join(QLatin1String("::")));
+ if (!template_instantiations.isEmpty()) {
+ QStringList insts;
+ foreach (const Info &info, template_instantiations)
+ insts << info.toString();
+ s += QLatin1String("< ") + insts.join(QLatin1String(", ")) + QLatin1String(" >");
+ }
+
+ return s;
+}
+
+QString TypeParser::Info::toString() const
+{
+ QString s;
+
+ if (is_constant)
+ s += QLatin1String("const ");
+ s += instantiationName();
+ for (int i = 0; i < arrays.size(); ++i)
+ s += QLatin1Char('[') + arrays.at(i) + QLatin1Char(']');
+ s += QString(indirections, QLatin1Char('*'));
+ switch (referenceType) {
+ case NoReference:
+ break;
+ case LValueReference:
+ s += QLatin1Char('&');
+ break;
+ case RValueReference:
+ s += QLatin1String("&&");
+ break;
+ }
+ return s;
+}
diff --git a/sources/shiboken2/ApiExtractor/typeparser.h b/sources/shiboken2/ApiExtractor/typeparser.h
new file mode 100644
index 000000000..9ccd0992c
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/typeparser.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TYPEPARSER_H
+#define TYPEPARSER_H
+
+#include "parser/codemodel_enums.h"
+
+#include <QtCore/QList>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+
+class TypeParser
+{
+public:
+ struct Info
+ {
+ Info() : referenceType(NoReference), is_constant(false), is_busted(false), indirections(0) { }
+ QStringList qualified_name;
+ QStringList arrays;
+ QList<Info> template_instantiations;
+ ReferenceType referenceType;
+ uint is_constant : 1;
+ uint is_busted : 1;
+ uint indirections : 6;
+
+ QString toString() const;
+ QString instantiationName() const;
+ };
+
+ static Info parse(const QString &str, QString *errorMessage = Q_NULLPTR);
+};
+
+#endif // TYPEPARSER_H
diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp
new file mode 100644
index 000000000..869904d43
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/typesystem.cpp
@@ -0,0 +1,2667 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "typesystem.h"
+#include "typesystem_p.h"
+#include "typedatabase.h"
+#include "reporthandler.h"
+#include <QtCore/QDir>
+#include <QtCore/QFile>
+#include <QtCore/QXmlStreamAttributes>
+#include <QtCore/QXmlStreamReader>
+
+static QString strings_Object = QLatin1String("Object");
+static QString strings_String = QLatin1String("String");
+static QString strings_char = QLatin1String("char");
+static QString strings_jchar = QLatin1String("jchar");
+static QString strings_jobject = QLatin1String("jobject");
+
+static inline QString colonColon() { return QStringLiteral("::"); }
+static inline QString quoteAfterLineAttribute() { return QStringLiteral("quote-after-line"); }
+static inline QString quoteBeforeLineAttribute() { return QStringLiteral("quote-before-line"); }
+static inline QString nameAttribute() { return QStringLiteral("name"); }
+static inline QString sinceAttribute() { return QStringLiteral("since"); }
+static inline QString flagsAttribute() { return QStringLiteral("flags"); }
+
+static QList<CustomConversion*> customConversionsForReview = QList<CustomConversion*>();
+
+Handler::Handler(TypeDatabase* database, bool generate)
+ : m_database(database), m_generate(generate ? TypeEntry::GenerateAll : TypeEntry::GenerateForSubclass)
+{
+ m_currentEnum = 0;
+ m_current = 0;
+ m_currentDroppedEntry = 0;
+ m_currentDroppedEntryDepth = 0;
+ m_ignoreDepth = 0;
+
+ tagNames.insert(QLatin1String("rejection"), StackElement::Rejection);
+ tagNames.insert(QLatin1String("custom-type"), StackElement::CustomTypeEntry);
+ tagNames.insert(QLatin1String("primitive-type"), StackElement::PrimitiveTypeEntry);
+ tagNames.insert(QLatin1String("container-type"), StackElement::ContainerTypeEntry);
+ tagNames.insert(QLatin1String("object-type"), StackElement::ObjectTypeEntry);
+ tagNames.insert(QLatin1String("value-type"), StackElement::ValueTypeEntry);
+ tagNames.insert(QLatin1String("interface-type"), StackElement::InterfaceTypeEntry);
+ tagNames.insert(QLatin1String("namespace-type"), StackElement::NamespaceTypeEntry);
+ tagNames.insert(QLatin1String("enum-type"), StackElement::EnumTypeEntry);
+ tagNames.insert(QLatin1String("smart-pointer-type"), StackElement::SmartPointerTypeEntry);
+ tagNames.insert(QLatin1String("function"), StackElement::FunctionTypeEntry);
+ tagNames.insert(QLatin1String("extra-includes"), StackElement::ExtraIncludes);
+ tagNames.insert(QLatin1String("include"), StackElement::Include);
+ tagNames.insert(QLatin1String("inject-code"), StackElement::InjectCode);
+ tagNames.insert(QLatin1String("modify-function"), StackElement::ModifyFunction);
+ tagNames.insert(QLatin1String("modify-field"), StackElement::ModifyField);
+ tagNames.insert(QLatin1String("access"), StackElement::Access);
+ tagNames.insert(QLatin1String("remove"), StackElement::Removal);
+ tagNames.insert(QLatin1String("rename"), StackElement::Rename);
+ tagNames.insert(QLatin1String("typesystem"), StackElement::Root);
+ tagNames.insert(QLatin1String("custom-constructor"), StackElement::CustomMetaConstructor);
+ tagNames.insert(QLatin1String("custom-destructor"), StackElement::CustomMetaDestructor);
+ tagNames.insert(QLatin1String("argument-map"), StackElement::ArgumentMap);
+ tagNames.insert(QLatin1String("suppress-warning"), StackElement::SuppressedWarning);
+ tagNames.insert(QLatin1String("load-typesystem"), StackElement::LoadTypesystem);
+ tagNames.insert(QLatin1String("define-ownership"), StackElement::DefineOwnership);
+ tagNames.insert(QLatin1String("replace-default-expression"), StackElement::ReplaceDefaultExpression);
+ tagNames.insert(QLatin1String("reject-enum-value"), StackElement::RejectEnumValue);
+ tagNames.insert(QLatin1String("replace-type"), StackElement::ReplaceType);
+ tagNames.insert(QLatin1String("conversion-rule"), StackElement::ConversionRule);
+ tagNames.insert(QLatin1String("native-to-target"), StackElement::NativeToTarget);
+ tagNames.insert(QLatin1String("target-to-native"), StackElement::TargetToNative);
+ tagNames.insert(QLatin1String("add-conversion"), StackElement::AddConversion);
+ tagNames.insert(QLatin1String("modify-argument"), StackElement::ModifyArgument);
+ tagNames.insert(QLatin1String("remove-argument"), StackElement::RemoveArgument);
+ tagNames.insert(QLatin1String("remove-default-expression"), StackElement::RemoveDefaultExpression);
+ tagNames.insert(QLatin1String("template"), StackElement::Template);
+ tagNames.insert(QLatin1String("insert-template"), StackElement::TemplateInstanceEnum);
+ tagNames.insert(QLatin1String("replace"), StackElement::Replace);
+ tagNames.insert(QLatin1String("no-null-pointer"), StackElement::NoNullPointers);
+ tagNames.insert(QLatin1String("reference-count"), StackElement::ReferenceCount);
+ tagNames.insert(QLatin1String("parent"), StackElement::ParentOwner);
+ tagNames.insert(QLatin1String("inject-documentation"), StackElement::InjectDocumentation);
+ tagNames.insert(QLatin1String("modify-documentation"), StackElement::ModifyDocumentation);
+ tagNames.insert(QLatin1String("add-function"), StackElement::AddFunction);
+}
+
+static QString msgReaderError(const QXmlStreamReader &reader, const QString &what)
+{
+ QString message;
+ QTextStream str(&message);
+ str << "Error: ";
+ if (const QFile *file = qobject_cast<const QFile *>(reader.device()))
+ str << "file=" << QDir::toNativeSeparators(file->fileName()) << ", ";
+ str << "line=" << reader.lineNumber() << ", column=" << reader.columnNumber()
+ << ", message=" << what;
+ return message;
+}
+
+static QString msgReaderError(const QXmlStreamReader &reader)
+{
+ return msgReaderError(reader, reader.errorString());
+}
+
+bool Handler::parse(QXmlStreamReader &reader)
+{
+ m_error.clear();
+ while (!reader.atEnd()) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::NoToken:
+ case QXmlStreamReader::Invalid:
+ qCWarning(lcShiboken).noquote().nospace() << msgReaderError(reader);
+ return false;
+ case QXmlStreamReader::StartElement:
+ if (!startElement(reader.name(), reader.attributes())) {
+ m_error = msgReaderError(reader, m_error);
+ return false;
+ }
+
+ break;
+ case QXmlStreamReader::EndElement:
+ if (!endElement(reader.name())) {
+ m_error = msgReaderError(reader, m_error);
+ return false;
+ }
+ break;
+ case QXmlStreamReader::Characters:
+ if (!characters(reader.text())) {
+ m_error = msgReaderError(reader, m_error);
+ return false;
+ }
+ break;
+ case QXmlStreamReader::StartDocument:
+ case QXmlStreamReader::EndDocument:
+ case QXmlStreamReader::Comment:
+ case QXmlStreamReader::DTD:
+ case QXmlStreamReader::EntityReference:
+ case QXmlStreamReader::ProcessingInstruction:
+ break;
+ }
+ }
+ return true;
+}
+
+void Handler::fetchAttributeValues(const QString &name, const QXmlStreamAttributes &atts,
+ QHash<QString, QString> *acceptedAttributes)
+{
+ Q_ASSERT(acceptedAttributes);
+
+ for (int i = 0; i < atts.length(); ++i) {
+ const QString key = atts.at(i).name().toString().toLower();
+ if (!acceptedAttributes->contains(key)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Unknown attribute for '%1': '%2'").arg(name, key);
+ } else {
+ acceptedAttributes->insert(key, atts.at(i).value().toString());
+ }
+ }
+}
+
+bool Handler::endElement(const QStringRef &localName)
+{
+ if (m_ignoreDepth) {
+ --m_ignoreDepth;
+ return true;
+ }
+
+ if (m_currentDroppedEntry) {
+ if (m_currentDroppedEntryDepth == 1) {
+ m_current = m_currentDroppedEntry->parent;
+ delete m_currentDroppedEntry;
+ m_currentDroppedEntry = 0;
+ m_currentDroppedEntryDepth = 0;
+ } else {
+ ++m_currentDroppedEntryDepth;
+ }
+ return true;
+ }
+
+ if (!localName.compare(QLatin1String("import-file"), Qt::CaseInsensitive))
+ return true;
+
+ if (!m_current)
+ return true;
+
+ switch (m_current->type) {
+ case StackElement::Root:
+ if (m_generate == TypeEntry::GenerateAll) {
+ TypeDatabase::instance()->addGlobalUserFunctions(m_contextStack.top()->addedFunctions);
+ TypeDatabase::instance()->addGlobalUserFunctionModifications(m_contextStack.top()->functionMods);
+ foreach (CustomConversion* customConversion, customConversionsForReview) {
+ foreach (CustomConversion::TargetToNativeConversion* toNative, customConversion->targetToNativeConversions())
+ toNative->setSourceType(m_database->findType(toNative->sourceTypeName()));
+ }
+ }
+ break;
+ case StackElement::ObjectTypeEntry:
+ case StackElement::ValueTypeEntry:
+ case StackElement::InterfaceTypeEntry:
+ case StackElement::NamespaceTypeEntry: {
+ ComplexTypeEntry *centry = static_cast<ComplexTypeEntry *>(m_current->entry);
+ centry->setAddedFunctions(m_contextStack.top()->addedFunctions);
+ centry->setFunctionModifications(m_contextStack.top()->functionMods);
+ centry->setFieldModifications(m_contextStack.top()->fieldMods);
+ centry->setCodeSnips(m_contextStack.top()->codeSnips);
+ centry->setDocModification(m_contextStack.top()->docModifications);
+
+ if (centry->designatedInterface()) {
+ centry->designatedInterface()->setCodeSnips(m_contextStack.top()->codeSnips);
+ centry->designatedInterface()->setFunctionModifications(m_contextStack.top()->functionMods);
+ }
+ }
+ break;
+ case StackElement::NativeToTarget:
+ case StackElement::AddConversion: {
+ CustomConversion* customConversion = static_cast<TypeEntry*>(m_current->entry)->customConversion();
+ if (!customConversion) {
+ m_error = QLatin1String("CustomConversion object is missing.");
+ return false;
+ }
+
+ QString code = m_contextStack.top()->codeSnips.takeLast().code();
+ if (m_current->type == StackElement::AddConversion) {
+ if (customConversion->targetToNativeConversions().isEmpty()) {
+ m_error = QLatin1String("CustomConversion's target to native conversions missing.");
+ return false;
+ }
+ customConversion->targetToNativeConversions().last()->setConversion(code);
+ } else {
+ customConversion->setNativeToTargetConversion(code);
+ }
+ }
+ break;
+ case StackElement::CustomMetaConstructor: {
+ m_current->entry->setCustomConstructor(*m_current->value.customFunction);
+ delete m_current->value.customFunction;
+ }
+ break;
+ case StackElement::CustomMetaDestructor: {
+ m_current->entry->setCustomDestructor(*m_current->value.customFunction);
+ delete m_current->value.customFunction;
+ }
+ break;
+ case StackElement::EnumTypeEntry:
+ m_current->entry->setDocModification(m_contextStack.top()->docModifications);
+ m_contextStack.top()->docModifications = DocModificationList();
+ m_currentEnum = 0;
+ break;
+ case StackElement::Template:
+ m_database->addTemplate(m_current->value.templateEntry);
+ break;
+ case StackElement::TemplateInstanceEnum:
+ switch (m_current->parent->type) {
+ case StackElement::InjectCode:
+ if (m_current->parent->parent->type == StackElement::Root) {
+ CodeSnipList snips = m_current->parent->entry->codeSnips();
+ CodeSnip snip = snips.takeLast();
+ snip.addTemplateInstance(m_current->value.templateInstance);
+ snips.append(snip);
+ m_current->parent->entry->setCodeSnips(snips);
+ break;
+ }
+ case StackElement::NativeToTarget:
+ case StackElement::AddConversion:
+ m_contextStack.top()->codeSnips.last().addTemplateInstance(m_current->value.templateInstance);
+ break;
+ case StackElement::Template:
+ m_current->parent->value.templateEntry->addTemplateInstance(m_current->value.templateInstance);
+ break;
+ case StackElement::CustomMetaConstructor:
+ case StackElement::CustomMetaDestructor:
+ m_current->parent->value.customFunction->addTemplateInstance(m_current->value.templateInstance);
+ break;
+ case StackElement::ConversionRule:
+ m_contextStack.top()->functionMods.last().argument_mods.last().conversion_rules.last().addTemplateInstance(m_current->value.templateInstance);
+ break;
+ case StackElement::InjectCodeInFunction:
+ m_contextStack.top()->functionMods.last().snips.last().addTemplateInstance(m_current->value.templateInstance);
+ break;
+ default:
+ break; // nada
+ };
+ break;
+ default:
+ break;
+ }
+
+ if (m_current->type == StackElement::Root
+ || m_current->type == StackElement::NamespaceTypeEntry
+ || m_current->type == StackElement::InterfaceTypeEntry
+ || m_current->type == StackElement::ObjectTypeEntry
+ || m_current->type == StackElement::ValueTypeEntry
+ || m_current->type == StackElement::PrimitiveTypeEntry) {
+ StackElementContext* context = m_contextStack.pop();
+ delete context;
+ }
+
+ StackElement *child = m_current;
+ m_current = m_current->parent;
+ delete(child);
+
+ return true;
+}
+
+template <class String> // QString/QStringRef
+bool Handler::characters(const String &ch)
+{
+ if (m_currentDroppedEntry || m_ignoreDepth)
+ return true;
+
+ if (m_current->type == StackElement::Template) {
+ m_current->value.templateEntry->addCode(ch);
+ return true;
+ }
+
+ if (m_current->type == StackElement::CustomMetaConstructor || m_current->type == StackElement::CustomMetaDestructor) {
+ m_current->value.customFunction->addCode(ch);
+ return true;
+ }
+
+ if (m_current->type == StackElement::ConversionRule
+ && m_current->parent->type == StackElement::ModifyArgument) {
+ m_contextStack.top()->functionMods.last().argument_mods.last().conversion_rules.last().addCode(ch);
+ return true;
+ }
+
+ if (m_current->type == StackElement::NativeToTarget || m_current->type == StackElement::AddConversion) {
+ m_contextStack.top()->codeSnips.last().addCode(ch);
+ return true;
+ }
+
+ if (m_current->parent) {
+ if ((m_current->type & StackElement::CodeSnipMask)) {
+ CodeSnipList snips;
+ switch (m_current->parent->type) {
+ case StackElement::Root:
+ snips = m_current->parent->entry->codeSnips();
+ snips.last().addCode(ch);
+ m_current->parent->entry->setCodeSnips(snips);
+ break;
+ case StackElement::ModifyFunction:
+ case StackElement::AddFunction:
+ m_contextStack.top()->functionMods.last().snips.last().addCode(ch);
+ m_contextStack.top()->functionMods.last().modifiers |= FunctionModification::CodeInjection;
+ break;
+ case StackElement::NamespaceTypeEntry:
+ case StackElement::ObjectTypeEntry:
+ case StackElement::ValueTypeEntry:
+ case StackElement::InterfaceTypeEntry:
+ m_contextStack.top()->codeSnips.last().addCode(ch);
+ break;
+ default:
+ Q_ASSERT(false);
+ };
+ return true;
+ }
+ }
+
+ if (m_current->type & StackElement::DocumentationMask)
+ m_contextStack.top()->docModifications.last().setCode(ch);
+
+ return true;
+}
+
+bool Handler::importFileElement(const QXmlStreamAttributes &atts)
+{
+ const QString fileName = atts.value(nameAttribute()).toString();
+ if (fileName.isEmpty()) {
+ m_error = QLatin1String("Required attribute 'name' missing for include-file tag.");
+ return false;
+ }
+
+ QFile file(fileName);
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ file.setFileName(QLatin1String(":/trolltech/generator/") + fileName);
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ m_error = QString::fromLatin1("Could not open file: '%1'").arg(QDir::toNativeSeparators(fileName));
+ return false;
+ }
+ }
+
+ const QStringRef quoteFrom = atts.value(quoteAfterLineAttribute());
+ bool foundFromOk = quoteFrom.isEmpty();
+ bool from = quoteFrom.isEmpty();
+
+ const QStringRef quoteTo = atts.value(quoteBeforeLineAttribute());
+ bool foundToOk = quoteTo.isEmpty();
+ bool to = true;
+
+ QTextStream in(&file);
+ while (!in.atEnd()) {
+ QString line = in.readLine();
+ if (from && to && line.contains(quoteTo)) {
+ to = false;
+ foundToOk = true;
+ break;
+ }
+ if (from && to)
+ characters(line + QLatin1Char('\n'));
+ if (!from && line.contains(quoteFrom)) {
+ from = true;
+ foundFromOk = true;
+ }
+ }
+ if (!foundFromOk || !foundToOk) {
+ QString fromError = QStringLiteral("Could not find quote-after-line='%1' in file '%2'.")
+ .arg(quoteFrom.toString(), fileName);
+ QString toError = QStringLiteral("Could not find quote-before-line='%1' in file '%2'.")
+ .arg(quoteTo.toString(), fileName);
+
+ if (!foundToOk)
+ m_error = toError;
+ if (!foundFromOk)
+ m_error = fromError;
+ if (!foundFromOk && !foundToOk)
+ m_error = fromError + QLatin1Char(' ') + toError;
+ return false;
+ }
+
+ return true;
+}
+
+bool Handler::convertBoolean(const QString &_value, const QString &attributeName, bool defaultValue)
+{
+ QString value = _value.toLower();
+ if (value == QLatin1String("true") || value == QLatin1String("yes"))
+ return true;
+ else if (value == QLatin1String("false") || value == QLatin1String("no"))
+ return false;
+ else {
+ QString warn = QStringLiteral("Boolean value '%1' not supported in attribute '%2'. Use 'yes' or 'no'. Defaulting to '%3'.")
+ .arg(value, attributeName,
+ defaultValue ? QLatin1String("yes") : QLatin1String("no"));
+
+ qCWarning(lcShiboken).noquote().nospace() << warn;
+ return defaultValue;
+ }
+}
+
+static bool convertRemovalAttribute(const QString& removalAttribute, Modification& mod, QString& errorMsg)
+{
+ QString remove = removalAttribute.toLower();
+ if (!remove.isEmpty()) {
+ if (remove == QLatin1String("all")) {
+ mod.removal = TypeSystem::All;
+ } else if (remove == QLatin1String("target")) {
+ mod.removal = TypeSystem::TargetLangAndNativeCode;
+ } else {
+ errorMsg = QString::fromLatin1("Bad removal type '%1'").arg(remove);
+ return false;
+ }
+ }
+ return true;
+}
+
+static void getNamePrefixRecursive(StackElement* element, QStringList& names)
+{
+ if (!element->parent || !element->parent->entry)
+ return;
+ getNamePrefixRecursive(element->parent, names);
+ names << element->parent->entry->name();
+}
+
+static QString getNamePrefix(StackElement* element)
+{
+ QStringList names;
+ getNamePrefixRecursive(element, names);
+ return names.join(QLatin1Char('.'));
+}
+
+// Returns empty string if there's no error.
+static QString checkSignatureError(const QString& signature, const QString& tag)
+{
+ QString funcName = signature.left(signature.indexOf(QLatin1Char('('))).trimmed();
+ static QRegExp whiteSpace(QLatin1String("\\s"));
+ if (!funcName.startsWith(QLatin1String("operator ")) && funcName.contains(whiteSpace)) {
+ return QString::fromLatin1("Error in <%1> tag signature attribute '%2'.\n"
+ "White spaces aren't allowed in function names, "
+ "and return types should not be part of the signature.")
+ .arg(tag, signature);
+ }
+ return QString();
+}
+
+void Handler::addFlags(const QString &name, QString flagName,
+ const QHash<QString, QString> &attributes, double since)
+{
+ FlagsTypeEntry *ftype = new FlagsTypeEntry(QLatin1String("QFlags<") + name + QLatin1Char('>'), since);
+ ftype->setOriginator(m_currentEnum);
+ // Try to get the guess the qualified flag name
+ const int lastSepPos = name.lastIndexOf(colonColon());
+ if (lastSepPos >= 0 && !flagName.contains(colonColon()))
+ flagName.prepend(name.left(lastSepPos + 2));
+
+ ftype->setOriginalName(flagName);
+ ftype->setCodeGeneration(m_generate);
+ QString n = ftype->originalName();
+
+ QStringList lst = n.split(colonColon());
+ if (QStringList(lst.mid(0, lst.size() - 1)).join(colonColon()) != m_currentEnum->targetLangQualifier()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("enum %1 and flags %2 differ in qualifiers")
+ // avoid constFirst to stay Qt 5.5 compatible
+ .arg(m_currentEnum->targetLangQualifier(), lst.first());
+ }
+
+ ftype->setFlagsName(lst.last());
+ m_currentEnum->setFlags(ftype);
+
+ m_database->addFlagsType(ftype);
+ m_database->addType(ftype);
+
+ QString revision = attributes.value(QLatin1String("flags-revision"));
+ if (revision.isEmpty())
+ revision = attributes.value(QLatin1String("revision"));
+ setTypeRevision(ftype, revision.toInt());
+}
+
+bool Handler::handleSmartPointerEntry(StackElement *element,
+ QHash<QString, QString> &attributes,
+ const QString &name,
+ double since)
+{
+ QString smartPointerType = attributes[QLatin1String("type")];
+ if (smartPointerType.isEmpty()) {
+ m_error = QLatin1String("No type specified for the smart pointer. Currently supported types: 'shared',");
+ return false;
+ }
+ if (smartPointerType != QLatin1String("shared")) {
+ m_error = QLatin1String("Currently only the 'shared' type is supported.");
+ return false;
+ }
+
+ QString getter = attributes[QLatin1String("getter")];
+ if (getter.isEmpty()) {
+ m_error = QLatin1String("No function getter name specified for getting the raw pointer held by the smart pointer.");
+ return false;
+ }
+
+ QString refCountMethodName = attributes[QLatin1String("ref-count-method")];
+ QString signature = getter + QLatin1String("()");
+
+ signature = TypeDatabase::normalizedSignature(signature);
+ if (signature.isEmpty()) {
+ m_error = QLatin1String("No signature for the smart pointer getter found.");
+ return false;
+ }
+
+ QString errorString = checkSignatureError(signature,
+ QLatin1String("smart-pointer-type"));
+ if (!errorString.isEmpty()) {
+ m_error = errorString;
+ return false;
+ }
+
+ SmartPointerTypeEntry *type = new SmartPointerTypeEntry(name,
+ getter,
+ smartPointerType,
+ refCountMethodName,
+ since);
+ type->setTargetLangPackage(m_defaultPackage);
+ type->setCodeGeneration(m_generate);
+ element->entry = type;
+ return true;
+}
+
+bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts)
+{
+ if (m_ignoreDepth) {
+ ++m_ignoreDepth;
+ return true;
+ }
+
+ if (!m_defaultPackage.isEmpty() && atts.hasAttribute(sinceAttribute())) {
+ TypeDatabase* td = TypeDatabase::instance();
+ if (!td->checkApiVersion(m_defaultPackage, atts.value(sinceAttribute()).toString())) {
+ ++m_ignoreDepth;
+ return true;
+ }
+ }
+
+ const QString tagName = n.toString().toLower();
+ if (tagName == QLatin1String("import-file"))
+ return importFileElement(atts);
+
+ const QHash<QString, StackElement::ElementType>::const_iterator tit = tagNames.constFind(tagName);
+ if (tit == tagNames.constEnd()) {
+ m_error = QStringLiteral("Unknown tag name: '%1'").arg(tagName);
+ return false;
+ }
+
+ if (m_currentDroppedEntry) {
+ ++m_currentDroppedEntryDepth;
+ return true;
+ }
+
+ StackElement* element = new StackElement(m_current);
+ element->type = tit.value();
+
+ if (element->type == StackElement::Root && m_generate == TypeEntry::GenerateAll)
+ customConversionsForReview.clear();
+
+ if (element->type == StackElement::Root
+ || element->type == StackElement::NamespaceTypeEntry
+ || element->type == StackElement::InterfaceTypeEntry
+ || element->type == StackElement::ObjectTypeEntry
+ || element->type == StackElement::ValueTypeEntry
+ || element->type == StackElement::PrimitiveTypeEntry) {
+ m_contextStack.push(new StackElementContext());
+ }
+
+ if (element->type & StackElement::TypeEntryMask) {
+ QHash<QString, QString> attributes;
+ attributes.insert(nameAttribute(), QString());
+ attributes.insert(QLatin1String("revision"), QLatin1String("0"));
+ attributes.insert(sinceAttribute(), QLatin1String("0"));
+
+ switch (element->type) {
+ case StackElement::PrimitiveTypeEntry:
+ attributes.insert(QLatin1String("target-lang-name"), QString());
+ attributes.insert(QLatin1String("target-lang-api-name"), QString());
+ attributes.insert(QLatin1String("preferred-conversion"), QLatin1String("yes"));
+ attributes.insert(QLatin1String("preferred-target-lang-type"), QLatin1String("yes"));
+ attributes.insert(QLatin1String("default-constructor"), QString());
+ break;
+ case StackElement::ContainerTypeEntry:
+ attributes.insert(QLatin1String("type"), QString());
+ break;
+ case StackElement::SmartPointerTypeEntry:
+ attributes.insert(QLatin1String("type"), QString());
+ attributes.insert(QLatin1String("getter"), QString());
+ attributes.insert(QLatin1String("ref-count-method"), QString());
+ break;
+ case StackElement::EnumTypeEntry:
+ attributes.insert(flagsAttribute(), QString());
+ attributes.insert(QLatin1String("flags-revision"), QString());
+ attributes.insert(QLatin1String("upper-bound"), QString());
+ attributes.insert(QLatin1String("lower-bound"), QString());
+ attributes.insert(QLatin1String("force-integer"), QLatin1String("no"));
+ attributes.insert(QLatin1String("extensible"), QLatin1String("no"));
+ attributes.insert(QLatin1String("identified-by-value"), QString());
+ break;
+ case StackElement::ValueTypeEntry:
+ attributes.insert(QLatin1String("default-constructor"), QString());
+ // fall throooough
+ case StackElement::ObjectTypeEntry:
+ attributes.insert(QLatin1String("force-abstract"), QLatin1String("no"));
+ attributes.insert(QLatin1String("deprecated"), QLatin1String("no"));
+ attributes.insert(QLatin1String("hash-function"), QString());
+ attributes.insert(QLatin1String("stream"), QLatin1String("no"));
+ // fall throooough
+ case StackElement::InterfaceTypeEntry:
+ attributes[QLatin1String("default-superclass")] = m_defaultSuperclass;
+ attributes.insert(QLatin1String("polymorphic-id-expression"), QString());
+ attributes.insert(QLatin1String("delete-in-main-thread"), QLatin1String("no"));
+ attributes.insert(QLatin1String("held-type"), QString());
+ attributes.insert(QLatin1String("copyable"), QString());
+ // fall through
+ case StackElement::NamespaceTypeEntry:
+ attributes.insert(QLatin1String("target-lang-name"), QString());
+ attributes[QLatin1String("package")] = m_defaultPackage;
+ attributes.insert(QLatin1String("expense-cost"), QLatin1String("1"));
+ attributes.insert(QLatin1String("expense-limit"), QLatin1String("none"));
+ attributes.insert(QLatin1String("polymorphic-base"), QLatin1String("no"));
+ attributes.insert(QLatin1String("generate"), QLatin1String("yes"));
+ attributes.insert(QLatin1String("target-type"), QString());
+ attributes.insert(QLatin1String("generic-class"), QLatin1String("no"));
+ break;
+ case StackElement::FunctionTypeEntry:
+ attributes.insert(QLatin1String("signature"), QString());
+ attributes.insert(QLatin1String("rename"), QString());
+ break;
+ default:
+ { } // nada
+ };
+
+ fetchAttributeValues(tagName, atts, &attributes);
+ QString name = attributes[nameAttribute()];
+ double since = attributes[sinceAttribute()].toDouble();
+
+ if (m_database->hasDroppedTypeEntries()) {
+ QString identifier = getNamePrefix(element) + QLatin1Char('.');
+ identifier += (element->type == StackElement::FunctionTypeEntry ? attributes[QLatin1String("signature")] : name);
+ if (m_database->shouldDropTypeEntry(identifier)) {
+ m_currentDroppedEntry = element;
+ m_currentDroppedEntryDepth = 1;
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug)) {
+ qCDebug(lcShiboken)
+ << QStringLiteral("Type system entry '%1' was intentionally dropped from generation.").arg(identifier);
+ }
+ return true;
+ }
+ }
+
+ // The top level tag 'function' has only the 'signature' tag
+ // and we should extract the 'name' value from it.
+ if (element->type == StackElement::FunctionTypeEntry) {
+ QString signature = attributes[QLatin1String("signature")];
+ name = signature.left(signature.indexOf(QLatin1Char('('))).trimmed();
+ QString errorString = checkSignatureError(signature, QLatin1String("function"));
+ if (!errorString.isEmpty()) {
+ m_error = errorString;
+ return false;
+ }
+ QString rename = attributes[QLatin1String("rename")];
+ if (!rename.isEmpty()) {
+ static QRegExp functionNameRegExp(QLatin1String("^[a-zA-Z_][a-zA-Z0-9_]*$"));
+ if (!functionNameRegExp.exactMatch(rename)) {
+ m_error = QLatin1String("can not rename '") + signature + QLatin1String("', '")
+ + rename + QLatin1String("' is not a valid function name");
+ return false;
+ }
+ FunctionModification mod(since);
+ mod.signature = signature;
+ mod.renamedToName = attributes[QLatin1String("rename")];
+ mod.modifiers |= Modification::Rename;
+ m_contextStack.top()->functionMods << mod;
+ }
+ }
+
+ // We need to be able to have duplicate primitive type entries,
+ // or it's not possible to cover all primitive target language
+ // types (which we need to do in order to support fake meta objects)
+ if (element->type != StackElement::PrimitiveTypeEntry
+ && element->type != StackElement::FunctionTypeEntry) {
+ TypeEntry *tmp = m_database->findType(name);
+ if (tmp)
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Duplicate type entry: '%1'").arg(name);
+ }
+
+ if (element->type == StackElement::EnumTypeEntry) {
+ if (name.isEmpty()) {
+ name = attributes[QLatin1String("identified-by-value")];
+ } else if (!attributes[QLatin1String("identified-by-value")].isEmpty()) {
+ m_error = QLatin1String("can't specify both 'name' and 'identified-by-value' attributes");
+ return false;
+ }
+ }
+
+ // Fix type entry name using nesting information.
+ if (element->type & StackElement::TypeEntryMask
+ && element->parent && element->parent->type != StackElement::Root) {
+ name = element->parent->entry->name() + colonColon() + name;
+ }
+
+
+ if (name.isEmpty()) {
+ m_error = QLatin1String("no 'name' attribute specified");
+ return false;
+ }
+
+ switch (element->type) {
+ case StackElement::CustomTypeEntry:
+ element->entry = new TypeEntry(name, TypeEntry::CustomType, since);
+ break;
+ case StackElement::PrimitiveTypeEntry: {
+ QString targetLangName = attributes[QLatin1String("target-lang-name")];
+ QString targetLangApiName = attributes[QLatin1String("target-lang-api-name")];
+ QString preferredConversion = attributes[QLatin1String("preferred-conversion")].toLower();
+ QString preferredTargetLangType = attributes[QLatin1String("preferred-target-lang-type")].toLower();
+ QString defaultConstructor = attributes[QLatin1String("default-constructor")];
+
+ if (targetLangName.isEmpty())
+ targetLangName = name;
+ if (targetLangApiName.isEmpty())
+ targetLangApiName = name;
+
+ PrimitiveTypeEntry *type = new PrimitiveTypeEntry(name, since);
+ type->setCodeGeneration(m_generate);
+ type->setTargetLangName(targetLangName);
+ type->setTargetLangApiName(targetLangApiName);
+ type->setTargetLangPackage(m_defaultPackage);
+ type->setDefaultConstructor(defaultConstructor);
+
+ bool preferred;
+ preferred = convertBoolean(preferredConversion, QLatin1String("preferred-conversion"), true);
+ type->setPreferredConversion(preferred);
+ preferred = convertBoolean(preferredTargetLangType,
+ QLatin1String("preferred-target-lang-type"), true);
+ type->setPreferredTargetLangType(preferred);
+
+ element->entry = type;
+ }
+ break;
+
+ case StackElement::ContainerTypeEntry: {
+ QString typeName = attributes[QLatin1String("type")];
+ ContainerTypeEntry::Type containerType =
+ ContainerTypeEntry::containerTypeFromString(typeName);
+ if (typeName.isEmpty()) {
+ m_error = QLatin1String("no 'type' attribute specified");
+ return false;
+ } else if (containerType == ContainerTypeEntry::NoContainer) {
+ m_error = QLatin1String("there is no container of type ") + typeName;
+ return false;
+ }
+
+ ContainerTypeEntry *type = new ContainerTypeEntry(name, containerType, since);
+ type->setCodeGeneration(m_generate);
+ element->entry = type;
+ }
+ break;
+
+ case StackElement::SmartPointerTypeEntry: {
+ bool result = handleSmartPointerEntry(element, attributes, name, since);
+ if (!result)
+ return result;
+ }
+ break;
+
+ case StackElement::EnumTypeEntry: {
+ QStringList names = name.split(colonColon());
+ if (names.size() == 1)
+ m_currentEnum = new EnumTypeEntry(QString(), name, since);
+ else
+ m_currentEnum =
+ new EnumTypeEntry(QStringList(names.mid(0, names.size() - 1)).join(colonColon()),
+ names.last(), since);
+ m_currentEnum->setAnonymous(!attributes[QLatin1String("identified-by-value")].isEmpty());
+ element->entry = m_currentEnum;
+ m_currentEnum->setCodeGeneration(m_generate);
+ m_currentEnum->setTargetLangPackage(m_defaultPackage);
+ m_currentEnum->setUpperBound(attributes[QLatin1String("upper-bound")]);
+ m_currentEnum->setLowerBound(attributes[QLatin1String("lower-bound")]);
+ m_currentEnum->setForceInteger(convertBoolean(attributes[QLatin1String("force-integer")], QLatin1String("force-integer"), false));
+ m_currentEnum->setExtensible(convertBoolean(attributes[QLatin1String("extensible")], QLatin1String("extensible"), false));
+
+ // put in the flags parallel...
+ const QString flagNames = attributes.value(flagsAttribute());
+ if (!flagNames.isEmpty()) {
+ foreach (const QString &flagName, flagNames.split(QLatin1Char(',')))
+ addFlags(name, flagName.trimmed(), attributes, since);
+ }
+ }
+ break;
+
+ case StackElement::InterfaceTypeEntry: {
+ ObjectTypeEntry *otype = new ObjectTypeEntry(name, since);
+ QString targetLangName = attributes[QLatin1String("target-lang-name")];
+ if (targetLangName.isEmpty())
+ targetLangName = name;
+ InterfaceTypeEntry *itype =
+ new InterfaceTypeEntry(InterfaceTypeEntry::interfaceName(targetLangName), since);
+
+ if (!convertBoolean(attributes[QLatin1String("generate")], QLatin1String("generate"), true))
+ itype->setCodeGeneration(TypeEntry::GenerateForSubclass);
+ else
+ itype->setCodeGeneration(m_generate);
+ otype->setDesignatedInterface(itype);
+ itype->setOrigin(otype);
+ element->entry = otype;
+ }
+ // fall through
+ case StackElement::ValueTypeEntry: {
+ if (!element->entry) {
+ ValueTypeEntry* typeEntry = new ValueTypeEntry(name, since);
+ QString defaultConstructor = attributes[QLatin1String("default-constructor")];
+ if (!defaultConstructor.isEmpty())
+ typeEntry->setDefaultConstructor(defaultConstructor);
+ element->entry = typeEntry;
+ }
+
+ // fall through
+ case StackElement::NamespaceTypeEntry:
+ if (!element->entry)
+ element->entry = new NamespaceTypeEntry(name, since);
+
+ // fall through
+ case StackElement::ObjectTypeEntry:
+ if (!element->entry)
+ element->entry = new ObjectTypeEntry(name, since);
+
+ element->entry->setStream(attributes[QLatin1String("stream")] == QLatin1String("yes"));
+
+ ComplexTypeEntry *ctype = static_cast<ComplexTypeEntry *>(element->entry);
+ ctype->setTargetLangPackage(attributes[QLatin1String("package")]);
+ ctype->setDefaultSuperclass(attributes[QLatin1String("default-superclass")]);
+ ctype->setGenericClass(convertBoolean(attributes[QLatin1String("generic-class")], QLatin1String("generic-class"), false));
+
+ if (!convertBoolean(attributes[QLatin1String("generate")], QLatin1String("generate"), true))
+ element->entry->setCodeGeneration(TypeEntry::GenerateForSubclass);
+ else
+ element->entry->setCodeGeneration(m_generate);
+
+ QString targetLangName = attributes[QLatin1String("target-lang-name")];
+ if (!targetLangName.isEmpty())
+ ctype->setTargetLangName(targetLangName);
+
+ // The expense policy
+ QString limit = attributes[QLatin1String("expense-limit")];
+ if (!limit.isEmpty() && limit != QLatin1String("none")) {
+ ExpensePolicy ep;
+ ep.limit = limit.toInt();
+ ep.cost = attributes[QLatin1String("expense-cost")];
+ ctype->setExpensePolicy(ep);
+ }
+
+
+ ctype->setIsPolymorphicBase(convertBoolean(attributes[QLatin1String("polymorphic-base")], QLatin1String("polymorphic-base"), false));
+ ctype->setPolymorphicIdValue(attributes[QLatin1String("polymorphic-id-expression")]);
+ //Copyable
+ if (attributes[QLatin1String("copyable")].isEmpty())
+ ctype->setCopyable(ComplexTypeEntry::Unknown);
+ else {
+ if (convertBoolean(attributes[QLatin1String("copyable")], QLatin1String("copyable"), false))
+ ctype->setCopyable(ComplexTypeEntry::CopyableSet);
+ else
+ ctype->setCopyable(ComplexTypeEntry::NonCopyableSet);
+
+ }
+
+ if (element->type == StackElement::ObjectTypeEntry || element->type == StackElement::ValueTypeEntry)
+ ctype->setHashFunction(attributes[QLatin1String("hash-function")]);
+
+
+ ctype->setHeldType(attributes[QLatin1String("held-type")]);
+
+ if (element->type == StackElement::ObjectTypeEntry
+ || element->type == StackElement::ValueTypeEntry) {
+ if (convertBoolean(attributes[QLatin1String("force-abstract")], QLatin1String("force-abstract"), false))
+ ctype->setTypeFlags(ctype->typeFlags() | ComplexTypeEntry::ForceAbstract);
+ if (convertBoolean(attributes[QLatin1String("deprecated")], QLatin1String("deprecated"), false))
+ ctype->setTypeFlags(ctype->typeFlags() | ComplexTypeEntry::Deprecated);
+ }
+
+ if (element->type == StackElement::InterfaceTypeEntry
+ || element->type == StackElement::ValueTypeEntry
+ || element->type == StackElement::ObjectTypeEntry) {
+ if (convertBoolean(attributes[QLatin1String("delete-in-main-thread")], QLatin1String("delete-in-main-thread"), false))
+ ctype->setTypeFlags(ctype->typeFlags() | ComplexTypeEntry::DeleteInMainThread);
+ }
+
+ QString targetType = attributes[QLatin1String("target-type")];
+ if (!targetType.isEmpty() && element->entry->isComplex())
+ static_cast<ComplexTypeEntry *>(element->entry)->setTargetType(targetType);
+
+ // ctype->setInclude(Include(Include::IncludePath, ctype->name()));
+ ctype = ctype->designatedInterface();
+ if (ctype)
+ ctype->setTargetLangPackage(attributes[QLatin1String("package")]);
+
+ }
+ break;
+ case StackElement::FunctionTypeEntry: {
+ QString signature = attributes[QLatin1String("signature")];
+ signature = TypeDatabase::normalizedSignature(signature);
+ element->entry = m_database->findType(name);
+ if (element->entry) {
+ if (element->entry->type() == TypeEntry::FunctionType) {
+ reinterpret_cast<FunctionTypeEntry*>(element->entry)->addSignature(signature);
+ } else {
+ m_error = QStringLiteral("%1 expected to be a function, but isn't! Maybe it was already declared as a class or something else.")
+ .arg(name);
+ return false;
+ }
+ } else {
+ element->entry = new FunctionTypeEntry(name, signature, since);
+ element->entry->setCodeGeneration(m_generate);
+ }
+ }
+ break;
+ default:
+ Q_ASSERT(false);
+ };
+
+ if (element->entry) {
+ m_database->addType(element->entry);
+ setTypeRevision(element->entry, attributes[QLatin1String("revision")].toInt());
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Type: %1 was rejected by typesystem").arg(name);
+ }
+
+ } else if (element->type == StackElement::InjectDocumentation) {
+ // check the XML tag attributes
+ QHash<QString, QString> attributes;
+ attributes.insert(QLatin1String("mode"), QLatin1String("replace"));
+ attributes.insert(QLatin1String("format"), QLatin1String("native"));
+ attributes.insert(sinceAttribute(), QLatin1String("0"));
+
+ fetchAttributeValues(tagName, atts, &attributes);
+ double since = attributes[sinceAttribute()].toDouble();
+
+ const int validParent = StackElement::TypeEntryMask
+ | StackElement::ModifyFunction
+ | StackElement::ModifyField;
+ if (m_current->parent && m_current->parent->type & validParent) {
+ QString modeName = attributes[QLatin1String("mode")];
+ TypeSystem::DocModificationMode mode;
+ if (modeName == QLatin1String("append")) {
+ mode = TypeSystem::DocModificationAppend;
+ } else if (modeName == QLatin1String("prepend")) {
+ mode = TypeSystem::DocModificationPrepend;
+ } else if (modeName == QLatin1String("replace")) {
+ mode = TypeSystem::DocModificationReplace;
+ } else {
+ m_error = QLatin1String("Unknow documentation injection mode: ") + modeName;
+ return false;
+ }
+
+ static QHash<QString, TypeSystem::Language> languageNames;
+ if (languageNames.isEmpty()) {
+ languageNames[QLatin1String("target")] = TypeSystem::TargetLangCode;
+ languageNames[QLatin1String("native")] = TypeSystem::NativeCode;
+ }
+
+ QString format = attributes[QLatin1String("format")].toLower();
+ TypeSystem::Language lang = languageNames.value(format, TypeSystem::NoLanguage);
+ if (lang == TypeSystem::NoLanguage) {
+ m_error = QStringLiteral("unsupported class attribute: '%1'").arg(format);
+ return false;
+ }
+
+ QString signature = m_current->type & StackElement::TypeEntryMask ? QString() : m_currentSignature;
+ DocModification mod(mode, signature, since);
+ mod.format = lang;
+ m_contextStack.top()->docModifications << mod;
+ } else {
+ m_error = QLatin1String("inject-documentation must be inside modify-function, "
+ "modify-field or other tags that creates a type");
+ return false;
+ }
+ } else if (element->type == StackElement::ModifyDocumentation) {
+ // check the XML tag attributes
+ QHash<QString, QString> attributes;
+ attributes.insert(QLatin1String("xpath"), QString());
+ attributes.insert(sinceAttribute(), QLatin1String("0"));
+ fetchAttributeValues(tagName, atts, &attributes);
+ double since = attributes[sinceAttribute()].toDouble();
+
+ const int validParent = StackElement::TypeEntryMask
+ | StackElement::ModifyFunction
+ | StackElement::ModifyField;
+ if (m_current->parent && m_current->parent->type & validParent) {
+ QString signature = (m_current->type & StackElement::TypeEntryMask) ? QString() : m_currentSignature;
+ m_contextStack.top()->docModifications << DocModification(attributes[QLatin1String("xpath")], signature, since);
+ } else {
+ m_error = QLatin1String("modify-documentation must be inside modify-function, "
+ "modify-field or other tags that creates a type");
+ return false;
+ }
+ } else if (element->type != StackElement::None) {
+ bool topLevel = element->type == StackElement::Root
+ || element->type == StackElement::SuppressedWarning
+ || element->type == StackElement::Rejection
+ || element->type == StackElement::LoadTypesystem
+ || element->type == StackElement::InjectCode
+ || element->type == StackElement::ExtraIncludes
+ || element->type == StackElement::ConversionRule
+ || element->type == StackElement::AddFunction
+ || element->type == StackElement::Template;
+
+ if (!topLevel && m_current->type == StackElement::Root) {
+ m_error = QStringLiteral("Tag requires parent: '%1'").arg(tagName);
+ return false;
+ }
+
+ StackElement topElement = !m_current ? StackElement(0) : *m_current;
+ element->entry = topElement.entry;
+
+ QHash<QString, QString> attributes;
+ attributes.insert(sinceAttribute(), QLatin1String("0"));
+ switch (element->type) {
+ case StackElement::Root:
+ attributes.insert(QLatin1String("package"), QString());
+ attributes.insert(QLatin1String("default-superclass"), QString());
+ break;
+ case StackElement::LoadTypesystem:
+ attributes.insert(nameAttribute(), QString());
+ attributes.insert(QLatin1String("generate"), QLatin1String("yes"));
+ break;
+ case StackElement::NoNullPointers:
+ attributes.insert(QLatin1String("default-value"), QString());
+ break;
+ case StackElement::SuppressedWarning:
+ attributes.insert(QLatin1String("text"), QString());
+ break;
+ case StackElement::ReplaceDefaultExpression:
+ attributes.insert(QLatin1String("with"), QString());
+ break;
+ case StackElement::DefineOwnership:
+ attributes.insert(QLatin1String("class"), QLatin1String("target"));
+ attributes.insert(QLatin1String("owner"), QString());
+ break;
+ case StackElement::AddFunction:
+ attributes.insert(QLatin1String("signature"), QString());
+ attributes.insert(QLatin1String("return-type"), QLatin1String("void"));
+ attributes.insert(QLatin1String("access"), QLatin1String("public"));
+ attributes.insert(QLatin1String("static"), QLatin1String("no"));
+ break;
+ case StackElement::ModifyFunction:
+ attributes.insert(QLatin1String("signature"), QString());
+ attributes.insert(QLatin1String("access"), QString());
+ attributes.insert(QLatin1String("remove"), QString());
+ attributes.insert(QLatin1String("rename"), QString());
+ attributes.insert(QLatin1String("deprecated"), QLatin1String("no"));
+ attributes.insert(QLatin1String("associated-to"), QString());
+ attributes.insert(QLatin1String("virtual-slot"), QLatin1String("no"));
+ attributes.insert(QLatin1String("thread"), QLatin1String("no"));
+ attributes.insert(QLatin1String("allow-thread"), QLatin1String("no"));
+ break;
+ case StackElement::ModifyArgument:
+ attributes.insert(QLatin1String("index"), QString());
+ attributes.insert(QLatin1String("replace-value"), QString());
+ attributes.insert(QLatin1String("invalidate-after-use"), QLatin1String("no"));
+ break;
+ case StackElement::ModifyField:
+ attributes.insert(nameAttribute(), QString());
+ attributes.insert(QLatin1String("write"), QLatin1String("true"));
+ attributes.insert(QLatin1String("read"), QLatin1String("true"));
+ attributes.insert(QLatin1String("remove"), QString());
+ break;
+ case StackElement::Access:
+ attributes.insert(QLatin1String("modifier"), QString());
+ break;
+ case StackElement::Include:
+ attributes.insert(QLatin1String("file-name"), QString());
+ attributes.insert(QLatin1String("location"), QString());
+ break;
+ case StackElement::CustomMetaConstructor:
+ attributes[nameAttribute()] = topElement.entry->name().toLower() + QLatin1String("_create");
+ attributes.insert(QLatin1String("param-name"), QLatin1String("copy"));
+ break;
+ case StackElement::CustomMetaDestructor:
+ attributes[nameAttribute()] = topElement.entry->name().toLower() + QLatin1String("_delete");
+ attributes.insert(QLatin1String("param-name"), QLatin1String("copy"));
+ break;
+ case StackElement::ReplaceType:
+ attributes.insert(QLatin1String("modified-type"), QString());
+ break;
+ case StackElement::InjectCode:
+ attributes.insert(QLatin1String("class"), QLatin1String("target"));
+ attributes.insert(QLatin1String("position"), QLatin1String("beginning"));
+ attributes.insert(QLatin1String("file"), QString());
+ break;
+ case StackElement::ConversionRule:
+ attributes.insert(QLatin1String("class"), QString());
+ attributes.insert(QLatin1String("file"), QString());
+ break;
+ case StackElement::TargetToNative:
+ attributes.insert(QLatin1String("replace"), QLatin1String("yes"));
+ break;
+ case StackElement::AddConversion:
+ attributes.insert(QLatin1String("type"), QString());
+ attributes.insert(QLatin1String("check"), QString());
+ break;
+ case StackElement::RejectEnumValue:
+ attributes.insert(nameAttribute(), QString());
+ break;
+ case StackElement::ArgumentMap:
+ attributes.insert(QLatin1String("index"), QLatin1String("1"));
+ attributes.insert(QLatin1String("meta-name"), QString());
+ break;
+ case StackElement::Rename:
+ attributes.insert(QLatin1String("to"), QString());
+ break;
+ case StackElement::Rejection:
+ attributes.insert(QLatin1String("class"), QLatin1String("*"));
+ attributes.insert(QLatin1String("function-name"), QLatin1String("*"));
+ attributes.insert(QLatin1String("field-name"), QLatin1String("*"));
+ attributes.insert(QLatin1String("enum-name"), QLatin1String("*"));
+ break;
+ case StackElement::Removal:
+ attributes.insert(QLatin1String("class"), QLatin1String("all"));
+ break;
+ case StackElement::Template:
+ attributes.insert(nameAttribute(), QString());
+ break;
+ case StackElement::TemplateInstanceEnum:
+ attributes.insert(nameAttribute(), QString());
+ break;
+ case StackElement::Replace:
+ attributes.insert(QLatin1String("from"), QString());
+ attributes.insert(QLatin1String("to"), QString());
+ break;
+ case StackElement::ReferenceCount:
+ attributes.insert(QLatin1String("action"), QString());
+ attributes.insert(QLatin1String("variable-name"), QString());
+ break;
+ case StackElement::ParentOwner:
+ attributes.insert(QLatin1String("index"), QString());
+ attributes.insert(QLatin1String("action"), QString());
+ default:
+ { };
+ };
+
+ double since = 0;
+ if (attributes.count() > 0) {
+ fetchAttributeValues(tagName, atts, &attributes);
+ since = attributes[sinceAttribute()].toDouble();
+ }
+
+ switch (element->type) {
+ case StackElement::Root:
+ m_defaultPackage = attributes[QLatin1String("package")];
+ m_defaultSuperclass = attributes[QLatin1String("default-superclass")];
+ element->type = StackElement::Root;
+ {
+ TypeSystemTypeEntry* moduleEntry = reinterpret_cast<TypeSystemTypeEntry*>(
+ m_database->findType(m_defaultPackage));
+ element->entry = moduleEntry ? moduleEntry : new TypeSystemTypeEntry(m_defaultPackage, since);
+ element->entry->setCodeGeneration(m_generate);
+ }
+
+ if ((m_generate == TypeEntry::GenerateForSubclass ||
+ m_generate == TypeEntry::GenerateNothing) && !m_defaultPackage.isEmpty())
+ TypeDatabase::instance()->addRequiredTargetImport(m_defaultPackage);
+
+ if (!element->entry->qualifiedCppName().isEmpty())
+ m_database->addType(element->entry);
+ break;
+ case StackElement::LoadTypesystem: {
+ QString name = attributes[nameAttribute()];
+ if (name.isEmpty()) {
+ m_error = QLatin1String("No typesystem name specified");
+ return false;
+ }
+ bool generateChild = (convertBoolean(attributes[QLatin1String("generate")], QLatin1String("generate"), true) && (m_generate == TypeEntry::GenerateAll));
+ if (!m_database->parseFile(name, generateChild)) {
+ m_error = QStringLiteral("Failed to parse: '%1'").arg(name);
+ return false;
+ }
+ }
+ break;
+ case StackElement::RejectEnumValue: {
+ if (!m_currentEnum) {
+ m_error = QLatin1String("<reject-enum-value> node must be used inside a <enum-type> node");
+ return false;
+ }
+ QString name = attributes[nameAttribute()];
+ } break;
+ case StackElement::ReplaceType: {
+ if (topElement.type != StackElement::ModifyArgument) {
+ m_error = QLatin1String("Type replacement can only be specified for argument modifications");
+ return false;
+ }
+
+ if (attributes[QLatin1String("modified-type")].isEmpty()) {
+ m_error = QLatin1String("Type replacement requires 'modified-type' attribute");
+ return false;
+ }
+
+ m_contextStack.top()->functionMods.last().argument_mods.last().modified_type = attributes[QLatin1String("modified-type")];
+ }
+ break;
+ case StackElement::ConversionRule: {
+ if (topElement.type != StackElement::ModifyArgument
+ && topElement.type != StackElement::ValueTypeEntry
+ && topElement.type != StackElement::PrimitiveTypeEntry
+ && topElement.type != StackElement::ContainerTypeEntry) {
+ m_error = QLatin1String("Conversion rules can only be specified for argument modification, "
+ "value-type, primitive-type or container-type conversion.");
+ return false;
+ }
+
+ static QHash<QString, TypeSystem::Language> languageNames;
+ if (languageNames.isEmpty()) {
+ languageNames[QLatin1String("target")] = TypeSystem::TargetLangCode;
+ languageNames[QLatin1String("native")] = TypeSystem::NativeCode;
+ }
+
+ QString languageAttribute = attributes[QLatin1String("class")].toLower();
+ TypeSystem::Language lang = languageNames.value(languageAttribute, TypeSystem::NoLanguage);
+
+ if (topElement.type == StackElement::ModifyArgument) {
+ if (lang == TypeSystem::NoLanguage) {
+ m_error = QStringLiteral("unsupported class attribute: '%1'").arg(lang);
+ return false;
+ }
+
+ CodeSnip snip(since);
+ snip.language = lang;
+ m_contextStack.top()->functionMods.last().argument_mods.last().conversion_rules.append(snip);
+ } else {
+ if (topElement.entry->hasConversionRule() || topElement.entry->hasCustomConversion()) {
+ m_error = QLatin1String("Types can have only one conversion rule");
+ return false;
+ }
+
+ // The old conversion rule tag that uses a file containing the conversion
+ // will be kept temporarily for compatibility reasons.
+ QString sourceFile = attributes[QLatin1String("file")];
+ if (!sourceFile.isEmpty()) {
+ if (m_generate != TypeEntry::GenerateForSubclass
+ && m_generate != TypeEntry::GenerateNothing) {
+
+ const char* conversionFlag = NATIVE_CONVERSION_RULE_FLAG;
+ if (lang == TypeSystem::TargetLangCode)
+ conversionFlag = TARGET_CONVERSION_RULE_FLAG;
+
+ QFile conversionSource(sourceFile);
+ if (conversionSource.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ topElement.entry->setConversionRule(QLatin1String(conversionFlag) + QString::fromUtf8(conversionSource.readAll()));
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "File containing conversion code for "
+ << topElement.entry->name() << " type does not exist or is not readable: "
+ << sourceFile;
+ }
+ }
+ }
+
+ CustomConversion* customConversion = new CustomConversion(static_cast<TypeEntry*>(m_current->entry));
+ customConversionsForReview.append(customConversion);
+ }
+ }
+ break;
+ case StackElement::NativeToTarget: {
+ if (topElement.type != StackElement::ConversionRule) {
+ m_error = QLatin1String("Native to Target conversion code can only be specified for custom conversion rules.");
+ return false;
+ }
+ m_contextStack.top()->codeSnips << CodeSnip(0);
+ }
+ break;
+ case StackElement::TargetToNative: {
+ if (topElement.type != StackElement::ConversionRule) {
+ m_error = QLatin1String("Target to Native conversions can only be specified for custom conversion rules.");
+ return false;
+ }
+ bool replace = attributes[QLatin1String("replace")] == QLatin1String("yes");
+ static_cast<TypeEntry*>(m_current->entry)->customConversion()->setReplaceOriginalTargetToNativeConversions(replace);
+ }
+ break;
+ case StackElement::AddConversion: {
+ if (topElement.type != StackElement::TargetToNative) {
+ m_error = QLatin1String("Target to Native conversions can only be added inside 'target-to-native' tags.");
+ return false;
+ }
+ QString sourceTypeName = attributes[QLatin1String("type")];
+ if (sourceTypeName.isEmpty()) {
+ m_error = QLatin1String("Target to Native conversions must specify the input type with the 'type' attribute.");
+ return false;
+ }
+ QString typeCheck = attributes[QLatin1String("check")];
+ static_cast<TypeEntry*>(m_current->entry)->customConversion()->addTargetToNativeConversion(sourceTypeName, typeCheck);
+ m_contextStack.top()->codeSnips << CodeSnip(0);
+ }
+ break;
+ case StackElement::ModifyArgument: {
+ if (topElement.type != StackElement::ModifyFunction
+ && topElement.type != StackElement::AddFunction) {
+ m_error = QString::fromLatin1("argument modification requires function"
+ " modification as parent, was %1")
+ .arg(topElement.type, 0, 16);
+ return false;
+ }
+
+ QString index = attributes[QLatin1String("index")];
+ if (index == QLatin1String("return"))
+ index = QLatin1String("0");
+ else if (index == QLatin1String("this"))
+ index = QLatin1String("-1");
+
+ bool ok = false;
+ int idx = index.toInt(&ok);
+ if (!ok) {
+ m_error = QStringLiteral("Cannot convert '%1' to integer").arg(index);
+ return false;
+ }
+
+ QString replace_value = attributes[QLatin1String("replace-value")];
+
+ if (!replace_value.isEmpty() && idx) {
+ m_error = QLatin1String("replace-value is only supported for return values (index=0).");
+ return false;
+ }
+
+ ArgumentModification argumentModification = ArgumentModification(idx, since);
+ argumentModification.replace_value = replace_value;
+ argumentModification.resetAfterUse = convertBoolean(attributes[QLatin1String("invalidate-after-use")], QLatin1String("invalidate-after-use"), false);
+ m_contextStack.top()->functionMods.last().argument_mods.append(argumentModification);
+ }
+ break;
+ case StackElement::NoNullPointers: {
+ if (topElement.type != StackElement::ModifyArgument) {
+ m_error = QLatin1String("no-null-pointer requires argument modification as parent");
+ return false;
+ }
+
+ m_contextStack.top()->functionMods.last().argument_mods.last().noNullPointers = true;
+ if (!m_contextStack.top()->functionMods.last().argument_mods.last().index)
+ m_contextStack.top()->functionMods.last().argument_mods.last().nullPointerDefaultValue = attributes[QLatin1String("default-value")];
+ else if (!attributes[QLatin1String("default-value")].isEmpty())
+ qCWarning(lcShiboken) << "default values for null pointer guards are only effective for return values";
+
+ }
+ break;
+ case StackElement::DefineOwnership: {
+ if (topElement.type != StackElement::ModifyArgument) {
+ m_error = QLatin1String("define-ownership requires argument modification as parent");
+ return false;
+ }
+
+ static QHash<QString, TypeSystem::Language> languageNames;
+ if (languageNames.isEmpty()) {
+ languageNames[QLatin1String("target")] = TypeSystem::TargetLangCode;
+ languageNames[QLatin1String("native")] = TypeSystem::NativeCode;
+ }
+
+ QString classAttribute = attributes[QLatin1String("class")].toLower();
+ TypeSystem::Language lang = languageNames.value(classAttribute, TypeSystem::NoLanguage);
+ if (lang == TypeSystem::NoLanguage) {
+ m_error = QStringLiteral("unsupported class attribute: '%1'").arg(classAttribute);
+ return false;
+ }
+
+ static QHash<QString, TypeSystem::Ownership> ownershipNames;
+ if (ownershipNames.isEmpty()) {
+ ownershipNames[QLatin1String("target")] = TypeSystem::TargetLangOwnership;
+ ownershipNames[QLatin1String("c++")] = TypeSystem::CppOwnership;
+ ownershipNames[QLatin1String("default")] = TypeSystem::DefaultOwnership;
+ }
+
+ QString ownershipAttribute = attributes[QLatin1String("owner")].toLower();
+ TypeSystem::Ownership owner = ownershipNames.value(ownershipAttribute, TypeSystem::InvalidOwnership);
+ if (owner == TypeSystem::InvalidOwnership) {
+ m_error = QStringLiteral("unsupported owner attribute: '%1'").arg(ownershipAttribute);
+ return false;
+ }
+
+ m_contextStack.top()->functionMods.last().argument_mods.last().ownerships[lang] = owner;
+ }
+ break;
+ case StackElement::SuppressedWarning:
+ if (attributes[QLatin1String("text")].isEmpty())
+ qCWarning(lcShiboken) << "Suppressed warning with no text specified";
+ else
+ m_database->addSuppressedWarning(attributes[QLatin1String("text")]);
+ break;
+ case StackElement::ArgumentMap: {
+ if (!(topElement.type & StackElement::CodeSnipMask)) {
+ m_error = QLatin1String("Argument maps requires code injection as parent");
+ return false;
+ }
+
+ bool ok;
+ int pos = attributes[QLatin1String("index")].toInt(&ok);
+ if (!ok) {
+ m_error = QStringLiteral("Can't convert position '%1' to integer")
+ .arg(attributes[QLatin1String("position")]);
+ return false;
+ }
+
+ if (pos <= 0) {
+ m_error = QStringLiteral("Argument position %1 must be a positive number").arg(pos);
+ return false;
+ }
+
+ QString meta_name = attributes[QLatin1String("meta-name")];
+ if (meta_name.isEmpty())
+ qCWarning(lcShiboken) << "Empty meta name in argument map";
+
+
+ if (topElement.type == StackElement::InjectCodeInFunction)
+ m_contextStack.top()->functionMods.last().snips.last().argumentMap[pos] = meta_name;
+ else {
+ qCWarning(lcShiboken) << "Argument maps are only useful for injection of code "
+ "into functions.";
+ }
+ }
+ break;
+ case StackElement::Removal: {
+ if (topElement.type != StackElement::ModifyFunction) {
+ m_error = QLatin1String("Function modification parent required");
+ return false;
+ }
+
+ static QHash<QString, TypeSystem::Language> languageNames;
+ if (languageNames.isEmpty()) {
+ languageNames.insert(QLatin1String("target"), TypeSystem::TargetLangAndNativeCode);
+ languageNames.insert(QLatin1String("all"), TypeSystem::All);
+ }
+
+ QString languageAttribute = attributes[QLatin1String("class")].toLower();
+ TypeSystem::Language lang = languageNames.value(languageAttribute, TypeSystem::NoLanguage);
+ if (lang == TypeSystem::NoLanguage) {
+ m_error = QStringLiteral("unsupported class attribute: '%1'").arg(languageAttribute);
+ return false;
+ }
+
+ m_contextStack.top()->functionMods.last().removal = lang;
+ }
+ break;
+ case StackElement::Rename:
+ case StackElement::Access: {
+ if (topElement.type != StackElement::ModifyField
+ && topElement.type != StackElement::ModifyFunction
+ && topElement.type != StackElement::ModifyArgument) {
+ m_error = QLatin1String("Function, field or argument modification parent required");
+ return false;
+ }
+
+ Modification *mod = 0;
+ if (topElement.type == StackElement::ModifyFunction)
+ mod = &m_contextStack.top()->functionMods.last();
+ else if (topElement.type == StackElement::ModifyField)
+ mod = &m_contextStack.top()->fieldMods.last();
+
+ QString modifier;
+ if (element->type == StackElement::Rename) {
+ modifier = QLatin1String("rename");
+ QString renamed_to = attributes[QLatin1String("to")];
+ if (renamed_to.isEmpty()) {
+ m_error = QLatin1String("Rename modifier requires 'to' attribute");
+ return false;
+ }
+
+ if (topElement.type == StackElement::ModifyFunction)
+ mod->setRenamedTo(renamed_to);
+ else if (topElement.type == StackElement::ModifyField)
+ mod->setRenamedTo(renamed_to);
+ else
+ m_contextStack.top()->functionMods.last().argument_mods.last().renamed_to = renamed_to;
+ } else
+ modifier = attributes[QLatin1String("modifier")].toLower();
+
+
+ if (modifier.isEmpty()) {
+ m_error = QLatin1String("No access modification specified");
+ return false;
+ }
+
+ static QHash<QString, FunctionModification::Modifiers> modifierNames;
+ if (modifierNames.isEmpty()) {
+ modifierNames[QLatin1String("private")] = Modification::Private;
+ modifierNames[QLatin1String("public")] = Modification::Public;
+ modifierNames[QLatin1String("protected")] = Modification::Protected;
+ modifierNames[QLatin1String("friendly")] = Modification::Friendly;
+ modifierNames[QLatin1String("rename")] = Modification::Rename;
+ modifierNames[QLatin1String("final")] = Modification::Final;
+ modifierNames[QLatin1String("non-final")] = Modification::NonFinal;
+ }
+
+ if (!modifierNames.contains(modifier)) {
+ m_error = QStringLiteral("Unknown access modifier: '%1'").arg(modifier);
+ return false;
+ }
+
+ if (mod)
+ mod->modifiers |= modifierNames[modifier];
+ }
+ break;
+ case StackElement::RemoveArgument:
+ if (topElement.type != StackElement::ModifyArgument) {
+ m_error = QLatin1String("Removing argument requires argument modification as parent");
+ return false;
+ }
+
+ m_contextStack.top()->functionMods.last().argument_mods.last().removed = true;
+ break;
+
+ case StackElement::ModifyField: {
+ QString name = attributes[nameAttribute()];
+ if (name.isEmpty())
+ break;
+ FieldModification fm;
+ fm.name = name;
+ fm.modifiers = 0;
+
+ if (!convertRemovalAttribute(attributes[QLatin1String("remove")], fm, m_error))
+ return false;
+
+ QString read = attributes[QLatin1String("read")];
+ QString write = attributes[QLatin1String("write")];
+
+ if (read == QLatin1String("true")) fm.modifiers |= FieldModification::Readable;
+ if (write == QLatin1String("true")) fm.modifiers |= FieldModification::Writable;
+
+ m_contextStack.top()->fieldMods << fm;
+ }
+ break;
+ case StackElement::AddFunction: {
+ if (!(topElement.type & (StackElement::ComplexTypeEntryMask | StackElement::Root))) {
+ m_error = QString::fromLatin1("Add function requires a complex type or a root tag as parent"
+ ", was=%1").arg(topElement.type, 0, 16);
+ return false;
+ }
+ QString signature = attributes[QLatin1String("signature")];
+
+ signature = TypeDatabase::normalizedSignature(signature);
+ if (signature.isEmpty()) {
+ m_error = QLatin1String("No signature for the added function");
+ return false;
+ }
+
+ QString errorString = checkSignatureError(signature, QLatin1String("add-function"));
+ if (!errorString.isEmpty()) {
+ m_error = errorString;
+ return false;
+ }
+
+ AddedFunction func(signature, attributes[QLatin1String("return-type")], since);
+ func.setStatic(attributes[QLatin1String("static")] == QLatin1String("yes"));
+ if (!signature.contains(QLatin1Char('(')))
+ signature += QLatin1String("()");
+ m_currentSignature = signature;
+
+ QString access = attributes[QLatin1String("access")].toLower();
+ if (!access.isEmpty()) {
+ if (access == QLatin1String("protected")) {
+ func.setAccess(AddedFunction::Protected);
+ } else if (access == QLatin1String("public")) {
+ func.setAccess(AddedFunction::Public);
+ } else {
+ m_error = QString::fromLatin1("Bad access type '%1'").arg(access);
+ return false;
+ }
+ }
+
+ m_contextStack.top()->addedFunctions << func;
+
+ FunctionModification mod(since);
+ mod.signature = m_currentSignature;
+ m_contextStack.top()->functionMods << mod;
+ }
+ break;
+ case StackElement::ModifyFunction: {
+ if (!(topElement.type & StackElement::ComplexTypeEntryMask)) {
+ m_error = QString::fromLatin1("Modify function requires complex type as parent"
+ ", was=%1").arg(topElement.type, 0, 16);
+ return false;
+ }
+ QString signature = attributes[QLatin1String("signature")];
+
+ signature = TypeDatabase::normalizedSignature(signature);
+ if (signature.isEmpty()) {
+ m_error = QLatin1String("No signature for modified function");
+ return false;
+ }
+
+ QString errorString = checkSignatureError(signature, QLatin1String("modify-function"));
+ if (!errorString.isEmpty()) {
+ m_error = errorString;
+ return false;
+ }
+
+ FunctionModification mod(since);
+ m_currentSignature = mod.signature = signature;
+
+ QString access = attributes[QLatin1String("access")].toLower();
+ if (!access.isEmpty()) {
+ if (access == QLatin1String("private"))
+ mod.modifiers |= Modification::Private;
+ else if (access == QLatin1String("protected"))
+ mod.modifiers |= Modification::Protected;
+ else if (access == QLatin1String("public"))
+ mod.modifiers |= Modification::Public;
+ else if (access == QLatin1String("final"))
+ mod.modifiers |= Modification::Final;
+ else if (access == QLatin1String("non-final"))
+ mod.modifiers |= Modification::NonFinal;
+ else {
+ m_error = QString::fromLatin1("Bad access type '%1'").arg(access);
+ return false;
+ }
+ }
+
+ if (convertBoolean(attributes[QLatin1String("deprecated")], QLatin1String("deprecated"), false))
+ mod.modifiers |= Modification::Deprecated;
+
+ if (!convertRemovalAttribute(attributes[QLatin1String("remove")], mod, m_error))
+ return false;
+
+ QString rename = attributes[QLatin1String("rename")];
+ if (!rename.isEmpty()) {
+ mod.renamedToName = rename;
+ mod.modifiers |= Modification::Rename;
+ }
+
+ QString association = attributes[QLatin1String("associated-to")];
+ if (!association.isEmpty())
+ mod.association = association;
+
+ mod.setIsThread(convertBoolean(attributes[QLatin1String("thread")], QLatin1String("thread"), false));
+ mod.setAllowThread(convertBoolean(attributes[QLatin1String("allow-thread")], QLatin1String("allow-thread"), false));
+
+ mod.modifiers |= (convertBoolean(attributes[QLatin1String("virtual-slot")], QLatin1String("virtual-slot"), false) ? Modification::VirtualSlot : 0);
+
+ m_contextStack.top()->functionMods << mod;
+ }
+ break;
+ case StackElement::ReplaceDefaultExpression:
+ if (!(topElement.type & StackElement::ModifyArgument)) {
+ m_error = QLatin1String("Replace default expression only allowed as child of argument modification");
+ return false;
+ }
+
+ if (attributes[QLatin1String("with")].isEmpty()) {
+ m_error = QLatin1String("Default expression replaced with empty string. Use remove-default-expression instead.");
+ return false;
+ }
+
+ m_contextStack.top()->functionMods.last().argument_mods.last().replacedDefaultExpression = attributes[QLatin1String("with")];
+ break;
+ case StackElement::RemoveDefaultExpression:
+ m_contextStack.top()->functionMods.last().argument_mods.last().removedDefaultExpression = true;
+ break;
+ case StackElement::CustomMetaConstructor:
+ case StackElement::CustomMetaDestructor: {
+ CustomFunction *func = new CustomFunction(attributes[nameAttribute()]);
+ func->paramName = attributes[QLatin1String("param-name")];
+ element->value.customFunction = func;
+ }
+ break;
+ case StackElement::ReferenceCount: {
+ if (topElement.type != StackElement::ModifyArgument) {
+ m_error = QLatin1String("reference-count must be child of modify-argument");
+ return false;
+ }
+
+ ReferenceCount rc;
+
+ static QHash<QString, ReferenceCount::Action> actions;
+ if (actions.isEmpty()) {
+ actions[QLatin1String("add")] = ReferenceCount::Add;
+ actions[QLatin1String("add-all")] = ReferenceCount::AddAll;
+ actions[QLatin1String("remove")] = ReferenceCount::Remove;
+ actions[QLatin1String("set")] = ReferenceCount::Set;
+ actions[QLatin1String("ignore")] = ReferenceCount::Ignore;
+ }
+ rc.action = actions.value(attributes[QLatin1String("action")].toLower(), ReferenceCount::Invalid);
+ rc.varName = attributes[QLatin1String("variable-name")];
+
+ if (rc.action == ReferenceCount::Invalid) {
+ m_error = QLatin1String("unrecognized value for action attribute. supported actions:");
+ foreach (const QString &action, actions.keys())
+ m_error += QLatin1Char(' ') + action;
+ }
+
+ m_contextStack.top()->functionMods.last().argument_mods.last().referenceCounts.append(rc);
+ }
+ break;
+
+ case StackElement::ParentOwner: {
+ if (topElement.type != StackElement::ModifyArgument) {
+ m_error = QLatin1String("parent-policy must be child of modify-argument");
+ return false;
+ }
+
+ ArgumentOwner ao;
+
+ QString index = attributes[QLatin1String("index")];
+ if (index == QLatin1String("return"))
+ index = QLatin1String("0");
+ else if (index == QLatin1String("this"))
+ index = QLatin1String("-1");
+
+ bool ok = false;
+ int idx = index.toInt(&ok);
+ if (!ok) {
+ m_error = QStringLiteral("Cannot convert '%1' to integer").arg(index);
+ return false;
+ }
+
+ static QHash<QString, ArgumentOwner::Action> actions;
+ if (actions.isEmpty()) {
+ actions[QLatin1String("add")] = ArgumentOwner::Add;
+ actions[QLatin1String("remove")] = ArgumentOwner::Remove;
+ }
+
+ ao.action = actions.value(attributes[QLatin1String("action")].toLower(), ArgumentOwner::Invalid);
+ if (!ao.action) {
+ m_error = QLatin1String("Invalid parent actionr");
+ return false;
+ }
+ ao.index = idx;
+ m_contextStack.top()->functionMods.last().argument_mods.last().owner = ao;
+ }
+ break;
+
+
+ case StackElement::InjectCode: {
+ if (!(topElement.type & StackElement::ComplexTypeEntryMask)
+ && (topElement.type != StackElement::AddFunction)
+ && (topElement.type != StackElement::ModifyFunction)
+ && (topElement.type != StackElement::Root)) {
+ m_error = QLatin1String("wrong parent type for code injection");
+ return false;
+ }
+
+ static QHash<QString, TypeSystem::Language> languageNames;
+ if (languageNames.isEmpty()) {
+ languageNames[QLatin1String("target")] = TypeSystem::TargetLangCode; // em algum lugar do cpp
+ languageNames[QLatin1String("native")] = TypeSystem::NativeCode; // em algum lugar do cpp
+ languageNames[QLatin1String("shell")] = TypeSystem::ShellCode; // coloca no header, mas antes da declaracao da classe
+ languageNames[QLatin1String("shell-declaration")] = TypeSystem::ShellDeclaration; // coloca no header, dentro da declaracao da classe
+ languageNames[QLatin1String("library-initializer")] = TypeSystem::PackageInitializer;
+ languageNames[QLatin1String("destructor-function")] = TypeSystem::DestructorFunction;
+ languageNames[QLatin1String("constructors")] = TypeSystem::Constructors;
+ languageNames[QLatin1String("interface")] = TypeSystem::Interface;
+ }
+
+ QString className = attributes[QLatin1String("class")].toLower();
+ if (!languageNames.contains(className)) {
+ m_error = QStringLiteral("Invalid class specifier: '%1'").arg(className);
+ return false;
+ }
+
+
+ static QHash<QString, TypeSystem::CodeSnipPosition> positionNames;
+ if (positionNames.isEmpty()) {
+ positionNames.insert(QLatin1String("beginning"), TypeSystem::CodeSnipPositionBeginning);
+ positionNames.insert(QLatin1String("end"), TypeSystem::CodeSnipPositionEnd);
+ // QtScript
+ positionNames.insert(QLatin1String("declaration"), TypeSystem::CodeSnipPositionDeclaration);
+ positionNames.insert(QLatin1String("prototype-initialization"), TypeSystem::CodeSnipPositionPrototypeInitialization);
+ positionNames.insert(QLatin1String("constructor-initialization"), TypeSystem::CodeSnipPositionConstructorInitialization);
+ positionNames.insert(QLatin1String("constructor"), TypeSystem::CodeSnipPositionConstructor);
+ }
+
+ QString position = attributes[QLatin1String("position")].toLower();
+ if (!positionNames.contains(position)) {
+ m_error = QStringLiteral("Invalid position: '%1'").arg(position);
+ return false;
+ }
+
+ CodeSnip snip(since);
+ snip.language = languageNames[className];
+ snip.position = positionNames[position];
+ bool in_file = false;
+
+ QString file_name = attributes[QLatin1String("file")];
+
+ //Handler constructor....
+ if (m_generate != TypeEntry::GenerateForSubclass &&
+ m_generate != TypeEntry::GenerateNothing &&
+ !file_name.isEmpty()) {
+ if (QFile::exists(file_name)) {
+ QFile codeFile(file_name);
+ if (codeFile.open(QIODevice::Text | QIODevice::ReadOnly)) {
+ QString content = QLatin1String("// ========================================================================\n"
+ "// START of custom code block [file: ");
+ content += file_name;
+ content += QLatin1String("]\n");
+ content += QString::fromUtf8(codeFile.readAll());
+ content += QLatin1String("\n// END of custom code block [file: ");
+ content += file_name;
+ content += QLatin1String("]\n// ========================================================================\n");
+ snip.addCode(content);
+ in_file = true;
+ }
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "File for inject code not exist: " << QDir::toNativeSeparators(file_name);
+ }
+
+ }
+
+ if (snip.language == TypeSystem::Interface && topElement.type != StackElement::InterfaceTypeEntry) {
+ m_error = QLatin1String("Interface code injections must be direct child of an interface type entry");
+ return false;
+ }
+
+ if (topElement.type == StackElement::ModifyFunction || topElement.type == StackElement::AddFunction) {
+ FunctionModification mod = m_contextStack.top()->functionMods.last();
+ if (snip.language == TypeSystem::ShellDeclaration) {
+ m_error = QLatin1String("no function implementation in shell declaration in which to inject code");
+ return false;
+ }
+
+ m_contextStack.top()->functionMods.last().snips << snip;
+ if (in_file)
+ m_contextStack.top()->functionMods.last().modifiers |= FunctionModification::CodeInjection;
+ element->type = StackElement::InjectCodeInFunction;
+ } else if (topElement.type == StackElement::Root) {
+ element->entry->addCodeSnip(snip);
+ } else if (topElement.type != StackElement::Root) {
+ m_contextStack.top()->codeSnips << snip;
+ }
+
+ }
+ break;
+ case StackElement::Include: {
+ QString location = attributes[QLatin1String("location")].toLower();
+
+ static QHash<QString, Include::IncludeType> locationNames;
+ if (locationNames.isEmpty()) {
+ locationNames[QLatin1String("global")] = Include::IncludePath;
+ locationNames[QLatin1String("local")] = Include::LocalPath;
+ locationNames[QLatin1String("target")] = Include::TargetLangImport;
+ }
+
+ if (!locationNames.contains(location)) {
+ m_error = QStringLiteral("Location not recognized: '%1'").arg(location);
+ return false;
+ }
+
+ Include::IncludeType loc = locationNames[location];
+ Include inc(loc, attributes[QLatin1String("file-name")]);
+
+ ComplexTypeEntry *ctype = static_cast<ComplexTypeEntry *>(element->entry);
+ if (topElement.type & (StackElement::ComplexTypeEntryMask | StackElement::PrimitiveTypeEntry)) {
+ element->entry->setInclude(inc);
+ } else if (topElement.type == StackElement::ExtraIncludes) {
+ element->entry->addExtraInclude(inc);
+ } else {
+ m_error = QLatin1String("Only supported parent tags are primitive-type, complex types or extra-includes");
+ return false;
+ }
+
+ inc = ctype->include();
+ IncludeList lst = ctype->extraIncludes();
+ ctype = ctype->designatedInterface();
+ if (ctype) {
+ ctype->setExtraIncludes(lst);
+ ctype->setInclude(inc);
+ }
+ }
+ break;
+ case StackElement::Rejection: {
+ QString cls = attributes[QLatin1String("class")];
+ QString function = attributes[QLatin1String("function-name")];
+ QString field = attributes[QLatin1String("field-name")];
+ QString enum_ = attributes[QLatin1String("enum-name")];
+ if (cls == QLatin1String("*") && function == QLatin1String("*") && field == QLatin1String("*") && enum_ == QLatin1String("*")) {
+ m_error = QLatin1String("bad reject entry, neither 'class', 'function-name' nor "
+ "'field' specified");
+ return false;
+ }
+ m_database->addRejection(cls, function, field, enum_);
+ }
+ break;
+ case StackElement::Template:
+ element->value.templateEntry = new TemplateEntry(attributes[nameAttribute()], since);
+ break;
+ case StackElement::TemplateInstanceEnum:
+ if (!(topElement.type & StackElement::CodeSnipMask) &&
+ (topElement.type != StackElement::Template) &&
+ (topElement.type != StackElement::CustomMetaConstructor) &&
+ (topElement.type != StackElement::CustomMetaDestructor) &&
+ (topElement.type != StackElement::NativeToTarget) &&
+ (topElement.type != StackElement::AddConversion) &&
+ (topElement.type != StackElement::ConversionRule)) {
+ m_error = QLatin1String("Can only insert templates into code snippets, templates, custom-constructors, "\
+ "custom-destructors, conversion-rule, native-to-target or add-conversion tags.");
+ return false;
+ }
+ element->value.templateInstance = new TemplateInstance(attributes[nameAttribute()], since);
+ break;
+ case StackElement::Replace:
+ if (topElement.type != StackElement::TemplateInstanceEnum) {
+ m_error = QLatin1String("Can only insert replace rules into insert-template.");
+ return false;
+ }
+ element->parent->value.templateInstance->addReplaceRule(attributes[QLatin1String("from")], attributes[QLatin1String("to")]);
+ break;
+ default:
+ break; // nada
+ };
+ }
+
+ m_current = element;
+ return true;
+}
+
+PrimitiveTypeEntry *PrimitiveTypeEntry::basicReferencedTypeEntry() const
+{
+ if (!m_referencedTypeEntry)
+ return 0;
+
+ PrimitiveTypeEntry *baseReferencedTypeEntry = m_referencedTypeEntry->basicReferencedTypeEntry();
+ if (baseReferencedTypeEntry)
+ return baseReferencedTypeEntry;
+ else
+ return m_referencedTypeEntry;
+}
+
+typedef QHash<const PrimitiveTypeEntry*, QString> PrimitiveTypeEntryTargetLangPackageMap;
+Q_GLOBAL_STATIC(PrimitiveTypeEntryTargetLangPackageMap, primitiveTypeEntryTargetLangPackages);
+
+void PrimitiveTypeEntry::setTargetLangPackage(const QString& package)
+{
+ primitiveTypeEntryTargetLangPackages()->insert(this, package);
+}
+QString PrimitiveTypeEntry::targetLangPackage() const
+{
+ if (!primitiveTypeEntryTargetLangPackages()->contains(this))
+ return this->::TypeEntry::targetLangPackage();
+ return primitiveTypeEntryTargetLangPackages()->value(this);
+}
+
+CodeSnipList TypeEntry::codeSnips() const
+{
+ return m_codeSnips;
+}
+
+QString Modification::accessModifierString() const
+{
+ if (isPrivate()) return QLatin1String("private");
+ if (isProtected()) return QLatin1String("protected");
+ if (isPublic()) return QLatin1String("public");
+ if (isFriendly()) return QLatin1String("friendly");
+ return QString();
+}
+
+FunctionModificationList ComplexTypeEntry::functionModifications(const QString &signature) const
+{
+ FunctionModificationList lst;
+ for (int i = 0; i < m_functionMods.count(); ++i) {
+ const FunctionModification &mod = m_functionMods.at(i);
+ if (mod.signature == signature)
+ lst << mod;
+ }
+ return lst;
+}
+
+FieldModification ComplexTypeEntry::fieldModification(const QString &name) const
+{
+ for (int i = 0; i < m_fieldMods.size(); ++i)
+ if (m_fieldMods.at(i).name == name)
+ return m_fieldMods.at(i);
+ FieldModification mod;
+ mod.name = name;
+ mod.modifiers = FieldModification::Readable | FieldModification::Writable;
+ return mod;
+}
+
+// The things we do not to break the ABI...
+typedef QHash<const ComplexTypeEntry*, QString> ComplexTypeEntryDefaultConstructorMap;
+Q_GLOBAL_STATIC(ComplexTypeEntryDefaultConstructorMap, complexTypeEntryDefaultConstructors);
+
+void ComplexTypeEntry::setDefaultConstructor(const QString& defaultConstructor)
+{
+ if (!defaultConstructor.isEmpty())
+ complexTypeEntryDefaultConstructors()->insert(this, defaultConstructor);
+}
+QString ComplexTypeEntry::defaultConstructor() const
+{
+ if (!complexTypeEntryDefaultConstructors()->contains(this))
+ return QString();
+ return complexTypeEntryDefaultConstructors()->value(this);
+}
+bool ComplexTypeEntry::hasDefaultConstructor() const
+{
+ return complexTypeEntryDefaultConstructors()->contains(this);
+}
+
+QString ContainerTypeEntry::targetLangPackage() const
+{
+ return QString();
+}
+
+QString ContainerTypeEntry::targetLangName() const
+{
+
+ switch (m_type) {
+ case StringListContainer: return QLatin1String("QStringList");
+ case ListContainer: return QLatin1String("QList");
+ case LinkedListContainer: return QLatin1String("QLinkedList");
+ case VectorContainer: return QLatin1String("QVector");
+ case StackContainer: return QLatin1String("QStack");
+ case QueueContainer: return QLatin1String("QQueue");
+ case SetContainer: return QLatin1String("QSet");
+ case MapContainer: return QLatin1String("QMap");
+ case MultiMapContainer: return QLatin1String("QMultiMap");
+ case HashContainer: return QLatin1String("QHash");
+ case MultiHashContainer: return QLatin1String("QMultiHash");
+ case PairContainer: return QLatin1String("QPair");
+ default:
+ qWarning("bad type... %d", m_type);
+ break;
+ }
+ return QString();
+}
+
+QString ContainerTypeEntry::qualifiedCppName() const
+{
+ if (m_type == StringListContainer)
+ return QLatin1String("QStringList");
+ return ComplexTypeEntry::qualifiedCppName();
+}
+
+QString EnumTypeEntry::targetLangQualifier() const
+{
+ TypeEntry *te = TypeDatabase::instance()->findType(m_qualifier);
+ if (te)
+ return te->targetLangName();
+ else
+ return m_qualifier;
+}
+
+QString EnumTypeEntry::targetLangApiName() const
+{
+ return QLatin1String("jint");
+}
+
+QString FlagsTypeEntry::targetLangApiName() const
+{
+ return QLatin1String("jint");
+}
+
+void EnumTypeEntry::addEnumValueRedirection(const QString &rejected, const QString &usedValue)
+{
+ m_enumRedirections << EnumValueRedirection(rejected, usedValue);
+}
+
+QString EnumTypeEntry::enumValueRedirection(const QString &value) const
+{
+ for (int i = 0; i < m_enumRedirections.size(); ++i)
+ if (m_enumRedirections.at(i).rejected == value)
+ return m_enumRedirections.at(i).used;
+ return QString();
+}
+
+QString FlagsTypeEntry::qualifiedTargetLangName() const
+{
+ return targetLangPackage() + QLatin1Char('.') + m_enum->targetLangQualifier()
+ + QLatin1Char('.') + targetLangName();
+}
+
+/*!
+ * The Visual Studio 2002 compiler doesn't support these symbols,
+ * which our typedefs unforntuatly expand to.
+ */
+QString fixCppTypeName(const QString &name)
+{
+ if (name == QLatin1String("long long"))
+ return QLatin1String("qint64");
+ else if (name == QLatin1String("unsigned long long"))
+ return QLatin1String("quint64");
+ return name;
+}
+
+QString TemplateInstance::expandCode() const
+{
+ TemplateEntry *templateEntry = TypeDatabase::instance()->findTemplate(m_name);
+ if (templateEntry) {
+ typedef QHash<QString, QString>::const_iterator ConstIt;
+ QString code = templateEntry->code();
+ for (ConstIt it = replaceRules.begin(), end = replaceRules.end(); it != end; ++it)
+ code.replace(it.key(), it.value());
+ while (!code.isEmpty() && code.at(code.size() - 1).isSpace())
+ code.chop(1);
+ QString result = QLatin1String("// TEMPLATE - ") + m_name + QLatin1String(" - START");
+ if (!code.startsWith(QLatin1Char('\n')))
+ result += QLatin1Char('\n');
+ result += code;
+ result += QLatin1String("\n// TEMPLATE - ") + m_name + QLatin1String(" - END");
+ return result;
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "insert-template referring to non-existing template '" << m_name << '\'';
+ }
+
+ return QString();
+}
+
+
+QString CodeSnipAbstract::code() const
+{
+ QString res;
+ foreach (const CodeSnipFragment &codeFrag, codeList)
+ res.append(codeFrag.code());
+
+ return res;
+}
+
+QString CodeSnipFragment::code() const
+{
+ if (m_instance)
+ return m_instance->expandCode();
+ else
+ return m_code;
+}
+
+QString FunctionModification::toString() const
+{
+ QString str = signature + QLatin1String("->");
+ if (modifiers & AccessModifierMask) {
+ switch (modifiers & AccessModifierMask) {
+ case Private: str += QLatin1String("private"); break;
+ case Protected: str += QLatin1String("protected"); break;
+ case Public: str += QLatin1String("public"); break;
+ case Friendly: str += QLatin1String("friendly"); break;
+ }
+ }
+
+ if (modifiers & Final) str += QLatin1String("final");
+ if (modifiers & NonFinal) str += QLatin1String("non-final");
+
+ if (modifiers & Readable) str += QLatin1String("readable");
+ if (modifiers & Writable) str += QLatin1String("writable");
+
+ if (modifiers & CodeInjection) {
+ foreach (const CodeSnip &s, snips) {
+ str += QLatin1String("\n//code injection:\n");
+ str += s.code();
+ }
+ }
+
+ if (modifiers & Rename) str += QLatin1String("renamed:") + renamedToName;
+
+ if (modifiers & Deprecated) str += QLatin1String("deprecate");
+
+ if (modifiers & ReplaceExpression) str += QLatin1String("replace-expression");
+
+ return str;
+}
+
+bool FunctionModification::operator!=(const FunctionModification& other) const
+{
+ return !(*this == other);
+}
+
+bool FunctionModification::operator==(const FunctionModification& other) const
+{
+ if (signature != other.signature)
+ return false;
+
+ if (association != other.association)
+ return false;
+
+ if (modifiers != other.modifiers)
+ return false;
+
+ if (removal != other.removal)
+ return false;
+
+ if (m_thread != other.m_thread)
+ return false;
+
+ if (m_allowThread != other.m_allowThread)
+ return false;
+
+ if (m_version != other.m_version)
+ return false;
+
+ return true;
+}
+
+static AddedFunction::TypeInfo parseType(const QString& signature, int startPos = 0, int* endPos = 0)
+{
+ AddedFunction::TypeInfo result;
+ QRegExp regex(QLatin1String("\\w"));
+ int length = signature.length();
+ int start = signature.indexOf(regex, startPos);
+ if (start == -1) {
+ if (signature.midRef(startPos + 1, 3) == QLatin1String("...")) { // varargs
+ if (endPos)
+ *endPos = startPos + 4;
+ result.name = QLatin1String("...");
+ } else { // error
+ if (endPos)
+ *endPos = length;
+ }
+ return result;
+ }
+
+ int cantStop = 0;
+ QString paramString;
+ QChar c;
+ int i = start;
+ for (; i < length; ++i) {
+ c = signature[i];
+ if (c == QLatin1Char('<'))
+ cantStop++;
+ if (c == QLatin1Char('>'))
+ cantStop--;
+ if (cantStop < 0)
+ break; // FIXME: report error?
+ if ((c == QLatin1Char(')') || c == QLatin1Char(',')) && !cantStop)
+ break;
+ paramString += signature[i];
+ }
+ if (endPos)
+ *endPos = i;
+
+ // Check default value
+ if (paramString.contains(QLatin1Char('='))) {
+ QStringList lst = paramString.split(QLatin1Char('='));
+ paramString = lst[0].trimmed();
+ result.defaultValue = lst[1].trimmed();
+ }
+
+ // check constness
+ if (paramString.startsWith(QLatin1String("const "))) {
+ result.isConstant = true;
+ paramString.remove(0, sizeof("const")/sizeof(char));
+ paramString = paramString.trimmed();
+ }
+ // check reference
+ if (paramString.endsWith(QLatin1Char('&'))) {
+ result.isReference = true;
+ paramString.chop(1);
+ paramString = paramString.trimmed();
+ }
+ // check Indirections
+ while (paramString.endsWith(QLatin1Char('*'))) {
+ result.indirections++;
+ paramString.chop(1);
+ paramString = paramString.trimmed();
+ }
+ result.name = paramString;
+
+ return result;
+}
+
+AddedFunction::AddedFunction(QString signature, QString returnType, double vr) : m_access(Public), m_version(vr)
+{
+ Q_ASSERT(!returnType.isEmpty());
+ m_returnType = parseType(returnType);
+ signature = signature.trimmed();
+ int endPos = signature.indexOf(QLatin1Char('('));
+ if (endPos < 0) {
+ m_isConst = false;
+ m_name = signature;
+ } else {
+ m_name = signature.left(endPos).trimmed();
+ int signatureLength = signature.length();
+ while (endPos < signatureLength) {
+ TypeInfo arg = parseType(signature, endPos, &endPos);
+ if (!arg.name.isEmpty())
+ m_arguments.append(arg);
+ // end of parameters...
+ if (signature[endPos] == QLatin1Char(')'))
+ break;
+ }
+ // is const?
+ m_isConst = signature.right(signatureLength - endPos).contains(QLatin1String("const"));
+ }
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AddedFunction::TypeInfo &ti)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "TypeInfo(";
+ if (ti.isConstant)
+ d << "const";
+ if (ti.indirections)
+ d << QByteArray(ti.indirections, '*');
+ if (ti.isReference)
+ d << " &";
+ d << ti.name;
+ if (!ti.defaultValue.isEmpty())
+ d << " = " << ti.defaultValue;
+ d << ')';
+ return d;
+}
+
+QDebug operator<<(QDebug d, const AddedFunction &af)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "AddedFunction(";
+ if (af.access() == AddedFunction::Protected)
+ d << "protected";
+ if (af.isStatic())
+ d << " static";
+ d << af.returnType() << ' ' << af.name() << '(' << af.arguments() << ')';
+ if (af.isConstant())
+ d << " const";
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+AddedFunction::TypeInfo AddedFunction::TypeInfo::fromSignature(const QString& signature)
+{
+ return parseType(signature);
+}
+
+QString ComplexTypeEntry::targetLangApiName() const
+{
+ return strings_jobject;
+}
+QString StringTypeEntry::targetLangApiName() const
+{
+ return strings_jobject;
+}
+QString StringTypeEntry::targetLangName() const
+{
+ return strings_String;
+}
+QString StringTypeEntry::targetLangPackage() const
+{
+ return QString();
+}
+QString CharTypeEntry::targetLangApiName() const
+{
+ return strings_jchar;
+}
+QString CharTypeEntry::targetLangName() const
+{
+ return strings_char;
+}
+QString VariantTypeEntry::targetLangApiName() const
+{
+ return strings_jobject;
+}
+QString VariantTypeEntry::targetLangName() const
+{
+ return strings_Object;
+}
+QString VariantTypeEntry::targetLangPackage() const
+{
+ return QString();
+}
+
+QString ContainerTypeEntry::typeName() const
+{
+ switch(m_type) {
+ case LinkedListContainer:
+ return QLatin1String("linked-list");
+ case ListContainer:
+ return QLatin1String("list");
+ case StringListContainer:
+ return QLatin1String("string-list");
+ case VectorContainer:
+ return QLatin1String("vector");
+ case StackContainer:
+ return QLatin1String("stack");
+ case QueueContainer:
+ return QLatin1String("queue");
+ case SetContainer:
+ return QLatin1String("set");
+ case MapContainer:
+ return QLatin1String("map");
+ case MultiMapContainer:
+ return QLatin1String("multi-map");
+ case HashContainer:
+ return QLatin1String("hash");
+ case MultiHashContainer:
+ return QLatin1String("multi-hash");
+ case PairContainer:
+ return QLatin1String("pair");
+ case NoContainer:
+ default:
+ return QLatin1String("?");
+ }
+}
+
+static bool strLess(const char* a, const char* b)
+{
+ return ::strcmp(a, b) < 0;
+}
+
+bool TypeEntry::isCppPrimitive() const
+{
+ if (!isPrimitive())
+ return false;
+
+ const PrimitiveTypeEntry *referencedType =
+ static_cast<const PrimitiveTypeEntry *>(this)->basicReferencedTypeEntry();
+ QByteArray typeName = (referencedType ? referencedType->name() : m_name).toUtf8();
+
+ if (typeName.contains(' ') || m_type == VoidType)
+ return true;
+ // Keep this sorted!!
+ static const char* cppTypes[] = { "bool", "char", "double", "float", "int", "long", "long long", "short", "wchar_t" };
+ const int N = sizeof(cppTypes)/sizeof(char*);
+
+ const char** res = qBinaryFind(&cppTypes[0], &cppTypes[N], typeName.constData(), strLess);
+
+ return res != &cppTypes[N];
+}
+
+// Again, stuff to avoid ABI breakage.
+typedef QHash<const TypeEntry*, CustomConversion*> TypeEntryCustomConversionMap;
+Q_GLOBAL_STATIC(TypeEntryCustomConversionMap, typeEntryCustomConversionMap);
+
+TypeEntry::~TypeEntry()
+{
+ if (typeEntryCustomConversionMap()->contains(this)) {
+ CustomConversion* customConversion = typeEntryCustomConversionMap()->value(this);
+ typeEntryCustomConversionMap()->remove(this);
+ delete customConversion;
+ }
+}
+
+bool TypeEntry::hasCustomConversion() const
+{
+ return typeEntryCustomConversionMap()->contains(this);
+}
+void TypeEntry::setCustomConversion(CustomConversion* customConversion)
+{
+ if (customConversion)
+ typeEntryCustomConversionMap()->insert(this, customConversion);
+ else if (typeEntryCustomConversionMap()->contains(this))
+ typeEntryCustomConversionMap()->remove(this);
+}
+CustomConversion* TypeEntry::customConversion() const
+{
+ if (typeEntryCustomConversionMap()->contains(this))
+ return typeEntryCustomConversionMap()->value(this);
+ return 0;
+}
+
+/*
+static void injectCode(ComplexTypeEntry *e,
+ const char *signature,
+ const QByteArray &code,
+ const ArgumentMap &args)
+{
+ CodeSnip snip;
+ snip.language = TypeSystem::NativeCode;
+ snip.position = CodeSnip::Beginning;
+ snip.addCode(QString::fromLatin1(code));
+ snip.argumentMap = args;
+
+ FunctionModification mod;
+ mod.signature = QMetaObject::normalizedSignature(signature);
+ mod.snips << snip;
+ mod.modifiers = Modification::CodeInjection;
+}
+*/
+
+struct CustomConversion::CustomConversionPrivate
+{
+ CustomConversionPrivate(const TypeEntry* ownerType)
+ : ownerType(ownerType), replaceOriginalTargetToNativeConversions(false)
+ {
+ }
+ const TypeEntry* ownerType;
+ QString nativeToTargetConversion;
+ bool replaceOriginalTargetToNativeConversions;
+ TargetToNativeConversions targetToNativeConversions;
+};
+
+struct CustomConversion::TargetToNativeConversion::TargetToNativeConversionPrivate
+{
+ TargetToNativeConversionPrivate()
+ : sourceType(0)
+ {
+ }
+ const TypeEntry* sourceType;
+ QString sourceTypeName;
+ QString sourceTypeCheck;
+ QString conversion;
+};
+
+CustomConversion::CustomConversion(TypeEntry* ownerType)
+{
+ m_d = new CustomConversionPrivate(ownerType);
+ if (ownerType)
+ ownerType->setCustomConversion(this);
+}
+
+CustomConversion::~CustomConversion()
+{
+ foreach (TargetToNativeConversion* targetToNativeConversion, m_d->targetToNativeConversions)
+ delete targetToNativeConversion;
+ m_d->targetToNativeConversions.clear();
+ delete m_d;
+}
+
+const TypeEntry* CustomConversion::ownerType() const
+{
+ return m_d->ownerType;
+}
+
+QString CustomConversion::nativeToTargetConversion() const
+{
+ return m_d->nativeToTargetConversion;
+}
+
+void CustomConversion::setNativeToTargetConversion(const QString& nativeToTargetConversion)
+{
+ m_d->nativeToTargetConversion = nativeToTargetConversion;
+}
+
+bool CustomConversion::replaceOriginalTargetToNativeConversions() const
+{
+ return m_d->replaceOriginalTargetToNativeConversions;
+}
+
+void CustomConversion::setReplaceOriginalTargetToNativeConversions(bool replaceOriginalTargetToNativeConversions)
+{
+ m_d->replaceOriginalTargetToNativeConversions = replaceOriginalTargetToNativeConversions;
+}
+
+bool CustomConversion::hasTargetToNativeConversions() const
+{
+ return !(m_d->targetToNativeConversions.isEmpty());
+}
+
+CustomConversion::TargetToNativeConversions& CustomConversion::targetToNativeConversions()
+{
+ return m_d->targetToNativeConversions;
+}
+
+const CustomConversion::TargetToNativeConversions& CustomConversion::targetToNativeConversions() const
+{
+ return m_d->targetToNativeConversions;
+}
+
+void CustomConversion::addTargetToNativeConversion(const QString& sourceTypeName,
+ const QString& sourceTypeCheck,
+ const QString& conversion)
+{
+ m_d->targetToNativeConversions.append(new TargetToNativeConversion(sourceTypeName, sourceTypeCheck, conversion));
+}
+
+CustomConversion::TargetToNativeConversion::TargetToNativeConversion(const QString& sourceTypeName,
+ const QString& sourceTypeCheck,
+ const QString& conversion)
+{
+ m_d = new TargetToNativeConversionPrivate;
+ m_d->sourceTypeName = sourceTypeName;
+ m_d->sourceTypeCheck = sourceTypeCheck;
+ m_d->conversion = conversion;
+}
+
+CustomConversion::TargetToNativeConversion::~TargetToNativeConversion()
+{
+ delete m_d;
+}
+
+const TypeEntry* CustomConversion::TargetToNativeConversion::sourceType() const
+{
+ return m_d->sourceType;
+}
+
+void CustomConversion::TargetToNativeConversion::setSourceType(const TypeEntry* sourceType)
+{
+ m_d->sourceType = sourceType;
+}
+
+bool CustomConversion::TargetToNativeConversion::isCustomType() const
+{
+ return !(m_d->sourceType);
+}
+
+QString CustomConversion::TargetToNativeConversion::sourceTypeName() const
+{
+ return m_d->sourceTypeName;
+}
+
+QString CustomConversion::TargetToNativeConversion::sourceTypeCheck() const
+{
+ return m_d->sourceTypeCheck;
+}
+
+QString CustomConversion::TargetToNativeConversion::conversion() const
+{
+ return m_d->conversion;
+}
+
+void CustomConversion::TargetToNativeConversion::setConversion(const QString& conversion)
+{
+ m_d->conversion = conversion;
+}
diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h
new file mode 100644
index 000000000..a8ee0ced4
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/typesystem.h
@@ -0,0 +1,1947 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TYPESYSTEM_H
+#define TYPESYSTEM_H
+
+#include "typesystem_enums.h"
+#include "typesystem_typedefs.h"
+#include "include.h"
+
+#include <QtCore/QHash>
+#include <QtCore/qobjectdefs.h>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QMap>
+
+//Used to identify the conversion rule to avoid break API
+#define TARGET_CONVERSION_RULE_FLAG "0"
+#define NATIVE_CONVERSION_RULE_FLAG "1"
+
+class Indentor;
+
+class AbstractMetaType;
+QT_BEGIN_NAMESPACE
+class QTextStream;
+QT_END_NAMESPACE
+
+class EnumTypeEntry;
+class FlagsTypeEntry;
+
+typedef QMap<int, QString> ArgumentMap;
+
+class TemplateInstance;
+
+struct ReferenceCount
+{
+ ReferenceCount() {}
+ enum Action { // 0x01 - 0xff
+ Invalid = 0x00,
+ Add = 0x01,
+ AddAll = 0x02,
+ Remove = 0x04,
+ Set = 0x08,
+ Ignore = 0x10,
+
+ ActionsMask = 0xff,
+
+ Padding = 0xffffffff
+ };
+
+ Action action;
+ QString varName;
+};
+
+struct ArgumentOwner
+{
+ enum Action {
+ Invalid = 0x00,
+ Add = 0x01,
+ Remove = 0x02
+ };
+ enum {
+ InvalidIndex = -2,
+ ThisIndex = -1,
+ ReturnIndex = 0,
+ FirstArgumentIndex = 1
+ };
+ ArgumentOwner() : action(ArgumentOwner::Invalid), index(ArgumentOwner::InvalidIndex) {}
+
+ Action action;
+ int index;
+};
+
+class CodeSnipFragment
+{
+private:
+ QString m_code;
+ TemplateInstance *m_instance;
+
+public:
+ CodeSnipFragment(const QString &code)
+ : m_code(code),
+ m_instance(0) {}
+
+ CodeSnipFragment(TemplateInstance *instance)
+ : m_instance(instance) {}
+
+ QString code() const;
+};
+
+class CodeSnipAbstract
+{
+public:
+ QString code() const;
+
+ void addCode(const QString &code) { codeList.append(CodeSnipFragment(code)); }
+ void addCode(const QStringRef &code) { addCode(code.toString()); }
+
+ void addTemplateInstance(TemplateInstance *ti)
+ {
+ codeList.append(CodeSnipFragment(ti));
+ }
+
+ QList<CodeSnipFragment> codeList;
+};
+
+class CustomFunction : public CodeSnipAbstract
+{
+public:
+ CustomFunction(const QString &n = QString()) : name(n) { }
+
+ QString name;
+ QString paramName;
+};
+
+class TemplateEntry : public CodeSnipAbstract
+{
+public:
+ TemplateEntry(const QString &name, double vr)
+ : m_name(name), m_version(vr)
+ {
+ };
+
+ QString name() const
+ {
+ return m_name;
+ };
+
+ double version() const
+ {
+ return m_version;
+ }
+
+private:
+ QString m_name;
+ double m_version;
+};
+
+class TemplateInstance
+{
+public:
+ TemplateInstance(const QString &name, double vr)
+ : m_name(name), m_version(vr) {}
+
+ void addReplaceRule(const QString &name, const QString &value)
+ {
+ replaceRules[name] = value;
+ }
+
+ QString expandCode() const;
+
+ QString name() const
+ {
+ return m_name;
+ }
+
+ double version() const
+ {
+ return m_version;
+ }
+
+private:
+ const QString m_name;
+ double m_version;
+ QHash<QString, QString> replaceRules;
+};
+
+
+class CodeSnip : public CodeSnipAbstract
+{
+public:
+ CodeSnip(double vr) : language(TypeSystem::TargetLangCode), version(vr) { }
+ CodeSnip(double vr, TypeSystem::Language lang) : language(lang), version(vr) { }
+
+ TypeSystem::Language language;
+ TypeSystem::CodeSnipPosition position;
+ ArgumentMap argumentMap;
+ double version;
+};
+
+struct ArgumentModification
+{
+ ArgumentModification(int idx, double vr)
+ : removedDefaultExpression(false), removed(false),
+ noNullPointers(false), index(idx), version(vr) {}
+
+ // Should the default expression be removed?
+ uint removedDefaultExpression : 1;
+ uint removed : 1;
+ uint noNullPointers : 1;
+ uint resetAfterUse : 1;
+
+ // The index of this argument
+ int index;
+
+ // Reference count flags for this argument
+ QList<ReferenceCount> referenceCounts;
+
+ // The text given for the new type of the argument
+ QString modified_type;
+
+ QString replace_value;
+
+ // The code to be used to construct a return value when noNullPointers is true and
+ // the returned value is null. If noNullPointers is true and this string is
+ // empty, then the base class implementation will be used (or a default construction
+ // if there is no implementation)
+ QString nullPointerDefaultValue;
+
+ // The text of the new default expression of the argument
+ QString replacedDefaultExpression;
+
+ // The new definition of ownership for a specific argument
+ QHash<TypeSystem::Language, TypeSystem::Ownership> ownerships;
+
+ // Different conversion rules
+ CodeSnipList conversion_rules;
+
+ //QObject parent(owner) of this argument
+ ArgumentOwner owner;
+
+ //Api version
+ double version;
+
+ //New name
+ QString renamed_to;
+};
+
+struct Modification
+{
+ enum Modifiers {
+ Private = 0x0001,
+ Protected = 0x0002,
+ Public = 0x0003,
+ Friendly = 0x0004,
+ AccessModifierMask = 0x000f,
+
+ Final = 0x0010,
+ NonFinal = 0x0020,
+ FinalMask = Final | NonFinal,
+
+ Readable = 0x0100,
+ Writable = 0x0200,
+
+ CodeInjection = 0x1000,
+ Rename = 0x2000,
+ Deprecated = 0x4000,
+ ReplaceExpression = 0x8000,
+ VirtualSlot = 0x10000 | NonFinal
+ };
+
+ Modification() : modifiers(0), removal(TypeSystem::NoLanguage) { }
+
+ bool isAccessModifier() const
+ {
+ return modifiers & AccessModifierMask;
+ }
+ Modifiers accessModifier() const
+ {
+ return Modifiers(modifiers & AccessModifierMask);
+ }
+ bool isPrivate() const
+ {
+ return accessModifier() == Private;
+ }
+ bool isProtected() const
+ {
+ return accessModifier() == Protected;
+ }
+ bool isPublic() const
+ {
+ return accessModifier() == Public;
+ }
+ bool isFriendly() const
+ {
+ return accessModifier() == Friendly;
+ }
+ bool isFinal() const
+ {
+ return modifiers & Final;
+ }
+ bool isNonFinal() const
+ {
+ return modifiers & NonFinal;
+ }
+ bool isVirtualSlot() const
+ {
+ return (modifiers & VirtualSlot) == VirtualSlot;
+ }
+ QString accessModifierString() const;
+
+ bool isDeprecated() const
+ {
+ return modifiers & Deprecated;
+ }
+
+ void setRenamedTo(const QString &name)
+ {
+ renamedToName = name;
+ }
+ QString renamedTo() const
+ {
+ return renamedToName;
+ }
+ bool isRenameModifier() const
+ {
+ return modifiers & Rename;
+ }
+
+ bool isRemoveModifier() const
+ {
+ return removal != TypeSystem::NoLanguage;
+ }
+
+ uint modifiers;
+ QString renamedToName;
+ TypeSystem::Language removal;
+};
+
+struct FunctionModification: public Modification
+{
+ FunctionModification(double vr) : m_thread(false), m_allowThread(false), m_version(vr) {}
+
+ bool isCodeInjection() const
+ {
+ return modifiers & CodeInjection;
+ }
+ void setIsThread(bool flag)
+ {
+ m_thread = flag;
+ }
+ bool isThread() const
+ {
+ return m_thread;
+ }
+ bool allowThread() const
+ {
+ return m_allowThread;
+ }
+ void setAllowThread(bool allow)
+ {
+ m_allowThread = allow;
+ }
+ double version() const
+ {
+ return m_version;
+ }
+
+ bool operator!=(const FunctionModification& other) const;
+ bool operator==(const FunctionModification& other) const;
+
+
+ QString toString() const;
+
+ QString signature;
+ QString association;
+ CodeSnipList snips;
+
+ QList<ArgumentModification> argument_mods;
+
+private:
+ FunctionModification() {}
+
+ bool m_thread;
+ bool m_allowThread;
+ double m_version;
+
+
+};
+
+struct FieldModification: public Modification
+{
+ bool isReadable() const
+ {
+ return modifiers & Readable;
+ }
+ bool isWritable() const
+ {
+ return modifiers & Writable;
+ }
+
+ QString name;
+};
+
+/**
+* \internal
+* Struct used to store information about functions added by the typesystem.
+* This info will be used later to create a fake AbstractMetaFunction which
+* will be inserted into the right AbstractMetaClass.
+*/
+struct AddedFunction
+{
+ /// Function access types.
+ enum Access {
+ Protected = 0x1,
+ Public = 0x2
+ };
+
+ /**
+ * \internal
+ * Internal struct used to store information about arguments and return type of the
+ * functions added by the type system. This information is later used to create
+ * AbstractMetaType and AbstractMetaArgument for the AbstractMetaFunctions.
+ */
+ struct TypeInfo {
+ TypeInfo() : isConstant(false), indirections(0), isReference(false) {}
+ static TypeInfo fromSignature(const QString& signature);
+
+ QString name;
+ bool isConstant;
+ int indirections;
+ bool isReference;
+ QString defaultValue;
+ };
+
+ /// Creates a new AddedFunction with a signature and a return type.
+ AddedFunction(QString signature, QString returnType, double vr);
+
+ /// Returns the function name.
+ QString name() const
+ {
+ return m_name;
+ }
+
+ /// Set the function access type.
+ void setAccess(Access access)
+ {
+ m_access = access;
+ }
+
+ /// Returns the function access type.
+ Access access() const
+ {
+ return m_access;
+ }
+
+ /// Returns the function return type.
+ TypeInfo returnType() const
+ {
+ return m_returnType;
+ }
+
+ /// Returns a list of argument type infos.
+ QList<TypeInfo> arguments() const
+ {
+ return m_arguments;
+ }
+
+ /// Returns true if this is a constant method.
+ bool isConstant() const
+ {
+ return m_isConst;
+ }
+
+ /// Set this method static.
+ void setStatic(bool value)
+ {
+ m_isStatic = value;
+ }
+
+ /// Returns true if this is a static method.
+ bool isStatic() const
+ {
+ return m_isStatic;
+ }
+
+ double version() const
+ {
+ return m_version;
+ }
+private:
+ QString m_name;
+ Access m_access;
+ QList<TypeInfo> m_arguments;
+ TypeInfo m_returnType;
+ bool m_isConst;
+ bool m_isStatic;
+ double m_version;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const AddedFunction::TypeInfo &ti);
+QDebug operator<<(QDebug d, const AddedFunction &af);
+#endif
+
+struct ExpensePolicy
+{
+ ExpensePolicy() : limit(-1) {}
+ int limit;
+ QString cost;
+ bool isValid() const
+ {
+ return limit >= 0;
+ }
+};
+
+class InterfaceTypeEntry;
+class ObjectTypeEntry;
+
+class DocModification
+{
+public:
+ DocModification(const QString& xpath, const QString& signature, double vr)
+ : format(TypeSystem::NativeCode), m_mode(TypeSystem::DocModificationXPathReplace),
+ m_xpath(xpath), m_signature(signature), m_version(vr) {}
+ DocModification(TypeSystem::DocModificationMode mode, const QString& signature, double vr)
+ : m_mode(mode), m_signature(signature), m_version(vr) {}
+
+ void setCode(const QString& code) { m_code = code; }
+ void setCode(const QStringRef& code) { m_code = code.toString(); }
+
+ QString code() const
+ {
+ return m_code;
+ }
+ QString xpath() const
+ {
+ return m_xpath;
+ }
+ QString signature() const
+ {
+ return m_signature;
+ }
+ TypeSystem::DocModificationMode mode() const
+ {
+ return m_mode;
+ }
+ double version() const
+ {
+ return m_version;
+ }
+
+ TypeSystem::Language format;
+
+private:
+ TypeSystem::DocModificationMode m_mode;
+ QString m_code;
+ QString m_xpath;
+ QString m_signature;
+ double m_version;
+};
+
+class CustomConversion;
+
+class TypeEntry
+{
+ Q_GADGET
+public:
+ enum Type {
+ PrimitiveType,
+ VoidType,
+ VarargsType,
+ FlagsType,
+ EnumType,
+ EnumValue,
+ TemplateArgumentType,
+ ThreadType,
+ BasicValueType,
+ StringType,
+ ContainerType,
+ InterfaceType,
+ ObjectType,
+ NamespaceType,
+ VariantType,
+ JObjectWrapperType,
+ CharType,
+ ArrayType,
+ TypeSystemType,
+ CustomType,
+ TargetLangType,
+ FunctionType,
+ SmartPointerType
+ };
+ Q_ENUM(Type)
+
+ enum CodeGeneration {
+ GenerateTargetLang = 0x0001,
+ GenerateCpp = 0x0002,
+ GenerateForSubclass = 0x0004,
+
+ GenerateNothing = 0,
+ GenerateAll = 0xffff,
+ GenerateCode = GenerateTargetLang | GenerateCpp
+ };
+ Q_ENUM(CodeGeneration)
+
+ TypeEntry(const QString &name, Type t, double vr)
+ : m_name(name),
+ m_type(t),
+ m_codeGeneration(GenerateAll),
+ m_preferredConversion(true),
+ m_stream(false),
+ m_version(vr)
+ {
+ };
+
+ virtual ~TypeEntry();
+
+ Type type() const
+ {
+ return m_type;
+ }
+ bool isPrimitive() const
+ {
+ return m_type == PrimitiveType;
+ }
+ bool isEnum() const
+ {
+ return m_type == EnumType;
+ }
+ bool isFlags() const
+ {
+ return m_type == FlagsType;
+ }
+ bool isInterface() const
+ {
+ return m_type == InterfaceType;
+ }
+ bool isObject() const
+ {
+ return m_type == ObjectType;
+ }
+ bool isString() const
+ {
+ return m_type == StringType;
+ }
+ bool isChar() const
+ {
+ return m_type == CharType;
+ }
+ bool isNamespace() const
+ {
+ return m_type == NamespaceType;
+ }
+ bool isContainer() const
+ {
+ return m_type == ContainerType;
+ }
+ bool isSmartPointer() const
+ {
+ return m_type == SmartPointerType;
+ }
+ bool isVariant() const
+ {
+ return m_type == VariantType;
+ }
+ bool isJObjectWrapper() const
+ {
+ return m_type == JObjectWrapperType;
+ }
+ bool isArray() const
+ {
+ return m_type == ArrayType;
+ }
+ bool isTemplateArgument() const
+ {
+ return m_type == TemplateArgumentType;
+ }
+ bool isVoid() const
+ {
+ return m_type == VoidType;
+ }
+ bool isVarargs() const
+ {
+ return m_type == VarargsType;
+ }
+ bool isThread() const
+ {
+ return m_type == ThreadType;
+ }
+ bool isCustom() const
+ {
+ return m_type == CustomType;
+ }
+ bool isBasicValue() const
+ {
+ return m_type == BasicValueType;
+ }
+ bool isTypeSystem() const
+ {
+ return m_type == TypeSystemType;
+ }
+ bool isFunction() const
+ {
+ return m_type == FunctionType;
+ }
+ bool isEnumValue() const
+ {
+ return m_type == EnumValue;
+ }
+
+ virtual bool preferredConversion() const
+ {
+ return m_preferredConversion;
+ }
+ virtual void setPreferredConversion(bool b)
+ {
+ m_preferredConversion = b;
+ }
+
+ bool stream() const
+ {
+ return m_stream;
+ }
+
+ void setStream(bool b)
+ {
+ m_stream = b;
+ }
+
+ // The type's name in C++, fully qualified
+ QString name() const
+ {
+ return m_name;
+ }
+
+ uint codeGeneration() const
+ {
+ return m_codeGeneration;
+ }
+ void setCodeGeneration(uint cg)
+ {
+ m_codeGeneration = cg;
+ }
+
+ // Returns true if code must be generated for this entry,
+ // it will return false in case of types coming from typesystems
+ // included for reference only.
+ // NOTE: 'GenerateForSubclass' means 'generate="no"'
+ // on 'load-typesystem' tag
+ inline bool generateCode() const
+ {
+ return m_codeGeneration != TypeEntry::GenerateForSubclass
+ && m_codeGeneration != TypeEntry::GenerateNothing;
+ }
+
+ virtual QString qualifiedCppName() const
+ {
+ return m_name;
+ }
+
+ /**
+ * Its type's name in target language API
+ * The target language API name represents how this type is
+ * referred on low level code for the target language.
+ * Examples: for Java this would be a JNI name, for Python
+ * it should represent the CPython type name.
+ * /return string representing the target language API name
+ * for this type entry
+ */
+ virtual QString targetLangApiName() const
+ {
+ return m_name;
+ }
+
+ // The type's name in TargetLang
+ virtual QString targetLangName() const
+ {
+ return m_name;
+ }
+
+ // The type to lookup when converting to TargetLang
+ virtual QString lookupName() const
+ {
+ return targetLangName();
+ }
+
+ // The package
+ virtual QString targetLangPackage() const
+ {
+ return QString();
+ }
+
+ virtual QString qualifiedTargetLangName() const
+ {
+ QString pkg = targetLangPackage();
+ if (pkg.isEmpty())
+ return targetLangName();
+ return pkg + QLatin1Char('.') + targetLangName();
+ }
+
+ virtual InterfaceTypeEntry *designatedInterface() const
+ {
+ return 0;
+ }
+
+ void setCustomConstructor(const CustomFunction &func)
+ {
+ m_customConstructor = func;
+ }
+ CustomFunction customConstructor() const
+ {
+ return m_customConstructor;
+ }
+
+ void setCustomDestructor(const CustomFunction &func)
+ {
+ m_customDestructor = func;
+ }
+ CustomFunction customDestructor() const
+ {
+ return m_customDestructor;
+ }
+
+ virtual bool isValue() const
+ {
+ return false;
+ }
+ virtual bool isComplex() const
+ {
+ return false;
+ }
+
+ virtual bool isNativeIdBased() const
+ {
+ return false;
+ }
+
+ CodeSnipList codeSnips() const;
+ void setCodeSnips(const CodeSnipList &codeSnips)
+ {
+ m_codeSnips = codeSnips;
+ }
+ void addCodeSnip(const CodeSnip &codeSnip)
+ {
+ m_codeSnips << codeSnip;
+ }
+
+ void setDocModification(const DocModificationList& docMods)
+ {
+ m_docModifications << docMods;
+ }
+ DocModificationList docModifications() const
+ {
+ return m_docModifications;
+ }
+
+ IncludeList extraIncludes() const
+ {
+ return m_extraIncludes;
+ }
+ void setExtraIncludes(const IncludeList &includes)
+ {
+ m_extraIncludes = includes;
+ }
+ void addExtraInclude(const Include &include)
+ {
+ if (!m_includesUsed.value(include.name(), false)) {
+ m_extraIncludes << include;
+ m_includesUsed[include.name()] = true;
+ }
+ }
+
+ Include include() const
+ {
+ return m_include;
+ }
+ void setInclude(const Include &inc)
+ {
+ m_include = inc;
+ }
+
+ // Replace conversionRule arg to CodeSnip in future version
+ /// Set the type convertion rule
+ void setConversionRule(const QString& conversionRule)
+ {
+ m_conversionRule = conversionRule;
+ }
+
+ /// Returns the type convertion rule
+ QString conversionRule() const
+ {
+ //skip conversions flag
+ return m_conversionRule.mid(1);
+ }
+
+ /// Returns true if there are any conversiton rule for this type, false otherwise.
+ bool hasConversionRule() const
+ {
+ return !m_conversionRule.isEmpty();
+ }
+
+ double version() const
+ {
+ return m_version;
+ }
+
+ /// TODO-CONVERTER: mark as deprecated
+ bool hasNativeConversionRule() const
+ {
+ return m_conversionRule.startsWith(QLatin1String(NATIVE_CONVERSION_RULE_FLAG));
+ }
+
+ /// TODO-CONVERTER: mark as deprecated
+ bool hasTargetConversionRule() const
+ {
+ return m_conversionRule.startsWith(QLatin1String(TARGET_CONVERSION_RULE_FLAG));
+ }
+
+ bool isCppPrimitive() const;
+
+ bool hasCustomConversion() const;
+ void setCustomConversion(CustomConversion* customConversion);
+ CustomConversion* customConversion() const;
+private:
+ QString m_name;
+ Type m_type;
+ uint m_codeGeneration;
+ CustomFunction m_customConstructor;
+ CustomFunction m_customDestructor;
+ bool m_preferredConversion;
+ CodeSnipList m_codeSnips;
+ DocModificationList m_docModifications;
+ IncludeList m_extraIncludes;
+ Include m_include;
+ QHash<QString, bool> m_includesUsed;
+ QString m_conversionRule;
+ bool m_stream;
+ double m_version;
+};
+
+class TypeSystemTypeEntry : public TypeEntry
+{
+public:
+ TypeSystemTypeEntry(const QString &name, double vr)
+ : TypeEntry(name, TypeSystemType, vr)
+ {
+ };
+};
+
+class VoidTypeEntry : public TypeEntry
+{
+public:
+ VoidTypeEntry() : TypeEntry(QLatin1String("void"), VoidType, 0) { }
+};
+
+class VarargsTypeEntry : public TypeEntry
+{
+public:
+ VarargsTypeEntry() : TypeEntry(QLatin1String("..."), VarargsType, 0) { }
+};
+
+class TemplateArgumentEntry : public TypeEntry
+{
+public:
+ TemplateArgumentEntry(const QString &name, double vr)
+ : TypeEntry(name, TemplateArgumentType, vr), m_ordinal(0)
+ {
+ }
+
+ int ordinal() const
+ {
+ return m_ordinal;
+ }
+ void setOrdinal(int o)
+ {
+ m_ordinal = o;
+ }
+
+private:
+ int m_ordinal;
+};
+
+class ArrayTypeEntry : public TypeEntry
+{
+public:
+ ArrayTypeEntry(const TypeEntry *nested_type, double vr)
+ : TypeEntry(QLatin1String("Array"), ArrayType, vr), m_nestedType(nested_type)
+ {
+ Q_ASSERT(m_nestedType);
+ }
+
+ void setNestedTypeEntry(TypeEntry *nested)
+ {
+ m_nestedType = nested;
+ }
+ const TypeEntry *nestedTypeEntry() const
+ {
+ return m_nestedType;
+ }
+
+ QString targetLangName() const
+ {
+ return m_nestedType->targetLangName() + QLatin1String("[]");
+ }
+ QString targetLangApiName() const
+ {
+ if (m_nestedType->isPrimitive())
+ return m_nestedType->targetLangApiName() + QLatin1String("Array");
+ else
+ return QLatin1String("jobjectArray");
+ }
+
+private:
+ const TypeEntry *m_nestedType;
+};
+
+
+class PrimitiveTypeEntry : public TypeEntry
+{
+public:
+ PrimitiveTypeEntry(const QString &name, double vr)
+ : TypeEntry(name, PrimitiveType, vr),
+ m_preferredConversion(true),
+ m_preferredTargetLangType(true),
+ m_referencedTypeEntry(0)
+ {
+ }
+
+ QString targetLangName() const
+ {
+ return m_targetLangName;
+ }
+ void setTargetLangName(const QString &targetLangName)
+ {
+ m_targetLangName = targetLangName;
+ }
+
+ QString targetLangApiName() const
+ {
+ return m_targetLangApiName;
+ }
+ void setTargetLangApiName(const QString &targetLangApiName)
+ {
+ m_targetLangApiName = targetLangApiName;
+ }
+
+ QString defaultConstructor() const
+ {
+ return m_defaultConstructor;
+ }
+ void setDefaultConstructor(const QString& defaultConstructor)
+ {
+ m_defaultConstructor = defaultConstructor;
+ }
+ bool hasDefaultConstructor() const
+ {
+ return !m_defaultConstructor.isEmpty();
+ }
+
+ /**
+ * The PrimitiveTypeEntry pointed by this type entry if it
+ * represents a typedef).
+ * /return the type referenced by the typedef, or a null pointer
+ * if the current object is not an typedef
+ */
+ PrimitiveTypeEntry* referencedTypeEntry() const { return m_referencedTypeEntry; }
+
+ /**
+ * Defines type referenced by this entry.
+ * /param referencedTypeEntry type referenced by this entry
+ */
+ void setReferencedTypeEntry(PrimitiveTypeEntry* referencedTypeEntry)
+ {
+ m_referencedTypeEntry = referencedTypeEntry;
+ }
+
+ /**
+ * Finds the most basic primitive type that the typedef represents,
+ * i.e. a type that is not an typedef'ed.
+ * /return the most basic non-typedef'ed primitive type represented
+ * by this typedef
+ */
+ PrimitiveTypeEntry* basicReferencedTypeEntry() const;
+
+ virtual bool preferredConversion() const
+ {
+ return m_preferredConversion;
+ }
+ virtual void setPreferredConversion(bool b)
+ {
+ m_preferredConversion = b;
+ }
+
+ virtual bool preferredTargetLangType() const
+ {
+ return m_preferredTargetLangType;
+ }
+ virtual void setPreferredTargetLangType(bool b)
+ {
+ m_preferredTargetLangType = b;
+ }
+
+ void setTargetLangPackage(const QString& package);
+ QString targetLangPackage() const;
+private:
+ QString m_targetLangName;
+ QString m_targetLangApiName;
+ QString m_defaultConstructor;
+ uint m_preferredConversion : 1;
+ uint m_preferredTargetLangType : 1;
+ PrimitiveTypeEntry* m_referencedTypeEntry;
+};
+
+struct EnumValueRedirection
+{
+ EnumValueRedirection(const QString &rej, const QString &us)
+ : rejected(rej),
+ used(us)
+ {
+ }
+ QString rejected;
+ QString used;
+};
+
+class EnumTypeEntry : public TypeEntry
+{
+public:
+ EnumTypeEntry(const QString &nspace, const QString &enumName, double vr)
+ : TypeEntry(nspace.isEmpty() ? enumName : nspace + QLatin1String("::") + enumName,
+ EnumType, vr),
+ m_qualifier(nspace),
+ m_targetLangName(enumName),
+ m_flags(0),
+ m_extensible(false),
+ m_forceInteger(false),
+ m_anonymous(false)
+ {
+ }
+
+ QString targetLangPackage() const
+ {
+ return m_packageName;
+ }
+ void setTargetLangPackage(const QString &package)
+ {
+ m_packageName = package;
+ }
+
+ QString targetLangName() const
+ {
+ return m_targetLangName;
+ }
+ QString targetLangQualifier() const;
+ QString qualifiedTargetLangName() const
+ {
+ QString qualifiedName;
+ QString pkg = targetLangPackage();
+ QString qualifier = targetLangQualifier();
+
+ if (!pkg.isEmpty())
+ qualifiedName += pkg + QLatin1Char('.');
+ if (!qualifier.isEmpty())
+ qualifiedName += qualifier + QLatin1Char('.');
+ qualifiedName += targetLangName();
+
+ return qualifiedName;
+ }
+
+ QString targetLangApiName() const;
+
+ QString qualifier() const
+ {
+ return m_qualifier;
+ }
+ void setQualifier(const QString &q)
+ {
+ m_qualifier = q;
+ }
+
+ virtual bool preferredConversion() const
+ {
+ return false;
+ }
+
+ bool isBoundsChecked() const
+ {
+ return m_lowerBound.isEmpty() && m_upperBound.isEmpty();
+ }
+
+ QString upperBound() const
+ {
+ return m_upperBound;
+ }
+ void setUpperBound(const QString &bound)
+ {
+ m_upperBound = bound;
+ }
+
+ QString lowerBound() const
+ {
+ return m_lowerBound;
+ }
+ void setLowerBound(const QString &bound)
+ {
+ m_lowerBound = bound;
+ }
+
+ void setFlags(FlagsTypeEntry *flags)
+ {
+ m_flags = flags;
+ }
+ FlagsTypeEntry *flags() const
+ {
+ return m_flags;
+ }
+
+ bool isExtensible() const
+ {
+ return m_extensible;
+ }
+ void setExtensible(bool is)
+ {
+ m_extensible = is;
+ }
+
+ bool isEnumValueRejected(const QString &name)
+ {
+ return m_rejectedEnums.contains(name);
+ }
+ void addEnumValueRejection(const QString &name)
+ {
+ m_rejectedEnums << name;
+ }
+ QStringList enumValueRejections() const
+ {
+ return m_rejectedEnums;
+ }
+
+ void addEnumValueRedirection(const QString &rejected, const QString &usedValue);
+ QString enumValueRedirection(const QString &value) const;
+
+ bool forceInteger() const
+ {
+ return m_forceInteger;
+ }
+ void setForceInteger(bool force)
+ {
+ m_forceInteger = force;
+ }
+
+ bool isAnonymous() const
+ {
+ return m_anonymous;
+ }
+ void setAnonymous(bool anonymous)
+ {
+ m_anonymous = anonymous;
+ }
+
+private:
+ QString m_packageName;
+ QString m_qualifier;
+ QString m_targetLangName;
+
+ QString m_lowerBound;
+ QString m_upperBound;
+
+ QStringList m_rejectedEnums;
+ QList<EnumValueRedirection> m_enumRedirections;
+
+ FlagsTypeEntry *m_flags;
+
+ bool m_extensible;
+ bool m_forceInteger;
+ bool m_anonymous;
+};
+
+class EnumValueTypeEntry : public TypeEntry
+{
+public:
+ EnumValueTypeEntry(const QString& name, const QString& value, const EnumTypeEntry* enclosingEnum, double vr)
+ : TypeEntry(name, TypeEntry::EnumValue, vr), m_value(value), m_enclosingEnum(enclosingEnum)
+ {
+ }
+
+ QString value() const { return m_value; }
+ const EnumTypeEntry* enclosingEnum() const { return m_enclosingEnum; }
+private:
+ QString m_value;
+ const EnumTypeEntry* m_enclosingEnum;
+};
+
+class FlagsTypeEntry : public TypeEntry
+{
+public:
+ FlagsTypeEntry(const QString &name, double vr) : TypeEntry(name, FlagsType, vr), m_enum(0)
+ {
+ }
+
+ QString qualifiedTargetLangName() const;
+ QString targetLangName() const
+ {
+ return m_targetLangName;
+ }
+ QString targetLangApiName() const;
+ virtual bool preferredConversion() const
+ {
+ return false;
+ }
+
+ QString originalName() const
+ {
+ return m_originalName;
+ }
+ void setOriginalName(const QString &s)
+ {
+ m_originalName = s;
+ }
+
+ QString flagsName() const
+ {
+ return m_targetLangName;
+ }
+ void setFlagsName(const QString &name)
+ {
+ m_targetLangName = name;
+ }
+
+ bool forceInteger() const
+ {
+ return m_enum->forceInteger();
+ }
+
+ EnumTypeEntry *originator() const
+ {
+ return m_enum;
+ }
+ void setOriginator(EnumTypeEntry *e)
+ {
+ m_enum = e;
+ }
+
+ QString targetLangPackage() const
+ {
+ return m_enum->targetLangPackage();
+ }
+
+private:
+ QString m_originalName;
+ QString m_targetLangName;
+ EnumTypeEntry *m_enum;
+};
+
+
+class ComplexTypeEntry : public TypeEntry
+{
+public:
+ enum TypeFlag {
+ ForceAbstract = 0x1,
+ DeleteInMainThread = 0x2,
+ Deprecated = 0x4
+ };
+ typedef QFlags<TypeFlag> TypeFlags;
+
+ enum CopyableFlag {
+ CopyableSet,
+ NonCopyableSet,
+ Unknown
+ };
+
+ ComplexTypeEntry(const QString &name, Type t, double vr)
+ : TypeEntry(QString(name).replace(QLatin1String(".*::"), QString()), t, vr),
+ m_qualifiedCppName(name),
+ m_qobject(false),
+ m_polymorphicBase(false),
+ m_genericClass(false),
+ m_typeFlags(0),
+ m_copyableFlag(Unknown),
+ m_baseContainerType(0)
+ {
+ }
+
+ bool isComplex() const
+ {
+ return true;
+ }
+
+ ComplexTypeEntry *copy() const
+ {
+ ComplexTypeEntry *centry = new ComplexTypeEntry(name(), type(), version());
+ centry->setInclude(include());
+ centry->setExtraIncludes(extraIncludes());
+ centry->setAddedFunctions(addedFunctions());
+ centry->setFunctionModifications(functionModifications());
+ centry->setFieldModifications(fieldModifications());
+ centry->setQObject(isQObject());
+ centry->setDefaultSuperclass(defaultSuperclass());
+ centry->setCodeSnips(codeSnips());
+ centry->setTargetLangPackage(targetLangPackage());
+ centry->setBaseContainerType(baseContainerType());
+ centry->setDefaultConstructor(defaultConstructor());
+
+ return centry;
+ }
+
+ void setLookupName(const QString &name)
+ {
+ m_lookupName = name;
+ }
+
+ virtual QString lookupName() const
+ {
+ return m_lookupName.isEmpty() ? targetLangName() : m_lookupName;
+ }
+
+ QString targetLangApiName() const;
+
+ void setTypeFlags(TypeFlags flags)
+ {
+ m_typeFlags = flags;
+ }
+
+ TypeFlags typeFlags() const
+ {
+ return m_typeFlags;
+ }
+
+ FunctionModificationList functionModifications() const
+ {
+ return m_functionMods;
+ }
+ void setFunctionModifications(const FunctionModificationList &functionModifications)
+ {
+ m_functionMods = functionModifications;
+ }
+ void addFunctionModification(const FunctionModification &functionModification)
+ {
+ m_functionMods << functionModification;
+ }
+ FunctionModificationList functionModifications(const QString &signature) const;
+
+ AddedFunctionList addedFunctions() const
+ {
+ return m_addedFunctions;
+ }
+ void setAddedFunctions(const AddedFunctionList &addedFunctions)
+ {
+ m_addedFunctions = addedFunctions;
+ }
+ void addNewFunction(const AddedFunction &addedFunction)
+ {
+ m_addedFunctions << addedFunction;
+ }
+
+ FieldModification fieldModification(const QString &name) const;
+ void setFieldModifications(const FieldModificationList &mods)
+ {
+ m_fieldMods = mods;
+ }
+ FieldModificationList fieldModifications() const
+ {
+ return m_fieldMods;
+ }
+
+ QString targetLangPackage() const
+ {
+ return m_package;
+ }
+ void setTargetLangPackage(const QString &package)
+ {
+ m_package = package;
+ }
+
+ bool isQObject() const
+ {
+ return m_qobject;
+ }
+ void setQObject(bool qobject)
+ {
+ m_qobject = qobject;
+ }
+
+ QString defaultSuperclass() const
+ {
+ return m_defaultSuperclass;
+ }
+ void setDefaultSuperclass(const QString &sc)
+ {
+ m_defaultSuperclass = sc;
+ }
+
+ virtual QString qualifiedCppName() const
+ {
+ return m_qualifiedCppName;
+ }
+
+
+ void setIsPolymorphicBase(bool on)
+ {
+ m_polymorphicBase = on;
+ }
+ bool isPolymorphicBase() const
+ {
+ return m_polymorphicBase;
+ }
+
+ void setPolymorphicIdValue(const QString &value)
+ {
+ m_polymorphicIdValue = value;
+ }
+ QString polymorphicIdValue() const
+ {
+ return m_polymorphicIdValue;
+ }
+
+ void setHeldType(const QString &value)
+ {
+ m_heldTypeValue = value;
+ }
+ QString heldTypeValue() const
+ {
+ return m_heldTypeValue;
+ }
+
+
+ void setExpensePolicy(const ExpensePolicy &policy)
+ {
+ m_expensePolicy = policy;
+ }
+ const ExpensePolicy &expensePolicy() const
+ {
+ return m_expensePolicy;
+ }
+
+ QString targetType() const
+ {
+ return m_targetType;
+ }
+ void setTargetType(const QString &code)
+ {
+ m_targetType = code;
+ }
+
+ QString targetLangName() const
+ {
+ return m_targetLangName.isEmpty()
+ ? TypeEntry::targetLangName()
+ : m_targetLangName;
+ }
+ void setTargetLangName(const QString &name)
+ {
+ m_targetLangName = name;
+ }
+
+ bool isGenericClass() const
+ {
+ return m_genericClass;
+ }
+ void setGenericClass(bool isGeneric)
+ {
+ m_genericClass = isGeneric;
+ }
+
+ CopyableFlag copyable() const
+ {
+ return m_copyableFlag;
+ }
+ void setCopyable(CopyableFlag flag)
+ {
+ m_copyableFlag = flag;
+ }
+
+ QString hashFunction() const
+ {
+ return m_hashFunction;
+ }
+ void setHashFunction(QString hashFunction)
+ {
+ m_hashFunction = hashFunction;
+ }
+
+ void setBaseContainerType(const ComplexTypeEntry *baseContainer)
+ {
+ m_baseContainerType = baseContainer;
+ }
+
+ const ComplexTypeEntry* baseContainerType() const
+ {
+ return m_baseContainerType;
+ }
+
+ QString defaultConstructor() const;
+ void setDefaultConstructor(const QString& defaultConstructor);
+ bool hasDefaultConstructor() const;
+
+private:
+ AddedFunctionList m_addedFunctions;
+ FunctionModificationList m_functionMods;
+ FieldModificationList m_fieldMods;
+ QString m_package;
+ QString m_defaultSuperclass;
+ QString m_qualifiedCppName;
+ QString m_targetLangName;
+
+ uint m_qobject : 1;
+ uint m_polymorphicBase : 1;
+ uint m_genericClass : 1;
+
+ QString m_polymorphicIdValue;
+ QString m_heldTypeValue;
+ QString m_lookupName;
+ QString m_targetType;
+ ExpensePolicy m_expensePolicy;
+ TypeFlags m_typeFlags;
+ CopyableFlag m_copyableFlag;
+ QString m_hashFunction;
+
+ const ComplexTypeEntry* m_baseContainerType;
+};
+
+class ContainerTypeEntry : public ComplexTypeEntry
+{
+ Q_GADGET
+public:
+ enum Type {
+ NoContainer,
+ ListContainer,
+ StringListContainer,
+ LinkedListContainer,
+ VectorContainer,
+ StackContainer,
+ QueueContainer,
+ SetContainer,
+ MapContainer,
+ MultiMapContainer,
+ HashContainer,
+ MultiHashContainer,
+ PairContainer,
+ };
+ Q_ENUM(Type)
+
+ ContainerTypeEntry(const QString &name, Type type, double vr)
+ : ComplexTypeEntry(name, ContainerType, vr), m_type(type)
+ {
+ setCodeGeneration(GenerateForSubclass);
+ }
+
+ Type type() const
+ {
+ return m_type;
+ }
+
+ QString typeName() const;
+ QString targetLangName() const;
+ QString targetLangPackage() const;
+ QString qualifiedCppName() const;
+
+ static Type containerTypeFromString(QString typeName)
+ {
+ static QHash<QString, Type> m_stringToContainerType;
+ if (m_stringToContainerType.isEmpty()) {
+ m_stringToContainerType.insert(QLatin1String("list"), ListContainer);
+ m_stringToContainerType.insert(QLatin1String("string-list"), StringListContainer);
+ m_stringToContainerType.insert(QLatin1String("linked-list"), LinkedListContainer);
+ m_stringToContainerType.insert(QLatin1String("vector"), VectorContainer);
+ m_stringToContainerType.insert(QLatin1String("stack"), StackContainer);
+ m_stringToContainerType.insert(QLatin1String("queue"), QueueContainer);
+ m_stringToContainerType.insert(QLatin1String("set"), SetContainer);
+ m_stringToContainerType.insert(QLatin1String("map"), MapContainer);
+ m_stringToContainerType.insert(QLatin1String("multi-map"), MultiMapContainer);
+ m_stringToContainerType.insert(QLatin1String("hash"), HashContainer);
+ m_stringToContainerType.insert(QLatin1String("multi-hash"), MultiHashContainer);
+ m_stringToContainerType.insert(QLatin1String("pair"), PairContainer);
+ }
+ return m_stringToContainerType.value(typeName, NoContainer);
+ }
+
+private:
+ Type m_type;
+};
+
+class SmartPointerTypeEntry : public ComplexTypeEntry
+{
+public:
+ SmartPointerTypeEntry(const QString &name,
+ const QString &getterName,
+ const QString &smartPointerType,
+ const QString &refCountMethodName,
+ double vr)
+ : ComplexTypeEntry(name, SmartPointerType, vr),
+ m_getterName(getterName),
+ m_smartPointerType(smartPointerType),
+ m_refCountMethodName(refCountMethodName)
+ {
+ }
+
+ QString getter() const
+ {
+ return m_getterName;
+ }
+
+ QString refCountMethodName() const
+ {
+ return m_refCountMethodName;
+ }
+
+private:
+ QString m_getterName;
+ QString m_smartPointerType;
+ QString m_refCountMethodName;
+};
+
+class NamespaceTypeEntry : public ComplexTypeEntry
+{
+public:
+ NamespaceTypeEntry(const QString &name, double vr) : ComplexTypeEntry(name, NamespaceType, vr) { }
+};
+
+
+class ValueTypeEntry : public ComplexTypeEntry
+{
+public:
+ ValueTypeEntry(const QString &name, double vr) : ComplexTypeEntry(name, BasicValueType, vr) { }
+
+ bool isValue() const
+ {
+ return true;
+ }
+
+ virtual bool isNativeIdBased() const
+ {
+ return true;
+ }
+
+protected:
+ ValueTypeEntry(const QString &name, Type t, double vr) : ComplexTypeEntry(name, t, vr) { }
+};
+
+
+class StringTypeEntry : public ValueTypeEntry
+{
+public:
+ StringTypeEntry(const QString &name, double vr)
+ : ValueTypeEntry(name, StringType, vr)
+ {
+ setCodeGeneration(GenerateNothing);
+ }
+
+ QString targetLangApiName() const;
+ QString targetLangName() const;
+ QString targetLangPackage() const;
+
+ virtual bool isNativeIdBased() const
+ {
+ return false;
+ }
+};
+
+class CharTypeEntry : public ValueTypeEntry
+{
+public:
+ CharTypeEntry(const QString &name, double vr) : ValueTypeEntry(name, CharType, vr)
+ {
+ setCodeGeneration(GenerateNothing);
+ }
+
+ QString targetLangApiName() const;
+ QString targetLangName() const;
+ QString targetLangPackage() const
+ {
+ return QString();
+ }
+
+ virtual bool isNativeIdBased() const
+ {
+ return false;
+ }
+};
+
+class VariantTypeEntry: public ValueTypeEntry
+{
+public:
+ VariantTypeEntry(const QString &name, double vr) : ValueTypeEntry(name, VariantType, vr) { }
+
+ QString targetLangApiName() const;
+ QString targetLangName() const;
+ QString targetLangPackage() const;
+
+ virtual bool isNativeIdBased() const
+ {
+ return false;
+ }
+};
+
+
+class InterfaceTypeEntry : public ComplexTypeEntry
+{
+public:
+ InterfaceTypeEntry(const QString &name, double vr)
+ : ComplexTypeEntry(name, InterfaceType, vr) {}
+
+ static QString interfaceName(const QString &name)
+ {
+ return name + QLatin1String("Interface");
+ }
+
+ ObjectTypeEntry *origin() const
+ {
+ return m_origin;
+ }
+ void setOrigin(ObjectTypeEntry *origin)
+ {
+ m_origin = origin;
+ }
+
+ virtual bool isNativeIdBased() const
+ {
+ return true;
+ }
+ virtual QString qualifiedCppName() const
+ {
+ const int len = ComplexTypeEntry::qualifiedCppName().length() - interfaceName(QString()).length();
+ return ComplexTypeEntry::qualifiedCppName().left(len);
+ }
+
+private:
+ ObjectTypeEntry *m_origin;
+};
+
+
+class FunctionTypeEntry : public TypeEntry
+{
+public:
+ FunctionTypeEntry(const QString& name, const QString& signature, double vr)
+ : TypeEntry(name, FunctionType, vr)
+ {
+ addSignature(signature);
+ }
+ void addSignature(const QString& signature)
+ {
+ m_signatures << signature;
+ }
+
+ QStringList signatures() const
+ {
+ return m_signatures;
+ }
+
+ bool hasSignature(const QString& signature) const
+ {
+ return m_signatures.contains(signature);
+ }
+private:
+ QStringList m_signatures;
+};
+
+class ObjectTypeEntry : public ComplexTypeEntry
+{
+public:
+ ObjectTypeEntry(const QString &name, double vr)
+ : ComplexTypeEntry(name, ObjectType, vr), m_interface(0) {}
+
+ InterfaceTypeEntry *designatedInterface() const
+ {
+ return m_interface;
+ }
+ void setDesignatedInterface(InterfaceTypeEntry *entry)
+ {
+ m_interface = entry;
+ }
+
+ virtual bool isNativeIdBased() const
+ {
+ return true;
+ }
+
+private:
+ InterfaceTypeEntry *m_interface;
+};
+
+struct TypeRejection
+{
+ QString class_name;
+ QString function_name;
+ QString field_name;
+ QString enum_name;
+};
+
+QString fixCppTypeName(const QString &name);
+
+class CustomConversion
+{
+public:
+ CustomConversion(TypeEntry* ownerType);
+ ~CustomConversion();
+
+ const TypeEntry* ownerType() const;
+ QString nativeToTargetConversion() const;
+ void setNativeToTargetConversion(const QString& nativeToTargetConversion);
+
+ class TargetToNativeConversion
+ {
+ public:
+ TargetToNativeConversion(const QString& sourceTypeName,
+ const QString& sourceTypeCheck,
+ const QString& conversion = QString());
+ ~TargetToNativeConversion();
+
+ const TypeEntry* sourceType() const;
+ void setSourceType(const TypeEntry* sourceType);
+ bool isCustomType() const;
+ QString sourceTypeName() const;
+ QString sourceTypeCheck() const;
+ QString conversion() const;
+ void setConversion(const QString& conversion);
+ private:
+ struct TargetToNativeConversionPrivate;
+ TargetToNativeConversionPrivate* m_d;
+ };
+
+ /**
+ * Returns true if the target to C++ custom conversions should
+ * replace the original existing ones, and false if the custom
+ * conversions should be added to the original.
+ */
+ bool replaceOriginalTargetToNativeConversions() const;
+ void setReplaceOriginalTargetToNativeConversions(bool replaceOriginalTargetToNativeConversions);
+
+ typedef QList<TargetToNativeConversion*> TargetToNativeConversions;
+ bool hasTargetToNativeConversions() const;
+ TargetToNativeConversions& targetToNativeConversions();
+ const TargetToNativeConversions& targetToNativeConversions() const;
+ void addTargetToNativeConversion(const QString& sourceTypeName,
+ const QString& sourceTypeCheck,
+ const QString& conversion = QString());
+private:
+ struct CustomConversionPrivate;
+ CustomConversionPrivate* m_d;
+};
+
+#endif // TYPESYSTEM_H
diff --git a/sources/shiboken2/ApiExtractor/typesystem_enums.h b/sources/shiboken2/ApiExtractor/typesystem_enums.h
new file mode 100644
index 000000000..2d67d7cc5
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/typesystem_enums.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TYPESYSTEM_ENUMS_H
+#define TYPESYSTEM_ENUMS_H
+
+namespace TypeSystem
+{
+enum Language {
+ NoLanguage = 0x0000,
+ TargetLangCode = 0x0001,
+ NativeCode = 0x0002,
+ ShellCode = 0x0004,
+ ShellDeclaration = 0x0008,
+ PackageInitializer = 0x0010,
+ DestructorFunction = 0x0020,
+ Constructors = 0x0040,
+ Interface = 0x0080,
+
+ // masks
+ All = TargetLangCode
+ | NativeCode
+ | ShellCode
+ | ShellDeclaration
+ | PackageInitializer
+ | Constructors
+ | Interface
+ | DestructorFunction,
+
+ TargetLangAndNativeCode = TargetLangCode | NativeCode
+};
+
+enum Ownership {
+ InvalidOwnership,
+ DefaultOwnership,
+ TargetLangOwnership,
+ CppOwnership
+};
+
+enum CodeSnipPosition {
+ CodeSnipPositionBeginning,
+ CodeSnipPositionEnd,
+ CodeSnipPositionAfterThis,
+ // QtScript
+ CodeSnipPositionDeclaration,
+ CodeSnipPositionPrototypeInitialization,
+ CodeSnipPositionConstructorInitialization,
+ CodeSnipPositionConstructor,
+ CodeSnipPositionAny
+};
+
+enum DocModificationMode {
+ DocModificationAppend,
+ DocModificationPrepend,
+ DocModificationReplace,
+ DocModificationXPathReplace
+};
+
+} // namespace TypeSystem
+
+#endif // TYPESYSTEM_ENUMS_H
diff --git a/sources/shiboken2/ApiExtractor/typesystem_p.h b/sources/shiboken2/ApiExtractor/typesystem_p.h
new file mode 100644
index 000000000..f2105a631
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/typesystem_p.h
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TYPESYSTEM_P_H
+#define TYPESYSTEM_P_H
+
+#include <QStack>
+#include "typesystem.h"
+
+QT_FORWARD_DECLARE_CLASS(QXmlStreamAttributes)
+QT_FORWARD_DECLARE_CLASS(QXmlStreamReader)
+
+class TypeDatabase;
+class StackElement
+{
+ public:
+ enum ElementType {
+ None = 0x0,
+
+ // Type tags (0x1, ... , 0xff)
+ ObjectTypeEntry = 0x1,
+ ValueTypeEntry = 0x2,
+ InterfaceTypeEntry = 0x3,
+ NamespaceTypeEntry = 0x4,
+ ComplexTypeEntryMask = 0x7,
+
+ // Non-complex type tags (0x8, 0x9, ... , 0xf)
+ PrimitiveTypeEntry = 0x8,
+ EnumTypeEntry = 0x9,
+ ContainerTypeEntry = 0xa,
+ FunctionTypeEntry = 0xb,
+ CustomTypeEntry = 0xc,
+ SmartPointerTypeEntry = 0xd,
+ TypeEntryMask = 0xf,
+
+ // Documentation tags
+ InjectDocumentation = 0x10,
+ ModifyDocumentation = 0x20,
+ DocumentationMask = 0xf0,
+
+ // Simple tags (0x100, 0x200, ... , 0xf00)
+ ExtraIncludes = 0x0100,
+ Include = 0x0200,
+ ModifyFunction = 0x0300,
+ ModifyField = 0x0400,
+ Root = 0x0500,
+ CustomMetaConstructor = 0x0600,
+ CustomMetaDestructor = 0x0700,
+ ArgumentMap = 0x0800,
+ SuppressedWarning = 0x0900,
+ Rejection = 0x0a00,
+ LoadTypesystem = 0x0b00,
+ RejectEnumValue = 0x0c00,
+ Template = 0x0d00,
+ TemplateInstanceEnum = 0x0e00,
+ Replace = 0x0f00,
+ AddFunction = 0x1000,
+ NativeToTarget = 0x1100,
+ TargetToNative = 0x1200,
+ AddConversion = 0x1300,
+ SimpleMask = 0x3f00,
+
+ // Code snip tags (0x1000, 0x2000, ... , 0xf000)
+ InjectCode = 0x4000,
+ InjectCodeInFunction = 0x8000,
+ CodeSnipMask = 0xc000,
+
+ // Function modifier tags (0x010000, 0x020000, ... , 0xf00000)
+ Access = 0x010000,
+ Removal = 0x020000,
+ Rename = 0x040000,
+ ModifyArgument = 0x080000,
+ Thread = 0x100000,
+ FunctionModifiers = 0xff0000,
+
+ // Argument modifier tags (0x01000000 ... 0xf0000000)
+ ConversionRule = 0x01000000,
+ ReplaceType = 0x02000000,
+ ReplaceDefaultExpression = 0x04000000,
+ RemoveArgument = 0x08000000,
+ DefineOwnership = 0x10000000,
+ RemoveDefaultExpression = 0x20000000,
+ NoNullPointers = 0x40000000,
+ ReferenceCount = 0x80000000,
+ ParentOwner = 0x90000000,
+ ArgumentModifiers = 0xff000000
+ };
+
+ StackElement(StackElement *p) : entry(0), type(None), parent(p) { }
+
+ TypeEntry* entry;
+ ElementType type;
+ StackElement *parent;
+
+ union {
+ TemplateInstance* templateInstance;
+ TemplateEntry* templateEntry;
+ CustomFunction* customFunction;
+ } value;
+};
+
+struct StackElementContext
+{
+ CodeSnipList codeSnips;
+ AddedFunctionList addedFunctions;
+ FunctionModificationList functionMods;
+ FieldModificationList fieldMods;
+ DocModificationList docModifications;
+};
+
+class Handler
+{
+public:
+ Handler(TypeDatabase* database, bool generate);
+
+ bool parse(QXmlStreamReader &reader);
+
+private:
+ bool startElement(const QStringRef& localName, const QXmlStreamAttributes& atts);
+ bool handleSmartPointerEntry(StackElement *element,
+ QHash<QString, QString> &attributes,
+ const QString &name,
+ double since);
+ bool endElement(const QStringRef& localName);
+ template <class String> // QString/QStringRef
+ bool characters(const String &ch);
+ void fetchAttributeValues(const QString &name, const QXmlStreamAttributes &atts,
+ QHash<QString, QString> *acceptedAttributes);
+
+ bool importFileElement(const QXmlStreamAttributes &atts);
+ bool convertBoolean(const QString &, const QString &, bool);
+ void addFlags(const QString &name, QString flagName,
+ const QHash<QString, QString> &attributes, double since);
+
+ TypeDatabase* m_database;
+ StackElement* m_current;
+ StackElement* m_currentDroppedEntry;
+ int m_currentDroppedEntryDepth;
+ int m_ignoreDepth;
+ QString m_defaultPackage;
+ QString m_defaultSuperclass;
+ QString m_error;
+ TypeEntry::CodeGeneration m_generate;
+
+ EnumTypeEntry* m_currentEnum;
+ QStack<StackElementContext*> m_contextStack;
+
+ QHash<QString, StackElement::ElementType> tagNames;
+ QString m_currentSignature;
+};
+
+#endif
diff --git a/sources/shiboken2/ApiExtractor/typesystem_typedefs.h b/sources/shiboken2/ApiExtractor/typesystem_typedefs.h
new file mode 100644
index 000000000..04b669655
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/typesystem_typedefs.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TYPESYSTEM_TYPEDEFS_H
+#define TYPESYSTEM_TYPEDEFS_H
+
+#include <QtCore/QHash>
+#include <QtCore/QList>
+
+class CodeSnip;
+class ContainerTypeEntry;
+class DocModification;
+class PrimitiveTypeEntry;
+class TemplateEntry;
+class TypeEntry;
+
+struct AddedFunction;
+struct FieldModification;
+struct FunctionModification;
+
+typedef QHash<QString, QList<TypeEntry *> > TypeEntryHash;
+typedef QHash<QString, TypeEntry *> SingleTypeEntryHash;
+typedef QHash<QString, TemplateEntry *> TemplateEntryHash;
+
+typedef QList<AddedFunction> AddedFunctionList;
+typedef QList<CodeSnip> CodeSnipList;
+typedef QList<const ContainerTypeEntry *> ContainerTypeEntryList;
+typedef QList<DocModification> DocModificationList;
+typedef QList<FieldModification> FieldModificationList;
+typedef QList<FunctionModification> FunctionModificationList;
+typedef QList<const PrimitiveTypeEntry *> PrimitiveTypeEntryList;
+
+#endif // TYPESYSTEM_TYPEDEFS_H
diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt
new file mode 100644
index 000000000..96d4ec5cc
--- /dev/null
+++ b/sources/shiboken2/CMakeLists.txt
@@ -0,0 +1,244 @@
+Include(icecc.cmake)
+project(shiboken2)
+
+cmake_minimum_required(VERSION 3.0)
+cmake_policy(VERSION 3.0)
+
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/
+ ${CMAKE_MODULE_PATH})
+
+find_package(Qt5 REQUIRED COMPONENTS Core Xml XmlPatterns)
+
+add_definitions(${Qt5Core_DEFINITIONS})
+
+set(shiboken_MAJOR_VERSION "2")
+set(shiboken_MINOR_VERSION "0")
+set(shiboken_MICRO_VERSION "0")
+set(shiboken2_VERSION "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}.${shiboken_MICRO_VERSION}")
+
+option(BUILD_TESTS "Build tests." TRUE)
+option(USE_PYTHON_VERSION "Use specific python version to build shiboken2." "")
+
+if (USE_PYTHON_VERSION)
+ find_package(PythonInterp ${USE_PYTHON_VERSION} REQUIRED)
+ find_package(PythonLibs ${USE_PYTHON_VERSION} REQUIRED)
+else()
+ find_package(PythonInterp 2.6)
+ find_package(PythonLibs 2.6)
+endif()
+
+## For debugging the PYTHON* variables
+message("PYTHONLIBS_FOUND: " ${PYTHONLIBS_FOUND})
+message("PYTHON_LIBRARIES: " ${PYTHON_LIBRARIES})
+message("PYTHON_INCLUDE_DIRS: " ${PYTHON_INCLUDE_DIRS})
+message("PYTHON_DEBUG_LIBRARIES: " ${PYTHON_DEBUG_LIBRARIES})
+message("PYTHONINTERP_FOUND: " ${PYTHONINTERP_FOUND})
+message("PYTHON_EXECUTABLE: " ${PYTHON_EXECUTABLE})
+message("PYTHON_VERSION: " ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH})
+
+# Queries the python sysconfig for the abi flags which need to be inserted into extension suffixes.
+# Only present starting with Python 3.2.
+# Corresponding configure switches to single letter flags:
+# --with-pymalloc -> m
+# --with-pydebug -> d
+# --with-unicode -> u (rare)
+macro(get_python3_abi_flags)
+ if (NOT PYTHON_ABI_FLAGS)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ import sysconfig
+ print(sysconfig.get_config_var('abiflags'))
+ "
+ OUTPUT_VARIABLE PYTHON_ABI_FLAGS
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ endif()
+ message("PYTHON_ABI_FLAGS: " ${PYTHON_ABI_FLAGS})
+endmacro()
+
+macro(get_python_multi_arch_suffix)
+ # TODO: This part needs testing to check if it is available on Windows.
+ # It is present on macOS, but is not used yet.
+ # Result is something like 'x86_64-linux-gnu'.
+ if (NOT PYTHON_MULTIARCH_SUFFIX)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ import sysconfig
+ print(sysconfig.get_config_var('MULTIARCH'))
+ "
+ OUTPUT_VARIABLE PYTHON_MULTIARCH_SUFFIX
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ endif()
+ message("PYTHON_MULTIARCH_SUFFIX: " ${PYTHON_MULTIARCH_SUFFIX})
+endmacro()
+
+macro(get_python2_release_suffix)
+ # Result of imp.get_suffixes() is something like:
+ # [('_d.so', 'rb', 3), ('module_d.so', 'rb', 3), ('.x86_64-linux-gnu_d.so', 'rb', 3)]
+ # or alternatively the same but withut the '_d' part.
+ # The list comprehension is used to choose which suffix to include in library names.
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ import imp
+ print('_d' if any([tup[0].endswith('_d.so') for tup in imp.get_suffixes()]) else '')
+ "
+ OUTPUT_VARIABLE PYTHON_MODULE_RELEASE_SUFFIX
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message("PYTHON_MODULE_RELEASE_SUFFIX: " ${PYTHON_MODULE_RELEASE_SUFFIX})
+endmacro()
+
+# Note the quirk that UNIX includes Apple!
+if (UNIX AND NOT APPLE)
+ if (NOT PYTHON_EXTENSION_SUFFIX)
+ get_python_multi_arch_suffix()
+ # The suffix added to .so libraries should be differenet between Python 2 and 3.
+ # The position of the multiarch suffix is different, and the way the debug flag is set
+ # computed differently.
+ # In Python 2 there is no standard way to query if the python interpeter was built in debug or
+ # release build (sysconfig.get_config_var('Py_Debug') can have a different value than you would
+ # expect if you do a custom Python build). The solution is to query for the import
+ # suffixes and check if _d is present there. It is present on Linux distribution
+ # packages of Python, but not in custom built Python builds, because the distros apply their
+ # custom patches too append the '_d's.
+ # In Python 3 (starting with 3.2) there is a standard way to check if '_d' needs to be added,
+ # as well as any other letters, by querying the abiflags sysconfig variable.
+ if (PYTHON_VERSION_MAJOR EQUAL 2)
+ get_python2_release_suffix()
+ if(PYTHON_MULTIARCH_SUFFIX)
+ set(PYTHON_EXTENSION_SUFFIX ".${PYTHON_MULTIARCH_SUFFIX}")
+ endif()
+ set(PYTHON_EXTENSION_SUFFIX "${PYTHON_EXTENSION_SUFFIX}${PYTHON_MODULE_RELEASE_SUFFIX}")
+ elseif (PYTHON_VERSION_MAJOR EQUAL 3)
+ get_python3_abi_flags()
+ set(PYTHON_EXTENSION_SUFFIX ".cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}${PYTHON_ABI_FLAGS}")
+ if(PYTHON_MULTIARCH_SUFFIX)
+ set(PYTHON_EXTENSION_SUFFIX "${PYTHON_EXTENSION_SUFFIX}-${PYTHON_MULTIARCH_SUFFIX}")
+ endif()
+ else()
+ message(FATAL_ERROR "Unsupported PYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}!")
+ endif()
+ endif()
+ message(STATUS "PYTHON_EXTENSION_SUFFIX: ${PYTHON_EXTENSION_SUFFIX}")
+endif ()
+
+if (NOT PYTHON_SITE_PACKAGES)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ from distutils import sysconfig
+ from os.path import sep
+ print(sysconfig.get_python_lib(1, 0, prefix='${CMAKE_INSTALL_PREFIX}').replace(sep, '/'))
+ "
+ OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (NOT PYTHON_SITE_PACKAGES)
+ message(FATAL_ERROR "Could not detect Python module installation directory.")
+ elseif (APPLE)
+ message(STATUS "!!! The generated bindings will be installed on ${PYTHON_SITE_PACKAGES}, is it right!?")
+ endif()
+endif()
+
+if(MSVC)
+ # Qt5: this flag has changed from /Zc:wchar_t- in Qt4.X
+ set(CMAKE_CXX_FLAGS "/Zc:wchar_t /GR /EHsc /DWIN32 /D_WINDOWS /D_SCL_SECURE_NO_WARNINGS")
+else()
+ if(CMAKE_HOST_UNIX AND NOT CYGWIN)
+ add_definitions(-fPIC)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden -Wno-strict-aliasing")
+ endif()
+ set(CMAKE_CXX_FLAGS_DEBUG "-g")
+ option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0)
+ if(ENABLE_GCC_OPTIMIZATION)
+ set(CMAKE_BUILD_TYPE Release)
+ set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -Os -Wl,-O1")
+ if(NOT CMAKE_HOST_APPLE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--hash-style=gnu")
+ endif()
+ endif()
+endif()
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D QT_NO_CAST_FROM_ASCII -D QT_NO_CAST_TO_ASCII")
+
+set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
+set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE)
+
+if (WIN32)
+ set(PATH_SEP "\;")
+else()
+ set(PATH_SEP ":")
+endif()
+
+if(CMAKE_HOST_APPLE)
+ set(OSX_USE_LIBCPP "OFF" CACHE BOOL "Explicitly link the libc++ standard library (useful for osx deployment targets lower than 10.9.")
+ if(OSX_USE_LIBCPP)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+ endif()
+endif()
+
+add_subdirectory(ApiExtractor)
+
+set(generator_plugin_DIR ${LIB_INSTALL_DIR}/generatorrunner${generator_SUFFIX})
+
+# uninstall target
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ IMMEDIATE @ONLY)
+add_custom_target(uninstall "${CMAKE_COMMAND}"
+ -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
+
+set(SHIBOKEN_BUILD_TYPE "Release")
+if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ if(NOT PYTHON_DEBUG_LIBRARIES)
+ message(WARNING "Python debug shared library not found; assuming python was built with shared library support disabled.")
+ endif()
+ if(NOT PYTHON_WITH_DEBUG)
+ message(WARNING "Compiling shiboken2 with debug enabled, but the python executable was not compiled with debug support.")
+ else()
+ add_definitions("-DPy_DEBUG")
+ set(SBK_ADD_PY_DEBUG_DEFINITION "add_definitions(\"-DPy_DEBUG\")")
+ set(SBK_PKG_CONFIG_PY_DEBUG_DEFINITION " -DPy_DEBUG")
+ endif()
+ set(SBK_PYTHON_LIBRARIES ${PYTHON_DEBUG_LIBRARIES})
+ set(SHIBOKEN_BUILD_TYPE "Debug")
+else()
+ set(SBK_PYTHON_LIBRARIES ${PYTHON_LIBRARIES})
+ add_definitions("-DNDEBUG")
+endif()
+if(APPLE)
+ set(SBK_PYTHON_LIBRARIES "-undefined dynamic_lookup")
+endif()
+
+if(CMAKE_VERSION VERSION_LESS 2.8)
+ set(SBK_PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_PATH})
+else()
+ set(SBK_PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_DIRS})
+endif()
+
+add_subdirectory(libshiboken)
+add_subdirectory(doc)
+
+# deps found, compile the generator.
+if (Qt5Core_FOUND AND PYTHONINTERP_FOUND)
+ add_subdirectory(generator)
+ add_subdirectory(shibokenmodule)
+
+ if (BUILD_TESTS)
+ enable_testing()
+ add_subdirectory(tests)
+ endif()
+else()
+ message(WARNING "Some dependencies were not found, shiboken2 generator compilation disabled!")
+endif()
+
+add_subdirectory(data)
+
+# dist target
+set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${shiboken2_VERSION})
+add_custom_target(dist
+ COMMAND mkdir -p "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}" &&
+ git log > "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}/ChangeLog" &&
+ git archive --prefix=${ARCHIVE_NAME}/ HEAD --format=tar --output="${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" &&
+ tar -C "${CMAKE_BINARY_DIR}" --owner=root --group=root -r "${ARCHIVE_NAME}/ChangeLog" -f "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" &&
+ bzip2 -f9 "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" &&
+ echo "Source package created at ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2."
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+
diff --git a/sources/shiboken2/COPYING b/sources/shiboken2/COPYING
new file mode 100644
index 000000000..4ccd71466
--- /dev/null
+++ b/sources/shiboken2/COPYING
@@ -0,0 +1,342 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
+-------------------------------------------------------------------------
diff --git a/sources/shiboken2/COPYING.libsample b/sources/shiboken2/COPYING.libsample
new file mode 100644
index 000000000..9315102f7
--- /dev/null
+++ b/sources/shiboken2/COPYING.libsample
@@ -0,0 +1,501 @@
+GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
diff --git a/sources/shiboken2/COPYING.libshiboken b/sources/shiboken2/COPYING.libshiboken
new file mode 100644
index 000000000..9315102f7
--- /dev/null
+++ b/sources/shiboken2/COPYING.libshiboken
@@ -0,0 +1,501 @@
+GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
diff --git a/sources/shiboken2/Doxyfile b/sources/shiboken2/Doxyfile
new file mode 100644
index 000000000..9be56a0e4
--- /dev/null
+++ b/sources/shiboken2/Doxyfile
@@ -0,0 +1,311 @@
+# Doxyfile 1.5.7.1
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+DOXYFILE_ENCODING = UTF-8
+PROJECT_NAME = "Generator Runner"
+PROJECT_NUMBER = 0.1
+OUTPUT_DIRECTORY = doc
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE = English
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = YES
+STRIP_FROM_PATH = /tmp/src/generatorrunner/
+STRIP_FROM_INC_PATH =
+SHORT_NAMES = NO
+JAVADOC_AUTOBRIEF = YES
+QT_AUTOBRIEF = NO
+MULTILINE_CPP_IS_BRIEF = NO
+INHERIT_DOCS = YES
+SEPARATE_MEMBER_PAGES = NO
+TAB_SIZE = 8
+ALIASES =
+OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_JAVA = NO
+OPTIMIZE_FOR_FORTRAN = NO
+OPTIMIZE_OUTPUT_VHDL = NO
+BUILTIN_STL_SUPPORT = NO
+CPP_CLI_SUPPORT = NO
+SIP_SUPPORT = NO
+IDL_PROPERTY_SUPPORT = YES
+DISTRIBUTE_GROUP_DOC = NO
+SUBGROUPING = YES
+TYPEDEF_HIDES_STRUCT = NO
+SYMBOL_CACHE_SIZE = 0
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL = YES
+EXTRACT_PRIVATE = YES
+EXTRACT_STATIC = YES
+EXTRACT_LOCAL_CLASSES = YES
+EXTRACT_LOCAL_METHODS = NO
+EXTRACT_ANON_NSPACES = NO
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+INTERNAL_DOCS = NO
+CASE_SENSE_NAMES = YES
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+SORT_BRIEF_DOCS = NO
+SORT_GROUP_NAMES = NO
+SORT_BY_SCOPE_NAME = NO
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_DIRECTORIES = NO
+SHOW_FILES = YES
+SHOW_NAMESPACES = YES
+FILE_VERSION_FILTER =
+LAYOUT_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_NO_PARAMDOC = NO
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = /tmp/src/generatorrunner
+INPUT_ENCODING = UTF-8
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.d \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.idl \
+ *.odl \
+ *.cs \
+ *.php \
+ *.php3 \
+ *.inc \
+ *.m \
+ *.mm \
+ *.dox \
+ *.py \
+ *.f90 \
+ *.f \
+ *.vhd \
+ *.vhdl \
+ *.C \
+ *.CC \
+ *.C++ \
+ *.II \
+ *.I++ \
+ *.H \
+ *.HH \
+ *.H++ \
+ *.CS \
+ *.PHP \
+ *.PHP3 \
+ *.M \
+ *.MM \
+ *.PY \
+ *.F90 \
+ *.F \
+ *.VHD \
+ *.VHDL
+RECURSIVE = YES
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXCLUDE_SYMBOLS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS = *
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_PATTERNS =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION = NO
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS = NO
+VERBATIM_HEADERS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = YES
+COLS_IN_ALPHA_INDEX = 3
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+HTML_DYNAMIC_SECTIONS = NO
+GENERATE_DOCSET = NO
+DOCSET_FEEDNAME = "Doxygen generated docs"
+DOCSET_BUNDLE_ID = org.doxygen.Project
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+CHM_INDEX_ENCODING =
+BINARY_TOC = NO
+TOC_EXPAND = NO
+GENERATE_QHP = NO
+QCH_FILE =
+QHP_NAMESPACE = org.doxygen.Project
+QHP_VIRTUAL_FOLDER = doc
+QHG_LOCATION =
+DISABLE_INDEX = NO
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = NONE
+TREEVIEW_WIDTH = 250
+FORMULA_FONTSIZE = 10
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = NO
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = YES
+USE_PDFLATEX = YES
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+XML_PROGRAMLISTING = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES = ../libgenrunner/libgenrunner.tag=../libgenrunner
+GENERATE_TAGFILE = generatorrunner.tag
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+MSCGEN_PATH =
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = YES
+DOT_FONTNAME = FreeSans
+DOT_FONTSIZE = 10
+DOT_FONTPATH =
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+GROUP_GRAPHS = NO
+UML_LOOK = NO
+TEMPLATE_RELATIONS = NO
+INCLUDE_GRAPH = NO
+INCLUDED_BY_GRAPH = NO
+CALL_GRAPH = NO
+CALLER_GRAPH = NO
+GRAPHICAL_HIERARCHY = YES
+DIRECTORY_GRAPH = NO
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+DOT_GRAPH_MAX_NODES = 50
+MAX_DOT_GRAPH_DEPTH = 1000
+DOT_TRANSPARENT = NO
+DOT_MULTI_TARGETS = NO
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO
diff --git a/sources/shiboken2/LICENSE.GPLv3 b/sources/shiboken2/LICENSE.GPLv3
new file mode 100644
index 000000000..71c4ad49c
--- /dev/null
+++ b/sources/shiboken2/LICENSE.GPLv3
@@ -0,0 +1,686 @@
+ GNU GENERAL PUBLIC LICENSE
+
+ The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
+ Contact: http://www.qt.io/licensing/
+
+ You may use, distribute and copy the Qt Toolkit under the terms of
+ GNU Lesser General Public License version 3. That license references
+ the General Public License version 3, that is displayed below. Other
+ portions of the Qt Toolkit may be licensed directly under this license.
+
+-------------------------------------------------------------------------
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/sources/shiboken2/LICENSE.LGPLv21 b/sources/shiboken2/LICENSE.LGPLv21
new file mode 100644
index 000000000..15a208b48
--- /dev/null
+++ b/sources/shiboken2/LICENSE.LGPLv21
@@ -0,0 +1,514 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+
+ The Qt Toolkit is Copyright (C) 2016 The Qt Company Ltd.
+ Contact: http://www.qt.io/licensing/
+
+ You may use, distribute and copy the Qt Toolkit under the terms of
+ GNU Lesser General Public License version 2.1, which is displayed below.
+
+-------------------------------------------------------------------------
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/sources/shiboken2/LICENSE.LGPLv3 b/sources/shiboken2/LICENSE.LGPLv3
new file mode 100644
index 000000000..849103ad9
--- /dev/null
+++ b/sources/shiboken2/LICENSE.LGPLv3
@@ -0,0 +1,175 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+
+ The Qt Toolkit is Copyright (C) 2016 The Qt Company Ltd.
+ Contact: http://www.qt.io/licensing/
+
+ You may use, distribute and copy the Qt Toolkit under the terms of
+ GNU Lesser General Public License version 3, which is displayed below.
+ This license makes reference to the version 3 of the GNU General
+ Public License, which you can find in the LICENSE.GPLv3 file.
+
+-------------------------------------------------------------------------
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
+Everyone is permitted to copy and distribute verbatim copies of this
+licensedocument, but changing it is not allowed.
+
+This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+0. Additional Definitions.
+
+ As used herein, “this License” refers to version 3 of the GNU Lesser
+General Public License, and the “GNU GPL” refers to version 3 of the
+GNU General Public License.
+
+ “The Library” refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An “Application” is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A “Combined Work” is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the “Linked
+Version”.
+
+ The “Minimal Corresponding Source” for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The “Corresponding Application Code” for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort
+ to ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this
+ license document.
+
+4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that, taken
+together, effectively do not restrict modification of the portions of
+the Library contained in the Combined Work and reverse engineering for
+debugging such modifications, if you also do each of the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this
+ license document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of
+ this License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with
+ the Library. A suitable mechanism is one that (a) uses at run
+ time a copy of the Library already present on the user's
+ computer system, and (b) will operate properly with a modified
+ version of the Library that is interface-compatible with the
+ Linked Version.
+
+ e) Provide Installation Information, but only if you would
+ otherwise be required to provide such information under section 6
+ of the GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the Application
+ with a modified version of the Linked Version. (If you use option
+ 4d0, the Installation Information must accompany the Minimal
+ Corresponding Source and Corresponding Application Code. If you
+ use option 4d1, you must provide the Installation Information in
+ the manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.)
+
+5. Combined Libraries.
+
+ You may place library facilities that are a work based on the Library
+side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities, conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of
+ it is a work based on the Library, and explaining where to find
+ the accompanying uncombined form of the same work.
+
+6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+as you received it specifies that a certain numbered version of the
+GNU Lesser General Public License “or any later version” applies to
+it, you have the option of following the terms and conditions either
+of that published version or of any later version published by the
+Free Software Foundation. If the Library as you received it does not
+specify a version number of the GNU Lesser General Public License,
+you may choose any version of the GNU Lesser General Public License
+ever published by the Free Software Foundation.
+
+If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the Library.
+
diff --git a/sources/shiboken2/LICENSE.PREVIEW.COMMERCIAL b/sources/shiboken2/LICENSE.PREVIEW.COMMERCIAL
new file mode 100644
index 000000000..0f96e738c
--- /dev/null
+++ b/sources/shiboken2/LICENSE.PREVIEW.COMMERCIAL
@@ -0,0 +1,630 @@
+TECHNOLOGY PREVIEW LICENSE AGREEMENT
+
+For individuals and/or legal entities resident in the Americas (North
+America, Central America and South America), the applicable licensing
+terms are specified under the heading "Technology Preview License
+Agreement: The Americas".
+
+For individuals and/or legal entities not resident in The Americas, the
+applicable licensing terms are specified under the heading "Technology
+Preview License Agreement: Rest of the World".
+
+
+TECHNOLOGY PREVIEW LICENSE AGREEMENT: The Americas
+Agreement version 2.4
+
+This Technology Preview License Agreement ("Agreement")is a legal agreement
+between The Qt Company USA, Inc. ("The Qt Company"), with its registered
+office at 2350 Mission College Blvd., Suite 1020, Santa Clara, California
+95054, U.S.A. and you (either an individual or a legal entity) ("Licensee")
+for the Licensed Software (as defined below).
+
+1. DEFINITIONS
+
+"Affiliate" of a Party shall mean an entity (i) which is directly or
+indirectly controlling such Party; (ii) which is under the same direct
+or indirect ownership or control as such Party; or (iii) which is
+directly or indirectly owned or controlled by such Party. For these
+purposes, an entity shall be treated as being controlled by another if
+that other entity has fifty percent (50 %) or more of the votes in such
+entity, is able to direct its affairs and/or to control the composition
+of its board of directors or equivalent body.
+
+"Applications" shall mean Licensee's software products created using the
+Licensed Software which may include portions of the Licensed Software.
+
+"Term" shall mean the period of time six (6) months from the later of
+(a) the Effective Date; or (b) the date the Licensed Software was
+initially delivered to Licensee by The Qt Company. If no specific Effective
+Date is set forth in the Agreement, the Effective Date shall be deemed to be
+the date the Licensed Software was initially delivered to Licensee.
+
+"Licensed Software" shall mean the computer software, "online" or
+electronic documentation, associated media and printed materials,
+including the source code, example programs and the documentation
+delivered by The Qt Company to Licensee in conjunction with this Agreement.
+
+"Party" or "Parties" shall mean Licensee and/or The Qt Company.
+
+
+2. OWNERSHIP
+
+The Licensed Software is protected by copyright laws and international
+copyright treaties, as well as other intellectual property laws and
+treaties. The Licensed Software is licensed, not sold.
+
+If Licensee provides any findings, proposals, suggestions or other
+feedback ("Feedback") to The Qt Company regarding the Licensed Software,
+The Qt Company shall own all right, title and interest including the
+intellectual property rights in and to such Feedback, excluding however any
+existing patent rights of Licensee. To the extent Licensee owns or controls
+any patents for such Feedback Licensee hereby grants to The Qt Company and its
+Affiliates, a worldwide, perpetual, non-transferable, sublicensable,
+royalty-free license to (i) use, copy and modify Feedback and to create
+derivative works thereof, (ii) to make (and have made), use, import,
+sell, offer for sale, lease, dispose, offer for disposal or otherwise
+exploit any products or services of The Qt Company containing Feedback, and
+(iii) sublicense all the foregoing rights to third party licensees and
+customers of The Qt Company and/or its Affiliates.
+
+
+3. VALIDITY OF THE AGREEMENT
+
+By installing, copying, or otherwise using the Licensed Software,
+Licensee agrees to be bound by the terms of this Agreement. If Licensee
+does not agree to the terms of this Agreement, Licensee may not install,
+copy, or otherwise use the Licensed Software. Upon Licensee's acceptance
+of the terms and conditions of this Agreement, The Qt Company grants Licensee
+the right to use the Licensed Software in the manner provided below.
+
+
+4. LICENSES
+
+4.1. Using and Copying
+
+The Qt Company grants to Licensee a non-exclusive, non-transferable,
+time-limited license to use and copy the Licensed Software for sole purpose
+of designing, developing and testing Applications, and evaluating and the
+Licensed Software during the Term.
+
+Licensee may install copies of the Licensed Software on an unlimited
+number of computers provided that (a) if an individual, only such
+individual; or (b) if a legal entity only its employees; use the
+Licensed Software for the authorized purposes.
+
+4.2 No Distribution or Modifications
+
+Licensee may not disclose, modify, sell, market, commercialise,
+distribute, loan, rent, lease, or license the Licensed Software or any
+copy of it or use the Licensed Software for any purpose that is not
+expressly granted in this Section 4. Licensee may not alter or remove
+any details of ownership, copyright, trademark or other property right
+connected with the Licensed Software. Licensee may not distribute any
+software statically or dynamically linked with the Licensed Software.
+
+4.3 No Technical Support
+
+The Qt Company has no obligation to furnish Licensee with any technical
+support whatsoever. Any such support is subject to separate agreement between
+the Parties.
+
+
+5. PRE-RELEASE CODE
+The Licensed Software contains pre-release code that is not at the level
+of performance and compatibility of a final, generally available,
+product offering. The Licensed Software may not operate correctly and
+may be substantially modified prior to the first commercial product
+release, if any. The Qt Company is not obligated to make this or any later
+version of the Licensed Software commercially available. The License
+Software is "Not for Commercial Use" and may only be used for the
+purposes described in Section 4. The Licensed Software may not be used
+in a live operating environment where it may be relied upon to perform
+in the same manner as a commercially released product or with data that
+has not been sufficiently backed up.
+
+6. THIRD PARTY SOFTWARE
+
+The Licensed Software may provide links to third party libraries or code
+(collectively "Third Party Software") to implement various functions.
+Third Party Software does not comprise part of the Licensed Software. In
+some cases, access to Third Party Software may be included along with
+the Licensed Software delivery as a convenience for development and
+testing only. Such source code and libraries may be listed in the
+".../src/3rdparty" source tree delivered with the Licensed Software or
+documented in the Licensed Software where the Third Party Software is
+used, as may be amended from time to time, do not comprise the Licensed
+Software. Licensee acknowledges (1) that some part of Third Party
+Software may require additional licensing of copyright and patents from
+the owners of such, and (2) that distribution of any of the Licensed
+Software referencing any portion of a Third Party Software may require
+appropriate licensing from such third parties.
+
+
+7. LIMITED WARRANTY AND WARRANTY DISCLAIMER
+
+The Licensed Software is licensed to Licensee "as is". To the maximum
+extent permitted by applicable law, The Qt Company on behalf of itself and
+its suppliers, disclaims all warranties and conditions, either express or
+implied, including, but not limited to, implied warranties of
+merchantability, fitness for a particular purpose, title and
+non-infringement with regard to the Licensed Software.
+
+
+8. LIMITATION OF LIABILITY
+
+If, The Qt Company's warranty disclaimer notwithstanding, The Qt Company is
+held liable to Licensee, whether in contract, tort or any other legal theory,
+based on the Licensed Software, The Qt Company's entire liability to Licensee
+and Licensee's exclusive remedy shall be, at The Qt Company's option, either
+(A) return of the price Licensee paid for the Licensed Software, or (B)
+repair or replacement of the Licensed Software, provided Licensee
+returns to The Qt Company all copies of the Licensed Software as originally
+delivered to Licensee. The Qt Company shall not under any circumstances be
+liable to Licensee based on failure of the Licensed Software if the failure
+resulted from accident, abuse or misapplication, nor shall The Qt Company
+under any circumstances be liable for special damages, punitive or exemplary
+damages, damages for loss of profits or interruption of business or for
+loss or corruption of data. Any award of damages from The Qt Company to
+Licensee shall not exceed the total amount Licensee has paid to The Qt
+Company in connection with this Agreement.
+
+
+9. CONFIDENTIALITY
+
+Each party acknowledges that during the Term of this Agreement it shall
+have access to information about the other party's business, business
+methods, business plans, customers, business relations, technology, and
+other information, including the terms of this Agreement, that is
+confidential and of great value to the other party, and the value of
+which would be significantly reduced if disclosed to third parties (the
+"Confidential Information"). Accordingly, when a party (the "Receiving
+Party") receives Confidential Information from another party (the
+"Disclosing Party"), the Receiving Party shall, and shall obligate its
+employees and agents and employees and agents of its Affiliates to: (i)
+maintain the Confidential Information in strict confidence; (ii) not
+disclose the Confidential Information to a third party without the
+Disclosing Party's prior written approval; and (iii) not, directly or
+indirectly, use the Confidential Information for any purpose other than
+for exercising its rights and fulfilling its responsibilities pursuant
+to this Agreement. Each party shall take reasonable measures to protect
+the Confidential Information of the other party, which measures shall
+not be less than the measures taken by such party to protect its own
+confidential and proprietary information.
+
+"Confidential Information" shall not include information that (a) is or
+becomes generally known to the public through no act or omission of the
+Receiving Party; (b) was in the Receiving Party's lawful possession
+prior to the disclosure hereunder and was not subject to limitations on
+disclosure or use; (c) is developed by the Receiving Party without
+access to the Confidential Information of the Disclosing Party or by
+persons who have not had access to the Confidential Information of the
+Disclosing Party as proven by the written records of the Receiving
+Party; (d) is lawfully disclosed to the Receiving Party without
+restrictions, by a third party not under an obligation of
+confidentiality; or (e) the Receiving Party is legally compelled to
+disclose the information, in which case the Receiving Party shall assert
+the privileged and confidential nature of the information and cooperate
+fully with the Disclosing Party to protect against and prevent
+disclosure of any Confidential Information and to limit the scope of
+disclosure and the dissemination of disclosed Confidential Information
+by all legally available means.
+
+The obligations of the Receiving Party under this Section shall continue
+during the Initial Term and for a period of five (5) years after
+expiration or termination of this Agreement. To the extent that the
+terms of the Non-Disclosure Agreement between The Qt Company and Licensee
+conflict with the terms of this Section 9, this Section 9 shall be
+controlling over the terms of the Non-Disclosure Agreement.
+
+
+10. GENERAL PROVISIONS
+
+10.1 No Assignment
+
+Licensee shall not be entitled to assign or transfer all or any of its
+rights, benefits and obligations under this Agreement without the prior
+written consent of The Qt Company, which shall not be unreasonably withheld.
+
+10.2 Termination
+
+The Qt Company may terminate the Agreement at any time immediately upon
+written notice by The Qt Company to Licensee if Licensee breaches this
+Agreement.
+
+Upon termination of this Agreement, Licensee shall return to The Qt Company
+all copies of Licensed Software that were supplied by The Qt Company. All
+other copies of Licensed Software in the possession or control of Licensee
+must be erased or destroyed. An officer of Licensee must promptly
+deliver to The Qt Company a written confirmation that this has occurred.
+
+10.3 Surviving Sections
+
+Any terms and conditions that by their nature or otherwise reasonably
+should survive a cancellation or termination of this Agreement shall
+also be deemed to survive. Such terms and conditions include, but are
+not limited to the following Sections: 2, 5, 6, 7, 8, 9, 10.2, 10.3, 10.4,
+10.5, 10.6, 10.7, and 10.8 of this Agreement.
+
+10.4 Entire Agreement
+
+This Agreement constitutes the complete agreement between the parties
+and supersedes all prior or contemporaneous discussions,
+representations, and proposals, written or oral, with respect to the
+subject matters discussed herein, with the exception of the
+non-disclosure agreement executed by the parties in connection with this
+Agreement ("Non-Disclosure Agreement"), if any, shall be subject to
+Section 9. No modification of this Agreement shall be effective unless
+contained in a writing executed by an authorized representative of each
+party. No term or condition contained in Licensee's purchase order shall
+apply unless expressly accepted by The Qt Company in writing. If any
+provision of the Agreement is found void or unenforceable, the remainder
+shall remain valid and enforceable according to its terms. If any remedy
+provided is determined to have failed for its essential purpose, all
+limitations of liability and exclusions of damages set forth in this
+Agreement shall remain in effect.
+
+10.5 Export Control
+
+Licensee acknowledges that the Licensed Software may be subject to
+export control restrictions of various countries. Licensee shall fully
+comply with all applicable export license restrictions and requirements
+as well as with all laws and regulations relating to the importation of
+the Licensed Software and shall procure all necessary governmental
+authorizations, including without limitation, all necessary licenses,
+approvals, permissions or consents, where necessary for the
+re-exportation of the Licensed Software.,
+
+10.6 Governing Law and Legal Venue
+
+This Agreement shall be governed by and construed in accordance with the
+federal laws of the United States of America and the internal laws of
+the State of New York without given effect to any choice of law rule
+that would result in the application of the laws of any other
+jurisdiction. The United Nations Convention on Contracts for the
+International Sale of Goods (CISG) shall not apply. Each Party (a)
+hereby irrevocably submits itself to and consents to the jurisdiction of
+the United States District Court for the Southern District of New York
+(or if such court lacks jurisdiction, the state courts of the State of
+New York) for the purposes of any action, claim, suit or proceeding
+between the Parties in connection with any controversy, claim, or
+dispute arising out of or relating to this Agreement; and (b) hereby
+waives, and agrees not to assert by way of motion, as a defense or
+otherwise, in any such action, claim, suit or proceeding, any claim that
+is not personally subject to the jurisdiction of such court(s), that the
+action, claim, suit or proceeding is brought in an inconvenient forum or
+that the venue of the action, claim, suit or proceeding is improper.
+Notwithstanding the foregoing, nothing in this Section 9.6 is intended
+to, or shall be deemed to, constitute a submission or consent to, or
+selection of, jurisdiction, forum or venue for any action for patent
+infringement, whether or not such action relates to this Agreement.
+
+10.7 No Implied License
+
+There are no implied licenses or other implied rights granted under this
+Agreement, and all rights, save for those expressly granted hereunder,
+shall remain with The Qt Company and its licensors. In addition, no licenses
+or immunities are granted to the combination of the Licensed Software with
+any other software or hardware not delivered by The Qt Company under this
+Agreement.
+
+10.8 Government End Users
+
+A "U.S. Government End User" shall mean any agency or entity of the
+government of the United States. The following shall apply if Licensee
+is a U.S. Government End User. The Licensed Software is a "commercial
+item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995),
+consisting of "commercial computer software" and "commercial computer
+software documentation," as such terms are used in 48 C.F.R. 12.212
+(Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+through 227.7202-4 (June 1995), all U.S. Government End Users acquire
+the Licensed Software with only those rights set forth herein. The
+Licensed Software (including related documentation) is provided to U.S.
+Government End Users: (a) only as a commercial end item; and (b) only
+pursuant to this Agreement.
+
+
+
+
+
+TECHNOLOGY PREVIEW LICENSE AGREEMENT: Rest of the World
+Agreement version 2.4
+
+This Technology Preview License Agreement ("Agreement") is a legal
+agreement between The Qt Company Ltd ("The Qt Company"), with its registered
+office at Valimotie 21,FI-00380 Helsinki, Finland and you (either an
+individual or a legal entity) ("Licensee") for the Licensed Software.
+
+1. DEFINITIONS
+
+"Affiliate" of a Party shall mean an entity (i) which is directly or
+indirectly controlling such Party; (ii) which is under the same direct
+or indirect ownership or control as such Party; or (iii) which is
+directly or indirectly owned or controlled by such Party. For these
+purposes, an entity shall be treated as being controlled by another if
+that other entity has fifty percent (50 %) or more of the votes in such
+entity, is able to direct its affairs and/or to control the composition
+of its board of directors or equivalent body.
+
+"Applications" shall mean Licensee's software products created using the
+Licensed Software which may include portions of the Licensed Software.
+
+"Term" shall mean the period of time six (6) months from the later of
+(a) the Effective Date; or (b) the date the Licensed Software was
+initially delivered to Licensee by The Qt Company. If no specific Effective
+Date is set forth in the Agreement, the Effective Date shall be deemed to be
+the date the Licensed Software was initially delivered to Licensee.
+
+"Licensed Software" shall mean the computer software, "online" or
+electronic documentation, associated media and printed materials,
+including the source code, example programs and the documentation
+delivered by The Qt Company to Licensee in conjunction with this Agreement.
+
+"Party" or "Parties" shall mean Licensee and/or The Qt Company.
+
+
+2. OWNERSHIP
+
+The Licensed Software is protected by copyright laws and international
+copyright treaties, as well as other intellectual property laws and
+treaties. The Licensed Software is licensed, not sold.
+
+If Licensee provides any findings, proposals, suggestions or other
+feedback ("Feedback") to The Qt Company regarding the Licensed Software,
+The Qt Companyshall own all right, title and interest including the
+intellectual property rights in and to such Feedback, excluding however any
+existing patent rights of Licensee. To the extent Licensee owns or controls
+any patents for such Feedback Licensee hereby grants to The Qt Company and
+its Affiliates, a worldwide, perpetual, non-transferable, sublicensable,
+royalty-free license to (i) use, copy and modify Feedback and to create
+derivative works thereof, (ii) to make (and have made), use, import,
+sell, offer for sale, lease, dispose, offer for disposal or otherwise
+exploit any products or services of The Qt Company containing Feedback, and
+(iii) sublicense all the foregoing rights to third party licensees and
+customers of The Qt Company and/or its Affiliates.
+
+3. VALIDITY OF THE AGREEMENT
+
+By installing, copying, or otherwise using the Licensed Software,
+Licensee agrees to be bound by the terms of this Agreement. If Licensee
+does not agree to the terms of this Agreement, Licensee may not install,
+copy, or otherwise use the Licensed Software. Upon Licensee's acceptance
+of the terms and conditions of this Agreement, The Qt Company grants Licensee
+the right to use the Licensed Software in the manner provided below.
+
+
+4. LICENSES
+
+4.1. Using and Copying
+
+The Qt Company grants to Licensee a non-exclusive, non-transferable,
+time-limited license to use and copy the Licensed Software for sole purpose
+of designing, developing and testing Applications, and evaluating and the
+Licensed Software during the Term.
+
+Licensee may install copies of the Licensed Software on an unlimited
+number of computers provided that (a) if an individual, only such
+individual; or (b) if a legal entity only its employees; use the
+Licensed Software for the authorized purposes.
+
+4.2 No Distribution or Modifications
+
+Licensee may not disclose, modify, sell, market, commercialise,
+distribute, loan, rent, lease, or license the Licensed Software or any
+copy of it or use the Licensed Software for any purpose that is not
+expressly granted in this Section 4. Licensee may not alter or remove
+any details of ownership, copyright, trademark or other property right
+connected with the Licensed Software. Licensee may not distribute any
+software statically or dynamically linked with the Licensed Software.
+
+4.3 No Technical Support
+
+The Qt Company has no obligation to furnish Licensee with any technical
+support whatsoever. Any such support is subject to separate agreement
+between the Parties.
+
+
+5. PRE-RELEASE CODE
+
+The Licensed Software contains pre-release code that is not at the level
+of performance and compatibility of a final, generally available,
+product offering. The Licensed Software may not operate correctly and
+may be substantially modified prior to the first commercial product
+release, if any. The Qt Company is not obligated to make this or any later
+version of the Licensed Software commercially available. The License
+Software is "Not for Commercial Use" and may only be used for the
+purposes described in Section 4. The Licensed Software may not be used
+in a live operating environment where it may be relied upon to perform
+in the same manner as a commercially released product or with data that
+has not been sufficiently backed up.
+
+6. THIRD PARTY SOFTWARE
+
+The Licensed Software may provide links to third party libraries or code
+(collectively "Third Party Software") to implement various functions.
+Third Party Software does not comprise part of the Licensed Software. In
+some cases, access to Third Party Software may be included along with
+the Licensed Software delivery as a convenience for development and
+testing only. Such source code and libraries may be listed in the
+".../src/3rdparty" source tree delivered with the Licensed Software or
+documented in the Licensed Software where the Third Party Software is
+used, as may be amended from time to time, do not comprise the Licensed
+Software. Licensee acknowledges (1) that some part of Third Party
+Software may require additional licensing of copyright and patents from
+the owners of such, and (2) that distribution of any of the Licensed
+Software referencing any portion of a Third Party Software may require
+appropriate licensing from such third parties.
+
+
+7. LIMITED WARRANTY AND WARRANTY DISCLAIMER
+
+The Licensed Software is licensed to Licensee "as is". To the maximum
+extent permitted by applicable law, The Qt Company on behalf of itself and
+its suppliers, disclaims all warranties and conditions, either express or
+implied, including, but not limited to, implied warranties of
+merchantability, fitness for a particular purpose, title and
+non-infringement with regard to the Licensed Software.
+
+
+8. LIMITATION OF LIABILITY
+
+If, The Qt Company's warranty disclaimer notwithstanding, The Qt Company is
+held liable to Licensee, whether in contract, tort or any other legal theory,
+based on the Licensed Software, The Qt Company's entire liability to Licensee
+and Licensee's exclusive remedy shall be, at The Qt Company's option, either
+(A) return of the price Licensee paid for the Licensed Software, or (B)
+repair or replacement of the Licensed Software, provided Licensee
+returns to The Qt Company all copies of the Licensed Software as originally
+delivered to Licensee. The Qt Company shall not under any circumstances be
+liable to Licensee based on failure of the Licensed Software if the failure
+resulted from accident, abuse or misapplication, nor shall The Qt Company
+under any circumstances be liable for special damages, punitive or exemplary
+damages, damages for loss of profits or interruption of business or for
+loss or corruption of data. Any award of damages from The Qt Company to
+Licensee shall not exceed the total amount Licensee has paid to
+The Qt Company in connection with this Agreement.
+
+
+9. CONFIDENTIALITY
+
+Each party acknowledges that during the Term of this Agreement it shall
+have access to information about the other party's business, business
+methods, business plans, customers, business relations, technology, and
+other information, including the terms of this Agreement, that is
+confidential and of great value to the other party, and the value of
+which would be significantly reduced if disclosed to third parties (the
+"Confidential Information"). Accordingly, when a party (the "Receiving
+Party") receives Confidential Information from another party (the
+"Disclosing Party"), the Receiving Party shall, and shall obligate its
+employees and agents and employees and agents of its Affiliates to: (i)
+maintain the Confidential Information in strict confidence; (ii) not
+disclose the Confidential Information to a third party without the
+Disclosing Party's prior written approval; and (iii) not, directly or
+indirectly, use the Confidential Information for any purpose other than
+for exercising its rights and fulfilling its responsibilities pursuant
+to this Agreement. Each party shall take reasonable measures to protect
+the Confidential Information of the other party, which measures shall
+not be less than the measures taken by such party to protect its own
+confidential and proprietary information.
+
+"Confidential Information" shall not include information that (a) is or
+becomes generally known to the public through no act or omission of the
+Receiving Party; (b) was in the Receiving Party's lawful possession
+prior to the disclosure hereunder and was not subject to limitations on
+disclosure or use; (c) is developed by the Receiving Party without
+access to the Confidential Information of the Disclosing Party or by
+persons who have not had access to the Confidential Information of the
+Disclosing Party as proven by the written records of the Receiving
+Party; (d) is lawfully disclosed to the Receiving Party without
+restrictions, by a third party not under an obligation of
+confidentiality; or (e) the Receiving Party is legally compelled to
+disclose the information, in which case the Receiving Party shall assert
+the privileged and confidential nature of the information and cooperate
+fully with the Disclosing Party to protect against and prevent
+disclosure of any Confidential Information and to limit the scope of
+disclosure and the dissemination of disclosed Confidential Information
+by all legally available means.
+
+The obligations of the Receiving Party under this Section shall continue
+during the Initial Term and for a period of five (5) years after
+expiration or termination of this Agreement. To the extent that the
+terms of the Non-Disclosure Agreement between The Qt Company and Licensee
+conflict with the terms of this Section 9, this Section 9 shall be
+controlling over the terms of the Non-Disclosure Agreement.
+
+
+10. GENERAL PROVISIONS
+
+10.1 No Assignment
+
+Licensee shall not be entitled to assign or transfer all or any of its
+rights, benefits and obligations under this Agreement without the prior
+written consent of The Qt Company, which shall not be unreasonably withheld.
+
+10.2 Termination
+
+The Qt Company may terminate the Agreement at any time immediately upon
+written notice by The Qt Company to Licensee if Licensee breaches this
+Agreement.
+
+Upon termination of this Agreement, Licensee shall return to The Qt Company
+all copies of Licensed Software that were supplied by The Qt Company. All
+other copies of Licensed Software in the possession or control of Licensee
+must be erased or destroyed. An officer of Licensee must promptly
+deliver to The Qt Company a written confirmation that this has occurred.
+
+10.3 Surviving Sections
+
+Any terms and conditions that by their nature or otherwise reasonably
+should survive a cancellation or termination of this Agreement shall
+also be deemed to survive. Such terms and conditions include, but are
+not limited to the following Sections: 2, 5, 6, 7, 8, 9, 10.2, 10.3, 10.4,
+10.5, 10.6, 10.7, and 10.8 of this Agreement.
+
+10.4 Entire Agreement
+
+This Agreement constitutes the complete agreement between the parties
+and supersedes all prior or contemporaneous discussions,
+representations, and proposals, written or oral, with respect to the
+subject matters discussed herein, with the exception of the
+non-disclosure agreement executed by the parties in connection with this
+Agreement ("Non-Disclosure Agreement"), if any, shall be subject to
+Section 9. No modification of this Agreement shall be effective unless
+contained in a writing executed by an authorized representative of each
+party. No term or condition contained in Licensee's purchase order shall
+apply unless expressly accepted by The Qt Company in writing. If any provision
+of the Agreement is found void or unenforceable, the remainder shall remain
+valid and enforceable according to its terms. If any remedy provided is
+determined to have failed for its essential purpose, all limitations of
+liability and exclusions of damages set forth in this Agreement shall
+remain in effect.
+
+10.5 Export Control
+
+Licensee acknowledges that the Licensed Software may be subject to
+export control restrictions of various countries. Licensee shall fully
+comply with all applicable export license restrictions and requirements
+as well as with all laws and regulations relating to the importation of
+the Licensed Software and shall procure all necessary governmental
+authorizations, including without limitation, all necessary licenses,
+approvals, permissions or consents, where necessary for the
+re-exportation of the Licensed Software.,
+
+10.6 Governing Law and Legal Venue
+
+This Agreement shall be construed and interpreted in accordance with the
+laws of Finland, excluding its choice of law provisions. Any disputes
+arising out of or relating to this Agreement shall be resolved in
+arbitration under the Rules of Arbitration of the Chamber of Commerce of
+Helsinki, Finland. The arbitration tribunal shall consist of one (1), or
+if either Party so requires, of three (3), arbitrators. The award shall
+be final and binding and enforceable in any court of competent
+jurisdiction. The arbitration shall be held in Helsinki, Finland and the
+process shall be conducted in the English language.
+
+10.7 No Implied License
+
+There are no implied licenses or other implied rights granted under this
+Agreement, and all rights, save for those expressly granted hereunder,
+shall remain with The Qt Company and its licensors. In addition, no licenses
+or immunities are granted to the combination of the Licensed Software with
+any other software or hardware not delivered by The Qt Company under this
+Agreement.
+
+10.8 Government End Users
+
+A "U.S. Government End User" shall mean any agency or entity of the
+government of the United States. The following shall apply if Licensee
+is a U.S. Government End User. The Licensed Software is a "commercial
+item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995),
+consisting of "commercial computer software" and "commercial computer
+software documentation," as such terms are used in 48 C.F.R. 12.212
+(Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+through 227.7202-4 (June 1995), all U.S. Government End Users acquire
+the Licensed Software with only those rights set forth herein. The
+Licensed Software (including related documentation) is provided to U.S.
+Government End Users: (a) only as a commercial end item; and (b) only
+pursuant to this Agreement.
+
+
+
+
diff --git a/sources/shiboken2/README.md b/sources/shiboken2/README.md
new file mode 100644
index 000000000..b64f97d36
--- /dev/null
+++ b/sources/shiboken2/README.md
@@ -0,0 +1,19 @@
+# shiboken2
+
+This is shiboken2, the code generator for PySide2. It is part of pyside2-setup, which you
+should download for building and getting further information.
+
+Resources:
+
+* [PySide2-setup](https://github.com/PySide/pyside2-setup)
+ The container-project with the setup.py script. It contains the following sub-projects:
+ * [PySide2 Wiki](https://github.com/PySide/pyside2/wiki)
+ Developer information
+ * [PySide2](https://github.com/PySide/pyside2)
+ The PySide2 project
+ * [Shiboken2](https://github.com/PySide/shiboken2)
+ The Shiboken2 project
+ * [PySide2-tools](https://github.com/PySide/pyside2-examples)
+ The PySide2-tools project
+ * [PySide2-examples](https://github.com/PySide/pyside2-examples)
+ The PySide2 example scripts
diff --git a/sources/shiboken2/cmake_uninstall.cmake b/sources/shiboken2/cmake_uninstall.cmake
new file mode 100644
index 000000000..df95fb9d8
--- /dev/null
+++ b/sources/shiboken2/cmake_uninstall.cmake
@@ -0,0 +1,21 @@
+IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
+ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+STRING(REGEX REPLACE "\n" ";" files "${files}")
+FOREACH(file ${files})
+ MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
+ IF(EXISTS "$ENV{DESTDIR}${file}")
+ EXEC_PROGRAM(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ IF(NOT "${rm_retval}" STREQUAL 0)
+ MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
+ ENDIF(NOT "${rm_retval}" STREQUAL 0)
+ ELSE(EXISTS "$ENV{DESTDIR}${file}")
+ MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
+ ENDIF(EXISTS "$ENV{DESTDIR}${file}")
+ENDFOREACH(file)
diff --git a/sources/shiboken2/data/CMakeLists.txt b/sources/shiboken2/data/CMakeLists.txt
new file mode 100644
index 000000000..c36cb148d
--- /dev/null
+++ b/sources/shiboken2/data/CMakeLists.txt
@@ -0,0 +1,28 @@
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(LIBRARY_OUTPUT_SUFFIX ${CMAKE_DEBUG_POSTFIX})
+else()
+ set(LIBRARY_OUTPUT_SUFFIX ${CMAKE_RELEASE_POSTFIX})
+endif()
+
+add_custom_target(data)
+add_dependencies(data shiboken2)
+get_target_property(SHIBOKEN_GENERATOR shiboken2 OUTPUT_NAME)
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Shiboken2Config.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/Shiboken2Config.cmake" @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Shiboken2Config-spec.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/Shiboken2Config${PYTHON_EXTENSION_SUFFIX}.cmake" @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Shiboken2ConfigVersion.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/Shiboken2ConfigVersion.cmake" @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/shiboken2.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/shiboken2${shiboken2_SUFFIX}.pc" @ONLY)
+
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Shiboken2Config.cmake"
+ DESTINATION "${LIB_INSTALL_DIR}/cmake/Shiboken2-${shiboken2_VERSION}")
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Shiboken2Config${PYTHON_EXTENSION_SUFFIX}.cmake"
+ DESTINATION "${LIB_INSTALL_DIR}/cmake/Shiboken2-${shiboken2_VERSION}")
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Shiboken2ConfigVersion.cmake"
+ DESTINATION "${LIB_INSTALL_DIR}/cmake/Shiboken2-${shiboken2_VERSION}")
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/shiboken2${shiboken2_SUFFIX}.pc"
+ DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
+
diff --git a/sources/shiboken2/data/GeneratorRunnerConfig.cmake.in b/sources/shiboken2/data/GeneratorRunnerConfig.cmake.in
new file mode 100644
index 000000000..cf973e2a6
--- /dev/null
+++ b/sources/shiboken2/data/GeneratorRunnerConfig.cmake.in
@@ -0,0 +1,17 @@
+# GENERATORRUNNER_INCLUDE_DIR - Directories to include to use GENERATORRUNNER
+# GENERATORRUNNER_LIBRARIES - Files to link against to use GENERATORRUNNER
+# GENERATORRUNNER_PLUGIN_DIR - Where to find/put plugins for generator runner
+# GENERATORRUNNER_BINARY - Executable name
+
+SET(GENERATORRUNNER_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include/generatorrunner@generator_SUFFIX@")
+if(MSVC)
+ SET(GENERATORRUNNER_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@genrunner@generator_SUFFIX@.lib")
+elseif(CYGWIN)
+ SET(GENERATORRUNNER_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@genrunner@generator_SUFFIX@@CMAKE_IMPORT_LIBRARY_SUFFIX@")
+elseif(WIN32)
+ SET(GENERATORRUNNER_LIBRARY "@CMAKE_INSTALL_PREFIX@/bin/@CMAKE_SHARED_LIBRARY_PREFIX@genrunner@generator_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@")
+else()
+ SET(GENERATORRUNNER_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@genrunner@generator_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@")
+endif()
+SET(GENERATORRUNNER_PLUGIN_DIR "@generator_plugin_DIR@")
+SET(GENERATORRUNNER_BINARY "@CMAKE_INSTALL_PREFIX@/bin/generatorrunner@generator_SUFFIX@")
diff --git a/sources/shiboken2/data/GeneratorRunnerConfigVersion.cmake.in b/sources/shiboken2/data/GeneratorRunnerConfigVersion.cmake.in
new file mode 100644
index 000000000..8eb5ba479
--- /dev/null
+++ b/sources/shiboken2/data/GeneratorRunnerConfigVersion.cmake.in
@@ -0,0 +1,10 @@
+set(PACKAGE_VERSION @generator_VERSION@)
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+endif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
diff --git a/sources/shiboken2/data/Shiboken2Config-spec.cmake.in b/sources/shiboken2/data/Shiboken2Config-spec.cmake.in
new file mode 100644
index 000000000..1aac9caa0
--- /dev/null
+++ b/sources/shiboken2/data/Shiboken2Config-spec.cmake.in
@@ -0,0 +1,29 @@
+# SHIBOKEN_INCLUDE_DIR - Directories to include to use SHIBOKEN
+# SHIBOKEN_LIBRARY - Files to link against to use SHIBOKEN
+# SHIBOKEN_BINARY - Executable name
+# SHIBOKEN_BUILD_TYPE - Tells if Shiboken was compiled in Release or Debug mode.
+# SHIBOKEN_PYTHON_INTERPRETER - Python interpreter (regular or debug) to be used with the bindings.
+# SHIBOKEN_PYTHON_LIBRARIES - Python libraries (regular or debug) Shiboken is linked against.
+
+SET(SHIBOKEN_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include/shiboken2@shiboken2_SUFFIX@")
+if(MSVC)
+ SET(SHIBOKEN_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@shiboken2@shiboken2_SUFFIX@@PYTHON_EXTENSION_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@.lib")
+elseif(CYGWIN)
+ SET(SHIBOKEN_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@shiboken2@shiboken2_SUFFIX@@PYTHON_EXTENSION_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@CMAKE_IMPORT_LIBRARY_SUFFIX@")
+elseif(WIN32)
+ SET(SHIBOKEN_LIBRARY "@CMAKE_INSTALL_PREFIX@/bin/@CMAKE_SHARED_LIBRARY_PREFIX@shiboken2@shiboken2_SUFFIX@@PYTHON_EXTENSION_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@")
+else()
+ SET(SHIBOKEN_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@shiboken2@shiboken2_SUFFIX@@PYTHON_EXTENSION_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@")
+endif()
+SET(SHIBOKEN_PYTHON_INCLUDE_DIR "@SBK_PYTHON_INCLUDE_DIR@")
+SET(SHIBOKEN_PYTHON_INCLUDE_DIR "@SBK_PYTHON_INCLUDE_DIR@")
+SET(SHIBOKEN_PYTHON_INTERPRETER "@PYTHON_EXECUTABLE@")
+SET(SHIBOKEN_PYTHON_VERSION_MAJOR "@PYTHON_VERSION_MAJOR@")
+SET(SHIBOKEN_PYTHON_VERSION_MINOR "@PYTHON_VERSION_MINOR@")
+SET(SHIBOKEN_PYTHON_VERSION_PATCH "@PYTHON_VERSION_PATCH@")
+SET(SHIBOKEN_PYTHON_LIBRARIES "@SBK_PYTHON_LIBRARIES@")
+SET(SHIBOKEN_PYTHON_EXTENSION_SUFFIX "@PYTHON_EXTENSION_SUFFIX@")
+message(STATUS "libshiboken built for @SHIBOKEN_BUILD_TYPE@")
+@SBK_ADD_PY_DEBUG_DEFINITION@
+
+set(SHIBOKEN_BINARY "@CMAKE_INSTALL_PREFIX@/bin/@SHIBOKEN_GENERATOR@")
diff --git a/sources/shiboken2/data/Shiboken2Config.cmake.in b/sources/shiboken2/data/Shiboken2Config.cmake.in
new file mode 100644
index 000000000..5f7ecaec1
--- /dev/null
+++ b/sources/shiboken2/data/Shiboken2Config.cmake.in
@@ -0,0 +1,5 @@
+if (NOT PYTHON_EXTENSION_SUFFIX)
+ message(STATUS "Shiboken2Config: Using default python: @PYTHON_EXTENSION_SUFFIX@")
+ SET(PYTHON_EXTENSION_SUFFIX @PYTHON_EXTENSION_SUFFIX@)
+endif()
+include(@LIB_INSTALL_DIR@/cmake/Shiboken2-@shiboken2_VERSION@/Shiboken2Config${PYTHON_EXTENSION_SUFFIX}.cmake)
diff --git a/sources/shiboken2/data/Shiboken2ConfigVersion.cmake.in b/sources/shiboken2/data/Shiboken2ConfigVersion.cmake.in
new file mode 100644
index 000000000..9460099b2
--- /dev/null
+++ b/sources/shiboken2/data/Shiboken2ConfigVersion.cmake.in
@@ -0,0 +1,10 @@
+set(PACKAGE_VERSION @shiboken2_VERSION@)
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+endif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
diff --git a/sources/shiboken2/data/docgenerator.1 b/sources/shiboken2/data/docgenerator.1
new file mode 120000
index 000000000..c65282f98
--- /dev/null
+++ b/sources/shiboken2/data/docgenerator.1
@@ -0,0 +1 @@
+generatorrunner.1 \ No newline at end of file
diff --git a/sources/shiboken2/data/generatorrunner.1 b/sources/shiboken2/data/generatorrunner.1
new file mode 100644
index 000000000..045b55ad4
--- /dev/null
+++ b/sources/shiboken2/data/generatorrunner.1
@@ -0,0 +1,76 @@
+.TH GENERATORRUNNER 1 "SEPTEMBER 2009" Linux "User Manuals"
+.SH NAME
+generatorrunner - plugin-based binding source code generator
+.SH SYNOPSIS
+.B generatorrunner \-\-generator-set=<plugin name> [options] header-file typesystem-file
+.SH DESCRIPTION
+.B generatorrunner
+is a utility that uses the information taken from APIExtractor
+related to the provided C++ headers and typesystem files and execute
+generators using this information. Generators are plugins and you need
+to specify one using the \-\-generator-set parameter. At the moment there
+are two generators available:
+
+.B qtdoc
+\- Generates Sphinx-based documentation for C++ libraries documented using
+.B qdoc3
+documentation syntax, using the XML files created by the documentation tool
+.B (qdoc3).
+Can be called supplying
+.B \-\-generator-set=qtdoc
+to
+.B generatorrunner
+or by calling the convenience executable
+.B docgenerator.
+
+Other plugins can be used with
+.B generatorrunner,
+provided that they follow the generator front-end specifications,
+and can be written to generate code or documentation for any target
+languague you desire. For more information about the generator front-end
+architecture and current limitations, refer to http://www.pyside.org/home-binding.
+
+.SH OPTIONS
+.SS "General options"
+.IP \-\-api-version=<version>
+Specify the supported api version used to generate the bindings.
+.IP \-\-debug-level=[sparse|medium|full]
+The amount of messages displayed.
+.IP \-\-documentation-only
+Only generates the documentation.
+.IP \-\-drop-type-entries="<TypeEntry0>[;TypeEntry1;...]"
+Semicolon separated list of type system entries (classes, namespaces, global functions and enums) to be dropped from generation.
+.IP \-\-help \fR,\fP \-h \fR,\fP -?
+Prints the usage message.
+.IP \-\-project-file=<file>
+Text file containing a description of the binding project. Replaces and overrides command line arguments.
+.IP \-\-include\-paths=\fI<path>[:path:..]\fR
+The directories where the generator will search for the
+headers. Works like gcc's \-I flag.
+.IP \-\-license\-file=\fI[licensefile]\fR
+Template for copyright headers of generated files.
+.IP \-\-no\-supress\-warnings
+Show all warnings.
+.IP \-\-output\-directory=\fI[dir]\fR
+The directory where the generated files will be written.
+.IP \-\-silent
+Avoid printing any messages.
+.IP \-\-typesytem\-paths=\fI<path>[:path:..]\fR
+The directories where the generator will search for the
+external typesystems referred by the main one.
+.IP \-\-version
+Displays the current version.
+Drops support for named args.
+.SS "Specific to qtdoc plugin"
+.IP \-\-documentation\-code\-snippets\-dir
+Directory used to search code snippets used by the documentation
+.IP \-\-documentation\-data\-dir
+Directory with XML files generated by documentation tool (qdoc3 or Doxygen)
+.IP \-\-documentation\-out\-dir
+The directory where the generated documentation files will be written
+.IP \-\-library\-source\-dir
+Directory where library source code is located
+
+.SH AUTHORS
+Lauro Moura <lauro.neto at openbossa dot org>, Bruno Araujo <bruno.araujo at openbossa dot org>, Hugo Lima <hugo.lima at openbossa dot org>
+
diff --git a/sources/shiboken2/data/generatorrunner.pc.in b/sources/shiboken2/data/generatorrunner.pc.in
new file mode 100644
index 000000000..a566f4356
--- /dev/null
+++ b/sources/shiboken2/data/generatorrunner.pc.in
@@ -0,0 +1,13 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@CMAKE_INSTALL_PREFIX@/include
+
+
+Name: generatorrunner@generator_SUFFIX@
+Description: Generator Runner loads and calls binding generator front-ends.
+Requires: apiextractor
+Version: @generatorrunner_VERSION@
+Libs: -L${libdir} -lgenrunner@generator_SUFFIX@
+Cflags: -I${includedir}@generator_SUFFIX@
+
diff --git a/sources/shiboken2/data/shiboken2.pc.in b/sources/shiboken2/data/shiboken2.pc.in
new file mode 100644
index 000000000..aec210c5c
--- /dev/null
+++ b/sources/shiboken2/data/shiboken2.pc.in
@@ -0,0 +1,13 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@CMAKE_INSTALL_PREFIX@/include/shiboken2
+generator_location=@CMAKE_INSTALL_PREFIX@/bin/@SHIBOKEN_GENERATOR@
+python_interpreter=@PYTHON_EXECUTABLE@
+python_include_dir=@SBK_PYTHON_INCLUDE_DIR@
+
+Name: shiboken2
+Description: Support library for Python bindings created with the Shiboken2 generator.
+Version: @shiboken2_VERSION@
+Libs: @SBK_PYTHON_LIBRARIES@ -L${libdir} -lshiboken2@shiboken2_SUFFIX@@PYTHON_EXTENSION_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@
+Cflags: -I@SBK_PYTHON_INCLUDE_DIR@ -I${includedir}/@shiboken2_SUFFIX@@SBK_PKG_CONFIG_PY_DEBUG_DEFINITION@
diff --git a/sources/shiboken2/doc/CMakeLists.txt b/sources/shiboken2/doc/CMakeLists.txt
new file mode 100644
index 000000000..7bd0161ad
--- /dev/null
+++ b/sources/shiboken2/doc/CMakeLists.txt
@@ -0,0 +1,24 @@
+
+find_program(SPHINX sphinx-build DOC "Path to sphinx-build binary.")
+
+if (SPHINX)
+ message("-- sphinx-build - found")
+ configure_file(conf.py.in conf.py @ONLY)
+ add_custom_target(doc ${SPHINX} -b html -c . ${CMAKE_CURRENT_SOURCE_DIR} html )
+else()
+ message("-- sphinx-build - not found! doc target disabled")
+ if (WIN32)
+ # if jom is used and we have no sphinx, then jom will crash.
+ # so for windows, we always create a doc target (until jom gets fixed...)
+ add_custom_target(doc echo.
+ COMMAND echo +++ This is a fake build, to make 'jom' happy.
+ COMMAND echo +++ The documentation was _not_ built!
+ COMMAND echo.
+ )
+ endif()
+endif()
+
+if (NOT WIN32)
+ file(GLOB manpages "${CMAKE_CURRENT_SOURCE_DIR}/*.1")
+ install(FILES ${manpages} DESTINATION share/man/man1)
+endif()
diff --git a/sources/shiboken2/doc/_templates/index.html b/sources/shiboken2/doc/_templates/index.html
new file mode 100644
index 000000000..00ac64271
--- /dev/null
+++ b/sources/shiboken2/doc/_templates/index.html
@@ -0,0 +1,35 @@
+{% extends "layout.html" %}
+{% set title = 'Overview' %}
+{% block body %}
+<div class="section">
+ <h1>{{ project }} {{ version }}</h1>
+
+ <p>{{ project }} is a plugin (front-end) for Generator Runner. It generates bindings for C++ libraries using CPython source code.</p>
+
+ <h2>Documentation</h2>
+ <table class="contentstable" align="center" style="margin-left: 30px"><tr>
+ <td width="50%">
+ <p class="biglink"><a class="biglink" href="{{ pathto("contents") }}">Contents</a><br/>
+ <span class="linkdescr">for a complete overview</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("faq") }}">FAQ</a><br/>
+ <span class="linkdescr">answers for frequent asked questions</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("commandlineoptions") }}">Command line options</a><br/>
+ <span class="linkdescr">explains the few flags used to change {{ project }} behaviour</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("typesystemvariables") }}">Type System Variables</a><br/>
+ <span class="linkdescr">describes the type system variables that could be used in user custom code</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("typeconverters") }}">Type Converters</a><br/>
+ <span class="linkdescr">describes how to define type converters</span></p>
+ </td>
+ <td width="50%">
+ <p class="biglink"><a class="biglink" href="{{ pathto("codeinjectionsemantics") }}">Code Injection Semantics</a><br/>
+ <span class="linkdescr">explains how custom code injection is interpreted by {{ project }}</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("sequenceprotocol") }}">Sequence Protocol</a><br/>
+ <span class="linkdescr">support for python sequence protocol</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("ownership") }}">Object Ownership</a><br/>
+ <span class="linkdescr">object ownership features</span></p>
+ <p class="biglink"><a class="biglink" href="{{ pathto("wordsofadvice") }}">Words of Advice</a><br/>
+ <span class="linkdescr">Advice for binding developers and users.</span></p>
+ </td></tr>
+ </table>
+</div>
+{% endblock %}
diff --git a/sources/shiboken2/doc/_templates/layout.html b/sources/shiboken2/doc/_templates/layout.html
new file mode 100644
index 000000000..94ff3534e
--- /dev/null
+++ b/sources/shiboken2/doc/_templates/layout.html
@@ -0,0 +1,29 @@
+{% extends "!layout.html" %}
+
+# Invert sidebars
+{%- block sidebar1 %}{{ sidebar() }}{%- endblock %}
+{%- block sidebar2 %}{%- endblock %}
+
+{%- block header %}
+<div id="container">
+<div class="header">
+ <div class="header_container">
+ <div class="logo"><a href="http://www.pyside.org"><img alt="PySide" src="{{ pathto('_static/pysidelogo.png', 1) }}" width="199" height="102" /></a></div>
+ {{ relbar() }}
+ </div>
+</div>
+{%- endblock -%}
+
+{%- block footer %}
+ <div class="footer">
+ <a href="http://www.qt.io/"><img src="{{ pathto('_static/logo_qt.png', 1) }}" alt="Qt" border="0" /></a>
+ <a href="http://www.python.org"><img src="{{ pathto('_static/logo_python.jpg', 1) }}" alt="Python" border="0" /></a>
+ </div>
+</div>
+{%- endblock %}
+
+# No top relbar.
+{%- block relbar1 %}{%- endblock %}
+
+# No bottom relbar.
+{%- block relbar2 %}{%- endblock %}
diff --git a/sources/shiboken2/doc/_themes/pysidedocs/searchbox.html b/sources/shiboken2/doc/_themes/pysidedocs/searchbox.html
new file mode 100644
index 000000000..55a972156
--- /dev/null
+++ b/sources/shiboken2/doc/_themes/pysidedocs/searchbox.html
@@ -0,0 +1,12 @@
+{%- if pagename != "search" %}
+<div id="searchbox" style="display: none">
+ <h3>{{ _('Quick search') }}</h3>
+ <form class="search" action="{{ pathto('search') }}" method="get">
+ <input type="text" name="q" id="q" size="18" />
+ <input type="submit" value="{{ _('Go') }}" id="search_button" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+{%- endif %}
diff --git a/sources/shiboken2/doc/_themes/pysidedocs/static/bg_header.png b/sources/shiboken2/doc/_themes/pysidedocs/static/bg_header.png
new file mode 100644
index 000000000..843e7e2c5
--- /dev/null
+++ b/sources/shiboken2/doc/_themes/pysidedocs/static/bg_header.png
Binary files differ
diff --git a/sources/shiboken2/doc/_themes/pysidedocs/static/bg_topo.jpg b/sources/shiboken2/doc/_themes/pysidedocs/static/bg_topo.jpg
new file mode 100644
index 000000000..4229ae8db
--- /dev/null
+++ b/sources/shiboken2/doc/_themes/pysidedocs/static/bg_topo.jpg
Binary files differ
diff --git a/sources/shiboken2/doc/_themes/pysidedocs/static/fakebar.png b/sources/shiboken2/doc/_themes/pysidedocs/static/fakebar.png
new file mode 100644
index 000000000..b45830e00
--- /dev/null
+++ b/sources/shiboken2/doc/_themes/pysidedocs/static/fakebar.png
Binary files differ
diff --git a/sources/shiboken2/doc/_themes/pysidedocs/static/logo_python.jpg b/sources/shiboken2/doc/_themes/pysidedocs/static/logo_python.jpg
new file mode 100644
index 000000000..cd474efba
--- /dev/null
+++ b/sources/shiboken2/doc/_themes/pysidedocs/static/logo_python.jpg
Binary files differ
diff --git a/sources/shiboken2/doc/_themes/pysidedocs/static/logo_qt.png b/sources/shiboken2/doc/_themes/pysidedocs/static/logo_qt.png
new file mode 100644
index 000000000..39a4a26f3
--- /dev/null
+++ b/sources/shiboken2/doc/_themes/pysidedocs/static/logo_qt.png
Binary files differ
diff --git a/sources/shiboken2/doc/_themes/pysidedocs/static/pysidedocs.css b/sources/shiboken2/doc/_themes/pysidedocs/static/pysidedocs.css
new file mode 100644
index 000000000..708ddf77c
--- /dev/null
+++ b/sources/shiboken2/doc/_themes/pysidedocs/static/pysidedocs.css
@@ -0,0 +1,475 @@
+* {
+ font: 100% Verdana, Arial, Helvetica, sans-serif;
+ font-size:12px;
+}
+
+html {
+ height: 100%;
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ background-color: #EBEBEB;
+ height: 100%;
+ color: #333;
+}
+
+strong {
+ font-weight:bold;
+}
+
+.document {
+ padding-bottom: 90px;
+}
+
+#container {
+ position: relative;
+ min-height: 100%;
+ background-image: url(fakebar.png);
+ background-repeat: repeat-y;
+ background-color: white;
+}
+
+.footer {
+ position: absolute;
+ bottom: 0px;
+ margin-top: 50px;
+ text-align:center;
+ background-color: white;
+ border-top: 2px solid #e0e0e0;
+ white-space: nowrap;
+ height: 90px;
+ width: 100%;
+}
+
+.footer img {
+ margin-left: 8px;
+ margin-right: 8px;
+}
+
+.sphinxsidebar {
+ float: left;
+ width: 250px;
+ padding: 0px 10px 0px 10px;
+ text-align: left;
+}
+
+.sphinxsidebar ul {
+ padding: 0px;
+ margin: 0px;
+ list-style-position: inside;
+}
+
+.sphinxsidebar > ul {
+ padding: 0px;
+ margin: 0px;
+}
+
+.sphinxsidebar ul li {
+ margin-left: 10px;
+ padding: 0px;
+}
+
+.sphinxsidebar h3, .sphinxsidebar h3 a {
+ font-weight: bold;
+ color: #333;
+}
+
+.documentwrapper {
+ margin-left: 270px;
+ text-align: left;
+ background-color: #ffffff;
+ border-left: 1px solid #989898;
+ font-size:18px;
+ padding: 10px 50px 15px 50px;
+ height: 100%;
+}
+
+h1 {
+ font-size:18px;
+ padding-left: 50px;
+ padding-bottom: 15px;
+ padding-top: 15px;
+ border-bottom: 1px solid #c2c2c2;
+ margin-right: -100px;
+ position: relative;
+ left: -50px;
+ top: -10px;
+}
+
+h2 {
+ font-size:12px;
+ font-weight:bold;
+ border-left-width: 1px;
+ border-right-width: 1px;
+ border-top-width: 1px;
+ border-bottom-width: 2px;
+ border-style: solid;
+ border-left-color: #b1b1b1;
+ border-right-color: #b1b1b1;
+ border-top-color: #b1b1b1;
+ border-bottom-color: #009491;
+ background-color: #e0e0e0;
+ padding:5px;
+ margin-top: 20px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ -khtml-border-radius:5px;
+}
+
+h3, h4 {
+ font-weight: bolder;
+}
+
+pre {
+ border-top: 1px solid #e0e0e0;
+ border-bottom: 1px solid #e0e0e0;
+ background-color: #fafafa;
+ padding: 5px;
+ font: 100% monospace;
+ overflow: auto;
+}
+
+pre * {
+ font: 100% monospace;
+}
+
+.pre {
+ font: 100% monospace;
+}
+
+.headerlink {
+ font-size: 100%;
+ color: inherit;
+ float: right;
+ visibility: Hidden
+}
+
+h1 .headerlink {
+ padding-right: 50px;
+}
+
+h1:hover .headerlink, h2:hover .headerlink, h3:hover .headerlink {
+ visibility: Visible;
+}
+
+a, a:visited {
+ color: #009491;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+/* -- admonitions ----------------------------------------------------------- */
+
+div.admonition {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ padding: 7px;
+}
+
+div.admonition dt {
+ font-weight: bold;
+}
+
+div.admonition dl {
+ margin-bottom: 0;
+}
+
+p.admonition-title {
+ margin: 0px 10px 5px 0px;
+ font-weight: bold;
+}
+
+div.body p.centered {
+ text-align: center;
+ margin-top: 25px;
+}
+
+div.warning {
+ background-color: #ffe4e4;
+ border: 1px solid #f66;
+}
+
+div.seealso {
+ background-color: #ffffcc;
+ border: 1px solid #ffff66;
+}
+
+div.note {
+ border: 1px solid #e3e3e3;
+}
+
+table.docutils {
+ margin-left: auto;
+ margin-right: auto;
+ margin-bottom: 10px;
+ border: none;
+}
+
+table.docutils td {
+ border: none;
+}
+
+table.docutils th {
+ border: none;
+ font-weight: bold;
+ vertical-align: top;
+}
+
+h2 em {
+ float: right;
+ font-size: 10px;
+ position: relative;
+ top: -20px;
+}
+
+/* Table of pymaemo components */
+
+#development table.docutils td {
+ border-bottom: 1px solid #EBEBEB;
+}
+
+#development th {
+ background-color: #EBEBEB;
+ color: #FC7E00;
+ padding: 5px;
+}
+
+#development th:first-child {
+ -moz-border-radius: 20px 0px 0px 0px;
+ -webkit-border-radius: 20px 0px 0px 0px;
+ -khtml-border-radius: 20px 0px 0px 0px;
+ padding-left: 10px;
+}
+#development th:last-child {
+ -moz-border-radius: 0px 20px 0px 0px;
+ -webkit-border-radius: 0px 20px 0px 0px;
+ -khtml-border-radius: 0px 20px 0px 0px;
+ padding-right: 10px;
+ width: 100px;
+}
+
+hr {
+ border: none;
+ border-bottom: 1px dashed #EBEBEB;
+ width: 70%
+}
+
+.oldnews {
+ text-align: right;
+}
+
+/******************* TOPO *****************************/
+.header {
+ background-image: url(bg_topo.jpg);
+ background-repeat: repeat-x;
+ height: 147px;
+}
+
+.header_container {
+ background-image: url(bg_header.png);
+ background-repeat: no-repeat;
+ background-position: 100px 0px;
+}
+
+.logo {
+ text-align: left;
+ margin-bottom: 10px;
+}
+
+#searchbox {
+ border-top: 1px solid #989898;
+ padding-top: 10px;
+ margin-left: -10px;
+ margin-right: -10px;
+ padding-left: 10px;
+ padding-right: 10px;
+}
+
+#search_button {
+ border: 1px solid #3A393A;
+ background-color: #3A393A;
+ color: white;
+ cursor: pointer;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -khtml-border-radius: 5px;
+
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+}
+
+/* search field */
+form #q {
+ width: 136px;
+/* height: 22px; */
+ border: none;
+ margin: 0px;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -khtml-border-radius: 5px;
+ margin-top: 2px;
+ padding: 4px;
+ line-height: 22px
+}
+
+#search-results h2 {
+ display: none;
+}
+
+#search-results h2 {
+ display: none;
+}
+
+#search-results ul.search {
+ margin: 0px;
+ padding: 0px;
+}
+
+ul.search div.context {
+ padding-left: 40px;
+}
+
+#installation td {
+ text-align: center;
+ font-weight: bold;
+}
+
+em {
+ color: inherit;
+ font-style:italic;
+}
+
+/******** REL bar *********/
+
+.related {
+ display: inline;
+}
+
+.related ul {
+ padding: 0px 0px 0px 10px;
+ margin: 0px;
+ text-align: left;
+ background-image: url(relbar_bg.png);
+}
+
+.related li {
+ display: inline;
+ color: white;
+ font-weight: bold;
+}
+
+.related li a {
+ color: inherit;
+ line-height: 35px;
+ font-weight: bold;
+ vertical-align: middle;
+}
+
+.related li.right {
+ float: right;
+ margin-right: 5px;
+}
+
+.related h3 {
+ display: none;
+}
+
+.align-center {
+ text-align: center;
+}
+
+.contentstable {
+ width: 100%;
+}
+
+.contentstable td {
+ padding-left: 30px;
+ vertical-align: top;
+}
+
+p.biglink a {
+ font-size: 20px;
+}
+
+dt:target, .highlight {
+ background-color: #fbe54e;
+}
+
+img {
+ border: 0px;
+}
+
+.figure .caption {
+ font-style:italic;
+}
+
+table.footnote {
+ margin: 0px;
+}
+
+#synopsis table, table.field-list {
+ margin: 0px;
+}
+
+tt.descname {
+ font-size: 120%;
+ font-weight: bold;
+}
+
+#functions ul, #virtual-functions ul, #slots ul, #signals ul, #static-functions ul {
+ list-style: none;
+ margin: 0px;
+ padding: 10px;
+ border: 1px solid #ddd;
+ background-color: #f4f4f4;
+ -moz-border-radius:10px;
+ -webkit-border-radius:10px;
+ -khtml-border-radius:10px;
+}
+
+#synopsis span.pre {
+ color: #009491;
+ font-weight: bolder;
+}
+
+#detailed-description .class dt, #detailed-description .method dt, #detailed-description .attribute dt, #detailed-description .function dt {
+ margin: 0px;
+ padding: 10px;
+ border: 1px solid #ddd;
+ background-color: #f4f4f4;
+ -moz-border-radius:10px;
+ -webkit-border-radius:10px;
+ -khtml-border-radius:10px;
+}
+
+.pysidetoc ul {
+ list-style: none;
+ padding: 0px;
+ margin: 0px;
+}
+
+.pysidetoc em {
+ font-style: normal;
+}
+
+.pysidetoc strong {
+ display: block;
+ padding: 5px;
+ border: 1px solid #ddd;
+ background-color: #f4f4f4;
+ -moz-border-radius:6px;
+ -webkit-border-radius:6px;
+ -khtml-border-radius:6px;
+}
+
+.hide {
+ display: none;
+}
diff --git a/sources/shiboken2/doc/_themes/pysidedocs/static/pysidelogo.png b/sources/shiboken2/doc/_themes/pysidedocs/static/pysidelogo.png
new file mode 100644
index 000000000..076c1057c
--- /dev/null
+++ b/sources/shiboken2/doc/_themes/pysidedocs/static/pysidelogo.png
Binary files differ
diff --git a/sources/shiboken2/doc/_themes/pysidedocs/static/relbar_bg.png b/sources/shiboken2/doc/_themes/pysidedocs/static/relbar_bg.png
new file mode 100644
index 000000000..4036733a7
--- /dev/null
+++ b/sources/shiboken2/doc/_themes/pysidedocs/static/relbar_bg.png
Binary files differ
diff --git a/sources/shiboken2/doc/_themes/pysidedocs/theme.conf b/sources/shiboken2/doc/_themes/pysidedocs/theme.conf
new file mode 100644
index 000000000..e0a652a5d
--- /dev/null
+++ b/sources/shiboken2/doc/_themes/pysidedocs/theme.conf
@@ -0,0 +1,7 @@
+[theme]
+inherit = default
+stylesheet = pysidedocs.css
+pygments_style = none
+
+[options]
+nosidebar = false
diff --git a/sources/shiboken2/doc/codeinjectionsemantics.rst b/sources/shiboken2/doc/codeinjectionsemantics.rst
new file mode 100644
index 000000000..d748a3aae
--- /dev/null
+++ b/sources/shiboken2/doc/codeinjectionsemantics.rst
@@ -0,0 +1,397 @@
+************************
+Code Injection Semantics
+************************
+
+API Extractor provides the `inject-code
+<http://www.pyside.org/docs/apiextractor/typesystem_manipulating_objects.html#inject-code>`_ tag
+allowing the user to put custom written code to on specific locations of the generated code.
+Yet this is only part of what is needed to generate proper binding code, where the custom code
+should be written to depends upon the technology used on the generated binding code.
+
+This is the ``inject-code`` tag options that matters to |project|.
+
+ .. code-block:: xml
+
+ <inject-code class="native | target" position="beginning | end">
+ // custom code
+ </inject-code>
+
+Conventions
+===========
+
+**C++ Wrapper**
+ This term refers to a generated C++ class that extends a class from the
+ wrapped library. It is used only when a wrapped C++ class is polymorphic,
+ i.e. it has or inherits any virtual methods.
+
+**Python Wrapper**
+ The code that exports the C++ wrapped class to Python. **Python wrapper**
+ refers to all the code needed to export a C++ class to Python, and
+ **Python method/function wrapper** means the specific function that calls
+ the C++ method/function on behalf of Python.
+
+**Native**
+ This is a possible value for the ``class`` attribute of the ``inject-code``
+ tag, it means things more akin to the C++ side.
+
+**Target**
+ Another ``class`` attribute value, it indicates things more close to the
+ Python side.
+
+inject-code tag
+===============
+
+The following table describes the semantics of ``inject-code`` tag as used on
+|project|.
+
+ +---------------+------+---------+--------------------------------------------------------------+
+ |Parent Tag |Class |Position |Meaning |
+ +===============+======+=========+==============================================================+
+ |value-type, |native|beginning|Write to the beginning of a class wrapper ``.cpp`` file, right|
+ |object-type | | |after the ``#include`` clauses. A common use would be to write|
+ | | | |prototypes for custom functions whose definitions are put on a|
+ | | | |``native/end`` code injection. |
+ | | +---------+--------------------------------------------------------------+
+ | | |end |Write to the end of a class wrapper ``.cpp`` file. Could be |
+ | | | |used to write custom/helper functions definitions for |
+ | | | |prototypes declared on ``native/beginning``. |
+ | +------+---------+--------------------------------------------------------------+
+ | |target|beginning|Put custom code on the beginning of the wrapper initializer |
+ | | | |function (``init_CLASS(PyObject *module)``). This could be |
+ | | | |used to manipulate the ``PyCLASS_Type`` structure before |
+ | | | |registering it on Python. |
+ | | +---------+--------------------------------------------------------------+
+ | | |end |Write the given custom code at the end of the class wrapper |
+ | | | |initializer function (``init_CLASS(PyObject *module)``). The |
+ | | | |code here will be executed after all the wrapped class |
+ | | | |components have been initialized. |
+ +---------------+------+---------+--------------------------------------------------------------+
+ |modify-function|native|beginning|Code here is put on the virtual method override of a C++ |
+ | | | |wrapper class (the one responsible for passing C++ calls to a |
+ | | | |Python override, if there is any), right after the C++ |
+ | | | |arguments have been converted but before the Python call. |
+ | | +---------+--------------------------------------------------------------+
+ | | |end |This code injection is put in a virtual method override on the|
+ | | | |C++ wrapper class, after the call to Python and before |
+ | | | |dereferencing the Python method and tuple of arguments. |
+ | +------+---------+--------------------------------------------------------------+
+ | |target|beginning|This code is injected on the Python method wrapper |
+ | | | |(``PyCLASS_METHOD(...)``), right after the decisor have found |
+ | | | |which signature to call and also after the conversion of the |
+ | | | |arguments to be used, but before the actual call. |
+ | | +---------+--------------------------------------------------------------+
+ | | |end |This code is injected on the Python method wrapper |
+ | | | |(``PyCLASS_METHOD(...)``), right after the C++ method call, |
+ | | | |but still inside the scope created by the overload for each |
+ | | | |signature. |
+ | +------+---------+--------------------------------------------------------------+
+ | |shell |beginning|Used only for virtual functions. The code is injected when the|
+ | | | |function does not has a pyhton implementation, then the code |
+ | | | |is inserted before c++ call |
+ | | +---------+--------------------------------------------------------------+
+ | | |end |Same as above, but the code is inserted after c++ call |
+ +---------------+------+---------+--------------------------------------------------------------+
+ |typesystem |native|beginning|Write code to the beginning of the module ``.cpp`` file, right|
+ | | | |after the ``#include`` clauses. This position has a similar |
+ | | | |purpose as the ``native/beginning`` position on a wrapper |
+ | | | |class ``.cpp`` file, namely write function prototypes, but not|
+ | | | |restricted to this use. |
+ | | +---------+--------------------------------------------------------------+
+ | | |end |Write code to the end of the module ``.cpp`` file. Usually |
+ | | | |implementations for function prototypes inserted at the |
+ | | | |beginning of the file with a ``native/beginning`` code |
+ | | | |injection. |
+ | +------+---------+--------------------------------------------------------------+
+ | |target|beginning|Insert code at the start of the module initialization function|
+ | | | |(``initMODULENAME()``), before the calling ``Py_InitModule``. |
+ | | +---------+--------------------------------------------------------------+
+ | | |end |Insert code at the end of the module initialization function |
+ | | | |(``initMODULENAME()``), but before the checking that emits a |
+ | | | |fatal error in case of problems importing the module. |
+ +---------------+------+---------+--------------------------------------------------------------+
+
+
+Anatomy of Code Injection
+=========================
+
+To make things clear let's use a simplified example of generated wrapper code
+and the places where each kind of code injection goes.
+
+Below is the example C++ class for whom wrapper code will be generated.
+
+ .. code-block:: c++
+
+ class InjectCode {
+ public:
+ InjectCode();
+ double overloadedMethod(int arg);
+ double overloadedMethod(double arg);
+ virtual int virtualMethod(int arg);
+ };
+
+From the C++ class, |project| will generate a ``injectcode_wrapper.cpp`` file
+with the binding code. The next section will use a simplified version of the
+generated wrapper code with the injection spots marked with comments.
+
+Noteworthy Cases
+----------------
+
+The type system description system gives the binding developer a lot of
+flexibility, which is power, which comes with responsibility. Some modifications
+to the wrapped API will not be complete without some code injection.
+
+
+Removing arguments and setting a default values for them
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+A simple case is when a function have one argument removed, as when the C++
+method ``METHOD(ARG)`` is modified to be used from Python as ``METHOD()``;
+of course the binding developer must provide some guidelines to the generator
+on what to do to call it. The most common solution is to remove the argument and
+set a default value for it at the same time, so the original C++ method could be
+called without problems.
+
+Removing arguments and calling the method with your own hands
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If the argument is removed and no default value is provided, the generator will
+not write any call to the method and expect the ``modify-function - target/beginning``
+code injection to call the original C++ method on its own terms. If even this
+custom code is not provided the generator will put an ``#error`` clause to
+prevent compilation of erroneus binding code.
+
+Calling the method with your own hands always!
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If your custom code to be injected contains a call to the wrapped C++ method,
+it surely means that you don't want the generator to write another call to the
+same method. As expected |project| will detect the user written call on the code
+injection and will not write its own call, but for this to work properly the
+binding developer must use the template variable ``%FUNCTION_NAME`` instead
+of writing the actual name of the wrapped method/function.
+
+In other words, use
+
+ .. code-block:: xml
+
+ <inject-code class="target" position="beginning | end">
+ %CPPSELF.originalMethodName();
+ </inject-code>
+
+
+instead of
+
+
+ .. code-block:: xml
+
+ <inject-code class="target" position="beginning | end">
+ %CPPSELF.%FUNCTION_NAME();
+ </inject-code>
+
+
+Code Injection for Functions/Methods
+====================================
+
+
+.. _codeinjecting_method_native:
+
+On The Native Side
+------------------
+
+Notice that this is only used when there is a C++ wrapper, i.e. the wrapped
+class is polymorphic.
+
+ .. code-block:: c++
+
+ int InjectCodeWrapper::virtualMethod(int arg)
+ {
+ PyObject* method = BindingManager::instance().getOverride(this, "virtualMethod");
+ if (!py_override)
+ return this->InjectCode::virtualMethod(arg);
+
+ (... here C++ arguments are converted to Python ...)
+
+ // INJECT-CODE: <modify-function><inject-code class="native" position="beginning">
+ // Uses: pre method call custom code, modify the argument before the
+ // Python call.
+
+ (... Python method call goes in here ...)
+
+ // INJECT-CODE: <modify-function><inject-code class="native" position="end">
+ // Uses: post method call custom code, modify the result before delivering
+ // it to C++ caller.
+
+ (... Python method and argument tuple are dereferenced here ...)
+
+ return Shiboken::Converter<int>::toCpp(method_result);
+ }
+
+
+On The Target Side
+------------------
+
+All the overloads of a method from C++ are gathered together on a single Python
+method that uses an overload decisor to call the correct C++ method based on the
+arguments passed by the Python call. Each overloaded method signature has its
+own ``beginning`` and ``end`` code injections.
+
+ .. code-block:: c++
+
+ static PyObject*
+ PyInjectCode_overloadedMethod(PyObject* self, PyObject* arg)
+ {
+ PyObject* py_result = 0;
+ if (PyFloat_Check(arg)) {
+ double cpp_arg0 = Shiboken::Converter<double >::toCpp(arg);
+
+ // INJECT-CODE: <modify-function><inject-code class="target" position="beginning">
+ // Uses: pre method call custom code.
+
+ py_result = Shiboken::Converter<double >::toPython(
+ PyInjectCode_cptr(self)->InjectCode::overloadedMethod(cpp_arg0)
+ );
+
+ // INJECT-CODE: <modify-function><inject-code class="target" position="end">
+ // Uses: post method call custom code.
+
+ } else if (PyNumber_Check(arg)) {
+ (... other overload calling code ...)
+ } else goto PyInjectCode_overloadedMethod_TypeError;
+
+ if (PyErr_Occurred() || !py_result)
+ return 0;
+
+ return py_result;
+
+ PyInjectCode_overloadedMethod_TypeError:
+ PyErr_SetString(PyExc_TypeError, "'overloadedMethod()' called with wrong parameters.");
+ return 0;
+ }
+
+
+.. _codeinjecting_classes:
+
+Code Injection for Wrapped Classes
+==================================
+
+.. _codeinjecting_classes_native:
+
+On The Native Side
+------------------
+
+Those injections go in the body of the ``CLASSNAME_wrapper.cpp`` file for the
+wrapped class.
+
+ .. code-block:: c++
+
+ // Start of ``CLASSNAME_wrapper.cpp``
+ #define protected public
+ // default includes
+ #include <shiboken.h>
+ (...)
+ #include "injectcode_wrapper.h"
+ using namespace Shiboken;
+
+ // INJECT-CODE: <value/object-type><inject-code class="native" position="beginning">
+ // Uses: prototype declarations
+
+ (... C++ wrapper virtual methods, if any ...)
+
+ (... Python wrapper code ...)
+
+ PyAPI_FUNC(void)
+ init_injectcode(PyObject *module)
+ {
+ (...)
+ }
+
+ (...)
+
+ // INJECT-CODE: <value/object-type><inject-code class="native" position="end">
+ // Uses: definition of functions prototyped at ``native/beginning``.
+
+ // End of ``CLASSNAME_wrapper.cpp``
+
+
+.. _codeinjecting_classes_target:
+
+On The Target Side
+------------------
+
+Code injections to the class Python initialization function.
+
+ .. code-block:: c++
+
+ // Start of ``CLASSNAME_wrapper.cpp``
+
+ (...)
+
+ PyAPI_FUNC(void)
+ init_injectcode(PyObject *module)
+ {
+ // INJECT-CODE: <value/object-type><inject-code class="target" position="beginning">
+ // Uses: Alter something in the PyInjectCode_Type (tp_flags value for example)
+ // before registering it.
+
+ if (PyType_Ready(&PyInjectCode_Type) < 0)
+ return;
+
+ Py_INCREF(&PyInjectCode_Type);
+ PyModule_AddObject(module, "InjectCode",
+ ((PyObject*)&PyInjectCode_Type));
+
+ // INJECT-CODE: <value/object-type><inject-code class="target" position="end">
+ // Uses: do something right after the class is registered, like set some static
+ // variable injected on this same file elsewhere.
+ }
+
+ (...)
+
+ // End of ``CLASSNAME_wrapper.cpp``
+
+Code Injection for Modules
+==========================
+
+The C++ libraries are wapped as Python modules, a collection of classes,
+functions, enums and namespaces. |project| creates wrapper files for all of
+them and also one extra ``MODULENAME_module_wrapper.cpp`` to register the whole
+module. Code injection xml tags who have the ``typesystem`` tag as parent will
+be put on this file.
+
+On The Native Side
+------------------
+
+This works exactly as the class wrapper code injections :ref:`codeinjecting_classes_native`.
+
+On The Target Side
+------------------
+
+This is very similar to class wrapper code injections :ref:`codeinjecting_classes_target`.
+Notice that the inject code at ``target/end`` is inserted before the check for errors
+to prevent bad custom code to pass unnoticed.
+
+ .. code-block:: c++
+
+ // Start of ``MODULENAME_module_wrapper.cpp``
+
+ (...)
+ initMODULENAME()
+ {
+ // INJECT-CODE: <typesystem><inject-code class="target" position="beginning">
+ // Uses: do something before the module is created.
+
+ PyObject* module = Py_InitModule("MODULENAME", MODULENAME_methods);
+
+ (... initialization of wrapped classes, namespaces, functions and enums ...)
+
+ // INJECT-CODE: <typesystem><inject-code class="target" position="end">
+ // Uses: do something after the module is registered and initialized.
+
+ if (PyErr_Occurred())
+ Py_FatalError("can't initialize module sample");
+ }
+
+ (...)
+
+ // Start of ``MODULENAME_module_wrapper.cpp``
+
diff --git a/sources/shiboken2/doc/commandlineoptions.rst b/sources/shiboken2/doc/commandlineoptions.rst
new file mode 100644
index 000000000..d373561cd
--- /dev/null
+++ b/sources/shiboken2/doc/commandlineoptions.rst
@@ -0,0 +1,105 @@
+.. _command-line:
+
+Command line options
+********************
+
+Usage
+-----
+
+::
+
+ shiboken [options] header-file typesystem-file
+
+
+Options
+-------
+
+``--disable-verbose-error-messages``
+ Disable verbose error messages. Turn the CPython code hard to debug but saves a few kilobytes
+ in the generated binding.
+
+.. _parent-heuristic:
+
+``--enable-parent-ctor-heuristic``
+ This flag enable an useful heuristic which can save a lot of work related to object ownership when
+ writing the typesystem.
+ For more info, check :ref:`ownership-parent-heuristics`.
+
+.. _pyside-extensions:
+
+``--enable-pyside-extensions``
+ Enable pyside extensions like support for signal/slots. Use this if you are creating a binding based
+ on PySide.
+
+.. _return-heuristic:
+
+``--enable-return-value-heuristic``
+ Enable heuristics to detect parent relationship on return values.
+ For more info, check :ref:`return-value-heuristics`.
+
+.. _api-version:
+
+``--api-version=<version>``
+ Specify the supported api version used to generate the bindings.
+
+.. _debug-level:
+
+``--debug-level=[sparse|medium|full]``
+ Set the debug level.
+
+.. _documentation-only:
+
+``--documentation-only``
+ Do not generate any code, just the documentation.
+
+.. _drop-type-entries:
+
+``--drop-type-entries="<TypeEntry0>[;TypeEntry1;...]"``
+ Semicolon separated list of type system entries (classes, namespaces,
+ global functions and enums) to be dropped from generation.
+
+.. _generation-set:
+
+``--generation-set``
+ Generator set to be used (e.g. qtdoc).
+
+.. _help:
+
+``--help``
+ Display this help and exit.
+
+.. _include-paths:
+
+``--include-paths=<path>[:<path>:...]``
+ Include paths used by the C++ parser.
+
+.. _license-file=[license-file]:
+
+``--license-file=[license-file]``
+ File used for copyright headers of generated files.
+
+.. _no-suppress-warnings:
+
+``--no-suppress-warnings``
+ Show all warnings.
+
+.. _output-directory:
+
+``--output-directory=[dir]``
+ The directory where the generated files will be written.
+
+.. _silent:
+
+``--silent``
+ Avoid printing any message.
+
+.. _typesystem-paths:
+
+``--typesystem-paths=<path>[:<path>:...]``
+ Paths used when searching for type system files.
+
+.. _version:
+
+``--version``
+ Output version information and exit.
+
diff --git a/sources/shiboken2/doc/conf.py.in b/sources/shiboken2/doc/conf.py.in
new file mode 100644
index 000000000..ed61d2695
--- /dev/null
+++ b/sources/shiboken2/doc/conf.py.in
@@ -0,0 +1,166 @@
+# -*- coding: utf-8 -*-
+#
+# PyQtB documentation build configuration file, created by
+# sphinx-quickstart on Wed Apr 22 15:04:20 2009.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.append(os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.ifconfig', 'sphinx.ext.coverage']
+
+rst_epilog = """
+.. |project| replace:: Shiboken
+"""
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+source_encoding = 'utf-8'
+
+# The master toctree document.
+#master_doc = 'contents'
+
+# General information about the project.
+project = u'Shiboken'
+copyright = u'Copyright (C) 2016 The Qt Company Ltd.'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '@shiboken_VERSION@'
+# The full version, including alpha/beta/rc tags.
+release = '@shiboken_VERSION@'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'pysidedocs'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {
+#}
+
+# Add any paths that contain custom themes here, relative to this directory.
+html_theme_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_themes']
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+#html_static_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = { '' : ''}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+html_additional_pages = { 'index' : 'index.html'}
+
+# If false, no module index is generated.
+html_use_modindex = False
+
+# If false, no index is generated.
+html_use_index = False
+
+# If true, the index is split into individual pages for each letter.
+html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+html_show_sourcelink = False
+
+html_add_permalinks = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
diff --git a/sources/shiboken2/doc/contents.rst b/sources/shiboken2/doc/contents.rst
new file mode 100644
index 000000000..24adb1c68
--- /dev/null
+++ b/sources/shiboken2/doc/contents.rst
@@ -0,0 +1,17 @@
+Table of contents
+*****************
+.. toctree::
+ :numbered:
+ :maxdepth: 3
+
+ faq.rst
+ overview.rst
+ commandlineoptions.rst
+ projectfile.rst
+ typesystemvariables.rst
+ typeconverters.rst
+ codeinjectionsemantics.rst
+ sequenceprotocol.rst
+ ownership.rst
+ wordsofadvice.rst
+ shibokenmodule.rst
diff --git a/sources/shiboken2/doc/dependency-pyqtb.svg b/sources/shiboken2/doc/dependency-pyqtb.svg
new file mode 100644
index 000000000..a458bf6fb
--- /dev/null
+++ b/sources/shiboken2/doc/dependency-pyqtb.svg
@@ -0,0 +1,600 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="800"
+ height="340"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="dependency-pyqtb.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="/var/www/lauro/dependency-pyqtb.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="Arrow1Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lstart"
+ style="overflow:visible">
+ <path
+ id="path3270"
+ d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(0.8,0,0,0.8,10,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend"
+ style="overflow:visible">
+ <path
+ id="path3679"
+ d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <inkscape:perspective
+ id="perspective3480"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3498"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3541"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.0425"
+ inkscape:cx="400"
+ inkscape:cy="170"
+ inkscape:document-units="px"
+ inkscape:current-layer="g3995"
+ showgrid="false"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1280"
+ inkscape:window-height="951"
+ inkscape:window-x="0"
+ inkscape:window-y="25" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-94.976306,-355.09425)" />
+ <g
+ id="g4087"
+ transform="translate(2.4157429e-6,1.9999951)">
+ <g
+ id="g3995"
+ transform="translate(6,-3.2661035e-8)">
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.66823119px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-end:none;stroke-opacity:1"
+ d="M 281.95594,47.06539 L 314.12853,47.06538"
+ id="path2877"
+ inkscape:connector-type="polyline" />
+ <g
+ id="g3801"
+ transform="translate(-9.3125054,-154.20033)">
+ <rect
+ y="286.49988"
+ x="322.2547"
+ height="73.367416"
+ width="194.85175"
+ id="rect3595"
+ style="fill:#9ac5ff;fill-opacity:1;fill-rule:evenodd;stroke:#003378;stroke-width:0.8142156;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ ry="10.318988"
+ rx="8.598484" />
+ <g
+ transform="translate(1.7229236,-30.915768)"
+ id="g3599">
+ <text
+ xml:space="preserve"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="336.95081"
+ id="text2443"><tspan
+ sodipodi:role="line"
+ id="tspan2445"
+ x="329.46826"
+ y="336.95081">API Extractor</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="352.61548"
+ id="text2447"><tspan
+ sodipodi:role="line"
+ id="tspan2449"
+ x="329.46826"
+ y="352.61548">0.2</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="368.15546"
+ id="text2451"><tspan
+ sodipodi:role="line"
+ x="329.46826"
+ y="368.15546"
+ id="tspan2453">Headers and libraries - compile-time</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="383.47839"
+ id="text2455"><tspan
+ sodipodi:role="line"
+ id="tspan2457"
+ x="329.46826"
+ y="383.47839">LGPL version 2.1</tspan></text>
+ </g>
+ </g>
+ <g
+ id="g3729"
+ transform="translate(-9.3125054,-153.6367)">
+ <rect
+ y="164.01837"
+ x="322.2547"
+ height="73.367416"
+ width="194.85175"
+ id="rect2459"
+ style="fill:#9ac5ff;fill-opacity:1;fill-rule:evenodd;stroke:#003378;stroke-width:0.8142156;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ ry="10.318988"
+ rx="8.598484" />
+ <g
+ transform="translate(3.673984,2.3276517)"
+ id="g3585">
+ <text
+ xml:space="preserve"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="181.23659"
+ id="text2461"><tspan
+ sodipodi:role="line"
+ id="tspan2463"
+ x="329.46826"
+ y="181.23659">Shiboken (generator)</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="196.90126"
+ id="text2465"><tspan
+ sodipodi:role="line"
+ id="tspan2467"
+ x="329.46826"
+ y="196.90126">0.1</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="212.44124"
+ id="text2469"><tspan
+ sodipodi:role="line"
+ x="329.46826"
+ y="212.44124"
+ id="tspan2471">Binary executable - compile-time</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="227.76418"
+ id="text2473"><tspan
+ sodipodi:role="line"
+ id="tspan2475"
+ x="329.46826"
+ y="227.76418">GPL version 2</tspan></text>
+ </g>
+ </g>
+ <g
+ id="g3789"
+ transform="translate(-9.3125054,-154.20033)">
+ <rect
+ y="406.48441"
+ x="322.2547"
+ height="73.367416"
+ width="194.85175"
+ id="rect3597"
+ style="fill:#f3a6a6;fill-opacity:1;fill-rule:evenodd;stroke:#6a0e0e;stroke-width:0.8142156;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ ry="10.318988"
+ rx="8.598484" />
+ <g
+ transform="translate(-0.7447933,-64)"
+ id="g3633">
+ <text
+ xml:space="preserve"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#350707;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="489.09369"
+ id="text2565"><tspan
+ sodipodi:role="line"
+ id="tspan2567"
+ x="329.46826"
+ y="489.09369">boost::graph</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#350707;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="504.75836"
+ id="text2569"><tspan
+ sodipodi:role="line"
+ id="tspan2571"
+ x="329.46826"
+ y="504.75836">1.38.0</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#350707;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="520.29834"
+ id="text2573"><tspan
+ sodipodi:role="line"
+ x="329.46826"
+ y="520.29834"
+ id="tspan2575">headers and libraries - compile-time</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#350707;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="535.62128"
+ id="text2577"><tspan
+ sodipodi:role="line"
+ id="tspan2579"
+ x="329.46826"
+ y="535.62128">Boost Software License 1.0</tspan></text>
+ </g>
+ </g>
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.77180147px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-end:none;stroke-opacity:1"
+ d="M 410.36806,130.70564 L 410.36806,83.52386"
+ id="path2879"
+ inkscape:connector-type="polyline" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.77360356px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-mid:none;marker-end:none;stroke-opacity:1"
+ d="M 410.36806,252.57322 L 410.36806,207.23899"
+ id="path2881"
+ inkscape:connector-type="polyline" />
+ <g
+ id="g3565"
+ transform="translate(1.4608973,-106.88798)">
+ <rect
+ ry="22.567146"
+ y="268.8403"
+ x="6.7667637"
+ height="163.45378"
+ width="273.78238"
+ id="rect7541"
+ style="fill:#e3e2db;stroke:#000000;stroke-width:1.30499184;stroke-opacity:1"
+ rx="22.567146" />
+ <g
+ transform="translate(0.2849671,3.2991583)"
+ id="g3547">
+ <g
+ id="g3516"
+ transform="translate(0,63.999998)">
+ <text
+ id="text7543"
+ y="339.74512"
+ x="76.614265"
+ style="font-size:20.61732101px;font-style:normal;font-weight:normal;fill:#350707;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="339.74512"
+ x="76.614265"
+ id="tspan7545"
+ sodipodi:role="line">Boost</tspan></text>
+ <rect
+ ry="6.4285707"
+ y="321.55374"
+ x="21.614267"
+ height="22.5"
+ width="43.163269"
+ id="rect7555"
+ style="fill:#f3a6a6;fill-opacity:1;stroke:#6a0e0e;stroke-width:0.64285713;stroke-opacity:1"
+ rx="6.4285707" />
+ </g>
+ <g
+ id="g3521"
+ transform="translate(0,-2.9523642)">
+ <text
+ id="text7547"
+ y="372.67505"
+ x="76.614265"
+ style="font-size:20.61732101px;font-style:normal;font-weight:normal;fill:#1c2d0f;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="372.67505"
+ x="76.614265"
+ id="tspan7549"
+ sodipodi:role="line">Qt Software</tspan></text>
+ <rect
+ ry="6.4285707"
+ y="355.4823"
+ x="21.614267"
+ height="22.5"
+ width="43.163269"
+ id="rect7561"
+ style="fill:#97ce6c;fill-opacity:1;stroke:#385a1e;stroke-width:0.64285713;stroke-opacity:1"
+ rx="6.4285707" />
+ </g>
+ <g
+ id="g3486"
+ transform="translate(0,2.8342009e-5)">
+ <text
+ id="text7551"
+ y="304.38055"
+ x="76.614265"
+ style="font-size:20.61732101px;font-style:normal;font-weight:normal;fill:#00193c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="304.38055"
+ x="76.614265"
+ id="tspan7553"
+ sodipodi:role="line">INdT/Nokia</tspan></text>
+ <rect
+ ry="6.4285707"
+ y="286.4823"
+ x="21.614267"
+ height="22.5"
+ width="43.163269"
+ id="rect7563"
+ style="fill:#9ac5ff;fill-opacity:1;stroke:#003378;stroke-width:0.64285713;stroke-opacity:1"
+ rx="6.4285707" />
+ </g>
+ <g
+ id="g3526"
+ transform="translate(-1.3182277,-35.976168)"
+ style="fill:#ffe052;fill-opacity:1">
+ <text
+ id="text3528"
+ y="372.67505"
+ x="76.614265"
+ style="font-size:20.61732101px;font-style:normal;font-weight:normal;fill:#3c3100;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="372.67505"
+ x="76.614265"
+ id="tspan3530"
+ sodipodi:role="line">Python Foundation</tspan></text>
+ <rect
+ ry="6.4285707"
+ y="355.4823"
+ x="21.614267"
+ height="22.5"
+ width="43.163269"
+ id="rect3532"
+ style="fill:#ffe052;fill-opacity:1;stroke:#786200;stroke-width:0.64285713;stroke-opacity:1"
+ rx="6.4285707" />
+ </g>
+ </g>
+ </g>
+ <g
+ id="g3717"
+ transform="translate(232.28126,-66.767457)">
+ <rect
+ y="77.149132"
+ x="322.2547"
+ height="73.367416"
+ width="194.85175"
+ id="rect3657"
+ style="fill:#9ac5ff;fill-opacity:1;fill-rule:evenodd;stroke:#003378;stroke-width:0.8142156;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ ry="10.318988"
+ rx="8.598484" />
+ <g
+ transform="translate(4.8773009,-84.541588)"
+ id="g3659">
+ <text
+ xml:space="preserve"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="181.23659"
+ id="text3661"><tspan
+ sodipodi:role="line"
+ id="tspan3663"
+ x="329.46826"
+ y="181.23659">libshiboken</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="196.90126"
+ id="text3665"><tspan
+ sodipodi:role="line"
+ id="tspan3667"
+ x="329.46826"
+ y="196.90126">0.1</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="212.44124"
+ id="text3669"><tspan
+ sodipodi:role="line"
+ x="329.46826"
+ y="212.44124"
+ id="tspan3671">Headers and libraries - compile-time</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#00183c;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="227.76418"
+ id="text3673"><tspan
+ sodipodi:role="line"
+ id="tspan3675"
+ x="329.46826"
+ y="227.76418">LGPL version 2.1</tspan></text>
+ </g>
+ </g>
+ <g
+ id="g3752"
+ transform="translate(-10.802055,-155.79173)">
+ <rect
+ rx="8.3239012"
+ y="166.21593"
+ x="18.860012"
+ height="73.282379"
+ width="274.18781"
+ id="rect2417"
+ style="fill:#97ce6c;fill-opacity:1;fill-rule:evenodd;stroke:#385a1e;stroke-width:0.96558368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ ry="9.2689295" />
+ <g
+ id="g3741">
+ <text
+ xml:space="preserve"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#1c2d0f;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="29.111408"
+ y="183.02223"
+ id="text2419"><tspan
+ sodipodi:role="line"
+ id="tspan2421"
+ x="29.111408"
+ y="183.02223">Qt 4.5</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#1c2d0f;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="29.111408"
+ y="198.68694"
+ id="text2423"><tspan
+ sodipodi:role="line"
+ id="tspan2425"
+ x="29.111408"
+ y="198.68694">4.5</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#1c2d0f;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="29.111408"
+ y="214.22688"
+ id="text2427"><tspan
+ sodipodi:role="line"
+ id="tspan2429"
+ x="29.111408"
+ y="214.22688">headers and libraries - compile-time and run-time</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#1c2d0f;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="29.111408"
+ y="224.19267"
+ id="text2431"><tspan
+ sodipodi:role="line"
+ id="tspan2433"
+ x="29.111408"
+ y="224.19267">GNU General Public License v3 /</tspan><tspan
+ id="tspan2472"
+ sodipodi:role="line"
+ x="29.111408"
+ y="234.5208">GNU Lesser General Public Licence v2.1</tspan></text>
+ </g>
+ </g>
+ <g
+ id="g3765"
+ transform="translate(201.65125,55.15042)">
+ <rect
+ y="77.208275"
+ x="322.31384"
+ height="73.24913"
+ width="255.99348"
+ id="rect3767"
+ style="fill:#ffe052;fill-opacity:1;fill-rule:evenodd;stroke:#786200;stroke-width:0.93250537;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ ry="10.318988"
+ rx="8.598484" />
+ <g
+ transform="translate(4.8773009,-84.541588)"
+ id="g3769">
+ <text
+ xml:space="preserve"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#3c3100;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="181.23659"
+ id="text3771"><tspan
+ sodipodi:role="line"
+ id="tspan3773"
+ x="329.46826"
+ y="181.23659">Python</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#3c3100;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="196.90126"
+ id="text3775"><tspan
+ sodipodi:role="line"
+ id="tspan3777"
+ x="329.46826"
+ y="196.90126">2.6</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#3c3100;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="212.44124"
+ id="text3779"><tspan
+ sodipodi:role="line"
+ x="329.46826"
+ y="212.44124"
+ id="tspan3781">Headers and libraries - compile-time and run-time</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#3c3100;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="329.46826"
+ y="227.76418"
+ id="text3783"><tspan
+ sodipodi:role="line"
+ id="tspan3785"
+ x="329.46826"
+ y="227.76418">Python license</tspan></text>
+ </g>
+ </g>
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.77180147px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-end:none;stroke-opacity:1"
+ d="M 651.96184,131.80908 L 651.96184,84.6273"
+ id="path3787"
+ inkscape:connector-type="polyline" />
+ </g>
+ </g>
+</svg>
diff --git a/sources/shiboken2/doc/dependency-pyside.svg b/sources/shiboken2/doc/dependency-pyside.svg
new file mode 100644
index 000000000..786bdb8a6
--- /dev/null
+++ b/sources/shiboken2/doc/dependency-pyside.svg
@@ -0,0 +1,527 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="900"
+ height="560"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="dependency-pyside.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="/tmp/dependency-pyside.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="Arrow1Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lstart"
+ style="overflow:visible">
+ <path
+ id="path3270"
+ d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(0.8,0,0,0.8,10,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend"
+ style="overflow:visible">
+ <path
+ id="path3679"
+ d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.79440331"
+ inkscape:cx="-36.66006"
+ inkscape:cy="372.04724"
+ inkscape:document-units="px"
+ inkscape:current-layer="svg2"
+ showgrid="false"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1278"
+ inkscape:window-height="949"
+ inkscape:window-x="0"
+ inkscape:window-y="0">
+ <sodipodi:guide
+ orientation="1,0"
+ position="384.28571,590"
+ id="guide2601" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="678.57143,491.42857"
+ id="guide2603" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="78.571429,257.14286"
+ id="guide2605" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="93.571429,280.71429"
+ id="guide7565" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="148.57143,216.42857"
+ id="guide7567" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-78.088635,-190.95252)" />
+ <g
+ id="g5394"
+ transform="translate(6.1314759,14.304617)">
+ <g
+ transform="translate(-65.84289,-190.95252)"
+ id="g5205">
+ <g
+ id="g5171">
+ <rect
+ rx="9.3643799"
+ y="338.7739"
+ x="678.57141"
+ height="73.281754"
+ width="274.54263"
+ id="rect2393"
+ style="fill:#aaeeff;fill-rule:evenodd;stroke:#006078;stroke-width:0.96620417px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ ry="13.104657" />
+ <text
+ id="text2395"
+ y="355.93701"
+ x="683.46539"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="355.93701"
+ x="683.46539"
+ id="tspan2397"
+ sodipodi:role="line">boost::python</tspan></text>
+ <text
+ id="text2399"
+ y="371.60172"
+ x="683.46539"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="371.60172"
+ x="683.46539"
+ id="tspan2401"
+ sodipodi:role="line">1.38.0</tspan></text>
+ <text
+ id="text2403"
+ y="387.14166"
+ x="683.46539"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ id="tspan2435"
+ y="387.14166"
+ x="683.46539"
+ sodipodi:role="line">headers and libraries - compile-time and run-time</tspan></text>
+ <text
+ id="text2413"
+ y="402.4646"
+ x="683.46539"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="402.4646"
+ x="683.46539"
+ id="tspan2415"
+ sodipodi:role="line">Boost Software License 1.0</tspan></text>
+ </g>
+ <g
+ id="g5193">
+ <rect
+ rx="8.3239012"
+ y="342.86383"
+ x="78.571426"
+ height="73.282379"
+ width="274.18781"
+ id="rect2417"
+ style="fill:#b3ff80;fill-rule:evenodd;stroke:#2a7800;stroke-width:0.96558368px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ ry="9.2689295" />
+ <text
+ id="text2419"
+ y="359.67014"
+ x="88.822823"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="359.67014"
+ x="88.822823"
+ id="tspan2421"
+ sodipodi:role="line">Qt 4.5</tspan></text>
+ <text
+ id="text2423"
+ y="375.33484"
+ x="88.822823"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="375.33484"
+ x="88.822823"
+ id="tspan2425"
+ sodipodi:role="line">4.5</tspan></text>
+ <text
+ id="text2427"
+ y="390.87479"
+ x="88.822823"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="390.87479"
+ x="88.822823"
+ id="tspan2429"
+ sodipodi:role="line">headers and libraries - compile-time and run-time</tspan></text>
+ <text
+ id="text2431"
+ y="400.84058"
+ x="88.822823"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="400.84058"
+ x="88.822823"
+ id="tspan2433"
+ sodipodi:role="line">GNU General Public License v3 /</tspan><tspan
+ y="411.1687"
+ x="88.822823"
+ sodipodi:role="line"
+ id="tspan2472">GNU Lesser General Public Licence v2.1</tspan></text>
+ </g>
+ <g
+ id="g5120">
+ <rect
+ y="496.43558"
+ x="384.28571"
+ height="73.281754"
+ width="274.54263"
+ id="rect2441"
+ style="fill:#e9ddaf;fill-rule:evenodd;stroke:#5f5019;stroke-width:0.96620417px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ ry="13.104635"
+ rx="10.404889" />
+ <text
+ id="text2443"
+ y="513.59869"
+ x="389.17969"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="513.59869"
+ x="389.17969"
+ id="tspan2445"
+ sodipodi:role="line">libapiextractor</tspan></text>
+ <text
+ id="text2447"
+ y="529.26337"
+ x="389.17969"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="529.26337"
+ x="389.17969"
+ id="tspan2449"
+ sodipodi:role="line">0.1</tspan></text>
+ <text
+ id="text2451"
+ y="544.80334"
+ x="389.17969"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ id="tspan2453"
+ y="544.80334"
+ x="389.17969"
+ sodipodi:role="line">headers and libraries - compile-time and run-time</tspan></text>
+ <text
+ id="text2455"
+ y="560.12628"
+ x="389.17969"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="560.12628"
+ x="389.17969"
+ id="tspan2457"
+ sodipodi:role="line">LGPL version 2.1</tspan></text>
+ </g>
+ <g
+ id="g5131">
+ <rect
+ y="340.72134"
+ x="384.28571"
+ height="73.281754"
+ width="274.54263"
+ id="rect2459"
+ style="fill:#e9ddaf;fill-rule:evenodd;stroke:#5f5019;stroke-width:0.96620417px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ ry="10.309408"
+ rx="9.3644047" />
+ <text
+ id="text2461"
+ y="357.88449"
+ x="389.17969"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="357.88449"
+ x="389.17969"
+ id="tspan2463"
+ sodipodi:role="line">BoostPythonGenerator</tspan></text>
+ <text
+ id="text2465"
+ y="373.54916"
+ x="389.17969"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="373.54916"
+ x="389.17969"
+ id="tspan2467"
+ sodipodi:role="line">0.1</tspan></text>
+ <text
+ id="text2469"
+ y="389.08914"
+ x="389.17969"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ id="tspan2471"
+ y="389.08914"
+ x="389.17969"
+ sodipodi:role="line">Binary executable - compile-time</tspan></text>
+ <text
+ id="text2473"
+ y="404.41208"
+ x="389.17969"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="404.41208"
+ x="389.17969"
+ id="tspan2475"
+ sodipodi:role="line">LGPL version 2.1</tspan></text>
+ </g>
+ <g
+ id="g5142">
+ <rect
+ y="191.43562"
+ x="384.28571"
+ height="73.281754"
+ width="274.54263"
+ id="rect2523"
+ style="fill:#e9ddaf;fill-opacity:1;fill-rule:evenodd;stroke:#5f5019;stroke-width:0.96620417px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ ry="14.285714" />
+ <text
+ id="text2525"
+ y="208.59874"
+ x="389.17966"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="208.59874"
+ x="389.17966"
+ id="tspan2527"
+ sodipodi:role="line">Qt Python bindings</tspan></text>
+ <text
+ id="text2529"
+ y="224.26344"
+ x="389.17966"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="224.26344"
+ x="389.17966"
+ id="tspan2531"
+ sodipodi:role="line">0.1</tspan></text>
+ <text
+ id="text2533"
+ y="239.80339"
+ x="389.17966"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ id="tspan2535"
+ y="239.80339"
+ x="389.17966"
+ sodipodi:role="line">Target</tspan></text>
+ <text
+ id="text2537"
+ y="255.12633"
+ x="389.17966"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="255.12633"
+ x="389.17966"
+ id="tspan2539"
+ sodipodi:role="line">LGPL version 2.1</tspan></text>
+ </g>
+ <g
+ id="g5182">
+ <rect
+ rx="10.404877"
+ y="648.57843"
+ x="384.28571"
+ height="73.281754"
+ width="274.54263"
+ id="rect2563"
+ style="fill:#aaeeff;fill-rule:evenodd;stroke:#006078;stroke-width:0.96620417px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ ry="11.287985" />
+ <text
+ id="text2565"
+ y="665.74158"
+ x="389.17969"
+ style="font-size:16.27989578px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="665.74158"
+ x="389.17969"
+ id="tspan2567"
+ sodipodi:role="line">boost::graph</tspan></text>
+ <text
+ id="text2569"
+ y="681.40625"
+ x="389.17969"
+ style="font-size:8.40044498px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="681.40625"
+ x="389.17969"
+ id="tspan2571"
+ sodipodi:role="line">1.38.0</tspan></text>
+ <text
+ id="text2573"
+ y="696.94623"
+ x="389.17969"
+ style="font-size:9.33067703px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ id="tspan2575"
+ y="696.94623"
+ x="389.17969"
+ sodipodi:role="line">headers and libraries - compile-time and run-time</tspan></text>
+ <text
+ id="text2577"
+ y="712.26917"
+ x="389.17969"
+ style="font-size:8.26250458px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="712.26917"
+ x="389.17969"
+ id="tspan2579"
+ sodipodi:role="line">Boost Software License 1.0</tspan></text>
+ </g>
+ </g>
+ <path
+ inkscape:connector-type="polyline"
+ id="path2869"
+ d="M 212.85114,151.42852 L 368.56822,74.247959"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-end:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-type="polyline"
+ id="path2871"
+ d="M 663.60462,147.33826 L 517.61788,74.247959"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-end:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-type="polyline"
+ id="path2877"
+ d="M 443.4684,149.28571 L 443.46839,74.247959"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-end:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-type="polyline"
+ id="path2879"
+ d="M 443.4684,304.99994 L 443.4684,223.53367"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-end:none;stroke-opacity:1" />
+ <path
+ inkscape:connector-type="polyline"
+ id="path2881"
+ d="M 443.4684,457.14279 L 443.4684,379.2479"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-mid:none;marker-end:none;stroke-opacity:1" />
+ <rect
+ ry="17.142857"
+ y="293.85626"
+ x="0.48279184"
+ height="124.28571"
+ width="211.42857"
+ id="rect7541"
+ style="fill:#e3e2db;stroke:#000000;stroke-opacity:1" />
+ <text
+ id="text7543"
+ y="325.44049"
+ x="70.482788"
+ style="font-size:20.61732101px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="325.44049"
+ x="70.482788"
+ id="tspan7545"
+ sodipodi:role="line">Boost</tspan></text>
+ <text
+ id="text7547"
+ y="358.37042"
+ x="70.482788"
+ style="font-size:20.61732101px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="358.37042"
+ x="70.482788"
+ id="tspan7549"
+ sodipodi:role="line">Qt Software</tspan></text>
+ <text
+ id="text7551"
+ y="394.07593"
+ x="70.482788"
+ style="font-size:20.61732101px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="394.07593"
+ x="70.482788"
+ id="tspan7553"
+ sodipodi:role="line">INdT/Nokia</tspan></text>
+ <rect
+ ry="6.4285707"
+ y="307.24911"
+ x="15.482792"
+ height="22.5"
+ width="43.163269"
+ id="rect7555"
+ style="fill:#aaeeff;fill-opacity:1;stroke:#000000;stroke-width:0.64285713;stroke-opacity:1" />
+ <rect
+ ry="6.4285707"
+ y="341.17767"
+ x="15.482792"
+ height="22.5"
+ width="43.163269"
+ id="rect7561"
+ style="fill:#b3ff80;fill-opacity:1;stroke:#000000;stroke-width:0.64285713;stroke-opacity:1" />
+ <rect
+ ry="6.4285707"
+ y="376.17767"
+ x="15.482792"
+ height="22.5"
+ width="43.163269"
+ id="rect7563"
+ style="fill:#e9ddaf;fill-opacity:1;stroke:#000000;stroke-width:0.64285713;stroke-opacity:1" />
+ </g>
+</svg>
diff --git a/sources/shiboken2/doc/faq.rst b/sources/shiboken2/doc/faq.rst
new file mode 100644
index 000000000..77e0fbdfc
--- /dev/null
+++ b/sources/shiboken2/doc/faq.rst
@@ -0,0 +1,67 @@
+**************************
+Frequently Asked Questions
+**************************
+
+This is a list of Frequently Asked Questions about |project|. Feel free to
+suggest new entries!
+
+General
+=======
+
+What is Shiboken?
+-----------------
+
+Shiboken is a `GeneratorRunner <http://www.pyside.org/home-binding/binding-generator>`_
+plugin that outputs C++ code for CPython extensions. The first version of PySide
+had source code based on Boost templates. It was easier to produce code but a
+paradigm change was needed, as the next question explains.
+
+Why did you switch from Boost.Python to Shiboken?
+-------------------------------------------------
+
+The main reason was the size reduction. Boost.Python makes excessive use of templates
+resulting in a significant increase of the binaries size. On the other hand, as Shiboken
+generates CPython code, the resulting binaries are smaller.
+
+Creating bindings
+=================
+
+Can I wrap non-Qt libraries?
+----------------------------
+
+Yes. Check Shiboken source code for an example (libsample).
+
+
+Is there any runtime dependency on the generated binding?
+---------------------------------------------------------
+
+Yes. Only libshiboken, and the obvious Python interpreter
+and the C++ library that is being wrapped.
+
+What do I have to do to create my bindings?
+-------------------------------------------
+
+.. todo: put link to typesystem documentation
+
+Most of the work is already done by the API Extractor. The developer creates
+a `typesystem <http://www.pyside.org/docs/apiextractor/typesystem.html>`_ file
+with any customization wanted in the generated code, like removing classes or
+changing method signatures. The generator will output the .h and .cpp files
+with the CPython code that will wrap the target library for python.
+
+Is there any recommended build system?
+--------------------------------------
+
+Both API Extractor and generator uses and recommends the CMake build system.
+
+Can I write closed-source bindings with the generator?
+------------------------------------------------------
+
+Yes, as long as you use a LGPL version of Qt, due to runtime requirements.
+
+What is 'inject code'?
+----------------------
+
+That's how we call customized code that will be *injected* into the
+generated at specific locations. They are specified inside the typesytem.
+
diff --git a/sources/shiboken2/doc/images/.directory b/sources/shiboken2/doc/images/.directory
new file mode 100644
index 000000000..e65475f65
--- /dev/null
+++ b/sources/shiboken2/doc/images/.directory
@@ -0,0 +1,3 @@
+[Dolphin]
+ShowPreview=true
+Timestamp=2009,5,5,17,43,26
diff --git a/sources/shiboken2/doc/images/bindinggen-development.png b/sources/shiboken2/doc/images/bindinggen-development.png
new file mode 100644
index 000000000..2dd64ba1d
--- /dev/null
+++ b/sources/shiboken2/doc/images/bindinggen-development.png
Binary files differ
diff --git a/sources/shiboken2/doc/images/bindinggen-development.svg b/sources/shiboken2/doc/images/bindinggen-development.svg
new file mode 100644
index 000000000..3b6b3a26e
--- /dev/null
+++ b/sources/shiboken2/doc/images/bindinggen-development.svg
@@ -0,0 +1,543 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="640"
+ height="200"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="bindgen-development.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="bindinggen-development.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="EmptyDiamondL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="EmptyDiamondL"
+ style="overflow:visible">
+ <path
+ id="path3930"
+ d="M 0,-7.0710768 L -7.0710894,0 L 0,7.0710589 L 7.0710462,0 L 0,-7.0710768 z"
+ style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="scale(0.8,0.8)" />
+ </marker>
+ <marker
+ inkscape:stockid="EmptyTriangleInL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="EmptyTriangleInL"
+ style="overflow:visible">
+ <path
+ id="path3975"
+ d="M 5.77,0 L -2.88,5 L -2.88,-5 L 5.77,0 z"
+ style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(-0.8,0,0,-0.8,4.8,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Sstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Sstart"
+ style="overflow:visible">
+ <path
+ id="path3835"
+ d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(0.2,0,0,0.2,1.2,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Mend"
+ style="overflow:visible">
+ <path
+ id="path3832"
+ d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Tail"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Tail"
+ style="overflow:visible">
+ <g
+ id="g3859"
+ transform="scale(-1.2,-1.2)">
+ <path
+ id="path3861"
+ d="M -3.8048674,-3.9585227 L 0.54352094,0"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ <path
+ id="path3863"
+ d="M -1.2866832,-3.9585227 L 3.0617053,0"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ <path
+ id="path3865"
+ d="M 1.3053582,-3.9585227 L 5.6537466,0"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ <path
+ id="path3867"
+ d="M -3.8048674,4.1775838 L 0.54352094,0.21974226"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ <path
+ id="path3869"
+ d="M -1.2866832,4.1775838 L 3.0617053,0.21974226"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ <path
+ id="path3871"
+ d="M 1.3053582,4.1775838 L 5.6537466,0.21974226"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ </g>
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible">
+ <path
+ id="path3636"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.97309,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.0859375"
+ inkscape:cx="320"
+ inkscape:cy="136.17463"
+ inkscape:document-units="px"
+ inkscape:current-layer="g5658"
+ showgrid="false"
+ inkscape:window-width="1156"
+ inkscape:window-height="883"
+ inkscape:window-x="1396"
+ inkscape:window-y="35"
+ showguides="true"
+ inkscape:guide-bbox="true">
+ <sodipodi:guide
+ orientation="1,0"
+ position="-557.55608,678.10875"
+ id="guide7299" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-1758.7331,-2056.8567)">
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot3229"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ transform="translate(4.1137413,-2.3429609)"><flowRegion
+ id="flowRegion3231"><rect
+ id="rect3233"
+ width="125.74072"
+ height="40.5849"
+ x="388.45547"
+ y="279.5423" /></flowRegion><flowPara
+ id="flowPara3235" /></flowRoot> <g
+ id="g5658"
+ transform="translate(6.5767925,7.0112479)">
+ <g
+ id="g5634">
+ <g
+ id="g6271"
+ transform="translate(1086.3689,746.93837)">
+ <g
+ transform="matrix(0,-1,1,0,-294.81158,2953.0504)"
+ id="g6252">
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline"
+ d="M 1586.5317,1300.2858 L 1586.6222,1389.8124"
+ id="path11089"
+ inkscape:connector-type="polyline"
+ sodipodi:nodetypes="cc" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-type="polyline"
+ id="path2758"
+ d="M 1586.7489,1389.4756 L 1594.7468,1380.3688"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-type="polyline"
+ id="path2760"
+ d="M 1586.6031,1389.5063 L 1578.6052,1380.3994"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline" />
+ </g>
+ </g>
+ </g>
+ <g
+ transform="translate(134.35978,44.472131)"
+ id="g2777">
+ <rect
+ style="fill:#addc52;fill-opacity:1;stroke:#6ca400;stroke-width:0.82399696;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect5172"
+ width="185.49777"
+ height="75.08918"
+ x="2047.775"
+ y="2029.4594"
+ ry="3.0323718"
+ rx="2.6724329" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="2140.5562"
+ y="2062.9375"
+ id="text5174"><tspan
+ sodipodi:role="line"
+ x="2140.5562"
+ y="2062.9375"
+ style="font-size:22px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+ id="tspan5176">Qt bindings</tspan><tspan
+ id="tspan6109"
+ sodipodi:role="line"
+ x="2140.5562"
+ y="2084.457"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">(generated code)</tspan></text>
+ </g>
+ <g
+ transform="translate(141.86951,-31.391207)"
+ id="g3216">
+ <rect
+ style="fill:#bff3bc;fill-opacity:1;stroke:#0af400;stroke-width:0.64492828;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect3625"
+ width="185.67708"
+ height="75.268074"
+ x="1829.1727"
+ y="2105.2332"
+ ry="2.3353095"
+ rx="2.1257713" />
+ <text
+ xml:space="preserve"
+ style="font-size:38.71272278px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="1921.9705"
+ y="2136.9409"
+ id="text3627"
+ transform="scale(1.0000266,0.9999734)"><tspan
+ id="tspan3697"
+ sodipodi:role="line"
+ x="1921.9705"
+ y="2136.9409"
+ style="font-size:21.29199791px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold">generator</tspan><tspan
+ sodipodi:role="line"
+ x="1921.9705"
+ y="2163.5559"
+ style="font-size:21.29199791px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+ id="tspan2464">front-end</tspan></text>
+ </g>
+ <g
+ id="g5641">
+ <g
+ id="g5465"
+ transform="translate(874.42628,746.93837)">
+ <g
+ transform="matrix(0,-1,1,0,-294.81158,2953.0504)"
+ id="g5467">
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline"
+ d="M 1586.5317,1300.2858 L 1586.6222,1389.8124"
+ id="path5469"
+ inkscape:connector-type="polyline"
+ sodipodi:nodetypes="cc" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-type="polyline"
+ id="path5471"
+ d="M 1586.7489,1389.4756 L 1594.7468,1380.3688"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-type="polyline"
+ id="path5473"
+ d="M 1586.6031,1389.5063 L 1578.6052,1380.3994"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline" />
+ </g>
+ </g>
+ </g>
+ <g
+ transform="translate(-194.79968,-212.08495)"
+ id="g5440">
+ <rect
+ rx="1.2158648"
+ ry="2.9911308"
+ y="2285.8806"
+ x="1953.809"
+ height="75.360634"
+ width="185.76964"
+ id="rect3166"
+ style="fill:#dfe994;fill-opacity:1;stroke:#d5f400;stroke-width:0.55236381;stroke-opacity:1" />
+ <text
+ id="text3168"
+ y="2328.8809"
+ x="2046.646"
+ style="font-size:27.94354057px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#4c5800;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ style="font-size:19.56047821px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#4c5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ y="2328.8809"
+ x="2046.646"
+ sodipodi:role="line"
+ id="tspan5424">API Extractor</tspan></text>
+ </g>
+ <g
+ transform="translate(-102.30216,-279.71223)"
+ id="g5541">
+ <path
+ sodipodi:type="arc"
+ style="fill:#f28888;fill-opacity:1;stroke:#d5f400;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:3, 3;stroke-dashoffset:0;stroke-opacity:1"
+ id="path5535"
+ sodipodi:cx="255.10791"
+ sodipodi:cy="326.69064"
+ sodipodi:rx="38.848923"
+ sodipodi:ry="38.848923"
+ d="M 293.95683,326.69064 A 38.848923,38.848923 0 1 1 216.25899,326.69064 A 38.848923,38.848923 0 1 1 293.95683,326.69064 z"
+ transform="matrix(0.4405339,0,0,0.4405339,1842.2283,2282.9708)" />
+ <text
+ xml:space="preserve"
+ style="font-size:27.62000275px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="1946.3259"
+ y="2435.7"
+ id="text5537"><tspan
+ sodipodi:role="line"
+ id="tspan5539"
+ x="1946.3259"
+ y="2435.7"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:FreeMono;-inkscape-font-specification:FreeMono Bold">1</tspan></text>
+ </g>
+ <g
+ transform="translate(52.589867,-352.69787)"
+ id="g5546">
+ <path
+ sodipodi:type="arc"
+ style="fill:#f28888;fill-opacity:1;stroke:#d5f400;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:3, 3;stroke-dashoffset:0;stroke-opacity:1"
+ id="path5548"
+ sodipodi:cx="255.10791"
+ sodipodi:cy="326.69064"
+ sodipodi:rx="38.848923"
+ sodipodi:ry="38.848923"
+ d="M 293.95683,326.69064 A 38.848923,38.848923 0 1 1 216.25899,326.69064 A 38.848923,38.848923 0 1 1 293.95683,326.69064 z"
+ transform="matrix(0.4405339,0,0,0.4405339,1842.2283,2282.9708)" />
+ <text
+ xml:space="preserve"
+ style="font-size:27.62000275px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="1946.3259"
+ y="2435.7"
+ id="text5550"><tspan
+ sodipodi:role="line"
+ id="tspan5552"
+ x="1946.3259"
+ y="2435.7"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:FreeMono;-inkscape-font-specification:FreeMono Bold">2</tspan></text>
+ </g>
+ <g
+ transform="matrix(0,-1,1,0,697.50638,3244.256)"
+ id="g5624">
+ <g
+ id="g5626"
+ transform="matrix(0,-1,1,0,-294.81158,2953.0504)">
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-type="polyline"
+ id="path5628"
+ d="M 1586.5317,1348.2858 L 1586.6222,1389.8124"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline"
+ d="M 1586.7489,1389.4756 L 1594.7468,1380.3688"
+ id="path5630"
+ inkscape:connector-type="polyline"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline"
+ d="M 1586.6031,1389.5063 L 1578.6052,1380.3994"
+ id="path5632"
+ inkscape:connector-type="polyline"
+ sodipodi:nodetypes="cc" />
+ </g>
+ </g>
+ <g
+ transform="translate(5.3442137,15.993306)"
+ id="g5459">
+ <rect
+ rx="2.4652832"
+ ry="2.9818845"
+ y="2151.3206"
+ x="1965.7682"
+ height="75.127686"
+ width="185.53668"
+ id="rect3485"
+ style="fill:#b2e994;fill-opacity:1;stroke:#56f400;stroke-width:0.78531456;stroke-opacity:1" />
+ <text
+ id="text3487"
+ y="2184.2461"
+ x="2059.1909"
+ style="font-size:27.94354057px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#1f5800;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ id="tspan2509"
+ style="font-size:19.56047821px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#1f5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ y="2184.2461"
+ x="2059.1909"
+ sodipodi:role="line">typesystem</tspan><tspan
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#1f5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ y="2205.1477"
+ x="2059.1909"
+ sodipodi:role="line"
+ id="tspan5432">(handwritten)</tspan></text>
+ </g>
+ <g
+ transform="matrix(0,-1,1,0,908.50929,3242.9612)"
+ id="g5648">
+ <g
+ id="g5650"
+ transform="matrix(0,-1,1,0,-294.81158,2953.0504)">
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-type="polyline"
+ id="path5652"
+ d="M 1586.5317,1348.2858 L 1586.6222,1389.8124"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline"
+ d="M 1586.7489,1389.4756 L 1594.7468,1380.3688"
+ id="path5654"
+ inkscape:connector-type="polyline"
+ sodipodi:nodetypes="cc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline"
+ d="M 1586.6031,1389.5063 L 1578.6052,1380.3994"
+ id="path5656"
+ inkscape:connector-type="polyline"
+ sodipodi:nodetypes="cc" />
+ </g>
+ </g>
+ <g
+ transform="translate(299.78191,21.148391)"
+ id="g2771">
+ <rect
+ style="fill:#cce994;fill-opacity:1;stroke:#a1f400;stroke-width:0.62429351;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect2733"
+ width="185.69771"
+ height="75.288704"
+ x="1882.2529"
+ y="2146.085"
+ ry="2.2607138"
+ rx="2.0576432" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#3a5800;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="1975.134"
+ y="2180.2722"
+ id="text2735"><tspan
+ sodipodi:role="line"
+ x="1975.134"
+ y="2180.2722"
+ style="font-size:22px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#3a5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+ id="tspan2737">injected code</tspan><tspan
+ id="tspan2743"
+ sodipodi:role="line"
+ x="1975.134"
+ y="2201.7917"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#3a5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">(handwritten)</tspan></text>
+ </g>
+ <g
+ transform="translate(200.4676,-222.96766)"
+ id="g5554">
+ <path
+ sodipodi:type="arc"
+ style="fill:#f28888;fill-opacity:1;stroke:#d5f400;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:3, 3;stroke-dashoffset:0;stroke-opacity:1"
+ id="path5556"
+ sodipodi:cx="255.10791"
+ sodipodi:cy="326.69064"
+ sodipodi:rx="38.848923"
+ sodipodi:ry="38.848923"
+ d="M 293.95683,326.69064 A 38.848923,38.848923 0 1 1 216.25899,326.69064 A 38.848923,38.848923 0 1 1 293.95683,326.69064 z"
+ transform="matrix(0.4405339,0,0,0.4405339,1842.2283,2282.9708)" />
+ <text
+ xml:space="preserve"
+ style="font-size:27.62000275px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="1946.3259"
+ y="2435.7"
+ id="text5558"><tspan
+ sodipodi:role="line"
+ id="tspan5560"
+ x="1946.3259"
+ y="2435.7"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:FreeMono;-inkscape-font-specification:FreeMono Bold">3</tspan></text>
+ </g>
+ <g
+ transform="translate(413.633,-206.84535)"
+ id="g5562">
+ <path
+ sodipodi:type="arc"
+ style="fill:#f28888;fill-opacity:1;stroke:#d5f400;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:3, 3;stroke-dashoffset:0;stroke-opacity:1"
+ id="path5564"
+ sodipodi:cx="255.10791"
+ sodipodi:cy="326.69064"
+ sodipodi:rx="38.848923"
+ sodipodi:ry="38.848923"
+ d="M 293.95683,326.69064 A 38.848923,38.848923 0 1 1 216.25899,326.69064 A 38.848923,38.848923 0 1 1 293.95683,326.69064 z"
+ transform="matrix(0.4405339,0,0,0.4405339,1842.2283,2282.9708)" />
+ <text
+ xml:space="preserve"
+ style="font-size:27.62000275px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="1946.3259"
+ y="2435.7"
+ id="text5566"><tspan
+ sodipodi:role="line"
+ id="tspan5568"
+ x="1946.3259"
+ y="2435.7"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:FreeMono;-inkscape-font-specification:FreeMono Bold">4</tspan></text>
+ </g>
+ </g>
+ </g>
+</svg>
diff --git a/sources/shiboken2/doc/images/boostgen.png b/sources/shiboken2/doc/images/boostgen.png
new file mode 100644
index 000000000..ae9d9fc3d
--- /dev/null
+++ b/sources/shiboken2/doc/images/boostgen.png
Binary files differ
diff --git a/sources/shiboken2/doc/images/boostqtarch.png b/sources/shiboken2/doc/images/boostqtarch.png
new file mode 100644
index 000000000..f1b145e9c
--- /dev/null
+++ b/sources/shiboken2/doc/images/boostqtarch.png
Binary files differ
diff --git a/sources/shiboken2/doc/images/boostqtarch.svg b/sources/shiboken2/doc/images/boostqtarch.svg
new file mode 100644
index 000000000..9fbb38271
--- /dev/null
+++ b/sources/shiboken2/doc/images/boostqtarch.svg
@@ -0,0 +1,226 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="350"
+ height="220"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="boostqtarch.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="boostqtarch.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible">
+ <path
+ id="path3636"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.97309,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.4812981"
+ inkscape:cx="145.70936"
+ inkscape:cy="94.089827"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1278"
+ inkscape:window-height="951"
+ inkscape:window-x="1592"
+ inkscape:window-y="29"
+ showguides="true"
+ inkscape:guide-bbox="true" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-61.076804,-301.50489)">
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot3229"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ transform="translate(2.0918751e-6,-6.0000008)"><flowRegion
+ id="flowRegion3231"><rect
+ id="rect3233"
+ width="125.74072"
+ height="40.5849"
+ x="388.45547"
+ y="279.5423" /></flowRegion><flowPara
+ id="flowPara3235" /></flowRoot> <g
+ id="g3010"
+ transform="matrix(0.9508755,0,0,0.9508755,11.317746,20.273572)">
+ <g
+ transform="translate(0,-9.7919846e-6)"
+ id="g2952">
+ <rect
+ style="fill:#dfe994;fill-opacity:1;stroke:#d5f400;stroke-width:0.7162478;stroke-opacity:1"
+ id="rect3166"
+ width="349.23203"
+ height="67.403336"
+ x="61.417336"
+ y="377.74161"
+ ry="2.6752985"
+ rx="2.285728" />
+ <text
+ xml:space="preserve"
+ style="font-size:29.38717079px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#4c5800;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="236.08904"
+ y="397.98755"
+ id="text3168"><tspan
+ sodipodi:role="line"
+ x="236.08904"
+ y="397.98755"
+ style="font-size:20.57102013px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#4c5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ id="tspan3176">Boost::Python</tspan><tspan
+ sodipodi:role="line"
+ x="236.08904"
+ y="418.35535"
+ style="font-size:15.20761585px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#4c5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ id="tspan2880">helper library to interface with CPython API</tspan><tspan
+ id="tspan2922"
+ sodipodi:role="line"
+ x="236.08904"
+ y="437.36487"
+ style="font-size:15.20761585px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#4c5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">and expose C++ entities to Python</tspan></text>
+ </g>
+ <g
+ transform="translate(0,-9.7025776e-6)"
+ id="g2959">
+ <rect
+ style="fill:#addc52;fill-opacity:1;stroke:#6ca400;stroke-width:0.71624762;stroke-opacity:1"
+ id="rect3542"
+ width="349.23203"
+ height="67.403351"
+ x="61.417336"
+ y="301.84543"
+ ry="2.675298"
+ rx="2.285728" />
+ <text
+ xml:space="preserve"
+ style="font-size:29.38717079px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#050800;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="236.5123"
+ y="322.09137"
+ id="text3544"><tspan
+ id="tspan3596"
+ sodipodi:role="line"
+ x="236.5123"
+ y="322.09137"
+ style="font-size:20.57102013px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">Qt-Python Bindings</tspan><tspan
+ sodipodi:role="line"
+ x="236.5123"
+ y="342.45917"
+ style="font-size:15.20761585px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ id="tspan12937">Qt classes and functions</tspan><tspan
+ sodipodi:role="line"
+ x="236.5123"
+ y="361.46869"
+ style="font-size:15.20761585px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ id="tspan2411">exported to Python</tspan></text>
+ </g>
+ <g
+ id="g2998">
+ <g
+ id="g2986">
+ <rect
+ rx="2.285728"
+ ry="2.675298"
+ y="453.63776"
+ x="61.417336"
+ height="67.403336"
+ width="172.02341"
+ id="rect3485"
+ style="fill:#b2e994;fill-opacity:1;stroke:#56f400;stroke-width:0.71624762;stroke-opacity:1" />
+ <text
+ id="text3487"
+ y="482.29712"
+ x="147.73038"
+ style="font-size:29.38717079px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#1f5800;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ style="font-size:20.57102013px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#1f5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ y="482.29712"
+ x="147.73038"
+ sodipodi:role="line"
+ id="tspan3499">CPython</tspan><tspan
+ id="tspan2509"
+ style="font-size:20.57102013px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#1f5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ y="508.01089"
+ x="147.73038"
+ sodipodi:role="line">API</tspan></text>
+ </g>
+ <g
+ id="g2992">
+ <rect
+ rx="2.285728"
+ ry="2.675298"
+ y="453.63776"
+ x="239.30101"
+ height="67.403351"
+ width="172.02295"
+ id="rect2459"
+ style="fill:#cce994;fill-opacity:1;stroke:#a1f400;stroke-width:0.71624762;stroke-opacity:1" />
+ <text
+ id="text2461"
+ y="481.97067"
+ x="324.86047"
+ style="font-size:29.38717079px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#3a5800;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ style="font-size:20.57102013px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#3a5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ y="481.97067"
+ x="324.86047"
+ sodipodi:role="line"
+ id="tspan2467">Qt4</tspan><tspan
+ id="tspan2490"
+ style="font-size:20.57102013px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#3a5800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ y="507.68445"
+ x="324.86047"
+ sodipodi:role="line">Libraries</tspan></text>
+ </g>
+ </g>
+ </g>
+ </g>
+</svg>
diff --git a/sources/shiboken2/doc/images/converter.dot b/sources/shiboken2/doc/images/converter.dot
new file mode 100644
index 000000000..412341df9
--- /dev/null
+++ b/sources/shiboken2/doc/images/converter.dot
@@ -0,0 +1,14 @@
+digraph Conversions {
+ rankdir=LR
+ CppType1 [ label="C++\nType" ]
+ Converter1 [ label="Converter\nPython -> C++", shape=hexagon ]
+ PythonType1 -> Converter1
+ PythonType2 -> Converter1
+ PythonType3 -> Converter1
+ Converter1 -> CppType1
+
+ CppType2 [ label="C++\nType" ]
+ PythonType4 [ label="PythonType" ]
+ Converter2 [ label="Converter\nPython -> C++", shape=hexagon ]
+ CppType2 -> Converter2 -> PythonType4
+} \ No newline at end of file
diff --git a/sources/shiboken2/doc/images/converter.png b/sources/shiboken2/doc/images/converter.png
new file mode 100644
index 000000000..51cd2af71
--- /dev/null
+++ b/sources/shiboken2/doc/images/converter.png
Binary files differ
diff --git a/sources/shiboken2/doc/images/genrunnerarch.png b/sources/shiboken2/doc/images/genrunnerarch.png
new file mode 100644
index 000000000..db1077cd0
--- /dev/null
+++ b/sources/shiboken2/doc/images/genrunnerarch.png
Binary files differ
diff --git a/sources/shiboken2/doc/images/genrunnerarch.svg b/sources/shiboken2/doc/images/genrunnerarch.svg
new file mode 100644
index 000000000..ea7eb73e7
--- /dev/null
+++ b/sources/shiboken2/doc/images/genrunnerarch.svg
@@ -0,0 +1,654 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="980"
+ height="380"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.47pre4 r22446"
+ version="1.0"
+ sodipodi:docname="genrunnerarch.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="genrunnerarch.png"
+ inkscape:export-xdpi="56.549999"
+ inkscape:export-ydpi="56.549999">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="EmptyDiamondL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="EmptyDiamondL"
+ style="overflow:visible">
+ <path
+ id="path3930"
+ d="M 0,-7.0710768 -7.0710894,0 0,7.0710589 7.0710462,0 0,-7.0710768 z"
+ style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="scale(0.8,0.8)" />
+ </marker>
+ <marker
+ inkscape:stockid="EmptyTriangleInL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="EmptyTriangleInL"
+ style="overflow:visible">
+ <path
+ id="path3975"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(-0.8,0,0,-0.8,4.8,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Sstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Sstart"
+ style="overflow:visible">
+ <path
+ id="path3835"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(0.2,0,0,0.2,1.2,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Mend"
+ style="overflow:visible">
+ <path
+ id="path3832"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Tail"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Tail"
+ style="overflow:visible">
+ <g
+ id="g3859"
+ transform="scale(-1.2,-1.2)">
+ <path
+ id="path3861"
+ d="M -3.8048674,-3.9585227 0.54352094,0"
+ style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ <path
+ id="path3863"
+ d="M -1.2866832,-3.9585227 3.0617053,0"
+ style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ <path
+ id="path3865"
+ d="M 1.3053582,-3.9585227 5.6537466,0"
+ style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ <path
+ id="path3867"
+ d="M -3.8048674,4.1775838 0.54352094,0.21974226"
+ style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ <path
+ id="path3869"
+ d="M -1.2866832,4.1775838 3.0617053,0.21974226"
+ style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ <path
+ id="path3871"
+ d="M 1.3053582,4.1775838 5.6537466,0.21974226"
+ style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;marker-start:none;marker-end:none" />
+ </g>
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible">
+ <path
+ id="path3636"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <inkscape:perspective
+ id="perspective3033"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3881"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3915"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3956"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective5100"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective5322"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective5365"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective5391"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <marker
+ inkscape:stockid="EmptyTriangleInL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="EmptyTriangleInL-4"
+ style="overflow:visible">
+ <path
+ id="path3975-9"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(-0.8,0,0,-0.8,4.8,0)" />
+ </marker>
+ <inkscape:perspective
+ id="perspective5621"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective5643"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <marker
+ inkscape:stockid="EmptyDiamondL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="EmptyDiamondL-7"
+ style="overflow:visible">
+ <path
+ id="path3930-7"
+ d="M 0,-7.0710768 -7.0710894,0 0,7.0710589 7.0710462,0 0,-7.0710768 z"
+ style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="scale(0.8,0.8)" />
+ </marker>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.0716799"
+ inkscape:cx="460.27913"
+ inkscape:cy="148.01364"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1862"
+ inkscape:window-height="1019"
+ inkscape:window-x="20"
+ inkscape:window-y="89"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(472.44407,-697.53823)">
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot3229"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ transform="translate(2.0918751e-6,-6.0000008)"><flowRegion
+ id="flowRegion3231"><rect
+ id="rect3233"
+ width="125.74072"
+ height="40.5849"
+ x="388.45547"
+ y="279.5423" /></flowRegion><flowPara
+ id="flowPara3235" /></flowRoot> <g
+ id="g5867"
+ transform="translate(6.7062969,-7.6922472)">
+ <rect
+ rx="3.4968286"
+ ry="5.2462597"
+ y="713.31403"
+ x="-472.05276"
+ height="363.61459"
+ width="393.78473"
+ id="rect3609"
+ style="fill:#e4fae3;fill-opacity:0.65882353;stroke:#8eff89;stroke-width:0.78260708;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <text
+ transform="scale(1.0000266,0.9999734)"
+ id="text3601"
+ y="742.43872"
+ x="-275.16165"
+ style="font-size:38.71272278px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ id="tspan3605"
+ style="font-size:27.09890556px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ y="742.43872"
+ x="-275.16165"
+ sodipodi:role="line"><tspan
+ id="tspan2508"
+ style="font-weight:bold">API Extractor</tspan></tspan></text>
+ <g
+ transform="matrix(0.9678438,0,0,0.9677923,-587.62742,-106.48682)"
+ id="g3763">
+ <rect
+ style="fill:#bff3bc;fill-opacity:1;stroke:#0af400;stroke-width:0.79775763;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="rect3737"
+ width="244.82956"
+ height="101.59812"
+ x="267.06232"
+ y="905.13727"
+ ry="3.1522403"
+ rx="2.4096873" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="389.39117"
+ y="931.86993"
+ id="text3739"><tspan
+ sodipodi:role="line"
+ x="389.39117"
+ y="931.86993"
+ style="font-size:22px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+ id="tspan3741">ApiExtractor</tspan><tspan
+ id="tspan2523"
+ sodipodi:role="line"
+ x="389.39117"
+ y="953.38947"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">commands the parsing and</tspan><tspan
+ id="tspan2517"
+ sodipodi:role="line"
+ x="389.39117"
+ y="973.38947"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">building of the data model</tspan><tspan
+ id="tspan2519"
+ sodipodi:role="line"
+ x="389.39117"
+ y="993.38947"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">and calls the user generators</tspan></text>
+ </g>
+ <rect
+ rx="2.1814992"
+ ry="5.2485871"
+ y="713.45312"
+ x="219.72128"
+ height="363.77597"
+ width="274.11292"
+ id="rect9190"
+ style="fill:#b8d1f1;fill-opacity:0.51184836;stroke:#0045a4;stroke-width:0.6182732;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <text
+ transform="scale(1.0000266,0.9999734)"
+ id="text9192"
+ y="742.66901"
+ x="357.65579"
+ style="font-size:38.71272278px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#002e7a;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ id="tspan9194"
+ style="font-size:27.09890556px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#002e7a;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ y="742.66901"
+ x="357.65579"
+ sodipodi:role="line"><tspan
+ id="tspan2512"
+ style="font-weight:bold;fill:#002e7a;fill-opacity:1">front-end</tspan><tspan
+ id="tspan2514"
+ style="font-size:22px;fill:#002e7a;fill-opacity:1" /></tspan></text>
+ <rect
+ rx="2.2192271"
+ ry="5.2485123"
+ y="713.23639"
+ x="-68.659073"
+ height="363.77075"
+ width="278.85358"
+ id="rect9190-9"
+ style="fill:#cbe990;fill-opacity:0.51184836;stroke:#6ca400;stroke-width:0.62359226;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <text
+ transform="scale(1.0000266,0.9999734)"
+ id="text9192-3"
+ y="741.71094"
+ x="70.291061"
+ style="font-size:38.71272278px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#050800;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ id="tspan9194-7"
+ style="font-size:26px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ y="741.71094"
+ x="70.291061"
+ sodipodi:role="line">Generator Runner</tspan></text>
+ <g
+ transform="matrix(0.9678438,0,0,0.9677923,-687.04869,-241.74888)"
+ id="g9234-4">
+ <rect
+ style="fill:#addc52;fill-opacity:1;stroke:#6ca400;stroke-width:0.73640609;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="rect9206-4"
+ width="218.17299"
+ height="83.517967"
+ x="694.6994"
+ y="1044.8701"
+ ry="2.5912752"
+ rx="2.4978092" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="803.78589"
+ y="1072.3693"
+ id="text9208-3"><tspan
+ sodipodi:role="line"
+ x="803.78589"
+ y="1072.3693"
+ style="font-size:22px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+ id="tspan9210-0">Generator</tspan><tspan
+ id="tspan9222-8"
+ sodipodi:role="line"
+ x="803.78589"
+ y="1093.8888"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">base class for front-end</tspan><tspan
+ id="tspan3946"
+ sodipodi:role="line"
+ x="803.78589"
+ y="1113.8888"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">output classes</tspan></text>
+ </g>
+ <g
+ transform="matrix(0.9678438,0,0,0.9677923,-726.09128,-46.791689)"
+ id="g10497-6">
+ <rect
+ style="fill:#89b3e7;fill-opacity:1;stroke:#0049a4;stroke-width:1.04736876;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="rect10444-8"
+ width="256.05252"
+ height="143.95157"
+ x="990.81482"
+ y="843.58032"
+ ry="4.4663219"
+ rx="2.9314826" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#002758;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="1118.0945"
+ y="873.04047"
+ id="text10446-8"><tspan
+ sodipodi:role="line"
+ x="1118.0945"
+ y="873.04047"
+ style="font-size:22px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#002758;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+ id="tspan10448-4">SpecificGenerator</tspan><tspan
+ id="tspan4063"
+ sodipodi:role="line"
+ x="1118.0945"
+ y="894.56"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#002758;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">generators written for any</tspan><tspan
+ id="tspan5381"
+ sodipodi:role="line"
+ x="1118.0945"
+ y="914.56"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#002758;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">desired output,</tspan><tspan
+ id="tspan4065"
+ sodipodi:role="line"
+ x="1118.0945"
+ y="934.56"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#002758;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"> e.g.: HppGenerator,</tspan><tspan
+ id="tspan4071"
+ sodipodi:role="line"
+ x="1118.0945"
+ y="954.56"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#002758;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">CppGenerator,</tspan><tspan
+ id="tspan4073"
+ sodipodi:role="line"
+ x="1118.0945"
+ y="974.56"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#002758;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">ConverterGenerator</tspan></text>
+ </g>
+ <path
+ sodipodi:nodetypes="cc"
+ transform="translate(109.91989,748.26874)"
+ id="path4056"
+ d="m -201.98482,41.728896 76.97065,5e-6"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:6, 1;stroke-dashoffset:0" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path4056-2"
+ d="m 197.04022,787.89746 35.38656,0"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-start:url(#EmptyTriangleInL)" />
+ <g
+ transform="matrix(0.9678438,0,0,0.9677923,-1010.4541,91.401187)"
+ id="g10497">
+ <rect
+ style="fill:#addc52;fill-opacity:1;stroke:#6ca400;stroke-width:0.88060772;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="rect10444"
+ width="256.21927"
+ height="101.69494"
+ x="990.73145"
+ y="843.49695"
+ ry="3.1552441"
+ rx="2.9333918" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;text-align:start;text-anchor:start;fill:#035800;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="1012.22"
+ y="870.08466"
+ id="text10446"><tspan
+ sodipodi:role="line"
+ x="1012.22"
+ y="870.08466"
+ style="font-size:22px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;text-anchor:start;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+ id="tspan10448">Generator App</tspan><tspan
+ id="tspan10456"
+ sodipodi:role="line"
+ x="1012.22"
+ y="891.60419"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;text-anchor:start;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">* loads generators</tspan><tspan
+ id="tspan5353"
+ sodipodi:role="line"
+ x="1012.22"
+ y="911.60419"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;text-anchor:start;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">* setup API Extractor</tspan><tspan
+ id="tspan5355"
+ sodipodi:role="line"
+ x="1012.22"
+ y="931.60419"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;text-anchor:start;fill:#050800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">* executes each generator</tspan></text>
+ </g>
+ <path
+ sodipodi:nodetypes="cc"
+ id="path4056-9"
+ d="m 72.409302,850.57374 0,56.99122"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:6, 1;stroke-dashoffset:0" />
+ <path
+ sodipodi:nodetypes="ccc"
+ id="path4056-2-0"
+ d="m -86.437722,825.54499 52.188784,0 0.06367,81.67009"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-start:url(#EmptyDiamondL)" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path4056-91"
+ d="m -394.83596,853.70064 0,121.42437"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:6, 1;stroke-dashoffset:0" />
+ <g
+ transform="matrix(0.9678438,0,0,0.9677923,-707.18032,-153.53291)"
+ id="g3809">
+ <rect
+ style="fill:#bff3bc;fill-opacity:1;stroke:#0af400;stroke-width:1.00168562;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="rect3785"
+ width="332.48172"
+ height="82.830231"
+ x="302.83319"
+ y="1068.9153"
+ ry="3.1461167"
+ rx="3.8065021" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="469.03497"
+ y="1095.5493"
+ id="text3787"><tspan
+ id="tspan3791"
+ sodipodi:role="line"
+ x="469.03497"
+ y="1095.5493"
+ style="font-size:22px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold">AbstractMetaBuilder</tspan><tspan
+ sodipodi:role="line"
+ x="469.03497"
+ y="1117.0688"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ id="tspan3807">builds the data model with information</tspan><tspan
+ id="tspan2545"
+ sodipodi:role="line"
+ x="469.03497"
+ y="1137.0688"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">from headers and binding directives</tspan><tspan
+ id="tspan3795"
+ sodipodi:role="line"
+ x="469.03497"
+ y="1157.0688"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans" /></text>
+ </g>
+ <g
+ transform="matrix(0.9678438,0,0,0.9677923,-755.89347,194.37862)"
+ id="g3709">
+ <rect
+ style="fill:#bff3bc;fill-opacity:1;stroke:#0af400;stroke-width:0.69825613;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="rect2821"
+ width="198.90968"
+ height="93.892342"
+ x="305.2475"
+ y="807.38849"
+ ry="2.6812849"
+ rx="2.1703238" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="405.17499"
+ y="831.81903"
+ id="text3611"><tspan
+ id="tspan3687"
+ sodipodi:role="line"
+ x="405.17499"
+ y="831.81903"
+ style="font-size:22px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold">TypeDatabase</tspan><tspan
+ id="tspan5641"
+ sodipodi:role="line"
+ x="405.17499"
+ y="853.33856"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">parses typesystem</tspan><tspan
+ id="tspan3689"
+ sodipodi:role="line"
+ x="405.17499"
+ y="873.33856"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">and stores information</tspan></text>
+ </g>
+ <g
+ transform="matrix(0.9678438,0,0,0.9677923,-589.50555,-13.923919)"
+ id="g3728">
+ <rect
+ style="fill:#bff3bc;fill-opacity:1;stroke:#0af400;stroke-width:0.54871088;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="rect3625"
+ width="117.15066"
+ height="86.355225"
+ x="133.25664"
+ y="809.36938"
+ ry="2.6793056"
+ rx="1.3412292" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="191.58197"
+ y="838.75159"
+ id="text3627"><tspan
+ sodipodi:role="line"
+ x="191.58197"
+ y="838.75159"
+ style="font-size:22px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+ id="tspan3631">Parser</tspan><tspan
+ id="tspan3695"
+ sodipodi:role="line"
+ x="191.58197"
+ y="860.27112"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">parses the</tspan><tspan
+ id="tspan3697"
+ sodipodi:role="line"
+ x="191.58197"
+ y="880.27112"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;fill:#035800;fill-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">lib headers</tspan></text>
+ </g>
+ <path
+ sodipodi:nodetypes="ccc"
+ id="path4056-2-0-1"
+ d="m 197.39006,961.71122 158.27877,0 0.19429,-51.88885"
+ style="fill:none;stroke:#000000;stroke-width:1.38812411;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:8.32874408, 1.38812401;stroke-dashoffset:0;marker-start:none" />
+ </g>
+ </g>
+</svg>
diff --git a/sources/shiboken2/doc/overview.rst b/sources/shiboken2/doc/overview.rst
new file mode 100644
index 000000000..5f50610ff
--- /dev/null
+++ b/sources/shiboken2/doc/overview.rst
@@ -0,0 +1,46 @@
+.. _gen-overview:
+
+******************
+Generator Overview
+******************
+
+In a few words, the Generator is a utility that parses a collection of header and
+typesystem files, generating other files (code, documentation, etc.) as result.
+
+Creating new bindings
+=====================
+
+.. figure:: images/bindinggen-development.png
+ :scale: 80
+ :align: center
+
+ Creating new bindings
+
+Each module of the generator system has an specific role.
+
+1. Provide enough data about the classes and functions.
+2. Generate valid code, with modifications from typesystems and injected codes.
+3. Modify the API to expose the objects in a way that fits you target language best.
+4. Insert customizations where handwritten code is needed.
+
+.. figure:: images/boostqtarch.png
+ :scale: 80
+ :align: center
+
+ Runtime architecture
+
+The newly created binding will run on top of Boost.Python library which takes
+care of interfacing Python and the underlying C++ library.
+
+Handwritten inputs
+==================
+
+Creating new bindings involves creating two pieces of "code": the typesystem and
+the inject code.
+
+:typesystem: XML files that provides the developer with a tool to customize the
+ way that the generators will see the classes and functions. For
+ example, functions can be renamed, have its signature changed and
+ many other actions.
+:inject code: allows the developer to insert handwritten code where the generated
+ code is not suitable or needs some customization.
diff --git a/sources/shiboken2/doc/ownership.rst b/sources/shiboken2/doc/ownership.rst
new file mode 100644
index 000000000..69791f855
--- /dev/null
+++ b/sources/shiboken2/doc/ownership.rst
@@ -0,0 +1,153 @@
+****************
+Object ownership
+****************
+
+One of the main things a binding developer should have in mind is
+how the C++ instances lives will cope with Python's reference count.
+The last thing you want is to crash a program due to a segfault
+when your C++ instance was deleted and the
+wrapper object tries to access the invalid memory there.
+
+In this section we'll show how |project| deals with object ownership
+and parentship, taking advantage of the information provided by the
+APIExtractor.
+
+Ownership basics
+================
+
+As any python binding, |project|-based bindings uses reference counting
+to handle the life of the wrapper object (the Python object that contains the
+C++ object, do not confuse with the *wrapped* C++ object).
+When a reference count reaches zero, the wrapper is deleted by Python garbage
+collector and tries to delete the wrapped instance, but sometimes the wrapped
+C++ object is already deleted, or maybe the C++ object should not be freed after
+the Python wrapper go out of scope and die, because C++ is already taking care of
+the wrapped instance.
+
+In order to handle this, you should tell the
+generator whether the instance's ownership belongs to the binding or
+to the C++ Library. When belonging to the binding, we are sure that the C++ object
+won't be deleted by C++ code and we can call the C++ destructor when the refcount
+reaches 0. Otherwise, instances owned by C++ code can be destroyed arbitrarily,
+without notifying the Python wrapper of its destruction.
+
+Invalidating objects
+====================
+
+To prevent segfaults and double frees, the wrapper objects are invalidated.
+An invalidated can't be passed as argument or have an attributte or method accessed.
+Trying to do this will raise RuntimeError.
+
+The following situations can invalidate an object:
+
+C++ taking ownership
+--------------------
+
+ When an object is passed to a function or method that takes ownership of it, the wrapper
+ is invalidated as we can't be sure of when the object is destroyed, unless it has a
+ :ref:`virtual destructor <ownership-virt-method>` or the transfer is due to the special case
+ of :ref:`parent ownership <ownership-parent>`.
+
+ Besides being passed as argument, the callee object can have its ownership changed, like
+ the `setParent` method in Qt's `QObject`.
+
+Invalidate after use
+--------------------
+
+ Objects marked with *invalidate-after-use* in the type system description always are
+ virtual method arguments provided by a C++ originated call. They should be
+ invalidated right after the Python function returns.
+
+.. _ownership-virt-method:
+
+Objects with virtual methods
+----------------------------
+
+ A little bit of implementation details:
+ virtual methods are supported by creating a C++ class, the **shell**, that inherits
+ from the class with virtual methods, the native one, and override those methods to check if
+ any derived class in Python also override it.
+
+ If the class has a virtual destructor (and C++ classes with virtual methods should have), this
+ C++ instance invalidates the wrapper only when the overriden destructor is called.
+
+ One exception to this rule is when the object is created in C++, like in a
+ factory method. This way the wrapped object is a C++ instance of the native
+ class, not the shell one, and we cannot know when it is destroyed.
+
+.. _ownership-parent:
+
+Parent-child relationship
+=========================
+
+One special type of ownership is the parent-child relationship.
+Being a child of an object means that when the object's parent dies,
+the C++ instance also dies, so the Python references will be invalidated.
+Qt's QObject system, for example, implements this behavior, but this is valid
+for any C++ library with similar behavior.
+
+.. _ownership-parent-heuristics:
+
+Parentship heuristics
+---------------------
+
+ As the parent-child relationship is very common, |project| tries to automatically
+ infer what methods falls into the parent-child scheme, adding the extra
+ directives related to ownership.
+
+ This heuristic will be triggered when generating code for a method and:
+
+ * The function is a constructor.
+ * The argument name is `parent`.
+ * The argument type is a pointer to an object.
+
+ When triggered, the heuristic will set the argument named "parent"
+ as the parent of the object being created by the constructor.
+
+ The main focus of this process was to remove a lot of hand written code from
+ type system when binding Qt libraries. For Qt, this heuristic works in all cases,
+ but be aware that it might not when binding your own libraries.
+
+ To activate this heuristic, use the :ref:`--enable-parent-ctor-heuristic <parent-heuristic>`
+ command line switch.
+
+.. _return-value-heuristics:
+
+Return value heuristics
+-----------------------
+
+ When enabled, object returned as pointer in C++ will become child of the object on which the method
+ was called.
+
+ To activate this heuristic, use the :ref:`--enable-return-value-heuristic <return-heuristic>`
+
+Common pitfalls
+===============
+
+Not saving unowned objects references
+-------------------------------------
+
+ Sometimes when you pass an instance as argument to a method and the receiving
+ instance will need that object to live indifinitely, but will not take ownership
+ of the argument instance. In this case, you should hold a reference to the argument
+ instance.
+
+ For example, let's say that you have a renderer class that will use a source class
+ in a setSource method but will not take ownership of it. The following code is wrong,
+ because when `render` is called the `Source` object created during the call to `setSource`
+ is already destroyed.
+
+ .. code-block:: python
+
+ renderer.setModel(Source())
+ renderer.render()
+
+ To solve this, you should hold a reference to the source object, like in
+
+ .. code-block:: python
+
+ source = Source()
+ renderer.setSource(source)
+ renderer.render()
+
+
diff --git a/sources/shiboken2/doc/projectfile.rst b/sources/shiboken2/doc/projectfile.rst
new file mode 100644
index 000000000..6c9808da4
--- /dev/null
+++ b/sources/shiboken2/doc/projectfile.rst
@@ -0,0 +1,65 @@
+.. _project-file:
+
+********************
+Binding Project File
+********************
+
+Instead of directing the Generator behaviour via command line, the binding developer
+can write a text project file describing the same information, and avoid the hassle
+of a long stream of command line arguments.
+
+.. _project-file-structure:
+
+The project file structure
+==========================
+
+Here follows a comprehensive example of a generator project file.
+
+ .. code-block:: ini
+
+ [generator-project]
+ generator-set = path/to/generator/CHOICE_GENERATOR
+ header-file = DIR/global.h" />
+ typesystem-file = DIR/typesystem_for_your_binding.xml
+ output-directory location="OUTPUTDIR" />
+ include-path = path/to/library/being/wrapped/headers/1
+ include-path = path/to/library/being/wrapped/headers/2
+ typesystem-path = path/to/directory/containing/type/system/files/1
+ typesystem-path = path/to/directory/containing/type/system/files/2
+ enable-parent-ctor-heuristic
+
+
+Project file tags
+=================
+
+The generator project file tags are in direct relation to the
+:ref:`command line arguments <command-line>`. All of the current command line
+options provided by |project| were already seen on the :ref:`project-file-structure`,
+for new command line options provided by additional generator modules (e.g.: qtdoc,
+Shiboken) could also be used in the generator project file following simple conversion rules.
+
+For tags without options, just write as an empty tag without any attributes. Example:
+
+ .. code-block:: bash
+
+ --BOOLEAN-ARGUMENT
+
+becomes
+
+ .. code-block:: ini
+
+ BOOLEAN-ARGUMENT
+
+and
+
+ .. code-block:: bash
+
+ --VALUE-ARGUMENT=VALUE
+
+becomes
+
+ .. code-block:: ini
+
+ VALUE-ARGUMENT = VALUE
+
+
diff --git a/sources/shiboken2/doc/sequenceprotocol.rst b/sources/shiboken2/doc/sequenceprotocol.rst
new file mode 100644
index 000000000..587c0f95b
--- /dev/null
+++ b/sources/shiboken2/doc/sequenceprotocol.rst
@@ -0,0 +1,23 @@
+Sequence Protocol
+-----------------
+
+Support for the sequence protocol is achieved adding functions with special names, this is done using the add-function tag.
+
+The special function names are:
+
+ ============= =============================================== ==================== ===================
+ Function name Parameters Return type CPython equivalent
+ ============= =============================================== ==================== ===================
+ __len__ PyObject* self Py_ssize_t PySequence_Size
+ __getitem__ PyObject* self, Py_ssize_t _i PyObject* PySequence_GetItem
+ __setitem__ PyObject* self, Py_ssize_t _i, PyObject* _value int PySequence_SetItem
+ __contains__ PyObject* self, PyObject* _value int PySequence_Contains
+ __concat__ PyObject* self, PyObject* _other PyObject* PySequence_Concat
+ ============= =============================================== ==================== ===================
+
+You just need to inform the function name to the add-function tag, without any parameter or return type information, when you do it, |project| will create a C function with parameters and return type definied by the table above.
+
+The function needs to follow the same semantics of the *CPython equivalent* function, the only way to do it is using the :doc:`inject-code <codeinjectionsemantics>` tag.
+
+A concrete exemple how to add sequence protocol support to a class can be found on shiboken tests, more precisely in the definition of the Str class in ``tests/samplebinding/typesystem_sample.xml``.
+
diff --git a/sources/shiboken2/doc/shiboken2.1 b/sources/shiboken2/doc/shiboken2.1
new file mode 100644
index 000000000..e017bd9a9
--- /dev/null
+++ b/sources/shiboken2/doc/shiboken2.1
@@ -0,0 +1,73 @@
+.TH SHIBOKEN "1" "March 2010" "shiboken v0.2.0" "User Commands"
+.SH NAME
+shiboken \- CPython bindings generator for C++ libraries
+.SH DESCRIPTION
+.SS "Usage:"
+.IP
+shiboken [options] header\-file typesystem\-file
+.SS "General options:"
+.TP
+\fB\-\-debug\-level\fR=\fI[sparse\fR|medium|full]
+Set the debug level
+.TP
+\fB\-\-documentation\-only\fR
+Do not generates any code, just the documentation
+.TP
+\fB\-\-generatorSet\fR
+generatorSet to be used. e.g. qtdoc
+.TP
+\fB\-\-help\fR
+Display this help and exit
+.TP
+\fB\-\-include\-paths=\fR<path>[:<path>:...]
+Include paths used by the C++ parser
+.TP
+\fB\-\-license\-file\fR=\fI[licensefile]\fR
+File used for copyright headers of generated files
+.TP
+\fB\-\-no\-suppress\-warnings\fR
+Show all warnings
+.TP
+\fB\-\-output\-directory\fR=\fI[dir]\fR
+The directory where the generated files will be written
+.TP
+\fB\-\-silent\fR
+Avoid printing any message
+.TP
+\fB\-\-typesystem\-paths=\fR<path>[:<path>:...]
+Paths used when searching for typesystems
+.TP
+\fB\-\-version\fR
+Output version information and exit
+.SS "Shiboken options:"
+.TP
+\fB\-\-disable\-verbose\-error\-messages\fR
+Disable verbose error messages. Turn the python code hard to debug but safe few kB on the generated bindings.
+.TP
+\fB\-\-enable\-parent\-ctor\-heuristic\fR
+Enable heuristics to detect parent relationship on constructors.
+.TP
+\fB\-\-enable\-pyside\-extensions\fR
+Enable PySide extensions, such as support for signal/slots, use this if you are creating a binding for a Qt\-based library.
+.TP
+\fB\-\-enable\-return\-value\-heuristic\fR
+Enable heuristics to detect parent relationship on return values (USE WITH CAUTION!)
+.SS "Shiboken options:"
+.TP
+\fB\-\-disable\-verbose\-error\-messages\fR
+Disable verbose error messages. Turn the python code hard to debug but safe few kB on the generated bindings.
+.TP
+\fB\-\-enable\-parent\-ctor\-heuristic\fR
+Enable heuristics to detect parent relationship on constructors.
+.TP
+\fB\-\-enable\-pyside\-extensions\fR
+Enable PySide extensions, such as support for signal/slots, use this if you are creating a binding for a Qt\-based library.
+.TP
+\fB\-\-enable\-return\-value\-heuristic\fR
+Enable heuristics to detect parent relationship on return values (USE WITH CAUTION!)
+.SH COPYRIGHT
+Copyright \(co 2016 The Qt Company Ltd.
+.SH AUTHOR
+.PP
+This manpage was written for Debian, starting with a help2man output, by
+Didier Raboud <didier@raboud.com>, on the 26. March 2010.
diff --git a/sources/shiboken2/doc/shibokenmodule.rst b/sources/shiboken2/doc/shibokenmodule.rst
new file mode 100644
index 000000000..150998ccd
--- /dev/null
+++ b/sources/shiboken2/doc/shibokenmodule.rst
@@ -0,0 +1,79 @@
+.. module:: shiboken
+
+.. |maya| unicode:: Maya U+2122
+
+Shiboken module
+***************
+
+Functions
+^^^^^^^^^
+
+.. container:: function_list
+
+ * def :meth:`isValid<shiboken.isValid>` (obj)
+ * def :meth:`wrapInstance<shiboken.wrapInstance>` (address, type)
+ * def :meth:`getCppPointer<shiboken.getCppPointer>` (obj)
+ * def :meth:`delete<shiboken.delete>` (obj)
+ * def :meth:`isOwnedByPython<shiboken.isOwnedByPython>` (obj)
+ * def :meth:`wasCreatedByPython<shiboken.wasCreatedByPython>` (obj)
+ * def :meth:`dump<shiboken.dump>` (obj)
+
+Detailed description
+^^^^^^^^^^^^^^^^^^^^
+
+This Python module can be used to access internal information related to our
+binding technology. Access to this internal information is required to e.g.:
+integrate PySide with Qt based programs that offer Python scripting like |maya|
+or just for debug purposes.
+
+Some function description refer to "Shiboken based objects", wich means
+Python objects instances of any Python Type created using Shiboken.
+
+
+.. function:: isValid(obj)
+
+ Given a Python object, returns True if the object methods can be called
+ without an exception being thrown. A Python wrapper becomes invalid when
+ the underlying C++ object is destroyed or unreachable.
+
+.. function:: wrapInstance(address, type)
+
+ Creates a Python wrapper for a C++ object instantiated at a given memory
+ address - the returned object type will be the same given by the user.
+
+ The type must be a Shiboken type, the C++ object will not be
+ destroyed when the returned Python object reach zero references.
+
+ If the address is invalid or doesn't point to a C++ object of given type
+ the behavior is undefined.
+
+.. function:: getCppPointer(obj)
+
+ Returns a tuple of longs that contain the memory addresses of the
+ C++ instances wrapped by the given object.
+
+.. function:: delete(obj)
+
+ Deletes the C++ object wrapped by the given Python object.
+
+.. function:: isOwnedByPython(obj)
+
+ Given a Python object, returns True if Python is responsible for deleting
+ the underlying C++ object, False otherwise.
+
+ If the object was not a Shiboken based object, a TypeError is
+ thrown.
+
+.. function:: wasCreatedByPython(obj)
+
+ Returns true if the given Python object was created by Python.
+
+.. function:: dump(obj)
+
+ Returns a string with implementation-defined information about the
+ object.
+ This method should be used **only** for debug purposes by developers
+ creating their own bindings as no guarantee is provided that
+ the string format will be the same across different versions.
+
+ If the object is not a Shiboken based object, a TypeError is thrown.
diff --git a/sources/shiboken2/doc/typeconverters.rst b/sources/shiboken2/doc/typeconverters.rst
new file mode 100644
index 000000000..3779b26d7
--- /dev/null
+++ b/sources/shiboken2/doc/typeconverters.rst
@@ -0,0 +1,288 @@
+****************************
+User Defined Type Conversion
+****************************
+
+In the process of creating Python bindings of a C++ library, most of the C++ classes will have wrappers representing them in Python land. But there may be other classes that are very simple and/or have a Python type as a direct counter part. (Example: a "Complex" class, that represents complex numbers, has a Python equivalent in the "complex" type.) Such classes, instead of getting a Python wrapper, normally have conversions rules, from Python to C++ and vice-versa.
+
+ .. code-block:: c++
+
+ // C++ class
+ struct Complex {
+ Complex(double real, double imag);
+ double real() const;
+ double imag() const;
+ };
+
+ // Converting from C++ to Python using the CPython API:
+ PyObject* pyCpxObj = PyComplex_FromDoubles(complex.real(), complex.imag());
+
+ // Converting from Python to C++:
+ double real = PyComplex_RealAsDouble(pyCpxObj);
+ double imag = PyComplex_ImagAsDouble(pyCpxObj);
+ Complex cpx(real, imag);
+
+
+For the user defined conversion code to be inserted in the proper places, the "<conversion-rule>" tag must be used.
+
+ .. code-block:: xml
+
+ <primitive-type name="Complex" target-lang-api-name="PyComplex">
+ <include file-name="complex.h" location="global"/>
+
+ <conversion-rule>
+
+ <native-to-target>
+ return PyComplex_FromDoubles(%in.real(), %in.imag());
+ </native-to-target>
+
+ <target-to-native>
+ <!-- The 'check' attribute can be derived from the 'type' attribute,
+ it is defined here to test the CHECKTYPE type system variable. -->
+ <add-conversion type="PyComplex" check="%CHECKTYPE[Complex](%in)">
+ double real = PyComplex_RealAsDouble(%in);
+ double imag = PyComplex_ImagAsDouble(%in);
+ %out = %OUTTYPE(real, imag);
+ </add-conversion>
+ </target-to-native>
+
+ </conversion-rule>
+
+ </primitive-type>
+
+
+The details will be given later, but the gist of it are the tags
+`<native-to-target> <http://www.pyside.org/docs/apiextractor/typesystem_conversionrule.html#native-to-target>`_,
+which has only one conversion from C++ to Python, and
+`<target-to-native> <http://www.pyside.org/docs/apiextractor/typesystem_conversionrule.html#target-to-native>`_,
+that may define the conversion of multiple Python types to C++'s "Complex" type.
+
+.. image:: images/converter.png
+ :height: 240px
+ :align: center
+
+|project| expects the code for `<native-to-target> <http://www.pyside.org/docs/apiextractor/typesystem_conversionrule.html#native-to-target>`_,
+to directly return the Python result of the conversion, and the added conversions inside the
+`<target-to-native> <http://www.pyside.org/docs/apiextractor/typesystem_conversionrule.html#target-to-native>`_
+must attribute the Python to C++ conversion result to the :ref:`%out <out>` variable.
+
+
+Expanding on the last example, if the binding developer want a Python 2-tuple of numbers to be accepted
+by wrapped C++ functions with "Complex" arguments, an
+`<add-conversion> <http://www.pyside.org/docs/apiextractor/typesystem_conversionrule.html#add-conversion>`_
+tag and a custom check must be added. Here's how to do it:
+
+ .. code-block:: xml
+
+ <!-- Code injection at module level. -->
+ <inject-code class="native" position="beginning">
+ static bool Check2TupleOfNumbers(PyObject* pyIn) {
+ if (!PySequence_Check(pyIn) || !(PySequence_Size(pyIn) == 2))
+ return false;
+ Shiboken::AutoDecRef pyReal(PySequence_GetItem(pyIn, 0));
+ if (!SbkNumber_Check(pyReal))
+ return false;
+ Shiboken::AutoDecRef pyImag(PySequence_GetItem(pyIn, 1));
+ if (!SbkNumber_Check(pyImag))
+ return false;
+ return true;
+ }
+ </inject-code>
+
+ <primitive-type name="Complex" target-lang-api-name="PyComplex">
+ <include file-name="complex.h" location="global"/>
+
+ <conversion-rule>
+
+ <native-to-target>
+ return PyComplex_FromDoubles(%in.real(), %in.imag());
+ </native-to-target>
+
+ <target-to-native>
+
+ <add-conversion type="PyComplex">
+ double real = PyComplex_RealAsDouble(%in);
+ double imag = PyComplex_ImagAsDouble(%in);
+ %out = %OUTTYPE(real, imag);
+ </add-conversion>
+
+ <add-conversion type="PySequence" check="Check2TupleOfNumbers(%in)">
+ Shiboken::AutoDecRef pyReal(PySequence_GetItem(%in, 0));
+ Shiboken::AutoDecRef pyImag(PySequence_GetItem(%in, 1));
+ double real = %CONVERTTOCPP[double](pyReal);
+ double imag = %CONVERTTOCPP[double](pyImag);
+ %out = %OUTTYPE(real, imag);
+ </add-conversion>
+
+ </target-to-native>
+
+ </conversion-rule>
+
+ </primitive-type>
+
+
+
+.. _container_conversions:
+
+Container Conversions
+=====================
+
+Converters for
+`<container-type> <http://www.pyside.org/docs/apiextractor/typesystem_specifying_types.html#container-type>`_
+are pretty much the same as for other type, except that they make use of the type system variables
+:ref:`%INTYPE_# <intype_n>` and :ref:`%OUTTYPE_# <outtype_n>`. |project| combines the conversion code for
+containers with the conversion defined (or automatically generated) for the containees.
+
+
+ .. code-block:: xml
+
+ <container-type name="std::map" type="map">
+ <include file-name="map" location="global"/>
+
+ <conversion-rule>
+
+ <native-to-target>
+ PyObject* %out = PyDict_New();
+ %INTYPE::const_iterator it = %in.begin();
+ for (; it != %in.end(); ++it) {
+ %INTYPE_0 key = it->first;
+ %INTYPE_1 value = it->second;
+ PyDict_SetItem(%out,
+ %CONVERTTOPYTHON[%INTYPE_0](key),
+ %CONVERTTOPYTHON[%INTYPE_1](value));
+ }
+ return %out;
+ </native-to-target>
+
+ <target-to-native>
+
+ <add-conversion type="PyDict">
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+ while (PyDict_Next(%in, &amp;pos, &amp;key, &amp;value)) {
+ %OUTTYPE_0 cppKey = %CONVERTTOCPP[%OUTTYPE_0](key);
+ %OUTTYPE_1 cppValue = %CONVERTTOCPP[%OUTTYPE_1](value);
+ %out.insert(%OUTTYPE::value_type(cppKey, cppValue));
+ }
+ </add-conversion>
+
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+
+
+.. _variables_and_functions:
+
+Variables & Functions
+=====================
+
+
+.. _in:
+
+**%in**
+
+ Variable replaced by the C++ input variable.
+
+
+.. _out:
+
+**%out**
+
+ Variable replaced by the C++ output variable. Needed to convey the
+ result of a Python to C++ conversion.
+
+
+.. _intype:
+
+**%INTYPE**
+
+ Used in Python to C++ conversions. It is replaced by the name of type for
+ which the conversion is being defined. Don't use the type's name directly.
+
+
+.. _intype_n:
+
+**%INTYPE_#**
+
+ Replaced by the name of the #th type used in a container.
+
+
+.. _outtype:
+
+**%OUTTYPE**
+
+ Used in Python to C++ conversions. It is replaced by the name of type for
+ which the conversion is being defined. Don't use the type's name directly.
+
+
+.. _outtype_n:
+
+**%OUTTYPE_#**
+
+ Replaced by the name of the #th type used in a container.
+
+
+.. _checktype:
+
+**%CHECKTYPE[CPPTYPE]**
+
+ Replaced by a |project| type checking function for a Python variable.
+ The C++ type is indicated by ``CPPTYPE``.
+
+
+.. _oldconverters:
+
+Converting The Old Converters
+=============================
+
+If you use |project| for your bindings, and has defined some type conversions
+using the ``Shiboken::Converter`` template, then you must update your converters
+to the new scheme.
+
+Previously your conversion rules were declared in one line, like this:
+
+
+ .. code-block:: xml
+
+ <primitive-type name="Complex" target-lang-api-name="PyComplex">
+ <include file-name="complex.h" location="global"/>
+ <conversion-rule file="complex_conversions.h"/>
+ </primitive-type>
+
+
+And implemented in a separate C++ file, like this:
+
+
+ .. code-block:: c++
+
+ namespace Shiboken {
+ template<> struct Converter<Complex>
+ {
+ static inline bool checkType(PyObject* pyObj) {
+ return PyComplex_Check(pyObj);
+ }
+ static inline bool isConvertible(PyObject* pyObj) {
+ return PyComplex_Check(pyObj);
+ }
+ static inline PyObject* toPython(void* cppobj) {
+ return toPython(*reinterpret_cast<Complex*>(cppobj));
+ }
+ static inline PyObject* toPython(const Complex& cpx) {
+ return PyComplex_FromDoubles(cpx.real(), cpx.imag());
+ }
+ static inline Complex toCpp(PyObject* pyobj) {
+ double real = PyComplex_RealAsDouble(pyobj);
+ double imag = PyComplex_ImagAsDouble(pyobj);
+ return Complex(real, imag);
+ }
+ };
+ }
+
+
+In this case, the parts of the implementation that will be used in the new conversion-rule
+are the ones in the two last method ``static inline PyObject* toPython(const Complex& cpx)``
+and ``static inline Complex toCpp(PyObject* pyobj)``. The ``isConvertible`` method is gone,
+and the ``checkType`` is now an attribute of the
+`<add-conversion> <http://www.pyside.org/docs/apiextractor/typesystem_conversionrule.html#add-conversion>`_
+tag. Refer back to the first example in this page and you will be able to correlate the above template
+with the new scheme of conversion rule definition.
diff --git a/sources/shiboken2/doc/typesystemvariables.rst b/sources/shiboken2/doc/typesystemvariables.rst
new file mode 100644
index 000000000..205430550
--- /dev/null
+++ b/sources/shiboken2/doc/typesystemvariables.rst
@@ -0,0 +1,336 @@
+*********************
+Type System Variables
+*********************
+
+User written code can be placed in arbitrary places using the
+:doc:`inject-code <codeinjectionsemantics>` tag. To ease the binding developer
+work, the injected code can make use of special variables that will be replaced
+by the correct values. This also shields the developer from some |project|
+implementation specifics.
+
+
+.. _variables:
+
+Variables
+=========
+
+
+.. _cpp_return_argument:
+
+**%0**
+
+ Replaced by the C++ return variable of the Python method/function wrapper.
+
+
+.. _arg_number:
+
+**%#**
+
+ Replaced by the name of a C++ argument in the position indicated by ``#``.
+ The argument counting starts with ``%1``, since ``%0`` represents the return
+ variable name. If the number indicates a variable that was removed in the
+ type system description, but there is a default value for it, this value will
+ be used. Consider this example:
+
+ .. code-block:: c++
+
+ void argRemoval(int a0, int a1 = 123);
+
+
+ .. code-block:: xml
+
+ <modify-function signature="argRemoval(int, int)">
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ </modify-function>
+
+ The ``%1`` will be replaced by the C++ argument name, and ``%2`` will get the
+ value ``123``.
+
+
+.. _argument_names:
+
+**%ARGUMENT_NAMES**
+
+ Replaced by a comma separated list with the names of all C++ arguments that
+ were not removed on the type system description for the method/function. When
+ the removed argument has a default value (original or provided in the type
+ system), this value will be inserted in the argument list. If you want to remove
+ the argument so completely that it doesn't appear in any form on the
+ ``%ARGUMENT_NAMES`` replacement, don't forget to remove also its default value
+ with the `<remove-default-expression/>
+ <http://www.pyside.org/docs/apiextractor/typesystem_arguments.html#remove-default-expression>`_
+ type system tag.
+
+ Take the following method and related type system description as an example:
+
+ .. code-block:: c++
+
+ void argRemoval(int a0, Point a1 = Point(1, 2), bool a2 = true, Point a3 = Point(3, 4), int a4 = 56);
+
+
+ .. code-block:: xml
+
+ <modify-function signature="argRemoval(int, Point, bool, Point, int)">
+ <modify-argument index="2">
+ <remove-argument/>
+ <replace-default-expression with="Point(6, 9)"/>
+ </modify-argument>
+ <modify-argument index="4">
+ <remove-argument/>
+ </modify-argument>
+ </modify-function>
+
+ As seen on the XML description, the function's ``a1`` and ``a3`` arguments
+ were removed. If any ``inject-code`` for this function uses ``%ARGUMENT_NAMES``
+ the resulting list will be the equivalent of using individual argument type
+ system variables this way:
+
+ .. code-block:: c++
+
+ %1, Point(6, 9), %3, Point(3, 4), %5
+
+
+.. _arg_type:
+
+**%ARG#_TYPE**
+
+ Replaced by the type of a C++ argument in the position indicated by ``#``.
+ The argument counting starts with ``%1``, since ``%0`` represents the return
+ variable in other contexts, but ``%ARG0_TYPE`` will not translate to the
+ return type, as this is already done by the
+ :ref:`%RETURN_TYPE <return_type>` variable.
+ Example:
+
+ .. code-block:: c++
+
+ void argRemoval(int a0, int a1 = 123);
+
+
+ .. code-block:: xml
+
+ <modify-function signature="argRemoval(int, int)">
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ </modify-function>
+
+ The ``%1`` will be replaced by the C++ argument name, and ``%2`` will get the
+ value ``123``.
+
+
+.. _converttocpp:
+
+**%CONVERTTOCPP[CPPTYPE]**
+
+ Replaced by a |project| conversion call that converts a Python variable
+ to a C++ variable of the type indicated by ``CPPTYPE``.
+
+
+.. _converttopython:
+
+**%CONVERTTOPYTHON[CPPTYPE]**
+
+ Replaced by a |project| conversion call that converts a C++ variable of the
+ type indicated by ``CPPTYPE`` to the proper Python object.
+
+
+.. _isconvertible:
+
+**%ISCONVERTIBLE[CPPTYPE]**
+
+ Replaced by a |project| "isConvertible" call that checks if a Python
+ variable is convertible (via an implicit conversion or cast operator call)
+ to a C++ variable of the type indicated by ``CPPTYPE``.
+
+
+.. _checktype:
+
+**%CHECKTYPE[CPPTYPE]**
+
+ Replaced by a |project| "checkType" call that verifies if a Python
+ if of the type indicated by ``CPPTYPE``.
+
+
+.. _cppself:
+
+**%CPPSELF**
+
+ Replaced by the wrapped C++ object instance that owns the method in which the
+ code with this variable was inserted.
+
+.. _cpptype:
+
+**%CPPTYPE**
+
+ Replaced by the original name of the C++ class, without any namespace prefix,
+ that owns the method in which the code with this variable was inserted. It will
+ work on class level code injections also. Notice that ``CPPTYPE`` differs from
+ the :ref:`%TYPE <type>` variable, for this latter may be translated to the original
+ C++ class name or to the C++ wrapper class name.
+
+ Namespaces will are treated as classes, so ``CPPTYPE`` will work for them and their
+ enclosed functions as well.
+
+.. _function_name:
+
+**%FUNCTION_NAME**
+
+ Replaced by the name of a function or method.
+
+
+
+.. _py_return_argument:
+
+**%PYARG_0**
+
+ Replaced by the name of the Python return variable of the Python method/function wrapper.
+
+
+.. _pyarg:
+
+**%PYARG_#**
+
+ Similar to ``%#``, but is replaced by the Python arguments (PyObjects)
+ received by the Python wrapper method.
+
+ If used in the context of a native code injection, i.e. in a virtual method
+ override, ``%PYARG_#`` will be translated to one item of the Python tuple
+ holding the arguments that should be passed to the Python override for this
+ virtual method.
+
+ The example
+
+ .. code-block:: c++
+
+ long a = PyInt_AS_LONG(%PYARG_1);
+
+
+ is equivalent of
+
+ .. code-block:: c++
+
+ long a = PyInt_AS_LONG(PyTuple_GET_ITEM(%PYTHON_ARGUMENTS, 0));
+
+
+ The generator tries to be smart with attributions, but it will work for the
+ only simplest cases.
+
+ This example
+
+ .. code-block:: c++
+
+ Py_DECREF(%PYARG_1);
+ %PYARG_1 = PyInt_FromLong(10);
+
+
+ is equivalent of
+
+ .. code-block:: c++
+
+ Py_DECREF(PyTuple_GET_ITEM(%PYTHON_ARGUMENTS, 0));
+ PyTuple_SET_ITEM(%PYTHON_ARGUMENTS, 0, PyInt_FromLong(10));
+
+
+.. _pyself:
+
+**%PYSELF**
+
+ Replaced by the Python wrapper variable (a PyObject) representing the instance
+ bounded to the Python wrapper method which receives the custom code.
+
+
+.. _python_arguments:
+
+**%PYTHON_ARGUMENTS**
+
+ Replaced by the pointer to the Python tuple with Python objects converted from
+ the C++ arguments received on the binding override of a virtual method.
+ This tuple is the same passed as arguments to the Python method overriding the
+ C++ parent's one.
+
+
+.. _python_method_override:
+
+**%PYTHON_METHOD_OVERRIDE**
+
+ This variable is used only on :ref:`native method code injections
+ <codeinjecting_method_native>`, i.e. on the binding overrides for C++ virtual
+ methods. It is replaced by a pointer to the Python method override.
+
+
+.. _pythontypeobject:
+
+**%PYTHONTYPEOBJECT**
+
+ Replaced by the Python type object for the context in which it is inserted:
+ method or class modification.
+
+
+.. _beginallowthreads:
+
+**%BEGIN_ALLOW_THREADS**
+
+ Replaced by a thread state saving procedure.
+ Must match with a :ref:`%END_ALLOW_THREADS <endallowthreads>` variable.
+
+
+.. _endallowthreads:
+
+**%END_ALLOW_THREADS**
+
+ Replaced by a thread state restoring procedure.
+ Must match with a :ref:`%BEGIN_ALLOW_THREADS <beginallowthreads>` variable.
+
+
+.. _return_type:
+
+**%RETURN_TYPE**
+
+ Replaced by the type returned by a function or method.
+
+
+.. _type:
+
+**%TYPE**
+
+ Replaced by the name of the class to which a function belongs. May be used
+ in code injected at method or class level.
+
+
+.. _example:
+
+Example
+=======
+
+Just to illustrate the usage of the variables described in the previous
+sections, below is an excerpt from the type system description of a |project|
+test. It changes a method that received ``argc/argv`` arguments into something
+that expects a Python sequence instead.
+
+ .. code-block:: xml
+
+ <modify-function signature="overloadedMethod(int, char**)">
+ <modify-argument index="1">
+ <replace-type modified-type="PySequence" />
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int argc;
+ char** argv;
+ if (!PySequence_to_argc_argv(%PYARG_1, &amp;argc, &amp;argv)) {
+ PyErr_SetString(PyExc_TypeError, "error");
+ return 0;
+ }
+ %RETURN_TYPE foo = %CPPSELF.%FUNCTION_NAME(argc, argv);
+ %0 = %CONVERTTOPYTHON[%RETURN_TYPE](foo);
+
+ for (int i = 0; i &lt; argc; ++i)
+ delete[] argv[i];
+ delete[] argv;
+ </inject-code>
+ </modify-function>
+
diff --git a/sources/shiboken2/doc/wordsofadvice.rst b/sources/shiboken2/doc/wordsofadvice.rst
new file mode 100644
index 000000000..b66799338
--- /dev/null
+++ b/sources/shiboken2/doc/wordsofadvice.rst
@@ -0,0 +1,109 @@
+.. _words-of-advice:
+
+***************
+Words of Advice
+***************
+
+When writing or using Python bindings there is some things you must keep in mind.
+
+
+.. _duck-punching-and-virtual-methods:
+
+Duck punching and virtual methods
+=================================
+
+The combination of duck punching, the practice of altering class characteristics
+of already instantiated objects, and virtual methods of wrapped C++ classes, can
+be tricky. That was an optimistic statement.
+
+Let's see duck punching in action for educational purposes.
+
+ .. code-block:: python
+
+ import types
+ import Binding
+
+ obj = Binding.CppClass()
+
+ # CppClass has a virtual method called 'virtualMethod',
+ # but we don't like it anymore.
+ def myVirtualMethod(self_obj, arg):
+ pass
+
+ obj.virtualMethod = types.MethodType(myVirtualMethod, obj, Binding.CppClass)
+
+
+If some C++ code happens to call `CppClass::virtualMethod(...)` on the C++ object
+held by "obj" Python object, the new duck punched "virtualMethod" method will be
+properly called. That happens because the underlying C++ object is in fact an instance
+of a generated C++ class that inherits from `CppClass`, let's call it `CppClassWrapper`,
+responsible for receiving the C++ virtual method calls and finding out the proper Python
+override to which handle such a call.
+
+Now that you know this, consider the case when C++ has a factory method that gives you
+new C++ objects originated somewhere in C++-land, in opposition to the ones generated in
+Python-land by the usage of class constructors, like in the example above.
+
+Brief interruption to show what I was saying:
+
+ .. code-block:: python
+
+ import types
+ import Binding
+
+ obj = Binding.createCppClass()
+ def myVirtualMethod(self_obj, arg):
+ pass
+
+ # Punching a dead duck...
+ obj.virtualMethod = types.MethodType(myVirtualMethod, obj, Binding.CppClass)
+
+
+The `Binding.createCppClass()` factory method is just an example, C++ created objects
+can pop out for a number of other reasons. Objects created this way have a Python wrapper
+holding them as usual, but the object held is not a `CppClassWrapper`, but a regular
+`CppClass`. All virtual method calls originated in C++ will stay in C++ and never reach
+a Python virtual method overridden via duck punching.
+
+Although duck punching is an interesting Python feature, it don't mix well with wrapped
+C++ virtual methods, specially when you can't tell the origin of every single wrapped
+C++ object. In summary: don't do it!
+
+
+.. _pyside-old-style-class:
+
+Python old style classes and PySide
+===================================
+
+Because of some architectural decisions and deprecated Python types. Since PySide 1.1 old style classes are not supported with multiple inheritance.
+
+Below you can check the examples:
+
+Example with old style class:
+
+ .. code-block:: python
+
+ from PySide2 import QtCore
+
+ class MyOldStyleObject:
+ pass
+
+ class MyObject(QtCore, MyOldStyleObject):
+ pass
+
+
+this example will raise a 'TypeError' due to the limitation on PySide, to fix this you will need use the new style class:
+
+
+ .. code-block:: python
+
+ from PySide2 import QtCore
+
+ class MyOldStyleObject(object):
+ pass
+
+ class MyObject(QtCore, MyOldStyleObject):
+ pass
+
+
+All classes used for multiple inheritance with other PySide types need to have 'object' as base class.
diff --git a/sources/shiboken2/ext/sparsehash/AUTHORS b/sources/shiboken2/ext/sparsehash/AUTHORS
new file mode 100644
index 000000000..ee92be88d
--- /dev/null
+++ b/sources/shiboken2/ext/sparsehash/AUTHORS
@@ -0,0 +1,2 @@
+opensource@google.com
+
diff --git a/sources/shiboken2/ext/sparsehash/COPYING b/sources/shiboken2/ext/sparsehash/COPYING
new file mode 100644
index 000000000..e4956cfd9
--- /dev/null
+++ b/sources/shiboken2/ext/sparsehash/COPYING
@@ -0,0 +1,28 @@
+Copyright (c) 2005, Google Inc.
+All rights reserved.
+
+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 Google Inc. 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.
diff --git a/sources/shiboken2/ext/sparsehash/google/dense_hash_map b/sources/shiboken2/ext/sparsehash/google/dense_hash_map
new file mode 100644
index 000000000..09b0c4428
--- /dev/null
+++ b/sources/shiboken2/ext/sparsehash/google/dense_hash_map
@@ -0,0 +1,310 @@
+// Copyright (c) 2005, Google Inc.
+// All rights reserved.
+//
+// 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 Google Inc. 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.
+
+// ----
+// Author: Craig Silverstein
+//
+// This is just a very thin wrapper over densehashtable.h, just
+// like sgi stl's stl_hash_map is a very thin wrapper over
+// stl_hashtable. The major thing we define is operator[], because
+// we have a concept of a data_type which stl_hashtable doesn't
+// (it only has a key and a value).
+//
+// NOTE: this is exactly like sparse_hash_map.h, with the word
+// "sparse" replaced by "dense", except for the addition of
+// set_empty_key().
+//
+// YOU MUST CALL SET_EMPTY_KEY() IMMEDIATELY AFTER CONSTRUCTION.
+//
+// Otherwise your program will die in mysterious ways.
+//
+// In other respects, we adhere mostly to the STL semantics for
+// hash-map. One important exception is that insert() invalidates
+// iterators entirely. On the plus side, though, erase() doesn't
+// invalidate iterators at all, or even change the ordering of elements.
+//
+// Here are a few "power user" tips:
+//
+// 1) set_deleted_key():
+// If you want to use erase() you *must* call set_deleted_key(),
+// in addition to set_empty_key(), after construction.
+// The deleted and empty keys must differ.
+//
+// 2) resize(0):
+// When an item is deleted, its memory isn't freed right
+// away. This allows you to iterate over a hashtable,
+// and call erase(), without invalidating the iterator.
+// To force the memory to be freed, call resize(0).
+// For tr1 compatibility, this can also be called as rehash(0).
+//
+// 3) min_load_factor(0.0)
+// Setting the minimum load factor to 0.0 guarantees that
+// the hash table will never shrink.
+//
+// Guide to what kind of hash_map to use:
+// (1) dense_hash_map: fastest, uses the most memory
+// (2) sparse_hash_map: slowest, uses the least memory
+// (3) hash_map (STL): in the middle
+// Typically I use sparse_hash_map when I care about space and/or when
+// I need to save the hashtable on disk. I use hash_map otherwise. I
+// don't personally use dense_hash_set ever; some people use it for
+// small sets with lots of lookups.
+//
+// - dense_hash_map has, typically, a factor of 2 memory overhead (if your
+// data takes up X bytes, the hash_map uses X more bytes in overhead).
+// - sparse_hash_map has about 2 bits overhead per entry.
+// - sparse_hash_map can be 3-7 times slower than the others for lookup and,
+// especially, inserts. See time_hash_map.cc for details.
+//
+// See /usr/(local/)?doc/sparsehash-*/dense_hash_map.html
+// for information about how to use this class.
+
+#ifndef _DENSE_HASH_MAP_H_
+#define _DENSE_HASH_MAP_H_
+
+#include "google/sparsehash/sparseconfig.h"
+#include <stdio.h> // for FILE * in read()/write()
+#include <algorithm> // for the default template args
+#include <functional> // for equal_to
+#include <memory> // for alloc<>
+#include <utility> // for pair<>
+#include HASH_FUN_H // defined in config.h
+#include "google/sparsehash/densehashtable.h"
+
+
+_START_GOOGLE_NAMESPACE_
+
+using STL_NAMESPACE::pair;
+
+template <class Key, class T,
+ class HashFcn = SPARSEHASH_HASH<Key>, // defined in sparseconfig.h
+ class EqualKey = STL_NAMESPACE::equal_to<Key>,
+ class Alloc = STL_NAMESPACE::allocator<T> >
+class dense_hash_map {
+ private:
+ // Apparently select1st is not stl-standard, so we define our own
+ struct SelectKey {
+ const Key& operator()(const pair<const Key, T>& p) const {
+ return p.first;
+ }
+ };
+ struct SetKey {
+ void operator()(pair<const Key, T>* value, const Key& new_key) const {
+ *const_cast<Key*>(&value->first) = new_key;
+ // It would be nice to clear the rest of value here as well, in
+ // case it's taking up a lot of memory. We do this by clearing
+ // the value. This assumes T has a zero-arg constructor!
+ value->second = T();
+ }
+ };
+
+ // The actual data
+ typedef dense_hashtable<pair<const Key, T>, Key, HashFcn,
+ SelectKey, SetKey, EqualKey, Alloc> ht;
+ ht rep;
+
+ public:
+ typedef typename ht::key_type key_type;
+ typedef T data_type;
+ typedef T mapped_type;
+ typedef typename ht::value_type value_type;
+ typedef typename ht::hasher hasher;
+ typedef typename ht::key_equal key_equal;
+ typedef Alloc allocator_type;
+
+ typedef typename ht::size_type size_type;
+ typedef typename ht::difference_type difference_type;
+ typedef typename ht::pointer pointer;
+ typedef typename ht::const_pointer const_pointer;
+ typedef typename ht::reference reference;
+ typedef typename ht::const_reference const_reference;
+
+ typedef typename ht::iterator iterator;
+ typedef typename ht::const_iterator const_iterator;
+ typedef typename ht::local_iterator local_iterator;
+ typedef typename ht::const_local_iterator const_local_iterator;
+
+ // Iterator functions
+ iterator begin() { return rep.begin(); }
+ iterator end() { return rep.end(); }
+ const_iterator begin() const { return rep.begin(); }
+ const_iterator end() const { return rep.end(); }
+
+
+ // These come from tr1's unordered_map. For us, a bucket has 0 or 1 elements.
+ local_iterator begin(size_type i) { return rep.begin(i); }
+ local_iterator end(size_type i) { return rep.end(i); }
+ const_local_iterator begin(size_type i) const { return rep.begin(i); }
+ const_local_iterator end(size_type i) const { return rep.end(i); }
+
+ // Accessor functions
+ // TODO(csilvers): implement Alloc get_allocator() const;
+ hasher hash_funct() const { return rep.hash_funct(); }
+ hasher hash_function() const { return hash_funct(); }
+ key_equal key_eq() const { return rep.key_eq(); }
+
+
+ // Constructors
+ explicit dense_hash_map(size_type expected_max_items_in_table = 0,
+ const hasher& hf = hasher(),
+ const key_equal& eql = key_equal())
+ : rep(expected_max_items_in_table, hf, eql) { }
+
+ template <class InputIterator>
+ dense_hash_map(InputIterator f, InputIterator l,
+ size_type expected_max_items_in_table = 0,
+ const hasher& hf = hasher(),
+ const key_equal& eql = key_equal())
+ : rep(expected_max_items_in_table, hf, eql) {
+ rep.insert(f, l);
+ }
+ // We use the default copy constructor
+ // We use the default operator=()
+ // We use the default destructor
+
+ void clear() { rep.clear(); }
+ // This clears the hash map without resizing it down to the minimum
+ // bucket count, but rather keeps the number of buckets constant
+ void clear_no_resize() { rep.clear_no_resize(); }
+ void swap(dense_hash_map& hs) { rep.swap(hs.rep); }
+
+
+ // Functions concerning size
+ size_type size() const { return rep.size(); }
+ size_type max_size() const { return rep.max_size(); }
+ bool empty() const { return rep.empty(); }
+ size_type bucket_count() const { return rep.bucket_count(); }
+ size_type max_bucket_count() const { return rep.max_bucket_count(); }
+
+ // These are tr1 methods. bucket() is the bucket the key is or would be in.
+ size_type bucket_size(size_type i) const { return rep.bucket_size(i); }
+ size_type bucket(const key_type& key) const { return rep.bucket(key); }
+ float load_factor() const {
+ return size() * 1.0f / bucket_count();
+ }
+ float max_load_factor() const {
+ float shrink, grow;
+ rep.get_resizing_parameters(&shrink, &grow);
+ return grow;
+ }
+ void max_load_factor(float new_grow) {
+ float shrink, grow;
+ rep.get_resizing_parameters(&shrink, &grow);
+ rep.set_resizing_parameters(shrink, new_grow);
+ }
+ // These aren't tr1 methods but perhaps ought to be.
+ float min_load_factor() const {
+ float shrink, grow;
+ rep.get_resizing_parameters(&shrink, &grow);
+ return shrink;
+ }
+ void min_load_factor(float new_shrink) {
+ float shrink, grow;
+ rep.get_resizing_parameters(&shrink, &grow);
+ rep.set_resizing_parameters(new_shrink, grow);
+ }
+ // Deprecated; use min_load_factor() or max_load_factor() instead.
+ void set_resizing_parameters(float shrink, float grow) {
+ return rep.set_resizing_parameters(shrink, grow);
+ }
+
+ void resize(size_type hint) { rep.resize(hint); }
+ void rehash(size_type hint) { resize(hint); } // the tr1 name
+
+ // Lookup routines
+ iterator find(const key_type& key) { return rep.find(key); }
+ const_iterator find(const key_type& key) const { return rep.find(key); }
+
+ data_type& operator[](const key_type& key) { // This is our value-add!
+ iterator it = find(key);
+ if (it != end()) {
+ return it->second;
+ } else {
+ return insert(value_type(key, data_type())).first->second;
+ }
+ }
+
+ size_type count(const key_type& key) const { return rep.count(key); }
+
+ pair<iterator, iterator> equal_range(const key_type& key) {
+ return rep.equal_range(key);
+ }
+ pair<const_iterator, const_iterator> equal_range(const key_type& key) const {
+ return rep.equal_range(key);
+ }
+
+ // Insertion routines
+ pair<iterator, bool> insert(const value_type& obj) { return rep.insert(obj); }
+ template <class InputIterator>
+ void insert(InputIterator f, InputIterator l) { rep.insert(f, l); }
+ void insert(const_iterator f, const_iterator l) { rep.insert(f, l); }
+ // required for std::insert_iterator; the passed-in iterator is ignored
+ iterator insert(iterator, const value_type& obj) { return insert(obj).first; }
+
+
+ // Deletion and empty routines
+ // THESE ARE NON-STANDARD! I make you specify an "impossible" key
+ // value to identify deleted and empty buckets. You can change the
+ // deleted key as time goes on, or get rid of it entirely to be insert-only.
+ void set_empty_key(const key_type& key) { // YOU MUST CALL THIS!
+ rep.set_empty_key(value_type(key, data_type())); // rep wants a value
+ }
+ void set_deleted_key(const key_type& key) {
+ rep.set_deleted_key(key);
+ }
+ void clear_deleted_key() { rep.clear_deleted_key(); }
+
+ // These are standard
+ size_type erase(const key_type& key) { return rep.erase(key); }
+ void erase(iterator it) { rep.erase(it); }
+ void erase(iterator f, iterator l) { rep.erase(f, l); }
+
+
+ // Comparison
+ bool operator==(const dense_hash_map& hs) const { return rep == hs.rep; }
+ bool operator!=(const dense_hash_map& hs) const { return rep != hs.rep; }
+
+
+ // I/O -- this is an add-on for writing metainformation to disk
+ bool write_metadata(FILE *fp) { return rep.write_metadata(fp); }
+ bool read_metadata(FILE *fp) { return rep.read_metadata(fp); }
+ bool write_nopointer_data(FILE *fp) { return rep.write_nopointer_data(fp); }
+ bool read_nopointer_data(FILE *fp) { return rep.read_nopointer_data(fp); }
+};
+
+// We need a global swap as well
+template <class Key, class T, class HashFcn, class EqualKey, class Alloc>
+inline void swap(dense_hash_map<Key, T, HashFcn, EqualKey, Alloc>& hm1,
+ dense_hash_map<Key, T, HashFcn, EqualKey, Alloc>& hm2) {
+ hm1.swap(hm2);
+}
+
+_END_GOOGLE_NAMESPACE_
+
+#endif /* _DENSE_HASH_MAP_H_ */
diff --git a/sources/shiboken2/ext/sparsehash/google/dense_hash_set b/sources/shiboken2/ext/sparsehash/google/dense_hash_set
new file mode 100644
index 000000000..faa21dc59
--- /dev/null
+++ b/sources/shiboken2/ext/sparsehash/google/dense_hash_set
@@ -0,0 +1,287 @@
+// Copyright (c) 2005, Google Inc.
+// All rights reserved.
+//
+// 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 Google Inc. 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.
+
+// ---
+// Author: Craig Silverstein
+//
+// This is just a very thin wrapper over densehashtable.h, just
+// like sgi stl's stl_hash_set is a very thin wrapper over
+// stl_hashtable. The major thing we define is operator[], because
+// we have a concept of a data_type which stl_hashtable doesn't
+// (it only has a key and a value).
+//
+// This is more different from dense_hash_map than you might think,
+// because all iterators for sets are const (you obviously can't
+// change the key, and for sets there is no value).
+//
+// NOTE: this is exactly like sparse_hash_set.h, with the word
+// "sparse" replaced by "dense", except for the addition of
+// set_empty_key().
+//
+// YOU MUST CALL SET_EMPTY_KEY() IMMEDIATELY AFTER CONSTRUCTION.
+//
+// Otherwise your program will die in mysterious ways.
+//
+// In other respects, we adhere mostly to the STL semantics for
+// hash-set. One important exception is that insert() invalidates
+// iterators entirely. On the plus side, though, erase() doesn't
+// invalidate iterators at all, or even change the ordering of elements.
+//
+// Here are a few "power user" tips:
+//
+// 1) set_deleted_key():
+// If you want to use erase() you must call set_deleted_key(),
+// in addition to set_empty_key(), after construction.
+// The deleted and empty keys must differ.
+//
+// 2) resize(0):
+// When an item is deleted, its memory isn't freed right
+// away. This allows you to iterate over a hashtable,
+// and call erase(), without invalidating the iterator.
+// To force the memory to be freed, call resize(0).
+// For tr1 compatibility, this can also be called as rehash(0).
+//
+// 3) min_load_factor(0.0)
+// Setting the minimum load factor to 0.0 guarantees that
+// the hash table will never shrink.
+//
+// Guide to what kind of hash_set to use:
+// (1) dense_hash_set: fastest, uses the most memory
+// (2) sparse_hash_set: slowest, uses the least memory
+// (3) hash_set (STL): in the middle
+// Typically I use sparse_hash_set when I care about space and/or when
+// I need to save the hashtable on disk. I use hash_set otherwise. I
+// don't personally use dense_hash_set ever; some people use it for
+// small sets with lots of lookups.
+//
+// - dense_hash_set has, typically, a factor of 2 memory overhead (if your
+// data takes up X bytes, the hash_set uses X more bytes in overhead).
+// - sparse_hash_set has about 2 bits overhead per entry.
+// - sparse_hash_map can be 3-7 times slower than the others for lookup and,
+// especially, inserts. See time_hash_map.cc for details.
+//
+// See /usr/(local/)?doc/sparsehash-*/dense_hash_set.html
+// for information about how to use this class.
+
+#ifndef _DENSE_HASH_SET_H_
+#define _DENSE_HASH_SET_H_
+
+#include <google/sparsehash/sparseconfig.h>
+#include <stdio.h> // for FILE * in read()/write()
+#include <algorithm> // for the default template args
+#include <functional> // for equal_to
+#include <memory> // for alloc<>
+#include <utility> // for pair<>
+#include HASH_FUN_H // defined in config.h
+#include <google/sparsehash/densehashtable.h>
+
+
+_START_GOOGLE_NAMESPACE_
+
+using STL_NAMESPACE::pair;
+
+template <class Value,
+ class HashFcn = SPARSEHASH_HASH<Value>, // defined in sparseconfig.h
+ class EqualKey = STL_NAMESPACE::equal_to<Value>,
+ class Alloc = STL_NAMESPACE::allocator<Value> >
+class dense_hash_set {
+ private:
+ // Apparently identity is not stl-standard, so we define our own
+ struct Identity {
+ Value& operator()(Value& v) const { return v; }
+ const Value& operator()(const Value& v) const { return v; }
+ };
+ struct SetKey {
+ void operator()(Value* value, const Value& new_key) const {
+ *value = new_key;
+ }
+ };
+
+ // The actual data
+ typedef dense_hashtable<Value, Value, HashFcn,
+ Identity, SetKey, EqualKey, Alloc> ht;
+ ht rep;
+
+ public:
+ typedef typename ht::key_type key_type;
+ typedef typename ht::value_type value_type;
+ typedef typename ht::hasher hasher;
+ typedef typename ht::key_equal key_equal;
+ typedef Alloc allocator_type;
+
+ typedef typename ht::size_type size_type;
+ typedef typename ht::difference_type difference_type;
+ typedef typename ht::const_pointer pointer;
+ typedef typename ht::const_pointer const_pointer;
+ typedef typename ht::const_reference reference;
+ typedef typename ht::const_reference const_reference;
+
+ typedef typename ht::const_iterator iterator;
+ typedef typename ht::const_iterator const_iterator;
+ typedef typename ht::const_local_iterator local_iterator;
+ typedef typename ht::const_local_iterator const_local_iterator;
+
+
+ // Iterator functions -- recall all iterators are const
+ iterator begin() const { return rep.begin(); }
+ iterator end() const { return rep.end(); }
+
+ // These come from tr1's unordered_set. For us, a bucket has 0 or 1 elements.
+ local_iterator begin(size_type i) const { return rep.begin(i); }
+ local_iterator end(size_type i) const { return rep.end(i); }
+
+
+ // Accessor functions
+ hasher hash_funct() const { return rep.hash_funct(); }
+ key_equal key_eq() const { return rep.key_eq(); }
+
+
+ // Constructors
+ explicit dense_hash_set(size_type expected_max_items_in_table = 0,
+ const hasher& hf = hasher(),
+ const key_equal& eql = key_equal())
+ : rep(expected_max_items_in_table, hf, eql) { }
+
+ template <class InputIterator>
+ dense_hash_set(InputIterator f, InputIterator l,
+ size_type expected_max_items_in_table = 0,
+ const hasher& hf = hasher(),
+ const key_equal& eql = key_equal())
+ : rep(expected_max_items_in_table, hf, eql) {
+ rep.insert(f, l);
+ }
+ // We use the default copy constructor
+ // We use the default operator=()
+ // We use the default destructor
+
+ void clear() { rep.clear(); }
+ // This clears the hash set without resizing it down to the minimum
+ // bucket count, but rather keeps the number of buckets constant
+ void clear_no_resize() { rep.clear_no_resize(); }
+ void swap(dense_hash_set& hs) { rep.swap(hs.rep); }
+
+
+ // Functions concerning size
+ size_type size() const { return rep.size(); }
+ size_type max_size() const { return rep.max_size(); }
+ bool empty() const { return rep.empty(); }
+ size_type bucket_count() const { return rep.bucket_count(); }
+ size_type max_bucket_count() const { return rep.max_bucket_count(); }
+
+ // These are tr1 methods. bucket() is the bucket the key is or would be in.
+ size_type bucket_size(size_type i) const { return rep.bucket_size(i); }
+ size_type bucket(const key_type& key) const { return rep.bucket(key); }
+ float load_factor() const {
+ return size() * 1.0f / bucket_count();
+ }
+ float max_load_factor() const {
+ float shrink, grow;
+ rep.get_resizing_parameters(&shrink, &grow);
+ return grow;
+ }
+ void max_load_factor(float new_grow) {
+ float shrink, grow;
+ rep.get_resizing_parameters(&shrink, &grow);
+ rep.set_resizing_parameters(shrink, new_grow);
+ }
+ // These aren't tr1 methods but perhaps ought to be.
+ float min_load_factor() const {
+ float shrink, grow;
+ rep.get_resizing_parameters(&shrink, &grow);
+ return shrink;
+ }
+ void min_load_factor(float new_shrink) {
+ float shrink, grow;
+ rep.get_resizing_parameters(&shrink, &grow);
+ rep.set_resizing_parameters(new_shrink, grow);
+ }
+ // Deprecated; use min_load_factor() or max_load_factor() instead.
+ void set_resizing_parameters(float shrink, float grow) {
+ return rep.set_resizing_parameters(shrink, grow);
+ }
+
+ void resize(size_type hint) { rep.resize(hint); }
+ void rehash(size_type hint) { resize(hint); } // the tr1 name
+
+ // Lookup routines
+ iterator find(const key_type& key) const { return rep.find(key); }
+
+ size_type count(const key_type& key) const { return rep.count(key); }
+
+ pair<iterator, iterator> equal_range(const key_type& key) const {
+ return rep.equal_range(key);
+ }
+
+ // Insertion routines
+ pair<iterator, bool> insert(const value_type& obj) {
+ pair<typename ht::iterator, bool> p = rep.insert(obj);
+ return pair<iterator, bool>(p.first, p.second); // const to non-const
+ }
+ template <class InputIterator>
+ void insert(InputIterator f, InputIterator l) { rep.insert(f, l); }
+ void insert(const_iterator f, const_iterator l) { rep.insert(f, l); }
+ // required for std::insert_iterator; the passed-in iterator is ignored
+ iterator insert(iterator, const value_type& obj) { return insert(obj).first; }
+
+
+ // Deletion and empty routines
+ // THESE ARE NON-STANDARD! I make you specify an "impossible" key
+ // value to identify deleted and empty buckets. You can change the
+ // deleted key as time goes on, or get rid of it entirely to be insert-only.
+ void set_empty_key(const key_type& key) { rep.set_empty_key(key); }
+ void set_deleted_key(const key_type& key) { rep.set_deleted_key(key); }
+ void clear_deleted_key() { rep.clear_deleted_key(); }
+
+ // These are standard
+ size_type erase(const key_type& key) { return rep.erase(key); }
+ void erase(iterator it) { rep.erase(it); }
+ void erase(iterator f, iterator l) { rep.erase(f, l); }
+
+
+ // Comparison
+ bool operator==(const dense_hash_set& hs) const { return rep == hs.rep; }
+ bool operator!=(const dense_hash_set& hs) const { return rep != hs.rep; }
+
+
+ // I/O -- this is an add-on for writing metainformation to disk
+ bool write_metadata(FILE *fp) { return rep.write_metadata(fp); }
+ bool read_metadata(FILE *fp) { return rep.read_metadata(fp); }
+ bool write_nopointer_data(FILE *fp) { return rep.write_nopointer_data(fp); }
+ bool read_nopointer_data(FILE *fp) { return rep.read_nopointer_data(fp); }
+};
+
+template <class Val, class HashFcn, class EqualKey, class Alloc>
+inline void swap(dense_hash_set<Val, HashFcn, EqualKey, Alloc>& hs1,
+ dense_hash_set<Val, HashFcn, EqualKey, Alloc>& hs2) {
+ hs1.swap(hs2);
+}
+
+_END_GOOGLE_NAMESPACE_
+
+#endif /* _DENSE_HASH_SET_H_ */
diff --git a/sources/shiboken2/ext/sparsehash/google/sparsehash/densehashtable.h b/sources/shiboken2/ext/sparsehash/google/sparsehash/densehashtable.h
new file mode 100644
index 000000000..33b191ec8
--- /dev/null
+++ b/sources/shiboken2/ext/sparsehash/google/sparsehash/densehashtable.h
@@ -0,0 +1,1062 @@
+// Copyright (c) 2005, Google Inc.
+// All rights reserved.
+//
+// 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 Google Inc. 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.
+
+// ---
+// Author: Craig Silverstein
+//
+// A dense hashtable is a particular implementation of
+// a hashtable: one that is meant to minimize memory allocation.
+// It does this by using an array to store all the data. We
+// steal a value from the key space to indicate "empty" array
+// elements (ie indices where no item lives) and another to indicate
+// "deleted" elements.
+//
+// (Note it is possible to change the value of the delete key
+// on the fly; you can even remove it, though after that point
+// the hashtable is insert_only until you set it again. The empty
+// value however can't be changed.)
+//
+// To minimize allocation and pointer overhead, we use internal
+// probing, in which the hashtable is a single table, and collisions
+// are resolved by trying to insert again in another bucket. The
+// most cache-efficient internal probing schemes are linear probing
+// (which suffers, alas, from clumping) and quadratic probing, which
+// is what we implement by default.
+//
+// Type requirements: value_type is required to be Copy Constructible
+// and Default Constructible. It is not required to be (and commonly
+// isn't) Assignable.
+//
+// You probably shouldn't use this code directly. Use
+// <google/dense_hash_map> or <google/dense_hash_set> instead.
+
+// You can change the following below:
+// HT_OCCUPANCY_FLT -- how full before we double size
+// HT_EMPTY_FLT -- how empty before we halve size
+// HT_MIN_BUCKETS -- default smallest bucket size
+//
+// You can also change enlarge_resize_percent (which defaults to
+// HT_OCCUPANCY_FLT), and shrink_resize_percent (which defaults to
+// HT_EMPTY_FLT) with set_resizing_parameters().
+//
+// How to decide what values to use?
+// shrink_resize_percent's default of .4 * OCCUPANCY_FLT, is probably good.
+// HT_MIN_BUCKETS is probably unnecessary since you can specify
+// (indirectly) the starting number of buckets at construct-time.
+// For enlarge_resize_percent, you can use this chart to try to trade-off
+// expected lookup time to the space taken up. By default, this
+// code uses quadratic probing, though you can change it to linear
+// via _JUMP below if you really want to.
+//
+// From http://www.augustana.ca/~mohrj/courses/1999.fall/csc210/lecture_notes/hashing.html
+// NUMBER OF PROBES / LOOKUP Successful Unsuccessful
+// Quadratic collision resolution 1 - ln(1-L) - L/2 1/(1-L) - L - ln(1-L)
+// Linear collision resolution [1+1/(1-L)]/2 [1+1/(1-L)2]/2
+//
+// -- enlarge_resize_percent -- 0.10 0.50 0.60 0.75 0.80 0.90 0.99
+// QUADRATIC COLLISION RES.
+// probes/successful lookup 1.05 1.44 1.62 2.01 2.21 2.85 5.11
+// probes/unsuccessful lookup 1.11 2.19 2.82 4.64 5.81 11.4 103.6
+// LINEAR COLLISION RES.
+// probes/successful lookup 1.06 1.5 1.75 2.5 3.0 5.5 50.5
+// probes/unsuccessful lookup 1.12 2.5 3.6 8.5 13.0 50.0 5000.0
+
+#ifndef _DENSEHASHTABLE_H_
+#define _DENSEHASHTABLE_H_
+
+// The probing method
+// Linear probing
+// #define JUMP_(key, num_probes) ( 1 )
+// Quadratic-ish probing
+#define JUMP_(key, num_probes) ( num_probes )
+
+
+#include "google/sparsehash/sparseconfig.h"
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h> // for abort()
+#include <algorithm> // For swap(), eg
+#include <iostream> // For cerr
+#include <memory> // For uninitialized_fill, uninitialized_copy
+#include <utility> // for pair<>
+#include <iterator> // for facts about iterator tags
+#include "google/type_traits.h" // for true_type, integral_constant, etc.
+
+_START_GOOGLE_NAMESPACE_
+
+using STL_NAMESPACE::pair;
+
+// Hashtable class, used to implement the hashed associative containers
+// hash_set and hash_map.
+
+// Value: what is stored in the table (each bucket is a Value).
+// Key: something in a 1-to-1 correspondence to a Value, that can be used
+// to search for a Value in the table (find() takes a Key).
+// HashFcn: Takes a Key and returns an integer, the more unique the better.
+// ExtractKey: given a Value, returns the unique Key associated with it.
+// SetKey: given a Value* and a Key, modifies the value such that
+// ExtractKey(value) == key. We guarantee this is only called
+// with key == deleted_key or key == empty_key.
+// EqualKey: Given two Keys, says whether they are the same (that is,
+// if they are both associated with the same Value).
+// Alloc: STL allocator to use to allocate memory. Currently ignored.
+
+template <class Value, class Key, class HashFcn,
+ class ExtractKey, class SetKey, class EqualKey, class Alloc>
+class dense_hashtable;
+
+template <class V, class K, class HF, class ExK, class SetK, class EqK, class A>
+struct dense_hashtable_iterator;
+
+template <class V, class K, class HF, class ExK, class SetK, class EqK, class A>
+struct dense_hashtable_const_iterator;
+
+// We're just an array, but we need to skip over empty and deleted elements
+template <class V, class K, class HF, class ExK, class SetK, class EqK, class A>
+struct dense_hashtable_iterator {
+ public:
+ typedef dense_hashtable_iterator<V,K,HF,ExK,SetK,EqK,A> iterator;
+ typedef dense_hashtable_const_iterator<V,K,HF,ExK,SetK,EqK,A> const_iterator;
+
+ typedef STL_NAMESPACE::forward_iterator_tag iterator_category;
+ typedef V value_type;
+ typedef STL_NAMESPACE::ptrdiff_t difference_type;
+ typedef size_t size_type;
+ typedef V& reference; // Value
+ typedef V* pointer;
+
+ // "Real" constructor and default constructor
+ dense_hashtable_iterator(const dense_hashtable<V,K,HF,ExK,SetK,EqK,A> *h,
+ pointer it, pointer it_end, bool advance)
+ : ht(h), pos(it), end(it_end) {
+ if (advance) advance_past_empty_and_deleted();
+ }
+ dense_hashtable_iterator() { }
+ // The default destructor is fine; we don't define one
+ // The default operator= is fine; we don't define one
+
+ // Happy dereferencer
+ reference operator*() const { return *pos; }
+ pointer operator->() const { return &(operator*()); }
+
+ // Arithmetic. The only hard part is making sure that
+ // we're not on an empty or marked-deleted array element
+ void advance_past_empty_and_deleted() {
+ while ( pos != end && (ht->test_empty(*this) || ht->test_deleted(*this)) )
+ ++pos;
+ }
+ iterator& operator++() {
+ assert(pos != end); ++pos; advance_past_empty_and_deleted(); return *this;
+ }
+ iterator operator++(int) { iterator tmp(*this); ++*this; return tmp; }
+
+ // Comparison.
+ bool operator==(const iterator& it) const { return pos == it.pos; }
+ bool operator!=(const iterator& it) const { return pos != it.pos; }
+
+
+ // The actual data
+ const dense_hashtable<V,K,HF,ExK,SetK,EqK,A> *ht;
+ pointer pos, end;
+};
+
+
+// Now do it all again, but with const-ness!
+template <class V, class K, class HF, class ExK, class SetK, class EqK, class A>
+struct dense_hashtable_const_iterator {
+ public:
+ typedef dense_hashtable_iterator<V,K,HF,ExK,SetK,EqK,A> iterator;
+ typedef dense_hashtable_const_iterator<V,K,HF,ExK,SetK,EqK,A> const_iterator;
+
+ typedef STL_NAMESPACE::forward_iterator_tag iterator_category;
+ typedef V value_type;
+ typedef STL_NAMESPACE::ptrdiff_t difference_type;
+ typedef size_t size_type;
+ typedef const V& reference; // Value
+ typedef const V* pointer;
+
+ // "Real" constructor and default constructor
+ dense_hashtable_const_iterator(
+ const dense_hashtable<V,K,HF,ExK,SetK,EqK,A> *h,
+ pointer it, pointer it_end, bool advance)
+ : ht(h), pos(it), end(it_end) {
+ if (advance) advance_past_empty_and_deleted();
+ }
+ dense_hashtable_const_iterator() { }
+ // This lets us convert regular iterators to const iterators
+ dense_hashtable_const_iterator(const iterator &it)
+ : ht(it.ht), pos(it.pos), end(it.end) { }
+ // The default destructor is fine; we don't define one
+ // The default operator= is fine; we don't define one
+
+ // Happy dereferencer
+ reference operator*() const { return *pos; }
+ pointer operator->() const { return &(operator*()); }
+
+ // Arithmetic. The only hard part is making sure that
+ // we're not on an empty or marked-deleted array element
+ void advance_past_empty_and_deleted() {
+ while ( pos != end && (ht->test_empty(*this) || ht->test_deleted(*this)) )
+ ++pos;
+ }
+ const_iterator& operator++() {
+ assert(pos != end); ++pos; advance_past_empty_and_deleted(); return *this;
+ }
+ const_iterator operator++(int) { const_iterator tmp(*this); ++*this; return tmp; }
+
+ // Comparison.
+ bool operator==(const const_iterator& it) const { return pos == it.pos; }
+ bool operator!=(const const_iterator& it) const { return pos != it.pos; }
+
+
+ // The actual data
+ const dense_hashtable<V,K,HF,ExK,SetK,EqK,A> *ht;
+ pointer pos, end;
+};
+
+template <class Value, class Key, class HashFcn,
+ class ExtractKey, class SetKey, class EqualKey, class Alloc>
+class dense_hashtable {
+ public:
+ typedef Key key_type;
+ typedef Value value_type;
+ typedef HashFcn hasher;
+ typedef EqualKey key_equal;
+
+ typedef size_t size_type;
+ typedef STL_NAMESPACE::ptrdiff_t difference_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef dense_hashtable_iterator<Value, Key, HashFcn,
+ ExtractKey, SetKey, EqualKey, Alloc>
+ iterator;
+
+ typedef dense_hashtable_const_iterator<Value, Key, HashFcn,
+ ExtractKey, SetKey, EqualKey, Alloc>
+ const_iterator;
+
+ // These come from tr1. For us they're the same as regular iterators.
+ typedef iterator local_iterator;
+ typedef const_iterator const_local_iterator;
+
+ // How full we let the table get before we resize, by default.
+ // Knuth says .8 is good -- higher causes us to probe too much,
+ // though it saves memory.
+ static const float HT_OCCUPANCY_FLT; // = 0.5;
+
+ // How empty we let the table get before we resize lower, by default.
+ // (0.0 means never resize lower.)
+ // It should be less than OCCUPANCY_FLT / 2 or we thrash resizing
+ static const float HT_EMPTY_FLT; // = 0.4 * HT_OCCUPANCY_FLT
+
+ // Minimum size we're willing to let hashtables be.
+ // Must be a power of two, and at least 4.
+ // Note, however, that for a given hashtable, the initial size is a
+ // function of the first constructor arg, and may be >HT_MIN_BUCKETS.
+ static const size_t HT_MIN_BUCKETS = 4;
+
+ // By default, if you don't specify a hashtable size at
+ // construction-time, we use this size. Must be a power of two, and
+ // at least HT_MIN_BUCKETS.
+ static const size_t HT_DEFAULT_STARTING_BUCKETS = 32;
+
+
+ // ITERATOR FUNCTIONS
+ iterator begin() { return iterator(this, table,
+ table + num_buckets, true); }
+ iterator end() { return iterator(this, table + num_buckets,
+ table + num_buckets, true); }
+ const_iterator begin() const { return const_iterator(this, table,
+ table+num_buckets,true);}
+ const_iterator end() const { return const_iterator(this, table + num_buckets,
+ table+num_buckets,true);}
+
+ // These come from tr1 unordered_map. They iterate over 'bucket' n.
+ // For sparsehashtable, we could consider each 'group' to be a bucket,
+ // I guess, but I don't really see the point. We'll just consider
+ // bucket n to be the n-th element of the sparsetable, if it's occupied,
+ // or some empty element, otherwise.
+ local_iterator begin(size_type i) {
+ return local_iterator(this, table + i, table + i+1, false);
+ }
+ local_iterator end(size_type i) {
+ local_iterator it = begin(i);
+ if (!test_empty(i) && !test_deleted(i))
+ ++it;
+ return it;
+ }
+ const_local_iterator begin(size_type i) const {
+ return const_local_iterator(this, table + i, table + i+1, false);
+ }
+ const_local_iterator end(size_type i) const {
+ const_local_iterator it = begin(i);
+ if (!test_empty(i) && !test_deleted(i))
+ ++it;
+ return it;
+ }
+
+ // ACCESSOR FUNCTIONS for the things we templatize on, basically
+ hasher hash_funct() const { return hash; }
+ key_equal key_eq() const { return equals; }
+
+ private:
+ // Annoyingly, we can't copy values around, because they might have
+ // const components (they're probably pair<const X, Y>). We use
+ // explicit destructor invocation and placement new to get around
+ // this. Arg.
+ void set_value(value_type* dst, const value_type& src) {
+ dst->~value_type();
+ new(dst) value_type(src);
+ }
+
+ void destroy_buckets(size_type first, size_type last) {
+ for ( ; first != last; ++first)
+ table[first].~value_type();
+ }
+
+ // DELETE HELPER FUNCTIONS
+ // This lets the user describe a key that will indicate deleted
+ // table entries. This key should be an "impossible" entry --
+ // if you try to insert it for real, you won't be able to retrieve it!
+ // (NB: while you pass in an entire value, only the key part is looked
+ // at. This is just because I don't know how to assign just a key.)
+ private:
+ void squash_deleted() { // gets rid of any deleted entries we have
+ if ( num_deleted ) { // get rid of deleted before writing
+ dense_hashtable tmp(*this); // copying will get rid of deleted
+ swap(tmp); // now we are tmp
+ }
+ assert(num_deleted == 0);
+ }
+
+ public:
+ void set_deleted_key(const key_type &key) {
+ // the empty indicator (if specified) and the deleted indicator
+ // must be different
+ assert(!use_empty || !equals(key, get_key(emptyval)));
+ // It's only safe to change what "deleted" means if we purge deleted guys
+ squash_deleted();
+ use_deleted = true;
+ delkey = key;
+ }
+ void clear_deleted_key() {
+ squash_deleted();
+ use_deleted = false;
+ }
+
+ // These are public so the iterators can use them
+ // True if the item at position bucknum is "deleted" marker
+ bool test_deleted(size_type bucknum) const {
+ // The num_deleted test is crucial for read(): after read(), the ht values
+ // are garbage, and we don't want to think some of them are deleted.
+ return (use_deleted && num_deleted > 0 &&
+ equals(delkey, get_key(table[bucknum])));
+ }
+ bool test_deleted(const iterator &it) const {
+ return (use_deleted && num_deleted > 0 &&
+ equals(delkey, get_key(*it)));
+ }
+ bool test_deleted(const const_iterator &it) const {
+ return (use_deleted && num_deleted > 0 &&
+ equals(delkey, get_key(*it)));
+ }
+ // Set it so test_deleted is true. true if object didn't used to be deleted
+ // See below (at erase()) to explain why we allow const_iterators
+ bool set_deleted(const_iterator &it) {
+ assert(use_deleted); // bad if set_deleted_key() wasn't called
+ bool retval = !test_deleted(it);
+ // &* converts from iterator to value-type
+ set_key(const_cast<value_type*>(&(*it)), delkey);
+ return retval;
+ }
+ // Set it so test_deleted is false. true if object used to be deleted
+ bool clear_deleted(const_iterator &it) {
+ assert(use_deleted); // bad if set_deleted_key() wasn't called
+ // happens automatically when we assign something else in its place
+ return test_deleted(it);
+ }
+
+ // EMPTY HELPER FUNCTIONS
+ // This lets the user describe a key that will indicate empty (unused)
+ // table entries. This key should be an "impossible" entry --
+ // if you try to insert it for real, you won't be able to retrieve it!
+ // (NB: while you pass in an entire value, only the key part is looked
+ // at. This is just because I don't know how to assign just a key.)
+ public:
+ // These are public so the iterators can use them
+ // True if the item at position bucknum is "empty" marker
+ bool test_empty(size_type bucknum) const {
+ assert(use_empty); // we always need to know what's empty!
+ return equals(get_key(emptyval), get_key(table[bucknum]));
+ }
+ bool test_empty(const iterator &it) const {
+ assert(use_empty); // we always need to know what's empty!
+ return equals(get_key(emptyval), get_key(*it));
+ }
+ bool test_empty(const const_iterator &it) const {
+ assert(use_empty); // we always need to know what's empty!
+ return equals(get_key(emptyval), get_key(*it));
+ }
+
+ private:
+ // You can either set a range empty or an individual element
+ void set_empty(size_type bucknum) {
+ assert(use_empty);
+ set_value(&table[bucknum], emptyval);
+ }
+ void fill_range_with_empty(value_type* table_start, value_type* table_end) {
+ // Like set_empty(range), but doesn't destroy previous contents
+ STL_NAMESPACE::uninitialized_fill(table_start, table_end, emptyval);
+ }
+ void set_empty(size_type buckstart, size_type buckend) {
+ assert(use_empty);
+ destroy_buckets(buckstart, buckend);
+ fill_range_with_empty(table + buckstart, table + buckend);
+ }
+
+ public:
+ // TODO(csilvers): change all callers of this to pass in a key instead,
+ // and take a const key_type instead of const value_type.
+ void set_empty_key(const value_type &val) {
+ // Once you set the empty key, you can't change it
+ assert(!use_empty);
+ // The deleted indicator (if specified) and the empty indicator
+ // must be different.
+ assert(!use_deleted || !equals(get_key(val), delkey));
+ use_empty = true;
+ set_value(&emptyval, val);
+
+ assert(!table); // must set before first use
+ // num_buckets was set in constructor even though table was NULL
+ table = (value_type *) malloc(num_buckets * sizeof(*table));
+ assert(table);
+ fill_range_with_empty(table, table + num_buckets);
+ }
+
+ // FUNCTIONS CONCERNING SIZE
+ public:
+ size_type size() const { return num_elements - num_deleted; }
+ // Buckets are always a power of 2
+ size_type max_size() const { return (size_type(-1) >> 1U) + 1; }
+ bool empty() const { return size() == 0; }
+ size_type bucket_count() const { return num_buckets; }
+ size_type max_bucket_count() const { return max_size(); }
+ size_type nonempty_bucket_count() const { return num_elements; }
+ // These are tr1 methods. Their idea of 'bucket' doesn't map well to
+ // what we do. We just say every bucket has 0 or 1 items in it.
+ size_type bucket_size(size_type i) const {
+ return begin(i) == end(i) ? 0 : 1;
+ }
+
+
+
+ private:
+ // Because of the above, size_type(-1) is never legal; use it for errors
+ static const size_type ILLEGAL_BUCKET = size_type(-1);
+
+ private:
+ // This is the smallest size a hashtable can be without being too crowded
+ // If you like, you can give a min #buckets as well as a min #elts
+ size_type min_size(size_type num_elts, size_type min_buckets_wanted) {
+ size_type sz = HT_MIN_BUCKETS; // min buckets allowed
+ while ( sz < min_buckets_wanted || num_elts >= sz * enlarge_resize_percent )
+ sz *= 2;
+ return sz;
+ }
+
+ // Used after a string of deletes
+ void maybe_shrink() {
+ assert(num_elements >= num_deleted);
+ assert((bucket_count() & (bucket_count()-1)) == 0); // is a power of two
+ assert(bucket_count() >= HT_MIN_BUCKETS);
+
+ // If you construct a hashtable with < HT_DEFAULT_STARTING_BUCKETS,
+ // we'll never shrink until you get relatively big, and we'll never
+ // shrink below HT_DEFAULT_STARTING_BUCKETS. Otherwise, something
+ // like "dense_hash_set<int> x; x.insert(4); x.erase(4);" will
+ // shrink us down to HT_MIN_BUCKETS buckets, which is too small.
+ if (shrink_threshold > 0 &&
+ (num_elements-num_deleted) < shrink_threshold &&
+ bucket_count() > HT_DEFAULT_STARTING_BUCKETS ) {
+ size_type sz = bucket_count() / 2; // find how much we should shrink
+ while ( sz > HT_DEFAULT_STARTING_BUCKETS &&
+ (num_elements - num_deleted) < sz * shrink_resize_percent )
+ sz /= 2; // stay a power of 2
+ dense_hashtable tmp(*this, sz); // Do the actual resizing
+ swap(tmp); // now we are tmp
+ }
+ consider_shrink = false; // because we just considered it
+ }
+
+ // We'll let you resize a hashtable -- though this makes us copy all!
+ // When you resize, you say, "make it big enough for this many more elements"
+ void resize_delta(size_type delta) {
+ if ( consider_shrink ) // see if lots of deletes happened
+ maybe_shrink();
+ if ( bucket_count() > HT_MIN_BUCKETS &&
+ (num_elements + delta) <= enlarge_threshold )
+ return; // we're ok as we are
+
+ // Sometimes, we need to resize just to get rid of all the
+ // "deleted" buckets that are clogging up the hashtable. So when
+ // deciding whether to resize, count the deleted buckets (which
+ // are currently taking up room). But later, when we decide what
+ // size to resize to, *don't* count deleted buckets, since they
+ // get discarded during the resize.
+ const size_type needed_size = min_size(num_elements + delta, 0);
+ if ( needed_size > bucket_count() ) { // we don't have enough buckets
+ const size_type resize_to = min_size(num_elements - num_deleted + delta,
+ 0);
+ dense_hashtable tmp(*this, resize_to);
+ swap(tmp); // now we are tmp
+ }
+ }
+
+ // Increase number of buckets, assuming value_type has trivial copy
+ // constructor and destructor. (Really, we want it to have "trivial
+ // move", because that's what realloc does. But there's no way to
+ // capture that using type_traits, so we pretend that move(x, y) is
+ // equivalent to "x.~T(); new(x) T(y);" which is pretty much
+ // correct, if a bit conservative.)
+ void expand_array(size_t resize_to, true_type) {
+ table = (value_type *) realloc(table, resize_to * sizeof(value_type));
+ assert(table);
+ fill_range_with_empty(table + num_buckets, table + resize_to);
+ }
+
+ // Increase number of buckets, without special assumptions about value_type.
+ // TODO(austern): make this exception safe. Handle exceptions from
+ // value_type's copy constructor.
+ void expand_array(size_t resize_to, false_type) {
+ value_type* new_table =
+ (value_type *) malloc(resize_to * sizeof(value_type));
+ assert(new_table);
+ STL_NAMESPACE::uninitialized_copy(table, table + num_buckets, new_table);
+ fill_range_with_empty(new_table + num_buckets, new_table + resize_to);
+ destroy_buckets(0, num_buckets);
+ free(table);
+ table = new_table;
+ }
+
+ // Used to actually do the rehashing when we grow/shrink a hashtable
+ void copy_from(const dense_hashtable &ht, size_type min_buckets_wanted) {
+ clear(); // clear table, set num_deleted to 0
+
+ // If we need to change the size of our table, do it now
+ const size_type resize_to = min_size(ht.size(), min_buckets_wanted);
+ if ( resize_to > bucket_count() ) { // we don't have enough buckets
+ typedef integral_constant<bool,
+ (has_trivial_copy<value_type>::value &&
+ has_trivial_destructor<value_type>::value)>
+ realloc_ok; // we pretend mv(x,y) == "x.~T(); new(x) T(y)"
+ expand_array(resize_to, realloc_ok());
+ num_buckets = resize_to;
+ reset_thresholds();
+ }
+
+ // We use a normal iterator to get non-deleted bcks from ht
+ // We could use insert() here, but since we know there are
+ // no duplicates and no deleted items, we can be more efficient
+ assert((bucket_count() & (bucket_count()-1)) == 0); // a power of two
+ for ( const_iterator it = ht.begin(); it != ht.end(); ++it ) {
+ size_type num_probes = 0; // how many times we've probed
+ size_type bucknum;
+ const size_type bucket_count_minus_one = bucket_count() - 1;
+ for (bucknum = hash(get_key(*it)) & bucket_count_minus_one;
+ !test_empty(bucknum); // not empty
+ bucknum = (bucknum + JUMP_(key, num_probes)) & bucket_count_minus_one) {
+ ++num_probes;
+ assert(num_probes < bucket_count()); // or else the hashtable is full
+ }
+ set_value(&table[bucknum], *it); // copies the value to here
+ num_elements++;
+ }
+ }
+
+ // Required by the spec for hashed associative container
+ public:
+ // Though the docs say this should be num_buckets, I think it's much
+ // more useful as req_elements. As a special feature, calling with
+ // req_elements==0 will cause us to shrink if we can, saving space.
+ void resize(size_type req_elements) { // resize to this or larger
+ if ( consider_shrink || req_elements == 0 )
+ maybe_shrink();
+ if ( req_elements > num_elements )
+ return resize_delta(req_elements - num_elements);
+ }
+
+ // Get and change the value of shrink_resize_percent and
+ // enlarge_resize_percent. The description at the beginning of this
+ // file explains how to choose the values. Setting the shrink
+ // parameter to 0.0 ensures that the table never shrinks.
+ void get_resizing_parameters(float* shrink, float* grow) const {
+ *shrink = shrink_resize_percent;
+ *grow = enlarge_resize_percent;
+ }
+ void set_resizing_parameters(float shrink, float grow) {
+ assert(shrink >= 0.0);
+ assert(grow <= 1.0);
+ if (shrink > grow/2.0f)
+ shrink = grow / 2.0f; // otherwise we thrash hashtable size
+ shrink_resize_percent = shrink;
+ enlarge_resize_percent = grow;
+ reset_thresholds();
+ }
+
+ // CONSTRUCTORS -- as required by the specs, we take a size,
+ // but also let you specify a hashfunction, key comparator,
+ // and key extractor. We also define a copy constructor and =.
+ // DESTRUCTOR -- needs to free the table
+ explicit dense_hashtable(size_type expected_max_items_in_table = 0,
+ const HashFcn& hf = HashFcn(),
+ const EqualKey& eql = EqualKey(),
+ const ExtractKey& ext = ExtractKey(),
+ const SetKey& set = SetKey())
+ : hash(hf), equals(eql), get_key(ext), set_key(set), num_deleted(0),
+ use_deleted(false), use_empty(false),
+ delkey(), emptyval(), enlarge_resize_percent(HT_OCCUPANCY_FLT),
+ shrink_resize_percent(HT_EMPTY_FLT), table(NULL),
+ num_buckets(expected_max_items_in_table == 0
+ ? HT_DEFAULT_STARTING_BUCKETS
+ : min_size(expected_max_items_in_table, 0)),
+ num_elements(0) {
+ // table is NULL until emptyval is set. However, we set num_buckets
+ // here so we know how much space to allocate once emptyval is set
+ reset_thresholds();
+ }
+
+ // As a convenience for resize(), we allow an optional second argument
+ // which lets you make this new hashtable a different size than ht
+ dense_hashtable(const dense_hashtable& ht,
+ size_type min_buckets_wanted = HT_DEFAULT_STARTING_BUCKETS)
+ : hash(ht.hash), equals(ht.equals),
+ get_key(ht.get_key), set_key(ht.set_key), num_deleted(0),
+ use_deleted(ht.use_deleted), use_empty(ht.use_empty),
+ delkey(ht.delkey), emptyval(ht.emptyval),
+ enlarge_resize_percent(ht.enlarge_resize_percent),
+ shrink_resize_percent(ht.shrink_resize_percent), table(NULL),
+ num_buckets(0), num_elements(0) {
+ reset_thresholds();
+ copy_from(ht, min_buckets_wanted); // copy_from() ignores deleted entries
+ }
+
+ dense_hashtable& operator= (const dense_hashtable& ht) {
+ if (&ht == this) return *this; // don't copy onto ourselves
+ clear();
+ hash = ht.hash;
+ equals = ht.equals;
+ get_key = ht.get_key;
+ set_key = ht.set_key;
+ use_deleted = ht.use_deleted;
+ use_empty = ht.use_empty;
+ delkey = ht.delkey;
+ set_value(&emptyval, ht.emptyval);
+ enlarge_resize_percent = ht.enlarge_resize_percent;
+ shrink_resize_percent = ht.shrink_resize_percent;
+ copy_from(ht, HT_MIN_BUCKETS); // sets num_deleted to 0 too
+ return *this;
+ }
+
+ ~dense_hashtable() {
+ if (table) {
+ destroy_buckets(0, num_buckets);
+ free(table);
+ }
+ }
+
+ // Many STL algorithms use swap instead of copy constructors
+ void swap(dense_hashtable& ht) {
+ STL_NAMESPACE::swap(hash, ht.hash);
+ STL_NAMESPACE::swap(equals, ht.equals);
+ STL_NAMESPACE::swap(get_key, ht.get_key);
+ STL_NAMESPACE::swap(set_key, ht.set_key);
+ STL_NAMESPACE::swap(num_deleted, ht.num_deleted);
+ STL_NAMESPACE::swap(use_deleted, ht.use_deleted);
+ STL_NAMESPACE::swap(use_empty, ht.use_empty);
+ STL_NAMESPACE::swap(enlarge_resize_percent, ht.enlarge_resize_percent);
+ STL_NAMESPACE::swap(shrink_resize_percent, ht.shrink_resize_percent);
+ STL_NAMESPACE::swap(delkey, ht.delkey);
+ { value_type tmp; // for annoying reasons, swap() doesn't work
+ set_value(&tmp, emptyval);
+ set_value(&emptyval, ht.emptyval);
+ set_value(&ht.emptyval, tmp);
+ }
+ STL_NAMESPACE::swap(table, ht.table);
+ STL_NAMESPACE::swap(num_buckets, ht.num_buckets);
+ STL_NAMESPACE::swap(num_elements, ht.num_elements);
+ reset_thresholds();
+ ht.reset_thresholds();
+ }
+
+ // It's always nice to be able to clear a table without deallocating it
+ void clear() {
+ if (table)
+ destroy_buckets(0, num_buckets);
+ num_buckets = min_size(0,0); // our new size
+ reset_thresholds();
+ table = (value_type *) realloc(table, num_buckets * sizeof(*table));
+ assert(table);
+ fill_range_with_empty(table, table + num_buckets);
+ num_elements = 0;
+ num_deleted = 0;
+ }
+
+ // Clear the table without resizing it.
+ // Mimicks the stl_hashtable's behaviour when clear()-ing in that it
+ // does not modify the bucket count
+ void clear_no_resize() {
+ if (table) {
+ set_empty(0, num_buckets);
+ }
+ // don't consider to shrink before another erase()
+ reset_thresholds();
+ num_elements = 0;
+ num_deleted = 0;
+ }
+
+ // LOOKUP ROUTINES
+ private:
+ // Returns a pair of positions: 1st where the object is, 2nd where
+ // it would go if you wanted to insert it. 1st is ILLEGAL_BUCKET
+ // if object is not found; 2nd is ILLEGAL_BUCKET if it is.
+ // Note: because of deletions where-to-insert is not trivial: it's the
+ // first deleted bucket we see, as long as we don't find the key later
+ pair<size_type, size_type> find_position(const key_type &key) const {
+ size_type num_probes = 0; // how many times we've probed
+ const size_type bucket_count_minus_one = bucket_count() - 1;
+ size_type bucknum = hash(key) & bucket_count_minus_one;
+ size_type insert_pos = ILLEGAL_BUCKET; // where we would insert
+ while ( 1 ) { // probe until something happens
+ if ( test_empty(bucknum) ) { // bucket is empty
+ if ( insert_pos == ILLEGAL_BUCKET ) // found no prior place to insert
+ return pair<size_type,size_type>(ILLEGAL_BUCKET, bucknum);
+ else
+ return pair<size_type,size_type>(ILLEGAL_BUCKET, insert_pos);
+
+ } else if ( test_deleted(bucknum) ) {// keep searching, but mark to insert
+ if ( insert_pos == ILLEGAL_BUCKET )
+ insert_pos = bucknum;
+
+ } else if ( equals(key, get_key(table[bucknum])) ) {
+ return pair<size_type,size_type>(bucknum, ILLEGAL_BUCKET);
+ }
+ ++num_probes; // we're doing another probe
+ bucknum = (bucknum + JUMP_(key, num_probes)) & bucket_count_minus_one;
+ assert(num_probes < bucket_count()); // don't probe too many times!
+ }
+ }
+
+ public:
+ iterator find(const key_type& key) {
+ if ( size() == 0 ) return end();
+ pair<size_type, size_type> pos = find_position(key);
+ if ( pos.first == ILLEGAL_BUCKET ) // alas, not there
+ return end();
+ else
+ return iterator(this, table + pos.first, table + num_buckets, false);
+ }
+
+ const_iterator find(const key_type& key) const {
+ if ( size() == 0 ) return end();
+ pair<size_type, size_type> pos = find_position(key);
+ if ( pos.first == ILLEGAL_BUCKET ) // alas, not there
+ return end();
+ else
+ return const_iterator(this, table + pos.first, table+num_buckets, false);
+ }
+
+ // This is a tr1 method: the bucket a given key is in, or what bucket
+ // it would be put in, if it were to be inserted. Shrug.
+ size_type bucket(const key_type& key) const {
+ pair<size_type, size_type> pos = find_position(key);
+ return pos.first == ILLEGAL_BUCKET ? pos.second : pos.first;
+ }
+
+ // Counts how many elements have key key. For maps, it's either 0 or 1.
+ size_type count(const key_type &key) const {
+ pair<size_type, size_type> pos = find_position(key);
+ return pos.first == ILLEGAL_BUCKET ? 0 : 1;
+ }
+
+ // Likewise, equal_range doesn't really make sense for us. Oh well.
+ pair<iterator,iterator> equal_range(const key_type& key) {
+ iterator pos = find(key); // either an iterator or end
+ if (pos == end()) {
+ return pair<iterator,iterator>(pos, pos);
+ } else {
+ const iterator startpos = pos++;
+ return pair<iterator,iterator>(startpos, pos);
+ }
+ }
+ pair<const_iterator,const_iterator> equal_range(const key_type& key) const {
+ const_iterator pos = find(key); // either an iterator or end
+ if (pos == end()) {
+ return pair<const_iterator,const_iterator>(pos, pos);
+ } else {
+ const const_iterator startpos = pos++;
+ return pair<const_iterator,const_iterator>(startpos, pos);
+ }
+ }
+
+
+ // INSERTION ROUTINES
+ private:
+ // If you know *this is big enough to hold obj, use this routine
+ pair<iterator, bool> insert_noresize(const value_type& obj) {
+ // First, double-check we're not inserting delkey or emptyval
+ assert(!use_empty || !equals(get_key(obj), get_key(emptyval)));
+ assert(!use_deleted || !equals(get_key(obj), delkey));
+ const pair<size_type,size_type> pos = find_position(get_key(obj));
+ if ( pos.first != ILLEGAL_BUCKET) { // object was already there
+ return pair<iterator,bool>(iterator(this, table + pos.first,
+ table + num_buckets, false),
+ false); // false: we didn't insert
+ } else { // pos.second says where to put it
+ if ( test_deleted(pos.second) ) { // just replace if it's been del.
+ const_iterator delpos(this, table + pos.second, // shrug:
+ table + num_buckets, false);// shouldn't need const
+ clear_deleted(delpos);
+ assert( num_deleted > 0);
+ --num_deleted; // used to be, now it isn't
+ } else {
+ ++num_elements; // replacing an empty bucket
+ }
+ set_value(&table[pos.second], obj);
+ return pair<iterator,bool>(iterator(this, table + pos.second,
+ table + num_buckets, false),
+ true); // true: we did insert
+ }
+ }
+
+ public:
+ // This is the normal insert routine, used by the outside world
+ pair<iterator, bool> insert(const value_type& obj) {
+ resize_delta(1); // adding an object, grow if need be
+ return insert_noresize(obj);
+ }
+
+ // When inserting a lot at a time, we specialize on the type of iterator
+ template <class InputIterator>
+ void insert(InputIterator f, InputIterator l) {
+ // specializes on iterator type
+ insert(f, l, typename STL_NAMESPACE::iterator_traits<InputIterator>::iterator_category());
+ }
+
+ // Iterator supports operator-, resize before inserting
+ template <class ForwardIterator>
+ void insert(ForwardIterator f, ForwardIterator l,
+ STL_NAMESPACE::forward_iterator_tag) {
+ size_type n = STL_NAMESPACE::distance(f, l); // TODO(csilvers): standard?
+ resize_delta(n);
+ for ( ; n > 0; --n, ++f)
+ insert_noresize(*f);
+ }
+
+ // Arbitrary iterator, can't tell how much to resize
+ template <class InputIterator>
+ void insert(InputIterator f, InputIterator l,
+ STL_NAMESPACE::input_iterator_tag) {
+ for ( ; f != l; ++f)
+ insert(*f);
+ }
+
+
+ // DELETION ROUTINES
+ size_type erase(const key_type& key) {
+ // First, double-check we're not trying to erase delkey or emptyval
+ assert(!use_empty || !equals(key, get_key(emptyval)));
+ assert(!use_deleted || !equals(key, delkey));
+ const_iterator pos = find(key); // shrug: shouldn't need to be const
+ if ( pos != end() ) {
+ assert(!test_deleted(pos)); // or find() shouldn't have returned it
+ set_deleted(pos);
+ ++num_deleted;
+ consider_shrink = true; // will think about shrink after next insert
+ return 1; // because we deleted one thing
+ } else {
+ return 0; // because we deleted nothing
+ }
+ }
+
+ // This is really evil: really it should be iterator, not const_iterator.
+ // But...the only reason keys are const is to allow lookup.
+ // Since that's a moot issue for deleted keys, we allow const_iterators
+ void erase(const_iterator pos) {
+ if ( pos == end() ) return; // sanity check
+ if ( set_deleted(pos) ) { // true if object has been newly deleted
+ ++num_deleted;
+ consider_shrink = true; // will think about shrink after next insert
+ }
+ }
+
+ void erase(const_iterator f, const_iterator l) {
+ for ( ; f != l; ++f) {
+ if ( set_deleted(f) ) // should always be true
+ ++num_deleted;
+ }
+ consider_shrink = true; // will think about shrink after next insert
+ }
+
+
+ // COMPARISON
+ bool operator==(const dense_hashtable& ht) const {
+ if (size() != ht.size()) {
+ return false;
+ } else if (this == &ht) {
+ return true;
+ } else {
+ // Iterate through the elements in "this" and see if the
+ // corresponding element is in ht
+ for ( const_iterator it = begin(); it != end(); ++it ) {
+ const_iterator it2 = ht.find(get_key(*it));
+ if ((it2 == ht.end()) || (*it != *it2)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ bool operator!=(const dense_hashtable& ht) const {
+ return !(*this == ht);
+ }
+
+
+ // I/O
+ // We support reading and writing hashtables to disk. Alas, since
+ // I don't know how to write a hasher or key_equal, you have to make
+ // sure everything but the table is the same. We compact before writing
+ //
+ // NOTE: These functions are currently TODO. They've not been implemented.
+ bool write_metadata(FILE *fp) {
+ squash_deleted(); // so we don't have to worry about delkey
+ return false; // TODO
+ }
+
+ bool read_metadata(FILE *fp) {
+ num_deleted = 0; // since we got rid before writing
+ assert(use_empty); // have to set this before calling us
+ if (table) free(table); // we'll make our own
+ // TODO: read magic number
+ // TODO: read num_buckets
+ reset_thresholds();
+ table = (value_type *) malloc(num_buckets * sizeof(*table));
+ assert(table);
+ fill_range_with_empty(table, table + num_buckets);
+ // TODO: read num_elements
+ for ( size_type i = 0; i < num_elements; ++i ) {
+ // TODO: read bucket_num
+ // TODO: set with non-empty, non-deleted value
+ }
+ return false; // TODO
+ }
+
+ // If your keys and values are simple enough, we can write them to
+ // disk for you. "simple enough" means value_type is a POD type
+ // that contains no pointers. However, we don't try to normalize
+ // endianness
+ bool write_nopointer_data(FILE *fp) const {
+ for ( const_iterator it = begin(); it != end(); ++it ) {
+ // TODO: skip empty/deleted values
+ if ( !fwrite(&*it, sizeof(*it), 1, fp) ) return false;
+ }
+ return false;
+ }
+
+ // When reading, we have to override the potential const-ness of *it
+ bool read_nopointer_data(FILE *fp) {
+ for ( iterator it = begin(); it != end(); ++it ) {
+ // TODO: skip empty/deleted values
+ if ( !fread(reinterpret_cast<void*>(&(*it)), sizeof(*it), 1, fp) )
+ return false;
+ }
+ return false;
+ }
+
+ private:
+ // The actual data
+ hasher hash; // required by hashed_associative_container
+ key_equal equals;
+ ExtractKey get_key;
+ SetKey set_key;
+ size_type num_deleted; // how many occupied buckets are marked deleted
+ bool use_deleted; // false until delkey has been set
+ bool use_empty; // you must do this before you start
+ // TODO(csilvers): make a pointer, and get rid of use_deleted (benchmark!)
+ key_type delkey; // which key marks deleted entries
+ value_type emptyval; // which key marks unused entries
+ float enlarge_resize_percent; // how full before resize
+ float shrink_resize_percent; // how empty before resize
+ size_type shrink_threshold; // num_buckets * shrink_resize_percent
+ size_type enlarge_threshold; // num_buckets * enlarge_resize_percent
+ value_type *table;
+ size_type num_buckets;
+ size_type num_elements;
+ bool consider_shrink; // true if we should try to shrink before next insert
+
+ void reset_thresholds() {
+ enlarge_threshold = static_cast<size_type>(num_buckets
+ * enlarge_resize_percent);
+ shrink_threshold = static_cast<size_type>(num_buckets
+ * shrink_resize_percent);
+ consider_shrink = false; // whatever caused us to reset already considered
+ }
+};
+
+// We need a global swap as well
+template <class V, class K, class HF, class ExK, class SetK, class EqK, class A>
+inline void swap(dense_hashtable<V,K,HF,ExK,SetK,EqK,A> &x,
+ dense_hashtable<V,K,HF,ExK,SetK,EqK,A> &y) {
+ x.swap(y);
+}
+
+#undef JUMP_
+
+template <class V, class K, class HF, class ExK, class SetK, class EqK, class A>
+const typename dense_hashtable<V,K,HF,ExK,SetK,EqK,A>::size_type
+dense_hashtable<V,K,HF,ExK,SetK,EqK,A>::ILLEGAL_BUCKET;
+
+// How full we let the table get before we resize. Knuth says .8 is
+// good -- higher causes us to probe too much, though saves memory.
+// However, we go with .5, getting better performance at the cost of
+// more space (a trade-off densehashtable explicitly chooses to make).
+// Feel free to play around with different values, though.
+template <class V, class K, class HF, class ExK, class SetK, class EqK, class A>
+const float dense_hashtable<V,K,HF,ExK,SetK,EqK,A>::HT_OCCUPANCY_FLT = 0.5f;
+
+// How empty we let the table get before we resize lower.
+// It should be less than OCCUPANCY_FLT / 2 or we thrash resizing
+template <class V, class K, class HF, class ExK, class SetK, class EqK, class A>
+const float dense_hashtable<V,K,HF,ExK,SetK,EqK,A>::HT_EMPTY_FLT
+ = 0.4f * dense_hashtable<V,K,HF,ExK,SetK,EqK,A>::HT_OCCUPANCY_FLT;
+
+_END_GOOGLE_NAMESPACE_
+
+#endif /* _DENSEHASHTABLE_H_ */
diff --git a/sources/shiboken2/ext/sparsehash/google/sparsehash/sparseconfig.h b/sources/shiboken2/ext/sparsehash/google/sparsehash/sparseconfig.h
new file mode 100644
index 000000000..28c85d1f4
--- /dev/null
+++ b/sources/shiboken2/ext/sparsehash/google/sparsehash/sparseconfig.h
@@ -0,0 +1,45 @@
+/*
+ * NOTE: This file is for internal use only.
+ * Do not use these #defines in your own program!
+ */
+
+/* Namespace for Google classes */
+#define GOOGLE_NAMESPACE ::google
+
+#ifdef _MSC_VER
+ /* the location of the header defining hash functions */
+ #define HASH_FUN_H <unordered_map>
+ /* the namespace of the hash<> function */
+ #define HASH_NAMESPACE stdext
+ /* The system-provided hash function including the namespace. */
+ #define SPARSEHASH_HASH HASH_NAMESPACE::hash_compare
+/* libc++ does not implement the tr1 namespce, instead the
+ * equivalient functionality is placed in namespace std,
+ * so use when it targeting such systems (OS X 10.7 onwards) */
+#elif defined(_LIBCPP_VERSION)
+ /* the location of the header defining hash functions */
+ #define HASH_FUN_H <functional>
+ /* the namespace of the hash<> function */
+ #define HASH_NAMESPACE std
+ /* The system-provided hash function including the namespace. */
+ #define SPARSEHASH_HASH HASH_NAMESPACE::hash
+#else
+ /* the location of the header defining hash functions */
+ #define HASH_FUN_H <tr1/functional>
+ /* the namespace of the hash<> function */
+ #define HASH_NAMESPACE std::tr1
+ /* The system-provided hash function including the namespace. */
+ #define SPARSEHASH_HASH HASH_NAMESPACE::hash
+#endif
+
+/* Define to 1 if the system has the type `long long'. */
+#define HAVE_LONG_LONG 1
+
+/* the namespace where STL code like vector<> is defined */
+#define STL_NAMESPACE std
+
+/* Stops putting the code inside the Google namespace */
+#define _END_GOOGLE_NAMESPACE_ }
+
+/* Puts following code inside the Google namespace */
+#define _START_GOOGLE_NAMESPACE_ namespace google {
diff --git a/sources/shiboken2/ext/sparsehash/google/type_traits.h b/sources/shiboken2/ext/sparsehash/google/type_traits.h
new file mode 100644
index 000000000..d9d4faf83
--- /dev/null
+++ b/sources/shiboken2/ext/sparsehash/google/type_traits.h
@@ -0,0 +1,250 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Google Inc. 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.
+
+// ----
+// Author: Matt Austern
+//
+// Define a small subset of tr1 type traits. The traits we define are:
+// is_integral
+// is_floating_point
+// is_pointer
+// is_reference
+// is_pod
+// has_trivial_constructor
+// has_trivial_copy
+// has_trivial_assign
+// has_trivial_destructor
+// remove_const
+// remove_volatile
+// remove_cv
+// remove_reference
+// remove_pointer
+// is_convertible
+// We can add more type traits as required.
+
+#ifndef BASE_TYPE_TRAITS_H_
+#define BASE_TYPE_TRAITS_H_
+
+#include "google/sparsehash/sparseconfig.h"
+#include <utility> // For pair
+
+_START_GOOGLE_NAMESPACE_
+
+// integral_constant, defined in tr1, is a wrapper for an integer
+// value. We don't really need this generality; we could get away
+// with hardcoding the integer type to bool. We use the fully
+// general integer_constant for compatibility with tr1.
+
+template<class T, T v>
+struct integral_constant {
+ static const T value = v;
+ typedef T value_type;
+ typedef integral_constant<T, v> type;
+};
+
+template <class T, T v> const T integral_constant<T, v>::value;
+
+// Abbreviations: true_type and false_type are structs that represent
+// boolean true and false values.
+typedef integral_constant<bool, true> true_type;
+typedef integral_constant<bool, false> false_type;
+
+// Types small_ and big_ are guaranteed such that sizeof(small_) <
+// sizeof(big_)
+typedef char small_;
+
+struct big_ {
+ char dummy[2];
+};
+
+// is_integral is false except for the built-in integer types.
+template <class T> struct is_integral : false_type { };
+template<> struct is_integral<bool> : true_type { };
+template<> struct is_integral<char> : true_type { };
+template<> struct is_integral<unsigned char> : true_type { };
+template<> struct is_integral<signed char> : true_type { };
+#if defined(_MSC_VER)
+// wchar_t is not by default a distinct type from unsigned short in
+// Microsoft C.
+// See http://msdn2.microsoft.com/en-us/library/dh8che7s(VS.80).aspx
+template<> struct is_integral<__wchar_t> : true_type { };
+#else
+template<> struct is_integral<wchar_t> : true_type { };
+#endif
+template<> struct is_integral<short> : true_type { };
+template<> struct is_integral<unsigned short> : true_type { };
+template<> struct is_integral<int> : true_type { };
+template<> struct is_integral<unsigned int> : true_type { };
+template<> struct is_integral<long> : true_type { };
+template<> struct is_integral<unsigned long> : true_type { };
+#ifdef HAVE_LONG_LONG
+template<> struct is_integral<long long> : true_type { };
+template<> struct is_integral<unsigned long long> : true_type { };
+#endif
+
+
+// is_floating_point is false except for the built-in floating-point types.
+template <class T> struct is_floating_point : false_type { };
+template<> struct is_floating_point<float> : true_type { };
+template<> struct is_floating_point<double> : true_type { };
+template<> struct is_floating_point<long double> : true_type { };
+
+
+// is_pointer is false except for pointer types.
+template <class T> struct is_pointer : false_type { };
+template <class T> struct is_pointer<T*> : true_type { };
+
+
+// is_reference is false except for reference types.
+template<typename T> struct is_reference : false_type {};
+template<typename T> struct is_reference<T&> : true_type {};
+
+
+// We can't get is_pod right without compiler help, so fail conservatively.
+// We will assume it's false except for arithmetic types and pointers,
+// and const versions thereof. Note that std::pair is not a POD.
+template <class T> struct is_pod
+ : integral_constant<bool, (is_integral<T>::value ||
+ is_floating_point<T>::value ||
+ is_pointer<T>::value)> { };
+template <class T> struct is_pod<const T> : is_pod<T> { };
+
+
+// We can't get has_trivial_constructor right without compiler help, so
+// fail conservatively. We will assume it's false except for: (1) types
+// for which is_pod is true. (2) std::pair of types with trivial
+// constructors. (3) array of a type with a trivial constructor.
+// (4) const versions thereof.
+template <class T> struct has_trivial_constructor : is_pod<T> { };
+template <class T, class U> struct has_trivial_constructor<std::pair<T, U> >
+ : integral_constant<bool,
+ (has_trivial_constructor<T>::value &&
+ has_trivial_constructor<U>::value)> { };
+template <class A, int N> struct has_trivial_constructor<A[N]>
+ : has_trivial_constructor<A> { };
+template <class T> struct has_trivial_constructor<const T>
+ : has_trivial_constructor<T> { };
+
+// We can't get has_trivial_copy right without compiler help, so fail
+// conservatively. We will assume it's false except for: (1) types
+// for which is_pod is true. (2) std::pair of types with trivial copy
+// constructors. (3) array of a type with a trivial copy constructor.
+// (4) const versions thereof.
+template <class T> struct has_trivial_copy : is_pod<T> { };
+template <class T, class U> struct has_trivial_copy<std::pair<T, U> >
+ : integral_constant<bool,
+ (has_trivial_copy<T>::value &&
+ has_trivial_copy<U>::value)> { };
+template <class A, int N> struct has_trivial_copy<A[N]>
+ : has_trivial_copy<A> { };
+template <class T> struct has_trivial_copy<const T> : has_trivial_copy<T> { };
+
+// We can't get has_trivial_assign right without compiler help, so fail
+// conservatively. We will assume it's false except for: (1) types
+// for which is_pod is true. (2) std::pair of types with trivial copy
+// constructors. (3) array of a type with a trivial assign constructor.
+template <class T> struct has_trivial_assign : is_pod<T> { };
+template <class T, class U> struct has_trivial_assign<std::pair<T, U> >
+ : integral_constant<bool,
+ (has_trivial_assign<T>::value &&
+ has_trivial_assign<U>::value)> { };
+template <class A, int N> struct has_trivial_assign<A[N]>
+ : has_trivial_assign<A> { };
+
+// We can't get has_trivial_destructor right without compiler help, so
+// fail conservatively. We will assume it's false except for: (1) types
+// for which is_pod is true. (2) std::pair of types with trivial
+// destructors. (3) array of a type with a trivial destructor.
+// (4) const versions thereof.
+template <class T> struct has_trivial_destructor : is_pod<T> { };
+template <class T, class U> struct has_trivial_destructor<std::pair<T, U> >
+ : integral_constant<bool,
+ (has_trivial_destructor<T>::value &&
+ has_trivial_destructor<U>::value)> { };
+template <class A, int N> struct has_trivial_destructor<A[N]>
+ : has_trivial_destructor<A> { };
+template <class T> struct has_trivial_destructor<const T>
+ : has_trivial_destructor<T> { };
+
+// Specified by TR1 [4.7.1]
+template<typename T> struct remove_const { typedef T type; };
+template<typename T> struct remove_const<T const> { typedef T type; };
+template<typename T> struct remove_volatile { typedef T type; };
+template<typename T> struct remove_volatile<T volatile> { typedef T type; };
+template<typename T> struct remove_cv {
+ typedef typename remove_const<typename remove_volatile<T>::type>::type type;
+};
+
+
+// Specified by TR1 [4.7.2]
+template<typename T> struct remove_reference { typedef T type; };
+template<typename T> struct remove_reference<T&> { typedef T type; };
+
+// Specified by TR1 [4.7.4] Pointer modifications.
+template<typename T> struct remove_pointer { typedef T type; };
+template<typename T> struct remove_pointer<T*> { typedef T type; };
+template<typename T> struct remove_pointer<T* const> { typedef T type; };
+template<typename T> struct remove_pointer<T* volatile> { typedef T type; };
+template<typename T> struct remove_pointer<T* const volatile> {
+ typedef T type; };
+
+// Specified by TR1 [4.6] Relationships between types
+#ifndef _MSC_VER
+namespace internal {
+
+// This class is an implementation detail for is_convertible, and you
+// don't need to know how it works to use is_convertible. For those
+// who care: we declare two different functions, one whose argument is
+// of type To and one with a variadic argument list. We give them
+// return types of different size, so we can use sizeof to trick the
+// compiler into telling us which function it would have chosen if we
+// had called it with an argument of type From. See Alexandrescu's
+// _Modern C++ Design_ for more details on this sort of trick.
+
+template <typename From, typename To>
+struct ConvertHelper {
+ static small_ Test(To);
+ static big_ Test(...);
+ static From Create();
+};
+} // namespace internal
+
+// Inherits from true_type if From is convertible to To, false_type otherwise.
+template <typename From, typename To>
+struct is_convertible
+ : integral_constant<bool,
+ sizeof(internal::ConvertHelper<From, To>::Test(
+ internal::ConvertHelper<From, To>::Create()))
+ == sizeof(small_)> {
+};
+#endif
+
+_END_GOOGLE_NAMESPACE_
+
+#endif // BASE_TYPE_TRAITS_H_
diff --git a/sources/shiboken2/generator/CMakeLists.txt b/sources/shiboken2/generator/CMakeLists.txt
new file mode 100644
index 000000000..032118666
--- /dev/null
+++ b/sources/shiboken2/generator/CMakeLists.txt
@@ -0,0 +1,40 @@
+project(shibokengenerator)
+
+find_package(Qt5Xml)
+find_package(Qt5XmlPatterns)
+
+set(shiboken2_SRC
+generator.cpp
+shiboken2/cppgenerator.cpp
+shiboken2/headergenerator.cpp
+shiboken2/overloaddata.cpp
+shiboken2/shibokengenerator.cpp
+main.cpp
+)
+
+if (NOT DISABLE_DOCSTRINGS)
+ set(shiboken2_SRC ${shiboken2_SRC} qtdoc/qtdocgenerator.cpp)
+ add_definitions(-DDOCSTRINGS_ENABLED)
+endif()
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/shiboken2
+ ${CMAKE_CURRENT_SOURCE_DIR}/qtdoc
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${apiextractor_SOURCE_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5XmlPatterns_INCLUDE_DIRS}
+ )
+
+add_executable(shiboken2 ${shiboken2_SRC})
+add_dependencies(shiboken2 apiextractor)
+set_target_properties(shiboken2 PROPERTIES OUTPUT_NAME shiboken2${shiboken2_SUFFIX})
+target_link_libraries(shiboken2
+ apiextractor
+ ${Qt5Core_LIBRARIES}
+ ${Qt5XmlPatterns_LIBRARIES}
+ )
+
+configure_file(shibokenconfig.h.in "${CMAKE_CURRENT_BINARY_DIR}/shibokenconfig.h" @ONLY)
+
+install(TARGETS shiboken2 DESTINATION bin)
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp
new file mode 100644
index 000000000..d7f98a90f
--- /dev/null
+++ b/sources/shiboken2/generator/generator.cpp
@@ -0,0 +1,854 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "generator.h"
+#include "abstractmetalang.h"
+#include "reporthandler.h"
+#include "fileout.h"
+#include "apiextractor.h"
+#include "typesystem.h"
+
+#include <QtCore/QDir>
+#include <QtCore/QFile>
+#include <QtCore/QFileInfo>
+#include <QDebug>
+#include <typedatabase.h>
+
+struct Generator::GeneratorPrivate {
+ const ApiExtractor* apiextractor;
+ QString outDir;
+ // License comment
+ QString licenseComment;
+ QString packageName;
+ int numGenerated;
+ QStringList instantiatedContainersNames;
+ QStringList instantiatedSmartPointerNames;
+ QList<const AbstractMetaType *> instantiatedContainers;
+ QList<const AbstractMetaType *> instantiatedSmartPointers;
+
+};
+
+Generator::Generator() : m_d(new GeneratorPrivate)
+{
+ m_d->numGenerated = 0;
+ m_d->instantiatedContainers = QList<const AbstractMetaType *>();
+ m_d->instantiatedSmartPointers = QList<const AbstractMetaType *>();
+ m_d->instantiatedContainersNames = QStringList();
+ m_d->instantiatedSmartPointerNames = QStringList();
+}
+
+Generator::~Generator()
+{
+ delete m_d;
+}
+
+bool Generator::setup(const ApiExtractor& extractor, const QMap< QString, QString > args)
+{
+ m_d->apiextractor = &extractor;
+ TypeEntryHash allEntries = TypeDatabase::instance()->allEntries();
+ TypeEntry* entryFound = 0;
+ for (TypeEntryHash::const_iterator it = allEntries.cbegin(), end = allEntries.cend(); it != end; ++it) {
+ foreach (TypeEntry *entry, it.value()) {
+ if (entry->type() == TypeEntry::TypeSystemType && entry->generateCode()) {
+ entryFound = entry;
+ break;
+ }
+ }
+ if (entryFound)
+ break;
+ }
+ if (entryFound)
+ m_d->packageName = entryFound->name();
+ else
+ qCWarning(lcShiboken) << "Couldn't find the package name!!";
+
+ collectInstantiatedContainersAndSmartPointers();
+
+ return doSetup(args);
+}
+
+QString Generator::getSimplifiedContainerTypeName(const AbstractMetaType* type)
+{
+ const QString signature = type->cppSignature();
+ if (!type->typeEntry()->isContainer() && !type->typeEntry()->isSmartPointer())
+ return signature;
+ QString typeName = signature;
+ if (type->isConstant())
+ typeName.remove(0, sizeof("const ") / sizeof(char) - 1);
+ switch (type->referenceType()) {
+ case NoReference:
+ break;
+ case LValueReference:
+ typeName.chop(1);
+ break;
+ case RValueReference:
+ typeName.chop(2);
+ break;
+ }
+ while (typeName.endsWith(QLatin1Char('*')) || typeName.endsWith(QLatin1Char(' ')))
+ typeName.chop(1);
+ return typeName;
+}
+
+void Generator::addInstantiatedContainersAndSmartPointers(const AbstractMetaType *type,
+ const QString &context)
+{
+ if (!type)
+ return;
+ foreach (const AbstractMetaType* t, type->instantiations())
+ addInstantiatedContainersAndSmartPointers(t, context);
+ if (!type->typeEntry()->isContainer() && !type->typeEntry()->isSmartPointer())
+ return;
+ bool isContainer = type->typeEntry()->isContainer();
+ if (type->hasTemplateChildren()) {
+ QString piece = isContainer ? QStringLiteral("container") : QStringLiteral("smart pointer");
+ QString warning =
+ QString::fromLatin1("Skipping instantiation of %1 '%2' because it has template"
+ " arguments.").arg(piece).arg(type->originalTypeDescription());
+ if (!context.isEmpty())
+ warning.append(QStringLiteral(" Calling context: %1").arg(context));
+
+ qCWarning(lcShiboken).noquote().nospace() << warning;
+ return;
+
+ }
+ QString typeName = getSimplifiedContainerTypeName(type);
+ if (isContainer) {
+ if (!m_d->instantiatedContainersNames.contains(typeName)) {
+ m_d->instantiatedContainersNames.append(typeName);
+ m_d->instantiatedContainers.append(type);
+ }
+ } else {
+ // Is smart pointer.
+ if (!m_d->instantiatedSmartPointerNames.contains(typeName)) {
+ m_d->instantiatedSmartPointerNames.append(typeName);
+ m_d->instantiatedSmartPointers.append(type);
+ }
+ }
+
+}
+
+void Generator::collectInstantiatedContainersAndSmartPointers(const AbstractMetaFunction *func)
+{
+ addInstantiatedContainersAndSmartPointers(func->type(), func->signature());
+ foreach (const AbstractMetaArgument* arg, func->arguments())
+ addInstantiatedContainersAndSmartPointers(arg->type(), func->signature());
+}
+
+void Generator::collectInstantiatedContainersAndSmartPointers(const AbstractMetaClass *metaClass)
+{
+ if (!metaClass->typeEntry()->generateCode())
+ return;
+ foreach (const AbstractMetaFunction* func, metaClass->functions())
+ collectInstantiatedContainersAndSmartPointers(func);
+ foreach (const AbstractMetaField* field, metaClass->fields())
+ addInstantiatedContainersAndSmartPointers(field->type(), field->name());
+ foreach (AbstractMetaClass* innerClass, metaClass->innerClasses())
+ collectInstantiatedContainersAndSmartPointers(innerClass);
+}
+
+void Generator::collectInstantiatedContainersAndSmartPointers()
+{
+ foreach (const AbstractMetaFunction* func, globalFunctions())
+ collectInstantiatedContainersAndSmartPointers(func);
+ foreach (const AbstractMetaClass* metaClass, classes())
+ collectInstantiatedContainersAndSmartPointers(metaClass);
+}
+
+QList<const AbstractMetaType*> Generator::instantiatedContainers() const
+{
+ return m_d->instantiatedContainers;
+}
+
+QList<const AbstractMetaType*> Generator::instantiatedSmartPointers() const
+{
+ return m_d->instantiatedSmartPointers;
+}
+
+QMap< QString, QString > Generator::options() const
+{
+ return QMap<QString, QString>();
+}
+
+AbstractMetaClassList Generator::classes() const
+{
+ return m_d->apiextractor->classes();
+}
+
+AbstractMetaClassList Generator::classesTopologicalSorted(const Dependencies &additionalDependencies) const
+{
+ return m_d->apiextractor->classesTopologicalSorted(additionalDependencies);
+}
+
+AbstractMetaFunctionList Generator::globalFunctions() const
+{
+ return m_d->apiextractor->globalFunctions();
+}
+
+AbstractMetaEnumList Generator::globalEnums() const
+{
+ return m_d->apiextractor->globalEnums();
+}
+
+QList<const PrimitiveTypeEntry*> Generator::primitiveTypes() const
+{
+ return m_d->apiextractor->primitiveTypes();
+}
+
+QList<const ContainerTypeEntry*> Generator::containerTypes() const
+{
+ return m_d->apiextractor->containerTypes();
+}
+
+const AbstractMetaEnum* Generator::findAbstractMetaEnum(const EnumTypeEntry* typeEntry) const
+{
+ return m_d->apiextractor->findAbstractMetaEnum(typeEntry);
+}
+
+const AbstractMetaEnum* Generator::findAbstractMetaEnum(const TypeEntry* typeEntry) const
+{
+ return m_d->apiextractor->findAbstractMetaEnum(typeEntry);
+}
+
+const AbstractMetaEnum* Generator::findAbstractMetaEnum(const FlagsTypeEntry* typeEntry) const
+{
+ return m_d->apiextractor->findAbstractMetaEnum(typeEntry);
+}
+
+const AbstractMetaEnum* Generator::findAbstractMetaEnum(const AbstractMetaType* metaType) const
+{
+ return m_d->apiextractor->findAbstractMetaEnum(metaType);
+}
+
+QSet< QString > Generator::qtMetaTypeDeclaredTypeNames() const
+{
+ return m_d->apiextractor->qtMetaTypeDeclaredTypeNames();
+}
+
+QString Generator::licenseComment() const
+{
+ return m_d->licenseComment;
+}
+
+void Generator::setLicenseComment(const QString& licenseComment)
+{
+ m_d->licenseComment = licenseComment;
+}
+
+QString Generator::packageName() const
+{
+ return m_d->packageName;
+}
+
+QString Generator::moduleName() const
+{
+ QString& pkgName = m_d->packageName;
+ return QString(pkgName).remove(0, pkgName.lastIndexOf(QLatin1Char('.')) + 1);
+}
+
+QString Generator::outputDirectory() const
+{
+ return m_d->outDir;
+}
+
+void Generator::setOutputDirectory(const QString &outDir)
+{
+ m_d->outDir = outDir;
+}
+
+int Generator::numGenerated() const
+{
+ return m_d->numGenerated;
+}
+
+inline void touchFile(const QString &filePath)
+{
+ QFile toucher(filePath);
+ qint64 size = toucher.size();
+ if (!toucher.open(QIODevice::ReadWrite)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Failed to touch file '%1'")
+ .arg(QDir::toNativeSeparators(filePath));
+ return;
+ }
+ toucher.resize(size+1);
+ toucher.resize(size);
+ toucher.close();
+}
+
+bool Generator::generateFileForContext(GeneratorContext &context)
+{
+ AbstractMetaClass *cls = context.metaClass();
+
+ if (!shouldGenerate(cls))
+ return true;
+
+ const QString fileName = fileNameForContext(context);
+ if (fileName.isEmpty())
+ return true;
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug))
+ qCDebug(lcShiboken) << "generating: " << fileName;
+
+ QString filePath = outputDirectory() + QLatin1Char('/') + subDirectoryForClass(cls)
+ + QLatin1Char('/') + fileName;
+ FileOut fileOut(filePath);
+
+ generateClass(fileOut.stream, context);
+
+ FileOut::State state = fileOut.done();
+ switch (state) {
+ case FileOut::Failure:
+ return false;
+ case FileOut::Unchanged:
+ // Even if contents is unchanged, the last file modification time should be updated,
+ // so that the build system can rely on the fact the generated file is up-to-date.
+ touchFile(filePath);
+ break;
+ case FileOut::Success:
+ break;
+ }
+
+ ++m_d->numGenerated;
+ return true;
+}
+
+QString Generator::getFileNameBaseForSmartPointer(const AbstractMetaType *smartPointerType,
+ const AbstractMetaClass *smartPointerClass) const
+{
+ const AbstractMetaType *innerType = smartPointerType->getSmartPointerInnerType();
+ QString fileName = smartPointerClass->qualifiedCppName().toLower();
+ fileName.replace(QLatin1String("::"), QLatin1String("_"));
+ fileName.append(QLatin1String("_"));
+ fileName.append(innerType->name().toLower());
+
+ return fileName;
+}
+
+bool Generator::generate()
+{
+ foreach (AbstractMetaClass *cls, m_d->apiextractor->classes()) {
+ GeneratorContext context(cls);
+ if (!generateFileForContext(context))
+ return false;
+ }
+
+ foreach (const AbstractMetaType *type, instantiatedSmartPointers()) {
+ AbstractMetaClass *smartPointerClass =
+ AbstractMetaClass::findClass(m_d->apiextractor->smartPointers(), type->name());
+ GeneratorContext context(smartPointerClass, type, true);
+ if (!generateFileForContext(context))
+ return false;
+ }
+ return finishGeneration();
+}
+
+bool Generator::shouldGenerateTypeEntry(const TypeEntry* type) const
+{
+ return type->codeGeneration() & TypeEntry::GenerateTargetLang;
+}
+
+bool Generator::shouldGenerate(const AbstractMetaClass* metaClass) const
+{
+ return shouldGenerateTypeEntry(metaClass->typeEntry());
+}
+
+void verifyDirectoryFor(const QFile &file)
+{
+ QDir dir = QFileInfo(file).dir();
+ if (!dir.exists()) {
+ if (!dir.mkpath(dir.absolutePath())) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("unable to create directory '%1'").arg(dir.absolutePath());
+ }
+ }
+}
+
+void Generator::replaceTemplateVariables(QString &code, const AbstractMetaFunction *func)
+{
+ const AbstractMetaClass *cpp_class = func->ownerClass();
+ if (cpp_class)
+ code.replace(QLatin1String("%TYPE"), cpp_class->name());
+
+ foreach (AbstractMetaArgument *arg, func->arguments())
+ code.replace(QLatin1Char('%') + QString::number(arg->argumentIndex() + 1), arg->name());
+
+ //template values
+ code.replace(QLatin1String("%RETURN_TYPE"), translateType(func->type(), cpp_class));
+ code.replace(QLatin1String("%FUNCTION_NAME"), func->originalName());
+
+ if (code.contains(QLatin1String("%ARGUMENT_NAMES"))) {
+ QString str;
+ QTextStream aux_stream(&str);
+ writeArgumentNames(aux_stream, func, Generator::SkipRemovedArguments);
+ code.replace(QLatin1String("%ARGUMENT_NAMES"), str);
+ }
+
+ if (code.contains(QLatin1String("%ARGUMENTS"))) {
+ QString str;
+ QTextStream aux_stream(&str);
+ writeFunctionArguments(aux_stream, func, Options(SkipDefaultValues) | SkipRemovedArguments);
+ code.replace(QLatin1String("%ARGUMENTS"), str);
+ }
+}
+
+QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor)
+{
+ // detect number of spaces before the first character
+ QStringList lst(code.split(QLatin1Char('\n')));
+ QRegExp nonSpaceRegex(QLatin1String("[^\\s]"));
+ int spacesToRemove = 0;
+ foreach(QString line, lst) {
+ if (!line.trimmed().isEmpty()) {
+ spacesToRemove = line.indexOf(nonSpaceRegex);
+ if (spacesToRemove == -1)
+ spacesToRemove = 0;
+ break;
+ }
+ }
+
+ static QRegExp emptyLine(QLatin1String("\\s*[\\r]?[\\n]?\\s*"));
+
+ foreach(QString line, lst) {
+ if (!line.isEmpty() && !emptyLine.exactMatch(line)) {
+ while (line.end()->isSpace())
+ line.chop(1);
+ int limit = 0;
+ for(int i = 0; i < spacesToRemove; ++i) {
+ if (!line[i].isSpace())
+ break;
+ limit++;
+ }
+
+ s << indentor << line.remove(0, limit);
+ }
+ s << endl;
+ }
+ return s;
+}
+
+AbstractMetaFunctionList Generator::implicitConversions(const TypeEntry* type) const
+{
+ if (type->isValue()) {
+ if (const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(classes(), type))
+ return metaClass->implicitConversions();
+ }
+ return AbstractMetaFunctionList();
+}
+
+AbstractMetaFunctionList Generator::implicitConversions(const AbstractMetaType* metaType) const
+{
+ return implicitConversions(metaType->typeEntry());
+}
+
+bool Generator::isObjectType(const TypeEntry* type)
+{
+ if (type->isComplex())
+ return Generator::isObjectType((const ComplexTypeEntry*)type);
+ return type->isObject();
+}
+bool Generator::isObjectType(const ComplexTypeEntry* type)
+{
+ return type->isObject() || type->isQObject();
+}
+bool Generator::isObjectType(const AbstractMetaClass* metaClass)
+{
+ return Generator::isObjectType(metaClass->typeEntry());
+}
+bool Generator::isObjectType(const AbstractMetaType* metaType)
+{
+ return isObjectType(metaType->typeEntry());
+}
+
+bool Generator::isPointer(const AbstractMetaType* type)
+{
+ return type->indirections() > 0
+ || type->isNativePointer()
+ || type->isValuePointer();
+}
+
+bool Generator::isCString(const AbstractMetaType* type)
+{
+ return type->isNativePointer()
+ && type->indirections() == 1
+ && type->name() == QLatin1String("char");
+}
+
+bool Generator::isVoidPointer(const AbstractMetaType* type)
+{
+ return type->isNativePointer()
+ && type->indirections() == 1
+ && type->name() == QLatin1String("void");
+}
+
+QString Generator::getFullTypeName(const TypeEntry* type) const
+{
+ return type->isCppPrimitive()
+ ? type->qualifiedCppName()
+ : (QLatin1String("::") + type->qualifiedCppName());
+}
+
+QString Generator::getFullTypeName(const AbstractMetaType* type) const
+{
+ if (isCString(type))
+ return QLatin1String("const char*");
+ if (isVoidPointer(type))
+ return QLatin1String("void*");
+ if (type->typeEntry()->isContainer())
+ return QLatin1String("::") + type->cppSignature();
+ QString typeName;
+ if (type->typeEntry()->isComplex() && type->hasInstantiations())
+ typeName = getFullTypeNameWithoutModifiers(type);
+ else
+ typeName = getFullTypeName(type->typeEntry());
+ return typeName + QString::fromLatin1("*").repeated(type->indirections());
+}
+
+QString Generator::getFullTypeName(const AbstractMetaClass* metaClass) const
+{
+ return QLatin1String("::") + metaClass->qualifiedCppName();
+}
+
+QString Generator::getFullTypeNameWithoutModifiers(const AbstractMetaType* type) const
+{
+ if (isCString(type))
+ return QLatin1String("const char*");
+ if (isVoidPointer(type))
+ return QLatin1String("void*");
+ if (!type->hasInstantiations())
+ return getFullTypeName(type->typeEntry());
+ QString typeName = type->cppSignature();
+ if (type->isConstant())
+ typeName.remove(0, sizeof("const ") / sizeof(char) - 1);
+ switch (type->referenceType()) {
+ case NoReference:
+ break;
+ case LValueReference:
+ typeName.chop(1);
+ break;
+ case RValueReference:
+ typeName.chop(2);
+ break;
+ }
+ while (typeName.endsWith(QLatin1Char('*')) || typeName.endsWith(QLatin1Char(' ')))
+ typeName.chop(1);
+ return QLatin1String("::") + typeName;
+}
+
+QString Generator::minimalConstructor(const AbstractMetaType* type) const
+{
+ if (!type || (type->referenceType() == LValueReference && Generator::isObjectType(type)))
+ return QString();
+
+ if (type->isContainer()) {
+ QString ctor = type->cppSignature();
+ if (ctor.endsWith(QLatin1Char('*')))
+ return QLatin1String("0");
+ if (ctor.startsWith(QLatin1String("const ")))
+ ctor.remove(0, sizeof("const ") / sizeof(char) - 1);
+ if (ctor.endsWith(QLatin1Char('&'))) {
+ ctor.chop(1);
+ ctor = ctor.trimmed();
+ }
+ return QLatin1String("::") + ctor + QLatin1String("()");
+ }
+
+ if (type->isNativePointer())
+ return QLatin1String("static_cast<") + type->typeEntry()->qualifiedCppName() + QLatin1String(" *>(0)");
+ if (Generator::isPointer(type))
+ return QLatin1String("static_cast< ::") + type->typeEntry()->qualifiedCppName() + QLatin1String(" *>(0)");
+
+ if (type->typeEntry()->isComplex()) {
+ const ComplexTypeEntry* cType = reinterpret_cast<const ComplexTypeEntry*>(type->typeEntry());
+ QString ctor = cType->defaultConstructor();
+ if (!ctor.isEmpty())
+ return ctor;
+ ctor = minimalConstructor(AbstractMetaClass::findClass(classes(), cType));
+ if (type->hasInstantiations())
+ ctor = ctor.replace(getFullTypeName(cType), getFullTypeNameWithoutModifiers(type));
+ return ctor;
+ }
+
+ return minimalConstructor(type->typeEntry());
+}
+
+QString Generator::minimalConstructor(const TypeEntry* type) const
+{
+ if (!type)
+ return QString();
+
+ if (type->isCppPrimitive()) {
+ const QString &name = type->qualifiedCppName();
+ return name == QLatin1String("bool")
+ ? QLatin1String("false") : name + QLatin1String("(0)");
+ }
+
+ if (type->isEnum())
+ return QLatin1String("static_cast< ::") + type->qualifiedCppName() + QLatin1String(">(0)");
+
+ if (type->isFlags())
+ return type->qualifiedCppName() + QLatin1String("(0)");
+
+ if (type->isPrimitive()) {
+ QString ctor = reinterpret_cast<const PrimitiveTypeEntry*>(type)->defaultConstructor();
+ // If a non-C++ (i.e. defined by the user) primitive type does not have
+ // a default constructor defined by the user, the empty constructor is
+ // heuristically returned. If this is wrong the build of the generated
+ // bindings will tell.
+ return ctor.isEmpty()
+ ? (QLatin1String("::") + type->qualifiedCppName() + QLatin1String("()"))
+ : ctor;
+ }
+
+ if (type->isComplex())
+ return minimalConstructor(AbstractMetaClass::findClass(classes(), type));
+
+ return QString();
+}
+
+QString Generator::minimalConstructor(const AbstractMetaClass* metaClass) const
+{
+ if (!metaClass)
+ return QString();
+
+ const ComplexTypeEntry* cType = reinterpret_cast<const ComplexTypeEntry*>(metaClass->typeEntry());
+ if (cType->hasDefaultConstructor())
+ return cType->defaultConstructor();
+
+ AbstractMetaFunctionList constructors = metaClass->queryFunctions(AbstractMetaClass::Constructors);
+ int maxArgs = 0;
+ foreach (const AbstractMetaFunction* ctor, constructors) {
+ if (ctor->isUserAdded() || ctor->isPrivate() || ctor->functionType() != AbstractMetaFunction::ConstructorFunction)
+ continue;
+
+ int numArgs = ctor->arguments().size();
+ if (numArgs == 0) {
+ maxArgs = 0;
+ break;
+ }
+ if (numArgs > maxArgs)
+ maxArgs = numArgs;
+ }
+
+ QString qualifiedCppName = metaClass->typeEntry()->qualifiedCppName();
+ QStringList templateTypes;
+ foreach (TypeEntry* templateType, metaClass->templateArguments())
+ templateTypes << templateType->qualifiedCppName();
+
+ // Empty constructor.
+ if (maxArgs == 0)
+ return QLatin1String("::") + qualifiedCppName + QLatin1String("()");
+
+ QList<const AbstractMetaFunction*> candidates;
+
+ // Constructors with C++ primitive types, enums or pointers only.
+ // Start with the ones with fewer arguments.
+ for (int i = 1; i <= maxArgs; ++i) {
+ foreach (const AbstractMetaFunction* ctor, constructors) {
+ if (ctor->isUserAdded() || ctor->isPrivate() || ctor->functionType() != AbstractMetaFunction::ConstructorFunction)
+ continue;
+
+ AbstractMetaArgumentList arguments = ctor->arguments();
+ if (arguments.size() != i)
+ continue;
+
+ QStringList args;
+ foreach (const AbstractMetaArgument* arg, arguments) {
+ const TypeEntry* type = arg->type()->typeEntry();
+ if (type == metaClass->typeEntry()) {
+ args.clear();
+ break;
+ }
+
+ if (!arg->originalDefaultValueExpression().isEmpty()) {
+ if (!arg->defaultValueExpression().isEmpty()
+ && arg->defaultValueExpression() != arg->originalDefaultValueExpression()) {
+ args << arg->defaultValueExpression();
+ }
+ break;
+ }
+
+ if (type->isCppPrimitive() || type->isEnum() || isPointer(arg->type())) {
+ QString argValue = minimalConstructor(arg->type());
+ if (argValue.isEmpty()) {
+ args.clear();
+ break;
+ }
+ args << argValue;
+ } else {
+ args.clear();
+ break;
+ }
+ }
+
+ if (!args.isEmpty())
+ return QString::fromLatin1("::%1(%2)").arg(qualifiedCppName, args.join(QLatin1String(", ")));
+
+ candidates << ctor;
+ }
+ }
+
+ // Constructors with C++ primitive types, enums, pointers, value types,
+ // and user defined primitive types.
+ // Builds the minimal constructor recursively.
+ foreach (const AbstractMetaFunction* ctor, candidates) {
+ QStringList args;
+ foreach (const AbstractMetaArgument* arg, ctor->arguments()) {
+ if (arg->type()->typeEntry() == metaClass->typeEntry()) {
+ args.clear();
+ break;
+ }
+ QString argValue = minimalConstructor(arg->type());
+ if (argValue.isEmpty()) {
+ args.clear();
+ break;
+ }
+ args << argValue;
+ }
+ if (!args.isEmpty()) {
+ return QString::fromLatin1("::%1(%2)").arg(qualifiedCppName, args.join(QLatin1String(", ")));
+ }
+ }
+
+ return QString();
+}
+
+QString Generator::translateType(const AbstractMetaType *cType,
+ const AbstractMetaClass *context,
+ Options options) const
+{
+ QString s;
+ static int constLen = strlen("const");
+
+ if (context && cType &&
+ context->typeEntry()->isGenericClass() &&
+ cType->originalTemplateType()) {
+ cType = cType->originalTemplateType();
+ }
+
+ if (!cType) {
+ s = QLatin1String("void");
+ } else if (cType->isArray()) {
+ s = translateType(cType->arrayElementType(), context, options) + QLatin1String("[]");
+ } else if (options & Generator::EnumAsInts && (cType->isEnum() || cType->isFlags())) {
+ s = QLatin1String("int");
+ } else {
+ if (options & Generator::OriginalName) {
+ s = cType->originalTypeDescription().trimmed();
+ if ((options & Generator::ExcludeReference) && s.endsWith(QLatin1Char('&')))
+ s.chop(1);
+
+ // remove only the last const (avoid remove template const)
+ if (options & Generator::ExcludeConst) {
+ int index = s.lastIndexOf(QLatin1String("const"));
+
+ if (index >= (s.size() - (constLen + 1))) // (VarType const) or (VarType const[*|&])
+ s = s.remove(index, constLen);
+ }
+ } else if (options & Generator::ExcludeConst || options & Generator::ExcludeReference) {
+ AbstractMetaType* copyType = cType->copy();
+
+ if (options & Generator::ExcludeConst)
+ copyType->setConstant(false);
+
+ if (options & Generator::ExcludeReference)
+ copyType->setReferenceType(NoReference);
+
+ s = copyType->cppSignature();
+ if (!copyType->typeEntry()->isVoid() && !copyType->typeEntry()->isCppPrimitive())
+ s.prepend(QLatin1String("::"));
+ delete copyType;
+ } else {
+ s = cType->cppSignature();
+ }
+ }
+
+ return s;
+}
+
+
+QString Generator::subDirectoryForClass(const AbstractMetaClass* clazz) const
+{
+ return subDirectoryForPackage(clazz->package());
+}
+
+QString Generator::subDirectoryForPackage(QString packageName) const
+{
+ if (packageName.isEmpty())
+ packageName = m_d->packageName;
+ return QString(packageName).replace(QLatin1Char('.'), QDir::separator());
+}
+
+template<typename T>
+static QString getClassTargetFullName_(const T* t, bool includePackageName)
+{
+ QString name = t->name();
+ const AbstractMetaClass* context = t->enclosingClass();
+ while (context) {
+ name.prepend(QLatin1Char('.'));
+ name.prepend(context->name());
+ context = context->enclosingClass();
+ }
+ if (includePackageName) {
+ name.prepend(QLatin1Char('.'));
+ name.prepend(t->package());
+ }
+ return name;
+}
+
+QString getClassTargetFullName(const AbstractMetaClass* metaClass, bool includePackageName)
+{
+ return getClassTargetFullName_(metaClass, includePackageName);
+}
+
+QString getClassTargetFullName(const AbstractMetaEnum* metaEnum, bool includePackageName)
+{
+ return getClassTargetFullName_(metaEnum, includePackageName);
+}
+
+QString getClassTargetFullName(const AbstractMetaType *metaType, bool includePackageName)
+{
+ QString name = metaType->cppSignature();
+ name.replace(QLatin1String("::"), QLatin1String("_"));
+ name.replace(QLatin1Char('<'), QLatin1Char('_'));
+ name.remove(QLatin1Char('>'));
+ name.remove(QLatin1Char(' '));
+ if (includePackageName) {
+ name.prepend(QLatin1Char('.'));
+ name.prepend(metaType->package());
+ }
+ return name;
+}
+
+QString getFilteredCppSignatureString(QString signature)
+{
+ signature.replace(QLatin1String("::"), QLatin1String("_"));
+ signature.replace(QLatin1Char('<'), QLatin1Char('_'));
+ signature.replace(QLatin1Char('>'), QLatin1Char('_'));
+ signature.replace(QLatin1Char(' '), QLatin1Char('_'));
+ return signature;
+}
diff --git a/sources/shiboken2/generator/generator.h b/sources/shiboken2/generator/generator.h
new file mode 100644
index 000000000..f734ff9d7
--- /dev/null
+++ b/sources/shiboken2/generator/generator.h
@@ -0,0 +1,447 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GENERATOR_H
+#define GENERATOR_H
+
+#include <abstractmetalang_typedefs.h>
+#include <dependency.h>
+#include <QtCore/QObject>
+#include <QtCore/QSharedPointer>
+#include <QtCore/QTextStream>
+#include <QtCore/QVector>
+
+class ApiExtractor;
+class AbstractMetaBuilder;
+class AbstractMetaFunction;
+class AbstractMetaClass;
+class AbstractMetaEnum;
+class TypeEntry;
+class ComplexTypeEntry;
+class AbstractMetaType;
+class EnumTypeEntry;
+class FlagsTypeEntry;
+
+QT_BEGIN_NAMESPACE
+class QFile;
+QT_END_NAMESPACE
+
+class PrimitiveTypeEntry;
+class ContainerTypeEntry;
+class Indentor;
+
+QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor);
+void verifyDirectoryFor(const QFile &file);
+
+QString getClassTargetFullName(const AbstractMetaClass* metaClass, bool includePackageName = true);
+QString getClassTargetFullName(const AbstractMetaEnum* metaEnum, bool includePackageName = true);
+QString getClassTargetFullName(const AbstractMetaType *metaType, bool includePackageName = true);
+QString getFilteredCppSignatureString(QString signature);
+
+/**
+ * PYSIDE-504: Handling the "protected hack"
+ *
+ * The problem: Creating wrappers when the class has private destructors.
+ * You can see an example on Windows in qclipboard_wrapper.h and others.
+ * Simply search for the text "// C++11: need to declare (unimplemented) destructor".
+ *
+ * The protected hack is the definition "#define protected public".
+ * For most compilers, this "hack" is enabled, because the problem of private
+ * destructors simply vanishes.
+ *
+ * If one does not want to use this hack, then a new problem arises:
+ * C++11 requires that a destructor is declared in a wrapper class when it is
+ * private in the base class. There is no implementation allowed!
+ *
+ * Unfortunately, MSVC in recent versions supports C++11, and due to restrictive
+ * rules, it is impossible to use the hack with this compiler.
+ * More unfortunate: Clang, when C++11 is enabled, also enforces a declaration
+ * of a private destructor, but it falsely then creates a linker error!
+ *
+ * Originally, we wanted to remove the protected hack. But due to the Clang
+ * problem, we gave up on removal of the protected hack and use it always
+ * when we can. This might change again when the Clang problem is solved.
+ */
+
+#ifdef Q_CC_MSVC
+const int alwaysGenerateDestructor = 1;
+#else
+const int alwaysGenerateDestructor = 0;
+#endif
+
+/**
+ * A GeneratorContext object contains a pointer to an AbstractMetaClass and/or a specialized
+ * AbstractMetaType, for which code is currently being generated.
+ *
+ * The main case is when the context contains only an AbstractMetaClass pointer, which is used
+ * by different methods to generate appropriate expressions, functions, type names, etc.
+ *
+ * The second case is for generation of code for smart pointers. In this case the m_metaClass member
+ * contains the generic template class of the smart pointer, and the m_preciseClassType member
+ * contains the instantiated template type, e.g. a concrete shared_ptr<int>. To
+ * distinguish this case, the member m_forSmartPointer is set to true.
+ *
+ * In the future the second case might be generalized for all template type instantiations.
+ */
+class GeneratorContext {
+public:
+ GeneratorContext() : m_metaClass(0), m_preciseClassType(0), m_forSmartPointer(false) {}
+ GeneratorContext(AbstractMetaClass *metaClass,
+ const AbstractMetaType *preciseType = 0,
+ bool forSmartPointer = false)
+ : m_metaClass(metaClass),
+ m_preciseClassType(preciseType),
+ m_forSmartPointer(forSmartPointer) {}
+
+
+ AbstractMetaClass *metaClass() const { return m_metaClass; }
+ bool forSmartPointer() const { return m_forSmartPointer; }
+ const AbstractMetaType *preciseType() const { return m_preciseClassType; }
+
+private:
+ AbstractMetaClass *m_metaClass;
+ const AbstractMetaType *m_preciseClassType;
+ bool m_forSmartPointer;
+};
+
+/**
+ * Base class for all generators. The default implementations does nothing,
+ * you must subclass this to create your own generators.
+ */
+class Generator
+{
+public:
+ /// Optiosn used around the generator code
+ enum Option {
+ NoOption = 0x00000000,
+ BoxedPrimitive = 0x00000001,
+ ExcludeConst = 0x00000002,
+ ExcludeReference = 0x00000004,
+ UseNativeIds = 0x00000008,
+
+ EnumAsInts = 0x00000010,
+ SkipName = 0x00000020,
+ NoCasts = 0x00000040,
+ SkipReturnType = 0x00000080,
+ OriginalName = 0x00000100,
+ ShowStatic = 0x00000200,
+ UnderscoreSpaces = 0x00000400,
+ ForceEnumCast = 0x00000800,
+ ArrayAsPointer = 0x00001000,
+ VirtualCall = 0x00002000,
+ SkipTemplateParameters = 0x00004000,
+ SkipAttributes = 0x00008000,
+ OriginalTypeDescription = 0x00010000,
+ SkipRemovedArguments = 0x00020000,
+ IncludeDefaultExpression = 0x00040000,
+ NoReturnStatement = 0x00080000,
+ NoBlockedSlot = 0x00100000,
+
+ SuperCall = 0x00200000,
+
+ GlobalRefJObject = 0x00100000,
+
+ SkipDefaultValues = 0x00400000,
+
+ WriteSelf = 0x00800000,
+ ExcludeMethodConst = 0x01000000,
+
+ ForceValueType = ExcludeReference | ExcludeConst
+ };
+ Q_DECLARE_FLAGS(Options, Option)
+
+ Generator();
+ virtual ~Generator();
+
+ bool setup(const ApiExtractor& extractor, const QMap<QString, QString> args);
+
+ virtual QMap<QString, QString> options() const;
+
+ /// Returns the classes used to generate the binding code.
+ AbstractMetaClassList classes() const;
+
+ /// Returns the classes, topologically ordered, used to generate the binding code.
+ ///
+ /// The classes are ordered such that derived classes appear later in the list than
+ /// their parent classes.
+ AbstractMetaClassList classesTopologicalSorted(const Dependencies &additionalDependencies = Dependencies()) const;
+
+ /// Returns all global functions found by APIExtractor
+ AbstractMetaFunctionList globalFunctions() const;
+
+ /// Returns all global enums found by APIExtractor
+ AbstractMetaEnumList globalEnums() const;
+
+ /// Returns all primitive types found by APIExtractor
+ QList<const PrimitiveTypeEntry*> primitiveTypes() const;
+
+ /// Returns all container types found by APIExtractor
+ QList<const ContainerTypeEntry*> containerTypes() const;
+
+ /// Returns an AbstractMetaEnum for a given EnumTypeEntry, or NULL if not found.
+ const AbstractMetaEnum* findAbstractMetaEnum(const EnumTypeEntry* typeEntry) const;
+
+ /// Returns an AbstractMetaEnum for a given TypeEntry that is an EnumTypeEntry, or NULL if not found.
+ const AbstractMetaEnum* findAbstractMetaEnum(const TypeEntry* typeEntry) const;
+
+ /// Returns an AbstractMetaEnum for the enum related to a given FlagsTypeEntry, or NULL if not found.
+ const AbstractMetaEnum* findAbstractMetaEnum(const FlagsTypeEntry* typeEntry) const;
+
+ /// Returns an AbstractMetaEnum for a given AbstractMetaType that holds an EnumTypeEntry, or NULL if not found.
+ const AbstractMetaEnum* findAbstractMetaEnum(const AbstractMetaType* metaType) const;
+
+ /// Returns the output directory
+ QString outputDirectory() const;
+
+ /// Set the output directory
+ void setOutputDirectory(const QString &outDir);
+
+ /**
+ * Start the code generation, be sure to call setClasses before callign this method.
+ * For each class it creates a QTextStream, call the write method with the current
+ * class and the associated text stream, then write the text stream contents if needed.
+ * \see #write
+ */
+ bool generate();
+
+
+ /// Generates a file for given AbstractMetaClass or AbstractMetaType (smart pointer case).
+ bool generateFileForContext(GeneratorContext &context);
+
+ /// Returns the file base name for a smart pointer.
+ QString getFileNameBaseForSmartPointer(const AbstractMetaType *smartPointerType,
+ const AbstractMetaClass *smartPointerClass) const;
+
+ /// Returns the number of generated items
+ int numGenerated() const;
+
+ /// Returns the generator's name. Used for cosmetic purposes.
+ virtual const char* name() const = 0;
+
+ /// Returns true if the generator should generate any code for the TypeEntry.
+ bool shouldGenerateTypeEntry(const TypeEntry*) const;
+
+ /// Returns true if the generator should generate any code for the AbstractMetaClass.
+ virtual bool shouldGenerate(const AbstractMetaClass *) const;
+
+ /// Returns the subdirectory used to write the binding code of an AbstractMetaClass.
+ virtual QString subDirectoryForClass(const AbstractMetaClass* clazz) const;
+
+ /**
+ * Translate metatypes to binding source format.
+ * \param metatype a pointer to metatype
+ * \param context the current meta class
+ * \param option some extra options
+ * \return the metatype translated to binding source format
+ */
+ QString translateType(const AbstractMetaType *metatype,
+ const AbstractMetaClass *context,
+ Options options = NoOption) const;
+
+ /**
+ * Function used to write the fucntion arguments on the class buffer.
+ * \param s the class output buffer
+ * \param metafunction the pointer to metafunction information
+ * \param count the number of function arguments
+ * \param options some extra options used during the parser
+ */
+ virtual void writeFunctionArguments(QTextStream &s,
+ const AbstractMetaFunction *metafunction,
+ Options options = NoOption) const = 0;
+
+ virtual void writeArgumentNames(QTextStream &s,
+ const AbstractMetaFunction *metafunction,
+ Options options = NoOption) const = 0;
+
+ void replaceTemplateVariables(QString &code, const AbstractMetaFunction *func);
+
+ // QtScript
+ QSet<QString> qtMetaTypeDeclaredTypeNames() const;
+
+ /**
+ * Returns the license comment to be prepended to each source file generated.
+ */
+ QString licenseComment() const;
+
+ /**
+ * Sets the license comment to be prepended to each source file generated.
+ */
+ void setLicenseComment(const QString &licenseComment);
+
+ /**
+ * Returns the package name.
+ */
+ QString packageName() const;
+
+ /**
+ * Retrieves the name of the currently processed module.
+ * While package name is a complete package idetification, e.g. 'PySide.QtCore',
+ * a module name represents the last part of the package, e.g. 'QtCore'.
+ * If the target language separates the modules with characters other than
+ * dots ('.') the generator subclass must overload this method.
+ * \return a string representing the last part of a package name
+ */
+ virtual QString moduleName() const;
+
+ /**
+ * Retrieves a list of constructors used in implicit conversions
+ * available on the given type. The TypeEntry must be a value-type
+ * or else it will return an empty list.
+ * \param type a TypeEntry that is expected to be a value-type
+ * \return a list of constructors that could be used as implicit converters
+ */
+ AbstractMetaFunctionList implicitConversions(const TypeEntry* type) const;
+
+ /// Convenience function for implicitConversions(const TypeEntry* type).
+ AbstractMetaFunctionList implicitConversions(const AbstractMetaType* metaType) const;
+
+ /// Check if type is a pointer.
+ static bool isPointer(const AbstractMetaType* type);
+
+ /// Tells if the type or class is an Object (or QObject) Type.
+ static bool isObjectType(const TypeEntry* type);
+ static bool isObjectType(const ComplexTypeEntry* type);
+ static bool isObjectType(const AbstractMetaType* metaType);
+ static bool isObjectType(const AbstractMetaClass* metaClass);
+
+ /// Returns true if the type is a C string (const char*).
+ static bool isCString(const AbstractMetaType* type);
+ /// Returns true if the type is a void pointer.
+ static bool isVoidPointer(const AbstractMetaType* type);
+
+ // Returns the full name of the type.
+ QString getFullTypeName(const TypeEntry* type) const;
+ QString getFullTypeName(const AbstractMetaType* type) const;
+ QString getFullTypeName(const AbstractMetaClass* metaClass) const;
+
+ /**
+ * Returns the full qualified C++ name for an AbstractMetaType, but removing modifiers
+ * as 'const', '&', and '*' (except if the class is not derived from a template).
+ * This is useful for instantiated templates.
+ */
+ QString getFullTypeNameWithoutModifiers(const AbstractMetaType* type) const;
+
+ /**
+ * Tries to build a minimal constructor for the type.
+ * It will check first for a user defined default constructor.
+ * Returns a null string if it fails.
+ */
+ QString minimalConstructor(const TypeEntry* type) const;
+ QString minimalConstructor(const AbstractMetaType* type) const;
+ QString minimalConstructor(const AbstractMetaClass* metaClass) const;
+
+protected:
+ /**
+ * Returns the file name used to write the binding code of an AbstractMetaClass/Type.
+ * \param context the GeneratorContext which contains an AbstractMetaClass or AbstractMetaType
+ * for which the file name must be returned
+ * \return the file name used to write the binding code for the class
+ */
+ virtual QString fileNamePrefix() const = 0;
+ virtual QString fileNameForContext(GeneratorContext &context) const = 0;
+
+
+ virtual bool doSetup(const QMap<QString, QString>& args) = 0;
+
+ /**
+ * Write the bindding code for an AbstractMetaClass.
+ * This is called by generate method.
+ * \param s text stream to write the generated output
+ * \param metaClass the class that should be generated
+ */
+ virtual void generateClass(QTextStream& s, GeneratorContext &classContext) = 0;
+ virtual bool finishGeneration() = 0;
+
+ /**
+ * Returns the subdirectory path for a given package
+ * (aka module, aka library) name.
+ * If the target language separates the package modules with characters other
+ * than dots ('.') the generator subclass must overload this method.
+ * /param packageName complete package name for which to return the subdirectory path
+ * or nothing the use the name of the currently processed package
+ * /return a string representing the subdirectory path for the given package
+ */
+ virtual QString subDirectoryForPackage(QString packageName = QString()) const;
+
+ QList<const AbstractMetaType*> instantiatedContainers() const;
+ QList<const AbstractMetaType*> instantiatedSmartPointers() const;
+
+ static QString getSimplifiedContainerTypeName(const AbstractMetaType *type);
+ void addInstantiatedContainersAndSmartPointers(const AbstractMetaType *type,
+ const QString &context);
+
+private:
+ struct GeneratorPrivate;
+ GeneratorPrivate* m_d;
+ void collectInstantiatedContainersAndSmartPointers(const AbstractMetaFunction* func);
+ void collectInstantiatedContainersAndSmartPointers(const AbstractMetaClass *metaClass);
+ void collectInstantiatedContainersAndSmartPointers();
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(Generator::Options)
+typedef QSharedPointer<Generator> GeneratorPtr;
+typedef QVector<GeneratorPtr> Generators;
+
+/**
+* Utility class to store the identation level, use it in a QTextStream.
+*/
+class Indentor
+{
+public:
+ Indentor() : indent(0) {}
+ int indent;
+};
+
+/**
+* Class that use the RAII idiom to set and unset the identation level.
+*/
+class Indentation
+{
+public:
+ Indentation(Indentor &indentor) : indentor(indentor)
+ {
+ indentor.indent++;
+ }
+ ~Indentation()
+ {
+ indentor.indent--;
+ }
+
+private:
+ Indentor &indentor;
+};
+
+inline QTextStream &operator <<(QTextStream &s, const Indentor &indentor)
+{
+ for (int i = 0; i < indentor.indent; ++i)
+ s << " ";
+ return s;
+}
+
+#endif // GENERATOR_H
+
diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp
new file mode 100644
index 000000000..874540e54
--- /dev/null
+++ b/sources/shiboken2/generator/main.cpp
@@ -0,0 +1,529 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QCoreApplication>
+#include <QElapsedTimer>
+#include <QLinkedList>
+#include <QLibrary>
+#include <QtCore/QFile>
+#include <QtCore/QDir>
+#include <iostream>
+#include <apiextractor.h>
+#include "generator.h"
+#include "shibokenconfig.h"
+#include "cppgenerator.h"
+#include "headergenerator.h"
+#include "qtdocgenerator.h"
+
+#ifdef _WINDOWS
+ #define PATH_SPLITTER ";"
+#else
+ #define PATH_SPLITTER ":"
+#endif
+
+namespace {
+
+class ArgsHandler
+{
+public:
+ explicit ArgsHandler(const QMap<QString, QString>& other);
+ virtual ~ArgsHandler();
+
+ inline QMap<QString, QString>& args() const
+ {
+ return *m_args;
+ }
+
+ inline bool argExists(const QString& s) const
+ {
+ return m_args->contains(s);
+ }
+
+ QString removeArg(const QString& s);
+ bool argExistsRemove(const QString& s);
+
+ inline QString argValue(const QString& s) const
+ {
+ return m_args->value(s);
+ }
+
+ inline bool noArgs() const
+ {
+ return m_args->isEmpty();
+ }
+
+ QString errorMessage() const;
+
+private:
+ QMap<QString, QString>* m_args;
+};
+
+ArgsHandler::ArgsHandler(const QMap<QString, QString>& other)
+ : m_args(new QMap<QString, QString>(other))
+{
+}
+
+ArgsHandler::~ArgsHandler()
+{
+ delete m_args;
+}
+
+QString ArgsHandler::removeArg(const QString& s)
+{
+ QString retval;
+
+ if (argExists(s)) {
+ retval = argValue(s);
+ m_args->remove(s);
+ }
+
+ return retval;
+}
+
+bool ArgsHandler::argExistsRemove(const QString& s)
+{
+ bool retval = false;
+
+ if (argExists(s)) {
+ retval = true;
+ m_args->remove(s);
+ }
+
+ return retval;
+}
+
+QString ArgsHandler::errorMessage() const
+{
+ typedef QMap<QString, QString>::ConstIterator StringMapConstIt;
+
+ QString message;
+ QTextStream str(&message);
+ str << "shiboken: Called with wrong arguments:";
+ for (StringMapConstIt it = m_args->cbegin(), end = m_args->cend(); it != end; ++it) {
+ str << ' ' << it.key();
+ if (!it.value().isEmpty())
+ str << ' ' << it.value();
+ }
+ str << "\nCommand line: " << QCoreApplication::arguments().join(QLatin1Char(' '));
+ return message;
+}
+}
+
+static void printOptions(QTextStream& s, const QMap<QString, QString>& options)
+{
+ QMap<QString, QString>::const_iterator it = options.constBegin();
+ s.setFieldAlignment(QTextStream::AlignLeft);
+ for (; it != options.constEnd(); ++it) {
+ s << " --";
+ s.setFieldWidth(38);
+ s << it.key() << it.value();
+ s.setFieldWidth(0);
+ s << endl;
+ }
+}
+
+typedef void (*getGeneratorsFunc)(QLinkedList<Generator*>*);
+
+static bool processProjectFile(QFile& projectFile, QMap<QString, QString>& args)
+{
+ QByteArray line = projectFile.readLine().trimmed();
+ if (line.isEmpty() || line != "[generator-project]")
+ return false;
+
+ QStringList includePaths;
+ QStringList typesystemPaths;
+ QStringList apiVersions;
+
+ while (!projectFile.atEnd()) {
+ line = projectFile.readLine().trimmed();
+ if (line.isEmpty())
+ continue;
+
+ int split = line.indexOf('=');
+ QByteArray key;
+ QString value;
+ if (split > 0) {
+ key = line.left(split - 1).trimmed();
+ value = QString::fromUtf8(line.mid(split + 1).trimmed());
+ } else {
+ key = line;
+ }
+
+ if (key == "include-path")
+ includePaths << QDir::toNativeSeparators(value);
+ else if (key == "typesystem-path")
+ typesystemPaths << QDir::toNativeSeparators(value);
+ else if (key == "api-version")
+ apiVersions << value;
+ else if (key == "header-file")
+ args.insert(QLatin1String("arg-1"), value);
+ else if (key == "typesystem-file")
+ args.insert(QLatin1String("arg-2"), value);
+ else
+ args.insert(QString::fromUtf8(key), value);
+ }
+
+ if (!includePaths.isEmpty())
+ args.insert(QLatin1String("include-paths"), includePaths.join(QLatin1String(PATH_SPLITTER)));
+
+ if (!typesystemPaths.isEmpty())
+ args.insert(QLatin1String("typesystem-paths"), typesystemPaths.join(QLatin1String(PATH_SPLITTER)));
+ if (!apiVersions.isEmpty())
+ args.insert(QLatin1String("api-version"), apiVersions.join(QLatin1Char('|')));
+ return true;
+}
+
+static QMap<QString, QString> getInitializedArguments()
+{
+ QMap<QString, QString> args;
+ QStringList arguments = QCoreApplication::arguments();
+ QString appName = arguments.first();
+ arguments.removeFirst();
+
+ QString projectFileName;
+ foreach (const QString& arg, arguments) {
+ if (arg.startsWith(QLatin1String("--project-file"))) {
+ int split = arg.indexOf(QLatin1Char('='));
+ if (split > 0)
+ projectFileName = arg.mid(split + 1).trimmed();
+ break;
+ }
+ }
+
+ if (projectFileName.isNull())
+ return args;
+
+ if (!QFile::exists(projectFileName)) {
+ std::cerr << qPrintable(appName) << ": Project file \"";
+ std::cerr << qPrintable(projectFileName) << "\" not found.";
+ std::cerr << std::endl;
+ return args;
+ }
+
+ QFile projectFile(projectFileName);
+ if (!projectFile.open(QIODevice::ReadOnly))
+ return args;
+
+ if (!processProjectFile(projectFile, args)) {
+ std::cerr << qPrintable(appName) << ": first line of project file \"";
+ std::cerr << qPrintable(projectFileName) << "\" must be the string \"[generator-project]\"";
+ std::cerr << std::endl;
+ return args;
+ }
+
+ return args;
+}
+
+static QMap<QString, QString> getCommandLineArgs()
+{
+ QMap<QString, QString> args = getInitializedArguments();
+ QStringList arguments = QCoreApplication::arguments();
+ arguments.removeFirst();
+
+ int argNum = 0;
+ foreach (const QString &carg, arguments) {
+ const QString &arg = carg.trimmed();
+ if (arg.startsWith(QLatin1String("--"))) {
+ int split = arg.indexOf(QLatin1Char('='));
+ if (split > 0)
+ args[arg.mid(2).left(split-2)] = arg.mid(split + 1).trimmed();
+ else
+ args[arg.mid(2)] = QString();
+ } else if (arg.startsWith(QLatin1Char('-'))) {
+ args[arg.mid(1)] = QString();
+ } else {
+ argNum++;
+ args[QString::fromLatin1("arg-%1").arg(argNum)] = arg;
+ }
+ }
+ return args;
+}
+
+static inline Generators docGenerators()
+{
+ Generators result;
+#ifdef DOCSTRINGS_ENABLED
+ result.append(GeneratorPtr(new QtDocGenerator));
+#endif
+ return result;
+}
+
+static inline Generators shibokenGenerators()
+{
+ Generators result;
+ result << GeneratorPtr(new CppGenerator) << GeneratorPtr(new HeaderGenerator);
+ return result;
+}
+
+void printUsage()
+{
+ QTextStream s(stdout);
+ s << "Usage:\n "
+ << "shiboken [options] header-file typesystem-file\n\n"
+ << "General options:\n";
+ QMap<QString, QString> generalOptions;
+ generalOptions.insert(QLatin1String("project-file=<file>"),
+ QLatin1String("text file containing a description of the binding project. Replaces and overrides command line arguments"));
+ generalOptions.insert(QLatin1String("debug-level=[sparse|medium|full]"),
+ QLatin1String("Set the debug level"));
+ generalOptions.insert(QLatin1String("silent"),
+ QLatin1String("Avoid printing any message"));
+ generalOptions.insert(QLatin1String("help"),
+ QLatin1String("Display this help and exit"));
+ generalOptions.insert(QLatin1String("no-suppress-warnings"),
+ QLatin1String("Show all warnings"));
+ generalOptions.insert(QLatin1String("output-directory=<path>"),
+ QLatin1String("The directory where the generated files will be written"));
+ generalOptions.insert(QLatin1String("include-paths=<path>[" PATH_SPLITTER "<path>" PATH_SPLITTER "...]"),
+ QLatin1String("Include paths used by the C++ parser"));
+ generalOptions.insert(QLatin1String("typesystem-paths=<path>[" PATH_SPLITTER "<path>" PATH_SPLITTER "...]"),
+ QLatin1String("Paths used when searching for typesystems"));
+ generalOptions.insert(QLatin1String("documentation-only"),
+ QLatin1String("Do not generates any code, just the documentation"));
+ generalOptions.insert(QLatin1String("license-file=<license-file>"),
+ QLatin1String("File used for copyright headers of generated files"));
+ generalOptions.insert(QLatin1String("version"),
+ QLatin1String("Output version information and exit"));
+ generalOptions.insert(QLatin1String("generator-set=<\"generator module\">"),
+ QLatin1String("generator-set to be used. e.g. qtdoc"));
+ generalOptions.insert(QLatin1String("api-version=<\"package mask\">,<\"version\">"),
+ QLatin1String("Specify the supported api version used to generate the bindings"));
+ generalOptions.insert(QLatin1String("drop-type-entries=\"<TypeEntry0>[;TypeEntry1;...]\""),
+ QLatin1String("Semicolon separated list of type system entries (classes, namespaces, global functions and enums) to be dropped from generation."));
+ printOptions(s, generalOptions);
+
+ const Generators generators = shibokenGenerators() + docGenerators();
+ foreach (const GeneratorPtr &generator, generators) {
+ QMap<QString, QString> options = generator->options();
+ if (!options.isEmpty()) {
+ s << endl << generator->name() << " options:\n";
+ printOptions(s, generator->options());
+ }
+ }
+}
+
+static inline void printVerAndBanner()
+{
+ std::cout << "shiboken v" SHIBOKEN_VERSION << std::endl;
+ std::cout << "Copyright (C) 2016 The Qt Company Ltd." << std::endl;
+}
+
+static inline void errorPrint(const QString& s)
+{
+ QStringList arguments = QCoreApplication::arguments();
+ arguments.pop_front();
+ std::cerr << "shiboken: " << qPrintable(s)
+ << "\nCommand line: " << qPrintable(arguments.join(QLatin1Char(' '))) << '\n';
+}
+
+static QString msgInvalidVersion(const QString &package, const QString &version)
+{
+ return QLatin1String("Invalid version \"") + version
+ + QLatin1String("\" specified for package ") + package + QLatin1Char('.');
+}
+
+int main(int argc, char *argv[])
+{
+ QElapsedTimer timer;
+ timer.start();
+ // needed by qxmlpatterns
+ QCoreApplication app(argc, argv);
+ ReportHandler::install();
+ qCDebug(lcShiboken()).noquote().nospace() << QCoreApplication::arguments().join(QLatin1Char(' '));
+
+ // Store command arguments in a map
+ QMap<QString, QString> args = getCommandLineArgs();
+ ArgsHandler argsHandler(args);
+ Generators generators;
+
+ if (argsHandler.argExistsRemove(QLatin1String("version"))) {
+ printVerAndBanner();
+ return EXIT_SUCCESS;
+ }
+
+ QString generatorSet = argsHandler.removeArg(QLatin1String("generator-set"));
+ // Also check QLatin1String("generatorSet") command line argument for backward compatibility.
+ if (generatorSet.isEmpty())
+ generatorSet = argsHandler.removeArg(QLatin1String("generatorSet"));
+
+ // Pre-defined generator sets.
+ if (generatorSet == QLatin1String("qtdoc")) {
+ generators = docGenerators();
+ if (generators.isEmpty()) {
+ errorPrint(QLatin1String("Doc strings extractions was not enabled in this shiboken build."));
+ return EXIT_FAILURE;
+ }
+ } else if (generatorSet.isEmpty() || generatorSet == QLatin1String("shiboken")) {
+ generators = shibokenGenerators();
+ } else {
+ errorPrint(QLatin1String("Unknown generator set, try \"shiboken\" or \"qtdoc\"."));
+ return EXIT_FAILURE;
+ }
+
+ if (argsHandler.argExistsRemove(QLatin1String("help"))) {
+ printUsage();
+ return EXIT_SUCCESS;
+ }
+
+ QString licenseComment;
+ QString licenseFileName = argsHandler.removeArg(QLatin1String("license-file"));
+ if (!licenseFileName.isEmpty()) {
+ if (QFile::exists(licenseFileName)) {
+ QFile licenseFile(licenseFileName);
+ if (licenseFile.open(QIODevice::ReadOnly))
+ licenseComment = QString::fromUtf8(licenseFile.readAll());
+ } else {
+ errorPrint(QStringLiteral("Couldn't find the file containing the license heading: %1").
+ arg(licenseFileName));
+ return EXIT_FAILURE;
+ }
+ }
+
+ QString outputDirectory = argsHandler.removeArg(QLatin1String("output-directory"));
+ if (outputDirectory.isEmpty())
+ outputDirectory = QLatin1String("out");
+
+ if (!QDir(outputDirectory).exists()) {
+ if (!QDir().mkpath(outputDirectory)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Can't create output directory: " << QDir::toNativeSeparators(outputDirectory);
+ return EXIT_FAILURE;
+ }
+ }
+
+ // Create and set-up API Extractor
+ ApiExtractor extractor;
+ extractor.setLogDirectory(outputDirectory);
+
+ if (argsHandler.argExistsRemove(QLatin1String("silent"))) {
+ extractor.setSilent(true);
+ } else {
+ QString level = argsHandler.removeArg(QLatin1String("debug-level"));
+ if (!level.isEmpty()) {
+ if (level == QLatin1String("sparse"))
+ extractor.setDebugLevel(ReportHandler::SparseDebug);
+ else if (level == QLatin1String("medium"))
+ extractor.setDebugLevel(ReportHandler::MediumDebug);
+ else if (level == QLatin1String("full"))
+ extractor.setDebugLevel(ReportHandler::FullDebug);
+ }
+ }
+ if (argsHandler.argExistsRemove(QLatin1String("no-suppress-warnings")))
+ extractor.setSuppressWarnings(false);
+
+ if (argsHandler.argExists(QLatin1String("api-version"))) {
+ QStringList versions = argsHandler.removeArg(QLatin1String("api-version")).split(QLatin1Char('|'));
+ foreach (const QString &fullVersion, versions) {
+ QStringList parts = fullVersion.split(QLatin1Char(','));
+ QString package;
+ QString version;
+ // avoid constFirst to stay Qt 5.5 compatible
+ package = parts.count() == 1 ? QLatin1String("*") : parts.first();
+ version = parts.last();
+ if (!extractor.setApiVersion(package, version)) {
+ errorPrint(msgInvalidVersion(package, version));
+ return EXIT_FAILURE;
+ }
+ }
+ }
+
+ if (argsHandler.argExists(QLatin1String("drop-type-entries")))
+ extractor.setDropTypeEntries(argsHandler.removeArg(QLatin1String("drop-type-entries")));
+
+ QString path = argsHandler.removeArg(QLatin1String("typesystem-paths"));
+ if (!path.isEmpty())
+ extractor.addTypesystemSearchPath(path.split(QLatin1String(PATH_SPLITTER)));
+
+ path = argsHandler.removeArg(QLatin1String("include-paths"));
+ if (!path.isEmpty())
+ extractor.addIncludePath(path.split(QLatin1String(PATH_SPLITTER)));
+
+ QString cppFileName = argsHandler.removeArg(QLatin1String("arg-1"));
+ QString typeSystemFileName = argsHandler.removeArg(QLatin1String("arg-2"));
+
+ /* Make sure to remove the project file's arguments (if any) and
+ * --project-file, also the arguments of each generator before
+ * checking if there isn't any existing arguments in argsHandler.
+ */
+ argsHandler.removeArg(QLatin1String("project-file"));
+ QMap<QString, QString> projectFileArgs = getInitializedArguments();
+ if (!projectFileArgs.isEmpty()) {
+ QMap<QString, QString>::const_iterator it =
+ projectFileArgs.constBegin();
+ for ( ; it != projectFileArgs.constEnd(); ++it)
+ argsHandler.removeArg(it.key());
+ }
+ foreach (const GeneratorPtr &generator, generators) {
+ QMap<QString, QString> options = generator->options();
+ if (!options.isEmpty()) {
+ QMap<QString, QString>::const_iterator it = options.constBegin();
+ for ( ; it != options.constEnd(); ++it)
+ argsHandler.removeArg(it.key());
+ }
+ }
+
+ if (!argsHandler.noArgs()) {
+ errorPrint(argsHandler.errorMessage());
+ std::cout << "Note: use --help option for more information." << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ extractor.setCppFileName(cppFileName);
+ extractor.setTypeSystem(typeSystemFileName);
+ if (!extractor.run()) {
+ errorPrint(QLatin1String("Error running ApiExtractor."));
+ return EXIT_FAILURE;
+ }
+
+ if (!extractor.classCount())
+ qCWarning(lcShiboken) << "No C++ classes found!";
+
+ qCDebug(lcShiboken) << extractor;
+
+ foreach (const GeneratorPtr &g, generators) {
+ g->setOutputDirectory(outputDirectory);
+ g->setLicenseComment(licenseComment);
+ if (g->setup(extractor, args)) {
+ if (!g->generate()) {
+ errorPrint(QLatin1String("Error running generator: ")
+ + QLatin1String(g->name()) + QLatin1Char('.'));
+ return EXIT_FAILURE;
+ }
+ }
+ }
+
+ QByteArray doneMessage = "Done, " + QByteArray::number(timer.elapsed()) + "ms";
+ if (const int w = ReportHandler::warningCount())
+ doneMessage += ", " + QByteArray::number(w) + " warnings";
+ if (const int sw = ReportHandler::suppressedCount())
+ doneMessage += " (" + QByteArray::number(sw) + " known issues)";
+ qCDebug(lcShiboken()).noquote().nospace() << doneMessage;
+ std::cout << doneMessage.constData() << std::endl;
+
+ return EXIT_SUCCESS;
+}
diff --git a/sources/shiboken2/generator/qtdoc/CMakeLists.txt b/sources/shiboken2/generator/qtdoc/CMakeLists.txt
new file mode 100644
index 000000000..1361ba8f1
--- /dev/null
+++ b/sources/shiboken2/generator/qtdoc/CMakeLists.txt
@@ -0,0 +1,21 @@
+project(qtdoc_generator)
+
+set(qtdoc_generator_SRC
+qtdocgenerator.cpp
+)
+
+include_directories(${generators_SOURCE_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${APIEXTRACTOR_INCLUDE_DIR})
+add_executable(docgenerator main.cpp)
+set_target_properties(docgenerator PROPERTIES OUTPUT_NAME docgenerator${generator_SUFFIX})
+
+target_link_libraries(docgenerator ${Qt5Core_LIBRARES})
+
+add_library(qtdoc_generator SHARED ${qtdoc_generator_SRC})
+target_link_libraries(qtdoc_generator ${APIEXTRACTOR_LIBRARY} ${Qt5Core_LIBRARES} genrunner)
+set_property(TARGET qtdoc_generator PROPERTY PREFIX "")
+
+install(TARGETS qtdoc_generator DESTINATION ${generator_plugin_DIR})
+install(TARGETS docgenerator DESTINATION bin)
+
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
new file mode 100644
index 000000000..a7a176907
--- /dev/null
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -0,0 +1,1704 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtdocgenerator.h"
+#include <abstractmetalang.h>
+#include <reporthandler.h>
+#include <typesystem.h>
+#include <qtdocparser.h>
+#include <doxygenparser.h>
+#include <typedatabase.h>
+#include <algorithm>
+#include <QtCore/QStack>
+#include <QtCore/QTextStream>
+#include <QtCore/QXmlStreamReader>
+#include <QtCore/QFile>
+#include <QtCore/QDir>
+#include <fileout.h>
+#include <limits>
+
+static Indentor INDENT;
+
+static bool shouldSkip(const AbstractMetaFunction* func)
+{
+ bool skipable = func->isConstructor()
+ || func->isModifiedRemoved()
+ || func->declaringClass() != func->ownerClass()
+ || func->isCastOperator()
+ || func->name() == QLatin1String("operator=");
+
+ // Search a const clone
+ if (!skipable && !func->isConstant()) {
+ const AbstractMetaArgumentList funcArgs = func->arguments();
+ foreach (AbstractMetaFunction* f, func->ownerClass()->functions()) {
+ if (f != func
+ && f->isConstant()
+ && f->name() == func->name()
+ && f->arguments().count() == funcArgs.count()) {
+ // Compare each argument
+ bool cloneFound = true;
+
+ const AbstractMetaArgumentList fargs = f->arguments();
+ for (int i = 0, max = funcArgs.count(); i < max; ++i) {
+ if (funcArgs.at(i)->type()->typeEntry() != fargs.at(i)->type()->typeEntry()) {
+ cloneFound = false;
+ break;
+ }
+ }
+ if (cloneFound)
+ return true;
+ }
+ }
+ }
+ return skipable;
+}
+
+static bool functionSort(const AbstractMetaFunction* func1, const AbstractMetaFunction* func2)
+{
+ return func1->name() < func2->name();
+}
+
+static QString createRepeatedChar(int i, char c)
+{
+ QString out;
+ for (int j = 0; j < i; ++j)
+ out += QLatin1Char(c);
+
+ return out;
+}
+
+static QString escape(QString str)
+{
+ str.replace(QLatin1Char('*'), QLatin1String("\\*"));
+ str.replace(QLatin1Char('_'), QLatin1String("\\_"));
+ return str;
+}
+
+static QString escape(const QStringRef& strref)
+{
+ QString str = strref.toString();
+ return escape(str);
+}
+
+
+QtXmlToSphinx::QtXmlToSphinx(QtDocGenerator* generator, const QString& doc, const QString& context)
+ : m_context(context), m_generator(generator), m_insideBold(false), m_insideItalic(false)
+{
+ m_handlerMap.insert(QLatin1String("heading"), &QtXmlToSphinx::handleHeadingTag);
+ m_handlerMap.insert(QLatin1String("brief"), &QtXmlToSphinx::handleParaTag);
+ m_handlerMap.insert(QLatin1String("para"), &QtXmlToSphinx::handleParaTag);
+ m_handlerMap.insert(QLatin1String("italic"), &QtXmlToSphinx::handleItalicTag);
+ m_handlerMap.insert(QLatin1String("bold"), &QtXmlToSphinx::handleBoldTag);
+ m_handlerMap.insert(QLatin1String("see-also"), &QtXmlToSphinx::handleSeeAlsoTag);
+ m_handlerMap.insert(QLatin1String("snippet"), &QtXmlToSphinx::handleSnippetTag);
+ m_handlerMap.insert(QLatin1String("dots"), &QtXmlToSphinx::handleDotsTag);
+ m_handlerMap.insert(QLatin1String("codeline"), &QtXmlToSphinx::handleDotsTag);
+ m_handlerMap.insert(QLatin1String("table"), &QtXmlToSphinx::handleTableTag);
+ m_handlerMap.insert(QLatin1String("header"), &QtXmlToSphinx::handleRowTag);
+ m_handlerMap.insert(QLatin1String("row"), &QtXmlToSphinx::handleRowTag);
+ m_handlerMap.insert(QLatin1String("item"), &QtXmlToSphinx::handleItemTag);
+ m_handlerMap.insert(QLatin1String("argument"), &QtXmlToSphinx::handleArgumentTag);
+ m_handlerMap.insert(QLatin1String("teletype"), &QtXmlToSphinx::handleArgumentTag);
+ m_handlerMap.insert(QLatin1String("link"), &QtXmlToSphinx::handleLinkTag);
+ m_handlerMap.insert(QLatin1String("inlineimage"), &QtXmlToSphinx::handleImageTag);
+ m_handlerMap.insert(QLatin1String("image"), &QtXmlToSphinx::handleImageTag);
+ m_handlerMap.insert(QLatin1String("list"), &QtXmlToSphinx::handleListTag);
+ m_handlerMap.insert(QLatin1String("term"), &QtXmlToSphinx::handleTermTag);
+ m_handlerMap.insert(QLatin1String("raw"), &QtXmlToSphinx::handleRawTag);
+ m_handlerMap.insert(QLatin1String("underline"), &QtXmlToSphinx::handleItalicTag);
+ m_handlerMap.insert(QLatin1String("superscript"), &QtXmlToSphinx::handleSuperScriptTag);
+ m_handlerMap.insert(QLatin1String("code"), &QtXmlToSphinx::handleCodeTag);
+ m_handlerMap.insert(QLatin1String("badcode"), &QtXmlToSphinx::handleCodeTag);
+ m_handlerMap.insert(QLatin1String("legalese"), &QtXmlToSphinx::handleCodeTag);
+ m_handlerMap.insert(QLatin1String("section"), &QtXmlToSphinx::handleAnchorTag);
+ m_handlerMap.insert(QLatin1String("quotefile"), &QtXmlToSphinx::handleQuoteFileTag);
+
+ // ignored tags
+ m_handlerMap.insert(QLatin1String("generatedlist"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("tableofcontents"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("quotefromfile"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("skipto"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("target"), &QtXmlToSphinx::handleIgnoredTag);
+
+ // useless tags
+ m_handlerMap.insert(QLatin1String("description"), &QtXmlToSphinx::handleUselessTag);
+ m_handlerMap.insert(QLatin1String("definition"), &QtXmlToSphinx::handleUselessTag);
+ m_handlerMap.insert(QLatin1String("printuntil"), &QtXmlToSphinx::handleUselessTag);
+ m_handlerMap.insert(QLatin1String("relation"), &QtXmlToSphinx::handleUselessTag);
+
+ // Doxygen tags
+ m_handlerMap.insert(QLatin1String("title"), &QtXmlToSphinx::handleHeadingTag);
+ m_handlerMap.insert(QLatin1String("ref"), &QtXmlToSphinx::handleParaTag);
+ m_handlerMap.insert(QLatin1String("computeroutput"), &QtXmlToSphinx::handleParaTag);
+ m_handlerMap.insert(QLatin1String("detaileddescription"), &QtXmlToSphinx::handleParaTag);
+ m_handlerMap.insert(QLatin1String("name"), &QtXmlToSphinx::handleParaTag);
+ m_handlerMap.insert(QLatin1String("listitem"), &QtXmlToSphinx::handleItemTag);
+ m_handlerMap.insert(QLatin1String("parametername"), &QtXmlToSphinx::handleItemTag);
+ m_handlerMap.insert(QLatin1String("parameteritem"), &QtXmlToSphinx::handleItemTag);
+ m_handlerMap.insert(QLatin1String("ulink"), &QtXmlToSphinx::handleLinkTag);
+ m_handlerMap.insert(QLatin1String("itemizedlist"), &QtXmlToSphinx::handleListTag);
+ m_handlerMap.insert(QLatin1String("parameternamelist"), &QtXmlToSphinx::handleListTag);
+ m_handlerMap.insert(QLatin1String("parameterlist"), &QtXmlToSphinx::handleListTag);
+
+ // Doxygen ignored tags
+ m_handlerMap.insert(QLatin1String("highlight"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("linebreak"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("programlisting"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("xreftitle"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("sp"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("entry"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("simplesect"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("verbatim"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("xrefsect"), &QtXmlToSphinx::handleIgnoredTag);
+ m_handlerMap.insert(QLatin1String("xrefdescription"), &QtXmlToSphinx::handleIgnoredTag);
+
+ m_result = transform(doc);
+}
+
+void QtXmlToSphinx::pushOutputBuffer()
+{
+ QString* buffer = new QString();
+ m_buffers << buffer;
+ m_output.setString(buffer);
+}
+
+QString QtXmlToSphinx::popOutputBuffer()
+{
+ Q_ASSERT(!m_buffers.isEmpty());
+ QString* str = m_buffers.pop();
+ QString strcpy(*str);
+ delete str;
+ m_output.setString(m_buffers.isEmpty() ? 0 : m_buffers.top());
+ return strcpy;
+}
+
+QString QtXmlToSphinx::expandFunction(const QString& function)
+{
+ QStringList functionSpec = function.split(QLatin1Char('.'));
+ QString className = functionSpec.first();
+ const AbstractMetaClass* metaClass = 0;
+ foreach (const AbstractMetaClass* cls, m_generator->classes()) {
+ if (cls->name() == className) {
+ metaClass = cls;
+ break;
+ }
+ }
+
+ if (metaClass) {
+ functionSpec.removeFirst();
+ return metaClass->typeEntry()->qualifiedTargetLangName()
+ + QLatin1Char('.') + functionSpec.join(QLatin1Char('.'));
+ } else {
+ return function;
+ }
+}
+
+QString QtXmlToSphinx::resolveContextForMethod(const QString& methodName)
+{
+ // avoid constLast to stay Qt 5.5 compatible
+ QString currentClass = m_context.split(QLatin1Char('.')).last();
+
+ const AbstractMetaClass* metaClass = 0;
+ foreach (const AbstractMetaClass* cls, m_generator->classes()) {
+ if (cls->name() == currentClass) {
+ metaClass = cls;
+ break;
+ }
+ }
+
+ if (metaClass) {
+ QList<const AbstractMetaFunction*> funcList;
+ foreach (const AbstractMetaFunction* func, metaClass->queryFunctionsByName(methodName)) {
+ if (methodName == func->name())
+ funcList.append(func);
+ }
+
+ const AbstractMetaClass* implementingClass = 0;
+ foreach (const AbstractMetaFunction* func, funcList) {
+ implementingClass = func->implementingClass();
+ if (implementingClass->name() == currentClass)
+ break;
+ }
+
+ if (implementingClass)
+ return implementingClass->typeEntry()->qualifiedTargetLangName();
+ }
+
+ return QLatin1Char('~') + m_context;
+}
+
+QString QtXmlToSphinx::transform(const QString& doc)
+{
+ Q_ASSERT(m_buffers.isEmpty());
+ Indentation indentation(INDENT);
+ if (doc.trimmed().isEmpty())
+ return doc;
+
+ pushOutputBuffer();
+
+ QXmlStreamReader reader(doc);
+
+ while (!reader.atEnd()) {
+ QXmlStreamReader::TokenType token = reader.readNext();
+ if (reader.hasError()) {
+ const QString message = QLatin1String("XML Error: ") + reader.errorString()
+ + QLatin1Char('\n') + doc;
+ m_output << INDENT << message;
+ qCWarning(lcShiboken).noquote().nospace() << message;
+ break;
+ }
+
+ if (token == QXmlStreamReader::StartElement) {
+ QStringRef 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)) )
+ handler = &QtXmlToSphinx::handleIgnoredTag;
+
+ m_handlers.push(handler);
+ }
+ if (!m_handlers.isEmpty())
+ (this->*(m_handlers.top()))(reader);
+
+ if (token == QXmlStreamReader::EndElement) {
+ m_handlers.pop();
+ m_lastTagName = reader.name().toString();
+ }
+ }
+ m_output.flush();
+ QString retval = popOutputBuffer();
+ Q_ASSERT(m_buffers.isEmpty());
+ return retval;
+}
+
+QString QtXmlToSphinx::readFromLocations(const QStringList& locations, const QString& path, const QString& identifier)
+{
+ QString result;
+ bool ok;
+ foreach (QString location, locations) {
+ location.append(QLatin1Char('/'));
+ location.append(path);
+ result = readFromLocation(location, identifier, &ok);
+ if (ok)
+ break;
+ }
+ if (!ok) {
+ qCDebug(lcShiboken).noquote().nospace() << "Couldn't read code snippet file: {"
+ << locations.join(QLatin1Char('|')) << '}' << path;
+ }
+ return result;
+
+}
+
+QString QtXmlToSphinx::readFromLocation(const QString& location, const QString& identifier, bool* ok)
+{
+ QFile inputFile;
+ inputFile.setFileName(location);
+ if (!inputFile.open(QIODevice::ReadOnly)) {
+ if (!ok) {
+ qCDebug(lcShiboken).noquote().nospace() << "Couldn't read code snippet file: "
+ << QDir::toNativeSeparators(inputFile.fileName());
+ } else {
+ *ok = false;
+ }
+ return QString();
+ }
+
+ QRegExp searchString(QLatin1String("//!\\s*\\[") + identifier + QLatin1String("\\]"));
+ QRegExp codeSnippetCode(QLatin1String("//!\\s*\\[[\\w\\d\\s]+\\]"));
+ QString code;
+
+ bool identifierIsEmpty = identifier.isEmpty();
+ bool getCode = false;
+
+ while (!inputFile.atEnd()) {
+ QString line = QString::fromUtf8(inputFile.readLine());
+ if (identifierIsEmpty) {
+ code += line;
+ } else if (getCode && !line.contains(searchString)) {
+ line.remove(codeSnippetCode);
+ code += line;
+ } else if (line.contains(searchString)) {
+ if (getCode)
+ break;
+ else
+ getCode = true;
+ }
+ }
+
+ if (!identifierIsEmpty && !getCode) {
+ qCDebug(lcShiboken).noquote().nospace() << "Code snippet file found ("
+ << location << "), but snippet " << identifier << " not found.";
+ }
+
+ if (ok)
+ *ok = true;
+ return code;
+}
+
+void QtXmlToSphinx::handleHeadingTag(QXmlStreamReader& reader)
+{
+ static QString heading;
+ static char type;
+ static char types[] = { '-', '^' };
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ uint typeIdx = reader.attributes().value(QLatin1String("level")).toString().toInt();
+ if (typeIdx >= sizeof(types))
+ type = types[sizeof(types)-1];
+ else
+ type = types[typeIdx];
+ } else if (token == QXmlStreamReader::EndElement) {
+ m_output << createRepeatedChar(heading.length(), type) << endl << endl;
+ } else if (token == QXmlStreamReader::Characters) {
+ heading = escape(reader.text()).trimmed();
+ m_output << endl << endl << heading << endl;
+ }
+}
+
+void QtXmlToSphinx::handleParaTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ pushOutputBuffer();
+ } else if (token == QXmlStreamReader::EndElement) {
+ QString result = popOutputBuffer().simplified();
+ if (result.startsWith(QLatin1String("**Warning:**")))
+ result.replace(0, 12, QLatin1String(".. warning:: "));
+ else if (result.startsWith(QLatin1String("**Note:**")))
+ result.replace(0, 9, QLatin1String(".. note:: "));
+
+ m_output << INDENT << result << endl << endl;
+ } else if (token == QXmlStreamReader::Characters) {
+ QString text = escape(reader.text());
+ if (!m_output.string()->isEmpty()) {
+ QChar start = text[0];
+ QChar end = m_output.string()->at(m_output.string()->length() - 1);
+ if ((end == QLatin1Char('*') || end == QLatin1Char('`')) && start != QLatin1Char(' ') && !start.isPunct())
+ m_output << '\\';
+ }
+ m_output << INDENT << text;
+ }
+}
+
+void QtXmlToSphinx::handleItalicTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement || token == QXmlStreamReader::EndElement) {
+ m_insideItalic = !m_insideItalic;
+ m_output << '*';
+ } else if (token == QXmlStreamReader::Characters) {
+ m_output << escape(reader.text()).trimmed();
+ }
+}
+
+void QtXmlToSphinx::handleBoldTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement || token == QXmlStreamReader::EndElement) {
+ m_insideBold = !m_insideBold;
+ m_output << "**";
+ } else if (token == QXmlStreamReader::Characters) {
+ m_output << escape(reader.text()).trimmed();
+ }
+}
+
+void QtXmlToSphinx::handleArgumentTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement || token == QXmlStreamReader::EndElement)
+ m_output << "``";
+ else if (token == QXmlStreamReader::Characters)
+ m_output << reader.text().toString().trimmed();
+}
+
+void QtXmlToSphinx::handleSeeAlsoTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement)
+ m_output << INDENT << ".. seealso:: ";
+ else if (token == QXmlStreamReader::EndElement)
+ m_output << endl;
+}
+
+void QtXmlToSphinx::handleSnippetTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ const bool consecutiveSnippet = m_lastTagName == QLatin1String("snippet")
+ || m_lastTagName == QLatin1String("dots") || m_lastTagName == QLatin1String("codeline");
+ if (consecutiveSnippet) {
+ m_output.flush();
+ m_output.string()->chop(2);
+ }
+ QString location = reader.attributes().value(QLatin1String("location")).toString();
+ QString identifier = reader.attributes().value(QLatin1String("identifier")).toString();
+ QString code = readFromLocations(m_generator->codeSnippetDirs(), location, identifier);
+ if (!consecutiveSnippet)
+ m_output << INDENT << "::\n\n";
+
+ Indentation indentation(INDENT);
+ if (code.isEmpty()) {
+ m_output << INDENT << "<Code snippet \"" << location << ':' << identifier << "\" not found>" << endl;
+ } else {
+ foreach (const QString &line, code.split(QLatin1Char('\n'))) {
+ if (!QString(line).trimmed().isEmpty())
+ m_output << INDENT << line;
+
+ m_output << endl;
+ }
+ }
+ m_output << endl;
+ }
+}
+void QtXmlToSphinx::handleDotsTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ const bool consecutiveSnippet = m_lastTagName == QLatin1String("snippet")
+ || m_lastTagName == QLatin1String("dots") || m_lastTagName == QLatin1String("codeline");
+ if (consecutiveSnippet) {
+ m_output.flush();
+ m_output.string()->chop(2);
+ }
+ Indentation indentation(INDENT);
+ pushOutputBuffer();
+ m_output << INDENT;
+ int indent = reader.attributes().value(QLatin1String("indent")).toString().toInt();
+ for (int i = 0; i < indent; ++i)
+ m_output << ' ';
+ } else if (token == QXmlStreamReader::Characters) {
+ m_output << reader.text().toString();
+ } else if (token == QXmlStreamReader::EndElement) {
+ m_output << popOutputBuffer() << "\n\n\n";
+ }
+}
+
+void QtXmlToSphinx::handleTableTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ m_currentTable.clear();
+ m_tableHasHeader = false;
+ } else if (token == QXmlStreamReader::EndElement) {
+ // write the table on m_output
+ m_currentTable.enableHeader(m_tableHasHeader);
+ m_currentTable.normalize();
+ m_output << m_currentTable;
+ m_currentTable.clear();
+ }
+}
+
+void QtXmlToSphinx::handleTermTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ pushOutputBuffer();
+ } else if (token == QXmlStreamReader::Characters) {
+ m_output << reader.text().toString().replace(QLatin1String("::"), QLatin1String("."));
+ } else if (token == QXmlStreamReader::EndElement) {
+ TableCell cell;
+ cell.data = popOutputBuffer().trimmed();
+ m_currentTable << (TableRow() << cell);
+ }
+}
+
+
+void QtXmlToSphinx::handleItemTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ if (m_currentTable.isEmpty())
+ m_currentTable << TableRow();
+ TableRow& row = m_currentTable.last();
+ TableCell cell;
+ cell.colSpan = reader.attributes().value(QLatin1String("colspan")).toString().toShort();
+ cell.rowSpan = reader.attributes().value(QLatin1String("rowspan")).toString().toShort();
+ row << cell;
+ pushOutputBuffer();
+ } else if (token == QXmlStreamReader::EndElement) {
+ QString data = popOutputBuffer().trimmed();
+ if (!m_currentTable.isEmpty()) {
+ TableRow& row = m_currentTable.last();
+ if (!row.isEmpty())
+ row.last().data = data;
+ }
+ }
+}
+
+void QtXmlToSphinx::handleRowTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ m_tableHasHeader = reader.name() == QLatin1String("header");
+ m_currentTable << TableRow();
+ }
+}
+
+void QtXmlToSphinx::handleListTag(QXmlStreamReader& reader)
+{
+ // BUG We do not support a list inside a table cell
+ static QString listType;
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ listType = reader.attributes().value(QLatin1String("type")).toString();
+ if (listType == QLatin1String("enum")) {
+ m_currentTable << (TableRow() << "Constant" << "Description");
+ m_tableHasHeader = true;
+ }
+ INDENT.indent--;
+ } else if (token == QXmlStreamReader::EndElement) {
+ INDENT.indent++;
+ if (!m_currentTable.isEmpty()) {
+ if (listType == QLatin1String("bullet")) {
+ m_output << endl;
+ foreach (TableCell cell, m_currentTable.first()) {
+ QStringList itemLines = cell.data.split(QLatin1Char('\n'));
+ m_output << INDENT << "* " << itemLines.first() << endl;
+ for (int i = 1, max = itemLines.count(); i < max; ++i)
+ m_output << INDENT << " " << itemLines[i] << endl;
+ }
+ m_output << endl;
+ } else if (listType == QLatin1String("enum")) {
+ m_currentTable.enableHeader(m_tableHasHeader);
+ m_currentTable.normalize();
+ m_output << m_currentTable;
+ }
+ }
+ m_currentTable.clear();
+ }
+}
+
+void QtXmlToSphinx::handleLinkTag(QXmlStreamReader& reader)
+{
+ static QString l_linktag;
+ static QString l_linkref;
+ static QString l_linktext;
+ static QString l_linktagending;
+ static QString l_type;
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ l_linktagending = QLatin1String("` ");
+ if (m_insideBold) {
+ l_linktag.prepend(QLatin1String("**"));
+ l_linktagending.append(QLatin1String("**"));
+ } else if (m_insideItalic) {
+ l_linktag.prepend(QLatin1Char('*'));
+ l_linktagending.append(QLatin1Char('*'));
+ }
+ l_type = reader.attributes().value(QLatin1String("type")).toString();
+
+ // TODO: create a flag PROPERTY-AS-FUNCTION to ask if the properties
+ // are recognized as such or not in the binding
+ if (l_type == QLatin1String("property"))
+ l_type = QLatin1String("function");
+
+ if (l_type == QLatin1String("typedef"))
+ l_type = QLatin1String("class");
+
+ QString linkSource;
+ if (l_type == QLatin1String("function") || l_type == QLatin1String("class")) {
+ linkSource = QLatin1String("raw");
+ } else if (l_type == QLatin1String("enum")) {
+ linkSource = QLatin1String("enum");
+ } else if (l_type == QLatin1String("page")) {
+ linkSource = QLatin1String("page");
+ } else {
+ linkSource = QLatin1String("href");
+ }
+
+ l_linkref = reader.attributes().value(linkSource).toString();
+ l_linkref.replace(QLatin1String("::"), QLatin1String("."));
+ l_linkref.remove(QLatin1String("()"));
+
+ if (l_type == QLatin1String("function") && !m_context.isEmpty()) {
+ l_linktag = QLatin1String(" :meth:`");
+ QStringList rawlinklist = l_linkref.split(QLatin1Char('.'));
+ if (rawlinklist.size() == 1 || rawlinklist.first() == m_context) {
+ QString context = resolveContextForMethod(rawlinklist.last());
+ if (!l_linkref.startsWith(context))
+ l_linkref.prepend(context + QLatin1Char('.'));
+ } else {
+ l_linkref = expandFunction(l_linkref);
+ }
+ } else if (l_type == QLatin1String("function") && m_context.isEmpty()) {
+ l_linktag = QLatin1String(" :func:`");
+ } else if (l_type == QLatin1String("class")) {
+ l_linktag = QLatin1String(" :class:`");
+ TypeEntry* type = TypeDatabase::instance()->findType(l_linkref);
+ if (type) {
+ l_linkref = type->qualifiedTargetLangName();
+ } else { // fall back to the old heuristic if the type wasn't found.
+ QStringList rawlinklist = l_linkref.split(QLatin1Char('.'));
+ QStringList splittedContext = m_context.split(QLatin1Char('.'));
+ if (rawlinklist.size() == 1 || rawlinklist.first() == splittedContext.last()) {
+ splittedContext.removeLast();
+ l_linkref.prepend(QLatin1Char('~') + splittedContext.join(QLatin1Char('.'))
+ + QLatin1Char('.'));
+ }
+ }
+ } else if (l_type == QLatin1String("enum")) {
+ l_linktag = QLatin1String(" :attr:`");
+ } else if (l_type == QLatin1String("page") && l_linkref == m_generator->moduleName()) {
+ l_linktag = QLatin1String(" :mod:`");
+ } else {
+ l_linktag = QLatin1String(" :ref:`");
+ }
+
+ } else if (token == QXmlStreamReader::Characters) {
+ QString linktext = reader.text().toString();
+ linktext.replace(QLatin1String("::"), QLatin1String("."));
+ // avoid constLast to stay Qt 5.5 compatible
+ QString item = l_linkref.split(QLatin1Char('.')).last();
+ if (l_linkref == linktext
+ || (l_linkref + QLatin1String("()")) == linktext
+ || item == linktext
+ || (item + QLatin1String("()")) == linktext)
+ l_linktext.clear();
+ else
+ l_linktext = linktext + QLatin1Char('<');
+ } else if (token == QXmlStreamReader::EndElement) {
+ if (!l_linktext.isEmpty())
+ l_linktagending.prepend(QLatin1Char('>'));
+ m_output << l_linktag << l_linktext << escape(l_linkref) << l_linktagending;
+ }
+}
+
+void QtXmlToSphinx::handleImageTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ QString href = reader.attributes().value(QLatin1String("href")).toString();
+ QString packageName = m_generator->packageName();
+ packageName.replace(QLatin1Char('.'), QLatin1Char('/'));
+ QDir dir(m_generator->outputDirectory() + QLatin1Char('/') + packageName);
+ QString imgPath = dir.relativeFilePath(m_generator->libSourceDir() + QLatin1String("/doc/src/"))
+ + QLatin1Char('/') + href;
+
+ if (reader.name() == QLatin1String("image"))
+ m_output << INDENT << ".. image:: " << imgPath << endl << endl;
+ else
+ m_output << ".. image:: " << imgPath << ' ';
+ }
+}
+
+void QtXmlToSphinx::handleRawTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ QString format = reader.attributes().value(QLatin1String("format")).toString();
+ m_output << INDENT << ".. raw:: " << format.toLower() << endl << endl;
+ } else if (token == QXmlStreamReader::Characters) {
+ QStringList lst(reader.text().toString().split(QLatin1Char('\n')));
+ foreach(QString row, lst)
+ m_output << INDENT << INDENT << row << endl;
+ } else if (token == QXmlStreamReader::EndElement) {
+ m_output << endl << endl;
+ }
+}
+
+void QtXmlToSphinx::handleCodeTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ QString format = reader.attributes().value(QLatin1String("format")).toString();
+ m_output << INDENT << "::" << endl << endl;
+ INDENT.indent++;
+ } else if (token == QXmlStreamReader::Characters) {
+ QStringList lst(reader.text().toString().split(QLatin1Char('\n')));
+ foreach(QString row, lst)
+ m_output << INDENT << INDENT << row << endl;
+ } else if (token == QXmlStreamReader::EndElement) {
+ m_output << endl << endl;
+ INDENT.indent--;
+ }
+}
+
+void QtXmlToSphinx::handleUnknownTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement)
+ qCDebug(lcShiboken).noquote().nospace() << "Unknown QtDoc tag: \"" << reader.name().toString() << "\".";
+}
+
+void QtXmlToSphinx::handleSuperScriptTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ m_output << " :sup:`";
+ pushOutputBuffer();
+ } else if (token == QXmlStreamReader::Characters) {
+ m_output << reader.text().toString();
+ } else if (token == QXmlStreamReader::EndElement) {
+ m_output << popOutputBuffer();
+ m_output << '`';
+ }
+}
+
+void QtXmlToSphinx::handleIgnoredTag(QXmlStreamReader&)
+{
+}
+
+void QtXmlToSphinx::handleUselessTag(QXmlStreamReader&)
+{
+ // Tag "description" just marks the init of "Detailed description" title.
+ // Tag "definition" just marks enums. We have a different way to process them.
+}
+
+void QtXmlToSphinx::handleAnchorTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::StartElement) {
+ QString anchor;
+ if (reader.attributes().hasAttribute(QLatin1String("id")))
+ anchor = reader.attributes().value(QLatin1String("id")).toString();
+ else if (reader.attributes().hasAttribute(QLatin1String("name")))
+ anchor = reader.attributes().value(QLatin1String("name")).toString();
+ if (!anchor.isEmpty() && m_opened_anchor != anchor) {
+ m_opened_anchor = anchor;
+ m_output << INDENT << ".. _" << m_context << "_" << anchor.toLower() << ":" << endl << endl;
+ }
+ } else if (token == QXmlStreamReader::EndElement) {
+ m_opened_anchor.clear();
+ }
+}
+
+void QtXmlToSphinx::handleQuoteFileTag(QXmlStreamReader& reader)
+{
+ QXmlStreamReader::TokenType token = reader.tokenType();
+ if (token == QXmlStreamReader::Characters) {
+ QString location = reader.text().toString();
+ QString identifier;
+ location.prepend(m_generator->libSourceDir() + QLatin1Char('/'));
+ QString code = readFromLocation(location, identifier);
+
+ m_output << INDENT << "::\n\n";
+ Indentation indentation(INDENT);
+ if (code.isEmpty()) {
+ m_output << INDENT << "<Code snippet \"" << location << "\" not found>" << endl;
+ } else {
+ foreach (QString line, code.split(QLatin1Char('\n'))) {
+ if (!QString(line).trimmed().isEmpty())
+ m_output << INDENT << line;
+
+ m_output << endl;
+ }
+ }
+ m_output << endl;
+ }
+}
+
+void QtXmlToSphinx::Table::normalize()
+{
+ if (m_normalized || isEmpty())
+ return;
+
+ int row;
+ int col;
+ QtXmlToSphinx::Table& self = *this;
+
+ //QDoc3 generates tables with wrong number of columns. We have to
+ //check and if necessary, merge the last columns.
+ int maxCols = self.at(0).count();
+ // add col spans
+ for (row = 0; row < count(); ++row) {
+ for (col = 0; col < at(row).count(); ++col) {
+ QtXmlToSphinx::TableCell& cell = self[row][col];
+ bool mergeCols = (col >= maxCols);
+ if (cell.colSpan > 0) {
+ QtXmlToSphinx::TableCell newCell;
+ newCell.colSpan = -1;
+ for (int i = 0, max = cell.colSpan-1; i < max; ++i) {
+ self[row].insert(col+1, newCell);
+ }
+ cell.colSpan = 0;
+ col++;
+ } else if (mergeCols) {
+ self[row][maxCols - 1].data += QLatin1Char(' ') + cell.data;
+ }
+ }
+ }
+
+ // row spans
+ const int numCols = first().count();
+ for (col = 0; col < numCols; ++col) {
+ for (row = 0; row < count(); ++row) {
+ if (col < self[row].count()) {
+ QtXmlToSphinx::TableCell& cell = self[row][col];
+ if (cell.rowSpan > 0) {
+ QtXmlToSphinx::TableCell newCell;
+ newCell.rowSpan = -1;
+ int max = std::min(cell.rowSpan - 1, count());
+ cell.rowSpan = 0;
+ for (int i = 0; i < max; ++i) {
+ self[row+i+1].insert(col, newCell);
+ }
+ row++;
+ }
+ }
+ }
+ }
+ m_normalized = true;
+}
+
+QTextStream& operator<<(QTextStream& s, const QtXmlToSphinx::Table &table)
+{
+ if (table.isEmpty())
+ return s;
+
+ if (!table.isNormalized()) {
+ qCDebug(lcShiboken) << "Attempt to print an unnormalized table!";
+ return s;
+ }
+
+ // calc width and height of each column and row
+ QVector<int> colWidths(table.first().count());
+ QVector<int> rowHeights(table.count());
+ for (int i = 0, maxI = table.count(); i < maxI; ++i) {
+ const QtXmlToSphinx::TableRow& row = table[i];
+ for (int j = 0, maxJ = std::min(row.count(), colWidths.size()); j < maxJ; ++j) {
+ QStringList rowLines = row[j].data.split(QLatin1Char('\n')); // cache this would be a good idea
+ foreach (QString str, rowLines)
+ colWidths[j] = std::max(colWidths[j], str.count());
+ rowHeights[i] = std::max(rowHeights[i], row[j].data.count(QLatin1Char('\n')) + 1);
+ }
+ }
+
+ if (!*std::max_element(colWidths.begin(), colWidths.end()))
+ return s; // empty table (table with empty cells)
+
+ // create a horizontal line to be used later.
+ QString horizontalLine = QLatin1String("+");
+ for (int i = 0, max = colWidths.count(); i < max; ++i) {
+ horizontalLine += createRepeatedChar(colWidths[i], '-');
+ horizontalLine += QLatin1Char('+');
+ }
+
+ // write table rows
+ for (int i = 0, maxI = table.count(); i < maxI; ++i) { // for each row
+ const QtXmlToSphinx::TableRow& row = table[i];
+
+ // print line
+ s << INDENT << '+';
+ for (int col = 0, max = colWidths.count(); col < max; ++col) {
+ char c;
+ if (col >= row.length() || row[col].rowSpan == -1)
+ c = ' ';
+ else if (i == 1 && table.hasHeader())
+ c = '=';
+ else
+ c = '-';
+ s << createRepeatedChar(colWidths[col], c) << '+';
+ }
+ s << endl;
+
+
+ // Print the table cells
+ for (int rowLine = 0; rowLine < rowHeights[i]; ++rowLine) { // for each line in a row
+ for (int j = 0, maxJ = std::min(row.count(), colWidths.size()); j < maxJ; ++j) { // for each column
+ const QtXmlToSphinx::TableCell& cell = row[j];
+ QStringList rowLines = cell.data.split(QLatin1Char('\n')); // FIXME: Cache this!!!
+ if (!j) // First column, so we need print the identation
+ s << INDENT;
+
+ if (!j || !cell.colSpan)
+ s << '|';
+ else
+ s << ' ';
+ s << qSetFieldWidth(colWidths[j]) << left;
+ s << (rowLine < rowLines.count() ? rowLines[rowLine] : QString());
+ s << qSetFieldWidth(0);
+ }
+ s << '|' << endl;
+ }
+ }
+ s << INDENT << horizontalLine << endl;
+ s << endl;
+ return s;
+}
+
+static QString getFuncName(const AbstractMetaFunction* cppFunc) {
+ static bool hashInitialized = false;
+ static QHash<QString, QString> operatorsHash;
+ if (!hashInitialized) {
+ operatorsHash.insert(QLatin1String("operator+"), QLatin1String("__add__"));
+ operatorsHash.insert(QLatin1String("operator+="), QLatin1String("__iadd__"));
+ operatorsHash.insert(QLatin1String("operator-"), QLatin1String("__sub__"));
+ operatorsHash.insert(QLatin1String("operator-="), QLatin1String("__isub__"));
+ operatorsHash.insert(QLatin1String("operator*"), QLatin1String("__mul__"));
+ operatorsHash.insert(QLatin1String("operator*="), QLatin1String("__imul__"));
+ operatorsHash.insert(QLatin1String("operator/"), QLatin1String("__div__"));
+ operatorsHash.insert(QLatin1String("operator/="), QLatin1String("__idiv__"));
+ operatorsHash.insert(QLatin1String("operator%"), QLatin1String("__mod__"));
+ operatorsHash.insert(QLatin1String("operator%="), QLatin1String("__imod__"));
+ operatorsHash.insert(QLatin1String("operator<<"), QLatin1String("__lshift__"));
+ operatorsHash.insert(QLatin1String("operator<<="), QLatin1String("__ilshift__"));
+ operatorsHash.insert(QLatin1String("operator>>"), QLatin1String("__rshift__"));
+ operatorsHash.insert(QLatin1String("operator>>="), QLatin1String("__irshift__"));
+ operatorsHash.insert(QLatin1String("operator&"), QLatin1String("__and__"));
+ operatorsHash.insert(QLatin1String("operator&="), QLatin1String("__iand__"));
+ operatorsHash.insert(QLatin1String("operator|"), QLatin1String("__or__"));
+ operatorsHash.insert(QLatin1String("operator|="), QLatin1String("__ior__"));
+ operatorsHash.insert(QLatin1String("operator^"), QLatin1String("__xor__"));
+ operatorsHash.insert(QLatin1String("operator^="), QLatin1String("__ixor__"));
+ operatorsHash.insert(QLatin1String("operator=="), QLatin1String("__eq__"));
+ operatorsHash.insert(QLatin1String("operator!="), QLatin1String("__ne__"));
+ operatorsHash.insert(QLatin1String("operator<"), QLatin1String("__lt__"));
+ operatorsHash.insert(QLatin1String("operator<="), QLatin1String("__le__"));
+ operatorsHash.insert(QLatin1String("operator>"), QLatin1String("__gt__"));
+ operatorsHash.insert(QLatin1String("operator>="), QLatin1String("__ge__"));
+ hashInitialized = true;
+ }
+
+ QHash<QString, QString>::const_iterator it = operatorsHash.find(cppFunc->name());
+ QString result = it != operatorsHash.end() ? it.value() : cppFunc->name();
+ result.replace(QLatin1String("::"), QLatin1String("."));
+ return result;
+}
+
+QtDocGenerator::QtDocGenerator() : m_docParser(0)
+{
+}
+
+QtDocGenerator::~QtDocGenerator()
+{
+ delete m_docParser;
+}
+
+QString QtDocGenerator::fileNamePrefix() const
+{
+ return QLatin1String(".rst");
+}
+
+QString QtDocGenerator::fileNameForContext(GeneratorContext &context) const
+{
+ const AbstractMetaClass *metaClass = context.metaClass();
+ if (!context.forSmartPointer()) {
+ return getClassTargetFullName(metaClass, false) + fileNamePrefix();
+ } else {
+ const AbstractMetaType *smartPointerType = context.preciseType();
+ QString fileNameBase = getFileNameBaseForSmartPointer(smartPointerType, metaClass);
+ return fileNameBase + fileNamePrefix();
+ }
+}
+
+void QtDocGenerator::writeFormatedText(QTextStream& s, const Documentation& doc, const AbstractMetaClass* metaClass)
+{
+ QString metaClassName;
+
+ if (metaClass)
+ metaClassName = getClassTargetFullName(metaClass);
+
+ if (doc.format() == Documentation::Native) {
+ QtXmlToSphinx x(this, doc.value(), metaClassName);
+ s << x;
+ } else {
+ QStringList lines = doc.value().split(QLatin1Char('\n'));
+ QRegExp regex(QLatin1String("\\S")); // non-space character
+ int typesystemIndentation = std::numeric_limits<int>().max();
+ // check how many spaces must be removed from the begining of each line
+ foreach (QString line, lines) {
+ int idx = line.indexOf(regex);
+ if (idx >= 0)
+ typesystemIndentation = qMin(typesystemIndentation, idx);
+ }
+ foreach (QString line, lines)
+ s << INDENT << line.remove(0, typesystemIndentation) << endl;
+ }
+
+ s << endl;
+}
+
+static void writeInheritedByList(QTextStream& s, const AbstractMetaClass* metaClass, const AbstractMetaClassList& allClasses)
+{
+ AbstractMetaClassList res;
+ foreach (AbstractMetaClass* c, allClasses) {
+ if (c != metaClass && c->inheritsFrom(metaClass))
+ res << c;
+ }
+
+ if (res.isEmpty())
+ return;
+
+ s << "**Inherited by:** ";
+ QStringList classes;
+ foreach (AbstractMetaClass* c, res)
+ classes << QLatin1String(":ref:`") + getClassTargetFullName(c, false) + QLatin1Char('`');
+ s << classes.join(QLatin1String(", ")) << endl << endl;
+}
+
+void QtDocGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
+{
+ AbstractMetaClass *metaClass = classContext.metaClass();
+ qCDebug(lcShiboken).noquote().nospace() << "Generating Documentation for " << metaClass->fullName();
+
+ m_packages[metaClass->package()] << fileNameForContext(classContext);
+
+ m_docParser->setPackageName(metaClass->package());
+ m_docParser->fillDocumentation(const_cast<AbstractMetaClass*>(metaClass));
+
+ s << ".. module:: " << metaClass->package() << endl;
+ QString className = getClassTargetFullName(metaClass, false);
+ s << ".. _" << className << ":" << endl << endl;
+
+ s << className << endl;
+ s << createRepeatedChar(className.count(), '*') << endl << endl;
+
+ s << ".. inheritance-diagram:: " << className << endl
+ << " :parts: 2" << endl << endl; // TODO: This would be a parameter in the future...
+
+
+ writeInheritedByList(s, metaClass, classes());
+
+ if (metaClass->typeEntry() && (metaClass->typeEntry()->version() != 0))
+ s << ".. note:: This class was introduced in Qt " << metaClass->typeEntry()->version() << endl;
+
+ writeFunctionList(s, metaClass);
+
+ //Function list
+ AbstractMetaFunctionList functionList = metaClass->functions();
+ qSort(functionList.begin(), functionList.end(), functionSort);
+
+ s << "Detailed Description\n"
+ "--------------------\n\n";
+
+ writeInjectDocumentation(s, TypeSystem::DocModificationPrepend, metaClass, 0);
+ if (!writeInjectDocumentation(s, TypeSystem::DocModificationReplace, metaClass, 0))
+ writeFormatedText(s, metaClass->documentation(), metaClass);
+
+ if (!metaClass->isNamespace())
+ writeConstructors(s, metaClass);
+ writeEnums(s, metaClass);
+ if (!metaClass->isNamespace())
+ writeFields(s, metaClass);
+
+
+ foreach (AbstractMetaFunction* func, functionList) {
+ if (shouldSkip(func))
+ continue;
+
+ if (func->isStatic())
+ s << ".. staticmethod:: ";
+ else
+ s << ".. method:: ";
+
+ writeFunction(s, true, metaClass, func);
+ }
+
+ writeInjectDocumentation(s, TypeSystem::DocModificationAppend, metaClass, 0);
+}
+
+void QtDocGenerator::writeFunctionList(QTextStream& s, const AbstractMetaClass* cppClass)
+{
+ QStringList functionList;
+ QStringList virtualList;
+ QStringList signalList;
+ QStringList slotList;
+ QStringList staticFunctionList;
+
+ foreach (AbstractMetaFunction* func, cppClass->functions()) {
+ if (shouldSkip(func))
+ continue;
+
+ QString className;
+ if (!func->isConstructor())
+ className = getClassTargetFullName(cppClass) + QLatin1Char('.');
+ else if (func->implementingClass() && func->implementingClass()->enclosingClass())
+ className = getClassTargetFullName(func->implementingClass()->enclosingClass()) + QLatin1Char('.');
+ QString funcName = getFuncName(func);
+
+ QString str = QLatin1String("def :meth:`");
+
+ str += funcName;
+ str += QLatin1Char('<');
+ if (!funcName.startsWith(className))
+ str += className;
+ str += funcName;
+ str += QLatin1String(">` (");
+ str += parseArgDocStyle(cppClass, func);
+ str += QLatin1Char(')');
+
+ if (func->isStatic())
+ staticFunctionList << str;
+ else if (func->isVirtual())
+ virtualList << str;
+ else if (func->isSignal())
+ signalList << str;
+ else if (func->isSlot())
+ slotList << str;
+ else
+ functionList << str;
+ }
+
+ if ((functionList.size() > 0) || (staticFunctionList.size() > 0)) {
+ QtXmlToSphinx::Table functionTable;
+ QtXmlToSphinx::TableRow row;
+
+ s << "Synopsis" << endl
+ << "--------" << endl << endl;
+
+ writeFunctionBlock(s, QLatin1String("Functions"), functionList);
+ writeFunctionBlock(s, QLatin1String("Virtual functions"), virtualList);
+ writeFunctionBlock(s, QLatin1String("Slots"), slotList);
+ writeFunctionBlock(s, QLatin1String("Signals"), signalList);
+ writeFunctionBlock(s, QLatin1String("Static functions"), staticFunctionList);
+ }
+}
+
+void QtDocGenerator::writeFunctionBlock(QTextStream& s, const QString& title, QStringList& functions)
+{
+ if (functions.size() > 0) {
+ s << title << endl
+ << QString(title.size(), QLatin1Char('^')) << endl;
+
+ qSort(functions);
+
+ s << ".. container:: function_list" << endl << endl;
+ Indentation indentation(INDENT);
+ foreach (QString func, functions)
+ s << '*' << INDENT << func << endl;
+
+ s << endl << endl;
+ }
+}
+
+void QtDocGenerator::writeEnums(QTextStream& s, const AbstractMetaClass* cppClass)
+{
+ static const QString section_title = QLatin1String(".. attribute:: ");
+
+ foreach (AbstractMetaEnum* en, cppClass->enums()) {
+ s << section_title << getClassTargetFullName(cppClass) << '.' << en->name() << endl << endl;
+ writeFormatedText(s, en->documentation(), cppClass);
+
+ if (en->typeEntry() && (en->typeEntry()->version() != 0))
+ s << ".. note:: This enum was introduced or modified in Qt " << en->typeEntry()->version() << endl;
+ }
+
+}
+
+void QtDocGenerator::writeFields(QTextStream& s, const AbstractMetaClass* cppClass)
+{
+ static const QString section_title = QLatin1String(".. attribute:: ");
+
+ foreach (AbstractMetaField* field, cppClass->fields()) {
+ s << section_title << getClassTargetFullName(cppClass) << "." << field->name() << endl << endl;
+ //TODO: request for member ‘documentation’ is ambiguous
+ writeFormatedText(s, field->AbstractMetaAttributes::documentation(), cppClass);
+ }
+}
+
+void QtDocGenerator::writeConstructors(QTextStream& s, const AbstractMetaClass* cppClass)
+{
+ static const QString sectionTitle = QLatin1String(".. class:: ");
+ static const QString sectionTitleSpace = QString(sectionTitle.size(), QLatin1Char(' '));
+
+ AbstractMetaFunctionList lst = cppClass->queryFunctions(AbstractMetaClass::Constructors | AbstractMetaClass::Visible);
+
+ bool first = true;
+ QHash<QString, AbstractMetaArgument*> arg_map;
+
+ foreach(AbstractMetaFunction* func, lst) {
+ if (func->isModifiedRemoved())
+ continue;
+
+ if (first) {
+ first = false;
+ s << sectionTitle;
+ } else {
+ s << sectionTitleSpace;
+ }
+ writeFunction(s, false, cppClass, func);
+ foreach(AbstractMetaArgument* arg, func->arguments())
+ {
+ if (!arg_map.contains(arg->name())) {
+ arg_map.insert(arg->name(), arg);
+ }
+ }
+ }
+
+ s << endl;
+
+ foreach (AbstractMetaArgument* arg, arg_map.values()) {
+ Indentation indentation(INDENT);
+ writeParamerteType(s, cppClass, arg);
+ }
+
+ s << endl;
+
+ foreach (AbstractMetaFunction* func, lst) {
+ writeFormatedText(s, func->documentation(), cppClass);
+ }
+}
+
+QString QtDocGenerator::parseArgDocStyle(const AbstractMetaClass* cppClass, const AbstractMetaFunction* func)
+{
+ QString ret;
+ int optArgs = 0;
+
+ foreach (AbstractMetaArgument* arg, func->arguments()) {
+
+ if (func->argumentRemoved(arg->argumentIndex() + 1))
+ continue;
+
+ bool thisIsoptional = !arg->defaultValueExpression().isEmpty();
+ if (optArgs || thisIsoptional) {
+ ret += QLatin1Char('[');
+ optArgs++;
+ }
+
+ if (arg->argumentIndex() > 0)
+ ret += QLatin1String(", ");
+
+ ret += arg->name();
+
+ if (thisIsoptional) {
+ QString defValue = arg->defaultValueExpression();
+ if (defValue == QLatin1String("QString()")) {
+ defValue = QLatin1String("\"\"");
+ } else if (defValue == QLatin1String("QStringList()")
+ || defValue.startsWith(QLatin1String("QVector"))
+ || defValue.startsWith(QLatin1String("QList"))) {
+ defValue = QLatin1String("list()");
+ } else if (defValue == QLatin1String("QVariant()")) {
+ defValue = QLatin1String("None");
+ } else {
+ defValue.replace(QLatin1String("::"), QLatin1String("."));
+ if (defValue == QLatin1String("0") && (arg->type()->isQObject() || arg->type()->isObject()))
+ defValue = QLatin1String("None");
+ }
+ ret += QLatin1Char('=') + defValue;
+ }
+ }
+
+ ret += QString(optArgs, QLatin1Char(']'));
+ return ret;
+}
+
+void QtDocGenerator::writeDocSnips(QTextStream &s,
+ const CodeSnipList &codeSnips,
+ TypeSystem::CodeSnipPosition position,
+ TypeSystem::Language language)
+{
+ Indentation indentation(INDENT);
+ QStringList invalidStrings;
+ const static QString startMarkup = QLatin1String("[sphinx-begin]");
+ const static QString endMarkup = QLatin1String("[sphinx-end]");
+
+ invalidStrings << QLatin1String("*") << QLatin1String("//") << QLatin1String("/*") << QLatin1String("*/");
+
+ foreach (CodeSnip snip, codeSnips) {
+ if ((snip.position != position) ||
+ !(snip.language & language))
+ continue;
+
+ QString code = snip.code();
+ while (code.contains(startMarkup) && code.contains(endMarkup)) {
+ int startBlock = code.indexOf(startMarkup) + startMarkup.size();
+ int endBlock = code.indexOf(endMarkup);
+
+ if ((startBlock == -1) || (endBlock == -1))
+ break;
+
+ QString codeBlock = code.mid(startBlock, endBlock - startBlock);
+ QStringList rows = codeBlock.split(QLatin1Char('\n'));
+ int currenRow = 0;
+ int offset = 0;
+
+ foreach(QString row, rows) {
+ foreach(QString invalidString, invalidStrings) {
+ row = row.remove(invalidString);
+ }
+
+ if (row.trimmed().size() == 0) {
+ if (currenRow == 0)
+ continue;
+ else
+ s << endl;
+ }
+
+ if (currenRow == 0) {
+ //find offset
+ for (int i=0, i_max = row.size(); i < i_max; i++) {
+ if (row[i] == QLatin1Char(' '))
+ offset++;
+ else if (row[i] == QLatin1Char('\n'))
+ offset = 0;
+ else
+ break;
+ }
+ }
+ row = row.mid(offset);
+ s << row << endl;
+ currenRow++;
+ }
+
+ code = code.mid(endBlock+endMarkup.size());
+ }
+ }
+}
+
+bool QtDocGenerator::writeInjectDocumentation(QTextStream& s,
+ TypeSystem::DocModificationMode mode,
+ const AbstractMetaClass* cppClass,
+ const AbstractMetaFunction* func)
+{
+ Indentation indentation(INDENT);
+ bool didSomething = false;
+
+ foreach (DocModification mod, cppClass->typeEntry()->docModifications()) {
+ if (mod.mode() == mode) {
+ bool modOk = func ? mod.signature() == func->minimalSignature() : mod.signature().isEmpty();
+
+ if (modOk) {
+ Documentation doc;
+ Documentation::Format fmt;
+
+ if (mod.format == TypeSystem::NativeCode)
+ fmt = Documentation::Native;
+ else if (mod.format == TypeSystem::TargetLangCode)
+ fmt = Documentation::Target;
+ else
+ continue;
+
+ doc.setValue(mod.code() , fmt);
+ writeFormatedText(s, doc, cppClass);
+ didSomething = true;
+ }
+ }
+ }
+
+ s << endl;
+
+ // TODO: Deprecate the use of doc string on glue code.
+ // This is pre "add-function" and "inject-documentation" tags.
+ const TypeSystem::CodeSnipPosition pos = mode == TypeSystem::DocModificationPrepend
+ ? TypeSystem::CodeSnipPositionBeginning : TypeSystem::CodeSnipPositionEnd;
+ if (func)
+ writeDocSnips(s, func->injectedCodeSnips(), pos, TypeSystem::TargetLangCode);
+ else
+ writeDocSnips(s, cppClass->typeEntry()->codeSnips(), pos, TypeSystem::TargetLangCode);
+ return didSomething;
+}
+
+void QtDocGenerator::writeFunctionSignature(QTextStream& s, const AbstractMetaClass* cppClass, const AbstractMetaFunction* func)
+{
+ QString className;
+ if (!func->isConstructor())
+ className = getClassTargetFullName(cppClass) + QLatin1Char('.');
+ else if (func->implementingClass() && func->implementingClass()->enclosingClass())
+ className = getClassTargetFullName(func->implementingClass()->enclosingClass()) + QLatin1Char('.');
+
+ QString funcName = getFuncName(func);
+ if (!funcName.startsWith(className))
+ funcName = className + funcName;
+
+ s << funcName << "(" << parseArgDocStyle(cppClass, func) << ")";
+}
+
+QString QtDocGenerator::translateToPythonType(const AbstractMetaType* type, const AbstractMetaClass* cppClass)
+{
+ QString strType;
+ if (type->name() == QLatin1String("QString")) {
+ strType = QLatin1String("unicode");
+ } else if (type->name() == QLatin1String("QVariant")) {
+ strType = QLatin1String("object");
+ } else if (type->name() == QLatin1String("QStringList")) {
+ strType = QLatin1String("list of strings");
+ } else if (type->isConstant() && type->name() == QLatin1String("char") && type->indirections() == 1) {
+ strType = QLatin1String("str");
+ } else if (type->name().startsWith(QLatin1String("unsigned short"))) {
+ strType = QLatin1String("int");
+ } else if (type->name().startsWith(QLatin1String("unsigned "))) { // uint and ulong
+ strType = QLatin1String("long");
+ } else if (type->isContainer()) {
+ QString strType = translateType(type, cppClass, Options(ExcludeConst) | ExcludeReference);
+ strType.remove(QLatin1Char('*'));
+ strType.remove(QLatin1Char('>'));
+ strType.remove(QLatin1Char('<'));
+ strType.replace(QLatin1String("::"), QLatin1String("."));
+ if (strType.contains(QLatin1String("QList")) || strType.contains(QLatin1String("QVector"))) {
+ strType.replace(QLatin1String("QList"), QLatin1String("list of "));
+ strType.replace(QLatin1String("QVector"), QLatin1String("list of "));
+ } else if (strType.contains(QLatin1String("QHash")) || strType.contains(QLatin1String("QMap"))) {
+ strType.remove(QLatin1String("QHash"));
+ strType.remove(QLatin1String("QMap"));
+ QStringList types = strType.split(QLatin1Char(','));
+ strType = QString::fromLatin1("Dictionary with keys of type %1 and values of type %2.")
+ .arg(types[0], types[1]);
+ }
+ } else {
+ QString refTag;
+ if (type->isEnum())
+ refTag = QLatin1String("attr");
+ else
+ refTag = QLatin1String("class");
+ strType = QLatin1Char(':') + refTag + QLatin1String(":`") + type->fullName() + QLatin1Char('`');
+ }
+ return strType;
+}
+
+void QtDocGenerator::writeParamerteType(QTextStream& s, const AbstractMetaClass* cppClass, const AbstractMetaArgument* arg)
+{
+ s << INDENT << ":param " << arg->name() << ": "
+ << translateToPythonType(arg->type(), cppClass) << endl;
+}
+
+void QtDocGenerator::writeFunctionParametersType(QTextStream& s, const AbstractMetaClass* cppClass, const AbstractMetaFunction* func)
+{
+ Indentation indentation(INDENT);
+
+ s << endl;
+ foreach (AbstractMetaArgument* arg, func->arguments()) {
+
+ if (func->argumentRemoved(arg->argumentIndex() + 1))
+ continue;
+
+ writeParamerteType(s, cppClass, arg);
+ }
+
+ if (!func->isConstructor() && func->type()) {
+
+ QString retType;
+ // check if the return type was modified
+ foreach (FunctionModification mod, func->modifications()) {
+ foreach (ArgumentModification argMod, mod.argument_mods) {
+ if (argMod.index == 0) {
+ retType = argMod.modified_type;
+ break;
+ }
+ }
+ }
+
+ if (retType.isEmpty())
+ retType = translateToPythonType(func->type(), cppClass);
+ s << INDENT << ":rtype: " << retType << endl;
+ }
+ s << endl;
+}
+
+void QtDocGenerator::writeFunction(QTextStream& s, bool writeDoc, const AbstractMetaClass* cppClass, const AbstractMetaFunction* func)
+{
+ writeFunctionSignature(s, cppClass, func);
+ s << endl;
+
+ if (func->typeEntry() && (func->typeEntry()->version() != 0))
+ s << ".. note:: This method was introduced in Qt " << func->typeEntry()->version() << endl;
+
+ if (writeDoc) {
+ s << endl;
+ writeFunctionParametersType(s, cppClass, func);
+ s << endl;
+ writeInjectDocumentation(s, TypeSystem::DocModificationPrepend, cppClass, func);
+ if (!writeInjectDocumentation(s, TypeSystem::DocModificationReplace, cppClass, func))
+ writeFormatedText(s, func->documentation(), cppClass);
+ writeInjectDocumentation(s, TypeSystem::DocModificationAppend, cppClass, func);
+ }
+}
+
+static void writeFancyToc(QTextStream& s, const QStringList& items, int cols = 4)
+{
+ typedef QMap<QChar, QStringList> TocMap;
+ TocMap tocMap;
+ QChar Q = QLatin1Char('Q');
+ QChar idx;
+ foreach (QString item, items) {
+ if (item.isEmpty())
+ continue;
+ if (item.startsWith(Q) && item.length() > 1)
+ idx = item[1];
+ item.chop(4); // Remove the .rst extension
+ tocMap[idx] << item;
+ }
+ QtXmlToSphinx::Table table;
+ QtXmlToSphinx::TableRow row;
+
+ int itemsPerCol = (items.size() + tocMap.size()*2) / cols;
+ QString currentColData;
+ int i = 0;
+ QTextStream ss(&currentColData);
+ QMutableMapIterator<QChar, QStringList> it(tocMap);
+ while (it.hasNext()) {
+ it.next();
+ qSort(it.value());
+
+ if (i)
+ ss << endl;
+
+ ss << "**" << it.key() << "**" << endl << endl;
+ i += 2; // a letter title is equivalent to two entries in space
+ foreach (QString item, it.value()) {
+ ss << "* :doc:`" << item << "`" << endl;
+ ++i;
+
+ // end of column detected!
+ if (i > itemsPerCol) {
+ ss.flush();
+ QtXmlToSphinx::TableCell cell(currentColData);
+ row << cell;
+ currentColData.clear();
+ i = 0;
+ }
+ }
+ }
+ if (i) {
+ ss.flush();
+ QtXmlToSphinx::TableCell cell(currentColData);
+ row << cell;
+ currentColData.clear();
+ i = 0;
+ }
+ table << row;
+ table.normalize();
+ s << ".. container:: pysidetoc" << endl << endl;
+ s << table;
+}
+
+bool QtDocGenerator::finishGeneration()
+{
+ if (classes().isEmpty())
+ return true;
+
+ QMap<QString, QStringList>::iterator it = m_packages.begin();
+ for (; it != m_packages.end(); ++it) {
+ QString key = it.key();
+ key.replace(QLatin1Char('.'), QLatin1Char('/'));
+ QString outputDir = outputDirectory() + QLatin1Char('/') + key;
+ FileOut output(outputDir + QLatin1String("/index.rst"));
+ QTextStream& s = output.stream;
+
+ s << ".. module:: " << it.key() << endl << endl;
+
+ QString title = it.key();
+ s << title << endl;
+ s << createRepeatedChar(title.length(), '*') << endl << endl;
+
+ /* Avoid showing "Detailed Description for *every* class in toc tree */
+ Indentation indentation(INDENT);
+
+ // Search for extra-sections
+ if (!m_extraSectionDir.isEmpty()) {
+ QDir extraSectionDir(m_extraSectionDir);
+ QStringList fileList = extraSectionDir.entryList(QStringList() << (it.key() + QLatin1String("?*.rst")), QDir::Files);
+ QStringList::iterator it2 = fileList.begin();
+ for (; it2 != fileList.end(); ++it2) {
+ QString origFileName(*it2);
+ it2->remove(0, it.key().count() + 1);
+ QString newFilePath = outputDir + QLatin1Char('/') + *it2;
+ if (QFile::exists(newFilePath))
+ QFile::remove(newFilePath);
+ if (!QFile::copy(m_extraSectionDir + QLatin1Char('/') + origFileName, newFilePath)) {
+ qCDebug(lcShiboken).noquote().nospace() << "Error copying extra doc "
+ << QDir::toNativeSeparators(m_extraSectionDir + QLatin1Char('/') + origFileName)
+ << " to " << QDir::toNativeSeparators(newFilePath);
+ }
+ }
+ it.value().append(fileList);
+ }
+
+ writeFancyToc(s, it.value());
+
+ s << INDENT << ".. container:: hide" << endl << endl;
+ {
+ Indentation indentation(INDENT);
+ s << INDENT << ".. toctree::" << endl;
+ Indentation deeperIndentation(INDENT);
+ s << INDENT << ":maxdepth: 1" << endl << endl;
+ foreach (QString className, it.value())
+ s << INDENT << className << endl;
+ s << endl << endl;
+ }
+
+ s << "Detailed Description" << endl;
+ s << "--------------------" << endl << endl;
+
+ // module doc is always wrong and C++istic, so go straight to the extra directory!
+ QFile moduleDoc(m_extraSectionDir + QLatin1Char('/') + it.key() + QLatin1String(".rst"));
+ if (moduleDoc.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ s << moduleDoc.readAll();
+ moduleDoc.close();
+ } else {
+ // try the normal way
+ Documentation moduleDoc = m_docParser->retrieveModuleDocumentation(it.key());
+ if (moduleDoc.format() == Documentation::Native) {
+ QString context = it.key();
+ context.remove(0, context.lastIndexOf(QLatin1Char('.')) + 1);
+ QtXmlToSphinx x(this, moduleDoc.value(), context);
+ s << x;
+ } else {
+ s << moduleDoc.value();
+ }
+ }
+ }
+ return true;
+}
+
+bool QtDocGenerator::doSetup(const QMap<QString, QString>& args)
+{
+ m_libSourceDir = args.value(QLatin1String("library-source-dir"));
+ m_docDataDir = args.value(QLatin1String("documentation-data-dir"));
+#ifdef __WIN32__
+# define PATH_SEP ';'
+#else
+# define PATH_SEP ':'
+#endif
+ m_codeSnippetDirs = args.value(QLatin1String("documentation-code-snippets-dir"), m_libSourceDir).split(QLatin1Char(PATH_SEP));
+ m_extraSectionDir = args.value(QLatin1String("documentation-extra-sections-dir"));
+
+ m_docParser = args.value(QLatin1String("doc-parser")) == QLatin1String("doxygen")
+ ? static_cast<DocParser*>(new DoxygenParser)
+ : static_cast<DocParser*>(new QtDocParser);
+ qCDebug(lcShiboken).noquote().nospace() << "doc-parser: " << args.value(QLatin1String("doc-parser"));
+
+ if (m_libSourceDir.isEmpty() || m_docDataDir.isEmpty()) {
+ qCWarning(lcShiboken) << "Documentation data dir and/or Qt source dir not informed, "
+ "documentation will not be extracted from Qt sources.";
+ return false;
+ } else {
+ m_docParser->setDocumentationDataDirectory(m_docDataDir);
+ m_docParser->setLibrarySourceDirectory(m_libSourceDir);
+ }
+ return true;
+}
+
+
+QMap<QString, QString> QtDocGenerator::options() const
+{
+ QMap<QString, QString> options;
+ options.insert(QLatin1String("doc-parser"),
+ QLatin1String("The documentation parser used to interpret the documentation input files (qdoc3|doxygen)"));
+ options.insert(QLatin1String("library-source-dir"),
+ QLatin1String("Directory where library source code is located"));
+ options.insert(QLatin1String("documentation-data-dir"),
+ QLatin1String("Directory with XML files generated by documentation tool (qdoc3 or Doxygen)"));
+ options.insert(QLatin1String("documentation-code-snippets-dir"),
+ QLatin1String("Directory used to search code snippets used by the documentation"));
+ options.insert(QLatin1String("documentation-extra-sections-dir"),
+ QLatin1String("Directory used to search for extra documentation sections"));
+ return options;
+}
+
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.h b/sources/shiboken2/generator/qtdoc/qtdocgenerator.h
new file mode 100644
index 000000000..fa8524b21
--- /dev/null
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.h
@@ -0,0 +1,235 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef DOCGENERATOR_H
+#define DOCGENERATOR_H
+
+#include <QtCore/QStack>
+#include <QtCore/QHash>
+#include <QtCore/QTextStream>
+#include <QXmlStreamReader>
+#include "generator.h"
+#include "docparser.h"
+#include "typesystem_enums.h"
+#include "typesystem_typedefs.h"
+
+class QtDocParser;
+class AbstractMetaFunction;
+class AbstractMetaClass;
+QT_BEGIN_NAMESPACE
+class QXmlStreamReader;
+QT_END_NAMESPACE
+class QtDocGenerator;
+
+class QtXmlToSphinx
+{
+public:
+ struct TableCell
+ {
+ short rowSpan;
+ short colSpan;
+ QString data;
+
+ TableCell(const QString& text = QString()) : rowSpan(0), colSpan(0), data(text) {}
+ TableCell(const char* text) : rowSpan(0), colSpan(0), data(QLatin1String(text)) {}
+ };
+
+ typedef QList<TableCell> TableRow;
+ class Table : public QList<TableRow>
+ {
+ public:
+ Table() : m_hasHeader(false), m_normalized(false)
+ {
+ }
+
+ void enableHeader(bool enable)
+ {
+ m_hasHeader = enable;
+ }
+
+ bool hasHeader() const
+ {
+ return m_hasHeader;
+ }
+
+ void normalize();
+
+ bool isNormalized() const
+ {
+ return m_normalized;
+ }
+
+ void clear() {
+ m_normalized = false;
+ QList<TableRow>::clear();
+ }
+
+ private:
+ bool m_hasHeader;
+ bool m_normalized;
+ };
+
+ QtXmlToSphinx(QtDocGenerator* generator, const QString& doc, const QString& context = QString());
+
+ QString result() const
+ {
+ return m_result;
+ }
+
+private:
+ QString resolveContextForMethod(const QString& methodName);
+ QString expandFunction(const QString& function);
+ QString transform(const QString& doc);
+
+ void handleHeadingTag(QXmlStreamReader& reader);
+ void handleParaTag(QXmlStreamReader& reader);
+ void handleItalicTag(QXmlStreamReader& reader);
+ void handleBoldTag(QXmlStreamReader& reader);
+ void handleArgumentTag(QXmlStreamReader& reader);
+ void handleSeeAlsoTag(QXmlStreamReader& reader);
+ void handleSnippetTag(QXmlStreamReader& reader);
+ void handleDotsTag(QXmlStreamReader& reader);
+ void handleLinkTag(QXmlStreamReader& reader);
+ void handleImageTag(QXmlStreamReader& reader);
+ void handleListTag(QXmlStreamReader& reader);
+ void handleTermTag(QXmlStreamReader& reader);
+ void handleSuperScriptTag(QXmlStreamReader& reader);
+ void handleQuoteFileTag(QXmlStreamReader& reader);
+
+ // table tagsvoid QtXmlToSphinx::handleValueTag(QXmlStreamReader& reader)
+
+ void handleTableTag(QXmlStreamReader& reader);
+ void handleRowTag(QXmlStreamReader& reader);
+ void handleItemTag(QXmlStreamReader& reader);
+ void handleRawTag(QXmlStreamReader& reader);
+ void handleCodeTag(QXmlStreamReader& reader);
+
+ void handleIgnoredTag(QXmlStreamReader& reader);
+ void handleUnknownTag(QXmlStreamReader& reader);
+ void handleUselessTag(QXmlStreamReader& reader);
+ void handleAnchorTag(QXmlStreamReader& reader);
+
+ typedef void (QtXmlToSphinx::*TagHandler)(QXmlStreamReader&);
+ QHash<QString, TagHandler> m_handlerMap;
+ QStack<TagHandler> m_handlers;
+ QTextStream m_output;
+ QString m_result;
+
+ QStack<QString*> m_buffers;
+
+
+ Table m_currentTable;
+ bool m_tableHasHeader;
+ QString m_context;
+ QtDocGenerator* m_generator;
+ bool m_insideBold;
+ bool m_insideItalic;
+ QString m_lastTagName;
+ QString m_opened_anchor;
+
+ QString readFromLocations(const QStringList& locations, const QString& path, const QString& identifier);
+ QString readFromLocation(const QString& location, const QString& identifier, bool* ok = 0);
+ void pushOutputBuffer();
+ QString popOutputBuffer();
+ void writeTable(Table& table);
+};
+
+inline QTextStream& operator<<(QTextStream& s, const QtXmlToSphinx& xmlToSphinx)
+{
+ return s << xmlToSphinx.result();
+}
+
+QTextStream& operator<<(QTextStream& s, const QtXmlToSphinx::Table &table);
+
+/**
+* The DocGenerator generates documentation from library being binded.
+*/
+class QtDocGenerator : public Generator
+{
+public:
+ QtDocGenerator();
+ ~QtDocGenerator();
+
+ QString libSourceDir() const
+ {
+ return m_libSourceDir;
+ }
+
+ bool doSetup(const QMap<QString, QString>& args);
+
+ const char* name() const
+ {
+ return "QtDocGenerator";
+ }
+
+ QMap<QString, QString> options() const;
+
+ QStringList codeSnippetDirs() const
+ {
+ return m_codeSnippetDirs;
+ }
+
+protected:
+ QString fileNamePrefix() const;
+ QString fileNameForContext(GeneratorContext &context) const;
+ void generateClass(QTextStream &s, GeneratorContext &classContext);
+ bool finishGeneration();
+
+ void writeFunctionArguments(QTextStream&, const AbstractMetaFunction*, Options) const {}
+ void writeArgumentNames(QTextStream&, const AbstractMetaFunction*, Options) const {}
+
+private:
+ void writeEnums(QTextStream& s, const AbstractMetaClass* cppClass);
+
+ void writeFields(QTextStream &s, const AbstractMetaClass *cppClass);
+ void writeArguments(QTextStream &s, const AbstractMetaClass *cppClass, const AbstractMetaFunction *func);
+ void writeFunctionSignature(QTextStream& s, const AbstractMetaClass* cppClass, const AbstractMetaFunction* func);
+ void writeFunction(QTextStream& s, bool writeDoc, const AbstractMetaClass* cppClass, const AbstractMetaFunction* func);
+ void writeFunctionParametersType(QTextStream &s, const AbstractMetaClass *cppClass, const AbstractMetaFunction* func);
+ void writeFunctionList(QTextStream& s, const AbstractMetaClass* cppClass);
+ void writeFunctionBlock(QTextStream& s, const QString& title, QStringList& functions);
+ void writeParamerteType(QTextStream &s, const AbstractMetaClass *cppClass, const AbstractMetaArgument *arg);
+
+ void writeConstructors(QTextStream &s, const AbstractMetaClass *cppClass);
+ void writeFormatedText(QTextStream& s, const Documentation& doc, const AbstractMetaClass* metaclass = 0);
+ bool writeInjectDocumentation(QTextStream& s, TypeSystem::DocModificationMode mode, const AbstractMetaClass* cppClass, const AbstractMetaFunction* func);
+ void writeDocSnips(QTextStream &s, const CodeSnipList &codeSnips, TypeSystem::CodeSnipPosition position, TypeSystem::Language language);
+
+
+ QString parseArgDocStyle(const AbstractMetaClass *cppClass, const AbstractMetaFunction *func);
+ QString translateToPythonType(const AbstractMetaType *type, const AbstractMetaClass *cppClass);
+
+ QString m_docDataDir;
+ QString m_libSourceDir;
+ QStringList m_codeSnippetDirs;
+ QString m_extraSectionDir;
+ QStringList m_functionList;
+ QMap<QString, QStringList> m_packages;
+ DocParser* m_docParser;
+};
+
+#endif // DOCGENERATOR_H
diff --git a/sources/shiboken2/generator/shiboken2/CMakeLists.txt b/sources/shiboken2/generator/shiboken2/CMakeLists.txt
new file mode 100644
index 000000000..5c1b612dd
--- /dev/null
+++ b/sources/shiboken2/generator/shiboken2/CMakeLists.txt
@@ -0,0 +1,28 @@
+project(shibokengenerator)
+
+set(shiboken_SRC
+../generator.cpp
+cppgenerator.cpp
+headergenerator.cpp
+overloaddata.cpp
+shibokengenerator.cpp
+main.cpp
+)
+
+include_directories(${generators_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${APIEXTRACTOR_INCLUDE_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ )
+
+add_executable(shiboken2 ${shiboken_SRC})
+set_target_properties(shiboken2 PROPERTIES OUTPUT_NAME shiboken2${shiboken_SUFFIX})
+target_link_libraries(shiboken2
+ ${APIEXTRACTOR_LIBRARY}
+ ${Qt5Core_LIBRARIES}
+ )
+
+configure_file(shibokenconfig.h.in "${CMAKE_CURRENT_BINARY_DIR}/shibokenconfig.h" @ONLY)
+
+install(TARGETS shiboken2 DESTINATION bin)
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
new file mode 100644
index 000000000..68b62477e
--- /dev/null
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -0,0 +1,5689 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <memory>
+
+#include "cppgenerator.h"
+#include "overloaddata.h"
+#include <abstractmetalang.h>
+#include <reporthandler.h>
+#include <typedatabase.h>
+
+#include <QtCore/QDir>
+#include <QtCore/QMetaObject>
+#include <QtCore/QTextStream>
+#include <QtCore/QDebug>
+#include <QMetaType>
+
+QHash<QString, QString> CppGenerator::m_nbFuncs = QHash<QString, QString>();
+QHash<QString, QString> CppGenerator::m_sqFuncs = QHash<QString, QString>();
+QHash<QString, QString> CppGenerator::m_mpFuncs = QHash<QString, QString>();
+QString CppGenerator::m_currentErrorCode(QLatin1String("0"));
+
+// utility functions
+inline AbstractMetaType* getTypeWithoutContainer(AbstractMetaType* arg)
+{
+ if (arg && arg->typeEntry()->isContainer()) {
+ AbstractMetaTypeList lst = arg->instantiations();
+ // only support containers with 1 type
+ if (lst.size() == 1)
+ return lst[0];
+ }
+ return arg;
+}
+
+CppGenerator::CppGenerator()
+{
+ // Number protocol structure members names
+ m_nbFuncs.insert(QLatin1String("__add__"), QLatin1String("nb_add"));
+ m_nbFuncs.insert(QLatin1String("__sub__"), QLatin1String("nb_subtract"));
+ m_nbFuncs.insert(QLatin1String("__mul__"), QLatin1String("nb_multiply"));
+ m_nbFuncs.insert(QLatin1String("__div__"), QLatin1String("nb_divide"));
+ m_nbFuncs.insert(QLatin1String("__mod__"), QLatin1String("nb_remainder"));
+ m_nbFuncs.insert(QLatin1String("__neg__"), QLatin1String("nb_negative"));
+ m_nbFuncs.insert(QLatin1String("__pos__"), QLatin1String("nb_positive"));
+ m_nbFuncs.insert(QLatin1String("__invert__"), QLatin1String("nb_invert"));
+ m_nbFuncs.insert(QLatin1String("__lshift__"), QLatin1String("nb_lshift"));
+ m_nbFuncs.insert(QLatin1String("__rshift__"), QLatin1String("nb_rshift"));
+ m_nbFuncs.insert(QLatin1String("__and__"), QLatin1String("nb_and"));
+ m_nbFuncs.insert(QLatin1String("__xor__"), QLatin1String("nb_xor"));
+ m_nbFuncs.insert(QLatin1String("__or__"), QLatin1String("nb_or"));
+ m_nbFuncs.insert(QLatin1String("__iadd__"), QLatin1String("nb_inplace_add"));
+ m_nbFuncs.insert(QLatin1String("__isub__"), QLatin1String("nb_inplace_subtract"));
+ m_nbFuncs.insert(QLatin1String("__imul__"), QLatin1String("nb_inplace_multiply"));
+ m_nbFuncs.insert(QLatin1String("__idiv__"), QLatin1String("nb_inplace_divide"));
+ m_nbFuncs.insert(QLatin1String("__imod__"), QLatin1String("nb_inplace_remainder"));
+ m_nbFuncs.insert(QLatin1String("__ilshift__"), QLatin1String("nb_inplace_lshift"));
+ m_nbFuncs.insert(QLatin1String("__irshift__"), QLatin1String("nb_inplace_rshift"));
+ m_nbFuncs.insert(QLatin1String("__iand__"), QLatin1String("nb_inplace_and"));
+ m_nbFuncs.insert(QLatin1String("__ixor__"), QLatin1String("nb_inplace_xor"));
+ m_nbFuncs.insert(QLatin1String("__ior__"), QLatin1String("nb_inplace_or"));
+ m_nbFuncs.insert(QLatin1String("bool"), QLatin1String("nb_nonzero"));
+
+ // sequence protocol functions
+ typedef QPair<QString, QString> StrPair;
+ m_sequenceProtocol.insert(QLatin1String("__len__"),
+ StrPair(QLatin1String("PyObject* " PYTHON_SELF_VAR), QLatin1String("Py_ssize_t")));
+ m_sequenceProtocol.insert(QLatin1String("__getitem__"),
+ StrPair(QLatin1String("PyObject* " PYTHON_SELF_VAR ", Py_ssize_t _i"),
+ QLatin1String("PyObject*")));
+ m_sequenceProtocol.insert(QLatin1String("__setitem__"),
+ StrPair(QLatin1String("PyObject* " PYTHON_SELF_VAR ", Py_ssize_t _i, PyObject* _value"),
+ QLatin1String("int")));
+ m_sequenceProtocol.insert(QLatin1String("__getslice__"),
+ StrPair(QLatin1String("PyObject* " PYTHON_SELF_VAR ", Py_ssize_t _i1, Py_ssize_t _i2"),
+ QLatin1String("PyObject*")));
+ m_sequenceProtocol.insert(QLatin1String("__setslice__"),
+ StrPair(QLatin1String("PyObject* " PYTHON_SELF_VAR ", Py_ssize_t _i1, Py_ssize_t _i2, PyObject* _value"),
+ QLatin1String("int")));
+ m_sequenceProtocol.insert(QLatin1String("__contains__"),
+ StrPair(QLatin1String("PyObject* " PYTHON_SELF_VAR ", PyObject* _value"),
+ QLatin1String("int")));
+ m_sequenceProtocol.insert(QLatin1String("__concat__"),
+ StrPair(QLatin1String("PyObject* " PYTHON_SELF_VAR ", PyObject* _other"),
+ QLatin1String("PyObject*")));
+
+ // Sequence protocol structure members names
+ m_sqFuncs.insert(QLatin1String("__concat__"), QLatin1String("sq_concat"));
+ m_sqFuncs.insert(QLatin1String("__contains__"), QLatin1String("sq_contains"));
+ m_sqFuncs.insert(QLatin1String("__getitem__"), QLatin1String("sq_item"));
+ m_sqFuncs.insert(QLatin1String("__getslice__"), QLatin1String("sq_slice"));
+ m_sqFuncs.insert(QLatin1String("__len__"), QLatin1String("sq_length"));
+ m_sqFuncs.insert(QLatin1String("__setitem__"), QLatin1String("sq_ass_item"));
+ m_sqFuncs.insert(QLatin1String("__setslice__"), QLatin1String("sq_ass_slice"));
+
+ // mapping protocol function
+ m_mappingProtocol.insert(QLatin1String("__mlen__"),
+ StrPair(QLatin1String("PyObject* " PYTHON_SELF_VAR),
+ QLatin1String("Py_ssize_t")));
+ m_mappingProtocol.insert(QLatin1String("__mgetitem__"),
+ StrPair(QLatin1String("PyObject* " PYTHON_SELF_VAR ", PyObject* _key"),
+ QLatin1String("PyObject*")));
+ m_mappingProtocol.insert(QLatin1String("__msetitem__"),
+ StrPair(QLatin1String("PyObject* " PYTHON_SELF_VAR ", PyObject* _key, PyObject* _value"),
+ QLatin1String("int")));
+
+ // Sequence protocol structure members names
+ m_mpFuncs.insert(QLatin1String("__mlen__"), QLatin1String("mp_length"));
+ m_mpFuncs.insert(QLatin1String("__mgetitem__"), QLatin1String("mp_subscript"));
+ m_mpFuncs.insert(QLatin1String("__msetitem__"), QLatin1String("mp_ass_subscript"));
+}
+
+QString CppGenerator::fileNamePrefix() const
+{
+ return QLatin1String("_wrapper.cpp");
+}
+
+QString CppGenerator::fileNameForContext(GeneratorContext &context) const
+{
+ const AbstractMetaClass *metaClass = context.metaClass();
+ if (!context.forSmartPointer()) {
+ QString fileNameBase = metaClass->qualifiedCppName().toLower();
+ fileNameBase.replace(QLatin1String("::"), QLatin1String("_"));
+ return fileNameBase + fileNamePrefix();
+ } else {
+ const AbstractMetaType *smartPointerType = context.preciseType();
+ QString fileNameBase = getFileNameBaseForSmartPointer(smartPointerType, metaClass);
+ return fileNameBase + fileNamePrefix();
+ }
+}
+
+QList<AbstractMetaFunctionList> CppGenerator::filterGroupedOperatorFunctions(const AbstractMetaClass* metaClass,
+ uint queryIn)
+{
+ // ( func_name, num_args ) => func_list
+ QMap<QPair<QString, int >, AbstractMetaFunctionList> results;
+ const AbstractMetaClass::OperatorQueryOptions query(queryIn);
+ foreach (AbstractMetaFunction* func, metaClass->operatorOverloads(query)) {
+ if (func->isModifiedRemoved()
+ || func->usesRValueReferences()
+ || func->name() == QLatin1String("operator[]")
+ || func->name() == QLatin1String("operator->")
+ || func->name() == QLatin1String("operator!")) {
+ continue;
+ }
+ int args;
+ if (func->isComparisonOperator()) {
+ args = -1;
+ } else {
+ args = func->arguments().size();
+ }
+ QPair<QString, int > op(func->name(), args);
+ results[op].append(func);
+ }
+ return results.values();
+}
+
+bool CppGenerator::hasBoolCast(const AbstractMetaClass* metaClass) const
+{
+ if (!useIsNullAsNbNonZero())
+ return false;
+ // TODO: This could be configurable someday
+ const AbstractMetaFunction* func = metaClass->findFunction(QLatin1String("isNull"));
+ if (!func || !func->type() || !func->type()->typeEntry()->isPrimitive() || !func->isPublic())
+ return false;
+ const PrimitiveTypeEntry* pte = static_cast<const PrimitiveTypeEntry*>(func->type()->typeEntry());
+ while (pte->referencedTypeEntry())
+ pte = pte->referencedTypeEntry();
+ return func && func->isConstant() && pte->name() == QLatin1String("bool") && func->arguments().isEmpty();
+}
+
+typedef QMap<QString, AbstractMetaFunctionList> FunctionGroupMap;
+typedef FunctionGroupMap::const_iterator FunctionGroupMapIt;
+
+// Prevent ELF symbol qt_version_tag from being generated into the source
+static const char includeQDebug[] =
+"#ifndef QT_NO_VERSION_TAGGING\n"
+"# define QT_NO_VERSION_TAGGING\n"
+"#endif\n"
+"#include <QDebug>\n";
+
+/*!
+ Function used to write the class generated binding code on the buffer
+ \param s the output buffer
+ \param metaClass the pointer to metaclass information
+*/
+void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
+{
+ AbstractMetaClass *metaClass = classContext.metaClass();
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug))
+ qCDebug(lcShiboken) << "Generating wrapper implementation for " << metaClass->fullName();
+
+ // write license comment
+ s << licenseComment() << endl;
+
+ if (!avoidProtectedHack() && !metaClass->isNamespace() && !metaClass->hasPrivateDestructor()) {
+ s << "//workaround to access protected functions" << endl;
+ s << "#define protected public" << endl << endl;
+ }
+
+ // headers
+ s << "// default includes" << endl;
+ s << "#include <shiboken.h>" << endl;
+ if (usePySideExtensions()) {
+ s << includeQDebug;
+ s << "#include <pysidesignal.h>" << endl;
+ s << "#include <pysideproperty.h>" << endl;
+ s << "#include <pyside.h>" << endl;
+ s << "#include <destroylistener.h>" << endl;
+ }
+
+ s << "#include <typeresolver.h>" << endl;
+ s << "#include <typeinfo>" << endl;
+ if (usePySideExtensions() && metaClass->isQObject()) {
+ s << "#include <signalmanager.h>" << endl;
+ s << "#include <pysidemetafunction.h>" << endl;
+ }
+
+ // The multiple inheritance initialization function
+ // needs the 'set' class from C++ STL.
+ if (hasMultipleInheritanceInAncestry(metaClass))
+ s << "#include <set>" << endl;
+
+ s << endl << "// module include" << endl << "#include \"" << getModuleHeaderFileName() << '"' << endl;
+
+ QString headerfile = fileNameForContext(classContext);
+ headerfile.replace(QLatin1String(".cpp"), QLatin1String(".h"));
+ s << endl << "// main header" << endl << "#include \"" << headerfile << '"' << endl;
+
+ // PYSIDE-500: Use also includes for inherited wrapper classes, because
+ // without the protected hack, we sometimes need to cast inherited wrappers.
+ s << endl << "// inherited wrapper classes" << endl;
+ AbstractMetaClass *basis = metaClass->baseClass();
+ for (; basis; basis = basis->baseClass()) {
+ GeneratorContext basisContext(basis);
+ QString headerfile = fileNameForContext(basisContext);
+ headerfile.replace(QLatin1String(".cpp"), QLatin1String(".h"));
+ s << "#include \"" << headerfile << '"' << endl;
+ }
+
+ s << endl << "// inner classes" << endl;
+ foreach (AbstractMetaClass* innerClass, metaClass->innerClasses()) {
+ GeneratorContext innerClassContext(innerClass);
+ if (shouldGenerate(innerClass)) {
+ QString headerfile = fileNameForContext(innerClassContext);
+ headerfile.replace(QLatin1String(".cpp"), QLatin1String(".h"));
+ s << "#include \"" << headerfile << '"' << endl;
+ }
+ }
+
+ AbstractMetaEnumList classEnums = metaClass->enums();
+ foreach (AbstractMetaClass* innerClass, metaClass->innerClasses())
+ lookForEnumsInClassesNotToBeGenerated(classEnums, innerClass);
+
+ //Extra includes
+ s << endl << "// Extra includes" << endl;
+ QList<Include> includes = metaClass->typeEntry()->extraIncludes();
+ foreach (AbstractMetaEnum* cppEnum, classEnums)
+ includes.append(cppEnum->typeEntry()->extraIncludes());
+ qSort(includes.begin(), includes.end());
+ foreach (const Include &inc, includes)
+ s << inc.toString() << endl;
+ s << endl;
+
+ if (metaClass->typeEntry()->typeFlags() & ComplexTypeEntry::Deprecated)
+ s << "#Deprecated" << endl;
+
+ // Use class base namespace
+ {
+ const AbstractMetaClass *context = metaClass->enclosingClass();
+ while (context) {
+ if (context->isNamespace() && !context->enclosingClass()) {
+ s << "using namespace " << context->qualifiedCppName() << ";" << endl;
+ break;
+ }
+ context = context->enclosingClass();
+ }
+ }
+
+ s << endl;
+
+ // Create string literal for smart pointer getter method.
+ if (classContext.forSmartPointer()) {
+ const SmartPointerTypeEntry *typeEntry =
+ static_cast<const SmartPointerTypeEntry *>(classContext.preciseType()
+ ->typeEntry());
+ QString rawGetter = typeEntry->getter();
+ s << "static const char * " SMART_POINTER_GETTER " = \"" << rawGetter << "\";";
+ }
+
+ // class inject-code native/beginning
+ if (!metaClass->typeEntry()->codeSnips().isEmpty()) {
+ writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), TypeSystem::CodeSnipPositionBeginning, TypeSystem::NativeCode, metaClass);
+ s << endl;
+ }
+
+ // python conversion rules
+ if (metaClass->typeEntry()->hasTargetConversionRule()) {
+ s << "// Python Conversion" << endl;
+ s << metaClass->typeEntry()->conversionRule() << endl;
+ }
+
+ if (shouldGenerateCppWrapper(metaClass)) {
+ s << "// Native ---------------------------------------------------------" << endl;
+ s << endl;
+
+ if (avoidProtectedHack() && usePySideExtensions()) {
+ s << "void " << wrapperName(metaClass) << "::pysideInitQtMetaTypes()\n{\n";
+ Indentation indent(INDENT);
+ writeInitQtMetaTypeFunctionBody(s, classContext);
+ s << "}\n\n";
+ }
+
+ foreach (const AbstractMetaFunction* func, filterFunctions(metaClass)) {
+ if ((func->isPrivate() && !visibilityModifiedToPrivate(func))
+ || (func->isModifiedRemoved() && !func->isAbstract()))
+ continue;
+ if (func->functionType() == AbstractMetaFunction::ConstructorFunction && !func->isUserAdded())
+ writeConstructorNative(s, func);
+ else if ((!avoidProtectedHack() || !metaClass->hasPrivateDestructor())
+ && (func->isVirtual() || func->isAbstract()))
+ writeVirtualMethodNative(s, func);
+ }
+
+ if (!avoidProtectedHack() || !metaClass->hasPrivateDestructor()) {
+ if (usePySideExtensions() && metaClass->isQObject())
+ writeMetaObjectMethod(s, metaClass);
+ writeDestructorNative(s, metaClass);
+ }
+ }
+
+ Indentation indentation(INDENT);
+
+ QString methodsDefinitions;
+ QTextStream md(&methodsDefinitions);
+ QString singleMethodDefinitions;
+ QTextStream smd(&singleMethodDefinitions);
+
+ s << endl << "// Target ---------------------------------------------------------" << endl << endl;
+ s << "extern \"C\" {" << endl;
+ const FunctionGroupMap &functionGroups = getFunctionGroups(metaClass);
+ for (FunctionGroupMapIt it = functionGroups.cbegin(), end = functionGroups.cend(); it != end; ++it) {
+ AbstractMetaFunctionList overloads;
+ QSet<QString> seenSignatures;
+ foreach (AbstractMetaFunction* func, it.value()) {
+ if (!func->isAssignmentOperator()
+ && !func->usesRValueReferences()
+ && !func->isCastOperator()
+ && !func->isModifiedRemoved()
+ && (!func->isPrivate() || func->functionType() == AbstractMetaFunction::EmptyFunction)
+ && func->ownerClass() == func->implementingClass()
+ && (func->name() != QLatin1String("qt_metacall"))) {
+ // PYSIDE-331: Inheritance works correctly when there are disjoint functions.
+ // But when a function is both in a class and inherited in a subclass,
+ // then we need to search through all subclasses and collect the new signatures.
+ overloads << getFunctionAndInheritedOverloads(func, &seenSignatures);
+ }
+ }
+
+ if (overloads.isEmpty())
+ continue;
+
+ const AbstractMetaFunction* rfunc = overloads.first();
+ if (m_sequenceProtocol.contains(rfunc->name()) || m_mappingProtocol.contains(rfunc->name()))
+ continue;
+
+ if (rfunc->isConstructor()) {
+ // @TODO: Implement constructor support for smart pointers, so that they can be
+ // instantiated in python code.
+ if (classContext.forSmartPointer())
+ continue;
+ writeConstructorWrapper(s, overloads, classContext);
+ }
+ // call operators
+ else if (rfunc->name() == QLatin1String("operator()"))
+ writeMethodWrapper(s, overloads, classContext);
+ else if (!rfunc->isOperatorOverload()) {
+
+ if (classContext.forSmartPointer()) {
+ const SmartPointerTypeEntry *smartPointerTypeEntry =
+ static_cast<const SmartPointerTypeEntry *>(
+ classContext.preciseType()->typeEntry());
+
+ if (smartPointerTypeEntry->getter() == rfunc->name()) {
+ // Replace the return type of the raw pointer getter method with the actual
+ // return type.
+ QString innerTypeName =
+ classContext.preciseType()->getSmartPointerInnerType()->name();
+ QString pointerToInnerTypeName = innerTypeName + QLatin1Char('*');
+ // @TODO: This possibly leaks, but there are a bunch of other places where this
+ // is done, so this will be fixed in bulk with all the other cases, because the
+ // ownership of the pointers is not clear at the moment.
+ AbstractMetaType *pointerToInnerType =
+ buildAbstractMetaTypeFromString(pointerToInnerTypeName);
+
+ AbstractMetaFunction *mutableRfunc = overloads.first();
+ mutableRfunc->replaceType(pointerToInnerType);
+ } else if (smartPointerTypeEntry->refCountMethodName().isEmpty()
+ || smartPointerTypeEntry->refCountMethodName() != rfunc->name()) {
+ // Skip all public methods of the smart pointer except for the raw getter and
+ // the ref count method.
+ continue;
+ }
+ }
+
+ writeMethodWrapper(s, overloads, classContext);
+ if (OverloadData::hasStaticAndInstanceFunctions(overloads)) {
+ QString methDefName = cpythonMethodDefinitionName(rfunc);
+ smd << "static PyMethodDef " << methDefName << " = {" << endl;
+ smd << INDENT;
+ writeMethodDefinitionEntry(smd, overloads);
+ smd << endl << "};" << endl << endl;
+ }
+ writeMethodDefinition(md, overloads);
+ }
+ }
+
+ QString className = cpythonTypeName(metaClass);
+ className.remove(QRegExp(QLatin1String("_Type$")));
+
+ if (metaClass->typeEntry()->isValue() || metaClass->typeEntry()->isSmartPointer())
+ writeCopyFunction(s, classContext);
+
+ // Write single method definitions
+ s << singleMethodDefinitions;
+
+ // Write methods definition
+ s << "static PyMethodDef " << className << "_methods[] = {" << endl;
+ s << methodsDefinitions << endl;
+ if (metaClass->typeEntry()->isValue() || metaClass->typeEntry()->isSmartPointer())
+ s << INDENT << "{\"__copy__\", (PyCFunction)" << className << "___copy__" << ", METH_NOARGS}," << endl;
+ s << INDENT << "{0} // Sentinel" << endl;
+ s << "};" << endl << endl;
+
+ // Write tp_getattro function
+ if ((usePySideExtensions() && metaClass->qualifiedCppName() == QLatin1String("QObject"))) {
+ writeGetattroFunction(s, classContext);
+ s << endl;
+ writeSetattroFunction(s, classContext);
+ s << endl;
+ } else {
+ if (classNeedsGetattroFunction(metaClass)) {
+ writeGetattroFunction(s, classContext);
+ s << endl;
+ }
+ if (classNeedsSetattroFunction(metaClass)) {
+ writeSetattroFunction(s, classContext);
+ s << endl;
+ }
+ }
+
+ if (hasBoolCast(metaClass)) {
+ ErrorCode errorCode(-1);
+ s << "static int " << cpythonBaseName(metaClass) << "___nb_bool(PyObject* " PYTHON_SELF_VAR ")" << endl;
+ s << '{' << endl;
+ writeCppSelfDefinition(s, classContext);
+ s << INDENT << "int result;" << endl;
+ s << INDENT << BEGIN_ALLOW_THREADS << endl;
+ s << INDENT << "result = !" CPP_SELF_VAR "->isNull();" << endl;
+ s << INDENT << END_ALLOW_THREADS << endl;
+ s << INDENT << "return result;" << endl;
+ s << '}' << endl << endl;
+ }
+
+ if (supportsNumberProtocol(metaClass) && !metaClass->typeEntry()->isSmartPointer()) {
+ QList<AbstractMetaFunctionList> opOverloads = filterGroupedOperatorFunctions(
+ metaClass,
+ AbstractMetaClass::ArithmeticOp
+ | AbstractMetaClass::LogicalOp
+ | AbstractMetaClass::BitwiseOp);
+
+ foreach (const AbstractMetaFunctionList &allOverloads, opOverloads) {
+ AbstractMetaFunctionList overloads;
+ foreach (AbstractMetaFunction* func, allOverloads) {
+ if (!func->isModifiedRemoved()
+ && !func->isPrivate()
+ && (func->ownerClass() == func->implementingClass() || func->isAbstract()))
+ overloads.append(func);
+ }
+
+ if (overloads.isEmpty())
+ continue;
+
+ writeMethodWrapper(s, overloads, classContext);
+ }
+ }
+
+ if (supportsSequenceProtocol(metaClass)) {
+ writeSequenceMethods(s, metaClass, classContext);
+ }
+
+ if (supportsMappingProtocol(metaClass)) {
+ writeMappingMethods(s, metaClass, classContext);
+ }
+
+ if (metaClass->hasComparisonOperatorOverload()) {
+ s << "// Rich comparison" << endl;
+ writeRichCompareFunction(s, classContext);
+ }
+
+ if (shouldGenerateGetSetList(metaClass) && !classContext.forSmartPointer()) {
+ foreach (const AbstractMetaField* metaField, metaClass->fields()) {
+ if (metaField->isStatic())
+ continue;
+ writeGetterFunction(s, metaField, classContext);
+ if (!metaField->type()->isConstant())
+ writeSetterFunction(s, metaField, classContext);
+ s << endl;
+ }
+
+ s << "// Getters and Setters for " << metaClass->name() << endl;
+ s << "static PyGetSetDef " << cpythonGettersSettersDefinitionName(metaClass) << "[] = {" << endl;
+ foreach (const AbstractMetaField* metaField, metaClass->fields()) {
+ if (metaField->isStatic())
+ continue;
+
+ bool hasSetter = !metaField->type()->isConstant();
+ s << INDENT << "{const_cast<char*>(\"" << metaField->name() << "\"), ";
+ s << cpythonGetterFunctionName(metaField);
+ s << ", " << (hasSetter ? cpythonSetterFunctionName(metaField) : QLatin1String("0"));
+ s << "}," << endl;
+ }
+ s << INDENT << "{0} // Sentinel" << endl;
+ s << "};" << endl << endl;
+ }
+
+ s << "} // extern \"C\"" << endl << endl;
+
+ if (!metaClass->typeEntry()->hashFunction().isEmpty())
+ writeHashFunction(s, classContext);
+
+ // Write tp_traverse and tp_clear functions.
+ writeTpTraverseFunction(s, metaClass);
+ writeTpClearFunction(s, metaClass);
+
+ writeClassDefinition(s, metaClass, classContext);
+ s << endl;
+
+ if (metaClass->isPolymorphic() && metaClass->baseClass())
+ writeTypeDiscoveryFunction(s, metaClass);
+
+
+ foreach (AbstractMetaEnum* cppEnum, classEnums) {
+ if (cppEnum->isAnonymous() || cppEnum->isPrivate())
+ continue;
+
+ bool hasFlags = cppEnum->typeEntry()->flags();
+ if (hasFlags) {
+ writeFlagsMethods(s, cppEnum);
+ writeFlagsNumberMethodsDefinition(s, cppEnum);
+ s << endl;
+ }
+ }
+ s << endl;
+
+ writeConverterFunctions(s, metaClass, classContext);
+ writeClassRegister(s, metaClass, classContext);
+
+ // class inject-code native/end
+ if (!metaClass->typeEntry()->codeSnips().isEmpty()) {
+ writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), TypeSystem::CodeSnipPositionEnd, TypeSystem::NativeCode, metaClass);
+ s << endl;
+ }
+}
+
+void CppGenerator::writeConstructorNative(QTextStream& s, const AbstractMetaFunction* func)
+{
+ Indentation indentation(INDENT);
+ s << functionSignature(func, wrapperName(func->ownerClass()) + QLatin1String("::"), QString(),
+ OriginalTypeDescription | SkipDefaultValues);
+ s << " : ";
+ writeFunctionCall(s, func);
+ s << " {" << endl;
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, func->injectedCodeSnips(), TypeSystem::CodeSnipPositionBeginning, TypeSystem::NativeCode, func, lastArg);
+ s << INDENT << "// ... middle" << endl;
+ writeCodeSnips(s, func->injectedCodeSnips(), TypeSystem::CodeSnipPositionEnd, TypeSystem::NativeCode, func, lastArg);
+ s << '}' << endl << endl;
+}
+
+void CppGenerator::writeDestructorNative(QTextStream &s, const AbstractMetaClass *metaClass)
+{
+ Indentation indentation(INDENT);
+ s << wrapperName(metaClass) << "::~" << wrapperName(metaClass) << "()" << endl << '{' << endl;
+ // kill pyobject
+ s << INDENT << "SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl;
+ s << INDENT << "Shiboken::Object::destroy(wrapper, this);" << endl;
+ s << '}' << endl;
+}
+
+static bool allArgumentsRemoved(const AbstractMetaFunction* func)
+{
+ if (func->arguments().isEmpty())
+ return false;
+ foreach (const AbstractMetaArgument* arg, func->arguments()) {
+ if (!func->argumentRemoved(arg->argumentIndex() + 1))
+ return false;
+ }
+ return true;
+}
+
+QString CppGenerator::getVirtualFunctionReturnTypeName(const AbstractMetaFunction* func)
+{
+ if (!func->type())
+ return QLatin1String("\"\"");
+
+ if (!func->typeReplaced(0).isEmpty())
+ return QLatin1Char('"') + func->typeReplaced(0) + QLatin1Char('"');
+
+ // SbkType would return null when the type is a container.
+ if (func->type()->typeEntry()->isContainer()) {
+ return QLatin1Char('"')
+ + reinterpret_cast<const ContainerTypeEntry*>(func->type()->typeEntry())->typeName()
+ + QLatin1Char('"');
+ }
+
+ if (avoidProtectedHack()) {
+ const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(func->type());
+ if (metaEnum && metaEnum->isProtected())
+ return QLatin1Char('"') + protectedEnumSurrogateName(metaEnum) + QLatin1Char('"');
+ }
+
+ if (func->type()->isPrimitive())
+ return QLatin1Char('"') + func->type()->name() + QLatin1Char('"');
+
+ return QString::fromLatin1("Shiboken::SbkType< %1 >()->tp_name").arg(func->type()->typeEntry()->qualifiedCppName());
+}
+
+void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFunction* func)
+{
+ //skip metaObject function, this will be written manually ahead
+ if (usePySideExtensions() && func->ownerClass() && func->ownerClass()->isQObject() &&
+ ((func->name() == QLatin1String("metaObject")) || (func->name() == QLatin1String("qt_metacall"))))
+ return;
+
+ const TypeEntry* retType = func->type() ? func->type()->typeEntry() : 0;
+ const QString funcName = func->isOperatorOverload() ? pythonOperatorFunctionName(func) : func->name();
+
+ QString prefix = wrapperName(func->ownerClass()) + QLatin1String("::");
+ s << functionSignature(func, prefix, QString(), Generator::SkipDefaultValues|Generator::OriginalTypeDescription)
+ << endl << '{' << endl;
+
+ Indentation indentation(INDENT);
+
+ QString defaultReturnExpr;
+ if (retType) {
+ foreach (const FunctionModification &mod, func->modifications()) {
+ foreach (const ArgumentModification &argMod, mod.argument_mods) {
+ if (argMod.index == 0 && !argMod.replacedDefaultExpression.isEmpty()) {
+ QRegExp regex(QLatin1String("%(\\d+)"));
+ defaultReturnExpr = argMod.replacedDefaultExpression;
+ int offset = 0;
+ while ((offset = regex.indexIn(defaultReturnExpr, offset)) != -1) {
+ int argId = regex.cap(1).toInt() - 1;
+ if (argId < 0 || argId > func->arguments().count()) {
+ qCWarning(lcShiboken) << "The expression used in return value contains an invalid index.";
+ break;
+ }
+ defaultReturnExpr.replace(regex.cap(0), func->arguments()[argId]->name());
+ }
+ }
+ }
+ }
+ if (defaultReturnExpr.isEmpty())
+ defaultReturnExpr = minimalConstructor(func->type());
+ if (defaultReturnExpr.isEmpty()) {
+ QString errorMsg = QLatin1String(__FUNCTION__) + QLatin1String(": ");
+ if (const AbstractMetaClass *c = func->implementingClass())
+ errorMsg += c->qualifiedCppName() + QLatin1String("::");
+ errorMsg += func->signature();
+ errorMsg = ShibokenGenerator::msgCouldNotFindMinimalConstructor(errorMsg, func->type()->cppSignature());
+ qCWarning(lcShiboken).noquote().nospace() << errorMsg;
+ s << endl << INDENT << "#error " << errorMsg << endl;
+ }
+ }
+
+ if (func->isAbstract() && func->isModifiedRemoved()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QString::fromLatin1("Pure virtual method '%1::%2' must be implement but was "\
+ "completely removed on type system.")
+ .arg(func->ownerClass()->name(), func->minimalSignature());
+ s << INDENT << "return " << defaultReturnExpr << ';' << endl;
+ s << '}' << endl << endl;
+ return;
+ }
+
+ //Write declaration/native injected code
+ if (func->hasInjectedCode()) {
+ CodeSnipList snips = func->injectedCodeSnips();
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionDeclaration, TypeSystem::NativeCode, func, lastArg);
+ s << endl;
+ }
+
+ s << INDENT << "Shiboken::GilState gil;" << endl;
+
+ // Get out of virtual method call if someone already threw an error.
+ s << INDENT << "if (PyErr_Occurred())" << endl;
+ {
+ Indentation indentation(INDENT);
+ s << INDENT << "return " << defaultReturnExpr << ';' << endl;
+ }
+
+ s << INDENT << "Shiboken::AutoDecRef " PYTHON_OVERRIDE_VAR "(Shiboken::BindingManager::instance().getOverride(this, \"";
+ s << funcName << "\"));" << endl;
+
+ s << INDENT << "if (" PYTHON_OVERRIDE_VAR ".isNull()) {" << endl;
+ {
+ Indentation indentation(INDENT);
+ CodeSnipList snips;
+ if (func->hasInjectedCode()) {
+ snips = func->injectedCodeSnips();
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::ShellCode, func, lastArg);
+ s << endl;
+ }
+
+ if (func->isAbstract()) {
+ s << INDENT << "PyErr_SetString(PyExc_NotImplementedError, \"pure virtual method '";
+ s << func->ownerClass()->name() << '.' << funcName;
+ s << "()' not implemented.\");" << endl;
+ s << INDENT << "return " << (retType ? defaultReturnExpr : QString());
+ } else {
+ s << INDENT << "gil.release();" << endl;
+ s << INDENT;
+ if (retType)
+ s << "return ";
+ s << "this->::" << func->implementingClass()->qualifiedCppName() << "::";
+ writeFunctionCall(s, func, Generator::VirtualCall);
+ if (!retType)
+ s << ";\n" << INDENT << "return";
+ }
+ }
+ s << ';' << endl;
+ s << INDENT << '}' << endl << endl;
+
+ writeConversionRule(s, func, TypeSystem::TargetLangCode);
+
+ s << INDENT << "Shiboken::AutoDecRef " PYTHON_ARGS "(";
+
+ if (func->arguments().isEmpty() || allArgumentsRemoved(func)) {
+ s << "PyTuple_New(0));" << endl;
+ } else {
+ QStringList argConversions;
+ foreach (const AbstractMetaArgument* arg, func->arguments()) {
+ if (func->argumentRemoved(arg->argumentIndex() + 1))
+ continue;
+
+ QString argConv;
+ QTextStream ac(&argConv);
+ const PrimitiveTypeEntry* argType = (const PrimitiveTypeEntry*) arg->type()->typeEntry();
+ bool convert = argType->isObject()
+ || arg->type()->isQObject()
+ || argType->isValue()
+ || arg->type()->isValuePointer()
+ || arg->type()->isNativePointer()
+ || argType->isFlags()
+ || argType->isEnum()
+ || argType->isContainer()
+ || arg->type()->referenceType() == LValueReference;
+
+ if (!convert && argType->isPrimitive()) {
+ if (argType->basicReferencedTypeEntry())
+ argType = argType->basicReferencedTypeEntry();
+ convert = !m_formatUnits.contains(argType->name());
+ }
+
+ Indentation indentation(INDENT);
+ ac << INDENT;
+ if (!func->conversionRule(TypeSystem::TargetLangCode, arg->argumentIndex() + 1).isEmpty()) {
+ // Has conversion rule.
+ ac << arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
+ } else {
+ QString argName = arg->name();
+ if (convert)
+ writeToPythonConversion(ac, arg->type(), func->ownerClass(), argName);
+ else
+ ac << argName;
+ }
+
+ argConversions << argConv;
+ }
+
+ s << "Py_BuildValue(\"(" << getFormatUnitString(func, false) << ")\"," << endl;
+ s << argConversions.join(QLatin1String(",\n")) << endl;
+ s << INDENT << "));" << endl;
+ }
+
+ bool invalidateReturn = false;
+ QSet<int> invalidateArgs;
+ foreach (const FunctionModification &funcMod, func->modifications()) {
+ foreach (const ArgumentModification &argMod, funcMod.argument_mods) {
+ if (argMod.resetAfterUse && !invalidateArgs.contains(argMod.index)) {
+ invalidateArgs.insert(argMod.index);
+ s << INDENT << "bool invalidateArg" << argMod.index;
+ s << " = PyTuple_GET_ITEM(" PYTHON_ARGS ", " << argMod.index - 1 << ")->ob_refcnt == 1;" << endl;
+ } else if (argMod.index == 0 && argMod.ownerships[TypeSystem::TargetLangCode] == TypeSystem::CppOwnership) {
+ invalidateReturn = true;
+ }
+ }
+ }
+ s << endl;
+
+ CodeSnipList snips;
+ if (func->hasInjectedCode()) {
+ snips = func->injectedCodeSnips();
+
+ if (injectedCodeUsesPySelf(func))
+ s << INDENT << "PyObject* pySelf = BindingManager::instance().retrieveWrapper(this);" << endl;
+
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::NativeCode, func, lastArg);
+ s << endl;
+ }
+
+ if (!injectedCodeCallsPythonOverride(func)) {
+ s << INDENT;
+ s << "Shiboken::AutoDecRef " PYTHON_RETURN_VAR "(PyObject_Call(" PYTHON_OVERRIDE_VAR ", " PYTHON_ARGS ", NULL));" << endl;
+
+ s << INDENT << "// An error happened in python code!" << endl;
+ s << INDENT << "if (" PYTHON_RETURN_VAR ".isNull()) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyErr_Print();" << endl;
+ s << INDENT << "return " << defaultReturnExpr << ';' << endl;
+ }
+ s << INDENT << '}' << endl;
+
+ if (retType) {
+ if (invalidateReturn)
+ s << INDENT << "bool invalidateArg0 = " PYTHON_RETURN_VAR "->ob_refcnt == 1;" << endl;
+
+ if (func->typeReplaced(0) != QLatin1String("PyObject")) {
+
+ s << INDENT << "// Check return type" << endl;
+ s << INDENT;
+ if (func->typeReplaced(0).isEmpty()) {
+ s << "PythonToCppFunc " PYTHON_TO_CPP_VAR " = " << cpythonIsConvertibleFunction(func->type());
+ s << PYTHON_RETURN_VAR ");" << endl;
+ s << INDENT << "if (!" PYTHON_TO_CPP_VAR ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "Shiboken::warning(PyExc_RuntimeWarning, 2, "\
+ "\"Invalid return value in function %s, expected %s, got %s.\", \"";
+ s << func->ownerClass()->name() << '.' << funcName << "\", " << getVirtualFunctionReturnTypeName(func);
+ s << ", " PYTHON_RETURN_VAR "->ob_type->tp_name);" << endl;
+ s << INDENT << "return " << defaultReturnExpr << ';' << endl;
+ }
+ s << INDENT << '}' << endl;
+
+ } else {
+
+ s << INDENT << "// Check return type" << endl;
+ s << INDENT << "bool typeIsValid = ";
+ writeTypeCheck(s, func->type(), QLatin1String(PYTHON_RETURN_VAR),
+ isNumber(func->type()->typeEntry()), func->typeReplaced(0));
+ s << ';' << endl;
+ s << INDENT << "if (!typeIsValid";
+ s << (isPointerToWrapperType(func->type()) ? " && " PYTHON_RETURN_VAR " != Py_None" : "");
+ s << ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "Shiboken::warning(PyExc_RuntimeWarning, 2, "\
+ "\"Invalid return value in function %s, expected %s, got %s.\", \"";
+ s << func->ownerClass()->name() << '.' << funcName << "\", " << getVirtualFunctionReturnTypeName(func);
+ s << ", " PYTHON_RETURN_VAR "->ob_type->tp_name);" << endl;
+ s << INDENT << "return " << defaultReturnExpr << ';' << endl;
+ }
+ s << INDENT << '}' << endl;
+
+ }
+ }
+
+ if (!func->conversionRule(TypeSystem::NativeCode, 0).isEmpty()) {
+ // Has conversion rule.
+ writeConversionRule(s, func, TypeSystem::NativeCode, QLatin1String(CPP_RETURN_VAR));
+ } else if (!injectedCodeHasReturnValueAttribution(func, TypeSystem::NativeCode)) {
+ writePythonToCppTypeConversion(s, func->type(), QLatin1String(PYTHON_RETURN_VAR),
+ QLatin1String(CPP_RETURN_VAR), func->implementingClass());
+ }
+ }
+ }
+
+ if (invalidateReturn) {
+ s << INDENT << "if (invalidateArg0)" << endl;
+ Indentation indentation(INDENT);
+ s << INDENT << "Shiboken::Object::releaseOwnership(" << PYTHON_RETURN_VAR ".object());" << endl;
+ }
+ foreach (int argIndex, invalidateArgs) {
+ s << INDENT << "if (invalidateArg" << argIndex << ')' << endl;
+ Indentation indentation(INDENT);
+ s << INDENT << "Shiboken::Object::invalidate(PyTuple_GET_ITEM(" PYTHON_ARGS ", ";
+ s << (argIndex - 1) << "));" << endl;
+ }
+
+
+ foreach (const FunctionModification &funcMod, func->modifications()) {
+ foreach (const ArgumentModification &argMod, funcMod.argument_mods) {
+ if (argMod.ownerships.contains(TypeSystem::NativeCode)
+ && argMod.index == 0 && argMod.ownerships[TypeSystem::NativeCode] == TypeSystem::CppOwnership) {
+ s << INDENT << "if (Shiboken::Object::checkType(" PYTHON_RETURN_VAR "))" << endl;
+ Indentation indent(INDENT);
+ s << INDENT << "Shiboken::Object::releaseOwnership(" PYTHON_RETURN_VAR ");" << endl;
+ }
+ }
+ }
+
+ if (func->hasInjectedCode()) {
+ s << endl;
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionEnd, TypeSystem::NativeCode, func, lastArg);
+ }
+
+ if (retType) {
+ s << INDENT << "return ";
+ if (avoidProtectedHack() && retType->isEnum()) {
+ const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(retType);
+ bool isProtectedEnum = metaEnum && metaEnum->isProtected();
+ if (isProtectedEnum) {
+ QString typeCast;
+ if (metaEnum->enclosingClass())
+ typeCast += QLatin1String("::") + metaEnum->enclosingClass()->qualifiedCppName();
+ typeCast += QLatin1String("::") + metaEnum->name();
+ s << '(' << typeCast << ')';
+ }
+ }
+ if (func->type()->referenceType() == LValueReference && !isPointer(func->type()))
+ s << '*';
+ s << CPP_RETURN_VAR ";" << endl;
+ }
+
+ s << '}' << endl << endl;
+}
+
+void CppGenerator::writeMetaObjectMethod(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ Indentation indentation(INDENT);
+ QString wrapperClassName = wrapperName(metaClass);
+ s << "const QMetaObject* " << wrapperClassName << "::metaObject() const" << endl;
+ s << '{' << endl;
+ s << INDENT << "if (QObject::d_ptr->metaObject)" << endl
+ << INDENT << INDENT << "return QObject::d_ptr->dynamicMetaObject();" << endl;
+ s << INDENT << "SbkObject* pySelf = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl;
+ s << INDENT << "if (pySelf == NULL)" << endl;
+ s << INDENT << INDENT << "return " << metaClass->qualifiedCppName() << "::metaObject();" << endl;
+ s << INDENT << "return PySide::SignalManager::retriveMetaObject(reinterpret_cast<PyObject*>(pySelf));" << endl;
+ s << '}' << endl << endl;
+
+ // qt_metacall function
+ s << "int " << wrapperClassName << "::qt_metacall(QMetaObject::Call call, int id, void** args)" << endl;
+ s << "{" << endl;
+
+ AbstractMetaFunction *func = NULL;
+ AbstractMetaFunctionList list = metaClass->queryFunctionsByName(QLatin1String("qt_metacall"));
+ if (list.size() == 1)
+ func = list[0];
+
+ CodeSnipList snips;
+ if (func) {
+ snips = func->injectedCodeSnips();
+ if (func->isUserAdded()) {
+ CodeSnipList snips = func->injectedCodeSnips();
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionAny, TypeSystem::NativeCode, func);
+ }
+ }
+
+ s << INDENT << "int result = " << metaClass->qualifiedCppName() << "::qt_metacall(call, id, args);" << endl;
+ s << INDENT << "return result < 0 ? result : PySide::SignalManager::qt_metacall(this, call, id, args);" << endl;
+ s << "}" << endl << endl;
+
+ // qt_metacast function
+ writeMetaCast(s, metaClass);
+}
+
+void CppGenerator::writeMetaCast(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ Indentation indentation(INDENT);
+ QString wrapperClassName = wrapperName(metaClass);
+ s << "void* " << wrapperClassName << "::qt_metacast(const char* _clname)" << endl;
+ s << '{' << endl;
+ s << INDENT << "if (!_clname) return 0;" << endl;
+ s << INDENT << "SbkObject* pySelf = Shiboken::BindingManager::instance().retrieveWrapper(this);" << endl;
+ s << INDENT << "if (pySelf && PySide::inherits(Py_TYPE(pySelf), _clname))" << endl;
+ s << INDENT << INDENT << "return static_cast<void*>(const_cast< " << wrapperClassName << "* >(this));" << endl;
+ s << INDENT << "return " << metaClass->qualifiedCppName() << "::qt_metacast(_clname);" << endl;
+ s << "}" << endl << endl;
+}
+
+void CppGenerator::writeEnumConverterFunctions(QTextStream& s, const AbstractMetaEnum* metaEnum)
+{
+ if (metaEnum->isPrivate() || metaEnum->isAnonymous())
+ return;
+ writeEnumConverterFunctions(s, metaEnum->typeEntry());
+}
+
+void CppGenerator::writeEnumConverterFunctions(QTextStream& s, const TypeEntry* enumType)
+{
+ if (!enumType)
+ return;
+ QString enumFlagName = enumType->isFlags() ? QLatin1String("flag") : QLatin1String("enum");
+ QString typeName = fixedCppTypeName(enumType);
+ QString enumPythonType = cpythonTypeNameExt(enumType);
+ QString cppTypeName = getFullTypeName(enumType).trimmed();
+ if (avoidProtectedHack()) {
+ const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(enumType);
+ if (metaEnum && metaEnum->isProtected())
+ cppTypeName = protectedEnumSurrogateName(metaEnum);
+ }
+ QString code;
+ QTextStream c(&code);
+ c << INDENT << "*((" << cppTypeName << "*)cppOut) = ";
+ if (enumType->isFlags())
+ c << cppTypeName << "(QFlag((int)PySide::QFlags::getValue(reinterpret_cast<PySideQFlagsObject*>(pyIn))))";
+ else
+ c << "(" << cppTypeName << ") Shiboken::Enum::getValue(pyIn)";
+ c << ';' << endl;
+ writePythonToCppFunction(s, code, typeName, typeName);
+
+ QString pyTypeCheck = QStringLiteral("PyObject_TypeCheck(pyIn, %1)").arg(enumPythonType);
+ writeIsPythonConvertibleToCppFunction(s, typeName, typeName, pyTypeCheck);
+
+ code.clear();
+
+ c << INDENT << "int castCppIn = *((" << cppTypeName << "*)cppIn);" << endl;
+ c << INDENT;
+ c << "return ";
+ if (enumType->isFlags())
+ c << "reinterpret_cast<PyObject*>(PySide::QFlags::newObject(castCppIn, " << enumPythonType << "))";
+
+ else
+ c << "Shiboken::Enum::newItem(" << enumPythonType << ", castCppIn)";
+ c << ';' << endl;
+ writeCppToPythonFunction(s, code, typeName, typeName);
+ s << endl;
+
+ if (enumType->isFlags())
+ return;
+
+ const FlagsTypeEntry* flags = reinterpret_cast<const EnumTypeEntry*>(enumType)->flags();
+ if (!flags)
+ return;
+
+ // QFlags part.
+
+ writeEnumConverterFunctions(s, flags);
+
+ code.clear();
+ cppTypeName = getFullTypeName(flags).trimmed();
+ c << INDENT << "*((" << cppTypeName << "*)cppOut) = " << cppTypeName;
+ c << "(QFlag((int)Shiboken::Enum::getValue(pyIn)));" << endl;
+
+ QString flagsTypeName = fixedCppTypeName(flags);
+ writePythonToCppFunction(s, code, typeName, flagsTypeName);
+ writeIsPythonConvertibleToCppFunction(s, typeName, flagsTypeName, pyTypeCheck);
+
+ code.clear();
+ c << INDENT << "Shiboken::AutoDecRef pyLong(PyNumber_Long(pyIn));" << endl;
+ c << INDENT << "*((" << cppTypeName << "*)cppOut) = " << cppTypeName;
+ c << "(QFlag((int)PyLong_AsLong(pyLong.object())));" << endl;
+ writePythonToCppFunction(s, code, QLatin1String("number"), flagsTypeName);
+ writeIsPythonConvertibleToCppFunction(s, QLatin1String("number"), flagsTypeName,
+ QLatin1String("PyNumber_Check(pyIn)"));
+}
+
+void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaClass *metaClass,
+ GeneratorContext &classContext)
+{
+ s << "// Type conversion functions." << endl << endl;
+
+ AbstractMetaEnumList classEnums = metaClass->enums();
+ foreach (AbstractMetaClass* innerClass, metaClass->innerClasses())
+ lookForEnumsInClassesNotToBeGenerated(classEnums, innerClass);
+ if (!classEnums.isEmpty())
+ s << "// Python to C++ enum conversion." << endl;
+ foreach (const AbstractMetaEnum* metaEnum, classEnums)
+ writeEnumConverterFunctions(s, metaEnum);
+
+ if (metaClass->isNamespace())
+ return;
+
+ QString typeName;
+ if (!classContext.forSmartPointer())
+ typeName = getFullTypeName(metaClass);
+ else
+ typeName = getFullTypeName(classContext.preciseType());
+
+ QString cpythonType = cpythonTypeName(metaClass);
+
+ // Returns the C++ pointer of the Python wrapper.
+ s << "// Python to C++ pointer conversion - returns the C++ object of the Python wrapper (keeps object identity)." << endl;
+
+ QString sourceTypeName = metaClass->name();
+ QString targetTypeName = metaClass->name() + QLatin1String("_PTR");
+ QString code;
+ QTextStream c(&code);
+ c << INDENT << "Shiboken::Conversions::pythonToCppPointer(&" << cpythonType << ", pyIn, cppOut);";
+ writePythonToCppFunction(s, code, sourceTypeName, targetTypeName);
+
+ // "Is convertible" function for the Python object to C++ pointer conversion.
+ QString pyTypeCheck = QStringLiteral("PyObject_TypeCheck(pyIn, (PyTypeObject*)&%1)").arg(cpythonType);
+ writeIsPythonConvertibleToCppFunction(s, sourceTypeName, targetTypeName, pyTypeCheck, QString(), true);
+ s << endl;
+
+ // C++ pointer to a Python wrapper, keeping identity.
+ s << "// C++ to Python pointer conversion - tries to find the Python wrapper for the C++ object (keeps object identity)." << endl;
+ code.clear();
+ if (usePySideExtensions() && metaClass->isQObject())
+ {
+ c << INDENT << "return PySide::getWrapperForQObject((" << typeName << "*)cppIn, &" << cpythonType << ");" << endl;
+ } else {
+ c << INDENT << "PyObject* pyOut = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(cppIn);" << endl;
+ c << INDENT << "if (pyOut) {" << endl;
+ {
+ Indentation indent(INDENT);
+ c << INDENT << "Py_INCREF(pyOut);" << endl;
+ c << INDENT << "return pyOut;" << endl;
+ }
+ c << INDENT << '}' << endl;
+ c << INDENT << "const char* typeName = typeid(*((" << typeName << "*)cppIn)).name();" << endl;
+ c << INDENT << "return Shiboken::Object::newObject(&" << cpythonType;
+ c << ", const_cast<void*>(cppIn), false, false, typeName);";
+ }
+ std::swap(targetTypeName, sourceTypeName);
+ writeCppToPythonFunction(s, code, sourceTypeName, targetTypeName);
+
+ // The conversions for an Object Type end here.
+ if (!metaClass->typeEntry()->isValue() && !metaClass->typeEntry()->isSmartPointer()) {
+ s << endl;
+ return;
+ }
+
+ // Always copies C++ value (not pointer, and not reference) to a new Python wrapper.
+ s << endl << "// C++ to Python copy conversion." << endl;
+ if (!classContext.forSmartPointer())
+ targetTypeName = metaClass->name();
+ else
+ targetTypeName = classContext.preciseType()->name();
+
+ sourceTypeName = targetTypeName + QLatin1String("_COPY");
+
+ code.clear();
+
+ QString computedWrapperName;
+ if (!classContext.forSmartPointer())
+ computedWrapperName = wrapperName(metaClass);
+ else
+ computedWrapperName = wrapperName(classContext.preciseType());
+
+ c << INDENT << "return Shiboken::Object::newObject(&" << cpythonType << ", new ::" << computedWrapperName;
+ c << "(*((" << typeName << "*)cppIn)), true, true);";
+ writeCppToPythonFunction(s, code, sourceTypeName, targetTypeName);
+ s << endl;
+
+ // Python to C++ copy conversion.
+ s << "// Python to C++ copy conversion." << endl;
+ if (!classContext.forSmartPointer())
+ sourceTypeName = metaClass->name();
+ else
+ sourceTypeName = classContext.preciseType()->name();
+
+ targetTypeName = QStringLiteral("%1_COPY").arg(sourceTypeName);
+ code.clear();
+
+ QString pyInVariable = QLatin1String("pyIn");
+ QString wrappedCPtrExpression;
+ if (!classContext.forSmartPointer())
+ wrappedCPtrExpression = cpythonWrapperCPtr(metaClass->typeEntry(), pyInVariable);
+ else
+ wrappedCPtrExpression = cpythonWrapperCPtr(classContext.preciseType(), pyInVariable);
+
+ c << INDENT << "*((" << typeName << "*)cppOut) = *"
+ << wrappedCPtrExpression << ';';
+ writePythonToCppFunction(s, code, sourceTypeName, targetTypeName);
+
+ // "Is convertible" function for the Python object to C++ value copy conversion.
+ writeIsPythonConvertibleToCppFunction(s, sourceTypeName, targetTypeName, pyTypeCheck);
+ s << endl;
+
+ // User provided implicit conversions.
+ CustomConversion* customConversion = metaClass->typeEntry()->customConversion();
+
+ // Implicit conversions.
+ AbstractMetaFunctionList implicitConvs;
+ if (!customConversion || !customConversion->replaceOriginalTargetToNativeConversions()) {
+ foreach (AbstractMetaFunction* func, implicitConversions(metaClass->typeEntry())) {
+ if (!func->isUserAdded())
+ implicitConvs << func;
+ }
+ }
+
+ if (!implicitConvs.isEmpty())
+ s << "// Implicit conversions." << endl;
+
+ AbstractMetaType* targetType = buildAbstractMetaTypeFromAbstractMetaClass(metaClass);
+ foreach (const AbstractMetaFunction* conv, implicitConvs) {
+ if (conv->isModifiedRemoved())
+ continue;
+
+ QString typeCheck;
+ QString toCppConv;
+ QString toCppPreConv;
+ if (conv->isConversionOperator()) {
+ const AbstractMetaClass* sourceClass = conv->ownerClass();
+ typeCheck = QStringLiteral("PyObject_TypeCheck(pyIn, %1)").arg(cpythonTypeNameExt(sourceClass->typeEntry()));
+ toCppConv = QLatin1Char('*') + cpythonWrapperCPtr(sourceClass->typeEntry(), QLatin1String("pyIn"));
+ } else {
+ // Constructor that does implicit conversion.
+ if (!conv->typeReplaced(1).isEmpty())
+ continue;
+ const AbstractMetaType* sourceType = conv->arguments().first()->type();
+ typeCheck = cpythonCheckFunction(sourceType);
+ bool isUserPrimitiveWithoutTargetLangName = isUserPrimitive(sourceType)
+ && sourceType->typeEntry()->targetLangApiName() == sourceType->typeEntry()->name();
+ if (!isWrapperType(sourceType)
+ && !isUserPrimitiveWithoutTargetLangName
+ && !sourceType->typeEntry()->isEnum()
+ && !sourceType->typeEntry()->isFlags()
+ && !sourceType->typeEntry()->isContainer()) {
+ typeCheck += QLatin1Char('(');
+ }
+ if (isWrapperType(sourceType)) {
+ typeCheck += QLatin1String("pyIn)");
+ toCppConv = (sourceType->referenceType() == LValueReference || !isPointerToWrapperType(sourceType))
+ ? QLatin1String("*") : QString();
+ toCppConv += cpythonWrapperCPtr(sourceType->typeEntry(), QLatin1String("pyIn"));
+ } else if (typeCheck.contains(QLatin1String("%in"))) {
+ typeCheck.replace(QLatin1String("%in"), QLatin1String("pyIn"));
+ typeCheck.append(QLatin1Char(')'));
+ } else {
+ typeCheck += QLatin1String("pyIn)");
+ }
+
+ if (isUserPrimitive(sourceType)
+ || isCppPrimitive(sourceType)
+ || sourceType->typeEntry()->isContainer()
+ || sourceType->typeEntry()->isEnum()
+ || sourceType->typeEntry()->isFlags()) {
+ QTextStream pc(&toCppPreConv);
+ pc << INDENT << getFullTypeNameWithoutModifiers(sourceType) << " cppIn";
+ writeMinimalConstructorExpression(pc, sourceType);
+ pc << ';' << endl;
+ writeToCppConversion(pc, sourceType, 0, QLatin1String("pyIn"), QLatin1String("cppIn"));
+ pc << ';';
+ toCppConv.append(QLatin1String("cppIn"));
+ } else if (!isWrapperType(sourceType)) {
+ QTextStream tcc(&toCppConv);
+ writeToCppConversion(tcc, sourceType, metaClass, QLatin1String("pyIn"), QLatin1String("/*BOZO-1061*/"));
+ }
+
+
+ }
+ const AbstractMetaType* sourceType = conv->isConversionOperator()
+ ? buildAbstractMetaTypeFromAbstractMetaClass(conv->ownerClass())
+ : conv->arguments().first()->type();
+ writePythonToCppConversionFunctions(s, sourceType, targetType, typeCheck, toCppConv, toCppPreConv);
+ }
+
+ writeCustomConverterFunctions(s, customConversion);
+}
+
+void CppGenerator::writeCustomConverterFunctions(QTextStream& s, const CustomConversion* customConversion)
+{
+ if (!customConversion)
+ return;
+ const CustomConversion::TargetToNativeConversions& toCppConversions = customConversion->targetToNativeConversions();
+ if (toCppConversions.isEmpty())
+ return;
+ s << "// Python to C++ conversions for type '" << customConversion->ownerType()->qualifiedCppName() << "'." << endl;
+ foreach (CustomConversion::TargetToNativeConversion* toNative, toCppConversions)
+ writePythonToCppConversionFunctions(s, toNative, customConversion->ownerType());
+ s << endl;
+}
+
+void CppGenerator::writeConverterRegister(QTextStream &s, const AbstractMetaClass *metaClass,
+ GeneratorContext &classContext)
+{
+ if (metaClass->isNamespace())
+ return;
+ s << INDENT << "// Register Converter" << endl;
+ s << INDENT << "SbkConverter* converter = Shiboken::Conversions::createConverter(&";
+ s << cpythonTypeName(metaClass) << ',' << endl;
+ {
+ Indentation indent(INDENT);
+ QString sourceTypeName = metaClass->name();
+ QString targetTypeName = sourceTypeName + QLatin1String("_PTR");
+ s << INDENT << pythonToCppFunctionName(sourceTypeName, targetTypeName) << ',' << endl;
+ s << INDENT << convertibleToCppFunctionName(sourceTypeName, targetTypeName) << ',' << endl;
+ std::swap(targetTypeName, sourceTypeName);
+ s << INDENT << cppToPythonFunctionName(sourceTypeName, targetTypeName);
+ if (metaClass->typeEntry()->isValue() || metaClass->typeEntry()->isSmartPointer()) {
+ s << ',' << endl;
+ sourceTypeName = metaClass->name() + QLatin1String("_COPY");
+ s << INDENT << cppToPythonFunctionName(sourceTypeName, targetTypeName);
+ }
+ }
+ s << ");" << endl;
+
+ s << endl;
+
+ QStringList cppSignature;
+ if (!classContext.forSmartPointer()) {
+ cppSignature = metaClass->qualifiedCppName().split(QLatin1String("::"),
+ QString::SkipEmptyParts);
+ } else {
+ cppSignature = classContext.preciseType()->cppSignature().split(QLatin1String("::"),
+ QString::SkipEmptyParts);
+ }
+ while (!cppSignature.isEmpty()) {
+ QString signature = cppSignature.join(QLatin1String("::"));
+ s << INDENT << "Shiboken::Conversions::registerConverterName(converter, \"" << signature << "\");" << endl;
+ s << INDENT << "Shiboken::Conversions::registerConverterName(converter, \"" << signature << "*\");" << endl;
+ s << INDENT << "Shiboken::Conversions::registerConverterName(converter, \"" << signature << "&\");" << endl;
+ cppSignature.removeFirst();
+ }
+
+ s << INDENT << "Shiboken::Conversions::registerConverterName(converter, typeid(::";
+ QString qualifiedCppNameInvocation;
+ if (!classContext.forSmartPointer())
+ qualifiedCppNameInvocation = metaClass->qualifiedCppName();
+ else
+ qualifiedCppNameInvocation = classContext.preciseType()->cppSignature();
+
+ s << qualifiedCppNameInvocation << ").name());" << endl;
+
+ if (shouldGenerateCppWrapper(metaClass)) {
+ s << INDENT << "Shiboken::Conversions::registerConverterName(converter, typeid(::";
+ s << wrapperName(metaClass) << ").name());" << endl;
+ }
+
+ s << endl;
+
+ if (!metaClass->typeEntry()->isValue() && !metaClass->typeEntry()->isSmartPointer())
+ return;
+
+ // Python to C++ copy (value, not pointer neither reference) conversion.
+ s << INDENT << "// Add Python to C++ copy (value, not pointer neither reference) conversion to type converter." << endl;
+ QString sourceTypeName = metaClass->name();
+ QString targetTypeName = sourceTypeName + QLatin1String("_COPY");
+ QString toCpp = pythonToCppFunctionName(sourceTypeName, targetTypeName);
+ QString isConv = convertibleToCppFunctionName(sourceTypeName, targetTypeName);
+ writeAddPythonToCppConversion(s, QLatin1String("converter"), toCpp, isConv);
+
+ // User provided implicit conversions.
+ CustomConversion* customConversion = metaClass->typeEntry()->customConversion();
+
+ // Add implicit conversions.
+ AbstractMetaFunctionList implicitConvs;
+ if (!customConversion || !customConversion->replaceOriginalTargetToNativeConversions()) {
+ foreach (AbstractMetaFunction* func, implicitConversions(metaClass->typeEntry())) {
+ if (!func->isUserAdded())
+ implicitConvs << func;
+ }
+ }
+
+ if (!implicitConvs.isEmpty())
+ s << INDENT << "// Add implicit conversions to type converter." << endl;
+
+ AbstractMetaType* targetType = buildAbstractMetaTypeFromAbstractMetaClass(metaClass);
+ foreach (const AbstractMetaFunction* conv, implicitConvs) {
+ if (conv->isModifiedRemoved())
+ continue;
+ const AbstractMetaType* sourceType;
+ if (conv->isConversionOperator()) {
+ sourceType = buildAbstractMetaTypeFromAbstractMetaClass(conv->ownerClass());
+ } else {
+ // Constructor that does implicit conversion.
+ if (!conv->typeReplaced(1).isEmpty())
+ continue;
+ sourceType = conv->arguments().first()->type();
+ }
+ QString toCpp = pythonToCppFunctionName(sourceType, targetType);
+ QString isConv = convertibleToCppFunctionName(sourceType, targetType);
+ writeAddPythonToCppConversion(s, QLatin1String("converter"), toCpp, isConv);
+ }
+
+ writeCustomConverterRegister(s, customConversion, QLatin1String("converter"));
+}
+
+void CppGenerator::writeCustomConverterRegister(QTextStream& s, const CustomConversion* customConversion, const QString& converterVar)
+{
+ if (!customConversion)
+ return;
+ const CustomConversion::TargetToNativeConversions& toCppConversions = customConversion->targetToNativeConversions();
+ if (toCppConversions.isEmpty())
+ return;
+ s << INDENT << "// Add user defined implicit conversions to type converter." << endl;
+ foreach (CustomConversion::TargetToNativeConversion* toNative, toCppConversions) {
+ QString toCpp = pythonToCppFunctionName(toNative, customConversion->ownerType());
+ QString isConv = convertibleToCppFunctionName(toNative, customConversion->ownerType());
+ writeAddPythonToCppConversion(s, converterVar, toCpp, isConv);
+ }
+}
+
+void CppGenerator::writeContainerConverterRegister(QTextStream& s, const AbstractMetaType* container, const QString& converterVar)
+{
+ s << INDENT << "// Add user defined container conversion to type converter." << endl;
+ QString typeName = fixedCppTypeName(container);
+ QString toCpp = pythonToCppFunctionName(typeName, typeName);
+ QString isConv = convertibleToCppFunctionName(typeName, typeName);
+ writeAddPythonToCppConversion(s, converterVar, toCpp, isConv);
+}
+
+void CppGenerator::writeContainerConverterFunctions(QTextStream& s, const AbstractMetaType* containerType)
+{
+ writeCppToPythonFunction(s, containerType);
+ writePythonToCppConversionFunctions(s, containerType);
+}
+
+void CppGenerator::writeMethodWrapperPreamble(QTextStream &s, OverloadData &overloadData,
+ GeneratorContext &context)
+{
+ const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
+ const AbstractMetaClass* ownerClass = rfunc->ownerClass();
+ int minArgs = overloadData.minArgs();
+ int maxArgs = overloadData.maxArgs();
+ bool initPythonArguments;
+ bool usesNamedArguments;
+
+ // If method is a constructor...
+ if (rfunc->isConstructor()) {
+ // Check if the right constructor was called.
+ if (!ownerClass->hasPrivateDestructor()) {
+ s << INDENT;
+ s << "if (Shiboken::Object::isUserType(" PYTHON_SELF_VAR ") && !Shiboken::ObjectType::canCallConstructor(" PYTHON_SELF_VAR "->ob_type, Shiboken::SbkType< ::";
+ QString qualifiedCppName;
+ if (!context.forSmartPointer())
+ qualifiedCppName = ownerClass->qualifiedCppName();
+ else
+ qualifiedCppName = context.preciseType()->cppSignature();
+
+ s << qualifiedCppName << " >()))" << endl;
+ Indentation indent(INDENT);
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl << endl;
+ }
+ // Declare pointer for the underlying C++ object.
+ s << INDENT << "::";
+ if (!context.forSmartPointer()) {
+ s << (shouldGenerateCppWrapper(ownerClass) ? wrapperName(ownerClass)
+ : ownerClass->qualifiedCppName());
+ } else {
+ s << context.preciseType()->cppSignature();
+ }
+ s << "* cptr = 0;" << endl;
+
+ initPythonArguments = maxArgs > 0;
+ usesNamedArguments = !ownerClass->isQObject() && overloadData.hasArgumentWithDefaultValue();
+
+ } else {
+ if (rfunc->implementingClass() &&
+ (!rfunc->implementingClass()->isNamespace() && overloadData.hasInstanceFunction())) {
+ writeCppSelfDefinition(s, rfunc, context, overloadData.hasStaticFunction());
+ }
+ if (!rfunc->isInplaceOperator() && overloadData.hasNonVoidReturnType())
+ s << INDENT << "PyObject* " PYTHON_RETURN_VAR " = 0;" << endl;
+
+ initPythonArguments = minArgs != maxArgs || maxArgs > 1;
+ usesNamedArguments = rfunc->isCallOperator() || overloadData.hasArgumentWithDefaultValue();
+ }
+
+ if (maxArgs > 0) {
+ s << INDENT << "int overloadId = -1;" << endl;
+ s << INDENT << "PythonToCppFunc " PYTHON_TO_CPP_VAR;
+ if (pythonFunctionWrapperUsesListOfArguments(overloadData))
+ s << "[] = { 0" << QString::fromLatin1(", 0").repeated(maxArgs-1) << " }";
+ s << ';' << endl;
+ writeUnusedVariableCast(s, QLatin1String(PYTHON_TO_CPP_VAR));
+ }
+
+ if (usesNamedArguments && !rfunc->isCallOperator())
+ s << INDENT << "int numNamedArgs = (kwds ? PyDict_Size(kwds) : 0);" << endl;
+
+ if (initPythonArguments) {
+ s << INDENT << "int numArgs = ";
+ if (minArgs == 0 && maxArgs == 1 && !rfunc->isConstructor() && !pythonFunctionWrapperUsesListOfArguments(overloadData))
+ s << "(" PYTHON_ARG " == 0 ? 0 : 1);" << endl;
+ else
+ writeArgumentsInitializer(s, overloadData);
+ }
+}
+
+void CppGenerator::writeConstructorWrapper(QTextStream &s, const AbstractMetaFunctionList overloads,
+ GeneratorContext &classContext)
+{
+ ErrorCode errorCode(-1);
+ OverloadData overloadData(overloads, this);
+
+ const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
+ const AbstractMetaClass* metaClass = rfunc->ownerClass();
+
+ s << "static int" << endl;
+ s << cpythonFunctionName(rfunc) << "(PyObject* " PYTHON_SELF_VAR ", PyObject* args, PyObject* kwds)" << endl;
+ s << '{' << endl;
+
+ QSet<QString> argNamesSet;
+ if (usePySideExtensions() && metaClass->isQObject()) {
+ // Write argNames variable with all known argument names.
+ foreach (const AbstractMetaFunction* func, overloadData.overloads()) {
+ foreach (const AbstractMetaArgument* arg, func->arguments()) {
+ if (arg->defaultValueExpression().isEmpty() || func->argumentRemoved(arg->argumentIndex() + 1))
+ continue;
+ argNamesSet << arg->name();
+ }
+ }
+ QStringList argNamesList = argNamesSet.toList();
+ qSort(argNamesList.begin(), argNamesList.end());
+ if (argNamesList.isEmpty()) {
+ s << INDENT << "const char** argNames = 0;" << endl;
+ } else {
+ s << INDENT << "const char* argNames[] = {\""
+ << argNamesList.join(QLatin1String("\", \"")) << "\"};" << endl;
+ }
+ s << INDENT << "const QMetaObject* metaObject;" << endl;
+ }
+
+ s << INDENT << "SbkObject* sbkSelf = reinterpret_cast<SbkObject*>(" PYTHON_SELF_VAR ");" << endl;
+
+ if (metaClass->isAbstract() || metaClass->baseClassNames().size() > 1) {
+ s << INDENT << "SbkObjectType* type = reinterpret_cast<SbkObjectType*>(" PYTHON_SELF_VAR "->ob_type);" << endl;
+ s << INDENT << "SbkObjectType* myType = reinterpret_cast<SbkObjectType*>(" << cpythonTypeNameExt(metaClass->typeEntry()) << ");" << endl;
+ }
+
+ if (metaClass->isAbstract()) {
+ s << INDENT << "if (type == myType) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyErr_SetString(PyExc_NotImplementedError," << endl;
+ {
+ Indentation indentation(INDENT);
+ s << INDENT << "\"'" << metaClass->qualifiedCppName();
+ }
+ s << "' represents a C++ abstract class and cannot be instantiated\");" << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ s << INDENT << '}' << endl << endl;
+ }
+
+ if (metaClass->baseClassNames().size() > 1) {
+ if (!metaClass->isAbstract()) {
+ s << INDENT << "if (type != myType) {" << endl;
+ }
+ {
+ Indentation indentation(INDENT);
+ s << INDENT << "Shiboken::ObjectType::copyMultimpleheritance(type, myType);" << endl;
+ }
+ if (!metaClass->isAbstract())
+ s << INDENT << '}' << endl << endl;
+ }
+
+ writeMethodWrapperPreamble(s, overloadData, classContext);
+
+ s << endl;
+
+ if (overloadData.maxArgs() > 0)
+ writeOverloadedFunctionDecisor(s, overloadData);
+
+ writeFunctionCalls(s, overloadData, classContext);
+ s << endl;
+
+ s << INDENT << "if (PyErr_Occurred() || !Shiboken::Object::setCppPointer(sbkSelf, Shiboken::SbkType< ::" << metaClass->qualifiedCppName() << " >(), cptr)) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "delete cptr;" << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ s << INDENT << '}' << endl;
+ if (overloadData.maxArgs() > 0) {
+ s << INDENT << "if (!cptr) goto " << cpythonFunctionName(rfunc) << "_TypeError;" << endl;
+ s << endl;
+ }
+
+ s << INDENT << "Shiboken::Object::setValidCpp(sbkSelf, true);" << endl;
+ // If the created C++ object has a C++ wrapper the ownership is assigned to Python
+ // (first "1") and the flag indicating that the Python wrapper holds an C++ wrapper
+ // is marked as true (the second "1"). Otherwise the default values apply:
+ // Python owns it and C++ wrapper is false.
+ if (shouldGenerateCppWrapper(overloads.first()->ownerClass()))
+ s << INDENT << "Shiboken::Object::setHasCppWrapper(sbkSelf, true);" << endl;
+ // Need to check if a wrapper for same pointer is already registered
+ // Caused by bug PYSIDE-217, where deleted objects' wrappers are not released
+ s << INDENT << "if (Shiboken::BindingManager::instance().hasWrapper(cptr)) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "Shiboken::BindingManager::instance().releaseWrapper(Shiboken::BindingManager::instance().retrieveWrapper(cptr));" << endl;
+ }
+ s << INDENT << "}" << endl;
+ s << INDENT << "Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);" << endl;
+
+ // Create metaObject and register signal/slot
+ if (metaClass->isQObject() && usePySideExtensions()) {
+ s << endl << INDENT << "// QObject setup" << endl;
+ s << INDENT << "PySide::Signal::updateSourceObject(" PYTHON_SELF_VAR ");" << endl;
+ s << INDENT << "metaObject = cptr->metaObject(); // <- init python qt properties" << endl;
+ s << INDENT << "if (kwds && !PySide::fillQtProperties(" PYTHON_SELF_VAR ", metaObject, kwds, argNames, " << argNamesSet.count() << "))" << endl;
+ {
+ Indentation indentation(INDENT);
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ }
+
+ // Constructor code injections, position=end
+ bool hasCodeInjectionsAtEnd = false;
+ foreach(AbstractMetaFunction* func, overloads) {
+ foreach (const CodeSnip &cs, func->injectedCodeSnips()) {
+ if (cs.position == TypeSystem::CodeSnipPositionEnd) {
+ hasCodeInjectionsAtEnd = true;
+ break;
+ }
+ }
+ }
+ if (hasCodeInjectionsAtEnd) {
+ // FIXME: C++ arguments are not available in code injection on constructor when position = end.
+ s << INDENT << "switch(overloadId) {" << endl;
+ foreach(AbstractMetaFunction* func, overloads) {
+ Indentation indent(INDENT);
+ foreach (const CodeSnip &cs, func->injectedCodeSnips()) {
+ if (cs.position == TypeSystem::CodeSnipPositionEnd) {
+ s << INDENT << "case " << metaClass->functions().indexOf(func) << ':' << endl;
+ s << INDENT << '{' << endl;
+ {
+ Indentation indent(INDENT);
+ writeCodeSnips(s, func->injectedCodeSnips(), TypeSystem::CodeSnipPositionEnd, TypeSystem::TargetLangCode, func);
+ }
+ s << INDENT << '}' << endl;
+ break;
+ }
+ }
+ }
+ s << '}' << endl;
+ }
+
+ s << endl;
+ s << endl << INDENT << "return 1;" << endl;
+ if (overloadData.maxArgs() > 0)
+ writeErrorSection(s, overloadData);
+ s << '}' << endl << endl;
+}
+
+void CppGenerator::writeMethodWrapper(QTextStream &s, const AbstractMetaFunctionList overloads,
+ GeneratorContext &classContext)
+{
+ OverloadData overloadData(overloads, this);
+ const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
+
+ int maxArgs = overloadData.maxArgs();
+
+ s << "static PyObject* ";
+ s << cpythonFunctionName(rfunc) << "(PyObject* " PYTHON_SELF_VAR;
+ if (maxArgs > 0) {
+ s << ", PyObject* " << (pythonFunctionWrapperUsesListOfArguments(overloadData) ? "args" : PYTHON_ARG);
+ if (overloadData.hasArgumentWithDefaultValue() || rfunc->isCallOperator())
+ s << ", PyObject* kwds";
+ }
+ s << ')' << endl << '{' << endl;
+
+ writeMethodWrapperPreamble(s, overloadData, classContext);
+
+ s << endl;
+
+ /*
+ * Make sure reverse <</>> operators defined in other classes (specially from other modules)
+ * are called. A proper and generic solution would require an reengineering in the operator
+ * system like the extended converters.
+ *
+ * Solves #119 - QDataStream <</>> operators not working for QPixmap
+ * http://bugs.openbossa.org/show_bug.cgi?id=119
+ */
+ bool hasReturnValue = overloadData.hasNonVoidReturnType();
+ bool callExtendedReverseOperator = hasReturnValue
+ && !rfunc->isInplaceOperator()
+ && !rfunc->isCallOperator()
+ && rfunc->isOperatorOverload();
+ if (callExtendedReverseOperator) {
+ QString revOpName = ShibokenGenerator::pythonOperatorFunctionName(rfunc).insert(2, QLatin1Char('r'));
+ if (rfunc->isBinaryOperator()) {
+ s << INDENT << "if (!isReverse" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "&& Shiboken::Object::checkType(" PYTHON_ARG ")" << endl;
+ s << INDENT << "&& !PyObject_TypeCheck(" PYTHON_ARG ", " PYTHON_SELF_VAR "->ob_type)" << endl;
+ s << INDENT << "&& PyObject_HasAttrString(" PYTHON_ARG ", const_cast<char*>(\"" << revOpName << "\"))) {" << endl;
+
+ // This PyObject_CallMethod call will emit lots of warnings like
+ // "deprecated conversion from string constant to char *" during compilation
+ // due to the method name argument being declared as "char*" instead of "const char*"
+ // issue 6952 http://bugs.python.org/issue6952
+ s << INDENT << "PyObject* revOpMethod = PyObject_GetAttrString(" PYTHON_ARG ", const_cast<char*>(\"" << revOpName << "\"));" << endl;
+ s << INDENT << "if (revOpMethod && PyCallable_Check(revOpMethod)) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << PYTHON_RETURN_VAR " = PyObject_CallFunction(revOpMethod, const_cast<char*>(\"O\"), " PYTHON_SELF_VAR ");" << endl;
+ s << INDENT << "if (PyErr_Occurred() && (PyErr_ExceptionMatches(PyExc_NotImplementedError)";
+ s << " || PyErr_ExceptionMatches(PyExc_AttributeError))) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyErr_Clear();" << endl;
+ s << INDENT << "Py_XDECREF(" PYTHON_RETURN_VAR ");" << endl;
+ s << INDENT << PYTHON_RETURN_VAR " = 0;" << endl;
+ }
+ s << INDENT << '}' << endl;
+ }
+ s << INDENT << "}" << endl;
+ s << INDENT << "Py_XDECREF(revOpMethod);" << endl << endl;
+ }
+ s << INDENT << "}" << endl;
+ }
+ s << INDENT << "// Do not enter here if other object has implemented a reverse operator." << endl;
+ s << INDENT << "if (!" PYTHON_RETURN_VAR ") {" << endl << endl;
+ }
+
+ if (maxArgs > 0)
+ writeOverloadedFunctionDecisor(s, overloadData);
+
+ writeFunctionCalls(s, overloadData, classContext);
+
+ if (callExtendedReverseOperator)
+ s << endl << INDENT << "} // End of \"if (!" PYTHON_RETURN_VAR ")\"" << endl;
+
+ s << endl;
+
+ writeFunctionReturnErrorCheckSection(s, hasReturnValue && !rfunc->isInplaceOperator());
+
+ if (hasReturnValue) {
+ if (rfunc->isInplaceOperator()) {
+ s << INDENT << "Py_INCREF(" PYTHON_SELF_VAR ");\n";
+ s << INDENT << "return " PYTHON_SELF_VAR ";\n";
+ } else {
+ s << INDENT << "return " PYTHON_RETURN_VAR ";\n";
+ }
+ } else {
+ s << INDENT << "Py_RETURN_NONE;" << endl;
+ }
+
+ if (maxArgs > 0)
+ writeErrorSection(s, overloadData);
+
+ s << '}' << endl << endl;
+}
+
+void CppGenerator::writeArgumentsInitializer(QTextStream& s, OverloadData& overloadData)
+{
+ const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
+ s << "PyTuple_GET_SIZE(args);" << endl;
+
+ int minArgs = overloadData.minArgs();
+ int maxArgs = overloadData.maxArgs();
+
+ s << INDENT << "PyObject* ";
+ s << PYTHON_ARGS "[] = {"
+ << QString(maxArgs, QLatin1Char('0')).split(QLatin1String(""), QString::SkipEmptyParts).join(QLatin1String(", "))
+ << "};" << endl;
+ s << endl;
+
+ if (overloadData.hasVarargs()) {
+ maxArgs--;
+ if (minArgs > maxArgs)
+ minArgs = maxArgs;
+
+ s << INDENT << "PyObject* nonvarargs = PyTuple_GetSlice(args, 0, " << maxArgs << ");" << endl;
+ s << INDENT << "Shiboken::AutoDecRef auto_nonvarargs(nonvarargs);" << endl;
+ s << INDENT << PYTHON_ARGS "[" << maxArgs << "] = PyTuple_GetSlice(args, " << maxArgs << ", numArgs);" << endl;
+ s << INDENT << "Shiboken::AutoDecRef auto_varargs(" PYTHON_ARGS "[" << maxArgs << "]);" << endl;
+ s << endl;
+ }
+
+ bool usesNamedArguments = overloadData.hasArgumentWithDefaultValue();
+
+ s << INDENT << "// invalid argument lengths" << endl;
+ bool ownerClassIsQObject = rfunc->ownerClass() && rfunc->ownerClass()->isQObject() && rfunc->isConstructor();
+ if (usesNamedArguments) {
+ if (!ownerClassIsQObject) {
+ s << INDENT << "if (numArgs" << (overloadData.hasArgumentWithDefaultValue() ? " + numNamedArgs" : "") << " > " << maxArgs << ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyErr_SetString(PyExc_TypeError, \"" << fullPythonFunctionName(rfunc) << "(): too many arguments\");" << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ s << INDENT << '}';
+ }
+ if (minArgs > 0) {
+ if (ownerClassIsQObject)
+ s << INDENT;
+ else
+ s << " else ";
+ s << "if (numArgs < " << minArgs << ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyErr_SetString(PyExc_TypeError, \"" << fullPythonFunctionName(rfunc) << "(): not enough arguments\");" << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ s << INDENT << '}';
+ }
+ }
+ QList<int> invalidArgsLength = overloadData.invalidArgumentLengths();
+ if (!invalidArgsLength.isEmpty()) {
+ QStringList invArgsLen;
+ foreach (int i, invalidArgsLength)
+ invArgsLen << QStringLiteral("numArgs == %1").arg(i);
+ if (usesNamedArguments && (!ownerClassIsQObject || minArgs > 0))
+ s << " else ";
+ else
+ s << INDENT;
+ s << "if (" << invArgsLen.join(QLatin1String(" || ")) << ")" << endl;
+ Indentation indent(INDENT);
+ s << INDENT << "goto " << cpythonFunctionName(rfunc) << "_TypeError;";
+ }
+ s << endl << endl;
+
+ QString funcName;
+ if (rfunc->isOperatorOverload())
+ funcName = ShibokenGenerator::pythonOperatorFunctionName(rfunc);
+ else
+ funcName = rfunc->name();
+
+ QString argsVar = overloadData.hasVarargs() ? QLatin1String("nonvarargs") : QLatin1String("args");
+ s << INDENT << "if (!";
+ if (usesNamedArguments)
+ s << "PyArg_ParseTuple(" << argsVar << ", \"|" << QByteArray(maxArgs, 'O') << ':' << funcName << '"';
+ else
+ s << "PyArg_UnpackTuple(" << argsVar << ", \"" << funcName << "\", " << minArgs << ", " << maxArgs;
+ QStringList palist;
+ for (int i = 0; i < maxArgs; i++)
+ palist << QString::fromLatin1("&(" PYTHON_ARGS "[%1])").arg(i);
+ s << ", " << palist.join(QLatin1String(", ")) << "))" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ s << endl;
+}
+
+void CppGenerator::writeCppSelfDefinition(QTextStream &s,
+ GeneratorContext &context,
+ bool hasStaticOverload,
+ bool cppSelfAsReference)
+{
+ const AbstractMetaClass *metaClass = context.metaClass();
+ bool useWrapperClass = avoidProtectedHack() && metaClass->hasProtectedMembers();
+ QString className;
+ if (!context.forSmartPointer()) {
+ className = useWrapperClass
+ ? wrapperName(metaClass)
+ : (QLatin1String("::") + metaClass->qualifiedCppName());
+ } else {
+ className = context.preciseType()->cppSignature();
+ }
+
+ QString cppSelfAttribution;
+ QString pythonSelfVar = QLatin1String(PYTHON_SELF_VAR);
+ QString cpythonWrapperCPtrResult;
+ if (!context.forSmartPointer())
+ cpythonWrapperCPtrResult = cpythonWrapperCPtr(metaClass, pythonSelfVar);
+ else
+ cpythonWrapperCPtrResult = cpythonWrapperCPtr(context.preciseType(), pythonSelfVar);
+
+ if (cppSelfAsReference) {
+ QString cast = useWrapperClass ? QString::fromLatin1("(%1*)").arg(className) : QString();
+ cppSelfAttribution = QString::fromLatin1("%1& %2 = *(%3%4)")
+ .arg(className, QLatin1String(CPP_SELF_VAR), cast,
+ cpythonWrapperCPtrResult);
+ } else {
+ s << INDENT << className << "* " CPP_SELF_VAR " = 0;" << endl;
+ writeUnusedVariableCast(s, QLatin1String(CPP_SELF_VAR));
+ cppSelfAttribution = QString::fromLatin1("%1 = %2%3")
+ .arg(QLatin1String(CPP_SELF_VAR),
+ (useWrapperClass ? QString::fromLatin1("(%1*)").arg(className) : QString()),
+ cpythonWrapperCPtrResult);
+ }
+
+ // Checks if the underlying C++ object is valid.
+ if (hasStaticOverload && !cppSelfAsReference) {
+ s << INDENT << "if (" PYTHON_SELF_VAR ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ writeInvalidPyObjectCheck(s, QLatin1String(PYTHON_SELF_VAR));
+ s << INDENT << cppSelfAttribution << ';' << endl;
+ }
+ s << INDENT << '}' << endl;
+ return;
+ }
+
+ writeInvalidPyObjectCheck(s, QLatin1String(PYTHON_SELF_VAR));
+ s << INDENT << cppSelfAttribution << ';' << endl;
+}
+
+void CppGenerator::writeCppSelfDefinition(QTextStream &s,
+ const AbstractMetaFunction *func,
+ GeneratorContext &context,
+ bool hasStaticOverload)
+{
+ if (!func->ownerClass() || func->isConstructor())
+ return;
+
+ if (func->isOperatorOverload() && func->isBinaryOperator()) {
+ QString checkFunc = cpythonCheckFunction(func->ownerClass()->typeEntry());
+ s << INDENT << "bool isReverse = " << checkFunc << PYTHON_ARG ")" << endl;
+ {
+ Indentation indent1(INDENT);
+ Indentation indent2(INDENT);
+ Indentation indent3(INDENT);
+ Indentation indent4(INDENT);
+ s << INDENT << "&& !" << checkFunc << PYTHON_SELF_VAR ");" << endl;
+ }
+ s << INDENT << "if (isReverse)" << endl;
+ Indentation indent(INDENT);
+ s << INDENT << "std::swap(" PYTHON_SELF_VAR ", " PYTHON_ARG ");" << endl;
+ }
+
+ writeCppSelfDefinition(s, context, hasStaticOverload);
+}
+
+void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData)
+{
+ const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
+ s << endl << INDENT << cpythonFunctionName(rfunc) << "_TypeError:" << endl;
+ Indentation indentation(INDENT);
+ QString funcName = fullPythonFunctionName(rfunc);
+
+ QString argsVar = pythonFunctionWrapperUsesListOfArguments(overloadData)
+ ? QLatin1String("args") : QLatin1String(PYTHON_ARG);
+ if (verboseErrorMessagesDisabled()) {
+ s << INDENT << "Shiboken::setErrorAboutWrongArguments(" << argsVar << ", \"" << funcName << "\", 0);" << endl;
+ } else {
+ QStringList overloadSignatures;
+ foreach (const AbstractMetaFunction* f, overloadData.overloads()) {
+ QStringList args;
+ foreach(AbstractMetaArgument* arg, f->arguments()) {
+ QString strArg;
+ AbstractMetaType* argType = arg->type();
+ if (isCString(argType)) {
+ strArg = QLatin1String("\" SBK_STR_NAME \"");
+ } else if (argType->isPrimitive()) {
+ const PrimitiveTypeEntry* ptp = reinterpret_cast<const PrimitiveTypeEntry*>(argType->typeEntry());
+ while (ptp->referencedTypeEntry())
+ ptp = ptp->referencedTypeEntry();
+ strArg = ptp->name();
+ if (strArg == QLatin1String("QString")) {
+ strArg = QLatin1String("unicode");
+ } else if (strArg == QLatin1String("QChar")) {
+ strArg = QLatin1String("1-unicode");
+ } else {
+ strArg = ptp->name();
+ strArg.remove(QRegExp(QLatin1String("^signed\\s+")));
+ if (strArg == QLatin1String("double"))
+ strArg = QLatin1String("float");
+ }
+ } else if (argType->typeEntry()->isContainer()) {
+ strArg = argType->fullName();
+ if (strArg == QLatin1String("QList") || strArg == QLatin1String("QVector")
+ || strArg == QLatin1String("QLinkedList") || strArg == QLatin1String("QStack")
+ || strArg == QLatin1String("QQueue")) {
+ strArg = QLatin1String("list");
+ } else if (strArg == QLatin1String("QMap") || strArg == QLatin1String("QHash")
+ || strArg == QLatin1String("QMultiMap") || strArg == QLatin1String("QMultiHash")) {
+ strArg = QLatin1String("dict");
+ } else if (strArg == QLatin1String("QPair")) {
+ strArg = QLatin1String("2-tuple");
+ }
+ } else {
+ strArg = argType->fullName();
+ if (strArg == QLatin1String("PyUnicode"))
+ strArg = QLatin1String("unicode");
+ else if (strArg == QLatin1String("PyString"))
+ strArg = QLatin1String("str");
+ else if (strArg == QLatin1String("PyBytes"))
+ strArg = QLatin1String("\" SBK_STR_NAME \"");
+ else if (strArg == QLatin1String("PySequece"))
+ strArg = QLatin1String("list");
+ else if (strArg == QLatin1String("PyTuple"))
+ strArg = QLatin1String("tuple");
+ else if (strArg == QLatin1String("PyDict"))
+ strArg = QLatin1String("dict");
+ else if (strArg == QLatin1String("PyObject"))
+ strArg = QLatin1String("object");
+ else if (strArg == QLatin1String("PyCallable"))
+ strArg = QLatin1String("callable");
+ else if (strArg == QLatin1String("uchar"))
+ strArg = QLatin1String("buffer"); // This depends on an inject code to be true, but if it's not true
+ // the function wont work at all, so it must be true.
+ }
+ if (!arg->defaultValueExpression().isEmpty()) {
+ strArg += QLatin1String(" = ");
+ if ((isCString(argType) || isPointerToWrapperType(argType))
+ && arg->defaultValueExpression() == QLatin1String("0")) {
+ strArg += QLatin1String("None");
+ } else {
+ QString e = arg->defaultValueExpression();
+ e.replace(QLatin1String("::"), QLatin1String("."));
+ e.replace(QLatin1String("\""), QLatin1String("\\\""));
+ strArg += e;
+ }
+ }
+ args << strArg;
+ }
+ overloadSignatures << QLatin1Char('"') + args.join(QLatin1String(", ")) + QLatin1Char('"');
+ }
+ s << INDENT << "const char* overloads[] = {" << overloadSignatures.join(QLatin1String(", "))
+ << ", 0};" << endl;
+ s << INDENT << "Shiboken::setErrorAboutWrongArguments(" << argsVar << ", \"" << funcName << "\", overloads);" << endl;
+ }
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+}
+
+void CppGenerator::writeFunctionReturnErrorCheckSection(QTextStream& s, bool hasReturnValue)
+{
+ s << INDENT << "if (PyErr_Occurred()" << (hasReturnValue ? " || !" PYTHON_RETURN_VAR : "") << ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ if (hasReturnValue)
+ s << INDENT << "Py_XDECREF(" PYTHON_RETURN_VAR ");" << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ s << INDENT << '}' << endl;
+}
+
+void CppGenerator::writeInvalidPyObjectCheck(QTextStream& s, const QString& pyObj)
+{
+ s << INDENT << "if (!Shiboken::Object::isValid(" << pyObj << "))" << endl;
+ Indentation indent(INDENT);
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+}
+
+static QString pythonToCppConverterForArgumentName(const QString& argumentName)
+{
+ static QRegExp pyArgsRegex(QLatin1String(PYTHON_ARGS"(\\[\\d+[-]?\\d*\\])"));
+ pyArgsRegex.indexIn(argumentName);
+ return QLatin1String(PYTHON_TO_CPP_VAR) + pyArgsRegex.cap(1);
+}
+
+void CppGenerator::writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, bool isNumber, QString customType, bool rejectNull)
+{
+ QString customCheck;
+ if (!customType.isEmpty()) {
+ AbstractMetaType* metaType;
+ customCheck = guessCPythonCheckFunction(customType, &metaType);
+ if (metaType)
+ argType = metaType;
+ }
+
+ // TODO-CONVERTER: merge this with the code below.
+ QString typeCheck;
+ if (customCheck.isEmpty())
+ typeCheck = cpythonIsConvertibleFunction(argType, argType->isEnum() ? false : isNumber);
+ else
+ typeCheck = customCheck;
+ typeCheck.append(QString::fromLatin1("(%1)").arg(argumentName));
+
+ // TODO-CONVERTER -----------------------------------------------------------------------
+ if (customCheck.isEmpty() && !argType->typeEntry()->isCustom()) {
+ typeCheck = QString::fromLatin1("(%1 = %2))").arg(pythonToCppConverterForArgumentName(argumentName), typeCheck);
+ if (!isNumber && argType->typeEntry()->isCppPrimitive())
+ typeCheck.prepend(QString::fromLatin1("%1(%2) && ").arg(cpythonCheckFunction(argType), argumentName));
+ }
+ // TODO-CONVERTER -----------------------------------------------------------------------
+
+ if (rejectNull)
+ typeCheck = QString::fromLatin1("(%1 != Py_None && %2)").arg(argumentName, typeCheck);
+
+ s << typeCheck;
+}
+
+static void checkTypeViability(const AbstractMetaFunction* func, const AbstractMetaType* type, int argIdx)
+{
+ if (!type
+ || !type->typeEntry()->isPrimitive()
+ || type->indirections() == 0
+ || ShibokenGenerator::isCString(type)
+ || func->argumentRemoved(argIdx)
+ || !func->typeReplaced(argIdx).isEmpty()
+ || !func->conversionRule(TypeSystem::All, argIdx).isEmpty()
+ || func->hasInjectedCode())
+ return;
+ QString prefix;
+ if (func->ownerClass())
+ prefix = func->ownerClass()->qualifiedCppName() + QLatin1String("::");
+ qCWarning(lcShiboken).noquote().nospace()
+ << QString::fromLatin1("There's no user provided way (conversion rule, argument removal, custom code, etc) "
+ "to handle the primitive %1 type '%2' in function '%3%4'.")
+ .arg(argIdx == 0 ? QStringLiteral("return") : QStringLiteral("argument"),
+ type->cppSignature(), prefix, func->signature());
+}
+
+static void checkTypeViability(const AbstractMetaFunction* func)
+{
+ if (func->isUserAdded())
+ return;
+ const AbstractMetaType* type = func->type();
+ checkTypeViability(func, type, 0);
+ for (int i = 0; i < func->arguments().count(); ++i)
+ checkTypeViability(func, func->arguments().at(i)->type(), i + 1);
+}
+
+void CppGenerator::writeTypeCheck(QTextStream& s, const OverloadData* overloadData, QString argumentName)
+{
+ QSet<const TypeEntry*> numericTypes;
+
+ foreach (OverloadData* od, overloadData->previousOverloadData()->nextOverloadData()) {
+ foreach (const AbstractMetaFunction* func, od->overloads()) {
+ checkTypeViability(func);
+ const AbstractMetaType* argType = od->argument(func)->type();
+ if (!argType->isPrimitive())
+ continue;
+ if (ShibokenGenerator::isNumber(argType->typeEntry()))
+ numericTypes << argType->typeEntry();
+ }
+ }
+
+ // 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();
+ bool numberType = numericTypes.count() == 1 || ShibokenGenerator::isPyInt(argType);
+ QString customType = (overloadData->hasArgumentTypeReplace() ? overloadData->argumentTypeReplaced() : QString());
+ bool rejectNull = shouldRejectNullPointerArgument(overloadData->referenceFunction(), overloadData->argPos());
+ writeTypeCheck(s, argType, argumentName, numberType, customType, rejectNull);
+}
+
+void CppGenerator::writeArgumentConversion(QTextStream& s,
+ const AbstractMetaType* argType,
+ const QString& argName, const QString& pyArgName,
+ const AbstractMetaClass* context,
+ const QString& defaultValue,
+ bool castArgumentAsUnused)
+{
+ if (argType->typeEntry()->isCustom() || argType->typeEntry()->isVarargs())
+ return;
+ if (isWrapperType(argType))
+ writeInvalidPyObjectCheck(s, pyArgName);
+ writePythonToCppTypeConversion(s, argType, pyArgName, argName, context, defaultValue);
+ if (castArgumentAsUnused)
+ writeUnusedVariableCast(s, argName);
+}
+
+const AbstractMetaType* CppGenerator::getArgumentType(const AbstractMetaFunction* func, int argPos)
+{
+ if (argPos < 0 || argPos > func->arguments().size()) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QStringLiteral("Argument index for function '%1' out of range.").arg(func->signature());
+ return 0;
+ }
+
+ const AbstractMetaType* argType = 0;
+ QString typeReplaced = func->typeReplaced(argPos);
+ if (typeReplaced.isEmpty())
+ argType = (argPos == 0) ? func->type() : func->arguments().at(argPos-1)->type();
+ else
+ argType = buildAbstractMetaTypeFromString(typeReplaced);
+ if (!argType && !m_knownPythonTypes.contains(typeReplaced)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QString::fromLatin1("Unknown type '%1' used as argument type replacement "\
+ "in function '%2', the generated code may be broken.")
+ .arg(typeReplaced, func->signature());
+ }
+ return argType;
+}
+
+void CppGenerator::writePythonToCppTypeConversion(QTextStream& s,
+ const AbstractMetaType* type,
+ const QString& pyIn,
+ const QString& cppOut,
+ const AbstractMetaClass* /* context */,
+ const QString& defaultValue)
+{
+ const TypeEntry* typeEntry = type->typeEntry();
+ if (typeEntry->isCustom() || typeEntry->isVarargs())
+ return;
+
+ QString cppOutAux = cppOut + QLatin1String("_local");
+
+ bool treatAsPointer = isValueTypeWithCopyConstructorOnly(type);
+ bool isPointerOrObjectType = (isObjectType(type) || isPointer(type)) && !isUserPrimitive(type) && !isCppPrimitive(type);
+ bool isNotContainerEnumOrFlags = !typeEntry->isContainer() && !typeEntry->isEnum() && !typeEntry->isFlags();
+ bool mayHaveImplicitConversion = type->referenceType() == LValueReference
+ && !isUserPrimitive(type)
+ && !isCppPrimitive(type)
+ && isNotContainerEnumOrFlags
+ && !(treatAsPointer || isPointerOrObjectType);
+ QString typeName = getFullTypeNameWithoutModifiers(type);
+
+ bool isProtectedEnum = false;
+
+ if (mayHaveImplicitConversion) {
+ s << INDENT << typeName << ' ' << cppOutAux;
+ writeMinimalConstructorExpression(s, type, defaultValue);
+ s << ';' << endl;
+ } else if (avoidProtectedHack() && type->typeEntry()->isEnum()) {
+ const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(type);
+ if (metaEnum && metaEnum->isProtected()) {
+ typeName = QLatin1String("long");
+ isProtectedEnum = true;
+ }
+ }
+
+ s << INDENT << typeName;
+ if (treatAsPointer || isPointerOrObjectType) {
+ s << "* " << cppOut;
+ if (!defaultValue.isEmpty())
+ s << " = " << defaultValue;
+ } else if (type->referenceType() == LValueReference && !typeEntry->isPrimitive() && isNotContainerEnumOrFlags) {
+ s << "* " << cppOut << " = &" << cppOutAux;
+ } else {
+ s << ' ' << cppOut;
+ if (isProtectedEnum && avoidProtectedHack()) {
+ s << " = ";
+ if (defaultValue.isEmpty())
+ s << "0";
+ else
+ s << "(long)" << defaultValue;
+ } else if (isUserPrimitive(type) || typeEntry->isEnum() || typeEntry->isFlags()) {
+ writeMinimalConstructorExpression(s, typeEntry, defaultValue);
+ } else if (!type->isContainer() && !type->isSmartPointer()) {
+ writeMinimalConstructorExpression(s, type, defaultValue);
+ }
+ }
+ s << ';' << endl;
+
+ QString pythonToCppFunc = pythonToCppConverterForArgumentName(pyIn);
+
+ s << INDENT;
+ if (!defaultValue.isEmpty())
+ s << "if (" << pythonToCppFunc << ") ";
+
+ QString pythonToCppCall = QString::fromLatin1("%1(%2, &%3)").arg(pythonToCppFunc, pyIn, cppOut);
+ if (!mayHaveImplicitConversion) {
+ s << pythonToCppCall << ';' << endl;
+ return;
+ }
+
+ if (!defaultValue.isEmpty())
+ s << '{' << endl << INDENT;
+
+ s << "if (Shiboken::Conversions::isImplicitConversion(reinterpret_cast<const SbkObjectType *>("
+ << cpythonTypeNameExt(type) << "), " << pythonToCppFunc << "))" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << pythonToCppFunc << '(' << pyIn << ", &" << cppOutAux << ");" << endl;
+ }
+ s << INDENT << "else" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << pythonToCppCall << ';' << endl;
+ }
+
+ if (!defaultValue.isEmpty())
+ s << INDENT << '}';
+ s << endl;
+}
+
+static void addConversionRuleCodeSnippet(CodeSnipList& snippetList, QString& rule,
+ TypeSystem::Language /* conversionLanguage */,
+ TypeSystem::Language snippetLanguage,
+ QString outputName = QString(),
+ QString inputName = QString())
+{
+ if (rule.isEmpty())
+ return;
+ if (snippetLanguage == TypeSystem::TargetLangCode) {
+ rule.replace(QLatin1String("%in"), inputName);
+ rule.replace(QLatin1String("%out"), outputName + QLatin1String("_out"));
+ } else {
+ rule.replace(QLatin1String("%out"), outputName);
+ }
+ CodeSnip snip(0, snippetLanguage);
+ snip.position = (snippetLanguage == TypeSystem::NativeCode) ? TypeSystem::CodeSnipPositionAny : TypeSystem::CodeSnipPositionBeginning;
+ snip.addCode(rule);
+ snippetList << snip;
+}
+
+void CppGenerator::writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language)
+{
+ CodeSnipList snippets;
+ foreach (AbstractMetaArgument* arg, func->arguments()) {
+ QString rule = func->conversionRule(language, arg->argumentIndex() + 1);
+ addConversionRuleCodeSnippet(snippets, rule, language, TypeSystem::TargetLangCode,
+ arg->name(), arg->name());
+ }
+ writeCodeSnips(s, snippets, TypeSystem::CodeSnipPositionBeginning, TypeSystem::TargetLangCode, func);
+}
+
+void CppGenerator::writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language, const QString& outputVar)
+{
+ CodeSnipList snippets;
+ QString rule = func->conversionRule(language, 0);
+ addConversionRuleCodeSnippet(snippets, rule, language, language, outputVar);
+ writeCodeSnips(s, snippets, TypeSystem::CodeSnipPositionAny, language, func);
+}
+
+void CppGenerator::writeNoneReturn(QTextStream& s, const AbstractMetaFunction* func, bool thereIsReturnValue)
+{
+ if (thereIsReturnValue && (!func->type() || func->argumentRemoved(0)) && !injectedCodeHasReturnValueAttribution(func)) {
+ s << INDENT << PYTHON_RETURN_VAR " = Py_None;" << endl;
+ s << INDENT << "Py_INCREF(Py_None);" << endl;
+ }
+}
+
+void CppGenerator::writeOverloadedFunctionDecisor(QTextStream& s, const OverloadData& overloadData)
+{
+ s << INDENT << "// Overloaded function decisor" << endl;
+ const AbstractMetaFunction* rfunc = overloadData.referenceFunction();
+ QList<const AbstractMetaFunction*> functionOverloads = overloadData.overloadsWithoutRepetition();
+ for (int i = 0; i < functionOverloads.count(); i++)
+ s << INDENT << "// " << i << ": " << functionOverloads.at(i)->minimalSignature() << endl;
+ writeOverloadedFunctionDecisorEngine(s, &overloadData);
+ s << endl;
+
+ // Ensure that the direct overload that called this reverse
+ // is called.
+ if (rfunc->isOperatorOverload() && !rfunc->isCallOperator()) {
+ s << INDENT << "if (isReverse && overloadId == -1) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyErr_SetString(PyExc_NotImplementedError, \"reverse operator not implemented.\");" << endl;
+ s << INDENT << "return 0;" << endl;
+ }
+ s << INDENT << "}" << endl << endl;
+ }
+
+ s << INDENT << "// Function signature not found." << endl;
+ s << INDENT << "if (overloadId == -1) goto " << cpythonFunctionName(overloadData.referenceFunction()) << "_TypeError;" << endl;
+ s << endl;
+}
+
+void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream& s, const OverloadData* parentOverloadData)
+{
+ bool hasDefaultCall = parentOverloadData->nextArgumentHasDefaultValue();
+ const AbstractMetaFunction* referenceFunction = parentOverloadData->referenceFunction();
+
+ // If the next argument has not an argument with a default value, it is still possible
+ // that one of the overloads for the current overload data has its final occurrence here.
+ // If found, the final occurrence of a method is attributed to the referenceFunction
+ // variable to be used further on this method on the conditional that identifies default
+ // method calls.
+ if (!hasDefaultCall) {
+ foreach (const AbstractMetaFunction* func, parentOverloadData->overloads()) {
+ if (parentOverloadData->isFinalOccurrence(func)) {
+ referenceFunction = func;
+ hasDefaultCall = true;
+ break;
+ }
+ }
+ }
+
+ int maxArgs = parentOverloadData->maxArgs();
+ // Python constructors always receive multiple arguments.
+ bool usePyArgs = pythonFunctionWrapperUsesListOfArguments(*parentOverloadData);
+
+ // Functions without arguments are identified right away.
+ if (maxArgs == 0) {
+ s << INDENT << "overloadId = " << parentOverloadData->headOverloadData()->overloads().indexOf(referenceFunction);
+ s << "; // " << referenceFunction->minimalSignature() << endl;
+ return;
+
+ // To decide if a method call is possible at this point the current overload
+ // data object cannot be the head, since it is just an entry point, or a root,
+ // for the tree of arguments and it does not represent a valid method call.
+ } else if (!parentOverloadData->isHeadOverloadData()) {
+ bool isLastArgument = parentOverloadData->nextOverloadData().isEmpty();
+ bool signatureFound = parentOverloadData->overloads().size() == 1;
+
+ // The current overload data describes the last argument of a signature,
+ // so the method can be identified right now.
+ if (isLastArgument || (signatureFound && !hasDefaultCall)) {
+ const AbstractMetaFunction* func = parentOverloadData->referenceFunction();
+ s << INDENT << "overloadId = " << parentOverloadData->headOverloadData()->overloads().indexOf(func);
+ s << "; // " << func->minimalSignature() << endl;
+ return;
+ }
+ }
+
+ bool isFirst = true;
+
+ // If the next argument has a default value the decisor can perform a method call;
+ // it just need to check if the number of arguments received from Python are equal
+ // to the number of parameters preceding the argument with the default value.
+ if (hasDefaultCall) {
+ isFirst = false;
+ int numArgs = parentOverloadData->argPos() + 1;
+ s << INDENT << "if (numArgs == " << numArgs << ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ const AbstractMetaFunction* func = referenceFunction;
+ foreach (OverloadData* overloadData, parentOverloadData->nextOverloadData()) {
+ const AbstractMetaFunction* defValFunc = overloadData->getFunctionWithDefaultValue();
+ if (defValFunc) {
+ func = defValFunc;
+ break;
+ }
+ }
+ s << INDENT << "overloadId = " << parentOverloadData->headOverloadData()->overloads().indexOf(func);
+ s << "; // " << func->minimalSignature() << endl;
+ }
+ s << INDENT << '}';
+ }
+
+ foreach (OverloadData* overloadData, parentOverloadData->nextOverloadData()) {
+ bool signatureFound = overloadData->overloads().size() == 1
+ && !overloadData->getFunctionWithDefaultValue()
+ && !overloadData->findNextArgWithDefault();
+
+ const AbstractMetaFunction* refFunc = overloadData->referenceFunction();
+
+ QStringList typeChecks;
+ QString pyArgName = (usePyArgs && maxArgs > 1)
+ ? QString::fromLatin1(PYTHON_ARGS "[%1]").arg(overloadData->argPos())
+ : QLatin1String(PYTHON_ARG);
+ OverloadData* od = overloadData;
+ int startArg = od->argPos();
+ int sequenceArgCount = 0;
+ while (od && !od->argType()->isVarargs()) {
+ bool typeReplacedByPyObject = od->argumentTypeReplaced() == QLatin1String("PyObject");
+ if (!typeReplacedByPyObject) {
+ if (usePyArgs)
+ pyArgName = QString::fromLatin1(PYTHON_ARGS "[%1]").arg(od->argPos());
+ QString typeCheck;
+ QTextStream tck(&typeCheck);
+ const AbstractMetaFunction* func = od->referenceFunction();
+
+ if (func->isConstructor() && func->arguments().count() == 1) {
+ const AbstractMetaClass* ownerClass = func->ownerClass();
+ const ComplexTypeEntry* baseContainerType = ownerClass->typeEntry()->baseContainerType();
+ if (baseContainerType && baseContainerType == func->arguments().first()->type()->typeEntry() && isCopyable(ownerClass)) {
+ tck << '!' << cpythonCheckFunction(ownerClass->typeEntry()) << pyArgName << ')' << endl;
+ Indentation indent(INDENT);
+ tck << INDENT << "&& ";
+ }
+ }
+ writeTypeCheck(tck, od, pyArgName);
+ typeChecks << typeCheck;
+ }
+
+ sequenceArgCount++;
+
+ if (od->nextOverloadData().isEmpty()
+ || od->nextArgumentHasDefaultValue()
+ || od->nextOverloadData().size() != 1
+ || od->overloads().size() != od->nextOverloadData().first()->overloads().size()) {
+ overloadData = od;
+ od = 0;
+ } else {
+ od = od->nextOverloadData().first();
+ }
+ }
+
+ if (usePyArgs && signatureFound) {
+ AbstractMetaArgumentList args = refFunc->arguments();
+ int lastArgIsVarargs = (int) (args.size() > 1 && args.last()->type()->isVarargs());
+ int numArgs = args.size() - OverloadData::numberOfRemovedArguments(refFunc) - lastArgIsVarargs;
+ typeChecks.prepend(QString::fromLatin1("numArgs %1 %2").arg(lastArgIsVarargs ? QLatin1String(">=") : QLatin1String("==")).arg(numArgs));
+ } else if (sequenceArgCount > 1) {
+ typeChecks.prepend(QString::fromLatin1("numArgs >= %1").arg(startArg + sequenceArgCount));
+ } else if (refFunc->isOperatorOverload() && !refFunc->isCallOperator()) {
+ typeChecks.prepend(QString::fromLatin1("%1isReverse").arg(refFunc->isReverseOperator() ? QString() : QLatin1String("!")));
+ }
+
+ if (isFirst) {
+ isFirst = false;
+ s << INDENT;
+ } else {
+ s << " else ";
+ }
+ s << "if (";
+ if (typeChecks.isEmpty()) {
+ s << "true";
+ } else {
+ Indentation indent(INDENT);
+ QString separator;
+ QTextStream sep(&separator);
+ sep << endl << INDENT << "&& ";
+ s << typeChecks.join(separator);
+ }
+ s << ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ writeOverloadedFunctionDecisorEngine(s, overloadData);
+ }
+ s << INDENT << "}";
+ }
+ s << endl;
+}
+
+void CppGenerator::writeFunctionCalls(QTextStream &s, const OverloadData &overloadData,
+ GeneratorContext &context)
+{
+ QList<const AbstractMetaFunction*> overloads = overloadData.overloadsWithoutRepetition();
+ s << INDENT << "// Call function/method" << endl;
+ s << INDENT << (overloads.count() > 1 ? "switch (overloadId) " : "") << '{' << endl;
+ {
+ Indentation indent(INDENT);
+ if (overloads.count() == 1) {
+ writeSingleFunctionCall(s, overloadData, overloads.first(), context);
+ } else {
+ for (int i = 0; i < overloads.count(); i++) {
+ const AbstractMetaFunction* func = overloads.at(i);
+ s << INDENT << "case " << i << ": // " << func->signature() << endl;
+ s << INDENT << '{' << endl;
+ {
+ Indentation indent(INDENT);
+ writeSingleFunctionCall(s, overloadData, func, context);
+ s << INDENT << "break;" << endl;
+ }
+ s << INDENT << '}' << endl;
+ }
+ }
+ }
+ s << INDENT << '}' << endl;
+}
+
+void CppGenerator::writeSingleFunctionCall(QTextStream &s,
+ const OverloadData &overloadData,
+ const AbstractMetaFunction *func,
+ GeneratorContext &context)
+{
+ if (func->isDeprecated()) {
+ s << INDENT << "Shiboken::warning(PyExc_DeprecationWarning, 1, \"Function: '"
+ << func->signature().replace(QLatin1String("::"), QLatin1String("."))
+ << "' is marked as deprecated, please check the documentation for more information.\");" << endl;
+ }
+
+ if (func->functionType() == AbstractMetaFunction::EmptyFunction) {
+ s << INDENT << "PyErr_Format(PyExc_TypeError, \"%s is a private method.\", \""
+ << func->signature().replace(QLatin1String("::"), QLatin1String("."))
+ << "\");" << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ return;
+ }
+
+ bool usePyArgs = pythonFunctionWrapperUsesListOfArguments(overloadData);
+
+ // Handle named arguments.
+ writeNamedArgumentResolution(s, func, usePyArgs);
+
+ bool injectCodeCallsFunc = injectedCodeCallsCppFunction(func);
+ bool mayHaveUnunsedArguments = !func->isUserAdded() && func->hasInjectedCode() && injectCodeCallsFunc;
+ int removedArgs = 0;
+ for (int argIdx = 0; argIdx < func->arguments().count(); ++argIdx) {
+ bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode, argIdx + 1).isEmpty();
+ const AbstractMetaArgument* arg = func->arguments().at(argIdx);
+ if (func->argumentRemoved(argIdx + 1)) {
+ if (!arg->defaultValueExpression().isEmpty()) {
+ QString cppArgRemoved = QString::fromLatin1(CPP_ARG_REMOVED "%1").arg(argIdx);
+ s << INDENT << getFullTypeName(arg->type()) << ' ' << cppArgRemoved;
+ s << " = " << guessScopeForDefaultValue(func, arg) << ';' << endl;
+ writeUnusedVariableCast(s, cppArgRemoved);
+ } else if (!injectCodeCallsFunc && !func->isUserAdded() && !hasConversionRule) {
+ // When an argument is removed from a method signature and no other means of calling
+ // the method are provided (as with code injection) the generator must abort.
+ qFatal(qPrintable(QString::fromLatin1("No way to call '%1::%2' with the modifications described in the type system.")
+ .arg(func->ownerClass()->name(), func->signature())), NULL);
+ }
+ removedArgs++;
+ continue;
+ }
+ if (hasConversionRule)
+ continue;
+ const AbstractMetaType* argType = getArgumentType(func, argIdx + 1);
+ if (!argType || (mayHaveUnunsedArguments && !injectedCodeUsesArgument(func, argIdx)))
+ continue;
+ int argPos = argIdx - removedArgs;
+ QString argName = QString::fromLatin1(CPP_ARG"%1").arg(argPos);
+ QString pyArgName = usePyArgs ? QString::fromLatin1(PYTHON_ARGS "[%1]").arg(argPos) : QLatin1String(PYTHON_ARG);
+ QString defaultValue = guessScopeForDefaultValue(func, arg);
+ writeArgumentConversion(s, argType, argName, pyArgName, func->implementingClass(), defaultValue, func->isUserAdded());
+ }
+
+ s << endl;
+
+ int numRemovedArgs = OverloadData::numberOfRemovedArguments(func);
+
+ s << INDENT << "if (!PyErr_Occurred()) {" << endl;
+ {
+ Indentation indentation(INDENT);
+ writeMethodCall(s, func, context, func->arguments().size() - numRemovedArgs);
+ if (!func->isConstructor())
+ writeNoneReturn(s, func, overloadData.hasNonVoidReturnType());
+ }
+ s << INDENT << '}' << endl;
+}
+
+QString CppGenerator::cppToPythonFunctionName(const QString& sourceTypeName, QString targetTypeName)
+{
+ if (targetTypeName.isEmpty())
+ targetTypeName = sourceTypeName;
+ return QString::fromLatin1("%1_CppToPython_%2").arg(sourceTypeName, targetTypeName);
+}
+
+QString CppGenerator::pythonToCppFunctionName(const QString& sourceTypeName, const QString& targetTypeName)
+{
+ return QString::fromLatin1("%1_PythonToCpp_%2").arg(sourceTypeName, targetTypeName);
+}
+QString CppGenerator::pythonToCppFunctionName(const AbstractMetaType* sourceType, const AbstractMetaType* targetType)
+{
+ return pythonToCppFunctionName(fixedCppTypeName(sourceType), fixedCppTypeName(targetType));
+}
+QString CppGenerator::pythonToCppFunctionName(const CustomConversion::TargetToNativeConversion* toNative,
+ const TypeEntry* targetType)
+{
+ return pythonToCppFunctionName(fixedCppTypeName(toNative), fixedCppTypeName(targetType));
+}
+
+QString CppGenerator::convertibleToCppFunctionName(const QString& sourceTypeName, const QString& targetTypeName)
+{
+ return QString::fromLatin1("is_%1_PythonToCpp_%2_Convertible").arg(sourceTypeName, targetTypeName);
+}
+QString CppGenerator::convertibleToCppFunctionName(const AbstractMetaType* sourceType, const AbstractMetaType* targetType)
+{
+ return convertibleToCppFunctionName(fixedCppTypeName(sourceType), fixedCppTypeName(targetType));
+}
+QString CppGenerator::convertibleToCppFunctionName(const CustomConversion::TargetToNativeConversion* toNative,
+ const TypeEntry* targetType)
+{
+ return convertibleToCppFunctionName(fixedCppTypeName(toNative), fixedCppTypeName(targetType));
+}
+
+void CppGenerator::writeCppToPythonFunction(QTextStream& s, const QString& code, const QString& sourceTypeName, QString targetTypeName)
+{
+ QString prettyCode;
+ QTextStream c(&prettyCode);
+ formatCode(c, code, INDENT);
+ processCodeSnip(prettyCode);
+
+ s << "static PyObject* " << cppToPythonFunctionName(sourceTypeName, targetTypeName);
+ s << "(const void* cppIn) {" << endl;
+ s << prettyCode;
+ s << '}' << endl;
+}
+
+static void replaceCppToPythonVariables(QString& code, const QString& typeName)
+{
+ code.prepend(QString::fromLatin1("%1& cppInRef = *((%1*)cppIn);\n").arg(typeName));
+ code.replace(QLatin1String("%INTYPE"), typeName);
+ code.replace(QLatin1String("%OUTTYPE"), QLatin1String("PyObject*"));
+ code.replace(QLatin1String("%in"), QLatin1String("cppInRef"));
+ code.replace(QLatin1String("%out"), QLatin1String("pyOut"));
+}
+void CppGenerator::writeCppToPythonFunction(QTextStream& s, const CustomConversion* customConversion)
+{
+ QString code = customConversion->nativeToTargetConversion();
+ replaceCppToPythonVariables(code, getFullTypeName(customConversion->ownerType()));
+ writeCppToPythonFunction(s, code, fixedCppTypeName(customConversion->ownerType()));
+}
+void CppGenerator::writeCppToPythonFunction(QTextStream& s, const AbstractMetaType* containerType)
+{
+ const CustomConversion* customConversion = containerType->typeEntry()->customConversion();
+ if (!customConversion) {
+ qFatal(qPrintable(QString::fromLatin1("Can't write the C++ to Python conversion function for container type '%1' - "\
+ "no conversion rule was defined for it in the type system.")
+ .arg(containerType->typeEntry()->qualifiedCppName())), NULL);
+ }
+ if (!containerType->typeEntry()->isContainer()) {
+ writeCppToPythonFunction(s, customConversion);
+ return;
+ }
+ QString code = customConversion->nativeToTargetConversion();
+ for (int i = 0; i < containerType->instantiations().count(); ++i) {
+ AbstractMetaType* type = containerType->instantiations().at(i);
+ QString typeName = getFullTypeName(type);
+ if (type->isConstant())
+ typeName = QLatin1String("const ") + typeName;
+ code.replace(QString::fromLatin1("%INTYPE_%1").arg(i), typeName);
+ }
+ replaceCppToPythonVariables(code, getFullTypeNameWithoutModifiers(containerType));
+ processCodeSnip(code);
+ writeCppToPythonFunction(s, code, fixedCppTypeName(containerType));
+}
+
+void CppGenerator::writePythonToCppFunction(QTextStream& s, const QString& code, const QString& sourceTypeName, const QString& targetTypeName)
+{
+ QString prettyCode;
+ QTextStream c(&prettyCode);
+ formatCode(c, code, INDENT);
+ processCodeSnip(prettyCode);
+ s << "static void " << pythonToCppFunctionName(sourceTypeName, targetTypeName);
+ s << "(PyObject* pyIn, void* cppOut) {" << endl;
+ s << prettyCode;
+ s << '}' << endl;
+}
+
+void CppGenerator::writeIsPythonConvertibleToCppFunction(QTextStream& s,
+ const QString& sourceTypeName,
+ const QString& targetTypeName,
+ const QString& condition,
+ QString pythonToCppFuncName,
+ bool acceptNoneAsCppNull)
+{
+ if (pythonToCppFuncName.isEmpty())
+ pythonToCppFuncName = pythonToCppFunctionName(sourceTypeName, targetTypeName);
+
+ s << "static PythonToCppFunc " << convertibleToCppFunctionName(sourceTypeName, targetTypeName);
+ s << "(PyObject* pyIn) {" << endl;
+ if (acceptNoneAsCppNull) {
+ s << INDENT << "if (pyIn == Py_None)" << endl;
+ Indentation indent(INDENT);
+ s << INDENT << "return Shiboken::Conversions::nonePythonToCppNullPtr;" << endl;
+ }
+ s << INDENT << "if (" << condition << ')' << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return " << pythonToCppFuncName << ';' << endl;
+ }
+ s << INDENT << "return 0;" << endl;
+ s << '}' << endl;
+}
+
+void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s,
+ const AbstractMetaType* sourceType,
+ const AbstractMetaType* targetType,
+ QString typeCheck,
+ QString conversion,
+ QString preConversion)
+{
+ QString sourcePyType = cpythonTypeNameExt(sourceType);
+
+ // Python to C++ conversion function.
+ QString code;
+ QTextStream c(&code);
+ if (conversion.isEmpty())
+ conversion = QLatin1Char('*') + cpythonWrapperCPtr(sourceType->typeEntry(), QLatin1String("pyIn"));
+ if (!preConversion.isEmpty())
+ c << INDENT << preConversion << endl;
+ c << INDENT << QString::fromLatin1("*((%1*)cppOut) = %1(%2);")
+ .arg(getFullTypeName(targetType->typeEntry()), conversion);
+ QString sourceTypeName = fixedCppTypeName(sourceType);
+ QString targetTypeName = fixedCppTypeName(targetType);
+ writePythonToCppFunction(s, code, sourceTypeName, targetTypeName);
+
+ // Python to C++ convertible check function.
+ if (typeCheck.isEmpty())
+ typeCheck = QString::fromLatin1("PyObject_TypeCheck(pyIn, %1)").arg(sourcePyType);
+ writeIsPythonConvertibleToCppFunction(s, sourceTypeName, targetTypeName, typeCheck);
+ s << endl;
+}
+
+void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s,
+ const CustomConversion::TargetToNativeConversion* toNative,
+ const TypeEntry* targetType)
+{
+ // Python to C++ conversion function.
+ QString code = toNative->conversion();
+ QString inType;
+ if (toNative->sourceType())
+ inType = cpythonTypeNameExt(toNative->sourceType());
+ else
+ inType = QString::fromLatin1("(&%1_Type)").arg(toNative->sourceTypeName());
+ code.replace(QLatin1String("%INTYPE"), inType);
+ code.replace(QLatin1String("%OUTTYPE"), targetType->qualifiedCppName());
+ code.replace(QLatin1String("%in"), QLatin1String("pyIn"));
+ code.replace(QLatin1String("%out"), QString::fromLatin1("*((%1*)cppOut)").arg(getFullTypeName(targetType)));
+
+ QString sourceTypeName = fixedCppTypeName(toNative);
+ QString targetTypeName = fixedCppTypeName(targetType);
+ writePythonToCppFunction(s, code, sourceTypeName, targetTypeName);
+
+ // Python to C++ convertible check function.
+ QString typeCheck = toNative->sourceTypeCheck();
+ if (typeCheck.isEmpty()) {
+ QString pyTypeName = toNative->sourceTypeName();
+ if (pyTypeName == QLatin1String("Py_None") || pyTypeName == QLatin1String("PyNone"))
+ typeCheck = QLatin1String("%in == Py_None");
+ else if (pyTypeName == QLatin1String("SbkEnumType"))
+ typeCheck = QLatin1String("Shiboken::isShibokenEnum(%in)");
+ else if (pyTypeName == QLatin1String("SbkObject"))
+ typeCheck = QLatin1String("Shiboken::Object::checkType(%in)");
+ else if (pyTypeName == QLatin1String("PyTypeObject"))
+ typeCheck = QLatin1String("PyType_Check(%in)");
+ else if (pyTypeName == QLatin1String("PyObject"))
+ typeCheck = QLatin1String("PyObject_TypeCheck(%in, &PyBaseObject_Type)");
+ else if (pyTypeName.startsWith(QLatin1String("Py")))
+ typeCheck = pyTypeName + QLatin1String("_Check(%in)");
+ }
+ if (typeCheck.isEmpty()) {
+ if (!toNative->sourceType() || toNative->sourceType()->isPrimitive()) {
+ qFatal(qPrintable(QString::fromLatin1("User added implicit conversion for C++ type '%1' must provide either an input "\
+ "type check function or a non primitive type entry.")
+ .arg(targetType->qualifiedCppName())), NULL);
+
+ }
+ typeCheck = QString::fromLatin1("PyObject_TypeCheck(%in, %1)").arg(cpythonTypeNameExt(toNative->sourceType()));
+ }
+ typeCheck.replace(QLatin1String("%in"), QLatin1String("pyIn"));
+ processCodeSnip(typeCheck);
+ writeIsPythonConvertibleToCppFunction(s, sourceTypeName, targetTypeName, typeCheck);
+}
+
+void CppGenerator::writePythonToCppConversionFunctions(QTextStream& s, const AbstractMetaType* containerType)
+{
+ const CustomConversion* customConversion = containerType->typeEntry()->customConversion();
+ if (!customConversion) {
+ //qFatal
+ return;
+ }
+ const CustomConversion::TargetToNativeConversions& toCppConversions = customConversion->targetToNativeConversions();
+ if (toCppConversions.isEmpty()) {
+ //qFatal
+ return;
+ }
+ // Python to C++ conversion function.
+ QString cppTypeName = getFullTypeNameWithoutModifiers(containerType);
+ QString code;
+ QTextStream c(&code);
+ c << INDENT << QString::fromLatin1("%1& cppOutRef = *((%1*)cppOut);").arg(cppTypeName) << endl;
+ code.append(toCppConversions.first()->conversion());
+ for (int i = 0; i < containerType->instantiations().count(); ++i) {
+ const AbstractMetaType* type = containerType->instantiations().at(i);
+ QString typeName = getFullTypeName(type);
+ if (type->isValue() && isValueTypeWithCopyConstructorOnly(type)) {
+ static QRegExp regex(QLatin1String(CONVERTTOCPP_REGEX));
+ int pos = 0;
+ while ((pos = regex.indexIn(code, pos)) != -1) {
+ pos += regex.matchedLength();
+ QStringList list = regex.capturedTexts();
+ QString varName = list.at(1);
+ QString leftCode = code.left(pos);
+ QString rightCode = code.mid(pos);
+ rightCode.replace(varName, QLatin1Char('*') + varName);
+ code = leftCode + rightCode;
+ }
+ typeName.append(QLatin1Char('*'));
+ }
+ code.replace(QString::fromLatin1("%OUTTYPE_%1").arg(i), typeName);
+ }
+ code.replace(QLatin1String("%OUTTYPE"), cppTypeName);
+ code.replace(QLatin1String("%in"), QLatin1String("pyIn"));
+ code.replace(QLatin1String("%out"), QLatin1String("cppOutRef"));
+ QString typeName = fixedCppTypeName(containerType);
+ writePythonToCppFunction(s, code, typeName, typeName);
+
+ // Python to C++ convertible check function.
+ QString typeCheck = cpythonCheckFunction(containerType);
+ if (typeCheck.isEmpty())
+ typeCheck = QLatin1String("false");
+ else
+ typeCheck = QString::fromLatin1("%1pyIn)").arg(typeCheck);
+ writeIsPythonConvertibleToCppFunction(s, typeName, typeName, typeCheck);
+ s << endl;
+}
+
+void CppGenerator::writeAddPythonToCppConversion(QTextStream& s, const QString& converterVar, const QString& pythonToCppFunc, const QString& isConvertibleFunc)
+{
+ s << INDENT << "Shiboken::Conversions::addPythonToCppValueConversion(" << converterVar << ',' << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << pythonToCppFunc << ',' << endl;
+ s << INDENT << isConvertibleFunc;
+ }
+ s << ");" << endl;
+}
+
+void CppGenerator::writeNamedArgumentResolution(QTextStream& s, const AbstractMetaFunction* func, bool usePyArgs)
+{
+ AbstractMetaArgumentList args = OverloadData::getArgumentsWithDefaultValues(func);
+ if (args.isEmpty())
+ return;
+
+ QString pyErrString(QLatin1String("PyErr_SetString(PyExc_TypeError, \"") + fullPythonFunctionName(func)
+ + QLatin1String("(): got multiple values for keyword argument '%1'.\");"));
+
+ s << INDENT << "if (kwds) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyObject* ";
+ foreach (const AbstractMetaArgument* arg, args) {
+ int pyArgIndex = arg->argumentIndex() - OverloadData::numberOfRemovedArguments(func, arg->argumentIndex());
+ QString pyArgName = usePyArgs
+ ? QString::fromLatin1(PYTHON_ARGS "[%1]").arg(pyArgIndex)
+ : QLatin1String(PYTHON_ARG);
+ s << "value = PyDict_GetItemString(kwds, \"" << arg->name() << "\");" << endl;
+ s << INDENT << "if (value && " << pyArgName << ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << pyErrString.arg(arg->name()) << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ s << INDENT << "} else if (value) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << pyArgName << " = value;" << endl;
+ s << INDENT << "if (!";
+ writeTypeCheck(s, arg->type(), pyArgName, isNumber(arg->type()->typeEntry()), func->typeReplaced(arg->argumentIndex() + 1));
+ s << ')' << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "goto " << cpythonFunctionName(func) << "_TypeError;" << endl;
+ }
+ }
+ s << INDENT << '}' << endl;
+ if (arg != args.last())
+ s << INDENT;
+ }
+ }
+ s << INDENT << '}' << endl;
+}
+
+QString CppGenerator::argumentNameFromIndex(const AbstractMetaFunction* func, int argIndex, const AbstractMetaClass** wrappedClass)
+{
+ *wrappedClass = 0;
+ QString pyArgName;
+ if (argIndex == -1) {
+ pyArgName = QLatin1String(PYTHON_SELF_VAR);
+ *wrappedClass = func->implementingClass();
+ } else if (argIndex == 0) {
+ AbstractMetaType *funcType = func->type();
+ AbstractMetaType *returnType = getTypeWithoutContainer(funcType);
+ if (returnType) {
+ pyArgName = QLatin1String(PYTHON_RETURN_VAR);
+ *wrappedClass = AbstractMetaClass::findClass(classes(), returnType->typeEntry()->name());
+ } else {
+ QString message = QLatin1String("Invalid Argument index (0, return value) on function modification: ")
+ + (funcType ? funcType->name() : QLatin1String("void")) + QLatin1Char(' ');
+ if (const AbstractMetaClass *declaringClass = func->declaringClass())
+ message += declaringClass->name() + QLatin1String("::");
+ message += func->name() + QLatin1String("()");
+ qCWarning(lcShiboken).noquote().nospace() << message;
+ }
+ } else {
+ int realIndex = argIndex - 1 - OverloadData::numberOfRemovedArguments(func, argIndex - 1);
+ AbstractMetaType* argType = getTypeWithoutContainer(func->arguments().at(realIndex)->type());
+
+ if (argType) {
+ *wrappedClass = AbstractMetaClass::findClass(classes(), argType->typeEntry()->name());
+ if (argIndex == 1
+ && !func->isConstructor()
+ && OverloadData::isSingleArgument(getFunctionGroups(func->implementingClass())[func->name()]))
+ pyArgName = QLatin1String(PYTHON_ARG);
+ else
+ pyArgName = QString::fromLatin1(PYTHON_ARGS "[%1]").arg(argIndex - 1);
+ }
+ }
+ return pyArgName;
+}
+
+void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *func,
+ GeneratorContext &context, int maxArgs)
+{
+ s << INDENT << "// " << func->minimalSignature() << (func->isReverseOperator() ? " [reverse operator]": "") << endl;
+ if (func->isConstructor()) {
+ foreach (const CodeSnip &cs, func->injectedCodeSnips()) {
+ if (cs.position == TypeSystem::CodeSnipPositionEnd) {
+ s << INDENT << "overloadId = " << func->ownerClass()->functions().indexOf(const_cast<AbstractMetaFunction* const>(func)) << ';' << endl;
+ break;
+ }
+ }
+ }
+
+ if (func->isAbstract()) {
+ s << INDENT << "if (Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject*>(" PYTHON_SELF_VAR "))) {\n";
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyErr_SetString(PyExc_NotImplementedError, \"pure virtual method '";
+ s << func->ownerClass()->name() << '.' << func->name() << "()' not implemented.\");" << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ s << INDENT << "}\n";
+ }
+
+ // Used to provide contextual information to custom code writer function.
+ const AbstractMetaArgument* lastArg = 0;
+
+ CodeSnipList snips;
+ if (func->hasInjectedCode()) {
+ snips = func->injectedCodeSnips();
+
+ // Find the last argument available in the method call to provide
+ // the injected code writer with information to avoid invalid replacements
+ // on the %# variable.
+ if (maxArgs > 0 && maxArgs < func->arguments().size() - OverloadData::numberOfRemovedArguments(func)) {
+ int removedArgs = 0;
+ for (int i = 0; i < maxArgs + removedArgs; i++) {
+ lastArg = func->arguments().at(i);
+ if (func->argumentRemoved(i + 1))
+ removedArgs++;
+ }
+ } else if (maxArgs != 0 && !func->arguments().isEmpty()) {
+ lastArg = func->arguments().last();
+ }
+
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::TargetLangCode, func, lastArg);
+ s << endl;
+ }
+
+ writeConversionRule(s, func, TypeSystem::NativeCode);
+
+ if (!func->isUserAdded()) {
+ QStringList userArgs;
+ if (func->functionType() != AbstractMetaFunction::CopyConstructorFunction) {
+ int removedArgs = 0;
+ for (int i = 0; i < maxArgs + removedArgs; i++) {
+ const AbstractMetaArgument* arg = func->arguments().at(i);
+ bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode, arg->argumentIndex() + 1).isEmpty();
+ if (func->argumentRemoved(i + 1)) {
+ // If some argument with default value is removed from a
+ // method signature, the said value must be explicitly
+ // added to the method call.
+ removedArgs++;
+
+ // If have conversion rules I will use this for removed args
+ if (hasConversionRule)
+ userArgs << arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
+ else if (!arg->defaultValueExpression().isEmpty())
+ userArgs << QString::fromLatin1(CPP_ARG_REMOVED "%1").arg(i);
+ } else {
+ int idx = arg->argumentIndex() - removedArgs;
+ bool deRef = isValueTypeWithCopyConstructorOnly(arg->type())
+ || isObjectTypeUsedAsValueType(arg->type())
+ || (arg->type()->referenceType() == LValueReference && isWrapperType(arg->type()) && !isPointer(arg->type()));
+ QString argName = hasConversionRule
+ ? arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX)
+ : QString::fromLatin1("%1" CPP_ARG "%2").arg(deRef ? QLatin1String("*") : QString()).arg(idx);
+ userArgs << argName;
+ }
+ }
+
+ // If any argument's default value was modified the method must be called
+ // with this new value whenever the user doesn't pass an explicit value to it.
+ // Also, any unmodified default value coming after the last user specified
+ // argument and before the modified argument must be explicitly stated.
+ QStringList otherArgs;
+ bool otherArgsModified = false;
+ bool argsClear = true;
+ for (int i = func->arguments().size() - 1; i >= maxArgs + removedArgs; i--) {
+ const AbstractMetaArgument* arg = func->arguments().at(i);
+ bool defValModified = arg->defaultValueExpression() != arg->originalDefaultValueExpression();
+ bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode, arg->argumentIndex() + 1).isEmpty();
+ if (argsClear && !defValModified && !hasConversionRule)
+ continue;
+ else
+ argsClear = false;
+ otherArgsModified |= defValModified || hasConversionRule || func->argumentRemoved(i + 1);
+ if (hasConversionRule)
+ otherArgs.prepend(arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX));
+ else
+ otherArgs.prepend(QString::fromLatin1(CPP_ARG_REMOVED "%1").arg(i));
+ }
+ if (otherArgsModified)
+ userArgs << otherArgs;
+ }
+
+ bool isCtor = false;
+ QString methodCall;
+ QTextStream mc(&methodCall);
+ QString useVAddr;
+ QTextStream uva(&useVAddr);
+ if (func->isOperatorOverload() && !func->isCallOperator()) {
+ QString firstArg = QLatin1String("(*" CPP_SELF_VAR ")");
+ if (func->isPointerOperator())
+ firstArg.remove(1, 1); // remove the de-reference operator
+
+ QString secondArg = QLatin1String(CPP_ARG0);
+ if (!func->isUnaryOperator() && shouldDereferenceArgumentPointer(func->arguments().first())) {
+ secondArg.prepend(QLatin1String("(*"));
+ secondArg.append(QLatin1Char(')'));
+ }
+
+ if (func->isUnaryOperator())
+ std::swap(firstArg, secondArg);
+
+ QString op = func->originalName();
+ op = op.right(op.size() - (sizeof("operator")/sizeof(char)-1));
+
+ if (func->isBinaryOperator()) {
+ if (func->isReverseOperator())
+ std::swap(firstArg, secondArg);
+
+ if (((op == QLatin1String("++")) || (op == QLatin1String("--"))) && !func->isReverseOperator()) {
+ s << endl << INDENT << "for(int i=0; i < " << secondArg << "; i++, " << firstArg << op << ");" << endl;
+ mc << firstArg;
+ } else {
+ mc << firstArg << ' ' << op << ' ' << secondArg;
+ }
+ } else {
+ mc << op << ' ' << secondArg;
+ }
+ } else if (!injectedCodeCallsCppFunction(func)) {
+ if (func->isConstructor()) {
+ isCtor = true;
+ QString className = wrapperName(func->ownerClass());
+
+ if (func->functionType() == AbstractMetaFunction::CopyConstructorFunction && maxArgs == 1) {
+ mc << "new ::" << className << "(*" << CPP_ARG0 << ')';
+ } else {
+ QString ctorCall = className + QLatin1Char('(') + userArgs.join(QLatin1String(", ")) + QLatin1Char(')');
+ if (usePySideExtensions() && func->ownerClass()->isQObject()) {
+ s << INDENT << "void* addr = PySide::nextQObjectMemoryAddr();" << endl;
+ uva << "if (addr) {" << endl;
+ {
+ Indentation indent(INDENT);
+
+ uva << INDENT << "cptr = " << "new (addr) ::"
+ << ctorCall << ';' << endl
+ << INDENT
+ << "PySide::setNextQObjectMemoryAddr(0);"
+ << endl;
+ }
+ uva << INDENT << "} else {" << endl;
+ {
+ Indentation indent(INDENT);
+
+ uva << INDENT << "cptr = " << "new ::"
+ << ctorCall << ';' << endl;
+ }
+ uva << INDENT << "}" << endl;
+ } else {
+ mc << "new ::" << ctorCall;
+ }
+ }
+ } else {
+ QString methodCallClassName;
+ if (context.forSmartPointer())
+ methodCallClassName = context.preciseType()->cppSignature();
+ else if (func->ownerClass())
+ methodCallClassName = func->ownerClass()->qualifiedCppName();
+
+ if (func->ownerClass()) {
+ if (!avoidProtectedHack() || !func->isProtected()) {
+ if (func->isStatic()) {
+ mc << "::" << methodCallClassName << "::";
+ } else {
+ const QString selfVarCast = func->ownerClass() == func->implementingClass()
+ ? QLatin1String(CPP_SELF_VAR)
+ : QLatin1String("reinterpret_cast<") + methodCallClassName + QLatin1String(" *>(" CPP_SELF_VAR ")");
+ if (func->isConstant()) {
+ if (avoidProtectedHack()) {
+ mc << "const_cast<const ::";
+ if (func->ownerClass()->hasProtectedMembers()) {
+ // PYSIDE-500: Need a special wrapper cast when inherited
+ const QString selfWrapCast = func->ownerClass() == func->implementingClass()
+ ? QLatin1String(CPP_SELF_VAR)
+ : QLatin1String("reinterpret_cast<") + wrapperName(func->ownerClass()) + QLatin1String(" *>(" CPP_SELF_VAR ")");
+ mc << wrapperName(func->ownerClass());
+ mc << "*>(" << selfWrapCast << ")->";
+ }
+ else {
+ mc << methodCallClassName;
+ mc << "*>(" << selfVarCast << ")->";
+ }
+ } else {
+ mc << "const_cast<const ::" << methodCallClassName;
+ mc << "*>(" << selfVarCast << ")->";
+ }
+ } else {
+ mc << selfVarCast << "->";
+ }
+ }
+
+ if (!func->isAbstract() && func->isVirtual())
+ mc << "::%CLASS_NAME::";
+
+ mc << func->originalName();
+ } else {
+ if (!func->isStatic())
+ mc << "((::" << wrapperName(func->ownerClass()) << "*) " << CPP_SELF_VAR << ")->";
+
+ if (!func->isAbstract())
+ mc << (func->isProtected() ? wrapperName(func->ownerClass()) :
+ QLatin1String("::")
+ + methodCallClassName) << "::";
+ mc << func->originalName() << "_protected";
+ }
+ } else {
+ mc << func->originalName();
+ }
+ mc << '(' << userArgs.join(QLatin1String(", ")) << ')';
+ if (!func->isAbstract() && func->isVirtual()) {
+ mc.flush();
+ if (!avoidProtectedHack() || !func->isProtected()) {
+ QString virtualCall(methodCall);
+ QString normalCall(methodCall);
+ virtualCall = virtualCall.replace(QLatin1String("%CLASS_NAME"),
+ methodCallClassName);
+ normalCall.remove(QLatin1String("::%CLASS_NAME::"));
+ methodCall.clear();
+ mc << "Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject*>(" PYTHON_SELF_VAR ")) ? ";
+ mc << virtualCall << " : " << normalCall;
+ }
+ }
+ }
+ }
+
+ if (!injectedCodeCallsCppFunction(func)) {
+ s << INDENT << BEGIN_ALLOW_THREADS << endl << INDENT;
+ if (isCtor) {
+ s << (useVAddr.isEmpty() ?
+ QString::fromLatin1("cptr = %1;").arg(methodCall) : useVAddr) << endl;
+ } else if (func->type() && !func->isInplaceOperator()) {
+ bool writeReturnType = true;
+ if (avoidProtectedHack()) {
+ const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(func->type());
+ if (metaEnum) {
+ QString enumName;
+ if (metaEnum->isProtected())
+ enumName = protectedEnumSurrogateName(metaEnum);
+ else
+ enumName = func->type()->cppSignature();
+ methodCall.prepend(enumName + QLatin1Char('('));
+ methodCall.append(QLatin1Char(')'));
+ s << enumName;
+ writeReturnType = false;
+ }
+ }
+ if (writeReturnType) {
+ s << func->type()->cppSignature();
+ if (isObjectTypeUsedAsValueType(func->type())) {
+ s << '*';
+ methodCall.prepend(QString::fromLatin1("new %1(").arg(func->type()->typeEntry()->qualifiedCppName()));
+ methodCall.append(QLatin1Char(')'));
+ }
+ }
+ s << " " CPP_RETURN_VAR " = ";
+ s << methodCall << ';' << endl;
+ } else {
+ s << methodCall << ';' << endl;
+ }
+ s << INDENT << END_ALLOW_THREADS << endl;
+
+ if (!func->conversionRule(TypeSystem::TargetLangCode, 0).isEmpty()) {
+ writeConversionRule(s, func, TypeSystem::TargetLangCode, QLatin1String(PYTHON_RETURN_VAR));
+ } else if (!isCtor && !func->isInplaceOperator() && func->type()
+ && !injectedCodeHasReturnValueAttribution(func, TypeSystem::TargetLangCode)) {
+ s << INDENT << PYTHON_RETURN_VAR " = ";
+ if (isObjectTypeUsedAsValueType(func->type())) {
+ s << "Shiboken::Object::newObject(reinterpret_cast<SbkObjectType *>(" << cpythonTypeNameExt(func->type()->typeEntry())
+ << "), " << CPP_RETURN_VAR << ", true, true)";
+ } else {
+ writeToPythonConversion(s, func->type(), func->ownerClass(), QLatin1String(CPP_RETURN_VAR));
+ }
+ s << ';' << endl;
+ }
+ }
+ }
+
+ if (func->hasInjectedCode() && !func->isConstructor()) {
+ s << endl;
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionEnd, TypeSystem::TargetLangCode, func, lastArg);
+ }
+
+ bool hasReturnPolicy = false;
+
+ // Ownership transference between C++ and Python.
+ QList<ArgumentModification> ownership_mods;
+ // Python object reference management.
+ QList<ArgumentModification> refcount_mods;
+ foreach (const FunctionModification &func_mod, func->modifications()) {
+ foreach (const ArgumentModification &arg_mod, func_mod.argument_mods) {
+ if (!arg_mod.ownerships.isEmpty() && arg_mod.ownerships.contains(TypeSystem::TargetLangCode))
+ ownership_mods.append(arg_mod);
+ else if (!arg_mod.referenceCounts.isEmpty())
+ refcount_mods.append(arg_mod);
+ }
+ }
+
+ // If there's already a setParent(return, me), don't use the return heuristic!
+ if (func->argumentOwner(func->ownerClass(), -1).index == 0)
+ hasReturnPolicy = true;
+
+ if (!ownership_mods.isEmpty()) {
+ s << endl << INDENT << "// Ownership transferences." << endl;
+ foreach (const ArgumentModification &arg_mod, ownership_mods) {
+ const AbstractMetaClass* wrappedClass = 0;
+ QString pyArgName = argumentNameFromIndex(func, arg_mod.index, &wrappedClass);
+ if (!wrappedClass) {
+ s << "#error Invalid ownership modification for argument " << arg_mod.index << '(' << pyArgName << ')' << endl << endl;
+ break;
+ }
+
+ if (arg_mod.index == 0 || arg_mod.owner.index == 0)
+ hasReturnPolicy = true;
+
+ // The default ownership does nothing. This is useful to avoid automatic heuristically
+ // based generation of code defining parenting.
+ if (arg_mod.ownerships[TypeSystem::TargetLangCode] == TypeSystem::DefaultOwnership)
+ continue;
+
+ s << INDENT << "Shiboken::Object::";
+ if (arg_mod.ownerships[TypeSystem::TargetLangCode] == TypeSystem::TargetLangOwnership) {
+ s << "getOwnership(" << pyArgName << ");";
+ } else if (wrappedClass->hasVirtualDestructor()) {
+ if (arg_mod.index == 0)
+ s << "releaseOwnership(" PYTHON_RETURN_VAR ");";
+ else
+ s << "releaseOwnership(" << pyArgName << ");";
+ } else {
+ s << "invalidate(" << pyArgName << ");";
+ }
+ s << endl;
+ }
+
+ } else if (!refcount_mods.isEmpty()) {
+ foreach (const ArgumentModification &arg_mod, refcount_mods) {
+ ReferenceCount refCount = arg_mod.referenceCounts.first();
+ if (refCount.action != ReferenceCount::Set
+ && refCount.action != ReferenceCount::Remove
+ && refCount.action != ReferenceCount::Add) {
+ qCWarning(lcShiboken) << "\"set\", \"add\" and \"remove\" are the only values supported by Shiboken for action attribute of reference-count tag.";
+ continue;
+ }
+ const AbstractMetaClass* wrappedClass = 0;
+
+ QString pyArgName;
+ if (refCount.action == ReferenceCount::Remove) {
+ pyArgName = QLatin1String("Py_None");
+ } else {
+ pyArgName = argumentNameFromIndex(func, arg_mod.index, &wrappedClass);
+ if (pyArgName.isEmpty()) {
+ s << "#error Invalid reference count modification for argument " << arg_mod.index << endl << endl;
+ break;
+ }
+ }
+
+ if (refCount.action == ReferenceCount::Add || refCount.action == ReferenceCount::Set)
+ s << INDENT << "Shiboken::Object::keepReference(";
+ else
+ s << INDENT << "Shiboken::Object::removeReference(";
+
+ s << "reinterpret_cast<SbkObject*>(" PYTHON_SELF_VAR "), \"";
+ QString varName = arg_mod.referenceCounts.first().varName;
+ if (varName.isEmpty())
+ varName = func->minimalSignature() + QString().number(arg_mod.index);
+
+ s << varName << "\", " << pyArgName
+ << (refCount.action == ReferenceCount::Add ? ", true" : "")
+ << ");" << endl;
+
+ if (arg_mod.index == 0)
+ hasReturnPolicy = true;
+ }
+ }
+ writeParentChildManagement(s, func, !hasReturnPolicy);
+}
+
+QStringList CppGenerator::getAncestorMultipleInheritance(const AbstractMetaClass* metaClass)
+{
+ QStringList result;
+ AbstractMetaClassList baseClases = getBaseClasses(metaClass);
+ if (!baseClases.isEmpty()) {
+ foreach (const AbstractMetaClass* baseClass, baseClases) {
+ result.append(QString::fromLatin1("((size_t) static_cast<const %1*>(class_ptr)) - base")
+ .arg(baseClass->qualifiedCppName()));
+ result.append(QString::fromLatin1("((size_t) static_cast<const %1*>((%2*)((void*)class_ptr))) - base")
+ .arg(baseClass->qualifiedCppName(), metaClass->qualifiedCppName()));
+ }
+ foreach (const AbstractMetaClass* baseClass, baseClases)
+ result.append(getAncestorMultipleInheritance(baseClass));
+ }
+ return result;
+}
+
+void CppGenerator::writeMultipleInheritanceInitializerFunction(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ QString className = metaClass->qualifiedCppName();
+ QStringList ancestors = getAncestorMultipleInheritance(metaClass);
+ s << "static int mi_offsets[] = { ";
+ for (int i = 0; i < ancestors.size(); i++)
+ s << "-1, ";
+ s << "-1 };" << endl;
+ s << "int*" << endl;
+ s << multipleInheritanceInitializerFunctionName(metaClass) << "(const void* cptr)" << endl;
+ s << '{' << endl;
+ s << INDENT << "if (mi_offsets[0] == -1) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "std::set<int> offsets;" << endl;
+ s << INDENT << "std::set<int>::iterator it;" << endl;
+ s << INDENT << "const " << className << "* class_ptr = reinterpret_cast<const " << className << "*>(cptr);" << endl;
+ s << INDENT << "size_t base = (size_t) class_ptr;" << endl;
+
+ foreach (const QString &ancestor, ancestors)
+ s << INDENT << "offsets.insert(" << ancestor << ");" << endl;
+
+ s << endl;
+ s << INDENT << "offsets.erase(0);" << endl;
+ s << endl;
+
+ s << INDENT << "int i = 0;" << endl;
+ s << INDENT << "for (it = offsets.begin(); it != offsets.end(); it++) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "mi_offsets[i] = *it;" << endl;
+ s << INDENT << "i++;" << endl;
+ }
+ s << INDENT << '}' << endl;
+ }
+ s << INDENT << '}' << endl;
+ s << INDENT << "return mi_offsets;" << endl;
+ s << '}' << endl;
+}
+
+void CppGenerator::writeSpecialCastFunction(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ QString className = metaClass->qualifiedCppName();
+ s << "static void* " << cpythonSpecialCastFunctionName(metaClass) << "(void* obj, SbkObjectType* desiredType)\n";
+ s << "{\n";
+ s << INDENT << className << "* me = reinterpret_cast< ::" << className << "*>(obj);\n";
+ bool firstClass = true;
+ foreach (const AbstractMetaClass* baseClass, getAllAncestors(metaClass)) {
+ s << INDENT << (!firstClass ? "else " : "") << "if (desiredType == reinterpret_cast<SbkObjectType*>(" << cpythonTypeNameExt(baseClass->typeEntry()) << "))\n";
+ Indentation indent(INDENT);
+ s << INDENT << "return static_cast< ::" << baseClass->qualifiedCppName() << "*>(me);\n";
+ firstClass = false;
+ }
+ s << INDENT << "return me;\n";
+ s << "}\n\n";
+}
+
+void CppGenerator::writePrimitiveConverterInitialization(QTextStream& s, const CustomConversion* customConversion)
+{
+ const TypeEntry* type = customConversion->ownerType();
+ QString converter = converterObject(type);
+ s << INDENT << "// Register converter for type '" << type->qualifiedTargetLangName() << "'." << endl;
+ s << INDENT << converter << " = Shiboken::Conversions::createConverter(";
+ if (type->targetLangApiName() == type->name())
+ s << '0';
+ else if (type->targetLangApiName() == QLatin1String("PyObject"))
+ s << "&PyBaseObject_Type";
+ else
+ s << '&' << type->targetLangApiName() << "_Type";
+ QString typeName = fixedCppTypeName(type);
+ s << ", " << cppToPythonFunctionName(typeName, typeName) << ");" << endl;
+ s << INDENT << "Shiboken::Conversions::registerConverterName(" << converter << ", \"" << type->qualifiedCppName() << "\");" << endl;
+ writeCustomConverterRegister(s, customConversion, converter);
+}
+
+void CppGenerator::writeEnumConverterInitialization(QTextStream& s, const AbstractMetaEnum* metaEnum)
+{
+ if (metaEnum->isPrivate() || metaEnum->isAnonymous())
+ return;
+ writeEnumConverterInitialization(s, metaEnum->typeEntry());
+}
+
+void CppGenerator::writeEnumConverterInitialization(QTextStream& s, const TypeEntry* enumType)
+{
+ if (!enumType)
+ return;
+ QString enumFlagName = enumType->isFlags() ? QLatin1String("flag") : QLatin1String("enum");
+ QString enumPythonType = cpythonTypeNameExt(enumType);
+
+ const FlagsTypeEntry* flags = 0;
+ if (enumType->isFlags())
+ flags = reinterpret_cast<const FlagsTypeEntry*>(enumType);
+
+ s << INDENT << "// Register converter for " << enumFlagName << " '" << enumType->qualifiedCppName() << "'." << endl;
+ s << INDENT << '{' << endl;
+ {
+ Indentation indent(INDENT);
+ QString typeName = fixedCppTypeName(enumType);
+ s << INDENT << "SbkConverter* converter = Shiboken::Conversions::createConverter(" << enumPythonType << ',' << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << cppToPythonFunctionName(typeName, typeName) << ");" << endl;
+ }
+
+ if (flags) {
+ QString enumTypeName = fixedCppTypeName(flags->originator());
+ QString toCpp = pythonToCppFunctionName(enumTypeName, typeName);
+ QString isConv = convertibleToCppFunctionName(enumTypeName, typeName);
+ writeAddPythonToCppConversion(s, QLatin1String("converter"), toCpp, isConv);
+ }
+
+ QString toCpp = pythonToCppFunctionName(typeName, typeName);
+ QString isConv = convertibleToCppFunctionName(typeName, typeName);
+ writeAddPythonToCppConversion(s, QLatin1String("converter"), toCpp, isConv);
+
+ if (flags) {
+ QString toCpp = pythonToCppFunctionName(QLatin1String("number"), typeName);
+ QString isConv = convertibleToCppFunctionName(QLatin1String("number"), typeName);
+ writeAddPythonToCppConversion(s, QLatin1String("converter"), toCpp, isConv);
+ }
+
+ s << INDENT << "Shiboken::Enum::setTypeConverter(" << enumPythonType << ", converter);" << endl;
+ s << INDENT << "Shiboken::Enum::setTypeConverter(" << enumPythonType << ", converter);" << endl;
+ QStringList cppSignature = enumType->qualifiedCppName().split(QLatin1String("::"), QString::SkipEmptyParts);
+ while (!cppSignature.isEmpty()) {
+ QString signature = cppSignature.join(QLatin1String("::"));
+ s << INDENT << "Shiboken::Conversions::registerConverterName(converter, \"";
+ if (flags)
+ s << "QFlags<";
+ s << signature << "\");" << endl;
+ cppSignature.removeFirst();
+ }
+ }
+ s << INDENT << '}' << endl;
+
+ if (!flags)
+ writeEnumConverterInitialization(s, reinterpret_cast<const EnumTypeEntry*>(enumType)->flags());
+}
+
+void CppGenerator::writeContainerConverterInitialization(QTextStream& s, const AbstractMetaType* type)
+{
+ QByteArray cppSignature = QMetaObject::normalizedSignature(type->cppSignature().toUtf8());
+ s << INDENT << "// Register converter for type '" << cppSignature << "'." << endl;
+ QString converter = converterObject(type);
+ s << INDENT << converter << " = Shiboken::Conversions::createConverter(";
+ if (type->typeEntry()->targetLangApiName() == QLatin1String("PyObject")) {
+ s << "&PyBaseObject_Type";
+ } else {
+ QString baseName = cpythonBaseName(type->typeEntry());
+ if (baseName == QLatin1String("PySequence"))
+ baseName = QLatin1String("PyList");
+ s << '&' << baseName << "_Type";
+ }
+ QString typeName = fixedCppTypeName(type);
+ s << ", " << cppToPythonFunctionName(typeName, typeName) << ");" << endl;
+ QString toCpp = pythonToCppFunctionName(typeName, typeName);
+ QString isConv = convertibleToCppFunctionName(typeName, typeName);
+ s << INDENT << "Shiboken::Conversions::registerConverterName(" << converter << ", \"" << cppSignature << "\");" << endl;
+ if (usePySideExtensions() && cppSignature.startsWith("const ") && cppSignature.endsWith("&")) {
+ cppSignature.chop(1);
+ cppSignature.remove(0, sizeof("const ") / sizeof(char) - 1);
+ s << INDENT << "Shiboken::Conversions::registerConverterName(" << converter << ", \"" << cppSignature << "\");" << endl;
+ }
+ writeAddPythonToCppConversion(s, converterObject(type), toCpp, isConv);
+}
+
+void CppGenerator::writeExtendedConverterInitialization(QTextStream& s, const TypeEntry* externalType, const QList<const AbstractMetaClass*>& conversions)
+{
+ s << INDENT << "// Extended implicit conversions for " << externalType->qualifiedTargetLangName() << '.' << endl;
+ foreach (const AbstractMetaClass* sourceClass, conversions) {
+ const QString converterVar = QLatin1String("reinterpret_cast<SbkObjectType *>(")
+ + cppApiVariableName(externalType->targetLangPackage()) + QLatin1Char('[')
+ + getTypeIndexVariableName(externalType) + QLatin1String("])");
+ QString sourceTypeName = fixedCppTypeName(sourceClass->typeEntry());
+ QString targetTypeName = fixedCppTypeName(externalType);
+ QString toCpp = pythonToCppFunctionName(sourceTypeName, targetTypeName);
+ QString isConv = convertibleToCppFunctionName(sourceTypeName, targetTypeName);
+ writeAddPythonToCppConversion(s, converterVar, toCpp, isConv);
+ }
+}
+
+QString CppGenerator::multipleInheritanceInitializerFunctionName(const AbstractMetaClass* metaClass)
+{
+ if (!hasMultipleInheritanceInAncestry(metaClass))
+ return QString();
+ return cpythonBaseName(metaClass->typeEntry()) + QLatin1String("_mi_init");
+}
+
+typedef QHash<QString, QPair<QString, QString> >::const_iterator ProtocolIt;
+
+bool CppGenerator::supportsMappingProtocol(const AbstractMetaClass* metaClass)
+{
+ for (ProtocolIt it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) {
+ if (metaClass->hasFunction(it.key()))
+ return true;
+ }
+
+ return false;
+}
+
+bool CppGenerator::supportsNumberProtocol(const AbstractMetaClass* metaClass)
+{
+ return metaClass->hasArithmeticOperatorOverload()
+ || metaClass->hasLogicalOperatorOverload()
+ || metaClass->hasBitwiseOperatorOverload()
+ || hasBoolCast(metaClass);
+}
+
+bool CppGenerator::supportsSequenceProtocol(const AbstractMetaClass* metaClass)
+{
+ for (ProtocolIt it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) {
+ if (metaClass->hasFunction(it.key()))
+ return true;
+ }
+
+ const ComplexTypeEntry* baseType = metaClass->typeEntry()->baseContainerType();
+ if (baseType && baseType->isContainer())
+ return true;
+
+ return false;
+}
+
+bool CppGenerator::shouldGenerateGetSetList(const AbstractMetaClass* metaClass)
+{
+ foreach (AbstractMetaField* f, metaClass->fields()) {
+ if (!f->isStatic())
+ return true;
+ }
+ return false;
+}
+
+void CppGenerator::writeClassDefinition(QTextStream &s,
+ const AbstractMetaClass *metaClass,
+ GeneratorContext &classContext)
+{
+ QString tp_flags;
+ QString tp_init;
+ QString tp_new;
+ QString tp_dealloc;
+ QString tp_hash(QLatin1Char('0'));
+ QString tp_call = tp_hash;
+ QString cppClassName = metaClass->qualifiedCppName();
+ QString className = cpythonTypeName(metaClass);
+ className.remove(QRegExp(QLatin1String("_Type$")));
+ QString baseClassName(QLatin1Char('0'));
+ AbstractMetaFunctionList ctors;
+ foreach (AbstractMetaFunction* f, metaClass->queryFunctions(AbstractMetaClass::Constructors)) {
+ if (!f->isPrivate() && !f->isModifiedRemoved() && !classContext.forSmartPointer())
+ ctors.append(f);
+ }
+
+ if (!metaClass->baseClass())
+ baseClassName = QLatin1String("reinterpret_cast<PyTypeObject*>(&SbkObject_Type)");
+
+ bool onlyPrivCtor = !metaClass->hasNonPrivateConstructor();
+
+ if (metaClass->isNamespace() || metaClass->hasPrivateDestructor()) {
+ tp_flags = QLatin1String("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_GC");
+ tp_dealloc = metaClass->hasPrivateDestructor() ?
+ QLatin1String("SbkDeallocWrapperWithPrivateDtor") : QLatin1String("0");
+ tp_init = QLatin1String("0");
+ } else {
+ if (onlyPrivCtor)
+ tp_flags = QLatin1String("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_GC");
+ else
+ tp_flags = QLatin1String("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_GC");
+
+ QString deallocClassName;
+ if (shouldGenerateCppWrapper(metaClass))
+ deallocClassName = wrapperName(metaClass);
+ else
+ deallocClassName = cppClassName;
+ tp_dealloc = QLatin1String("&SbkDeallocWrapper");
+ // avoid constFirst to stay Qt 5.5 compatible
+ tp_init = (onlyPrivCtor || ctors.isEmpty()) ? QLatin1String("0") : cpythonFunctionName(ctors.first());
+ }
+
+ QString tp_getattro(QLatin1Char('0'));
+ QString tp_setattro = tp_getattro;
+ if (usePySideExtensions() && (metaClass->qualifiedCppName() == QLatin1String("QObject"))) {
+ tp_getattro = cpythonGetattroFunctionName(metaClass);
+ tp_setattro = cpythonSetattroFunctionName(metaClass);
+ } else {
+ if (classNeedsGetattroFunction(metaClass))
+ tp_getattro = cpythonGetattroFunctionName(metaClass);
+ if (classNeedsSetattroFunction(metaClass))
+ tp_setattro = cpythonSetattroFunctionName(metaClass);
+ }
+
+ if (metaClass->hasPrivateDestructor() || onlyPrivCtor)
+ tp_new = QLatin1String("0");
+ else
+ tp_new = QLatin1String("SbkObjectTpNew");
+
+ QString tp_richcompare = QString(QLatin1Char('0'));
+ if (metaClass->hasComparisonOperatorOverload())
+ tp_richcompare = cpythonBaseName(metaClass) + QLatin1String("_richcompare");
+
+ QString tp_getset = QString(QLatin1Char('0'));
+ if (shouldGenerateGetSetList(metaClass) && !classContext.forSmartPointer())
+ tp_getset = cpythonGettersSettersDefinitionName(metaClass);
+
+ // search for special functions
+ ShibokenGenerator::clearTpFuncs();
+ foreach (AbstractMetaFunction* func, metaClass->functions()) {
+ if (m_tpFuncs.contains(func->name()))
+ m_tpFuncs[func->name()] = cpythonFunctionName(func);
+ }
+ if (m_tpFuncs[QLatin1String("__repr__")] == QLatin1String("0")
+ && !metaClass->isQObject()
+ && metaClass->hasToStringCapability()) {
+ m_tpFuncs[QLatin1String("__repr__")] = writeReprFunction(s, classContext);
+ }
+
+ // class or some ancestor has multiple inheritance
+ const AbstractMetaClass* miClass = getMultipleInheritingClass(metaClass);
+ if (miClass) {
+ if (metaClass == miClass)
+ writeMultipleInheritanceInitializerFunction(s, metaClass);
+ writeSpecialCastFunction(s, metaClass);
+ s << endl;
+ }
+
+ if (!metaClass->typeEntry()->hashFunction().isEmpty())
+ tp_hash = QLatin1Char('&') + cpythonBaseName(metaClass) + QLatin1String("_HashFunc");
+
+ const AbstractMetaFunction* callOp = metaClass->findFunction(QLatin1String("operator()"));
+ if (callOp && !callOp->isModifiedRemoved())
+ tp_call = QLatin1Char('&') + cpythonFunctionName(callOp);
+
+ s << "// Class Definition -----------------------------------------------" << endl;
+ s << "extern \"C\" {" << endl;
+
+ if (supportsNumberProtocol(metaClass)) {
+ s << "static PyNumberMethods " << className + QLatin1String("_TypeAsNumber") << ";" << endl;
+ s << endl;
+ }
+
+ if (supportsSequenceProtocol(metaClass)) {
+ s << "static PySequenceMethods " << className + QLatin1String("_TypeAsSequence") << ";" << endl;
+ s << endl;
+ }
+
+ if (supportsMappingProtocol(metaClass)) {
+ s << "static PyMappingMethods " << className + QLatin1String("_TypeAsMapping") << ";" << endl;
+ s << endl;
+ }
+
+ s << "static SbkObjectType " << className + QLatin1String("_Type") << " = { { {" << endl;
+ s << INDENT << "PyVarObject_HEAD_INIT(&SbkObjectType_Type, 0)" << endl;
+ QString computedClassTargetFullName;
+ if (!classContext.forSmartPointer())
+ computedClassTargetFullName = getClassTargetFullName(metaClass);
+ else
+ computedClassTargetFullName = getClassTargetFullName(classContext.preciseType());
+
+ s << INDENT << "/*tp_name*/ \"" << computedClassTargetFullName << "\"," << endl;
+ s << INDENT << "/*tp_basicsize*/ sizeof(SbkObject)," << endl;
+ s << INDENT << "/*tp_itemsize*/ 0," << endl;
+ s << INDENT << "/*tp_dealloc*/ " << tp_dealloc << ',' << endl;
+ s << INDENT << "/*tp_print*/ 0," << endl;
+ s << INDENT << "/*tp_getattr*/ 0," << endl;
+ s << INDENT << "/*tp_setattr*/ 0," << endl;
+ s << INDENT << "/*tp_compare*/ 0," << endl;
+ s << INDENT << "/*tp_repr*/ " << m_tpFuncs[QLatin1String("__repr__")] << "," << endl;
+ s << INDENT << "/*tp_as_number*/ 0," << endl;
+ s << INDENT << "/*tp_as_sequence*/ 0," << endl;
+ s << INDENT << "/*tp_as_mapping*/ 0," << endl;
+ s << INDENT << "/*tp_hash*/ " << tp_hash << ',' << endl;
+ s << INDENT << "/*tp_call*/ " << tp_call << ',' << endl;
+ s << INDENT << "/*tp_str*/ " << m_tpFuncs[QLatin1String("__str__")] << ',' << endl;
+ s << INDENT << "/*tp_getattro*/ " << tp_getattro << ',' << endl;
+ s << INDENT << "/*tp_setattro*/ " << tp_setattro << ',' << endl;
+ s << INDENT << "/*tp_as_buffer*/ 0," << endl;
+ s << INDENT << "/*tp_flags*/ " << tp_flags << ',' << endl;
+ s << INDENT << "/*tp_doc*/ 0," << endl;
+ s << INDENT << "/*tp_traverse*/ " << className << "_traverse," << endl;
+ s << INDENT << "/*tp_clear*/ " << className << "_clear," << endl;
+ s << INDENT << "/*tp_richcompare*/ " << tp_richcompare << ',' << endl;
+ s << INDENT << "/*tp_weaklistoffset*/ 0," << endl;
+ s << INDENT << "/*tp_iter*/ " << m_tpFuncs[QLatin1String("__iter__")] << ',' << endl;
+ s << INDENT << "/*tp_iternext*/ " << m_tpFuncs[QLatin1String("__next__")] << ',' << endl;
+ s << INDENT << "/*tp_methods*/ " << className << "_methods," << endl;
+ s << INDENT << "/*tp_members*/ 0," << endl;
+ s << INDENT << "/*tp_getset*/ " << tp_getset << ',' << endl;
+ s << INDENT << "/*tp_base*/ " << baseClassName << ',' << endl;
+ s << INDENT << "/*tp_dict*/ 0," << endl;
+ s << INDENT << "/*tp_descr_get*/ 0," << endl;
+ s << INDENT << "/*tp_descr_set*/ 0," << endl;
+ s << INDENT << "/*tp_dictoffset*/ 0," << endl;
+ s << INDENT << "/*tp_init*/ " << tp_init << ',' << endl;
+ s << INDENT << "/*tp_alloc*/ 0," << endl;
+ s << INDENT << "/*tp_new*/ " << tp_new << ',' << endl;
+ s << INDENT << "/*tp_free*/ 0," << endl;
+ s << INDENT << "/*tp_is_gc*/ 0," << endl;
+ s << INDENT << "/*tp_bases*/ 0," << endl;
+ s << INDENT << "/*tp_mro*/ 0," << endl;
+ s << INDENT << "/*tp_cache*/ 0," << endl;
+ s << INDENT << "/*tp_subclasses*/ 0," << endl;
+ s << INDENT << "/*tp_weaklist*/ 0" << endl;
+ s << "}, }," << endl;
+ s << INDENT << "/*priv_data*/ 0" << endl;
+ s << "};" << endl;
+ QString suffix;
+ if (isObjectType(metaClass))
+ suffix = QLatin1String("*");
+ s << "} //extern" << endl;
+}
+
+void CppGenerator::writeMappingMethods(QTextStream &s,
+ const AbstractMetaClass *metaClass,
+ GeneratorContext &context)
+{
+
+ QMap<QString, QString> funcs;
+
+ QHash< QString, QPair< QString, QString > >::const_iterator it = m_mappingProtocol.begin();
+ for (; it != m_mappingProtocol.end(); ++it) {
+ const AbstractMetaFunction* func = metaClass->findFunction(it.key());
+ if (!func)
+ continue;
+ QString funcName = cpythonFunctionName(func);
+ QString funcArgs = it.value().first;
+ QString funcRetVal = it.value().second;
+
+ CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode);
+ s << funcRetVal << ' ' << funcName << '(' << funcArgs << ')' << endl << '{' << endl;
+ writeInvalidPyObjectCheck(s, QLatin1String(PYTHON_SELF_VAR));
+
+ writeCppSelfDefinition(s, func, context);
+
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode, func, lastArg);
+ s << '}' << endl << endl;
+ }
+}
+
+void CppGenerator::writeSequenceMethods(QTextStream &s,
+ const AbstractMetaClass *metaClass,
+ GeneratorContext &context)
+{
+
+ QMap<QString, QString> funcs;
+ bool injectedCode = false;
+
+ QHash< QString, QPair< QString, QString > >::const_iterator it = m_sequenceProtocol.begin();
+ for (; it != m_sequenceProtocol.end(); ++it) {
+ const AbstractMetaFunction* func = metaClass->findFunction(it.key());
+ if (!func)
+ continue;
+ injectedCode = true;
+ QString funcName = cpythonFunctionName(func);
+ QString funcArgs = it.value().first;
+ QString funcRetVal = it.value().second;
+
+ CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode);
+ s << funcRetVal << ' ' << funcName << '(' << funcArgs << ')' << endl << '{' << endl;
+ writeInvalidPyObjectCheck(s, QLatin1String(PYTHON_SELF_VAR));
+
+ writeCppSelfDefinition(s, func, context);
+
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, snips,TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode, func, lastArg);
+ s << '}' << endl << endl;
+ }
+
+ if (!injectedCode)
+ writeStdListWrapperMethods(s, context);
+}
+
+void CppGenerator::writeTypeAsSequenceDefinition(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ bool hasFunctions = false;
+ QMap<QString, QString> funcs;
+ for (ProtocolIt it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) {
+ const QString &funcName = it.key();
+ const AbstractMetaFunction* func = metaClass->findFunction(funcName);
+ funcs[funcName] = func ? cpythonFunctionName(func).prepend(QLatin1Char('&')) : QString();
+ if (!hasFunctions && func)
+ hasFunctions = true;
+ }
+
+ QString baseName = cpythonBaseName(metaClass);
+
+ //use default implementation
+ if (!hasFunctions) {
+ funcs[QLatin1String("__len__")] = baseName + QLatin1String("__len__");
+ funcs[QLatin1String("__getitem__")] = baseName + QLatin1String("__getitem__");
+ funcs[QLatin1String("__setitem__")] = baseName + QLatin1String("__setitem__");
+ }
+
+ s << INDENT << "memset(&" << baseName << "_TypeAsSequence, 0, sizeof(PySequenceMethods));" << endl;
+ for (QHash<QString, QString>::const_iterator it = m_sqFuncs.cbegin(), end = m_sqFuncs.cend(); it != end; ++it) {
+ const QString& sqName = it.key();
+ if (funcs[sqName].isEmpty())
+ continue;
+ if (it.value() == QLatin1String("sq_slice"))
+ s << "#ifndef IS_PY3K" << endl;
+ s << INDENT << baseName << "_TypeAsSequence." << it.value() << " = " << funcs[sqName] << ';' << endl;
+ if (it.value() == QLatin1String("sq_slice"))
+ s << "#endif" << endl;
+ }
+}
+
+void CppGenerator::writeTypeAsMappingDefinition(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ bool hasFunctions = false;
+ QMap<QString, QString> funcs;
+ for (ProtocolIt it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) {
+ const QString &funcName = it.key();
+ const AbstractMetaFunction* func = metaClass->findFunction(funcName);
+ funcs[funcName] = func ? cpythonFunctionName(func).prepend(QLatin1Char('&')) : QLatin1String("0");
+ if (!hasFunctions && func)
+ hasFunctions = true;
+ }
+
+ //use default implementation
+ if (!hasFunctions) {
+ funcs.insert(QLatin1String("__mlen__"), QString());
+ funcs.insert(QLatin1String("__mgetitem__"), QString());
+ funcs.insert(QLatin1String("__msetitem__"), QString());
+ }
+
+ QString baseName = cpythonBaseName(metaClass);
+ s << INDENT << "memset(&" << baseName << "_TypeAsMapping, 0, sizeof(PyMappingMethods));" << endl;
+ for (QHash<QString, QString>::const_iterator it = m_mpFuncs.cbegin(), end = m_mpFuncs.end(); it != end; ++it) {
+ const QString &mpName = it.key();
+ if (funcs[mpName].isEmpty())
+ continue;
+ s << INDENT << baseName << "_TypeAsMapping." << it.value() << " = " << funcs[mpName] << ';' << endl;
+ }
+}
+
+void CppGenerator::writeTypeAsNumberDefinition(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ QMap<QString, QString> nb;
+
+ nb.insert(QLatin1String("__add__"), QString());
+ nb.insert(QLatin1String("__sub__"), QString());
+ nb.insert(QLatin1String("__mul__"), QString());
+ nb.insert(QLatin1String("__div__"), QString());
+ nb.insert(QLatin1String("__mod__"), QString());
+ nb.insert(QLatin1String("__neg__"), QString());
+ nb.insert(QLatin1String("__pos__"), QString());
+ nb.insert(QLatin1String("__invert__"), QString());
+ nb.insert(QLatin1String("__lshift__"), QString());
+ nb.insert(QLatin1String("__rshift__"), QString());
+ nb.insert(QLatin1String("__and__"), QString());
+ nb.insert(QLatin1String("__xor__"), QString());
+ nb.insert(QLatin1String("__or__"), QString());
+ nb.insert(QLatin1String("__iadd__"), QString());
+ nb.insert(QLatin1String("__isub__"), QString());
+ nb.insert(QLatin1String("__imul__"), QString());
+ nb.insert(QLatin1String("__idiv__"), QString());
+ nb.insert(QLatin1String("__imod__"), QString());
+ nb.insert(QLatin1String("__ilshift__"), QString());
+ nb.insert(QLatin1String("__irshift__"), QString());
+ nb.insert(QLatin1String("__iand__"), QString());
+ nb.insert(QLatin1String("__ixor__"), QString());
+ nb.insert(QLatin1String("__ior__"), QString());
+
+ QList<AbstractMetaFunctionList> opOverloads =
+ filterGroupedOperatorFunctions(metaClass,
+ AbstractMetaClass::ArithmeticOp
+ | AbstractMetaClass::LogicalOp
+ | AbstractMetaClass::BitwiseOp);
+
+ foreach (const AbstractMetaFunctionList &opOverload, opOverloads) {
+ const AbstractMetaFunction* rfunc = opOverload[0];
+ QString opName = ShibokenGenerator::pythonOperatorFunctionName(rfunc);
+ nb[opName] = cpythonFunctionName(rfunc);
+ }
+
+ QString baseName = cpythonBaseName(metaClass);
+
+ nb[QLatin1String("bool")] = hasBoolCast(metaClass) ? baseName + QLatin1String("___nb_bool") : QString();
+
+ s << INDENT << "memset(&" << baseName << "_TypeAsNumber, 0, sizeof(PyNumberMethods));" << endl;
+ for (QHash<QString, QString>::const_iterator it = m_nbFuncs.cbegin(), end = m_nbFuncs.cend(); it != end; ++it) {
+ const QString &nbName = it.key();
+ 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 << INDENT << "SBK_NB_BOOL(" << baseName << "_TypeAsNumber) = " << nb[nbName] << ';' << endl;
+ } else {
+ bool excludeFromPy3K = nbName == QLatin1String("__div__") || nbName == QLatin1String("__idiv__");
+ if (excludeFromPy3K) {
+ s << "#ifdef IS_PY3K" << endl;
+ s << INDENT << "SBK_UNUSED(&" << nb[nbName] << ");" << endl;
+ s << "#else" << endl;
+ }
+ s << INDENT << baseName << "_TypeAsNumber." << it.value() << " = " << nb[nbName] << ';' << endl;
+ if (excludeFromPy3K)
+ s << "#endif" << endl;
+ }
+ }
+ if (!nb[QLatin1String("__div__")].isEmpty())
+ s << INDENT << baseName << "_TypeAsNumber.nb_true_divide = " << nb[QLatin1String("__div__")] << ';' << endl;
+}
+
+void CppGenerator::writeTpTraverseFunction(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ QString baseName = cpythonBaseName(metaClass);
+ s << "static int ";
+ s << baseName << "_traverse(PyObject* " PYTHON_SELF_VAR ", visitproc visit, void* arg)" << endl;
+ s << '{' << endl;
+ s << INDENT << "return reinterpret_cast<PyTypeObject*>(&SbkObject_Type)->tp_traverse(" PYTHON_SELF_VAR ", visit, arg);" << endl;
+ s << '}' << endl;
+}
+
+void CppGenerator::writeTpClearFunction(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ QString baseName = cpythonBaseName(metaClass);
+ s << "static int ";
+ s << baseName << "_clear(PyObject* " PYTHON_SELF_VAR ")" << endl;
+ s << '{' << endl;
+ s << INDENT << "return reinterpret_cast<PyTypeObject*>(&SbkObject_Type)->tp_clear(" PYTHON_SELF_VAR ");" << endl;
+ s << '}' << endl;
+}
+
+void CppGenerator::writeCopyFunction(QTextStream &s, GeneratorContext &context)
+{
+ const AbstractMetaClass *metaClass = context.metaClass();
+ QString className = cpythonTypeName(metaClass);
+ className.remove(QRegExp(QLatin1String("_Type$")));
+ s << "static PyObject* " << className << "___copy__(PyObject* " PYTHON_SELF_VAR ")" << endl;
+ s << "{" << endl;
+ writeCppSelfDefinition(s, context, false, true);
+ QString conversionCode;
+ if (!context.forSmartPointer())
+ conversionCode = cpythonToPythonConversionFunction(metaClass);
+ else
+ conversionCode = cpythonToPythonConversionFunction(context.preciseType());
+
+ s << INDENT << "PyObject* " << PYTHON_RETURN_VAR << " = " << conversionCode;
+ s << CPP_SELF_VAR ");" << endl;
+ writeFunctionReturnErrorCheckSection(s);
+ s << INDENT << "return " PYTHON_RETURN_VAR ";" << endl;
+ s << "}" << endl;
+ s << endl;
+}
+
+void CppGenerator::writeGetterFunction(QTextStream &s,
+ const AbstractMetaField *metaField,
+ GeneratorContext &context)
+{
+ ErrorCode errorCode(0);
+ s << "static PyObject* " << cpythonGetterFunctionName(metaField) << "(PyObject* " PYTHON_SELF_VAR ", void*)" << endl;
+ s << '{' << endl;
+
+ writeCppSelfDefinition(s, context);
+
+ AbstractMetaType* fieldType = metaField->type();
+ // Force use of pointer to return internal variable memory
+ bool newWrapperSameObject = !fieldType->isConstant() && isWrapperType(fieldType) && !isPointer(fieldType);
+
+ QString cppField;
+ if (avoidProtectedHack() && metaField->isProtected()) {
+ cppField = QString::fromLatin1("((%1*)%2)->%3()")
+ .arg(wrapperName(metaField->enclosingClass()), QLatin1String(CPP_SELF_VAR),
+ protectedFieldGetterName(metaField));
+ } else {
+ cppField = QLatin1String(CPP_SELF_VAR) + QLatin1String("->") + metaField->name();
+ if (newWrapperSameObject) {
+ cppField.prepend(QLatin1String("&("));
+ cppField.append(QLatin1Char(')'));
+ }
+ }
+ if (isCppIntegralPrimitive(fieldType) || fieldType->isEnum()) {
+ s << INDENT << getFullTypeNameWithoutModifiers(fieldType) << " cppOut_local = " << cppField << ';' << endl;
+ cppField = QLatin1String("cppOut_local");
+ } else if (avoidProtectedHack() && metaField->isProtected()) {
+ s << INDENT << getFullTypeNameWithoutModifiers(fieldType);
+ if (fieldType->isContainer() || fieldType->isFlags() || fieldType->isSmartPointer()) {
+ s << '&';
+ cppField.prepend(QLatin1Char('*'));
+ } else if ((!fieldType->isConstant() && !fieldType->isEnum() && !fieldType->isPrimitive()) || fieldType->indirections() == 1) {
+ s << '*';
+ }
+ s << " fieldValue = " << cppField << ';' << endl;
+ cppField = QLatin1String("fieldValue");
+ }
+
+ s << INDENT << "PyObject* pyOut = 0;\n";
+ if (newWrapperSameObject) {
+ // Special case colocated field with same address (first field in a struct)
+ s << INDENT << "if (reinterpret_cast<void *>("
+ << cppField
+ << ") == reinterpret_cast<void *>("
+ << CPP_SELF_VAR << ")) {\n";
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "pyOut = reinterpret_cast<PyObject *>(Shiboken::Object::findColocatedChild("
+ << "reinterpret_cast<SbkObject *>(self), reinterpret_cast<const SbkObjectType *>("
+ << cpythonTypeNameExt(fieldType)
+ << ")));\n";
+ s << INDENT << "if (pyOut) {Py_IncRef(pyOut); return pyOut;}\n";
+ }
+ s << INDENT << "}\n";
+ // Check if field wrapper has already been created.
+ s << INDENT << "else if (Shiboken::BindingManager::instance().hasWrapper(" << cppField << ")) {" << "\n";
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "pyOut = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(" << cppField << ");" << "\n";
+ s << INDENT << "Py_IncRef(pyOut);" << "\n";
+ s << INDENT << "return pyOut;" << "\n";
+ }
+ s << INDENT << "}\n";
+ // Create and register new wrapper
+ s << INDENT << "pyOut = ";
+ s << "Shiboken::Object::newObject(reinterpret_cast<SbkObjectType *>(" << cpythonTypeNameExt(fieldType)
+ << "), " << cppField << ", false, true);" << endl;
+ s << INDENT << "Shiboken::Object::setParent(" PYTHON_SELF_VAR ", pyOut)";
+ } else {
+ s << INDENT << "pyOut = ";
+ writeToPythonConversion(s, fieldType, metaField->enclosingClass(), cppField);
+ }
+ s << ';' << endl;
+
+ s << INDENT << "return pyOut;" << endl;
+ s << '}' << endl;
+}
+
+void CppGenerator::writeSetterFunction(QTextStream &s,
+ const AbstractMetaField *metaField,
+ GeneratorContext &context)
+{
+ ErrorCode errorCode(0);
+ s << "static int " << cpythonSetterFunctionName(metaField) << "(PyObject* " PYTHON_SELF_VAR ", PyObject* pyIn, void*)" << endl;
+ s << '{' << endl;
+
+ writeCppSelfDefinition(s, context);
+
+ s << INDENT << "if (pyIn == 0) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyErr_SetString(PyExc_TypeError, \"'";
+ s << metaField->name() << "' may not be deleted\");" << endl;
+ s << INDENT << "return -1;" << endl;
+ }
+ s << INDENT << '}' << endl;
+
+ AbstractMetaType* fieldType = metaField->type();
+
+ s << INDENT << "PythonToCppFunc " << PYTHON_TO_CPP_VAR << ';' << endl;
+ s << INDENT << "if (!";
+ writeTypeCheck(s, fieldType, QLatin1String("pyIn"), isNumber(fieldType->typeEntry()));
+ s << ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyErr_SetString(PyExc_TypeError, \"wrong type attributed to '";
+ s << metaField->name() << "', '" << fieldType->name() << "' or convertible type expected\");" << endl;
+ s << INDENT << "return -1;" << endl;
+ }
+ s << INDENT << '}' << endl << endl;
+
+ QString cppField = QString::fromLatin1("%1->%2").arg(QLatin1String(CPP_SELF_VAR), metaField->name());
+ s << INDENT;
+ if (avoidProtectedHack() && metaField->isProtected()) {
+ s << getFullTypeNameWithoutModifiers(fieldType);
+ s << (fieldType->indirections() == 1 ? "*" : "") << " cppOut;" << endl;
+ s << INDENT << PYTHON_TO_CPP_VAR << "(pyIn, &cppOut);" << endl;
+ s << INDENT << QString::fromLatin1("((%1*)%2)->%3(cppOut)")
+ .arg(wrapperName(metaField->enclosingClass()),
+ QLatin1String(CPP_SELF_VAR), protectedFieldSetterName(metaField));
+ } else if (isCppIntegralPrimitive(fieldType) || fieldType->typeEntry()->isEnum() || fieldType->typeEntry()->isFlags()) {
+ s << getFullTypeNameWithoutModifiers(fieldType) << " cppOut_local = " << cppField << ';' << endl;
+ s << INDENT << PYTHON_TO_CPP_VAR << "(pyIn, &cppOut_local);" << endl;
+ s << INDENT << cppField << " = cppOut_local";
+ } else {
+ s << getFullTypeNameWithoutModifiers(fieldType);
+ s << QString::fromLatin1("*").repeated(fieldType->indirections()) << "& cppOut_ptr = ";
+ s << cppField << ';' << endl;
+ s << INDENT << PYTHON_TO_CPP_VAR << "(pyIn, &cppOut_ptr)";
+ }
+ s << ';' << endl << endl;
+
+ if (isPointerToWrapperType(fieldType)) {
+ s << INDENT << "Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(" PYTHON_SELF_VAR "), \"";
+ s << metaField->name() << "\", pyIn);" << endl;
+ }
+
+ s << INDENT << "return 0;" << endl;
+ s << '}' << endl;
+}
+
+void CppGenerator::writeRichCompareFunction(QTextStream &s, GeneratorContext &context)
+{
+ const AbstractMetaClass *metaClass = context.metaClass();
+ QString baseName = cpythonBaseName(metaClass);
+ s << "static PyObject* ";
+ s << baseName << "_richcompare(PyObject* " PYTHON_SELF_VAR ", PyObject* " PYTHON_ARG ", int op)" << endl;
+ s << '{' << endl;
+ writeCppSelfDefinition(s, context, false, true);
+ writeUnusedVariableCast(s, QLatin1String(CPP_SELF_VAR));
+ s << INDENT << "PyObject* " PYTHON_RETURN_VAR " = 0;" << endl;
+ s << INDENT << "PythonToCppFunc " PYTHON_TO_CPP_VAR << ';' << endl;
+ writeUnusedVariableCast(s, QLatin1String(PYTHON_TO_CPP_VAR));
+ s << endl;
+
+ s << INDENT << "switch (op) {" << endl;
+ {
+ Indentation indent(INDENT);
+ foreach (const AbstractMetaFunctionList &overloads, filterGroupedOperatorFunctions(metaClass, AbstractMetaClass::ComparisonOp)) {
+ const AbstractMetaFunction* rfunc = overloads[0];
+
+ QString operatorId = ShibokenGenerator::pythonRichCompareOperatorId(rfunc);
+ s << INDENT << "case " << operatorId << ':' << endl;
+
+ Indentation indent(INDENT);
+
+ QString op = rfunc->originalName();
+ op = op.right(op.size() - QLatin1String("operator").size());
+
+ int alternativeNumericTypes = 0;
+ foreach (const AbstractMetaFunction* func, overloads) {
+ if (!func->isStatic() &&
+ ShibokenGenerator::isNumber(func->arguments()[0]->type()->typeEntry()))
+ alternativeNumericTypes++;
+ }
+
+ bool first = true;
+ OverloadData overloadData(overloads, this);
+ foreach (OverloadData* od, overloadData.nextOverloadData()) {
+ const AbstractMetaFunction* func = od->referenceFunction();
+ if (func->isStatic())
+ continue;
+ const AbstractMetaType* argType = getArgumentType(func, 1);
+ if (!argType)
+ continue;
+ if (!first) {
+ s << " else ";
+ } else {
+ first = false;
+ s << INDENT;
+ }
+ s << "if (";
+ writeTypeCheck(s, argType, QLatin1String(PYTHON_ARG), alternativeNumericTypes == 1 || isPyInt(argType));
+ s << ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "// " << func->signature() << endl;
+ writeArgumentConversion(s, argType, QLatin1String(CPP_ARG0),
+ QLatin1String(PYTHON_ARG), metaClass,
+ QString(), func->isUserAdded());
+
+ // If the function is user added, use the inject code
+ if (func->isUserAdded()) {
+ CodeSnipList snips = func->injectedCodeSnips();
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode, func, func->arguments().last());
+ } else {
+ QString expression = QString::fromLatin1("%1%2 %3 (%4" CPP_ARG0 ")")
+ .arg(func->isPointerOperator() ? QLatin1String("&") : QString(),
+ QLatin1String(CPP_SELF_VAR), op,
+ shouldDereferenceAbstractMetaTypePointer(argType) ? QLatin1String("*") : QString());
+ s << INDENT;
+ if (func->type())
+ s << func->type()->cppSignature() << " " CPP_RETURN_VAR " = ";
+ s << expression << ';' << endl;
+ s << INDENT << PYTHON_RETURN_VAR " = ";
+ if (func->type())
+ writeToPythonConversion(s, func->type(), metaClass, QLatin1String(CPP_RETURN_VAR));
+ else
+ s << "Py_None;" << endl << INDENT << "Py_INCREF(Py_None)";
+ s << ';' << endl;
+ }
+ }
+ s << INDENT << '}';
+ }
+
+ s << " else {" << endl;
+ if (operatorId == QLatin1String("Py_EQ") || operatorId == QLatin1String("Py_NE")) {
+ Indentation indent(INDENT);
+ s << INDENT << PYTHON_RETURN_VAR " = "
+ << (operatorId == QLatin1String("Py_EQ") ? "Py_False" : "Py_True") << ';' << endl;
+ s << INDENT << "Py_INCREF(" PYTHON_RETURN_VAR ");" << endl;
+ } else {
+ Indentation indent(INDENT);
+ s << INDENT << "goto " << baseName << "_RichComparison_TypeError;" << endl;
+ }
+ s << INDENT << '}' << endl << endl;
+
+ s << INDENT << "break;" << endl;
+ }
+ s << INDENT << "default:" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "goto " << baseName << "_RichComparison_TypeError;" << endl;
+ }
+ }
+ s << INDENT << '}' << endl << endl;
+
+ s << INDENT << "if (" PYTHON_RETURN_VAR " && !PyErr_Occurred())" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return " PYTHON_RETURN_VAR ";" << endl;
+ }
+ s << INDENT << baseName << "_RichComparison_TypeError:" << endl;
+ s << INDENT << "PyErr_SetString(PyExc_NotImplementedError, \"operator not implemented.\");" << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl << endl;
+ s << '}' << endl << endl;
+}
+
+void CppGenerator::writeMethodDefinitionEntry(QTextStream& s, const AbstractMetaFunctionList overloads)
+{
+ Q_ASSERT(!overloads.isEmpty());
+ OverloadData overloadData(overloads, this);
+ bool usePyArgs = pythonFunctionWrapperUsesListOfArguments(overloadData);
+ const AbstractMetaFunction* func = overloadData.referenceFunction();
+ int min = overloadData.minArgs();
+ int max = overloadData.maxArgs();
+
+ s << '"' << func->name() << "\", (PyCFunction)" << cpythonFunctionName(func) << ", ";
+ if ((min == max) && (max < 2) && !usePyArgs) {
+ if (max == 0)
+ s << "METH_NOARGS";
+ else
+ s << "METH_O";
+ } else {
+ s << "METH_VARARGS";
+ if (overloadData.hasArgumentWithDefaultValue())
+ s << "|METH_KEYWORDS";
+ }
+ if (func->ownerClass() && overloadData.hasStaticFunction())
+ s << "|METH_STATIC";
+}
+
+void CppGenerator::writeMethodDefinition(QTextStream& s, const AbstractMetaFunctionList overloads)
+{
+ Q_ASSERT(!overloads.isEmpty());
+ const AbstractMetaFunction* func = overloads.first();
+ if (m_tpFuncs.contains(func->name()))
+ return;
+
+ s << INDENT;
+ if (OverloadData::hasStaticAndInstanceFunctions(overloads)) {
+ s << cpythonMethodDefinitionName(func);
+ } else {
+ s << '{';
+ writeMethodDefinitionEntry(s, overloads);
+ s << '}';
+ }
+ s << ',' << endl;
+}
+
+void CppGenerator::writeEnumsInitialization(QTextStream& s, AbstractMetaEnumList& enums)
+{
+ if (enums.isEmpty())
+ return;
+ s << INDENT << "// Initialization of enums." << endl << endl;
+ foreach (const AbstractMetaEnum* cppEnum, enums) {
+ if (cppEnum->isPrivate())
+ continue;
+ writeEnumInitialization(s, cppEnum);
+ }
+}
+
+void CppGenerator::writeEnumInitialization(QTextStream& s, const AbstractMetaEnum* cppEnum)
+{
+ const AbstractMetaClass* enclosingClass = getProperEnclosingClassForEnum(cppEnum);
+ const AbstractMetaClass* upper = enclosingClass ? enclosingClass->enclosingClass() : 0;
+ bool hasUpperEnclosingClass = upper && upper->typeEntry()->codeGeneration() != TypeEntry::GenerateForSubclass;
+ QString enclosingObjectVariable;
+ if (enclosingClass)
+ enclosingObjectVariable = QLatin1Char('&') + cpythonTypeName(enclosingClass);
+ else if (hasUpperEnclosingClass)
+ enclosingObjectVariable = QLatin1String("enclosingClass");
+ else
+ enclosingObjectVariable = QLatin1String("module");
+
+ s << INDENT << "// Initialization of ";
+ s << (cppEnum->isAnonymous() ? "anonymous enum identified by enum value" : "enum");
+ s << " '" << cppEnum->name() << "'." << endl;
+
+ if (!cppEnum->isAnonymous()) {
+ FlagsTypeEntry* flags = cppEnum->typeEntry()->flags();
+ if (flags) {
+ s << INDENT << cpythonTypeNameExt(flags) << " = PySide::QFlags::create(\"" << flags->flagsName() << "\", &"
+ << cpythonEnumName(cppEnum) << "_as_number);" << endl;
+ }
+
+ s << INDENT << cpythonTypeNameExt(cppEnum->typeEntry()) << " = Shiboken::Enum::";
+ s << ((enclosingClass || hasUpperEnclosingClass) ? "createScopedEnum" : "createGlobalEnum");
+ s << '(' << enclosingObjectVariable << ',' << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << '"' << cppEnum->name() << "\"," << endl;
+ s << INDENT << '"' << getClassTargetFullName(cppEnum) << "\"," << endl;
+ s << INDENT << '"' << (cppEnum->enclosingClass() ? (cppEnum->enclosingClass()->qualifiedCppName() + QLatin1String("::")) : QString());
+ s << cppEnum->name() << '"';
+ if (flags)
+ s << ',' << endl << INDENT << cpythonTypeNameExt(flags);
+ s << ");" << endl;
+ }
+ s << INDENT << "if (!" << cpythonTypeNameExt(cppEnum->typeEntry()) << ')' << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl << endl;
+ }
+ }
+
+ foreach (const AbstractMetaEnumValue* enumValue, cppEnum->values()) {
+ if (cppEnum->typeEntry()->isEnumValueRejected(enumValue->name()))
+ continue;
+
+ QString enumValueText;
+ if (!avoidProtectedHack() || !cppEnum->isProtected()) {
+ enumValueText = QLatin1String("(long) ");
+ if (cppEnum->enclosingClass())
+ enumValueText += cppEnum->enclosingClass()->qualifiedCppName() + QLatin1String("::");
+ enumValueText += enumValue->name();
+ } else {
+ enumValueText += QString::number(enumValue->value());
+ }
+
+ if (cppEnum->isAnonymous()) {
+ if (enclosingClass || hasUpperEnclosingClass) {
+ s << INDENT << '{' << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyObject* anonEnumItem = PyInt_FromLong(" << enumValueText << ");" << endl;
+ s << INDENT << "if (PyDict_SetItemString(reinterpret_cast<SbkObjectType *>(" << enclosingObjectVariable
+ << ")->super.ht_type.tp_dict, \"" << enumValue->name() << "\", anonEnumItem) < 0)" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ s << INDENT << "Py_DECREF(anonEnumItem);" << endl;
+ }
+ s << INDENT << '}' << endl;
+ } else {
+ s << INDENT << "if (PyModule_AddIntConstant(module, \"" << enumValue->name() << "\", ";
+ s << enumValueText << ") < 0)" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ }
+ } else {
+ s << INDENT << "if (!Shiboken::Enum::";
+ s << ((enclosingClass || hasUpperEnclosingClass) ? "createScopedEnumItem" : "createGlobalEnumItem");
+ s << '(' << cpythonTypeNameExt(cppEnum->typeEntry()) << ',' << endl;
+ Indentation indent(INDENT);
+ s << INDENT << enclosingObjectVariable << ", \"" << enumValue->name() << "\", ";
+ s << enumValueText << "))" << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ }
+
+ writeEnumConverterInitialization(s, cppEnum);
+
+ s << INDENT << "// End of '" << cppEnum->name() << "' enum";
+ if (cppEnum->typeEntry()->flags())
+ s << "/flags";
+ s << '.' << endl << endl;
+}
+
+void CppGenerator::writeSignalInitialization(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ // Try to check something and print some warnings
+ foreach (const AbstractMetaFunction* cppSignal, metaClass->cppSignalFunctions()) {
+ if (cppSignal->declaringClass() != metaClass)
+ continue;
+ foreach (AbstractMetaArgument* arg, cppSignal->arguments()) {
+ AbstractMetaType* metaType = arg->type();
+ const QByteArray origType =
+ QMetaObject::normalizedType(qPrintable(metaType->originalTypeDescription()));
+ const QByteArray cppSig =
+ QMetaObject::normalizedType(qPrintable(metaType->cppSignature()));
+ if ((origType != cppSig) && (!metaType->isFlags())) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Typedef used on signal " << metaClass->qualifiedCppName() << "::"
+ << cppSignal->signature();
+ }
+ }
+ }
+
+ s << INDENT << "PySide::Signal::registerSignals(&" << cpythonTypeName(metaClass) << ", &::"
+ << metaClass->qualifiedCppName() << "::staticMetaObject);" << endl;
+}
+
+void CppGenerator::writeFlagsToLong(QTextStream& s, const AbstractMetaEnum* cppEnum)
+{
+ FlagsTypeEntry* flagsEntry = cppEnum->typeEntry()->flags();
+ if (!flagsEntry)
+ return;
+ s << "static PyObject* " << cpythonEnumName(cppEnum) << "_long(PyObject* " PYTHON_SELF_VAR ")" << endl;
+ s << "{" << endl;
+ s << INDENT << "int val;" << endl;
+ AbstractMetaType* flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
+ s << INDENT << cpythonToCppConversionFunction(flagsType) << PYTHON_SELF_VAR << ", &val);" << endl;
+ s << INDENT << "return Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<int>(), &val);" << endl;
+ s << "}" << endl;
+}
+
+void CppGenerator::writeFlagsNonZero(QTextStream& s, const AbstractMetaEnum* cppEnum)
+{
+ FlagsTypeEntry* flagsEntry = cppEnum->typeEntry()->flags();
+ if (!flagsEntry)
+ return;
+ s << "static int " << cpythonEnumName(cppEnum) << "__nonzero(PyObject* " PYTHON_SELF_VAR ")" << endl;
+ s << "{" << endl;
+
+ s << INDENT << "int val;" << endl;
+ AbstractMetaType* flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
+ s << INDENT << cpythonToCppConversionFunction(flagsType) << PYTHON_SELF_VAR << ", &val);" << endl;
+ s << INDENT << "return val != 0;" << endl;
+ s << "}" << endl;
+}
+
+void CppGenerator::writeFlagsMethods(QTextStream& s, const AbstractMetaEnum* cppEnum)
+{
+ writeFlagsBinaryOperator(s, cppEnum, QLatin1String("and"), QLatin1String("&"));
+ writeFlagsBinaryOperator(s, cppEnum, QLatin1String("or"), QLatin1String("|"));
+ writeFlagsBinaryOperator(s, cppEnum, QLatin1String("xor"), QLatin1String("^"));
+
+ writeFlagsUnaryOperator(s, cppEnum, QLatin1String("invert"), QLatin1String("~"));
+ writeFlagsToLong(s, cppEnum);
+ writeFlagsNonZero(s, cppEnum);
+
+ s << endl;
+}
+
+void CppGenerator::writeFlagsNumberMethodsDefinition(QTextStream& s, const AbstractMetaEnum* cppEnum)
+{
+ QString cpythonName = cpythonEnumName(cppEnum);
+
+ s << "static PyNumberMethods " << cpythonName << "_as_number = {" << endl;
+ s << INDENT << "/*nb_add*/ 0," << endl;
+ s << INDENT << "/*nb_subtract*/ 0," << endl;
+ s << INDENT << "/*nb_multiply*/ 0," << endl;
+ s << INDENT << "#ifndef IS_PY3K" << endl;
+ s << INDENT << "/* nb_divide */ 0," << endl;
+ s << INDENT << "#endif" << endl;
+ s << INDENT << "/*nb_remainder*/ 0," << endl;
+ s << INDENT << "/*nb_divmod*/ 0," << endl;
+ s << INDENT << "/*nb_power*/ 0," << endl;
+ s << INDENT << "/*nb_negative*/ 0," << endl;
+ s << INDENT << "/*nb_positive*/ 0," << endl;
+ s << INDENT << "/*nb_absolute*/ 0," << endl;
+ s << INDENT << "/*nb_nonzero*/ " << cpythonName << "__nonzero," << endl;
+ s << INDENT << "/*nb_invert*/ (unaryfunc)" << cpythonName << "___invert__," << endl;
+ s << INDENT << "/*nb_lshift*/ 0," << endl;
+ s << INDENT << "/*nb_rshift*/ 0," << endl;
+ s << INDENT << "/*nb_and*/ (binaryfunc)" << cpythonName << "___and__," << endl;
+ s << INDENT << "/*nb_xor*/ (binaryfunc)" << cpythonName << "___xor__," << endl;
+ s << INDENT << "/*nb_or*/ (binaryfunc)" << cpythonName << "___or__," << endl;
+ s << INDENT << "#ifndef IS_PY3K" << endl;
+ s << INDENT << "/* nb_coerce */ 0," << endl;
+ s << INDENT << "#endif" << endl;
+ s << INDENT << "/*nb_int*/ " << cpythonName << "_long," << endl;
+ s << INDENT << "#ifdef IS_PY3K" << endl;
+ s << INDENT << "/*nb_reserved*/ 0," << endl;
+ s << INDENT << "/*nb_float*/ 0," << endl;
+ s << INDENT << "#else" << endl;
+ s << INDENT << "/*nb_long*/ " << cpythonName << "_long," << endl;
+ s << INDENT << "/*nb_float*/ 0," << endl;
+ s << INDENT << "/*nb_oct*/ 0," << endl;
+ s << INDENT << "/*nb_hex*/ 0," << endl;
+ s << INDENT << "#endif" << endl;
+ s << INDENT << "/*nb_inplace_add*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_subtract*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_multiply*/ 0," << endl;
+ s << INDENT << "#ifndef IS_PY3K" << endl;
+ s << INDENT << "/*nb_inplace_divide*/ 0," << endl;
+ s << INDENT << "#endif" << endl;
+ s << INDENT << "/*nb_inplace_remainder*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_power*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_lshift*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_rshift*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_and*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_xor*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_or*/ 0," << endl;
+ s << INDENT << "/*nb_floor_divide*/ 0," << endl;
+ s << INDENT << "/*nb_true_divide*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_floor_divide*/ 0," << endl;
+ s << INDENT << "/*nb_inplace_true_divide*/ 0," << endl;
+ s << INDENT << "/*nb_index*/ 0" << endl;
+ s << "};" << endl << endl;
+}
+
+void CppGenerator::writeFlagsBinaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
+ QString pyOpName, QString cppOpName)
+{
+ FlagsTypeEntry* flagsEntry = cppEnum->typeEntry()->flags();
+ Q_ASSERT(flagsEntry);
+
+ s << "PyObject* " << cpythonEnumName(cppEnum) << "___" << pyOpName << "__(PyObject* " PYTHON_SELF_VAR ", PyObject* " PYTHON_ARG ")" << endl;
+ s << '{' << endl;
+
+ AbstractMetaType* flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
+ s << INDENT << "::" << flagsEntry->originalName() << " cppResult, " CPP_SELF_VAR ", cppArg;" << endl;
+ s << "#ifdef IS_PY3K" << endl;
+ s << INDENT << CPP_SELF_VAR " = (::" << flagsEntry->originalName() << ")(int)PyLong_AsLong(" PYTHON_SELF_VAR ");" << endl;
+ s << INDENT << "cppArg = (" << flagsEntry->originalName() << ")(int)PyLong_AsLong(" PYTHON_ARG ");" << endl;
+ s << "#else" << endl;
+ s << INDENT << CPP_SELF_VAR " = (::" << flagsEntry->originalName() << ")(int)PyInt_AsLong(" PYTHON_SELF_VAR ");" << endl;
+ s << INDENT << "cppArg = (" << flagsEntry->originalName() << ")(int)PyInt_AsLong(" PYTHON_ARG ");" << endl;
+ s << "#endif" << endl << endl;
+ s << INDENT << "cppResult = " CPP_SELF_VAR " " << cppOpName << " cppArg;" << endl;
+ s << INDENT << "return ";
+ writeToPythonConversion(s, flagsType, 0, QLatin1String("cppResult"));
+ s << ';' << endl;
+ s << '}' << endl << endl;
+}
+
+void CppGenerator::writeFlagsUnaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
+ QString pyOpName, QString cppOpName, bool boolResult)
+{
+ FlagsTypeEntry* flagsEntry = cppEnum->typeEntry()->flags();
+ Q_ASSERT(flagsEntry);
+
+ s << "PyObject* " << cpythonEnumName(cppEnum) << "___" << pyOpName << "__(PyObject* " PYTHON_SELF_VAR ", PyObject* " PYTHON_ARG ")" << endl;
+ s << '{' << endl;
+
+ AbstractMetaType* flagsType = buildAbstractMetaTypeFromTypeEntry(flagsEntry);
+ s << INDENT << "::" << flagsEntry->originalName() << " " CPP_SELF_VAR ";" << endl;
+ s << INDENT << cpythonToCppConversionFunction(flagsType) << PYTHON_SELF_VAR << ", &" CPP_SELF_VAR ");" << endl;
+ s << INDENT;
+ if (boolResult)
+ s << "bool";
+ else
+ s << "::" << flagsEntry->originalName();
+ s << " cppResult = " << cppOpName << CPP_SELF_VAR ";" << endl;
+ s << INDENT << "return ";
+ if (boolResult)
+ s << "PyBool_FromLong(cppResult)";
+ else
+ writeToPythonConversion(s, flagsType, 0, QLatin1String("cppResult"));
+ s << ';' << endl;
+ s << '}' << endl << endl;
+}
+
+QString CppGenerator::getInitFunctionName(GeneratorContext &context) const
+{
+ QString initFunctionName;
+ if (!context.forSmartPointer()) {
+ initFunctionName = context.metaClass()->qualifiedCppName();
+ initFunctionName.replace(QLatin1String("::"), QLatin1String("_"));
+ } else {
+ initFunctionName = getFilteredCppSignatureString(context.preciseType()->cppSignature());
+ }
+ return initFunctionName;
+}
+
+void CppGenerator::writeClassRegister(QTextStream &s,
+ const AbstractMetaClass *metaClass,
+ GeneratorContext &classContext)
+{
+ const ComplexTypeEntry* classTypeEntry = metaClass->typeEntry();
+
+ const AbstractMetaClass* enc = metaClass->enclosingClass();
+ bool hasEnclosingClass = enc && enc->typeEntry()->codeGeneration() != TypeEntry::GenerateForSubclass;
+ QString enclosingObjectVariable = hasEnclosingClass ? QLatin1String("enclosingClass") : QLatin1String("module");
+
+ QString pyTypeName = cpythonTypeName(metaClass);
+ QString initFunctionName = getInitFunctionName(classContext);
+ s << "void init_" << initFunctionName;
+ s << "(PyObject* " << enclosingObjectVariable << ")" << endl;
+ s << '{' << endl;
+
+ if (supportsNumberProtocol(metaClass)) {
+ s << INDENT << "// type has number operators" << endl;
+ writeTypeAsNumberDefinition(s, metaClass);
+ s << INDENT << pyTypeName << ".super.ht_type.tp_as_number = &" << pyTypeName << "AsNumber;" << endl;
+ s << endl;
+ }
+
+ if (supportsSequenceProtocol(metaClass)) {
+ s << INDENT << "// type supports sequence protocol" << endl;
+ writeTypeAsSequenceDefinition(s, metaClass);
+ s << INDENT << pyTypeName << ".super.ht_type.tp_as_sequence = &" << pyTypeName << "AsSequence;" << endl;
+ s << endl;
+ }
+
+ if (supportsMappingProtocol(metaClass)) {
+ s << INDENT << "// type supports mapping protocol" << endl;
+ writeTypeAsMappingDefinition(s, metaClass);
+ s << INDENT << pyTypeName << ".super.ht_type.tp_as_mapping = &" << pyTypeName << "AsMapping;" << endl;
+ s << endl;
+ }
+
+ if (!classContext.forSmartPointer())
+ s << INDENT << cpythonTypeNameExt(classTypeEntry);
+ else
+ s << INDENT << cpythonTypeNameExt(classContext.preciseType());
+
+ s << " = reinterpret_cast<PyTypeObject*>(&" << pyTypeName << ");" << endl;
+ s << endl;
+
+ // Multiple inheritance
+ QString pyTypeBasesVariable = pyTypeName + QLatin1String("_bases");
+ const AbstractMetaClassList baseClasses = getBaseClasses(metaClass);
+ if (metaClass->baseClassNames().size() > 1) {
+ s << INDENT << "PyObject* " << pyTypeBasesVariable << " = PyTuple_Pack(" << baseClasses.size() << ',' << endl;
+ QStringList bases;
+ foreach (const AbstractMetaClass* base, baseClasses)
+ bases << QLatin1String("(PyObject*)") + cpythonTypeNameExt(base->typeEntry());
+ Indentation indent(INDENT);
+ QString separator;
+ QTextStream sep(&separator);
+ sep << "," << endl << INDENT;
+ s << INDENT << bases.join(separator) << ");" << endl << endl;
+ }
+
+ // Create type and insert it in the module or enclosing class.
+ s << INDENT << "if (!Shiboken::ObjectType::introduceWrapperType(" << enclosingObjectVariable;
+ QString typeName;
+ if (!classContext.forSmartPointer())
+ typeName = metaClass->name();
+ else
+ typeName = classContext.preciseType()->cppSignature();
+
+ s << ", \"" << typeName << "\", \"";
+
+ // Original name
+ if (!classContext.forSmartPointer())
+ s << metaClass->qualifiedCppName() << (isObjectType(classTypeEntry) ? "*" : "");
+ else
+ s << classContext.preciseType()->cppSignature();
+
+ s << "\"," << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "&" << pyTypeName;
+
+ // Set destructor function
+ if (!metaClass->isNamespace() && !metaClass->hasPrivateDestructor()) {
+ QString dtorClassName = metaClass->qualifiedCppName();
+ if ((avoidProtectedHack() && metaClass->hasProtectedDestructor()) || classTypeEntry->isValue())
+ dtorClassName = wrapperName(metaClass);
+ if (classContext.forSmartPointer())
+ dtorClassName = wrapperName(classContext.preciseType());
+
+ s << ", &Shiboken::callCppDestructor< ::" << dtorClassName << " >";
+ } else if (metaClass->baseClass() || hasEnclosingClass) {
+ s << ", 0";
+ }
+
+ // Base type
+ if (metaClass->baseClass()) {
+ s << ", reinterpret_cast<SbkObjectType *>(" << cpythonTypeNameExt(metaClass->baseClass()->typeEntry()) << ')';
+ // The other base types
+ if (metaClass->baseClassNames().size() > 1)
+ s << ", " << pyTypeBasesVariable;
+ else if (hasEnclosingClass)
+ s << ", 0";
+ } else if (hasEnclosingClass) {
+ s << ", 0, 0";
+ }
+ if (hasEnclosingClass)
+ s << ", true";
+ s << ")) {" << endl;
+ s << INDENT << "return;" << endl;
+ }
+ s << INDENT << '}' << endl << endl;
+
+ // Register conversions for the type.
+ writeConverterRegister(s, metaClass, classContext);
+ s << endl;
+
+ // class inject-code target/beginning
+ if (!classTypeEntry->codeSnips().isEmpty()) {
+ writeCodeSnips(s, classTypeEntry->codeSnips(), TypeSystem::CodeSnipPositionBeginning, TypeSystem::TargetLangCode, metaClass);
+ s << endl;
+ }
+
+ // Fill multiple inheritance data, if needed.
+ const AbstractMetaClass* miClass = getMultipleInheritingClass(metaClass);
+ if (miClass) {
+ s << INDENT << "MultipleInheritanceInitFunction func = ";
+ if (miClass == metaClass) {
+ s << multipleInheritanceInitializerFunctionName(miClass) << ";" << endl;
+ } else {
+ s << "Shiboken::ObjectType::getMultipleIheritanceFunction(reinterpret_cast<SbkObjectType*>(";
+ s << cpythonTypeNameExt(miClass->typeEntry()) << "));" << endl;
+ }
+ s << INDENT << "Shiboken::ObjectType::setMultipleIheritanceFunction(&";
+ s << cpythonTypeName(metaClass) << ", func);" << endl;
+ s << INDENT << "Shiboken::ObjectType::setCastFunction(&" << cpythonTypeName(metaClass);
+ s << ", &" << cpythonSpecialCastFunctionName(metaClass) << ");" << endl;
+ }
+
+ // Set typediscovery struct or fill the struct of another one
+ if (metaClass->isPolymorphic() && metaClass->baseClass()) {
+ s << INDENT << "Shiboken::ObjectType::setTypeDiscoveryFunctionV2(&" << cpythonTypeName(metaClass);
+ s << ", &" << cpythonBaseName(metaClass) << "_typeDiscovery);" << endl << endl;
+ }
+
+ AbstractMetaEnumList classEnums = metaClass->enums();
+ foreach (AbstractMetaClass* innerClass, metaClass->innerClasses())
+ lookForEnumsInClassesNotToBeGenerated(classEnums, innerClass);
+
+ ErrorCode errorCode(QString::null);
+ writeEnumsInitialization(s, classEnums);
+
+ if (metaClass->hasSignals())
+ writeSignalInitialization(s, metaClass);
+
+ // Write static fields
+ foreach (const AbstractMetaField* field, metaClass->fields()) {
+ if (!field->isStatic())
+ continue;
+ s << INDENT << QLatin1String("PyDict_SetItemString(") + cpythonTypeName(metaClass) + QLatin1String(".super.ht_type.tp_dict, \"");
+ s << field->name() << "\", ";
+ writeToPythonConversion(s, field->type(), metaClass, metaClass->qualifiedCppName() + QLatin1String("::") + field->name());
+ s << ");" << endl;
+ }
+ s << endl;
+
+ // class inject-code target/end
+ if (!classTypeEntry->codeSnips().isEmpty()) {
+ s << endl;
+ writeCodeSnips(s, classTypeEntry->codeSnips(), TypeSystem::CodeSnipPositionEnd, TypeSystem::TargetLangCode, metaClass);
+ }
+
+ if (usePySideExtensions()) {
+ if (avoidProtectedHack() && shouldGenerateCppWrapper(metaClass))
+ s << INDENT << wrapperName(metaClass) << "::pysideInitQtMetaTypes();\n";
+ else
+ writeInitQtMetaTypeFunctionBody(s, classContext);
+ }
+
+ if (usePySideExtensions() && metaClass->isQObject()) {
+ s << INDENT << "Shiboken::ObjectType::setSubTypeInitHook(&" << pyTypeName << ", &PySide::initQObjectSubType);" << endl;
+ s << INDENT << "PySide::initDynamicMetaObject(&" << pyTypeName << ", &::" << metaClass->qualifiedCppName()
+ << "::staticMetaObject, sizeof(::" << metaClass->qualifiedCppName() << "));" << endl;
+ }
+
+ s << '}' << endl;
+}
+
+void CppGenerator::writeInitQtMetaTypeFunctionBody(QTextStream &s, GeneratorContext &context) const
+{
+ const AbstractMetaClass* metaClass = context.metaClass();
+ // Gets all class name variants used on different possible scopes
+ QStringList nameVariants;
+ if (!context.forSmartPointer())
+ nameVariants << metaClass->name();
+ else
+ nameVariants << context.preciseType()->cppSignature();
+
+ const AbstractMetaClass* enclosingClass = metaClass->enclosingClass();
+ while (enclosingClass) {
+ if (enclosingClass->typeEntry()->generateCode())
+ nameVariants << (enclosingClass->name() + QLatin1String("::") + nameVariants.last());
+ enclosingClass = enclosingClass->enclosingClass();
+ }
+
+ QString className;
+ if (!context.forSmartPointer())
+ className = metaClass->qualifiedCppName();
+ else
+ className = context.preciseType()->cppSignature();
+
+ if (!metaClass->isNamespace() && !metaClass->isAbstract()) {
+ // Qt metatypes are registered only on their first use, so we do this now.
+ bool canBeValue = false;
+ if (!isObjectType(metaClass)) {
+ // check if there's a empty ctor
+ foreach (AbstractMetaFunction* func, metaClass->functions()) {
+ if (func->isConstructor() && !func->arguments().count()) {
+ canBeValue = true;
+ break;
+ }
+ }
+ }
+
+ if (canBeValue) {
+ foreach (const QString &name, nameVariants) {
+ if (name == QLatin1String("iterator")) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << QString::fromLatin1("%1:%2 FIXME:\n"
+ " The code tried to qRegisterMetaType the unqualified name "
+ "'iterator'. This is currently fixed by a hack(ct) and needs improvement!")
+ .arg(QFile::decodeName(__FILE__)).arg(__LINE__);
+ continue;
+ }
+ s << INDENT << "qRegisterMetaType< ::" << className << " >(\"" << name << "\");" << endl;
+ }
+ }
+ }
+
+ foreach (AbstractMetaEnum* metaEnum, metaClass->enums()) {
+ if (!metaEnum->isPrivate() && !metaEnum->isAnonymous()) {
+ foreach (const QString &name, nameVariants)
+ s << INDENT << "qRegisterMetaType< ::" << metaEnum->typeEntry()->qualifiedCppName() << " >(\"" << name << "::" << metaEnum->name() << "\");" << endl;
+
+ if (metaEnum->typeEntry()->flags()) {
+ QString n = metaEnum->typeEntry()->flags()->originalName();
+ s << INDENT << "qRegisterMetaType< ::" << n << " >(\"" << n << "\");" << endl;
+ }
+ }
+ }
+}
+
+void CppGenerator::writeTypeDiscoveryFunction(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ QString polymorphicExpr = metaClass->typeEntry()->polymorphicIdValue();
+
+ s << "static void* " << cpythonBaseName(metaClass) << "_typeDiscovery(void* cptr, SbkObjectType* instanceType)\n{" << endl;
+
+ if (!polymorphicExpr.isEmpty()) {
+ polymorphicExpr = polymorphicExpr.replace(QLatin1String("%1"),
+ QLatin1String(" reinterpret_cast< ::")
+ + metaClass->qualifiedCppName()
+ + QLatin1String("*>(cptr)"));
+ s << INDENT << " if (" << polymorphicExpr << ")" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return cptr;" << endl;
+ }
+ } else if (metaClass->isPolymorphic()) {
+ AbstractMetaClassList ancestors = getAllAncestors(metaClass);
+ foreach (AbstractMetaClass* ancestor, ancestors) {
+ if (ancestor->baseClass())
+ continue;
+ if (ancestor->isPolymorphic()) {
+ s << INDENT << "if (instanceType == reinterpret_cast<SbkObjectType*>(Shiboken::SbkType< ::"
+ << ancestor->qualifiedCppName() << " >()))" << endl;
+ Indentation indent(INDENT);
+ s << INDENT << "return dynamic_cast< ::" << metaClass->qualifiedCppName()
+ << "*>(reinterpret_cast< ::"<< ancestor->qualifiedCppName() << "*>(cptr));" << endl;
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << metaClass->qualifiedCppName() << " inherits from a non polymorphic type ("
+ << ancestor->qualifiedCppName() << "), type discovery based on RTTI is "
+ "impossible, write a polymorphic-id-expression for this type.";
+ }
+
+ }
+ }
+ s << INDENT << "return 0;" << endl;
+ s << "}\n\n";
+}
+
+QString CppGenerator::writeSmartPointerGetterCast() {
+ return QLatin1String("const_cast<char *>(" SMART_POINTER_GETTER ")");
+}
+
+void CppGenerator::writeSetattroFunction(QTextStream &s, GeneratorContext &context)
+{
+ const AbstractMetaClass* metaClass = context.metaClass();
+ s << "static int " << cpythonSetattroFunctionName(metaClass) << "(PyObject* " PYTHON_SELF_VAR ", PyObject* name, PyObject* value)" << endl;
+ s << '{' << endl;
+ if (usePySideExtensions()) {
+ s << INDENT << "Shiboken::AutoDecRef pp(reinterpret_cast<PyObject*>(PySide::Property::getObject(" PYTHON_SELF_VAR ", name)));" << endl;
+ s << INDENT << "if (!pp.isNull())" << endl;
+ Indentation indent(INDENT);
+ s << INDENT << "return PySide::Property::setValue(reinterpret_cast<PySideProperty*>(pp.object()), " PYTHON_SELF_VAR ", value);" << endl;
+ }
+
+ if (context.forSmartPointer()) {
+ s << INDENT << "// Try to find the 'name' attribute, by retrieving the PyObject for the corresponding C++ object held by the smart pointer." << endl;
+ s << INDENT << "PyObject *rawObj = PyObject_CallMethod(" PYTHON_SELF_VAR ", "
+ << writeSmartPointerGetterCast() << ", 0);" << endl;
+ s << INDENT << "if (rawObj) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "int hasAttribute = PyObject_HasAttr(rawObj, name);" << endl;
+ s << INDENT << "if (hasAttribute) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return PyObject_GenericSetAttr(rawObj, name, value);" << endl;
+ }
+ s << INDENT << '}' << endl;
+ s << INDENT << "Py_DECREF(rawObj);" << endl;
+ }
+ s << INDENT << '}' << endl;
+
+ }
+
+ s << INDENT << "return PyObject_GenericSetAttr(" PYTHON_SELF_VAR ", name, value);" << endl;
+ s << '}' << endl;
+}
+
+static inline QString qObjectClassName() { return QStringLiteral("QObject"); }
+static inline QString qMetaObjectClassName() { return QStringLiteral("QMetaObject"); }
+
+void CppGenerator::writeGetattroFunction(QTextStream& s, GeneratorContext &context)
+{
+ const AbstractMetaClass* metaClass = context.metaClass();
+ s << "static PyObject* " << cpythonGetattroFunctionName(metaClass) << "(PyObject* " PYTHON_SELF_VAR ", PyObject* name)" << endl;
+ s << '{' << endl;
+
+ QString getattrFunc;
+ if (usePySideExtensions() && metaClass->isQObject()) {
+ AbstractMetaClass *qobjectClass = AbstractMetaClass::findClass(classes(), qObjectClassName());
+ getattrFunc = QString::fromLatin1("PySide::getMetaDataFromQObject(%1, " PYTHON_SELF_VAR ", name)")
+ .arg(cpythonWrapperCPtr(qobjectClass, QLatin1String(PYTHON_SELF_VAR)));
+ } else {
+ getattrFunc = QLatin1String("PyObject_GenericGetAttr(" PYTHON_SELF_VAR ", name)");
+ }
+
+ if (classNeedsGetattroFunction(metaClass)) {
+ s << INDENT << "if (" PYTHON_SELF_VAR ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "// Search the method in the instance dict" << endl;
+ s << INDENT << "if (reinterpret_cast<SbkObject*>(" PYTHON_SELF_VAR ")->ob_dict) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyObject* meth = PyDict_GetItem(reinterpret_cast<SbkObject*>(" PYTHON_SELF_VAR ")->ob_dict, name);" << endl;
+ s << INDENT << "if (meth) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "Py_INCREF(meth);" << endl;
+ s << INDENT << "return meth;" << endl;
+ }
+ s << INDENT << '}' << endl;
+ }
+ s << INDENT << '}' << endl;
+ s << INDENT << "// Search the method in the type dict" << endl;
+ s << INDENT << "if (Shiboken::Object::isUserType(" PYTHON_SELF_VAR ")) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyObject* meth = PyDict_GetItem(" PYTHON_SELF_VAR "->ob_type->tp_dict, name);" << endl;
+ s << INDENT << "if (meth)" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return PyFunction_Check(meth) ? SBK_PyMethod_New(meth, " PYTHON_SELF_VAR ") : " << getattrFunc << ';' << endl;
+ }
+ }
+ s << INDENT << '}' << endl;
+
+ foreach (const AbstractMetaFunction* func, getMethodsWithBothStaticAndNonStaticMethods(metaClass)) {
+ QString defName = cpythonMethodDefinitionName(func);
+ s << INDENT << "static PyMethodDef non_static_" << defName << " = {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << defName << ".ml_name," << endl;
+ s << INDENT << defName << ".ml_meth," << endl;
+ s << INDENT << defName << ".ml_flags & (~METH_STATIC)," << endl;
+ s << INDENT << defName << ".ml_doc," << endl;
+ }
+ s << INDENT << "};" << endl;
+ s << INDENT << "if (Shiboken::String::compare(name, \"" << func->name() << "\") == 0)" << endl;
+ Indentation indent(INDENT);
+ s << INDENT << "return PyCFunction_NewEx(&non_static_" << defName << ", " PYTHON_SELF_VAR ", 0);" << endl;
+ }
+ }
+ s << INDENT << '}' << endl;
+ }
+
+ if (context.forSmartPointer()) {
+ s << INDENT << "PyObject *tmp = " << getattrFunc << ';' << endl;
+ s << INDENT << "if (tmp) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return tmp;" << endl;
+ }
+ s << INDENT << "} else {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "if (!PyErr_ExceptionMatches(PyExc_AttributeError)) return NULL;" << endl;
+ s << INDENT << "PyErr_Clear();" << endl;
+
+ s << INDENT << "// Try to find the 'name' attribute, by retrieving the PyObject for "
+ "the corresponding C++ object held by the smart pointer." << endl;
+ s << INDENT << "PyObject *rawObj = PyObject_CallMethod(" PYTHON_SELF_VAR ", "
+ << writeSmartPointerGetterCast() << ", 0);" << endl;
+ s << INDENT << "if (rawObj) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyObject *attribute = PyObject_GetAttr(rawObj, name);" << endl;
+ s << INDENT << "if (attribute) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "tmp = attribute;" << endl;
+ }
+ s << INDENT << '}' << endl;
+ s << INDENT << "Py_DECREF(rawObj);" << endl;
+ }
+ s << INDENT << '}' << endl;
+ s << INDENT << "if (!tmp) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyTypeObject *tp = Py_TYPE(self);" << endl;
+ s << INDENT << "PyErr_Format(PyExc_AttributeError," << endl;
+ s << INDENT << " \"'%.50s' object has no attribute '%.400s'\"," << endl;
+ s << INDENT << " tp->tp_name, PyBytes_AS_STRING(name));" << endl;
+ s << INDENT << "return NULL;" << endl;
+ }
+ s << INDENT << "} else {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return tmp;" << endl;
+ }
+ s << INDENT << '}' << endl;
+
+ }
+ s << INDENT << '}' << endl;
+
+ } else {
+ s << INDENT << "return " << getattrFunc << ';' << endl;
+ }
+ s << '}' << endl;
+}
+
+bool CppGenerator::finishGeneration()
+{
+ //Generate CPython wrapper file
+ QString classInitDecl;
+ QTextStream s_classInitDecl(&classInitDecl);
+ QString classPythonDefines;
+ QTextStream s_classPythonDefines(&classPythonDefines);
+
+ QSet<Include> includes;
+ QString globalFunctionImpl;
+ QTextStream s_globalFunctionImpl(&globalFunctionImpl);
+ QString globalFunctionDecl;
+ QTextStream s_globalFunctionDef(&globalFunctionDecl);
+
+ Indentation indent(INDENT);
+
+ const FunctionGroupMap &functionGroups = getFunctionGroups();
+ for (FunctionGroupMapIt it = functionGroups.cbegin(), end = functionGroups.cend(); it != end; ++it) {
+ AbstractMetaFunctionList overloads;
+ foreach (AbstractMetaFunction* func, it.value()) {
+ if (!func->isModifiedRemoved()) {
+ overloads.append(func);
+ if (func->typeEntry())
+ includes << func->typeEntry()->include();
+ }
+ }
+
+ if (overloads.isEmpty())
+ continue;
+
+ // Dummy context to satisfy the API.
+ GeneratorContext classContext;
+ writeMethodWrapper(s_globalFunctionImpl, overloads, classContext);
+ writeMethodDefinition(s_globalFunctionDef, overloads);
+ }
+
+ //this is a temporary solution before new type revison implementation
+ //We need move QMetaObject register before QObject
+ Dependencies additionalDependencies;
+ const AbstractMetaClassList &allClasses = classes();
+ if (AbstractMetaClass::findClass(allClasses, qObjectClassName()) != Q_NULLPTR
+ && AbstractMetaClass::findClass(allClasses, qMetaObjectClassName()) != Q_NULLPTR) {
+ Dependency dependency;
+ dependency.parent = qMetaObjectClassName();
+ dependency.child = qObjectClassName();
+ additionalDependencies.append(dependency);
+ }
+ const AbstractMetaClassList lst = classesTopologicalSorted(additionalDependencies);
+
+ foreach (const AbstractMetaClass* cls, lst) {
+ if (!shouldGenerate(cls))
+ continue;
+
+ s_classInitDecl << "void init_" << cls->qualifiedCppName().replace(QLatin1String("::"), QLatin1String("_")) << "(PyObject* module);" << endl;
+
+ QString defineStr = QLatin1String("init_") + cls->qualifiedCppName().replace(QLatin1String("::"), QLatin1String("_"));
+
+ if (cls->enclosingClass() && (cls->enclosingClass()->typeEntry()->codeGeneration() != TypeEntry::GenerateForSubclass))
+ defineStr += QLatin1Char('(') + cpythonTypeNameExt(cls->enclosingClass()->typeEntry()) + QLatin1String("->tp_dict);");
+ else
+ defineStr += QLatin1String("(module);");
+ s_classPythonDefines << INDENT << defineStr << endl;
+ }
+
+ // Initialize smart pointer types.
+ foreach (const AbstractMetaType *metaType, instantiatedSmartPointers()) {
+ GeneratorContext context(0, metaType, true);
+ QString initFunctionName = getInitFunctionName(context);
+ s_classInitDecl << "void init_" << initFunctionName << "(PyObject* module);" << endl;
+ QString defineStr = QLatin1String("init_") + initFunctionName;
+ defineStr += QLatin1String("(module);");
+ s_classPythonDefines << INDENT << defineStr << endl;
+ }
+
+ QString moduleFileName(outputDirectory() + QLatin1Char('/') + subDirectoryForPackage(packageName()));
+ moduleFileName += QLatin1Char('/') + moduleName().toLower() + QLatin1String("_module_wrapper.cpp");
+
+ QFile file(moduleFileName);
+ verifyDirectoryFor(file);
+ if (!file.open(QFile::WriteOnly)) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Error writing file: " << QDir::toNativeSeparators(moduleFileName);
+ return false;
+ }
+
+ QTextStream s(&file);
+
+ // write license comment
+ s << licenseComment() << endl;
+
+ s << "#include <sbkpython.h>" << endl;
+ s << "#include <shiboken.h>" << endl;
+ s << "#include <algorithm>" << endl;
+ if (usePySideExtensions()) {
+ s << includeQDebug;
+ s << "#include <pyside.h>" << endl;
+ }
+
+ s << "#include \"" << getModuleHeaderFileName() << '"' << endl << endl;
+ foreach (const Include& include, includes)
+ s << include;
+ s << endl;
+
+ // Global enums
+ AbstractMetaEnumList globalEnums = this->globalEnums();
+ foreach (const AbstractMetaClass* metaClass, classes()) {
+ const AbstractMetaClass* encClass = metaClass->enclosingClass();
+ if (encClass && encClass->typeEntry()->codeGeneration() != TypeEntry::GenerateForSubclass)
+ continue;
+ lookForEnumsInClassesNotToBeGenerated(globalEnums, metaClass);
+ }
+
+ TypeDatabase* typeDb = TypeDatabase::instance();
+ TypeSystemTypeEntry* moduleEntry = reinterpret_cast<TypeSystemTypeEntry*>(typeDb->findType(packageName()));
+
+ //Extra includes
+ s << endl << "// Extra includes" << endl;
+ QList<Include> extraIncludes;
+ if (moduleEntry)
+ extraIncludes = moduleEntry->extraIncludes();
+ foreach (AbstractMetaEnum* cppEnum, globalEnums)
+ extraIncludes.append(cppEnum->typeEntry()->extraIncludes());
+ qSort(extraIncludes.begin(), extraIncludes.end());
+ foreach (const Include& inc, extraIncludes)
+ s << inc;
+ s << endl;
+
+ s << "// Current module's type array." << endl;
+ s << "PyTypeObject** " << cppApiVariableName() << ';' << endl;
+
+ s << "// Current module's converter array." << endl;
+ s << "SbkConverter** " << convertersVariableName() << ';' << endl;
+
+ CodeSnipList snips;
+ if (moduleEntry)
+ snips = moduleEntry->codeSnips();
+
+ // module inject-code native/beginning
+ if (!snips.isEmpty()) {
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::NativeCode);
+ s << endl;
+ }
+
+ // cleanup staticMetaObject attribute
+ if (usePySideExtensions()) {
+ s << "void cleanTypesAttributes(void) {" << endl;
+ s << INDENT << "for (int i = 0, imax = SBK_" << moduleName() << "_IDX_COUNT; i < imax; i++) {" << endl;
+ {
+ Indentation indentation(INDENT);
+ s << INDENT << "PyObject *pyType = reinterpret_cast<PyObject*>(" << cppApiVariableName() << "[i]);" << endl;
+ s << INDENT << "if (pyType && PyObject_HasAttrString(pyType, \"staticMetaObject\"))"<< endl;
+ {
+ Indentation indentation(INDENT);
+ s << INDENT << "PyObject_SetAttrString(pyType, \"staticMetaObject\", Py_None);" << endl;
+ }
+ }
+ s << INDENT << "}" << endl;
+ s << "}" << endl;
+ }
+
+ s << "// Global functions ";
+ s << "------------------------------------------------------------" << endl;
+ s << globalFunctionImpl << endl;
+
+ s << "static PyMethodDef " << moduleName() << "_methods[] = {" << endl;
+ s << globalFunctionDecl;
+ s << INDENT << "{0} // Sentinel" << endl << "};" << endl << endl;
+
+ s << "// Classes initialization functions ";
+ s << "------------------------------------------------------------" << endl;
+ s << classInitDecl << endl;
+
+ if (!globalEnums.isEmpty()) {
+ QString converterImpl;
+ QTextStream convImpl(&converterImpl);
+
+ s << "// Enum definitions ";
+ s << "------------------------------------------------------------" << endl;
+ foreach (const AbstractMetaEnum* cppEnum, globalEnums) {
+ if (cppEnum->isAnonymous() || cppEnum->isPrivate())
+ continue;
+ writeEnumConverterFunctions(s, cppEnum);
+ s << endl;
+ }
+
+ if (!converterImpl.isEmpty()) {
+ s << "// Enum converters ";
+ s << "------------------------------------------------------------" << endl;
+ s << "namespace Shiboken" << endl << '{' << endl;
+ s << converterImpl << endl;
+ s << "} // namespace Shiboken" << endl << endl;
+ }
+ }
+
+ QStringList requiredModules = typeDb->requiredTargetImports();
+ if (!requiredModules.isEmpty())
+ s << "// Required modules' type and converter arrays." << endl;
+ foreach (const QString& requiredModule, requiredModules) {
+ s << "PyTypeObject** " << cppApiVariableName(requiredModule) << ';' << endl;
+ s << "SbkConverter** " << convertersVariableName(requiredModule) << ';' << endl;
+ }
+ s << endl;
+
+ s << "// Module initialization ";
+ s << "------------------------------------------------------------" << endl;
+ ExtendedConverterData extendedConverters = getExtendedConverters();
+ if (!extendedConverters.isEmpty()) {
+ s << endl << "// Extended Converters." << endl << endl;
+ for (ExtendedConverterData::const_iterator it = extendedConverters.cbegin(), end = extendedConverters.cend(); it != end; ++it) {
+ const TypeEntry *externalType = it.key();
+ s << "// Extended implicit conversions for " << externalType->qualifiedTargetLangName() << '.' << endl;
+ foreach (const AbstractMetaClass* sourceClass, extendedConverters[externalType]) {
+ AbstractMetaType* sourceType = buildAbstractMetaTypeFromAbstractMetaClass(sourceClass);
+ AbstractMetaType* targetType = buildAbstractMetaTypeFromTypeEntry(externalType);
+ writePythonToCppConversionFunctions(s, sourceType, targetType);
+ }
+ }
+ }
+
+ QList<const CustomConversion*> typeConversions = getPrimitiveCustomConversions();
+ if (!typeConversions.isEmpty()) {
+ s << endl << "// Primitive Type converters." << endl << endl;
+ foreach (const CustomConversion* conversion, typeConversions) {
+ s << "// C++ to Python conversion for type '" << conversion->ownerType()->qualifiedCppName() << "'." << endl;
+ writeCppToPythonFunction(s, conversion);
+ writeCustomConverterFunctions(s, conversion);
+ }
+ s << endl;
+ }
+
+ QList<const AbstractMetaType*> containers = instantiatedContainers();
+ if (!containers.isEmpty()) {
+ s << "// Container Type converters." << endl << endl;
+ foreach (const AbstractMetaType* container, containers) {
+ s << "// C++ to Python conversion for type '" << container->cppSignature() << "'." << endl;
+ writeContainerConverterFunctions(s, container);
+ }
+ s << endl;
+ }
+
+ s << "#if defined _WIN32 || defined __CYGWIN__" << endl;
+ s << " #define SBK_EXPORT_MODULE __declspec(dllexport)" << endl;
+ s << "#elif __GNUC__ >= 4" << endl;
+ s << " #define SBK_EXPORT_MODULE __attribute__ ((visibility(\"default\")))" << endl;
+ s << "#else" << endl;
+ s << " #define SBK_EXPORT_MODULE" << endl;
+ s << "#endif" << endl << endl;
+
+ s << "#ifdef IS_PY3K" << endl;
+ s << "static struct PyModuleDef moduledef = {" << endl;
+ s << " /* m_base */ PyModuleDef_HEAD_INIT," << endl;
+ s << " /* m_name */ \"" << moduleName() << "\"," << endl;
+ s << " /* m_doc */ 0," << endl;
+ s << " /* m_size */ -1," << endl;
+ s << " /* m_methods */ " << moduleName() << "_methods," << endl;
+ s << " /* m_reload */ 0," << endl;
+ s << " /* m_traverse */ 0," << endl;
+ s << " /* m_clear */ 0," << endl;
+ s << " /* m_free */ 0" << endl;
+ s << "};" << endl << endl;
+ s << "#endif" << endl;
+ s << "SBK_MODULE_INIT_FUNCTION_BEGIN(" << moduleName() << ")" << endl;
+
+ ErrorCode errorCode(QLatin1String("SBK_MODULE_INIT_ERROR"));
+ // module inject-code target/beginning
+ if (!snips.isEmpty()) {
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::TargetLangCode);
+ s << endl;
+ }
+
+ foreach (const QString& requiredModule, typeDb->requiredTargetImports()) {
+ s << INDENT << "{" << endl;
+ {
+ Indentation indentation(INDENT);
+ s << INDENT << "Shiboken::AutoDecRef requiredModule(Shiboken::Module::import(\"" << requiredModule << "\"));" << endl;
+ s << INDENT << "if (requiredModule.isNull())" << endl;
+ {
+ Indentation indentation(INDENT);
+ s << INDENT << "return SBK_MODULE_INIT_ERROR;" << endl;
+ }
+ s << INDENT << cppApiVariableName(requiredModule) << " = Shiboken::Module::getTypes(requiredModule);" << endl;
+ s << INDENT << convertersVariableName(requiredModule) << " = Shiboken::Module::getTypeConverters(requiredModule);" << endl;
+ }
+ s << INDENT << "}" << endl << endl;
+ }
+
+ int maxTypeIndex = getMaxTypeIndex() + instantiatedSmartPointers().size();
+ if (maxTypeIndex) {
+ s << INDENT << "// Create an array of wrapper types for the current module." << endl;
+ s << INDENT << "static PyTypeObject* cppApi[SBK_" << moduleName() << "_IDX_COUNT];" << endl;
+ s << INDENT << cppApiVariableName() << " = cppApi;" << endl << endl;
+ }
+
+ s << INDENT << "// Create an array of primitive type converters for the current module." << endl;
+ s << INDENT << "static SbkConverter* sbkConverters[SBK_" << moduleName() << "_CONVERTERS_IDX_COUNT" << "];" << endl;
+ s << INDENT << convertersVariableName() << " = sbkConverters;" << endl << endl;
+
+ s << "#ifdef IS_PY3K" << endl;
+ s << INDENT << "PyObject* module = Shiboken::Module::create(\"" << moduleName() << "\", &moduledef);" << endl;
+ s << "#else" << endl;
+ s << INDENT << "PyObject* module = Shiboken::Module::create(\"" << moduleName() << "\", ";
+ s << moduleName() << "_methods);" << endl;
+ s << "#endif" << endl << endl;
+
+ //s << INDENT << "// Initialize converters for primitive types." << endl;
+ //s << INDENT << "initConverters();" << endl << endl;
+
+ s << INDENT << "// Initialize classes in the type system" << endl;
+ s << classPythonDefines;
+
+ if (!typeConversions.isEmpty()) {
+ s << endl;
+ foreach (const CustomConversion* conversion, typeConversions) {
+ writePrimitiveConverterInitialization(s, conversion);
+ s << endl;
+ }
+ }
+
+ if (!containers.isEmpty()) {
+ s << endl;
+ foreach (const AbstractMetaType* container, containers) {
+ writeContainerConverterInitialization(s, container);
+ s << endl;
+ }
+ }
+
+ if (!extendedConverters.isEmpty()) {
+ s << endl;
+ for (ExtendedConverterData::const_iterator it = extendedConverters.cbegin(), end = extendedConverters.cend(); it != end; ++it) {
+ writeExtendedConverterInitialization(s, it.key(), it.value());
+ s << endl;
+ }
+ }
+
+ writeEnumsInitialization(s, globalEnums);
+
+ s << INDENT << "// Register primitive types converters." << endl;
+ foreach(const PrimitiveTypeEntry* pte, primitiveTypes()) {
+ if (!pte->generateCode() || !pte->isCppPrimitive())
+ continue;
+ const TypeEntry *referencedType = pte->basicReferencedTypeEntry();
+ if (!referencedType)
+ continue;
+ QString converter = converterObject(referencedType);
+ QStringList cppSignature = pte->qualifiedCppName().split(QLatin1String("::"), QString::SkipEmptyParts);
+ while (!cppSignature.isEmpty()) {
+ QString signature = cppSignature.join(QLatin1String("::"));
+ s << INDENT << "Shiboken::Conversions::registerConverterName(" << converter << ", \"" << signature << "\");" << endl;
+ cppSignature.removeFirst();
+ }
+ }
+ // Register type resolver for all containers found in signals.
+ QSet<QByteArray> typeResolvers;
+ foreach (AbstractMetaClass* metaClass, classes()) {
+ if (!metaClass->isQObject() || !metaClass->typeEntry()->generateCode())
+ continue;
+ foreach (AbstractMetaFunction* func, metaClass->functions()) {
+ if (func->isSignal()) {
+ foreach (AbstractMetaArgument* arg, func->arguments()) {
+ if (arg->type()->isContainer()) {
+ QString value = translateType(arg->type(), metaClass, ExcludeConst | ExcludeReference);
+ if (value.startsWith(QLatin1String("::")))
+ value.remove(0, 2);
+ typeResolvers << QMetaObject::normalizedType(value.toUtf8().constData());
+ }
+ }
+ }
+ }
+ }
+
+ s << endl;
+ if (maxTypeIndex)
+ s << INDENT << "Shiboken::Module::registerTypes(module, " << cppApiVariableName() << ");" << endl;
+ s << INDENT << "Shiboken::Module::registerTypeConverters(module, " << convertersVariableName() << ");" << endl;
+
+ s << endl << INDENT << "if (PyErr_Occurred()) {" << endl;
+ {
+ Indentation indentation(INDENT);
+ s << INDENT << "PyErr_Print();" << endl;
+ s << INDENT << "Py_FatalError(\"can't initialize module " << moduleName() << "\");" << endl;
+ }
+ s << INDENT << '}' << endl;
+
+ // module inject-code target/end
+ if (!snips.isEmpty()) {
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionEnd, TypeSystem::TargetLangCode);
+ s << endl;
+ }
+
+ // module inject-code native/end
+ if (!snips.isEmpty()) {
+ writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionEnd, TypeSystem::NativeCode);
+ s << endl;
+ }
+
+ if (usePySideExtensions()) {
+ foreach (AbstractMetaEnum* metaEnum, globalEnums)
+ if (!metaEnum->isAnonymous()) {
+ s << INDENT << "qRegisterMetaType< ::" << metaEnum->typeEntry()->qualifiedCppName() << " >(\"" << metaEnum->name() << "\");" << endl;
+ }
+
+ // cleanup staticMetaObject attribute
+ s << INDENT << "PySide::registerCleanupFunction(cleanTypesAttributes);" << endl;
+ }
+
+ s << "SBK_MODULE_INIT_FUNCTION_END" << endl;
+
+ return true;
+}
+
+static ArgumentOwner getArgumentOwner(const AbstractMetaFunction* func, int argIndex)
+{
+ ArgumentOwner argOwner = func->argumentOwner(func->ownerClass(), argIndex);
+ if (argOwner.index == ArgumentOwner::InvalidIndex)
+ argOwner = func->argumentOwner(func->declaringClass(), argIndex);
+ return argOwner;
+}
+
+bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMetaFunction* func, int argIndex, bool useHeuristicPolicy)
+{
+ const int numArgs = func->arguments().count();
+ bool ctorHeuristicEnabled = func->isConstructor() && useCtorHeuristic() && useHeuristicPolicy;
+
+ bool usePyArgs = pythonFunctionWrapperUsesListOfArguments(OverloadData(getFunctionGroups(func->implementingClass())[func->name()], this));
+
+ ArgumentOwner argOwner = getArgumentOwner(func, argIndex);
+ ArgumentOwner::Action action = argOwner.action;
+ int parentIndex = argOwner.index;
+ int childIndex = argIndex;
+ if (ctorHeuristicEnabled && argIndex > 0 && numArgs) {
+ AbstractMetaArgument* arg = func->arguments().at(argIndex-1);
+ if (arg->name() == QLatin1String("parent") && isObjectType(arg->type())) {
+ action = ArgumentOwner::Add;
+ parentIndex = argIndex;
+ childIndex = -1;
+ }
+ }
+
+ QString parentVariable;
+ QString childVariable;
+ if (action != ArgumentOwner::Invalid) {
+ if (!usePyArgs && argIndex > 1)
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Argument index for parent tag out of bounds: " << func->signature();
+
+ if (action == ArgumentOwner::Remove) {
+ parentVariable = QLatin1String("Py_None");
+ } else {
+ if (parentIndex == 0) {
+ parentVariable = QLatin1String(PYTHON_RETURN_VAR);
+ } else if (parentIndex == -1) {
+ parentVariable = QLatin1String(PYTHON_SELF_VAR);
+ } else {
+ parentVariable = usePyArgs
+ ? QString::fromLatin1(PYTHON_ARGS "[%1]").arg(parentIndex - 1)
+ : QLatin1String(PYTHON_ARG);
+ }
+ }
+
+ if (childIndex == 0) {
+ childVariable = QLatin1String(PYTHON_RETURN_VAR);
+ } else if (childIndex == -1) {
+ childVariable = QLatin1String(PYTHON_SELF_VAR);
+ } else {
+ childVariable = usePyArgs
+ ? QString::fromLatin1(PYTHON_ARGS "[%1]").arg(childIndex - 1)
+ : QLatin1String(PYTHON_ARG);
+ }
+
+ s << INDENT << "Shiboken::Object::setParent(" << parentVariable << ", " << childVariable << ");\n";
+ return true;
+ }
+
+ return false;
+}
+
+void CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMetaFunction* func, bool useHeuristicForReturn)
+{
+ const int numArgs = func->arguments().count();
+
+ // -1 = return value
+ // 0 = self
+ // 1..n = func. args.
+ for (int i = -1; i <= numArgs; ++i)
+ writeParentChildManagement(s, func, i, useHeuristicForReturn);
+
+ if (useHeuristicForReturn)
+ writeReturnValueHeuristics(s, func);
+}
+
+void CppGenerator::writeReturnValueHeuristics(QTextStream& s, const AbstractMetaFunction* func, const QString& self)
+{
+ AbstractMetaType *type = func->type();
+ if (!useReturnValueHeuristic()
+ || !func->ownerClass()
+ || !type
+ || func->isStatic()
+ || func->isConstructor()
+ || !func->typeReplaced(0).isEmpty()) {
+ return;
+ }
+
+ ArgumentOwner argOwner = getArgumentOwner(func, ArgumentOwner::ReturnIndex);
+ if (argOwner.action == ArgumentOwner::Invalid || argOwner.index != ArgumentOwner::ThisIndex) {
+ if (isPointerToWrapperType(type))
+ s << INDENT << "Shiboken::Object::setParent(" << self << ", " PYTHON_RETURN_VAR ");" << endl;
+ }
+}
+
+void CppGenerator::writeHashFunction(QTextStream &s, GeneratorContext &context)
+{
+ const AbstractMetaClass *metaClass = context.metaClass();
+ s << "static Py_hash_t " << cpythonBaseName(metaClass) << "_HashFunc(PyObject* self) {" << endl;
+ writeCppSelfDefinition(s, context);
+ s << INDENT << "return " << metaClass->typeEntry()->hashFunction() << '(';
+ s << (isObjectType(metaClass) ? "" : "*") << CPP_SELF_VAR << ");" << endl;
+ s << '}' << endl << endl;
+}
+
+void CppGenerator::writeStdListWrapperMethods(QTextStream &s, GeneratorContext &context)
+{
+ const AbstractMetaClass *metaClass = context.metaClass();
+ ErrorCode errorCode(0);
+
+ // __len__
+ s << "Py_ssize_t " << cpythonBaseName(metaClass->typeEntry()) << "__len__(PyObject* " PYTHON_SELF_VAR ")" << endl;
+ s << '{' << endl;
+ writeCppSelfDefinition(s, context);
+ s << INDENT << "return " CPP_SELF_VAR "->size();" << endl;
+ s << '}' << endl;
+
+ // __getitem__
+ s << "PyObject* " << cpythonBaseName(metaClass->typeEntry()) << "__getitem__(PyObject* " PYTHON_SELF_VAR ", Py_ssize_t _i)" << endl;
+ s << '{' << endl;
+ writeCppSelfDefinition(s, context);
+ writeIndexError(s, QLatin1String("index out of bounds"));
+
+ s << INDENT << metaClass->qualifiedCppName() << "::iterator _item = " CPP_SELF_VAR "->begin();" << endl;
+ s << INDENT << "for (Py_ssize_t pos = 0; pos < _i; pos++) _item++;" << endl;
+
+ const AbstractMetaType* itemType = metaClass->templateBaseClassInstantiations().first();
+
+ s << INDENT << "return ";
+ writeToPythonConversion(s, itemType, metaClass, QLatin1String("*_item"));
+ s << ';' << endl;
+ s << '}' << endl;
+
+ // __setitem__
+ ErrorCode errorCode2(-1);
+ s << "int " << cpythonBaseName(metaClass->typeEntry()) << "__setitem__(PyObject* " PYTHON_SELF_VAR ", Py_ssize_t _i, PyObject* pyArg)" << endl;
+ s << '{' << endl;
+ writeCppSelfDefinition(s, context);
+ writeIndexError(s, QLatin1String("list assignment index out of range"));
+
+ s << INDENT << "PythonToCppFunc " << PYTHON_TO_CPP_VAR << ';' << endl;
+ s << INDENT << "if (!";
+ writeTypeCheck(s, itemType, QLatin1String("pyArg"), isNumber(itemType->typeEntry()));
+ s << ") {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyErr_SetString(PyExc_TypeError, \"attributed value with wrong type, '";
+ s << itemType->name() << "' or other convertible type expected\");" << endl;
+ s << INDENT << "return -1;" << endl;
+ }
+ s << INDENT << '}' << endl;
+ writeArgumentConversion(s, itemType, QLatin1String("cppValue"), QLatin1String("pyArg"), metaClass);
+
+ s << INDENT << metaClass->qualifiedCppName() << "::iterator _item = " CPP_SELF_VAR "->begin();" << endl;
+ s << INDENT << "for (Py_ssize_t pos = 0; pos < _i; pos++) _item++;" << endl;
+ s << INDENT << "*_item = cppValue;" << endl;
+ s << INDENT << "return 0;" << endl;
+ s << '}' << endl;
+}
+void CppGenerator::writeIndexError(QTextStream& s, const QString& errorMsg)
+{
+ s << INDENT << "if (_i < 0 || _i >= (Py_ssize_t) " CPP_SELF_VAR "->size()) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "PyErr_SetString(PyExc_IndexError, \"" << errorMsg << "\");" << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
+ }
+ s << INDENT << '}' << endl;
+}
+
+QString CppGenerator::writeReprFunction(QTextStream &s, GeneratorContext &context)
+{
+ const AbstractMetaClass *metaClass = context.metaClass();
+ QString funcName = cpythonBaseName(metaClass) + QLatin1String("__repr__");
+ s << "extern \"C\"" << endl;
+ s << '{' << endl;
+ s << "static PyObject* " << funcName << "(PyObject* self)" << endl;
+ s << '{' << endl;
+ writeCppSelfDefinition(s, context);
+ s << INDENT << "QBuffer buffer;" << endl;
+ s << INDENT << "buffer.open(QBuffer::ReadWrite);" << endl;
+ s << INDENT << "QDebug dbg(&buffer);" << endl;
+ s << INDENT << "dbg << " << (metaClass->typeEntry()->isValue() ? "*" : "") << CPP_SELF_VAR ";" << endl;
+ s << INDENT << "buffer.close();" << endl;
+ s << INDENT << "QByteArray str = buffer.data();" << endl;
+ s << INDENT << "int idx = str.indexOf('(');" << endl;
+ s << INDENT << "if (idx >= 0)" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "str.replace(0, idx, Py_TYPE(self)->tp_name);" << endl;
+ }
+ s << INDENT << "PyObject* mod = PyDict_GetItemString(Py_TYPE(self)->tp_dict, \"__module__\");" << endl;
+ s << INDENT << "if (mod)" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return Shiboken::String::fromFormat(\"<%s.%s at %p>\", Shiboken::String::toCString(mod), str.constData(), self);" << endl;
+ }
+ s << INDENT << "else" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return Shiboken::String::fromFormat(\"<%s at %p>\", str.constData(), self);" << endl;
+ }
+ s << '}' << endl;
+ s << "} // extern C" << endl << endl;;
+ return funcName;
+}
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.h b/sources/shiboken2/generator/shiboken2/cppgenerator.h
new file mode 100644
index 000000000..5dc3f5a15
--- /dev/null
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.h
@@ -0,0 +1,370 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CPPGENERATOR_H
+#define CPPGENERATOR_H
+
+#include "shibokengenerator.h"
+
+/**
+ * The CppGenerator generate the implementations of C++ bindings classes.
+ */
+class CppGenerator : public ShibokenGenerator
+{
+public:
+ CppGenerator();
+protected:
+ QString fileNamePrefix() const;
+ QString fileNameForContext(GeneratorContext &context) const;
+ QList<AbstractMetaFunctionList> filterGroupedOperatorFunctions(const AbstractMetaClass* metaClass,
+ uint query);
+ void generateClass(QTextStream& s, GeneratorContext &classContext);
+ bool finishGeneration();
+
+private:
+ void writeConstructorNative(QTextStream& s, const AbstractMetaFunction* func);
+ void writeDestructorNative(QTextStream& s, const AbstractMetaClass* metaClass);
+
+ QString getVirtualFunctionReturnTypeName(const AbstractMetaFunction* func);
+ void writeVirtualMethodNative(QTextStream& s, const AbstractMetaFunction* func);
+
+ void writeMetaObjectMethod(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeMetaCast(QTextStream& s, const AbstractMetaClass* metaClass);
+
+ void writeEnumConverterFunctions(QTextStream& s, const TypeEntry* enumType);
+ void writeEnumConverterFunctions(QTextStream& s, const AbstractMetaEnum* metaEnum);
+ void writeConverterFunctions(QTextStream &s, const AbstractMetaClass *metaClass,
+ GeneratorContext &classContext);
+ void writeCustomConverterFunctions(QTextStream& s, const CustomConversion* customConversion);
+ void writeConverterRegister(QTextStream &s, const AbstractMetaClass *metaClass,
+ GeneratorContext &classContext);
+ void writeCustomConverterRegister(QTextStream& s, const CustomConversion* customConversion, const QString& converterVar);
+ void writeContainerConverterRegister(QTextStream& s, const AbstractMetaType* container, const QString& converterVar);
+
+ void writeContainerConverterFunctions(QTextStream& s, const AbstractMetaType* containerType);
+
+ void writeMethodWrapperPreamble(QTextStream &s, OverloadData &overloadData,
+ GeneratorContext &context);
+ void writeConstructorWrapper(QTextStream &s, const AbstractMetaFunctionList overloads, GeneratorContext &classContext);
+ void writeDestructorWrapper(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeMethodWrapper(QTextStream &s, const AbstractMetaFunctionList overloads,
+ GeneratorContext &classContext);
+ void writeArgumentsInitializer(QTextStream& s, OverloadData& overloadData);
+ void writeCppSelfDefinition(QTextStream &s,
+ const AbstractMetaFunction *func,
+ GeneratorContext &context,
+ bool hasStaticOverload = false);
+ void writeCppSelfDefinition(QTextStream &s,
+ GeneratorContext &context,
+ bool hasStaticOverload = false,
+ bool cppSelfAsReference = false);
+
+ void writeErrorSection(QTextStream& s, OverloadData& overloadData);
+ void writeFunctionReturnErrorCheckSection(QTextStream& s, bool hasReturnValue = true);
+
+ /// Writes the check section for the validity of wrapped C++ objects.
+ void writeInvalidPyObjectCheck(QTextStream& s, const QString& pyObj);
+
+ void writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, bool isNumber = false, QString customType = QString(), bool rejectNull = false);
+ void writeTypeCheck(QTextStream& s, const OverloadData* overloadData, QString argumentName);
+
+ void writeTypeDiscoveryFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+
+ void writeSetattroFunction(QTextStream &s, GeneratorContext &context);
+ void writeGetattroFunction(QTextStream &s, GeneratorContext &context);
+ QString writeSmartPointerGetterCast();
+
+ /**
+ * Writes Python to C++ conversions for arguments on Python wrappers.
+ * If implicit conversions, and thus new object allocation, are needed,
+ * code to deallocate a possible new instance is also generated.
+ * \param s text stream to write
+ * \param argType a pointer to the argument type to be converted
+ * \param argName C++ argument name
+ * \param pyArgName Python argument name
+ * \param context the current meta class
+ * \param defaultValue an optional default value to be used instead of the conversion result
+ * \param castArgumentAsUnused if true the converted argument is cast as unused to avoid compiler warnings
+ */
+ void writeArgumentConversion(QTextStream& s, const AbstractMetaType* argType,
+ const QString& argName, const QString& pyArgName,
+ const AbstractMetaClass* context = 0,
+ const QString& defaultValue = QString(),
+ bool castArgumentAsUnused = false);
+
+ /**
+ * Returns the AbstractMetaType for a function argument.
+ * If the argument type was modified in the type system, this method will
+ * try to build a new type based on the type name defined in the type system.
+ * \param func The function which owns the argument.
+ * \param argPos Argument position in the function signature.
+ * Note that the position 0 represents the return value, and the function
+ * parameters start counting on 1.
+ * \param newType It is set to true if the type returned is a new object that must be deallocated.
+ * \return The type of the argument indicated by \p argPos.
+ */
+ const AbstractMetaType* getArgumentType(const AbstractMetaFunction* func, int argPos);
+
+ void writePythonToCppTypeConversion(QTextStream& s,
+ const AbstractMetaType* type,
+ const QString& pyIn,
+ const QString& cppOut,
+ const AbstractMetaClass* context = 0,
+ const QString& defaultValue = QString());
+
+ /// Writes the conversion rule for arguments of regular and virtual methods.
+ void writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language);
+ /// Writes the conversion rule for the return value of a method.
+ void writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language, const QString& outputVar);
+
+ /**
+ * Set the Python method wrapper return value variable to Py_None if
+ * there are return types different from void in any of the other overloads
+ * for the function passed as parameter.
+ * \param s text stream to write
+ * \param func a pointer to the function that will possibly return Py_None
+ * \param thereIsReturnValue indicates if the return type of any of the other overloads
+ * for this function is different from 'void'
+ */
+ void writeNoneReturn(QTextStream& s, const AbstractMetaFunction* func, bool thereIsReturnValue);
+
+ /**
+ * Writes the Python function wrapper overload decisor that selects which C++
+ * method/function to call with the received Python arguments.
+ * \param s text stream to write
+ * \param overloadData the overload data describing all the possible overloads for the function/method
+ */
+ void writeOverloadedFunctionDecisor(QTextStream& s, const OverloadData& overloadData);
+ /// Recursive auxiliar method to the other writeOverloadedFunctionDecisor.
+ void writeOverloadedFunctionDecisorEngine(QTextStream& s, const OverloadData* parentOverloadData);
+
+ /// Writes calls to all the possible method/function overloads.
+ void writeFunctionCalls(QTextStream &s,
+ const OverloadData &overloadData,
+ GeneratorContext &context);
+
+ /// Writes the call to a single function usually from a collection of overloads.
+ void writeSingleFunctionCall(QTextStream &s,
+ const OverloadData &overloadData,
+ const AbstractMetaFunction *func,
+ GeneratorContext &context);
+
+ /// Returns the name of a C++ to Python conversion function.
+ static QString cppToPythonFunctionName(const QString& sourceTypeName, QString targetTypeName = QString());
+
+ /// Returns the name of a Python to C++ conversion function.
+ static QString pythonToCppFunctionName(const QString& sourceTypeName, const QString& targetTypeName);
+ static QString pythonToCppFunctionName(const AbstractMetaType* sourceType, const AbstractMetaType* targetType);
+ static QString pythonToCppFunctionName(const CustomConversion::TargetToNativeConversion* toNative, const TypeEntry* targetType);
+
+ /// Returns the name of a Python to C++ convertible check function.
+ static QString convertibleToCppFunctionName(const QString& sourceTypeName, const QString& targetTypeName);
+ static QString convertibleToCppFunctionName(const AbstractMetaType* sourceType, const AbstractMetaType* targetType);
+ static QString convertibleToCppFunctionName(const CustomConversion::TargetToNativeConversion* toNative, const TypeEntry* targetType);
+
+ /// Writes a C++ to Python conversion function.
+ void writeCppToPythonFunction(QTextStream& s, const QString& code, const QString& sourceTypeName, QString targetTypeName = QString());
+ void writeCppToPythonFunction(QTextStream& s, const CustomConversion* customConversion);
+ void writeCppToPythonFunction(QTextStream& s, const AbstractMetaType* containerType);
+
+ /// Writes a Python to C++ conversion function.
+ void writePythonToCppFunction(QTextStream& s, const QString& code, const QString& sourceTypeName, const QString& targetTypeName);
+
+ /// Writes a Python to C++ convertible check function.
+ void writeIsPythonConvertibleToCppFunction(QTextStream& s,
+ const QString& sourceTypeName,
+ const QString& targetTypeName,
+ const QString& condition,
+ QString pythonToCppFuncName = QString(),
+ bool acceptNoneAsCppNull = false);
+
+ /// Writes a pair of Python to C++ conversion and check functions.
+ void writePythonToCppConversionFunctions(QTextStream& s,
+ const AbstractMetaType* sourceType,
+ const AbstractMetaType* targetType,
+ QString typeCheck = QString(),
+ QString conversion = QString(),
+ QString preConversion = QString());
+ /// Writes a pair of Python to C++ conversion and check functions for implicit conversions.
+ void writePythonToCppConversionFunctions(QTextStream& s,
+ const CustomConversion::TargetToNativeConversion* toNative,
+ const TypeEntry* targetType);
+
+ /// Writes a pair of Python to C++ conversion and check functions for instantiated container types.
+ void writePythonToCppConversionFunctions(QTextStream& s, const AbstractMetaType* containerType);
+
+ void writeAddPythonToCppConversion(QTextStream& s, const QString& converterVar, const QString& pythonToCppFunc, const QString& isConvertibleFunc);
+
+ void writeNamedArgumentResolution(QTextStream& s, const AbstractMetaFunction* func, bool usePyArgs);
+
+ /// Returns a string containing the name of an argument for the given function and argument index.
+ QString argumentNameFromIndex(const AbstractMetaFunction* func, int argIndex, const AbstractMetaClass** wrappedClass);
+ void writeMethodCall(QTextStream &s, const AbstractMetaFunction *func,
+ GeneratorContext &context, int maxArgs = 0);
+
+ QString getInitFunctionName(GeneratorContext &context) const;
+
+ void writeClassRegister(QTextStream &s,
+ const AbstractMetaClass *metaClass,
+ GeneratorContext &classContext);
+ void writeClassDefinition(QTextStream &s,
+ const AbstractMetaClass *metaClass,
+ GeneratorContext &classContext);
+ void writeMethodDefinitionEntry(QTextStream& s, const AbstractMetaFunctionList overloads);
+ void writeMethodDefinition(QTextStream& s, const AbstractMetaFunctionList overloads);
+
+ /// Writes the implementation of all methods part of python sequence protocol
+ void writeSequenceMethods(QTextStream &s,
+ const AbstractMetaClass *metaClass,
+ GeneratorContext &context);
+ void writeTypeAsSequenceDefinition(QTextStream& s, const AbstractMetaClass* metaClass);
+
+ /// Writes the PyMappingMethods structure for types that supports the python mapping protocol.
+ void writeTypeAsMappingDefinition(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeMappingMethods(QTextStream &s,
+ const AbstractMetaClass *metaClass,
+ GeneratorContext &context);
+
+ void writeTypeAsNumberDefinition(QTextStream& s, const AbstractMetaClass* metaClass);
+
+ void writeTpTraverseFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeTpClearFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+
+ void writeCopyFunction(QTextStream &s, GeneratorContext &context);
+
+ void writeGetterFunction(QTextStream &s,
+ const AbstractMetaField *metaField,
+ GeneratorContext &context);
+ void writeSetterFunction(QTextStream &s,
+ const AbstractMetaField *metaField,
+ GeneratorContext &context);
+
+ void writeRichCompareFunction(QTextStream &s, GeneratorContext &context);
+ void writeToPythonFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+
+ void writeEnumsInitialization(QTextStream& s, AbstractMetaEnumList& enums);
+ void writeEnumInitialization(QTextStream& s, const AbstractMetaEnum* metaEnum);
+
+ void writeSignalInitialization(QTextStream& s, const AbstractMetaClass* metaClass);
+
+ void writeFlagsMethods(QTextStream& s, const AbstractMetaEnum* cppEnum);
+ void writeFlagsToLong(QTextStream& s, const AbstractMetaEnum* cppEnum);
+ void writeFlagsNonZero(QTextStream& s, const AbstractMetaEnum* cppEnum);
+ void writeFlagsNumberMethodsDefinition(QTextStream& s, const AbstractMetaEnum* cppEnum);
+ void writeFlagsBinaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
+ QString pyOpName, QString cppOpName);
+ void writeFlagsUnaryOperator(QTextStream& s, const AbstractMetaEnum* cppEnum,
+ QString pyOpName, QString cppOpName, bool boolResult = false);
+
+ /// Writes the function that registers the multiple inheritance information for the classes that need it.
+ void writeMultipleInheritanceInitializerFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+ /// Writes the implementation of special cast functions, used when we need to cast a class with multiple inheritance.
+ void writeSpecialCastFunction(QTextStream& s, const AbstractMetaClass* metaClass);
+
+ void writePrimitiveConverterInitialization(QTextStream& s, const CustomConversion* customConversion);
+ void writeEnumConverterInitialization(QTextStream& s, const TypeEntry* enumType);
+ void writeEnumConverterInitialization(QTextStream& s, const AbstractMetaEnum* metaEnum);
+ void writeContainerConverterInitialization(QTextStream& s, const AbstractMetaType* type);
+ void writeExtendedConverterInitialization(QTextStream& s, const TypeEntry* externalType, const QList<const AbstractMetaClass*>& conversions);
+
+ void writeParentChildManagement(QTextStream& s, const AbstractMetaFunction* func, bool userHeuristicForReturn);
+ bool writeParentChildManagement(QTextStream& s, const AbstractMetaFunction* func, int argIndex, bool userHeuristicPolicy);
+ void writeReturnValueHeuristics(QTextStream& s, const AbstractMetaFunction* func, const QString& self = QLatin1String(PYTHON_SELF_VAR));
+ void writeInitQtMetaTypeFunctionBody(QTextStream &s, GeneratorContext &context) const;
+
+ /**
+ * Returns the multiple inheritance initializer function for the given class.
+ * \param metaClass the class for whom the function name must be generated.
+ * \return name of the multiple inheritance information initializer function or
+ * an empty string if there is no multiple inheritance in its ancestry.
+ */
+ QString multipleInheritanceInitializerFunctionName(const AbstractMetaClass* metaClass);
+
+ /// Returns a list of all classes to which the given class could be cast.
+ QStringList getAncestorMultipleInheritance(const AbstractMetaClass* metaClass);
+
+ /// Returns true if the given class supports the python number protocol
+ bool supportsNumberProtocol(const AbstractMetaClass* metaClass);
+
+ /// Returns true if the given class supports the python sequence protocol
+ bool supportsSequenceProtocol(const AbstractMetaClass* metaClass);
+
+ /// Returns true if the given class supports the python mapping protocol
+ bool supportsMappingProtocol(const AbstractMetaClass* metaClass);
+
+ /// Returns true if generator should produce getters and setters for the given class.
+ bool shouldGenerateGetSetList(const AbstractMetaClass* metaClass);
+
+ void writeHashFunction(QTextStream &s, GeneratorContext &context);
+
+ /// Write default implementations for sequence protocol
+ void writeStdListWrapperMethods(QTextStream &s, GeneratorContext &context);
+ /// Helper function for writeStdListWrapperMethods.
+ void writeIndexError(QTextStream& s, const QString& errorMsg);
+
+ QString writeReprFunction(QTextStream &s, GeneratorContext &context);
+
+ bool hasBoolCast(const AbstractMetaClass* metaClass) const;
+
+ // Number protocol structure members names.
+ static QHash<QString, QString> m_nbFuncs;
+
+ // Maps special function names to function parameters and return types
+ // used by CPython API in the sequence protocol.
+ QHash<QString, QPair<QString, QString> > m_sequenceProtocol;
+ // Sequence protocol structure members names.
+ static QHash<QString, QString> m_sqFuncs;
+
+ // Maps special function names to function parameters and return types
+ // used by CPython API in the mapping protocol.
+ QHash<QString, QPair<QString, QString> > m_mappingProtocol;
+ // Mapping protocol structure members names.
+ static QHash<QString, QString> m_mpFuncs;
+
+ static QString m_currentErrorCode;
+
+ /// Helper class to set and restore the current error code.
+ class ErrorCode {
+ public:
+ explicit ErrorCode(QString errorCode) {
+ m_savedErrorCode = CppGenerator::m_currentErrorCode;
+ CppGenerator::m_currentErrorCode = errorCode;
+ }
+ explicit ErrorCode(int errorCode) {
+ m_savedErrorCode = CppGenerator::m_currentErrorCode;
+ CppGenerator::m_currentErrorCode = QString::number(errorCode);
+ }
+ ~ErrorCode() {
+ CppGenerator::m_currentErrorCode = m_savedErrorCode;
+ }
+ private:
+ QString m_savedErrorCode;
+ };
+};
+
+#endif // CPPGENERATOR_H
diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.cpp b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
new file mode 100644
index 000000000..5ef5d5612
--- /dev/null
+++ b/sources/shiboken2/generator/shiboken2/headergenerator.cpp
@@ -0,0 +1,558 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "headergenerator.h"
+#include <abstractmetalang.h>
+#include <typedatabase.h>
+#include <reporthandler.h>
+#include <fileout.h>
+
+#include <QtCore/QDir>
+#include <QtCore/QTextStream>
+#include <QtCore/QVariant>
+#include <QtCore/QRegExp>
+#include <QtCore/QDebug>
+
+QString HeaderGenerator::fileNamePrefix() const
+{
+ return QLatin1String("_wrapper.h");
+}
+
+QString HeaderGenerator::fileNameForContext(GeneratorContext &context) const
+{
+ const AbstractMetaClass *metaClass = context.metaClass();
+ if (!context.forSmartPointer()) {
+ QString fileNameBase = metaClass->qualifiedCppName().toLower();
+ fileNameBase.replace(QLatin1String("::"), QLatin1String("_"));
+ return fileNameBase + fileNamePrefix();
+ } else {
+ const AbstractMetaType *smartPointerType = context.preciseType();
+ QString fileNameBase = getFileNameBaseForSmartPointer(smartPointerType, metaClass);
+ return fileNameBase + fileNamePrefix();
+ }
+}
+
+void HeaderGenerator::writeCopyCtor(QTextStream& s, const AbstractMetaClass* metaClass) const
+{
+ s << INDENT << wrapperName(metaClass) << "(const " << metaClass->qualifiedCppName() << "& self)";
+ s << " : " << metaClass->qualifiedCppName() << "(self)" << endl;
+ s << INDENT << "{" << endl;
+ s << INDENT << "}" << endl << endl;
+}
+
+void HeaderGenerator::writeProtectedFieldAccessors(QTextStream& s, const AbstractMetaField* field) const
+{
+ AbstractMetaType *metaType = field->type();
+ QString fieldType = metaType->cppSignature();
+ QString fieldName = field->enclosingClass()->qualifiedCppName() + QLatin1String("::") + field->name();
+
+ // Force use of pointer to return internal variable memory
+ bool useReference = (!metaType->isConstant() &&
+ !metaType->isEnum() &&
+ !metaType->isPrimitive() &&
+ metaType->indirections() == 0);
+
+
+ // Get function
+ s << INDENT << "inline " << fieldType
+ << (useReference ? '*' : ' ')
+ << ' ' << protectedFieldGetterName(field) << "()"
+ << " { return "
+ << (useReference ? '&' : ' ') << "this->" << fieldName << "; }" << endl;
+
+ // Set function
+ s << INDENT << "inline void " << protectedFieldSetterName(field) << '(' << fieldType << " value)"
+ << " { " << fieldName << " = value; }" << endl;
+}
+
+void HeaderGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
+{
+ AbstractMetaClass *metaClass = classContext.metaClass();
+ if (ReportHandler::isDebug(ReportHandler::SparseDebug))
+ qCDebug(lcShiboken) << "Generating header for " << metaClass->fullName();
+ m_inheritedOverloads.clear();
+ Indentation indent(INDENT);
+
+ // write license comment
+ s << licenseComment();
+
+ QString wrapperName;
+ if (!classContext.forSmartPointer()) {
+ wrapperName = HeaderGenerator::wrapperName(metaClass);
+ } else {
+ wrapperName = HeaderGenerator::wrapperName(classContext.preciseType());
+ }
+ QString headerGuard = getFilteredCppSignatureString(wrapperName).toUpper();
+
+ // Header
+ s << "#ifndef SBK_" << headerGuard << "_H" << endl;
+ s << "#define SBK_" << headerGuard << "_H" << endl<< endl;
+
+ if (!avoidProtectedHack())
+ s << "#define protected public" << endl << endl;
+
+ s << "#include <shiboken.h>" << endl << endl;
+
+ //Includes
+ s << metaClass->typeEntry()->include() << endl;
+
+ if (shouldGenerateCppWrapper(metaClass)) {
+
+ if (usePySideExtensions() && metaClass->isQObject())
+ s << "namespace PySide { class DynamicQMetaObject; }\n\n";
+
+ // Class
+ s << "class " << wrapperName;
+ s << " : public " << metaClass->qualifiedCppName();
+
+ s << endl << '{' << endl << "public:" << endl;
+
+ bool hasVirtualFunction = false;
+ foreach (AbstractMetaFunction *func, filterFunctions(metaClass)) {
+ if (func->isVirtual())
+ hasVirtualFunction = true;
+ writeFunction(s, func);
+ }
+
+ if (avoidProtectedHack() && metaClass->hasProtectedFields()) {
+ foreach (AbstractMetaField* field, metaClass->fields()) {
+ if (!field->isProtected())
+ continue;
+ writeProtectedFieldAccessors(s, field);
+ }
+ }
+
+ //destructor
+ // PYSIDE-504: When C++ 11 is used, then the destructor must always be written.
+ // See generator.h for further reference.
+ if (!avoidProtectedHack() || !metaClass->hasPrivateDestructor() || alwaysGenerateDestructor) {
+ s << INDENT;
+ if (avoidProtectedHack() && metaClass->hasPrivateDestructor())
+ s << "// C++11: need to declare (unimplemented) destructor because "
+ "the base class destructor is private." << endl;
+ if (metaClass->hasVirtualDestructor() || hasVirtualFunction)
+ s << "virtual ";
+ s << '~' << wrapperName << "();" << endl;
+ }
+
+ writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), TypeSystem::CodeSnipPositionDeclaration, TypeSystem::NativeCode);
+
+ if ((!avoidProtectedHack() || !metaClass->hasPrivateDestructor())
+ && usePySideExtensions() && metaClass->isQObject()) {
+ s << "public:\n";
+ s << INDENT << "virtual int qt_metacall(QMetaObject::Call call, int id, void** args);" << endl;
+ s << INDENT << "virtual void* qt_metacast(const char* _clname);" << endl;
+ }
+
+ if (m_inheritedOverloads.size()) {
+ s << INDENT << "// Inherited overloads, because the using keyword sux" << endl;
+ writeInheritedOverloads(s);
+ }
+
+ if (usePySideExtensions())
+ s << INDENT << "static void pysideInitQtMetaTypes();" << endl;
+
+ s << "};" << endl << endl;
+ }
+
+ s << "#endif // SBK_" << headerGuard << "_H" << endl << endl;
+}
+
+void HeaderGenerator::writeFunction(QTextStream& s, const AbstractMetaFunction* func)
+{
+
+ // do not write copy ctors here.
+ if (!func->isPrivate() && func->functionType() == AbstractMetaFunction::CopyConstructorFunction) {
+ writeCopyCtor(s, func->ownerClass());
+ return;
+ }
+ if (func->isUserAdded())
+ return;
+
+ if (avoidProtectedHack() && func->isProtected() && !func->isConstructor() && !func->isOperatorOverload()) {
+ s << INDENT << "inline " << (func->isStatic() ? "static " : "");
+ s << functionSignature(func, QString(), QLatin1String("_protected"), Generator::EnumAsInts|Generator::OriginalTypeDescription)
+ << " { ";
+ s << (func->type() ? "return " : "");
+ if (!func->isAbstract())
+ s << func->ownerClass()->qualifiedCppName() << "::";
+ s << func->originalName() << '(';
+ QStringList args;
+ foreach (const AbstractMetaArgument* arg, func->arguments()) {
+ QString argName = arg->name();
+ const TypeEntry* enumTypeEntry = 0;
+ if (arg->type()->isFlags())
+ enumTypeEntry = reinterpret_cast<const FlagsTypeEntry*>(arg->type()->typeEntry())->originator();
+ else if (arg->type()->isEnum())
+ enumTypeEntry = arg->type()->typeEntry();
+ if (enumTypeEntry)
+ argName = QString::fromLatin1("%1(%2)").arg(arg->type()->cppSignature(), argName);
+ args << argName;
+ }
+ s << args.join(QLatin1String(", ")) << ')';
+ s << "; }" << endl;
+ }
+
+ // pure virtual functions need a default implementation
+ if ((func->isPrivate() && !visibilityModifiedToPrivate(func))
+ || (func->isModifiedRemoved() && !func->isAbstract()))
+ return;
+
+ if (avoidProtectedHack() && func->ownerClass()->hasPrivateDestructor()
+ && (func->isAbstract() || func->isVirtual()))
+ return;
+
+ if (func->isConstructor() || func->isAbstract() || func->isVirtual()) {
+ s << INDENT;
+ Options virtualOption = Generator::OriginalTypeDescription;
+
+ if (func->isVirtual() || func->isAbstract())
+ s << "virtual ";
+ else if (!func->hasSignatureModifications())
+ virtualOption = Generator::NoOption;
+
+ s << functionSignature(func, QString(), QString(), virtualOption) << ';' << endl;
+
+ // Check if this method hide other methods in base classes
+ foreach (const AbstractMetaFunction* f, func->ownerClass()->functions()) {
+ if (f != func
+ && !f->isConstructor()
+ && !f->isPrivate()
+ && !f->isVirtual()
+ && !f->isAbstract()
+ && !f->isStatic()
+ && f->name() == func->name()) {
+ m_inheritedOverloads << f;
+ }
+ }
+
+ // TODO: when modified an abstract method ceases to be virtual but stays abstract
+ //if (func->isModifiedRemoved() && func->isAbstract()) {
+ //}
+ }
+}
+
+static void _writeTypeIndexDefineLine(QTextStream& s, const QString& variableName, int typeIndex)
+{
+ s << "#define ";
+ s.setFieldWidth(60);
+ s << variableName;
+ s.setFieldWidth(0);
+ s << ' ' << typeIndex << endl;
+}
+void HeaderGenerator::writeTypeIndexDefineLine(QTextStream& s, const TypeEntry* typeEntry)
+{
+ if (!typeEntry || !typeEntry->generateCode())
+ return;
+ s.setFieldAlignment(QTextStream::AlignLeft);
+ int typeIndex = getTypeIndex(typeEntry);
+ _writeTypeIndexDefineLine(s, getTypeIndexVariableName(typeEntry), typeIndex);
+ if (typeEntry->isComplex()) {
+ const ComplexTypeEntry* cType = reinterpret_cast<const ComplexTypeEntry*>(typeEntry);
+ if (cType->baseContainerType()) {
+ const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(classes(), cType);
+ if (metaClass->templateBaseClass())
+ _writeTypeIndexDefineLine(s, getTypeIndexVariableName(metaClass, true), typeIndex);
+ }
+ }
+ if (typeEntry->isEnum()) {
+ const EnumTypeEntry* ete = reinterpret_cast<const EnumTypeEntry*>(typeEntry);
+ if (ete->flags())
+ writeTypeIndexDefineLine(s, ete->flags());
+ }
+}
+
+void HeaderGenerator::writeTypeIndexDefine(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ if (!metaClass->typeEntry()->generateCode())
+ return;
+ writeTypeIndexDefineLine(s, metaClass->typeEntry());
+ foreach (const AbstractMetaEnum* metaEnum, metaClass->enums()) {
+ if (metaEnum->isPrivate())
+ continue;
+ writeTypeIndexDefineLine(s, metaEnum->typeEntry());
+ }
+}
+
+bool HeaderGenerator::finishGeneration()
+{
+ // Generate the main header for this module.
+ // This header should be included by binding modules
+ // extendind on top of this one.
+ QSet<Include> includes;
+ QString macros;
+ QTextStream macrosStream(&macros);
+ QString sbkTypeFunctions;
+ QTextStream typeFunctions(&sbkTypeFunctions);
+ QString protectedEnumSurrogates;
+ QTextStream protEnumsSurrogates(&protectedEnumSurrogates);
+
+ Indentation indent(INDENT);
+
+ macrosStream << "// Type indices" << endl;
+ AbstractMetaEnumList globalEnums = this->globalEnums();
+ foreach (const AbstractMetaClass* metaClass, classes()) {
+ writeTypeIndexDefine(macrosStream, metaClass);
+ lookForEnumsInClassesNotToBeGenerated(globalEnums, metaClass);
+ }
+
+ foreach (const AbstractMetaEnum* metaEnum, globalEnums)
+ writeTypeIndexDefineLine(macrosStream, metaEnum->typeEntry());
+
+ // Write the smart pointer define indexes.
+ int smartPointerCountIndex = getMaxTypeIndex();
+ int smartPointerCount = 0;
+ foreach (const AbstractMetaType *metaType, instantiatedSmartPointers()) {
+ QString variableName = getTypeIndexVariableName(metaType);
+ macrosStream << "#define ";
+ macrosStream.setFieldWidth(60);
+ macrosStream << variableName;
+ macrosStream.setFieldWidth(0);
+ macrosStream << ' ' << smartPointerCountIndex << " // " << metaType->cppSignature()
+ << endl;
+ ++smartPointerCountIndex;
+ ++smartPointerCount;
+ }
+
+
+ macrosStream << "#define ";
+ macrosStream.setFieldWidth(60);
+ macrosStream << QLatin1String("SBK_") + moduleName() + QLatin1String("_IDX_COUNT");
+ macrosStream.setFieldWidth(0);
+ macrosStream << ' ' << getMaxTypeIndex() + smartPointerCount << endl << endl;
+ macrosStream << "// This variable stores all Python types exported by this module." << endl;
+ macrosStream << "extern PyTypeObject** " << cppApiVariableName() << ';' << endl << endl;
+ macrosStream << "// This variable stores all type converters exported by this module." << endl;
+ macrosStream << "extern SbkConverter** " << convertersVariableName() << ';' << endl << endl;
+
+ // TODO-CONVERTER ------------------------------------------------------------------------------
+ // Using a counter would not do, a fix must be made to APIExtractor's getTypeIndex().
+ macrosStream << "// Converter indices" << endl;
+ QList<const PrimitiveTypeEntry*> primitives = primitiveTypes();
+ int pCount = 0;
+ foreach (const PrimitiveTypeEntry* ptype, primitives) {
+ /* Note: do not generate indices for typedef'd primitive types
+ * as they'll use the primitive type converters instead, so we
+ * don't need to create any other.
+ */
+ if (!ptype->generateCode() || !ptype->customConversion())
+ continue;
+
+ _writeTypeIndexDefineLine(macrosStream, getTypeIndexVariableName(ptype), pCount++);
+ }
+
+ foreach (const AbstractMetaType* container, instantiatedContainers()) {
+ //_writeTypeIndexDefineLine(macrosStream, getTypeIndexVariableName(container), pCount);
+ // DEBUG
+ QString variableName = getTypeIndexVariableName(container);
+ macrosStream << "#define ";
+ macrosStream.setFieldWidth(60);
+ macrosStream << variableName;
+ macrosStream.setFieldWidth(0);
+ macrosStream << ' ' << pCount << " // " << container->cppSignature() << endl;
+ // DEBUG
+ pCount++;
+ }
+
+ // Because on win32 the compiler will not accept a zero length array.
+ if (pCount == 0)
+ pCount++;
+ _writeTypeIndexDefineLine(macrosStream, QStringLiteral("SBK_%1_CONVERTERS_IDX_COUNT").arg(moduleName()), pCount);
+ macrosStream << endl;
+ // TODO-CONVERTER ------------------------------------------------------------------------------
+
+ macrosStream << "// Macros for type check" << endl;
+ foreach (const AbstractMetaEnum* cppEnum, globalEnums) {
+ if (cppEnum->isAnonymous() || cppEnum->isPrivate())
+ continue;
+ includes << cppEnum->typeEntry()->include();
+ writeProtectedEnumSurrogate(protEnumsSurrogates, cppEnum);
+ writeSbkTypeFunction(typeFunctions, cppEnum);
+ }
+
+ foreach (AbstractMetaClass* metaClass, classes()) {
+ if (!shouldGenerate(metaClass))
+ continue;
+
+ //Includes
+ const TypeEntry* classType = metaClass->typeEntry();
+ includes << classType->include();
+
+ foreach (const AbstractMetaEnum* cppEnum, metaClass->enums()) {
+ if (cppEnum->isAnonymous() || cppEnum->isPrivate())
+ continue;
+ EnumTypeEntry* enumType = cppEnum->typeEntry();
+ includes << enumType->include();
+ writeProtectedEnumSurrogate(protEnumsSurrogates, cppEnum);
+ writeSbkTypeFunction(typeFunctions, cppEnum);
+ }
+
+ if (!metaClass->isNamespace())
+ writeSbkTypeFunction(typeFunctions, metaClass);
+ }
+
+ foreach (const AbstractMetaType *metaType, instantiatedSmartPointers()) {
+ const TypeEntry *classType = metaType->typeEntry();
+ includes << classType->include();
+ writeSbkTypeFunction(typeFunctions, metaType);
+ }
+
+ QString moduleHeaderFileName(outputDirectory()
+ + QDir::separator() + subDirectoryForPackage(packageName())
+ + QDir::separator() + getModuleHeaderFileName());
+
+ QString includeShield(QLatin1String("SBK_") + moduleName().toUpper() + QLatin1String("_PYTHON_H"));
+
+ FileOut file(moduleHeaderFileName);
+ QTextStream& s = file.stream;
+ // write license comment
+ s << licenseComment() << endl << endl;
+
+ s << "#ifndef " << includeShield << endl;
+ s << "#define " << includeShield << endl<< endl;
+ if (!avoidProtectedHack()) {
+ s << "//workaround to access protected functions" << endl;
+ s << "#define protected public" << endl << endl;
+ }
+
+ s << "#include <sbkpython.h>" << endl;
+ s << "#include <conversions.h>" << endl;
+ s << "#include <sbkenum.h>" << endl;
+ s << "#include <basewrapper.h>" << endl;
+ s << "#include <bindingmanager.h>" << endl;
+ s << "#include <memory>" << endl << endl;
+ if (usePySideExtensions())
+ s << "#include <pysidesignal.h>" << endl;
+
+ QStringList requiredTargetImports = TypeDatabase::instance()->requiredTargetImports();
+ if (!requiredTargetImports.isEmpty()) {
+ s << "// Module Includes" << endl;
+ foreach (const QString& requiredModule, requiredTargetImports)
+ s << "#include <" << getModuleHeaderFileName(requiredModule) << ">" << endl;
+ s << endl;
+ }
+
+ s << "// Binded library includes" << endl;
+ foreach (const Include& include, includes)
+ s << include;
+
+ if (!primitiveTypes().isEmpty()) {
+ s << "// Conversion Includes - Primitive Types" << endl;
+ foreach (const PrimitiveTypeEntry* ptype, primitiveTypes())
+ s << ptype->include();
+ s << endl;
+ }
+
+ if (!containerTypes().isEmpty()) {
+ s << "// Conversion Includes - Container Types" << endl;
+ foreach (const ContainerTypeEntry* ctype, containerTypes())
+ s << ctype->include();
+ s << endl;
+ }
+
+ s << macros << endl;
+
+ if (!protectedEnumSurrogates.isEmpty()) {
+ s << "// Protected enum surrogates" << endl;
+ s << protectedEnumSurrogates << endl;
+ }
+
+ s << "namespace Shiboken" << endl << '{' << endl << endl;
+
+ s << "// PyType functions, to get the PyObjectType for a type T\n";
+ s << sbkTypeFunctions << endl;
+
+ s << "} // namespace Shiboken" << endl << endl;
+
+ s << "#endif // " << includeShield << endl << endl;
+
+ return file.done() != FileOut::Failure;
+}
+
+void HeaderGenerator::writeProtectedEnumSurrogate(QTextStream& s, const AbstractMetaEnum* cppEnum)
+{
+ if (avoidProtectedHack() && cppEnum->isProtected())
+ s << "enum " << protectedEnumSurrogateName(cppEnum) << " {};" << endl;
+}
+
+void HeaderGenerator::writeSbkTypeFunction(QTextStream& s, const AbstractMetaEnum* cppEnum)
+{
+ QString enumName;
+ if (avoidProtectedHack() && cppEnum->isProtected()) {
+ enumName = protectedEnumSurrogateName(cppEnum);
+ } else {
+ enumName = cppEnum->name();
+ if (cppEnum->enclosingClass())
+ enumName = cppEnum->enclosingClass()->qualifiedCppName() + QLatin1String("::") + enumName;
+ }
+
+ s << "template<> inline PyTypeObject* SbkType< ::" << enumName << " >() ";
+ s << "{ return " << cpythonTypeNameExt(cppEnum->typeEntry()) << "; }\n";
+
+ FlagsTypeEntry* flag = cppEnum->typeEntry()->flags();
+ if (flag) {
+ s << "template<> inline PyTypeObject* SbkType< ::" << flag->name() << " >() "
+ << "{ return " << cpythonTypeNameExt(flag) << "; }\n";
+ }
+}
+
+void HeaderGenerator::writeSbkTypeFunction(QTextStream& s, const AbstractMetaClass* cppClass)
+{
+ s << "template<> inline PyTypeObject* SbkType< ::" << cppClass->qualifiedCppName() << " >() "
+ << "{ return reinterpret_cast<PyTypeObject*>(" << cpythonTypeNameExt(cppClass->typeEntry()) << "); }\n";
+}
+
+void HeaderGenerator::writeSbkTypeFunction(QTextStream &s, const AbstractMetaType *metaType)
+{
+ s << "template<> inline PyTypeObject* SbkType< ::" << metaType->cppSignature() << " >() "
+ << "{ return reinterpret_cast<PyTypeObject*>(" << cpythonTypeNameExt(metaType) << "); }\n";
+}
+
+void HeaderGenerator::writeInheritedOverloads(QTextStream& s)
+{
+ foreach (const AbstractMetaFunction* func, m_inheritedOverloads) {
+ s << INDENT << "inline ";
+ s << functionSignature(func, QString(), QString(), Generator::EnumAsInts|Generator::OriginalTypeDescription) << " { ";
+ s << (func->type() ? "return " : "");
+ s << func->ownerClass()->qualifiedCppName() << "::" << func->originalName() << '(';
+ QStringList args;
+ foreach (const AbstractMetaArgument* arg, func->arguments()) {
+ QString argName = arg->name();
+ const TypeEntry* enumTypeEntry = 0;
+ if (arg->type()->isFlags())
+ enumTypeEntry = reinterpret_cast<const FlagsTypeEntry*>(arg->type()->typeEntry())->originator();
+ else if (arg->type()->isEnum())
+ enumTypeEntry = arg->type()->typeEntry();
+ if (enumTypeEntry)
+ argName = arg->type()->cppSignature() + QLatin1Char('(') + argName + QLatin1Char(')');
+ args << argName;
+ }
+ s << args.join(QLatin1String(", ")) << ')';
+ s << "; }" << endl;
+ }
+}
diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.h b/sources/shiboken2/generator/shiboken2/headergenerator.h
new file mode 100644
index 000000000..72dcbf69f
--- /dev/null
+++ b/sources/shiboken2/generator/shiboken2/headergenerator.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HEADERGENERATOR_H
+#define HEADERGENERATOR_H
+
+#include "shibokengenerator.h"
+
+#include <QtCore/QSet>
+
+class AbstractMetaFunction;
+
+/**
+ * The HeaderGenerator generate the declarations of C++ bindings classes.
+ */
+class HeaderGenerator : public ShibokenGenerator
+{
+public:
+ QMap<QString, QString> options() const { return QMap<QString, QString>(); }
+protected:
+ QString fileNamePrefix() const;
+ QString fileNameForContext(GeneratorContext &context) const;
+ void generateClass(QTextStream& s, GeneratorContext &classContext);
+ bool finishGeneration();
+
+private:
+ void writeCopyCtor(QTextStream &s, const AbstractMetaClass* metaClass) const;
+ void writeProtectedFieldAccessors(QTextStream& s, const AbstractMetaField* field) const;
+ void writeFunction(QTextStream& s, const AbstractMetaFunction* func);
+ void writeSbkTypeFunction(QTextStream& s, const AbstractMetaEnum* cppEnum);
+ void writeSbkTypeFunction(QTextStream& s, const AbstractMetaClass* cppClass);
+ void writeSbkTypeFunction(QTextStream &s, const AbstractMetaType *metaType);
+ void writeTypeIndexDefineLine(QTextStream& s, const TypeEntry* typeEntry);
+ void writeTypeIndexDefine(QTextStream& s, const AbstractMetaClass* metaClass);
+ void writeProtectedEnumSurrogate(QTextStream& s, const AbstractMetaEnum* cppEnum);
+ void writeInheritedOverloads(QTextStream& s);
+
+ QSet<const AbstractMetaFunction*> m_inheritedOverloads;
+};
+
+#endif // HEADERGENERATOR_H
+
diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
new file mode 100644
index 000000000..8731fe911
--- /dev/null
+++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
@@ -0,0 +1,1079 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <abstractmetalang.h>
+#include <reporthandler.h>
+#include <graph.h>
+#include "overloaddata.h"
+#include "shibokengenerator.h"
+
+#include <QtCore/QDir>
+#include <QtCore/QFile>
+#include <QtCore/QTemporaryFile>
+
+static const TypeEntry *getReferencedTypeEntry(const TypeEntry *typeEntry)
+{
+ if (typeEntry->isPrimitive()) {
+ const PrimitiveTypeEntry* pte = dynamic_cast<const PrimitiveTypeEntry*>(typeEntry);
+ while (pte->referencedTypeEntry())
+ pte = pte->referencedTypeEntry();
+ typeEntry = pte;
+ }
+ return typeEntry;
+}
+
+static QString getTypeName(const AbstractMetaType* type)
+{
+ const TypeEntry* typeEntry = getReferencedTypeEntry(type->typeEntry());
+ QString typeName = typeEntry->name();
+ if (typeEntry->isContainer()) {
+ QStringList types;
+ foreach (const AbstractMetaType* cType, type->instantiations()) {
+ const TypeEntry *typeEntry = getReferencedTypeEntry(cType->typeEntry());
+ types << typeEntry->name();
+ }
+ typeName += QLatin1Char('<') + types.join(QLatin1Char(',')) + QLatin1String(" >");
+ }
+ return typeName;
+}
+
+static QString getTypeName(const OverloadData* ov)
+{
+ return ov->hasArgumentTypeReplace() ? ov->argumentTypeReplaced() : getTypeName(ov->argType());
+}
+
+static bool typesAreEqual(const AbstractMetaType* typeA, const AbstractMetaType* typeB)
+{
+ if (typeA->typeEntry() == typeB->typeEntry()) {
+ if (typeA->isContainer() || typeA->isSmartPointer()) {
+ if (typeA->instantiations().size() != typeB->instantiations().size())
+ return false;
+
+ for (int i = 0; i < typeA->instantiations().size(); ++i) {
+ if (!typesAreEqual(typeA->instantiations().at(i), typeB->instantiations().at(i)))
+ return false;
+ }
+ return true;
+ }
+
+ return !(ShibokenGenerator::isCString(typeA) ^ ShibokenGenerator::isCString(typeB));
+ }
+ return false;
+}
+
+
+/**
+ * OverloadSortData just helps writing clearer code in the
+ * OverloadData::sortNextOverloads method.
+ */
+struct OverloadSortData
+{
+ OverloadSortData() : counter(0) {};
+
+ /**
+ * Adds a typeName into the type map without associating it with
+ * a OverloadData. This is done to express type dependencies that could
+ * or could not appear in overloaded signatures not processed yet.
+ */
+ void mapType(const QString& typeName)
+ {
+ if (map.contains(typeName))
+ return;
+ map[typeName] = counter;
+ if (!reverseMap.contains(counter))
+ reverseMap[counter] = 0;
+ counter++;
+ }
+
+ void mapType(OverloadData* overloadData)
+ {
+ QString typeName = getTypeName(overloadData);
+ map[typeName] = counter;
+ reverseMap[counter] = overloadData;
+ counter++;
+ }
+
+ int lastProcessedItemId() { return counter - 1; }
+
+ int counter;
+ QHash<QString, int> map; // typeName -> id
+ QHash<int, OverloadData*> reverseMap; // id -> OverloadData;
+};
+
+/**
+ * Helper function that returns the name of a container get from containerType argument and
+ * an instantiation taken either from an implicit conversion expressed by the function argument,
+ * or from the string argument implicitConvTypeName.
+ */
+static QString getImplicitConversionTypeName(const AbstractMetaType* containerType,
+ const AbstractMetaType* instantiation,
+ const AbstractMetaFunction* function,
+ const QString& implicitConvTypeName = QString())
+{
+ QString impConv;
+ if (!implicitConvTypeName.isEmpty())
+ impConv = implicitConvTypeName;
+ else if (function->isConversionOperator())
+ impConv = function->ownerClass()->typeEntry()->name();
+ else
+ impConv = getTypeName(function->arguments().first()->type());
+
+ QStringList types;
+ foreach (const AbstractMetaType* otherType, containerType->instantiations())
+ types << (otherType == instantiation ? impConv : getTypeName(otherType));
+
+ const ContainerTypeEntry* containerTypeEntry = dynamic_cast<const ContainerTypeEntry*>(containerType->typeEntry());
+ return containerTypeEntry->qualifiedCppName() + QLatin1Char('<')
+ + types.join(QLatin1String(", ")) + QLatin1String(" >");
+}
+
+static QString msgCyclicDependency(const QString &funcName, const QString &graphName,
+ const QList<const AbstractMetaFunction *> &involvedConversions)
+{
+ QString result;
+ QTextStream str(&result);
+ str << "Cyclic dependency found on overloaddata for \"" << funcName
+ << "\" method! The graph boy saved the graph at \"" << QDir::toNativeSeparators(graphName)
+ << "\".";
+ if (const int count = involvedConversions.size()) {
+ str << " Implicit conversions (" << count << "): ";
+ for (int i = 0; i < count; ++i) {
+ if (i)
+ str << ", \"";
+ str << involvedConversions.at(i)->signature() << '"';
+ if (const AbstractMetaClass *c = involvedConversions.at(i)->implementingClass())
+ str << '(' << c->name() << ')';
+ }
+ }
+ return result;
+}
+
+/**
+ * Topologically sort the overloads by implicit convertion order
+ *
+ * This avoids using an implicit conversion if there's an explicit
+ * overload for the convertible type. So, if there's an implicit convert
+ * like TargetType(ConvertibleType foo) and both are in the overload list,
+ * ConvertibleType is checked before TargetType.
+ *
+ * Side effects: Modifies m_nextOverloadData
+ */
+void OverloadData::sortNextOverloads()
+{
+ OverloadSortData sortData;
+ bool checkPyObject = false;
+ int pyobjectIndex = 0;
+ bool checkPySequence = false;
+ int pySeqIndex = 0;
+ bool checkQString = false;
+ int qstringIndex = 0;
+ bool checkQVariant = false;
+ int qvariantIndex = 0;
+ bool checkPyBuffer = false;
+ int pyBufferIndex = 0;
+
+ // Primitive types that are not int, long, short,
+ // char and their respective unsigned counterparts.
+ QStringList nonIntegerPrimitives;
+ nonIntegerPrimitives << QLatin1String("float") << QLatin1String("double")
+ << QLatin1String("bool");
+
+ // Signed integer primitive types.
+ QStringList signedIntegerPrimitives;
+ signedIntegerPrimitives << QLatin1String("int") << QLatin1String("short")
+ << QLatin1String("long");
+
+ // sort the children overloads
+ foreach(OverloadData *ov, m_nextOverloadData)
+ ov->sortNextOverloads();
+
+ if (m_nextOverloadData.size() <= 1)
+ return;
+
+ // Populates the OverloadSortData object containing map and reverseMap, to map type names to ids,
+ // these ids will be used by the topological sort algorithm, because is easier and faster to work
+ // with graph sorting using integers.
+ foreach(OverloadData* ov, m_nextOverloadData) {
+ sortData.mapType(ov);
+
+ const QString typeName(getTypeName(ov));
+
+ if (!checkPyObject && typeName.contains(QLatin1String("PyObject"))) {
+ checkPyObject = true;
+ pyobjectIndex = sortData.lastProcessedItemId();
+ } else if (!checkPySequence && typeName == QLatin1String("PySequence")) {
+ checkPySequence = true;
+ pySeqIndex = sortData.lastProcessedItemId();
+ } else if (!checkPyBuffer && typeName == QLatin1String("PyBuffer")) {
+ checkPyBuffer = true;
+ pyBufferIndex = sortData.lastProcessedItemId();
+ } else if (!checkQVariant && typeName == QLatin1String("QVariant")) {
+ checkQVariant = true;
+ qvariantIndex = sortData.lastProcessedItemId();
+ } else if (!checkQString && typeName == QLatin1String("QString")) {
+ checkQString = true;
+ qstringIndex = sortData.lastProcessedItemId();
+ }
+
+ foreach (const AbstractMetaType* instantiation, ov->argType()->instantiations()) {
+ // Add dependencies for type instantiation of container.
+ QString typeName = getTypeName(instantiation);
+ sortData.mapType(typeName);
+
+ // Build dependency for implicit conversion types instantiations for base container.
+ // For example, considering signatures "method(list<PointF>)" and "method(list<Point>)",
+ // and being PointF implicitly convertible from Point, an list<T> instantiation with T
+ // as Point must come before the PointF instantiation, or else list<Point> will never
+ // be called. In the case of primitive types, list<double> must come before list<int>.
+ if (instantiation->isPrimitive() && (signedIntegerPrimitives.contains(instantiation->name()))) {
+ foreach (const QString& primitive, nonIntegerPrimitives)
+ sortData.mapType(getImplicitConversionTypeName(ov->argType(), instantiation, 0, primitive));
+ } else {
+ foreach (const AbstractMetaFunction* function, m_generator->implicitConversions(instantiation))
+ sortData.mapType(getImplicitConversionTypeName(ov->argType(), instantiation, function));
+ }
+ }
+ }
+
+
+ // Create the graph of type dependencies based on implicit conversions.
+ Graph graph(sortData.reverseMap.count());
+ // All C++ primitive types, add any forgotten type AT THE END OF THIS LIST!
+ const char* primitiveTypes[] = {"int",
+ "unsigned int",
+ "long",
+ "unsigned long",
+ "short",
+ "unsigned short",
+ "bool",
+ "unsigned char",
+ "char",
+ "float",
+ "double",
+ "const char*"
+ };
+ const int numPrimitives = sizeof(primitiveTypes)/sizeof(const char*);
+ bool hasPrimitive[numPrimitives];
+ for (int i = 0; i < numPrimitives; ++i)
+ hasPrimitive[i] = sortData.map.contains(QLatin1String(primitiveTypes[i]));
+
+ if (checkPySequence && checkPyObject)
+ graph.addEdge(pySeqIndex, pyobjectIndex);
+
+ QStringList classesWithIntegerImplicitConversion;
+
+ QList<const AbstractMetaFunction *> involvedConversions;
+
+ foreach(OverloadData* ov, m_nextOverloadData) {
+ const AbstractMetaType* targetType = ov->argType();
+ const QString targetTypeEntryName(getTypeName(ov));
+ int targetTypeId = sortData.map[targetTypeEntryName];
+
+ // Process implicit conversions
+ foreach(AbstractMetaFunction* function, m_generator->implicitConversions(targetType)) {
+ QString convertibleType;
+ if (function->isConversionOperator())
+ convertibleType = function->ownerClass()->typeEntry()->name();
+ else
+ convertibleType = getTypeName(function->arguments().first()->type());
+
+ if (convertibleType == QLatin1String("int") || convertibleType == QLatin1String("unsigned int"))
+ classesWithIntegerImplicitConversion << targetTypeEntryName;
+
+ if (!sortData.map.contains(convertibleType))
+ continue;
+
+ int convertibleTypeId = sortData.map[convertibleType];
+
+ // If a reverse pair already exists, remove it. Probably due to the
+ // container check (This happened to QVariant and QHash)
+ graph.removeEdge(targetTypeId, convertibleTypeId);
+ graph.addEdge(convertibleTypeId, targetTypeId);
+ involvedConversions.append(function);
+ }
+
+ // Process inheritance relationships
+ if (targetType->isValue() || targetType->isObject()) {
+ const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(m_generator->classes(), targetType->typeEntry());
+ foreach (const AbstractMetaClass* ancestor, m_generator->getAllAncestors(metaClass)) {
+ QString ancestorTypeName = ancestor->typeEntry()->name();
+ if (!sortData.map.contains(ancestorTypeName))
+ continue;
+ int ancestorTypeId = sortData.map[ancestorTypeName];
+ graph.removeEdge(ancestorTypeId, targetTypeId);
+ graph.addEdge(targetTypeId, ancestorTypeId);
+ }
+ }
+
+ // Process template instantiations
+ foreach (const AbstractMetaType* instantiation, targetType->instantiations()) {
+ if (sortData.map.contains(getTypeName(instantiation))) {
+ int convertible = sortData.map[getTypeName(instantiation)];
+
+ if (!graph.containsEdge(targetTypeId, convertible)) // Avoid cyclic dependency.
+ graph.addEdge(convertible, targetTypeId);
+
+ if (instantiation->isPrimitive() && (signedIntegerPrimitives.contains(instantiation->name()))) {
+ foreach (const QString& primitive, nonIntegerPrimitives) {
+ QString convertibleTypeName = getImplicitConversionTypeName(ov->argType(), instantiation, 0, primitive);
+ if (!graph.containsEdge(targetTypeId, sortData.map[convertibleTypeName])) // Avoid cyclic dependency.
+ graph.addEdge(sortData.map[convertibleTypeName], targetTypeId);
+ }
+
+ } else {
+ foreach (const AbstractMetaFunction* function, m_generator->implicitConversions(instantiation)) {
+ QString convertibleTypeName = getImplicitConversionTypeName(ov->argType(), instantiation, function);
+ if (!graph.containsEdge(targetTypeId, sortData.map[convertibleTypeName])) { // Avoid cyclic dependency.
+ graph.addEdge(sortData.map[convertibleTypeName], targetTypeId);
+ involvedConversions.append(function);
+ }
+ }
+ }
+ }
+ }
+
+
+ if ((checkPySequence || checkPyObject || checkPyBuffer)
+ && !targetTypeEntryName.contains(QLatin1String("PyObject"))
+ && !targetTypeEntryName.contains(QLatin1String("PyBuffer"))
+ && !targetTypeEntryName.contains(QLatin1String("PySequence"))) {
+ if (checkPySequence) {
+ // PySequence will be checked after all more specific types, but before PyObject.
+ graph.addEdge(targetTypeId, pySeqIndex);
+ } else if (checkPyBuffer) {
+ // PySequence will be checked after all more specific types, but before PyObject.
+ graph.addEdge(targetTypeId, pyBufferIndex);
+ } else {
+ // Add dependency on PyObject, so its check is the last one (too generic).
+ graph.addEdge(targetTypeId, pyobjectIndex);
+ }
+ } else if (checkQVariant && targetTypeEntryName != QLatin1String("QVariant")) {
+ if (!graph.containsEdge(qvariantIndex, targetTypeId)) // Avoid cyclic dependency.
+ graph.addEdge(targetTypeId, qvariantIndex);
+ } else if (checkQString && ShibokenGenerator::isPointer(ov->argType())
+ && targetTypeEntryName != QLatin1String("QString")
+ && targetTypeEntryName != QLatin1String("QByteArray")
+ && (!checkPyObject || targetTypeId != pyobjectIndex)) {
+ if (!graph.containsEdge(qstringIndex, targetTypeId)) // Avoid cyclic dependency.
+ graph.addEdge(targetTypeId, qstringIndex);
+ }
+
+ if (targetType->isEnum()) {
+ // Enum values must precede primitive types.
+ for (int i = 0; i < numPrimitives; ++i) {
+ if (hasPrimitive[i])
+ graph.addEdge(targetTypeId, sortData.map[QLatin1String(primitiveTypes[i])]);
+ }
+ }
+ }
+
+ // QByteArray args need to be checked after QString args
+ if (sortData.map.contains(QLatin1String("QString")) && sortData.map.contains(QLatin1String("QByteArray")))
+ graph.addEdge(sortData.map[QLatin1String("QString")], sortData.map[QLatin1String("QByteArray")]);
+
+ foreach(OverloadData* ov, m_nextOverloadData) {
+ const AbstractMetaType* targetType = ov->argType();
+ if (!targetType->isEnum())
+ continue;
+
+ QString targetTypeEntryName = getTypeName(targetType);
+ // Enum values must precede types implicitly convertible from "int" or "unsigned int".
+ foreach (const QString& implicitFromInt, classesWithIntegerImplicitConversion)
+ graph.addEdge(sortData.map[targetTypeEntryName], sortData.map[implicitFromInt]);
+ }
+
+
+ // Special case for double(int i) (not tracked by m_generator->implicitConversions
+ foreach (const QString& signedIntegerName, signedIntegerPrimitives) {
+ if (sortData.map.contains(signedIntegerName)) {
+ foreach (const QString& nonIntegerName, nonIntegerPrimitives) {
+ if (sortData.map.contains(nonIntegerName))
+ graph.addEdge(sortData.map[nonIntegerName], sortData.map[signedIntegerName]);
+ }
+ }
+ }
+
+ // sort the overloads topologically based on the dependency graph.
+ QLinkedList<int> unmappedResult = graph.topologicalSort();
+ if (unmappedResult.isEmpty()) {
+ QString funcName = referenceFunction()->name();
+ if (referenceFunction()->ownerClass())
+ funcName.prepend(referenceFunction()->ownerClass()->name() + QLatin1Char('.'));
+
+ // Dump overload graph
+ QString graphName = QDir::tempPath() + QLatin1Char('/') + funcName + QLatin1String(".dot");
+ QHash<QString, int>::const_iterator it = sortData.map.begin();
+ QHash<int, QString> nodeNames;
+ for (; it != sortData.map.end(); ++it)
+ nodeNames.insert(it.value(), it.key());
+ graph.dumpDot(nodeNames, graphName);
+ qCWarning(lcShiboken).noquote() << qPrintable(msgCyclicDependency(funcName, graphName, involvedConversions));
+ }
+
+ m_nextOverloadData.clear();
+ foreach(int i, unmappedResult) {
+ if (!sortData.reverseMap[i])
+ continue;
+ m_nextOverloadData << sortData.reverseMap[i];
+ }
+}
+
+/**
+ * Root constructor for OverloadData
+ *
+ * This constructor receives the list of overloads for a given function and iterates generating
+ * the graph of OverloadData instances. Each OverloadData instance references an argument/type
+ * combination.
+ *
+ * Example:
+ * addStuff(double, PyObject *)
+ * addStuff(double, int)
+ *
+ * Given these two overloads, there will be the following graph:
+ *
+ * addStuff - double - PyObject*
+ * \- int
+ *
+ */
+OverloadData::OverloadData(const AbstractMetaFunctionList& overloads, const ShibokenGenerator* generator)
+ : m_minArgs(256), m_maxArgs(0), m_argPos(-1), m_argType(0),
+ m_headOverloadData(this), m_previousOverloadData(0), m_generator(generator)
+{
+ foreach (const AbstractMetaFunction* func, overloads) {
+ m_overloads.append(func);
+ int argSize = func->arguments().size() - numberOfRemovedArguments(func);
+ if (m_minArgs > argSize)
+ m_minArgs = argSize;
+ else if (m_maxArgs < argSize)
+ m_maxArgs = argSize;
+ OverloadData* currentOverloadData = this;
+ foreach (const AbstractMetaArgument* arg, func->arguments()) {
+ if (func->argumentRemoved(arg->argumentIndex() + 1))
+ continue;
+ currentOverloadData = currentOverloadData->addOverloadData(func, arg);
+ }
+ }
+
+ // Sort the overload possibilities so that the overload decisor code goes for the most
+ // important cases first, based on the topological order of the implicit conversions
+ sortNextOverloads();
+
+ // Fix minArgs
+ if (minArgs() > maxArgs())
+ m_headOverloadData->m_minArgs = maxArgs();
+}
+
+OverloadData::OverloadData(OverloadData* headOverloadData, const AbstractMetaFunction* func,
+ const AbstractMetaType* argType, int argPos)
+ : m_minArgs(256), m_maxArgs(0), m_argPos(argPos), m_argType(argType),
+ m_headOverloadData(headOverloadData), m_previousOverloadData(0)
+{
+ if (func)
+ this->addOverload(func);
+}
+
+void OverloadData::addOverload(const AbstractMetaFunction* func)
+{
+ int origNumArgs = func->arguments().size();
+ int removed = numberOfRemovedArguments(func);
+ int numArgs = origNumArgs - removed;
+
+ if (numArgs > m_headOverloadData->m_maxArgs)
+ m_headOverloadData->m_maxArgs = numArgs;
+
+ if (numArgs < m_headOverloadData->m_minArgs)
+ m_headOverloadData->m_minArgs = numArgs;
+
+ for (int i = 0; m_headOverloadData->m_minArgs > 0 && i < origNumArgs; i++) {
+ if (func->argumentRemoved(i + 1))
+ continue;
+ if (!ShibokenGenerator::getDefaultValue(func, func->arguments()[i]).isEmpty()) {
+ int fixedArgIndex = i - removed;
+ if (fixedArgIndex < m_headOverloadData->m_minArgs)
+ m_headOverloadData->m_minArgs = fixedArgIndex;
+ }
+ }
+
+ m_overloads.append(func);
+}
+
+OverloadData* OverloadData::addOverloadData(const AbstractMetaFunction* func,
+ const AbstractMetaArgument* arg)
+{
+ const AbstractMetaType* argType = arg->type();
+ OverloadData* overloadData = 0;
+ if (!func->isOperatorOverload()) {
+ foreach (OverloadData* tmp, m_nextOverloadData) {
+ // TODO: 'const char *', 'char *' and 'char' will have the same TypeEntry?
+
+ // If an argument have a type replacement, then we should create a new overloaddata
+ // for it, unless the next argument also have a identical type replacement.
+ QString replacedArg = func->typeReplaced(tmp->m_argPos + 1);
+ bool argsReplaced = !replacedArg.isEmpty() || !tmp->m_argTypeReplaced.isEmpty();
+ if ((!argsReplaced && typesAreEqual(tmp->m_argType, argType))
+ || (argsReplaced && replacedArg == tmp->argumentTypeReplaced())) {
+ tmp->addOverload(func);
+ overloadData = tmp;
+ }
+ }
+ }
+
+ if (!overloadData) {
+ overloadData = new OverloadData(m_headOverloadData, func, argType, m_argPos + 1);
+ overloadData->m_previousOverloadData = this;
+ overloadData->m_generator = this->m_generator;
+ QString typeReplaced = func->typeReplaced(arg->argumentIndex() + 1);
+
+ if (!typeReplaced.isEmpty())
+ overloadData->m_argTypeReplaced = typeReplaced;
+ m_nextOverloadData.append(overloadData);
+ }
+
+ return overloadData;
+}
+
+QStringList OverloadData::returnTypes() const
+{
+ QSet<QString> retTypes;
+ foreach (const AbstractMetaFunction* func, m_overloads) {
+ if (!func->typeReplaced(0).isEmpty())
+ retTypes << func->typeReplaced(0);
+ else if (func->type() && !func->argumentRemoved(0))
+ retTypes << func->type()->cppSignature();
+ else
+ retTypes << QLatin1String("void");
+ }
+ return QStringList(retTypes.toList());
+}
+
+bool OverloadData::hasNonVoidReturnType() const
+{
+ QStringList retTypes = returnTypes();
+ return !retTypes.contains(QLatin1String("void")) || retTypes.size() > 1;
+}
+
+bool OverloadData::hasVarargs() const
+{
+ foreach (const AbstractMetaFunction* func, m_overloads) {
+ AbstractMetaArgumentList args = func->arguments();
+ if (args.size() > 1 && args.last()->type()->isVarargs())
+ return true;
+ }
+ return false;
+}
+
+bool OverloadData::hasAllowThread() const
+{
+ foreach (const AbstractMetaFunction* func, m_overloads) {
+ if (func->allowThread())
+ return true;
+ }
+ return false;
+}
+
+bool OverloadData::hasStaticFunction(const AbstractMetaFunctionList& overloads)
+{
+ foreach (const AbstractMetaFunction* func, overloads) {
+ if (func->isStatic())
+ return true;
+ }
+ return false;
+}
+
+bool OverloadData::hasStaticFunction() const
+{
+ foreach (const AbstractMetaFunction* func, m_overloads) {
+ if (func->isStatic())
+ return true;
+ }
+ return false;
+}
+
+bool OverloadData::hasInstanceFunction(const AbstractMetaFunctionList& overloads)
+{
+ foreach (const AbstractMetaFunction* func, overloads) {
+ if (!func->isStatic())
+ return true;
+ }
+ return false;
+}
+
+bool OverloadData::hasInstanceFunction() const
+{
+ foreach (const AbstractMetaFunction* func, m_overloads) {
+ if (!func->isStatic())
+ return true;
+ }
+ return false;
+}
+
+bool OverloadData::hasStaticAndInstanceFunctions(const AbstractMetaFunctionList& overloads)
+{
+ return OverloadData::hasStaticFunction(overloads) && OverloadData::hasInstanceFunction(overloads);
+}
+
+bool OverloadData::hasStaticAndInstanceFunctions() const
+{
+ return OverloadData::hasStaticFunction() && OverloadData::hasInstanceFunction();
+}
+
+const AbstractMetaFunction* OverloadData::referenceFunction() const
+{
+ return m_overloads.first();
+}
+
+const AbstractMetaArgument* OverloadData::argument(const AbstractMetaFunction* func) const
+{
+ if (isHeadOverloadData() || !m_overloads.contains(func))
+ return 0;
+
+ int argPos = 0;
+ int removed = 0;
+ for (int i = 0; argPos <= m_argPos; i++) {
+ if (func->argumentRemoved(i + 1))
+ removed++;
+ else
+ argPos++;
+ }
+
+ return func->arguments()[m_argPos + removed];
+}
+
+OverloadDataList OverloadData::overloadDataOnPosition(OverloadData* overloadData, int argPos) const
+{
+ OverloadDataList overloadDataList;
+ if (overloadData->argPos() == argPos) {
+ overloadDataList.append(overloadData);
+ } else if (overloadData->argPos() < argPos) {
+ foreach (OverloadData* pd, overloadData->nextOverloadData())
+ overloadDataList += overloadDataOnPosition(pd, argPos);
+ }
+ return overloadDataList;
+}
+
+OverloadDataList OverloadData::overloadDataOnPosition(int argPos) const
+{
+ OverloadDataList overloadDataList;
+ overloadDataList += overloadDataOnPosition(m_headOverloadData, argPos);
+ return overloadDataList;
+}
+
+bool OverloadData::nextArgumentHasDefaultValue() const
+{
+ foreach (OverloadData* overloadData, m_nextOverloadData) {
+ if (overloadData->getFunctionWithDefaultValue())
+ return true;
+ }
+ return false;
+}
+
+static OverloadData* _findNextArgWithDefault(OverloadData* overloadData)
+{
+ if (overloadData->getFunctionWithDefaultValue())
+ return overloadData;
+
+ OverloadData* result = 0;
+ foreach (OverloadData* odata, overloadData->nextOverloadData()) {
+ OverloadData* tmp = _findNextArgWithDefault(odata);
+ if (!result || (tmp && result->argPos() > tmp->argPos()))
+ result = tmp;
+ }
+ return result;
+}
+
+OverloadData* OverloadData::findNextArgWithDefault()
+{
+ return _findNextArgWithDefault(this);
+}
+
+bool OverloadData::isFinalOccurrence(const AbstractMetaFunction* func) const
+{
+ foreach (const OverloadData* pd, m_nextOverloadData) {
+ if (pd->overloads().contains(func))
+ return false;
+ }
+ return true;
+}
+
+QList<const AbstractMetaFunction*> OverloadData::overloadsWithoutRepetition() const
+{
+ QList<const AbstractMetaFunction*> overloads = m_overloads;
+ foreach (const AbstractMetaFunction* func, m_overloads) {
+ if (func->minimalSignature().endsWith(QLatin1String("const")))
+ continue;
+ foreach (const AbstractMetaFunction* f, overloads) {
+ if ((func->minimalSignature() + QLatin1String("const")) == f->minimalSignature()) {
+ overloads.removeOne(f);
+ break;
+ }
+ }
+ }
+ return overloads;
+}
+
+const AbstractMetaFunction* OverloadData::getFunctionWithDefaultValue() const
+{
+ foreach (const AbstractMetaFunction* func, m_overloads) {
+ int removedArgs = 0;
+ for (int i = 0; i <= m_argPos + removedArgs; i++) {
+ if (func->argumentRemoved(i + 1))
+ removedArgs++;
+ }
+ if (!ShibokenGenerator::getDefaultValue(func, func->arguments()[m_argPos + removedArgs]).isEmpty())
+ return func;
+ }
+ return 0;
+}
+
+QList<int> OverloadData::invalidArgumentLengths() const
+{
+ QSet<int> validArgLengths;
+
+ foreach (const AbstractMetaFunction* func, m_headOverloadData->m_overloads) {
+ const AbstractMetaArgumentList args = func->arguments();
+ int offset = 0;
+ for (int i = 0; i < args.size(); ++i) {
+ if (func->argumentRemoved(i+1)) {
+ offset++;
+ } else {
+ if (!ShibokenGenerator::getDefaultValue(func, args[i]).isEmpty())
+ validArgLengths << i-offset;
+ }
+ }
+ validArgLengths << args.size() - offset;
+ }
+
+ QList<int> invalidArgLengths;
+ for (int i = minArgs() + 1; i < maxArgs(); i++) {
+ if (!validArgLengths.contains(i))
+ invalidArgLengths.append(i);
+ }
+
+ return invalidArgLengths;
+}
+
+int OverloadData::numberOfRemovedArguments(const AbstractMetaFunction* func, int finalArgPos)
+{
+ int removed = 0;
+ if (finalArgPos < 0) {
+ for (int i = 0; i < func->arguments().size(); i++) {
+ if (func->argumentRemoved(i + 1))
+ removed++;
+ }
+ } else {
+ for (int i = 0; i < finalArgPos + removed; i++) {
+ if (func->argumentRemoved(i + 1))
+ removed++;
+ }
+ }
+ return removed;
+}
+
+QPair<int, int> OverloadData::getMinMaxArguments(const AbstractMetaFunctionList& overloads)
+{
+ int minArgs = 10000;
+ int maxArgs = 0;
+ for (int i = 0; i < overloads.size(); i++) {
+ const AbstractMetaFunction* func = overloads[i];
+ int origNumArgs = func->arguments().size();
+ int removed = numberOfRemovedArguments(func);
+ int numArgs = origNumArgs - removed;
+ if (maxArgs < numArgs)
+ maxArgs = numArgs;
+ if (minArgs > numArgs)
+ minArgs = numArgs;
+ for (int j = 0; j < origNumArgs; j++) {
+ if (func->argumentRemoved(j + 1))
+ continue;
+ int fixedArgIndex = j - removed;
+ if (fixedArgIndex < minArgs && !ShibokenGenerator::getDefaultValue(func, func->arguments()[j]).isEmpty())
+ minArgs = fixedArgIndex;
+ }
+ }
+ return QPair<int, int>(minArgs, maxArgs);
+}
+
+bool OverloadData::isSingleArgument(const AbstractMetaFunctionList& overloads)
+{
+ bool singleArgument = true;
+ foreach (const AbstractMetaFunction* func, overloads) {
+ if (func->arguments().size() - numberOfRemovedArguments(func) != 1) {
+ singleArgument = false;
+ break;
+ }
+ }
+ return singleArgument;
+}
+
+void OverloadData::dumpGraph(QString filename) const
+{
+ QFile file(filename);
+ if (file.open(QFile::WriteOnly)) {
+ QTextStream s(&file);
+ s << m_headOverloadData->dumpGraph();
+ }
+}
+
+static inline QString toHtml(QString s)
+{
+ s.replace(QLatin1Char('<'), QLatin1String("&lt;"));
+ s.replace(QLatin1Char('>'), QLatin1String("&gt;"));
+ s.replace(QLatin1Char('&'), QLatin1String("&amp;"));
+ return s;
+}
+
+QString OverloadData::dumpGraph() const
+{
+ QString indent(4, QLatin1Char(' '));
+ QString result;
+ QTextStream s(&result);
+ if (m_argPos == -1) {
+ const AbstractMetaFunction* rfunc = referenceFunction();
+ s << "digraph OverloadedFunction {" << endl;
+ s << indent << "graph [fontsize=12 fontname=freemono labelloc=t splines=true overlap=false rankdir=LR];" << endl;
+
+ // Shows all function signatures
+ s << "legend [fontsize=9 fontname=freemono shape=rect label=\"";
+ foreach (const AbstractMetaFunction* func, overloads()) {
+ s << "f" << functionNumber(func) << " : ";
+ if (func->type())
+ s << toHtml(func->type()->cppSignature());
+ else
+ s << "void";
+ s << ' ' << toHtml(func->minimalSignature()) << "\\l";
+ }
+ s << "\"];" << endl;
+
+ // Function box title
+ s << indent << '"' << rfunc->name() << "\" [shape=plaintext style=\"filled,bold\" margin=0 fontname=freemono fillcolor=white penwidth=1 ";
+ s << "label=<<table border=\"0\" cellborder=\"0\" cellpadding=\"3\" bgcolor=\"white\">";
+ s << "<tr><td bgcolor=\"black\" align=\"center\" cellpadding=\"6\" colspan=\"2\"><font color=\"white\">";
+ if (rfunc->ownerClass())
+ s << rfunc->ownerClass()->name() << "::";
+ s << toHtml(rfunc->name()) << "</font>";
+ if (rfunc->isVirtual()) {
+ s << "<br/><font color=\"white\" point-size=\"10\">&lt;&lt;";
+ if (rfunc->isAbstract())
+ s << "pure ";
+ s << "virtual&gt;&gt;</font>";
+ }
+ s << "</td></tr>";
+
+ // Function return type
+ s << "<tr><td bgcolor=\"gray\" align=\"right\">original type</td><td bgcolor=\"gray\" align=\"left\">";
+ if (rfunc->type())
+ s << toHtml(rfunc->type()->cppSignature());
+ else
+ s << "void";
+ s << "</td></tr>";
+
+ // Shows type changes for all function signatures
+ foreach (const AbstractMetaFunction* func, overloads()) {
+ if (func->typeReplaced(0).isEmpty())
+ continue;
+ s << "<tr><td bgcolor=\"gray\" align=\"right\">f" << functionNumber(func);
+ s << "-type</td><td bgcolor=\"gray\" align=\"left\">";
+ s << toHtml(func->typeReplaced(0)) << "</td></tr>";
+ }
+
+ // Minimum and maximum number of arguments
+ s << "<tr><td bgcolor=\"gray\" align=\"right\">minArgs</td><td bgcolor=\"gray\" align=\"left\">";
+ s << minArgs() << "</td></tr>";
+ s << "<tr><td bgcolor=\"gray\" align=\"right\">maxArgs</td><td bgcolor=\"gray\" align=\"left\">";
+ s << maxArgs() << "</td></tr>";
+
+ if (rfunc->ownerClass()) {
+ if (rfunc->implementingClass() != rfunc->ownerClass())
+ s << "<tr><td align=\"right\">implementor</td><td align=\"left\">" << rfunc->implementingClass()->name() << "</td></tr>";
+ if (rfunc->declaringClass() != rfunc->ownerClass() && rfunc->declaringClass() != rfunc->implementingClass())
+ s << "<tr><td align=\"right\">declarator</td><td align=\"left\">" << rfunc->declaringClass()->name() << "</td></tr>";
+ }
+
+ // Overloads for the signature to present point
+ s << "<tr><td bgcolor=\"gray\" align=\"right\">overloads</td><td bgcolor=\"gray\" align=\"left\">";
+ foreach (const AbstractMetaFunction* func, overloads())
+ s << 'f' << functionNumber(func) << ' ';
+ s << "</td></tr>";
+
+ s << "</table>> ];" << endl;
+
+ foreach (const OverloadData* pd, nextOverloadData())
+ s << indent << '"' << rfunc->name() << "\" -> " << pd->dumpGraph();
+
+ s << "}" << endl;
+ } else {
+ QString argId = QLatin1String("arg_") + QString::number(quintptr(this));
+ s << argId << ';' << endl;
+
+ s << indent << '"' << argId << "\" [shape=\"plaintext\" style=\"filled,bold\" margin=\"0\" fontname=\"freemono\" fillcolor=\"white\" penwidth=1 ";
+ s << "label=<<table border=\"0\" cellborder=\"0\" cellpadding=\"3\" bgcolor=\"white\">";
+
+ // Argument box title
+ s << "<tr><td bgcolor=\"black\" align=\"left\" cellpadding=\"2\" colspan=\"2\">";
+ s << "<font color=\"white\" point-size=\"11\">arg #" << argPos() << "</font></td></tr>";
+
+ // Argument type information
+ QString type = hasArgumentTypeReplace() ? argumentTypeReplaced() : argType()->cppSignature();
+ s << "<tr><td bgcolor=\"gray\" align=\"right\">type</td><td bgcolor=\"gray\" align=\"left\">";
+ s << toHtml(type) << "</td></tr>";
+ if (hasArgumentTypeReplace()) {
+ s << "<tr><td bgcolor=\"gray\" align=\"right\">orig. type</td><td bgcolor=\"gray\" align=\"left\">";
+ s << toHtml(argType()->cppSignature()) << "</td></tr>";
+ }
+
+ // Overloads for the signature to present point
+ s << "<tr><td bgcolor=\"gray\" align=\"right\">overloads</td><td bgcolor=\"gray\" align=\"left\">";
+ foreach (const AbstractMetaFunction* func, overloads())
+ s << 'f' << functionNumber(func) << ' ';
+ s << "</td></tr>";
+
+ // Show default values (original and modified) for various functions
+ foreach (const AbstractMetaFunction* func, overloads()) {
+ const AbstractMetaArgument* arg = argument(func);
+ if (!arg)
+ continue;
+ QString argDefault = ShibokenGenerator::getDefaultValue(func, arg);
+ if (!argDefault.isEmpty() ||
+ argDefault != arg->originalDefaultValueExpression()) {
+ s << "<tr><td bgcolor=\"gray\" align=\"right\">f" << functionNumber(func);
+ s << "-default</td><td bgcolor=\"gray\" align=\"left\">";
+ s << argDefault << "</td></tr>";
+ }
+ if (argDefault != arg->originalDefaultValueExpression()) {
+ s << "<tr><td bgcolor=\"gray\" align=\"right\">f" << functionNumber(func);
+ s << "-orig-default</td><td bgcolor=\"gray\" align=\"left\">";
+ s << arg->originalDefaultValueExpression() << "</td></tr>";
+ }
+ }
+
+ s << "</table>>];" << endl;
+
+ foreach (const OverloadData* pd, nextOverloadData())
+ s << indent << argId << " -> " << pd->dumpGraph();
+ }
+ return result;
+}
+
+int OverloadData::functionNumber(const AbstractMetaFunction* func) const
+{
+ return m_headOverloadData->m_overloads.indexOf(func);
+}
+
+OverloadData::~OverloadData()
+{
+ while (!m_nextOverloadData.isEmpty())
+ delete m_nextOverloadData.takeLast();
+}
+
+bool OverloadData::hasArgumentTypeReplace() const
+{
+ return !m_argTypeReplaced.isEmpty();
+}
+
+QString OverloadData::argumentTypeReplaced() const
+{
+ return m_argTypeReplaced;
+}
+
+bool OverloadData::hasArgumentWithDefaultValue(const AbstractMetaFunctionList& overloads)
+{
+ if (OverloadData::getMinMaxArguments(overloads).second == 0)
+ return false;
+ foreach (const AbstractMetaFunction* func, overloads) {
+ if (hasArgumentWithDefaultValue(func))
+ return true;
+ }
+ return false;
+}
+
+bool OverloadData::hasArgumentWithDefaultValue() const
+{
+ if (maxArgs() == 0)
+ return false;
+ foreach (const AbstractMetaFunction* func, overloads()) {
+ if (hasArgumentWithDefaultValue(func))
+ return true;
+ }
+ return false;
+}
+
+bool OverloadData::hasArgumentWithDefaultValue(const AbstractMetaFunction* func)
+{
+ foreach (const AbstractMetaArgument* arg, func->arguments()) {
+ if (func->argumentRemoved(arg->argumentIndex() + 1))
+ continue;
+ if (!ShibokenGenerator::getDefaultValue(func, arg).isEmpty())
+ return true;
+ }
+ return false;
+}
+
+AbstractMetaArgumentList OverloadData::getArgumentsWithDefaultValues(const AbstractMetaFunction* func)
+{
+ AbstractMetaArgumentList args;
+ foreach (AbstractMetaArgument* arg, func->arguments()) {
+ if (ShibokenGenerator::getDefaultValue(func, arg).isEmpty()
+ || func->argumentRemoved(arg->argumentIndex() + 1))
+ continue;
+ args << arg;
+ }
+ return args;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+void OverloadData::formatDebug(QDebug &d) const
+{
+ const int count = m_overloads.size();
+ d << "argType=" << m_argType << ", minArgs=" << m_minArgs << ", maxArgs=" << m_maxArgs
+ << ", argPos=" << m_argPos << ", argTypeReplaced=\"" << m_argTypeReplaced
+ << "\", overloads[" << count << "]=(";
+ const int oldVerbosity = d.verbosity();
+ d.setVerbosity(3);
+ for (int i = 0; i < count; ++i) {
+ if (i)
+ d << '\n';
+ d << m_overloads.at(i);
+ }
+ d << ')';
+ d.setVerbosity(oldVerbosity);
+}
+
+QDebug operator<<(QDebug d, const OverloadData *od)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "OverloadData(";
+ if (od)
+ od->formatDebug(d);
+ else
+ d << '0';
+ d << ')';
+ return d;
+}
+#endif // !QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.h b/sources/shiboken2/generator/shiboken2/overloaddata.h
new file mode 100644
index 000000000..959b96d0b
--- /dev/null
+++ b/sources/shiboken2/generator/shiboken2/overloaddata.h
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OVERLOADDATA_H
+#define OVERLOADDATA_H
+
+#include <abstractmetalang_typedefs.h>
+#include <QtCore/QList>
+#include <QtCore/QBitArray>
+
+QT_FORWARD_DECLARE_CLASS(QDebug)
+
+class ShibokenGenerator;
+
+class OverloadData;
+typedef QList<OverloadData*> OverloadDataList;
+
+class OverloadData
+{
+public:
+ OverloadData(const AbstractMetaFunctionList& overloads, const ShibokenGenerator* generator);
+ ~OverloadData();
+
+ int minArgs() const { return m_headOverloadData->m_minArgs; }
+ int maxArgs() const { return m_headOverloadData->m_maxArgs; }
+ int argPos() const { return m_argPos; }
+
+ const AbstractMetaType* argType() const { return m_argType; }
+
+ /// Returns a string list containing all the possible return types (including void) for the current OverloadData.
+ QStringList returnTypes() const;
+
+ /// Returns true if any of the overloads for the current OverloadData has a return type different from void.
+ bool hasNonVoidReturnType() const;
+
+ /// Returns true if any of the overloads for the current OverloadData has a varargs argument.
+ bool hasVarargs() const;
+
+ /// Returns true if any of the overloads for the current OverloadData allows threads when called.
+ bool hasAllowThread() const;
+
+ /// Returns true if any of the overloads for the current OverloadData is static.
+ bool hasStaticFunction() const;
+
+ /// Returns true if any of the overloads passed as argument is static.
+ static bool hasStaticFunction(const AbstractMetaFunctionList& overloads);
+
+ /// Returns true if any of the overloads for the current OverloadData is not static.
+ bool hasInstanceFunction() const;
+
+ /// Returns true if any of the overloads passed as argument is not static.
+ static bool hasInstanceFunction(const AbstractMetaFunctionList& overloads);
+
+ /// Returns true if among the overloads for the current OverloadData there are static and non-static methods altogether.
+ bool hasStaticAndInstanceFunctions() const;
+
+ /// Returns true if among the overloads passed as argument there are static and non-static methods altogether.
+ static bool hasStaticAndInstanceFunctions(const AbstractMetaFunctionList& overloads);
+
+ const AbstractMetaFunction* referenceFunction() const;
+ const AbstractMetaArgument* argument(const AbstractMetaFunction* func) const;
+ OverloadDataList overloadDataOnPosition(int argPos) const;
+
+ bool isHeadOverloadData() const { return this == m_headOverloadData; }
+
+ /// Returns the root OverloadData object that represents all the overloads.
+ OverloadData* headOverloadData() const { return m_headOverloadData; }
+
+ /// Returns the function that has a default value at the current OverloadData argument position, otherwise returns null.
+ const AbstractMetaFunction* getFunctionWithDefaultValue() const;
+
+ bool nextArgumentHasDefaultValue() const;
+ /// Returns the nearest occurrence, including this instance, of an argument with a default value.
+ OverloadData* findNextArgWithDefault();
+ bool isFinalOccurrence(const AbstractMetaFunction* func) const;
+
+ /// Returns the list of overloads removing repeated constant functions (ex.: "foo()" and "foo()const", the second is removed).
+ QList<const AbstractMetaFunction*> overloadsWithoutRepetition() const;
+ const QList<const AbstractMetaFunction*>& overloads() const { return m_overloads; }
+ OverloadDataList nextOverloadData() const { return m_nextOverloadData; }
+ OverloadData* previousOverloadData() const { return m_previousOverloadData; }
+
+ QList<int> invalidArgumentLengths() const;
+
+ static int numberOfRemovedArguments(const AbstractMetaFunction* func, int finalArgPos = -1);
+ static QPair<int, int> getMinMaxArguments(const AbstractMetaFunctionList& overloads);
+ /// Returns true if all overloads have no more than one argument.
+ static bool isSingleArgument(const AbstractMetaFunctionList& overloads);
+
+ void dumpGraph(QString filename) const;
+ QString dumpGraph() const;
+
+ bool hasArgumentTypeReplace() const;
+ QString argumentTypeReplaced() const;
+
+ bool hasArgumentWithDefaultValue() const;
+ static bool hasArgumentWithDefaultValue(const AbstractMetaFunctionList& overloads);
+ static bool hasArgumentWithDefaultValue(const AbstractMetaFunction* func);
+
+ /// Returns a list of function arguments which have default values and were not removed.
+ static AbstractMetaArgumentList getArgumentsWithDefaultValues(const AbstractMetaFunction* func);
+
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &) const;
+#endif
+
+private:
+ OverloadData(OverloadData* headOverloadData, const AbstractMetaFunction* func,
+ const AbstractMetaType* argType, int argPos);
+
+ void addOverload(const AbstractMetaFunction* func);
+ OverloadData* addOverloadData(const AbstractMetaFunction* func, const AbstractMetaArgument* arg);
+
+ void sortNextOverloads();
+
+ int functionNumber(const AbstractMetaFunction* func) const;
+ OverloadDataList overloadDataOnPosition(OverloadData* overloadData, int argPos) const;
+
+ int m_minArgs;
+ int m_maxArgs;
+ int m_argPos;
+ const AbstractMetaType* m_argType;
+ QString m_argTypeReplaced;
+ QList<const AbstractMetaFunction*> m_overloads;
+
+ OverloadData* m_headOverloadData;
+ OverloadDataList m_nextOverloadData;
+ OverloadData* m_previousOverloadData;
+ const ShibokenGenerator* m_generator;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug, const OverloadData *);
+#endif
+
+#endif // OVERLOADDATA_H
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
new file mode 100644
index 000000000..7b664e105
--- /dev/null
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -0,0 +1,2674 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "shibokengenerator.h"
+#include <abstractmetalang.h>
+#include "overloaddata.h"
+#include <reporthandler.h>
+#include <typedatabase.h>
+#include <iostream>
+
+#include <QtCore/QDir>
+#include <QtCore/QDebug>
+#include <limits>
+#include <memory>
+
+#define NULL_VALUE "NULL"
+#define AVOID_PROTECTED_HACK "avoid-protected-hack"
+#define PARENT_CTOR_HEURISTIC "enable-parent-ctor-heuristic"
+#define RETURN_VALUE_HEURISTIC "enable-return-value-heuristic"
+#define ENABLE_PYSIDE_EXTENSIONS "enable-pyside-extensions"
+#define DISABLE_VERBOSE_ERROR_MESSAGES "disable-verbose-error-messages"
+#define USE_ISNULL_AS_NB_NONZERO "use-isnull-as-nb_nonzero"
+
+//static void dumpFunction(AbstractMetaFunctionList lst);
+
+QHash<QString, QString> ShibokenGenerator::m_pythonPrimitiveTypeName = QHash<QString, QString>();
+QHash<QString, QString> ShibokenGenerator::m_pythonOperators = QHash<QString, QString>();
+QHash<QString, QString> ShibokenGenerator::m_formatUnits = QHash<QString, QString>();
+QHash<QString, QString> ShibokenGenerator::m_tpFuncs = QHash<QString, QString>();
+QStringList ShibokenGenerator::m_knownPythonTypes = QStringList();
+
+static QString resolveScopePrefix(const AbstractMetaClass* scope, const QString& value)
+{
+ if (!scope)
+ return QString();
+
+ QString name;
+ QStringList parts = scope->qualifiedCppName().split(QLatin1String("::"), QString::SkipEmptyParts);
+ for(int i = (parts.size() - 1) ; i >= 0; i--) {
+ if (!value.startsWith(parts[i] + QLatin1String("::")))
+ name = parts[i] + QLatin1String("::") + name;
+ else
+ name.clear();
+ }
+
+ return name;
+}
+ShibokenGenerator::ShibokenGenerator() : Generator()
+{
+ if (m_pythonPrimitiveTypeName.isEmpty())
+ ShibokenGenerator::initPrimitiveTypesCorrespondences();
+
+ if (m_tpFuncs.isEmpty())
+ ShibokenGenerator::clearTpFuncs();
+
+ if (m_knownPythonTypes.isEmpty())
+ ShibokenGenerator::initKnownPythonTypes();
+
+ m_metaTypeFromStringCache = AbstractMetaTypeCache();
+
+ m_typeSystemConvName[TypeSystemCheckFunction] = QLatin1String("checkType");
+ m_typeSystemConvName[TypeSystemIsConvertibleFunction] = QLatin1String("isConvertible");
+ m_typeSystemConvName[TypeSystemToCppFunction] = QLatin1String("toCpp");
+ m_typeSystemConvName[TypeSystemToPythonFunction] = QLatin1String("toPython");
+ m_typeSystemConvRegEx[TypeSystemCheckFunction] = QRegExp(QLatin1String(CHECKTYPE_REGEX));
+ m_typeSystemConvRegEx[TypeSystemIsConvertibleFunction] = QRegExp(QLatin1String(ISCONVERTIBLE_REGEX));
+ m_typeSystemConvRegEx[TypeSystemToPythonFunction] = QRegExp(QLatin1String(CONVERTTOPYTHON_REGEX));
+ m_typeSystemConvRegEx[TypeSystemToCppFunction] = QRegExp(QLatin1String(CONVERTTOCPP_REGEX));
+}
+
+ShibokenGenerator::~ShibokenGenerator()
+{
+ // TODO-CONVERTER: it must be caching types that were not created here.
+ //qDeleteAll(m_metaTypeFromStringCache.values());
+}
+
+void ShibokenGenerator::clearTpFuncs()
+{
+ m_tpFuncs.insert(QLatin1String("__str__"), QLatin1String("0"));
+ m_tpFuncs.insert(QLatin1String("__repr__"), QLatin1String("0"));
+ m_tpFuncs.insert(QLatin1String("__iter__"), QLatin1String("0"));
+ m_tpFuncs.insert(QLatin1String("__next__"), QLatin1String("0"));
+}
+
+void ShibokenGenerator::initPrimitiveTypesCorrespondences()
+{
+ // Python primitive types names
+ m_pythonPrimitiveTypeName.clear();
+
+ // PyBool
+ m_pythonPrimitiveTypeName.insert(QLatin1String("bool"), QLatin1String("PyBool"));
+
+ // PyInt
+ m_pythonPrimitiveTypeName.insert(QLatin1String("char"), QLatin1String("SbkChar"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("signed char"), QLatin1String("SbkChar"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("unsigned char"), QLatin1String("SbkChar"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("int"), QLatin1String("PyInt"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("signed int"), QLatin1String("PyInt"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("uint"), QLatin1String("PyInt"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("unsigned int"), QLatin1String("PyInt"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("short"), QLatin1String("PyInt"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("ushort"), QLatin1String("PyInt"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("signed short"), QLatin1String("PyInt"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("signed short int"), QLatin1String("PyInt"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("unsigned short"), QLatin1String("PyInt"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("unsigned short int"), QLatin1String("PyInt"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("long"), QLatin1String("PyInt"));
+
+ // PyFloat
+ m_pythonPrimitiveTypeName.insert(QLatin1String("double"), QLatin1String("PyFloat"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("float"), QLatin1String("PyFloat"));
+
+ // PyLong
+ m_pythonPrimitiveTypeName.insert(QLatin1String("unsigned long"), QLatin1String("PyLong"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("signed long"), QLatin1String("PyLong"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("ulong"), QLatin1String("PyLong"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("unsigned long int"), QLatin1String("PyLong"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("long long"), QLatin1String("PyLong"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("__int64"), QLatin1String("PyLong"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("unsigned long long"), QLatin1String("PyLong"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("unsigned __int64"), QLatin1String("PyLong"));
+ m_pythonPrimitiveTypeName.insert(QLatin1String("size_t"), QLatin1String("PyLong"));
+
+ // Python operators
+ m_pythonOperators.clear();
+
+ // call operator
+ m_pythonOperators.insert(QLatin1String("operator()"), QLatin1String("call"));
+
+ // Arithmetic operators
+ m_pythonOperators.insert(QLatin1String("operator+"), QLatin1String("add"));
+ m_pythonOperators.insert(QLatin1String("operator-"), QLatin1String("sub"));
+ m_pythonOperators.insert(QLatin1String("operator*"), QLatin1String("mul"));
+ m_pythonOperators.insert(QLatin1String("operator/"), QLatin1String("div"));
+ m_pythonOperators.insert(QLatin1String("operator%"), QLatin1String("mod"));
+
+ // Inplace arithmetic operators
+ m_pythonOperators.insert(QLatin1String("operator+="), QLatin1String("iadd"));
+ m_pythonOperators.insert(QLatin1String("operator-="), QLatin1String("isub"));
+ m_pythonOperators.insert(QLatin1String("operator++"), QLatin1String("iadd"));
+ m_pythonOperators.insert(QLatin1String("operator--"), QLatin1String("isub"));
+ m_pythonOperators.insert(QLatin1String("operator*="), QLatin1String("imul"));
+ m_pythonOperators.insert(QLatin1String("operator/="), QLatin1String("idiv"));
+ m_pythonOperators.insert(QLatin1String("operator%="), QLatin1String("imod"));
+
+ // Bitwise operators
+ m_pythonOperators.insert(QLatin1String("operator&"), QLatin1String("and"));
+ m_pythonOperators.insert(QLatin1String("operator^"), QLatin1String("xor"));
+ m_pythonOperators.insert(QLatin1String("operator|"), QLatin1String("or"));
+ m_pythonOperators.insert(QLatin1String("operator<<"), QLatin1String("lshift"));
+ m_pythonOperators.insert(QLatin1String("operator>>"), QLatin1String("rshift"));
+ m_pythonOperators.insert(QLatin1String("operator~"), QLatin1String("invert"));
+
+ // Inplace bitwise operators
+ m_pythonOperators.insert(QLatin1String("operator&="), QLatin1String("iand"));
+ m_pythonOperators.insert(QLatin1String("operator^="), QLatin1String("ixor"));
+ m_pythonOperators.insert(QLatin1String("operator|="), QLatin1String("ior"));
+ m_pythonOperators.insert(QLatin1String("operator<<="), QLatin1String("ilshift"));
+ m_pythonOperators.insert(QLatin1String("operator>>="), QLatin1String("irshift"));
+
+ // Comparison operators
+ m_pythonOperators.insert(QLatin1String("operator=="), QLatin1String("eq"));
+ m_pythonOperators.insert(QLatin1String("operator!="), QLatin1String("ne"));
+ m_pythonOperators.insert(QLatin1String("operator<"), QLatin1String("lt"));
+ m_pythonOperators.insert(QLatin1String("operator>"), QLatin1String("gt"));
+ m_pythonOperators.insert(QLatin1String("operator<="), QLatin1String("le"));
+ m_pythonOperators.insert(QLatin1String("operator>="), QLatin1String("ge"));
+
+ // Initialize format units for C++->Python->C++ conversion
+ m_formatUnits.clear();
+ m_formatUnits.insert(QLatin1String("char"), QLatin1String("b"));
+ m_formatUnits.insert(QLatin1String("unsigned char"), QLatin1String("B"));
+ m_formatUnits.insert(QLatin1String("int"), QLatin1String("i"));
+ m_formatUnits.insert(QLatin1String("unsigned int"), QLatin1String("I"));
+ m_formatUnits.insert(QLatin1String("short"), QLatin1String("h"));
+ m_formatUnits.insert(QLatin1String("unsigned short"), QLatin1String("H"));
+ m_formatUnits.insert(QLatin1String("long"), QLatin1String("l"));
+ m_formatUnits.insert(QLatin1String("unsigned long"), QLatin1String("k"));
+ m_formatUnits.insert(QLatin1String("long long"), QLatin1String("L"));
+ m_formatUnits.insert(QLatin1String("__int64"), QLatin1String("L"));
+ m_formatUnits.insert(QLatin1String("unsigned long long"), QLatin1String("K"));
+ m_formatUnits.insert(QLatin1String("unsigned __int64"), QLatin1String("K"));
+ m_formatUnits.insert(QLatin1String("double"), QLatin1String("d"));
+ m_formatUnits.insert(QLatin1String("float"), QLatin1String("f"));
+}
+
+void ShibokenGenerator::initKnownPythonTypes()
+{
+ m_knownPythonTypes.clear();
+ m_knownPythonTypes << QLatin1String("PyBool") << QLatin1String("PyInt")
+ << QLatin1String("PyFloat") << QLatin1String("PyLong") << QLatin1String("PyObject")
+ << QLatin1String("PyString") << QLatin1String("PyBuffer") << QLatin1String("PySequence")
+ << QLatin1String("PyTuple") << QLatin1String("PyList") << QLatin1String("PyDict")
+ << QLatin1String("PyObject*") << QLatin1String("PyObject *") << QLatin1String("PyTupleObject*");
+}
+
+QString ShibokenGenerator::translateTypeForWrapperMethod(const AbstractMetaType* cType,
+ const AbstractMetaClass* context,
+ Options options) const
+{
+ if (cType->isArray())
+ return translateTypeForWrapperMethod(cType->arrayElementType(), context, options) + QLatin1String("[]");
+
+ if (avoidProtectedHack() && cType->isEnum()) {
+ const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(cType);
+ if (metaEnum && metaEnum->isProtected())
+ return protectedEnumSurrogateName(metaEnum);
+ }
+
+ return translateType(cType, context, options);
+}
+
+bool ShibokenGenerator::shouldGenerateCppWrapper(const AbstractMetaClass* metaClass) const
+{
+ bool result = metaClass->isPolymorphic() || metaClass->hasVirtualDestructor();
+ if (avoidProtectedHack()) {
+ result = result || metaClass->hasProtectedFields() || metaClass->hasProtectedDestructor();
+ if (!result && metaClass->hasProtectedFunctions()) {
+ int protectedFunctions = 0;
+ int protectedOperators = 0;
+ foreach (const AbstractMetaFunction* func, metaClass->functions()) {
+ if (!func->isProtected() || func->isSignal() || func->isModifiedRemoved())
+ continue;
+ else if (func->isOperatorOverload())
+ protectedOperators++;
+ else
+ protectedFunctions++;
+ }
+ result = result || (protectedFunctions > protectedOperators);
+ }
+ } else {
+ result = result && !metaClass->hasPrivateDestructor();
+ }
+ return result && !metaClass->isNamespace();
+}
+
+void ShibokenGenerator::lookForEnumsInClassesNotToBeGenerated(AbstractMetaEnumList& enumList, const AbstractMetaClass* metaClass)
+{
+ if (!metaClass)
+ return;
+
+ if (metaClass->typeEntry()->codeGeneration() == TypeEntry::GenerateForSubclass) {
+ foreach (const AbstractMetaEnum* metaEnum, metaClass->enums()) {
+ if (metaEnum->isPrivate() || metaEnum->typeEntry()->codeGeneration() == TypeEntry::GenerateForSubclass)
+ continue;
+ if (!enumList.contains(const_cast<AbstractMetaEnum*>(metaEnum)))
+ enumList.append(const_cast<AbstractMetaEnum*>(metaEnum));
+ }
+ lookForEnumsInClassesNotToBeGenerated(enumList, metaClass->enclosingClass());
+ }
+}
+
+static const AbstractMetaClass* getProperEnclosingClass(const AbstractMetaClass* metaClass)
+{
+ if (!metaClass)
+ return 0;
+
+ if (metaClass->typeEntry()->codeGeneration() != TypeEntry::GenerateForSubclass)
+ return metaClass;
+
+ return getProperEnclosingClass(metaClass->enclosingClass());
+}
+
+const AbstractMetaClass* ShibokenGenerator::getProperEnclosingClassForEnum(const AbstractMetaEnum* metaEnum)
+{
+ return getProperEnclosingClass(metaEnum->enclosingClass());
+}
+
+QString ShibokenGenerator::wrapperName(const AbstractMetaClass* metaClass) const
+{
+ if (shouldGenerateCppWrapper(metaClass)) {
+ QString result = metaClass->name();
+ if (metaClass->enclosingClass()) // is a inner class
+ result.replace(QLatin1String("::"), QLatin1String("_"));
+
+ result += QLatin1String("Wrapper");
+ return result;
+ } else {
+ return metaClass->qualifiedCppName();
+ }
+}
+
+QString ShibokenGenerator::wrapperName(const AbstractMetaType *metaType) const
+{
+ return metaType->cppSignature();
+}
+
+QString ShibokenGenerator::fullPythonFunctionName(const AbstractMetaFunction* func)
+{
+ QString funcName;
+ if (func->isOperatorOverload())
+ funcName = ShibokenGenerator::pythonOperatorFunctionName(func);
+ else
+ funcName = func->name();
+ if (func->ownerClass()) {
+ QString fullName = func->ownerClass()->fullName();
+ if (func->isConstructor())
+ funcName = fullName;
+ else
+ funcName.prepend(fullName + QLatin1Char('.'));
+ }
+ return funcName;
+}
+
+QString ShibokenGenerator::protectedEnumSurrogateName(const AbstractMetaEnum* metaEnum)
+{
+ return metaEnum->fullName().replace(QLatin1Char('.'), QLatin1Char('_')).replace(QLatin1String("::"), QLatin1String("_")) + QLatin1String("_Surrogate");
+}
+
+QString ShibokenGenerator::protectedFieldGetterName(const AbstractMetaField* field)
+{
+ return QStringLiteral("protected_%1_getter").arg(field->name());
+}
+
+QString ShibokenGenerator::protectedFieldSetterName(const AbstractMetaField* field)
+{
+ return QStringLiteral("protected_%1_setter").arg(field->name());
+}
+
+QString ShibokenGenerator::cpythonFunctionName(const AbstractMetaFunction* func)
+{
+ QString result;
+
+ // PYSIDE-331: For inherited functions, we need to find the same labels.
+ // Therefore we use the implementing class.
+ if (func->implementingClass()) {
+ result = cpythonBaseName(func->implementingClass()->typeEntry());
+ if (func->isConstructor()) {
+ result += QLatin1String("_Init");
+ } else {
+ result += QLatin1String("Func_");
+ if (func->isOperatorOverload())
+ result += ShibokenGenerator::pythonOperatorFunctionName(func);
+ else
+ result += func->name();
+ }
+ } else {
+ result = QLatin1String("Sbk") + moduleName() + QLatin1String("Module_") + func->name();
+ }
+
+ return result;
+}
+
+QString ShibokenGenerator::cpythonMethodDefinitionName(const AbstractMetaFunction* func)
+{
+ if (!func->ownerClass())
+ return QString();
+ return QStringLiteral("%1Method_%2").arg(cpythonBaseName(func->ownerClass()->typeEntry()), func->name());
+}
+
+QString ShibokenGenerator::cpythonGettersSettersDefinitionName(const AbstractMetaClass* metaClass)
+{
+ return cpythonBaseName(metaClass) + QLatin1String("_getsetlist");
+}
+
+QString ShibokenGenerator::cpythonSetattroFunctionName(const AbstractMetaClass* metaClass)
+{
+ return cpythonBaseName(metaClass) + QLatin1String("_setattro");
+}
+
+
+QString ShibokenGenerator::cpythonGetattroFunctionName(const AbstractMetaClass* metaClass)
+{
+ return cpythonBaseName(metaClass) + QLatin1String("_getattro");
+}
+
+QString ShibokenGenerator::cpythonGetterFunctionName(const AbstractMetaField* metaField)
+{
+ return QStringLiteral("%1_get_%2").arg(cpythonBaseName(metaField->enclosingClass()), metaField->name());
+}
+
+QString ShibokenGenerator::cpythonSetterFunctionName(const AbstractMetaField* metaField)
+{
+ return QStringLiteral("%1_set_%2").arg(cpythonBaseName(metaField->enclosingClass()), metaField->name());
+}
+
+static QString cpythonEnumFlagsName(QString moduleName, QString qualifiedCppName)
+{
+ QString result = QStringLiteral("Sbk%1_%2").arg(moduleName, qualifiedCppName);
+ result.replace(QLatin1String("::"), QLatin1String("_"));
+ return result;
+}
+
+static QString searchForEnumScope(const AbstractMetaClass* metaClass, const QString& value)
+{
+ QString enumValueName = value.trimmed();
+
+ if (!metaClass)
+ return QString();
+
+ foreach (const AbstractMetaEnum* metaEnum, metaClass->enums()) {
+ foreach (const AbstractMetaEnumValue* enumValue, metaEnum->values()) {
+ if (enumValueName == enumValue->name())
+ return metaClass->qualifiedCppName();
+ }
+ }
+ // PYSIDE-331: We need to also search the base classes.
+ QString ret = searchForEnumScope(metaClass->enclosingClass(), enumValueName);
+ if (ret.isEmpty())
+ ret = searchForEnumScope(metaClass->baseClass(), enumValueName);
+ return ret;
+}
+
+/*
+ * This function uses some heuristics to find out the scope for a given
+ * argument default value. New situations may arise in the future and
+ * this method should be updated, do it with care.
+ */
+QString ShibokenGenerator::guessScopeForDefaultValue(const AbstractMetaFunction* func, const AbstractMetaArgument* arg)
+{
+ QString value = getDefaultValue(func, arg);
+
+ if (value.isEmpty())
+ return QString();
+
+ if (isPointer(arg->type()))
+ return value;
+
+ static QRegExp enumValueRegEx(QLatin1String("^([A-Za-z_]\\w*)?$"));
+ QString prefix;
+ QString suffix;
+
+ if (arg->type()->isEnum()) {
+ const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(arg->type());
+ if (metaEnum)
+ prefix = resolveScopePrefix(metaEnum->enclosingClass(), value);
+ } else if (arg->type()->isFlags()) {
+ static QRegExp numberRegEx(QLatin1String("^\\d+$")); // Numbers to flags
+ if (numberRegEx.exactMatch(value)) {
+ QString typeName = translateTypeForWrapperMethod(arg->type(), func->implementingClass());
+ if (arg->type()->isConstant())
+ typeName.remove(0, sizeof("const ") / sizeof(char) - 1);
+ switch (arg->type()->referenceType()) {
+ case NoReference:
+ break;
+ case LValueReference:
+ typeName.chop(1);
+ break;
+ case RValueReference:
+ typeName.chop(2);
+ break;
+ }
+ prefix = typeName + QLatin1Char('(');
+ suffix = QLatin1Char(')');
+ }
+
+ static QRegExp enumCombinationRegEx(QLatin1String("^([A-Za-z_][\\w:]*)\\(([^,\\(\\)]*)\\)$")); // FlagName(EnumItem|EnumItem|...)
+ if (prefix.isEmpty() && enumCombinationRegEx.indexIn(value) != -1) {
+ QString flagName = enumCombinationRegEx.cap(1);
+ QStringList enumItems = enumCombinationRegEx.cap(2).split(QLatin1Char('|'));
+ QString scope = searchForEnumScope(func->implementingClass(), enumItems.first());
+ if (!scope.isEmpty())
+ scope.append(QLatin1String("::"));
+
+ QStringList fixedEnumItems;
+ foreach (const QString& enumItem, enumItems)
+ fixedEnumItems << QString(scope + enumItem);
+
+ if (!fixedEnumItems.isEmpty()) {
+ prefix = flagName + QLatin1Char('(');
+ value = fixedEnumItems.join(QLatin1Char('|'));
+ suffix = QLatin1Char(')');
+ }
+ }
+ } else if (arg->type()->typeEntry()->isValue()) {
+ const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(classes(), arg->type()->typeEntry());
+ if (enumValueRegEx.exactMatch(value)&& value != QLatin1String("NULL"))
+ prefix = resolveScopePrefix(metaClass, value);
+ } else if (arg->type()->isPrimitive() && arg->type()->name() == QLatin1String("int")) {
+ if (enumValueRegEx.exactMatch(value) && func->implementingClass())
+ prefix = resolveScopePrefix(func->implementingClass(), value);
+ } else if(arg->type()->isPrimitive()) {
+ static QRegExp unknowArgumentRegEx(QLatin1String("^(?:[A-Za-z_][\\w:]*\\()?([A-Za-z_]\\w*)(?:\\))?$")); // [PrimitiveType(] DESIREDNAME [)]
+ if (unknowArgumentRegEx.indexIn(value) != -1 && func->implementingClass()) {
+ foreach (const AbstractMetaField* field, func->implementingClass()->fields()) {
+ if (unknowArgumentRegEx.cap(1).trimmed() == field->name()) {
+ QString fieldName = field->name();
+ if (field->isStatic()) {
+ prefix = resolveScopePrefix(func->implementingClass(), value);
+ fieldName.prepend(prefix);
+ prefix.clear();
+ } else {
+ fieldName.prepend(QLatin1String(CPP_SELF_VAR "->"));
+ }
+ value.replace(unknowArgumentRegEx.cap(1), fieldName);
+ break;
+ }
+ }
+ }
+ }
+
+ if (!prefix.isEmpty())
+ value.prepend(prefix);
+ if (!suffix.isEmpty())
+ value.append(suffix);
+
+ return value;
+}
+
+QString ShibokenGenerator::cpythonEnumName(const EnumTypeEntry* enumEntry)
+{
+ QString p = enumEntry->targetLangPackage();
+ p.replace(QLatin1Char('.'), QLatin1Char('_'));
+ return cpythonEnumFlagsName(p, enumEntry->qualifiedCppName());
+}
+
+QString ShibokenGenerator::cpythonEnumName(const AbstractMetaEnum *metaEnum)
+{
+ return cpythonEnumName(metaEnum->typeEntry());
+}
+
+QString ShibokenGenerator::cpythonFlagsName(const FlagsTypeEntry* flagsEntry)
+{
+ QString p = flagsEntry->targetLangPackage();
+ p.replace(QLatin1Char('.'), QLatin1Char('_'));
+ return cpythonEnumFlagsName(p, flagsEntry->originalName());
+}
+
+QString ShibokenGenerator::cpythonFlagsName(const AbstractMetaEnum *metaEnum)
+{
+ const FlagsTypeEntry *flags = metaEnum->typeEntry()->flags();
+ if (!flags)
+ return QString();
+ return cpythonFlagsName(flags);
+}
+
+QString ShibokenGenerator::cpythonSpecialCastFunctionName(const AbstractMetaClass* metaClass)
+{
+ return cpythonBaseName(metaClass->typeEntry()) + QLatin1String("SpecialCastFunction");
+}
+
+QString ShibokenGenerator::cpythonWrapperCPtr(const AbstractMetaClass* metaClass, QString argName)
+{
+ return cpythonWrapperCPtr(metaClass->typeEntry(), argName);
+}
+
+QString ShibokenGenerator::cpythonWrapperCPtr(const AbstractMetaType *metaType, QString argName)
+{
+ if (!ShibokenGenerator::isWrapperType(metaType->typeEntry()))
+ return QString();
+ return QLatin1String("reinterpret_cast< ::") + metaType->cppSignature()
+ + QLatin1String(" *>(Shiboken::Conversions::cppPointer(") + cpythonTypeNameExt(metaType)
+ + QLatin1String(", reinterpret_cast<SbkObject *>(") + argName + QLatin1String(")))");
+}
+
+QString ShibokenGenerator::cpythonWrapperCPtr(const TypeEntry* type, QString argName)
+{
+ if (!ShibokenGenerator::isWrapperType(type))
+ return QString();
+ return QLatin1String("reinterpret_cast< ::") + type->qualifiedCppName()
+ + QLatin1String(" *>(Shiboken::Conversions::cppPointer(") + cpythonTypeNameExt(type)
+ + QLatin1String(", reinterpret_cast<SbkObject *>(") + argName + QLatin1String(")))");
+}
+
+QString ShibokenGenerator::getFunctionReturnType(const AbstractMetaFunction* func, Options) const
+{
+ if (func->ownerClass() && func->isConstructor())
+ return func->ownerClass()->qualifiedCppName() + QLatin1Char('*');
+
+ return translateTypeForWrapperMethod(func->type(), func->implementingClass());
+}
+
+void ShibokenGenerator::writeToPythonConversion(QTextStream & s, const AbstractMetaType* type,
+ const AbstractMetaClass * /* context */,
+ const QString& argumentName)
+{
+ s << cpythonToPythonConversionFunction(type) << argumentName << ')';
+}
+
+void ShibokenGenerator::writeToCppConversion(QTextStream& s, const AbstractMetaClass* metaClass,
+ const QString& inArgName, const QString& outArgName)
+{
+ s << cpythonToCppConversionFunction(metaClass) << inArgName << ", &" << outArgName << ')';
+}
+
+void ShibokenGenerator::writeToCppConversion(QTextStream& s, const AbstractMetaType* type, const AbstractMetaClass* context,
+ const QString& inArgName, const QString& outArgName)
+{
+ s << cpythonToCppConversionFunction(type, context) << inArgName << ", &" << outArgName << ')';
+}
+
+bool ShibokenGenerator::shouldRejectNullPointerArgument(const AbstractMetaFunction* func, int argIndex)
+{
+ if (argIndex < 0 || argIndex >= func->arguments().count())
+ return false;
+
+ const AbstractMetaArgument* arg = func->arguments().at(argIndex);
+ if (isValueTypeWithCopyConstructorOnly(arg->type()))
+ return true;
+
+ // Argument type is not a pointer, a None rejection should not be
+ // necessary because the type checking would handle that already.
+ if (!isPointer(arg->type()))
+ return false;
+ if (func->argumentRemoved(argIndex + 1))
+ return false;
+ foreach (const FunctionModification &funcMod, func->modifications()) {
+ foreach (const ArgumentModification &argMod, funcMod.argument_mods) {
+ if (argMod.index == argIndex + 1 && argMod.noNullPointers)
+ return true;
+ }
+ }
+ return false;
+}
+
+QString ShibokenGenerator::getFormatUnitString(const AbstractMetaFunction* func, bool incRef) const
+{
+ QString result;
+ const char objType = (incRef ? 'O' : 'N');
+ foreach (const AbstractMetaArgument* arg, func->arguments()) {
+ if (func->argumentRemoved(arg->argumentIndex() + 1))
+ continue;
+
+ if (!func->typeReplaced(arg->argumentIndex() + 1).isEmpty()) {
+ result += QLatin1Char(objType);
+ } else if (arg->type()->isQObject()
+ || arg->type()->isObject()
+ || arg->type()->isValue()
+ || arg->type()->isValuePointer()
+ || arg->type()->isNativePointer()
+ || arg->type()->isEnum()
+ || arg->type()->isFlags()
+ || arg->type()->isContainer()
+ || arg->type()->isSmartPointer()
+ || arg->type()->referenceType() == LValueReference) {
+ result += QLatin1Char(objType);
+ } else if (arg->type()->isPrimitive()) {
+ const PrimitiveTypeEntry* ptype = (const PrimitiveTypeEntry*) arg->type()->typeEntry();
+ if (ptype->basicReferencedTypeEntry())
+ ptype = ptype->basicReferencedTypeEntry();
+ if (m_formatUnits.contains(ptype->name()))
+ result += m_formatUnits[ptype->name()];
+ else
+ result += QLatin1Char(objType);
+ } else if (isCString(arg->type())) {
+ result += QLatin1Char('z');
+ } else {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Method: " << func->ownerClass()->qualifiedCppName()
+ << "::" << func->signature() << " => Arg:"
+ << arg->name() << "index: " << arg->argumentIndex()
+ << " - cannot be handled properly. Use an inject-code to fix it!";
+ result += QLatin1Char('?');
+ }
+ }
+ return result;
+}
+
+QString ShibokenGenerator::cpythonBaseName(const AbstractMetaType* type)
+{
+ if (isCString(type))
+ return QLatin1String("PyString");
+ return cpythonBaseName(type->typeEntry());
+}
+
+QString ShibokenGenerator::cpythonBaseName(const AbstractMetaClass* metaClass)
+{
+ return cpythonBaseName(metaClass->typeEntry());
+}
+
+QString ShibokenGenerator::cpythonBaseName(const TypeEntry* type)
+{
+ QString baseName;
+ if (ShibokenGenerator::isWrapperType(type) || type->isNamespace()) { // && type->referenceType() == NoReference) {
+ baseName = QLatin1String("Sbk_") + type->name();
+ } else if (type->isPrimitive()) {
+ const PrimitiveTypeEntry* ptype = (const PrimitiveTypeEntry*) type;
+ while (ptype->basicReferencedTypeEntry())
+ ptype = ptype->basicReferencedTypeEntry();
+ if (ptype->targetLangApiName() == ptype->name())
+ baseName = pythonPrimitiveTypeName(ptype->name());
+ else
+ baseName = ptype->targetLangApiName();
+ } else if (type->isEnum()) {
+ baseName = cpythonEnumName((const EnumTypeEntry*) type);
+ } else if (type->isFlags()) {
+ baseName = cpythonFlagsName((const FlagsTypeEntry*) type);
+ } else if (type->isContainer()) {
+ const ContainerTypeEntry* ctype = (const ContainerTypeEntry*) type;
+ switch (ctype->type()) {
+ case ContainerTypeEntry::ListContainer:
+ case ContainerTypeEntry::StringListContainer:
+ case ContainerTypeEntry::LinkedListContainer:
+ case ContainerTypeEntry::VectorContainer:
+ case ContainerTypeEntry::StackContainer:
+ case ContainerTypeEntry::QueueContainer:
+ //baseName = "PyList";
+ //break;
+ case ContainerTypeEntry::PairContainer:
+ //baseName = "PyTuple";
+ baseName = QLatin1String("PySequence");
+ break;
+ case ContainerTypeEntry::SetContainer:
+ baseName = QLatin1String("PySet");
+ break;
+ case ContainerTypeEntry::MapContainer:
+ case ContainerTypeEntry::MultiMapContainer:
+ case ContainerTypeEntry::HashContainer:
+ case ContainerTypeEntry::MultiHashContainer:
+ baseName = QLatin1String("PyDict");
+ break;
+ default:
+ Q_ASSERT(false);
+ }
+ } else {
+ baseName = QLatin1String("PyObject");
+ }
+ return baseName.replace(QLatin1String("::"), QLatin1String("_"));
+}
+
+QString ShibokenGenerator::cpythonTypeName(const AbstractMetaClass* metaClass)
+{
+ return cpythonTypeName(metaClass->typeEntry());
+}
+
+QString ShibokenGenerator::cpythonTypeName(const TypeEntry* type)
+{
+ return cpythonBaseName(type) + QLatin1String("_Type");
+}
+
+QString ShibokenGenerator::cpythonTypeNameExt(const TypeEntry* type)
+{
+ return cppApiVariableName(type->targetLangPackage()) + QLatin1Char('[')
+ + getTypeIndexVariableName(type) + QLatin1Char(']');
+}
+
+QString ShibokenGenerator::converterObject(const AbstractMetaType* type)
+{
+ if (isCString(type))
+ return QLatin1String("Shiboken::Conversions::PrimitiveTypeConverter<const char*>()");
+ if (isVoidPointer(type))
+ return QLatin1String("Shiboken::Conversions::PrimitiveTypeConverter<void*>()");
+ if (type->typeEntry()->isContainer()) {
+ return convertersVariableName(type->typeEntry()->targetLangPackage())
+ + QLatin1Char('[') + getTypeIndexVariableName(type) + QLatin1Char(']');
+ }
+ return converterObject(type->typeEntry());
+}
+
+QString ShibokenGenerator::converterObject(const TypeEntry* type)
+{
+ if (isCppPrimitive(type))
+ return QString::fromLatin1("Shiboken::Conversions::PrimitiveTypeConverter<%1>()").arg(type->qualifiedCppName());
+ if (isWrapperType(type) || type->isEnum() || type->isFlags())
+ return QString::fromLatin1("SBK_CONVERTER(%1)").arg(cpythonTypeNameExt(type));
+
+ if (type->isArray()) {
+ qDebug() << "Warning: no idea how to handle the Qt5 type " << type->qualifiedCppName();
+ return QString::null;
+ }
+
+ /* the typedef'd primitive types case */
+ const PrimitiveTypeEntry* pte = dynamic_cast<const PrimitiveTypeEntry*>(type);
+ if (!pte) {
+ qDebug() << "Warning: the Qt5 primitive type is unknown" << type->qualifiedCppName();
+ return QString::null;
+ }
+ if (pte->basicReferencedTypeEntry())
+ pte = pte->basicReferencedTypeEntry();
+ if (pte->isPrimitive() && !pte->isCppPrimitive() && !pte->customConversion())
+ return QString::fromLatin1("Shiboken::Conversions::PrimitiveTypeConverter<%1>()").arg(pte->qualifiedCppName());
+
+ return convertersVariableName(type->targetLangPackage())
+ + QLatin1Char('[') + getTypeIndexVariableName(type) + QLatin1Char(']');
+}
+
+QString ShibokenGenerator::cpythonTypeNameExt(const AbstractMetaType* type)
+{
+ return cppApiVariableName(type->typeEntry()->targetLangPackage()) + QLatin1Char('[')
+ + getTypeIndexVariableName(type) + QLatin1Char(']');
+}
+
+static QString msgUnknownOperator(const AbstractMetaFunction* func)
+{
+ QString result = QLatin1String("Unknown operator: \"") + func->originalName() + QLatin1Char('"');
+ if (const AbstractMetaClass *c = func->implementingClass())
+ result += QLatin1String(" in class: ") + c->name();
+ return result;
+}
+
+static inline QString unknownOperator() { return QStringLiteral("__UNKNOWN_OPERATOR__"); }
+
+QString ShibokenGenerator::cpythonOperatorFunctionName(const AbstractMetaFunction* func)
+{
+ if (!func->isOperatorOverload())
+ return QString();
+ const QString pythonOp = pythonOperatorFunctionName(func->originalName());
+ if (pythonOp == unknownOperator())
+ qCWarning(lcShiboken).noquote().nospace() << msgUnknownOperator(func);
+ return QLatin1String("Sbk") + func->ownerClass()->name()
+ + QLatin1Char('_') + pythonOp;
+}
+
+QString ShibokenGenerator::fixedCppTypeName(const CustomConversion::TargetToNativeConversion* toNative)
+{
+ if (toNative->sourceType())
+ return fixedCppTypeName(toNative->sourceType());
+ return toNative->sourceTypeName();
+}
+QString ShibokenGenerator::fixedCppTypeName(const AbstractMetaType* type)
+{
+ return fixedCppTypeName(type->typeEntry(), type->cppSignature());
+}
+
+static QString _fixedCppTypeName(QString typeName)
+{
+ typeName.remove(QLatin1Char(' '));
+ typeName.replace(QLatin1Char('.'), QLatin1Char('_'));
+ typeName.replace(QLatin1Char(','), QLatin1Char('_'));
+ typeName.replace(QLatin1Char('<'), QLatin1Char('_'));
+ typeName.replace(QLatin1Char('>'), QLatin1Char('_'));
+ typeName.replace(QLatin1String("::"), QLatin1String("_"));
+ typeName.replace(QLatin1String("*"), QLatin1String("PTR"));
+ typeName.replace(QLatin1String("&"), QLatin1String("REF"));
+ return typeName;
+}
+QString ShibokenGenerator::fixedCppTypeName(const TypeEntry* type, QString typeName)
+{
+ if (typeName.isEmpty())
+ typeName = type->qualifiedCppName();
+ if (!(type->codeGeneration() & TypeEntry::GenerateTargetLang)) {
+ typeName.prepend(QLatin1Char('_'));
+ typeName.prepend(type->targetLangPackage());
+ }
+ return _fixedCppTypeName(typeName);
+}
+
+QString ShibokenGenerator::pythonPrimitiveTypeName(const QString& cppTypeName)
+{
+ QString rv = ShibokenGenerator::m_pythonPrimitiveTypeName.value(cppTypeName, QString());
+ if (rv.isEmpty()) {
+ // activate this when some primitive types are missing,
+ // i.e. when shiboken itself fails to build.
+ // In general, this is valid while just called by isNumeric()
+ // used on Qt5, 2015-09-20
+ if (false) {
+ std::cerr << "primitive type not found: " << qPrintable(cppTypeName) << std::endl;
+ abort();
+ }
+ }
+ return rv;
+}
+
+QString ShibokenGenerator::pythonPrimitiveTypeName(const PrimitiveTypeEntry* type)
+{
+ while (type->basicReferencedTypeEntry())
+ type = type->basicReferencedTypeEntry();
+ return pythonPrimitiveTypeName(type->name());
+}
+
+QString ShibokenGenerator::pythonOperatorFunctionName(QString cppOpFuncName)
+{
+ QString value = m_pythonOperators.value(cppOpFuncName);
+ if (value.isEmpty())
+ return unknownOperator();
+ value.prepend(QLatin1String("__"));
+ value.append(QLatin1String("__"));
+ return value;
+}
+
+QString ShibokenGenerator::pythonOperatorFunctionName(const AbstractMetaFunction* func)
+{
+ QString op = pythonOperatorFunctionName(func->originalName());
+ if (op == unknownOperator())
+ qCWarning(lcShiboken).noquote().nospace() << msgUnknownOperator(func);
+ if (func->arguments().isEmpty()) {
+ if (op == QLatin1String("__sub__"))
+ op = QLatin1String("__neg__");
+ else if (op == QLatin1String("__add__"))
+ op = QLatin1String("__pos__");
+ } else if (func->isStatic() && func->arguments().size() == 2) {
+ // If a operator overload function has 2 arguments and
+ // is static we assume that it is a reverse operator.
+ op = op.insert(2, QLatin1Char('r'));
+ }
+ return op;
+}
+
+QString ShibokenGenerator::pythonRichCompareOperatorId(QString cppOpFuncName)
+{
+ return QLatin1String("Py_") + m_pythonOperators.value(cppOpFuncName).toUpper();
+}
+
+QString ShibokenGenerator::pythonRichCompareOperatorId(const AbstractMetaFunction* func)
+{
+ return pythonRichCompareOperatorId(func->originalName());
+}
+
+bool ShibokenGenerator::isNumber(QString cpythonApiName)
+{
+ return cpythonApiName == QLatin1String("PyInt")
+ || cpythonApiName == QLatin1String("PyFloat")
+ || cpythonApiName == QLatin1String("PyLong")
+ || cpythonApiName == QLatin1String("PyBool");
+}
+
+bool ShibokenGenerator::isNumber(const TypeEntry* type)
+{
+ if (!type->isPrimitive())
+ return false;
+ return isNumber(pythonPrimitiveTypeName((const PrimitiveTypeEntry*) type));
+}
+
+bool ShibokenGenerator::isNumber(const AbstractMetaType* type)
+{
+ return isNumber(type->typeEntry());
+}
+
+bool ShibokenGenerator::isPyInt(const TypeEntry* type)
+{
+ if (!type->isPrimitive())
+ return false;
+ return pythonPrimitiveTypeName((const PrimitiveTypeEntry*) type) == QLatin1String("PyInt");
+}
+
+bool ShibokenGenerator::isPyInt(const AbstractMetaType* type)
+{
+ return isPyInt(type->typeEntry());
+}
+
+bool ShibokenGenerator::isPairContainer(const AbstractMetaType* type)
+{
+ return type->isContainer()
+ && static_cast<const ContainerTypeEntry *>(type->typeEntry())->type() == ContainerTypeEntry::PairContainer;
+}
+
+bool ShibokenGenerator::isWrapperType(const TypeEntry* type)
+{
+ if (type->isComplex())
+ return ShibokenGenerator::isWrapperType((const ComplexTypeEntry*)type);
+ return type->isObject() || type->isValue() || type->isSmartPointer();
+}
+bool ShibokenGenerator::isWrapperType(const ComplexTypeEntry* type)
+{
+ return isObjectType(type) || type->isValue() || type->isSmartPointer();
+}
+bool ShibokenGenerator::isWrapperType(const AbstractMetaType* metaType)
+{
+ return isObjectType(metaType)
+ || metaType->typeEntry()->isValue()
+ || metaType->typeEntry()->isSmartPointer();
+}
+
+bool ShibokenGenerator::isPointerToWrapperType(const AbstractMetaType* type)
+{
+ return (isObjectType(type) && type->indirections() == 1) || type->isValuePointer();
+}
+
+bool ShibokenGenerator::isObjectTypeUsedAsValueType(const AbstractMetaType* type)
+{
+ return type->typeEntry()->isObject() && type->referenceType() == NoReference && type->indirections() == 0;
+}
+
+bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const AbstractMetaClass* metaClass)
+{
+ if (!metaClass || !metaClass->typeEntry()->isValue())
+ return false;
+ AbstractMetaFunctionList ctors = metaClass->queryFunctions(AbstractMetaClass::Constructors);
+ if (ctors.count() != 1)
+ return false;
+ return ctors.first()->functionType() == AbstractMetaFunction::CopyConstructorFunction;
+}
+
+bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const TypeEntry* type) const
+{
+ if (!type || !type->isValue())
+ return false;
+ return isValueTypeWithCopyConstructorOnly(AbstractMetaClass::findClass(classes(), type));
+}
+
+bool ShibokenGenerator::isValueTypeWithCopyConstructorOnly(const AbstractMetaType* type) const
+{
+ if (!type || !type->typeEntry()->isValue())
+ return false;
+ return isValueTypeWithCopyConstructorOnly(type->typeEntry());
+}
+
+bool ShibokenGenerator::isUserPrimitive(const TypeEntry* type)
+{
+ if (!type->isPrimitive())
+ return false;
+ const PrimitiveTypeEntry* trueType = (const PrimitiveTypeEntry*) type;
+ if (trueType->basicReferencedTypeEntry())
+ trueType = trueType->basicReferencedTypeEntry();
+ return trueType->isPrimitive() && !trueType->isCppPrimitive()
+ && trueType->qualifiedCppName() != QLatin1String("std::string");
+}
+
+bool ShibokenGenerator::isUserPrimitive(const AbstractMetaType* type)
+{
+ if (type->indirections() != 0)
+ return false;
+ return isUserPrimitive(type->typeEntry());
+}
+
+bool ShibokenGenerator::isCppPrimitive(const TypeEntry* type)
+{
+ if (type->isCppPrimitive())
+ return true;
+ if (!type->isPrimitive())
+ return false;
+ const PrimitiveTypeEntry* trueType = (const PrimitiveTypeEntry*) type;
+ if (trueType->basicReferencedTypeEntry())
+ trueType = trueType->basicReferencedTypeEntry();
+ return trueType->qualifiedCppName() == QLatin1String("std::string");
+}
+
+bool ShibokenGenerator::isCppPrimitive(const AbstractMetaType* type)
+{
+ if (isCString(type) || isVoidPointer(type))
+ return true;
+ if (type->indirections() != 0)
+ return false;
+ return isCppPrimitive(type->typeEntry());
+}
+
+bool ShibokenGenerator::shouldDereferenceArgumentPointer(const AbstractMetaArgument* arg)
+{
+ return shouldDereferenceAbstractMetaTypePointer(arg->type());
+}
+
+bool ShibokenGenerator::shouldDereferenceAbstractMetaTypePointer(const AbstractMetaType* metaType)
+{
+ return metaType->referenceType() == LValueReference && isWrapperType(metaType) && !isPointer(metaType);
+}
+
+bool ShibokenGenerator::visibilityModifiedToPrivate(const AbstractMetaFunction* func)
+{
+ foreach (const FunctionModification &mod, func->modifications()) {
+ if (mod.modifiers & Modification::Private)
+ return true;
+ }
+ return false;
+}
+
+QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType, bool genericNumberType)
+{
+ QString customCheck;
+ if (metaType->typeEntry()->isCustom()) {
+ AbstractMetaType* type;
+ customCheck = guessCPythonCheckFunction(metaType->typeEntry()->name(), &type);
+ if (type)
+ metaType = type;
+ if (!customCheck.isEmpty())
+ return customCheck;
+ }
+
+ if (isCppPrimitive(metaType)) {
+ if (isCString(metaType))
+ return QLatin1String("Shiboken::String::check");
+ if (isVoidPointer(metaType))
+ return QLatin1String("PyObject_Check");
+ return cpythonCheckFunction(metaType->typeEntry(), genericNumberType);
+ } else if (metaType->typeEntry()->isContainer()) {
+ QString typeCheck = QLatin1String("Shiboken::Conversions::");
+ ContainerTypeEntry::Type type = ((const ContainerTypeEntry*)metaType->typeEntry())->type();
+ if (type == ContainerTypeEntry::ListContainer
+ || type == ContainerTypeEntry::StringListContainer
+ || type == ContainerTypeEntry::LinkedListContainer
+ || type == ContainerTypeEntry::VectorContainer
+ || type == ContainerTypeEntry::StackContainer
+ || type == ContainerTypeEntry::SetContainer
+ || type == ContainerTypeEntry::QueueContainer) {
+ const AbstractMetaType* type = metaType->instantiations().first();
+ if (isPointerToWrapperType(type)) {
+ typeCheck += QString::fromLatin1("checkSequenceTypes(%1, ").arg(cpythonTypeNameExt(type));
+ } else if (isWrapperType(type)) {
+ typeCheck += QLatin1String("convertibleSequenceTypes(reinterpret_cast<const SbkObjectType *>(");
+ typeCheck += cpythonTypeNameExt(type);
+ typeCheck += QLatin1String("), ");
+ } else {
+ typeCheck += QString::fromLatin1("convertibleSequenceTypes(%1, ").arg(converterObject(type));
+ }
+ } else if (type == ContainerTypeEntry::MapContainer
+ || type == ContainerTypeEntry::MultiMapContainer
+ || type == ContainerTypeEntry::HashContainer
+ || type == ContainerTypeEntry::MultiHashContainer
+ || type == ContainerTypeEntry::PairContainer) {
+ QString pyType = (type == ContainerTypeEntry::PairContainer) ? QLatin1String("Pair") : QLatin1String("Dict");
+ const AbstractMetaType* firstType = metaType->instantiations().first();
+ const AbstractMetaType* secondType = metaType->instantiations().last();
+ if (isPointerToWrapperType(firstType) && isPointerToWrapperType(secondType)) {
+ typeCheck += QString::fromLatin1("check%1Types(%2, %3, ").arg(pyType)
+ .arg(cpythonTypeNameExt(firstType), cpythonTypeNameExt(secondType));
+ } else {
+ typeCheck += QString::fromLatin1("convertible%1Types(%2, %3, %4, %5, ")
+ .arg(pyType, converterObject(firstType),
+ isPointerToWrapperType(firstType) ? QLatin1String("true") : QLatin1String("false"),
+ converterObject(secondType),
+ isPointerToWrapperType(secondType) ? QLatin1String("true") : QLatin1String("false"));
+ }
+ }
+ return typeCheck;
+ }
+ return cpythonCheckFunction(metaType->typeEntry(), genericNumberType);
+}
+
+QString ShibokenGenerator::cpythonCheckFunction(const TypeEntry* type, bool genericNumberType)
+{
+ QString customCheck;
+ if (type->isCustom()) {
+ AbstractMetaType* metaType;
+ customCheck = guessCPythonCheckFunction(type->name(), &metaType);
+ if (metaType)
+ return cpythonCheckFunction(metaType, genericNumberType);
+ return customCheck;
+ }
+
+ if (type->isEnum() || type->isFlags() || isWrapperType(type))
+ return QString::fromLatin1("SbkObject_TypeCheck(%1, ").arg(cpythonTypeNameExt(type));
+ else if (isCppPrimitive(type))
+ return pythonPrimitiveTypeName((const PrimitiveTypeEntry*)type) + QLatin1String("_Check");
+ QString typeCheck;
+ if (type->targetLangApiName() == type->name())
+ typeCheck = cpythonIsConvertibleFunction(type);
+ else if (type->targetLangApiName() == QLatin1String("PyUnicode"))
+ typeCheck = QLatin1String("Shiboken::String::check");
+ else
+ typeCheck = type->targetLangApiName() + QLatin1String("_Check");
+ return typeCheck;
+}
+
+QString ShibokenGenerator::guessCPythonCheckFunction(const QString& type, AbstractMetaType** metaType)
+{
+ *metaType = 0;
+ if (type == QLatin1String("PyTypeObject"))
+ return QLatin1String("PyType_Check");
+
+ if (type == QLatin1String("PyBuffer"))
+ return QLatin1String("Shiboken::Buffer::checkType");
+
+ if (type == QLatin1String("str"))
+ return QLatin1String("Shiboken::String::check");
+
+ *metaType = buildAbstractMetaTypeFromString(type);
+ if (*metaType && !(*metaType)->typeEntry()->isCustom())
+ return QString();
+
+ return type + QLatin1String("_Check");
+}
+
+QString ShibokenGenerator::guessCPythonIsConvertible(const QString& type)
+{
+ if (type == QLatin1String("PyTypeObject"))
+ return QLatin1String("PyType_Check");
+
+ AbstractMetaType* metaType = buildAbstractMetaTypeFromString(type);
+ if (metaType && !metaType->typeEntry()->isCustom())
+ return cpythonIsConvertibleFunction(metaType);
+
+ return type + QLatin1String("_Check");
+}
+
+QString ShibokenGenerator::cpythonIsConvertibleFunction(const TypeEntry* type,
+ bool /* genericNumberType */,
+ bool /* checkExact */)
+{
+ if (isWrapperType(type)) {
+ QString result = QLatin1String("Shiboken::Conversions::");
+ result += (type->isValue() && !isValueTypeWithCopyConstructorOnly(type))
+ ? QLatin1String("isPythonToCppValueConvertible")
+ : QLatin1String("isPythonToCppPointerConvertible");
+ result += QLatin1String("(reinterpret_cast<SbkObjectType *>(")
+ + cpythonTypeNameExt(type) + QLatin1String("), ");
+ return result;
+ }
+ return QString::fromLatin1("Shiboken::Conversions::isPythonToCppConvertible(%1, ")
+ .arg(converterObject(type));
+}
+QString ShibokenGenerator::cpythonIsConvertibleFunction(const AbstractMetaType* metaType,
+ bool /* genericNumberType */)
+{
+ QString customCheck;
+ if (metaType->typeEntry()->isCustom()) {
+ AbstractMetaType* type;
+ customCheck = guessCPythonCheckFunction(metaType->typeEntry()->name(), &type);
+ if (type)
+ metaType = type;
+ if (!customCheck.isEmpty())
+ return customCheck;
+ }
+
+ if (isWrapperType(metaType)) {
+ QString result = QLatin1String("Shiboken::Conversions::");
+ if (isPointer(metaType) || isValueTypeWithCopyConstructorOnly(metaType))
+ result += QLatin1String("isPythonToCppPointerConvertible");
+ else if (metaType->referenceType() == LValueReference)
+ result += QLatin1String("isPythonToCppReferenceConvertible");
+ else
+ result += QLatin1String("isPythonToCppValueConvertible");
+ result += QLatin1String("(reinterpret_cast<const SbkObjectType *>(")
+ + cpythonTypeNameExt(metaType) + QLatin1String("), ");
+ return result;
+ }
+ return QStringLiteral("Shiboken::Conversions::isPythonToCppConvertible(%1, ")
+ .arg(converterObject(metaType));
+}
+
+QString ShibokenGenerator::cpythonIsConvertibleFunction(const AbstractMetaArgument *metaArg, bool genericNumberType)
+{
+ return cpythonIsConvertibleFunction(metaArg->type(), genericNumberType);
+}
+
+QString ShibokenGenerator::cpythonToCppConversionFunction(const AbstractMetaClass* metaClass)
+{
+ return QLatin1String("Shiboken::Conversions::pythonToCppPointer(reinterpret_cast<SbkObjectType *>(")
+ + cpythonTypeNameExt(metaClass->typeEntry()) + QLatin1String("), ");
+}
+
+QString ShibokenGenerator::cpythonToCppConversionFunction(const AbstractMetaType *type,
+ const AbstractMetaClass * /* context */)
+{
+ if (isWrapperType(type)) {
+ return QLatin1String("Shiboken::Conversions::pythonToCpp")
+ + (isPointer(type) ? QLatin1String("Pointer") : QLatin1String("Copy"))
+ + QLatin1String("(reinterpret_cast<SbkObjectType *>(")
+ + cpythonTypeNameExt(type) + QLatin1String("), ");
+ }
+ return QStringLiteral("Shiboken::Conversions::pythonToCppCopy(%1, ")
+ .arg(converterObject(type));
+}
+
+QString ShibokenGenerator::cpythonToPythonConversionFunction(const AbstractMetaType *type,
+ const AbstractMetaClass * /* context */)
+{
+ if (isWrapperType(type)) {
+ QString conversion;
+ if (type->referenceType() == LValueReference && !(type->isValue() && type->isConstant()) && !isPointer(type))
+ conversion = QLatin1String("reference");
+ else if (type->isValue() || type->isSmartPointer())
+ conversion = QLatin1String("copy");
+ else
+ conversion = QLatin1String("pointer");
+ QString result = QLatin1String("Shiboken::Conversions::") + conversion
+ + QLatin1String("ToPython(reinterpret_cast<const SbkObjectType *>(")
+ + cpythonTypeNameExt(type) + QLatin1String("), ");
+ if (conversion != QLatin1String("pointer"))
+ result += QLatin1Char('&');
+ return result;
+ }
+ return QStringLiteral("Shiboken::Conversions::copyToPython(%1, %2")
+ .arg(converterObject(type),
+ (isCString(type) || isVoidPointer(type)) ? QString() : QLatin1String("&"));
+}
+
+QString ShibokenGenerator::cpythonToPythonConversionFunction(const AbstractMetaClass* metaClass)
+{
+ return cpythonToPythonConversionFunction(metaClass->typeEntry());
+}
+
+QString ShibokenGenerator::cpythonToPythonConversionFunction(const TypeEntry* type)
+{
+ if (isWrapperType(type)) {
+ const QString conversion = type->isValue() ? QLatin1String("copy") : QLatin1String("pointer");
+ QString result = QLatin1String("Shiboken::Conversions::") + conversion
+ + QLatin1String("ToPython(reinterpret_cast<const SbkObjectType *>(") + cpythonTypeNameExt(type)
+ + QLatin1String("), ");
+ if (conversion != QLatin1String("pointer"))
+ result += QLatin1Char('&');
+ return result;
+ }
+
+ return QStringLiteral("Shiboken::Conversions::copyToPython(%1, &").arg(converterObject(type));
+}
+
+QString ShibokenGenerator::argumentString(const AbstractMetaFunction *func,
+ const AbstractMetaArgument *argument,
+ Options options) const
+{
+ QString modified_type;
+ if (!(options & OriginalTypeDescription))
+ modified_type = func->typeReplaced(argument->argumentIndex() + 1);
+ QString arg;
+
+ if (modified_type.isEmpty())
+ arg = translateType(argument->type(), func->implementingClass(), options);
+ else
+ arg = modified_type.replace(QLatin1Char('$'), QLatin1Char('.'));
+
+ if (!(options & Generator::SkipName)) {
+ arg += QLatin1Char(' ');
+ arg += argument->name();
+ }
+
+ QList<ReferenceCount> referenceCounts;
+ referenceCounts = func->referenceCounts(func->implementingClass(), argument->argumentIndex() + 1);
+ if ((options & Generator::SkipDefaultValues) != Generator::SkipDefaultValues &&
+ !argument->originalDefaultValueExpression().isEmpty())
+ {
+ QString default_value = argument->originalDefaultValueExpression();
+ if (default_value == QLatin1String("NULL"))
+ default_value = QLatin1String(NULL_VALUE);
+
+ //WORKAROUND: fix this please
+ if (default_value.startsWith(QLatin1String("new ")))
+ default_value.remove(0, 4);
+
+ arg += QLatin1String(" = ") + default_value;
+ }
+
+ return arg;
+}
+
+void ShibokenGenerator::writeArgument(QTextStream &s,
+ const AbstractMetaFunction *func,
+ const AbstractMetaArgument *argument,
+ Options options) const
+{
+ s << argumentString(func, argument, options);
+}
+
+void ShibokenGenerator::writeFunctionArguments(QTextStream &s,
+ const AbstractMetaFunction *func,
+ Options options) const
+{
+ AbstractMetaArgumentList arguments = func->arguments();
+
+ if (options & Generator::WriteSelf) {
+ s << func->implementingClass()->name() << '&';
+ if (!(options & SkipName))
+ s << " " PYTHON_SELF_VAR;
+ }
+
+ int argUsed = 0;
+ for (int i = 0; i < arguments.size(); ++i) {
+ if ((options & Generator::SkipRemovedArguments) && func->argumentRemoved(i+1))
+ continue;
+
+ if ((options & Generator::WriteSelf) || argUsed != 0)
+ s << ", ";
+ writeArgument(s, func, arguments[i], options);
+ argUsed++;
+ }
+}
+
+QString ShibokenGenerator::functionReturnType(const AbstractMetaFunction* func, Options options) const
+{
+ QString modifiedReturnType = QString(func->typeReplaced(0));
+ if (!modifiedReturnType.isNull() && !(options & OriginalTypeDescription))
+ return modifiedReturnType;
+ else
+ return translateType(func->type(), func->implementingClass(), options);
+}
+
+QString ShibokenGenerator::functionSignature(const AbstractMetaFunction *func,
+ QString prepend,
+ QString append,
+ Options options,
+ int /* argCount */) const
+{
+ QString result;
+ QTextStream s(&result);
+ // The actual function
+ if (!(func->isEmptyFunction() ||
+ func->isNormal() ||
+ func->isSignal())) {
+ options |= Generator::SkipReturnType;
+ } else {
+ s << functionReturnType(func, options) << ' ';
+ }
+
+ // name
+ QString name(func->originalName());
+ if (func->isConstructor())
+ name = wrapperName(func->ownerClass());
+
+ s << prepend << name << append << '(';
+ writeFunctionArguments(s, func, options);
+ s << ')';
+
+ if (func->isConstant() && !(options & Generator::ExcludeMethodConst))
+ s << " const";
+
+ return result;
+}
+
+void ShibokenGenerator::writeArgumentNames(QTextStream &s,
+ const AbstractMetaFunction *func,
+ Options options) const
+{
+ AbstractMetaArgumentList arguments = func->arguments();
+ int argCount = 0;
+ for (int j = 0, max = arguments.size(); j < max; j++) {
+
+ if ((options & Generator::SkipRemovedArguments) && (func->argumentRemoved(arguments.at(j)->argumentIndex()+1)))
+ continue;
+
+ s << ((argCount > 0) ? ", " : "") << arguments.at(j)->name();
+
+ if (((options & Generator::VirtualCall) == 0)
+ && (!func->conversionRule(TypeSystem::NativeCode, arguments.at(j)->argumentIndex() + 1).isEmpty()
+ || !func->conversionRule(TypeSystem::TargetLangCode, arguments.at(j)->argumentIndex() + 1).isEmpty())
+ && !func->isConstructor()) {
+ s << CONV_RULE_OUT_VAR_SUFFIX;
+ }
+
+ argCount++;
+ }
+}
+
+void ShibokenGenerator::writeFunctionCall(QTextStream& s,
+ const AbstractMetaFunction* func,
+ Options options) const
+{
+ if (!(options & Generator::SkipName))
+ s << (func->isConstructor() ? func->ownerClass()->qualifiedCppName() : func->originalName());
+ s << '(';
+ writeArgumentNames(s, func, options);
+ s << ')';
+}
+
+void ShibokenGenerator::writeUnusedVariableCast(QTextStream& s, const QString& variableName)
+{
+ s << INDENT << "SBK_UNUSED(" << variableName<< ')' << endl;
+}
+
+AbstractMetaFunctionList ShibokenGenerator::filterFunctions(const AbstractMetaClass* metaClass)
+{
+ AbstractMetaFunctionList result;
+ foreach (AbstractMetaFunction *func, metaClass->functions()) {
+ if (func->isSignal() || func->isDestructor() || func->usesRValueReferences()
+ || (func->isModifiedRemoved() && !func->isAbstract()
+ && (!avoidProtectedHack() || !func->isProtected())))
+ continue;
+ result << func;
+ }
+ return result;
+}
+
+ShibokenGenerator::ExtendedConverterData ShibokenGenerator::getExtendedConverters() const
+{
+ ExtendedConverterData extConvs;
+ foreach (const AbstractMetaClass* metaClass, classes()) {
+ // Use only the classes for the current module.
+ if (!shouldGenerate(metaClass))
+ continue;
+ foreach (AbstractMetaFunction* convOp, metaClass->operatorOverloads(AbstractMetaClass::ConversionOp)) {
+ // Get only the conversion operators that return a type from another module,
+ // that are value-types and were not removed in the type system.
+ const TypeEntry* convType = convOp->type()->typeEntry();
+ if ((convType->codeGeneration() & TypeEntry::GenerateTargetLang)
+ || !convType->isValue()
+ || convOp->isModifiedRemoved())
+ continue;
+ extConvs[convType].append(convOp->ownerClass());
+ }
+ }
+ return extConvs;
+}
+
+QList<const CustomConversion*> ShibokenGenerator::getPrimitiveCustomConversions()
+{
+ QList<const CustomConversion*> conversions;
+ foreach (const PrimitiveTypeEntry* type, primitiveTypes()) {
+ if (!shouldGenerateTypeEntry(type) || !isUserPrimitive(type) || !type->customConversion())
+ continue;
+
+ conversions << type->customConversion();
+ }
+ return conversions;
+}
+
+static QString getArgumentsFromMethodCall(const QString& str)
+{
+ // It would be way nicer to be able to use a Perl like
+ // regular expression that accepts temporary variables
+ // to count the parenthesis.
+ // For more information check this:
+ // http://perl.plover.com/yak/regex/samples/slide083.html
+ static QLatin1String funcCall("%CPPSELF.%FUNCTION_NAME");
+ int pos = str.indexOf(funcCall);
+ if (pos == -1)
+ return QString();
+ pos = pos + funcCall.size();
+ while (str.at(pos) == QLatin1Char(' ') || str.at(pos) == QLatin1Char('\t'))
+ ++pos;
+ if (str.at(pos) == QLatin1Char('('))
+ ++pos;
+ int begin = pos;
+ int counter = 1;
+ while (counter != 0) {
+ if (str.at(pos) == QLatin1Char('('))
+ ++counter;
+ else if (str.at(pos) == QLatin1Char(')'))
+ --counter;
+ ++pos;
+ }
+ return str.mid(begin, pos-begin-1);
+}
+
+QString ShibokenGenerator::getCodeSnippets(const CodeSnipList& codeSnips,
+ TypeSystem::CodeSnipPosition position,
+ TypeSystem::Language language)
+{
+ QString code;
+ QTextStream c(&code);
+ foreach (const CodeSnip &snip, codeSnips) {
+ if ((position != TypeSystem::CodeSnipPositionAny && snip.position != position) || !(snip.language & language))
+ continue;
+ QString snipCode;
+ QTextStream sc(&snipCode);
+ formatCode(sc, snip.code(), INDENT);
+ c << snipCode;
+ }
+ return code;
+}
+void ShibokenGenerator::processCodeSnip(QString& code, const AbstractMetaClass* context)
+{
+ if (context) {
+ // Replace template variable by the Python Type object
+ // for the class context in which the variable is used.
+ code.replace(QLatin1String("%PYTHONTYPEOBJECT"),
+ cpythonTypeName(context) + QLatin1String(".super.ht_type"));
+ code.replace(QLatin1String("%TYPE"), wrapperName(context));
+ code.replace(QLatin1String("%CPPTYPE"), context->name());
+ }
+
+ // replace "toPython" converters
+ replaceConvertToPythonTypeSystemVariable(code);
+
+ // replace "toCpp" converters
+ replaceConvertToCppTypeSystemVariable(code);
+
+ // replace "isConvertible" check
+ replaceIsConvertibleToCppTypeSystemVariable(code);
+
+ // replace "checkType" check
+ replaceTypeCheckTypeSystemVariable(code);
+}
+
+ShibokenGenerator::ArgumentVarReplacementList ShibokenGenerator::getArgumentReplacement(const AbstractMetaFunction* func,
+ bool usePyArgs, TypeSystem::Language language,
+ const AbstractMetaArgument* lastArg)
+{
+ ArgumentVarReplacementList argReplacements;
+ TypeSystem::Language convLang = (language == TypeSystem::TargetLangCode)
+ ? TypeSystem::NativeCode : TypeSystem::TargetLangCode;
+ int removed = 0;
+ for (int i = 0; i < func->arguments().size(); ++i) {
+ const AbstractMetaArgument* arg = func->arguments().at(i);
+ QString argValue;
+ if (language == TypeSystem::TargetLangCode) {
+ bool hasConversionRule = !func->conversionRule(convLang, i+1).isEmpty();
+ bool argRemoved = func->argumentRemoved(i+1);
+ removed = removed + (int) argRemoved;
+ if (argRemoved && hasConversionRule)
+ argValue = arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
+ else if (argRemoved || (lastArg && arg->argumentIndex() > lastArg->argumentIndex()))
+ argValue = QLatin1String(CPP_ARG_REMOVED) + QString::number(i);
+ if (!argRemoved && argValue.isEmpty()) {
+ int argPos = i - removed;
+ const AbstractMetaType* type = arg->type();
+ QString typeReplaced = func->typeReplaced(arg->argumentIndex() + 1);
+ if (!typeReplaced.isEmpty()) {
+ AbstractMetaType* builtType = buildAbstractMetaTypeFromString(typeReplaced);
+ if (builtType)
+ type = builtType;
+ }
+ if (type->typeEntry()->isCustom()) {
+ argValue = usePyArgs
+ ? QString::fromLatin1(PYTHON_ARGS "[%1]").arg(argPos)
+ : QLatin1String(PYTHON_ARG);
+ } else {
+ argValue = hasConversionRule
+ ? arg->name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX)
+ : QLatin1String(CPP_ARG) + QString::number(argPos);
+ if (isWrapperType(type)) {
+ if (type->referenceType() == LValueReference && !isPointer(type))
+ argValue.prepend(QLatin1Char('*'));
+ }
+ }
+ }
+ } else {
+ argValue = arg->name();
+ }
+ if (!argValue.isEmpty())
+ argReplacements << ArgumentVarReplacementPair(arg, argValue);
+
+ }
+ return argReplacements;
+}
+
+void ShibokenGenerator::writeCodeSnips(QTextStream& s,
+ const CodeSnipList& codeSnips,
+ TypeSystem::CodeSnipPosition position,
+ TypeSystem::Language language,
+ const AbstractMetaClass* context)
+{
+ QString code = getCodeSnippets(codeSnips, position, language);
+ if (code.isEmpty())
+ return;
+ processCodeSnip(code, context);
+ s << INDENT << "// Begin code injection" << endl;
+ s << code;
+ s << INDENT << "// End of code injection" << endl;
+}
+
+void ShibokenGenerator::writeCodeSnips(QTextStream& s,
+ const CodeSnipList& codeSnips,
+ TypeSystem::CodeSnipPosition position,
+ TypeSystem::Language language,
+ const AbstractMetaFunction* func,
+ const AbstractMetaArgument* lastArg)
+{
+ QString code = getCodeSnippets(codeSnips, position, language);
+ if (code.isEmpty())
+ return;
+
+ // Calculate the real number of arguments.
+ int argsRemoved = 0;
+ for (int i = 0; i < func->arguments().size(); i++) {
+ if (func->argumentRemoved(i+1))
+ argsRemoved++;
+ }
+
+ OverloadData od(getFunctionGroups(func->implementingClass())[func->name()], this);
+ bool usePyArgs = pythonFunctionWrapperUsesListOfArguments(od);
+
+ // Replace %PYARG_# variables.
+ code.replace(QLatin1String("%PYARG_0"), QLatin1String(PYTHON_RETURN_VAR));
+
+ static QRegExp pyArgsRegex(QLatin1String("%PYARG_(\\d+)"));
+ if (language == TypeSystem::TargetLangCode) {
+ if (usePyArgs) {
+ code.replace(pyArgsRegex, QLatin1String(PYTHON_ARGS"[\\1-1]"));
+ } else {
+ static QRegExp pyArgsRegexCheck(QLatin1String("%PYARG_([2-9]+)"));
+ if (pyArgsRegexCheck.indexIn(code) != -1) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Wrong index for %PYARG variable (" << pyArgsRegexCheck.cap(1) << ") on " << func->signature();
+ return;
+ }
+ code.replace(QLatin1String("%PYARG_1"), QLatin1String(PYTHON_ARG));
+ }
+ } else {
+ // Replaces the simplest case of attribution to a
+ // Python argument on the binding virtual method.
+ static QRegExp pyArgsAttributionRegex(QLatin1String("%PYARG_(\\d+)\\s*=[^=]\\s*([^;]+)"));
+ code.replace(pyArgsAttributionRegex, QLatin1String("PyTuple_SET_ITEM(" PYTHON_ARGS ", \\1-1, \\2)"));
+ code.replace(pyArgsRegex, QLatin1String("PyTuple_GET_ITEM(" PYTHON_ARGS ", \\1-1)"));
+ }
+
+ // Replace %ARG#_TYPE variables.
+ foreach (const AbstractMetaArgument* arg, func->arguments()) {
+ QString argTypeVar = QStringLiteral("%ARG%1_TYPE").arg(arg->argumentIndex() + 1);
+ QString argTypeVal = arg->type()->cppSignature();
+ code.replace(argTypeVar, argTypeVal);
+ }
+
+ int pos = 0;
+ static QRegExp cppArgTypeRegexCheck(QLatin1String("%ARG(\\d+)_TYPE"));
+ while ((pos = cppArgTypeRegexCheck.indexIn(code, pos)) != -1) {
+ qCWarning(lcShiboken).noquote().nospace()
+ << "Wrong index for %ARG#_TYPE variable (" << cppArgTypeRegexCheck.cap(1)
+ << ") on " << func->signature();
+ pos += cppArgTypeRegexCheck.matchedLength();
+ }
+
+ // Replace template variable for return variable name.
+ if (func->isConstructor()) {
+ code.replace(QLatin1String("%0."), QLatin1String("cptr->"));
+ code.replace(QLatin1String("%0"), QLatin1String("cptr"));
+ } else if (func->type()) {
+ QString returnValueOp = isPointerToWrapperType(func->type())
+ ? QLatin1String("%1->") : QLatin1String("%1.");
+ if (ShibokenGenerator::isWrapperType(func->type()))
+ code.replace(QLatin1String("%0."), returnValueOp.arg(QLatin1String(CPP_RETURN_VAR)));
+ code.replace(QLatin1String("%0"), QLatin1String(CPP_RETURN_VAR));
+ }
+
+ // Replace template variable for self Python object.
+ QString pySelf = (language == TypeSystem::NativeCode) ? QLatin1String("pySelf") : QLatin1String(PYTHON_SELF_VAR);
+ code.replace(QLatin1String("%PYSELF"), pySelf);
+
+ // Replace template variable for a pointer to C++ of this object.
+ if (func->implementingClass()) {
+ QString replacement = func->isStatic() ? QLatin1String("%1::") : QLatin1String("%1->");
+ QString cppSelf;
+ if (func->isStatic())
+ cppSelf = func->ownerClass()->qualifiedCppName();
+ else if (language == TypeSystem::NativeCode)
+ cppSelf = QLatin1String("this");
+ else
+ cppSelf = QLatin1String(CPP_SELF_VAR);
+
+ // On comparison operator CPP_SELF_VAR is always a reference.
+ if (func->isComparisonOperator())
+ replacement = QLatin1String("%1.");
+
+ if (func->isVirtual() && !func->isAbstract() && (!avoidProtectedHack() || !func->isProtected())) {
+ QString methodCallArgs = getArgumentsFromMethodCall(code);
+ if (!methodCallArgs.isNull()) {
+ const QString pattern = QStringLiteral("%CPPSELF.%FUNCTION_NAME(%1)").arg(methodCallArgs);
+ if (func->name() == QLatin1String("metaObject")) {
+ QString wrapperClassName = wrapperName(func->ownerClass());
+ QString cppSelfVar = avoidProtectedHack()
+ ? QLatin1String("%CPPSELF")
+ : QStringLiteral("reinterpret_cast<%1*>(%CPPSELF)").arg(wrapperClassName);
+ code.replace(pattern,
+ QString::fromLatin1("(Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject*>(%1))"
+ " ? %2->::%3::%FUNCTION_NAME(%4)"
+ " : %CPPSELF.%FUNCTION_NAME(%4))").arg(pySelf, cppSelfVar, wrapperClassName, methodCallArgs));
+ } else {
+ code.replace(pattern,
+ QString::fromLatin1("(Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject*>(%1))"
+ " ? %CPPSELF->::%TYPE::%FUNCTION_NAME(%2)"
+ " : %CPPSELF.%FUNCTION_NAME(%2))").arg(pySelf, methodCallArgs));
+ }
+ }
+ }
+
+ code.replace(QLatin1String("%CPPSELF."), replacement.arg(cppSelf));
+ code.replace(QLatin1String("%CPPSELF"), cppSelf);
+
+ if (code.indexOf(QLatin1String("%BEGIN_ALLOW_THREADS")) > -1) {
+ if (code.count(QLatin1String("%BEGIN_ALLOW_THREADS")) == code.count(QLatin1String("%END_ALLOW_THREADS"))) {
+ code.replace(QLatin1String("%BEGIN_ALLOW_THREADS"), QLatin1String(BEGIN_ALLOW_THREADS));
+ code.replace(QLatin1String("%END_ALLOW_THREADS"), QLatin1String(END_ALLOW_THREADS));
+ } else {
+ qCWarning(lcShiboken) << "%BEGIN_ALLOW_THREADS and %END_ALLOW_THREADS mismatch";
+ }
+ }
+
+ // replace template variable for the Python Type object for the
+ // class implementing the method in which the code snip is written
+ if (func->isStatic()) {
+ code.replace(QLatin1String("%PYTHONTYPEOBJECT"),
+ cpythonTypeName(func->implementingClass()) + QLatin1String(".super.ht_type"));
+ } else {
+ code.replace(QLatin1String("%PYTHONTYPEOBJECT."), pySelf + QLatin1String("->ob_type->"));
+ code.replace(QLatin1String("%PYTHONTYPEOBJECT"), pySelf + QLatin1String("->ob_type"));
+ }
+ }
+
+ // Replaces template %ARGUMENT_NAMES and %# variables by argument variables and values.
+ // Replaces template variables %# for individual arguments.
+ ArgumentVarReplacementList argReplacements = getArgumentReplacement(func, usePyArgs, language, lastArg);
+
+ QStringList args;
+ foreach (const ArgumentVarReplacementPair &pair, argReplacements) {
+ if (pair.second.startsWith(QLatin1String(CPP_ARG_REMOVED)))
+ continue;
+ args << pair.second;
+ }
+ code.replace(QLatin1String("%ARGUMENT_NAMES"), args.join(QLatin1String(", ")));
+
+ foreach (const ArgumentVarReplacementPair &pair, argReplacements) {
+ const AbstractMetaArgument* arg = pair.first;
+ int idx = arg->argumentIndex() + 1;
+ AbstractMetaType* type = arg->type();
+ QString typeReplaced = func->typeReplaced(arg->argumentIndex() + 1);
+ if (!typeReplaced.isEmpty()) {
+ AbstractMetaType* builtType = buildAbstractMetaTypeFromString(typeReplaced);
+ if (builtType)
+ type = builtType;
+ }
+ if (isWrapperType(type)) {
+ QString replacement = pair.second;
+ if (type->referenceType() == LValueReference && !isPointer(type))
+ replacement.remove(0, 1);
+ if (type->referenceType() == LValueReference || isPointer(type))
+ code.replace(QString::fromLatin1("%%1.").arg(idx), replacement + QLatin1String("->"));
+ }
+ code.replace(QRegExp(QString::fromLatin1("%%1\\b").arg(idx)), pair.second);
+ }
+
+ if (language == TypeSystem::NativeCode) {
+ // Replaces template %PYTHON_ARGUMENTS variable with a pointer to the Python tuple
+ // containing the converted virtual method arguments received from C++ to be passed
+ // to the Python override.
+ code.replace(QLatin1String("%PYTHON_ARGUMENTS"), QLatin1String(PYTHON_ARGS));
+
+ // replace variable %PYTHON_METHOD_OVERRIDE for a pointer to the Python method
+ // override for the C++ virtual method in which this piece of code was inserted
+ code.replace(QLatin1String("%PYTHON_METHOD_OVERRIDE"), QLatin1String(PYTHON_OVERRIDE_VAR));
+ }
+
+ if (avoidProtectedHack()) {
+ // If the function being processed was added by the user via type system,
+ // Shiboken needs to find out if there are other overloads for the same method
+ // name and if any of them is of the protected visibility. This is used to replace
+ // calls to %FUNCTION_NAME on user written custom code for calls to the protected
+ // dispatcher.
+ bool hasProtectedOverload = false;
+ if (func->isUserAdded()) {
+ foreach (const AbstractMetaFunction* f, getFunctionOverloads(func->ownerClass(), func->name()))
+ hasProtectedOverload |= f->isProtected();
+ }
+
+ if (func->isProtected() || hasProtectedOverload) {
+ code.replace(QLatin1String("%TYPE::%FUNCTION_NAME"),
+ QStringLiteral("%1::%2_protected")
+ .arg(wrapperName(func->ownerClass()), func->originalName()));
+ code.replace(QLatin1String("%FUNCTION_NAME"),
+ func->originalName() + QLatin1String("_protected"));
+ }
+ }
+
+ if (func->isConstructor() && shouldGenerateCppWrapper(func->ownerClass()))
+ code.replace(QLatin1String("%TYPE"), wrapperName(func->ownerClass()));
+
+ if (func->ownerClass())
+ code.replace(QLatin1String("%CPPTYPE"), func->ownerClass()->name());
+
+ replaceTemplateVariables(code, func);
+
+ processCodeSnip(code);
+ s << INDENT << "// Begin code injection" << endl;
+ s << code;
+ s << INDENT << "// End of code injection" << endl;
+}
+
+// Returns true if the string is an expression,
+// and false if it is a variable.
+static bool isVariable(const QString& code)
+{
+ static QRegExp expr(QLatin1String("\\s*\\*?\\s*[A-Za-z_][A-Za-z_0-9.]*\\s*(?:\\[[^\\[]+\\])*"));
+ return expr.exactMatch(code.trimmed());
+}
+
+// A miniature normalizer that puts a type string into a format
+// suitable for comparison with AbstractMetaType::cppSignature()
+// result.
+static QString miniNormalizer(const QString& varType)
+{
+ QString normalized = varType.trimmed();
+ if (normalized.isEmpty())
+ return normalized;
+ if (normalized.startsWith(QLatin1String("::")))
+ normalized.remove(0, 2);
+ QString suffix;
+ while (normalized.endsWith(QLatin1Char('*')) || normalized.endsWith(QLatin1Char('&'))) {
+ suffix.prepend(normalized.at(normalized.count() - 1));
+ normalized.chop(1);
+ normalized = normalized.trimmed();
+ }
+ const QString result = normalized + QLatin1Char(' ') + suffix;
+ return result.trimmed();
+}
+// The position must indicate the first character after the opening '('.
+// ATTENTION: do not modify this function to trim any resulting string!
+// This must be done elsewhere.
+static QString getConverterTypeSystemVariableArgument(const QString& code, int pos)
+{
+ QString arg;
+ int parenthesisDepth = 0;
+ int count = 0;
+ while (pos + count < code.count()) {
+ char c = code.at(pos+count).toLatin1(); // toAscii is gone
+ if (c == '(') {
+ ++parenthesisDepth;
+ } else if (c == ')') {
+ if (parenthesisDepth == 0) {
+ arg = code.mid(pos, count).trimmed();
+ break;
+ }
+ --parenthesisDepth;
+ }
+ ++count;
+ }
+ if (parenthesisDepth != 0)
+ qFatal("Unbalanced parenthesis on type system converter variable call.");
+ return arg;
+}
+typedef QPair<QString, QString> StringPair;
+void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVariable converterVariable, QString& code)
+{
+ QRegExp& regex = m_typeSystemConvRegEx[converterVariable];
+ int pos = 0;
+ QList<StringPair> replacements;
+ while ((pos = regex.indexIn(code, pos)) != -1) {
+ pos += regex.matchedLength();
+ QStringList list = regex.capturedTexts();
+ QString conversionString = list.first();
+ QString conversionTypeName = list.last();
+ const AbstractMetaType* conversionType = buildAbstractMetaTypeFromString(conversionTypeName);
+ if (!conversionType) {
+ qFatal(qPrintable(QString::fromLatin1("Could not find type '%1' for use in '%2' conversion. "
+ "Make sure to use the full C++ name, e.g. 'Namespace::Class'.")
+ .arg(conversionTypeName).arg(m_typeSystemConvName[converterVariable])), NULL);
+
+ }
+ QString conversion;
+ QTextStream c(&conversion);
+ switch (converterVariable) {
+ case TypeSystemToCppFunction: {
+ int end = pos - list.first().count();
+ int start = end;
+ while (start > 0 && code.at(start) != QLatin1Char('\n'))
+ --start;
+ while (code.at(start).isSpace())
+ ++start;
+ QString varType = code.mid(start, end - start);
+ conversionString = varType + list.first();
+ varType = miniNormalizer(varType);
+ QString varName = list.at(1).trimmed();
+ if (!varType.isEmpty()) {
+ if (varType != conversionType->cppSignature()) {
+ qFatal(qPrintable(QString::fromLatin1("Types of receiver variable ('%1') and %CONVERTTOCPP type system variable ('%2') differ.")
+ .arg(varType, conversionType->cppSignature())), NULL);
+ }
+ c << getFullTypeName(conversionType) << ' ' << varName;
+ writeMinimalConstructorExpression(c, conversionType);
+ c << ';' << endl;
+ Indentation indent(INDENT);
+ c << INDENT;
+ }
+ c << cpythonToCppConversionFunction(conversionType);
+ QString prefix;
+ if (varName.startsWith(QLatin1Char('*'))) {
+ varName.remove(0, 1);
+ varName = varName.trimmed();
+ } else {
+ prefix = QLatin1Char('&');
+ }
+ QString arg = getConverterTypeSystemVariableArgument(code, pos);
+ conversionString += arg;
+ c << arg << ", " << prefix << '(' << varName << ')';
+ break;
+ }
+ case TypeSystemCheckFunction:
+ conversion = cpythonCheckFunction(conversionType);
+ if (conversionType->typeEntry()->isPrimitive()
+ && (conversionType->typeEntry()->name() == QLatin1String("PyObject")
+ || !conversion.endsWith(QLatin1Char(' ')))) {
+ c << '(';
+ break;
+ }
+ case TypeSystemIsConvertibleFunction:
+ if (conversion.isEmpty())
+ conversion = cpythonIsConvertibleFunction(conversionType);
+ case TypeSystemToPythonFunction:
+ if (conversion.isEmpty())
+ conversion = cpythonToPythonConversionFunction(conversionType);
+ default: {
+ QString arg = getConverterTypeSystemVariableArgument(code, pos);
+ conversionString += arg;
+ if (converterVariable == TypeSystemToPythonFunction && !isVariable(arg)) {
+ qFatal(qPrintable(QString::fromLatin1("Only variables are acceptable as argument to %%CONVERTTOPYTHON type system variable on code snippet: '%1'")
+ .arg(code)), NULL);
+ }
+ if (conversion.contains(QLatin1String("%in"))) {
+ conversion.prepend(QLatin1Char('('));
+ conversion.replace(QLatin1String("%in"), arg);
+ } else {
+ c << arg;
+ }
+ }
+ }
+ replacements.append(qMakePair(conversionString, conversion));
+ }
+ foreach (const StringPair &rep, replacements)
+ code.replace(rep.first, rep.second);
+}
+
+bool ShibokenGenerator::injectedCodeUsesCppSelf(const AbstractMetaFunction* func)
+{
+ CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode);
+ foreach (const CodeSnip &snip, snips) {
+ if (snip.code().contains(QLatin1String("%CPPSELF")))
+ return true;
+ }
+ return false;
+}
+
+bool ShibokenGenerator::injectedCodeUsesPySelf(const AbstractMetaFunction* func)
+{
+ CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::NativeCode);
+ foreach (const CodeSnip &snip, snips) {
+ if (snip.code().contains(QLatin1String("%PYSELF")))
+ return true;
+ }
+ return false;
+}
+
+bool ShibokenGenerator::injectedCodeCallsCppFunction(const AbstractMetaFunction* func)
+{
+ QString funcCall = func->originalName() + QLatin1Char('(');
+ QString wrappedCtorCall;
+ if (func->isConstructor()) {
+ funcCall.prepend(QLatin1String("new "));
+ wrappedCtorCall = QStringLiteral("new %1(").arg(wrapperName(func->ownerClass()));
+ }
+ CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode);
+ foreach (const CodeSnip &snip, snips) {
+ if (snip.code().contains(QLatin1String("%FUNCTION_NAME(")) || snip.code().contains(funcCall)
+ || (func->isConstructor()
+ && ((func->ownerClass()->isPolymorphic() && snip.code().contains(wrappedCtorCall))
+ || snip.code().contains(QLatin1String("new %TYPE("))))
+ )
+ return true;
+ }
+ return false;
+}
+
+bool ShibokenGenerator::injectedCodeCallsPythonOverride(const AbstractMetaFunction* func)
+{
+ static QRegExp overrideCallRegexCheck(QLatin1String("PyObject_Call\\s*\\(\\s*%PYTHON_METHOD_OVERRIDE\\s*,"));
+ CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::NativeCode);
+ foreach (const CodeSnip &snip, snips) {
+ if (overrideCallRegexCheck.indexIn(snip.code()) != -1)
+ return true;
+ }
+ return false;
+}
+
+bool ShibokenGenerator::injectedCodeHasReturnValueAttribution(const AbstractMetaFunction* func, TypeSystem::Language language)
+{
+ static QRegExp retValAttributionRegexCheck_native(QLatin1String("%0\\s*=[^=]\\s*.+"));
+ static QRegExp retValAttributionRegexCheck_target(QLatin1String("%PYARG_0\\s*=[^=]\\s*.+"));
+ CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, language);
+ foreach (const CodeSnip &snip, snips) {
+ if (language == TypeSystem::TargetLangCode) {
+ if (retValAttributionRegexCheck_target.indexIn(snip.code()) != -1)
+ return true;
+ } else {
+ if (retValAttributionRegexCheck_native.indexIn(snip.code()) != -1)
+ return true;
+ }
+ }
+ return false;
+}
+
+bool ShibokenGenerator::injectedCodeUsesArgument(const AbstractMetaFunction* func, int argumentIndex)
+{
+ CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny);
+ foreach (const CodeSnip &snip, snips) {
+ QString code = snip.code();
+ if (code.contains(QLatin1String("%ARGUMENT_NAMES")))
+ return true;
+ if (code.contains(QRegExp(QStringLiteral("%%1\\b").arg(argumentIndex + 1))))
+ return true;
+ }
+ return false;
+}
+
+bool ShibokenGenerator::hasMultipleInheritanceInAncestry(const AbstractMetaClass* metaClass)
+{
+ if (!metaClass || metaClass->baseClassNames().isEmpty())
+ return false;
+ if (metaClass->baseClassNames().size() > 1)
+ return true;
+ return hasMultipleInheritanceInAncestry(metaClass->baseClass());
+}
+
+typedef QMap<QString, AbstractMetaFunctionList> FunctionGroupMap;
+typedef FunctionGroupMap::const_iterator FunctionGroupMapIt;
+
+bool ShibokenGenerator::classNeedsGetattroFunction(const AbstractMetaClass* metaClass)
+{
+ if (!metaClass)
+ return false;
+ if (metaClass->typeEntry()->isSmartPointer())
+ return true;
+ const FunctionGroupMap &functionGroup = getFunctionGroups(metaClass);
+ for (FunctionGroupMapIt it = functionGroup.cbegin(), end = functionGroup.cend(); it != end; ++it) {
+ AbstractMetaFunctionList overloads;
+ foreach (AbstractMetaFunction* func, it.value()) {
+ if (func->isAssignmentOperator() || func->isCastOperator() || func->isModifiedRemoved()
+ || func->isPrivate() || func->ownerClass() != func->implementingClass()
+ || func->isConstructor() || func->isOperatorOverload())
+ continue;
+ overloads.append(func);
+ }
+ if (overloads.isEmpty())
+ continue;
+ if (OverloadData::hasStaticAndInstanceFunctions(overloads))
+ return true;
+ }
+ return false;
+}
+
+bool ShibokenGenerator::classNeedsSetattroFunction(const AbstractMetaClass *metaClass)
+{
+ if (!metaClass)
+ return false;
+ if (metaClass->typeEntry()->isSmartPointer())
+ return true;
+ return false;
+}
+
+AbstractMetaFunctionList ShibokenGenerator::getMethodsWithBothStaticAndNonStaticMethods(const AbstractMetaClass* metaClass)
+{
+ AbstractMetaFunctionList methods;
+ if (metaClass) {
+ const FunctionGroupMap &functionGroups = getFunctionGroups(metaClass);
+ for (FunctionGroupMapIt it = functionGroups.cbegin(), end = functionGroups.cend(); it != end; ++it) {
+ AbstractMetaFunctionList overloads;
+ foreach (AbstractMetaFunction* func, it.value()) {
+ if (func->isAssignmentOperator() || func->isCastOperator() || func->isModifiedRemoved()
+ || func->isPrivate() || func->ownerClass() != func->implementingClass()
+ || func->isConstructor() || func->isOperatorOverload())
+ continue;
+ overloads.append(func);
+ }
+ if (overloads.isEmpty())
+ continue;
+ if (OverloadData::hasStaticAndInstanceFunctions(overloads))
+ methods.append(overloads.first());
+ }
+ }
+ return methods;
+}
+
+AbstractMetaClassList ShibokenGenerator::getBaseClasses(const AbstractMetaClass* metaClass) const
+{
+ AbstractMetaClassList baseClasses;
+ if (metaClass) {
+ foreach (const QString &parent, metaClass->baseClassNames()) {
+ AbstractMetaClass *clazz = AbstractMetaClass::findClass(classes(), parent);
+ if (clazz)
+ baseClasses << clazz;
+ }
+ }
+ return baseClasses;
+}
+
+const AbstractMetaClass* ShibokenGenerator::getMultipleInheritingClass(const AbstractMetaClass* metaClass)
+{
+ if (!metaClass || metaClass->baseClassNames().isEmpty())
+ return 0;
+ if (metaClass->baseClassNames().size() > 1)
+ return metaClass;
+ return getMultipleInheritingClass(metaClass->baseClass());
+}
+
+AbstractMetaClassList ShibokenGenerator::getAllAncestors(const AbstractMetaClass* metaClass) const
+{
+ AbstractMetaClassList result;
+ if (metaClass) {
+ AbstractMetaClassList baseClasses = getBaseClasses(metaClass);
+ foreach (AbstractMetaClass* base, baseClasses) {
+ result.append(base);
+ result.append(getAllAncestors(base));
+ }
+ }
+ return result;
+}
+
+QString ShibokenGenerator::getModuleHeaderFileName(const QString& moduleName) const
+{
+ QString result = moduleName.isEmpty() ? packageName() : moduleName;
+ result.replace(QLatin1Char('.'), QLatin1Char('_'));
+ return result.toLower() + QLatin1String("_python.h");
+}
+
+QString ShibokenGenerator::extendedIsConvertibleFunctionName(const TypeEntry* targetType) const
+{
+ QString p = targetType->targetLangPackage();
+ p.replace(QLatin1Char('.'), QLatin1Char('_'));
+ return QStringLiteral("ExtendedIsConvertible_%1_%2").arg(p, targetType->name());
+}
+
+QString ShibokenGenerator::extendedToCppFunctionName(const TypeEntry* targetType) const
+{
+ QString p = targetType->targetLangPackage();
+ p.replace(QLatin1Char('.'), QLatin1Char('_'));
+ return QStringLiteral("ExtendedToCpp_%1_%2").arg(p, targetType->name());
+}
+
+bool ShibokenGenerator::isCopyable(const AbstractMetaClass *metaClass)
+
+{
+ if (metaClass->isNamespace() || isObjectType(metaClass))
+ return false;
+ else if (metaClass->typeEntry()->copyable() == ComplexTypeEntry::Unknown)
+ return metaClass->hasCloneOperator();
+ else
+ return (metaClass->typeEntry()->copyable() == ComplexTypeEntry::CopyableSet);
+
+ return false;
+}
+
+AbstractMetaType* ShibokenGenerator::buildAbstractMetaTypeFromString(QString typeSignature)
+{
+ typeSignature = typeSignature.trimmed();
+ if (typeSignature.startsWith(QLatin1String("::")))
+ typeSignature.remove(0, 2);
+
+ if (m_metaTypeFromStringCache.contains(typeSignature))
+ return m_metaTypeFromStringCache.value(typeSignature);
+
+ QString typeString = typeSignature;
+ bool isConst = typeString.startsWith(QLatin1String("const "));
+ if (isConst)
+ typeString.remove(0, sizeof("const ") / sizeof(char) - 1);
+
+ ReferenceType refType = NoReference;
+ if (typeString.endsWith(QLatin1String("&&"))) {
+ refType = RValueReference;
+ typeString.chop(2);
+ typeString = typeString.trimmed();
+ } else if (typeString.endsWith(QLatin1Char('&'))) {
+ refType = LValueReference;
+ typeString.chop(1);
+ typeString = typeString.trimmed();
+ }
+
+ int indirections = 0;
+ while (typeString.endsWith(QLatin1Char('*'))) {
+ ++indirections;
+ typeString.chop(1);
+ typeString = typeString.trimmed();
+ }
+
+ if (typeString.startsWith(QLatin1String("::")))
+ typeString.remove(0, 2);
+
+ QString adjustedTypeName = typeString;
+ QStringList instantiatedTypes;
+ int lpos = typeString.indexOf(QLatin1Char('<'));
+ if (lpos > -1) {
+ int rpos = typeString.lastIndexOf(QLatin1Char('>'));
+ if ((lpos != -1) && (rpos != -1)) {
+ QString type = typeString.mid(lpos + 1, rpos - lpos - 1);
+ int depth = 0;
+ int start = 0;
+ for (int i = 0; i < type.count(); ++i) {
+ if (type.at(i) == QLatin1Char('<')) {
+ ++depth;
+ } else if (type.at(i) == QLatin1Char('>')) {
+ --depth;
+ } else if (type.at(i) == QLatin1Char(',') && depth == 0) {
+ instantiatedTypes << type.mid(start, i - start).trimmed();
+ start = i + 1;
+ }
+ }
+ instantiatedTypes << type.mid(start).trimmed();
+ adjustedTypeName.truncate(lpos);
+ }
+ }
+
+ TypeEntry* typeEntry = TypeDatabase::instance()->findType(adjustedTypeName);
+
+ AbstractMetaType* metaType = 0;
+ if (typeEntry) {
+ metaType = new AbstractMetaType();
+ metaType->setTypeEntry(typeEntry);
+ metaType->setIndirections(indirections);
+ metaType->setReferenceType(refType);
+ metaType->setConstant(isConst);
+ metaType->setTypeUsagePattern(AbstractMetaType::ContainerPattern);
+ foreach (const QString& instantiation, instantiatedTypes) {
+ AbstractMetaType* tmplArgType = buildAbstractMetaTypeFromString(instantiation);
+ metaType->addInstantiation(tmplArgType);
+ }
+ metaType->decideUsagePattern();
+ m_metaTypeFromStringCache.insert(typeSignature, metaType);
+ }
+ return metaType;
+}
+
+AbstractMetaType* ShibokenGenerator::buildAbstractMetaTypeFromTypeEntry(const TypeEntry* typeEntry)
+{
+ QString typeName = typeEntry->qualifiedCppName();
+ if (typeName.startsWith(QLatin1String("::")))
+ typeName.remove(0, 2);
+ if (m_metaTypeFromStringCache.contains(typeName))
+ return m_metaTypeFromStringCache.value(typeName);
+ AbstractMetaType* metaType = new AbstractMetaType;
+ metaType->setTypeEntry(typeEntry);
+ metaType->setIndirections(0);
+ metaType->setReferenceType(NoReference);
+ metaType->setConstant(false);
+ metaType->decideUsagePattern();
+ m_metaTypeFromStringCache.insert(typeName, metaType);
+ return metaType;
+}
+AbstractMetaType* ShibokenGenerator::buildAbstractMetaTypeFromAbstractMetaClass(const AbstractMetaClass* metaClass)
+{
+ return ShibokenGenerator::buildAbstractMetaTypeFromTypeEntry(metaClass->typeEntry());
+}
+
+/*
+static void dumpFunction(AbstractMetaFunctionList lst)
+{
+ qDebug() << "DUMP FUNCTIONS: ";
+ foreach (AbstractMetaFunction *func, lst)
+ qDebug() << "*" << func->ownerClass()->name()
+ << func->signature()
+ << "Private: " << func->isPrivate()
+ << "Empty: " << func->isEmptyFunction()
+ << "Static:" << func->isStatic()
+ << "Signal:" << func->isSignal()
+ << "ClassImplements: " << (func->ownerClass() != func->implementingClass())
+ << "is operator:" << func->isOperatorOverload()
+ << "is global:" << func->isInGlobalScope();
+}
+*/
+
+static bool isGroupable(const AbstractMetaFunction* func)
+{
+ if (func->isSignal() || func->isDestructor() || (func->isModifiedRemoved() && !func->isAbstract()))
+ return false;
+ // weird operator overloads
+ if (func->name() == QLatin1String("operator[]") || func->name() == QLatin1String("operator->")) // FIXME: what about cast operators?
+ return false;;
+ return true;
+}
+
+QMap< QString, AbstractMetaFunctionList > ShibokenGenerator::getFunctionGroups(const AbstractMetaClass* scope)
+{
+ AbstractMetaFunctionList lst = scope ? scope->functions() : globalFunctions();
+
+ QMap<QString, AbstractMetaFunctionList> results;
+ foreach (AbstractMetaFunction* func, lst) {
+ if (isGroupable(func))
+ results[func->name()].append(func);
+ }
+ return results;
+}
+
+AbstractMetaFunctionList ShibokenGenerator::getInheritedOverloads(const AbstractMetaFunction *func, QSet<QString> *seen)
+{
+ AbstractMetaFunctionList results;
+ AbstractMetaClass* basis;
+ if (func->ownerClass() && (basis = func->ownerClass()->baseClass(), basis)) {
+ for (; basis; basis = basis->baseClass()) {
+ const AbstractMetaFunction* inFunc = basis->findFunction(func->name());
+ if (inFunc && !seen->contains(inFunc->minimalSignature())) {
+ seen->insert(inFunc->minimalSignature());
+ AbstractMetaFunction* newFunc = inFunc->copy();
+ newFunc->setImplementingClass(func->implementingClass());
+ results << newFunc;
+ }
+ }
+ }
+ return results;
+}
+
+AbstractMetaFunctionList ShibokenGenerator::getFunctionAndInheritedOverloads(const AbstractMetaFunction *func, QSet<QString> *seen)
+{
+ AbstractMetaFunctionList results;
+ seen->insert(func->minimalSignature());
+ results << const_cast<AbstractMetaFunction *>(func) << getInheritedOverloads(func, seen);
+ return results;
+}
+
+AbstractMetaFunctionList ShibokenGenerator::getFunctionOverloads(const AbstractMetaClass* scope, const QString& functionName)
+{
+ AbstractMetaFunctionList lst = scope ? scope->functions() : globalFunctions();
+
+ AbstractMetaFunctionList results;
+ QSet<QString> seenSignatures;
+ foreach (AbstractMetaFunction* func, lst) {
+ if (func->name() != functionName)
+ continue;
+ if (isGroupable(func)) {
+ // PYSIDE-331: look also into base classes.
+ results << getFunctionAndInheritedOverloads(func, &seenSignatures);
+ }
+ }
+ return results;
+}
+
+QPair< int, int > ShibokenGenerator::getMinMaxArguments(const AbstractMetaFunction* metaFunction)
+{
+ AbstractMetaFunctionList overloads = getFunctionOverloads(metaFunction->ownerClass(), metaFunction->name());
+
+ int minArgs = std::numeric_limits<int>::max();
+ int maxArgs = 0;
+ foreach (const AbstractMetaFunction* func, overloads) {
+ int numArgs = 0;
+ foreach (const AbstractMetaArgument* arg, func->arguments()) {
+ if (!func->argumentRemoved(arg->argumentIndex() + 1))
+ numArgs++;
+ }
+ maxArgs = std::max(maxArgs, numArgs);
+ minArgs = std::min(minArgs, numArgs);
+ }
+ return qMakePair(minArgs, maxArgs);
+}
+
+QMap<QString, QString> ShibokenGenerator::options() const
+{
+ QMap<QString, QString> opts(Generator::options());
+ opts.insert(QLatin1String(AVOID_PROTECTED_HACK),
+ QLatin1String("Avoid the use of the '#define protected public' hack."));
+ opts.insert(QLatin1String(PARENT_CTOR_HEURISTIC),
+ QLatin1String("Enable heuristics to detect parent relationship on constructors."));
+ opts.insert(QLatin1String(RETURN_VALUE_HEURISTIC),
+ QLatin1String("Enable heuristics to detect parent relationship on return values (USE WITH CAUTION!)"));
+ opts.insert(QLatin1String(ENABLE_PYSIDE_EXTENSIONS),
+ QLatin1String("Enable PySide extensions, such as support for signal/slots, use this if you are creating a binding for a Qt-based library."));
+ opts.insert(QLatin1String(DISABLE_VERBOSE_ERROR_MESSAGES),
+ QLatin1String("Disable verbose error messages. Turn the python code hard to debug but safe few kB on the generated bindings."));
+ opts.insert(QLatin1String(USE_ISNULL_AS_NB_NONZERO),
+ QLatin1String("If a class have an isNull()const method, it will be used to compute the value of boolean casts"));
+ return opts;
+}
+
+static void getCode(QStringList& code, const CodeSnipList& codeSnips)
+{
+ foreach (const CodeSnip& snip, codeSnips)
+ code.append(snip.code());
+}
+
+static void getCode(QStringList& code, const TypeEntry* type)
+{
+ getCode(code, type->codeSnips());
+
+ CustomConversion* customConversion = type->customConversion();
+ if (!customConversion)
+ return;
+
+ if (!customConversion->nativeToTargetConversion().isEmpty())
+ code.append(customConversion->nativeToTargetConversion());
+
+ const CustomConversion::TargetToNativeConversions& toCppConversions = customConversion->targetToNativeConversions();
+ if (toCppConversions.isEmpty())
+ return;
+
+ foreach (CustomConversion::TargetToNativeConversion* toNative, toCppConversions)
+ code.append(toNative->conversion());
+}
+
+bool ShibokenGenerator::doSetup(const QMap<QString, QString>& args)
+{
+ m_useCtorHeuristic = args.contains(QLatin1String(PARENT_CTOR_HEURISTIC));
+ m_usePySideExtensions = args.contains(QLatin1String(ENABLE_PYSIDE_EXTENSIONS));
+ m_userReturnValueHeuristic = args.contains(QLatin1String(RETURN_VALUE_HEURISTIC));
+ m_verboseErrorMessagesDisabled = args.contains(QLatin1String(DISABLE_VERBOSE_ERROR_MESSAGES));
+ m_useIsNullAsNbNonZero = args.contains(QLatin1String(USE_ISNULL_AS_NB_NONZERO));
+ m_avoidProtectedHack = args.contains(QLatin1String(AVOID_PROTECTED_HACK));
+
+ TypeDatabase* td = TypeDatabase::instance();
+ QStringList snips;
+ foreach (const PrimitiveTypeEntry* type, primitiveTypes())
+ getCode(snips, type);
+ foreach (const ContainerTypeEntry* type, containerTypes())
+ getCode(snips, type);
+ foreach (const AbstractMetaClass* metaClass, classes())
+ getCode(snips, metaClass->typeEntry());
+ getCode(snips, td->findType(packageName()));
+ const FunctionGroupMap &functionGroups = getFunctionGroups();
+ for (FunctionGroupMapIt it = functionGroups.cbegin(), end = functionGroups.cend(); it != end; ++it) {
+ foreach (AbstractMetaFunction* func, it.value())
+ getCode(snips, func->injectedCodeSnips());
+ }
+
+ foreach (const QString& code, snips) {
+ collectContainerTypesFromConverterMacros(code, true);
+ collectContainerTypesFromConverterMacros(code, false);
+ }
+
+ return true;
+}
+
+void ShibokenGenerator::collectContainerTypesFromConverterMacros(const QString& code, bool toPythonMacro)
+{
+ QString convMacro = toPythonMacro ? QLatin1String("%CONVERTTOPYTHON[") : QLatin1String("%CONVERTTOCPP[");
+ int offset = toPythonMacro ? sizeof("%CONVERTTOPYTHON") : sizeof("%CONVERTTOCPP");
+ int start = 0;
+ while ((start = code.indexOf(convMacro, start)) != -1) {
+ int end = code.indexOf(QLatin1Char(']'), start);
+ start += offset;
+ if (code.at(start) != QLatin1Char('%')) {
+ QString typeString = code.mid(start, end - start);
+ AbstractMetaType* type = buildAbstractMetaTypeFromString(typeString);
+ addInstantiatedContainersAndSmartPointers(type, type->originalTypeDescription());
+ }
+ start = end;
+ }
+}
+
+bool ShibokenGenerator::useCtorHeuristic() const
+{
+ return m_useCtorHeuristic;
+}
+
+bool ShibokenGenerator::useReturnValueHeuristic() const
+{
+ return m_userReturnValueHeuristic;
+}
+
+bool ShibokenGenerator::usePySideExtensions() const
+{
+ return m_usePySideExtensions;
+}
+
+bool ShibokenGenerator::useIsNullAsNbNonZero() const
+{
+ return m_useIsNullAsNbNonZero;
+}
+
+bool ShibokenGenerator::avoidProtectedHack() const
+{
+ return m_avoidProtectedHack;
+}
+
+QString ShibokenGenerator::cppApiVariableName(const QString& moduleName) const
+{
+ QString result = moduleName.isEmpty() ? ShibokenGenerator::packageName() : moduleName;
+ result.replace(QLatin1Char('.'), QLatin1Char('_'));
+ result.prepend(QLatin1String("Sbk"));
+ result.append(QLatin1String("Types"));
+ return result;
+}
+
+QString ShibokenGenerator::convertersVariableName(const QString& moduleName) const
+{
+ QString result = cppApiVariableName(moduleName);
+ result.chop(1);
+ result.append(QLatin1String("Converters"));
+ return result;
+}
+
+static QString processInstantiationsVariableName(const AbstractMetaType* type)
+{
+ QString res = QLatin1Char('_') + _fixedCppTypeName(type->typeEntry()->qualifiedCppName()).toUpper();
+ foreach (const AbstractMetaType* instantiation, type->instantiations()) {
+ res += instantiation->isContainer()
+ ? processInstantiationsVariableName(instantiation)
+ : QLatin1Char('_') + _fixedCppTypeName(instantiation->cppSignature()).toUpper();
+ }
+ return res;
+}
+QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaClass* metaClass, bool alternativeTemplateName)
+{
+ if (alternativeTemplateName) {
+ const AbstractMetaClass* templateBaseClass = metaClass->templateBaseClass();
+ if (!templateBaseClass)
+ return QString();
+ QString base = _fixedCppTypeName(templateBaseClass->typeEntry()->qualifiedCppName()).toUpper();
+ QString instantiations;
+ foreach (const AbstractMetaType* instantiation, metaClass->templateBaseClassInstantiations())
+ instantiations += processInstantiationsVariableName(instantiation);
+ return QString::fromLatin1("SBK_%1%2_IDX").arg(base, instantiations);
+ }
+ return getTypeIndexVariableName(metaClass->typeEntry());
+}
+QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry* type)
+{
+ if (type->isCppPrimitive()) {
+ const PrimitiveTypeEntry* trueType = (const PrimitiveTypeEntry*) type;
+ if (trueType->basicReferencedTypeEntry())
+ type = trueType->basicReferencedTypeEntry();
+ }
+ return QString::fromLatin1("SBK_%1_IDX").arg(_fixedCppTypeName(type->qualifiedCppName()).toUpper());
+}
+QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaType* type)
+{
+ return QString::fromLatin1("SBK%1%2_IDX")
+ .arg(type->typeEntry()->isContainer() ? QLatin1Char('_') + moduleName().toUpper() : QString(),
+ processInstantiationsVariableName(type));
+}
+
+bool ShibokenGenerator::verboseErrorMessagesDisabled() const
+{
+ return m_verboseErrorMessagesDisabled;
+}
+
+bool ShibokenGenerator::pythonFunctionWrapperUsesListOfArguments(const OverloadData& overloadData)
+{
+ if (overloadData.referenceFunction()->isCallOperator())
+ return true;
+ if (overloadData.referenceFunction()->isOperatorOverload())
+ return false;
+ int maxArgs = overloadData.maxArgs();
+ int minArgs = overloadData.minArgs();
+ return (minArgs != maxArgs)
+ || (maxArgs > 1)
+ || overloadData.referenceFunction()->isConstructor()
+ || overloadData.hasArgumentWithDefaultValue();
+}
+
+Generator::Options ShibokenGenerator::getConverterOptions(const AbstractMetaType* metaType)
+{
+ // exclude const on Objects
+ Options flags;
+ const TypeEntry* type = metaType->typeEntry();
+ bool isCStr = isCString(metaType);
+ if (metaType->indirections() && !isCStr) {
+ flags = ExcludeConst;
+ } else if (metaType->isContainer()
+ || (type->isPrimitive() && !isCStr)
+ // const refs become just the value, but pure refs must remain pure.
+ || (type->isValue() && metaType->isConstant() && metaType->referenceType() == LValueReference)) {
+ flags = ExcludeConst | ExcludeReference;
+ }
+ return flags;
+}
+
+QString ShibokenGenerator::getDefaultValue(const AbstractMetaFunction* func, const AbstractMetaArgument* arg)
+{
+ if (!arg->defaultValueExpression().isEmpty())
+ return arg->defaultValueExpression();
+
+ //Check modifications
+ foreach(FunctionModification m, func->modifications()) {
+ foreach(ArgumentModification am, m.argument_mods) {
+ if (am.index == (arg->argumentIndex() + 1))
+ return am.replacedDefaultExpression;
+ }
+ }
+ return QString();
+}
+
+void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream& s, const AbstractMetaType* type, const QString& defaultCtor)
+{
+ if (defaultCtor.isEmpty() && isCppPrimitive(type))
+ return;
+ QString ctor = defaultCtor.isEmpty() ? minimalConstructor(type) : defaultCtor;
+ if (ctor.isEmpty()) {
+ const QString message = msgCouldNotFindMinimalConstructor(QLatin1String(__FUNCTION__), type->cppSignature());
+ qCWarning(lcShiboken()).noquote() << message;
+ s << ";\n#error " << message << '\n';
+ } else {
+ s << " = " << ctor;
+ }
+}
+
+void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream& s, const TypeEntry* type, const QString& defaultCtor)
+{
+ if (defaultCtor.isEmpty() && isCppPrimitive(type))
+ return;
+ QString ctor = defaultCtor.isEmpty() ? minimalConstructor(type) : defaultCtor;
+
+ if (ctor.isEmpty()) {
+ const QString message = msgCouldNotFindMinimalConstructor(QLatin1String(__FUNCTION__), type->qualifiedCppName());
+ qCWarning(lcShiboken()).noquote() << message;
+ s << ";\n#error " << message << endl;
+ } else {
+ s << " = " << ctor;
+ }
+}
+
+bool ShibokenGenerator::isCppIntegralPrimitive(const TypeEntry* type)
+{
+ if (!type->isCppPrimitive())
+ return false;
+ const PrimitiveTypeEntry* trueType = (const PrimitiveTypeEntry*) type;
+ if (trueType->basicReferencedTypeEntry())
+ trueType = trueType->basicReferencedTypeEntry();
+ QString typeName = trueType->qualifiedCppName();
+ return !typeName.contains(QLatin1String("double"))
+ && !typeName.contains(QLatin1String("float"))
+ && !typeName.contains(QLatin1String("wchar"));
+}
+bool ShibokenGenerator::isCppIntegralPrimitive(const AbstractMetaType* type)
+{
+ return isCppIntegralPrimitive(type->typeEntry());
+}
+
+QString ShibokenGenerator::msgCouldNotFindMinimalConstructor(const QString &where, const QString &type)
+{
+ return where + QLatin1String(": Could not find a minimal constructor for type '") + type
+ + QLatin1String("'. This will result in a compilation error.");
+}
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
new file mode 100644
index 000000000..837e7d640
--- /dev/null
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
@@ -0,0 +1,554 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SHIBOKENGENERATOR_H
+#define SHIBOKENGENERATOR_H
+
+#define CONV_RULE_OUT_VAR_SUFFIX "_out"
+#define CPP_ARG "cppArg"
+#define CPP_ARG0 CPP_ARG"0"
+#define CPP_ARG_REMOVED "removed_" CPP_ARG
+#define CPP_RETURN_VAR "cppResult"
+#define CPP_SELF_VAR "cppSelf"
+#define PYTHON_ARG "pyArg"
+#define PYTHON_ARGS PYTHON_ARG "s"
+#define PYTHON_OVERRIDE_VAR "pyOverride"
+#define PYTHON_RETURN_VAR "pyResult"
+#define PYTHON_SELF_VAR "self"
+#define THREAD_STATE_SAVER_VAR "threadStateSaver"
+#define BEGIN_ALLOW_THREADS "PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS"
+#define END_ALLOW_THREADS "PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS"
+#define PYTHON_TO_CPP_VAR "pythonToCpp"
+#define SMART_POINTER_GETTER "kSmartPointerGetter"
+
+#define CHECKTYPE_REGEX "%CHECKTYPE\\[([^\\[]*)\\]\\("
+#define ISCONVERTIBLE_REGEX "%ISCONVERTIBLE\\[([^\\[]*)\\]\\("
+#define CONVERTTOPYTHON_REGEX "%CONVERTTOPYTHON\\[([^\\[]*)\\]\\("
+#define CONVERTTOCPP_REGEX "(\\*?%?[a-zA-Z_][\\w\\.]*(?:\\[[^\\[^<^>]+\\])*)"\
+ "(?:\\s+)=(?:\\s+)%CONVERTTOCPP\\[([^\\[]*)\\]\\("
+
+#include <generator.h>
+
+#include "typesystem.h"
+
+class DocParser;
+class CodeSnip;
+class OverloadData;
+
+QT_FORWARD_DECLARE_CLASS(QTextStream)
+
+/**
+ * Abstract generator that contains common methods used in CppGenerator and HeaderGenerator.
+ */
+class ShibokenGenerator : public Generator
+{
+public:
+ ShibokenGenerator();
+ virtual ~ShibokenGenerator();
+
+ QString translateTypeForWrapperMethod(const AbstractMetaType* cType,
+ const AbstractMetaClass* context, Options opt = NoOption) const;
+
+ /**
+ * Returns a map with all functions grouped, the function name is used as key.
+ * Example of return value: { "foo" -> ["foo(int)", "foo(int, long)], "bar" -> "bar(double)"}
+ * \param scope Where to search for functions, null means all global functions.
+ */
+ QMap<QString, AbstractMetaFunctionList> getFunctionGroups(const AbstractMetaClass* scope = 0);
+
+ /**
+ * Returns all different inherited overloads of func.
+ * The function can be called multiple times without duplication.
+ * \param func the metafunction to be searched in subclasses.
+ * \param seen the function's minimal signatures already seen.
+ */
+ AbstractMetaFunctionList getInheritedOverloads(const AbstractMetaFunction *func, QSet<QString> *seen);
+
+ /**
+ * Returns all different inherited overloads of func, and includes func as well.
+ * The function can be called multiple times without duplication.
+ * \param func the metafunction to be searched in subclasses.
+ * \param seen the function's minimal signatures already seen.
+ */
+ AbstractMetaFunctionList getFunctionAndInheritedOverloads(const AbstractMetaFunction *func, QSet<QString> *seen);
+
+ /**
+ * Returns all overloads for a function named \p functionName.
+ * \param scope scope used to search for overloads.
+ * \param functionName the function name.
+ */
+ AbstractMetaFunctionList getFunctionOverloads(const AbstractMetaClass* scope, const QString& functionName);
+ /**
+ * Returns the minimun and maximun number of arguments which this function and all overloads
+ * can accept. Arguments removed by typesystem are considered as well.
+ */
+ QPair<int, int> getMinMaxArguments(const AbstractMetaFunction* metaFunction);
+ /**
+ * Write a function argument in the C++ in the text stream \p s.
+ * This function just call \code s << argumentString(); \endcode
+ * \param s text stream used to write the output.
+ * \param func the current metafunction.
+ * \param argument metaargument information to be parsed.
+ * \param options some extra options.
+ */
+ void writeArgument(QTextStream &s,
+ const AbstractMetaFunction* func,
+ const AbstractMetaArgument* argument,
+ Options options = NoOption) const;
+ /**
+ * Create a QString in the C++ format to an function argument.
+ * \param func the current metafunction.
+ * \param argument metaargument information to be parsed.
+ * \param options some extra options.
+ */
+ QString argumentString(const AbstractMetaFunction* func,
+ const AbstractMetaArgument* argument,
+ Options options = NoOption) const;
+
+ void writeArgumentNames(QTextStream &s,
+ const AbstractMetaFunction* func,
+ Options options = NoOption) const;
+
+ /**
+ * Function used to write the fucntion arguments on the class buffer.
+ * \param s the class output buffer
+ * \param func the pointer to metafunction information
+ * \param count the number of function arguments
+ * \param options some extra options used during the parser
+ */
+ void writeFunctionArguments(QTextStream &s,
+ const AbstractMetaFunction* func,
+ Options options = NoOption) const;
+ QString functionReturnType(const AbstractMetaFunction* func, Options options = NoOption) const;
+
+ /// Utility function for writeCodeSnips.
+ typedef QPair<const AbstractMetaArgument*, QString> ArgumentVarReplacementPair;
+ typedef QList<ArgumentVarReplacementPair> ArgumentVarReplacementList;
+ ArgumentVarReplacementList getArgumentReplacement(const AbstractMetaFunction* func,
+ bool usePyArgs, TypeSystem::Language language,
+ const AbstractMetaArgument* lastArg);
+
+ /// Write user's custom code snippets at class or module level.
+ void writeCodeSnips(QTextStream& s,
+ const QList<CodeSnip>& codeSnips,
+ TypeSystem::CodeSnipPosition position,
+ TypeSystem::Language language,
+ const AbstractMetaClass* context = 0);
+ /// Write user's custom code snippets at function level.
+ void writeCodeSnips(QTextStream& s,
+ const QList<CodeSnip>& codeSnips,
+ TypeSystem::CodeSnipPosition position,
+ TypeSystem::Language language,
+ const AbstractMetaFunction* func,
+ const AbstractMetaArgument* lastArg = 0);
+
+ /// Returns a string with the user's custom code snippets that comply with \p position and \p language.
+ QString getCodeSnippets(const QList<CodeSnip>& codeSnips, TypeSystem::CodeSnipPosition position, TypeSystem::Language language);
+
+ /// Replaces variables for the user's custom code at global or class level.
+ void processCodeSnip(QString& code, const AbstractMetaClass* context = 0);
+
+ /// Replaces the %CONVERTTOPYTHON type system variable.
+ inline void replaceConvertToPythonTypeSystemVariable(QString& code)
+ {
+ replaceConverterTypeSystemVariable(TypeSystemToPythonFunction, code);
+ }
+ /// Replaces the %CONVERTTOCPP type system variable.
+ inline void replaceConvertToCppTypeSystemVariable(QString& code)
+ {
+ replaceConverterTypeSystemVariable(TypeSystemToCppFunction, code);
+ }
+ /// Replaces the %ISCONVERTIBLE type system variable.
+ inline void replaceIsConvertibleToCppTypeSystemVariable(QString& code)
+ {
+ replaceConverterTypeSystemVariable(TypeSystemIsConvertibleFunction, code);
+ }
+ /// Replaces the %CHECKTYPE type system variable.
+ inline void replaceTypeCheckTypeSystemVariable(QString& code)
+ {
+ replaceConverterTypeSystemVariable(TypeSystemCheckFunction, code);
+ }
+
+ /**
+ * Verifies if any of the function's code injections of the "target"
+ * type needs the type system variable "%CPPSELF".
+ * \param func the function to check
+ * \return true if the function's target code snippets use "%CPPSELF"
+ */
+ bool injectedCodeUsesCppSelf(const AbstractMetaFunction* func);
+
+ /**
+ * Verifies if any of the function's code injections of the "native"
+ * type needs the type system variable "%PYSELF".
+ * \param func the function to check
+ * \return true if the function's native code snippets use "%PYSELF"
+ */
+ bool injectedCodeUsesPySelf(const AbstractMetaFunction* func);
+
+ /**
+ * Verifies if any of the function's code injections makes a call
+ * to the C++ method. This is used by the generator to avoid writing calls
+ * to C++ when the user custom code already does this.
+ * \param func the function to check
+ * \return true if the function's code snippets call the wrapped C++ function
+ */
+ bool injectedCodeCallsCppFunction(const AbstractMetaFunction* func);
+
+ /**
+ * Verifies if any of the function's code injections of the "native" class makes a
+ * call to the C++ method. This is used by the generator to avoid writing calls to
+ * Python overrides of C++ virtual methods when the user custom code already does this.
+ * \param func the function to check
+ * \return true if the function's code snippets call the Python override for a C++ virtual method
+ */
+ bool injectedCodeCallsPythonOverride(const AbstractMetaFunction* func);
+
+ /**
+ * Verifies if any of the function's code injections attributes values to
+ * the return variable (%0 or %PYARG_0).
+ * \param func the function to check
+ * \param language the kind of code snip
+ * \return true if the function's code attributes values to "%0" or "%PYARG_0"
+ */
+ bool injectedCodeHasReturnValueAttribution(const AbstractMetaFunction* func, TypeSystem::Language language = TypeSystem::TargetLangCode);
+
+ /**
+ * Verifies if any of the function's code injections uses the type system variable
+ * for function arguments of a given index.
+ */
+ bool injectedCodeUsesArgument(const AbstractMetaFunction* func, int argumentIndex);
+
+ /**
+ * Function which parse the metafunction information
+ * \param func the function witch will be parserd
+ * \param option some extra options
+ * \param arg_count the number of function arguments
+ */
+ QString functionSignature(const AbstractMetaFunction* func,
+ QString prepend = QString(),
+ QString append = QString(),
+ Options options = NoOption,
+ int arg_count = -1) const;
+
+ /// Returns true if there are cases of multiple inheritance in any of its ancestors.
+ bool hasMultipleInheritanceInAncestry(const AbstractMetaClass* metaClass);
+
+ /// Returns true if the class needs to have a getattro function.
+ bool classNeedsGetattroFunction(const AbstractMetaClass* metaClass);
+
+ /// Returns true if the class needs to have a setattro function.
+ bool classNeedsSetattroFunction(const AbstractMetaClass *metaClass);
+
+ /// Returns a list of methods of the given class where each one is part of a different overload with both static and non-static method.
+ AbstractMetaFunctionList getMethodsWithBothStaticAndNonStaticMethods(const AbstractMetaClass* metaClass);
+
+ /// Returns a list of parent classes for a given class.
+ AbstractMetaClassList getBaseClasses(const AbstractMetaClass* metaClass) const;
+
+ /// Returns a list of all ancestor classes for the given class.
+ AbstractMetaClassList getAllAncestors(const AbstractMetaClass* metaClass) const;
+
+ const AbstractMetaClass* getMultipleInheritingClass(const AbstractMetaClass* metaClass);
+
+ void writeToPythonConversion(QTextStream& s, const AbstractMetaType* type,
+ const AbstractMetaClass* context, const QString& argumentName);
+ void writeToCppConversion(QTextStream& s, const AbstractMetaType* type, const AbstractMetaClass* context, const QString& inArgName, const QString& outArgName);
+ void writeToCppConversion(QTextStream& s, const AbstractMetaClass* metaClass, const QString& inArgName, const QString& outArgName);
+
+ /// Returns true if the argument is a pointer that rejects NULL values.
+ bool shouldRejectNullPointerArgument(const AbstractMetaFunction* func, int argIndex);
+
+ /// Verifies if the class should have a C++ wrapper generated for it, instead of only a Python wrapper.
+ bool shouldGenerateCppWrapper(const AbstractMetaClass* metaClass) const;
+
+ /// Adds enums eligible for generation from classes/namespaces marked not to be generated.
+ static void lookForEnumsInClassesNotToBeGenerated(AbstractMetaEnumList& enumList, const AbstractMetaClass* metaClass);
+ /// Returns the enclosing class for an enum, or NULL if it should be global.
+ const AbstractMetaClass* getProperEnclosingClassForEnum(const AbstractMetaEnum* metaEnum);
+
+ QString wrapperName(const AbstractMetaClass* metaClass) const;
+ QString wrapperName(const AbstractMetaType *metaType) const;
+
+ static QString fullPythonFunctionName(const AbstractMetaFunction* func);
+ static QString protectedEnumSurrogateName(const AbstractMetaEnum* metaEnum);
+ static QString protectedFieldGetterName(const AbstractMetaField* field);
+ static QString protectedFieldSetterName(const AbstractMetaField* field);
+
+ static QString pythonPrimitiveTypeName(const QString& cppTypeName);
+ static QString pythonPrimitiveTypeName(const PrimitiveTypeEntry* type);
+
+ static QString pythonOperatorFunctionName(QString cppOpFuncName);
+ static QString pythonOperatorFunctionName(const AbstractMetaFunction* func);
+ static QString pythonRichCompareOperatorId(QString cppOpFuncName);
+ static QString pythonRichCompareOperatorId(const AbstractMetaFunction* func);
+
+ static QString cpythonOperatorFunctionName(const AbstractMetaFunction* func);
+
+ static QString fixedCppTypeName(const CustomConversion::TargetToNativeConversion* toNative);
+ static QString fixedCppTypeName(const AbstractMetaType* type);
+ static QString fixedCppTypeName(const TypeEntry* type, QString typeName = QString());
+
+ static bool isNumber(QString cpythonApiName);
+ static bool isNumber(const TypeEntry* type);
+ static bool isNumber(const AbstractMetaType* type);
+ static bool isPyInt(const TypeEntry* type);
+ static bool isPyInt(const AbstractMetaType* type);
+ static bool isPairContainer(const AbstractMetaType* type);
+
+ /**
+ * Returns true if the type passed has a Python wrapper for it.
+ * Although namespace has a Python wrapper, it's not considered a type.
+ */
+ static bool isWrapperType(const TypeEntry* type);
+ static bool isWrapperType(const ComplexTypeEntry* type);
+ static bool isWrapperType(const AbstractMetaType* metaType);
+
+ /**
+ * Checks if the type is an Object/QObject or pointer to Value Type.
+ * In other words, tells if the type is "T*" and T has a Python wrapper.
+ */
+ static bool isPointerToWrapperType(const AbstractMetaType* type);
+
+ /**
+ * Returns true if \p type is an Object Type used as a value.
+ */
+ static bool isObjectTypeUsedAsValueType(const AbstractMetaType* type);
+
+ static bool isValueTypeWithCopyConstructorOnly(const AbstractMetaClass* metaClass);
+ bool isValueTypeWithCopyConstructorOnly(const TypeEntry* type) const;
+ bool isValueTypeWithCopyConstructorOnly(const AbstractMetaType* type) const;
+
+ /// Returns true if the type is a primitive but not a C++ primitive.
+ static bool isUserPrimitive(const TypeEntry* type);
+ static bool isUserPrimitive(const AbstractMetaType* type);
+
+ /// Returns true if the type is a C++ primitive, a void*, a const char*, or a std::string.
+ static bool isCppPrimitive(const TypeEntry* type);
+ static bool isCppPrimitive(const AbstractMetaType* type);
+
+ /// Returns true if the type is a C++ integral primitive, i.e. bool, char, int, long, and their unsigned counterparts.
+ static bool isCppIntegralPrimitive(const TypeEntry* type);
+ static bool isCppIntegralPrimitive(const AbstractMetaType* type);
+
+ /// Checks if an argument type should be dereferenced by the Python method wrapper before calling the C++ method.
+ static bool shouldDereferenceArgumentPointer(const AbstractMetaArgument* arg);
+ /// Checks if a meta type should be dereferenced by the Python method wrapper passing it to C++.
+ static bool shouldDereferenceAbstractMetaTypePointer(const AbstractMetaType* metaType);
+
+ static bool visibilityModifiedToPrivate(const AbstractMetaFunction* func);
+
+ QString converterObject(const AbstractMetaType* type);
+ QString converterObject(const TypeEntry* type);
+
+ QString cpythonBaseName(const AbstractMetaClass* metaClass);
+ QString cpythonBaseName(const TypeEntry* type);
+ QString cpythonBaseName(const AbstractMetaType* type);
+ QString cpythonTypeName(const AbstractMetaClass* metaClass);
+ QString cpythonTypeName(const TypeEntry* type);
+ QString cpythonTypeNameExt(const TypeEntry* type);
+ QString cpythonTypeNameExt(const AbstractMetaType* type);
+ QString cpythonCheckFunction(const TypeEntry* type, bool genericNumberType = false);
+ QString cpythonCheckFunction(const AbstractMetaType* metaType, bool genericNumberType = false);
+ /**
+ * Receives the argument \p type and tries to find the appropriate AbstractMetaType for it
+ * or a custom type check.
+ * \param type A string representing the type to be discovered.
+ * \param metaType A pointer to an AbstractMetaType pointer, to where write a new meta type object
+ * if one is produced from the \p type string. This object must be deallocated by
+ * the caller. It will set the target variable to NULL, is \p type is a Python type.
+ * \return A custom check if \p type is a custom type, or an empty string if \p metaType
+ * receives an existing type object.
+ */
+ QString guessCPythonCheckFunction(const QString& type, AbstractMetaType** metaType);
+ QString cpythonIsConvertibleFunction(const TypeEntry* type, bool genericNumberType = false, bool checkExact = false);
+ QString cpythonIsConvertibleFunction(const AbstractMetaType* metaType, bool genericNumberType = false);
+ QString cpythonIsConvertibleFunction(const AbstractMetaArgument* metaArg, bool genericNumberType = false);
+ QString guessCPythonIsConvertible(const QString& type);
+
+ QString cpythonToCppConversionFunction(const AbstractMetaClass* metaClass);
+ QString cpythonToCppConversionFunction(const AbstractMetaType* type, const AbstractMetaClass* context = 0);
+ QString cpythonToPythonConversionFunction(const AbstractMetaType* type, const AbstractMetaClass* context = 0);
+ QString cpythonToPythonConversionFunction(const AbstractMetaClass* metaClass);
+ QString cpythonToPythonConversionFunction(const TypeEntry* type);
+
+ QString cpythonFunctionName(const AbstractMetaFunction* func);
+ QString cpythonMethodDefinitionName(const AbstractMetaFunction* func);
+ QString cpythonGettersSettersDefinitionName(const AbstractMetaClass* metaClass);
+ QString cpythonGetattroFunctionName(const AbstractMetaClass* metaClass);
+ QString cpythonSetattroFunctionName(const AbstractMetaClass* metaClass);
+ QString cpythonGetterFunctionName(const AbstractMetaField* metaField);
+ QString cpythonSetterFunctionName(const AbstractMetaField* metaField);
+ QString cpythonWrapperCPtr(const AbstractMetaClass* metaClass, QString argName = QLatin1String(PYTHON_SELF_VAR));
+ QString cpythonWrapperCPtr(const AbstractMetaType *metaType, QString argName);
+ QString cpythonWrapperCPtr(const TypeEntry* type, QString argName);
+
+ /// Guesses the scope to where belongs an argument's default value.
+ QString guessScopeForDefaultValue(const AbstractMetaFunction* func, const AbstractMetaArgument* arg);
+
+ QString cpythonEnumName(const EnumTypeEntry* enumEntry);
+ QString cpythonEnumName(const AbstractMetaEnum* metaEnum);
+
+ QString cpythonFlagsName(const FlagsTypeEntry* flagsEntry);
+ QString cpythonFlagsName(const AbstractMetaEnum* metaEnum);
+ /// Returns the special cast function name, the function used to proper cast class with multiple inheritance.
+ QString cpythonSpecialCastFunctionName(const AbstractMetaClass* metaClass);
+
+ QString getFunctionReturnType(const AbstractMetaFunction* func, Options options = NoOption) const;
+ QString getFormatUnitString(const AbstractMetaFunction* func, bool incRef = false) const;
+
+ /// Returns the file name for the module global header. If no module name is provided the current will be used.
+ QString getModuleHeaderFileName(const QString& moduleName = QString()) const;
+
+ QString extendedIsConvertibleFunctionName(const TypeEntry* targetType) const;
+ QString extendedToCppFunctionName(const TypeEntry* targetType) const;
+
+ QMap< QString, QString > options() const;
+
+ /// Returns true if the user enabled the so called "parent constructor heuristic".
+ bool useCtorHeuristic() const;
+ /// Returns true if the user enabled the so called "return value heuristic".
+ bool useReturnValueHeuristic() const;
+ /// Returns true if the user enabled PySide extensions.
+ bool usePySideExtensions() const;
+ /// Returns true if the generator should use the result of isNull()const to compute boolean casts.
+ bool useIsNullAsNbNonZero() const;
+ /// Returns true if the generated code should use the "#define protected public" hack.
+ bool avoidProtectedHack() const;
+ QString cppApiVariableName(const QString& moduleName = QString()) const;
+ QString convertersVariableName(const QString& moduleName = QString()) const;
+ /**
+ * Returns the type index variable name for a given class. If \p alternativeTemplateName is true
+ * and the class is a typedef for a template class instantiation, it will return an alternative name
+ * made of the template class and the instantiation values, or an empty string if the class isn't
+ * derived from a template class at all.
+ */
+ QString getTypeIndexVariableName(const AbstractMetaClass* metaClass, bool alternativeTemplateName = false);
+ QString getTypeIndexVariableName(const TypeEntry* type);
+ QString getTypeIndexVariableName(const AbstractMetaType* type);
+
+ /// Returns true if the user don't want verbose error messages on the generated bindings.
+ bool verboseErrorMessagesDisabled() const;
+
+ /**
+ * Builds an AbstractMetaType object from a QString.
+ * Returns NULL if no type could be built from the string.
+ * \param typeSignature The string describing the type to be built.
+ * \return A new AbstractMetaType object that must be deleted by the caller, or a NULL pointer in case of failure.
+ */
+ AbstractMetaType* buildAbstractMetaTypeFromString(QString typeSignature);
+
+ /// Creates an AbstractMetaType object from a TypeEntry.
+ AbstractMetaType* buildAbstractMetaTypeFromTypeEntry(const TypeEntry* typeEntry);
+ /// Creates an AbstractMetaType object from an AbstractMetaClass.
+ AbstractMetaType* buildAbstractMetaTypeFromAbstractMetaClass(const AbstractMetaClass* metaClass);
+
+ void writeMinimalConstructorExpression(QTextStream& s, const AbstractMetaType* type, const QString& defaultCtor = QString());
+ void writeMinimalConstructorExpression(QTextStream& s, const TypeEntry* type, const QString& defaultCtor = QString());
+
+ /**
+ * Helper function to return the flags to be used by a meta type when
+ * it needs to write some converter code.
+ */
+ static Options getConverterOptions(const AbstractMetaType* metaType);
+
+ /**
+ * Helper function to find for argument default value
+ */
+ static QString getDefaultValue(const AbstractMetaFunction* func, const AbstractMetaArgument* arg);
+protected:
+ bool doSetup(const QMap<QString, QString>& args);
+ void collectContainerTypesFromConverterMacros(const QString& code, bool toPythonMacro);
+ // verify whether the class is copyable
+ bool isCopyable(const AbstractMetaClass* metaClass);
+
+ bool m_native_jump_table;
+ static QHash<QString, QString> m_pythonPrimitiveTypeName;
+ static QHash<QString, QString> m_pythonOperators;
+ static QHash<QString, QString> m_formatUnits;
+ static QHash<QString, QString> m_tpFuncs;
+ static QStringList m_knownPythonTypes;
+
+ void clearTpFuncs();
+
+ const char* name() const { return "Shiboken"; }
+
+ /// Initializes correspondences between primitive and Python types.
+ static void initPrimitiveTypesCorrespondences();
+ /// Initializes a list of Python known type names.
+ static void initKnownPythonTypes();
+
+ void writeFunctionCall(QTextStream& s,
+ const AbstractMetaFunction* metaFunc,
+ Options options = NoOption) const;
+
+ void writeUnusedVariableCast(QTextStream& s, const QString& variableName);
+
+ AbstractMetaFunctionList filterFunctions(const AbstractMetaClass* metaClass);
+
+ // All data about extended converters: the type entries of the target type, and a
+ // list of AbstractMetaClasses accepted as argument for the conversion.
+ typedef QHash<const TypeEntry*, QList<const AbstractMetaClass*> > ExtendedConverterData;
+ /// Returns all extended conversions for the current module.
+ ExtendedConverterData getExtendedConverters() const;
+
+ /// Returns a list of converters for the non wrapper types of the current module.
+ QList<const CustomConversion*> getPrimitiveCustomConversions();
+
+ /// Returns true if the Python wrapper for the received OverloadData must accept a list of arguments.
+ static bool pythonFunctionWrapperUsesListOfArguments(const OverloadData& overloadData);
+
+ Indentor INDENT;
+
+ enum TypeSystemConverterVariable {
+ TypeSystemCheckFunction = 0,
+ TypeSystemIsConvertibleFunction,
+ TypeSystemToCppFunction,
+ TypeSystemToPythonFunction,
+ TypeSystemConverterVariables
+ };
+ void replaceConverterTypeSystemVariable(TypeSystemConverterVariable converterVariable, QString& code);
+
+ static QString msgCouldNotFindMinimalConstructor(const QString &where, const QString &type);
+
+private:
+ bool m_useCtorHeuristic;
+ bool m_userReturnValueHeuristic;
+ bool m_usePySideExtensions;
+ bool m_verboseErrorMessagesDisabled;
+ bool m_useIsNullAsNbNonZero;
+ bool m_avoidProtectedHack;
+
+ typedef QHash<QString, AbstractMetaType*> AbstractMetaTypeCache;
+ AbstractMetaTypeCache m_metaTypeFromStringCache;
+
+ /// Type system converter variable replacement names and regular expressions.
+ QString m_typeSystemConvName[TypeSystemConverterVariables];
+ QRegExp m_typeSystemConvRegEx[TypeSystemConverterVariables];
+};
+
+#endif // SHIBOKENGENERATOR_H
diff --git a/sources/shiboken2/generator/shibokenconfig.h.in b/sources/shiboken2/generator/shibokenconfig.h.in
new file mode 100644
index 000000000..2c86a4a3c
--- /dev/null
+++ b/sources/shiboken2/generator/shibokenconfig.h.in
@@ -0,0 +1,6 @@
+#ifndef SHIBOKENCONFIG_H
+#define SHIBOKENCONFIG_H
+
+#define SHIBOKEN_VERSION "@shiboken2_VERSION@"
+
+#endif
diff --git a/sources/shiboken2/generatorrunnerconfig.h.in b/sources/shiboken2/generatorrunnerconfig.h.in
new file mode 100644
index 000000000..d291fcc53
--- /dev/null
+++ b/sources/shiboken2/generatorrunnerconfig.h.in
@@ -0,0 +1,13 @@
+#ifndef GENERATORRUNNERCONFIG_H
+#define GENERATORRUNNERCONFIG_H
+
+// generatorrunner version
+#define GENERATORRUNNER_VERSION "@generator_VERSION@"
+
+// generatorrunner plugin dir
+#define GENERATORRUNNER_PLUGIN_DIR "@generator_plugin_DIR@"
+
+// module extension
+#define MODULE_EXTENSION "@CMAKE_SHARED_LIBRARY_SUFFIX@"
+
+#endif
diff --git a/sources/shiboken2/generatorrunnermacros.h b/sources/shiboken2/generatorrunnermacros.h
new file mode 100644
index 000000000..d54ed3b9a
--- /dev/null
+++ b/sources/shiboken2/generatorrunnermacros.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GENERATORRUNNERMACROS_H
+#define GENERATORRUNNERMACROS_H
+
+// GENRUNNER_API is used for the public API symbols.
+#if defined _WIN32
+ #define GENRUNNER_EXPORT __declspec(dllexport)
+ #if GENRUNNER_EXPORTS
+ #define GENRUNNER_API GENRUNNER_EXPORT
+ #endif
+#elif __GNUC__ >= 4
+ #define GENRUNNER_EXPORT __attribute__ ((visibility("default")))
+ #define GENRUNNER_API GENRUNNER_EXPORT
+#elif __GNUC__ < 4
+ #define GENRUNNER_EXPORT
+#endif
+
+#ifndef GENRUNNER_API
+ #define GENRUNNER_API
+#endif
+#endif
diff --git a/sources/shiboken2/generators/shiboken/shiboken.cpp b/sources/shiboken2/generators/shiboken/shiboken.cpp
new file mode 100644
index 000000000..829862f19
--- /dev/null
+++ b/sources/shiboken2/generators/shiboken/shiboken.cpp
@@ -0,0 +1,32 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cppgenerator.h"
+#include "headergenerator.h"
+
+EXPORT_GENERATOR_PLUGIN(new CppGenerator << new HeaderGenerator)
diff --git a/sources/shiboken2/header.COMM b/sources/shiboken2/header.COMM
new file mode 100644
index 000000000..1c8cb00e7
--- /dev/null
+++ b/sources/shiboken2/header.COMM
@@ -0,0 +1,20 @@
+/******************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the <Fill> module.
+**
+** $QT_BEGIN_LICENSE:COMM$
+**
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** $QT_END_LICENSE$
+**
+******************************************************************************/
diff --git a/sources/shiboken2/header.LGPL-ONLY b/sources/shiboken2/header.LGPL-ONLY
new file mode 100644
index 000000000..9a676032e
--- /dev/null
+++ b/sources/shiboken2/header.LGPL-ONLY
@@ -0,0 +1,22 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you have questions regarding the use of this file, please contact
+** us via http://www.qt.io/contact-us/.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
diff --git a/sources/shiboken2/header.LGPL21 b/sources/shiboken2/header.LGPL21
new file mode 100644
index 000000000..533390b07
--- /dev/null
+++ b/sources/shiboken2/header.LGPL21
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/sources/shiboken2/header.LGPL3 b/sources/shiboken2/header.LGPL3
new file mode 100644
index 000000000..d9a65c2e4
--- /dev/null
+++ b/sources/shiboken2/header.LGPL3
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/sources/shiboken2/header.LGPL3-COMM b/sources/shiboken2/header.LGPL3-COMM
new file mode 100644
index 000000000..b5dc15d38
--- /dev/null
+++ b/sources/shiboken2/header.LGPL3-COMM
@@ -0,0 +1,28 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3-COMM$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/sources/shiboken2/icecc.cmake b/sources/shiboken2/icecc.cmake
new file mode 100644
index 000000000..b2bf071aa
--- /dev/null
+++ b/sources/shiboken2/icecc.cmake
@@ -0,0 +1,11 @@
+include (CMakeForceCompiler)
+option(ENABLE_ICECC "Enable icecc checking, for distributed compilation")
+if (ENABLE_ICECC)
+ find_program(ICECC icecc)
+ if (ICECC)
+ message(STATUS "icecc found! Distributed compilation for all!! huhuhu.")
+ cmake_force_cxx_compiler(${ICECC} icecc)
+ else(ICECC)
+ message(FATAL_ERROR "icecc NOT found! re-run cmake without -DENABLE_ICECC")
+ endif(ICECC)
+endif(ENABLE_ICECC)
diff --git a/sources/shiboken2/libshiboken/CMakeLists.txt b/sources/shiboken2/libshiboken/CMakeLists.txt
new file mode 100644
index 000000000..9ec49d5bd
--- /dev/null
+++ b/sources/shiboken2/libshiboken/CMakeLists.txt
@@ -0,0 +1,77 @@
+project(libshiboken)
+
+option(ENABLE_VERSION_SUFFIX "Used to use current version in suffix to generated files. This is used to allow multiples versions installed simultaneous." FALSE)
+if(ENABLE_VERSION_SUFFIX)
+ set(shiboken2_SUFFIX "-${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}")
+else()
+ set(shiboken2_SUFFIX "")
+endif()
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sbkversion.h.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/sbkversion.h" @ONLY)
+
+#Find installed sparsehash
+find_path(SPARSEHASH_INCLUDE_PATH sparseconfig.h PATH_SUFFIXES "/google/sparsehash")
+if(SPARSEHASH_INCLUDE_PATH)
+ message(STATUS "Using system hash found in: ${SPARSEHASH_INCLUDE_PATH}")
+else()
+ set(SPARSEHASH_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/ext/sparsehash)
+endif()
+
+set(libshiboken_MAJOR_VERSION ${shiboken_MAJOR_VERSION})
+set(libshiboken_MINOR_VERSION ${shiboken_MINOR_VERSION})
+set(libshiboken_MICRO_VERSION ${shiboken_MICRO_VERSION})
+set(libshiboken_VERSION "${libshiboken_MAJOR_VERSION}.${libshiboken_MINOR_VERSION}.${libshiboken_MICRO_VERSION}")
+set(libshiboken_SOVERSION "${libshiboken_MAJOR_VERSION}.${libshiboken_MINOR_VERSION}")
+
+set(libshiboken_SRC
+basewrapper.cpp
+debugfreehook.cpp
+gilstate.cpp
+helper.cpp
+sbkconverter.cpp
+sbkenum.cpp
+sbkmodule.cpp
+sbkstring.cpp
+bindingmanager.cpp
+threadstatesaver.cpp
+typeresolver.cpp
+shibokenbuffer.cpp
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${SBK_PYTHON_INCLUDE_DIR}
+ ${SPARSEHASH_INCLUDE_PATH})
+add_library(libshiboken SHARED ${libshiboken_SRC})
+target_link_libraries(libshiboken ${SBK_PYTHON_LIBRARIES})
+set_target_properties(libshiboken PROPERTIES OUTPUT_NAME "shiboken2${shiboken2_SUFFIX}${PYTHON_EXTENSION_SUFFIX}"
+ VERSION ${libshiboken_VERSION}
+ SOVERSION ${libshiboken_SOVERSION}
+ DEFINE_SYMBOL LIBSHIBOKEN_EXPORTS)
+
+install(FILES
+ autodecref.h
+ basewrapper.h
+ bindingmanager.h
+ conversions.h
+ gilstate.h
+ helper.h
+ sbkconverter.h
+ sbkenum.h
+ sbkmodule.h
+ python25compat.h
+ sbkdbg.h
+ sbkstring.h
+ shiboken.h
+ shibokenmacros.h
+ threadstatesaver.h
+ typeresolver.h
+ shibokenbuffer.h
+ sbkpython.h
+ "${CMAKE_CURRENT_BINARY_DIR}/sbkversion.h"
+ DESTINATION include/shiboken2${shiboken2_SUFFIX})
+install(TARGETS libshiboken EXPORT shiboken2
+ LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
+ ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
+ RUNTIME DESTINATION bin)
diff --git a/sources/shiboken2/libshiboken/autodecref.h b/sources/shiboken2/libshiboken/autodecref.h
new file mode 100644
index 000000000..1fefcc259
--- /dev/null
+++ b/sources/shiboken2/libshiboken/autodecref.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 AUTODECREF_H
+#define AUTODECREF_H
+
+#include "sbkpython.h"
+#include "basewrapper.h"
+
+struct SbkObject;
+namespace Shiboken
+{
+
+/**
+ * AutoDecRef holds a PyObject pointer and decrement its reference counter when destroyed.
+ */
+struct LIBSHIBOKEN_API AutoDecRef
+{
+public:
+ /**
+ * AutoDecRef constructor.
+ * \param pyobj A borrowed reference to a Python object
+ */
+ explicit AutoDecRef(PyObject* pyObj) : m_pyObj(pyObj) {}
+ /**
+ * AutoDecRef constructor.
+ * \param pyobj A borrowed reference to a Python object
+ */
+ explicit AutoDecRef(SbkObject* pyObj) : m_pyObj(reinterpret_cast<PyObject*>(pyObj)) {}
+
+ /// Decref the borrowed python reference
+ ~AutoDecRef()
+ {
+ Py_XDECREF(m_pyObj);
+ }
+
+ inline bool isNull() const { return m_pyObj == 0; }
+ /// Returns the pointer of the Python object being held.
+ inline PyObject* object() { return m_pyObj; }
+ inline operator PyObject*() { return m_pyObj; }
+ inline operator PyTupleObject*() { return reinterpret_cast<PyTupleObject*>(m_pyObj); }
+ inline operator bool() const { return m_pyObj; }
+ inline PyObject* operator->() { return m_pyObj; }
+
+ template<typename T>
+ T cast()
+ {
+ return reinterpret_cast<T>(m_pyObj);
+ }
+
+ /**
+ * Decref the current borrowed python reference and take the reference
+ * borrowed by \p other, so other.isNull() will return true.
+ */
+ void operator=(AutoDecRef& other)
+ {
+ Py_XDECREF(m_pyObj);
+ m_pyObj = other.m_pyObj;
+ other.m_pyObj = 0;
+ }
+
+ /**
+ * Decref the current borrowed python reference and borrow \p other.
+ */
+ void operator=(PyObject* other)
+ {
+ Py_XDECREF(m_pyObj);
+ m_pyObj = other;
+ }
+private:
+ PyObject* m_pyObj;
+ AutoDecRef(const AutoDecRef&);
+ AutoDecRef& operator=(const AutoDecRef&);
+};
+
+} // namespace Shiboken
+
+#endif // AUTODECREF_H
+
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp
new file mode 100644
index 000000000..b3f99a8a5
--- /dev/null
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
@@ -0,0 +1,1518 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "basewrapper.h"
+#include "basewrapper_p.h"
+#include "sbkconverter.h"
+#include "sbkenum.h"
+#include "autodecref.h"
+#include "typeresolver.h"
+#include "gilstate.h"
+#include <string>
+#include <cstring>
+#include <cstddef>
+#include <set>
+#include <sstream>
+#include <algorithm>
+#include "threadstatesaver.h"
+
+namespace {
+ void _destroyParentInfo(SbkObject* obj, bool keepReference);
+}
+
+extern "C"
+{
+
+static void SbkObjectTypeDealloc(PyObject* pyObj);
+static PyObject* SbkObjectTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwds);
+
+PyTypeObject SbkObjectType_Type = {
+ PyVarObject_HEAD_INIT(0, 0)
+ /*tp_name*/ "Shiboken.ObjectType",
+ /*tp_basicsize*/ sizeof(SbkObjectType),
+ /*tp_itemsize*/ 0,
+ /*tp_dealloc*/ SbkObjectTypeDealloc,
+ /*tp_print*/ 0,
+ /*tp_getattr*/ 0,
+ /*tp_setattr*/ 0,
+ /*tp_compare*/ 0,
+ /*tp_repr*/ 0,
+ /*tp_as_number*/ 0,
+ /*tp_as_sequence*/ 0,
+ /*tp_as_mapping*/ 0,
+ /*tp_hash*/ 0,
+ /*tp_call*/ 0,
+ /*tp_str*/ 0,
+ /*tp_getattro*/ 0,
+ /*tp_setattro*/ PyObject_GenericSetAttr,
+ /*tp_as_buffer*/ 0,
+ /*tp_flags*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
+ /*tp_doc*/ 0,
+ /*tp_traverse*/ 0,
+ /*tp_clear*/ 0,
+ /*tp_richcompare*/ 0,
+ /*tp_weaklistoffset*/ 0,
+ /*tp_iter*/ 0,
+ /*tp_iternext*/ 0,
+ /*tp_methods*/ 0,
+ /*tp_members*/ 0,
+ /*tp_getset*/ 0,
+ /*tp_base*/ &PyType_Type,
+ /*tp_dict*/ 0,
+ /*tp_descr_get*/ 0,
+ /*tp_descr_set*/ 0,
+ /*tp_dictoffset*/ 0,
+ /*tp_init*/ 0,
+ /*tp_alloc*/ PyType_GenericAlloc,
+ /*tp_new*/ SbkObjectTypeTpNew,
+ /*tp_free*/ PyObject_GC_Del,
+ /*tp_is_gc*/ 0,
+ /*tp_bases*/ 0,
+ /*tp_mro*/ 0,
+ /*tp_cache*/ 0,
+ /*tp_subclasses*/ 0,
+ /*tp_weaklist*/ 0,
+ /*tp_del*/ 0,
+ /*tp_version_tag*/ 0
+};
+
+static PyObject *SbkObjectGetDict(PyObject* pObj, void *)
+{
+ SbkObject *obj = reinterpret_cast<SbkObject *>(pObj);
+ if (!obj->ob_dict)
+ obj->ob_dict = PyDict_New();
+ if (!obj->ob_dict)
+ return 0;
+ Py_INCREF(obj->ob_dict);
+ return obj->ob_dict;
+}
+
+static PyGetSetDef SbkObjectGetSetList[] = {
+ {const_cast<char*>("__dict__"), SbkObjectGetDict, 0, 0, 0},
+ {0, 0, 0, 0, 0} // Sentinel
+};
+
+static int SbkObject_traverse(PyObject* self, visitproc visit, void* arg)
+{
+ SbkObject* sbkSelf = reinterpret_cast<SbkObject*>(self);
+
+ //Visit children
+ Shiboken::ParentInfo* pInfo = sbkSelf->d->parentInfo;
+ if (pInfo) {
+ std::set<SbkObject*>::const_iterator it = pInfo->children.begin();
+ for(; it != pInfo->children.end(); ++it)
+ Py_VISIT(*it);
+ }
+
+ //Visit refs
+ Shiboken::RefCountMap* rInfo = sbkSelf->d->referredObjects;
+ if (rInfo) {
+ Shiboken::RefCountMap::const_iterator it = rInfo->begin();
+ for (; it != rInfo->end(); ++it) {
+ std::list<PyObject*>::const_iterator ref = it->second.begin();
+ for(; ref != it->second.end(); ++ref)
+ Py_VISIT(*ref);
+ }
+ }
+
+ if (sbkSelf->ob_dict)
+ Py_VISIT(sbkSelf->ob_dict);
+ return 0;
+}
+
+static int SbkObject_clear(PyObject* self)
+{
+ SbkObject* sbkSelf = reinterpret_cast<SbkObject*>(self);
+
+ Shiboken::Object::removeParent(sbkSelf);
+
+ if (sbkSelf->d->parentInfo)
+ _destroyParentInfo(sbkSelf, true);
+
+ Shiboken::Object::clearReferences(sbkSelf);
+
+ if (sbkSelf->ob_dict)
+ Py_CLEAR(sbkSelf->ob_dict);
+ return 0;
+}
+
+SbkObjectType SbkObject_Type = { { {
+ PyVarObject_HEAD_INIT(&SbkObjectType_Type, 0)
+ /*tp_name*/ "Shiboken.Object",
+ /*tp_basicsize*/ sizeof(SbkObject),
+ /*tp_itemsize*/ 0,
+ /*tp_dealloc*/ SbkDeallocWrapperWithPrivateDtor,
+ /*tp_print*/ 0,
+ /*tp_getattr*/ 0,
+ /*tp_setattr*/ 0,
+ /*tp_compare*/ 0,
+ /*tp_repr*/ 0,
+ /*tp_as_number*/ 0,
+ /*tp_as_sequence*/ 0,
+ /*tp_as_mapping*/ 0,
+ /*tp_hash*/ 0,
+ /*tp_call*/ 0,
+ /*tp_str*/ 0,
+ /*tp_getattro*/ 0,
+ /*tp_setattro*/ 0,
+ /*tp_as_buffer*/ 0,
+ /*tp_flags*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
+ /*tp_doc*/ 0,
+ /*tp_traverse*/ SbkObject_traverse,
+ /*tp_clear*/ SbkObject_clear,
+ /*tp_richcompare*/ 0,
+ /*tp_weaklistoffset*/ offsetof(SbkObject, weakreflist),
+ /*tp_iter*/ 0,
+ /*tp_iternext*/ 0,
+ /*tp_methods*/ 0,
+ /*tp_members*/ 0,
+ /*tp_getset*/ SbkObjectGetSetList,
+ /*tp_base*/ 0,
+ /*tp_dict*/ 0,
+ /*tp_descr_get*/ 0,
+ /*tp_descr_set*/ 0,
+ /*tp_dictoffset*/ offsetof(SbkObject, ob_dict),
+ /*tp_init*/ 0,
+ /*tp_alloc*/ 0,
+ /*tp_new*/ 0,
+ /*tp_free*/ 0,
+ /*tp_is_gc*/ 0,
+ /*tp_bases*/ 0,
+ /*tp_mro*/ 0,
+ /*tp_cache*/ 0,
+ /*tp_subclasses*/ 0,
+ /*tp_weaklist*/ 0,
+ /*tp_del*/ 0,
+ /*tp_version_tag*/ 0
+}, },
+ /*priv_data*/ 0
+};
+
+
+static void SbkDeallocWrapperCommon(PyObject* pyObj, bool canDelete)
+{
+ SbkObject* sbkObj = reinterpret_cast<SbkObject*>(pyObj);
+ PyTypeObject* pyType = Py_TYPE(pyObj);
+
+ // Need to decref the type if this is the dealloc func; if type
+ // is subclassed, that dealloc func will decref (see subtype_dealloc
+ // in typeobject.c in the python sources)
+ bool needTypeDecref = (pyType->tp_dealloc == SbkDeallocWrapper
+ || pyType->tp_dealloc == SbkDeallocWrapperWithPrivateDtor);
+
+ // Ensure that the GC is no longer tracking this object to avoid a
+ // possible reentrancy problem. Since there are multiple steps involved
+ // in deallocating a SbkObject it is possible for the garbage collector to
+ // be invoked and it trying to delete this object while it is still in
+ // progress from the first time around, resulting in a double delete and a
+ // crash.
+ PyObject_GC_UnTrack(pyObj);
+
+ // Check that Python is still initialized as sometimes this is called by a static destructor
+ // after Python interpeter is shutdown.
+ if (sbkObj->weakreflist && Py_IsInitialized())
+ PyObject_ClearWeakRefs(pyObj);
+
+ // If I have ownership and is valid delete C++ pointer
+ if (canDelete && sbkObj->d->hasOwnership && sbkObj->d->validCppObject) {
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(pyType);
+ if (sbkType->d->is_multicpp) {
+ Shiboken::DeallocVisitor visitor(sbkObj);
+ Shiboken::walkThroughClassHierarchy(pyObj->ob_type, &visitor);
+ } else {
+ void* cptr = sbkObj->d->cptr[0];
+ Shiboken::Object::deallocData(sbkObj, true);
+
+ Shiboken::ThreadStateSaver threadSaver;
+ if (Py_IsInitialized())
+ threadSaver.save();
+ sbkType->d->cpp_dtor(cptr);
+ }
+ } else {
+ Shiboken::Object::deallocData(sbkObj, true);
+ }
+
+ if (needTypeDecref)
+ Py_DECREF(pyType);
+}
+
+void SbkDeallocWrapper(PyObject* pyObj)
+{
+ SbkDeallocWrapperCommon(pyObj, true);
+}
+
+void SbkDeallocWrapperWithPrivateDtor(PyObject* self)
+{
+ SbkDeallocWrapperCommon(self, false);
+}
+
+void SbkObjectTypeDealloc(PyObject* pyObj)
+{
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(pyObj);
+
+ PyObject_GC_UnTrack(pyObj);
+ Py_TRASHCAN_SAFE_BEGIN(pyObj);
+ if (sbkType->d) {
+ if(sbkType->d->user_data && sbkType->d->d_func) {
+ sbkType->d->d_func(sbkType->d->user_data);
+ sbkType->d->user_data = 0;
+ }
+ free(sbkType->d->original_name);
+ sbkType->d->original_name = 0;
+ if (!Shiboken::ObjectType::isUserType(reinterpret_cast<PyTypeObject*>(sbkType)))
+ Shiboken::Conversions::deleteConverter(sbkType->d->converter);
+ delete sbkType->d;
+ sbkType->d = 0;
+ }
+ Py_TRASHCAN_SAFE_END(pyObj);
+}
+
+PyObject* SbkObjectTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwds)
+{
+#ifndef IS_PY3K
+ // Check if all bases are new style before calling type.tp_new
+ // Was causing gc assert errors in test_bug704.py when
+ // this check happened after creating the type object.
+ // Argument parsing take from type.tp_new code.
+ PyObject* name;
+ PyObject* pyBases;
+ PyObject* dict;
+ static const char* kwlist[] = { "name", "bases", "dict", 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "SO!O!:sbktype", (char**)kwlist,
+ &name,
+ &PyTuple_Type, &pyBases,
+ &PyDict_Type, &dict))
+ return NULL;
+
+ for(int i=0, i_max=PyTuple_GET_SIZE(pyBases); i < i_max; i++) {
+ PyObject* baseType = PyTuple_GET_ITEM(pyBases, i);
+ if (PyClass_Check(baseType)) {
+ PyErr_Format(PyExc_TypeError, "Invalid base class used in type %s. PySide only support multiple inheritance from python new style class.", metatype->tp_name);
+ return 0;
+ }
+ }
+#endif
+
+ // The meta type creates a new type when the Python programmer extends a wrapped C++ class.
+ SbkObjectType* newType = reinterpret_cast<SbkObjectType*>(PyType_Type.tp_new(metatype, args, kwds));
+ if (!newType)
+ return 0;
+
+ Shiboken::ObjectType::initPrivateData(newType);
+ SbkObjectTypePrivate* d = newType->d;
+
+ std::list<SbkObjectType*> bases = Shiboken::getCppBaseClasses(reinterpret_cast<PyTypeObject*>(newType));
+ if (bases.size() == 1) {
+ SbkObjectTypePrivate* parentType = bases.front()->d;
+ d->mi_offsets = parentType->mi_offsets;
+ d->mi_init = parentType->mi_init;
+ d->mi_specialcast = parentType->mi_specialcast;
+ d->type_discovery = parentType->type_discovery;
+ d->cpp_dtor = parentType->cpp_dtor;
+ d->is_multicpp = 0;
+ d->converter = parentType->converter;
+ } else {
+ d->mi_offsets = 0;
+ d->mi_init = 0;
+ d->mi_specialcast = 0;
+ d->type_discovery = 0;
+ d->cpp_dtor = 0;
+ d->is_multicpp = 1;
+ d->converter = 0;
+ }
+ if (bases.size() == 1)
+ d->original_name = strdup(bases.front()->d->original_name);
+ else
+ d->original_name = strdup("object");
+ d->user_data = 0;
+ d->d_func = 0;
+ d->is_user_type = 1;
+
+ std::list<SbkObjectType*>::const_iterator it = bases.begin();
+ for (; it != bases.end(); ++it) {
+ if ((*it)->d->subtype_init)
+ (*it)->d->subtype_init(newType, args, kwds);
+ }
+
+ return reinterpret_cast<PyObject*>(newType);
+}
+
+PyObject* SbkObjectTpNew(PyTypeObject* subtype, PyObject*, PyObject*)
+{
+ SbkObject* self = PyObject_GC_New(SbkObject, subtype);
+ Py_INCREF(reinterpret_cast<PyObject*>(subtype));
+ SbkObjectPrivate* d = new SbkObjectPrivate;
+
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(subtype);
+ int numBases = ((sbkType->d && sbkType->d->is_multicpp) ? Shiboken::getNumberOfCppBaseClasses(subtype) : 1);
+ d->cptr = new void*[numBases];
+ std::memset(d->cptr, 0, sizeof(void*)*numBases);
+ d->hasOwnership = 1;
+ d->containsCppWrapper = 0;
+ d->validCppObject = 0;
+ d->parentInfo = 0;
+ d->referredObjects = 0;
+ d->cppObjectCreated = 0;
+ self->ob_dict = 0;
+ self->weakreflist = 0;
+ self->d = d;
+ PyObject_GC_Track(reinterpret_cast<PyObject*>(self));
+ return reinterpret_cast<PyObject*>(self);
+}
+
+
+} //extern "C"
+
+
+namespace
+{
+
+void _destroyParentInfo(SbkObject* obj, bool keepReference)
+{
+ Shiboken::ParentInfo* pInfo = obj->d->parentInfo;
+ if (pInfo) {
+ while(!pInfo->children.empty()) {
+ SbkObject* first = *pInfo->children.begin();
+ // Mark child as invalid
+ Shiboken::Object::invalidate(first);
+ Shiboken::Object::removeParent(first, false, keepReference);
+ }
+ Shiboken::Object::removeParent(obj, false);
+ }
+}
+
+}
+
+namespace Shiboken
+{
+
+static void decRefPyObjectList(const std::list<PyObject*> &pyObj, PyObject* skip = 0);
+
+static void _walkThroughClassHierarchy(PyTypeObject* currentType, HierarchyVisitor* visitor)
+{
+ PyObject* bases = currentType->tp_bases;
+ Py_ssize_t numBases = PyTuple_GET_SIZE(bases);
+ for (int i = 0; i < numBases; ++i) {
+ PyTypeObject* type = reinterpret_cast<PyTypeObject*>(PyTuple_GET_ITEM(bases, i));
+
+ if (!PyType_IsSubtype(type, reinterpret_cast<PyTypeObject*>(&SbkObject_Type))) {
+ continue;
+ } else {
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(type);
+ if (sbkType->d->is_user_type)
+ _walkThroughClassHierarchy(type, visitor);
+ else
+ visitor->visit(sbkType);
+ }
+ if (visitor->wasFinished())
+ break;
+ }
+}
+
+void walkThroughClassHierarchy(PyTypeObject* currentType, HierarchyVisitor* visitor)
+{
+ _walkThroughClassHierarchy(currentType, visitor);
+ visitor->done();
+}
+
+
+bool importModule(const char* moduleName, PyTypeObject*** cppApiPtr)
+{
+ PyObject* sysModules = PyImport_GetModuleDict();
+ PyObject* module = PyDict_GetItemString(sysModules, moduleName);
+ if (!module) {
+ module = PyImport_ImportModule(moduleName);
+ if (!module)
+ return false;
+ } else {
+ Py_INCREF(module);
+ }
+
+ Shiboken::AutoDecRef cppApi(PyObject_GetAttrString(module, "_Cpp_Api"));
+ Py_DECREF(module);
+
+ if (cppApi.isNull())
+ return false;
+
+#ifdef IS_PY3K
+ if (PyCapsule_CheckExact(cppApi))
+ *cppApiPtr = reinterpret_cast<PyTypeObject**>(PyCapsule_GetPointer(cppApi, 0));
+#else
+ // Python 2.6 doesn't have PyCapsule API, so let's keep usign PyCObject on all Python 2.x
+ if (PyCObject_Check(cppApi))
+ *cppApiPtr = reinterpret_cast<PyTypeObject**>(PyCObject_AsVoidPtr(cppApi));
+#endif
+ return true;
+}
+
+// Wrapper metatype and base type ----------------------------------------------------------
+
+void DtorCallerVisitor::visit(SbkObjectType* node)
+{
+ m_ptrs.push_back(std::make_pair(m_pyObj->d->cptr[m_ptrs.size()], node));
+}
+
+void DtorCallerVisitor::done()
+{
+ std::list<std::pair<void*, SbkObjectType*> >::const_iterator it = m_ptrs.begin();
+ for (; it != m_ptrs.end(); ++it) {
+ Shiboken::ThreadStateSaver threadSaver;
+ threadSaver.save();
+ it->second->d->cpp_dtor(it->first);
+ }
+}
+
+void DeallocVisitor::done()
+{
+ Shiboken::Object::deallocData(m_pyObj, true);
+ DtorCallerVisitor::done();
+}
+
+namespace Module { void init(); }
+namespace Conversions { void init(); }
+
+void init()
+{
+ static bool shibokenAlreadInitialised = false;
+ if (shibokenAlreadInitialised)
+ return;
+
+ Module::init();
+ Conversions::init();
+
+ initTypeResolver();
+ PyEval_InitThreads();
+
+ //Init private data
+ Shiboken::ObjectType::initPrivateData(&SbkObject_Type);
+
+ if (PyType_Ready(&SbkEnumType_Type) < 0)
+ Py_FatalError("[libshiboken] Failed to initialise Shiboken.SbkEnumType metatype.");
+
+ if (PyType_Ready(&SbkObjectType_Type) < 0)
+ Py_FatalError("[libshiboken] Failed to initialise Shiboken.BaseWrapperType metatype.");
+
+ if (PyType_Ready(reinterpret_cast<PyTypeObject *>(&SbkObject_Type)) < 0)
+ Py_FatalError("[libshiboken] Failed to initialise Shiboken.BaseWrapper type.");
+
+ shibokenAlreadInitialised = true;
+}
+
+void setErrorAboutWrongArguments(PyObject* args, const char* funcName, const char** cppOverloads)
+{
+ std::string msg;
+ std::string params;
+ if (args) {
+ if (PyTuple_Check(args)) {
+ for (Py_ssize_t i = 0, max = PyTuple_GET_SIZE(args); i < max; ++i) {
+ if (i)
+ params += ", ";
+ PyObject* arg = PyTuple_GET_ITEM(args, i);
+ params += arg->ob_type->tp_name;
+ }
+ } else {
+ params = args->ob_type->tp_name;
+ }
+ }
+
+ if (!cppOverloads) {
+ msg = "'" + std::string(funcName) + "' called with wrong argument types: " + params;
+ } else {
+ msg = "'" + std::string(funcName) + "' called with wrong argument types:\n ";
+ msg += funcName;
+ msg += '(';
+ msg += params;
+ msg += ")\n";
+ msg += "Supported signatures:";
+ for (int i = 0; cppOverloads[i]; ++i) {
+ msg += "\n ";
+ msg += funcName;
+ msg += '(';
+ msg += cppOverloads[i];
+ msg += ')';
+ }
+ }
+ PyErr_SetString(PyExc_TypeError, msg.c_str());
+
+}
+
+class FindBaseTypeVisitor : public HierarchyVisitor
+{
+ public:
+ FindBaseTypeVisitor(PyTypeObject* typeToFind) : m_found(false), m_typeToFind(typeToFind) {}
+ virtual void visit(SbkObjectType* node)
+ {
+ if (reinterpret_cast<PyTypeObject*>(node) == m_typeToFind) {
+ m_found = true;
+ finish();
+ }
+ }
+ bool found() const { return m_found; }
+
+ private:
+ bool m_found;
+ PyTypeObject* m_typeToFind;
+};
+
+std::list<SbkObject*> splitPyObject(PyObject* pyObj)
+{
+ std::list<SbkObject*> result;
+ if (PySequence_Check(pyObj)) {
+ AutoDecRef lst(PySequence_Fast(pyObj, "Invalid keep reference object."));
+ if (!lst.isNull()) {
+ for (Py_ssize_t i = 0, i_max = PySequence_Fast_GET_SIZE(lst.object()); i < i_max; ++i) {
+ PyObject* item = PySequence_Fast_GET_ITEM(lst.object(), i);
+ if (Object::checkType(item))
+ result.push_back(reinterpret_cast<SbkObject*>(item));
+ }
+ }
+ } else {
+ result.push_back(reinterpret_cast<SbkObject*>(pyObj));
+ }
+ return result;
+}
+
+static void decRefPyObjectList(const std::list<PyObject*>& lst, PyObject *skip)
+{
+ std::list<PyObject*>::const_iterator iter = lst.begin();
+ while(iter != lst.end()) {
+ if (*iter != skip)
+ Py_DECREF(*iter);
+ ++iter;
+ }
+}
+
+namespace ObjectType
+{
+
+bool checkType(PyTypeObject* type)
+{
+ return PyType_IsSubtype(type, reinterpret_cast<PyTypeObject*>(&SbkObject_Type));
+}
+
+bool isUserType(PyTypeObject* type)
+{
+ return checkType(type) && reinterpret_cast<SbkObjectType*>(type)->d->is_user_type;
+}
+
+bool canCallConstructor(PyTypeObject* myType, PyTypeObject* ctorType)
+{
+ FindBaseTypeVisitor visitor(ctorType);
+ walkThroughClassHierarchy(myType, &visitor);
+ if (!visitor.found()) {
+ PyErr_Format(PyExc_TypeError, "%s isn't a direct base class of %s", ctorType->tp_name, myType->tp_name);
+ return false;
+ }
+ return true;
+}
+
+
+bool hasExternalCppConversions(SbkObjectType*) { return false; } // DEPRECATED.
+bool isExternalConvertible(SbkObjectType *, PyObject *) { return false; } // DEPRECATED.
+void setExternalCppConversionFunction(SbkObjectType*, ExtendedToCppFunc) {} // DEPRECATED.
+void setExternalIsConvertibleFunction(SbkObjectType*, ExtendedIsConvertibleFunc) {} // DEPRECATED.
+void* callExternalCppConversion(SbkObjectType*, PyObject*) { return 0; } // DEPRECATED.
+
+
+bool hasCast(SbkObjectType* type)
+{
+ return type->d->mi_specialcast;
+}
+
+void* cast(SbkObjectType* sourceType, SbkObject* obj, PyTypeObject* targetType)
+{
+ return sourceType->d->mi_specialcast(Object::cppPointer(obj, targetType), reinterpret_cast<SbkObjectType*>(targetType));
+}
+
+void setCastFunction(SbkObjectType* type, SpecialCastFunction func)
+{
+ type->d->mi_specialcast = func;
+}
+
+void setOriginalName(SbkObjectType* self, const char* name)
+{
+ if (self->d->original_name)
+ free(self->d->original_name);
+ self->d->original_name = strdup(name);
+}
+
+const char* getOriginalName(SbkObjectType* self)
+{
+ return self->d->original_name;
+}
+
+void setTypeDiscoveryFunctionV2(SbkObjectType* self, TypeDiscoveryFuncV2 func)
+{
+ self->d->type_discovery = func;
+}
+
+void setTypeDiscoveryFunction(SbkObjectType* self, TypeDiscoveryFunc func)
+{
+ self->d->type_discovery = (TypeDiscoveryFuncV2)func;
+}
+
+TypeDiscoveryFunc getTypeDiscoveryFunction(SbkObjectType* self)
+{
+ // This is an illegal cast because the return value is different,
+ // but nobody ever used this function, so... =]
+ return (TypeDiscoveryFunc)self->d->type_discovery;
+}
+
+void copyMultimpleheritance(SbkObjectType* self, SbkObjectType* other)
+{
+ self->d->mi_init = other->d->mi_init;
+ self->d->mi_offsets = other->d->mi_offsets;
+ self->d->mi_specialcast = other->d->mi_specialcast;
+}
+
+void setMultipleIheritanceFunction(SbkObjectType* self, MultipleInheritanceInitFunction function)
+{
+ self->d->mi_init = function;
+}
+
+MultipleInheritanceInitFunction getMultipleIheritanceFunction(SbkObjectType* self)
+{
+ return self->d->mi_init;
+}
+
+void setDestructorFunction(SbkObjectType* self, ObjectDestructor func)
+{
+ self->d->cpp_dtor = func;
+}
+
+void initPrivateData(SbkObjectType* self)
+{
+ self->d = new SbkObjectTypePrivate;
+ memset(self->d, 0, sizeof(SbkObjectTypePrivate));
+}
+
+bool introduceWrapperType(PyObject* enclosingObject,
+ const char* typeName, const char* originalName,
+ SbkObjectType* type, ObjectDestructor cppObjDtor,
+ SbkObjectType* baseType, PyObject* baseTypes,
+ bool isInnerClass)
+{
+ initPrivateData(type);
+ setOriginalName(type, originalName);
+ setDestructorFunction(type, cppObjDtor);
+
+ if (baseType) {
+ type->super.ht_type.tp_base = reinterpret_cast<PyTypeObject *>(baseType);
+ if (baseTypes) {
+ for (int i = 0; i < PySequence_Fast_GET_SIZE(baseTypes); ++i)
+ BindingManager::instance().addClassInheritance(reinterpret_cast<SbkObjectType *>(PySequence_Fast_GET_ITEM(baseTypes, i)), type);
+ type->super.ht_type.tp_bases = baseTypes;
+ } else {
+ BindingManager::instance().addClassInheritance(baseType, type);
+ }
+ }
+
+ if (PyType_Ready(reinterpret_cast<PyTypeObject *>(type)) < 0)
+ return false;
+
+ if (isInnerClass)
+ return PyDict_SetItemString(enclosingObject, typeName, reinterpret_cast<PyObject *>(type)) == 0;
+
+ //PyModule_AddObject steals type's reference.
+ Py_INCREF(reinterpret_cast<PyObject *>(type));
+ return PyModule_AddObject(enclosingObject, typeName, reinterpret_cast<PyObject *>(type)) == 0;
+}
+
+void setSubTypeInitHook(SbkObjectType* self, SubTypeInitHook func)
+{
+ self->d->subtype_init = func;
+}
+
+void* getTypeUserData(SbkObjectType* self)
+{
+ return self->d->user_data;
+}
+
+void setTypeUserData(SbkObjectType* self, void* userData, DeleteUserDataFunc d_func)
+{
+ self->d->user_data = userData;
+ self->d->d_func = d_func;
+}
+
+} // namespace ObjectType
+
+
+namespace Object
+{
+
+static void recursive_invalidate(SbkObject* self, std::set<SbkObject*>& seen);
+
+bool checkType(PyObject* pyObj)
+{
+ return ObjectType::checkType(pyObj->ob_type);
+}
+
+bool isUserType(PyObject* pyObj)
+{
+ return ObjectType::isUserType(pyObj->ob_type);
+}
+
+Py_hash_t hash(PyObject* pyObj)
+{
+ assert(Shiboken::Object::checkType(pyObj));
+ return reinterpret_cast<Py_hash_t>(pyObj);
+}
+
+static void setSequenceOwnership(PyObject* pyObj, bool owner)
+{
+ if (PySequence_Check(pyObj)) {
+ std::list<SbkObject*> objs = splitPyObject(pyObj);
+ std::list<SbkObject*>::const_iterator it = objs.begin();
+ for(; it != objs.end(); ++it) {
+ if (owner)
+ getOwnership(*it);
+ else
+ releaseOwnership(*it);
+ }
+ } else if (Object::checkType(pyObj)) {
+ if (owner)
+ getOwnership(reinterpret_cast<SbkObject*>(pyObj));
+ else
+ releaseOwnership(reinterpret_cast<SbkObject*>(pyObj));
+ }
+}
+
+void setValidCpp(SbkObject* pyObj, bool value)
+{
+ pyObj->d->validCppObject = value;
+}
+
+void setHasCppWrapper(SbkObject* pyObj, bool value)
+{
+ pyObj->d->containsCppWrapper = value;
+}
+
+bool hasCppWrapper(SbkObject* pyObj)
+{
+ return pyObj->d->containsCppWrapper;
+}
+
+bool wasCreatedByPython(SbkObject* pyObj)
+{
+ return pyObj->d->cppObjectCreated;
+}
+
+void callCppDestructors(SbkObject* pyObj)
+{
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(Py_TYPE(pyObj));
+ if (sbkType->d->is_multicpp) {
+ Shiboken::DtorCallerVisitor visitor(pyObj);
+ Shiboken::walkThroughClassHierarchy(Py_TYPE(pyObj), &visitor);
+ } else {
+ Shiboken::ThreadStateSaver threadSaver;
+ threadSaver.save();
+ sbkType->d->cpp_dtor(pyObj->d->cptr[0]);
+ }
+
+ /* invalidate needs to be called before deleting pointer array because
+ it needs to delete entries for them from the BindingManager hash table;
+ also release wrapper explicitly if object contains C++ wrapper because
+ invalidate doesn't */
+ invalidate(pyObj);
+ if (pyObj->d->validCppObject && pyObj->d->containsCppWrapper) {
+ BindingManager::instance().releaseWrapper(pyObj);
+ }
+
+ delete[] pyObj->d->cptr;
+ pyObj->d->cptr = 0;
+ pyObj->d->validCppObject = false;
+}
+
+bool hasOwnership(SbkObject* pyObj)
+{
+ return pyObj->d->hasOwnership;
+}
+
+void getOwnership(SbkObject* self)
+{
+ // skip if already have the ownership
+ if (self->d->hasOwnership)
+ return;
+
+ // skip if this object has parent
+ if (self->d->parentInfo && self->d->parentInfo->parent)
+ return;
+
+ // Get back the ownership
+ self->d->hasOwnership = true;
+
+ if (self->d->containsCppWrapper)
+ Py_DECREF(reinterpret_cast<PyObject *>(self)); // Remove extra ref
+ else
+ makeValid(self); // Make the object valid again
+}
+
+void getOwnership(PyObject* pyObj)
+{
+ if (pyObj)
+ setSequenceOwnership(pyObj, true);
+}
+
+void releaseOwnership(SbkObject* self)
+{
+ // skip if the ownership have already moved to c++
+ SbkObjectType* selfType = reinterpret_cast<SbkObjectType*>(Py_TYPE(self));
+ if (!self->d->hasOwnership || Shiboken::Conversions::pythonTypeIsValueType(selfType->d->converter))
+ return;
+
+ // remove object ownership
+ self->d->hasOwnership = false;
+
+ // If We have control over object life
+ if (self->d->containsCppWrapper)
+ Py_INCREF(reinterpret_cast<PyObject *>(self)); // keep the python object alive until the wrapper destructor call
+ else
+ invalidate(self); // If I do not know when this object will die We need to invalidate this to avoid use after
+}
+
+void releaseOwnership(PyObject* self)
+{
+ setSequenceOwnership(self, false);
+}
+
+/* Needed forward declarations */
+static void recursive_invalidate(PyObject* pyobj, std::set<SbkObject*>& seen);
+static void recursive_invalidate(SbkObject* self, std::set<SbkObject*>& seen);
+
+void invalidate(PyObject* pyobj)
+{
+ std::set<SbkObject*> seen;
+ recursive_invalidate(pyobj, seen);
+}
+
+void invalidate(SbkObject* self)
+{
+ std::set<SbkObject*> seen;
+ recursive_invalidate(self, seen);
+}
+
+static void recursive_invalidate(PyObject* pyobj, std::set<SbkObject*>& seen)
+{
+ std::list<SbkObject*> objs = splitPyObject(pyobj);
+ std::list<SbkObject*>::const_iterator it = objs.begin();
+ for (; it != objs.end(); it++)
+ recursive_invalidate(*it, seen);
+}
+
+static void recursive_invalidate(SbkObject* self, std::set<SbkObject*>& seen)
+{
+ // Skip if this object not is a valid object or if it's already been seen
+ if (!self || reinterpret_cast<PyObject *>(self) == Py_None || seen.find(self) != seen.end())
+ return;
+ seen.insert(self);
+
+ if (!self->d->containsCppWrapper) {
+ self->d->validCppObject = false; // Mark object as invalid only if this is not a wrapper class
+ BindingManager::instance().releaseWrapper(self);
+ }
+
+ // If it is a parent invalidate all children.
+ if (self->d->parentInfo) {
+ // Create a copy because this list can be changed during the process
+ ChildrenList copy = self->d->parentInfo->children;
+ ChildrenList::iterator it = copy.begin();
+
+ for (; it != copy.end(); ++it) {
+ // invalidate the child
+ recursive_invalidate(*it, seen);
+
+ // if the parent not is a wrapper class, then remove children from him, because We do not know when this object will be destroyed
+ if (!self->d->validCppObject)
+ removeParent(*it, true, true);
+ }
+ }
+
+ // If has ref to other objects invalidate all
+ if (self->d->referredObjects) {
+ RefCountMap& refCountMap = *(self->d->referredObjects);
+ RefCountMap::iterator iter;
+ for (iter = refCountMap.begin(); iter != refCountMap.end(); ++iter) {
+ const std::list<PyObject*> lst = iter->second;
+ std::list<PyObject*>::const_iterator it = lst.begin();
+ while(it != lst.end()) {
+ recursive_invalidate(*it, seen);
+ ++it;
+ }
+ }
+ }
+}
+
+void makeValid(SbkObject* self)
+{
+ // Skip if this object not is a valid object
+ if (!self || reinterpret_cast<PyObject *>(self) == Py_None || self->d->validCppObject)
+ return;
+
+ // Mark object as invalid only if this is not a wrapper class
+ self->d->validCppObject = true;
+
+ // If it is a parent make all children valid
+ if (self->d->parentInfo) {
+ ChildrenList::iterator it = self->d->parentInfo->children.begin();
+ for (; it != self->d->parentInfo->children.end(); ++it)
+ makeValid(*it);
+ }
+
+ // If has ref to other objects make all valid again
+ if (self->d->referredObjects) {
+ RefCountMap& refCountMap = *(self->d->referredObjects);
+ RefCountMap::iterator iter;
+ for (iter = refCountMap.begin(); iter != refCountMap.end(); ++iter) {
+ const std::list<PyObject*> lst = iter->second;
+ std::list<PyObject*>::const_iterator it = lst.begin();
+ while(it != lst.end()) {
+ if (Shiboken::Object::checkType(*it))
+ makeValid(reinterpret_cast<SbkObject*>(*it));
+ ++it;
+ }
+ }
+ }
+}
+
+bool hasParentInfo(SbkObject* pyObj)
+{
+ return pyObj->d->parentInfo;
+}
+
+void* cppPointer(SbkObject* pyObj, PyTypeObject* desiredType)
+{
+ PyTypeObject* type = Py_TYPE(pyObj);
+ int idx = 0;
+ if (reinterpret_cast<SbkObjectType*>(type)->d->is_multicpp)
+ idx = getTypeIndexOnHierarchy(type, desiredType);
+ if (pyObj->d->cptr)
+ return pyObj->d->cptr[idx];
+ return 0;
+}
+
+std::vector<void*> cppPointers(SbkObject* pyObj)
+{
+ int n = getNumberOfCppBaseClasses(Py_TYPE(pyObj));
+ std::vector<void*> ptrs(n);
+ for (int i = 0; i < n; ++i)
+ ptrs[i] = pyObj->d->cptr[i];
+ return ptrs;
+}
+
+
+bool setCppPointer(SbkObject* sbkObj, PyTypeObject* desiredType, void* cptr)
+{
+ int idx = 0;
+ if (reinterpret_cast<SbkObjectType*>(Py_TYPE(sbkObj))->d->is_multicpp)
+ idx = getTypeIndexOnHierarchy(Py_TYPE(sbkObj), desiredType);
+
+ bool alreadyInitialized = sbkObj->d->cptr[idx];
+ if (alreadyInitialized)
+ PyErr_SetString(PyExc_RuntimeError, "You can't initialize an object twice!");
+ else
+ sbkObj->d->cptr[idx] = cptr;
+
+ sbkObj->d->cppObjectCreated = true;
+ return !alreadyInitialized;
+}
+
+bool isValid(PyObject* pyObj)
+{
+ if (!pyObj || pyObj == Py_None
+ || Py_TYPE(pyObj->ob_type) != &SbkObjectType_Type) {
+ return true;
+ }
+
+ SbkObjectPrivate* priv = reinterpret_cast<SbkObject*>(pyObj)->d;
+
+ if (!priv->cppObjectCreated && isUserType(pyObj)) {
+ PyErr_Format(PyExc_RuntimeError, "'__init__' method of object's base class (%s) not called.", pyObj->ob_type->tp_name);
+ return false;
+ }
+
+ if (!priv->validCppObject) {
+ PyErr_Format(PyExc_RuntimeError, "Internal C++ object (%s) already deleted.", pyObj->ob_type->tp_name);
+ return false;
+ }
+
+ return true;
+}
+
+bool isValid(SbkObject* pyObj, bool throwPyError)
+{
+ if (!pyObj)
+ return false;
+
+ SbkObjectPrivate* priv = pyObj->d;
+ if (!priv->cppObjectCreated && isUserType(reinterpret_cast<PyObject*>(pyObj))) {
+ if (throwPyError)
+ PyErr_Format(PyExc_RuntimeError, "Base constructor of the object (%s) not called.", Py_TYPE(pyObj)->tp_name);
+ return false;
+ }
+
+ if (!priv->validCppObject) {
+ if (throwPyError)
+ PyErr_Format(PyExc_RuntimeError, "Internal C++ object (%s) already deleted.", Py_TYPE(pyObj)->tp_name);
+ return false;
+ }
+
+ return true;
+}
+
+bool isValid(PyObject* pyObj, bool throwPyError)
+{
+ if (!pyObj || pyObj == Py_None ||
+ !PyType_IsSubtype(pyObj->ob_type, reinterpret_cast<PyTypeObject*>(&SbkObject_Type))) {
+ return true;
+ }
+ return isValid(reinterpret_cast<SbkObject*>(pyObj), throwPyError);
+}
+
+SbkObject *findColocatedChild(SbkObject *wrapper,
+ const SbkObjectType *instanceType)
+{
+ // Degenerate case, wrapper is the correct wrapper.
+ if (reinterpret_cast<const void *>(Py_TYPE(wrapper)) == reinterpret_cast<const void *>(instanceType))
+ return wrapper;
+
+ if (!(wrapper->d && wrapper->d->cptr))
+ return 0;
+
+ ParentInfo* pInfo = wrapper->d->parentInfo;
+ if (!pInfo)
+ return 0;
+
+ ChildrenList& children = pInfo->children;
+
+ ChildrenList::iterator childrenEnd = children.end();
+ for (ChildrenList::iterator iChild = children.begin(); iChild != childrenEnd; ++iChild) {
+ if (!((*iChild)->d && (*iChild)->d->cptr))
+ continue;
+ if ((*iChild)->d->cptr[0] == wrapper->d->cptr[0]) {
+ if (reinterpret_cast<const void *>(Py_TYPE(*iChild)) == reinterpret_cast<const void *>(instanceType))
+ return const_cast<SbkObject *>((*iChild));
+ else
+ return findColocatedChild(const_cast<SbkObject *>(*iChild), instanceType);
+ }
+ }
+ return 0;
+}
+
+
+PyObject *newObject(SbkObjectType* instanceType,
+ void* cptr,
+ bool hasOwnership,
+ bool isExactType,
+ const char* typeName)
+{
+ // Try to find the exact type of cptr.
+ if (!isExactType) {
+ PyTypeObject* exactType = 0;
+ if (typeName) {
+ exactType = Shiboken::Conversions::getPythonTypeObject(typeName);
+ if (exactType)
+ instanceType = reinterpret_cast<SbkObjectType*>(exactType);
+ }
+ if (!exactType)
+ instanceType = BindingManager::instance().resolveType(&cptr, instanceType);
+ }
+
+ bool shouldCreate = true;
+ bool shouldRegister = true;
+ SbkObject* self = 0;
+
+ // Some logic to ensure that colocated child field does not overwrite the parent
+ if (BindingManager::instance().hasWrapper(cptr)) {
+ SbkObject* existingWrapper = BindingManager::instance().retrieveWrapper(cptr);
+
+ self = findColocatedChild(existingWrapper, instanceType);
+ if (self) {
+ // Wrapper already registered for cptr.
+ // This should not ideally happen, binding code should know when a wrapper
+ // already exists and retrieve it instead.
+ shouldRegister = shouldCreate = false;
+ } else if (hasOwnership &&
+ (!(Shiboken::Object::hasCppWrapper(existingWrapper) ||
+ Shiboken::Object::hasOwnership(existingWrapper)))) {
+ // Old wrapper is likely junk, since we have ownership and it doesn't.
+ BindingManager::instance().releaseWrapper(existingWrapper);
+ } else {
+ // Old wrapper may be junk caused by some bug in identifying object deletion
+ // but it may not be junk when a colocated field is accessed for an
+ // object which was not created by python (returned from c++ factory function).
+ // Hence we cannot release the wrapper confidently so we do not register.
+ shouldRegister = false;
+ }
+ }
+
+ if (shouldCreate) {
+ self = reinterpret_cast<SbkObject*>(SbkObjectTpNew(reinterpret_cast<PyTypeObject*>(instanceType), 0, 0));
+ self->d->cptr[0] = cptr;
+ self->d->hasOwnership = hasOwnership;
+ self->d->validCppObject = 1;
+ if (shouldRegister) {
+ BindingManager::instance().registerWrapper(self, cptr);
+ }
+ } else {
+ Py_IncRef(reinterpret_cast<PyObject*>(self));
+ }
+ return reinterpret_cast<PyObject*>(self);
+}
+
+void destroy(SbkObject* self)
+{
+ destroy(self, 0);
+}
+
+void destroy(SbkObject* self, void* cppData)
+{
+ // Skip if this is called with NULL pointer this can happen in derived classes
+ if (!self)
+ return;
+
+ // This can be called in c++ side
+ Shiboken::GilState gil;
+
+ // Remove all references attached to this object
+ clearReferences(self);
+
+ // Remove the object from parent control
+
+ // Verify if this object has parent
+ bool hasParent = (self->d->parentInfo && self->d->parentInfo->parent);
+
+ if (self->d->parentInfo) {
+ // Check for children information and make all invalid if they exists
+ _destroyParentInfo(self, true);
+ // If this object has parent then the pyobject can be invalid now, because we remove the last ref after remove from parent
+ }
+
+ //if !hasParent this object could still alive
+ if (!hasParent && self->d->containsCppWrapper && !self->d->hasOwnership) {
+ // Remove extra ref used by c++ object this will case the pyobject destruction
+ // This can cause the object death
+ Py_DECREF(reinterpret_cast<PyObject *>(self));
+ }
+
+ //Python Object is not destroyed yet
+ if (cppData && Shiboken::BindingManager::instance().hasWrapper(cppData)) {
+ // Remove from BindingManager
+ Shiboken::BindingManager::instance().releaseWrapper(self);
+ self->d->hasOwnership = false;
+
+ // the cpp object instance was deleted
+ delete[] self->d->cptr;
+ self->d->cptr = 0;
+ }
+
+ // After this point the object can be death do not use the self pointer bellow
+}
+
+void removeParent(SbkObject* child, bool giveOwnershipBack, bool keepReference)
+{
+ ParentInfo* pInfo = child->d->parentInfo;
+ if (!pInfo || !pInfo->parent) {
+ if (pInfo && pInfo->hasWrapperRef) {
+ pInfo->hasWrapperRef = false;
+ }
+ return;
+ }
+
+ ChildrenList& oldBrothers = pInfo->parent->d->parentInfo->children;
+ // Verify if this child is part of parent list
+ ChildrenList::iterator iChild = std::find(oldBrothers.begin(), oldBrothers.end(), child);
+ if (iChild == oldBrothers.end())
+ return;
+
+ oldBrothers.erase(iChild);
+
+ pInfo->parent = 0;
+
+ // This will keep the wrapper reference, will wait for wrapper destruction to remove that
+ if (keepReference &&
+ child->d->containsCppWrapper) {
+ //If have already a extra ref remove this one
+ if (pInfo->hasWrapperRef)
+ Py_DECREF(child);
+ else
+ pInfo->hasWrapperRef = true;
+ return;
+ }
+
+ // Transfer ownership back to Python
+ child->d->hasOwnership = giveOwnershipBack;
+
+ // Remove parent ref
+ Py_DECREF(child);
+}
+
+void setParent(PyObject* parent, PyObject* child)
+{
+ if (!child || child == Py_None || child == parent)
+ return;
+
+ /*
+ * setParent is recursive when the child is a native Python sequence, i.e. objects not binded by Shiboken
+ * like tuple and list.
+ *
+ * This "limitation" exists to fix the following problem: A class multiple inherits QObject and QString,
+ * so if you pass this class to someone that takes the ownership, we CAN'T enter in this if, but hey! QString
+ * follows the sequence protocol.
+ */
+ if (PySequence_Check(child) && !Object::checkType(child)) {
+ Shiboken::AutoDecRef seq(PySequence_Fast(child, 0));
+ for (Py_ssize_t i = 0, max = PySequence_Size(seq); i < max; ++i)
+ setParent(parent, PySequence_Fast_GET_ITEM(seq.object(), i));
+ return;
+ }
+
+ bool parentIsNull = !parent || parent == Py_None;
+ SbkObject* parent_ = reinterpret_cast<SbkObject*>(parent);
+ SbkObject* child_ = reinterpret_cast<SbkObject*>(child);
+
+ if (!parentIsNull) {
+ if (!parent_->d->parentInfo)
+ parent_->d->parentInfo = new ParentInfo;
+
+ // do not re-add a child
+ if (child_->d->parentInfo && (child_->d->parentInfo->parent == parent_))
+ return;
+ }
+
+ ParentInfo* pInfo = child_->d->parentInfo;
+ bool hasAnotherParent = pInfo && pInfo->parent && pInfo->parent != parent_;
+
+ //Avoid destroy child during reparent operation
+ Py_INCREF(child);
+
+ // check if we need to remove this child from the old parent
+ if (parentIsNull || hasAnotherParent)
+ removeParent(child_);
+
+ // Add the child to the new parent
+ pInfo = child_->d->parentInfo;
+ if (!parentIsNull) {
+ if (!pInfo)
+ pInfo = child_->d->parentInfo = new ParentInfo;
+
+ pInfo->parent = parent_;
+ parent_->d->parentInfo->children.insert(child_);
+
+ // Add Parent ref
+ Py_INCREF(child_);
+
+ // Remove ownership
+ child_->d->hasOwnership = false;
+ }
+
+ // Remove previous safe ref
+ Py_DECREF(child);
+}
+
+void deallocData(SbkObject* self, bool cleanup)
+{
+ // Make cleanup if this is not a wrapper otherwise this will be done on wrapper destructor
+ if(cleanup) {
+ removeParent(self);
+
+ if (self->d->parentInfo)
+ _destroyParentInfo(self, true);
+
+ clearReferences(self);
+ }
+
+ if (self->d->cptr) {
+ // Remove from BindingManager
+ Shiboken::BindingManager::instance().releaseWrapper(self);
+ delete[] self->d->cptr;
+ self->d->cptr = 0;
+ // delete self->d; PYSIDE-205: wrong!
+ }
+ delete self->d; // PYSIDE-205: always delete d.
+ Py_XDECREF(self->ob_dict);
+ Py_TYPE(self)->tp_free(self);
+}
+
+void setTypeUserData(SbkObject* wrapper, void* userData, DeleteUserDataFunc d_func)
+{
+ SbkObjectType* ob_type = reinterpret_cast<SbkObjectType*>(Py_TYPE(wrapper));
+ if (ob_type->d->user_data)
+ ob_type->d->d_func(ob_type->d->user_data);
+
+ ob_type->d->d_func = d_func;
+ ob_type->d->user_data = userData;
+}
+
+void* getTypeUserData(SbkObject* wrapper)
+{
+ return reinterpret_cast<SbkObjectType*>(Py_TYPE(wrapper))->d->user_data;
+}
+
+void keepReference(SbkObject* self, const char* key, PyObject* referredObject, bool append)
+{
+ bool isNone = (!referredObject || (referredObject == Py_None));
+
+ if (!self->d->referredObjects)
+ self->d->referredObjects = new Shiboken::RefCountMap;
+
+ RefCountMap& refCountMap = *(self->d->referredObjects);
+ RefCountMap::iterator iter = refCountMap.find(key);
+ std::list<PyObject*> objects;
+ if (iter != refCountMap.end()) {
+ objects = (*iter).second;
+ std::list<PyObject*>::const_iterator found = std::find(objects.begin(), objects.end(), referredObject);
+
+ // skip if objects already exists
+ if (found != objects.end())
+ return;
+ }
+
+ if (append && !isNone) {
+ refCountMap[key].push_back(referredObject);
+ Py_INCREF(referredObject);
+ } else if (!append) {
+ if (objects.size() > 0)
+ decRefPyObjectList(objects, isNone ? 0 : referredObject);
+ if (isNone) {
+ if (iter != refCountMap.end())
+ refCountMap.erase(iter);
+ } else {
+ objects.clear();
+ objects.push_back(referredObject);
+ refCountMap[key] = objects;
+ Py_INCREF(referredObject);
+ }
+ }
+}
+
+void removeReference(SbkObject* self, const char* key, PyObject* referredObject)
+{
+ if (!referredObject || (referredObject == Py_None))
+ return;
+
+ if (!self->d->referredObjects)
+ return;
+
+ RefCountMap& refCountMap = *(self->d->referredObjects);
+ RefCountMap::iterator iter = refCountMap.find(key);
+ if (iter != refCountMap.end()) {
+ decRefPyObjectList(iter->second);
+ refCountMap.erase(iter);
+ }
+}
+
+void clearReferences(SbkObject* self)
+{
+ if (!self->d->referredObjects)
+ return;
+
+ RefCountMap& refCountMap = *(self->d->referredObjects);
+ RefCountMap::iterator iter;
+ for (iter = refCountMap.begin(); iter != refCountMap.end(); ++iter)
+ decRefPyObjectList(iter->second);
+ self->d->referredObjects->clear();
+}
+
+std::string info(SbkObject* self)
+{
+ std::ostringstream s;
+ std::list<SbkObjectType*> bases;
+
+ if (self->d && self->d->cptr) {
+ if (ObjectType::isUserType(Py_TYPE(self)))
+ bases = getCppBaseClasses(Py_TYPE(self));
+ else
+ bases.push_back(reinterpret_cast<SbkObjectType*>(Py_TYPE(self)));
+
+ s << "C++ address....... ";
+ std::list<SbkObjectType*>::const_iterator it = bases.begin();
+ for (int i = 0; it != bases.end(); ++it, ++i)
+ s << reinterpret_cast<PyTypeObject *>(*it)->tp_name << '/' << self->d->cptr[i] << ' ';
+ s << "\n";
+ }
+ else {
+ s << "C++ address....... <<Deleted>>\n";
+ }
+
+ s << "hasOwnership...... " << bool(self->d->hasOwnership) << "\n"
+ "containsCppWrapper " << self->d->containsCppWrapper << "\n"
+ "validCppObject.... " << self->d->validCppObject << "\n"
+ "wasCreatedByPython " << self->d->cppObjectCreated << "\n";
+
+
+ if (self->d->parentInfo && self->d->parentInfo->parent) {
+ s << "parent............ ";
+ Shiboken::AutoDecRef parent(PyObject_Str(reinterpret_cast<PyObject *>(self->d->parentInfo->parent)));
+ s << String::toCString(parent) << "\n";
+ }
+
+ if (self->d->parentInfo && self->d->parentInfo->children.size()) {
+ s << "children.......... ";
+ ChildrenList& children = self->d->parentInfo->children;
+ for (ChildrenList::const_iterator it = children.begin(); it != children.end(); ++it) {
+ Shiboken::AutoDecRef child(PyObject_Str(reinterpret_cast<PyObject *>(*it)));
+ s << String::toCString(child) << ' ';
+ }
+ s << '\n';
+ }
+
+ if (self->d->referredObjects && self->d->referredObjects->size()) {
+ Shiboken::RefCountMap& map = *self->d->referredObjects;
+ s << "referred objects.. ";
+ Shiboken::RefCountMap::const_iterator it = map.begin();
+ for (; it != map.end(); ++it) {
+ if (it != map.begin())
+ s << " ";
+ s << '"' << it->first << "\" => ";
+ std::list<PyObject*>::const_iterator j = it->second.begin();
+ for (; j != it->second.end(); ++j) {
+ Shiboken::AutoDecRef obj(PyObject_Str(*j));
+ s << String::toCString(obj) << ' ';
+ }
+ s << ' ';
+ }
+ s << '\n';
+ }
+ return s.str();
+}
+
+} // namespace Object
+
+} // namespace Shiboken
diff --git a/sources/shiboken2/libshiboken/basewrapper.h b/sources/shiboken2/libshiboken/basewrapper.h
new file mode 100644
index 000000000..002337f3c
--- /dev/null
+++ b/sources/shiboken2/libshiboken/basewrapper.h
@@ -0,0 +1,451 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 BASEWRAPPER_H
+#define BASEWRAPPER_H
+
+#include "sbkpython.h"
+#include "shibokenmacros.h"
+
+#include <vector>
+#include <string>
+
+extern "C"
+{
+
+struct SbkConverter;
+struct SbkObjectPrivate;
+
+/// Base Python object for all the wrapped C++ classes.
+struct LIBSHIBOKEN_API SbkObject
+{
+ PyObject_HEAD
+ /// Instance dictionary.
+ PyObject* ob_dict;
+ /// List of weak references
+ PyObject* weakreflist;
+ SbkObjectPrivate* d;
+};
+
+
+/// Dealloc the python object \p pyObj and the C++ object represented by it.
+LIBSHIBOKEN_API void SbkDeallocWrapper(PyObject* pyObj);
+LIBSHIBOKEN_API void SbkDeallocWrapperWithPrivateDtor(PyObject* self);
+
+struct SbkObjectType;
+
+/// Function signature for the multiple inheritance information initializers that should be provided by classes with multiple inheritance.
+typedef int* (*MultipleInheritanceInitFunction)(const void*);
+
+/**
+ * Special cast function is used to correctly cast an object when it's
+ * part of a multiple inheritance hierarchy.
+ * The implementation of this function is auto generated by the generator and you don't need to care about it.
+ */
+typedef void* (*SpecialCastFunction)(void*, SbkObjectType*);
+typedef SbkObjectType* (*TypeDiscoveryFunc)(void*, SbkObjectType*);
+typedef void* (*TypeDiscoveryFuncV2)(void*, SbkObjectType*);
+
+typedef void* (*ExtendedToCppFunc)(PyObject*); // DEPRECATED.
+typedef bool (*ExtendedIsConvertibleFunc)(PyObject*); // DEPRECATED.
+
+// Used in userdata dealloc function
+typedef void (*DeleteUserDataFunc)(void*);
+
+typedef void (*ObjectDestructor)(void*);
+
+typedef void (*SubTypeInitHook)(SbkObjectType*, PyObject*, PyObject*);
+
+extern LIBSHIBOKEN_API PyTypeObject SbkObjectType_Type;
+extern LIBSHIBOKEN_API SbkObjectType SbkObject_Type;
+
+
+struct SbkObjectTypePrivate;
+/// PyTypeObject extended with C++ multiple inheritance information.
+struct LIBSHIBOKEN_API SbkObjectType
+{
+ PyHeapTypeObject super;
+ SbkObjectTypePrivate* d;
+};
+
+LIBSHIBOKEN_API PyObject* SbkObjectTpNew(PyTypeObject* subtype, PyObject*, PyObject*);
+
+} // extern "C"
+
+namespace Shiboken
+{
+
+/**
+* Init shiboken library.
+*/
+LIBSHIBOKEN_API void init();
+
+
+/// Delete the class T allocated on \p cptr.
+template<typename T>
+void callCppDestructor(void* cptr)
+{
+ delete reinterpret_cast<T*>(cptr);
+}
+
+/**
+ * Shiboken::importModule is DEPRECATED. Use Shiboken::Module::import() instead.
+ */
+SBK_DEPRECATED(LIBSHIBOKEN_API bool importModule(const char* moduleName, PyTypeObject*** cppApiPtr));
+LIBSHIBOKEN_API void setErrorAboutWrongArguments(PyObject* args, const char* funcName, const char** cppOverloads);
+
+namespace ObjectType {
+
+/**
+* Returns true if the object is an instance of a type created by the Shiboken generator.
+*/
+LIBSHIBOKEN_API bool checkType(PyTypeObject* pyObj);
+
+/**
+* Returns true if this object is an instance of an user defined type derived from an Shiboken type.
+*/
+LIBSHIBOKEN_API bool isUserType(PyTypeObject* pyObj);
+
+/**
+* Returns true if the constructor of \p ctorType can be called for a instance of type \p myType.
+* \note This function set a python error when returning false.
+*/
+LIBSHIBOKEN_API bool canCallConstructor(PyTypeObject* myType, PyTypeObject* ctorType);
+
+
+LIBSHIBOKEN_API bool hasExternalCppConversions(SbkObjectType*); // DEPRECATED.
+LIBSHIBOKEN_API bool isExternalConvertible(SbkObjectType*, PyObject*); // DEPRECATED.
+LIBSHIBOKEN_API void setExternalCppConversionFunction(SbkObjectType*, ExtendedToCppFunc); // DEPRECATED.
+LIBSHIBOKEN_API void setExternalIsConvertibleFunction(SbkObjectType*, ExtendedIsConvertibleFunc); // DEPRECATED.
+LIBSHIBOKEN_API void* callExternalCppConversion(SbkObjectType*, PyObject*); // DEPRECATED.
+
+
+/**
+ * Tells if the \p type represents an object of a class with multiple inheritance in C++.
+ * When this occurs, the C++ pointer held by the Python wrapper will need to be cast when
+ * passed as a parameter that expects a type of its ancestry.
+ * \returns true if a call to ObjectType::cast() is needed to obtain the correct
+ * C++ pointer for Python objects of type \p type.
+ */
+LIBSHIBOKEN_API bool hasCast(SbkObjectType* type);
+/**
+ * Cast the C++ pointer held by a Python object \p obj of type \p sourceType,
+ * to a C++ pointer of a C++ class indicated by type \p targetType.
+ * \returns The cast C++ pointer.
+ */
+LIBSHIBOKEN_API void* cast(SbkObjectType* sourceType, SbkObject* obj, PyTypeObject* targetType);
+/// Set the C++ cast function for \p type.
+LIBSHIBOKEN_API void setCastFunction(SbkObjectType* type, SpecialCastFunction func);
+
+LIBSHIBOKEN_API void setOriginalName(SbkObjectType* self, const char* name);
+LIBSHIBOKEN_API const char* getOriginalName(SbkObjectType* self);
+
+LIBSHIBOKEN_API void setTypeDiscoveryFunctionV2(SbkObjectType* self, TypeDiscoveryFuncV2 func);
+LIBSHIBOKEN_API SBK_DEPRECATED(void setTypeDiscoveryFunction(SbkObjectType* self, TypeDiscoveryFunc func));
+LIBSHIBOKEN_API SBK_DEPRECATED(TypeDiscoveryFunc getTypeDiscoveryFunction(SbkObjectType* self));
+
+LIBSHIBOKEN_API void copyMultimpleheritance(SbkObjectType* self, SbkObjectType* other);
+LIBSHIBOKEN_API void setMultipleIheritanceFunction(SbkObjectType* self, MultipleInheritanceInitFunction func);
+LIBSHIBOKEN_API MultipleInheritanceInitFunction getMultipleIheritanceFunction(SbkObjectType* self);
+
+LIBSHIBOKEN_API void setDestructorFunction(SbkObjectType* self, ObjectDestructor func);
+
+LIBSHIBOKEN_API void initPrivateData(SbkObjectType* self);
+
+/**
+ * Initializes a Shiboken wrapper type and adds it to the module,
+ * or to the enclosing class if the type is an inner class.
+ * This function also calls initPrivateData and setDestructorFunction.
+ * \param enclosingObject The module or enclosing class to where the new \p type will be added.
+ * \param typeName Name by which the type will be known in Python.
+ * \param originalName Original C++ name of the type.
+ * \param type The new type to be initialized and added to the module.
+ * \param cppObjDtor Memory deallocation function for the C++ object held by \p type.
+ * Should not be used if the underlying C++ class has a private destructor.
+ * \param baseType Base type from whom the new \p type inherits.
+ * \param baseTypes Other base types from whom the new \p type inherits.
+ * \param isInnerClass Tells if the new \p type is an inner class (the default is that it isn't).
+ * If false then the \p enclosingObject is a module, otherwise it is another
+ * wrapper type.
+ * \returns true if the initialization went fine, false otherwise.
+ */
+LIBSHIBOKEN_API bool introduceWrapperType(PyObject* enclosingObject,
+ const char* typeName, const char* originalName,
+ SbkObjectType* type, ObjectDestructor cppObjDtor = 0,
+ SbkObjectType* baseType = 0, PyObject* baseTypes = 0,
+ bool isInnerClass = false);
+
+/**
+ * Set the subtype init hook for a type.
+ *
+ * This hook will be invoked every time the user creates a sub-type inherited from a Shiboken based type.
+ * The hook gets 3 params, they are: The new type being created, args and kwds. The last two are the very
+ * same got from tp_new.
+ */
+LIBSHIBOKEN_API void setSubTypeInitHook(SbkObjectType* self, SubTypeInitHook func);
+
+/**
+ * Get the user data previously set by Shiboken::Object::setTypeUserData
+ */
+LIBSHIBOKEN_API void* getTypeUserData(SbkObjectType* self);
+LIBSHIBOKEN_API void setTypeUserData(SbkObjectType* self, void* userData, DeleteUserDataFunc d_func);
+
+}
+
+namespace Object {
+
+/**
+ * Returns a string with information about the internal state of the instance object, useful for debug purposes.
+ */
+LIBSHIBOKEN_API std::string info(SbkObject* self);
+
+/**
+* Returns true if the object is an instance of a type created by the Shiboken generator.
+*/
+LIBSHIBOKEN_API bool checkType(PyObject* pyObj);
+
+/**
+ * Returns true if this object type is an instance of an user defined type derived from an Shiboken type.
+ * \see Shiboken::ObjectType::isUserType
+ */
+LIBSHIBOKEN_API bool isUserType(PyObject* pyObj);
+
+/**
+ * Generic function used to make ObjectType hashable, the C++ pointer is used as hash value.
+ */
+LIBSHIBOKEN_API Py_hash_t hash(PyObject* pyObj);
+
+/**
+ * Find a child of given wrapper having same address having the specified type.
+ */
+LIBSHIBOKEN_API SbkObject *findColocatedChild(SbkObject *wrapper,
+ const SbkObjectType *instanceType);
+
+/**
+ * Bind a C++ object to Python.
+ * \param instanceType equivalent Python type for the C++ object.
+ * \param hasOwnership if true, Python will try to delete the underlying C++ object when there's no more refs.
+ * \param isExactType if false, Shiboken will use some heuristics to detect the correct Python type of this C++
+ * object, in any case you must provide \p instanceType, it'll be used as search starting point
+ * and as fallback.
+ * \param typeName If non-null, this will be used as helper to find the correct Python type for this object.
+ */
+LIBSHIBOKEN_API PyObject* newObject(SbkObjectType* instanceType,
+ void* cptr,
+ bool hasOwnership = true,
+ bool isExactType = false,
+ const char* typeName = 0);
+
+/**
+ * Changes the valid flag of a PyObject, invalid objects will raise an exception when someone tries to access it.
+ */
+LIBSHIBOKEN_API void setValidCpp(SbkObject* pyObj, bool value);
+/**
+ * Tells shiboken the Python object \p pyObj has a C++ wrapper used to intercept virtual method calls.
+ */
+LIBSHIBOKEN_API void setHasCppWrapper(SbkObject* pyObj, bool value);
+/**
+ * Return true if the Python object \p pyObj has a C++ wrapper used to intercept virtual method calls.
+ */
+LIBSHIBOKEN_API bool hasCppWrapper(SbkObject* pyObj);
+
+/**
+ * Return true if the Python object was created by Python, false otherwise.
+ * \note This function was added to libshiboken only to be used by shiboken.wasCreatedByPython()
+ */
+LIBSHIBOKEN_API bool wasCreatedByPython(SbkObject* pyObj);
+
+/**
+ * Call the C++ object destructor and invalidates the Python object.
+ * \note This function was added to libshiboken only to be used by shiboken.delete()
+ */
+LIBSHIBOKEN_API void callCppDestructors(SbkObject* pyObj);
+
+/**
+ * Return true if the Python is responsible for deleting the underlying C++ object.
+ */
+LIBSHIBOKEN_API bool hasOwnership(SbkObject* pyObj);
+
+/**
+ * Sets python as responsible to delete the underlying C++ object.
+ * \note You this overload only when the PyObject can be a sequence and you want to
+ * call this function for every item in the sequence.
+ * \see getOwnership(SbkObject*)
+ */
+LIBSHIBOKEN_API void getOwnership(PyObject* pyObj);
+
+/**
+ * Sets python as responsible to delete the underlying C++ object.
+ */
+LIBSHIBOKEN_API void getOwnership(SbkObject* pyObj);
+
+/**
+ * Release the ownership, so Python will not delete the underlying C++ object.
+ * \note You this overload only when the PyObject can be a sequence and you want to
+ * call this function for every item in the sequence.
+ * \see releaseOwnership(SbkObject*)
+ */
+LIBSHIBOKEN_API void releaseOwnership(PyObject* pyObj);
+/**
+ * Release the ownership, so Python will not delete the underlying C++ object.
+ */
+LIBSHIBOKEN_API void releaseOwnership(SbkObject* pyObj);
+
+/**
+ * Returns true if the pyObj holds information about their parents.
+ */
+LIBSHIBOKEN_API bool hasParentInfo(SbkObject* pyObj);
+
+/**
+ * Get the C++ pointer of type \p desiredType from a Python object.
+ */
+LIBSHIBOKEN_API void* cppPointer(SbkObject* pyObj, PyTypeObject* desiredType);
+
+/**
+ * Return a list with all C++ pointers held from a Python object.
+ * \note This function was added to libshiboken only to be used by shiboken.getCppPointer()
+ */
+LIBSHIBOKEN_API std::vector<void*> cppPointers(SbkObject* pyObj);
+
+/**
+ * Set the C++ pointer of type \p desiredType of a Python object.
+ */
+LIBSHIBOKEN_API bool setCppPointer(SbkObject* sbkObj, PyTypeObject* desiredType, void* cptr);
+
+/**
+ * Returns false and sets a Python RuntimeError if the Python wrapper is not marked as valid.
+ */
+LIBSHIBOKEN_API bool isValid(PyObject* pyObj);
+
+/**
+ * Returns false if the Python wrapper is not marked as valid.
+ * \param pyObj the object.
+ * \param throwPyError sets a Python RuntimeError when the object isn't valid.
+ */
+LIBSHIBOKEN_API bool isValid(SbkObject* pyObj, bool throwPyError = true);
+
+/**
+ * Returns false if the Python wrapper is not marked as valid.
+ * \param pyObj the object.
+ * \param throwPyError sets a Python RuntimeError when the object isn't valid.
+ */
+LIBSHIBOKEN_API bool isValid(PyObject* pyObj, bool throwPyError);
+
+/**
+* Set the parent of \p child to \p parent.
+* When an object dies, all their children, grandchildren, etc, are tagged as invalid.
+* \param parent the parent object, if null, the child will have no parents.
+* \param child the child.
+*/
+LIBSHIBOKEN_API void setParent(PyObject* parent, PyObject* child);
+
+/**
+* Remove this child from their parent, if any.
+* \param child the child.
+*/
+LIBSHIBOKEN_API void removeParent(SbkObject* child, bool giveOwnershipBack = true, bool keepReferenc = false);
+
+/**
+* \internal This is an internal function called by tp_dealloc, it's exported just for technical reasons.
+* \note Do not call this function inside your bindings.
+*/
+LIBSHIBOKEN_API void destroyParentInfo(SbkObject* obj, bool removeFromParent = true);
+
+/**
+ * Mark the object as invalid
+ */
+LIBSHIBOKEN_API void invalidate(SbkObject* self);
+
+/**
+ * Help function can be used to invalidate a sequence of object
+ **/
+LIBSHIBOKEN_API void invalidate(PyObject* pyobj);
+
+/**
+ * Make the object valid again
+ */
+LIBSHIBOKEN_API void makeValid(SbkObject* self);
+
+/// \deprecated Use destroy(SbkObject*, void*)
+SBK_DEPRECATED(LIBSHIBOKEN_API void destroy(SbkObject* self));
+
+/**
+ * Destroy any data in Shiboken structure and c++ pointer if the pyboject has the ownership
+ */
+LIBSHIBOKEN_API void destroy(SbkObject* self, void* cppData);
+
+/**
+ * Set user data on type of \p wrapper.
+ * \param wrapper instance object, the user data will be set on his type
+ * \param userData the user data
+ * \param d_func a function used to delete the user data
+ */
+LIBSHIBOKEN_API void setTypeUserData(SbkObject* wrapper, void* userData, DeleteUserDataFunc d_func);
+/**
+ * Get the user data previously set by Shiboken::Object::setTypeUserData
+ */
+LIBSHIBOKEN_API void* getTypeUserData(SbkObject* wrapper);
+
+/**
+ * Increments the reference count of the referred Python object.
+ * A previous Python object in the same position identified by the 'key' parameter
+ * will have its reference counter decremented automatically when replaced.
+ * All the kept references should be decremented when the Python wrapper indicated by
+ * 'self' dies.
+ * No checking is done for any of the passed arguments, since it is meant to be used
+ * by generated code it is supposed that the generator is correct.
+ * \param self the wrapper instance that keeps references to other objects.
+ * \param key a key that identifies the C++ method signature and argument where the referred Object came from.
+ * \param referredObject the object whose reference is used by the self object.
+ */
+LIBSHIBOKEN_API void keepReference(SbkObject* self, const char* key, PyObject* referredObject, bool append = false);
+
+/**
+ * Removes any reference previously added by keepReference function
+ * \param self the wrapper instance that keeps references to other objects.
+ * \param key a key that identifies the C++ method signature and argument from where the referred Object came.
+ * \param referredObject the object whose reference is used by the self object.
+ */
+LIBSHIBOKEN_API void removeReference(SbkObject* self, const char* key, PyObject* referredObject);
+
+} // namespace Object
+
+} // namespace Shiboken
+
+#endif // BASEWRAPPER_H
diff --git a/sources/shiboken2/libshiboken/basewrapper_p.h b/sources/shiboken2/libshiboken/basewrapper_p.h
new file mode 100644
index 000000000..129322246
--- /dev/null
+++ b/sources/shiboken2/libshiboken/basewrapper_p.h
@@ -0,0 +1,287 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 BASEWRAPPER_P_H
+#define BASEWRAPPER_P_H
+
+#include "sbkpython.h"
+#include "basewrapper.h"
+
+#include <list>
+#include <map>
+#include <set>
+#include <string>
+
+struct SbkObject;
+struct SbkObjectType;
+struct SbkConverter;
+
+namespace Shiboken
+{
+/**
+ * This mapping associates a method and argument of an wrapper object with the wrapper of
+ * said argument when it needs the binding to help manage its reference count.
+ */
+typedef std::map<std::string, std::list<PyObject*> > RefCountMap;
+
+/// Linked list of SbkBaseWrapper pointers
+typedef std::set<SbkObject*> ChildrenList;
+
+/// Structure used to store information about object parent and children.
+struct ParentInfo
+{
+ /// Default ctor.
+ ParentInfo() : parent(0), hasWrapperRef(false) {}
+ /// Pointer to parent object.
+ SbkObject* parent;
+ /// List of object children.
+ ChildrenList children;
+ /// has internal ref
+ bool hasWrapperRef;
+};
+
+} // namespace Shiboken
+
+extern "C"
+{
+
+/**
+ * \internal
+ * Private data for SbkBaseWrapper
+ */
+struct SbkObjectPrivate
+{
+ /// Pointer to the C++ class.
+ void** cptr;
+ /// True when Python is responsible for freeing the used memory.
+ unsigned int hasOwnership : 1;
+ /// This is true when the C++ class of the wrapped object has a virtual destructor AND was created by Python.
+ unsigned int containsCppWrapper : 1;
+ /// Marked as false when the object is lost to C++ and the binding can not know if it was deleted or not.
+ unsigned int validCppObject : 1;
+ /// Marked as true when the object constructor was called
+ unsigned int cppObjectCreated : 1;
+ /// Information about the object parents and children, may be null.
+ Shiboken::ParentInfo* parentInfo;
+ /// Manage reference count of objects that are referred to but not owned from.
+ Shiboken::RefCountMap* referredObjects;
+
+ ~SbkObjectPrivate()
+ {
+ delete parentInfo;
+ parentInfo = 0;
+ delete referredObjects;
+ referredObjects = 0;
+ }
+};
+
+// TODO-CONVERTERS: to be deprecated/removed
+/// The type behaviour was not defined yet
+#define BEHAVIOUR_UNDEFINED 0
+/// The type is a value type
+#define BEHAVIOUR_VALUETYPE 1
+/// The type is an object type
+#define BEHAVIOUR_OBJECTTYPE 2
+
+struct SbkObjectTypePrivate
+{
+ SbkConverter* converter;
+ int* mi_offsets;
+ MultipleInheritanceInitFunction mi_init;
+
+ /// Special cast function, null if this class doesn't have multiple inheritance.
+ SpecialCastFunction mi_specialcast;
+ TypeDiscoveryFuncV2 type_discovery;
+ /// Pointer to a function responsible for deletion of the C++ instance calling the proper destructor.
+ ObjectDestructor cpp_dtor;
+ /// True if this type holds two or more C++ instances, e.g.: a Python class which inherits from two C++ classes.
+ int is_multicpp : 1;
+ /// True if this type was defined by the user.
+ int is_user_type : 1;
+ /// Tells is the type is a value type or an object-type, see BEHAVIOUR_* constants.
+ // TODO-CONVERTERS: to be deprecated/removed
+ int type_behaviour : 2;
+ /// C++ name
+ char* original_name;
+ /// Type user data
+ void* user_data;
+ DeleteUserDataFunc d_func;
+ void (*subtype_init)(SbkObjectType*, PyObject*, PyObject*);
+};
+
+
+} // extern "C"
+
+namespace Shiboken
+{
+/**
+ * Utility function used to transform a PyObject that implements sequence protocol into a std::list.
+ **/
+std::list<SbkObject*> splitPyObject(PyObject* pyObj);
+
+/**
+* Visitor class used by walkOnClassHierarchy function.
+*/
+class HierarchyVisitor
+{
+public:
+ HierarchyVisitor() : m_wasFinished(false) {}
+ virtual ~HierarchyVisitor() {}
+ virtual void visit(SbkObjectType* node) = 0;
+ virtual void done() {}
+ void finish() { m_wasFinished = true; };
+ bool wasFinished() const { return m_wasFinished; }
+private:
+ bool m_wasFinished;
+};
+
+class BaseCountVisitor : public HierarchyVisitor
+{
+public:
+ BaseCountVisitor() : m_count(0) {}
+
+ void visit(SbkObjectType*)
+ {
+ m_count++;
+ }
+
+ int count() const { return m_count; }
+private:
+ int m_count;
+};
+
+class BaseAccumulatorVisitor : public HierarchyVisitor
+{
+public:
+ BaseAccumulatorVisitor() {}
+
+ void visit(SbkObjectType* node)
+ {
+ m_bases.push_back(node);
+ }
+
+ std::list<SbkObjectType*> bases() const { return m_bases; }
+private:
+ std::list<SbkObjectType*> m_bases;
+};
+
+class GetIndexVisitor : public HierarchyVisitor
+{
+public:
+ GetIndexVisitor(PyTypeObject* desiredType) : m_index(-1), m_desiredType(desiredType) {}
+ virtual void visit(SbkObjectType* node)
+ {
+ m_index++;
+ if (PyType_IsSubtype(reinterpret_cast<PyTypeObject*>(node), m_desiredType))
+ finish();
+ }
+ int index() const { return m_index; }
+
+private:
+ int m_index;
+ PyTypeObject* m_desiredType;
+};
+
+/// Call the destructor of each C++ object held by a Python object
+class DtorCallerVisitor : public HierarchyVisitor
+{
+public:
+ DtorCallerVisitor(SbkObject* pyObj) : m_pyObj(pyObj) {}
+ void visit(SbkObjectType* node);
+ void done();
+protected:
+ std::list<std::pair<void*, SbkObjectType*> > m_ptrs;
+ SbkObject* m_pyObj;
+};
+
+/// Dealloc of each C++ object held by a Python object, this implies a call to the C++ object destructor
+class DeallocVisitor : public DtorCallerVisitor
+{
+public:
+ DeallocVisitor(SbkObject* pyObj) : DtorCallerVisitor(pyObj) {}
+ void done();
+};
+
+/// \internal Internal function used to walk on classes inheritance trees.
+/**
+* Walk on class hierarchy using a DFS algorithm.
+* For each pure Shiboken type found, HiearchyVisitor::visit is called and the algorithm consider
+* all children of this type as visited.
+*/
+void walkThroughClassHierarchy(PyTypeObject* currentType, HierarchyVisitor* visitor);
+
+inline int getTypeIndexOnHierarchy(PyTypeObject* baseType, PyTypeObject* desiredType)
+{
+ GetIndexVisitor visitor(desiredType);
+ walkThroughClassHierarchy(baseType, &visitor);
+ return visitor.index();
+}
+
+inline int getNumberOfCppBaseClasses(PyTypeObject* baseType)
+{
+ BaseCountVisitor visitor;
+ walkThroughClassHierarchy(baseType, &visitor);
+ return visitor.count();
+}
+
+inline std::list<SbkObjectType*> getCppBaseClasses(PyTypeObject* baseType)
+{
+ BaseAccumulatorVisitor visitor;
+ walkThroughClassHierarchy(baseType, &visitor);
+ return visitor.bases();
+}
+
+namespace Object
+{
+/**
+* Decrements the reference counters of every object referred by self.
+* \param self the wrapper instance that keeps references to other objects.
+*/
+void clearReferences(SbkObject* self);
+
+/**
+ * Destroy internal data
+ **/
+void deallocData(SbkObject* self, bool doCleanup);
+
+} // namespace Object
+
+} // namespace Shiboken
+
+#endif
diff --git a/sources/shiboken2/libshiboken/bindingmanager.cpp b/sources/shiboken2/libshiboken/bindingmanager.cpp
new file mode 100644
index 000000000..d7e122cd7
--- /dev/null
+++ b/sources/shiboken2/libshiboken/bindingmanager.cpp
@@ -0,0 +1,344 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "basewrapper.h"
+#include "basewrapper_p.h"
+#include "bindingmanager.h"
+#include "google/dense_hash_map"
+#include "sbkdbg.h"
+#include "gilstate.h"
+#include "sbkstring.h"
+#include "debugfreehook.h"
+
+#include <cstddef>
+#include <fstream>
+
+namespace Shiboken
+{
+
+typedef google::dense_hash_map<const void*, SbkObject*> WrapperMap;
+
+class Graph
+{
+public:
+ typedef std::list<SbkObjectType*> NodeList;
+ typedef google::dense_hash_map<SbkObjectType*, NodeList> Edges;
+
+ Edges m_edges;
+
+ Graph()
+ {
+ m_edges.set_empty_key(0);
+ }
+
+ void addEdge(SbkObjectType* from, SbkObjectType* to)
+ {
+ m_edges[from].push_back(to);
+ }
+
+#ifndef NDEBUG
+ void dumpDotGraph()
+ {
+ std::ofstream file("/tmp/shiboken_graph.dot");
+
+ file << "digraph D {\n";
+
+ Edges::const_iterator i = m_edges.begin();
+ for (; i != m_edges.end(); ++i) {
+ SbkObjectType* node1 = i->first;
+ const NodeList& nodeList = i->second;
+ NodeList::const_iterator j = nodeList.begin();
+ for (; j != nodeList.end(); ++j)
+ file << '"' << (*j)->super.ht_type.tp_name << "\" -> \"" << node1->super.ht_type.tp_name << "\"\n";
+ }
+ file << "}\n";
+ }
+#endif
+
+ SbkObjectType* identifyType(void** cptr, SbkObjectType* type, SbkObjectType* baseType) const
+ {
+ Edges::const_iterator edgesIt = m_edges.find(type);
+ if (edgesIt != m_edges.end()) {
+ const NodeList& adjNodes = m_edges.find(type)->second;
+ NodeList::const_iterator i = adjNodes.begin();
+ for (; i != adjNodes.end(); ++i) {
+ SbkObjectType* newType = identifyType(cptr, *i, baseType);
+ if (newType)
+ return newType;
+ }
+ }
+ void* typeFound = ((type->d && type->d->type_discovery) ? type->d->type_discovery(*cptr, baseType) : 0);
+ if (typeFound) {
+ // This "typeFound != type" is needed for backwards compatibility with old modules using a newer version of
+ // libshiboken because old versions of type_discovery function used to return a SbkObjectType* instead of
+ // a possible variation of the C++ instance pointer (*cptr).
+ if (typeFound != type)
+ *cptr = typeFound;
+ return type;
+ } else {
+ return 0;
+ }
+ }
+};
+
+
+#ifndef NDEBUG
+static void showWrapperMap(const WrapperMap& wrapperMap)
+{
+ if (Py_VerboseFlag > 0) {
+ fprintf(stderr, "-------------------------------\n");
+ fprintf(stderr, "WrapperMap: %p (size: %d)\n", &wrapperMap, (int) wrapperMap.size());
+ WrapperMap::const_iterator iter;
+ for (iter = wrapperMap.begin(); iter != wrapperMap.end(); ++iter) {
+ const SbkObject *sbkObj = iter->second;
+ fprintf(stderr, "key: %p, value: %p (%s, refcnt: %d)\n", iter->first,
+ static_cast<const void *>(sbkObj),
+ Py_TYPE(sbkObj)->tp_name,
+ int(reinterpret_cast<const PyObject *>(sbkObj)->ob_refcnt));
+ }
+ fprintf(stderr, "-------------------------------\n");
+ }
+}
+#endif
+
+struct BindingManager::BindingManagerPrivate {
+ WrapperMap wrapperMapper;
+ Graph classHierarchy;
+ bool destroying;
+
+ BindingManagerPrivate() : destroying(false) {}
+ bool releaseWrapper(void* cptr, SbkObject* wrapper);
+ void assignWrapper(SbkObject* wrapper, const void* cptr);
+
+};
+
+bool BindingManager::BindingManagerPrivate::releaseWrapper(void* cptr, SbkObject* wrapper)
+{
+ // The wrapper argument is checked to ensure that the correct wrapper is released.
+ // Returns true if the correct wrapper is found and released.
+ // If wrapper argument is NULL, no such check is performed.
+ WrapperMap::iterator iter = wrapperMapper.find(cptr);
+ if (iter != wrapperMapper.end() && (wrapper == 0 || iter->second == wrapper)) {
+ wrapperMapper.erase(iter);
+ return true;
+ }
+ return false;
+}
+
+void BindingManager::BindingManagerPrivate::assignWrapper(SbkObject* wrapper, const void* cptr)
+{
+ assert(cptr);
+ WrapperMap::iterator iter = wrapperMapper.find(cptr);
+ if (iter == wrapperMapper.end())
+ wrapperMapper.insert(std::make_pair(cptr, wrapper));
+}
+
+BindingManager::BindingManager()
+{
+ m_d = new BindingManager::BindingManagerPrivate;
+ m_d->wrapperMapper.set_empty_key((WrapperMap::key_type)0);
+ m_d->wrapperMapper.set_deleted_key((WrapperMap::key_type)1);
+
+#ifdef SHIBOKEN_INSTALL_FREE_DEBUG_HOOK
+ debugInstallFreeHook();
+#endif
+}
+
+BindingManager::~BindingManager()
+{
+#ifdef SHIBOKEN_INSTALL_FREE_DEBUG_HOOK
+ debugRemoveFreeHook();
+#endif
+#ifndef NDEBUG
+ showWrapperMap(m_d->wrapperMapper);
+#endif
+ /* Cleanup hanging references. We just invalidate them as when
+ * the BindingManager is being destroyed the interpreter is alredy
+ * shutting down. */
+ if (Py_IsInitialized()) { // ensure the interpreter is still valid
+ while (!m_d->wrapperMapper.empty()) {
+ Object::destroy(m_d->wrapperMapper.begin()->second, const_cast<void*>(m_d->wrapperMapper.begin()->first));
+ }
+ assert(m_d->wrapperMapper.size() == 0);
+ }
+ delete m_d;
+}
+
+BindingManager& BindingManager::instance() {
+ static BindingManager singleton;
+ return singleton;
+}
+
+bool BindingManager::hasWrapper(const void* cptr)
+{
+ return m_d->wrapperMapper.find(cptr) != m_d->wrapperMapper.end();
+}
+
+void BindingManager::registerWrapper(SbkObject* pyObj, void* cptr)
+{
+ SbkObjectType* instanceType = reinterpret_cast<SbkObjectType*>(Py_TYPE(pyObj));
+ SbkObjectTypePrivate* d = instanceType->d;
+
+ if (!d)
+ return;
+
+ if (d->mi_init && !d->mi_offsets)
+ d->mi_offsets = d->mi_init(cptr);
+ m_d->assignWrapper(pyObj, cptr);
+ if (d->mi_offsets) {
+ int* offset = d->mi_offsets;
+ while (*offset != -1) {
+ if (*offset > 0)
+ m_d->assignWrapper(pyObj, reinterpret_cast<void*>((std::size_t) cptr + (*offset)));
+ offset++;
+ }
+ }
+}
+
+void BindingManager::releaseWrapper(SbkObject* sbkObj)
+{
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(Py_TYPE(sbkObj));
+ SbkObjectTypePrivate* d = sbkType->d;
+ int numBases = ((d && d->is_multicpp) ? getNumberOfCppBaseClasses(Py_TYPE(sbkObj)) : 1);
+
+ void** cptrs = reinterpret_cast<SbkObject*>(sbkObj)->d->cptr;
+ for (int i = 0; i < numBases; ++i) {
+ unsigned char *cptr = reinterpret_cast<unsigned char *>(cptrs[i]);
+ m_d->releaseWrapper(cptr, sbkObj);
+ if (d && d->mi_offsets) {
+ int* offset = d->mi_offsets;
+ while (*offset != -1) {
+ if (*offset > 0)
+ m_d->releaseWrapper(reinterpret_cast<void *>((std::size_t) cptr + (*offset)), sbkObj);
+ offset++;
+ }
+ }
+ }
+ sbkObj->d->validCppObject = false;
+}
+
+SbkObject* BindingManager::retrieveWrapper(const void* cptr)
+{
+ WrapperMap::iterator iter = m_d->wrapperMapper.find(cptr);
+ if (iter == m_d->wrapperMapper.end())
+ return 0;
+ return iter->second;
+}
+
+PyObject* BindingManager::getOverride(const void* cptr, const char* methodName)
+{
+ SbkObject* wrapper = retrieveWrapper(cptr);
+ // The refcount can be 0 if the object is dieing and someone called
+ // a virtual method from the destructor
+ if (!wrapper || reinterpret_cast<const PyObject *>(wrapper)->ob_refcnt == 0)
+ return 0;
+
+ if (wrapper->ob_dict) {
+ PyObject* method = PyDict_GetItemString(wrapper->ob_dict, methodName);
+ if (method) {
+ Py_INCREF(reinterpret_cast<PyObject *>(method));
+ return method;
+ }
+ }
+
+ PyObject* pyMethodName = Shiboken::String::fromCString(methodName);
+ PyObject *method = PyObject_GetAttr(reinterpret_cast<PyObject *>(wrapper), pyMethodName);
+
+ if (method && PyMethod_Check(method)
+ && reinterpret_cast<PyMethodObject*>(method)->im_self == reinterpret_cast<PyObject*>(wrapper)) {
+ PyObject* defaultMethod;
+ PyObject* mro = Py_TYPE(wrapper)->tp_mro;
+
+ // The first class in the mro (index 0) is the class being checked and it should not be tested.
+ // The last class in the mro (size - 1) is the base Python object class which should not be tested also.
+ for (int i = 1; i < PyTuple_GET_SIZE(mro) - 1; i++) {
+ PyTypeObject* parent = reinterpret_cast<PyTypeObject*>(PyTuple_GET_ITEM(mro, i));
+ if (parent->tp_dict) {
+ defaultMethod = PyDict_GetItem(parent->tp_dict, pyMethodName);
+ if (defaultMethod && reinterpret_cast<PyMethodObject*>(method)->im_func != defaultMethod) {
+ Py_DECREF(pyMethodName);
+ return method;
+ }
+ }
+ }
+ }
+
+ Py_XDECREF(method);
+ Py_DECREF(pyMethodName);
+ return 0;
+}
+
+void BindingManager::addClassInheritance(SbkObjectType* parent, SbkObjectType* child)
+{
+ m_d->classHierarchy.addEdge(parent, child);
+}
+
+SbkObjectType* BindingManager::resolveType(void* cptr, SbkObjectType* type)
+{
+ return resolveType(&cptr, type);
+}
+
+SbkObjectType* BindingManager::resolveType(void** cptr, SbkObjectType* type)
+{
+ SbkObjectType* identifiedType = m_d->classHierarchy.identifyType(cptr, type, type);
+ return identifiedType ? identifiedType : type;
+}
+
+std::set<PyObject*> BindingManager::getAllPyObjects()
+{
+ std::set<PyObject*> pyObjects;
+ const WrapperMap& wrappersMap = m_d->wrapperMapper;
+ WrapperMap::const_iterator it = wrappersMap.begin();
+ for (; it != wrappersMap.end(); ++it)
+ pyObjects.insert(reinterpret_cast<PyObject*>(it->second));
+
+ return pyObjects;
+}
+
+void BindingManager::visitAllPyObjects(ObjectVisitor visitor, void* data)
+{
+ WrapperMap copy = m_d->wrapperMapper;
+ for (WrapperMap::iterator it = copy.begin(); it != copy.end(); ++it) {
+ if (hasWrapper(it->first))
+ visitor(it->second, data);
+ }
+}
+
+} // namespace Shiboken
+
diff --git a/sources/shiboken2/libshiboken/bindingmanager.h b/sources/shiboken2/libshiboken/bindingmanager.h
new file mode 100644
index 000000000..80c5add2f
--- /dev/null
+++ b/sources/shiboken2/libshiboken/bindingmanager.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 BINDINGMANAGER_H
+#define BINDINGMANAGER_H
+
+#include "sbkpython.h"
+#include <set>
+#include "shibokenmacros.h"
+
+struct SbkObject;
+struct SbkObjectType;
+
+namespace Shiboken
+{
+
+typedef void (*ObjectVisitor)(SbkObject*, void*);
+
+class LIBSHIBOKEN_API BindingManager
+{
+public:
+ static BindingManager& instance();
+
+ bool hasWrapper(const void *cptr);
+
+ void registerWrapper(SbkObject* pyObj, void* cptr);
+ void releaseWrapper(SbkObject* wrapper);
+
+ SbkObject* retrieveWrapper(const void* cptr);
+ PyObject* getOverride(const void* cptr, const char* methodName);
+
+ void addClassInheritance(SbkObjectType* parent, SbkObjectType* child);
+ /**
+ * \deprecated Use \fn resolveType(void**, SbkObjectType*), this version is broken when used with multiple inheritance
+ * because the \p cptr pointer of the discovered type may be different of the given \p cptr in case
+ * of multiple inheritance
+ */
+ SBK_DEPRECATED(SbkObjectType* resolveType(void* cptr, SbkObjectType* type));
+ /**
+ * Try to find the correct type of *cptr knowing that it's at least of type \p type.
+ * In case of multiple inheritance this function may change the contents of cptr.
+ * \param cptr a pointer to a pointer to the instance of type \p type
+ * \param type type of *cptr
+ * \warning This function is slow, use it only as last resort.
+ */
+ SbkObjectType* resolveType(void** cptr, SbkObjectType* type);
+
+ std::set<PyObject*> getAllPyObjects();
+
+ /**
+ * Calls the function \p visitor for each object registered on binding manager.
+ * \note As various C++ pointers can point to the same PyObject due to multiple inheritance
+ * a PyObject can be called more than one time for each PyObject.
+ * \param visitor function called for each object.
+ * \param data user data passed as second argument to the visitor function.
+ */
+ void visitAllPyObjects(ObjectVisitor visitor, void* data);
+
+private:
+ ~BindingManager();
+ // disable copy
+ BindingManager();
+ BindingManager(const BindingManager&);
+ BindingManager& operator=(const BindingManager&);
+
+ struct BindingManagerPrivate;
+ BindingManagerPrivate* m_d;
+};
+
+} // namespace Shiboken
+
+#endif // BINDINGMANAGER_H
+
diff --git a/sources/shiboken2/libshiboken/conversions.h b/sources/shiboken2/libshiboken/conversions.h
new file mode 100644
index 000000000..f0af2be8e
--- /dev/null
+++ b/sources/shiboken2/libshiboken/conversions.h
@@ -0,0 +1,731 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 CONVERSIONS_H
+#define CONVERSIONS_H
+
+#include "sbkpython.h"
+#include <limits>
+#include <typeinfo>
+
+#include "sbkstring.h"
+#include "sbkenum.h"
+#include "basewrapper.h"
+#include "bindingmanager.h"
+#include "sbkdbg.h"
+
+// When the user adds a function with an argument unknown for the typesystem, the generator writes type checks as
+// TYPENAME_Check, so this macro allows users to add PyObject arguments to their added functions.
+#define PyObject_Check(X) true
+#define SbkChar_Check(X) (SbkNumber_Check(X) || Shiboken::String::checkChar(X))
+#include "autodecref.h"
+
+namespace Shiboken
+{
+/**
+* This function template is used to get the PyTypeObject of a C++ type T.
+* All implementations should be provided by template specializations generated by the generator when
+* T isn't a C++ primitive type.
+* \see SpecialCastFunction
+*/
+template<typename T>
+PyTypeObject* SbkType()
+{
+ return 0;
+}
+
+template<> inline PyTypeObject* SbkType<int>() { return &PyInt_Type; }
+template<> inline PyTypeObject* SbkType<unsigned int>() { return &PyLong_Type; }
+template<> inline PyTypeObject* SbkType<short>() { return &PyInt_Type; }
+template<> inline PyTypeObject* SbkType<unsigned short>() { return &PyInt_Type; }
+template<> inline PyTypeObject* SbkType<long>() { return &PyLong_Type; }
+template<> inline PyTypeObject* SbkType<unsigned long>() { return &PyLong_Type; }
+template<> inline PyTypeObject* SbkType<PY_LONG_LONG>() { return &PyLong_Type; }
+template<> inline PyTypeObject* SbkType<unsigned PY_LONG_LONG>() { return &PyLong_Type; }
+template<> inline PyTypeObject* SbkType<bool>() { return &PyBool_Type; }
+template<> inline PyTypeObject* SbkType<float>() { return &PyFloat_Type; }
+template<> inline PyTypeObject* SbkType<double>() { return &PyFloat_Type; }
+template<> inline PyTypeObject* SbkType<char>() { return &PyInt_Type; }
+template<> inline PyTypeObject* SbkType<signed char>() { return &PyInt_Type; }
+template<> inline PyTypeObject* SbkType<unsigned char>() { return &PyInt_Type; }
+
+/**
+ * Convenience template to create wrappers using the proper Python type for a given C++ class instance.
+ */
+template<typename T>
+inline PyObject* createWrapper(const T* cppobj, bool hasOwnership = false, bool isExactType = false)
+{
+ const char* typeName = 0;
+ if (!isExactType)
+ typeName = typeid(*const_cast<T*>(cppobj)).name();
+ return Object::newObject(reinterpret_cast<SbkObjectType*>(SbkType<T>()),
+ const_cast<T*>(cppobj), hasOwnership, isExactType, typeName);
+}
+
+// Base Conversions ----------------------------------------------------------
+// The basic converter must be empty to avoid object types being converted by value.
+template <typename T> struct Converter {};
+
+// Pointer conversion specialization for value types.
+template <typename T>
+struct Converter<T*>
+{
+ static inline bool checkType(PyObject* pyObj)
+ {
+ return Converter<T>::checkType(pyObj);
+ }
+
+ static inline bool isConvertible(PyObject* pyObj)
+ {
+ return pyObj == Py_None || PyObject_TypeCheck(pyObj, SbkType<T>());
+ }
+
+ static PyObject* toPython(const T* cppobj)
+ {
+ if (!cppobj)
+ Py_RETURN_NONE;
+ PyObject* pyobj = reinterpret_cast<PyObject*>(BindingManager::instance().retrieveWrapper(cppobj));
+ if (pyobj)
+ Py_INCREF(pyobj);
+ else
+ pyobj = createWrapper<T>(cppobj);
+ return pyobj;
+ }
+
+ static T* toCpp(PyObject* pyobj)
+ {
+ if (PyObject_TypeCheck(pyobj, SbkType<T>()))
+ return reinterpret_cast<T *>(Object::cppPointer(reinterpret_cast<SbkObject *>(pyobj), SbkType<T>()));
+ else if (Converter<T>::isConvertible(pyobj))
+ return new T(Converter<T>::toCpp(pyobj));
+ else if (pyobj == Py_None)
+ return 0;
+
+ assert(false);
+ return 0;
+ }
+};
+template <typename T> struct Converter<const T*> : Converter<T*> {};
+
+// Specialization for reference conversions.
+template <typename T>
+struct Converter<T&>
+{
+ static inline bool checkType(PyObject* pyObj) { return Converter<T>::checkType(pyObj); }
+ static inline bool isConvertible(PyObject* pyObj) { return Converter<T>::isConvertible(pyObj); }
+ static inline PyObject* toPython(const T& cppobj) { return Converter<T*>::toPython(&cppobj); }
+ static inline T& toCpp(PyObject* pyobj) { return *Converter<T*>::toCpp(pyobj); }
+};
+
+// Void pointer conversions.
+template<>
+struct Converter<void*>
+{
+ static inline bool checkType(PyObject *) { return false; }
+ static inline bool isConvertible(PyObject *) { return true; }
+ static PyObject* toPython(void* cppobj)
+ {
+ if (!cppobj)
+ Py_RETURN_NONE;
+ PyObject *result = reinterpret_cast<PyObject *>(cppobj);
+ Py_INCREF(result);
+ return result;
+ }
+ static void* toCpp(PyObject* pyobj) { return pyobj; }
+};
+
+// Base converter meant to be inherited by converters for classes that could be
+// passed by value.
+// Example: "struct Converter<ValueTypeClass> : ValueTypeConverter<ValueTypeClass>"
+template <typename T>
+struct ValueTypeConverter
+{
+ static inline bool checkType(PyObject* pyObj) { return PyObject_TypeCheck(pyObj, SbkType<T>()); }
+
+ // The basic version of this method also tries to use the extended 'isConvertible' method.
+ static inline bool isConvertible(PyObject* pyobj)
+ {
+ if (PyObject_TypeCheck(pyobj, SbkType<T>()))
+ return true;
+ SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<T>());
+ return ObjectType::isExternalConvertible(shiboType, pyobj);
+ }
+ static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<T*>(cppobj)); }
+ static inline PyObject* toPython(const T& cppobj)
+ {
+ PyObject* obj = createWrapper<T>(new T(cppobj), true, true);
+// SbkBaseWrapper_setContainsCppWrapper(obj, SbkTypeInfo<T>::isCppWrapper);
+ return obj;
+ }
+ // Classes with implicit conversions are expected to reimplement 'toCpp' to build T from
+ // its various implicit constructors. Even classes without implicit conversions could
+ // get some of those via other modules defining conversion operator for them, thus
+ // the basic Converter for value types checks for extended conversion and tries to
+ // use them if it is the case.
+ static inline T toCpp(PyObject* pyobj)
+ {
+ if (!PyObject_TypeCheck(pyobj, SbkType<T>())) {
+ SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<T>());
+ if (ObjectType::hasExternalCppConversions(shiboType) && isConvertible(pyobj)) {
+ T* cptr = reinterpret_cast<T*>(ObjectType::callExternalCppConversion(shiboType, pyobj));
+ const T result = *cptr;
+ delete cptr;
+ return result;
+ }
+ assert(false);
+ }
+ return *reinterpret_cast<T*>(Object::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>()));
+ }
+};
+
+// Base converter meant to be inherited by converters for abstract classes and object types
+// (i.e. classes with private copy constructors and = operators).
+// Example: "struct Converter<AbstractClass*> : ObjectTypeConverter<AbstractClass>"
+template <typename T>
+struct ObjectTypeConverter
+{
+ static inline bool checkType(PyObject* pyObj) { return pyObj == Py_None || PyObject_TypeCheck(pyObj, SbkType<T>()); }
+ /// Py_None objects are the only objects convertible to an object type (in the form of a NULL pointer).
+ static inline bool isConvertible(PyObject* pyObj) { return pyObj == Py_None || PyObject_TypeCheck(pyObj, SbkType<T>()); }
+ /// Convenience overload that calls "toPython(const T*)" method.
+ static inline PyObject* toPython(void* cppobj) { return toPython(reinterpret_cast<T*>(cppobj)); }
+ /// Returns a new Python wrapper for the C++ object or an existing one with its reference counter incremented.
+ static PyObject* toPython(const T* cppobj)
+ {
+ if (!cppobj)
+ Py_RETURN_NONE;
+ PyObject* pyobj = reinterpret_cast<PyObject*>(BindingManager::instance().retrieveWrapper(cppobj));
+ if (pyobj)
+ Py_INCREF(pyobj);
+ else
+ pyobj = createWrapper<T>(cppobj);
+ return pyobj;
+ }
+ /// Returns the wrapped C++ pointer casted properly, or a NULL pointer if the argument is a Py_None.
+ static T* toCpp(PyObject* pyobj)
+ {
+ if (pyobj == Py_None)
+ return 0;
+ SbkObject *sbkObj = reinterpret_cast<SbkObject *>(pyobj);
+ SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(pyobj->ob_type);
+ if (ObjectType::hasCast(shiboType))
+ return reinterpret_cast<T*>(ObjectType::cast(shiboType, sbkObj, SbkType<T>()));
+ return reinterpret_cast<T *>(Object::cppPointer(sbkObj, SbkType<T>()));
+ }
+};
+
+template <typename T>
+struct ObjectTypeReferenceConverter : ObjectTypeConverter<T>
+{
+ static inline bool checkType(PyObject* pyObj) { return PyObject_TypeCheck(pyObj, SbkType<T>()); }
+ static inline bool isConvertible(PyObject* pyObj) { return PyObject_TypeCheck(pyObj, SbkType<T>()); }
+ static inline PyObject* toPython(const T& cppobj) { return Converter<T*>::toPython(&cppobj); }
+ static inline T& toCpp(PyObject* pyobj)
+ {
+ T* t = Converter<T*>::toCpp(pyobj);
+ assert(t);
+ return *t;
+ }
+};
+
+// PyObject* specialization to avoid converting what doesn't need to be converted.
+template<>
+struct Converter<PyObject*> : ObjectTypeConverter<PyObject*>
+{
+ static inline PyObject* toCpp(PyObject* pyobj) { return pyobj; }
+};
+
+// Primitive Conversions ------------------------------------------------------
+template <>
+struct Converter<bool>
+{
+ static inline bool checkType(PyObject* pyobj) { return PyBool_Check(pyobj); }
+ static inline bool isConvertible(PyObject* pyobj) { return PyInt_Check(pyobj); }
+ static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<bool*>(cppobj)); }
+ static inline PyObject* toPython(bool cppobj) { return PyBool_FromLong(cppobj); }
+ static inline bool toCpp(PyObject* pyobj) { return PyInt_AS_LONG(pyobj); }
+};
+
+/**
+ * Helper template for checking if a value overflows when casted to type T
+ */
+template<typename T, bool isSigned = std::numeric_limits<T>::is_signed >
+struct OverFlowChecker;
+
+template<typename T>
+struct OverFlowChecker<T, true>
+{
+ static bool check(const PY_LONG_LONG& value)
+ {
+ return value < std::numeric_limits<T>::min() || value > std::numeric_limits<T>::max();
+ }
+};
+
+template<typename T>
+struct OverFlowChecker<T, false>
+{
+ static bool check(const PY_LONG_LONG& value)
+ {
+ return value < 0 || static_cast<unsigned long long>(value) > std::numeric_limits<T>::max();
+ }
+};
+
+template<>
+struct OverFlowChecker<PY_LONG_LONG, true>
+{
+ static bool check(const PY_LONG_LONG &)
+ {
+ return false;
+ }
+};
+
+template<>
+struct OverFlowChecker<double, true>
+{
+ static bool check(const double &)
+ {
+ return false;
+ }
+};
+
+template<>
+struct OverFlowChecker<float, true>
+{
+ static bool check(const double& value)
+ {
+ return value < std::numeric_limits<float>::min() || value > std::numeric_limits<float>::max();
+ }
+};
+
+template <typename PyIntEquiv>
+struct Converter_PyInt
+{
+ static inline bool checkType(PyObject* pyobj) { return PyInt_Check(pyobj); }
+ static inline bool isConvertible(PyObject* pyobj) { return SbkNumber_Check(pyobj); }
+ static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<PyIntEquiv*>(cppobj)); }
+ static inline PyObject* toPython(const PyIntEquiv& cppobj) { return PyInt_FromLong((long) cppobj); }
+ static PyIntEquiv toCpp(PyObject* pyobj)
+ {
+ if (PyFloat_Check(pyobj)) {
+ double d_result = PyFloat_AS_DOUBLE(pyobj);
+ // If cast to long directly it could overflow silently
+ if (OverFlowChecker<PyIntEquiv>::check(d_result))
+ PyErr_SetObject(PyExc_OverflowError, 0);
+ return static_cast<PyIntEquiv>(d_result);
+ } else {
+ PY_LONG_LONG result = PyLong_AsLongLong(pyobj);
+ if (OverFlowChecker<PyIntEquiv>::check(result))
+ PyErr_SetObject(PyExc_OverflowError, 0);
+ return static_cast<PyIntEquiv>(result);
+ }
+ }
+};
+
+template <typename T>
+struct Converter_PyULongInt : Converter_PyInt<T>
+{
+ static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<T*>(cppobj)); }
+ static inline PyObject* toPython(const T& cppobj) { return PyLong_FromUnsignedLong(cppobj); }
+};
+
+/// Specialization to convert char and unsigned char, it accepts Python numbers and strings with just one character.
+template <typename CharType>
+struct CharConverter
+{
+ static inline bool checkType(PyObject* pyobj) { return SbkChar_Check(pyobj); }
+ static inline bool isConvertible(PyObject* pyobj) { return SbkChar_Check(pyobj); }
+ static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<CharType*>(cppobj)); }
+ static inline PyObject* toPython(const CharType& cppobj) { return PyInt_FromLong(cppobj); }
+ static CharType toCpp(PyObject* pyobj)
+ {
+ if (PyBytes_Check(pyobj)) {
+ assert(PyBytes_GET_SIZE(pyobj) == 1); // This check is made on SbkChar_Check
+ return PyBytes_AS_STRING(pyobj)[0];
+ } else if (PyInt_Check(pyobj)) {
+ PY_LONG_LONG result = PyInt_AsUnsignedLongLongMask(pyobj);
+ if (OverFlowChecker<CharType>::check(result))
+ PyErr_SetObject(PyExc_OverflowError, 0);
+ return result;
+ } else if (Shiboken::String::check(pyobj)) {
+ return Shiboken::String::toCString(pyobj)[0];
+ } else {
+ return 0;
+ }
+ }
+};
+
+template <> struct Converter<unsigned long> : Converter_PyULongInt<unsigned long> {};
+template <> struct Converter<unsigned int> : Converter_PyULongInt<unsigned int> {};
+template <> struct Converter<char> : CharConverter<char>
+{
+ // Should we really return a string?
+ using CharConverter<char>::toPython;
+ using CharConverter<char>::isConvertible;
+ using CharConverter<char>::toCpp;
+
+
+ static inline bool isConvertible(PyObject* pyobj) {
+ return SbkChar_Check(pyobj);
+ }
+
+ static inline PyObject* toPython(const char& cppObj) {
+ return Shiboken::String::fromFormat("%c", cppObj);
+ }
+
+ static char toCpp(PyObject* pyobj)
+ {
+ if (PyBytes_Check(pyobj)) {
+ assert(PyBytes_GET_SIZE(pyobj) == 1); // This check is made on SbkChar_Check
+ return PyBytes_AS_STRING(pyobj)[0];
+ } else if (PyInt_Check(pyobj)) {
+ PY_LONG_LONG result = PyInt_AsUnsignedLongLongMask(pyobj);
+ if (OverFlowChecker<char>::check(result))
+ PyErr_SetObject(PyExc_OverflowError, 0);
+ return char(result);
+ } else if (Shiboken::String::check(pyobj)) {
+ return Shiboken::String::toCString(pyobj)[0];
+ } else {
+ return 0;
+ }
+ }
+};
+template <> struct Converter<signed char> : CharConverter<signed char> {};
+template <> struct Converter<unsigned char> : CharConverter<unsigned char> {};
+template <> struct Converter<int> : Converter_PyInt<int> {};
+template <> struct Converter<short> : Converter_PyInt<short> {};
+template <> struct Converter<unsigned short> : Converter_PyInt<unsigned short> {};
+template <> struct Converter<long> : Converter_PyInt<long> {};
+
+template <>
+struct Converter<PY_LONG_LONG>
+{
+ static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<PY_LONG_LONG*>(cppobj)); }
+ static inline PyObject* toPython(PY_LONG_LONG cppobj) { return PyLong_FromLongLong(cppobj); }
+ static inline PY_LONG_LONG toCpp(PyObject* pyobj) { return (PY_LONG_LONG) PyLong_AsLongLong(pyobj); }
+};
+
+template <>
+struct Converter<unsigned PY_LONG_LONG>
+{
+ static inline PyObject* toPython(void* cppobj)
+ {
+ return toPython(*reinterpret_cast<unsigned PY_LONG_LONG*>(cppobj));
+ }
+ static inline PyObject* toPython(unsigned PY_LONG_LONG cppobj)
+ {
+ return PyLong_FromUnsignedLongLong(cppobj);
+ }
+ static inline unsigned PY_LONG_LONG toCpp(PyObject* pyobj)
+ {
+#if PY_MAJOR_VERSION >= 3
+ if (!PyLong_Check(pyobj)) {
+ PyErr_SetString(PyExc_TypeError, "Invalid type for unsigned long long conversion");
+ return 0;
+ }
+
+ return PyLong_AsUnsignedLongLong(pyobj);
+#else
+ if (PyInt_Check(pyobj)) {
+ long result = (unsigned PY_LONG_LONG) PyInt_AsLong(pyobj);
+ if (result < 0) {
+ PyErr_SetObject(PyExc_OverflowError, 0);
+ return 0;
+ } else
+ return (unsigned PY_LONG_LONG) result;
+ } else if (PyLong_Check(pyobj)) {
+ return (unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(pyobj);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "Invalid type for unsigned long long conversion");
+ return 0;
+ }
+#endif // Python 2
+ }
+};
+
+template <typename PyFloatEquiv>
+struct Converter_PyFloat
+{
+ static inline bool checkType(PyObject* obj) { return PyFloat_Check(obj); }
+ static inline bool isConvertible(PyObject* obj) { return SbkNumber_Check(obj); }
+ static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<PyFloatEquiv*>(cppobj)); }
+ static inline PyObject* toPython(PyFloatEquiv cppobj) { return PyFloat_FromDouble((double) cppobj); }
+ static inline PyFloatEquiv toCpp(PyObject* pyobj)
+ {
+ if (PyInt_Check(pyobj) || PyLong_Check(pyobj))
+ return (PyFloatEquiv) PyLong_AsLong(pyobj);
+ return (PyFloatEquiv) PyFloat_AsDouble(pyobj);
+ }
+};
+
+template <> struct Converter<float> : Converter_PyFloat<float> {};
+template <> struct Converter<double> : Converter_PyFloat<double> {};
+
+// PyEnum Conversions ---------------------------------------------------------
+template <typename CppEnum>
+struct EnumConverter
+{
+ static inline bool checkType(PyObject* pyObj) { return PyObject_TypeCheck(pyObj, SbkType<CppEnum>()); }
+ static inline bool isConvertible(PyObject* pyObj) { return PyObject_TypeCheck(pyObj, SbkType<CppEnum>()); }
+ static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<CppEnum*>(cppobj)); }
+ static inline PyObject* toPython(CppEnum cppenum)
+ {
+ return Shiboken::Enum::newItem(Shiboken::SbkType<CppEnum>(), (long) cppenum);
+ }
+ static inline CppEnum toCpp(PyObject* pyObj)
+ {
+ return (CppEnum) Shiboken::Enum::getValue(pyObj);;
+ }
+};
+
+// C Sting Types --------------------------------------------------------------
+template <typename CString>
+struct Converter_CString
+{
+ // Note: 0 is also a const char* in C++, so None is accepted in checkType
+ static inline bool checkType(PyObject* pyObj) {
+ return Shiboken::String::check(pyObj);
+ }
+ static inline bool isConvertible(PyObject* pyObj) {
+ return Shiboken::String::isConvertible(pyObj);
+ }
+ static inline PyObject* toPython(void* cppobj) { return toPython(reinterpret_cast<CString>(cppobj)); }
+ static inline PyObject* toPython(CString cppobj)
+ {
+ if (!cppobj)
+ Py_RETURN_NONE;
+ return Shiboken::String::fromCString(cppobj);
+ }
+ static inline CString toCpp(PyObject* pyobj) {
+ if (pyobj == Py_None)
+ return 0;
+ return Shiboken::String::toCString(pyobj);
+ }
+};
+
+template <> struct Converter<const char*> : Converter_CString<const char*> {};
+
+template <> struct Converter<std::string> : Converter_CString<std::string>
+{
+ static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<std::string*>(cppobj)); }
+ static inline PyObject* toPython(std::string cppObj)
+ {
+ return Shiboken::String::fromCString(cppObj.c_str());
+ }
+
+ static inline std::string toCpp(PyObject* pyobj)
+ {
+ if (pyobj == Py_None)
+ return 0;
+ return std::string(Shiboken::String::toCString(pyobj));
+ }
+};
+
+// C++ containers -------------------------------------------------------------
+// The following container converters are meant to be used for pairs, lists and maps
+// that are similar to the STL containers of the same name.
+
+// For example to create a converter for a std::list the following code is enough:
+// template<typename T> struct Converter<std::list<T> > : StdListConverter<std::list<T> > {};
+
+// And this for a std::map:
+// template<typename KT, typename VT>
+// struct Converter<std::map<KT, VT> > : StdMapConverter<std::map<KT, VT> > {};
+
+template <typename StdList>
+struct StdListConverter
+{
+ static inline bool checkType(PyObject* pyObj)
+ {
+ return isConvertible(pyObj);
+ }
+
+ static inline bool isConvertible(PyObject* pyObj)
+ {
+ if (PyObject_TypeCheck(pyObj, SbkType<StdList>()))
+ return true;
+ // Sequence conversion are made ONLY for python sequences, not for
+ // binded types implementing sequence protocol, otherwise this will
+ // cause a mess like QBitArray being accepted by someone expecting a
+ // QStringList.
+ if ((SbkType<StdList>() && Object::checkType(pyObj)) || !PySequence_Check(pyObj))
+ return false;
+ for (int i = 0, max = PySequence_Length(pyObj); i < max; ++i) {
+ AutoDecRef item(PySequence_GetItem(pyObj, i));
+ if (!Converter<typename StdList::value_type>::isConvertible(item))
+ return false;
+ }
+ return true;
+ }
+ static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<StdList*>(cppObj)); }
+ static PyObject* toPython(const StdList& cppobj)
+ {
+ PyObject* result = PyList_New((int) cppobj.size());
+ typename StdList::const_iterator it = cppobj.begin();
+ for (int idx = 0; it != cppobj.end(); ++it, ++idx) {
+ typename StdList::value_type vh(*it);
+ PyList_SET_ITEM(result, idx, Converter<typename StdList::value_type>::toPython(vh));
+ }
+ return result;
+ }
+ static StdList toCpp(PyObject* pyobj)
+ {
+ if (PyObject_TypeCheck(pyobj, SbkType<StdList>()))
+ return *reinterpret_cast<StdList*>(Object::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<StdList>()));
+
+ StdList result;
+ for (int i = 0; i < PySequence_Size(pyobj); i++) {
+ AutoDecRef pyItem(PySequence_GetItem(pyobj, i));
+ result.push_back(Converter<typename StdList::value_type>::toCpp(pyItem));
+ }
+ return result;
+ }
+};
+
+template <typename StdPair>
+struct StdPairConverter
+{
+ static inline bool checkType(PyObject* pyObj)
+ {
+ return isConvertible(pyObj);
+ }
+
+ static inline bool isConvertible(PyObject* pyObj)
+ {
+ if (PyObject_TypeCheck(pyObj, SbkType<StdPair>()))
+ return true;
+ if ((SbkType<StdPair>() && Object::checkType(pyObj)) || !PySequence_Check(pyObj) || PySequence_Length(pyObj) != 2)
+ return false;
+
+ AutoDecRef item1(PySequence_GetItem(pyObj, 0));
+ AutoDecRef item2(PySequence_GetItem(pyObj, 1));
+
+ if (!Converter<typename StdPair::first_type>::isConvertible(item1)
+ && !Converter<typename StdPair::second_type>::isConvertible(item2)) {
+ return false;
+ }
+ return true;
+ }
+ static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<StdPair*>(cppObj)); }
+ static PyObject* toPython(const StdPair& cppobj)
+ {
+ typename StdPair::first_type first(cppobj.first);
+ typename StdPair::second_type second(cppobj.second);
+ PyObject* tuple = PyTuple_New(2);
+ PyTuple_SET_ITEM(tuple, 0, Converter<typename StdPair::first_type>::toPython(first));
+ PyTuple_SET_ITEM(tuple, 1, Converter<typename StdPair::second_type>::toPython(second));
+ return tuple;
+ }
+ static StdPair toCpp(PyObject* pyobj)
+ {
+ StdPair result;
+ AutoDecRef pyFirst(PySequence_GetItem(pyobj, 0));
+ AutoDecRef pySecond(PySequence_GetItem(pyobj, 1));
+ result.first = Converter<typename StdPair::first_type>::toCpp(pyFirst);
+ result.second = Converter<typename StdPair::second_type>::toCpp(pySecond);
+ return result;
+ }
+};
+
+template <typename StdMap>
+struct StdMapConverter
+{
+ static inline bool checkType(PyObject* pyObj)
+ {
+ return isConvertible(pyObj);
+ }
+
+ static inline bool isConvertible(PyObject* pyObj)
+ {
+ if (PyObject_TypeCheck(pyObj, SbkType<StdMap>()))
+ return true;
+ if ((SbkType<StdMap>() && Object::checkType(pyObj)) || !PyDict_Check(pyObj))
+ return false;
+
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+
+ while (PyDict_Next(pyObj, &pos, &key, &value)) {
+ if (!Converter<typename StdMap::key_type>::isConvertible(key)
+ || !Converter<typename StdMap::mapped_type>::isConvertible(value)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<StdMap*>(cppObj)); }
+ static PyObject* toPython(const StdMap& cppobj)
+ {
+ PyObject* result = PyDict_New();
+ typename StdMap::const_iterator it = cppobj.begin();
+
+ for (; it != cppobj.end(); ++it) {
+ PyDict_SetItem(result,
+ Converter<typename StdMap::key_type>::toPython(it->first),
+ Converter<typename StdMap::mapped_type>::toPython(it->second));
+ }
+
+ return result;
+ }
+ static StdMap toCpp(PyObject* pyobj)
+ {
+ StdMap result;
+
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+
+ while (PyDict_Next(pyobj, &pos, &key, &value)) {
+ result.insert(typename StdMap::value_type(
+ Converter<typename StdMap::key_type>::toCpp(key),
+ Converter<typename StdMap::mapped_type>::toCpp(value)));
+ }
+ return result;
+ }
+};
+
+
+// class used to translate python objects to another type
+template <typename T> struct PythonConverter {};
+
+} // namespace Shiboken
+
+#endif // CONVERSIONS_H
+
diff --git a/sources/shiboken2/libshiboken/debugfreehook.cpp b/sources/shiboken2/libshiboken/debugfreehook.cpp
new file mode 100644
index 000000000..f5757a70f
--- /dev/null
+++ b/sources/shiboken2/libshiboken/debugfreehook.cpp
@@ -0,0 +1,194 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "debugfreehook.h"
+#include "bindingmanager.h"
+#include "gilstate.h"
+
+#if defined(_WIN32) && defined(_DEBUG)
+#include <crtdbg.h>
+#include <windows.h>
+#endif
+
+#ifdef __GLIBC__
+#include <malloc.h>
+#endif
+
+#ifdef __APPLE__
+#include <malloc/malloc.h>
+#include <mach/mach.h>
+#include <mach/mach_vm.h>
+#endif
+
+#ifdef SHIBOKEN_INSTALL_FREE_DEBUG_HOOK
+extern "C" {
+
+static int testPointerBeingFreed(void *ptr)
+{
+ // It is an error for a deleted pointer address to still be registered
+ // in the BindingManager
+ if (Shiboken::BindingManager::instance().hasWrapper(ptr)) {
+ Shiboken::GilState state;
+
+ SbkObject *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(ptr);
+
+ fprintf(stderr, "SbkObject still in binding map when deleted: ");
+ PyObject_Print(reinterpret_cast<PyObject *>(wrapper), stderr, 0);
+ fprintf(stderr, "\n");
+
+#ifdef _WIN32
+ DebugBreak();
+#else
+ assert(0);
+#endif
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+#if defined(_WIN32) && defined(_DEBUG)
+static _CRT_ALLOC_HOOK lastCrtAllocHook;
+static int DebugAllocHook(int nAllocType, void *pvData,
+ size_t nSize, int nBlockUse, long lRequest,
+ const unsigned char * szFileName, int nLine)
+{
+ // It is an error for a deleted pointer address to still be registered
+ // in the BindingManager
+ if ( nAllocType == _HOOK_FREE) {
+ if ( !testPointerBeingFreed(pvData) ) {
+ return 0;
+ }
+ }
+
+ if ( lastCrtAllocHook != NULL ) {
+ return lastCrtAllocHook(nAllocType, pvData, nSize, nBlockUse, lRequest,
+ szFileName, nLine);
+ }
+
+ return 1;
+}
+#endif // _WIN32 && _DEBUG
+
+#ifdef __GLIBC__
+static void (*lastFreeHook)(void* ptr, const void* caller);
+static void DebugFreeHook(void* ptr, const void* caller)
+{
+ testPointerBeingFreed(ptr);
+
+ if ( lastFreeHook != NULL )
+ lastFreeHook(ptr, caller);
+}
+#endif // __GLIBC__
+
+#ifdef __APPLE__
+static malloc_zone_t lastMallocZone;
+static void DebugFreeHook(malloc_zone_t *zone, void *ptr)
+{
+ testPointerBeingFreed(ptr);
+
+ if ( lastMallocZone.free != NULL )
+ lastMallocZone.free(zone, ptr);
+}
+static void DebugFreeDefiniteSizeHook(malloc_zone_t *zone, void *ptr, size_t size)
+{
+ testPointerBeingFreed(ptr);
+
+ if ( lastMallocZone.free_definite_size != NULL )
+ lastMallocZone.free_definite_size(zone, ptr, size);
+}
+#endif __APPLE__
+
+void debugInstallFreeHook(void)
+{
+#if defined(_WIN32) && defined(_DEBUG)
+ lastCrtAllocHook = _CrtSetAllocHook(DebugAllocHook);
+#endif
+
+#ifdef __GLIBC__
+ // __free_hook is not thread safe so it marked as deprecated. Use here
+ // is hopefully safe and should catch errors in a single threaded program
+ // and only miss some in a multithreaded program
+ lastFreeHook = __free_hook;
+ __free_hook = DebugFreeHook;
+#endif
+
+#ifdef __APPLE__
+ malloc_zone_t* zone = malloc_default_zone();
+ assert(zone != NULL);
+ //remove the write protection from the zone struct
+ if (zone->version >= 8) {
+ vm_protect(mach_task_self(), (uintptr_t)zone, sizeof(*zone), 0, VM_PROT_READ | VM_PROT_WRITE);
+ }
+ lastMallocZone = *zone;
+ zone->free = DebugFreeHook;
+ zone->free_definite_size = DebugFreeDefiniteSizeHook;
+ if (zone->version >= 8) {
+ vm_protect(mach_task_self(), (uintptr_t)zone, sizeof(*zone), 0, VM_PROT_READ);
+ }
+#endif
+}
+
+void debugRemoveFreeHook(void)
+{
+#if defined(_WIN32) && defined(_DEBUG)
+ _CrtSetAllocHook(lastCrtAllocHook);
+#endif
+
+#ifdef __GLIBC__
+ __free_hook = lastFreeHook;
+#endif
+
+#ifdef __APPLE__
+ malloc_zone_t* zone = malloc_default_zone();
+ assert(zone != NULL);
+ //remove the write protection from the zone struct
+ if (zone->version >= 8) {
+ vm_protect(mach_task_self(), (uintptr_t)zone, sizeof(*zone), 0, VM_PROT_READ | VM_PROT_WRITE);
+ }
+ zone->free = lastMallocZone.free;
+ zone->free_definite_size = lastMallocZone.free_definite_size;
+ if (zone->version >= 8) {
+ vm_protect(mach_task_self(), (uintptr_t)zone, sizeof(*zone), 0, VM_PROT_READ);
+ }
+#endif
+}
+
+} // extern "C"
+#endif // SHIBOKEN_INSTALL_DEBUG_FREE_HOOK
diff --git a/sources/shiboken2/libshiboken/debugfreehook.h b/sources/shiboken2/libshiboken/debugfreehook.h
new file mode 100644
index 000000000..743d56e4c
--- /dev/null
+++ b/sources/shiboken2/libshiboken/debugfreehook.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 DEBUGFREEHOOK_H
+#define DEBUGFREEHOOK_H
+
+// These functions enable C library runtime hooks to try to catch cases where
+// C++ object addresses remain in hash table of valid wrappers when the address
+// is passed to free. The hooks are probably not thread safe and thus
+// should only be enabled in single threaded environments
+
+// To enable the hook, uncomment the following define.
+//#define SHIBOKEN_INSTALL_FREE_DEBUG_HOOK
+
+#ifdef SHIBOKEN_INSTALL_FREE_DEBUG_HOOK
+extern "C" {
+
+void debugInstallFreeHook(void);
+void debugRemoveFreeHook(void);
+
+} // extern "C"
+
+#endif // SHIBOKEN_INSTALL_FREE_DEBUG_HOOK
+
+#endif // DEBUGFREEHOOK_H
diff --git a/sources/shiboken2/libshiboken/gilstate.cpp b/sources/shiboken2/libshiboken/gilstate.cpp
new file mode 100644
index 000000000..e7406fdd6
--- /dev/null
+++ b/sources/shiboken2/libshiboken/gilstate.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "gilstate.h"
+
+namespace Shiboken
+{
+
+GilState::GilState()
+ : m_locked(false)
+{
+ if (Py_IsInitialized()) {
+ m_gstate = PyGILState_Ensure();
+ m_locked = true;
+ }
+}
+
+GilState::~GilState()
+{
+ release();
+}
+
+void GilState::release()
+{
+ if (m_locked && Py_IsInitialized()) {
+ PyGILState_Release(m_gstate);
+ m_locked = false;
+ }
+}
+
+} // namespace Shiboken
+
diff --git a/sources/shiboken2/libshiboken/gilstate.h b/sources/shiboken2/libshiboken/gilstate.h
new file mode 100644
index 000000000..e0f18a814
--- /dev/null
+++ b/sources/shiboken2/libshiboken/gilstate.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 GILSTATE_H
+#define GILSTATE_H
+
+#include <shibokenmacros.h>
+#include "sbkpython.h"
+
+namespace Shiboken
+{
+
+class LIBSHIBOKEN_API GilState
+{
+public:
+ GilState();
+ ~GilState();
+ void release();
+private:
+ PyGILState_STATE m_gstate;
+ bool m_locked;
+};
+
+} // namespace Shiboken
+
+#endif // GILSTATE_H
+
diff --git a/sources/shiboken2/libshiboken/helper.cpp b/sources/shiboken2/libshiboken/helper.cpp
new file mode 100644
index 000000000..9709d0776
--- /dev/null
+++ b/sources/shiboken2/libshiboken/helper.cpp
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "helper.h"
+#include <stdarg.h>
+
+namespace Shiboken
+{
+
+bool sequenceToArgcArgv(PyObject* argList, int* argc, char*** argv, const char* defaultAppName)
+{
+ if (!PySequence_Check(argList))
+ return false;
+
+ if (!defaultAppName)
+ defaultAppName = "PySideApplication";
+
+ // Check all items
+ Shiboken::AutoDecRef args(PySequence_Fast(argList, 0));
+ int numArgs = PySequence_Fast_GET_SIZE(argList);
+ for (int i = 0; i < numArgs; ++i) {
+ PyObject* item = PySequence_Fast_GET_ITEM(args.object(), i);
+ if (!PyBytes_Check(item) && !PyUnicode_Check(item))
+ return false;
+ }
+
+ bool hasEmptyArgList = numArgs == 0;
+ if (hasEmptyArgList)
+ numArgs = 1;
+
+ *argc = numArgs;
+ *argv = new char*[*argc];
+
+ if (hasEmptyArgList) {
+ // Try to get the script name
+ PyObject* globals = PyEval_GetGlobals();
+ PyObject* appName = PyDict_GetItemString(globals, "__file__");
+ (*argv)[0] = strdup(appName ? Shiboken::String::toCString(appName) : defaultAppName);
+ } else {
+ for (int i = 0; i < numArgs; ++i) {
+ PyObject* item = PySequence_Fast_GET_ITEM(args.object(), i);
+ char* string = 0;
+ if (Shiboken::String::check(item)) {
+ string = strdup(Shiboken::String::toCString(item));
+ }
+ (*argv)[i] = string;
+ }
+ }
+
+ return true;
+}
+
+int* sequenceToIntArray(PyObject* obj, bool zeroTerminated)
+{
+ AutoDecRef seq(PySequence_Fast(obj, "Sequence of ints expected"));
+ if (seq.isNull())
+ return 0;
+
+ Py_ssize_t size = PySequence_Fast_GET_SIZE(seq.object());
+ int* array = new int[size + (zeroTerminated ? 1 : 0)];
+
+ for (int i = 0; i < size; i++) {
+ PyObject* item = PySequence_Fast_GET_ITEM(seq.object(), i);
+ if (!PyInt_Check(item)) {
+ PyErr_SetString(PyExc_TypeError, "Sequence of ints expected");
+ delete[] array;
+ return 0;
+ } else {
+ array[i] = PyInt_AsLong(item);
+ }
+ }
+
+ if (zeroTerminated)
+ array[size] = 0;
+
+ return array;
+}
+
+
+int warning(PyObject* category, int stacklevel, const char* format, ...)
+{
+ va_list args;
+ va_start(args, format);
+#if _WIN32
+ va_list args2 = args;
+#else
+ va_list args2;
+ va_copy(args2, args);
+#endif
+
+ // check the necessary memory
+ int size = vsnprintf(NULL, 0, format, args) + 1;
+ char* message = new char[size];
+ int result = 0;
+ if (message) {
+ // format the message
+ vsnprintf(message, size, format, args2);
+ result = PyErr_WarnEx(category, message, stacklevel);
+ delete [] message;
+ }
+ va_end(args2);
+ va_end(args);
+ return result;
+}
+
+} // namespace Shiboken
diff --git a/sources/shiboken2/libshiboken/helper.h b/sources/shiboken2/libshiboken/helper.h
new file mode 100644
index 000000000..f2061b667
--- /dev/null
+++ b/sources/shiboken2/libshiboken/helper.h
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 HELPER_H
+#define HELPER_H
+
+#include "sbkpython.h"
+#include "shibokenmacros.h"
+#include "conversions.h"
+#include "autodecref.h"
+
+#define SBK_UNUSED(x) (void)x;
+
+namespace Shiboken
+{
+
+template<typename A>
+inline PyObject* makeTuple(const A& a)
+{
+ return PyTuple_Pack(1, AutoDecRef(Converter<A>::toPython(a)).object());
+}
+
+template<typename A, typename B>
+inline PyObject* makeTuple(const A& a, const B& b)
+{
+ return PyTuple_Pack(2, AutoDecRef(Converter<A>::toPython(a)).object(),
+ AutoDecRef(Converter<B>::toPython(b)).object());
+}
+
+template<typename A, typename B, typename C>
+inline PyObject* makeTuple(const A& a, const B& b, const C& c)
+{
+ return PyTuple_Pack(3, AutoDecRef(Converter<A>::toPython(a)).object(),
+ AutoDecRef(Converter<B>::toPython(b)).object(),
+ AutoDecRef(Converter<C>::toPython(c)).object());
+}
+
+template<typename A, typename B, typename C, typename D>
+inline PyObject* makeTuple(const A& a, const B& b, const C& c, const D& d)
+{
+ return PyTuple_Pack(4, AutoDecRef(Converter<A>::toPython(a)).object(),
+ AutoDecRef(Converter<B>::toPython(b)).object(),
+ AutoDecRef(Converter<C>::toPython(c)).object(),
+ AutoDecRef(Converter<D>::toPython(d)).object());
+}
+
+template<typename A, typename B, typename C, typename D, typename E>
+inline PyObject* makeTuple(const A& a, const B& b, const C& c, const D& d, const E& e)
+{
+ return PyTuple_Pack(5, AutoDecRef(Converter<A>::toPython(a)).object(),
+ AutoDecRef(Converter<B>::toPython(b)).object(),
+ AutoDecRef(Converter<C>::toPython(c)).object(),
+ AutoDecRef(Converter<D>::toPython(d)).object(),
+ AutoDecRef(Converter<E>::toPython(e)).object());
+}
+
+/**
+* It transforms a python sequence into two C variables, argc and argv.
+* This function tries to find the application (script) name and put it into argv[0], if
+* the application name can't be guessed, defaultAppName will be used.
+*
+* No memory is allocated is an error occur.
+*
+* \note argc must be a valid address.
+* \note The argv array is allocated using new operator and each item is allocated using malloc.
+* \returns True on sucess, false otherwise.
+*/
+LIBSHIBOKEN_API bool sequenceToArgcArgv(PyObject* argList, int* argc, char*** argv, const char* defaultAppName = 0);
+
+/**
+ * Convert a python sequence into a heap-allocated array of ints.
+ *
+ * \returns The newly allocated array or NULL in case of error or empty sequence. Check with PyErr_Occurred
+ * if it was successfull.
+ */
+LIBSHIBOKEN_API int* sequenceToIntArray(PyObject* obj, bool zeroTerminated = false);
+
+/**
+ * Creates and automatically deallocates C++ arrays.
+ */
+template<class T>
+class AutoArrayPointer
+{
+ public:
+ AutoArrayPointer(int size) { data = new T[size]; }
+ T& operator[](int pos) { return data[pos]; }
+ operator T*() const { return data; }
+ ~AutoArrayPointer() { delete[] data; }
+ private:
+ T* data;
+};
+
+/**
+ * An utility function used to call PyErr_WarnEx with a formatted message.
+ */
+LIBSHIBOKEN_API int warning(PyObject* category, int stacklevel, const char* format, ...);
+
+} // namespace Shiboken
+
+#endif // HELPER_H
diff --git a/sources/shiboken2/libshiboken/python25compat.h b/sources/shiboken2/libshiboken/python25compat.h
new file mode 100644
index 000000000..71c88d86a
--- /dev/null
+++ b/sources/shiboken2/libshiboken/python25compat.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 PYTHON25COMPAT_H
+#define PYTHON25COMPAT_H
+#include <Python.h>
+#include <cstring>
+
+/*
+ *The #defines below were taken from Cython-generated code to allow shiboken to be used with python2.5.
+ * Maybe not all of these defines are useful to us, time will tell which ones are really needed or not.
+ */
+
+#if PY_VERSION_HEX < 0x02060000
+#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
+#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
+#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
+#define PyVarObject_HEAD_INIT(type, size) \
+ PyObject_HEAD_INIT(type) size,
+#define PyType_Modified(t)
+
+typedef struct {
+ void *buf;
+ PyObject *obj;
+ Py_ssize_t len;
+ Py_ssize_t itemsize;
+ int readonly;
+ int ndim;
+ char *format;
+ Py_ssize_t *shape;
+ Py_ssize_t *strides;
+ Py_ssize_t *suboffsets;
+ void *internal;
+} Py_buffer;
+
+#define PyBUF_SIMPLE 0
+#define PyBUF_WRITABLE 0x0001
+#define PyBUF_LOCK 0x0002
+#define PyBUF_FORMAT 0x0004
+#define PyBUF_ND 0x0008
+#define PyBUF_STRIDES (0x0010 | PyBUF_ND)
+#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
+#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
+#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
+#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
+
+#define PyBytes_Check PyString_Check
+#define PyBytes_FromString PyString_FromString
+#define PyBytes_FromFormat PyString_FromFormat
+#define PyBytes_FromStringAndSize PyString_FromStringAndSize
+#define PyBytes_GET_SIZE PyString_GET_SIZE
+#define PyBytes_AS_STRING PyString_AS_STRING
+#define PyBytes_AsString PyString_AsString
+#define PyBytes_Concat PyString_Concat
+#define PyBytes_Size PyString_Size
+
+inline PyObject* PyUnicode_FromString(const char* s)
+{
+ std::size_t len = std::strlen(s);
+ return PyUnicode_DecodeUTF8(s, len, 0);
+}
+
+#define PyLong_FromSize_t _PyLong_FromSize_t
+#define PyLong_AsSsize_t _PyLong_AsSsize_t
+
+#endif
+
+#endif
diff --git a/sources/shiboken2/libshiboken/sbkconverter.cpp b/sources/shiboken2/libshiboken/sbkconverter.cpp
new file mode 100644
index 000000000..e7e9995b4
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkconverter.cpp
@@ -0,0 +1,572 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "sbkconverter.h"
+#include "sbkconverter_p.h"
+#include "basewrapper_p.h"
+#include "google/dense_hash_map"
+#include "autodecref.h"
+#include "sbkdbg.h"
+#include "helper.h"
+
+static SbkConverter** PrimitiveTypeConverters;
+
+typedef google::dense_hash_map<std::string, SbkConverter*> ConvertersMap;
+static ConvertersMap converters;
+
+namespace Shiboken {
+namespace Conversions {
+
+void init()
+{
+ static SbkConverter* primitiveTypeConverters[] = {
+ Primitive<PY_LONG_LONG>::createConverter(),
+ Primitive<bool>::createConverter(),
+ Primitive<char>::createConverter(),
+ Primitive<const char*>::createConverter(),
+ Primitive<double>::createConverter(),
+ Primitive<float>::createConverter(),
+ Primitive<int>::createConverter(),
+ Primitive<long>::createConverter(),
+ Primitive<short>::createConverter(),
+ Primitive<signed char>::createConverter(),
+ Primitive<std::string>::createConverter(),
+ Primitive<unsigned PY_LONG_LONG>::createConverter(),
+ Primitive<unsigned char>::createConverter(),
+ Primitive<unsigned int>::createConverter(),
+ Primitive<unsigned long>::createConverter(),
+ Primitive<unsigned short>::createConverter(),
+ Primitive<void*>::createConverter()
+ };
+ PrimitiveTypeConverters = primitiveTypeConverters;
+
+ assert(converters.empty());
+ converters.set_empty_key("");
+ converters.set_deleted_key("?");
+ converters["PY_LONG_LONG"] = primitiveTypeConverters[SBK_PY_LONG_LONG_IDX];
+ converters["bool"] = primitiveTypeConverters[SBK_BOOL_IDX_1];
+ converters["char"] = primitiveTypeConverters[SBK_CHAR_IDX];
+ converters["const char *"] = primitiveTypeConverters[SBK_CONSTCHARPTR_IDX];
+ converters["double"] = primitiveTypeConverters[SBK_DOUBLE_IDX];
+ converters["float"] = primitiveTypeConverters[SBK_FLOAT_IDX];
+ converters["int"] = primitiveTypeConverters[SBK_INT_IDX];
+ converters["long"] = primitiveTypeConverters[SBK_LONG_IDX];
+ converters["short"] = primitiveTypeConverters[SBK_SHORT_IDX];
+ converters["signed char"] = primitiveTypeConverters[SBK_SIGNEDCHAR_IDX];
+ converters["std::string"] = primitiveTypeConverters[SBK_STD_STRING_IDX];
+ converters["unsigned PY_LONG_LONG"] = primitiveTypeConverters[SBK_UNSIGNEDPY_LONG_LONG_IDX];
+ converters["unsigned char"] = primitiveTypeConverters[SBK_UNSIGNEDCHAR_IDX];
+ converters["unsigned int"] = primitiveTypeConverters[SBK_UNSIGNEDINT_IDX];
+ converters["unsigned long"] = primitiveTypeConverters[SBK_UNSIGNEDLONG_IDX];
+ converters["unsigned short"] = primitiveTypeConverters[SBK_UNSIGNEDSHORT_IDX];
+ converters["void*"] = primitiveTypeConverters[SBK_VOIDPTR_IDX];
+}
+
+static SbkConverter* createConverterObject(PyTypeObject* type,
+ PythonToCppFunc toCppPointerConvFunc,
+ IsConvertibleToCppFunc toCppPointerCheckFunc,
+ CppToPythonFunc pointerToPythonFunc,
+ CppToPythonFunc copyToPythonFunc)
+{
+ SbkConverter* converter = new SbkConverter;
+ converter->pythonType = type;
+
+ converter->pointerToPython = pointerToPythonFunc;
+ converter->copyToPython = copyToPythonFunc;
+
+ if (toCppPointerCheckFunc && toCppPointerConvFunc)
+ converter->toCppPointerConversion = std::make_pair(toCppPointerCheckFunc, toCppPointerConvFunc);
+ converter->toCppConversions.clear();
+
+ return converter;
+}
+
+SbkConverter* createConverter(SbkObjectType* type,
+ PythonToCppFunc toCppPointerConvFunc,
+ IsConvertibleToCppFunc toCppPointerCheckFunc,
+ CppToPythonFunc pointerToPythonFunc,
+ CppToPythonFunc copyToPythonFunc)
+{
+ SbkConverter *converter =
+ createConverterObject(reinterpret_cast<PyTypeObject *>(type),
+ toCppPointerConvFunc, toCppPointerCheckFunc,
+ pointerToPythonFunc, copyToPythonFunc);
+ type->d->converter = converter;
+ return converter;
+}
+
+SbkConverter* createConverter(PyTypeObject* type, CppToPythonFunc toPythonFunc)
+{
+ return createConverterObject(type, 0, 0, 0, toPythonFunc);
+}
+
+void deleteConverter(SbkConverter* converter)
+{
+ if (converter) {
+ converter->toCppConversions.clear();
+ delete converter;
+ }
+}
+
+void setCppPointerToPythonFunction(SbkConverter* converter, CppToPythonFunc pointerToPythonFunc)
+{
+ converter->pointerToPython = pointerToPythonFunc;
+}
+
+void setPythonToCppPointerFunctions(SbkConverter* converter,
+ PythonToCppFunc toCppPointerConvFunc,
+ IsConvertibleToCppFunc toCppPointerCheckFunc)
+{
+ converter->toCppPointerConversion = std::make_pair(toCppPointerCheckFunc, toCppPointerConvFunc);
+}
+
+void addPythonToCppValueConversion(SbkConverter* converter,
+ PythonToCppFunc pythonToCppFunc,
+ IsConvertibleToCppFunc isConvertibleToCppFunc)
+{
+ converter->toCppConversions.push_back(std::make_pair(isConvertibleToCppFunc, pythonToCppFunc));
+}
+void addPythonToCppValueConversion(SbkObjectType* type,
+ PythonToCppFunc pythonToCppFunc,
+ IsConvertibleToCppFunc isConvertibleToCppFunc)
+{
+ addPythonToCppValueConversion(type->d->converter, pythonToCppFunc, isConvertibleToCppFunc);
+}
+
+PyObject* pointerToPython(const SbkObjectType *type, const void *cppIn)
+{
+ return pointerToPython(type->d->converter, cppIn);
+}
+
+PyObject* pointerToPython(const SbkConverter *converter, const void *cppIn)
+{
+ assert(converter);
+ if (!cppIn)
+ Py_RETURN_NONE;
+ if (!converter->pointerToPython) {
+ warning(PyExc_RuntimeWarning, 0, "pointerToPython(): SbkConverter::pointerToPython is null for \"%s\".",
+ converter->pythonType->tp_name);
+ Py_RETURN_NONE;
+ }
+ return converter->pointerToPython(cppIn);
+}
+
+PyObject* referenceToPython(const SbkObjectType *type, const void *cppIn)
+{
+ return referenceToPython(type->d->converter, cppIn);
+}
+
+PyObject* referenceToPython(const SbkConverter *converter, const void *cppIn)
+{
+ assert(cppIn);
+
+ PyObject *pyOut = reinterpret_cast<PyObject *>(BindingManager::instance().retrieveWrapper(cppIn));
+ if (pyOut) {
+ Py_INCREF(pyOut);
+ return pyOut;
+ }
+ if (!converter->pointerToPython) {
+ warning(PyExc_RuntimeWarning, 0, "referenceToPython(): SbkConverter::pointerToPython is null for \"%s\".",
+ converter->pythonType->tp_name);
+ Py_RETURN_NONE;
+ }
+ return converter->pointerToPython(cppIn);
+}
+
+static inline PyObject* CopyCppToPython(const SbkConverter *converter, const void *cppIn)
+{
+ if (!cppIn)
+ Py_RETURN_NONE;
+ if (!converter->copyToPython) {
+ warning(PyExc_RuntimeWarning, 0, "CopyCppToPython(): SbkConverter::copyToPython is null for \"%s\".",
+ converter->pythonType->tp_name);
+ Py_RETURN_NONE;
+ }
+ return converter->copyToPython(cppIn);
+}
+PyObject* copyToPython(const SbkObjectType *type, const void *cppIn)
+{
+ return CopyCppToPython(type->d->converter, cppIn);
+}
+PyObject* copyToPython(const SbkConverter *converter, const void *cppIn)
+{
+ return CopyCppToPython(converter, cppIn);
+}
+
+PythonToCppFunc isPythonToCppPointerConvertible(const SbkObjectType *type, PyObject *pyIn)
+{
+ assert(pyIn);
+ return type->d->converter->toCppPointerConversion.first(pyIn);
+}
+
+static inline PythonToCppFunc IsPythonToCppConvertible(const SbkConverter *converter, PyObject *pyIn)
+{
+ assert(pyIn);
+ const ToCppConversionList& convs = converter->toCppConversions;
+ for (ToCppConversionList::const_iterator conv = convs.begin(), end = convs.end(); conv != end; ++conv) {
+ PythonToCppFunc toCppFunc = 0;
+ if ((toCppFunc = (*conv).first(pyIn)))
+ return toCppFunc;
+ }
+ return 0;
+}
+PythonToCppFunc isPythonToCppValueConvertible(const SbkObjectType *type, PyObject *pyIn)
+{
+ return IsPythonToCppConvertible(type->d->converter, pyIn);
+}
+PythonToCppFunc isPythonToCppConvertible(const SbkConverter *converter, PyObject *pyIn)
+{
+ return IsPythonToCppConvertible(converter, pyIn);
+}
+
+PythonToCppFunc isPythonToCppReferenceConvertible(const SbkObjectType *type, PyObject *pyIn)
+{
+ if (pyIn != Py_None) {
+ PythonToCppFunc toCpp = isPythonToCppPointerConvertible(type, pyIn);
+ if (toCpp)
+ return toCpp;
+ }
+ return isPythonToCppValueConvertible(type, pyIn);
+}
+
+void nonePythonToCppNullPtr(PyObject*, void* cppOut)
+{
+ assert(cppOut);
+ *((void**)cppOut) = 0;
+}
+
+void* cppPointer(PyTypeObject* desiredType, SbkObject* pyIn)
+{
+ assert(pyIn);
+ if (!ObjectType::checkType(desiredType))
+ return pyIn;
+ SbkObjectType *inType = reinterpret_cast<SbkObjectType *>(Py_TYPE(pyIn));
+ if (ObjectType::hasCast(inType))
+ return ObjectType::cast(inType, pyIn, desiredType);
+ return Object::cppPointer(pyIn, desiredType);
+}
+
+void pythonToCppPointer(SbkObjectType* type, PyObject* pyIn, void* cppOut)
+{
+ assert(type);
+ assert(pyIn);
+ assert(cppOut);
+ *reinterpret_cast<void **>(cppOut) = pyIn == Py_None
+ ? 0
+ : cppPointer(reinterpret_cast<PyTypeObject *>(type), reinterpret_cast<SbkObject *>(pyIn));
+}
+
+void pythonToCppPointer(const SbkConverter *converter, PyObject *pyIn, void *cppOut)
+{
+ assert(converter);
+ assert(pyIn);
+ assert(cppOut);
+ *reinterpret_cast<void **>(cppOut) = pyIn == Py_None
+ ? 0
+ : cppPointer(reinterpret_cast<PyTypeObject *>(converter->pythonType), reinterpret_cast<SbkObject *>(pyIn));
+}
+
+static void _pythonToCppCopy(const SbkConverter *converter, PyObject *pyIn, void *cppOut)
+{
+ assert(converter);
+ assert(pyIn);
+ assert(cppOut);
+ PythonToCppFunc toCpp = IsPythonToCppConvertible(converter, pyIn);
+ if (toCpp)
+ toCpp(pyIn, cppOut);
+}
+
+void pythonToCppCopy(const SbkObjectType *type, PyObject *pyIn, void *cppOut)
+{
+ assert(type);
+ _pythonToCppCopy(type->d->converter, pyIn, cppOut);
+}
+
+void pythonToCppCopy(const SbkConverter *converter, PyObject *pyIn, void *cppOut)
+{
+ _pythonToCppCopy(converter, pyIn, cppOut);
+}
+
+bool isImplicitConversion(const SbkObjectType *type, PythonToCppFunc toCppFunc)
+{
+ // This is the Object Type or Value Type conversion that only
+ // retrieves the C++ pointer held in the Python wrapper.
+ if (toCppFunc == type->d->converter->toCppPointerConversion.second)
+ return false;
+
+ // Object Types doesn't have any kind of value conversion,
+ // only C++ pointer retrieval.
+ if (type->d->converter->toCppConversions.empty())
+ return false;
+
+ // The first conversion of the non-pointer conversion list is
+ // a Value Type's copy to C++ function, which is not an implicit
+ // conversion.
+ // Otherwise it must be one of the implicit conversions.
+ // Note that we don't check if the Python to C++ conversion is in
+ // the list of the type's conversions, for it is expected that the
+ // caller knows what he's doing.
+ ToCppConversionList::iterator conv = type->d->converter->toCppConversions.begin();
+ return toCppFunc != (*conv).second;
+}
+
+void registerConverterName(SbkConverter* converter , const char* typeName)
+{
+ ConvertersMap::iterator iter = converters.find(typeName);
+ if (iter == converters.end())
+ converters.insert(std::make_pair(typeName, converter));
+}
+
+SbkConverter* getConverter(const char* typeName)
+{
+ ConvertersMap::const_iterator it = converters.find(typeName);
+ if (it != converters.end())
+ return it->second;
+ if (Py_VerboseFlag > 0)
+ SbkDbg() << "Can't find type resolver for type '" << typeName << "'.";
+ return 0;
+}
+
+SbkConverter* primitiveTypeConverter(int index)
+{
+ return PrimitiveTypeConverters[index];
+}
+
+bool checkSequenceTypes(PyTypeObject* type, PyObject* pyIn)
+{
+ assert(type);
+ assert(pyIn);
+ if (!PySequence_Check(pyIn))
+ return false;
+ const Py_ssize_t size = PySequence_Size(pyIn);
+ for (Py_ssize_t i = 0; i < size; ++i) {
+ if (!PyObject_TypeCheck(AutoDecRef(PySequence_GetItem(pyIn, i)), type))
+ return false;
+ }
+ return true;
+}
+bool convertibleSequenceTypes(const SbkConverter *converter, PyObject *pyIn)
+{
+ assert(converter);
+ assert(pyIn);
+ if (!PySequence_Check(pyIn))
+ return false;
+ const Py_ssize_t size = PySequence_Size(pyIn);
+ for (Py_ssize_t i = 0; i < size; ++i) {
+ if (!isPythonToCppConvertible(converter, AutoDecRef(PySequence_GetItem(pyIn, i))))
+ return false;
+ }
+ return true;
+}
+bool convertibleSequenceTypes(const SbkObjectType *type, PyObject *pyIn)
+{
+ assert(type);
+ return convertibleSequenceTypes(type->d->converter, pyIn);
+}
+
+bool checkPairTypes(PyTypeObject* firstType, PyTypeObject* secondType, PyObject* pyIn)
+{
+ assert(firstType);
+ assert(secondType);
+ assert(pyIn);
+ if (!PySequence_Check(pyIn))
+ return false;
+ if (PySequence_Size(pyIn) != 2)
+ return false;
+ if (!PyObject_TypeCheck(AutoDecRef(PySequence_GetItem(pyIn, 0)), firstType))
+ return false;
+ if (!PyObject_TypeCheck(AutoDecRef(PySequence_GetItem(pyIn, 1)), secondType))
+ return false;
+ return true;
+}
+bool convertiblePairTypes(const SbkConverter *firstConverter, bool firstCheckExact,
+ const SbkConverter *secondConverter, bool secondCheckExact,
+ PyObject *pyIn)
+{
+ assert(firstConverter);
+ assert(secondConverter);
+ assert(pyIn);
+ if (!PySequence_Check(pyIn))
+ return false;
+ if (PySequence_Size(pyIn) != 2)
+ return false;
+ AutoDecRef firstItem(PySequence_GetItem(pyIn, 0));
+ if (firstCheckExact) {
+ if (!PyObject_TypeCheck(firstItem, firstConverter->pythonType))
+ return false;
+ } else if (!isPythonToCppConvertible(firstConverter, firstItem)) {
+ return false;
+ }
+ AutoDecRef secondItem(PySequence_GetItem(pyIn, 1));
+ if (secondCheckExact) {
+ if (!PyObject_TypeCheck(secondItem, secondConverter->pythonType))
+ return false;
+ } else if (!isPythonToCppConvertible(secondConverter, secondItem)) {
+ return false;
+ }
+
+ return true;
+}
+
+bool checkDictTypes(PyTypeObject* keyType, PyTypeObject* valueType, PyObject* pyIn)
+{
+ assert(keyType);
+ assert(valueType);
+ assert(pyIn);
+ if (!PyDict_Check(pyIn))
+ return false;
+
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+ while (PyDict_Next(pyIn, &pos, &key, &value)) {
+ if (!PyObject_TypeCheck(key, keyType))
+ return false;
+ if (!PyObject_TypeCheck(value, valueType))
+ return false;
+ }
+ return true;
+}
+
+bool convertibleDictTypes(const SbkConverter * keyConverter, bool keyCheckExact, const SbkConverter *valueConverter,
+ bool valueCheckExact, PyObject *pyIn)
+{
+ assert(keyConverter);
+ assert(valueConverter);
+ assert(pyIn);
+ if (!PyDict_Check(pyIn))
+ return false;
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+ while (PyDict_Next(pyIn, &pos, &key, &value)) {
+ if (keyCheckExact) {
+ if (!PyObject_TypeCheck(key, keyConverter->pythonType))
+ return false;
+ } else if (!isPythonToCppConvertible(keyConverter, key)) {
+ return false;
+ }
+ if (valueCheckExact) {
+ if (!PyObject_TypeCheck(value, valueConverter->pythonType))
+ return false;
+ } else if (!isPythonToCppConvertible(valueConverter, value)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+PyTypeObject* getPythonTypeObject(const SbkConverter *converter)
+{
+ if (converter)
+ return converter->pythonType;
+ return 0;
+}
+
+PyTypeObject* getPythonTypeObject(const char* typeName)
+{
+ return getPythonTypeObject(getConverter(typeName));
+}
+
+bool pythonTypeIsValueType(const SbkConverter *converter)
+{
+ assert(converter);
+ return converter->pointerToPython && converter->copyToPython;
+}
+
+bool pythonTypeIsObjectType(const SbkConverter *converter)
+{
+ return converter->pointerToPython && !converter->copyToPython;
+}
+
+bool pythonTypeIsWrapperType(const SbkConverter *converter)
+{
+ return converter->pointerToPython;
+}
+
+SpecificConverter::SpecificConverter(const char* typeName)
+ : m_type(InvalidConversion)
+{
+ m_converter = getConverter(typeName);
+ if (!m_converter)
+ return;
+ const Py_ssize_t len = strlen(typeName);
+ char lastChar = typeName[len -1];
+ if (lastChar == '&') {
+ m_type = ReferenceConversion;
+ } else if (lastChar == '*' || pythonTypeIsObjectType(m_converter)) {
+ m_type = PointerConversion;
+ } else {
+ m_type = CopyConversion;
+ }
+}
+
+PyObject* SpecificConverter::toPython(const void* cppIn)
+{
+ switch (m_type) {
+ case CopyConversion:
+ return copyToPython(m_converter, cppIn);
+ case PointerConversion:
+ return pointerToPython(m_converter, *((const void**)cppIn));
+ case ReferenceConversion:
+ return referenceToPython(m_converter, cppIn);
+ default:
+ PyErr_SetString(PyExc_RuntimeError, "tried to use invalid converter in 'C++ to Python' conversion");
+ }
+ return 0;
+}
+
+void SpecificConverter::toCpp(PyObject* pyIn, void* cppOut)
+{
+ switch (m_type) {
+ case CopyConversion:
+ pythonToCppCopy(m_converter, pyIn, cppOut);
+ break;
+ case PointerConversion:
+ pythonToCppPointer(m_converter, pyIn, cppOut);
+ break;
+ case ReferenceConversion:
+ pythonToCppPointer(m_converter, pyIn, &cppOut);
+ break;
+ default:
+ PyErr_SetString(PyExc_RuntimeError, "tried to use invalid converter in 'Python to C++' conversion");
+ }
+}
+
+} } // namespace Shiboken::Conversions
diff --git a/sources/shiboken2/libshiboken/sbkconverter.h b/sources/shiboken2/libshiboken/sbkconverter.h
new file mode 100644
index 000000000..7489b930d
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkconverter.h
@@ -0,0 +1,367 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SBK_CONVERTER_H
+#define SBK_CONVERTER_H
+
+#include "sbkpython.h"
+#include "shibokenmacros.h"
+
+#include <limits>
+#include <string>
+
+struct SbkObject;
+struct SbkObjectType;
+
+/**
+ * This is a convenience macro identical to Python's PyObject_TypeCheck,
+ * except that the arguments have swapped places, for the great convenience
+ * of generator.
+ */
+#define SbkObject_TypeCheck(tp, ob) \
+ (Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
+
+extern "C"
+{
+
+/**
+ * SbkConverter is used to perform type conversions from C++
+ * to Python and vice-versa;.and it is also used for type checking.
+ * SbkConverter is a private structure that must be accessed
+ * using the functions provided by the converter API.
+ */
+struct SbkConverter;
+
+/**
+ * Given a void pointer to a C++ object, this function must return
+ * the proper Python object. It may be either an existing wrapper
+ * for the C++ object, or a newly create one. Or even the Python
+ * equivalent of the C++ value passed in the argument.
+ *
+ * C++ -> Python
+ */
+typedef PyObject* (*CppToPythonFunc)(const void*);
+
+/**
+ * This function converts a Python object to a C++ value, it may be
+ * a pointer, value, class, container or primitive type, passed via
+ * a void pointer, that will be cast properly inside the function.
+ * This function is usually returned by an IsConvertibleToCppFunc
+ * function, or obtained knowing the type of the Python object input,
+ * thus it will not check the Python object type, and will expect
+ * the void pointer to be pointing to a proper variable.
+ *
+ * Python -> C++
+ */
+typedef void (*PythonToCppFunc)(PyObject*,void*);
+
+/**
+ * Checks if the Python object passed in the argument is convertible to a
+ * C++ type defined inside the function, it returns the converter function
+ * that will transform a Python argument into a C++ value.
+ * It returns NULL if the Python object is not convertible to the C++ type
+ * that the function represents.
+ *
+ * Python -> C++ ?
+ */
+typedef PythonToCppFunc (*IsConvertibleToCppFunc)(PyObject*);
+
+} // extern "C"
+
+namespace Shiboken {
+namespace Conversions {
+
+
+class LIBSHIBOKEN_API SpecificConverter
+{
+public:
+ enum Type
+ {
+ InvalidConversion,
+ CopyConversion,
+ PointerConversion,
+ ReferenceConversion
+ };
+
+ explicit SpecificConverter(const char* typeName);
+
+ inline SbkConverter* converter() { return m_converter; }
+ inline operator SbkConverter*() const { return m_converter; }
+
+ inline bool isValid() { return m_type != InvalidConversion; }
+ inline operator bool() const { return m_type != InvalidConversion; }
+
+ inline Type conversionType() { return m_type; }
+
+ PyObject* toPython(const void* cppIn);
+ void toCpp(PyObject* pyIn, void* cppOut);
+private:
+ SbkConverter* m_converter;
+ Type m_type;
+};
+
+
+/**
+ * Creates a converter for a wrapper type.
+ * \param type A Shiboken.ObjectType that will receive the new converter.
+ * \param toCppPointerConvFunc Function to retrieve the C++ pointer held by a Python wrapper.
+ * \param toCppPointerCheckFunc Check and return the retriever function of the C++ pointer held by a Python wrapper.
+ * \param pointerToPythonFunc Function to convert a C++ object to a Python \p type wrapper, keeping their identity.
+ * \param copyToPythonFunc Function to convert a C++ object to a Python \p type, copying the object.
+ * \returns The new converter referred by the wrapper \p type.
+ */
+LIBSHIBOKEN_API SbkConverter* createConverter(SbkObjectType* type,
+ PythonToCppFunc toCppPointerConvFunc,
+ IsConvertibleToCppFunc toCppPointerCheckFunc,
+ CppToPythonFunc pointerToPythonFunc,
+ CppToPythonFunc copyToPythonFunc = 0);
+
+/**
+ * Creates a converter for a non wrapper type (primitive or container type).
+ * \param type Python type representing to the new converter.
+ * \param toPythonFunc Function to convert a C++ object to a Python \p type.
+ * \returns A new type converter.
+ */
+LIBSHIBOKEN_API SbkConverter* createConverter(PyTypeObject* type, CppToPythonFunc toPythonFunc);
+
+LIBSHIBOKEN_API void deleteConverter(SbkConverter* converter);
+
+/// Sets the Python object to C++ pointer conversion function.
+LIBSHIBOKEN_API void setCppPointerToPythonFunction(SbkConverter* converter, CppToPythonFunc pointerToPythonFunc);
+
+/// Sets the C++ pointer to Python object conversion functions.
+LIBSHIBOKEN_API void setPythonToCppPointerFunctions(SbkConverter* converter,
+ PythonToCppFunc toCppPointerConvFunc,
+ IsConvertibleToCppFunc toCppPointerCheckFunc);
+
+/**
+ * Adds a new conversion of a Python object to a C++ value.
+ * This is used in copy and implicit conversions.
+ */
+LIBSHIBOKEN_API void addPythonToCppValueConversion(SbkConverter* converter,
+ PythonToCppFunc pythonToCppFunc,
+ IsConvertibleToCppFunc isConvertibleToCppFunc);
+LIBSHIBOKEN_API void addPythonToCppValueConversion(SbkObjectType* type,
+ PythonToCppFunc pythonToCppFunc,
+ IsConvertibleToCppFunc isConvertibleToCppFunc);
+
+// C++ -> Python ---------------------------------------------------------------------------
+
+/**
+ * Retrieves the Python wrapper object for the given \p cppIn C++ pointer object.
+ * This function is used only for Value and Object Types.
+ * Example usage:
+ * TYPE* var;
+ * PyObject* pyVar = pointerToPython(SBKTYPE, &var);
+ */
+LIBSHIBOKEN_API PyObject* pointerToPython(const SbkObjectType *type, const void *cppIn);
+LIBSHIBOKEN_API PyObject* pointerToPython(const SbkConverter *converter, const void *cppIn);
+
+/**
+ * For the given \p cppIn C++ reference it returns the Python wrapper object,
+ * always for Object Types, and when they already exist for reference types;
+ * for when the latter doesn't have an existing wrapper type, the C++ object
+ * is copied to Python.
+ * Example usage:
+ * TYPE& var = SOMETHING;
+ * PyObject* pyVar = referenceToPython(SBKTYPE, &var);
+ */
+LIBSHIBOKEN_API PyObject* referenceToPython(const SbkObjectType *type, const void *cppIn);
+LIBSHIBOKEN_API PyObject* referenceToPython(const SbkConverter *converter, const void *cppIn);
+
+/**
+ * Retrieves the Python wrapper object for the given C++ value pointed by \p cppIn.
+ * This function is used only for Value Types.
+ * Example usage:
+ * TYPE var;
+ * PyObject* pyVar = copyToPython(SBKTYPE, &var);
+ */
+LIBSHIBOKEN_API PyObject* copyToPython(const SbkObjectType *type, const void *cppIn);
+LIBSHIBOKEN_API PyObject* copyToPython(const SbkConverter *converter, const void *cppIn);
+
+// Python -> C++ ---------------------------------------------------------------------------
+
+/**
+ * Returns a Python to C++ conversion function if the Python object is convertible to a C++ pointer.
+ * It returns NULL if the Python object is not convertible to \p type.
+ */
+LIBSHIBOKEN_API PythonToCppFunc isPythonToCppPointerConvertible(const SbkObjectType *type, PyObject *pyIn);
+
+/**
+ * Returns a Python to C++ conversion function if the Python object is convertible to a C++ value.
+ * The resulting converter function will create a copy of the Python object in C++, or implicitly
+ * convert the object to the expected \p type.
+ * It returns NULL if the Python object is not convertible to \p type.
+ */
+LIBSHIBOKEN_API PythonToCppFunc isPythonToCppValueConvertible(const SbkObjectType *type, PyObject *pyIn);
+
+/**
+ * Returns a Python to C++ conversion function if the Python object is convertible to a C++ reference.
+ * The resulting converter function will return the underlying C++ object held by the Python wrapper,
+ * or a new C++ value if it must be a implicit conversion.
+ * It returns NULL if the Python object is not convertible to \p type.
+ */
+LIBSHIBOKEN_API PythonToCppFunc isPythonToCppReferenceConvertible(const SbkObjectType *type, PyObject *pyIn);
+
+/// This is the same as isPythonToCppValueConvertible function.
+LIBSHIBOKEN_API PythonToCppFunc isPythonToCppConvertible(const SbkConverter *converter, PyObject *pyIn);
+
+/**
+ * Returns the C++ pointer for the \p pyIn object cast to the type passed via \p desiredType.
+ * It differs from Shiboken::Object::cppPointer because it casts the pointer to a proper
+ * memory offset depending on the desired type.
+ */
+LIBSHIBOKEN_API void* cppPointer(PyTypeObject* desiredType, SbkObject* pyIn);
+
+/// Converts a Python object \p pyIn to C++ and stores the result in the C++ pointer passed in \p cppOut.
+LIBSHIBOKEN_API void pythonToCppPointer(SbkObjectType* type, PyObject* pyIn, void* cppOut);
+LIBSHIBOKEN_API void pythonToCppPointer(const SbkConverter *converter, PyObject *pyIn, void *cppOut);
+
+/// Converts a Python object \p pyIn to C++, and copies the result in the C++ variable passed in \p cppOut.
+LIBSHIBOKEN_API void pythonToCppCopy(const SbkObjectType *type, PyObject *pyIn, void *cppOut);
+LIBSHIBOKEN_API void pythonToCppCopy(const SbkConverter *converter, PyObject *pyIn, void *cppOut);
+
+/**
+ * Helper function returned by generated convertible checking functions
+ * that returns a C++ NULL when the input Python object is None.
+ */
+LIBSHIBOKEN_API void nonePythonToCppNullPtr(PyObject*, void* cppOut);
+
+/**
+ * Returns true if the \p toCpp function passed is an implicit conversion of Python \p type.
+ * It is used when C++ expects a reference argument, so it may be the same object received
+ * from Python, or another created through implicit conversion.
+ */
+LIBSHIBOKEN_API bool isImplicitConversion(const SbkObjectType *type, PythonToCppFunc toCpp);
+
+/// Registers a converter with a type name that may be used to retrieve the converter.
+LIBSHIBOKEN_API void registerConverterName(SbkConverter* converter, const char* typeName);
+
+/// Returns the converter for a given type name, or NULL if it wasn't registered before.
+LIBSHIBOKEN_API SbkConverter* getConverter(const char* typeName);
+
+/// Returns the converter for a primitive type.
+LIBSHIBOKEN_API SbkConverter* primitiveTypeConverter(int index);
+
+/// Returns true if a Python sequence is comprised of objects of the given \p type.
+LIBSHIBOKEN_API bool checkSequenceTypes(PyTypeObject* type, PyObject* pyIn);
+
+/// Returns true if a Python sequence is comprised of objects of a type convertible to the one represented by the given \p converter.
+LIBSHIBOKEN_API bool convertibleSequenceTypes(const SbkConverter *converter, PyObject *pyIn);
+
+/// Returns true if a Python sequence is comprised of objects of a type convertible to \p type.
+LIBSHIBOKEN_API bool convertibleSequenceTypes(const SbkObjectType *type, PyObject *pyIn);
+
+/// Returns true if a Python sequence can be converted to a C++ pair.
+LIBSHIBOKEN_API bool checkPairTypes(PyTypeObject* firstType, PyTypeObject* secondType, PyObject* pyIn);
+
+/// Returns true if a Python sequence can be converted to a C++ pair.
+LIBSHIBOKEN_API bool convertiblePairTypes(const SbkConverter *firstConverter, bool firstCheckExact,
+ const SbkConverter *secondConverter, bool secondCheckExact,
+ PyObject *pyIn);
+
+/// Returns true if a Python dictionary can be converted to a C++ hash or map.
+LIBSHIBOKEN_API bool checkDictTypes(PyTypeObject* keyType, PyTypeObject* valueType, PyObject* pyIn);
+
+/// Returns true if a Python dictionary can be converted to a C++ hash or map.
+LIBSHIBOKEN_API bool convertibleDictTypes(const SbkConverter *keyConverter, bool keyCheckExact,
+ const SbkConverter *valueConverter, bool valueCheckExact,
+ PyObject *pyIn);
+
+/// Returns the Python type object associated with the given \p converter.
+LIBSHIBOKEN_API PyTypeObject* getPythonTypeObject(const SbkConverter *converter);
+
+/// Returns the Python type object for the given \p typeName.
+LIBSHIBOKEN_API PyTypeObject* getPythonTypeObject(const char* typeName);
+
+/// Returns true if the Python type associated with the converter is a value type.
+LIBSHIBOKEN_API bool pythonTypeIsValueType(const SbkConverter *converter);
+
+/// Returns true if the Python type associated with the converter is an object type.
+LIBSHIBOKEN_API bool pythonTypeIsObjectType(const SbkConverter *converter);
+
+/// Returns true if the Python type associated with the converter is a wrapper type.
+LIBSHIBOKEN_API bool pythonTypeIsWrapperType(const SbkConverter *converter);
+
+#define SBK_PY_LONG_LONG_IDX 0
+// Qt5: name collision in QtCore after QBool is replaced by bool
+#define SBK_BOOL_IDX_1 1
+#define SBK_CHAR_IDX 2
+#define SBK_CONSTCHARPTR_IDX 3
+#define SBK_DOUBLE_IDX 4
+#define SBK_FLOAT_IDX 5
+#define SBK_INT_IDX 6
+#define SBK_SIGNEDINT_IDX 6
+#define SBK_LONG_IDX 7
+#define SBK_SHORT_IDX 8
+#define SBK_SIGNEDCHAR_IDX 9
+#define SBK_STD_STRING_IDX 10
+#define SBK_UNSIGNEDPY_LONG_LONG_IDX 11
+#define SBK_UNSIGNEDCHAR_IDX 12
+#define SBK_UNSIGNEDINT_IDX 13
+#define SBK_UNSIGNEDLONG_IDX 14
+#define SBK_UNSIGNEDSHORT_IDX 15
+#define SBK_VOIDPTR_IDX 16
+
+template<typename T> SbkConverter* PrimitiveTypeConverter() { return 0; }
+template<> inline SbkConverter* PrimitiveTypeConverter<PY_LONG_LONG>() { return primitiveTypeConverter(SBK_PY_LONG_LONG_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<bool>() { return primitiveTypeConverter(SBK_BOOL_IDX_1); }
+template<> inline SbkConverter* PrimitiveTypeConverter<char>() { return primitiveTypeConverter(SBK_CHAR_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<const char*>() { return primitiveTypeConverter(SBK_CONSTCHARPTR_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<double>() { return primitiveTypeConverter(SBK_DOUBLE_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<float>() { return primitiveTypeConverter(SBK_FLOAT_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<int>() { return primitiveTypeConverter(SBK_INT_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<long>() { return primitiveTypeConverter(SBK_LONG_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<short>() { return primitiveTypeConverter(SBK_SHORT_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<signed char>() { return primitiveTypeConverter(SBK_SIGNEDCHAR_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<std::string>() { return primitiveTypeConverter(SBK_STD_STRING_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<unsigned PY_LONG_LONG>() { return primitiveTypeConverter(SBK_UNSIGNEDPY_LONG_LONG_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<unsigned char>() { return primitiveTypeConverter(SBK_UNSIGNEDCHAR_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<unsigned int>() { return primitiveTypeConverter(SBK_UNSIGNEDINT_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<unsigned long>() { return primitiveTypeConverter(SBK_UNSIGNEDLONG_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<unsigned short>() { return primitiveTypeConverter(SBK_UNSIGNEDSHORT_IDX); }
+template<> inline SbkConverter* PrimitiveTypeConverter<void*>() { return primitiveTypeConverter(SBK_VOIDPTR_IDX); }
+
+} } // namespace Shiboken::Conversions
+
+struct _SbkGenericType { PyHeapTypeObject super; SbkConverter** converter; };
+#define SBK_CONVERTER(pyType) (*reinterpret_cast<_SbkGenericType*>(pyType)->converter)
+
+
+#endif // SBK_CONVERTER_H
diff --git a/sources/shiboken2/libshiboken/sbkconverter_p.h b/sources/shiboken2/libshiboken/sbkconverter_p.h
new file mode 100644
index 000000000..b38561780
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkconverter_p.h
@@ -0,0 +1,574 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SBK_CONVERTER_P_H
+#define SBK_CONVERTER_P_H
+
+#include "sbkpython.h"
+#include "sbkconverter.h"
+#include "sbkstring.h"
+#include <list>
+#include <limits>
+#include <typeinfo>
+#include <sstream>
+#include <iostream>
+
+#include "sbkdbg.h"
+
+extern "C"
+{
+
+typedef std::pair<IsConvertibleToCppFunc, PythonToCppFunc> ToCppConversion;
+typedef std::list<ToCppConversion> ToCppConversionList;
+
+/**
+ * \internal
+ * Private structure of SbkConverter.
+ */
+struct SbkConverter
+{
+ /**
+ * Python type associated with this converter. If the type is a Shiboken
+ * wrapper, then it must be a SbkObjectType; otherwise it will be the
+ * Python type to which the C++ value will be converted (note that the
+ * C++ type could be produced from various Python types).
+ */
+ PyTypeObject* pythonType;
+ /**
+ * This function converts a C++ object to a Python object of the type
+ * indicated in pythonType. The identity of the C++ object is kept,
+ * because it looks for an already existing Python wrapper associated
+ * with the C++ instance.
+ * It is used to convert C++ pointers and references to Python objects.
+ */
+ CppToPythonFunc pointerToPython;
+ /**
+ * This function converts a C++ object to a Python object of the type
+ * indicated in pythonType. The identity of the object is not kept,
+ * because a new instance of the C++ object is created.
+ * It is used to convert objects passed by value, or reference, if said
+ * reference can't be traced to an object that already has a Python
+ * wrapper assigned for it.
+ */
+ CppToPythonFunc copyToPython;
+ /**
+ * This is a special case of a Python to C++ conversion. It returns
+ * the underlying C++ pointer of a Python wrapper passed as parameter
+ * or NULL if the Python object is a None value.
+ * It comes separated from the other toCppConversions because if you
+ * have a Python object representing a Value Type the type checking
+ * for both ValueType and ValueType* would be the same, thus the first
+ * check would be true and the second would never be reached.
+ */
+ ToCppConversion toCppPointerConversion;
+ /**
+ * This is a list of type checking functions that return the
+ * proper Python to C++ conversion function, for the given Python
+ * object.
+ * For Object Types, that never have implicit conversions, this
+ * list is always empty.
+ */
+ ToCppConversionList toCppConversions;
+};
+
+} // extern "C"
+
+template<typename T, typename MaxLimitType, bool isSigned>
+struct OverFlowCheckerBase {
+ static void formatOverFlowMessage(const MaxLimitType& value,
+ const std::string *valueAsString = 0)
+ {
+ std::ostringstream str;
+ str << "libshiboken: Overflow: Value ";
+ if (valueAsString != 0 && !valueAsString->empty())
+ str << *valueAsString;
+ else
+ str << value;
+ str << " exceeds limits of type "
+ << " [" << (isSigned ? "signed" : "unsigned")
+ << "] \"" << typeid(T).name()
+ << "\" (" << sizeof(T) << "bytes).";
+ const std::string message = str.str();
+ PyErr_WarnEx(PyExc_RuntimeWarning, message.c_str(), 0);
+ }
+
+ // Checks if an overflow occurred inside Python code.
+ // Precondition: use after calls like PyLong_AsLongLong or PyLong_AsUnsignedLongLong.
+ // Postcondition: if error ocurred, sets the string reference to the string representation of
+ // the passed value.
+ static bool checkForInternalPyOverflow(PyObject *pyIn, std::string &valueAsString)
+ {
+ if (PyErr_Occurred()) {
+ PyErr_Print();
+ PyObject *stringRepresentation = PyObject_Str(pyIn);
+ const char *cString = Shiboken::String::toCString(stringRepresentation);
+ valueAsString.assign(cString);
+ Py_DECREF(stringRepresentation);
+ return true;
+ }
+ return false;
+ }
+};
+
+// Helper template for checking if a value overflows when cast to type T.
+// The MaxLimitType size is usually >= than type T size, so that it can still represent values that
+// can't be stored in T (unless the types are of course the same).
+// TLDR: MaxLimitType is either long long or unsigned long long.
+template<typename T, typename MaxLimitType = PY_LONG_LONG,
+ bool isSigned = std::numeric_limits<T>::is_signed >
+struct OverFlowChecker;
+
+template<typename T, typename MaxLimitType>
+struct OverFlowChecker<T, MaxLimitType, true> :
+ public OverFlowCheckerBase<T, MaxLimitType, true> {
+ static bool check(const MaxLimitType& value, PyObject *pyIn)
+ {
+ std::string valueAsString;
+ const bool isOverflow =
+ OverFlowChecker::checkForInternalPyOverflow(pyIn, valueAsString)
+ || value < std::numeric_limits<T>::min()
+ || value > std::numeric_limits<T>::max();
+ if (isOverflow)
+ OverFlowChecker::formatOverFlowMessage(value, &valueAsString);
+ return isOverflow;
+ }
+};
+
+template<typename T, typename MaxLimitType>
+struct OverFlowChecker<T, MaxLimitType, false>
+ : public OverFlowCheckerBase<T, MaxLimitType, false> {
+ static bool check(const MaxLimitType& value, PyObject *pyIn)
+ {
+ std::string valueAsString;
+ const bool isOverflow =
+ OverFlowChecker::checkForInternalPyOverflow(pyIn, valueAsString)
+ || value < 0
+ || static_cast<unsigned long long>(value) > std::numeric_limits<T>::max();
+ if (isOverflow)
+ OverFlowChecker::formatOverFlowMessage(value, &valueAsString);
+ return isOverflow;
+ }
+};
+template<>
+struct OverFlowChecker<PY_LONG_LONG, PY_LONG_LONG, true> :
+ public OverFlowCheckerBase<PY_LONG_LONG, PY_LONG_LONG, true> {
+ static bool check(const PY_LONG_LONG &value, PyObject *pyIn) {
+ std::string valueAsString;
+ const bool isOverflow = checkForInternalPyOverflow(pyIn, valueAsString);
+ if (isOverflow)
+ OverFlowChecker::formatOverFlowMessage(value, &valueAsString);
+ return isOverflow;
+
+ }
+};
+template<>
+struct OverFlowChecker<double, PY_LONG_LONG, true> {
+ static bool check(const double &, PyObject *) { return false; }
+};
+template<>
+struct OverFlowChecker<float, PY_LONG_LONG, true> :
+ public OverFlowCheckerBase<float, PY_LONG_LONG, true> {
+ static bool check(const double& value, PyObject *)
+ {
+ const bool result = value < std::numeric_limits<float>::min()
+ || value > std::numeric_limits<float>::max();
+ if (result)
+ formatOverFlowMessage(value);
+ return result;
+ }
+};
+
+// Basic primitive type converters ---------------------------------------------------------
+template<typename T> PyTypeObject* SbkType() { return 0; }
+template<> inline PyTypeObject* SbkType<PY_LONG_LONG>() { return &PyLong_Type; }
+template<> inline PyTypeObject* SbkType<bool>() { return &PyBool_Type; }
+template<> inline PyTypeObject* SbkType<char>() { return &PyInt_Type; }
+template<> inline PyTypeObject* SbkType<const char*>() { return &PyString_Type; }
+template<> inline PyTypeObject* SbkType<double>() { return &PyFloat_Type; }
+template<> inline PyTypeObject* SbkType<float>() { return &PyFloat_Type; }
+template<> inline PyTypeObject* SbkType<int>() { return &PyInt_Type; }
+template<> inline PyTypeObject* SbkType<long>() { return &PyLong_Type; }
+template<> inline PyTypeObject* SbkType<short>() { return &PyInt_Type; }
+template<> inline PyTypeObject* SbkType<signed char>() { return &PyInt_Type; }
+template<> inline PyTypeObject* SbkType<unsigned PY_LONG_LONG>() { return &PyLong_Type; }
+template<> inline PyTypeObject* SbkType<unsigned char>() { return &PyInt_Type; }
+template<> inline PyTypeObject* SbkType<unsigned int>() { return &PyLong_Type; }
+template<> inline PyTypeObject* SbkType<unsigned long>() { return &PyLong_Type; }
+template<> inline PyTypeObject* SbkType<unsigned short>() { return &PyInt_Type; }
+
+template <typename T> struct Primitive {};
+
+template <typename T>
+struct OnePrimitive
+{
+ static PyObject* toPython(const void*) { return 0; }
+ static PythonToCppFunc isConvertible(PyObject*) { return 0; }
+ static void toCpp(PyObject*, void*) {}
+ static SbkConverter* createConverter()
+ {
+ SbkConverter* converter = Shiboken::Conversions::createConverter(SbkType<T>(), Primitive<T>::toPython);
+ Shiboken::Conversions::addPythonToCppValueConversion(converter, Primitive<T>::toCpp, Primitive<T>::isConvertible);
+ return converter;
+ }
+};
+template <typename T>
+struct TwoPrimitive : OnePrimitive<T>
+{
+ static PythonToCppFunc isOtherConvertible(PyObject*) { return 0; }
+ static void otherToCpp(PyObject*, void*) {}
+ static SbkConverter* createConverter()
+ {
+ SbkConverter* converter = OnePrimitive<T>::createConverter();
+ Shiboken::Conversions::addPythonToCppValueConversion(converter, Primitive<T>::otherToCpp, Primitive<T>::isOtherConvertible);
+ return converter;
+ }
+};
+
+// Integers --------------------------------------------------------------------------------
+
+template <typename INT>
+struct IntPrimitive : TwoPrimitive<INT>
+{
+ static PyObject* toPython(const void* cppIn)
+ {
+ return PyInt_FromLong(*reinterpret_cast<const INT *>(cppIn));
+ }
+ static void toCpp(PyObject* pyIn, void* cppOut)
+ {
+ double result = PyFloat_AS_DOUBLE(pyIn);
+ // If cast to long directly it could overflow silently.
+ if (OverFlowChecker<INT>::check(result, pyIn))
+ PyErr_SetObject(PyExc_OverflowError, 0);
+ *reinterpret_cast<INT * >(cppOut) = static_cast<INT>(result);
+ }
+ static PythonToCppFunc isConvertible(PyObject* pyIn)
+ {
+ if (PyFloat_Check(pyIn))
+ return toCpp;
+ return 0;
+ }
+ static void otherToCpp(PyObject* pyIn, void* cppOut)
+ {
+ PY_LONG_LONG result = PyLong_AsLongLong(pyIn);
+ if (OverFlowChecker<INT>::check(result, pyIn))
+ PyErr_SetObject(PyExc_OverflowError, 0);
+ *reinterpret_cast<INT * >(cppOut) = static_cast<INT>(result);
+ }
+ static PythonToCppFunc isOtherConvertible(PyObject* pyIn)
+ {
+ if (SbkNumber_Check(pyIn))
+ return otherToCpp;
+ return 0;
+ }
+};
+template <> struct Primitive<int> : IntPrimitive<int> {};
+template <> struct Primitive<long> : IntPrimitive<long> {};
+template <> struct Primitive<short> : IntPrimitive<short> {};
+template <> struct Primitive<unsigned short> : IntPrimitive<unsigned short> {};
+
+// Unsigned Long Integers ------------------------------------------------------------------
+
+template <typename LONG>
+struct UnsignedLongPrimitive : IntPrimitive<LONG>
+{
+ static PyObject* toPython(const void* cppIn)
+ {
+ return PyLong_FromUnsignedLong(*reinterpret_cast<const LONG *>(cppIn));
+ }
+};
+template <> struct Primitive<unsigned int> : UnsignedLongPrimitive<unsigned int> {};
+template <> struct Primitive<unsigned long> : UnsignedLongPrimitive<unsigned long> {};
+
+// Big integers ----------------------------------------------------------------------------
+
+template <>
+struct Primitive<PY_LONG_LONG> : OnePrimitive<PY_LONG_LONG>
+{
+ static PyObject* toPython(const void* cppIn)
+ {
+ return PyLong_FromLongLong(*((PY_LONG_LONG*)cppIn));
+ }
+ static void toCpp(PyObject* pyIn, void* cppOut)
+ {
+ PY_LONG_LONG result = PyLong_AsLongLong(pyIn);
+ if (OverFlowChecker<PY_LONG_LONG>::check(result, pyIn))
+ PyErr_SetObject(PyExc_OverflowError, 0);
+ *reinterpret_cast<PY_LONG_LONG * >(cppOut) = result;
+ }
+ static PythonToCppFunc isConvertible(PyObject* pyIn)
+ {
+ if (SbkNumber_Check(pyIn))
+ return toCpp;
+ return 0;
+ }
+};
+
+template <>
+struct Primitive<unsigned PY_LONG_LONG> : OnePrimitive<unsigned PY_LONG_LONG>
+{
+ static PyObject* toPython(const void* cppIn)
+ {
+ return PyLong_FromUnsignedLongLong(*((unsigned PY_LONG_LONG*)cppIn));
+ }
+ 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))
+ 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");
+ }
+#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)
+ {
+ if (SbkNumber_Check(pyIn))
+ return toCpp;
+ return 0;
+ }
+};
+
+// Floating point --------------------------------------------------------------------------
+
+template <typename FLOAT>
+struct FloatPrimitive : TwoPrimitive<FLOAT>
+{
+ static PyObject* toPython(const void* cppIn)
+ {
+ return PyFloat_FromDouble(*reinterpret_cast<const FLOAT *>(cppIn));
+ }
+ static void toCpp(PyObject* pyIn, void* cppOut)
+ {
+ *reinterpret_cast<FLOAT *>(cppOut) = FLOAT(PyLong_AsLong(pyIn));
+ }
+ static PythonToCppFunc isConvertible(PyObject* pyIn)
+ {
+ if (PyInt_Check(pyIn) || PyLong_Check(pyIn))
+ return toCpp;
+ return 0;
+ }
+ static void otherToCpp(PyObject* pyIn, void* cppOut)
+ {
+ *reinterpret_cast<FLOAT *>(cppOut) = FLOAT(PyFloat_AsDouble(pyIn));
+ }
+ static PythonToCppFunc isOtherConvertible(PyObject* pyIn)
+ {
+ if (SbkNumber_Check(pyIn))
+ return otherToCpp;
+ return 0;
+ }
+};
+template <> struct Primitive<float> : FloatPrimitive<float> {};
+template <> struct Primitive<double> : FloatPrimitive<double> {};
+
+// Boolean ---------------------------------------------------------------------------------
+
+template <>
+struct Primitive<bool> : OnePrimitive<bool>
+{
+ static PyObject* toPython(const void* cppIn)
+ {
+ return PyBool_FromLong(*reinterpret_cast<const bool *>(cppIn));
+ }
+ static PythonToCppFunc isConvertible(PyObject* pyIn)
+ {
+ if (SbkNumber_Check(pyIn))
+ return toCpp;
+ return 0;
+ }
+ static void toCpp(PyObject* pyIn, void* cppOut)
+ {
+ *reinterpret_cast<bool *>(cppOut) = PyInt_AS_LONG(pyIn) != 0;
+ }
+};
+
+// Characters ------------------------------------------------------------------------------
+
+template <typename CHAR>
+struct CharPrimitive : IntPrimitive<CHAR>
+{
+ static void toCpp(PyObject* pyIn, void* cppOut)
+ {
+ *reinterpret_cast<CHAR *>(cppOut) = CHAR(Shiboken::String::toCString(pyIn)[0]);
+ }
+ static PythonToCppFunc isConvertible(PyObject* pyIn)
+ {
+ if (Shiboken::String::checkChar(pyIn))
+ return toCpp;
+ return 0;
+ }
+ static void otherToCpp(PyObject* pyIn, void* cppOut)
+ {
+ PY_LONG_LONG result = PyLong_AsLongLong(pyIn);
+ if (OverFlowChecker<CHAR>::check(result, pyIn))
+ PyErr_SetObject(PyExc_OverflowError, 0);
+ *reinterpret_cast<CHAR *>(cppOut) = CHAR(result);
+ }
+ static PythonToCppFunc isOtherConvertible(PyObject* pyIn)
+ {
+ if (SbkNumber_Check(pyIn))
+ return otherToCpp;
+ return 0;
+ }
+ static SbkConverter* createConverter()
+ {
+ SbkConverter* converter = IntPrimitive<CHAR>::createConverter();
+ Shiboken::Conversions::addPythonToCppValueConversion(converter, CharPrimitive<CHAR>::otherToCpp, CharPrimitive<CHAR>::isOtherConvertible);
+ return converter;
+ }
+
+};
+template <> struct Primitive<signed char> : CharPrimitive<signed char> {};
+template <> struct Primitive<unsigned char> : CharPrimitive<unsigned char> {};
+template <> struct Primitive<char> : CharPrimitive<char> {
+ using CharPrimitive<char>::toPython;
+ static PyObject* toPython(const void* cppIn) {
+ return Shiboken::String::fromCString((const char*)cppIn, 1);
+ }
+};
+
+
+
+// Strings ---------------------------------------------------------------------------------
+
+template <>
+struct Primitive<const char*> : TwoPrimitive<const char*>
+{
+ static PyObject* toPython(const void* cppIn)
+ {
+ if (!cppIn)
+ Py_RETURN_NONE;
+ return Shiboken::String::fromCString((const char*)cppIn);
+ }
+ static void toCpp(PyObject *, void *cppOut)
+ {
+ *((const char**)cppOut) = 0;
+ }
+ static PythonToCppFunc isConvertible(PyObject* pyIn)
+ {
+ if (pyIn == Py_None)
+ return toCpp;
+ return 0;
+ }
+ static void otherToCpp(PyObject* pyIn, void* cppOut)
+ {
+ *((const char**)cppOut) = (const char*) Shiboken::String::toCString(pyIn);
+ }
+ static PythonToCppFunc isOtherConvertible(PyObject* pyIn)
+ {
+ if (Shiboken::String::check(pyIn))
+ return otherToCpp;
+ return 0;
+ }
+};
+
+template <>
+struct Primitive<std::string> : TwoPrimitive<std::string>
+{
+ static PyObject* toPython(const void* cppIn)
+ {
+ return Shiboken::String::fromCString(((std::string*)cppIn)->c_str());
+ }
+ static void toCpp(PyObject *, void *cppOut)
+ {
+ *((std::string*)cppOut) = std::string();
+ }
+ static PythonToCppFunc isConvertible(PyObject* pyIn)
+ {
+ if (pyIn == Py_None)
+ return toCpp;
+ return 0;
+ }
+ static void otherToCpp(PyObject* pyIn, void* cppOut)
+ {
+ *((std::string*)cppOut) = Shiboken::String::toCString(pyIn);
+ }
+ static PythonToCppFunc isOtherConvertible(PyObject* pyIn)
+ {
+ if (Shiboken::String::check(pyIn))
+ return otherToCpp;
+ return 0;
+ }
+};
+
+// Void pointer ----------------------------------------------------------------------------
+
+template <>
+struct Primitive<void*> : OnePrimitive<void*>
+{
+ static PyObject* toPython(const void* cppIn)
+ {
+ SbkDbg() << cppIn;
+ if (!cppIn)
+ Py_RETURN_NONE;
+ PyObject *result = reinterpret_cast<PyObject *>(const_cast<void *>(cppIn));
+ Py_INCREF(result);
+ return result;
+ }
+ static void toCpp(PyObject* pyIn, void* cppOut)
+ {
+ SbkDbg() << pyIn;
+ *reinterpret_cast<void **>(cppOut) = pyIn;
+ }
+ static PythonToCppFunc isConvertible(PyObject *)
+ {
+ return toCpp;
+ }
+};
+
+#endif // SBK_CONVERTER_P_H
diff --git a/sources/shiboken2/libshiboken/sbkdbg.h b/sources/shiboken2/libshiboken/sbkdbg.h
new file mode 100644
index 000000000..937153adf
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkdbg.h
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SBKDBG_H
+#define SBKDBG_H
+
+#include "sbkpython.h"
+#include "basewrapper.h"
+#include <iostream>
+
+#ifndef NOCOLOR
+ #define COLOR_END "\033[0m"
+ #define COLOR_WHITE "\033[1;37m"
+ #define COLOR_YELLOW "\033[1;33m"
+ #define COLOR_GREEN "\033[0;32m"
+ #define COLOR_RED "\033[0;31m"
+#else
+ #define COLOR_END ""
+ #define COLOR_WHITE ""
+ #define COLOR_YELLOW ""
+ #define COLOR_GREEN ""
+ #define COLOR_RED ""
+#endif
+
+#ifndef NDEBUG
+
+class BaseLogger
+{
+public:
+ BaseLogger(std::ostream& output, const char* function, const char* context)
+ : m_stream(output), m_function(function), m_context(context) {}
+ ~BaseLogger()
+ {
+ m_stream << std::endl;
+ }
+ std::ostream& operator()() { return m_stream; };
+ template <typename T>
+ std::ostream& operator<<(const T& t)
+ {
+ m_stream << '[';
+ if (m_context[0])
+ m_stream << COLOR_GREEN << m_context << COLOR_END << "|";
+ return m_stream << COLOR_WHITE << m_function << COLOR_END << "] " << t;
+ }
+private:
+ std::ostream& m_stream;
+ const char* m_function;
+ const char* m_context;
+};
+
+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 {
+ out << reinterpret_cast<void*>(obj);
+ }
+ return out;
+}
+
+class _SbkDbg : public BaseLogger
+{
+public:
+ _SbkDbg(const char* function, const char* context = "") : BaseLogger(std::cout, function, context) {}
+};
+
+#ifdef __GNUG__
+#define SbkDbg(X) _SbkDbg(__PRETTY_FUNCTION__, X"")
+#else
+#define SbkDbg(X) _SbkDbg(__FUNCTION__, X"")
+#endif
+
+#else
+
+struct SbkDbg {
+ template <typename T>
+ SbkDbg& operator<<(const T&) { return *this; }
+};
+
+#endif
+#endif // LOGGER_H
diff --git a/sources/shiboken2/libshiboken/sbkenum.cpp b/sources/shiboken2/libshiboken/sbkenum.cpp
new file mode 100644
index 000000000..009d9ab2f
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkenum.cpp
@@ -0,0 +1,623 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "sbkenum.h"
+#include "sbkstring.h"
+#include "sbkconverter.h"
+#include "basewrapper.h"
+#include "sbkdbg.h"
+#include "autodecref.h"
+#include "typeresolver.h"
+#include "sbkpython.h"
+
+#include <string.h>
+#include <cstring>
+#include <list>
+
+#define SBK_ENUM(ENUM) reinterpret_cast<SbkEnumObject*>(ENUM)
+
+extern "C"
+{
+
+struct SbkEnumType
+{
+ PyHeapTypeObject super;
+ SbkConverter** converterPtr;
+ SbkConverter* converter;
+ const char* cppName;
+};
+
+struct SbkEnumObject
+{
+ PyObject_HEAD
+ long ob_value;
+ PyObject* ob_name;
+};
+
+static PyObject* SbkEnumObject_repr(PyObject* self)
+{
+ const SbkEnumObject *enumObj = reinterpret_cast<SbkEnumObject *>(self);
+ if (enumObj->ob_name)
+ return Shiboken::String::fromFormat("%s.%s", self->ob_type->tp_name, PyBytes_AS_STRING(enumObj->ob_name));
+ else
+ return Shiboken::String::fromFormat("%s(%ld)", self->ob_type->tp_name, enumObj->ob_value);
+}
+
+static int SbkEnumObject_print(PyObject* self, FILE* fp, int)
+{
+ Py_BEGIN_ALLOW_THREADS
+ const SbkEnumObject *enumObj = reinterpret_cast<SbkEnumObject *>(self);
+ if (enumObj->ob_name)
+ fprintf(fp, "%s.%s", self->ob_type->tp_name, PyBytes_AS_STRING(enumObj->ob_name));
+ else
+ fprintf(fp, "%s(%ld)", self->ob_type->tp_name, enumObj->ob_value);
+ Py_END_ALLOW_THREADS
+ return 0;
+}
+
+static PyObject* SbkEnumObject_name(PyObject* self, void*)
+{
+ SbkEnumObject *enum_self = reinterpret_cast<SbkEnumObject *>(self);
+
+ if (enum_self->ob_name == NULL)
+ Py_RETURN_NONE;
+
+ Py_INCREF(enum_self->ob_name);
+ return enum_self->ob_name;
+}
+
+static PyObject* SbkEnum_tp_new(PyTypeObject *type, PyObject *args, PyObject *)
+{
+ long itemValue = 0;
+ if (!PyArg_ParseTuple(args, "|l:__new__", &itemValue))
+ return 0;
+
+ SbkEnumObject* self = PyObject_New(SbkEnumObject, type);
+ if (!self)
+ return 0;
+ self->ob_value = itemValue;
+ PyObject* item = Shiboken::Enum::getEnumItemFromValue(type, itemValue);
+ if (item) {
+ self->ob_name = SbkEnumObject_name(item, 0);
+ Py_XDECREF(item);
+ } else {
+ self->ob_name = 0;
+ }
+ return reinterpret_cast<PyObject*>(self);
+}
+
+/* Notes:
+ * On Py3k land we use long type when using integer numbers. However, on older
+ * versions of Python (version 2) we need to convert it to int type,
+ * respectively.
+ *
+ * Thus calling PyInt_FromLong() will result in calling PyLong_FromLong in
+ * Py3k.
+ */
+static PyObject* enum_int(PyObject* v)
+{
+ return PyInt_FromLong(SBK_ENUM(v)->ob_value);
+}
+
+static long getNumberValue(PyObject* v)
+{
+ PyObject* number = PyNumber_Long(v);
+ long result = PyLong_AsLong(number);
+ Py_XDECREF(number);
+ return result;
+}
+
+static PyObject* enum_and(PyObject* self, PyObject* b)
+{
+ if (!PyNumber_Check(b)) {
+ Py_INCREF(Py_NotImplemented);
+ return Py_NotImplemented;
+ }
+
+ long valA = SBK_ENUM(self)->ob_value;
+ long valB = getNumberValue(b);
+ return PyInt_FromLong(valA & valB);
+}
+
+static PyObject* enum_or(PyObject* self, PyObject* b)
+{
+ if (!PyNumber_Check(b)) {
+ Py_INCREF(Py_NotImplemented);
+ return Py_NotImplemented;
+ }
+
+ long valA = SBK_ENUM(self)->ob_value;
+ long valB = getNumberValue(b);
+ return PyInt_FromLong(valA | valB);
+}
+
+static PyObject* enum_xor(PyObject* self, PyObject* b)
+{
+ if (!PyNumber_Check(b)) {
+ Py_INCREF(Py_NotImplemented);
+ return Py_NotImplemented;
+ }
+
+ long valA = SBK_ENUM(self)->ob_value;
+ long valB = getNumberValue(b);
+ return PyInt_FromLong(valA ^ valB);
+}
+
+static int enum_bool(PyObject* v)
+{
+ return (SBK_ENUM(v)->ob_value > 0);
+}
+
+static PyObject* enum_add(PyObject* self, PyObject* v)
+{
+ long valA = SBK_ENUM(self)->ob_value;
+ long valB = getNumberValue(v);
+ return PyInt_FromLong(valA + valB);
+}
+
+static PyObject* enum_subtract(PyObject* self, PyObject* v)
+{
+ long valA = SBK_ENUM(self)->ob_value;
+ long valB = getNumberValue(v);
+ return PyInt_FromLong(valA - valB);
+}
+
+static PyObject* enum_multiply(PyObject* self, PyObject* v)
+{
+ long valA = SBK_ENUM(self)->ob_value;
+ long valB = getNumberValue(v);
+ return PyInt_FromLong(valA * valB);
+}
+
+#ifndef IS_PY3K
+static PyObject* enum_divide(PyObject* self, PyObject* v)
+{
+ long valA = SBK_ENUM(self)->ob_value;
+ long valB = getNumberValue(v);
+ return PyLong_FromLong(valA / valB);
+}
+#endif
+
+static PyObject* enum_richcompare(PyObject* self, PyObject* other, int op)
+{
+ int result = 0;
+ if (!PyNumber_Check(other)) {
+ Py_INCREF(Py_NotImplemented);
+ return Py_NotImplemented;
+ }
+
+ long valA = SBK_ENUM(self)->ob_value;
+ long valB = getNumberValue(other);
+
+ switch (op) {
+ case Py_EQ:
+ result = (valA == valB);
+ break;
+ case Py_NE:
+ result = (valA != valB);
+ break;
+ case Py_LE:
+ result = (valA <= valB);
+ break;
+ case Py_GE:
+ result = (valA >= valB);
+ break;
+ case Py_LT:
+ result = (valA < valB);
+ break;
+ case Py_GT:
+ result = (valA > valB);
+ break;
+ default:
+ PyErr_BadArgument();
+ return NULL;
+ }
+ if (result)
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+}
+
+static Py_hash_t enum_hash(PyObject* pyObj)
+{
+ Py_hash_t val = reinterpret_cast<SbkEnumObject*>(pyObj)->ob_value;
+ if (val == -1)
+ val = -2;
+ return val;
+}
+
+static PyGetSetDef SbkEnumGetSetList[] = {
+ {const_cast<char*>("name"), &SbkEnumObject_name, 0, 0, 0},
+ {0, 0, 0, 0, 0} // Sentinel
+};
+
+static PyNumberMethods enum_as_number = {
+ /* nb_add */ enum_add,
+ /* nb_subtract */ enum_subtract,
+ /* nb_multiply */ enum_multiply,
+#ifndef IS_PY3K
+ /* nb_divide */ enum_divide,
+#endif
+ /* nb_remainder */ 0,
+ /* nb_divmod */ 0,
+ /* nb_power */ 0,
+ /* nb_negative */ 0,
+ /* nb_positive */ enum_int,
+ /* nb_absolute */ 0,
+ /* nb_bool/nb_nonzero */ enum_bool,
+ /* nb_invert */ 0,
+ /* nb_lshift */ 0,
+ /* nb_rshift */ 0,
+ /* nb_and */ enum_and,
+ /* nb_xor */ enum_xor,
+ /* nb_or */ enum_or,
+#ifndef IS_PY3K
+ /* nb_coerce */ 0,
+#endif
+ /* nb_int */ enum_int,
+#ifdef IS_PY3K
+ /* nb_reserved */ 0,
+ /* nb_float */ 0,
+#else
+ /* nb_long */ enum_int,
+ /* nb_float */ 0,
+ /* nb_oct */ 0,
+ /* nb_hex */ 0,
+#endif
+
+ /* nb_inplace_add */ 0,
+ /* nb_inplace_subtract */ 0,
+ /* nb_inplace_multiply */ 0,
+#ifndef IS_PY3K
+ /* nb_inplace_div */ 0,
+#endif
+ /* nb_inplace_remainder */ 0,
+ /* nb_inplace_power */ 0,
+ /* nb_inplace_lshift */ 0,
+ /* nb_inplace_rshift */ 0,
+ /* nb_inplace_and */ 0,
+ /* nb_inplace_xor */ 0,
+ /* nb_inplace_or */ 0,
+
+ /* nb_floor_divide */ 0,
+ /* nb_true_divide */ 0,
+ /* nb_inplace_floor_divide */ 0,
+ /* nb_inplace_true_divide */ 0,
+
+ /* nb_index */ enum_int
+};
+
+static void SbkEnumTypeDealloc(PyObject* pyObj);
+static PyObject* SbkEnumTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwds);
+
+PyTypeObject SbkEnumType_Type = {
+ PyVarObject_HEAD_INIT(0, 0)
+ /*tp_name*/ "Shiboken.EnumType",
+ /*tp_basicsize*/ sizeof(SbkEnumType),
+ /*tp_itemsize*/ 0,
+ /*tp_dealloc*/ SbkEnumTypeDealloc,
+ /*tp_print*/ 0,
+ /*tp_getattr*/ 0,
+ /*tp_setattr*/ 0,
+ /*tp_compare*/ 0,
+ /*tp_repr*/ 0,
+ /*tp_as_number*/ &enum_as_number,
+ /*tp_as_sequence*/ 0,
+ /*tp_as_mapping*/ 0,
+ /*tp_hash*/ 0,
+ /*tp_call*/ 0,
+ /*tp_str*/ 0,
+ /*tp_getattro*/ 0,
+ /*tp_setattro*/ 0,
+ /*tp_as_buffer*/ 0,
+ /*tp_flags*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES,
+ /*tp_doc*/ 0,
+ /*tp_traverse*/ 0,
+ /*tp_clear*/ 0,
+ /*tp_richcompare*/ 0,
+ /*tp_weaklistoffset*/ 0,
+ /*tp_iter*/ 0,
+ /*tp_iternext*/ 0,
+ /*tp_methods*/ 0,
+ /*tp_members*/ 0,
+ /*tp_getset*/ 0,
+ /*tp_base*/ &PyType_Type,
+ /*tp_dict*/ 0,
+ /*tp_descr_get*/ 0,
+ /*tp_descr_set*/ 0,
+ /*tp_dictoffset*/ 0,
+ /*tp_init*/ 0,
+ /*tp_alloc*/ PyType_GenericAlloc,
+ /*tp_new*/ SbkEnumTypeTpNew,
+ /*tp_free*/ PyObject_GC_Del,
+ /*tp_is_gc*/ 0,
+ /*tp_bases*/ 0,
+ /*tp_mro*/ 0,
+ /*tp_cache*/ 0,
+ /*tp_subclasses*/ 0,
+ /*tp_weaklist*/ 0,
+ /*tp_del*/ 0,
+ /*tp_version_tag*/ 0
+};
+
+void SbkEnumTypeDealloc(PyObject* pyObj)
+{
+ SbkEnumType* sbkType = reinterpret_cast<SbkEnumType*>(pyObj);
+
+ PyObject_GC_UnTrack(pyObj);
+ Py_TRASHCAN_SAFE_BEGIN(pyObj);
+ if (sbkType->converter) {
+ Shiboken::Conversions::deleteConverter(sbkType->converter);
+ }
+ Py_TRASHCAN_SAFE_END(pyObj);
+}
+
+PyObject* SbkEnumTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwds)
+{
+ SbkEnumType* newType = reinterpret_cast<SbkEnumType*>(PyType_Type.tp_new(metatype, args, kwds));
+ if (!newType)
+ return 0;
+ return reinterpret_cast<PyObject*>(newType);
+}
+
+} // extern "C"
+
+namespace Shiboken {
+
+class DeclaredEnumTypes
+{
+public:
+ DeclaredEnumTypes();
+ ~DeclaredEnumTypes();
+ static DeclaredEnumTypes& instance();
+ void addEnumType(PyTypeObject* type);
+
+private:
+ DeclaredEnumTypes(const DeclaredEnumTypes&);
+ DeclaredEnumTypes& operator=(const DeclaredEnumTypes&);
+ std::list<PyTypeObject*> m_enumTypes;
+};
+
+namespace Enum {
+
+bool check(PyObject* pyObj)
+{
+ return Py_TYPE(pyObj->ob_type) == &SbkEnumType_Type;
+}
+
+PyObject* getEnumItemFromValue(PyTypeObject* enumType, long itemValue)
+{
+ PyObject *key, *value;
+ Py_ssize_t pos = 0;
+ PyObject* values = PyDict_GetItemString(enumType->tp_dict, const_cast<char*>("values"));
+
+ while (PyDict_Next(values, &pos, &key, &value)) {
+ SbkEnumObject *obj = reinterpret_cast<SbkEnumObject *>(value);
+ if (obj->ob_value == itemValue) {
+ Py_INCREF(obj);
+ return value;
+ }
+ }
+ return 0;
+}
+
+static PyTypeObject* createEnum(const char* fullName, const char* cppName, const char* shortName, PyTypeObject* flagsType)
+{
+ PyTypeObject* enumType = newTypeWithName(fullName, cppName);
+ if (flagsType)
+ enumType->tp_as_number = flagsType->tp_as_number;
+ if (PyType_Ready(enumType) < 0)
+ return 0;
+ Shiboken::TypeResolver::createValueTypeResolver<int>(cppName);
+ if (shortName)
+ Shiboken::TypeResolver::createValueTypeResolver<int>(shortName);
+ return enumType;
+}
+
+PyTypeObject* createGlobalEnum(PyObject* module, const char* name, const char* fullName, const char* cppName, PyTypeObject* flagsType)
+{
+ PyTypeObject* enumType = createEnum(fullName, cppName, name, flagsType);
+ Shiboken::TypeResolver::createValueTypeResolver<int>("Qt::WindowType");
+ Shiboken::TypeResolver::createValueTypeResolver<int>("WindowType");
+ if (enumType && PyModule_AddObject(module, name, reinterpret_cast<PyObject *>(enumType)) < 0)
+ return 0;
+ if (flagsType && PyModule_AddObject(module, flagsType->tp_name, reinterpret_cast<PyObject *>(flagsType)) < 0)
+ return 0;
+ return enumType;
+}
+
+PyTypeObject* createScopedEnum(SbkObjectType* scope, const char* name, const char* fullName, const char* cppName, PyTypeObject* flagsType)
+{
+ PyTypeObject* enumType = createEnum(fullName, cppName, name, flagsType);
+ if (enumType && PyDict_SetItemString(scope->super.ht_type.tp_dict, name, reinterpret_cast<PyObject *>(enumType)) < 0)
+ return 0;
+ if (flagsType && PyDict_SetItemString(scope->super.ht_type.tp_dict, flagsType->tp_name, reinterpret_cast<PyObject *>(flagsType)) < 0)
+ return 0;
+ return enumType;
+}
+
+static PyObject* createEnumItem(PyTypeObject* enumType, const char* itemName, long itemValue)
+{
+ PyObject* enumItem = newItem(enumType, itemValue, itemName);
+ if (PyDict_SetItemString(enumType->tp_dict, itemName, enumItem) < 0)
+ return 0;
+ Py_DECREF(enumItem);
+ return enumItem;
+}
+
+bool createGlobalEnumItem(PyTypeObject* enumType, PyObject* module, const char* itemName, long itemValue)
+{
+ PyObject* enumItem = createEnumItem(enumType, itemName, itemValue);
+ if (enumItem) {
+ if (PyModule_AddObject(module, itemName, enumItem) < 0)
+ return false;
+ // @TODO This Py_DECREF causes crashes on exit with a debug Python interpreter, essentially
+ // causing a use-after-free in the GC. This is now commented out to cause a memory leak
+ // instead of a crash. Proper memory management of Enum types and items should be
+ // implemented. See PYSIDE-488. This will require proper allocation and deallocation of
+ // the underlying Enum PyHeapType, which is currently just deallocated at application exit.
+ // Py_DECREF(enumItem);
+ return true;
+ }
+ return false;
+}
+
+bool createScopedEnumItem(PyTypeObject* enumType, SbkObjectType* scope, const char* itemName, long itemValue)
+{
+ PyObject* enumItem = createEnumItem(enumType, itemName, itemValue);
+ if (enumItem) {
+ if (PyDict_SetItemString(scope->super.ht_type.tp_dict, itemName, enumItem) < 0)
+ return false;
+ Py_DECREF(enumItem);
+ return true;
+ }
+ return false;
+}
+
+PyObject* newItem(PyTypeObject* enumType, long itemValue, const char* itemName)
+{
+ bool newValue = true;
+ SbkEnumObject* enumObj;
+ if (!itemName) {
+ enumObj = reinterpret_cast<SbkEnumObject*>(getEnumItemFromValue(enumType, itemValue));
+ if (enumObj)
+ return reinterpret_cast<PyObject*>(enumObj);
+
+ newValue = false;
+ }
+
+ enumObj = PyObject_New(SbkEnumObject, enumType);
+ if (!enumObj)
+ return 0;
+
+ enumObj->ob_name = itemName ? PyBytes_FromString(itemName) : 0;
+ enumObj->ob_value = itemValue;
+
+ if (newValue) {
+ PyObject* values = PyDict_GetItemString(enumType->tp_dict, const_cast<char*>("values"));
+ if (!values) {
+ values = PyDict_New();
+ PyDict_SetItemString(enumType->tp_dict, const_cast<char*>("values"), values);
+ Py_DECREF(values); // ^ values still alive, because setitemstring incref it
+ }
+ PyDict_SetItemString(values, itemName, reinterpret_cast<PyObject*>(enumObj));
+ }
+
+ return reinterpret_cast<PyObject*>(enumObj);
+}
+
+PyTypeObject* newType(const char* name)
+{
+ return newTypeWithName(name, "");
+}
+
+PyTypeObject* newTypeWithName(const char* name, const char* cppName)
+{
+ PyTypeObject* type = reinterpret_cast<PyTypeObject*>(new SbkEnumType);
+ ::memset(type, 0, sizeof(SbkEnumType));
+ Py_TYPE(type) = &SbkEnumType_Type;
+ type->tp_basicsize = sizeof(SbkEnumObject);
+ type->tp_print = &SbkEnumObject_print;
+ type->tp_repr = &SbkEnumObject_repr;
+ type->tp_str = &SbkEnumObject_repr;
+ type->tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES;
+ type->tp_name = name;
+ type->tp_getset = SbkEnumGetSetList;
+ type->tp_new = SbkEnum_tp_new;
+ type->tp_as_number = &enum_as_number;
+ type->tp_richcompare = &enum_richcompare;
+ type->tp_hash = &enum_hash;
+
+ SbkEnumType* enumType = reinterpret_cast<SbkEnumType*>(type);
+ enumType->cppName = cppName;
+ enumType->converterPtr = &enumType->converter;
+ DeclaredEnumTypes::instance().addEnumType(type);
+ return type;
+}
+
+const char* getCppName(PyTypeObject* enumType)
+{
+ assert(Py_TYPE(enumType) == &SbkEnumType_Type);
+ return reinterpret_cast<SbkEnumType*>(enumType)->cppName;;
+}
+
+long int getValue(PyObject* enumItem)
+{
+ assert(Shiboken::Enum::check(enumItem));
+ return reinterpret_cast<SbkEnumObject*>(enumItem)->ob_value;
+}
+
+void setTypeConverter(PyTypeObject* enumType, SbkConverter* converter)
+{
+ //reinterpret_cast<SbkEnumType*>(enumType)->converter = converter;
+ SBK_CONVERTER(enumType) = converter;
+}
+
+SbkConverter* getTypeConverter(PyTypeObject* enumType)
+{
+ //return reinterpret_cast<SbkEnumType*>(enumType)->converter;
+ return SBK_CONVERTER(enumType);
+}
+
+} // namespace Enum
+
+DeclaredEnumTypes& DeclaredEnumTypes::instance()
+{
+ static DeclaredEnumTypes me;
+ return me;
+}
+
+DeclaredEnumTypes::DeclaredEnumTypes()
+{
+}
+
+DeclaredEnumTypes::~DeclaredEnumTypes()
+{
+ std::list<PyTypeObject*>::const_iterator it = m_enumTypes.begin();
+ for (; it != m_enumTypes.end(); ++it)
+ delete *it;
+ m_enumTypes.clear();
+}
+
+void DeclaredEnumTypes::addEnumType(PyTypeObject* type)
+{
+ m_enumTypes.push_back(type);
+}
+
+}
diff --git a/sources/shiboken2/libshiboken/sbkenum.h b/sources/shiboken2/libshiboken/sbkenum.h
new file mode 100644
index 000000000..4b572dbcc
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkenum.h
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SBKENUM_H
+#define SBKENUM_H
+
+#include "sbkpython.h"
+#include "shibokenmacros.h"
+
+extern "C"
+{
+
+extern LIBSHIBOKEN_API PyTypeObject SbkEnumType_Type;
+struct SbkObjectType;
+struct SbkConverter;
+
+} // extern "C"
+
+namespace Shiboken
+{
+
+inline bool isShibokenEnum(PyObject* pyObj)
+{
+ return Py_TYPE(pyObj->ob_type) == &SbkEnumType_Type;
+}
+
+namespace Enum
+{
+ LIBSHIBOKEN_API bool check(PyObject* obj);
+ /**
+ * Creates a new enum type (and its flags type, if any is given)
+ * and registers it to Python and adds it to \p module.
+ * \param module Module to where the new enum type will be added.
+ * \param name Name of the enum.
+ * \param fullName Name of the enum that includes all scope information (e.g.: "module.Enum").
+ * \param cppName Full qualified C++ name of the enum.
+ * \param flagsType Optional Python type for the flags associated with the enum.
+ * \return The new enum type or NULL if it fails.
+ */
+ LIBSHIBOKEN_API PyTypeObject* createGlobalEnum(PyObject* module,
+ const char* name,
+ const char* fullName,
+ const char* cppName,
+ PyTypeObject* flagsType = 0);
+ /// This function does the same as createGlobalEnum, but adds the enum to a Shiboken type or namespace.
+ LIBSHIBOKEN_API PyTypeObject* createScopedEnum(SbkObjectType* scope,
+ const char* name,
+ const char* fullName,
+ const char* cppName,
+ PyTypeObject* flagsType = 0);
+
+ /**
+ * Creates a new enum item for a given enum type and adds it to \p module.
+ * \param enumType Enum type to where the new enum item will be added.
+ * \param module Module to where the enum type of the new enum item belongs.
+ * \param itemName Name of the enum item.
+ * \param itemValue Numerical value of the enum item.
+ * \return true if everything goes fine, false if it fails.
+ */
+ LIBSHIBOKEN_API bool createGlobalEnumItem(PyTypeObject* enumType, PyObject* module, const char* itemName, long itemValue);
+ /// This function does the same as createGlobalEnumItem, but adds the enum to a Shiboken type or namespace.
+ LIBSHIBOKEN_API bool createScopedEnumItem(PyTypeObject* enumType, SbkObjectType* scope, const char* itemName, long itemValue);
+
+ LIBSHIBOKEN_API PyObject* newItem(PyTypeObject* enumType, long itemValue, const char* itemName = 0);
+
+ /// \deprecated Use 'newTypeWithName'
+ SBK_DEPRECATED(LIBSHIBOKEN_API PyTypeObject* newType(const char* name));
+ LIBSHIBOKEN_API PyTypeObject* newTypeWithName(const char* name, const char* cppName);
+ LIBSHIBOKEN_API const char* getCppName(PyTypeObject* type);
+
+ LIBSHIBOKEN_API long getValue(PyObject* enumItem);
+ LIBSHIBOKEN_API PyObject* getEnumItemFromValue(PyTypeObject* enumType, long itemValue);
+
+ /// Sets the enum's type converter.
+ LIBSHIBOKEN_API void setTypeConverter(PyTypeObject* enumType, SbkConverter* converter);
+ /// Returns the converter assigned to the enum \p type.
+ LIBSHIBOKEN_API SbkConverter* getTypeConverter(PyTypeObject* enumType);
+}
+
+} // namespace Shiboken
+
+#endif // SKB_PYENUM_H
diff --git a/sources/shiboken2/libshiboken/sbkmodule.cpp b/sources/shiboken2/libshiboken/sbkmodule.cpp
new file mode 100644
index 000000000..084e23efa
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkmodule.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "sbkmodule.h"
+#include "basewrapper.h"
+#include "bindingmanager.h"
+
+// TODO: for performance reasons this should be a sparse_hash_map,
+// because there'll be very few modules as keys. The sparse_hash_map
+// is missing from the code added in ../ext/sparsehash/google directory.
+#include "google/dense_hash_map"
+
+/// This hash maps module objects to arrays of Python types.
+typedef google::dense_hash_map<PyObject*, PyTypeObject**> ModuleTypesMap;
+
+/// This hash maps module objects to arrays of converters.
+typedef google::dense_hash_map<PyObject*, SbkConverter**> ModuleConvertersMap;
+
+/// All types produced in imported modules are mapped here.
+static ModuleTypesMap moduleTypes;
+static ModuleConvertersMap moduleConverters;
+
+namespace Shiboken
+{
+namespace Module
+{
+
+void init()
+{
+ // Initializes type registry for modules.
+ moduleTypes.set_empty_key((ModuleTypesMap::key_type)0);
+ moduleTypes.set_deleted_key((ModuleTypesMap::key_type)1);
+ moduleConverters.set_empty_key((ModuleConvertersMap::key_type)0);
+ moduleConverters.set_deleted_key((ModuleConvertersMap::key_type)1);
+}
+
+PyObject* import(const char* moduleName)
+{
+ PyObject* sysModules = PyImport_GetModuleDict();
+ PyObject* module = PyDict_GetItemString(sysModules, moduleName);
+ if (module)
+ Py_INCREF(module);
+ else
+ module = PyImport_ImportModule(moduleName);
+
+ if (!module)
+ PyErr_Format(PyExc_ImportError,"could not import module '%s'", moduleName);
+
+ return module;
+}
+
+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)
+{
+ ModuleTypesMap::iterator iter = moduleTypes.find(module);
+ if (iter == moduleTypes.end())
+ moduleTypes.insert(std::make_pair(module, types));
+}
+
+PyTypeObject** getTypes(PyObject* module)
+{
+ ModuleTypesMap::iterator iter = moduleTypes.find(module);
+ return (iter == moduleTypes.end()) ? 0 : iter->second;
+}
+
+void registerTypeConverters(PyObject* module, SbkConverter** converters)
+{
+ ModuleConvertersMap::iterator iter = moduleConverters.find(module);
+ if (iter == moduleConverters.end())
+ moduleConverters.insert(std::make_pair(module, converters));
+}
+
+SbkConverter** getTypeConverters(PyObject* module)
+{
+ ModuleConvertersMap::iterator iter = moduleConverters.find(module);
+ return (iter == moduleConverters.end()) ? 0 : iter->second;
+}
+
+} } // namespace Shiboken::Module
diff --git a/sources/shiboken2/libshiboken/sbkmodule.h b/sources/shiboken2/libshiboken/sbkmodule.h
new file mode 100644
index 000000000..e1ec7a860
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkmodule.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SBK_MODULE_H
+#define SBK_MODULE_H
+
+#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" SBK_EXPORT_MODULE 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" SBK_EXPORT_MODULE void init##ModuleName() {
+
+ #define SBK_MODULE_INIT_FUNCTION_END \
+ }
+#endif
+
+extern "C"
+{
+struct SbkConverter;
+}
+
+namespace Shiboken {
+namespace Module {
+
+/**
+ * Imports and returns the module named \p moduleName, or a NULL pointer in case of failure.
+ * If the module is already imported, it increments its reference count before returning it.
+ * \returns the module specified in \p moduleName or NULL if an error occurs.
+ */
+LIBSHIBOKEN_API PyObject* import(const char* moduleName);
+
+/**
+ * Creates a new Python module named \p moduleName using the information passed in \p moduleData.
+ * In fact, \p moduleData expects a "PyMethodDef*" object, but that's for Python 2. A void*
+ * was preferred to make this work with future Python 3 support.
+ * \returns a newly created module.
+ */
+LIBSHIBOKEN_API PyObject* create(const char* moduleName, void* moduleData);
+
+/**
+ * Registers the list of types created by \p module.
+ * \param module Module where the types were created.
+ * \param types Array of PyTypeObject* objects representing the types created on \p module.
+ */
+LIBSHIBOKEN_API void registerTypes(PyObject* module, PyTypeObject** types);
+
+/**
+ * Retrieves the array of types.
+ * \param module Module where the types were created.
+ * \returns A pointer to the PyTypeObject* array of types.
+ */
+LIBSHIBOKEN_API PyTypeObject** getTypes(PyObject* module);
+
+/**
+ * Registers the list of converters created by \p module for non-wrapper types.
+ * \param module Module where the converters were created.
+ * \param converters Array of SbkConverter* objects representing the converters created on \p module.
+ */
+LIBSHIBOKEN_API void registerTypeConverters(PyObject* module, SbkConverter** converters);
+
+/**
+ * Retrieves the array of converters.
+ * \param module Module where the converters were created.
+ * \returns A pointer to the SbkConverter* array of converters.
+ */
+LIBSHIBOKEN_API SbkConverter** getTypeConverters(PyObject* module);
+
+} } // namespace Shiboken::Module
+
+#endif // SBK_MODULE_H
diff --git a/sources/shiboken2/libshiboken/sbkpython.h b/sources/shiboken2/libshiboken/sbkpython.h
new file mode 100644
index 000000000..208618d50
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkpython.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SBKPYTHON_H
+#define SBKPYTHON_H
+
+#include "Python.h"
+#include "python25compat.h"
+
+#if PY_MAJOR_VERSION >= 3
+ #define IS_PY3K
+
+ #define PyInt_Type PyLong_Type
+ #define PyInt_Check PyLong_Check
+ #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
+
+#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_STR_NAME "str"
+ #define SBK_PyMethod_New(X, Y) PyMethod_New(X, Y, reinterpret_cast<PyObject *>(Py_TYPE(Y)))
+
+ #define Py_hash_t long
+#endif
+
+#endif
diff --git a/sources/shiboken2/libshiboken/sbkstring.cpp b/sources/shiboken2/libshiboken/sbkstring.cpp
new file mode 100644
index 000000000..598bccc46
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkstring.cpp
@@ -0,0 +1,202 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "sbkstring.h"
+#include "autodecref.h"
+
+namespace Shiboken
+{
+
+namespace String
+{
+
+bool checkType(PyTypeObject* type)
+{
+ return type == &PyUnicode_Type
+#if PY_MAJOR_VERSION < 3
+ || type == &PyString_Type
+#endif
+ ;
+}
+
+bool check(PyObject* obj)
+{
+ return obj == Py_None ||
+#if PY_MAJOR_VERSION < 3
+ PyString_Check(obj) ||
+#endif
+ PyUnicode_Check(obj);
+}
+
+bool checkChar(PyObject* pyobj)
+{
+ if (check(pyobj) && (len(pyobj) == 1))
+ return true;
+
+ return false;
+}
+
+bool isConvertible(PyObject* obj)
+{
+ return check(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)
+{
+ if (str == Py_None)
+ return NULL;
+#ifdef IS_PY3K
+ if (PyUnicode_Check(str)) {
+ if (len) {
+ // We need to encode the unicode string into utf8 to know the size of returned char*.
+ Shiboken::AutoDecRef uniStr(PyUnicode_AsUTF8String(str));
+ *len = PyBytes_GET_SIZE(uniStr.object());
+ }
+ // Return unicode from str instead of uniStr, because the lifetime of the returned pointer
+ // depends on the lifetime of str.
+ return _PyUnicode_AsString(str);
+ }
+#endif
+ if (PyBytes_Check(str)) {
+ if (len)
+ *len = PyBytes_GET_SIZE(str);
+ return PyBytes_AS_STRING(str);
+ }
+ return 0;
+}
+
+bool concat(PyObject** val1, PyObject* val2)
+{
+ if (PyUnicode_Check(*val1) && PyUnicode_Check(val2)) {
+ PyObject* result = PyUnicode_Concat(*val1, val2);
+ Py_DECREF(*val1);
+ *val1 = result;
+ return true;
+ }
+
+ if (PyBytes_Check(*val1) && PyBytes_Check(val2)) {
+ PyBytes_Concat(val1, val2);
+ return true;
+ }
+
+#if PY_MAJOR_VERSION < 3
+ if (PyString_Check(*val1) && PyString_Check(val2)) {
+ PyString_Concat(val1, val2);
+ return true;
+ }
+#endif
+ return false;
+}
+
+PyObject* fromFormat(const char* format, ...)
+{
+ va_list argp;
+ va_start(argp, format);
+ PyObject* result = 0;
+#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;
+
+}
+
+Py_ssize_t len(PyObject* str)
+{
+ if (str == Py_None)
+ return 0;
+
+ if (PyUnicode_Check(str))
+ return PyUnicode_GET_SIZE(str);
+
+ if (PyBytes_Check(str))
+ return PyBytes_GET_SIZE(str);
+ return 0;
+}
+
+} // namespace String
+
+} // namespace Shiboken
diff --git a/sources/shiboken2/libshiboken/sbkstring.h b/sources/shiboken2/libshiboken/sbkstring.h
new file mode 100644
index 000000000..0d498da6d
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkstring.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SBKSTRING_H
+#define SBKSTRING_H
+
+#include "sbkpython.h"
+#include "shibokenmacros.h"
+
+#if PY_MAJOR_VERSION >= 3
+ #define SBK_STR_NAME "unicode"
+#else
+ #define SBK_STR_NAME "str"
+#endif
+
+namespace Shiboken
+{
+namespace String
+{
+ LIBSHIBOKEN_API bool check(PyObject* obj);
+ LIBSHIBOKEN_API bool checkType(PyTypeObject* obj);
+ LIBSHIBOKEN_API bool checkChar(PyObject* obj);
+ LIBSHIBOKEN_API bool isConvertible(PyObject* obj);
+ LIBSHIBOKEN_API PyObject* fromCString(const char* value);
+ LIBSHIBOKEN_API PyObject* fromCString(const char* value, int len);
+ LIBSHIBOKEN_API const char* toCString(PyObject* str, Py_ssize_t* len = 0);
+ LIBSHIBOKEN_API bool concat(PyObject** val1, PyObject* val2);
+ LIBSHIBOKEN_API PyObject* fromFormat(const char* format, ...);
+ LIBSHIBOKEN_API PyObject* fromStringAndSize(const char* str, Py_ssize_t size);
+ LIBSHIBOKEN_API int compare(PyObject* val1, const char* val2);
+ LIBSHIBOKEN_API Py_ssize_t len(PyObject* str);
+
+} // namespace String
+} // namespace Shiboken
+
+
+#endif
+
+
diff --git a/sources/shiboken2/libshiboken/sbkversion.h.in b/sources/shiboken2/libshiboken/sbkversion.h.in
new file mode 100644
index 000000000..589c5ac26
--- /dev/null
+++ b/sources/shiboken2/libshiboken/sbkversion.h.in
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SBKVERSION_H
+#define SBKVERSION_H
+
+#define SHIBOKEN_VERSION "@shiboken_MAJOR_VERSION@.@shiboken_MINOR_VERSION@.@shiboken_MICRO_VERSION@"
+#define SHIBOKEN_MAJOR_VERSION @shiboken_MAJOR_VERSION@
+#define SHIBOKEN_MINOR_VERSION @shiboken_MINOR_VERSION@
+#define SHIBOKEN_MICRO_VERSION @shiboken_MICRO_VERSION@
+#define SHIBOKEN_RELEASE_LEVEL "final"
+#define SHIBOKEN_SERIAL 0
+
+#endif
diff --git a/sources/shiboken2/libshiboken/shiboken.h b/sources/shiboken2/libshiboken/shiboken.h
new file mode 100644
index 000000000..2738bf51f
--- /dev/null
+++ b/sources/shiboken2/libshiboken/shiboken.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SHIBOKEN_H
+#define SHIBOKEN_H
+
+#include "sbkpython.h"
+#include "autodecref.h"
+#include "basewrapper.h"
+#include "bindingmanager.h"
+#include "conversions.h"
+#include "gilstate.h"
+#include "threadstatesaver.h"
+#include "helper.h"
+#include "sbkconverter.h"
+#include "sbkenum.h"
+#include "sbkmodule.h"
+#include "sbkstring.h"
+#include "shibokenmacros.h"
+#include "typeresolver.h"
+#include "shibokenbuffer.h"
+
+#endif // SHIBOKEN_H
+
diff --git a/sources/shiboken2/libshiboken/shibokenbuffer.cpp b/sources/shiboken2/libshiboken/shibokenbuffer.cpp
new file mode 100644
index 000000000..6cc617668
--- /dev/null
+++ b/sources/shiboken2/libshiboken/shibokenbuffer.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "shibokenbuffer.h"
+#include <cstdlib>
+#include <cstring>
+
+bool Shiboken::Buffer::checkType(PyObject* pyObj)
+{
+ return PyObject_CheckReadBuffer(pyObj);
+}
+
+void* Shiboken::Buffer::getPointer(PyObject* pyObj, Py_ssize_t* size)
+{
+
+#ifdef IS_PY3K
+ Py_buffer view;
+ if (PyObject_GetBuffer(pyObj, &view, PyBUF_ND) == 0) {
+ if (size)
+ *size = view.len;
+ return view.buf;
+ } else {
+ return 0;
+ }
+#else
+ const void* buffer = 0;
+ Py_ssize_t bufferSize = 0;
+
+ PyObject_AsReadBuffer(pyObj, &buffer, &bufferSize);
+
+ if (size)
+ *size = bufferSize;
+ return const_cast<void*>(buffer);
+#endif
+}
+
+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;
+ view.len = size;
+ view.readonly = type == Shiboken::Buffer::ReadOnly;
+ view.ndim = 1;
+ view.itemsize = sizeof(char);
+ Py_ssize_t shape[] = { size };
+ view.shape = shape;
+ return PyMemoryView_FromBuffer(&view);
+#else
+ return type == ReadOnly ? PyBuffer_FromMemory(memory, size) : PyBuffer_FromReadWriteMemory(memory, size);
+#endif
+}
+
+PyObject* Shiboken::Buffer::newObject(const void* memory, Py_ssize_t size)
+{
+ return newObject(const_cast<void*>(memory), size, ReadOnly);
+}
diff --git a/sources/shiboken2/libshiboken/shibokenbuffer.h b/sources/shiboken2/libshiboken/shibokenbuffer.h
new file mode 100644
index 000000000..18d86c6e1
--- /dev/null
+++ b/sources/shiboken2/libshiboken/shibokenbuffer.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SHIBOKEN_BUFFER_H
+#define SHIBOKEN_BUFFER_H
+
+#include "sbkpython.h"
+#include "shibokenmacros.h"
+
+namespace Shiboken
+{
+
+namespace Buffer
+{
+ enum Type {
+ ReadOnly,
+ WriteOnly,
+ ReadWrite
+ };
+
+ /**
+ * Creates a new Python buffer pointing to a contiguous memory block at
+ * \p memory of size \p size.
+ */
+ LIBSHIBOKEN_API PyObject* newObject(void* memory, Py_ssize_t size, Type type);
+
+ /**
+ * Creates a new <b>read only</b> Python buffer pointing to a contiguous memory block at
+ * \p memory of size \p size.
+ */
+ LIBSHIBOKEN_API PyObject* newObject(const void* memory, Py_ssize_t size);
+
+ /**
+ * Check if is ok to use \p pyObj as argument in all function under Shiboken::Buffer namespace.
+ */
+ LIBSHIBOKEN_API bool checkType(PyObject* pyObj);
+
+ /**
+ * Returns a pointer to the memory pointed by the buffer \p pyObj, \p size is filled with the buffer
+ * size if not null.
+ *
+ * If the \p pyObj is a non-contiguous buffer a Python error is set.
+ */
+ LIBSHIBOKEN_API void* getPointer(PyObject* pyObj, Py_ssize_t* size = 0);
+
+} // namespace Buffer
+} // namespace Shiboken
+
+#endif
diff --git a/sources/shiboken2/libshiboken/shibokenmacros.h b/sources/shiboken2/libshiboken/shibokenmacros.h
new file mode 100644
index 000000000..acd8f6ada
--- /dev/null
+++ b/sources/shiboken2/libshiboken/shibokenmacros.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SHIBOKENMACROS_H
+#define SHIBOKENMACROS_H
+
+// LIBSHIBOKEN_API macro is used for the public API symbols.
+#if defined _WIN32
+ #if LIBSHIBOKEN_EXPORTS
+ #define LIBSHIBOKEN_API __declspec(dllexport)
+ #else
+ #ifdef _MSC_VER
+ #define LIBSHIBOKEN_API __declspec(dllimport)
+ #endif
+ #endif
+ #define SBK_DEPRECATED(func) __declspec(deprecated) func
+#elif __GNUC__ >= 4
+ #define LIBSHIBOKEN_API __attribute__ ((visibility("default")))
+ #define SBK_DEPRECATED(func) func __attribute__ ((deprecated))
+#endif
+
+#ifndef LIBSHIBOKEN_API
+ #define LIBSHIBOKEN_API
+ #define SBK_DEPRECATED(func) func
+#endif
+
+#endif
diff --git a/sources/shiboken2/libshiboken/threadstatesaver.cpp b/sources/shiboken2/libshiboken/threadstatesaver.cpp
new file mode 100644
index 000000000..3d3ba81ab
--- /dev/null
+++ b/sources/shiboken2/libshiboken/threadstatesaver.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "threadstatesaver.h"
+
+namespace Shiboken
+{
+
+ThreadStateSaver::ThreadStateSaver()
+ : m_threadState(0)
+ {}
+
+ThreadStateSaver::~ThreadStateSaver()
+{
+ restore();
+}
+
+void ThreadStateSaver::save()
+{
+ if (PyEval_ThreadsInitialized())
+ m_threadState = PyEval_SaveThread();
+}
+
+void ThreadStateSaver::restore()
+{
+ if (m_threadState) {
+ PyEval_RestoreThread(m_threadState);
+ m_threadState = 0;
+ }
+}
+
+} // namespace Shiboken
+
diff --git a/sources/shiboken2/libshiboken/threadstatesaver.h b/sources/shiboken2/libshiboken/threadstatesaver.h
new file mode 100644
index 000000000..3fe595d95
--- /dev/null
+++ b/sources/shiboken2/libshiboken/threadstatesaver.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 THREADSTATESAVER_H
+#define THREADSTATESAVER_H
+
+#include "sbkpython.h"
+#include <shibokenmacros.h>
+
+namespace Shiboken
+{
+
+class LIBSHIBOKEN_API ThreadStateSaver
+{
+public:
+ ThreadStateSaver();
+ ~ThreadStateSaver();
+ void save();
+ void restore();
+private:
+ PyThreadState* m_threadState;
+
+ ThreadStateSaver(const ThreadStateSaver&);
+ ThreadStateSaver& operator=(const ThreadStateSaver&);
+};
+
+} // namespace Shiboken
+
+#endif // THREADSTATESAVER_H
+
diff --git a/sources/shiboken2/libshiboken/tmp-referencetopython/sbkconverter.cpp b/sources/shiboken2/libshiboken/tmp-referencetopython/sbkconverter.cpp
new file mode 100644
index 000000000..c3e25014e
--- /dev/null
+++ b/sources/shiboken2/libshiboken/tmp-referencetopython/sbkconverter.cpp
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "sbkconverter.h"
+#include "sbkconverter_p.h"
+#include "basewrapper_p.h"
+
+#include "sbkdbg.h"
+
+namespace Shiboken {
+namespace Conversions {
+
+static SbkConverter* createConverterObject(PyTypeObject* type,
+ PythonToCppFunc toCppPointerConvFunc,
+ IsConvertibleToCppFunc toCppPointerCheckFunc,
+ CppToPythonFunc pointerToPythonFunc,
+ CppToPythonFunc copyToPythonFunc)
+{
+ SbkConverter* converter = new SbkConverter;
+ converter->pythonType = type;
+
+ converter->pointerToPython = pointerToPythonFunc;
+ converter->copyToPython = copyToPythonFunc;
+
+ converter->toCppPointerConversion = std::make_pair(toCppPointerCheckFunc, toCppPointerConvFunc);
+ converter->toCppConversions.clear();
+
+ return converter;
+}
+
+SbkConverter* createConverter(SbkObjectType* type,
+ PythonToCppFunc toCppPointerConvFunc,
+ IsConvertibleToCppFunc toCppPointerCheckFunc,
+ CppToPythonFunc pointerToPythonFunc,
+ CppToPythonFunc copyToPythonFunc)
+{
+ SbkConverter* converter = createConverterObject((PyTypeObject*)type,
+ toCppPointerConvFunc, toCppPointerCheckFunc,
+ pointerToPythonFunc, copyToPythonFunc);
+ type->d->converter = converter;
+ return converter;
+}
+
+void deleteConverter(SbkConverter* converter)
+{
+ if (converter) {
+ converter->toCppConversions.clear();
+ delete converter;
+ }
+}
+
+void addPythonToCppValueConversion(SbkConverter* converter,
+ PythonToCppFunc pythonToCppFunc,
+ IsConvertibleToCppFunc isConvertibleToCppFunc)
+{
+ converter->toCppConversions.push_back(std::make_pair(isConvertibleToCppFunc, pythonToCppFunc));
+}
+void addPythonToCppValueConversion(SbkObjectType* type,
+ PythonToCppFunc pythonToCppFunc,
+ IsConvertibleToCppFunc isConvertibleToCppFunc)
+{
+ addPythonToCppValueConversion(type->d->converter, pythonToCppFunc, isConvertibleToCppFunc);
+}
+
+PyObject* pointerToPython(SbkObjectType* type, const void* cppIn)
+{
+ if (!cppIn)
+ Py_RETURN_NONE;
+ return type->d->converter->pointerToPython(cppIn);
+}
+
+static inline PyObject* CopyCppToPython(SbkConverter* converter, const void* cppIn)
+{
+ assert(cppIn);
+ return converter->copyToPython(cppIn);
+}
+PyObject* copyToPython(SbkObjectType* type, const void* cppIn)
+{
+ return CopyCppToPython(type->d->converter, cppIn);
+}
+PyObject* toPython(SbkConverter* converter, const void* cppIn)
+{
+ return CopyCppToPython(converter, cppIn);
+}
+
+PyObject* referenceToPython(SbkObjectType* type, const void* cppIn)
+{
+ assert(cppIn);
+ PyObject* pyOut = (PyObject*)BindingManager::instance().retrieveWrapper(cppIn);
+ if (pyOut) {
+ Py_INCREF(pyOut);
+ return pyOut;
+ }
+ // If it is Value Type, return a copy of the C++ object.
+ if (type->d->converter->copyToPython)
+ return type->d->converter->copyToPython(cppIn);
+ // If it is an Object Type, return a copy of the C++ object.
+ return type->d->converter->pointerToPython(cppIn);
+}
+
+PythonToCppFunc isPythonToCppPointerConvertible(SbkObjectType* type, PyObject* pyIn)
+{
+ assert(pyIn);
+ return type->d->converter->toCppPointerConversion.first(pyIn);
+}
+
+static inline PythonToCppFunc IsPythonToCppConvertible(SbkConverter* converter, PyObject* pyIn)
+{
+ assert(pyIn);
+ ToCppConversionList& convs = converter->toCppConversions;
+ for (ToCppConversionList::iterator conv = convs.begin(); conv != convs.end(); ++conv) {
+ PythonToCppFunc toCppFunc = 0;
+ if ((toCppFunc = (*conv).first(pyIn)))
+ return toCppFunc;
+ }
+ return 0;
+}
+PythonToCppFunc isPythonToCppValueConvertible(SbkObjectType* type, PyObject* pyIn)
+{
+ return IsPythonToCppConvertible(type->d->converter, pyIn);
+}
+PythonToCppFunc isPythonToCppConvertible(SbkConverter* converter, PyObject* pyIn)
+{
+ return IsPythonToCppConvertible(converter, pyIn);
+}
+
+PythonToCppFunc isPythonToCppReferenceConvertible(SbkObjectType* type, PyObject* pyIn)
+{
+ if (pyIn != Py_None) {
+ PythonToCppFunc toCpp = isPythonToCppPointerConvertible(type, pyIn);
+ if (toCpp)
+ return toCpp;
+ }
+ return isPythonToCppValueConvertible(type, pyIn);
+}
+
+void nonePythonToCppNullPtr(PyObject*, void* cppOut)
+{
+ assert(cppOut);
+ *((void**)cppOut) = 0;
+}
+
+void pythonToCppPointer(SbkObjectType* type, PyObject* pyIn, void* cppOut)
+{
+ assert(pyIn);
+ assert(cppOut);
+ SbkObjectType* inType = (SbkObjectType*)pyIn->ob_type;
+ if (ObjectType::hasCast(inType))
+ *((void**)cppOut) = ObjectType::cast(inType, (SbkObject*)pyIn, (PyTypeObject*)type);
+ else
+ *((void**)cppOut) = Object::cppPointer((SbkObject*)pyIn, (PyTypeObject*)type);
+}
+
+bool isImplicitConversion(SbkObjectType* type, PythonToCppFunc toCppFunc)
+{
+ // This is the Object Type or Value Type conversion that only
+ // retrieves the C++ pointer held in the Python wrapper.
+ if (toCppFunc == type->d->converter->toCppPointerConversion.second)
+ return false;
+
+ // Object Types doesn't have any kind of value conversion,
+ // only C++ pointer retrieval.
+ if (type->d->converter->toCppConversions.empty())
+ return false;
+
+ // The first conversion of the non-pointer conversion list is
+ // a Value Type's copy to C++ function, which is not an implicit
+ // conversion.
+ // Otherwise it must be one of the implicit conversions.
+ // Note that we don't check if the Python to C++ conversion is in
+ // the list of the type's conversions, for it is expected that the
+ // caller knows what he's doing.
+ ToCppConversionList::iterator conv = type->d->converter->toCppConversions.begin();
+ return toCppFunc != (*conv).second;
+}
+
+} } // namespace Shiboken::Conversions
diff --git a/sources/shiboken2/libshiboken/tmp-referencetopython/sbkconverter.h b/sources/shiboken2/libshiboken/tmp-referencetopython/sbkconverter.h
new file mode 100644
index 000000000..d4bbbca1d
--- /dev/null
+++ b/sources/shiboken2/libshiboken/tmp-referencetopython/sbkconverter.h
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 SBK_CONVERTER_H
+#define SBK_CONVERTER_H
+
+#include <limits>
+#include <Python.h>
+#include "shibokenmacros.h"
+#include "basewrapper.h"
+
+extern "C"
+{
+
+/**
+ * SbkConverter is used to perform type conversions from C++
+ * to Python and vice-versa;.and it is also used for type checking.
+ * SbkConverter is a private structure that must be accessed
+ * using the functions provided by the converter API.
+ */
+struct SbkConverter;
+
+/**
+ * Given a void pointer to a C++ object, this function must return
+ * the proper Python object. It may be either an existing wrapper
+ * for the C++ object, or a newly create one. Or even the Python
+ * equivalent of the C++ value passed in the argument.
+ *
+ * C++ -> Python
+ */
+typedef PyObject* (*CppToPythonFunc)(const void*);
+
+/**
+ * This function converts a Python object to a C++ value, it may be
+ * a pointer, value, class, container or primitive type, passed via
+ * a void pointer, that will be cast properly inside the function.
+ * This function is usually returned by an IsConvertibleToCppFunc
+ * function, or obtained knowing the type of the Python object input,
+ * thus it will not check the Python object type, and will expect
+ * the void pointer to be pointing to a proper variable.
+ *
+ * Python -> C++
+ */
+typedef void (*PythonToCppFunc)(PyObject*,void*);
+
+/**
+ * Checks if the Python object passed in the argument is convertible to a
+ * C++ type defined inside the function, it returns the converter function
+ * that will transform a Python argument into a C++ value.
+ * It returns NULL if the Python object is not convertible to the C++ type
+ * that the function represents.
+ *
+ * Python -> C++ ?
+ */
+typedef PythonToCppFunc (*IsConvertibleToCppFunc)(PyObject*);
+
+} // extern "C"
+
+
+namespace Shiboken {
+namespace Conversions {
+
+/**
+ * Creates a converter for a wrapper type.
+ * \param type A Shiboken.ObjectType that will receive the new converter.
+ * \param toCppPointerConvFunc Function to retrieve the C++ pointer held by a Python wrapper.
+ * \param toCppPointerCheckFunc Check and return the retriever function of the C++ pointer held by a Python wrapper.
+ * \param pointerToPythonFunc Function to convert a C++ object to a Python \p type wrapper, keeping their identity.
+ * \param copyToPythonFunc Function to convert a C++ object to a Python \p type, copying the object.
+ * \returns The new converter referred by the wrapper \p type.
+ */
+LIBSHIBOKEN_API SbkConverter* createConverter(SbkObjectType* type,
+ PythonToCppFunc toCppPointerConvFunc,
+ IsConvertibleToCppFunc toCppPointerCheckFunc,
+ CppToPythonFunc pointerToPythonFunc,
+ CppToPythonFunc copyToPythonFunc = 0);
+
+LIBSHIBOKEN_API void deleteConverter(SbkConverter* converter);
+
+/**
+ * Adds a new conversion of a Python object to a C++ value.
+ * This is used in copy and implicit conversions.
+ */
+LIBSHIBOKEN_API void addPythonToCppValueConversion(SbkConverter* converter,
+ PythonToCppFunc pythonToCppFunc,
+ IsConvertibleToCppFunc isConvertibleToCppFunc);
+LIBSHIBOKEN_API void addPythonToCppValueConversion(SbkObjectType* type,
+ PythonToCppFunc pythonToCppFunc,
+ IsConvertibleToCppFunc isConvertibleToCppFunc);
+
+// C++ -> Python ---------------------------------------------------------------------------
+
+/**
+ * Retrieves the Python wrapper object for the given \p cppIn C++ pointer object.
+ * This function is used only for Value and Object Types.
+ * Example usage:
+ * TYPE* var;
+ * PyObject* pyVar = pointerToPython(SBKTYPE, &var);
+ */
+LIBSHIBOKEN_API PyObject* pointerToPython(SbkObjectType* type, const void* cppIn);
+
+/**
+ * Retrieves the Python wrapper object for the given C++ value pointed by \p cppIn.
+ * This function is used only for Value Types.
+ * Example usage:
+ * TYPE var;
+ * PyObject* pyVar = copyToPython(SBKTYPE, &var);
+ */
+LIBSHIBOKEN_API PyObject* copyToPython(SbkObjectType* type, const void* cppIn);
+
+// TODO:WRITEDOCSTRING - used only for Value Types - cppIn must point to a value
+/**
+ * Retrieves the Python wrapper object for the given C++ reference pointed by \p cppIn.
+ * This function is used only for Value and Object Types.
+ * It differs from pointerToPython() for not checking for a NULL pointer.
+ * Example usage:
+ * TYPE& var = SOMETHING;
+ * PyObject* pyVar = copyToPython(SBKTYPE, &var);
+ */
+LIBSHIBOKEN_API PyObject* referenceToPython(SbkObjectType* type, const void* cppIn);
+
+// TODO:WRITEDOCSTRING - used only for Primitives and Containers (and Value Types) - cppIn must point to a primitive, container or value type
+/// This is the same as copyToPython function.
+LIBSHIBOKEN_API PyObject* toPython(SbkConverter* converter, const void* cppIn);
+
+// Python -> C++ convertibility checks -----------------------------------------------------
+
+// TODO:WRITEDOCSTRING
+LIBSHIBOKEN_API PythonToCppFunc isPythonToCppPointerConvertible(SbkObjectType* type, PyObject* pyIn);
+
+// TODO:WRITEDOCSTRING- Returns a Python to C++ conversion function if true, or NULL if false.
+LIBSHIBOKEN_API PythonToCppFunc isPythonToCppValueConvertible(SbkObjectType* type, PyObject* pyIn);
+
+// TODO:WRITEDOCSTRING- Returns a Python to C++ conversion function if true, or NULL if false.
+LIBSHIBOKEN_API PythonToCppFunc isPythonToCppReferenceConvertible(SbkObjectType* type, PyObject* pyIn);
+
+/// This is the same as isPythonToCppValueConvertible function.
+LIBSHIBOKEN_API PythonToCppFunc isPythonToCppConvertible(SbkConverter* converter, PyObject* pyIn);
+
+// Python -> C++ ---------------------------------------------------------------------------
+
+// TODO:WRITEDOCSTRING - function used by the generated [TYPE]_PythonToCpp_[TYPE]_PTR
+LIBSHIBOKEN_API void pythonToCppPointer(SbkObjectType* type, PyObject* pyIn, void* cppOut);
+
+// TODO:WRITEDOCSTRING - function used by the generated isConvertible when the PyObject is None,
+// making a C++ NULL pointer the result of the toCpp function call.
+// DRAFT: When the Python object is a Py_None, it's C++ conversion is always a NULL pointer.
+LIBSHIBOKEN_API void nonePythonToCppNullPtr(PyObject*, void* cppOut);
+
+// TODO:WRITEDOCSTRING - tells if \p toCpp is an implicit conversion.
+LIBSHIBOKEN_API bool isImplicitConversion(SbkObjectType* type, PythonToCppFunc toCpp);
+
+} } // namespace Shiboken::Conversions
+
+#endif // SBK_CONVERTER_H
diff --git a/sources/shiboken2/libshiboken/typeresolver.cpp b/sources/shiboken2/libshiboken/typeresolver.cpp
new file mode 100644
index 000000000..3939fff5f
--- /dev/null
+++ b/sources/shiboken2/libshiboken/typeresolver.cpp
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 "typeresolver.h"
+#include "google/dense_hash_map"
+#include "sbkdbg.h"
+#include <cstdlib>
+#include <string>
+#include "basewrapper_p.h"
+
+using namespace Shiboken;
+
+typedef google::dense_hash_map<std::string, TypeResolver*> TypeResolverMap;
+static TypeResolverMap typeResolverMap;
+
+struct TypeResolver::TypeResolverPrivate
+{
+ CppToPythonFunc cppToPython;
+ PythonToCppFunc pythonToCpp;
+ PyTypeObject* pyType;
+};
+
+static void deinitTypeResolver()
+{
+ for (TypeResolverMap::const_iterator it = typeResolverMap.begin(); it != typeResolverMap.end(); ++it)
+ delete it->second;
+ typeResolverMap.clear();
+}
+
+void Shiboken::initTypeResolver()
+{
+ assert(typeResolverMap.empty());
+ typeResolverMap.set_empty_key("");
+ typeResolverMap.set_deleted_key("?");
+ std::atexit(deinitTypeResolver);
+}
+
+TypeResolver::TypeResolver() : m_d(new TypeResolverPrivate)
+{
+}
+
+TypeResolver* TypeResolver::createTypeResolver(const char* typeName,
+ CppToPythonFunc cppToPy,
+ PythonToCppFunc pyToCpp,
+ PyTypeObject* pyType)
+{
+ TypeResolver*& tr = typeResolverMap[typeName];
+ if (!tr) {
+ tr = new TypeResolver;
+ tr->m_d->cppToPython = cppToPy;
+ tr->m_d->pythonToCpp = pyToCpp;
+ tr->m_d->pyType = pyType;
+
+ /*
+ * Note:
+ *
+ * Value types are also registered as object types, but the generator *always* first register the value
+ * type version in the TypeResolver and it *must* always do it! otherwise this code wont work.
+ */
+ if (pyType && PyType_IsSubtype(pyType, reinterpret_cast<PyTypeObject*>(&SbkObject_Type))) {
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(pyType);
+ // TODO-CONVERTERS: to be deprecated
+ if (!sbkType->d->type_behaviour) {
+ const size_t len = strlen(typeName);
+ sbkType->d->type_behaviour = typeName[len -1] == '*' ? BEHAVIOUR_OBJECTTYPE : BEHAVIOUR_VALUETYPE;
+ }
+ }
+ }
+ return tr;
+}
+
+TypeResolver::~TypeResolver()
+{
+ delete m_d;
+}
+
+TypeResolver* TypeResolver::get(const char* typeName)
+{
+ TypeResolverMap::const_iterator it = typeResolverMap.find(typeName);
+ if (it != typeResolverMap.end()) {
+ return it->second;
+ } else {
+ if (Py_VerboseFlag > 0)
+ SbkDbg() << "Can't find type resolver for " << typeName;
+ return 0;
+ }
+}
+
+void TypeResolver::toCpp(PyObject* pyObj, void** place)
+{
+ m_d->pythonToCpp(pyObj, place);
+}
+
+PyObject* TypeResolver::toPython(void* cppObj)
+{
+ return m_d->cppToPython(cppObj);
+}
+
+PyTypeObject* TypeResolver::pythonType()
+{
+ return m_d->pyType;
+}
+
+TypeResolver::Type TypeResolver::getType(const char* name)
+{
+ const size_t len = strlen(name);
+ bool isObjTypeName = name[len - 1] == '*';
+ if (TypeResolver::get(name)) {
+ // great, we found the type in our first attempt!
+ return isObjTypeName ? ObjectType : ValueType;
+ } else {
+ // Type not found... let's copy the string.
+ std::string typeName(name);
+ if (isObjTypeName)
+ typeName.erase(len - 1, 1);
+ else
+ typeName += '*';
+ isObjTypeName = !isObjTypeName;
+
+ if (TypeResolver::get(typeName.c_str()))
+ return isObjTypeName ? ObjectType : ValueType;
+ else
+ return UnknownType;
+ }
+}
+
diff --git a/sources/shiboken2/libshiboken/typeresolver.h b/sources/shiboken2/libshiboken/typeresolver.h
new file mode 100644
index 000000000..bc56522fe
--- /dev/null
+++ b/sources/shiboken2/libshiboken/typeresolver.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of PySide2.
+**
+** $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 TYPERESOLVER_H
+#define TYPERESOLVER_H
+
+#include "shibokenmacros.h"
+#include "conversions.h"
+
+namespace Shiboken
+{
+
+/* To C++ convertion functions. */
+template <typename T>
+inline void pythonToValueType(PyObject* pyobj, void** data)
+{
+ *reinterpret_cast<T*>(*data) = Shiboken::Converter<T>::toCpp(pyobj);
+}
+
+template <typename T>
+inline void pythonToObjectType(PyObject* pyobj, void** data)
+{
+ *reinterpret_cast<T**>(*data) = Shiboken::Converter<T*>::toCpp(pyobj);
+}
+
+template <typename T>
+inline PyObject* objectTypeToPython(void* cptr)
+{
+ return Shiboken::Converter<T*>::toPython(*reinterpret_cast<T**>(cptr));
+}
+
+template <typename T>
+inline PyObject* referenceTypeToPython(void* cptr)
+{
+ // cptr comes the same way it come when we have a value type, but
+ // we deliver a Python object of a reference
+ return Shiboken::Converter<T&>::toPython(*reinterpret_cast<T*>(cptr));
+}
+
+/**
+* \internal This function is not part of the public API.
+* Initialize the TypeResource internal cache.
+*/
+void initTypeResolver();
+
+class LIBSHIBOKEN_API TypeResolver
+{
+public:
+ enum Type
+ {
+ ObjectType,
+ ValueType,
+ UnknownType
+ };
+
+ typedef PyObject* (*CppToPythonFunc)(void*);
+ typedef void (*PythonToCppFunc)(PyObject*, void**);
+
+ ~TypeResolver();
+
+ template<typename T>
+ static TypeResolver* createValueTypeResolver(const char* typeName)
+ {
+ return createTypeResolver(typeName, &Shiboken::Converter<T>::toPython, &pythonToValueType<T>, SbkType<T>());
+ }
+
+ template<typename T>
+ static TypeResolver* createObjectTypeResolver(const char* typeName)
+ {
+ return createTypeResolver(typeName, &objectTypeToPython<T>, &pythonToObjectType<T>, SbkType<T>());
+ }
+
+ /**
+ * This kind of type resolver is used only when we have a signal with a reference in their arguments
+ * like on QSqlTableModel::primeInsert.
+ */
+ template<typename T>
+ static TypeResolver* createReferenceTypeResolver(const char* typeName)
+ {
+ return createTypeResolver(typeName, &referenceTypeToPython<T>, &pythonToValueType<T>, SbkType<T>());
+ }
+
+ static Type getType(const char* name);
+ static TypeResolver* get(const char* typeName);
+
+ PyObject* toPython(void* cppObj);
+ void toCpp(PyObject* pyObj, void** place);
+ PyTypeObject* pythonType();
+
+private:
+ struct TypeResolverPrivate;
+ TypeResolverPrivate* m_d;
+
+ TypeResolver();
+ // disable object copy
+ TypeResolver(const TypeResolver&);
+ TypeResolver& operator=(const TypeResolver&);
+
+ static TypeResolver* createTypeResolver(const char* typeName, CppToPythonFunc cppToPy, PythonToCppFunc pyToCpp, PyTypeObject* pyType);
+};
+}
+
+#endif
diff --git a/sources/shiboken2/shibokenmodule/CMakeLists.txt b/sources/shiboken2/shibokenmodule/CMakeLists.txt
new file mode 100644
index 000000000..7e90b51ab
--- /dev/null
+++ b/sources/shiboken2/shibokenmodule/CMakeLists.txt
@@ -0,0 +1,40 @@
+project(shibokenmodule)
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/shibokenmodule.txt.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/shibokenmodule.txt" @ONLY)
+
+
+set(sample_SRC
+${CMAKE_CURRENT_BINARY_DIR}/shiboken2/shiboken2_module_wrapper.cpp
+)
+
+add_custom_command(OUTPUT ${sample_SRC}
+# Note: shiboken2 is an executable target. By not specifying its explicit
+# path, CMAKE figures it out, itself!
+# This fixes an issue with Visual Studio, see https://github.com/PySide/shiboken2/pull/11
+COMMAND shiboken2 --project-file=${CMAKE_CURRENT_BINARY_DIR}/shibokenmodule.txt ${GENERATOR_EXTRA_FLAGS}
+WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+COMMENT "Running generator for 'shiboken2'..."
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}
+ ${SBK_PYTHON_INCLUDE_DIR}
+ ${libshiboken_SOURCE_DIR}
+ ${libshiboken_BINARY_DIR})
+add_library(shibokenmodule MODULE ${sample_SRC})
+set_property(TARGET shibokenmodule PROPERTY PREFIX "")
+set_property(TARGET shibokenmodule PROPERTY OUTPUT_NAME "shiboken2")
+if(WIN32)
+ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set_property(TARGET shibokenmodule PROPERTY OUTPUT_NAME "shiboken2_d")
+ endif()
+ set_property(TARGET shibokenmodule PROPERTY SUFFIX ".pyd")
+endif()
+target_link_libraries(shibokenmodule
+ ${SBK_PYTHON_LIBRARIES}
+ libshiboken)
+
+add_dependencies(shibokenmodule shiboken2)
+
+install(TARGETS shibokenmodule DESTINATION ${PYTHON_SITE_PACKAGES}) \ No newline at end of file
diff --git a/sources/shiboken2/shibokenmodule/nothing.h b/sources/shiboken2/shibokenmodule/nothing.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/sources/shiboken2/shibokenmodule/nothing.h
diff --git a/sources/shiboken2/shibokenmodule/shibokenmodule.txt.in b/sources/shiboken2/shibokenmodule/shibokenmodule.txt.in
new file mode 100644
index 000000000..c5adc6091
--- /dev/null
+++ b/sources/shiboken2/shibokenmodule/shibokenmodule.txt.in
@@ -0,0 +1,16 @@
+[generator-project]
+
+generator-set = shiboken
+
+header-file = @CMAKE_CURRENT_SOURCE_DIR@/nothing.h
+typesystem-file = @CMAKE_CURRENT_SOURCE_DIR@/typesystem_shiboken.xml
+
+output-directory = @CMAKE_CURRENT_BINARY_DIR@
+
+# include-path = @libsample_SOURCE_DIR@
+
+typesystem-path = @CMAKE_CURRENT_SOURCE_DIR@
+
+avoid-protected-hack
+#enable-parent-ctor-heuristic
+#use-isnull-as-nb_nonzero
diff --git a/sources/shiboken2/shibokenmodule/typesystem_shiboken.xml b/sources/shiboken2/shibokenmodule/typesystem_shiboken.xml
new file mode 100644
index 000000000..18ab52e80
--- /dev/null
+++ b/sources/shiboken2/shibokenmodule/typesystem_shiboken.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" ?>
+<typesystem package="shiboken2">
+ <custom-type name="PyObject" />
+ <custom-type name="PyType" />
+ <primitive-type name="bool" />
+ <primitive-type name="unsigned long" />
+ <primitive-type name="size_t" />
+ <add-function signature="isValid(PyObject*)" return-type="bool">
+ <inject-code>
+ bool isValid = Shiboken::Object::isValid(%1, false);
+ %PYARG_0 = %CONVERTTOPYTHON[bool](isValid);
+ </inject-code>
+ </add-function>
+
+ <add-function signature="invalidate(PyObject*)">
+ <inject-code>
+ Shiboken::Object::invalidate(%1);
+ </inject-code>
+ </add-function>
+
+ <add-function signature="wrapInstance(size_t, PyType)" return-type="PyObject*">
+ <inject-code>
+ if (Shiboken::ObjectType::checkType((PyTypeObject*)%2))
+ %PYARG_0 = Shiboken::Object::newObject((SbkObjectType*)%2, (void*)%1, false, true);
+ else
+ PyErr_SetString(PyExc_TypeError, "You need a shiboken-based type.");
+ </inject-code>
+ </add-function>
+
+ <add-function signature="getCppPointer(PyObject*)" return-type="PyObject*">
+ <inject-code>
+ if (Shiboken::Object::checkType(%1)) {
+ std::vector&lt;void*> ptrs = Shiboken::Object::cppPointers((SbkObject*)%1);
+ %PYARG_0 = PyTuple_New(ptrs.size());
+ for (std::size_t i = 0; i &lt; ptrs.size(); ++i)
+ PyTuple_SET_ITEM(%PYARG_0, i, PyLong_FromVoidPtr(ptrs[i]));
+ } else {
+ PyErr_SetString(PyExc_TypeError, "You need a shiboken-based type.");
+ }
+ </inject-code>
+ </add-function>
+
+ <add-function signature="delete(PyObject*)">
+ <inject-code>
+ if (Shiboken::Object::checkType(%1)) {
+ Shiboken::Object::callCppDestructors((SbkObject*)%1);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "You need a shiboken-based type.");
+ }
+ </inject-code>
+ </add-function>
+
+ <add-function signature="ownedByPython(PyObject*)" return-type="bool">
+ <inject-code>
+ if (Shiboken::Object::checkType(%1)) {
+ bool hasOwnership = Shiboken::Object::hasOwnership((SbkObject*)%1);
+ %PYARG_0 = %CONVERTTOPYTHON[bool](hasOwnership);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "You need a shiboken-based type.");
+ }
+ </inject-code>
+ </add-function>
+
+ <add-function signature="createdByPython(PyObject*)" return-type="bool">
+ <inject-code>
+ if (Shiboken::Object::checkType(%1)) {
+ bool wasCreatedByPython = Shiboken::Object::wasCreatedByPython((SbkObject*)%1);
+ %PYARG_0 = %CONVERTTOPYTHON[bool](wasCreatedByPython);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "You need a shiboken-based type.");
+ }
+ </inject-code>
+ </add-function>
+
+ <add-function signature="dump(PyObject*)" return-type="PyObject*">
+ <inject-code>
+ if (!Shiboken::Object::checkType(%1)) {
+ %PYARG_0 = Shiboken::String::fromCString("Ordinary Python type.");
+ } else {
+ std::string str = Shiboken::Object::info((SbkObject*)%1);
+ %PYARG_0 = Shiboken::String::fromCString(str.c_str());
+ }
+ </inject-code>
+ </add-function>
+
+ <add-function signature="getAllValidWrappers(void)" return-type="PyObject*">
+ <inject-code>
+ std::set&lt;PyObject*&gt; setAll = Shiboken::BindingManager::instance().getAllPyObjects();
+ PyObject* listAll = PyList_New(0);
+ if (listAll == NULL)
+ return NULL;
+
+ const std::set&lt;PyObject*&gt;::iterator end = setAll.end();
+ for (std::set&lt;PyObject*&gt;::iterator iter = setAll.begin(); iter != end; ++iter) {
+ if (*iter != NULL) {
+ if (PyList_Append(listAll, *iter) != 0) {
+ Py_DECREF(listAll);
+ return NULL;
+ }
+ }
+ }
+ return listAll;
+ </inject-code>
+ </add-function>
+
+ <extra-includes>
+ <include file-name="sbkversion.h" location="local"/>
+ </extra-includes>
+ <inject-code position="end">
+ // Add __version__ and __version_info__ attributes to the module
+ PyObject* version = PyTuple_New(5);
+ PyTuple_SET_ITEM(version, 0, PyInt_FromLong(SHIBOKEN_MAJOR_VERSION));
+ PyTuple_SET_ITEM(version, 1, PyInt_FromLong(SHIBOKEN_MINOR_VERSION));
+ PyTuple_SET_ITEM(version, 2, PyInt_FromLong(SHIBOKEN_MICRO_VERSION));
+ PyTuple_SET_ITEM(version, 3, Shiboken::String::fromCString(SHIBOKEN_RELEASE_LEVEL));
+ PyTuple_SET_ITEM(version, 4, PyInt_FromLong(SHIBOKEN_SERIAL));
+ PyModule_AddObject(module, "__version_info__", version);
+ PyModule_AddStringConstant(module, "__version__", SHIBOKEN_VERSION);
+ </inject-code>
+</typesystem>
diff --git a/sources/shiboken2/tests/CMakeLists.txt b/sources/shiboken2/tests/CMakeLists.txt
new file mode 100644
index 000000000..c06c56f6d
--- /dev/null
+++ b/sources/shiboken2/tests/CMakeLists.txt
@@ -0,0 +1,102 @@
+find_package(Qt5 REQUIRED COMPONENTS Core)
+include_directories(${Qt5Core_INCLUDE_DIRS})
+
+add_subdirectory(libminimal)
+if(NOT DEFINED MINIMAL_TESTS)
+ add_subdirectory(libsample)
+ add_subdirectory(libsmart)
+ add_subdirectory(libother)
+endif()
+
+if(WIN32 OR DEFINED AVOID_PROTECTED_HACK)
+ message(STATUS "Tests will be generated avoiding the protected hack!")
+ set(GENERATOR_EXTRA_FLAGS --avoid-protected-hack)
+else()
+ message(STATUS "Tests will be generated using the protected hack!")
+ set(GENERATOR_EXTRA_FLAGS )
+endif()
+
+add_subdirectory(minimalbinding)
+if(NOT DEFINED MINIMAL_TESTS)
+ add_subdirectory(samplebinding)
+ add_subdirectory(smartbinding)
+ add_subdirectory(otherbinding)
+endif()
+
+if(DEFINED MINIMAL_TESTS)
+ file(GLOB TEST_FILES minimalbinding/*_test.py)
+else()
+ file(GLOB TEST_FILES minimalbinding/*_test.py
+ samplebinding/*_test.py
+ otherbinding/*_test.py
+ smartbinding/*_test.py
+ shibokenmodule/*_test.py)
+endif()
+list(SORT TEST_FILES)
+
+set(test_blacklist "")
+
+find_package(PythonInterp REQUIRED)
+if(NOT CTEST_TESTING_TIMEOUT)
+ set(CTEST_TESTING_TIMEOUT 60)
+endif()
+
+if(CMAKE_VERSION VERSION_LESS 2.8)
+ message("CMake version greater than 2.8 necessary to run tests")
+else()
+ if(WIN32)
+ set(TEST_PYTHONPATH "${smart_BINARY_DIR};${minimal_BINARY_DIR};${sample_BINARY_DIR};${other_BINARY_DIR};${shibokenmodule_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}")
+ set(TEST_LIBRARY_PATH "$ENV{PATH};${libminimal_BINARY_DIR};${libsample_BINARY_DIR};${libother_BINARY_DIR};${libsmart_BINARY_DIR};${libshiboken_BINARY_DIR}")
+ set(LIBRARY_PATH_VAR "PATH")
+ string(REPLACE "\\" "/" TEST_PYTHONPATH "${TEST_PYTHONPATH}")
+ string(REPLACE "\\" "/" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}")
+ string(REPLACE ";" "\\;" TEST_PYTHONPATH "${TEST_PYTHONPATH}")
+ string(REPLACE ";" "\\;" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}")
+ else()
+ set(TEST_PYTHONPATH "${smart_BINARY_DIR}:${minimal_BINARY_DIR}:${sample_BINARY_DIR}:${other_BINARY_DIR}:${shibokenmodule_BINARY_DIR}:${CMAKE_CURRENT_SOURCE_DIR}")
+ set(TEST_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}:${libminimal_BINARY_DIR}:${libsample_BINARY_DIR}:${libother_BINARY_DIR}:${libsmart_BINARY_DIR}:${libshiboken_BINARY_DIR}")
+ set(LIBRARY_PATH_VAR "LD_LIBRARY_PATH")
+ endif()
+ foreach(test_file ${TEST_FILES})
+ string(REGEX MATCH "/([^/]+)(binding|module)/([^/]+)_test.py" tmp ${test_file})
+ set(test_name "${CMAKE_MATCH_1}_${CMAKE_MATCH_3}")
+ list(FIND test_blacklist ${test_name} expect_fail)
+ add_test(${test_name} ${PYTHON_EXECUTABLE} ${test_file})
+ set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "PYTHONPATH=${TEST_PYTHONPATH};${LIBRARY_PATH_VAR}=${TEST_LIBRARY_PATH}")
+ set_tests_properties(${test_name} PROPERTIES TIMEOUT ${CTEST_TESTING_TIMEOUT})
+ if (${expect_fail} GREATER -1)
+ set_tests_properties(${test_name} PROPERTIES WILL_FAIL TRUE)
+ endif()
+ endforeach()
+endif()
+
+add_subdirectory(dumpcodemodel)
+
+# FIXME Skipped until add an option to choose the generator
+# add_subdirectory(test_generator)
+
+if (NOT APIEXTRACTOR_DOCSTRINGS_DISABLED)
+# project(sphinxtabletest)
+#
+# # TODO
+# set(sphinxtabletest_SRC sphinxtabletest.cpp)
+# qt4_automoc(${sphinxtabletest_SRC})
+#
+# include_directories(${QT_INCLUDE_DIR}
+# ${QT_QTCORE_INCLUDE_DIR}
+# ${CMAKE_CURRENT_BINARY_DIR}
+# ${qtdoc_generator_SOURCE_DIR})
+#
+# add_executable(sphinxtabletest ${sphinxtabletest_SRC})
+#
+# target_link_libraries(sphinxtabletest
+# ${QT_QTTEST_LIBRARY}
+# ${APIEXTRACTOR_LIBRARY}
+# qtdoc_generator
+# genrunner)
+#
+# add_test("sphinxtable" sphinxtabletest)
+# if (INSTALL_TESTS)
+# install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/sphinxtabletest DESTINATION ${TEST_INSTALL_DIR})
+# endif()
+endif()
diff --git a/sources/shiboken2/tests/dumpcodemodel/CMakeLists.txt b/sources/shiboken2/tests/dumpcodemodel/CMakeLists.txt
new file mode 100644
index 000000000..af18cb3c8
--- /dev/null
+++ b/sources/shiboken2/tests/dumpcodemodel/CMakeLists.txt
@@ -0,0 +1,5 @@
+add_executable(dumpcodemodel main.cpp)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${apiextractor_SOURCE_DIR} ${Qt5Core_INCLUDE_DIRS})
+
+target_link_libraries(dumpcodemodel apiextractor ${Qt5Core_LIBRARIES})
diff --git a/sources/shiboken2/tests/dumpcodemodel/main.cpp b/sources/shiboken2/tests/dumpcodemodel/main.cpp
new file mode 100644
index 000000000..9e62faa16
--- /dev/null
+++ b/sources/shiboken2/tests/dumpcodemodel/main.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <abstractmetabuilder_p.h>
+#include <parser/codemodel.h>
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QCommandLineOption>
+#include <QtCore/QCommandLineParser>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QFile>
+
+#include <iostream>
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QCommandLineParser parser;
+ parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
+ parser.setApplicationDescription(QStringLiteral("Code model tester"));
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption verboseOption(QStringLiteral("d"),
+ QStringLiteral("Display verbose output about types"));
+ parser.addOption(verboseOption);
+ parser.addPositionalArgument(QStringLiteral("file"), QStringLiteral("C++ source file"));
+
+ parser.process(app);
+ if (parser.positionalArguments().isEmpty())
+ parser.showHelp(1);
+
+ const QString sourceFileName = parser.positionalArguments().at(0);
+ QFile sourceFile(sourceFileName);
+ if (!sourceFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QString message = QLatin1String("Cannot open \"") + QDir::toNativeSeparators(sourceFileName)
+ + QLatin1String("\": ") + sourceFile.errorString();
+ std::cerr << qPrintable(message) << '\n';
+ return -1;
+ }
+
+ const FileModelItem dom = AbstractMetaBuilderPrivate::buildDom(&sourceFile);
+ sourceFile.close();
+ if (dom.isNull())
+ return -2;
+
+ QString output;
+ {
+ QDebug debug(&output);
+ if (parser.isSet(verboseOption))
+ debug.setVerbosity(3);
+ debug << dom.data();
+ }
+ std::cout << qPrintable(output) << '\n';
+
+ return 0;
+}
diff --git a/sources/shiboken2/tests/libminimal/CMakeLists.txt b/sources/shiboken2/tests/libminimal/CMakeLists.txt
new file mode 100644
index 000000000..a25892571
--- /dev/null
+++ b/sources/shiboken2/tests/libminimal/CMakeLists.txt
@@ -0,0 +1,13 @@
+project(libminimal)
+
+set(libminimal_SRC
+obj.cpp
+listuser.cpp
+typedef.cpp
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+add_definitions("-DLIBMINIMAL_BUILD")
+add_library(libminimal SHARED ${libminimal_SRC})
+set_property(TARGET libminimal PROPERTY PREFIX "")
+
diff --git a/sources/shiboken2/tests/libminimal/libminimalmacros.h b/sources/shiboken2/tests/libminimal/libminimalmacros.h
new file mode 100644
index 000000000..5c9e62e8a
--- /dev/null
+++ b/sources/shiboken2/tests/libminimal/libminimalmacros.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIBMINIMALMACROS_H
+#define LIBMINIMALMACROS_H
+
+#if defined _WIN32 || defined __CYGWIN__
+ #if LIBMINIMAL_BUILD
+ #define LIBMINIMAL_API __declspec(dllexport)
+ #else
+ #define LIBMINIMAL_API __declspec(dllimport)
+ #endif
+#else
+#if __GNUC__ >= 4
+ #define LIBMINIMAL_API __attribute__ ((visibility("default")))
+#else
+ #define LIBMINIMAL_API
+#endif
+#endif
+
+#endif
diff --git a/sources/shiboken2/tests/libminimal/listuser.cpp b/sources/shiboken2/tests/libminimal/listuser.cpp
new file mode 100644
index 000000000..ec2eb3923
--- /dev/null
+++ b/sources/shiboken2/tests/libminimal/listuser.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <numeric>
+#include <cstdlib>
+#include "listuser.h"
+
+std::list<int>
+ListUser::createIntList(int num)
+{
+ std::list<int> retval;
+ for (int i = 0; i < num; ++i)
+ retval.push_back(i);
+ return retval;
+}
+
+int
+ListUser::sumIntList(std::list<int> intList)
+{
+ int total = 0;
+ for (std::list<int>::iterator iter = intList.begin(); iter != intList.end(); iter++)
+ total += *iter;
+ return total;
+}
+
+std::list<MinBool>
+ListUser::createMinBoolList(MinBool mb1, MinBool mb2)
+{
+ std::list<MinBool> retval;
+ retval.push_back(mb1);
+ retval.push_back(mb2);
+ return retval;
+}
+
+MinBool
+ListUser::oredMinBoolList(std::list<MinBool> minBoolList)
+{
+ MinBool result(false);
+ for (std::list<MinBool>::iterator iter = minBoolList.begin(); iter != minBoolList.end(); iter++)
+ result |= *iter;
+ return result;
+}
+
+std::list<Val>
+ListUser::createValList(int num)
+{
+ std::list<Val> retval;
+ for (int i = 0; i < num; ++i)
+ retval.push_back(Val(i));
+ return retval;
+}
+
+int
+ListUser::sumValList(std::list<Val> valList)
+{
+ int total = 0;
+ for (std::list<Val>::iterator iter = valList.begin(); iter != valList.end(); iter++)
+ total += iter->valId();
+ return total;
+}
+
+std::list<Obj*>
+ListUser::createObjList(Obj* o1, Obj* o2)
+{
+ std::list<Obj*> retval;
+ retval.push_back(o1);
+ retval.push_back(o2);
+ return retval;
+}
+
+int
+ListUser::sumObjList(std::list<Obj*> objList)
+{
+ int total = 0;
+ for (std::list<Obj*>::iterator iter = objList.begin(); iter != objList.end(); iter++)
+ total += (*iter)->objId();
+ return total;
+}
+
+std::list<std::list<int> >
+ListUser::createListOfIntLists(int num)
+{
+ std::list<std::list<int> > retval;
+ for (int i = 0; i < num; ++i)
+ retval.push_back(createIntList(num));
+ return retval;
+}
+
+int
+ListUser::sumListOfIntLists(std::list<std::list<int> > intListList)
+{
+ int total = 0;
+ for (std::list<std::list<int> >::iterator it0 = intListList.begin(); it0 != intListList.end(); it0++) {
+ for (std::list<int>::iterator it1 = (*it0).begin(); it1 != (*it0).end(); it1++)
+ total += *it1;
+ }
+ return total;
+}
+
diff --git a/sources/shiboken2/tests/libminimal/listuser.h b/sources/shiboken2/tests/libminimal/listuser.h
new file mode 100644
index 000000000..4138b9f3c
--- /dev/null
+++ b/sources/shiboken2/tests/libminimal/listuser.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LISTUSER_H
+#define LISTUSER_H
+
+#include <list>
+#include "obj.h"
+#include "val.h"
+#include "minbool.h"
+
+#include "libminimalmacros.h"
+
+struct LIBMINIMAL_API ListUser
+{
+ virtual ~ListUser() {}
+
+ // List of C++ primitive type items
+ virtual std::list<int> createIntList(int num);
+ std::list<int> callCreateIntList(int num) { return createIntList(num); }
+ virtual int sumIntList(std::list<int> intList);
+ int callSumIntList(std::list<int> intList) { return sumIntList(intList); }
+
+ // List of C++ MinBool objects used as primitives in Python
+ virtual std::list<MinBool> createMinBoolList(MinBool mb1, MinBool mb2);
+ std::list<MinBool> callCreateMinBoolList(MinBool mb1, MinBool mb2) { return createMinBoolList(mb1, mb2); }
+ virtual MinBool oredMinBoolList(std::list<MinBool> minBoolList);
+ MinBool callOredMinBoolList(std::list<MinBool> minBoolList) { return oredMinBoolList(minBoolList); }
+
+ // List of C++ value types
+ virtual std::list<Val> createValList(int num);
+ std::list<Val> callCreateValList(int num) { return createValList(num); }
+ virtual int sumValList(std::list<Val> valList);
+ int callSumValList(std::list<Val> valList) { return sumValList(valList); }
+
+ // List of C++ object types
+ virtual std::list<Obj*> createObjList(Obj* o1, Obj* o2);
+ std::list<Obj*> callCreateObjList(Obj* o1, Obj* o2) { return createObjList(o1, o2); }
+ virtual int sumObjList(std::list<Obj*> objList);
+ int callSumObjList(std::list<Obj*> objList) { return sumObjList(objList); }
+
+ // List of lists of C++ primitive type items
+ virtual std::list<std::list<int> > createListOfIntLists(int num);
+ std::list<std::list<int> > callCreateListOfIntLists(int num) { return createListOfIntLists(num); }
+ virtual int sumListOfIntLists(std::list<std::list<int> > intListList);
+ int callSumListOfIntLists(std::list<std::list<int> > intListList) { return sumListOfIntLists(intListList); }
+};
+
+#endif // LISTUSER_H
+
diff --git a/sources/shiboken2/tests/libminimal/minbool.h b/sources/shiboken2/tests/libminimal/minbool.h
new file mode 100644
index 000000000..ebd2f71e2
--- /dev/null
+++ b/sources/shiboken2/tests/libminimal/minbool.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MINBOOL_H
+#define MINBOOL_H
+
+#include "libminimalmacros.h"
+
+class LIBMINIMAL_API MinBool
+{
+public:
+ inline explicit MinBool(bool b) : m_value(b) {}
+ bool value() const { return m_value; }
+ inline MinBool operator!() const { return MinBool(!m_value); }
+ inline MinBool& operator|=(const MinBool& other) {
+ m_value = m_value | other.m_value;
+ return *this;
+ }
+private:
+ bool m_value;
+};
+
+inline bool operator==(MinBool b1, bool b2) { return (!b1).value() == !b2; }
+inline bool operator==(bool b1, MinBool b2) { return (!b1) == (!b2).value(); }
+inline bool operator==(MinBool b1, MinBool b2) { return (!b1).value() == (!b2).value(); }
+inline bool operator!=(MinBool b1, bool b2) { return (!b1).value() != !b2; }
+inline bool operator!=(bool b1, MinBool b2) { return (!b1) != (!b2).value(); }
+inline bool operator!=(MinBool b1, MinBool b2) { return (!b1).value() != (!b2).value(); }
+
+class LIBMINIMAL_API MinBoolUser
+{
+public:
+ MinBoolUser() : m_minbool(MinBool(false)) {}
+ virtual ~MinBoolUser() {}
+ inline MinBool minBool() { return m_minbool; }
+ inline void setMinBool(MinBool minBool) { m_minbool = minBool; }
+ virtual MinBool invertedMinBool() { return !m_minbool; }
+ inline MinBool callInvertedMinBool() { return invertedMinBool(); }
+private:
+ MinBool m_minbool;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libminimal/obj.cpp b/sources/shiboken2/tests/libminimal/obj.cpp
new file mode 100644
index 000000000..a1d18d0e3
--- /dev/null
+++ b/sources/shiboken2/tests/libminimal/obj.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "obj.h"
+
+Obj::Obj(int objId) : m_objId(objId)
+{
+}
+
+Obj::~Obj()
+{
+}
+
+bool
+Obj::virtualMethod(int val)
+{
+ return !bool(val%2);
+}
+
diff --git a/sources/shiboken2/tests/libminimal/obj.h b/sources/shiboken2/tests/libminimal/obj.h
new file mode 100644
index 000000000..16f838e19
--- /dev/null
+++ b/sources/shiboken2/tests/libminimal/obj.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJ_H
+#define OBJ_H
+
+#include "libminimalmacros.h"
+
+class LIBMINIMAL_API Obj
+{
+public:
+ explicit Obj(int objId);
+ virtual ~Obj();
+
+ int objId() { return m_objId; }
+ void setObjId(int objId) { m_objId = objId; }
+
+ virtual bool virtualMethod(int val);
+ bool callVirtualMethod(int val) { return virtualMethod(val); }
+
+ virtual Obj* passObjectType(Obj* obj) { return obj; }
+ Obj* callPassObjectType(Obj* obj) { return passObjectType(obj); }
+
+ virtual Obj* passObjectTypeReference(Obj& obj) { return &obj; }
+ Obj* callPassObjectTypeReference(Obj& obj) { return passObjectTypeReference(obj); }
+
+private:
+ Obj(const Obj&);
+ Obj& operator=(const Obj&);
+ int m_objId;
+};
+
+#endif // OBJ_H
+
diff --git a/sources/shiboken2/tests/libminimal/typedef.cpp b/sources/shiboken2/tests/libminimal/typedef.cpp
new file mode 100644
index 000000000..4948d9944
--- /dev/null
+++ b/sources/shiboken2/tests/libminimal/typedef.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "typedef.h"
+
+//
+// Test wrapping of a typedef
+//
+bool arrayFuncInt(std::vector<int> a)
+{
+ return a.empty();
+}
+
+bool arrayFuncIntTypedef(MyArray a)
+{
+ return arrayFuncInt(a);
+}
+
+std::vector<int> arrayFuncIntReturn(int size)
+{
+ return std::vector<int>(size);
+}
+
+MyArray arrayFuncIntReturnTypedef(int size)
+{
+ return arrayFuncIntReturn(size);
+}
+
+//
+// Test wrapping of a typedef of a typedef
+//
+bool arrayFunc(std::vector<int> a)
+{
+ return a.empty();
+}
+
+bool arrayFuncTypedef(MyArray a)
+{
+ return arrayFunc(a);
+}
+
+std::vector<int> arrayFuncReturn(int size)
+{
+ return std::vector<int>(size);
+}
+
+MyArray arrayFuncReturnTypedef(int size)
+{
+ return arrayFuncReturn(size);
+}
diff --git a/sources/shiboken2/tests/libminimal/typedef.h b/sources/shiboken2/tests/libminimal/typedef.h
new file mode 100644
index 000000000..f54a6ed18
--- /dev/null
+++ b/sources/shiboken2/tests/libminimal/typedef.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TYPEDEF_H
+#define TYPEDEF_H
+
+#include "libminimalmacros.h"
+
+#include <vector>
+
+// Test wrapping of a typedef
+typedef std::vector<int> MyArrayInt;
+
+LIBMINIMAL_API bool arrayFuncInt(std::vector<int> a);
+LIBMINIMAL_API bool arrayFuncIntTypedef(MyArrayInt a);
+
+LIBMINIMAL_API std::vector<int> arrayFuncIntReturn(int size);
+LIBMINIMAL_API MyArrayInt arrayFuncIntReturnTypedef(int size);
+
+// Test wrapping of a typedef of a typedef
+typedef MyArrayInt MyArray;
+
+LIBMINIMAL_API bool arrayFunc(std::vector<int> a);
+LIBMINIMAL_API bool arrayFuncTypedef(MyArray a);
+
+LIBMINIMAL_API std::vector<int> arrayFuncReturn(int size);
+LIBMINIMAL_API MyArray arrayFuncReturnTypedef(int size);
+
+#endif
diff --git a/sources/shiboken2/tests/libminimal/val.h b/sources/shiboken2/tests/libminimal/val.h
new file mode 100644
index 000000000..5ba4b3aff
--- /dev/null
+++ b/sources/shiboken2/tests/libminimal/val.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VAL_H
+#define VAL_H
+
+#include "libminimalmacros.h"
+
+class LIBMINIMAL_API Val
+{
+public:
+ explicit Val(int valId) : m_valId(valId) {}
+ virtual ~Val() {}
+
+ int valId() { return m_valId; }
+ void setValId(int valId) { m_valId = valId; }
+
+ virtual Val passValueType(Val val) { return val; }
+ Val callPassValueType(Val val) { return passValueType(val); }
+
+ virtual Val* passValueTypePointer(Val* val) { return val; }
+ Val* callPassValueTypePointer(Val* val) { return passValueTypePointer(val); }
+
+ virtual Val* passValueTypeReference(Val& val) { return &val; }
+ Val* callPassValueTypeReference(Val& val) { return passValueTypeReference(val); }
+
+ enum ValEnum { One, Other };
+ ValEnum oneOrTheOtherEnumValue(ValEnum enumValue) { return enumValue == One ? Other : One; }
+private:
+ int m_valId;
+};
+
+#endif // VAL_H
+
diff --git a/sources/shiboken2/tests/libother/CMakeLists.txt b/sources/shiboken2/tests/libother/CMakeLists.txt
new file mode 100644
index 000000000..9b3cf5552
--- /dev/null
+++ b/sources/shiboken2/tests/libother/CMakeLists.txt
@@ -0,0 +1,18 @@
+project(libother)
+
+set(libother_SRC
+number.cpp
+otherderived.cpp
+otherobjecttype.cpp
+othermultiplederived.cpp
+)
+
+add_definitions("-DLIBOTHER_BUILD")
+add_library(libother SHARED ${libother_SRC})
+set_property(TARGET libother PROPERTY PREFIX "")
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${libsample_SOURCE_DIR}
+ ${libsample_SOURCE_DIR}/..)
+target_link_libraries(libother libsample)
+
diff --git a/sources/shiboken2/tests/libother/extendsnoimplicitconversion.h b/sources/shiboken2/tests/libother/extendsnoimplicitconversion.h
new file mode 100644
index 000000000..744bfdc0d
--- /dev/null
+++ b/sources/shiboken2/tests/libother/extendsnoimplicitconversion.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef EXTENDSNOIMPLICITCONVERSION_H
+#define EXTENDSNOIMPLICITCONVERSION_H
+
+#include "libothermacros.h"
+#include "noimplicitconversion.h"
+
+class ExtendsNoImplicitConversion
+{
+public:
+ explicit ExtendsNoImplicitConversion(int objId) : m_objId(objId) {};
+ inline int objId() const { return m_objId; }
+ inline operator NoImplicitConversion() const { return NoImplicitConversion(m_objId); }
+private:
+ int m_objId;
+};
+#endif // EXTENDSNOIMPLICITCONVERSION_H
+
diff --git a/sources/shiboken2/tests/libother/libothermacros.h b/sources/shiboken2/tests/libother/libothermacros.h
new file mode 100644
index 000000000..41a4fb13e
--- /dev/null
+++ b/sources/shiboken2/tests/libother/libothermacros.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIBOTHERMACROS_H
+#define LIBOTHERMACROS_H
+
+#if defined _WIN32 || defined __CYGWIN__
+ #if LIBOTHER_BUILD
+ #define LIBOTHER_API __declspec(dllexport)
+ #else
+ #define LIBOTHER_API __declspec(dllimport)
+ #endif
+#else
+#if __GNUC__ >= 4
+ #define LIBOTHER_API __attribute__ ((visibility("default")))
+#else
+ #define LIBOTHER_API
+#endif
+#endif
+
+#endif
diff --git a/sources/shiboken2/tests/libother/number.cpp b/sources/shiboken2/tests/libother/number.cpp
new file mode 100644
index 000000000..4da254286
--- /dev/null
+++ b/sources/shiboken2/tests/libother/number.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "number.h"
+#include <cstring>
+#include <sstream>
+
+using namespace std;
+
+Str
+Number::toStr() const
+{
+ ostringstream in;
+ in << m_value;
+ return in.str().c_str();
+}
+
+Point
+operator*(const Point& p, const Number& n)
+{
+ return Point(p.x() * n.value(), p.y() * n.value());
+}
+
+Complex
+Number::toComplex() const
+{
+ return Complex(m_value);
+}
+
+Number
+Number::fromComplex(Complex cpx)
+{
+ return Number(cpx.real());
+}
diff --git a/sources/shiboken2/tests/libother/number.h b/sources/shiboken2/tests/libother/number.h
new file mode 100644
index 000000000..4286068d5
--- /dev/null
+++ b/sources/shiboken2/tests/libother/number.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NUMBER_H
+#define NUMBER_H
+
+#include "libothermacros.h"
+#include "str.h"
+#include "point.h"
+#include "complex.h"
+
+class LIBOTHER_API Number
+{
+public:
+ explicit Number(int value) : m_value(value) {};
+ inline int value() const { return m_value; }
+
+ Str toStr() const;
+ inline operator Str() const { return toStr(); }
+
+ friend LIBOTHER_API Point operator*(const Point&, const Number&);
+
+ Complex toComplex() const;
+ static Number fromComplex(Complex cpx);
+
+private:
+ int m_value;
+};
+
+LIBOTHER_API Point operator*(const Point&, const Number&);
+
+#endif // NUMBER_H
diff --git a/sources/shiboken2/tests/libother/otherderived.cpp b/sources/shiboken2/tests/libother/otherderived.cpp
new file mode 100644
index 000000000..4128d73ff
--- /dev/null
+++ b/sources/shiboken2/tests/libother/otherderived.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "otherderived.h"
+
+OtherDerived::OtherDerived(int id) : Abstract(id)
+{
+}
+
+OtherDerived::~OtherDerived()
+{
+}
+
+Abstract*
+OtherDerived::createObject()
+{
+ static int id = 100;
+ return new OtherDerived(id++);
+}
+
+void
+OtherDerived::pureVirtual()
+{
+}
+
+void*
+OtherDerived::pureVirtualReturningVoidPtr()
+{
+ return 0;
+}
+
+void
+OtherDerived::unpureVirtual()
+{
+}
+
diff --git a/sources/shiboken2/tests/libother/otherderived.h b/sources/shiboken2/tests/libother/otherderived.h
new file mode 100644
index 000000000..792b7c408
--- /dev/null
+++ b/sources/shiboken2/tests/libother/otherderived.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OTHERDERIVED_H
+#define OTHERDERIVED_H
+
+#include "libothermacros.h"
+#include "abstract.h"
+#include "derived.h"
+#include "objecttype.h"
+#include "complex.h"
+
+class ObjectType;
+
+class LIBOTHER_API OtherDerived : public Abstract
+{
+public:
+ OtherDerived(int id = -1);
+ virtual ~OtherDerived();
+ virtual void pureVirtual();
+ virtual void* pureVirtualReturningVoidPtr();
+ virtual void unpureVirtual();
+ virtual PrintFormat returnAnEnum() { return Short; }
+
+ inline void useObjectTypeFromOtherModule(ObjectType*) {}
+ inline Event useValueTypeFromOtherModule(const Event& e) { return e; }
+ inline Complex useValueTypeFromOtherModule(const Complex& c) { return c; }
+ inline void useEnumTypeFromOtherModule(OverloadedFuncEnum) {}
+
+ // factory method
+ static Abstract* createObject();
+
+ void hideFunction(HideType*) {}
+
+protected:
+ inline const char* getClassName() { return className(); }
+ virtual const char* className() { return "OtherDerived"; }
+};
+#endif // OTHERDERIVED_H
+
diff --git a/sources/shiboken2/tests/libother/othermultiplederived.cpp b/sources/shiboken2/tests/libother/othermultiplederived.cpp
new file mode 100644
index 000000000..77fa44b83
--- /dev/null
+++ b/sources/shiboken2/tests/libother/othermultiplederived.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "othermultiplederived.h"
+
+VirtualMethods OtherMultipleDerived::returnUselessClass()
+{
+ return VirtualMethods();
+}
+
+Base1* OtherMultipleDerived::createObject(const std::string& objName)
+{
+ if (objName == "Base1")
+ return new Base1;
+ else if (objName == "MDerived1")
+ return new MDerived1;
+ else if (objName == "SonOfMDerived1")
+ return new SonOfMDerived1;
+ else if (objName == "MDerived3")
+ return new MDerived3;
+ else if (objName == "OtherMultipleDerived")
+ return new OtherMultipleDerived;
+ return 0;
+}
+
diff --git a/sources/shiboken2/tests/libother/othermultiplederived.h b/sources/shiboken2/tests/libother/othermultiplederived.h
new file mode 100644
index 000000000..e75504320
--- /dev/null
+++ b/sources/shiboken2/tests/libother/othermultiplederived.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OTHERMULTIPLEDERIVED_H
+#define OTHERMULTIPLEDERIVED_H
+
+#include "libothermacros.h"
+#include "multiple_derived.h"
+#include "virtualmethods.h"
+
+class ObjectType;
+
+class LIBOTHER_API OtherMultipleDerived : public MDerived1
+{
+public:
+ // this will use CppCopier from other module (bug#142)
+ VirtualMethods returnUselessClass();
+ static Base1* createObject(const std::string& objName);
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libother/otherobjecttype.cpp b/sources/shiboken2/tests/libother/otherobjecttype.cpp
new file mode 100644
index 000000000..266b2583e
--- /dev/null
+++ b/sources/shiboken2/tests/libother/otherobjecttype.cpp
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "otherobjecttype.h"
+
+Collector&
+operator<<(Collector& collector, const OtherObjectType& obj)
+{
+ collector << obj.identifier()*2;
+ return collector;
+}
diff --git a/sources/shiboken2/tests/libother/otherobjecttype.h b/sources/shiboken2/tests/libother/otherobjecttype.h
new file mode 100644
index 000000000..2bba912b6
--- /dev/null
+++ b/sources/shiboken2/tests/libother/otherobjecttype.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OTHEROBJECTTYPE_H
+#define OTHEROBJECTTYPE_H
+
+#include <list>
+#include "str.h"
+
+#include "libothermacros.h"
+#include "objecttype.h"
+#include "collector.h"
+
+class OtherObjectType : public ObjectType
+{
+public:
+
+};
+
+
+LIBOTHER_API Collector& operator<<(Collector&, const OtherObjectType&);
+
+#endif // OTHEROBJECTTYPE_H
+
diff --git a/sources/shiboken2/tests/libsample/CMakeLists.txt b/sources/shiboken2/tests/libsample/CMakeLists.txt
new file mode 100644
index 000000000..7bbc0c3dd
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/CMakeLists.txt
@@ -0,0 +1,57 @@
+project(libsample)
+
+set(libsample_SRC
+abstract.cpp
+blackbox.cpp
+bytearray.cpp
+bucket.cpp
+collector.cpp
+complex.cpp
+onlycopy.cpp
+derived.cpp
+echo.cpp
+functions.cpp
+handle.cpp
+implicitconv.cpp
+injectcode.cpp
+listuser.cpp
+modifications.cpp
+mapuser.cpp
+modified_constructor.cpp
+multiple_derived.cpp
+objectmodel.cpp
+objecttype.cpp
+objecttypeholder.cpp
+objecttypelayout.cpp
+objecttypeoperators.cpp
+objectview.cpp
+overload.cpp
+overloadsort.cpp
+pairuser.cpp
+pen.cpp
+photon.cpp
+point.cpp
+pointf.cpp
+polygon.cpp
+protected.cpp
+reference.cpp
+sample.cpp
+samplenamespace.cpp
+sbkdate.cpp
+simplefile.cpp
+size.cpp
+sometime.cpp
+str.cpp
+strlist.cpp
+templateptr.cpp
+transform.cpp
+virtualmethods.cpp
+expression.cpp
+filter.cpp
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+add_definitions("-DLIBSAMPLE_BUILD")
+add_library(libsample SHARED ${libsample_SRC})
+set_property(TARGET libsample PROPERTY PREFIX "")
+
diff --git a/sources/shiboken2/tests/libsample/abstract.cpp b/sources/shiboken2/tests/libsample/abstract.cpp
new file mode 100644
index 000000000..ab00a3bcc
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/abstract.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "abstract.h"
+#include "objecttype.h"
+
+using namespace std;
+
+const int Abstract::staticPrimitiveField = 0;
+
+Abstract::Abstract(int id) : m_id(id)
+{
+ primitiveField = 123;
+ valueTypeField = Point(12, 34);
+ objectTypeField = 0;
+ bitField = 0;
+}
+
+Abstract::~Abstract()
+{
+}
+
+void
+Abstract::unpureVirtual()
+{
+}
+
+void
+Abstract::callUnpureVirtual()
+{
+ this->unpureVirtual();
+}
+
+
+void
+Abstract::callPureVirtual()
+{
+ this->pureVirtual();
+}
+
+void
+Abstract::show(PrintFormat format)
+{
+ cout << '<';
+ switch(format) {
+ case Short:
+ cout << this;
+ break;
+ case Verbose:
+ cout << "class " << className() << " | cptr: " << this;
+ cout << ", id: " << m_id;
+ break;
+ case OnlyId:
+ cout << "id: " << m_id;
+ break;
+ case ClassNameAndId:
+ cout << className() << " - id: " << m_id;
+ break;
+ }
+ cout << '>';
+}
+
+void Abstract::callVirtualGettingEnum(PrintFormat p)
+{
+ virtualGettingAEnum(p);
+}
+
+void Abstract::virtualGettingAEnum(Abstract::PrintFormat p)
+{
+}
+
diff --git a/sources/shiboken2/tests/libsample/abstract.h b/sources/shiboken2/tests/libsample/abstract.h
new file mode 100644
index 000000000..77a43f3d1
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/abstract.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACT_H
+#define ABSTRACT_H
+
+#include "libsamplemacros.h"
+#include "point.h"
+#include "complex.h"
+
+class ObjectType;
+
+// this class is not exported to python
+class HideType
+{
+};
+
+class LIBSAMPLE_API Abstract
+{
+private:
+ enum PrivateEnum {
+ PrivValue0,
+ PrivValue1,
+ PrivValue2 = PrivValue1 + 2
+ };
+public:
+ enum PrintFormat {
+ Short,
+ Verbose,
+ OnlyId,
+ ClassNameAndId,
+ DummyItemToTestPrivateEnum1 = Abstract::PrivValue1,
+ DummyItemToTestPrivateEnum2 = PrivValue2,
+ };
+
+ enum Type {
+ TpAbstract, TpDerived
+ };
+
+ static const int staticPrimitiveField;
+ int primitiveField;
+ Complex userPrimitiveField;
+ Point valueTypeField;
+ ObjectType* objectTypeField;
+
+ Abstract(int id = -1);
+ virtual ~Abstract();
+
+ inline int id() { return m_id; }
+
+ // factory method
+ inline static Abstract* createObject() { return 0; }
+
+ // method that receives an Object Type
+ inline static int getObjectId(Abstract* obj) { return obj->id(); }
+
+ virtual void pureVirtual() = 0;
+ virtual void* pureVirtualReturningVoidPtr() = 0;
+ virtual void unpureVirtual();
+
+ virtual PrintFormat returnAnEnum() = 0;
+ void callVirtualGettingEnum(PrintFormat p);
+ virtual void virtualGettingAEnum(PrintFormat p);
+
+ void callPureVirtual();
+ void callUnpureVirtual();
+
+ void show(PrintFormat format = Verbose);
+ virtual Type type() const { return TpAbstract; }
+
+ virtual void hideFunction(HideType* arg) = 0;
+
+protected:
+ virtual const char* className() { return "Abstract"; }
+
+ // Protected bit-field structure member.
+ unsigned int bitField: 1;
+
+private:
+ int m_id;
+};
+#endif // ABSTRACT_H
diff --git a/sources/shiboken2/tests/libsample/blackbox.cpp b/sources/shiboken2/tests/libsample/blackbox.cpp
new file mode 100644
index 000000000..9a10850f3
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/blackbox.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "blackbox.h"
+
+using namespace std;
+
+BlackBox::~BlackBox()
+{
+ // Free all maps.
+ while (!m_objects.empty()) {
+ delete (*m_objects.begin()).second;
+ m_objects.erase(m_objects.begin());
+ }
+ while (!m_points.empty()) {
+ delete (*m_points.begin()).second;
+ m_points.erase(m_points.begin());
+ }
+}
+
+int
+BlackBox::keepObjectType(ObjectType* object)
+{
+ m_ticket++;
+ std::pair<int, ObjectType*> item(m_ticket, object);
+ m_objects.insert(item);
+ object->setParent(0);
+
+ return m_ticket;
+}
+
+ObjectType*
+BlackBox::retrieveObjectType(int ticket)
+{
+ map<int, ObjectType*>::iterator it = m_objects.find(ticket);
+ if (it != m_objects.end()) {
+ ObjectType* second = it->second;
+ m_objects.erase(it);
+ return second;
+ }
+ return 0;
+}
+
+void
+BlackBox::disposeObjectType(int ticket)
+{
+ ObjectType* object = retrieveObjectType(ticket);
+ if (object)
+ delete object;
+}
+
+int
+BlackBox::keepPoint(Point* point)
+{
+ m_ticket++;
+ std::pair<int, Point*> item(m_ticket, point);
+ m_points.insert(item);
+
+ return m_ticket;
+}
+
+Point*
+BlackBox::retrievePoint(int ticket)
+{
+ map<int, Point*>::iterator it = m_points.find(ticket);
+ if (it != m_points.end()) {
+ Point* second = it->second;
+ m_points.erase(it);
+ return second;
+ }
+ return 0;
+}
+
+void
+BlackBox::disposePoint(int ticket)
+{
+ Point* point = retrievePoint(ticket);
+ if (point)
+ delete point;
+}
+
+
+std::list<ObjectType*>
+BlackBox::objects()
+{
+ std::list<ObjectType*> l;
+ map<int, ObjectType*>::iterator it;
+
+ for ( it = m_objects.begin() ; it != m_objects.end(); it++ )
+ l.push_back((*it).second);
+
+ return l;
+}
+
+std::list<Point*>
+BlackBox::points()
+{
+ std::list<Point*> l;
+ map<int, Point*>::iterator it;
+
+ for ( it = m_points.begin() ; it != m_points.end(); it++ )
+ l.push_back((*it).second);
+
+ return l;
+}
+
diff --git a/sources/shiboken2/tests/libsample/blackbox.h b/sources/shiboken2/tests/libsample/blackbox.h
new file mode 100644
index 000000000..de776668c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/blackbox.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BLACKBOX_H
+#define BLACKBOX_H
+
+#include "libsamplemacros.h"
+#include <map>
+#include "objecttype.h"
+#include "point.h"
+
+class LIBSAMPLE_API BlackBox
+{
+public:
+ typedef std::map<int, ObjectType*> ObjectTypeMap;
+ typedef std::map<int, Point*> PointMap;
+
+ BlackBox() { m_ticket = -1;}
+ ~BlackBox();
+
+ int keepObjectType(ObjectType* object);
+ ObjectType* retrieveObjectType(int ticket);
+ void disposeObjectType(int ticket);
+
+ int keepPoint(Point* point);
+ Point* retrievePoint(int ticket);
+ void disposePoint(int ticket);
+
+ std::list<ObjectType*> objects();
+ std::list<Point*> points();
+
+ inline void referenceToValuePointer(Point*&) {}
+ inline void referenceToObjectPointer(ObjectType*&) {}
+
+private:
+ ObjectTypeMap m_objects;
+ PointMap m_points;
+ int m_ticket;
+};
+
+#endif // BLACKBOX_H
+
diff --git a/sources/shiboken2/tests/libsample/bucket.cpp b/sources/shiboken2/tests/libsample/bucket.cpp
new file mode 100644
index 000000000..50a1310e7
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/bucket.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bucket.h"
+#include <iostream>
+
+#ifdef _WIN32 // _WIN32 is defined by all Windows 32 and 64 bit compilers, but not by others.
+#include <windows.h>
+#define SLEEP(x) Sleep(x)
+#else
+#include <unistd.h>
+#define SLEEP(x) usleep(x)
+#endif
+
+
+using namespace std;
+
+Bucket::Bucket() : m_locked(false)
+{
+}
+
+void Bucket::push(int x)
+{
+ m_data.push_back(x);
+}
+
+int Bucket::pop(void)
+{
+ int x = 0;
+
+ if (m_data.size() > 0) {
+ x = m_data.front();
+ m_data.pop_front();
+ }
+
+ return x;
+}
+
+bool Bucket::empty()
+{
+ return m_data.empty();
+}
+
+void Bucket::lock()
+{
+ m_locked = true;
+ while (m_locked) { SLEEP(300); }
+}
+
+void Bucket::unlock()
+{
+ m_locked = false;
+}
+
+bool Bucket::virtualBlockerMethod()
+{
+ lock();
+ // The return value was added just for diversity sake.
+ return true;
+}
+
diff --git a/sources/shiboken2/tests/libsample/bucket.h b/sources/shiboken2/tests/libsample/bucket.h
new file mode 100644
index 000000000..bd8648b6b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/bucket.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BUCKET_H
+#define BUCKET_H
+
+#include "libsamplemacros.h"
+#include "objecttype.h"
+#include <list>
+
+class ObjectType;
+
+class LIBSAMPLE_API Bucket : public ObjectType
+{
+public:
+ Bucket();
+ void push(int);
+ int pop();
+ bool empty();
+ void lock();
+ inline bool locked() { return m_locked; }
+ void unlock();
+
+ virtual bool virtualBlockerMethod();
+ inline bool callVirtualBlockerMethodButYouDontKnowThis() { return virtualBlockerMethod(); }
+
+private:
+ std::list<int> m_data;
+
+ volatile bool m_locked;
+};
+
+#endif // BUCKET_H
+
diff --git a/sources/shiboken2/tests/libsample/bytearray.cpp b/sources/shiboken2/tests/libsample/bytearray.cpp
new file mode 100644
index 000000000..c86ada124
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/bytearray.cpp
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <cstring>
+#include "bytearray.h"
+
+ByteArray::ByteArray()
+{
+ m_data = std::vector<char>(1);
+ m_data[0] = '\0';
+}
+
+ByteArray::ByteArray(char c)
+{
+ m_data = std::vector<char>(2);
+ m_data[0] = c;
+ m_data[1] = '\0';
+}
+
+ByteArray::ByteArray(const char* data)
+{
+ size_t len = strlen(data);
+ m_data = std::vector<char>(len + 1);
+ memcpy(&m_data[0], data, len);
+ m_data[len] = '\0';
+}
+
+ByteArray::ByteArray(const char* data, int len)
+{
+ m_data = std::vector<char>(len + 1);
+ memcpy(&m_data[0], data, len);
+ m_data[len] = '\0';
+}
+
+ByteArray::ByteArray(const ByteArray& other)
+{
+ m_data = std::vector<char>(other.size() + 1);
+ memcpy(&m_data[0], &other.m_data[0], other.size());
+ m_data[other.size()] = '\0';
+}
+
+int
+ByteArray::size() const
+{
+ return m_data.size() - 1;
+}
+
+char
+ByteArray::at(int pos) const
+{
+ return m_data[pos];
+}
+
+const char*
+ByteArray::data() const
+{
+ return &(m_data[0]);
+}
+
+ByteArray&
+ByteArray::append(char c)
+{
+ m_data.pop_back();
+ m_data.push_back(c);
+ m_data.push_back('\0');
+ return *this;
+}
+
+ByteArray&
+ByteArray::append(const char* data)
+{
+ m_data.pop_back();
+ for (int i = 0; i < (int)strlen(data); ++i)
+ m_data.push_back(data[i]);
+ m_data.push_back('\0');
+ return *this;
+}
+
+ByteArray&
+ByteArray::append(const char* data, int len)
+{
+ m_data.pop_back();
+ for (int i = 0; i < len; ++i)
+ m_data.push_back(data[i]);
+ m_data.push_back('\0');
+ return *this;
+}
+
+ByteArray&
+ByteArray::append(const ByteArray& other)
+{
+ m_data.pop_back();
+ for (int i = 0; i < (int)other.m_data.size(); ++i)
+ m_data.push_back(other.m_data[i]);
+ m_data.push_back('\0');
+ return *this;
+}
+
+static bool compare(const std::vector<char>& mine, const char* other)
+{
+ for (int i = 0; i < (int)mine.size() - 1; ++i) {
+ if (mine[i] != other[i])
+ return false;
+ }
+ return true;
+}
+
+bool
+ByteArray::operator==(const ByteArray& other) const
+{
+ return compare(m_data, &other.m_data[0]);
+}
+bool
+operator==(const ByteArray& ba1, const char* ba2)
+{
+ return compare(ba1.m_data, ba2);
+}
+bool
+operator==(const char* ba1, const ByteArray& ba2)
+{
+ return compare(ba2.m_data, ba1);
+}
+
+bool
+ByteArray::operator!=(const ByteArray& other) const
+{
+ return !(m_data == other.m_data);
+}
+bool
+operator!=(const ByteArray& ba1, const char* ba2)
+{
+ return !(ba1 == ba2);
+}
+bool
+operator!=(const char* ba1, const ByteArray& ba2)
+{
+ return !(ba1 == ba2);
+}
+
+ByteArray&
+ByteArray::operator+=(char c)
+{
+ return append(c);
+}
+ByteArray&
+ByteArray::operator+=(const char* data)
+{
+ return append(data);
+}
+ByteArray&
+ByteArray::operator+=(const ByteArray& other)
+{
+ return append(other);
+}
+
+ByteArray
+operator+(const ByteArray& ba1, const ByteArray& ba2)
+{
+ return ByteArray(ba1) += ba2;
+}
+ByteArray
+operator+(const ByteArray& ba1, const char* ba2)
+{
+ return ByteArray(ba1) += ByteArray(ba2);
+}
+ByteArray
+operator+(const char* ba1, const ByteArray& ba2)
+{
+ return ByteArray(ba1) += ba2;
+}
+ByteArray
+operator+(const ByteArray& ba1, char ba2)
+{
+ return ByteArray(ba1) += ByteArray(ba2);
+}
+ByteArray
+operator+(char ba1, const ByteArray& ba2)
+{
+ return ByteArray(ba1) += ba2;
+}
+
+unsigned int
+ByteArray::hash(const ByteArray& byteArray)
+{
+ unsigned int result = 0;
+ for (int i = 0; i < (int)byteArray.m_data.size(); ++i)
+ result = 5 * result + byteArray.m_data[i];
+ return result;
+}
diff --git a/sources/shiboken2/tests/libsample/bytearray.h b/sources/shiboken2/tests/libsample/bytearray.h
new file mode 100644
index 000000000..d2219ee5d
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/bytearray.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BYTEARRAY_H
+#define BYTEARRAY_H
+
+#include "str.h"
+#include "libsamplemacros.h"
+#include <vector>
+
+class LIBSAMPLE_API ByteArray
+{
+public:
+ ByteArray();
+ ByteArray(char data);
+ ByteArray(const char* data);
+ ByteArray(const char* data, int len);
+ ByteArray(const ByteArray& other);
+
+ int size() const;
+ char at(int i) const;
+ char operator[](int i) const;
+
+ const char* data() const;
+
+ ByteArray& append(char c);
+ ByteArray& append(const char* data);
+ ByteArray& append(const char* data, int len);
+ ByteArray& append(const ByteArray& other);
+
+ bool operator==(const ByteArray& other) const;
+ bool operator!=(const ByteArray& other) const;
+
+ ByteArray& operator+=(char c);
+ ByteArray& operator+=(const char* data);
+ ByteArray& operator+=(const ByteArray& other);
+
+ static unsigned int hash(const ByteArray& byteArray);
+private:
+ std::vector<char> m_data;
+ friend LIBSAMPLE_API bool operator==(const ByteArray& ba1, const char* ba2);
+ friend LIBSAMPLE_API bool operator==(const char* ba1, const ByteArray& ba2);
+ friend LIBSAMPLE_API bool operator!=(const ByteArray& ba1, const char* ba2);
+ friend LIBSAMPLE_API bool operator!=(const char* ba1, const ByteArray& ba2);
+
+ friend LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, const ByteArray& ba2);
+ friend LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, const char* ba2);
+ friend LIBSAMPLE_API ByteArray operator+(const char* ba1, const ByteArray& ba2);
+ friend LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, char ba2);
+ friend LIBSAMPLE_API ByteArray operator+(char ba1, const ByteArray& ba2);
+};
+
+LIBSAMPLE_API bool operator==(const ByteArray& ba1, const char* ba2);
+LIBSAMPLE_API bool operator==(const char* ba1, const ByteArray& ba2);
+LIBSAMPLE_API bool operator!=(const ByteArray& ba1, const char* ba2);
+LIBSAMPLE_API bool operator!=(const char* ba1, const ByteArray& ba2);
+
+LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, const ByteArray& ba2);
+LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, const char* ba2);
+LIBSAMPLE_API ByteArray operator+(const char* ba1, const ByteArray& ba2);
+LIBSAMPLE_API ByteArray operator+(const ByteArray& ba1, char ba2);
+LIBSAMPLE_API ByteArray operator+(char ba1, const ByteArray& ba2);
+
+#endif // BYTEARRAY_H
diff --git a/sources/shiboken2/tests/libsample/collector.cpp b/sources/shiboken2/tests/libsample/collector.cpp
new file mode 100644
index 000000000..e60ed3af3
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/collector.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "collector.h"
+
+void Collector::clear()
+{
+ m_items.clear();
+}
+
+Collector& Collector::operator<<(ObjectType::Identifier item)
+{
+ m_items.push_back(item);
+ return *this;
+}
+
+Collector& Collector::operator<<(const ObjectType *obj)
+{
+ m_items.push_back(obj->identifier());
+ return *this;
+}
+
+std::list<ObjectType::Identifier> Collector::items()
+{
+ return m_items;
+}
+
+int Collector::size()
+{
+ return (int) m_items.size();
+}
+
+Collector &operator<<(Collector &s, const IntWrapper &w)
+{
+ s << w.value;
+ return s;
+}
diff --git a/sources/shiboken2/tests/libsample/collector.h b/sources/shiboken2/tests/libsample/collector.h
new file mode 100644
index 000000000..fe82909cb
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/collector.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COLLECTOR_H
+#define COLLECTOR_H
+
+#include <list>
+#include "libsamplemacros.h"
+
+#include "objecttype.h"
+
+class LIBSAMPLE_API Collector
+{
+public:
+ Collector() {}
+ virtual ~Collector() {}
+
+ void clear();
+
+ Collector& operator<<(ObjectType::Identifier item);
+
+ Collector& operator<<(const ObjectType *);
+
+ std::list<ObjectType::Identifier> items();
+ int size();
+
+private:
+ std::list<ObjectType::Identifier> m_items;
+
+ Collector(const Collector&);
+ Collector& operator=(const Collector&);
+};
+
+/* Helper for testing external operators */
+class IntWrapper
+{
+public:
+ IntWrapper(int x=0):value(x){}
+
+ int value;
+};
+
+LIBSAMPLE_API Collector &operator<<(Collector&, const IntWrapper&);
+
+#endif // COLLECTOR_H
+
diff --git a/sources/shiboken2/tests/libsample/complex.cpp b/sources/shiboken2/tests/libsample/complex.cpp
new file mode 100644
index 000000000..10e4b3f58
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/complex.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "complex.h"
+
+using namespace std;
+
+Complex::Complex(double real, double imag)
+ : m_real(real), m_imag(imag)
+{
+}
+
+Complex
+Complex::operator+(Complex& other)
+{
+ Complex result;
+ result.setReal(m_real + other.real());
+ result.setImaginary(m_imag + other.imag());
+ return result;
+}
+
+void
+Complex::show()
+{
+ cout << "(real: " << m_real << ", imag: " << m_imag << ")";
+}
+
+
diff --git a/sources/shiboken2/tests/libsample/complex.h b/sources/shiboken2/tests/libsample/complex.h
new file mode 100644
index 000000000..cb167bde9
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/complex.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COMPLEX_H
+#define COMPLEX_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Complex
+{
+public:
+ Complex(double real = 0.0, double imag = 0.0);
+ ~Complex() {}
+
+ inline double real() const { return m_real; }
+ inline void setReal(double real) { m_real = real; }
+ inline double imag() const { return m_imag; }
+ inline void setImaginary(double imag) { m_imag = imag; }
+
+ Complex operator+(Complex& other);
+
+ void show();
+
+private:
+ double m_real;
+ double m_imag;
+};
+
+#endif // COMPLEX_H
+
diff --git a/sources/shiboken2/tests/libsample/ctorconvrule.h b/sources/shiboken2/tests/libsample/ctorconvrule.h
new file mode 100644
index 000000000..776f4744c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/ctorconvrule.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CTORCONVRULE_H
+#define CTORCONVRULE_H
+
+#include "libsamplemacros.h"
+
+class CtorConvRule
+{
+public:
+ explicit CtorConvRule(long value) : m_value(value) {}
+ virtual ~CtorConvRule() {}
+ virtual void dummyVirtualMethod() {}
+ long value() { return m_value; }
+private:
+ long m_value;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/cvlist.h b/sources/shiboken2/tests/libsample/cvlist.h
new file mode 100644
index 000000000..c74007945
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/cvlist.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CONSTVALUELIST_H
+#define CONSTVALUELIST_H
+
+#include <list>
+#include "libsamplemacros.h"
+
+class CVValueType
+{
+ CVValueType();
+};
+
+typedef std::list<const CVValueType*> const_ptr_value_list;
+
+// This tests binding generation for a container of a const value type. The
+// class doesn't need to do anything; this is just to verify that the generated
+// binding code (the container conversion in particular) is const-valid.
+
+class CVListUser
+{
+public:
+ static const_ptr_value_list produce() { return const_ptr_value_list(); }
+ static void consume(const const_ptr_value_list& l) { (void)l; }
+};
+
+#endif // LIST_H
diff --git a/sources/shiboken2/tests/libsample/derived.cpp b/sources/shiboken2/tests/libsample/derived.cpp
new file mode 100644
index 000000000..00ac8ebe5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/derived.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "derived.h"
+
+using namespace std;
+
+Derived::Derived(int id) : Abstract(id)
+{
+}
+
+Derived::~Derived()
+{
+}
+
+Abstract*
+Derived::createObject()
+{
+ static int id = 100;
+ return new Derived(id++);
+}
+
+void
+Derived::pureVirtual()
+{
+}
+
+void*
+Derived::pureVirtualReturningVoidPtr()
+{
+ return 0;
+}
+
+void
+Derived::unpureVirtual()
+{
+}
+
+bool
+Derived::singleArgument(bool b)
+{
+ return !b;
+}
+
+double
+Derived::defaultValue(int n)
+{
+ return ((double) n) + 0.1;
+}
+
+OverloadedFuncEnum
+Derived::overloaded(int i, int d)
+{
+ return OverloadedFunc_ii;
+}
+
+OverloadedFuncEnum
+Derived::overloaded(double n)
+{
+ return OverloadedFunc_d;
+}
+
+Derived::OtherOverloadedFuncEnum
+Derived::otherOverloaded(int a, int b, bool c, double d)
+{
+ return OtherOverloadedFunc_iibd;
+}
+
+Derived::OtherOverloadedFuncEnum
+Derived::otherOverloaded(int a, double b)
+{
+ return OtherOverloadedFunc_id;
+}
+
+struct SecretClass : public Abstract {
+ virtual void pureVirtual() {}
+ virtual void* pureVirtualReturningVoidPtr() { return 0; }
+ virtual PrintFormat returnAnEnum() { return Short; }
+ void hideFunction(HideType*){};
+};
+
+Abstract* Derived::triggerImpossibleTypeDiscovery()
+{
+ return new SecretClass;
+}
+
+struct AnotherSecretClass : public Derived {
+};
+
+Abstract* Derived::triggerAnotherImpossibleTypeDiscovery()
+{
+ return new AnotherSecretClass;
+}
diff --git a/sources/shiboken2/tests/libsample/derived.h b/sources/shiboken2/tests/libsample/derived.h
new file mode 100644
index 000000000..5c57e4691
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/derived.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DERIVED_H
+#define DERIVED_H
+
+#include "libsamplemacros.h"
+#include "abstract.h"
+
+enum OverloadedFuncEnum {
+ OverloadedFunc_ii,
+ OverloadedFunc_d
+};
+
+class LIBSAMPLE_API Derived : public Abstract
+{
+public:
+ enum OtherOverloadedFuncEnum {
+ OtherOverloadedFunc_iibd,
+ OtherOverloadedFunc_id
+ };
+
+ class SomeInnerClass {
+ public:
+ void uselessMethod() {}
+ SomeInnerClass operator+(const SomeInnerClass& other) { return other; }
+ bool operator==(const SomeInnerClass& other) { return true; }
+ };
+
+ Derived(int id = -1);
+ virtual ~Derived();
+ virtual void pureVirtual();
+ virtual void* pureVirtualReturningVoidPtr();
+ virtual void unpureVirtual();
+
+ virtual PrintFormat returnAnEnum() { return Short; }
+ virtual Type type() const { return TpDerived; }
+
+ // factory method
+ static Abstract* createObject();
+
+ // single argument
+ bool singleArgument(bool b);
+
+ // method with default value
+ double defaultValue(int n = 0);
+
+ // overloads
+ OverloadedFuncEnum overloaded(int i = 0, int d = 0);
+ OverloadedFuncEnum overloaded(double n);
+
+ // more overloads
+ OtherOverloadedFuncEnum otherOverloaded(int a, int b, bool c, double d);
+ OtherOverloadedFuncEnum otherOverloaded(int a, double b);
+
+ inline SomeInnerClass returnMyParameter(const SomeInnerClass& s) { return s; }
+
+ static Abstract* triggerImpossibleTypeDiscovery();
+ static Abstract* triggerAnotherImpossibleTypeDiscovery();
+
+ void hideFunction(HideType*) {}
+protected:
+ const char* getClassName() { return className(); }
+ virtual const char* className() { return "Derived"; }
+};
+#endif // DERIVED_H
+
diff --git a/sources/shiboken2/tests/libsample/echo.cpp b/sources/shiboken2/tests/libsample/echo.cpp
new file mode 100644
index 000000000..00fec78b0
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/echo.cpp
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "echo.h"
diff --git a/sources/shiboken2/tests/libsample/echo.h b/sources/shiboken2/tests/libsample/echo.h
new file mode 100644
index 000000000..a976c9cbc
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/echo.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ECHO_H
+#define ECHO_H
+
+#include "libsamplemacros.h"
+#include "str.h"
+
+class ObjectType;
+
+class Echo
+{
+public:
+ Echo(){}
+ ~Echo(){}
+
+ void doNothingWithConstBool(const bool hi) {}
+ void methodWithNamedArg(const Str& string = Str("")) {}
+
+ Str operator()(const Str& s, const int i) { return s + i; }
+
+ // These method are here just for compilation test purposes
+ Echo& operator<<(unsigned int item) { return *this; }
+ Echo& operator<<(signed int item) { return *this; }
+ Echo& operator<<(const ObjectType* item) { return *this; }
+ Echo& operator<<(Str str) { return *this; }
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/expression.cpp b/sources/shiboken2/tests/libsample/expression.cpp
new file mode 100644
index 000000000..ff87e2ed2
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/expression.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "expression.h"
+#include <sstream>
+
+Expression::Expression() : m_value(0), m_operation(None), m_operand1(0), m_operand2(0)
+{
+}
+
+Expression::Expression(int number) : m_value(number), m_operation(None), m_operand1(0), m_operand2(0)
+{
+}
+
+Expression::Expression(const Expression& other)
+{
+ m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : 0;
+ m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : 0;
+ m_value = other.m_value;
+ m_operation = other.m_operation;
+}
+
+Expression& Expression::operator=(const Expression& other)
+{
+ delete m_operand1;
+ delete m_operand2;
+ m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : 0;
+ m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : 0;
+ m_operation = other.m_operation;
+ m_value = other.m_value;
+ return *this;
+}
+
+Expression::~Expression()
+{
+ delete m_operand1;
+ delete m_operand2;
+}
+
+Expression Expression::operator+(const Expression& other)
+{
+ Expression expr;
+ expr.m_operation = Add;
+ expr.m_operand1 = new Expression(*this);
+ expr.m_operand2 = new Expression(other);
+ return expr;
+}
+
+Expression Expression::operator-(const Expression& other)
+{
+ Expression expr;
+ expr.m_operation = Add;
+ expr.m_operand1 = new Expression(*this);
+ expr.m_operand2 = new Expression(other);
+ return expr;
+}
+
+Expression Expression::operator<(const Expression& other)
+{
+ Expression expr;
+ expr.m_operation = LessThan;
+ expr.m_operand1 = new Expression(*this);
+ expr.m_operand2 = new Expression(other);
+ return expr;
+}
+
+Expression Expression::operator>(const Expression& other)
+{
+ Expression expr;
+ expr.m_operation = GreaterThan;
+ expr.m_operand1 = new Expression(*this);
+ expr.m_operand2 = new Expression(other);
+ return expr;
+}
+
+std::string Expression::toString() const
+{
+ if (m_operation == None) {
+ std::ostringstream s;
+ s << m_value;
+ return s.str();
+ }
+
+ std::string result;
+ result += '(';
+ result += m_operand1->toString();
+ char op;
+ switch (m_operation) {
+ case Add:
+ op = '+';
+ break;
+ case Sub:
+ op = '-';
+ break;
+ case LessThan:
+ op = '<';
+ break;
+ case GreaterThan:
+ op = '<';
+ break;
+ case None: // just to avoid the compiler warning
+ default:
+ op = '?';
+ break;
+ }
+ result += op;
+ result += m_operand2->toString();
+ result += ')';
+ return result;
+}
+
diff --git a/sources/shiboken2/tests/libsample/expression.h b/sources/shiboken2/tests/libsample/expression.h
new file mode 100644
index 000000000..c4bb1a1f5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/expression.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef EXPRESSION_H
+#define EXPRESSION_H
+
+#include "libsamplemacros.h"
+#include <string>
+
+class LIBSAMPLE_API Expression
+{
+public:
+ enum Operation {
+ None, Add, Sub, LessThan, GreaterThan
+ };
+
+ Expression(int number);
+ Expression(const Expression& other);
+ Expression& operator=(const Expression& other);
+
+ ~Expression();
+
+ Expression operator>(const Expression& other);
+ Expression operator<(const Expression& other);
+ Expression operator+(const Expression& other);
+ Expression operator-(const Expression& other);
+
+ std::string toString() const;
+private:
+ int m_value;
+ Operation m_operation;
+ Expression* m_operand1;
+ Expression* m_operand2;
+
+ Expression();
+};
+
+#endif // EXPRESSION_H
diff --git a/sources/shiboken2/tests/libsample/filter.cpp b/sources/shiboken2/tests/libsample/filter.cpp
new file mode 100644
index 000000000..dac5d5e96
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/filter.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <string>
+#include "filter.h"
+Data::Data(Field field, std::string value)
+ : m_field(field), m_value(value)
+{
+}
+
+Union::Union(const Data& filter)
+{
+ m_filters.push_back(filter);
+}
+
+Union::Union(const Intersection& filter)
+{
+ m_filters.push_back(filter);
+}
+
+Union::Union(const Union& filter)
+{
+ m_filters = filter.filters();
+}
+
+Intersection::Intersection(const Data& filter)
+{
+ m_filters.push_back(filter);
+}
+
+Intersection::Intersection(const Union& filter)
+{
+ m_filters.push_back(filter);
+}
+
+Intersection::Intersection(const Intersection& filter)
+{
+ m_filters = filter.filters();
+}
+
+Intersection operator&(const Intersection& a, const Intersection& b)
+{
+ Intersection filter;
+ filter.addFilter(a);
+ filter.addFilter(b);
+
+ return filter;
+}
diff --git a/sources/shiboken2/tests/libsample/filter.h b/sources/shiboken2/tests/libsample/filter.h
new file mode 100644
index 000000000..6ee2e6123
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/filter.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FILTER_H
+#define FILTER_H
+
+#include <string>
+#include <list>
+
+#include "libsamplemacros.h"
+
+class Intersection;
+
+class LIBSAMPLE_API Filter
+{
+};
+
+class LIBSAMPLE_API Data : public Filter
+{
+
+public:
+ enum Field {
+ Name,
+ Album,
+ Year
+ };
+
+ Data(Field field, std::string value);
+
+ Field field() const { return m_field; }
+ std::string value() const { return m_value; }
+
+private:
+ Field m_field;
+ std::string m_value;
+};
+
+class LIBSAMPLE_API Union : public Filter
+{
+public:
+
+ Union(const Data&);
+ Union(const Intersection&);
+ Union() {};
+ Union(const Union&);
+
+ std::list<Filter> filters() const { return m_filters; }
+ void addFilter(const Filter& data) { m_filters.push_back(data); }
+
+private:
+ std::list<Filter> m_filters;
+};
+
+class LIBSAMPLE_API Intersection : public Filter
+{
+public:
+
+ Intersection(const Data&);
+ Intersection(const Union&);
+ Intersection() {};
+ Intersection(const Intersection&);
+
+ std::list<Filter> filters() const { return m_filters; }
+ void addFilter(const Filter& data) { m_filters.push_back(data); }
+
+private:
+ std::list<Filter> m_filters;
+};
+
+LIBSAMPLE_API Intersection operator&(const Intersection& a, const Intersection& b);
+
+#endif // FILTER_H
+
+
diff --git a/sources/shiboken2/tests/libsample/functions.cpp b/sources/shiboken2/tests/libsample/functions.cpp
new file mode 100644
index 000000000..4a15cdae8
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/functions.cpp
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "functions.h"
+#include <string.h>
+#include <iostream>
+
+using namespace std;
+
+void
+printSomething()
+{
+ cout << __FUNCTION__ << endl;
+}
+
+int
+gimmeInt()
+{
+ static int val = 2;
+ val = val * 1.3;
+ return val;
+}
+
+double
+gimmeDouble()
+{
+ static double val = 7.77;
+ val = val * 1.3;
+ return val;
+}
+
+std::list<Complex>
+gimmeComplexList()
+{
+ std::list<Complex> lst;
+ lst.push_back(Complex());
+ lst.push_back(Complex(1.1, 2.2));
+ lst.push_back(Complex(1.3, 2.4));
+ return lst;
+}
+
+Complex
+sumComplexPair(std::pair<Complex, Complex> cpx_pair)
+{
+ return cpx_pair.first + cpx_pair.second;
+}
+
+double
+multiplyPair(std::pair<double, double> pair)
+{
+ return pair.first * pair.second;
+}
+
+int
+countCharacters(const char* text)
+{
+ if (!text)
+ return -1;
+ int count;
+ for(count = 0; text[count] != '\0'; count++)
+ ;
+ return count;
+}
+
+char*
+makeCString()
+{
+ char* string = new char[strlen(__FUNCTION__) + 1];
+ strcpy(string, __FUNCTION__);
+ return string;
+}
+
+const char*
+returnCString()
+{
+ return __FUNCTION__;
+}
+
+GlobalOverloadFuncEnum
+overloadedFunc(int val)
+{
+ return GlobalOverloadFunc_i;
+}
+
+GlobalOverloadFuncEnum
+overloadedFunc(double val)
+{
+ return GlobalOverloadFunc_d;
+}
+
+char*
+returnNullPrimitivePointer()
+{
+ return 0;
+}
+
+ObjectType*
+returnNullObjectTypePointer()
+{
+ return 0;
+}
+
+Event*
+returnNullValueTypePointer()
+{
+ return 0;
+}
+
+unsigned int
+doubleUnsignedInt(unsigned int value)
+{
+ return value * 2;
+}
+
+long long
+doubleLongLong(long long value)
+{
+ return value * 2;
+}
+
+unsigned long long
+doubleUnsignedLongLong(unsigned long long value)
+{
+ return value * 2;
+}
+
+short
+doubleShort(short value)
+{
+ return value * 2;
+}
+
+int
+acceptInt(int x)
+{
+ return x;
+}
+
+unsigned int
+acceptUInt(unsigned int x)
+{
+ return x;
+}
+
+long
+acceptLong(long x)
+{
+ return x;
+}
+
+unsigned long
+acceptULong(unsigned long x)
+{
+ return x;
+}
+
+double
+acceptDouble(double x)
+{
+ return x;
+}
+
+int
+acceptIntReference(int& x)
+{
+ return x;
+}
+
+OddBool
+acceptOddBoolReference(OddBool& x)
+{
+ return x;
+}
+
+ClassWithFunctionPointer::ClassWithFunctionPointer()
+{
+ callFunctionPointer(0, &ClassWithFunctionPointer::doNothing);
+}
+
+void ClassWithFunctionPointer::callFunctionPointer(int dummy, void (*fp)(void *))
+{
+ size_t a = dummy;
+ fp(reinterpret_cast<void *>(a));
+}
+
+void ClassWithFunctionPointer::doNothing(void *operand)
+{
+ (void) operand;
+}
diff --git a/sources/shiboken2/tests/libsample/functions.h b/sources/shiboken2/tests/libsample/functions.h
new file mode 100644
index 000000000..89a175bc4
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/functions.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FUNCTIONS_H
+#define FUNCTIONS_H
+
+#include "libsamplemacros.h"
+#include <list>
+#include <utility>
+#include "oddbool.h"
+#include "complex.h"
+#include "objecttype.h"
+
+enum GlobalEnum {
+ NoThing,
+ FirstThing,
+ SecondThing,
+ ThirdThing
+};
+
+enum GlobalOverloadFuncEnum {
+ GlobalOverloadFunc_i,
+ GlobalOverloadFunc_d
+};
+
+LIBSAMPLE_API void printSomething();
+LIBSAMPLE_API int gimmeInt();
+LIBSAMPLE_API double gimmeDouble();
+LIBSAMPLE_API double multiplyPair(std::pair<double, double> pair);
+LIBSAMPLE_API std::list<Complex> gimmeComplexList();
+LIBSAMPLE_API Complex sumComplexPair(std::pair<Complex, Complex> cpx_pair);
+
+LIBSAMPLE_API int countCharacters(const char* text);
+LIBSAMPLE_API char* makeCString();
+LIBSAMPLE_API const char* returnCString();
+
+LIBSAMPLE_API char* returnNullPrimitivePointer();
+LIBSAMPLE_API ObjectType* returnNullObjectTypePointer();
+LIBSAMPLE_API Event* returnNullValueTypePointer();
+
+// Tests overloading on functions (!methods)
+LIBSAMPLE_API GlobalOverloadFuncEnum overloadedFunc(int val);
+LIBSAMPLE_API GlobalOverloadFuncEnum overloadedFunc(double val);
+
+LIBSAMPLE_API unsigned int doubleUnsignedInt(unsigned int value);
+LIBSAMPLE_API long long doubleLongLong(long long value);
+LIBSAMPLE_API unsigned long long doubleUnsignedLongLong(unsigned long long value);
+LIBSAMPLE_API short doubleShort(short value);
+
+LIBSAMPLE_API int acceptInt(int x);
+LIBSAMPLE_API unsigned int acceptUInt(unsigned int x);
+LIBSAMPLE_API long acceptLong(long x);
+LIBSAMPLE_API unsigned long acceptULong(unsigned long x);
+LIBSAMPLE_API double acceptDouble(double x);
+
+LIBSAMPLE_API int acceptIntReference(int& x);
+LIBSAMPLE_API OddBool acceptOddBoolReference(OddBool& x);
+
+
+class LIBSAMPLE_API ClassWithFunctionPointer
+{
+public:
+ explicit ClassWithFunctionPointer();
+ void callFunctionPointer(int dummy, void (*fp)(void *));
+ static void doNothing(void *operand);
+};
+
+#endif // FUNCTIONS_H
diff --git a/sources/shiboken2/tests/libsample/handle.cpp b/sources/shiboken2/tests/libsample/handle.cpp
new file mode 100644
index 000000000..e0b1d8d18
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/handle.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "handle.h"
+
+HANDLE HandleHolder::createHandle()
+{
+ return (HANDLE) new OBJ;
+}
+
+bool HandleHolder::compare(HandleHolder* other)
+{
+ return other->m_handle == m_handle;
+}
+
+bool HandleHolder::compare2(HandleHolder* other)
+{
+ return other->m_handle2 == m_handle2;
+}
diff --git a/sources/shiboken2/tests/libsample/handle.h b/sources/shiboken2/tests/libsample/handle.h
new file mode 100644
index 000000000..d656f946b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/handle.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HANDLE_H
+#define HANDLE_H
+
+#include "libsamplemacros.h"
+
+/* See http://bugs.pyside.org/show_bug.cgi?id=1105. */
+namespace Foo {
+ typedef unsigned long HANDLE;
+}
+
+class LIBSAMPLE_API OBJ
+{
+};
+
+typedef OBJ* HANDLE;
+
+class LIBSAMPLE_API HandleHolder
+{
+public:
+ explicit HandleHolder(HANDLE ptr = 0) : m_handle(ptr) {}
+ explicit HandleHolder(Foo::HANDLE val): m_handle2(val) {}
+
+ inline void set(HANDLE ptr) { HANDLE tmp; tmp = m_handle; m_handle = tmp; }
+ inline void set(const Foo::HANDLE& val) { m_handle2 = val; }
+ inline HANDLE handle() { return m_handle; }
+ inline Foo::HANDLE handle2() { return m_handle2; }
+
+ static HANDLE createHandle();
+ bool compare(HandleHolder* other);
+ bool compare2(HandleHolder* other);
+
+private:
+ HANDLE m_handle;
+ Foo::HANDLE m_handle2;
+};
+
+struct LIBSAMPLE_API PrimitiveStruct {};
+typedef struct PrimitiveStruct* PrimitiveStructPtr;
+struct LIBSAMPLE_API PrimitiveStructPointerHolder
+{
+ PrimitiveStructPtr primitiveStructPtr;
+};
+
+#endif // HANDLE_H
diff --git a/sources/shiboken2/tests/libsample/implicitconv.cpp b/sources/shiboken2/tests/libsample/implicitconv.cpp
new file mode 100644
index 000000000..df4af2537
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/implicitconv.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "implicitconv.h"
+
+ImplicitConv
+ImplicitConv::implicitConvCommon(ImplicitConv implicit)
+{
+ return implicit;
+}
+
+ImplicitConv
+ImplicitConv::implicitConvDefault(ImplicitConv implicit)
+{
+ return implicit;
+}
+
+ImplicitConv::ICOverloadedFuncEnum
+ImplicitConv::implicitConvOverloading(ImplicitConv implicit, int dummyArg)
+{
+ return ImplicitConv::OverFunc_Ii;
+}
+
+ImplicitConv::ICOverloadedFuncEnum
+ImplicitConv::implicitConvOverloading(ImplicitConv implicit, bool dummyArg)
+{
+ return ImplicitConv::OverFunc_Ib;
+}
+
+ImplicitConv::ICOverloadedFuncEnum
+ImplicitConv::implicitConvOverloading(int dummyArg)
+{
+ return ImplicitConv::OverFunc_i;
+}
+
+ImplicitConv::ICOverloadedFuncEnum
+ImplicitConv::implicitConvOverloading(CtorEnum dummyArg)
+{
+ return ImplicitConv::OverFunc_C;
+}
+
diff --git a/sources/shiboken2/tests/libsample/implicitconv.h b/sources/shiboken2/tests/libsample/implicitconv.h
new file mode 100644
index 000000000..2a8ac66c2
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/implicitconv.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IMPLICITCONV_H
+#define IMPLICITCONV_H
+
+#include "libsamplemacros.h"
+#include "null.h"
+
+class ObjectType;
+
+class LIBSAMPLE_API ImplicitConv
+{
+public:
+ enum CtorEnum {
+ CtorNone,
+ CtorOne,
+ CtorTwo,
+ CtorThree,
+ CtorObjectTypeReference,
+ CtorPrimitiveType
+ };
+
+ enum ICOverloadedFuncEnum {
+ OverFunc_Ii,
+ OverFunc_Ib,
+ OverFunc_i,
+ OverFunc_C
+ };
+
+ ImplicitConv() : m_ctorEnum(CtorNone), m_objId(-1), m_value(-1.0) {}
+ ImplicitConv(int objId) : m_ctorEnum(CtorOne), m_objId(objId), m_value(-1.0) {}
+ ImplicitConv(CtorEnum ctorEnum) : m_ctorEnum(ctorEnum), m_objId(-1), m_value(-1.0) {}
+ ImplicitConv(ObjectType&) : m_ctorEnum(CtorObjectTypeReference), m_objId(-1), m_value(-1.0) {}
+ ImplicitConv(double value, bool=true) : m_ctorEnum(CtorNone), m_value(value) {}
+ ImplicitConv(const Null& null) : m_ctorEnum(CtorPrimitiveType) {}
+ ~ImplicitConv() {}
+
+ inline CtorEnum ctorEnum() { return m_ctorEnum; }
+ inline int objId() { return m_objId; }
+ inline double value() { return m_value; }
+
+ static ImplicitConv implicitConvCommon(ImplicitConv implicit);
+
+ static ImplicitConv implicitConvDefault(ImplicitConv implicit = CtorTwo);
+
+ static ICOverloadedFuncEnum implicitConvOverloading(ImplicitConv implicit, int dummyArg);
+ static ICOverloadedFuncEnum implicitConvOverloading(ImplicitConv implicit, bool dummyArg);
+ static ICOverloadedFuncEnum implicitConvOverloading(int dummyArg);
+ static ICOverloadedFuncEnum implicitConvOverloading(CtorEnum dummyArg);
+
+private:
+ CtorEnum m_ctorEnum;
+ int m_objId;
+ double m_value;
+};
+
+#endif // IMPLICITCONV_H
diff --git a/sources/shiboken2/tests/libsample/injectcode.cpp b/sources/shiboken2/tests/libsample/injectcode.cpp
new file mode 100644
index 000000000..4406cdc5c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/injectcode.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "injectcode.h"
+#include <sstream>
+
+using namespace std;
+
+InjectCode::InjectCode()
+{
+}
+
+InjectCode::~InjectCode()
+{
+}
+
+template<typename T>
+const char* InjectCode::toStr(const T& value)
+{
+ std::ostringstream s;
+ s << value;
+ m_valueHolder = s.str();
+ return m_valueHolder.c_str();
+}
+
+const char* InjectCode::simpleMethod1(int arg0, int arg1)
+{
+ return toStr(arg0 + arg1);
+}
+
+const char* InjectCode::simpleMethod2()
+{
+ return "_";
+}
+
+const char* InjectCode::simpleMethod3(int argc, char** argv)
+{
+ for (int i = 0; i < argc; ++i)
+ m_valueHolder += argv[i];
+ return m_valueHolder.c_str();
+}
+
+const char* InjectCode::overloadedMethod(int arg0, bool arg1)
+{
+ toStr(arg0);
+ m_valueHolder += arg1 ? "true" : "false";
+ return m_valueHolder.c_str();
+}
+
+const char* InjectCode::overloadedMethod(int arg0, double arg1)
+{
+ return toStr(arg0 + arg1);
+}
+
+const char* InjectCode::overloadedMethod(int argc, char** argv)
+{
+ return simpleMethod3(argc, argv);
+}
+
+const char* InjectCode::virtualMethod(int arg)
+{
+ return toStr(arg);
+}
+
+int InjectCode::arrayMethod(int count, int *values) const
+{
+ int ret = 0;
+ for (int i=0; i < count; i++)
+ ret += values[i];
+ return ret;
+}
+
+int InjectCode::sumArrayAndLength(int* values) const
+{
+ int sum = 0;
+
+ while(*values) {
+ sum = sum + *values + 1;
+ values++;
+ }
+
+ return sum;
+}
diff --git a/sources/shiboken2/tests/libsample/injectcode.h b/sources/shiboken2/tests/libsample/injectcode.h
new file mode 100644
index 000000000..ba1bedb17
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/injectcode.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef INJECTCODE_H
+#define INJECTCODE_H
+
+#include "libsamplemacros.h"
+#include <utility>
+#include <string>
+
+class LIBSAMPLE_API InjectCode
+{
+public:
+ InjectCode();
+ virtual ~InjectCode();
+
+ const char* simpleMethod1(int arg0, int arg1);
+ const char* simpleMethod2();
+ const char* simpleMethod3(int argc, char** argv);
+
+ const char* overloadedMethod(int argc, char** argv);
+ const char* overloadedMethod(int arg0, double arg1);
+ const char* overloadedMethod(int arg0, bool arg1);
+
+ virtual int arrayMethod(int count, int* values) const;
+ inline int callArrayMethod(int count, int *values) const { return arrayMethod(count, values); }
+ virtual const char* virtualMethod(int arg);
+ int sumArrayAndLength(int* values) const;
+private:
+ // This attr is just to retain the memory pointed by all return values,
+ // So, the memory returned by all methods will be valid until someone call
+ // another method of this class.
+ std::string m_valueHolder;
+
+ template<typename T>
+ const char* toStr(const T& value);
+};
+
+#endif // INJECTCODE_H
+
diff --git a/sources/shiboken2/tests/libsample/libsamplemacros.h b/sources/shiboken2/tests/libsample/libsamplemacros.h
new file mode 100644
index 000000000..6a1bba88d
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/libsamplemacros.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIBSAMPLEMACROS_H
+#define LIBSAMPLEMACROS_H
+
+#if defined _WIN32 || defined __CYGWIN__
+ #if LIBSAMPLE_BUILD
+ #define LIBSAMPLE_API __declspec(dllexport)
+ #else
+ #define LIBSAMPLE_API __declspec(dllimport)
+ #endif
+#else
+#if __GNUC__ >= 4
+ #define LIBSAMPLE_API __attribute__ ((visibility("default")))
+#else
+ #define LIBSAMPLE_API
+#endif
+#endif
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/list.h b/sources/shiboken2/tests/libsample/list.h
new file mode 100644
index 000000000..f1183440c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/list.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIST_H
+#define LIST_H
+
+#include <list>
+#include "libsamplemacros.h"
+#include "point.h"
+
+class ObjectType;
+
+template<class T>
+class List : public std::list<T>
+{
+};
+
+class IntList : public List<int>
+{
+public:
+ enum CtorEnum {
+ NoParamsCtor,
+ IntCtor,
+ CopyCtor,
+ ListOfIntCtor
+ };
+
+ inline IntList() : m_ctorUsed(NoParamsCtor) {}
+ inline explicit IntList(int val) : m_ctorUsed(IntCtor) { push_back(val); }
+ inline IntList(const IntList& lst) : List<int>(lst), m_ctorUsed(CopyCtor) {}
+ inline IntList(const List<int>& lst) : List<int>(lst), m_ctorUsed(ListOfIntCtor) {}
+
+ inline void append(int v) { insert(end(), v); }
+ CtorEnum constructorUsed() { return m_ctorUsed; }
+private:
+ CtorEnum m_ctorUsed;
+};
+
+class PointValueList : public List<Point>
+{
+public:
+ enum CtorEnum {
+ NoParamsCtor,
+ PointCtor,
+ CopyCtor,
+ ListOfPointValuesCtor
+ };
+
+ inline PointValueList() : m_ctorUsed(NoParamsCtor) {}
+ inline explicit PointValueList(Point val) : m_ctorUsed(PointCtor) { push_back(val); }
+ inline PointValueList(const PointValueList& lst) : List<Point>(lst), m_ctorUsed(CopyCtor) {}
+ inline PointValueList(const List<Point>& lst) : List<Point>(lst), m_ctorUsed(ListOfPointValuesCtor) {}
+
+ inline void append(Point v) { insert(end(), v); }
+ CtorEnum constructorUsed() { return m_ctorUsed; }
+private:
+ CtorEnum m_ctorUsed;
+};
+
+class ObjectTypePtrList : public List<ObjectType*>
+{
+public:
+ enum CtorEnum {
+ NoParamsCtor,
+ ObjectTypeCtor,
+ CopyCtor,
+ ListOfObjectTypePtrCtor
+ };
+
+ inline ObjectTypePtrList() : m_ctorUsed(NoParamsCtor) {}
+ inline explicit ObjectTypePtrList(ObjectType* val) : m_ctorUsed(ObjectTypeCtor) { push_back(val); }
+ inline ObjectTypePtrList(const ObjectTypePtrList& lst) : List<ObjectType*>(lst), m_ctorUsed(CopyCtor) {}
+ inline ObjectTypePtrList(const List<ObjectType*>& lst) : List<ObjectType*>(lst), m_ctorUsed(ListOfObjectTypePtrCtor) {}
+
+ inline void append(ObjectType* v) { insert(end(), v); }
+ CtorEnum constructorUsed() { return m_ctorUsed; }
+private:
+ CtorEnum m_ctorUsed;
+};
+
+#endif // LIST_H
diff --git a/sources/shiboken2/tests/libsample/listuser.cpp b/sources/shiboken2/tests/libsample/listuser.cpp
new file mode 100644
index 000000000..24389766e
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/listuser.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <numeric>
+#include <cstdlib>
+#include "listuser.h"
+
+using namespace std;
+
+std::list<int>
+ListUser::callCreateList()
+{
+ return createList();
+}
+
+std::list<int>
+ListUser::createList()
+{
+ std::list<int> retval;
+ for (int i = 0; i < 4; i++)
+ retval.push_front(rand());
+ return retval;
+}
+
+std::list<Complex>
+ListUser::createComplexList(Complex cpx0, Complex cpx1)
+{
+ std::list<Complex> retval;
+ retval.push_back(cpx0);
+ retval.push_back(cpx1);
+ return retval;
+}
+
+double
+ListUser::sumList(std::list<int> vallist)
+{
+ return std::accumulate(vallist.begin(), vallist.end(), 0.0);
+}
+
+double
+ListUser::sumList(std::list<double> vallist)
+{
+ return std::accumulate(vallist.begin(), vallist.end(), 0.0);
+}
+
+ListUser::ListOfSomething
+ListUser::listOfPoints(const std::list<Point>& pointlist)
+{
+ return ListOfPoint;
+}
+
+ListUser::ListOfSomething
+ListUser::listOfPoints(const std::list<PointF>& pointlist)
+{
+ return ListOfPointF;
+}
+
+void
+ListUser::multiplyPointList(PointList& points, double multiplier)
+{
+ for(PointList::iterator piter = points.begin(); piter != points.end(); piter++) {
+ (*piter)->setX((*piter)->x() * multiplier);
+ (*piter)->setY((*piter)->y() * multiplier);
+ }
+}
+
diff --git a/sources/shiboken2/tests/libsample/listuser.h b/sources/shiboken2/tests/libsample/listuser.h
new file mode 100644
index 000000000..8f49c80d3
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/listuser.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LISTUSER_H
+#define LISTUSER_H
+
+#include <list>
+#include "complex.h"
+#include "point.h"
+#include "pointf.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API ListUser
+{
+public:
+ typedef std::list<Point*> PointList;
+
+ enum ListOfSomething {
+ ListOfPoint,
+ ListOfPointF
+ };
+
+ ListUser() {}
+ ListUser(const ListUser& other) : m_lst(other.m_lst) {}
+ virtual ~ListUser() {}
+
+ virtual std::list<int> createList();
+ std::list<int> callCreateList();
+
+ static std::list<Complex> createComplexList(Complex cpx0, Complex cpx1);
+
+ double sumList(std::list<int> vallist);
+ double sumList(std::list<double> vallist);
+
+ static ListOfSomething listOfPoints(const std::list<Point>& pointlist);
+ static ListOfSomething listOfPoints(const std::list<PointF>& pointlist);
+
+ static void multiplyPointList(PointList& points, double multiplier);
+
+ inline void setList(std::list<int> lst) { m_lst = lst; }
+ inline std::list<int> getList() { return m_lst; }
+
+private:
+ std::list<int> m_lst;
+};
+
+#endif // LISTUSER_H
+
diff --git a/sources/shiboken2/tests/libsample/main.cpp b/sources/shiboken2/tests/libsample/main.cpp
new file mode 100644
index 000000000..b22d05a36
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/main.cpp
@@ -0,0 +1,244 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include <list>
+#include "abstract.h"
+#include "derived.h"
+#include "kindergarten.h"
+#include "complex.h"
+#include "point.h"
+#include "size.h"
+#include "listuser.h"
+#include "samplenamespace.h"
+
+using namespace std;
+
+int
+main(int argv, char **argc)
+{
+ cout << endl;
+
+ Derived derived;
+
+ cout << endl;
+
+ derived.unpureVirtual();
+ derived.pureVirtual();
+ derived.callPureVirtual();
+
+ cout << endl;
+ Abstract* abs;
+ abs = Abstract::createObject();
+ cout << "Abstract::createObject(): " << abs << endl << endl;
+ delete abs;
+
+ abs = Derived::createObject();
+ cout << "Derived::createObject() : ";
+ abs->show();
+ cout << endl;
+ delete abs;
+ cout << endl;
+
+ abs = Derived::createObject();
+ cout << "Derived::createObject() : ";
+ abs->show();
+ cout << endl;
+ delete abs;
+ cout << endl;
+
+ cout << endl << "-----------------------------------------" << endl;
+
+ KinderGarten kg;
+ Derived* d[] = { 0, 0, 0 };
+
+ for (int i = 0; i < 3; i++) {
+ d[i] = new Derived(i);
+ d[i]->show();
+ cout << endl;
+ kg.addChild(d[i]);
+ }
+
+ kg.show();
+ cout << endl;
+
+ cout << endl << "* kill child ";
+ d[2]->show();
+ cout << " ----------------" << endl;
+ kg.killChild(d[2]);
+ kg.show();
+ cout << endl;
+
+ cout << endl << "* release child ";
+ d[1]->show();
+ cout << " -------------" << endl;
+ Abstract* released = kg.releaseChild(d[1]);
+ cout << "released: ";
+ released->show();
+ cout << endl;
+ kg.show();
+ cout << endl;
+
+ cout << endl << "* kill children ------------------------------------" << endl;
+ kg.killChildren();
+ kg.show();
+ cout << endl << endl;
+
+ cout << "-----------------------------------------" << endl;
+ ListUser lu;
+ cout << "ListUser::createList()" << endl;
+ std::list<int> intlist = lu.createList();
+ for (std::list<int>::iterator it = intlist.begin(); it != intlist.end(); it++) {
+ cout << "* " << *it << endl;
+ }
+
+ cout << "ListUser::createComplexList" << endl;
+ std::list<Complex> cpxlist = ListUser::createComplexList(Complex(1.1, 2.2), Complex(3.3, 4.4));
+ for (std::list<Complex>::iterator it = cpxlist.begin(); it != cpxlist.end(); it++) {
+ cout << "* ";
+ (*it).show();
+ cout << endl;
+ }
+ cout << endl;
+
+ cout << "-----------------------------------------" << endl;
+ cout << "SampleNamespace" << endl;
+
+ cout << "SampleNamespace::RandomNumber: ";
+ cout << SampleNamespace::getNumber(SampleNamespace::RandomNumber);
+ cout << endl;
+ cout << "SampleNamespace::UnixTime: ";
+ cout << SampleNamespace::getNumber(SampleNamespace::UnixTime);
+ cout << endl;
+ double val_d = 1.3;
+ cout << "SampleNamespace::powerOfTwo(" << val_d << "): ";
+ cout << SampleNamespace::powerOfTwo(val_d) << endl;
+ int val_i = 7;
+ cout << "SampleNamespace::powerOfTwo(" << val_i << "): ";
+ cout << SampleNamespace::powerOfTwo(val_i) << endl;
+ cout << endl;
+
+ cout << "-----------------------------------------" << endl;
+ cout << "Point" << endl;
+
+ Point p1(1.1, 2.2);
+ cout << "p1: ";
+ p1.show();
+ cout << endl;
+
+ Point p2(3.4, 5.6);
+ cout << "p2: ";
+ p2.show();
+ cout << endl;
+
+ cout << "p1 + p2 == ";
+ (p1 + p2).show();
+ cout << endl;
+
+ cout << "p1 * 2.0 == ";
+ (p1 * 2.0).show();
+ cout << endl;
+
+ cout << "1.5 * p2 == ";
+ (1.5 * p2).show();
+ cout << endl;
+
+ cout << "p1: ";
+ p1.show();
+ cout << endl << "p2: ";
+ p2.show();
+ cout << endl << "p1 += p2" << endl;
+ p1 += p2;
+ cout << "p1: ";
+ p1.show();
+ cout << endl;
+
+ cout << "p1 == p2 ? " << ((p1 == p2) ? "true" : "false") << endl;
+ cout << "p1 == p1 ? " << ((p1 == p1) ? "true" : "false") << endl;
+ cout << "p2 == p2 ? " << ((p2 == p2) ? "true" : "false") << endl;
+
+ cout << "-----------------------------------------" << endl;
+ cout << "Size" << endl;
+
+ Size s1(2, 2);
+ cout << "s1: ";
+ s1.show();
+ cout << ", area: " << s1.calculateArea();
+ cout << endl;
+
+ Size s2(3, 5);
+ cout << "s2: ";
+ s2.show();
+ cout << ", area: " << s2.calculateArea();
+ cout << endl;
+
+ cout << endl;
+
+ cout << "s1 == s2 ? " << ((s1 == s2) ? "true" : "false") << endl;
+ cout << "s1 != s2 ? " << ((s1 != s2) ? "true" : "false") << endl;
+
+ cout << "s1 < s2 ? " << ((s1 < s2) ? "true" : "false") << endl;
+ cout << "s1 <= s2 ? " << ((s1 <= s2) ? "true" : "false") << endl;
+ cout << "s1 > s2 ? " << ((s1 > s2) ? "true" : "false") << endl;
+ cout << "s1 >= s2 ? " << ((s1 >= s2) ? "true" : "false") << endl;
+
+ cout << "s1 < 10 ? " << ((s1 < 10) ? "true" : "false") << endl;
+ cout << "s1 <= 10 ? " << ((s1 <= 10) ? "true" : "false") << endl;
+ cout << "s1 > 10 ? " << ((s1 > 10) ? "true" : "false") << endl;
+ cout << "s1 >= 10 ? " << ((s1 >= 10) ? "true" : "false") << endl;
+ cout << "s2 < 10 ? " << ((s2 < 10) ? "true" : "false") << endl;
+ cout << "s2 <= 10 ? " << ((s2 <= 10) ? "true" : "false") << endl;
+ cout << "s2 > 10 ? " << ((s2 > 10) ? "true" : "false") << endl;
+ cout << "s2 >= 10 ? " << ((s2 >= 10) ? "true" : "false") << endl;
+ cout << endl;
+
+ cout << "s1: ";
+ s1.show();
+ cout << endl << "s2: ";
+ s2.show();
+ cout << endl << "s1 += s2" << endl;
+ s1 += s2;
+ cout << "s1: ";
+ s1.show();
+ cout << endl;
+
+ cout << endl;
+
+ cout << "s1: ";
+ s1.show();
+ cout << endl << "s1 *= 2.0" << endl;
+ s1 *= 2.0;
+ cout << "s1: ";
+ s1.show();
+ cout << endl;
+
+ cout << endl;
+
+ return 0;
+}
+
diff --git a/sources/shiboken2/tests/libsample/mapuser.cpp b/sources/shiboken2/tests/libsample/mapuser.cpp
new file mode 100644
index 000000000..666188512
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/mapuser.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "mapuser.h"
+
+using namespace std;
+
+std::map<std::string, std::pair<Complex, int> >
+MapUser::callCreateMap()
+{
+ return createMap();
+}
+
+
+std::map<std::string, std::pair<Complex, int> >
+MapUser::createMap()
+{
+ std::map<std::string, std::pair<Complex, int> > retval;
+
+ std::pair<std::string, std::pair<Complex, int> >
+ item0("zero", std::pair<Complex, int>(Complex(1.2, 3.4), 2));
+ retval.insert(item0);
+
+ std::pair<std::string, std::pair<Complex, int> >
+ item1("one", std::pair<Complex, int>(Complex(5.6, 7.8), 3));
+ retval.insert(item1);
+
+ std::pair<std::string, std::pair<Complex, int> >
+ item2("two", std::pair<Complex, int>(Complex(9.1, 2.3), 5));
+ retval.insert(item2);
+
+ return retval;
+}
+
+void
+MapUser::showMap(std::map<std::string, int> mapping)
+{
+ std::map<std::string, int>::iterator it;
+ cout << __FUNCTION__ << endl;
+ for (it = mapping.begin() ; it != mapping.end(); it++)
+ cout << (*it).first << " => " << (*it).second << endl;
+}
+
diff --git a/sources/shiboken2/tests/libsample/mapuser.h b/sources/shiboken2/tests/libsample/mapuser.h
new file mode 100644
index 000000000..90d036945
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/mapuser.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAPUSER_H
+#define MAPUSER_H
+
+#include <map>
+#include <list>
+#include <utility>
+#include <string>
+#include "complex.h"
+#include "bytearray.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API MapUser
+{
+public:
+ MapUser() {}
+ virtual ~MapUser() {}
+
+ virtual std::map<std::string, std::pair<Complex, int> > createMap();
+ std::map<std::string, std::pair<Complex, int> > callCreateMap();
+
+ void showMap(std::map<std::string, int> mapping);
+
+ inline void setMap(std::map<std::string, std::list<int> > map) { m_map = map; }
+ inline std::map<std::string, std::list<int> > getMap() { return m_map; }
+
+ // Compile test
+ static void pointerToMap(std::map<std::string, std::string>* arg) {}
+ static void referenceToMap(std::map<std::string, std::string>& arg) {}
+
+ inline const std::map<int, ByteArray>& passMapIntValueType(const std::map<int, ByteArray>& arg) { return arg; }
+
+private:
+ std::map<std::string, std::list<int> > m_map;
+};
+
+#endif // MAPUSER_H
diff --git a/sources/shiboken2/tests/libsample/modelindex.h b/sources/shiboken2/tests/libsample/modelindex.h
new file mode 100644
index 000000000..12cc97ce4
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/modelindex.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODELINDEX_H
+#define MODELINDEX_H
+
+#include "libsamplemacros.h"
+
+class ModelIndex
+{
+public:
+ ModelIndex() : m_value(0) {}
+ ModelIndex(const ModelIndex& other) { m_value = other.m_value; }
+ inline void setValue(int value) { m_value = value; }
+ inline int value() const { return m_value; }
+ static int getValue(const ModelIndex& index) { return index.value(); }
+private:
+ int m_value;
+};
+
+class ReferentModelIndex
+{
+public:
+ ReferentModelIndex() {}
+ ReferentModelIndex(const ModelIndex& index) : m_index(index) {}
+ ReferentModelIndex(const ReferentModelIndex& other) { m_index = other.m_index; }
+ inline void setValue(int value) { m_index.setValue(value); }
+ inline int value() const { return m_index.value(); }
+ operator const ModelIndex&() const { return m_index; }
+private:
+ ModelIndex m_index;
+};
+
+class PersistentModelIndex
+{
+public:
+ PersistentModelIndex() {}
+ PersistentModelIndex(const ModelIndex& index) : m_index(index) {}
+ PersistentModelIndex(const PersistentModelIndex& other) { m_index = other.m_index; }
+ inline void setValue(int value) { m_index.setValue(value); }
+ inline int value() const { return m_index.value(); }
+ operator ModelIndex() const { return m_index; }
+private:
+ ModelIndex m_index;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/modifications.cpp b/sources/shiboken2/tests/libsample/modifications.cpp
new file mode 100644
index 000000000..4a60a8071
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/modifications.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "modifications.h"
+#include "objecttype.h"
+
+using namespace std;
+
+Modifications::Modifications()
+{
+ m_object = new ObjectType();
+ m_object->setObjectName("MyObject");
+}
+
+Modifications::~Modifications()
+{
+ delete m_object;
+}
+
+std::pair<double, double>
+Modifications::pointToPair(Point pt, bool* ok)
+{
+ std::pair<double, double> retval(pt.x(), pt.y());
+ *ok = true;
+ return retval;
+}
+
+double
+Modifications::multiplyPointCoordsPlusValue(bool* ok, Point pt, double value)
+{
+ double retval = (pt.x() * pt.y()) + value;
+ *ok = true;
+ return retval;
+}
+
+int
+Modifications::doublePlus(int value, int plus)
+{
+ return (2 * value) + plus;
+}
+
+int
+Modifications::power(int base, int exponent)
+{
+ if (exponent == 0)
+ return 1;
+ int retval = base;
+ for (int i = 1; i < exponent; i++)
+ retval = retval * base;
+ return retval;
+}
+
+int
+Modifications::timesTen(int number)
+{
+ return number * 10;
+}
+
+int
+Modifications::increment(int number)
+{
+ return ++number;
+}
+
+void
+Modifications::exclusiveCppStuff()
+{
+ cout << __FUNCTION__ << endl;
+}
+
+int
+Modifications::cppMultiply(int a, int b)
+{
+ return a * b;
+}
+
+const char*
+Modifications::className()
+{
+ return "Modifications";
+}
+
+Point
+Modifications::sumPointArray(int arraySize, const Point pointArray[])
+{
+ Point point;
+ for (int i = 0; i < arraySize; ++i)
+ point = point + pointArray[i];
+ return point;
+}
+
+int
+Modifications::getSize(const void* data, int size)
+{
+ (void)data;
+ return size;
+}
+
+int
+Modifications::sumPointCoordinates(const Point* point)
+{
+ return point->x() + point->y();
+}
+
+double
+Modifications::differenceOfPointCoordinates(const Point* pt, bool* ok)
+{
+ if (!pt) {
+ *ok = false;
+ return 0.0;
+ }
+ *ok = true;
+ double result = pt->x() - pt->y();
+ if (result < 0)
+ result = result * -1.0;
+ return result;
+}
+
+bool
+Modifications::nonConversionRuleForArgumentWithDefaultValue(ObjectType** object)
+{
+ if (object)
+ *object = m_object;
+ return true;
+}
diff --git a/sources/shiboken2/tests/libsample/modifications.h b/sources/shiboken2/tests/libsample/modifications.h
new file mode 100644
index 000000000..2978270b0
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/modifications.h
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODIFICATIONS_H
+#define MODIFICATIONS_H
+
+#include "libsamplemacros.h"
+#include <utility>
+#include "point.h"
+#include "oddbool.h"
+
+class ObjectType;
+
+class LIBSAMPLE_API Modifications
+{
+public:
+ Modifications();
+ virtual ~Modifications();
+
+ enum OverloadedModFunc {
+ OverloadedNone,
+ Overloaded_ibid,
+ Overloaded_ibib,
+ Overloaded_ibiP,
+ Overloaded_ibii,
+ Overloaded_ibPP
+ };
+
+ // those overloaded methods should be heavily modified
+ // to push the overload decisor to its limits
+ inline OverloadedModFunc overloaded(int a0, bool b0, int c0, double d0) { return Overloaded_ibid; }
+ inline OverloadedModFunc overloaded(int a1, bool b1, int c1, bool d1) { return Overloaded_ibib; }
+ inline OverloadedModFunc overloaded(int a2, bool b2, int c2, Point d2) { return Overloaded_ibiP; }
+ inline OverloadedModFunc overloaded(int a3, bool b3, int c3 = 123, int d3 = 456) { return Overloaded_ibii; }
+ inline OverloadedModFunc overloaded(int a4, bool b4, Point c4, Point d4) { return Overloaded_ibPP; }
+
+ inline void argRemoval0(int a0, bool a1, int a2 = 123, int a3 = 456) {}
+ inline void argRemoval0(int a0, bool a1, int a2, bool a3) {}
+
+ inline void argRemoval1(int a0, bool a1, Point a2 = Point(1, 2), Point a3 = Point(3, 4), int a4 = 333) {}
+ inline void argRemoval1(int a0, bool a1, int a2, bool a3) {}
+
+ inline void argRemoval2(int a0, bool a1, Point a2 = Point(1, 2), Point a3 = Point(3, 4), int a4 = 333) {}
+
+ inline void argRemoval3(int a0, Point a1 = Point(1, 2), bool a2 = true, Point a3 = Point(3, 4), int a4 = 333) {}
+
+ inline void argRemoval4(int a0, Point a1, bool a2, Point a3 = Point(3, 4), int a4 = 333) {}
+
+ inline void argRemoval5(int a0, bool a1, Point a2 = Point(1, 2), Point a3 = Point(3, 4), int a4 = 333) {}
+ inline void argRemoval5(int a0, bool a1, int a2, bool a3) {}
+
+ // 'ok' must be removed and the return value will be changed
+ // to a tuple (PyObject*) containing the expected result plus
+ // the 'ok' value as a Python boolean
+ std::pair<double, double> pointToPair(Point pt, bool* ok);
+
+ // same as 'pointToPair' except that this time 'ok' is the first argument
+ double multiplyPointCoordsPlusValue(bool* ok, Point pt, double value);
+
+ // completely remove 'plus' from the Python side
+ int doublePlus(int value, int plus = 0);
+
+ // the default value for both arguments must be changed in Python
+ int power(int base = 1, int exponent = 0);
+
+ // in Python set argument default value to 10
+ int timesTen(int number);
+
+ // in Python remove the argument default value
+ int increment(int number = 0);
+
+ // don't export this method to Python
+ void exclusiveCppStuff();
+
+ // change the name of this regular method
+ int cppMultiply(int a, int b);
+
+ // change the name of this virtual method
+ virtual const char* className();
+
+ Point sumPointArray(int arraySize, const Point pointArray[]);
+
+ // Replace 'const void*' by 'ByteArray&'.
+ int getSize(const void* data, int size);
+
+ // Mark the argument with a <no-null-pointer/> tag;
+ // the test implementation must expect point never to be null.
+ int sumPointCoordinates(const Point* point);
+
+ // Modify the return value of a virtual method.
+ virtual double differenceOfPointCoordinates(const Point* pt, bool* ok);
+ double callDifferenceOfPointCoordinates(const Point* pt, bool* ok) { return differenceOfPointCoordinates(pt, ok); }
+
+ // Sets an ObjectType in the argument and returns true.
+ bool nonConversionRuleForArgumentWithDefaultValue(ObjectType** object = 0);
+ ObjectType* getObject() const { return m_object; }
+
+ // Inject code with a %CONVERTTOPYTHON that receives an user's primitive type.
+ static inline OddBool passOddBool(OddBool ob) { return ob; }
+
+private:
+ ObjectType* m_object;
+};
+
+class LIBSAMPLE_API AbstractModifications : public Modifications
+{
+public:
+ AbstractModifications() {}
+ virtual ~AbstractModifications() {}
+
+ inline bool invert(bool value) { return !value; }
+
+ // completely remove this method in Python
+ virtual void pointlessPureVirtualMethod() = 0;
+};
+
+#endif // MODIFICATIONS_H
diff --git a/sources/shiboken2/tests/libsample/modified_constructor.cpp b/sources/shiboken2/tests/libsample/modified_constructor.cpp
new file mode 100644
index 000000000..48224358f
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/modified_constructor.cpp
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "modified_constructor.h"
+
+ModifiedConstructor::ModifiedConstructor(int first_arg)
+{
+ m_stored_value = first_arg;
+}
+
+int
+ModifiedConstructor::retrieveValue()
+{
+ return m_stored_value;
+}
+
+
diff --git a/sources/shiboken2/tests/libsample/modified_constructor.h b/sources/shiboken2/tests/libsample/modified_constructor.h
new file mode 100644
index 000000000..9ac5497d7
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/modified_constructor.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODIFIEDCONSTRUCTOR_H
+#define MODIFIEDCONSTRUCTOR_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API ModifiedConstructor
+{
+public:
+
+ ModifiedConstructor(int first_arg);
+ int retrieveValue();
+
+private:
+ int m_stored_value;
+};
+
+#endif // MODIFIEDCONSTRUCTOR_H
+
diff --git a/sources/shiboken2/tests/libsample/multiple_derived.cpp b/sources/shiboken2/tests/libsample/multiple_derived.cpp
new file mode 100644
index 000000000..1d7a33cbe
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/multiple_derived.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "multiple_derived.h"
+
+MDerived1::MDerived1() : m_value(100)
+{
+}
+
+MDerived2::MDerived2() : m_value(200)
+{
+}
+
+MDerived3::MDerived3() : m_value(3000)
+{
+}
+
+MDerived4::MDerived4()
+{
+}
+
+MDerived5::MDerived5()
+{
+}
+
+MDerived1*
+MDerived1::transformFromBase1(Base1* self)
+{
+ MDerived1* ptr = dynamic_cast<MDerived1*>(self);
+ return ptr;
+}
+
+MDerived1*
+MDerived1::transformFromBase2(Base2* self)
+{
+ MDerived1* ptr = dynamic_cast<MDerived1*>(self);
+ return ptr;
+}
+
diff --git a/sources/shiboken2/tests/libsample/multiple_derived.h b/sources/shiboken2/tests/libsample/multiple_derived.h
new file mode 100644
index 000000000..5825e59b4
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/multiple_derived.h
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MDERIVED_H
+#define MDERIVED_H
+
+#include "libsamplemacros.h"
+#include <string>
+
+class Base1
+{
+public:
+ Base1() : m_value(1) {}
+ virtual ~Base1() {}
+ virtual int base1Method() { return m_value; }
+
+ virtual void publicMethod() {};
+private:
+ int m_value;
+};
+
+class Base2
+{
+public:
+ Base2() : m_value(2) {}
+ virtual ~Base2() {}
+ virtual int base2Method() { return m_value; }
+private:
+ int m_value;
+};
+
+class LIBSAMPLE_API MDerived1 : public Base1, public Base2
+{
+public:
+ MDerived1();
+ virtual ~MDerived1() {}
+
+ virtual int mderived1Method() { return m_value; }
+ virtual int base1Method() { return Base1::base1Method() * 10; }
+ virtual int base2Method() { return Base2::base2Method() * 10; }
+
+ inline Base1* castToBase1() { return (Base1*) this; }
+ inline Base2* castToBase2() { return (Base2*) this; }
+
+ static MDerived1* transformFromBase1(Base1 *self);
+ static MDerived1* transformFromBase2(Base2 *self);
+
+private:
+ virtual void publicMethod() {}
+ int m_value;
+};
+
+class SonOfMDerived1 : public MDerived1
+{
+public:
+ SonOfMDerived1() : m_value(0) {}
+ ~SonOfMDerived1() {}
+
+ inline MDerived1* castToMDerived1() { return (MDerived1*) this; }
+
+ int sonOfMDerived1Method() { return m_value; }
+private:
+ int m_value;
+};
+
+class Base3
+{
+public:
+ explicit Base3(int val = 3) : m_value(val) {}
+ virtual ~Base3() {}
+ int base3Method() { return m_value; }
+private:
+ int m_value;
+};
+
+class Base4
+{
+public:
+ Base4() : m_value(4) {}
+ virtual ~Base4() {}
+ int base4Method() { return m_value; }
+private:
+ int m_value;
+};
+
+class Base5
+{
+public:
+ Base5() : m_value(5) {}
+ virtual ~Base5() {}
+ virtual int base5Method() { return m_value; }
+private:
+ int m_value;
+};
+
+class Base6
+{
+public:
+ Base6() : m_value(6) {}
+ virtual ~Base6() {}
+ virtual int base6Method() { return m_value; }
+private:
+ int m_value;
+};
+
+
+class LIBSAMPLE_API MDerived2 : public Base3, public Base4, public Base5, public Base6
+{
+public:
+ MDerived2();
+ virtual ~MDerived2() {}
+
+ inline int base4Method() { return Base3::base3Method() * 10; }
+ inline int mderived2Method() { return m_value; }
+
+ inline Base3* castToBase3() { return (Base3*) this; }
+ inline Base4* castToBase4() { return (Base4*) this; }
+ inline Base5* castToBase5() { return (Base5*) this; }
+ inline Base6* castToBase6() { return (Base6*) this; }
+
+private:
+ int m_value;
+};
+
+class LIBSAMPLE_API MDerived3 : public MDerived1, public MDerived2
+{
+public:
+ MDerived3();
+ virtual ~MDerived3() {}
+
+ inline virtual int mderived3Method() { return m_value; }
+
+ inline MDerived1* castToMDerived1() { return (MDerived1*) this; }
+ inline MDerived2* castToMDerived2() { return (MDerived2*) this; }
+
+ inline Base3* castToBase3() { return (Base3*) this; }
+
+private:
+ int m_value;
+};
+
+class LIBSAMPLE_API MDerived4 : public Base3, public Base4
+{
+public:
+ MDerived4();
+ ~MDerived4() {}
+
+ inline int mderived4Method() { return 0; }
+ inline int justDummyMethod() { return m_value; }
+
+ inline Base3* castToBase3() { return (Base3*) this; }
+ inline Base4* castToBase4() { return (Base4*) this; }
+private:
+ int m_value;
+};
+
+class LIBSAMPLE_API MDerived5 : public Base3, public Base4
+{
+public:
+ MDerived5();
+ virtual ~MDerived5() {}
+
+ virtual int mderived5Method() { return 0; }
+
+ inline Base3* castToBase3() { return (Base3*) this; }
+ inline Base4* castToBase4() { return (Base4*) this; }
+};
+
+#endif // MDERIVED_H
+
diff --git a/sources/shiboken2/tests/libsample/noimplicitconversion.h b/sources/shiboken2/tests/libsample/noimplicitconversion.h
new file mode 100644
index 000000000..0a8882d3a
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/noimplicitconversion.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NOIMPLICITCONVERSION_H
+#define NOIMPLICITCONVERSION_H
+
+#include "libsamplemacros.h"
+
+// This class must not have implicit conversions AND
+// no conversion operators should be defined in its own module.
+class NoImplicitConversion
+{
+public:
+ explicit NoImplicitConversion(int objId) : m_objId(objId) {}
+ inline int objId() const { return m_objId; }
+ inline static int receivesNoImplicitConversionByValue(NoImplicitConversion arg) { return arg.m_objId; }
+ inline static int receivesNoImplicitConversionByPointer(NoImplicitConversion* arg) { return arg->m_objId; }
+ inline static int receivesNoImplicitConversionByReference(NoImplicitConversion& arg) { return arg.m_objId; }
+private:
+ int m_objId;
+};
+
+#endif // NOIMPLICITCONVERSION_H
+
diff --git a/sources/shiboken2/tests/libsample/nondefaultctor.h b/sources/shiboken2/tests/libsample/nondefaultctor.h
new file mode 100644
index 000000000..d2b186bd8
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/nondefaultctor.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NONDEFAULTCTOR_H
+#define NONDEFAULTCTOR_H
+
+#include "libsamplemacros.h"
+
+class NonDefaultCtor
+{
+ int m_value;
+public:
+ NonDefaultCtor(int value) : m_value(value)
+ {
+ }
+
+ inline int value()
+ {
+ return m_value;
+ }
+
+ inline NonDefaultCtor returnMyself()
+ {
+ return *this;
+ }
+
+ inline NonDefaultCtor returnMyself(int)
+ {
+ return *this;
+ }
+
+ inline NonDefaultCtor returnMyself(int, NonDefaultCtor)
+ {
+ return *this;
+ }
+
+ virtual NonDefaultCtor returnMyselfVirtual()
+ {
+ return *this;
+ }
+
+ inline NonDefaultCtor callReturnMyselfVirtual()
+ {
+ return returnMyselfVirtual();
+ }
+
+ virtual ~NonDefaultCtor() {}
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/null.h b/sources/shiboken2/tests/libsample/null.h
new file mode 100644
index 000000000..634262a99
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/null.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NULL_H
+#define NULL_H
+
+class Null
+{
+public:
+ Null(bool value) : m_isNull(value) {}
+ Null() : m_isNull(false) {}
+ void setIsNull(bool flag) { m_isNull = flag; }
+
+private:
+ bool m_isNull;
+};
+
+#endif // STR_H
+
diff --git a/sources/shiboken2/tests/libsample/objectmodel.cpp b/sources/shiboken2/tests/libsample/objectmodel.cpp
new file mode 100644
index 000000000..370b58aa1
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objectmodel.cpp
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objectmodel.h"
+
+void
+ObjectModel::setData(ObjectType* data)
+{
+ m_data = data;
+}
+
+ObjectType*
+ObjectModel::data() const
+{
+ return m_data;
+}
+
diff --git a/sources/shiboken2/tests/libsample/objectmodel.h b/sources/shiboken2/tests/libsample/objectmodel.h
new file mode 100644
index 000000000..aa4a64433
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objectmodel.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTMODEL_H
+#define OBJECTMODEL_H
+
+#include "objecttype.h"
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API ObjectModel : public ObjectType
+{
+public:
+ explicit ObjectModel(ObjectType* parent = 0)
+ : ObjectType(parent), m_data(0)
+ {}
+
+ void setData(ObjectType* data);
+ virtual ObjectType* data() const;
+
+ // The MethodCalled enum and related static methods were created to
+ // test bug #630 [http://bugs.openbossa.org/show_bug.cgi?id=630]
+ enum MethodCalled { ObjectTypeCalled, ObjectModelCalled };
+ static MethodCalled receivesObjectTypeFamily(const ObjectType& object) { return ObjectModel::ObjectTypeCalled; }
+ static MethodCalled receivesObjectTypeFamily(const ObjectModel& object) { return ObjectModel::ObjectModelCalled; }
+
+private:
+ // The model holds only one piece of data.
+ // (This is just a test after all.)
+ ObjectType* m_data;
+};
+
+#endif // OBJECTMODEL_H
+
diff --git a/sources/shiboken2/tests/libsample/objecttype.cpp b/sources/shiboken2/tests/libsample/objecttype.cpp
new file mode 100644
index 000000000..4f10b01df
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttype.cpp
@@ -0,0 +1,311 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objecttype.h"
+#include "objecttypelayout.h"
+#include <algorithm>
+#include <iostream>
+#include <string>
+#include <assert.h>
+
+using namespace std;
+
+ObjectType::ObjectType(ObjectType* parent) : m_parent(0), m_layout(0), m_call_id(-1)
+{
+ setParent(parent);
+}
+
+ObjectType::~ObjectType()
+{
+ for (ObjectTypeList::iterator child_iter = m_children.begin();
+ child_iter != m_children.end(); ++child_iter)
+ delete *child_iter;
+}
+
+ObjectType*
+ObjectType::createWithChild()
+{
+ ObjectType* parent = create();
+ ObjectType* child = create();
+ child->setObjectName("child");
+ child->setParent(parent);
+ return parent;
+}
+
+void
+ObjectType::removeChild(ObjectType* child)
+{
+ if (!child)
+ return;
+
+ ObjectTypeList::iterator child_iter = std::find(m_children.begin(), m_children.end(), child);
+ if (child_iter != m_children.end()) {
+ m_children.erase(child_iter);
+ child->m_parent = 0;
+ }
+}
+
+ObjectType*
+ObjectType::takeChild(ObjectType* child)
+{
+ if (!child)
+ return 0;
+
+ ObjectTypeList::iterator child_iter = std::find(m_children.begin(), m_children.end(), child);
+ if (child_iter != m_children.end()) {
+ m_children.erase(child_iter);
+ child->m_parent = 0;
+ return child;
+ }
+ return 0;
+}
+
+ObjectType*
+ObjectType::takeChild(const Str& name)
+{
+ return takeChild(findChild(name));
+
+}
+
+ObjectType*
+ObjectType::findChild(const Str& name)
+{
+ for (ObjectTypeList::iterator child_iter = m_children.begin();
+ child_iter != m_children.end(); ++child_iter) {
+
+ if ((*child_iter)->objectName() == name)
+ return *child_iter;
+ }
+ return 0;
+}
+
+void
+ObjectType::killChild(const Str& name)
+{
+ for (ObjectTypeList::iterator child_iter = m_children.begin();
+ child_iter != m_children.end(); ++child_iter) {
+
+ if ((*child_iter)->objectName() == name) {
+ ObjectType* child = *child_iter;
+ removeChild(child);
+ delete child;
+ break;
+ }
+ }
+}
+
+void
+ObjectType::setParent(ObjectType* parent)
+{
+ if (m_parent == parent)
+ return;
+
+ if (m_parent)
+ m_parent->removeChild(this);
+
+ m_parent = parent;
+ if (m_parent)
+ m_parent->m_children.push_back(this);
+}
+
+void
+ObjectType::setObjectName(const Str& name)
+{
+ m_objectName = name;
+}
+
+Str
+ObjectType::objectName() const
+{
+ return m_objectName;
+}
+
+bool
+ObjectType::causeEvent(Event::EventType eventType)
+{
+ Event e(eventType);
+ return event(&e);
+}
+
+bool
+ObjectType::event(Event* event)
+{
+ return true;
+}
+
+int
+ObjectType::processEvent(ObjectTypeList objects, Event *event)
+{
+ int evaluated = 0;
+
+ for (ObjectTypeList::iterator obj_iter = objects.begin();
+ obj_iter != objects.end(); ++obj_iter) {
+ if((*obj_iter)->event(event))
+ evaluated++;
+ }
+
+ return evaluated;
+
+}
+
+void
+ObjectType::callInvalidateEvent(Event* event)
+{
+ invalidateEvent(event);
+}
+
+void
+ObjectType::setLayout(ObjectTypeLayout* l)
+{
+ if (!l) {
+ cerr << "[WARNING] ObjectType::setLayout: Cannot set layout to 0." << endl;
+ return;
+ }
+
+ if (layout()) {
+ if (layout() != l) {
+ cerr << "[WARNING] ObjectType::setLayout: Attempting to set ObjectTypeLayout '" << l->objectName().cstring();
+ cerr << "' on ObjectType '" << objectName().cstring() << "', which already has a layout." << endl;
+ }
+ return;
+ }
+
+ ObjectType* oldParent = l->parent();
+ if (oldParent && oldParent != this) {
+ if (oldParent->isLayoutType()) {
+ cerr << "[WARNING] ObjectType::setLayout: Attempting to set ObjectTypeLayout '" << l->objectName().cstring();
+ cerr << "' on ObjectType '" << objectName().cstring() << "', when the ObjectTypeLayout already has a parent layout." << endl;
+ return;
+ } else {
+ // Steal the layout from an ObjectType parent.
+ oldParent->takeLayout();
+ }
+ }
+
+ m_layout = l;
+ if (oldParent != this) {
+ l->setParent(this);
+ l->reparentChildren(this);
+ }
+}
+
+ObjectTypeLayout* ObjectType::takeLayout()
+{
+ ObjectTypeLayout* l = layout();
+ if (!l)
+ return 0;
+ m_layout = 0;
+ l->setParent(0);
+ return l;
+}
+
+unsigned int
+objectTypeHash(const ObjectType* objectType)
+{
+ return reinterpret_cast<std::size_t>(objectType);
+}
+
+unsigned char
+ObjectType::callWithEnum(const Str& prefix, Event::EventType type, unsigned char value){
+ return value*value;
+}
+
+unsigned char
+ObjectType::callWithEnum(const Str& prefix, unsigned char value) {
+ return value;
+}
+
+void
+ObjectType::setObjectSplittedName(const char*, const Str& prefix, const Str& suffix)
+{
+ std::string result(prefix.cstring());
+ result += suffix.cstring();
+ m_objectName = result.c_str();
+}
+
+void
+ObjectType::setObjectNameWithSize(const char*, int size, const Str& name)
+{
+ std::string result(name.cstring(), size);
+ m_objectName = result.c_str();
+}
+
+void
+ObjectType::setObjectNameWithSize(const Str& name, int size)
+{
+ setObjectNameWithSize("", size, name);
+}
+
+void ObjectType::setObject(ObjectType *)
+{
+ m_call_id = 0;
+}
+
+void ObjectType::setObject(const Null&)
+{
+ m_call_id = 1;
+}
+
+int ObjectType::callId() const
+{
+ return m_call_id;
+}
+
+
+void ObjectType::callVirtualCreateChild()
+{
+ ObjectType* fake_parent = new ObjectType();
+ ObjectType* fake_child = createChild(fake_parent);
+ assert(fake_child->isPython());
+ delete fake_parent;
+}
+
+ObjectType* ObjectType::createChild(ObjectType* parent)
+{
+ return new ObjectType(parent);
+}
+
+std::size_t ObjectType::createObjectType()
+{
+ void* addr = new ObjectType();
+ return (std::size_t) addr;
+}
+
+OtherBase::~OtherBase()
+{
+}
+
+ObjectTypeDerived::~ObjectTypeDerived()
+{
+}
+
+bool
+ObjectTypeDerived::event(Event* event)
+{
+ return true;
+}
diff --git a/sources/shiboken2/tests/libsample/objecttype.h b/sources/shiboken2/tests/libsample/objecttype.h
new file mode 100644
index 000000000..eae95b3b1
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttype.h
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTTYPE_H
+#define OBJECTTYPE_H
+
+#include <list>
+#include "str.h"
+#include "null.h"
+
+#include "libsamplemacros.h"
+
+#include <stddef.h>
+
+struct Event
+{
+ enum EventType {
+ NO_EVENT,
+ BASIC_EVENT,
+ SOME_EVENT,
+ ANY_EVENT
+ };
+ Event(EventType eventType) : m_eventType(eventType) {}
+ EventType eventType() { return m_eventType; }
+private:
+ EventType m_eventType;
+};
+
+class ObjectTypeLayout;
+class ObjectType;
+typedef std::list<ObjectType*> ObjectTypeList;
+
+class LIBSAMPLE_API ObjectType
+{
+public:
+ // ### Fixme: Use uintptr_t in C++ 11
+ typedef size_t Identifier;
+
+ explicit ObjectType(ObjectType* parent = 0);
+ virtual ~ObjectType();
+
+ // factory method
+ inline static ObjectType* create() { return new ObjectType(); }
+ static ObjectType* createWithChild();
+
+ void setParent(ObjectType* parent);
+ inline ObjectType* parent() const { return m_parent; }
+ inline const ObjectTypeList& children() const { return m_children; }
+ void killChild(const Str& name);
+ void removeChild(ObjectType* child);
+ ObjectType* takeChild(ObjectType* child);
+ virtual ObjectType* takeChild(const Str& name);
+ ObjectType* findChild(const Str& name);
+
+ Str objectName() const;
+ void setObjectName(const Str& name);
+
+ inline Identifier identifier() const { return reinterpret_cast<Identifier>(this); }
+
+ bool causeEvent(Event::EventType eventType);
+
+ // Returns true if the event is processed.
+ virtual bool event(Event* event);
+ static int processEvent(ObjectTypeList objects, Event *event);
+
+ void callInvalidateEvent(Event* event);
+ virtual void invalidateEvent(Event* event) {}
+
+ // This nonsense method emulate QWidget.setLayout method
+ // All layout objects will became children of this object.
+ void setLayout(ObjectTypeLayout* layout);
+ inline ObjectTypeLayout* layout() const { return m_layout; }
+
+ // This method should be reimplemented by ObjectTypeLayout.
+ virtual bool isLayoutType() { return false; }
+
+ unsigned char callWithEnum(const Str& prefix, Event::EventType type, unsigned char value=80);
+ unsigned char callWithEnum(const Str& prefix, unsigned char value=0);
+
+ //Functions used in test with named arguments
+ void setObjectSplittedName(const char*, const Str& prefix = Str("<unk"), const Str& suffix = Str("nown>"));
+ void setObjectNameWithSize(const char*, int size=9, const Str& name = Str("<unknown>"));
+ void setObjectNameWithSize(const Str& name = Str("<unknown>"), int size=9);
+
+ //Function used to confuse the generator when two values accept Null as arg
+ void setObject(ObjectType *);
+ void setObject(const Null&);
+ int callId() const;
+
+ //Function used to create a parent from C++
+ virtual bool isPython() { return false; }
+ void callVirtualCreateChild();
+ virtual ObjectType* createChild(ObjectType* parent);
+ static std::size_t createObjectType();
+
+ //return a parent from C++
+ ObjectType* getCppParent() {
+ if (!m_parent) {
+ ObjectType* parent = new ObjectType();
+ setParent(parent);
+ }
+ return m_parent;
+ }
+
+ void destroyCppParent() {
+ delete m_parent;
+ m_parent = 0;
+ }
+
+ //Deprecated test
+ bool deprecatedFunction() { return true; }
+
+ // nextInFocusChain simply returns the parent to test object cycles; the parent
+ // may be returned by the QWidget's implementation but isn't always returned
+ ObjectType* nextInFocusChain() { return m_parent; }
+
+private:
+ ObjectType(const ObjectType&);
+ ObjectType& operator=(const ObjectType&);
+
+ ObjectTypeLayout* takeLayout();
+
+ Str m_objectName;
+ ObjectType* m_parent;
+ ObjectTypeList m_children;
+
+ ObjectTypeLayout* m_layout;
+
+
+ //used on overload null test
+ int m_call_id;
+};
+
+LIBSAMPLE_API unsigned int objectTypeHash(const ObjectType* objectType);
+
+class LIBSAMPLE_API OtherBase {
+public:
+ OtherBase() {};
+ virtual ~OtherBase();
+};
+
+class LIBSAMPLE_API ObjectTypeDerived: public ObjectType, public OtherBase {
+public:
+ ObjectTypeDerived(): ObjectType(), OtherBase() {};
+
+ virtual bool event(Event* event);
+ virtual ~ObjectTypeDerived();
+};
+
+#endif // OBJECTTYPE_H
+
diff --git a/sources/shiboken2/tests/libsample/objecttypebyvalue.h b/sources/shiboken2/tests/libsample/objecttypebyvalue.h
new file mode 100644
index 000000000..1b61ec4dc
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypebyvalue.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTTYPEBYVALUE_H
+#define OBJECTTYPEBYVALUE_H
+#include <list>
+#include "protected.h"
+
+class ObjectTypeByValue
+{
+public:
+ ObjectTypeByValue returnSomeKindOfMe() { return ObjectTypeByValue(); }
+ void acceptKindOfMeAsValue(ObjectTypeByValue kindOfMe) {}
+
+ void acceptListOfObjectTypeByValue(std::list<ObjectTypeByValue> listOfMe) {}
+
+ // prop used to check for segfaults
+ ProtectedProperty prop;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/objecttypeholder.cpp b/sources/shiboken2/tests/libsample/objecttypeholder.cpp
new file mode 100644
index 000000000..dabeb2f86
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypeholder.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objecttypeholder.h"
+
+ObjectTypeHolder::ObjectTypeHolder(const char* objectName)
+{
+ m_objectType = new ObjectType();
+ m_objectType->setObjectName(objectName);
+}
+
+ObjectTypeHolder::~ObjectTypeHolder()
+{
+ delete m_objectType;
+}
+
+Str
+ObjectTypeHolder::passObjectTypeAsReference(const ObjectType& objectType)
+{
+ return objectType.objectName();
+}
+
+Str
+ObjectTypeHolder::callPassObjectTypeAsReference()
+{
+ return passObjectTypeAsReference(*m_objectType);
+}
diff --git a/sources/shiboken2/tests/libsample/objecttypeholder.h b/sources/shiboken2/tests/libsample/objecttypeholder.h
new file mode 100644
index 000000000..c2e7275d4
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypeholder.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTTYPEHOLDER_H
+#define OBJECTTYPEHOLDER_H
+
+#include "libsamplemacros.h"
+#include "objecttype.h"
+#include "str.h"
+
+class LIBSAMPLE_API ObjectTypeHolder
+{
+public:
+ explicit ObjectTypeHolder(const char* objectName);
+ virtual ~ObjectTypeHolder();
+
+ ObjectType* getObjecType() { return m_objectType; }
+
+ virtual Str passObjectTypeAsReference(const ObjectType& objectType);
+ Str callPassObjectTypeAsReference();
+
+private:
+ ObjectType* m_objectType;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/objecttypelayout.cpp b/sources/shiboken2/tests/libsample/objecttypelayout.cpp
new file mode 100644
index 000000000..d2a7d1bba
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypelayout.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objecttypelayout.h"
+#include <iostream>
+
+using namespace std;
+
+void ObjectTypeLayout::addObject(ObjectType* obj)
+{
+ if (obj->isLayoutType()) {
+ ObjectTypeLayout* l = reinterpret_cast<ObjectTypeLayout*>(obj);
+ if (l->parent()) {
+ cerr << "[WARNING] ObjectTypeLayout::addObject: layout '" << l->objectName().cstring();
+ cerr << "' already has a parent." << endl;
+ return;
+ }
+
+ l->setParent(this);
+
+ if (parent() && !parent()->isLayoutType())
+ l->reparentChildren(parent());
+ }
+
+ m_objects.push_back(obj);
+}
+
+std::list< ObjectType* > ObjectTypeLayout::objects() const
+{
+ return m_objects;
+}
+
+void ObjectTypeLayout::reparentChildren(ObjectType* parent)
+{
+ std::list<ObjectType*>::const_iterator it = m_objects.begin();
+ for (; it != m_objects.end(); ++it) {
+ if ((*it)->isLayoutType())
+ reinterpret_cast<ObjectTypeLayout*>(*it)->reparentChildren(parent);
+ else
+ (*it)->setParent(parent);
+ }
+}
+
diff --git a/sources/shiboken2/tests/libsample/objecttypelayout.h b/sources/shiboken2/tests/libsample/objecttypelayout.h
new file mode 100644
index 000000000..3fa8b9dbf
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypelayout.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTTYPELAYOUT_H
+#define OBJECTTYPELAYOUT_H
+
+#include "libsamplemacros.h"
+#include "objecttype.h"
+#include <list>
+
+class ObjectType;
+
+class LIBSAMPLE_API ObjectTypeLayout : public ObjectType
+{
+public:
+ void addObject(ObjectType* obj);
+ std::list<ObjectType*> objects() const;
+
+ virtual bool isLayoutType() { return true; }
+ inline static ObjectTypeLayout* create() { return new ObjectTypeLayout(); }
+
+ virtual ObjectType* takeChild(const Str& name) { return ObjectType::takeChild(name); }
+private:
+ std::list<ObjectType*> m_objects;
+
+ void reparentChildren(ObjectType* parent);
+ friend LIBSAMPLE_API void ObjectType::setLayout(ObjectTypeLayout* l);
+};
+
+#endif // OBJECTTYPELAYOUT_H
+
diff --git a/sources/shiboken2/tests/libsample/objecttypeoperators.cpp b/sources/shiboken2/tests/libsample/objecttypeoperators.cpp
new file mode 100644
index 000000000..1bdaded30
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypeoperators.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objecttypeoperators.h"
+
+ObjectTypeOperators::ObjectTypeOperators(const std::string key) : m_key(key)
+{
+}
+
+bool ObjectTypeOperators::operator==(const ObjectTypeOperators& other) const
+{
+ return m_key == other.m_key;
+}
+
+const ObjectTypeOperators& ObjectTypeOperators::operator<(const ObjectTypeOperators& other) const
+{
+ return m_key < other.m_key ? *this : other;
+}
+
+bool operator==(const ObjectTypeOperators* obj, const std::string& str)
+{
+ return obj->key() == str;
+}
+
+bool operator==(const std::string& str, const ObjectTypeOperators* obj)
+{
+ return str == obj->key();
+}
+
+std::string operator+(const ObjectTypeOperators* obj, const std::string& str)
+{
+ return obj->key() + str;
+}
+
+std::string operator+(const std::string& str, const ObjectTypeOperators* obj)
+{
+ return str + obj->key();
+}
diff --git a/sources/shiboken2/tests/libsample/objecttypeoperators.h b/sources/shiboken2/tests/libsample/objecttypeoperators.h
new file mode 100644
index 000000000..5795ac456
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objecttypeoperators.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTTYPEOPERATORS_H
+#define OBJECTTYPEOPERATORS_H
+
+#include "libsamplemacros.h"
+#include <string>
+
+class LIBSAMPLE_API ObjectTypeOperators
+{
+public:
+ explicit ObjectTypeOperators(const std::string key);
+ virtual ~ObjectTypeOperators() {}
+
+ bool operator==(const ObjectTypeOperators& other) const;
+ const ObjectTypeOperators& operator<(const ObjectTypeOperators& other) const;
+
+ // chaos!
+ virtual void operator>(const ObjectTypeOperators&) { m_key.append("operator>"); }
+
+ std::string key() const { return m_key; }
+
+private:
+ std::string m_key;
+
+ ObjectTypeOperators(ObjectTypeOperators&);
+ ObjectTypeOperators& operator=(ObjectTypeOperators&);
+};
+
+LIBSAMPLE_API bool operator==(const ObjectTypeOperators* obj, const std::string& str);
+LIBSAMPLE_API bool operator==(const std::string& str, const ObjectTypeOperators* obj);
+LIBSAMPLE_API std::string operator+(const ObjectTypeOperators* obj, const std::string& str);
+LIBSAMPLE_API std::string operator+(const std::string& str, const ObjectTypeOperators* obj);
+
+#endif // OBJECTTYPEOPERATORS_H
diff --git a/sources/shiboken2/tests/libsample/objectview.cpp b/sources/shiboken2/tests/libsample/objectview.cpp
new file mode 100644
index 000000000..08c5f45f6
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objectview.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "objectview.h"
+#include "objectmodel.h"
+#include "str.h"
+
+Str
+ObjectView::displayModelData()
+{
+ if (!m_model)
+ return Str("(NULL)");
+ return Str("Name: %VAR").arg(m_model->objectName());
+}
+
+void
+ObjectView::modifyModelData(Str& data)
+{
+ if (m_model)
+ m_model->setObjectName(data);
+}
+
+
+ObjectType*
+ObjectView::getRawModelData()
+{
+ return m_model->data();
+}
+
diff --git a/sources/shiboken2/tests/libsample/objectview.h b/sources/shiboken2/tests/libsample/objectview.h
new file mode 100644
index 000000000..0bcc09a30
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/objectview.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJECTVIEW_H
+#define OBJECTVIEW_H
+
+#include "objecttype.h"
+#include "libsamplemacros.h"
+
+class Str;
+class ObjectModel;
+
+class LIBSAMPLE_API ObjectView : public ObjectType
+{
+public:
+ ObjectView(ObjectModel* model = 0, ObjectType* parent = 0)
+ : ObjectType(parent), m_model(model)
+ {}
+
+ inline void setModel(ObjectModel* model) { m_model = model; }
+ inline ObjectModel* model() const { return m_model; }
+
+ Str displayModelData();
+ void modifyModelData(Str& data);
+
+ ObjectType* getRawModelData();
+
+private:
+ ObjectModel* m_model;
+};
+
+#endif // OBJECTVIEW_H
+
diff --git a/sources/shiboken2/tests/libsample/oddbool.h b/sources/shiboken2/tests/libsample/oddbool.h
new file mode 100644
index 000000000..ee0f4fa03
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/oddbool.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ODDBOOL_H
+#define ODDBOOL_H
+
+#include "libsamplemacros.h"
+
+class OddBool
+{
+
+public:
+ inline explicit OddBool(bool b) : m_value(b) {}
+ bool value() const { return m_value; }
+
+ inline OddBool operator!() const { return OddBool(!m_value); }
+
+private:
+ bool m_value;
+};
+
+inline bool operator==(OddBool b1, bool b2) { return (!b1).value() == !b2; }
+inline bool operator==(bool b1, OddBool b2) { return (!b1) == (!b2).value(); }
+inline bool operator==(OddBool b1, OddBool b2) { return (!b1).value() == (!b2).value(); }
+inline bool operator!=(OddBool b1, bool b2) { return (!b1).value() != !b2; }
+inline bool operator!=(bool b1, OddBool b2) { return (!b1) != (!b2).value(); }
+inline bool operator!=(OddBool b1, OddBool b2) { return (!b1).value() != (!b2).value(); }
+
+class OddBoolUser
+{
+public:
+ OddBoolUser() : m_oddbool(OddBool(false)) {}
+ OddBoolUser(const OddBool& oddBool) : m_oddbool(oddBool) {}
+ virtual ~OddBoolUser() {}
+
+ inline OddBool oddBool() { return m_oddbool; }
+ inline void setOddBool(OddBool oddBool) { m_oddbool = oddBool; }
+
+ virtual OddBool invertedOddBool()
+ {
+ return !m_oddbool;
+ }
+
+ inline OddBool callInvertedOddBool()
+ {
+ return invertedOddBool();
+ }
+
+ static inline OddBool getOddBool(const OddBoolUser& oddBoolUser)
+ {
+ return oddBoolUser.m_oddbool;
+ }
+
+private:
+ OddBool m_oddbool;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/onlycopy.cpp b/sources/shiboken2/tests/libsample/onlycopy.cpp
new file mode 100644
index 000000000..5407f9d33
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/onlycopy.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "onlycopy.h"
+
+OnlyCopy::OnlyCopy(const OnlyCopy& other)
+{
+ m_value = other.m_value;
+}
+
+OnlyCopy&
+OnlyCopy::operator=(const OnlyCopy& other)
+{
+ m_value = other.m_value;
+ return *this;
+}
+
+OnlyCopy
+FriendOfOnlyCopy::createOnlyCopy(int value)
+{
+
+ return OnlyCopy(value);
+}
+
+std::list<OnlyCopy>
+FriendOfOnlyCopy::createListOfOnlyCopy(int quantity)
+{
+ std::list<OnlyCopy> list;
+ for (int i = 0; i < quantity; ++i)
+ list.push_back(createOnlyCopy(i));
+ return list;
+}
diff --git a/sources/shiboken2/tests/libsample/onlycopy.h b/sources/shiboken2/tests/libsample/onlycopy.h
new file mode 100644
index 000000000..6abad7382
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/onlycopy.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ONLYCOPYCLASS_H
+#define ONLYCOPYCLASS_H
+
+#include "libsamplemacros.h"
+#include <list>
+
+// These classes simulate a situation found in
+// QtWebKit's QWebDatabase and QWebSecurityOrigin.
+
+class LIBSAMPLE_API OnlyCopy
+{
+public:
+ OnlyCopy(const OnlyCopy& other);
+ OnlyCopy& operator=(const OnlyCopy& other);
+ int value() const { return m_value; }
+ static int getValue(OnlyCopy onlyCopy) { return onlyCopy.m_value; }
+ static int getValueFromReference(const OnlyCopy& onlyCopy) { return onlyCopy.m_value; }
+private:
+ int m_value;
+ OnlyCopy(int value) : m_value(value) {};
+ friend class FriendOfOnlyCopy;
+};
+
+class LIBSAMPLE_API FriendOfOnlyCopy
+{
+public:
+ static OnlyCopy createOnlyCopy(int value);
+ static std::list<OnlyCopy> createListOfOnlyCopy(int quantity);
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/overload.cpp b/sources/shiboken2/tests/libsample/overload.cpp
new file mode 100644
index 000000000..753407e35
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/overload.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "overload.h"
+
+Overload::FunctionEnum Overload::overloaded()
+{
+ return Function0;
+}
+
+Overload::FunctionEnum Overload::overloaded(Size* size)
+{
+ return Function1;
+}
+
+Overload::FunctionEnum Overload::overloaded(Point* point, ParamEnum param)
+{
+ return Function2;
+}
+
+Overload::FunctionEnum Overload::overloaded(const Point& point)
+{
+ return Function3;
+}
+
diff --git a/sources/shiboken2/tests/libsample/overload.h b/sources/shiboken2/tests/libsample/overload.h
new file mode 100644
index 000000000..5005b4f8c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/overload.h
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OVERLOAD_H
+#define OVERLOAD_H
+
+#include "echo.h"
+#include "str.h"
+#include "size.h"
+#include "point.h"
+#include "pointf.h"
+#include "polygon.h"
+#include "rect.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Overload
+{
+public:
+ enum FunctionEnum {
+ Function0,
+ Function1,
+ Function2,
+ Function3,
+ Function4,
+ Function5,
+ Function6
+ };
+
+ enum ParamEnum {
+ Param0,
+ Param1
+ };
+
+ Overload() {}
+ virtual ~Overload() {}
+
+ FunctionEnum overloaded();
+ FunctionEnum overloaded(Size* size);
+ FunctionEnum overloaded(Point* point, ParamEnum param);
+ FunctionEnum overloaded(const Point& point);
+
+ inline void differentReturnTypes(ParamEnum param = Param0) {}
+ inline int differentReturnTypes(ParamEnum param, int val) { return val; }
+
+ inline int intOverloads(const Point& p, double d) { return 1; }
+ inline int intOverloads(int i, int i2) { return 2; }
+ inline int intOverloads(int i, int removedArg, double d) { return 3; }
+
+ inline FunctionEnum intDoubleOverloads(int a0, int a1) const { return Function0; }
+ inline FunctionEnum intDoubleOverloads(double a0, double a1) const { return Function1; }
+
+ void singleOverload(Point* x) {}
+ Point* singleOverload() {return new Point();}
+
+ // Similar to QImage::trueMatrix(QMatrix,int,int) and QImage::trueMatrix(QTransform,int,int)
+ FunctionEnum wrapperIntIntOverloads(const Point& arg0, int arg1, int arg2) { return Function0; }
+ FunctionEnum wrapperIntIntOverloads(const Polygon& arg0, int arg1, int arg2) { return Function1; }
+
+ // Similar to QImage constructor
+ FunctionEnum strBufferOverloads(const Str& arg0, const char* arg1 = 0, bool arg2 = true) { return Function0; }
+ FunctionEnum strBufferOverloads(unsigned char* arg0, int arg1) { return Function1; }
+ FunctionEnum strBufferOverloads() { return Function2; }
+
+ // Similar to QPainter::drawText(...)
+ FunctionEnum drawText(const Point& a0, const Str& a1) { return Function0; }
+ FunctionEnum drawText(const PointF& a0, const Str& a1) { return Function1; }
+ FunctionEnum drawText(const Rect& a0, int a1, const Str& a2) { return Function2; }
+ FunctionEnum drawText(const RectF& a0, int a1, const Str& a2) { return Function3; }
+ FunctionEnum drawText(const RectF& a0, const Str& a1, const Echo& a2 = Echo()) { return Function4; }
+ FunctionEnum drawText(int a0, int a1, const Str& a2) { return Function5; }
+ FunctionEnum drawText(int a0, int a1, int a2, int a3, int a4, const Str& a5) { return Function6; }
+
+ // A variant of the one similar to QPainter::drawText(...)
+ FunctionEnum drawText2(const Point& a0, const Str& a1) { return Function0; }
+ FunctionEnum drawText2(const PointF& a0, const Str& a1) { return Function1; }
+ FunctionEnum drawText2(const Rect& a0, int a1, const Str& a2) { return Function2; }
+ FunctionEnum drawText2(const RectF& a0, int a1, const Str& a2) { return Function3; }
+ FunctionEnum drawText2(const RectF& a0, const Str& a1, const Echo& a2 = Echo()) { return Function4; }
+ FunctionEnum drawText2(int a0, int a1, const Str& a2) { return Function5; }
+ FunctionEnum drawText2(int a0, int a1, int a2, int a3 = 0, int a4 = 0, const Str& a5 = Str()) { return Function6; }
+
+ // A simpler variant of the one similar to QPainter::drawText(...)
+ FunctionEnum drawText3(const Str& a0, const Str& a1, const Str& a2) { return Function0; }
+ FunctionEnum drawText3(int a0, int a1, int a2, int a3, int a4) { return Function1; }
+
+ // Another simpler variant of the one similar to QPainter::drawText(...)
+ FunctionEnum drawText4(int a0, int a1, int a2) { return Function0; }
+ FunctionEnum drawText4(int a0, int a1, int a2, int a3, int a4) { return Function1; }
+
+ FunctionEnum acceptSequence() { return Function0; }
+ FunctionEnum acceptSequence(int a0, int a1) { return Function1; }
+ FunctionEnum acceptSequence(const Str& a0, ParamEnum a1 = Param0) { return Function2; }
+ FunctionEnum acceptSequence(const Size& a0) { return Function3; }
+ // The type must be changed to PySequence.
+ FunctionEnum acceptSequence(const char* const a0[]) { return Function4; }
+ FunctionEnum acceptSequence(void* a0) { return Function5; }
+};
+
+class LIBSAMPLE_API Overload2 : public Overload
+{
+public:
+ // test bug#616, public and private method differ only by const
+ void doNothingInPublic() const {}
+ void doNothingInPublic(int) {}
+ virtual void doNothingInPublic3() const {}
+ void doNothingInPublic3(int) const {}
+protected:
+ void doNothingInPublic2() const {}
+ void doNothingInPublic2(int) {}
+private:
+ void doNothingInPublic() {}
+ void doNothingInPublic2() {}
+ void doNothingInPublic3() {}
+};
+
+#endif // OVERLOAD_H
+
diff --git a/sources/shiboken2/tests/libsample/overloadsort.cpp b/sources/shiboken2/tests/libsample/overloadsort.cpp
new file mode 100644
index 000000000..f1bc9665b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/overloadsort.cpp
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "overloadsort.h"
+
diff --git a/sources/shiboken2/tests/libsample/overloadsort.h b/sources/shiboken2/tests/libsample/overloadsort.h
new file mode 100644
index 000000000..9145504ae
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/overloadsort.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OVERLOADSORT_H
+#define OVERLOADSORT_H
+
+#include "libsamplemacros.h"
+
+#include <list>
+
+class ImplicitTarget
+{
+public:
+ ImplicitTarget(){}
+};
+
+class ImplicitBase
+{
+public:
+ ImplicitBase(){}
+ ImplicitBase(const ImplicitTarget &b){}
+};
+
+class SortedOverload
+{
+public:
+
+ inline const char *overload(int x) {
+ return "int";
+ }
+
+ inline const char *overload(double x) {
+ return "double";
+ }
+
+ inline const char *overload(ImplicitBase x) {
+ return "ImplicitBase";
+ }
+
+ inline const char *overload(ImplicitTarget x) {
+ return "ImplicitTarget";
+ }
+
+ inline const char *overload(const std::list<ImplicitBase> &x) {
+ return "list(ImplicitBase)";
+ }
+
+ inline int implicit_overload(const ImplicitBase &x) {
+ return 1;
+ }
+
+ inline const char *overloadDeep(int x, ImplicitBase &y) {
+ return "ImplicitBase";
+ }
+
+
+ inline const char* pyObjOverload(int, int) { return "int,int"; }
+ inline const char* pyObjOverload(unsigned char*, int) { return "PyObject,int"; }
+
+};
+
+#endif // OVERLOADSORT_H
+
diff --git a/sources/shiboken2/tests/libsample/pairuser.cpp b/sources/shiboken2/tests/libsample/pairuser.cpp
new file mode 100644
index 000000000..b4b51b8cf
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pairuser.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "pairuser.h"
+
+using namespace std;
+
+std::pair<int, int>
+PairUser::callCreatePair()
+{
+ return createPair();
+}
+
+std::pair<int, int>
+PairUser::createPair()
+{
+ return std::pair<int, int>(10, 20);
+}
+
+std::pair<Complex, Complex>
+PairUser::createComplexPair(Complex cpx0, Complex cpx1)
+{
+ return std::pair<Complex, Complex>(cpx0, cpx1);
+}
+
+double
+PairUser::sumPair(std::pair<int, double> pair)
+{
+ return ((double) pair.first) + pair.second;
+}
+
diff --git a/sources/shiboken2/tests/libsample/pairuser.h b/sources/shiboken2/tests/libsample/pairuser.h
new file mode 100644
index 000000000..7b87ba65b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pairuser.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PAIRUSER_H
+#define PAIRUSER_H
+
+#include <utility>
+#include "complex.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API PairUser
+{
+public:
+ PairUser() {}
+ virtual ~PairUser() {}
+
+ virtual std::pair<int, int> createPair();
+ std::pair<int, int> callCreatePair();
+ static std::pair<Complex, Complex> createComplexPair(Complex cpx0, Complex cpx1);
+ double sumPair(std::pair<int, double> pair);
+
+ inline void setPair(std::pair<int, int> pair) { m_pair = pair; }
+ inline std::pair<int, int> getPair() { return m_pair; }
+
+private:
+ std::pair<int, int> m_pair;
+};
+#endif // PAIRUSER_H
+
diff --git a/sources/shiboken2/tests/libsample/pen.cpp b/sources/shiboken2/tests/libsample/pen.cpp
new file mode 100644
index 000000000..509b47c76
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pen.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "pen.h"
+
+Color::Color() : m_null(true)
+{
+}
+
+Color::Color(SampleNamespace::InValue arg) : m_null(false)
+{
+}
+
+Color::Color(unsigned int arg) : m_null(false)
+{
+}
+
+bool Color::isNull() const
+{
+ return m_null;
+}
+
+Pen::Pen() : m_ctor(EmptyCtor)
+{
+}
+
+Pen::Pen(SampleNamespace::Option option) : m_ctor(EnumCtor)
+{
+}
+
+Pen::Pen(const Color& color) : m_ctor(ColorCtor)
+{
+}
+
+Pen::Pen(const Pen& pen) : m_ctor(CopyCtor)
+{
+}
+
+int Pen::ctorType()
+{
+ return m_ctor;
+}
diff --git a/sources/shiboken2/tests/libsample/pen.h b/sources/shiboken2/tests/libsample/pen.h
new file mode 100644
index 000000000..e1fb641d3
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pen.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PEN_H
+#define PEN_H
+
+#include "libsamplemacros.h"
+#include "samplenamespace.h"
+
+class LIBSAMPLE_API Color
+{
+public:
+ Color();
+ Color(SampleNamespace::InValue arg);
+ Color(unsigned int arg);
+
+ bool isNull() const;
+private:
+ bool m_null;
+};
+
+class LIBSAMPLE_API Pen
+{
+public:
+ enum { EmptyCtor, EnumCtor, ColorCtor, CopyCtor };
+
+ Pen();
+ Pen(SampleNamespace::Option option);
+ Pen(const Color& color);
+ Pen(const Pen& pen);
+
+ int ctorType();
+private:
+ int m_ctor;
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/photon.cpp b/sources/shiboken2/tests/libsample/photon.cpp
new file mode 100644
index 000000000..debc9f116
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/photon.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "photon.h"
+
+namespace Photon
+{
+const ClassType Base::staticType;
+int callCalculateForValueDuplicatorPointer(ValueDuplicator* value)
+{
+ return value->calculate();
+}
+int callCalculateForValueDuplicatorReference(ValueDuplicator& value)
+{
+ return value.calculate();
+}
+int countValueIdentities(const std::list<ValueIdentity>& values)
+{
+ return values.size();
+}
+int countValueDuplicators(const std::list<TemplateBase<DuplicatorType> >& values)
+{
+ return values.size();
+}
+} // namespace Photon
diff --git a/sources/shiboken2/tests/libsample/photon.h b/sources/shiboken2/tests/libsample/photon.h
new file mode 100644
index 000000000..d8b1be423
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/photon.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PHOTON_H
+#define PHOTON_H
+
+#include <list>
+#include "libsamplemacros.h"
+
+// This namespace and classes simulate
+// situations found in Qt's phonon module.
+
+namespace Photon
+{
+
+enum ClassType {
+ BaseType = 0,
+ IdentityType = 1,
+ DuplicatorType = 2
+};
+
+class LIBSAMPLE_API Base
+{
+public:
+ explicit Base(int value) : m_value(value) {}
+ virtual ~Base() {}
+ inline void setValue(int value) { m_value = value; }
+ inline int value() const { return m_value; }
+
+ template <class T> bool isType() { return type() == T::staticType; }
+ bool isType(ClassType t) { return type() == t; }
+
+ virtual ClassType type() const { return BaseType; };
+ static const ClassType staticType = BaseType;
+
+protected:
+ int m_value;
+};
+
+template<ClassType CLASS_TYPE>
+class LIBSAMPLE_API TemplateBase : public Base
+{
+public:
+ explicit TemplateBase(int value) : Base(value) {}
+ inline int multiplicator() const { return (int)CLASS_TYPE; }
+ inline int calculate() const { return m_value * ((int)CLASS_TYPE); }
+ static inline ClassType classType() { return CLASS_TYPE; }
+
+ inline int sumValueUsingPointer(TemplateBase<CLASS_TYPE>* other) const { return m_value + other->m_value; }
+ inline int sumValueUsingReference(TemplateBase<CLASS_TYPE>& other) const { return m_value + other.m_value; }
+
+ inline std::list<TemplateBase<CLASS_TYPE> > getListOfThisTemplateBase()
+ {
+ std::list<TemplateBase<CLASS_TYPE> > objs;
+ objs.push_back(*this);
+ objs.push_back(*this);
+ return objs;
+ }
+
+ static inline TemplateBase<CLASS_TYPE>* passPointerThrough(TemplateBase<CLASS_TYPE>* obj) { return obj; }
+
+ virtual ClassType type() const { return CLASS_TYPE; }
+ static const ClassType staticType = CLASS_TYPE;
+};
+
+#if defined _WIN32 || defined __CYGWIN__
+template class LIBSAMPLE_API TemplateBase<IdentityType>;
+template class LIBSAMPLE_API TemplateBase<DuplicatorType>;
+#endif
+
+typedef TemplateBase<IdentityType> ValueIdentity;
+typedef TemplateBase<DuplicatorType> ValueDuplicator;
+
+LIBSAMPLE_API int callCalculateForValueDuplicatorPointer(ValueDuplicator* value);
+LIBSAMPLE_API int callCalculateForValueDuplicatorReference(ValueDuplicator& value);
+LIBSAMPLE_API int countValueIdentities(const std::list<ValueIdentity>& values);
+LIBSAMPLE_API int countValueDuplicators(const std::list<TemplateBase<DuplicatorType> >& values);
+
+// This simulates an internal error (SEGV) caused by 'noexcept' in
+// boost::intrusive_ptr before support for 'noexcept' was added. The ENTIRE
+// code below is needed to trigger the exception; it isn't seen with just a
+// 'noexcept' following a declaration.
+//
+// NOTE: For reasons that should be fairly obvious, this test unfortunately can
+// only be "run" when building in C++11 mode.
+#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900)
+# define PHOTON_NOEXCEPT noexcept
+#else
+# define PHOTON_NOEXCEPT
+#endif
+class Pointer
+{
+public:
+ Pointer() PHOTON_NOEXCEPT : px(0) {}
+ Pointer(int* p) : px(p) {}
+
+ void reset() PHOTON_NOEXCEPT { Pointer().swap(*this); }
+
+ int* get() const PHOTON_NOEXCEPT { return px; }
+ int& operator*() const { return *px; }
+
+ void swap(Pointer& rhs) PHOTON_NOEXCEPT
+ {
+ int* tmp = px;
+ px = rhs.px;
+ rhs.px = tmp;
+ }
+
+private:
+ int* px;
+};
+
+} // namespace Photon
+
+#endif // PHOTON_H
diff --git a/sources/shiboken2/tests/libsample/point.cpp b/sources/shiboken2/tests/libsample/point.cpp
new file mode 100644
index 000000000..30275393b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/point.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "point.h"
+
+using namespace std;
+
+Point::Point(int x, int y) : m_x(x), m_y(y)
+{
+}
+
+Point::Point(double x, double y) : m_x(x), m_y(y)
+{
+}
+
+void
+Point::midpoint(const Point& other, Point* midpoint) const
+{
+ if (!midpoint)
+ return;
+ midpoint->setX((m_x + other.m_x) / 2.0);
+ midpoint->setY((m_y + other.m_y) / 2.0);
+}
+
+Point*
+Point::copy() const
+{
+ Point* pt = new Point();
+ pt->m_x = m_x;
+ pt->m_y = m_y;
+ return pt;
+}
+
+void
+Point::show()
+{
+ cout << "(x: " << m_x << ", y: " << m_y << ")";
+}
+
+bool
+Point::operator==(const Point& other)
+{
+ return m_x == other.m_x && m_y == other.m_y;
+}
+
+Point
+Point::operator+(const Point& other)
+{
+ return Point(m_x + other.m_x, m_y + other.m_y);
+}
+
+Point
+Point::operator-(const Point& other)
+{
+ return Point(m_x - other.m_x, m_y - other.m_y);
+}
+
+Point&
+Point::operator+=(Point &other)
+{
+ m_x += other.m_x;
+ m_y += other.m_y;
+ return *this;
+}
+
+Point&
+Point::operator-=(Point &other)
+{
+ m_x -= other.m_x;
+ m_y -= other.m_y;
+ return *this;
+}
+
+Point
+operator*(const Point& pt, double mult)
+{
+ return Point(pt.m_x * mult, pt.m_y * mult);
+}
+
+Point
+operator*(const Point& pt, int mult)
+{
+ return Point(((int) pt.m_x) * mult, ((int) pt.m_y) * mult);
+}
+
+Point
+operator*(double mult, const Point& pt)
+{
+ return Point(pt.m_x * mult, pt.m_y * mult);
+}
+
+Point
+operator*(int mult, const Point& pt)
+{
+ return Point(((int) pt.m_x) * mult, ((int) pt.m_y) * mult);
+}
+
+Point
+operator-(const Point& pt)
+{
+ return Point(-pt.m_x, -pt.m_y);
+}
+
+bool
+operator!(const Point& pt)
+{
+ return (pt.m_x == 0.0 && pt.m_y == 0.0);
+}
+
+Point
+Point::operator/(int operand)
+{
+ return Point(m_x/operand, m_y/operand);
+}
+
+Complex
+transmutePointIntoComplex(const Point& point)
+{
+ Complex cpx(point.x(), point.y());
+ return cpx;
+}
+
+Point
+transmuteComplexIntoPoint(const Complex& cpx)
+{
+ Point pt(cpx.real(), cpx.imag());
+ return pt;
+}
+
diff --git a/sources/shiboken2/tests/libsample/point.h b/sources/shiboken2/tests/libsample/point.h
new file mode 100644
index 000000000..9416d6ddf
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/point.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef POINT_H
+#define POINT_H
+
+#include "complex.h"
+#include <utility>
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Point
+{
+public:
+ Point(int x = 0, int y = 0);
+ Point(double x, double y);
+ ~Point() {}
+
+ inline double x() const { return m_x; }
+ inline double y() const { return m_y; }
+
+ inline void setX(double x) { m_x = x; }
+ inline void setY(double y) { m_y = y; }
+ inline void setXAsUint(unsigned int x) { m_x = x; }
+ inline void setYAsUint(unsigned int y) { m_y = y; }
+
+ // This method could simply return the midpoint,
+ // but the interesting part of the test is to set the
+ // result in the pointer argument.
+ void midpoint(const Point& other, Point* midpoint) const;
+
+ Point* copy() const;
+
+ inline const Point& getConstReferenceToSelf() const { return *this; }
+ inline const Point* getSelf() const { return this; }
+
+ // The != operator is not implemented for the purpose of testing
+ // for the absense of the __ne__ method in the Python binding.
+ bool operator==(const Point& other);
+
+ Point operator+(const Point& other);
+ Point operator-(const Point& other);
+ Point operator/(int operand);
+
+ friend LIBSAMPLE_API Point operator*(const Point& pt, double mult);
+ friend LIBSAMPLE_API Point operator*(const Point& pt, int mult);
+ friend LIBSAMPLE_API Point operator*(double mult, const Point& pt);
+ friend LIBSAMPLE_API Point operator*(int mult, const Point& pt);
+ friend LIBSAMPLE_API Point operator-(const Point& pt);
+ friend LIBSAMPLE_API bool operator!(const Point& pt);
+
+ Point& operator+=(Point &other);
+ Point& operator-=(Point &other);
+
+ void show();
+
+private:
+ double m_x;
+ double m_y;
+};
+
+LIBSAMPLE_API Point operator*(const Point& pt, double mult);
+LIBSAMPLE_API Point operator*(const Point& pt, int mult);
+LIBSAMPLE_API Point operator*(double mult, const Point& pt);
+LIBSAMPLE_API Point operator*(int mult, const Point& pt);
+LIBSAMPLE_API Point operator-(const Point& pt);
+LIBSAMPLE_API bool operator!(const Point& pt);
+
+LIBSAMPLE_API Complex transmutePointIntoComplex(const Point& point);
+LIBSAMPLE_API Point transmuteComplexIntoPoint(const Complex& cpx);
+
+LIBSAMPLE_API Point operator*(const Point& pt, double multiplier);
+
+#endif // POINT_H
diff --git a/sources/shiboken2/tests/libsample/pointerholder.h b/sources/shiboken2/tests/libsample/pointerholder.h
new file mode 100644
index 000000000..84e709d38
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pointerholder.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef POINTERHOLDER_H
+#define POINTERHOLDER_H
+
+#include "libsamplemacros.h"
+
+class PointerHolder
+{
+public:
+ explicit PointerHolder(void* ptr) : m_pointer(ptr) {}
+ ~PointerHolder() {}
+ inline void* pointer() const { return m_pointer; }
+private:
+ void* m_pointer;
+};
+
+#endif // POINTERHOLDER_H
+
diff --git a/sources/shiboken2/tests/libsample/pointf.cpp b/sources/shiboken2/tests/libsample/pointf.cpp
new file mode 100644
index 000000000..0719bdb87
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pointf.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "pointf.h"
+
+using namespace std;
+
+PointF::PointF(const Point& point) : m_x(point.x()), m_y(point.y())
+{
+}
+
+PointF::PointF(double x, double y) : m_x(x), m_y(y)
+{
+}
+
+void
+PointF::midpoint(const PointF& other, PointF* midpoint) const
+{
+ if (!midpoint)
+ return;
+ midpoint->setX((m_x + other.m_x) / 2.0);
+ midpoint->setY((m_y + other.m_y) / 2.0);
+}
+
+void
+PointF::show()
+{
+ cout << "(x: " << m_x << ", y: " << m_y << ")";
+}
+
+bool
+PointF::operator==(const PointF& other)
+{
+ return m_x == other.m_x && m_y == other.m_y;
+}
+
+PointF
+PointF::operator+(const PointF& other)
+{
+ return PointF(m_x + other.m_x, m_y + other.m_y);
+}
+
+PointF
+PointF::operator-(const PointF& other)
+{
+ return PointF(m_x - other.m_x, m_y - other.m_y);
+}
+
+PointF&
+PointF::operator+=(PointF &other)
+{
+ m_x += other.m_x;
+ m_y += other.m_y;
+ return *this;
+}
+
+PointF&
+PointF::operator-=(PointF &other)
+{
+ m_x -= other.m_x;
+ m_y -= other.m_y;
+ return *this;
+}
+
+PointF
+operator*(const PointF& pt, double mult)
+{
+ return PointF(pt.m_x * mult, pt.m_y * mult);
+}
+
+PointF
+operator*(const PointF& pt, int mult)
+{
+ return PointF(((int) pt.m_x) * mult, ((int) pt.m_y) * mult);
+}
+
+PointF
+operator*(double mult, const PointF& pt)
+{
+ return PointF(pt.m_x * mult, pt.m_y * mult);
+}
+
+PointF
+operator*(int mult, const PointF& pt)
+{
+ return PointF(((int) pt.m_x) * mult, ((int) pt.m_y) * mult);
+}
+
+PointF
+operator-(const PointF& pt)
+{
+ return PointF(-pt.m_x, -pt.m_y);
+}
+
+bool
+operator!(const PointF& pt)
+{
+ return (pt.m_x == 0.0 && pt.m_y == 0.0);
+}
+
diff --git a/sources/shiboken2/tests/libsample/pointf.h b/sources/shiboken2/tests/libsample/pointf.h
new file mode 100644
index 000000000..c80739fea
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/pointf.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef POINTF_H
+#define POINTF_H
+
+#include "point.h"
+#include <utility>
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API PointF
+{
+public:
+ PointF(const Point& point);
+ PointF(double x = 0.0, double y = 0.0);
+ ~PointF() {}
+
+ inline double x() const { return m_x; }
+ inline double y() const { return m_y; }
+
+ inline void setX(double x) { m_x = x; }
+ inline void setY(double y) { m_y = y; }
+
+ // This method could simply return the midpoint,
+ // but the interesting part of the test is to set the
+ // result in the pointer argument.
+ void midpoint(const PointF& other, PointF* midpoint) const;
+
+ // The != operator is not implemented for the purpose of testing
+ // for the absence of the __ne__ method in the Python binding.
+ bool operator==(const PointF& other);
+
+ PointF operator+(const PointF& other);
+ PointF operator-(const PointF& other);
+
+ friend LIBSAMPLE_API PointF operator*(const PointF& pt, double mult);
+ friend LIBSAMPLE_API PointF operator*(const PointF& pt, int mult);
+ friend LIBSAMPLE_API PointF operator*(double mult, const PointF& pt);
+ friend LIBSAMPLE_API PointF operator*(int mult, const PointF& pt);
+ friend LIBSAMPLE_API PointF operator-(const PointF& pt);
+ friend LIBSAMPLE_API bool operator!(const PointF& pt);
+
+ PointF& operator+=(PointF &other);
+ PointF& operator-=(PointF &other);
+
+ void show();
+
+private:
+ double m_x;
+ double m_y;
+};
+
+LIBSAMPLE_API PointF operator*(const PointF& pt, double mult);
+LIBSAMPLE_API PointF operator*(const PointF& pt, int mult);
+LIBSAMPLE_API PointF operator*(double mult, const PointF& pt);
+LIBSAMPLE_API PointF operator*(int mult, const PointF& pt);
+LIBSAMPLE_API PointF operator-(const PointF& pt);
+LIBSAMPLE_API bool operator!(const PointF& pt);
+
+LIBSAMPLE_API PointF operator*(const PointF& pt, double multiplier);
+
+#endif // POINTF_H
diff --git a/sources/shiboken2/tests/libsample/polygon.cpp b/sources/shiboken2/tests/libsample/polygon.cpp
new file mode 100644
index 000000000..cb553a75c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/polygon.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "polygon.h"
+
+using namespace std;
+
+Polygon::Polygon(double x, double y)
+{
+ m_points.push_back(Point(x, y));
+}
+
+Polygon::Polygon(Point point)
+{
+ m_points.push_back(point);
+}
+
+Polygon::Polygon(PointList points)
+{
+ m_points = points;
+}
+
+void
+Polygon::addPoint(Point point)
+{
+ m_points.push_back(point);
+}
+
+Polygon
+Polygon::doublePolygonScale(Polygon polygon)
+{
+ Polygon result;
+ for(PointList::const_iterator piter = result.points().begin(); piter != result.points().end(); piter++)
+ result.addPoint((*piter) * 2.0);
+ return result;
+}
+
+void
+Polygon::stealOwnershipFromPython(Point* point)
+{
+ delete point;
+}
+
+void
+Polygon::stealOwnershipFromPython(Polygon* polygon)
+{
+ delete polygon;
+}
+
diff --git a/sources/shiboken2/tests/libsample/polygon.h b/sources/shiboken2/tests/libsample/polygon.h
new file mode 100644
index 000000000..5e0769e0f
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/polygon.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef POLYGON_H
+#define POLYGON_H
+
+#include <list>
+#include "point.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Polygon
+{
+public:
+ typedef std::list<Point> PointList;
+
+ Polygon() {}
+ Polygon(double x, double y);
+ Polygon(Point point);
+ Polygon(PointList points);
+ ~Polygon() {}
+
+ void addPoint(Point point);
+
+ inline const PointList& points() const { return m_points; }
+
+ // This method intentionally receives and returns copies of a Polygon object.
+ static Polygon doublePolygonScale(Polygon polygon);
+
+ // This method invalidates the argument to be used for Polygon(Point) implicit conversion.
+ static void stealOwnershipFromPython(Point* point);
+
+ // This method invalidates the argument to be used in a call to doublePolygonScale(Polygon).
+ static void stealOwnershipFromPython(Polygon* polygon);
+
+private:
+ PointList m_points;
+};
+
+#endif // POLYGON_H
+
diff --git a/sources/shiboken2/tests/libsample/privatector.h b/sources/shiboken2/tests/libsample/privatector.h
new file mode 100644
index 000000000..4f4699761
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/privatector.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PRIVATECTOR_H
+#define PRIVATECTOR_H
+
+#include "libsamplemacros.h"
+
+class PrivateCtor
+{
+public:
+ inline static PrivateCtor* instance()
+ {
+ static PrivateCtor self;
+ self.m_instanciations++;
+ return &self;
+ }
+
+ inline int instanceCalls()
+ {
+ return m_instanciations;
+ }
+
+private:
+ int m_instanciations;
+
+ PrivateCtor() : m_instanciations(0) {}
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/privatedtor.h b/sources/shiboken2/tests/libsample/privatedtor.h
new file mode 100644
index 000000000..a0c4d4769
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/privatedtor.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PRIVATEDTOR_H
+#define PRIVATEDTOR_H
+
+#include "libsamplemacros.h"
+
+class PrivateDtor
+{
+public:
+ inline static PrivateDtor* instance()
+ {
+ static PrivateDtor self;
+ self.m_instanciations++;
+ return &self;
+ }
+
+ inline int instanceCalls()
+ {
+ return m_instanciations;
+ }
+
+protected:
+ inline int protectedInstanceCalls() { return m_instanciations; }
+
+private:
+ int m_instanciations;
+
+ PrivateDtor() : m_instanciations(0) {}
+ PrivateDtor(const PrivateDtor&) {}
+ ~PrivateDtor() {}
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/protected.cpp b/sources/shiboken2/tests/libsample/protected.cpp
new file mode 100644
index 000000000..08c9fd065
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/protected.cpp
@@ -0,0 +1,32 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "protected.h"
+
+int ProtectedVirtualDestructor::dtor_called = 0;
+
diff --git a/sources/shiboken2/tests/libsample/protected.h b/sources/shiboken2/tests/libsample/protected.h
new file mode 100644
index 000000000..c33bdf4b2
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/protected.h
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PROTECTED_H
+#define PROTECTED_H
+
+#include "libsamplemacros.h"
+#include "objecttype.h"
+#include "point.h"
+#include <string>
+#include <list>
+
+class LIBSAMPLE_API ProtectedNonPolymorphic
+{
+public:
+ explicit ProtectedNonPolymorphic(const char *name) : m_name(name) {}
+ ~ProtectedNonPolymorphic() {}
+
+ inline const char* publicName() { return m_name.c_str(); }
+
+ inline static ProtectedNonPolymorphic* create() { return new ProtectedNonPolymorphic("created"); }
+
+protected:
+ inline const char* protectedName() { return m_name.c_str(); }
+ inline int protectedSum(int a0, int a1) { return a0 + a1; }
+ inline int modifiedProtectedSum(int a0, int a1) { return a0 + a1; }
+ inline static const char* protectedStatic() { return "protectedStatic"; }
+ inline const char* dataTypeName(void *data = 0) const { return "pointer"; }
+ inline const char* dataTypeName(int data) const { return "integer"; }
+
+private:
+ std::string m_name;
+};
+
+class LIBSAMPLE_API ProtectedPolymorphic
+{
+public:
+ explicit ProtectedPolymorphic(const char *name) : m_name(name) {}
+ virtual ~ProtectedPolymorphic() {}
+
+ inline static ProtectedPolymorphic* create() { return new ProtectedPolymorphic("created"); }
+ inline const char* publicName() { return m_name.c_str(); }
+ inline const char* callProtectedName() { return protectedName(); }
+
+protected:
+ virtual const char* protectedName() { return m_name.c_str(); }
+
+private:
+ std::string m_name;
+};
+
+class LIBSAMPLE_API ProtectedPolymorphicDaughter : public ProtectedPolymorphic
+{
+public:
+ explicit ProtectedPolymorphicDaughter(const char *name) : ProtectedPolymorphic(name) {}
+ inline static ProtectedPolymorphicDaughter* create() { return new ProtectedPolymorphicDaughter("created"); }
+};
+
+class LIBSAMPLE_API ProtectedPolymorphicGrandDaughter: public ProtectedPolymorphicDaughter
+{
+public:
+ explicit ProtectedPolymorphicGrandDaughter(const char *name) : ProtectedPolymorphicDaughter(name) {}
+ inline static ProtectedPolymorphicGrandDaughter* create() { return new ProtectedPolymorphicGrandDaughter("created"); }
+};
+
+class LIBSAMPLE_API ProtectedVirtualDestructor
+{
+public:
+ ProtectedVirtualDestructor() {}
+ inline static ProtectedVirtualDestructor* create() { return new ProtectedVirtualDestructor(); }
+ inline static int dtorCalled() { return dtor_called; }
+ inline static void resetDtorCounter() { dtor_called = 0; }
+protected:
+ virtual ~ProtectedVirtualDestructor() { dtor_called++; }
+private:
+ static int dtor_called;
+};
+
+class LIBSAMPLE_API ProtectedEnumClass
+{
+public:
+ ProtectedEnumClass() {}
+ virtual ~ProtectedEnumClass() {}
+ enum PublicEnum {
+ PublicItem0,
+ PublicItem1
+ };
+protected:
+ enum ProtectedEnum {
+ ProtectedItem0,
+ ProtectedItem1
+ };
+ ProtectedEnum callProtectedEnumMethod(ProtectedEnum in) { return protectedEnumMethod(in); }
+ inline PublicEnum callPublicEnumMethod(PublicEnum in) { return publicEnumMethod(in); }
+
+ virtual ProtectedEnum protectedEnumMethod(ProtectedEnum in) { return in; }
+ virtual PublicEnum publicEnumMethod(PublicEnum in) { return in; }
+};
+
+
+class LIBSAMPLE_API ProtectedProperty
+{
+public:
+ ProtectedProperty()
+ : protectedValueTypeProperty(Point(0, 0)),
+ protectedProperty(0),
+ protectedEnumProperty(Event::NO_EVENT),
+ protectedValueTypePointerProperty(0),
+ protectedObjectTypeProperty(0)
+ {}
+protected:
+ // This is deliberately the first member to test wrapper registration
+ // for value type members sharing the same memory address.
+ Point protectedValueTypeProperty;
+ int protectedProperty;
+ std::list<int> protectedContainerProperty;
+ Event::EventType protectedEnumProperty;
+ Point* protectedValueTypePointerProperty;
+ ObjectType* protectedObjectTypeProperty;
+};
+
+LIBSAMPLE_API inline ProtectedProperty* createProtectedProperty() {
+ return new ProtectedProperty;
+}
+
+#endif // PROTECTED_H
diff --git a/sources/shiboken2/tests/libsample/rect.h b/sources/shiboken2/tests/libsample/rect.h
new file mode 100644
index 000000000..b7ce6e890
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/rect.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RECT_H
+#define RECT_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Rect
+{
+public:
+ Rect()
+ {
+ m_left = m_top = 0;
+ m_right = m_bottom = -1;
+ }
+ Rect(int left, int top, int right, int bottom)
+ : m_left(left), m_top(top), m_right(right), m_bottom(bottom) { }
+ ~Rect() {}
+ inline int left() const { return m_left; }
+ inline int top() const { return m_top; }
+ inline int right() const { return m_right; }
+ inline int bottom() const { return m_bottom; }
+private:
+ int m_left;
+ int m_top;
+ int m_right;
+ int m_bottom;
+};
+
+class LIBSAMPLE_API RectF
+{
+public:
+ RectF()
+ {
+ m_left = m_top = 0;
+ m_right = m_bottom = -1;
+ }
+ RectF(int left, int top, int right, int bottom)
+ : m_left(left), m_top(top), m_right(right), m_bottom(bottom) { }
+ RectF(const Rect& other)
+ {
+ m_left = other.left();
+ m_top = other.top();
+ m_right = other.right();
+ m_bottom = other.bottom();
+ }
+ ~RectF() {}
+ inline double left() const { return m_left; }
+ inline double top() const { return m_top; }
+ inline double right() const { return m_right; }
+ inline double bottom() const { return m_bottom; }
+private:
+ double m_left;
+ double m_top;
+ double m_right;
+ double m_bottom;
+};
+
+#endif // RECT_H
+
diff --git a/sources/shiboken2/tests/libsample/reference.cpp b/sources/shiboken2/tests/libsample/reference.cpp
new file mode 100644
index 000000000..31a11a8ae
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/reference.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "reference.h"
+
+using namespace std;
+
+void
+Reference::show() const
+{
+ cout << "Reference.objId: " << m_objId << ", address: " << this;
+}
+
+int
+Reference::usesReferenceVirtual(Reference& r, int inc)
+{
+ return r.m_objId + inc;
+}
+
+int
+Reference::usesConstReferenceVirtual(const Reference& r, int inc)
+{
+ return r.m_objId + inc;
+}
+
+int
+Reference::callUsesReferenceVirtual(Reference& r, int inc)
+{
+ return usesReferenceVirtual(r, inc);
+}
+
+int
+Reference::callUsesConstReferenceVirtual(const Reference& r, int inc)
+{
+ return usesConstReferenceVirtual(r, inc);
+}
+
+void
+Reference::alterReferenceIdVirtual(Reference& r)
+{
+ r.setObjId(r.objId() * Reference::multiplier());
+}
+
+void
+Reference::callAlterReferenceIdVirtual(Reference& r)
+{
+ alterReferenceIdVirtual(r);
+}
+
+ObjTypeReference::~ObjTypeReference()
+{
+}
diff --git a/sources/shiboken2/tests/libsample/reference.h b/sources/shiboken2/tests/libsample/reference.h
new file mode 100644
index 000000000..4ec8ee7fd
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/reference.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef REFERENCE_H
+#define REFERENCE_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Reference
+{
+public:
+ explicit Reference(int objId = -1)
+ : m_objId(objId) {}
+ virtual ~Reference() {}
+
+ inline int objId() { return m_objId; }
+ inline void setObjId(int objId) { m_objId = objId; }
+
+ inline static int usesReference(Reference& r) { return r.m_objId; }
+ inline static int usesConstReference(const Reference& r) { return r.m_objId; }
+
+ virtual int usesReferenceVirtual(Reference& r, int inc);
+ virtual int usesConstReferenceVirtual(const Reference& r, int inc);
+
+ int callUsesReferenceVirtual(Reference& r, int inc);
+ int callUsesConstReferenceVirtual(const Reference& r, int inc);
+
+ virtual void alterReferenceIdVirtual(Reference& r);
+ void callAlterReferenceIdVirtual(Reference& r);
+
+ void show() const;
+
+ inline static int multiplier() { return 10; }
+
+ virtual Reference& returnMyFirstArg(Reference& ref) { return ref; }
+ virtual Reference& returnMySecondArg(int a, Reference& ref) { return ref; }
+
+ // nonsense operator to test if Shiboken is ignoring dereference operators.
+ int operator*() { return m_objId; }
+private:
+ int m_objId;
+};
+
+class LIBSAMPLE_API ObjTypeReference
+{
+public:
+ ObjTypeReference() {}
+ ObjTypeReference(const ObjTypeReference&) {}
+ virtual ~ObjTypeReference();
+ virtual ObjTypeReference& returnMyFirstArg(ObjTypeReference& ref) { return ref; }
+ virtual ObjTypeReference& returnMySecondArg(int a, ObjTypeReference& ref) { return ref; }
+ virtual ObjTypeReference& justAPureVirtualFunc(ObjTypeReference& ref) = 0;
+};
+
+#endif // REFERENCE_H
+
diff --git a/sources/shiboken2/tests/libsample/removednamespaces.h b/sources/shiboken2/tests/libsample/removednamespaces.h
new file mode 100644
index 000000000..4520b6a27
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/removednamespaces.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef REMOVEDNAMESPACE_H
+#define REMOVEDNAMESPACE_H
+
+#include "libsamplemacros.h"
+
+namespace RemovedNamespace1
+{
+
+enum RemovedNamespace1_Enum {
+ RemovedNamespace1_Enum_Value0
+};
+
+enum {
+ RemovedNamespace1_AnonymousEnum_Value0
+};
+
+namespace RemovedNamespace2 {
+ enum RemovedNamespace2_Enum {
+ RemovedNamespace2_Enum_Value0
+ };
+}
+
+}
+
+namespace UnremovedNamespace
+{
+namespace RemovedNamespace3
+{
+ enum RemovedNamespace3_Enum {
+ RemovedNamespace3_Enum_Value0
+ };
+
+ enum {
+ RemovedNamespace3_AnonymousEnum_Value0
+ };
+}
+}
+
+#endif // REMOVEDNAMESPACE_H
+
diff --git a/sources/shiboken2/tests/libsample/sample.cpp b/sources/shiboken2/tests/libsample/sample.cpp
new file mode 100644
index 000000000..fa1e1fda3
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sample.cpp
@@ -0,0 +1,39 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sample.h"
+
+sample::sample::sample(int value) : m_value(value)
+{
+}
+
+int sample::sample::value() const
+{
+ return m_value;
+}
+
diff --git a/sources/shiboken2/tests/libsample/sample.h b/sources/shiboken2/tests/libsample/sample.h
new file mode 100644
index 000000000..46e3d0d1a
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sample.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SAMPLE_H
+#define SAMPLE_H
+
+#include "libsamplemacros.h"
+
+// namespace with the same name of the current package to try to mess up with the generator
+namespace sample
+{
+ // to increase the mess we add a class with the same name of the package/namespace
+ class LIBSAMPLE_API sample
+ {
+ public:
+ sample(int value = 0);
+ int value() const;
+ private:
+ int m_value;
+ };
+}
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/samplenamespace.cpp b/sources/shiboken2/tests/libsample/samplenamespace.cpp
new file mode 100644
index 000000000..1fc6dff40
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/samplenamespace.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include <cstdlib>
+#include <time.h>
+#include "samplenamespace.h"
+
+using namespace std;
+
+namespace SampleNamespace
+{
+
+OutValue
+enumInEnumOut(InValue in)
+{
+ OutValue retval;
+ switch(in) {
+ case ZeroIn:
+ retval = ZeroOut;
+ break;
+ case OneIn:
+ retval = OneOut;
+ break;
+ case TwoIn:
+ retval = TwoOut;
+ break;
+ default:
+ retval = (OutValue) -1;
+ }
+ return retval;
+}
+
+Option
+enumArgumentWithDefaultValue(Option opt)
+{
+ return opt;
+}
+
+int
+getNumber(Option opt)
+{
+ int retval;
+ switch(opt) {
+ case RandomNumber:
+ retval = rand() % 100;
+ break;
+ case UnixTime:
+ retval = (int) time(0);
+ break;
+ default:
+ retval = 0;
+ }
+ return retval;
+}
+
+void
+doSomethingWithArray(const unsigned char* data, unsigned int size, const char* format)
+{
+ // This function does nothing in fact.
+ // It is here as a dummy copy of QPixmap.loadFromData method
+ // to check compilation issues, i.e. if it compiles, it's ok.
+}
+
+int
+enumItemAsDefaultValueToIntArgument(int value)
+{
+ return value;
+}
+
+void
+forceDecisorSideA(ObjectType* object)
+{
+}
+
+void
+forceDecisorSideA(const Point& pt, const Str& text, ObjectType* object)
+{
+}
+
+void
+forceDecisorSideB(int a, ObjectType* object)
+{
+}
+
+void
+forceDecisorSideB(int a, const Point& pt, const Str& text, ObjectType* object)
+{
+}
+
+double
+passReferenceToValueType(const Point& point, double multiplier)
+{
+ return (point.x() + point.y()) * multiplier;
+}
+
+int
+passReferenceToObjectType(const ObjectType& obj, int multiplier)
+{
+ return obj.objectName().size() * multiplier;
+}
+
+} // namespace SampleNamespace
diff --git a/sources/shiboken2/tests/libsample/samplenamespace.h b/sources/shiboken2/tests/libsample/samplenamespace.h
new file mode 100644
index 000000000..3ce410941
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/samplenamespace.h
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SAMPLENAMESPACE_H
+#define SAMPLENAMESPACE_H
+
+#include <list>
+#include "libsamplemacros.h"
+#include "str.h"
+#include "point.h"
+#include "objecttype.h"
+
+// Anonymous global enum
+enum {
+ AnonymousGlobalEnum_Value0,
+ AnonymousGlobalEnum_Value1
+};
+
+// Invisible namespace
+namespace Invisible
+{
+
+enum EnumOnNamespace {
+ Option1 = 1,
+ Option2 = 2,
+ Option3 = 3
+};
+
+};
+
+namespace SampleNamespace
+{
+
+enum Option {
+ None_,
+ RandomNumber,
+ UnixTime
+};
+
+enum InValue {
+ ZeroIn,
+ OneIn,
+ TwoIn
+};
+
+enum OutValue {
+ ZeroOut,
+ OneOut,
+ TwoOut
+};
+
+// Anonymous non-global enum.
+// This counts as a class enum, since C++ namespaces
+// are represented as classes in Python.
+enum {
+ AnonymousClassEnum_Value0,
+ AnonymousClassEnum_Value1
+};
+
+LIBSAMPLE_API OutValue enumInEnumOut(InValue in);
+
+LIBSAMPLE_API Option enumArgumentWithDefaultValue(Option opt = UnixTime);
+
+LIBSAMPLE_API int getNumber(Option opt);
+
+inline double powerOfTwo(double num) {
+ return num * num;
+}
+
+LIBSAMPLE_API void doSomethingWithArray(const unsigned char* data, unsigned int size, const char* format = 0);
+
+LIBSAMPLE_API int enumItemAsDefaultValueToIntArgument(int value = ZeroIn);
+
+class SomeClass
+{
+public:
+ class SomeInnerClass
+ {
+ public:
+ class OkThisIsRecursiveEnough
+ {
+ public:
+ virtual ~OkThisIsRecursiveEnough() {}
+ enum NiceEnum {
+ NiceValue1, NiceValue2
+ };
+
+ inline int someMethod(SomeInnerClass*) { return 0; }
+ virtual OkThisIsRecursiveEnough* someVirtualMethod(OkThisIsRecursiveEnough* arg) { return arg; }
+ };
+ protected:
+ enum ProtectedEnum {
+ ProtectedItem0,
+ ProtectedItem1
+ };
+ };
+ struct SomeOtherInnerClass {
+ std::list<SomeInnerClass> someInnerClasses;
+ };
+protected:
+ enum ProtectedEnum {
+ ProtectedItem0,
+ ProtectedItem1
+ };
+};
+
+class DerivedFromNamespace : public SomeClass::SomeInnerClass::OkThisIsRecursiveEnough
+{
+public:
+ // FIXME Uncomment this when the fix for MSVC is available
+ // only to cause namespace confusion
+// enum SampleNamespace {
+// };
+ virtual OkThisIsRecursiveEnough* someVirtualMethod(OkThisIsRecursiveEnough* arg) { return arg; }
+ inline OkThisIsRecursiveEnough* methodReturningTypeFromParentScope() { return 0; }
+};
+
+// The combination of the following two overloaded methods could trigger a
+// problematic behaviour on the overload decisor, if it isn't working properly.
+LIBSAMPLE_API void forceDecisorSideA(ObjectType* object = 0);
+LIBSAMPLE_API void forceDecisorSideA(const Point& pt, const Str& text, ObjectType* object = 0);
+
+// The combination of the following two overloaded methods could trigger a
+// problematic behaviour on the overload decisor, if it isn't working properly.
+// This is a variation of forceDecisorSideB.
+LIBSAMPLE_API void forceDecisorSideB(int a, ObjectType* object = 0);
+LIBSAMPLE_API void forceDecisorSideB(int a, const Point& pt, const Str& text, ObjectType* object = 0);
+
+// Add a new signature on type system with only a Point value as parameter.
+LIBSAMPLE_API double passReferenceToValueType(const Point& point, double multiplier);
+// Add a new signature on type system with only a ObjectType pointer as parameter.
+LIBSAMPLE_API int passReferenceToObjectType(const ObjectType& obj, int multiplier);
+
+} // namespace SampleNamespace
+
+#endif // SAMPLENAMESPACE_H
+
diff --git a/sources/shiboken2/tests/libsample/sbkdate.cpp b/sources/shiboken2/tests/libsample/sbkdate.cpp
new file mode 100644
index 000000000..e823521ec
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sbkdate.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sbkdate.h"
+
+SbkDate::SbkDate(int d, int m, int y) : m_d(d), m_m(m), m_y(y)
+{
+}
+
+int SbkDate::day() const
+{
+ return m_d;
+}
+
+int SbkDate::month() const
+{
+ return m_m;
+}
+
+int SbkDate::year() const
+{
+ return m_y;
+}
diff --git a/sources/shiboken2/tests/libsample/sbkdate.h b/sources/shiboken2/tests/libsample/sbkdate.h
new file mode 100644
index 000000000..7d0893cbb
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sbkdate.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SBKDATE_H
+#define SBKDATE_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API SbkDate
+{
+public:
+ SbkDate(int d, int m, int y);
+
+ int day() const;
+ int month() const;
+ int year() const;
+
+private:
+ int m_d;
+ int m_m;
+ int m_y;
+};
+
+#endif // SBKDATE_H
+
diff --git a/sources/shiboken2/tests/libsample/simplefile.cpp b/sources/shiboken2/tests/libsample/simplefile.cpp
new file mode 100644
index 000000000..bdbd3d1f5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/simplefile.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include <fstream>
+#include "simplefile.h"
+
+class SimpleFile_p
+{
+public:
+ SimpleFile_p(const char* filename) : m_descriptor(0), m_size(0)
+ {
+ m_filename = strdup(filename);
+ }
+
+ ~SimpleFile_p()
+ {
+ free(m_filename);
+ }
+
+ char* m_filename;
+ FILE* m_descriptor;
+ long m_size;
+};
+
+SimpleFile::SimpleFile(const char* filename)
+{
+ p = new SimpleFile_p(filename);
+}
+
+SimpleFile::~SimpleFile()
+{
+ close();
+ delete p;
+}
+
+const char* SimpleFile::filename()
+{
+ return p->m_filename;
+}
+
+long SimpleFile::size()
+{
+ return p->m_size;
+}
+
+bool
+SimpleFile::open()
+{
+ if ((p->m_descriptor = fopen(p->m_filename, "rb")) == 0)
+ return false;
+
+ fseek(p->m_descriptor, 0, SEEK_END);
+ p->m_size = ftell(p->m_descriptor);
+ rewind(p->m_descriptor);
+
+ return true;
+}
+
+void
+SimpleFile::close()
+{
+ if (p->m_descriptor) {
+ fclose(p->m_descriptor);
+ p->m_descriptor = 0;
+ }
+}
+
+bool
+SimpleFile::exists() const
+{
+ std::ifstream ifile(p->m_filename);
+ return !ifile.fail();
+}
+
+bool
+SimpleFile::exists(const char* filename)
+{
+ std::ifstream ifile(filename);
+ return !ifile.fail();
+}
+
diff --git a/sources/shiboken2/tests/libsample/simplefile.h b/sources/shiboken2/tests/libsample/simplefile.h
new file mode 100644
index 000000000..bae3b9998
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/simplefile.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIMPLEFILE_H
+#define SIMPLEFILE_H
+
+#include "libsamplemacros.h"
+#include <stdio.h>
+
+class SimpleFile_p;
+
+class LIBSAMPLE_API SimpleFile
+{
+public:
+ explicit SimpleFile(const char* filename);
+ ~SimpleFile();
+
+ const char* filename();
+ long size();
+ bool open();
+ void close();
+
+ bool exists() const;
+ static bool exists(const char* filename);
+
+private:
+ SimpleFile_p *p;
+};
+
+#endif // SIMPLEFILE_H
+
diff --git a/sources/shiboken2/tests/libsample/size.cpp b/sources/shiboken2/tests/libsample/size.cpp
new file mode 100644
index 000000000..1faf5dfb2
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/size.cpp
@@ -0,0 +1,39 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "size.h"
+
+using namespace std;
+
+void
+Size::show() const
+{
+ cout << "(width: " << m_width << ", height: " << m_height << ")";
+}
+
diff --git a/sources/shiboken2/tests/libsample/size.h b/sources/shiboken2/tests/libsample/size.h
new file mode 100644
index 000000000..433aba770
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/size.h
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIZE_H
+#define SIZE_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Size
+{
+public:
+ Size(double width = 0.0, double height = 0.0) : m_width(width), m_height(height) {}
+ ~Size() {}
+
+ inline double width() { return m_width; }
+ inline void setWidth(double width) { m_width = width; }
+ inline double height() { return m_height; }
+ inline void setHeight(double height) { m_height = height; }
+
+ inline double calculateArea() const { return m_width * m_height; }
+
+ // Comparison Operators
+ inline bool operator==(const Size& other)
+ {
+ return m_width == other.m_width && m_height == other.m_height;
+ }
+
+ inline bool operator<(const Size& other)
+ {
+ return calculateArea() < other.calculateArea();
+ }
+
+ inline bool operator>(const Size& other)
+ {
+ // On some x86 hardware and compiler combinations, floating point
+ // comparisons may fail due to a hardware bug. One workaround is to
+ // simplify comparison expressions by putting partial results in
+ // variables. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323#c109
+ // for details.
+ double a = calculateArea();
+ double b = other.calculateArea();
+ return a > b;
+ }
+
+ inline bool operator<=(const Size& other)
+ {
+ // See comments for operator>()
+ double a = calculateArea();
+ double b = other.calculateArea();
+ return a <= b;
+ }
+
+ inline bool operator>=(const Size& other)
+ {
+ return calculateArea() >= other.calculateArea();
+ }
+
+ inline bool operator<(double area) { return calculateArea() < area; }
+ inline bool operator>(double area) { return calculateArea() > area; }
+ inline bool operator<=(double area) { return calculateArea() <= area; }
+ inline bool operator>=(double area) { return calculateArea() >= area; }
+
+ // Arithmetic Operators
+ inline Size& operator+=(const Size& s)
+ {
+ m_width += s.m_width;
+ m_height += s.m_height;
+ return *this;
+ }
+
+ inline Size& operator-=(const Size& s)
+ {
+ m_width -= s.m_width;
+ m_height -= s.m_height;
+ return *this;
+ }
+
+ inline Size& operator*=(double mult)
+ {
+ m_width *= mult;
+ m_height *= mult;
+ return *this;
+ }
+
+ inline Size& operator/=(double div)
+ {
+ m_width /= div;
+ m_height /= div;
+ return *this;
+ }
+
+ // TODO: add ++size, size++, --size, size--
+
+ // External operators
+ friend inline bool operator!=(const Size&, const Size&);
+ friend inline const Size operator+(const Size&, const Size&);
+ friend inline const Size operator-(const Size&, const Size&);
+ friend inline const Size operator*(const Size&, double);
+ friend inline const Size operator*(double, const Size&);
+ friend inline const Size operator/(const Size&, double);
+
+ friend inline bool operator<(double, const Size&);
+ friend inline bool operator>(double, const Size&);
+ friend inline bool operator<=(double, const Size&);
+ friend inline bool operator>=(double, const Size&);
+
+ void show() const;
+
+private:
+ double m_width;
+ double m_height;
+};
+
+// Comparison Operators
+inline bool operator!=(const Size& s1, const Size& s2)
+{
+ return s1.m_width != s2.m_width || s1.m_height != s2.m_height;
+}
+
+inline bool operator<(double area, const Size& s)
+{
+ return area < s.calculateArea();
+}
+
+inline bool operator>(double area, const Size& s)
+{
+ return area > s.calculateArea();
+}
+
+inline bool operator<=(double area, const Size& s)
+{
+ return area <= s.calculateArea();
+}
+
+inline bool operator>=(double area, const Size& s)
+{
+ return area >= s.calculateArea();
+}
+
+// Arithmetic Operators
+inline const Size operator+(const Size& s1, const Size& s2)
+{
+ return Size(s1.m_width + s2.m_width, s1.m_height + s2.m_height);
+}
+
+inline const Size operator-(const Size& s1, const Size& s2)
+{
+ return Size(s1.m_width - s2.m_width, s1.m_height - s2.m_height);
+}
+
+inline const Size operator*(const Size& s, double mult)
+{
+ return Size(s.m_width * mult, s.m_height * mult);
+}
+
+inline const Size operator*(double mult, const Size& s)
+{
+ return Size(s.m_width * mult, s.m_height * mult);
+}
+
+inline const Size operator/(const Size& s, double div)
+{
+ return Size(s.m_width / div, s.m_height / div);
+}
+
+typedef double real;
+typedef unsigned short ushort;
+class LIBSAMPLE_API SizeF
+{
+public:
+ SizeF(real width, real height) : m_width(width), m_height(height) {}
+ real width() { return m_width; }
+ real height() { return m_height; }
+ static inline ushort passTypedefOfUnsignedShort(ushort value) { return value; }
+private:
+ real m_width;
+ real m_height;
+};
+
+#endif // SIZE_H
+
diff --git a/sources/shiboken2/tests/libsample/sometime.cpp b/sources/shiboken2/tests/libsample/sometime.cpp
new file mode 100644
index 000000000..3038e26ca
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sometime.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sometime.h"
+#include <stdio.h>
+
+void
+Time::setTime()
+{
+ m_hour = 0;
+ m_minute = 0;
+ m_second = 0;
+ m_msec = 0;
+ m_is_null = true;
+}
+
+void
+Time::setTime(int h, int m, int s, int ms)
+{
+ m_hour = h;
+ m_minute = m;
+ m_second = s;
+ m_msec = ms;
+ m_is_null = false;
+}
+
+
+Time::NumArgs
+Time::somethingCompletelyDifferent()
+{
+ return ZeroArgs;
+}
+
+Time::NumArgs
+Time::somethingCompletelyDifferent(int h, int m, ImplicitConv ic, ObjectType* type)
+{
+ if (type)
+ return FourArgs;
+ if (ic.ctorEnum() == ImplicitConv::CtorThree && ic.objId() == -1)
+ return TwoArgs;
+ return ThreeArgs;
+}
+
+Str
+Time::toString() const
+{
+ if (m_is_null)
+ return Str();
+ char buffer[13];
+ sprintf(buffer, "%02d:%02d:%02d.%03d", m_hour, m_minute, m_second, m_msec);
+ return Str(buffer);
+}
+
+bool
+Time::operator==(const Time& other) const
+{
+ return m_hour == other.m_hour
+ && m_minute == other.m_minute
+ && m_second == other.m_second
+ && m_msec == other.m_msec
+ && m_is_null == other.m_is_null;
+}
+
+bool
+Time::operator!=(const Time& other) const
+{
+ return !operator==(other);
+}
+
+Time::operator Str() const
+{
+ return Time::toString();
+}
+
diff --git a/sources/shiboken2/tests/libsample/sometime.h b/sources/shiboken2/tests/libsample/sometime.h
new file mode 100644
index 000000000..5f2ccf88a
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/sometime.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SOMETIME_H
+#define SOMETIME_H
+
+#include "libsamplemacros.h"
+#include "str.h"
+#include "implicitconv.h"
+#include "objecttype.h"
+
+class LIBSAMPLE_API Time
+{
+public:
+ enum NumArgs {
+ ZeroArgs,
+ TwoArgs,
+ ThreeArgs,
+ FourArgs
+ };
+
+ Time()
+ : m_hour(0), m_minute(0), m_second(0), m_msec(0), m_is_null(true)
+ {}
+ Time(int h, int m, int s = 0, int ms = 0)
+ : m_hour(h), m_minute(m), m_second(s), m_msec(ms), m_is_null(false)
+ {}
+
+ ~Time() {}
+
+ inline bool isNull() const { return m_is_null; }
+
+ inline int hour() const { return m_hour; }
+ inline int minute() const { return m_minute; }
+ inline int second() const { return m_second; }
+ inline int msec() const { return m_msec; }
+
+ void setTime();
+ void setTime(int h, int m, int s = 0, int ms = 0);
+
+ // This one is completely different from the other methods in this class,
+ // it was added to give the overload decisor a really hard time with
+ // an value-type with implicit conversion and a default argument, and also
+ // an object-type, just because I feel like it.
+ NumArgs somethingCompletelyDifferent();
+ NumArgs somethingCompletelyDifferent(int h, int m,
+ ImplicitConv ic = ImplicitConv::CtorThree,
+ ObjectType* type = 0);
+
+ Str toString() const;
+ bool operator==(const Time& other) const;
+ bool operator!=(const Time& other) const;
+
+ // This cast operator must become an implicit conversion of Str.
+ operator Str() const;
+
+private:
+ int m_hour;
+ int m_minute;
+ int m_second;
+ int m_msec;
+
+ bool m_is_null;
+};
+
+#endif // SOMETIME_H
+
diff --git a/sources/shiboken2/tests/libsample/str.cpp b/sources/shiboken2/tests/libsample/str.cpp
new file mode 100644
index 000000000..f3be2591e
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/str.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "str.h"
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <sstream>
+
+using namespace std;
+
+Str::Str(const Str& s)
+{
+ init(s.cstring());
+}
+
+Str::Str(char c)
+{
+ char str[2] = { c, 0 };
+ init(str);
+}
+
+Str::Str(const char* cstr)
+{
+ init(cstr);
+}
+
+void
+Str::init(const char* cstr)
+{
+ if (cstr)
+ m_str = cstr;
+}
+
+Str::~Str()
+{
+}
+
+Str
+Str::arg(const Str& s) const
+{
+ size_t idx = m_str.find_first_of("%VAR");
+ if (idx == std::string::npos) {
+ return *this;
+ } else {
+ std::string result = m_str;
+ result.replace(idx, 4, s.m_str);
+ return result.c_str();
+ }
+}
+
+Str&
+Str::append(const Str& s)
+{
+ m_str += s.m_str;
+ return *this;
+}
+
+Str&
+Str::prepend(const Str& s)
+{
+ m_str = s.m_str + m_str;
+ return *this;
+}
+
+const char*
+Str::cstring() const
+{
+ return m_str.c_str();
+}
+
+int
+Str::toInt(bool* ok, int base) const
+{
+ bool my_ok;
+ int result = 0;
+ istringstream conv(m_str);
+ switch (base) {
+ case 8:
+ conv >> std::oct >> result;
+ break;
+ case 10:
+ conv >> std::dec >> result;
+ break;
+ case 16:
+ conv >> std::hex >> result;
+ break;
+ }
+ my_ok = istringstream::eofbit & conv.rdstate();
+ if (!my_ok)
+ result = 0;
+ if (ok)
+ *ok = my_ok;
+ return result;
+}
+
+void
+Str::show() const
+{
+ printf("%s", cstring());
+}
+
+char
+Str::get_char(int pos) const
+{
+ return m_str[pos];
+}
+
+bool
+Str::set_char(int pos, char ch)
+{
+ m_str[pos] = ch;
+ return true;
+}
+
+Str Str::operator+(int number) const
+{
+ ostringstream in;
+ in << m_str << number;
+ return in.str().c_str();
+}
+
+bool Str::operator==(const Str& other) const
+{
+ return m_str == other.m_str;
+}
+
+Str operator+(int number, const Str& str)
+{
+ ostringstream in;
+ in << number << str.m_str;
+ return in.str().c_str();
+}
+
+bool Str::operator<(const Str& other) const
+{
+ return m_str < other.m_str;
+}
+
+unsigned int strHash(const Str& str)
+{
+ unsigned int result = 0;
+ const std::string& cppStr = str.m_str;
+ std::string::const_iterator it = cppStr.begin();
+ for (; it != cppStr.end(); ++it)
+ result = 5 * result + *it;
+ return result;
+}
+
+void changePStr(PStr* pstr, const char* suffix)
+{
+ pstr->append(suffix);
+}
+
+void duplicatePStr(PStr* pstr)
+{
+ if (!pstr)
+ return;
+ pstr->append(*pstr);
+}
diff --git a/sources/shiboken2/tests/libsample/str.h b/sources/shiboken2/tests/libsample/str.h
new file mode 100644
index 000000000..9c1e8c0a8
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/str.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef STR_H
+#define STR_H
+#include <string>
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Str
+{
+public:
+ Str(const Str& s);
+ Str(char c);
+ Str(const char* cstr = "");
+ ~Str();
+
+ Str arg(const Str& s) const;
+
+ Str& append(const Str& s);
+ Str& prepend(const Str& s);
+
+ const char* cstring() const;
+ char get_char(int pos) const;
+ bool set_char(int pos, char ch);
+
+ int toInt(bool* ok = 0, int base = 10) const;
+
+ void show() const;
+
+ inline int size() const { return m_str.size(); }
+
+ // nonsense operator just to test reverse operators
+ Str operator+(int number) const;
+ bool operator==(const Str& other) const;
+ bool operator<(const Str& other) const;
+
+private:
+ void init(const char* cstr);
+ std::string m_str;
+
+ friend LIBSAMPLE_API Str operator+(int number, const Str& str);
+ friend LIBSAMPLE_API unsigned int strHash(const Str& str);
+};
+
+LIBSAMPLE_API Str operator+(int number, const Str& str);
+LIBSAMPLE_API unsigned int strHash(const Str& str);
+
+typedef Str PStr;
+LIBSAMPLE_API void changePStr(PStr* pstr, const char* suffix);
+LIBSAMPLE_API void duplicatePStr(PStr* pstr = 0);
+
+#endif // STR_H
diff --git a/sources/shiboken2/tests/libsample/strlist.cpp b/sources/shiboken2/tests/libsample/strlist.cpp
new file mode 100644
index 000000000..8956110d8
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/strlist.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "strlist.h"
+
+bool
+StrList::operator==(const std::list<Str>& other) const
+{
+ if (size() != other.size())
+ return false;
+ StrList::const_iterator this_it = begin();
+ StrList::const_iterator other_it = begin();
+ while (this_it != end()) {
+ if (!((*this_it) == (*other_it)))
+ return false;
+ ++this_it;
+ ++other_it;
+ }
+ return true;
+}
+
+Str
+StrList::join(const Str& sep) const
+{
+ Str result;
+ for (StrList::const_iterator it = begin(); it != end(); ++it) {
+ if (it != begin())
+ result.append(sep);
+ result.append(*it);
+ }
+ return result;
+}
diff --git a/sources/shiboken2/tests/libsample/strlist.h b/sources/shiboken2/tests/libsample/strlist.h
new file mode 100644
index 000000000..be908d5d5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/strlist.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef STRLIST_H
+#define STRLIST_H
+
+#include <list>
+#include "str.h"
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API StrList : public std::list<Str>
+{
+public:
+ enum CtorEnum {
+ NoParamsCtor,
+ StrCtor,
+ CopyCtor,
+ ListOfStrCtor
+ };
+
+ inline StrList() : m_ctorUsed(NoParamsCtor) {}
+ inline explicit StrList(const Str& str) : m_ctorUsed(StrCtor) { push_back(str); }
+ inline StrList(const StrList& lst) : std::list<Str>(lst), m_ctorUsed(CopyCtor) {}
+ inline StrList(const std::list<Str>& lst) : std::list<Str>(lst), m_ctorUsed(ListOfStrCtor) {}
+
+ inline void append(Str str) { push_back(str); }
+ Str join(const Str& sep) const;
+
+ bool operator==(const std::list<Str>& other) const;
+ inline bool operator!=(const std::list<Str>& other) const { return !(*this == other); }
+
+ CtorEnum constructorUsed() { return m_ctorUsed; }
+private:
+ CtorEnum m_ctorUsed;
+};
+
+typedef StrList PStrList;
+
+#endif // STRLIST_H
diff --git a/sources/shiboken2/tests/libsample/templateptr.cpp b/sources/shiboken2/tests/libsample/templateptr.cpp
new file mode 100644
index 000000000..571184776
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/templateptr.cpp
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "templateptr.h"
+
+void TemplatePtr::dummy(std::list<std::pair<BlackBox *, BlackBox *> > & items)
+{
+} \ No newline at end of file
diff --git a/sources/shiboken2/tests/libsample/templateptr.h b/sources/shiboken2/tests/libsample/templateptr.h
new file mode 100644
index 000000000..67e154b1c
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/templateptr.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEMPLATEPTR_H
+#define TEMPLATEPTR_H
+
+#include <utility>
+#include <list>
+#include "libsamplemacros.h"
+#include "blackbox.h"
+
+class LIBSAMPLE_API TemplatePtr
+{
+public:
+ void dummy(std::list<std::pair<BlackBox *, BlackBox *> > & items);
+};
+
+#endif
diff --git a/sources/shiboken2/tests/libsample/transform.cpp b/sources/shiboken2/tests/libsample/transform.cpp
new file mode 100644
index 000000000..951e2ca5b
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/transform.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2013 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "transform.h"
+
+#ifdef _WIN32
+#include <math.h>
+#include <float.h>
+static inline bool isfinite(double a) { return _finite(a); }
+#else
+#include <cmath>
+#endif
+
+using namespace std;
+
+Point applyHomogeneousTransform(
+ const Point& in,
+ double m11, double m12, double m13,
+ double m21, double m22, double m23,
+ double m31, double m32, double m33,
+ bool* okay)
+{
+ double x = m11 * in.x() + m12 * in.y() + m13;
+ double y = m21 * in.x() + m22 * in.y() + m23;
+ double w = m31 * in.x() + m32 * in.y() + m33;
+
+ if (isfinite(w) && fabs(w) > 1e-10)
+ {
+ if (okay)
+ *okay = true;
+ return Point(x / w, y / w);
+ }
+ else
+ {
+ if (okay)
+ *okay = false;
+ return Point();
+ }
+}
diff --git a/sources/shiboken2/tests/libsample/transform.h b/sources/shiboken2/tests/libsample/transform.h
new file mode 100644
index 000000000..fda5b33c5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/transform.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2013 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TRANSFORM_H
+#define TRANSFORM_H
+
+#include "point.h"
+
+#include "libsamplemacros.h"
+
+LIBSAMPLE_API Point
+applyHomogeneousTransform(
+ const Point& in,
+ double m11, double m12, double m13,
+ double m21, double m22, double m23,
+ double m31, double m32, double m33,
+ bool* okay);
+
+#endif // TRANSFORM_H
diff --git a/sources/shiboken2/tests/libsample/valueandvirtual.h b/sources/shiboken2/tests/libsample/valueandvirtual.h
new file mode 100644
index 000000000..54e8114b5
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/valueandvirtual.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VALUEANDVIRTUAL_H
+#define VALUEANDVIRTUAL_H
+
+class ValueAndVirtual
+{
+public:
+ ValueAndVirtual(int id) : m_id(id) {}
+ ValueAndVirtual(const ValueAndVirtual &other) { m_id = other.m_id; }
+
+ bool operator()(int id, int id2) { return id == id2; }
+
+ inline int id() { return m_id; }
+ virtual ~ValueAndVirtual() {};
+private:
+ int m_id;
+};
+
+#endif // VALUEANDVIRTUAL_H
+
diff --git a/sources/shiboken2/tests/libsample/virtualmethods.cpp b/sources/shiboken2/tests/libsample/virtualmethods.cpp
new file mode 100644
index 000000000..05b854e08
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/virtualmethods.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "virtualmethods.h"
+
+int VirtualDtor::dtor_called = 0;
+
+double
+VirtualMethods::virtualMethod0(Point pt, int val, Complex cpx, bool b)
+{
+ return (pt.x() * pt.y() * val) + cpx.imag() + ((int) b);
+}
+
+bool
+VirtualMethods::createStr(const char* text, Str*& ret)
+{
+ if (!text) {
+ ret = 0;
+ return false;
+ }
+
+ ret = new Str(text);
+ return true;
+}
+
+void
+VirtualMethods::getMargins(int* left, int* top, int* right, int* bottom) const
+{
+ *left = m_left;
+ *top = m_top;
+ *right = m_right;
+ *bottom = m_bottom;
+}
+
diff --git a/sources/shiboken2/tests/libsample/virtualmethods.h b/sources/shiboken2/tests/libsample/virtualmethods.h
new file mode 100644
index 000000000..5754d0d5d
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/virtualmethods.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VIRTUALMETHODS_H
+#define VIRTUALMETHODS_H
+
+#include "point.h"
+#include "complex.h"
+#include "str.h"
+
+#include "libsamplemacros.h"
+#include "strlist.h"
+
+class LIBSAMPLE_API VirtualMethods
+{
+public:
+ VirtualMethods(Str name = "VirtualMethods") : m_name(name)
+ {
+ m_left = m_top = m_right = m_bottom = 0;
+ }
+ virtual ~VirtualMethods() {}
+
+ virtual double virtualMethod0(Point pt, int val, Complex cpx, bool b);
+ double callVirtualMethod0(Point pt, int val, Complex cpx, bool b)
+ {
+ return virtualMethod0(pt, val, cpx, b);
+ }
+
+ // Binding modification: rename.
+ virtual int sum0(int a0, int a1, int a2) { return a0 + a1 + a2; }
+ int callSum0(int a0, int a1, int a2) { return sum0(a0, a1, a2); }
+
+ // Binding modification: set default value for the last argument.
+ virtual int sum1(int a0, int a1, int a2) { return a0 + a1 + a2; }
+ int callSum1(int a0, int a1, int a2) { return sum1(a0, a1, a2); }
+
+ // Binding modification: remove the last argument and set a default value for it.
+ virtual int sum2(int a0, int a1, int a2) { return a0 + a1 + a2; }
+ int callSum2(int a0, int a1, int a2) { return sum2(a0, a1, a2); }
+
+ // Binding modification: remove the second argument.
+ virtual int sum3(int a0, int a1, int a2) { return a0 + a1 + a2; }
+ int callSum3(int a0, int a1, int a2) { return sum3(a0, a1, a2); }
+
+ // Binding modification: remove the second argument and set its default
+ // value, then inject code on the binding reimplementation of the virtual
+ // (with a native inject-code) to sum the value of the removed
+ // argument to the first argument before the method is called.
+ virtual int sum4(int a0, int a1, int a2) { return a0 + a1 + a2; }
+ int callSum4(int a0, int a1, int a2) { return sum4(a0, a1, a2); }
+
+ // Binding modification: prepend a string to the results of a Python override.
+ virtual Str name() { return m_name; }
+ Str callName() { return name(); }
+
+ // Binding modification: code injection that calls the Python override by itself.
+ virtual void callMe() {}
+ void callCallMe() { callMe(); }
+
+ // Passing reference to pointers.
+ virtual bool createStr(const char* text, Str*& ret);
+ bool callCreateStr(const char* text, Str*& ret) { return createStr(text, ret); }
+
+ // Return a non-binded method
+ std::list<Str> callStrListToStdList(const StrList& strList) { return strListToStdList(strList); }
+ virtual std::list<Str> strListToStdList(const StrList& strList ) { return strList; }
+
+ void setMargins(int left, int top, int right, int bottom)
+ {
+ m_left = left;
+ m_top = top;
+ m_right = right;
+ m_bottom = bottom;
+ }
+ virtual void getMargins(int* left, int* top, int* right, int* bottom) const;
+ void callGetMargins(int* left, int* top, int* right, int* bottom) const
+ {
+ getMargins(left, top, right, bottom);
+ }
+
+ virtual int recursionOnModifiedVirtual(Str arg) const { return 0; }
+ int callRecursionOnModifiedVirtual(Str arg) const { return recursionOnModifiedVirtual(arg); }
+
+private:
+ Str m_name;
+ int m_left;
+ int m_top;
+ int m_right;
+ int m_bottom;
+};
+
+class LIBSAMPLE_API VirtualDaughter : public VirtualMethods
+{
+public:
+ VirtualDaughter() : VirtualMethods() {}
+ VirtualDaughter(Str name) : VirtualMethods(name) {}
+};
+
+class LIBSAMPLE_API VirtualDtor
+{
+public:
+ VirtualDtor() {}
+ virtual ~VirtualDtor() { dtor_called++; }
+
+ static VirtualDtor* create() { return new VirtualDtor(); }
+ static int dtorCalled() { return dtor_called; }
+ static void resetDtorCounter() { dtor_called = 0; }
+
+private:
+ static int dtor_called;
+};
+
+#endif // VIRTUALMETHODS_H
+
diff --git a/sources/shiboken2/tests/libsample/voidholder.h b/sources/shiboken2/tests/libsample/voidholder.h
new file mode 100644
index 000000000..228bbae3f
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/voidholder.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VOIDHOLDER_H
+#define VOIDHOLDER_H
+
+#include "libsamplemacros.h"
+
+class VoidHolder
+{
+public:
+ explicit VoidHolder(void* ptr = 0) : m_ptr(ptr) {}
+ ~VoidHolder() {}
+ inline void* voidPointer() { return m_ptr; }
+ inline static void* gimmeMeSomeVoidPointer()
+ {
+ static void* pointerToSomething = new VoidHolder();
+ return pointerToSomething;
+ }
+private:
+ void* m_ptr;
+};
+
+#endif // VOIDHOLDER_H
+
diff --git a/sources/shiboken2/tests/libsmart/CMakeLists.txt b/sources/shiboken2/tests/libsmart/CMakeLists.txt
new file mode 100644
index 000000000..66c27cdae
--- /dev/null
+++ b/sources/shiboken2/tests/libsmart/CMakeLists.txt
@@ -0,0 +1,11 @@
+project(libsmart)
+
+set(libsmart_SRC
+smart.cpp
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+add_definitions("-DLIBSMART_BUILD")
+add_library(libsmart SHARED ${libsmart_SRC})
+set_property(TARGET libsmart PROPERTY PREFIX "")
+
diff --git a/sources/shiboken2/tests/libsmart/libsmartmacros.h b/sources/shiboken2/tests/libsmart/libsmartmacros.h
new file mode 100644
index 000000000..e4166caff
--- /dev/null
+++ b/sources/shiboken2/tests/libsmart/libsmartmacros.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LIB_SMART_MACROS_H
+#define LIB_SMART_MACROS_H
+
+#if defined _WIN32 || defined __CYGWIN__
+ #if LIBSMART_BUILD
+ #define LIB_SMART_API __declspec(dllexport)
+ #else
+ #define LIB_SMART_API __declspec(dllimport)
+ #endif
+#else
+#if __GNUC__ >= 4
+ #define LIB_SMART_API __attribute__ ((visibility("default")))
+#else
+ #define LIB_SMART_API
+#endif
+#endif
+
+#endif
diff --git a/sources/shiboken2/tests/libsmart/smart.cpp b/sources/shiboken2/tests/libsmart/smart.cpp
new file mode 100644
index 000000000..28c9cf055
--- /dev/null
+++ b/sources/shiboken2/tests/libsmart/smart.cpp
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "smart.h"
+
+bool shouldPrint() {
+ return Registry::getInstance()->shouldPrint();
+}
+
+Obj::Obj() : m_integer(123), m_internalInteger(new Integer)
+{
+ Registry::getInstance()->add(this);
+ if (shouldPrint())
+ std::cout << "Object constructor " << this << '\n';
+}
+
+Obj::~Obj()
+{
+ Registry::getInstance()->remove(this);
+ delete m_internalInteger;
+ if (shouldPrint())
+ std::cout << "Object destructor " << this << '\n';
+}
+
+
+void Obj::printObj() {
+ if (shouldPrint()) {
+ std::cout << "integer value: " << m_integer
+ << " internal integer value: " << m_internalInteger->m_int << '\n';
+ }
+}
+
+
+SharedPtr<Obj> Obj::giveSharedPtrToObj()
+{
+ SharedPtr<Obj> o(new Obj);
+ return o;
+}
+
+SharedPtr<Integer> Obj::giveSharedPtrToInteger()
+{
+ SharedPtr<Integer> o(new Integer);
+ return o;
+}
+
+int Obj::takeSharedPtrToObj(SharedPtr<Obj> pObj)
+{
+ pObj->printObj();
+ return pObj->m_integer;
+}
+
+int Obj::takeSharedPtrToInteger(SharedPtr<Integer> pInt)
+{
+ pInt->printInteger();
+ return pInt->m_int;
+}
+
+Integer Obj::takeInteger(Integer val)
+{
+ return val;
+}
+
+Integer::Integer() : m_int(456)
+{
+ Registry::getInstance()->add(this);
+ if (shouldPrint())
+ std::cout << "Integer constructor " << this << '\n';
+}
+
+Integer::Integer(const Integer &other)
+{
+ Registry::getInstance()->add(this);
+ if (shouldPrint())
+ std::cout << "Integer copy constructor " << this << '\n';
+ m_int = other.m_int;
+}
+
+Integer &Integer::operator=(const Integer &other)
+{
+ Registry::getInstance()->add(this);
+ if (shouldPrint())
+ std::cout << "Integer operator= " << this << '\n';
+ m_int = other.m_int;
+ return *this;
+}
+
+Integer::~Integer()
+{
+ Registry::getInstance()->remove(this);
+ if (shouldPrint())
+ std::cout << "Integer destructor " << this << '\n';
+}
+
+void Integer::printInteger()
+{
+ if (shouldPrint())
+ std::cout << "Integer value for object " << this << " is " << m_int << '\n';
+}
+
+Registry *Registry::getInstance()
+{
+ static Registry registry;
+ return &registry;
+}
+
+Registry::Registry() : m_printStuff(false)
+{
+
+}
+
+void Registry::add(Obj *p)
+{
+ m_objects.push_back(p);
+}
+
+void Registry::add(Integer *p)
+{
+ m_integers.push_back(p);
+}
+
+void Registry::remove(Obj *p)
+{
+ m_objects.erase(std::remove(m_objects.begin(), m_objects.end(), p), m_objects.end());
+}
+
+void Registry::remove(Integer *p)
+{
+ m_integers.erase(std::remove(m_integers.begin(), m_integers.end(), p), m_integers.end());
+}
+
+int Registry::countObjects() const
+{
+ return static_cast<int>(m_objects.size());
+}
+
+int Registry::countIntegers() const
+{
+ return static_cast<int>(m_integers.size());
+}
+
+bool Registry::shouldPrint() const
+{
+ return m_printStuff;
+}
+
+void Registry::setShouldPrint(bool flag)
+{
+ m_printStuff = flag;
+}
diff --git a/sources/shiboken2/tests/libsmart/smart.h b/sources/shiboken2/tests/libsmart/smart.h
new file mode 100644
index 000000000..c6b0dbbca
--- /dev/null
+++ b/sources/shiboken2/tests/libsmart/smart.h
@@ -0,0 +1,210 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SMART_H
+#define SMART_H
+
+#include <algorithm>
+#include <iostream>
+#include <vector>
+
+#include "libsmartmacros.h"
+
+// Forward declarations.
+template <class T>
+class SharedPtr;
+class Integer;
+class Obj;
+
+LIB_SMART_API bool shouldPrint();
+
+// Used to track which C++ objects are alive.
+class LIB_SMART_API Registry {
+public:
+ static Registry *getInstance();
+
+ void add(Obj *p);
+ void add(Integer *p);
+ void remove(Obj *p);
+ void remove(Integer *p);
+ int countObjects() const;
+ int countIntegers() const;
+ bool shouldPrint() const;
+ void setShouldPrint(bool flag);
+
+protected:
+ Registry();
+
+private:
+ bool m_printStuff;
+ std::vector<Obj *> m_objects;
+ std::vector<Integer *> m_integers;
+};
+
+template <class T>
+class RefData {
+public:
+ RefData(T *ptr) : m_refCount(1), m_heldPtr(ptr) {}
+ ~RefData() { delete m_heldPtr; }
+ int inc() { return ++m_refCount; }
+ int dec() { return --m_refCount; }
+ int useCount() { return m_refCount; }
+ int m_refCount;
+ T *m_heldPtr;
+};
+
+template <class T>
+class SharedPtr {
+public:
+ SharedPtr() : m_refData(0) {
+ if (shouldPrint())
+ std::cout << "shared_ptr default constructor " << this << "\n";
+ }
+
+ SharedPtr(T *v)
+ {
+ if (shouldPrint())
+ std::cout << "shared_ptr constructor " << this << " with pointer " << v << "\n";
+ if (v)
+ m_refData = new RefData<T>(v);
+ }
+
+ SharedPtr(const SharedPtr<T> &other) : m_refData(other.m_refData)
+ {
+ if (shouldPrint())
+ std::cout << "shared_ptr copy constructor " << this << " with pointer "
+ << other.m_refData << "\n";
+ if (m_refData)
+ m_refData->inc();
+ }
+
+ SharedPtr<T> &operator=(const SharedPtr<T>& other)
+ {
+ if (this != &other) {
+ if (shouldPrint())
+ std::cout << "shared_ptr assignment operator " << this << " with pointer "
+ << other.m_refData << "\n";
+ if (m_refData && m_refData->dec() == 0)
+ delete m_refData;
+ m_refData = other.m_refData;
+ if (m_refData)
+ m_refData->inc();
+ }
+ return *this;
+ }
+
+ T *data() const
+ {
+ if (m_refData)
+ return m_refData->m_heldPtr;
+ return 0;
+ }
+
+ int useCount() const
+ {
+ if (m_refData)
+ return m_refData->useCount();
+ return 0;
+ }
+
+ void dummyMethod1()
+ {
+
+ }
+
+ T& operator*() const
+ {
+ // Crashes if smart pointer is empty (just like std::shared_ptr).
+ return *(m_refData->m_heldPtr);
+ }
+
+ T *operator->() const
+ {
+ if (m_refData)
+ return m_refData->m_heldPtr;
+ return 0;
+ }
+
+ bool operator!() const
+ {
+ return !m_refData || !m_refData->m_heldPtr;
+ }
+
+ bool isNull() const
+ {
+ return !m_refData || !m_refData->m_heldPtr;
+ }
+
+ operator bool() const
+ {
+ return m_refData && m_refData->m_heldPtr;
+ }
+
+ ~SharedPtr()
+ {
+ if (m_refData) {
+ if (shouldPrint())
+ std::cout << "shared_ptr destructor " << this << " remaining refcount "
+ << m_refData->useCount() - 1 << "\n";
+ }
+ if (m_refData && m_refData->dec() == 0)
+ delete m_refData;
+ }
+
+ RefData<T> *m_refData;
+};
+
+class LIB_SMART_API Integer {
+public:
+ Integer();
+ Integer(const Integer &other);
+ Integer &operator=(const Integer &other);
+ ~Integer();
+ void printInteger();
+ int m_int;
+};
+
+// Couldn't name it Object because it caused some namespace clashes.
+class LIB_SMART_API Obj {
+public:
+ Obj();
+ virtual ~Obj();
+
+ void printObj();
+ Integer takeInteger(Integer val);
+ SharedPtr<Obj> giveSharedPtrToObj();
+ SharedPtr<Integer> giveSharedPtrToInteger();
+ int takeSharedPtrToObj(SharedPtr<Obj> pObj);
+ int takeSharedPtrToInteger(SharedPtr<Integer> pInt);
+
+ int m_integer;
+ Integer *m_internalInteger;
+};
+
+#endif // SMART_H
+
diff --git a/sources/shiboken2/tests/minimalbinding/CMakeLists.txt b/sources/shiboken2/tests/minimalbinding/CMakeLists.txt
new file mode 100644
index 000000000..fb0b2cc74
--- /dev/null
+++ b/sources/shiboken2/tests/minimalbinding/CMakeLists.txt
@@ -0,0 +1,38 @@
+project(minimal)
+
+set(minimal_TYPESYSTEM
+${CMAKE_CURRENT_SOURCE_DIR}/typesystem_minimal.xml
+)
+
+set(minimal_SRC
+${CMAKE_CURRENT_BINARY_DIR}/minimal/minimal_module_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/minimal/obj_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/minimal/val_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/minimal/listuser_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/minimal/minbooluser_wrapper.cpp
+)
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/minimal-binding.txt.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/minimal-binding.txt" @ONLY)
+
+add_custom_command(OUTPUT ${minimal_SRC}
+COMMAND shiboken2 --project-file=${CMAKE_CURRENT_BINARY_DIR}/minimal-binding.txt ${GENERATOR_EXTRA_FLAGS}
+DEPENDS ${minimal_TYPESYSTEM} ${CMAKE_CURRENT_SOURCE_DIR}/global.h shiboken2
+WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+COMMENT "Running generator for 'minimal' test binding..."
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}
+ ${SBK_PYTHON_INCLUDE_DIR}
+ ${libminimal_SOURCE_DIR}
+ ${libshiboken_SOURCE_DIR})
+add_library(minimal MODULE ${minimal_SRC})
+set_property(TARGET minimal PROPERTY PREFIX "")
+if(WIN32)
+ set_property(TARGET minimal PROPERTY SUFFIX ".pyd")
+endif()
+target_link_libraries(minimal
+ libminimal
+ ${SBK_PYTHON_LIBRARIES}
+ libshiboken)
diff --git a/sources/shiboken2/tests/minimalbinding/global.h b/sources/shiboken2/tests/minimalbinding/global.h
new file mode 100644
index 000000000..93eb38ed5
--- /dev/null
+++ b/sources/shiboken2/tests/minimalbinding/global.h
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "obj.h"
+#include "val.h"
+#include "minbool.h"
+#include "listuser.h"
+#include "typedef.h"
diff --git a/sources/shiboken2/tests/minimalbinding/listuser_test.py b/sources/shiboken2/tests/minimalbinding/listuser_test.py
new file mode 100644
index 000000000..d3b7f01e7
--- /dev/null
+++ b/sources/shiboken2/tests/minimalbinding/listuser_test.py
@@ -0,0 +1,323 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from minimal import ListUser, Val, Obj
+from py3kcompat import IS_PY3K
+
+if IS_PY3K:
+ import functools
+ reduce = functools.reduce
+
+
+class ExtListUser(ListUser):
+ def __init__(self):
+ ListUser.__init__(self)
+
+ def createIntList(self, num):
+ return list(range(0, num * 2, 2))
+
+ def sumIntList(self, intList):
+ return sum(intList) * 2
+
+ def createMinBoolList(self, mb1, mb2):
+ return [not mb1, not mb2]
+
+ def oredMinBoolList(self, minBoolList):
+ return not reduce(lambda a, b: a|b, minBoolList)
+
+ def createValList(self, num):
+ return [Val(i) for i in range(0, num * 2, 2)]
+
+ def sumValList(self, valList):
+ return sum([val.valId() for val in valList]) * 2
+
+ def createObjList(self, o1, o2):
+ o1.setObjId(o1.objId() * 2)
+ o2.setObjId(o2.objId() * 2)
+ return [o1, o2]
+
+ def sumObjList(self, objList):
+ return sum([obj.objId() for obj in objList]) * 2
+
+ def createListOfIntLists(self, num):
+ return [self.createIntList(num)] * 4
+
+ def sumListOfIntLists(self, intListList):
+ return sum([sum(line) for line in intListList]) * 2
+
+
+class IntListConversionTest(unittest.TestCase):
+
+ def testCreateIntList(self):
+ num = 4
+ lu = ListUser()
+ lst = lu.createIntList(num)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), num)
+ for i in lst:
+ self.assertEqual(type(i), int)
+ self.assertEqual(lst, list(range(num)))
+ lst = lu.callCreateIntList(num)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), num)
+ for i in lst:
+ self.assertEqual(type(i), int)
+ self.assertEqual(lst, list(range(num)))
+
+ def testCreateIntListFromExtendedClass(self):
+ lu = ExtListUser()
+ num = 4
+ lst = lu.createIntList(num)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), num)
+ for i in lst:
+ self.assertEqual(type(i), int)
+ self.assertEqual(lst, list(range(0, num * 2, 2)))
+ lst = lu.callCreateIntList(num)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), num)
+ for i in lst:
+ self.assertEqual(type(i), int)
+ self.assertEqual(lst, list(range(0, num * 2, 2)))
+
+ def testSumIntList(self):
+ lu = ListUser()
+ lst = range(4)
+ self.assertEqual(lu.sumIntList(lst), sum(lst))
+ self.assertEqual(lu.callSumIntList(lst), sum(lst))
+
+ def testSumIntListFromExtendedClass(self):
+ lu = ExtListUser()
+ lst = range(4)
+ self.assertEqual(lu.sumIntList(lst), sum(lst) * 2)
+ self.assertEqual(lu.callSumIntList(lst), sum(lst) * 2)
+
+
+class MinBoolListConversionTest(unittest.TestCase):
+
+ def testCreateMinBoolList(self):
+ lu = ListUser()
+ lst = lu.createMinBoolList(True, False)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), 2)
+ for i in lst:
+ self.assertEqual(type(i), bool)
+ self.assertEqual(lst, [True, False])
+
+ lst = lu.callCreateMinBoolList(False, True)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), 2)
+ for i in lst:
+ self.assertEqual(type(i), bool)
+ self.assertEqual(lst, [False, True])
+
+ def testCreateMinBoolListFromExtendedClass(self):
+ lu = ExtListUser()
+ lst = lu.createMinBoolList(True, False)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), 2)
+ for i in lst:
+ self.assertEqual(type(i), bool)
+ self.assertEqual(lst, [False, True])
+
+ lst = lu.callCreateMinBoolList(False, True)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), 2)
+ for i in lst:
+ self.assertEqual(type(i), bool)
+ self.assertEqual(lst, [True, False])
+
+ def testOredMinBoolList(self):
+ lu = ListUser()
+ lst = [False, False, True]
+ self.assertTrue(lu.oredMinBoolList(lst))
+ self.assertTrue(lu.callOredMinBoolList(lst))
+ lst = [False, False, False]
+ self.assertFalse(lu.oredMinBoolList(lst))
+ self.assertFalse(lu.callOredMinBoolList(lst))
+
+ def testOredMinBoolListFromExtendedClass(self):
+ lu = ExtListUser()
+ lst = [False, False, True]
+ self.assertFalse(lu.oredMinBoolList(lst))
+ self.assertFalse(lu.callOredMinBoolList(lst))
+ lst = [False, False, False]
+ self.assertTrue(lu.oredMinBoolList(lst))
+ self.assertTrue(lu.callOredMinBoolList(lst))
+
+
+class ValListConversionTest(unittest.TestCase):
+
+ def testCreateValList(self):
+ num = 4
+ lu = ListUser()
+ lst = lu.createValList(num)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), num)
+ for i in lst:
+ self.assertEqual(type(i), Val)
+ self.assertEqual([val.valId() for val in lst], list(range(num)))
+ lst = lu.callCreateValList(num)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), num)
+ for i in lst:
+ self.assertEqual(type(i), Val)
+ self.assertEqual([val.valId() for val in lst], list(range(num)))
+
+ def testCreateValListFromExtendedClass(self):
+ lu = ExtListUser()
+ num = 4
+ lst = lu.createValList(num)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), num)
+ for i in lst:
+ self.assertEqual(type(i), Val)
+ self.assertEqual([val.valId() for val in lst], list(range(0, num * 2, 2)))
+ lst = lu.callCreateValList(num)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), num)
+ for i in lst:
+ self.assertEqual(type(i), Val)
+ self.assertEqual([val.valId() for val in lst], list(range(0, num * 2, 2)))
+
+ def testSumValList(self):
+ lu = ListUser()
+ lst = [Val(i) for i in range(4)]
+ self.assertEqual(lu.sumValList(lst), sum([val.valId() for val in lst]))
+ self.assertEqual(lu.callSumValList(lst), sum([val.valId() for val in lst]))
+
+ def testSumValListFromExtendedClass(self):
+ lu = ExtListUser()
+ lst = [Val(i) for i in range(4)]
+ self.assertEqual(lu.sumValList(lst), sum([val.valId() for val in lst]) * 2)
+ self.assertEqual(lu.callSumValList(lst), sum([val.valId() for val in lst]) * 2)
+
+
+class ObjListConversionTest(unittest.TestCase):
+
+ def testCreateObjList(self):
+ o1 = Obj(1)
+ o2 = Obj(2)
+ lu = ListUser()
+ lst = lu.createObjList(o1, o2)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), 2)
+ for i in lst:
+ self.assertEqual(type(i), Obj)
+ self.assertEqual(lst, [o1, o2])
+ self.assertEqual([obj.objId() for obj in lst], [1, 2])
+
+ lst = lu.callCreateObjList(o1, o2)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), 2)
+ for i in lst:
+ self.assertEqual(type(i), Obj)
+ self.assertEqual(lst, [o1, o2])
+ self.assertEqual([obj.objId() for obj in lst], [1, 2])
+
+ def testCreateObjListFromExtendedClass(self):
+ o1 = Obj(1)
+ o2 = Obj(2)
+ lu = ExtListUser()
+ lst = lu.createObjList(o1, o2)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), 2)
+ for i in lst:
+ self.assertEqual(type(i), Obj)
+ self.assertEqual(lst, [o1, o2])
+ self.assertEqual([obj.objId() for obj in lst], [2, 4])
+
+ lst = lu.callCreateObjList(o1, o2)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), 2)
+ for i in lst:
+ self.assertEqual(type(i), Obj)
+ self.assertEqual(lst, [o1, o2])
+ self.assertEqual([obj.objId() for obj in lst], [4, 8])
+
+ def testSumObjList(self):
+ lu = ListUser()
+ lst = [Obj(i) for i in list(range(4))]
+ self.assertEqual(lu.sumObjList(lst), sum([obj.objId() for obj in lst]))
+ self.assertEqual(lu.callSumObjList(lst), sum([obj.objId() for obj in lst]))
+
+ def testSumObjListFromExtendedClass(self):
+ lu = ExtListUser()
+ lst = [Obj(i) for i in list(range(4))]
+ self.assertEqual(lu.sumObjList(lst), sum([obj.objId() for obj in lst]) * 2)
+ self.assertEqual(lu.callSumObjList(lst), sum([obj.objId() for obj in lst]) * 2)
+
+
+class ListOfIntListConversionTest(unittest.TestCase):
+
+ def testCreateListOfIntLists(self):
+ num = 4
+ lu = ListUser()
+ lst = lu.createListOfIntLists(num)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), num)
+ for i in lst:
+ self.assertEqual(type(i), list)
+ self.assertEqual(i, list(range(num)))
+ for j in i:
+ self.assertEqual(type(j), int)
+ self.assertEqual(lst, [list(range(num))] * 4)
+
+ def testCreateListOfIntListsFromExtendedClass(self):
+ num = 4
+ lu = ExtListUser()
+ lst = lu.createListOfIntLists(num)
+ self.assertEqual(type(lst), list)
+ self.assertEqual(len(lst), num)
+ for i in lst:
+ self.assertEqual(type(i), list)
+ self.assertEqual(i, list(range(0, num * 2, 2)))
+ for j in i:
+ self.assertEqual(type(j), int)
+ self.assertEqual(lst, [list(range(0, num * 2, 2))] * 4)
+
+ def testSumListIntLists(self):
+ lu = ListUser()
+ lst = [range(4)] * 4
+ self.assertEqual(lu.sumListOfIntLists(lst), sum([sum(line) for line in [range(4)] * 4]))
+ self.assertEqual(lu.callSumListOfIntLists(lst), sum([sum(line) for line in [range(4)] * 4]))
+
+ def testSumListOfIntListsFromExtendedClass(self):
+ lu = ExtListUser()
+ lst = [range(4)] * 4
+ self.assertEqual(lu.sumListOfIntLists(lst), sum([sum(line) for line in [range(4)] * 4]) * 2)
+ self.assertEqual(lu.callSumListOfIntLists(lst), sum([sum(line) for line in [range(4)] * 4]) * 2)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/minimalbinding/minbool_test.py b/sources/shiboken2/tests/minimalbinding/minbool_test.py
new file mode 100644
index 000000000..b7830a79b
--- /dev/null
+++ b/sources/shiboken2/tests/minimalbinding/minbool_test.py
@@ -0,0 +1,64 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from minimal import MinBoolUser
+
+class DerivedMinBoolUser (MinBoolUser):
+ def returnMyselfVirtual(self):
+ return MinBoolUser()
+
+class MinBoolTest(unittest.TestCase):
+
+ def testMinBoolUser(self):
+ mbuTrue = MinBoolUser()
+ mbuFalse = MinBoolUser()
+ mbuTrue.setMinBool(True)
+ self.assertEqual(mbuFalse.minBool(), False)
+ self.assertEqual(mbuTrue.minBool(), True)
+ self.assertEqual(mbuTrue.callInvertedMinBool(), False)
+
+ self.assertEqual(mbuTrue.minBool() == True, True)
+ self.assertEqual(False == mbuFalse.minBool(), True)
+ self.assertEqual(mbuTrue.minBool() == mbuFalse.minBool(), False)
+
+ self.assertEqual(mbuFalse.minBool() != True, True)
+ self.assertEqual(True != mbuFalse.minBool(), True)
+ self.assertEqual(mbuTrue.minBool() != mbuFalse.minBool(), True)
+
+ def testVirtuals(self):
+ dmbu = DerivedMinBoolUser()
+ self.assertEqual(dmbu.invertedMinBool(), True)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/minimalbinding/minimal-binding.txt.in b/sources/shiboken2/tests/minimalbinding/minimal-binding.txt.in
new file mode 100644
index 000000000..85b139676
--- /dev/null
+++ b/sources/shiboken2/tests/minimalbinding/minimal-binding.txt.in
@@ -0,0 +1,15 @@
+[generator-project]
+
+generator-set = shiboken
+
+header-file = @CMAKE_CURRENT_SOURCE_DIR@/global.h
+typesystem-file = @minimal_TYPESYSTEM@
+
+output-directory = @CMAKE_CURRENT_BINARY_DIR@
+
+include-path = @libminimal_SOURCE_DIR@
+
+typesystem-path = @CMAKE_CURRENT_SOURCE_DIR@
+
+enable-parent-ctor-heuristic
+use-isnull-as-nb_nonzero
diff --git a/sources/shiboken2/tests/minimalbinding/obj_test.py b/sources/shiboken2/tests/minimalbinding/obj_test.py
new file mode 100644
index 000000000..bf00f1c92
--- /dev/null
+++ b/sources/shiboken2/tests/minimalbinding/obj_test.py
@@ -0,0 +1,114 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from minimal import Obj
+
+class ExtObj(Obj):
+ def __init__(self, objId):
+ Obj.__init__(self, objId)
+ self.virtual_method_called = False
+
+ def virtualMethod(self, val):
+ self.virtual_method_called = True
+ return not Obj.virtualMethod(self, val)
+
+ def passObjectType(self, obj):
+ obj.setObjId(obj.objId() + 1)
+ return obj
+
+ def passObjectTypeReference(self, obj):
+ obj.setObjId(obj.objId() + 1)
+ return obj
+
+
+class ObjTest(unittest.TestCase):
+
+ def testNormalMethod(self):
+ objId = 123
+ obj = Obj(objId)
+ self.assertEqual(obj.objId(), objId)
+
+ def testNormalMethodFromExtendedClass(self):
+ objId = 123
+ obj = ExtObj(objId)
+ self.assertEqual(obj.objId(), objId)
+
+ def testVirtualMethod(self):
+ obj = Obj(0)
+ even_number = 8
+ self.assertEqual(obj.virtualMethod(even_number), obj.callVirtualMethod(even_number))
+
+ def testVirtualMethodFromExtendedClass(self):
+ obj = ExtObj(0)
+ even_number = 8
+ self.assertEqual(obj.virtualMethod(even_number), obj.callVirtualMethod(even_number))
+ self.assertTrue(obj.virtual_method_called)
+
+ def testPassObjectType(self):
+ obj = Obj(0)
+ self.assertEqual(obj, obj.passObjectType(obj))
+ self.assertEqual(obj, obj.callPassObjectType(obj))
+
+ def testPassObjectTypeNone(self):
+ obj = Obj(0)
+ self.assertEqual(None, obj.passObjectType(None))
+ self.assertEqual(None, obj.callPassObjectType(None))
+
+ def testPassObjectTypeReference(self):
+ obj = Obj(0)
+ self.assertEqual(obj, obj.passObjectTypeReference(obj))
+ self.assertEqual(obj, obj.callPassObjectTypeReference(obj))
+
+ def testPassObjectTypeFromExtendedClass(self):
+ obj = ExtObj(0)
+ self.assertEqual(obj.objId(), 0)
+ sameObj = obj.passObjectType(obj)
+ self.assertEqual(obj, sameObj)
+ self.assertEqual(sameObj.objId(), 1)
+ sameObj = obj.callPassObjectType(obj)
+ self.assertEqual(obj, sameObj)
+ self.assertEqual(sameObj.objId(), 2)
+
+ def testPassObjectTypeReferenceFromExtendedClass(self):
+ obj = ExtObj(0)
+ self.assertEqual(obj.objId(), 0)
+ sameObj = obj.passObjectTypeReference(obj)
+ self.assertEqual(obj, sameObj)
+ self.assertEqual(sameObj.objId(), 1)
+ sameObj = obj.callPassObjectTypeReference(obj)
+ self.assertEqual(obj, sameObj)
+ self.assertEqual(sameObj.objId(), 2)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/minimalbinding/typedef_test.py b/sources/shiboken2/tests/minimalbinding/typedef_test.py
new file mode 100644
index 000000000..62df9cbea
--- /dev/null
+++ b/sources/shiboken2/tests/minimalbinding/typedef_test.py
@@ -0,0 +1,116 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from minimal import *
+from py3kcompat import IS_PY3K
+
+try:
+ import numpy as np
+except ImportError as e:
+ print(e)
+ np = None
+
+
+if IS_PY3K:
+ import functools
+ reduce = functools.reduce
+
+
+class TypedefTest(unittest.TestCase):
+
+ def setUp(self):
+ self.the_size = 8
+
+ def test_arrayFuncInt(self):
+ none = ()
+ full = range(self.the_size)
+ self.assertTrue(arrayFuncInt(none), "None is empty, arrayFuncInt should return true")
+ self.assertFalse(arrayFuncInt(full), "Full is NOT empty, arrayFuncInt should return false")
+
+ self.assertTrue(arrayFuncInt(np.array(none)), "None is empty, arrayFuncInt should return true")
+ self.assertFalse(arrayFuncInt(np.array(full)), "Full is NOT empty, arrayFuncInt should return false")
+
+ def test_arrayFuncIntTypedef(self):
+ none = ()
+ full = (1, 2, 3)
+ self.assertTrue(arrayFuncIntTypedef(none), "None is empty, arrayFuncIntTypedef should return true")
+ self.assertFalse(arrayFuncIntTypedef(full), "Full is NOT empty, arrayFuncIntTypedef should return false")
+
+ self.assertTrue(arrayFuncIntTypedef(np.array(none)), "None is empty, arrayFuncIntTypedef should return true")
+ self.assertFalse(arrayFuncIntTypedef(np.array(full)), "Full is NOT empty, arrayFuncIntTypedef should return false")
+
+ def test_arrayFuncIntReturn(self):
+ none = arrayFuncIntReturn(0)
+ full = arrayFuncIntReturn(self.the_size)
+ self.assertTrue((len(none) == 0), "none should be empty")
+ self.assertTrue((len(full) == self.the_size), "full should have " + str(self.the_size) + " elements")
+
+ def test_arrayFuncIntReturnTypedef(self):
+ none = arrayFuncIntReturnTypedef(0)
+ full = arrayFuncIntReturnTypedef(self.the_size)
+ self.assertTrue((len(none) == 0), "none should be empty")
+ self.assertTrue((len(full) == self.the_size), "full should have " + str(self.the_size) + " elements")
+
+ def test_arrayFunc(self):
+ none = ()
+ full = range(self.the_size)
+ self.assertTrue(arrayFunc(none), "None is empty, arrayFunc should return true")
+ self.assertFalse(arrayFunc(full), "Full is NOT empty, arrayFunc should return false")
+
+ self.assertTrue(arrayFunc(np.array(none)), "None is empty, arrayFunc should return true")
+ self.assertFalse(arrayFunc(np.array(full)), "Full is NOT empty, arrayFunc should return false")
+
+ def test_arrayFuncTypedef(self):
+ none = ()
+ full = (1, 2, 3)
+ self.assertTrue(arrayFuncTypedef(none), "None is empty, arrayFuncTypedef should return true")
+ self.assertFalse(arrayFuncTypedef(full), "Full is NOT empty, arrayFuncTypedef should return false")
+
+ self.assertTrue(arrayFuncTypedef(np.array(none)), "None is empty, arrayFuncTypedef should return true")
+ self.assertFalse(arrayFuncTypedef(np.array(full)), "Full is NOT empty, arrayFuncTypedef should return false")
+
+ def test_arrayFuncReturn(self):
+ none = arrayFuncReturn(0)
+ full = arrayFuncReturn(self.the_size)
+ self.assertTrue((len(none) == 0), "none should be empty")
+ self.assertTrue((len(full) == self.the_size), "full should have " + str(self.the_size) + " elements")
+
+ def test_arrayFuncReturnTypedef(self):
+ none = arrayFuncReturnTypedef(0)
+ full = arrayFuncReturnTypedef(self.the_size)
+ self.assertTrue((len(none) == 0), "none should be empty")
+ self.assertTrue((len(full) == self.the_size), "full should have " + str(self.the_size) + " elements")
+
+
+if __name__ == '__main__':
+ if np != None:
+ unittest.main()
diff --git a/sources/shiboken2/tests/minimalbinding/typesystem_minimal.xml b/sources/shiboken2/tests/minimalbinding/typesystem_minimal.xml
new file mode 100644
index 000000000..968b27c53
--- /dev/null
+++ b/sources/shiboken2/tests/minimalbinding/typesystem_minimal.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+<typesystem package="minimal">
+ <primitive-type name="bool"/>
+ <primitive-type name="int"/>
+
+ <primitive-type name="MinBool" target-lang-api-name="PyBool" default-constructor="MinBool(false)">
+ <include file-name="minbool.h" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ return PyBool_FromLong(%in.value());
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyBool" check="PyBool_Check(%in)">
+ %out = %OUTTYPE(%in == Py_True);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <container-type name="std::list" type="list">
+ <include file-name="list" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ PyObject* %out = PyList_New((int) %in.size());
+ %INTYPE::const_iterator it = %in.begin();
+ for (int idx = 0; it != %in.end(); ++it, ++idx) {
+ %INTYPE_0 cppItem(*it);
+ PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem));
+ }
+ return %out;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PySequence">
+ Shiboken::AutoDecRef seq(PySequence_Fast(%in, 0));
+ for (int i = 0; i &lt; PySequence_Fast_GET_SIZE(seq.object()); i++) {
+ PyObject* pyItem = PySequence_Fast_GET_ITEM(seq.object(), i);
+ %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem);
+ %out.push_back(cppItem);
+ }
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+
+ <object-type name="Obj"/>
+ <value-type name="Val">
+ <enum-type name="ValEnum"/>
+ </value-type>
+ <value-type name="ListUser"/>
+ <value-type name="MinBoolUser"/>
+
+ <container-type name="std::vector" type="vector">
+ <include file-name="vector" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ %INTYPE::size_type vectorSize = %in.size();
+ PyObject* %out = PyList_New((int) vectorSize);
+ for (%INTYPE::size_type idx = 0; idx &lt; vectorSize; ++idx) {
+ %INTYPE_0 cppItem(%in[idx]);
+ PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem));
+ }
+ return %out;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PySequence">
+ Shiboken::AutoDecRef seq(PySequence_Fast(%in, 0));
+ int vectorSize = PySequence_Fast_GET_SIZE(seq.object());
+ %out.reserve(vectorSize);
+ for (int idx = 0; idx &lt; vectorSize; ++idx ) {
+ PyObject* pyItem = PySequence_Fast_GET_ITEM(seq.object(), idx);
+ %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem);
+ %out.push_back(cppItem);
+ }
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+ <!-- Test wrapping of a typedef -->
+ <function signature="arrayFuncInt(std::vector&lt;int&gt;)" />
+ <!-- Note manual expansion of the typedef -->
+ <function signature="arrayFuncIntTypedef(std::vector&lt;int&gt;)" />
+
+ <function signature="arrayFuncIntReturn(int)" />
+ <function signature="arrayFuncIntReturnTypedef(int)" />
+
+ <!-- Test wrapping of a typedef of a typedef -->
+ <function signature="arrayFunc(std::vector&lt;int&gt;)" />
+ <!-- Note manual expansion of the typedef -->
+ <function signature="arrayFuncTypedef(std::vector&lt;int&gt;)" />
+
+ <function signature="arrayFuncReturn(int)" />
+ <function signature="arrayFuncReturnTypedef(int)" />
+</typesystem>
diff --git a/sources/shiboken2/tests/minimalbinding/val_test.py b/sources/shiboken2/tests/minimalbinding/val_test.py
new file mode 100644
index 000000000..97e4e4778
--- /dev/null
+++ b/sources/shiboken2/tests/minimalbinding/val_test.py
@@ -0,0 +1,115 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from minimal import Val
+
+
+class ExtVal(Val):
+ def __init__(self, valId):
+ Val.__init__(self, valId)
+
+ def passValueType(self, val):
+ return ExtVal(val.valId() + 1)
+
+ def passValueTypePointer(self, val):
+ val.setValId(val.valId() + 1)
+ return val
+
+ def passValueTypeReference(self, val):
+ val.setValId(val.valId() + 1)
+ return val
+
+
+class ValTest(unittest.TestCase):
+
+ def testNormalMethod(self):
+ valId = 123
+ val = Val(valId)
+ self.assertEqual(val.valId(), valId)
+
+ def testPassValueType(self):
+ val = Val(123)
+ val1 = val.passValueType(val)
+ self.assertNotEqual(val, val1)
+ self.assertEqual(val1.valId(), 123)
+ val2 = val.callPassValueType(val)
+ self.assertNotEqual(val, val2)
+ self.assertEqual(val2.valId(), 123)
+
+ def testPassValueTypePointer(self):
+ val = Val(0)
+ self.assertEqual(val, val.passValueTypePointer(val))
+ self.assertEqual(val, val.callPassValueTypePointer(val))
+
+ def testPassValueTypeReference(self):
+ val = Val(0)
+ self.assertEqual(val, val.passValueTypeReference(val))
+ self.assertEqual(val, val.callPassValueTypeReference(val))
+
+ def testPassAndReceiveEnumValue(self):
+ val = Val(0)
+ self.assertEqual(val.oneOrTheOtherEnumValue(Val.One), Val.Other)
+ self.assertEqual(val.oneOrTheOtherEnumValue(Val.Other), Val.One)
+
+ def testPassValueTypeFromExtendedClass(self):
+ val = ExtVal(0)
+ val1 = val.passValueType(val)
+ self.assertNotEqual(val, val1)
+ self.assertEqual(val1.valId(), val.valId() + 1)
+ val2 = val.callPassValueType(val)
+ self.assertNotEqual(val, val2)
+ self.assertEqual(val2.valId(), val.valId() + 1)
+
+ def testPassValueTypePointerFromExtendedClass(self):
+ val = ExtVal(0)
+ self.assertEqual(val.valId(), 0)
+ sameVal = val.passValueTypePointer(val)
+ self.assertEqual(val, sameVal)
+ self.assertEqual(sameVal.valId(), 1)
+ sameVal = val.callPassValueTypePointer(val)
+ self.assertEqual(val, sameVal)
+ self.assertEqual(sameVal.valId(), 2)
+
+ def testPassValueTypeReferenceFromExtendedClass(self):
+ val = ExtVal(0)
+ self.assertEqual(val.valId(), 0)
+ sameVal = val.passValueTypeReference(val)
+ self.assertEqual(val, sameVal)
+ self.assertEqual(sameVal.valId(), 1)
+ sameVal = val.callPassValueTypeReference(val)
+ self.assertEqual(val, sameVal)
+ self.assertEqual(sameVal.valId(), 2)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/otherbinding/CMakeLists.txt b/sources/shiboken2/tests/otherbinding/CMakeLists.txt
new file mode 100644
index 000000000..ac7178e5d
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/CMakeLists.txt
@@ -0,0 +1,48 @@
+project(other)
+
+set(other_TYPESYSTEM
+${CMAKE_CURRENT_SOURCE_DIR}/typesystem_other.xml
+)
+
+set(other_SRC
+${CMAKE_CURRENT_BINARY_DIR}/other/extendsnoimplicitconversion_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/number_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/otherderived_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/othermultiplederived_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/otherobjecttype_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/other_module_wrapper.cpp
+)
+
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/other-binding.txt.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/other-binding.txt" @ONLY)
+
+add_custom_command(OUTPUT ${other_SRC}
+COMMAND shiboken2 --project-file=${CMAKE_CURRENT_BINARY_DIR}/other-binding.txt ${GENERATOR_EXTRA_FLAGS}
+DEPENDS ${other_TYPESYSTEM} ${CMAKE_CURRENT_SOURCE_DIR}/global.h shiboken2
+WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+COMMENT "Running generator for 'other' test binding..."
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}
+ ${SBK_PYTHON_INCLUDE_DIR}
+ ${libother_SOURCE_DIR}
+ ${libsample_SOURCE_DIR}
+ ${libsample_SOURCE_DIR}/..
+ ${sample_BINARY_DIR}
+ ${sample_BINARY_DIR}/sample
+ ${libshiboken_SOURCE_DIR})
+add_library(other MODULE ${other_SRC})
+set_property(TARGET other PROPERTY PREFIX "")
+if(WIN32)
+ set_property(TARGET other PROPERTY SUFFIX ".pyd")
+endif()
+target_link_libraries(other
+ libother
+ libsample
+ ${SBK_PYTHON_LIBRARIES}
+ libshiboken)
+
+add_dependencies(other sample)
+
diff --git a/sources/shiboken2/tests/otherbinding/collector_external_operator_test.py b/sources/shiboken2/tests/otherbinding/collector_external_operator_test.py
new file mode 100644
index 000000000..328aec837
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/collector_external_operator_test.py
@@ -0,0 +1,58 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for Collector shift operators defined in other modules.'''
+
+import unittest
+
+from sample import Collector, ObjectType
+from other import OtherObjectType
+
+class CollectorOtherObjectType(unittest.TestCase):
+ '''Test cases for Collector << OtherObjectType'''
+
+ def testLShiftWithExpectedType(self):
+ '''Collector << ObjectType # libsample << operator'''
+ collector = Collector()
+ obj = ObjectType()
+ collector << obj
+ self.assertEqual(collector.items()[0], obj.identifier())
+
+ def testOtherReversal(self):
+ '''Collector << OtherObjectType # libother << operator'''
+ collector = Collector()
+ obj = OtherObjectType()
+ collector << obj
+ self.assertEqual(collector.items()[0], obj.identifier() * 2)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py b/sources/shiboken2/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py
new file mode 100755
index 000000000..5c3733dc2
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py
@@ -0,0 +1,73 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests calling NoImplicitConversion using a ExtendsNoImplicitConversion parameter,
+ being that the latter defines a new conversion operator for the former, and this one
+ has no implicit conversions.'''
+
+import unittest
+
+from sample import NoImplicitConversion
+from other import ExtendsNoImplicitConversion
+
+class ConversionOperatorForClassWithoutImplicitConversionsTest(unittest.TestCase):
+ '''Tests calling NoImplicitConversion constructor using a ExtendsNoImplicitConversion parameter.'''
+
+ def testNoImplicitConversion(self):
+ '''Basic test to see if the NoImplicitConversion is Ok.'''
+ obj = NoImplicitConversion(123)
+ # NoImplicitConversion.receivesNoImplicitConversionByValue(NoImplicitConversion)
+ self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByValue(obj))
+ # NoImplicitConversion.receivesNoImplicitConversionByPointer(NoImplicitConversion*)
+ self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByPointer(obj))
+ # NoImplicitConversion.receivesNoImplicitConversionByReference(NoImplicitConversion&)
+ self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByReference(obj))
+
+ def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByValue(self):
+ '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by value.'''
+ obj = ExtendsNoImplicitConversion(123)
+ self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByValue(obj))
+
+ def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByReference(self):
+ '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by reference.'''
+ obj = ExtendsNoImplicitConversion(123)
+ self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByReference(obj))
+
+ def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByPointer(self):
+ '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by pointer.
+ This should not be accepted, since pointers should not be converted.'''
+ obj = ExtendsNoImplicitConversion(123)
+ self.assertRaises(TypeError, NoImplicitConversion.receivesNoImplicitConversionByPointer, obj)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py b/sources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py
new file mode 100755
index 000000000..4acc53024
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py
@@ -0,0 +1,64 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for libsample's Point multiply operator defined in libother module.'''
+
+import unittest
+
+from sample import Point
+from other import Number
+
+class PointOperationsWithNumber(unittest.TestCase):
+ '''Test cases for libsample's Point multiply operator defined in libother module.'''
+
+ def testPointTimesInt(self):
+ '''sample.Point * int'''
+ pt1 = Point(2, 7)
+ num = 3
+ pt2 = Point(pt1.x() * num, pt1.y() * num)
+ self.assertEqual(pt1 * num, pt2)
+
+ def testIntTimesPoint(self):
+ '''int * sample.Point'''
+ pt1 = Point(2, 7)
+ num = 3
+ pt2 = Point(pt1.x() * num, pt1.y() * num)
+ self.assertEqual(num * pt1, pt2)
+
+ def testPointTimesNumber(self):
+ '''sample.Point * other.Number'''
+ pt = Point(2, 7)
+ num = Number(11)
+ self.assertEqual(pt * num, pt * 11)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/otherbinding/global.h b/sources/shiboken2/tests/otherbinding/global.h
new file mode 100644
index 000000000..cc6634ab4
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/global.h
@@ -0,0 +1,35 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "../samplebinding/global.h"
+#include "extendsnoimplicitconversion.h"
+#include "number.h"
+#include "otherderived.h"
+#include "otherobjecttype.h"
+#include "othermultiplederived.h"
+
diff --git a/sources/shiboken2/tests/otherbinding/module_reload_test.py b/sources/shiboken2/tests/otherbinding/module_reload_test.py
new file mode 100644
index 000000000..0f601d1a3
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/module_reload_test.py
@@ -0,0 +1,61 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import os
+import sys
+import shutil
+import unittest
+
+from py3kcompat import IS_PY3K
+
+if IS_PY3K:
+ from imp import reload
+
+orig_path = os.path.join(os.path.dirname(__file__))
+workdir = os.getcwd()
+src = os.path.join(orig_path, 'test_module_template.py')
+dst = os.path.join(workdir, 'test_module.py')
+shutil.copyfile(src, dst)
+sys.path.append(workdir)
+
+class TestModuleReloading(unittest.TestCase):
+
+ def testModuleReloading(self):
+ '''Test module reloading with on-the-fly modifications.'''
+ import test_module
+ for i in range(3):
+ oldObject = test_module.obj
+ self.assertTrue(oldObject is test_module.obj)
+ reload(test_module)
+ self.assertFalse(oldObject is test_module.obj)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/shiboken2/tests/otherbinding/new_ctor_operator_test.py b/sources/shiboken2/tests/otherbinding/new_ctor_operator_test.py
new file mode 100755
index 000000000..634106cea
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/new_ctor_operator_test.py
@@ -0,0 +1,56 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests calling Str constructor using a Number parameter, being that number defines a cast operator to Str.'''
+
+import unittest
+
+from sample import Str
+from other import Number
+
+class NewCtorOperatorTest(unittest.TestCase):
+ '''Tests calling Str constructor using a Number parameter, being that number defines a cast operator to Str.'''
+
+ def testNumber(self):
+ '''Basic test to see if the Number class is Ok.'''
+ value = 123
+ num = Number(value)
+ self.assertEqual(num.value(), value)
+
+ def testStrCtorWithNumberArgument(self):
+ '''Try to build a Str from 'sample' module with a Number argument from 'other' module.'''
+ value = 123
+ num = Number(value)
+ string = Str(num)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/otherbinding/objtypehashes_test.py b/sources/shiboken2/tests/otherbinding/objtypehashes_test.py
new file mode 100644
index 000000000..753aec1a1
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/objtypehashes_test.py
@@ -0,0 +1,53 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sample import *
+from other import *
+import shiboken2 as shiboken
+
+class TestHashFuncs (unittest.TestCase):
+
+ def testIt(self):
+ obj1 = HandleHolder()
+ obj2 = HandleHolder()
+
+ hash1 = hash(obj1)
+ hash2 = hash(obj2)
+ self.assertNotEqual(hash1, hash2)
+
+ # Now invalidate the object and test its hash. It shouldn't segfault.
+ shiboken.invalidate(obj1)
+
+ hash1_2 = hash(obj1)
+ self.assertEqual(hash1_2, hash1)
+
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/otherbinding/other-binding.txt.in b/sources/shiboken2/tests/otherbinding/other-binding.txt.in
new file mode 100644
index 000000000..a17b70fc1
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/other-binding.txt.in
@@ -0,0 +1,18 @@
+[generator-project]
+
+generator-set = shiboken
+
+header-file = @CMAKE_CURRENT_SOURCE_DIR@/global.h
+typesystem-file = @other_TYPESYSTEM@
+
+output-directory = @CMAKE_CURRENT_BINARY_DIR@
+
+include-path = @libother_SOURCE_DIR@
+include-path = @libsample_SOURCE_DIR@
+include-path = @libsample_SOURCE_DIR@/..
+
+typesystem-path = @CMAKE_CURRENT_SOURCE_DIR@
+typesystem-path = @sample_SOURCE_DIR@
+
+enable-parent-ctor-heuristic
+
diff --git a/sources/shiboken2/tests/otherbinding/otherderived_test.py b/sources/shiboken2/tests/otherbinding/otherderived_test.py
new file mode 100644
index 000000000..f6906c88a
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/otherderived_test.py
@@ -0,0 +1,120 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for OtherDerived class'''
+
+import sys
+import unittest
+
+from sample import Abstract, Derived
+from other import OtherDerived, Number
+
+class Multiple(Derived, Number):
+ def __init__(self):
+ Derived.__init__(self, 42)
+ Number.__init__(self, 42)
+
+ def testCall(self):
+ return True
+
+class OtherDeviant(OtherDerived):
+ def __init__(self):
+ OtherDerived.__init__(self)
+ self.pure_virtual_called = False
+ self.unpure_virtual_called = False
+
+ def pureVirtual(self):
+ self.pure_virtual_called = True
+
+ def unpureVirtual(self):
+ self.unpure_virtual_called = True
+
+ def className(self):
+ return 'OtherDeviant'
+
+class MultipleTest(unittest.TestCase):
+ '''Test case for Multiple derived class'''
+
+ def testConstructor(self):
+ o = Multiple()
+ self.assertTrue(isinstance(o, Multiple))
+ self.assertTrue(isinstance(o, Number))
+ self.assertTrue(isinstance(o, Derived))
+ del o
+
+ def testMethodCall(self):
+ o = Multiple()
+ self.assertTrue(o.id_(), 42)
+ self.assertTrue(o.value(), 42)
+ self.assertTrue(o.testCall())
+
+class OtherDerivedTest(unittest.TestCase):
+ '''Test case for OtherDerived class'''
+
+ def testParentClassMethodsAvailability(self):
+ '''Test if OtherDerived class really inherits its methods from parent.'''
+ inherited_methods = set(['callPureVirtual', 'callUnpureVirtual',
+ 'id_', 'pureVirtual', 'unpureVirtual'])
+ self.assertTrue(inherited_methods.issubset(dir(OtherDerived)))
+
+ def testReimplementedPureVirtualMethodCall(self):
+ '''Test if a Python override of a implemented pure virtual method is correctly called from C++.'''
+ d = OtherDeviant()
+ d.callPureVirtual()
+ self.assertTrue(d.pure_virtual_called)
+
+ def testReimplementedVirtualMethodCall(self):
+ '''Test if a Python override of a reimplemented virtual method is correctly called from C++.'''
+ d = OtherDeviant()
+ d.callUnpureVirtual()
+ self.assertTrue(d.unpure_virtual_called)
+
+ def testVirtualMethodCallString(self):
+ '''Test virtual method call returning string.'''
+ d = OtherDerived()
+ self.assertEqual(d.className(), 'OtherDerived')
+ self.assertEqual(d.getClassName(), 'OtherDerived')
+
+ def testReimplementedVirtualMethodCallReturningString(self):
+ '''Test if a Python override of a reimplemented virtual method is correctly called from C++.'''
+ d = OtherDeviant()
+ self.assertEqual(d.className(), 'OtherDeviant')
+ self.assertEqual(d.getClassName(), 'OtherDeviant')
+
+ def testCallToMethodWithAbstractArgument(self):
+ '''Call to method that expects an Abstract argument.'''
+ objId = 123
+ d = OtherDerived(objId)
+ self.assertEqual(Abstract.getObjectId(d), objId)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/otherbinding/test_module_template.py b/sources/shiboken2/tests/otherbinding/test_module_template.py
new file mode 100644
index 000000000..ddde85c2e
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/test_module_template.py
@@ -0,0 +1,40 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from other import *
+from sample import *
+
+
+class MyObjectType(ObjectType):
+ pass
+
+class MyOtherObjectType(OtherObjectType):
+ value = 10
+
+
+obj = MyObjectType()
diff --git a/sources/shiboken2/tests/otherbinding/typediscovery_test.py b/sources/shiboken2/tests/otherbinding/typediscovery_test.py
new file mode 100644
index 000000000..507c5be94
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/typediscovery_test.py
@@ -0,0 +1,64 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for type discovery'''
+
+import unittest
+
+from sample import Abstract, Base1, Derived, MDerived1, MDerived3, SonOfMDerived1
+from other import OtherMultipleDerived
+
+class TypeDiscoveryTest(unittest.TestCase):
+
+ def testPureVirtualsOfImpossibleTypeDiscovery(self):
+ a = Derived.triggerImpossibleTypeDiscovery()
+ self.assertEqual(type(a), Abstract)
+ # call some pure virtual method
+ a.pureVirtual()
+
+ def testAnotherImpossibleTypeDiscovery(self):
+ a = Derived.triggerAnotherImpossibleTypeDiscovery()
+ self.assertEqual(type(a), Derived)
+
+ def testMultipleInheritance(self):
+ obj = OtherMultipleDerived.createObject("Base1");
+ self.assertEqual(type(obj), Base1)
+ obj = OtherMultipleDerived.createObject("MDerived1");
+ self.assertEqual(type(obj), MDerived1)
+ obj = OtherMultipleDerived.createObject("SonOfMDerived1");
+ self.assertEqual(type(obj), SonOfMDerived1)
+ obj = OtherMultipleDerived.createObject("MDerived3");
+ self.assertEqual(type(obj), MDerived3)
+ obj = OtherMultipleDerived.createObject("OtherMultipleDerived");
+ self.assertEqual(type(obj), OtherMultipleDerived)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/otherbinding/typesystem_other.xml b/sources/shiboken2/tests/otherbinding/typesystem_other.xml
new file mode 100644
index 000000000..63ccdd518
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/typesystem_other.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<typesystem package="other">
+ <load-typesystem name="typesystem_sample.xml" generate="no" />
+
+ <object-type name="OtherObjectType" />
+ <object-type name="OtherDerived" />
+ <object-type name="OtherMultipleDerived" />
+
+ <value-type name="ExtendsNoImplicitConversion" />
+ <value-type name="Number" />
+
+ <suppress-warning text="signature 'operator!=(ByteArray,const char*)' for function modification in 'ByteArray' not found." />
+ <suppress-warning text="signature 'operator+(ByteArray,const char*)' for function modification in 'ByteArray' not found." />
+ <suppress-warning text="signature 'operator==(ByteArray,const char*)' for function modification in 'ByteArray' not found." />
+</typesystem>
diff --git a/sources/shiboken2/tests/otherbinding/usersprimitivefromothermodule_test.py b/sources/shiboken2/tests/otherbinding/usersprimitivefromothermodule_test.py
new file mode 100755
index 000000000..06cfce371
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/usersprimitivefromothermodule_test.py
@@ -0,0 +1,52 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests user defined primitive type from a required module.'''
+
+import unittest
+from other import Number
+
+class UserDefinedPrimitiveTypeFromRequiredModuleTest(unittest.TestCase):
+
+ def testUsersPrimitiveFromRequiredModuleAsArgument(self):
+ '''static Number Number::fromComplex(Complex)'''
+ cpx = complex(3.0, 1.2)
+ number = Number.fromComplex(cpx)
+ self.assertEqual(number.value(), int(cpx.real))
+
+ def testUsersPrimitiveFromRequiredModuleAsReturnValue(self):
+ '''Complex Number::toComplex()'''
+ number = Number(12)
+ cpx = number.toComplex()
+ self.assertEqual(number.value(), int(cpx.real))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/otherbinding/wrongctor_test.py b/sources/shiboken2/tests/otherbinding/wrongctor_test.py
new file mode 100644
index 000000000..61317fe66
--- /dev/null
+++ b/sources/shiboken2/tests/otherbinding/wrongctor_test.py
@@ -0,0 +1,53 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sample import *
+from other import *
+
+class Foo(OtherDerived):
+ def __init__(self):
+ Abstract.__init__(self, 2) # this should raise an exception
+
+class Foo2(ObjectType, OtherDerived):
+ def __init__(self):
+ ObjectType.__init__(self)
+ Abstract.__init__(self, 2) # this should raise an exception
+
+
+class WrongCtorTest(unittest.TestCase):
+ def testIt(self):
+ self.assertRaises(TypeError, Foo)
+ self.assertRaises(TypeError, Foo2)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/py3k.py b/sources/shiboken2/tests/py3k.py
new file mode 100644
index 000000000..5f2961a6a
--- /dev/null
+++ b/sources/shiboken2/tests/py3k.py
@@ -0,0 +1,2 @@
+def printToFile(f, str):
+ print(str, file=f)
diff --git a/sources/shiboken2/tests/py3kcompat.py b/sources/shiboken2/tests/py3kcompat.py
new file mode 100644
index 000000000..45550efb3
--- /dev/null
+++ b/sources/shiboken2/tests/py3kcompat.py
@@ -0,0 +1,54 @@
+# -*- 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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+
+IS_PY3K = sys.version_info[0] == 3
+
+if IS_PY3K:
+ def unicode(s):
+ return s
+
+ def b(s):
+ return bytes(s, "UTF8")
+
+ def l(n):
+ return n
+
+ long = int
+else:
+ def b(s):
+ return s
+
+ def l(n):
+ return long(n)
+
+ unicode = unicode
+ long = long
diff --git a/sources/shiboken2/tests/samplebinding/CMakeLists.txt b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
new file mode 100644
index 000000000..f897712f4
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
@@ -0,0 +1,145 @@
+project(sample)
+
+set(sample_TYPESYSTEM
+${CMAKE_CURRENT_SOURCE_DIR}/typesystem_sample.xml
+)
+
+set(sample_SRC
+${CMAKE_CURRENT_BINARY_DIR}/sample/abstractmodifications_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/abstract_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/base1_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/base2_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/base3_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/base4_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/base5_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/base6_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/blackbox_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/bytearray_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/bucket_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/classwithfunctionpointer_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/collector_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/color_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/ctorconvrule_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/cvlistuser_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/cvvaluetype_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/sbkdate_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/derived_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/derived_someinnerclass_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/echo_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/event_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/expression_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/friendofonlycopy_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/handleholder_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/implicitconv_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/implicitbase_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/implicittarget_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/intlist_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/sortedoverload_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/intwrapper_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/injectcode_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/listuser_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/mapuser_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/mderived1_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/mderived2_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/mderived3_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/mderived4_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/mderived5_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/modelindex_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/modifications_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/modifiedconstructor_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/noimplicitconversion_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/nondefaultctor_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objectmodel_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objecttype_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypebyvalue_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypeholder_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypederived_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypelayout_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypeptrlist_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypeoperators_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objectview_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objtypereference_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/oddbooluser_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/onlycopy_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/otherbase_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/overload_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/overload2_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/pairuser_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/pen_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/persistentmodelindex_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/photon_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/photon_base_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/photon_valueidentity_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/photon_valueduplicator_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/point_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/pointerholder_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/pointf_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/pointvaluelist_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/polygon_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/primitivestructpointerholder_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/privatector_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/privatedtor_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/protectedenumclass_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/protectednonpolymorphic_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/protectedpolymorphic_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/protectedpolymorphicdaughter_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/protectedpolymorphicgranddaughter_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/protectedproperty_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/protectedvirtualdestructor_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/rect_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/rectf_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/reference_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/referentmodelindex_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/sample_module_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/sample_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/sample_sample_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/samplenamespace_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/samplenamespace_someclass_someinnerclass_okthisisrecursiveenough_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/samplenamespace_someclass_someinnerclass_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/samplenamespace_someclass_someotherinnerclass_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/samplenamespace_someclass_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/samplenamespace_derivedfromnamespace_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/simplefile_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/size_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/sizef_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/sonofmderived1_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/str_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/strlist_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/time_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/templateptr_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/unremovednamespace_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/virtualdaughter_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/virtualdtor_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/virtualmethods_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/voidholder_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/valueandvirtual_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/filter_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/data_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/intersection_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/union_wrapper.cpp
+)
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sample-binding.txt.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/sample-binding.txt" @ONLY)
+
+add_custom_command(OUTPUT ${sample_SRC}
+COMMAND shiboken2 --project-file=${CMAKE_CURRENT_BINARY_DIR}/sample-binding.txt ${GENERATOR_EXTRA_FLAGS}
+DEPENDS ${sample_TYPESYSTEM} ${CMAKE_CURRENT_SOURCE_DIR}/global.h shiboken2
+WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+COMMENT "Running generator for 'sample' test binding..."
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}
+ ${SBK_PYTHON_INCLUDE_DIR}
+ ${libsample_SOURCE_DIR}
+ ${libshiboken_SOURCE_DIR})
+add_library(sample MODULE ${sample_SRC})
+set_property(TARGET sample PROPERTY PREFIX "")
+if(WIN32)
+ set_property(TARGET sample PROPERTY SUFFIX ".pyd")
+endif()
+target_link_libraries(sample
+ libsample
+ ${SBK_PYTHON_LIBRARIES}
+ libshiboken)
diff --git a/sources/shiboken2/tests/samplebinding/__del___test.py b/sources/shiboken2/tests/samplebinding/__del___test.py
new file mode 100644
index 000000000..fd787b5f0
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/__del___test.py
@@ -0,0 +1,50 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sample
+
+delCalled = False
+
+class MyObject(sample.ObjectType):
+ def __del__(self):
+ global delCalled
+ delCalled = True
+
+class TestDel(unittest.TestCase):
+ def testIt(self):
+ a = MyObject()
+ del a
+ self.assertTrue(delCalled)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/abstract_test.py b/sources/shiboken2/tests/samplebinding/abstract_test.py
new file mode 100644
index 000000000..46aad3260
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/abstract_test.py
@@ -0,0 +1,111 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for Abstract class'''
+
+import sys
+import unittest
+
+from sample import Abstract
+
+class Incomplete(Abstract):
+ def __init__(self):
+ Abstract.__init__(self)
+
+class Concrete(Abstract):
+ def __init__(self):
+ Abstract.__init__(self)
+ self.pure_virtual_called = False
+ self.unpure_virtual_called = False
+
+ def pureVirtual(self):
+ self.pure_virtual_called = True
+
+ def pureVirtualReturningVoidPtr(self):
+ return 42
+
+ def unpureVirtual(self):
+ self.unpure_virtual_called = True
+
+ def virtualGettingAEnum(self, enum):
+ self.virtual_getting_enum = True
+
+
+class AbstractTest(unittest.TestCase):
+ '''Test case for Abstract class'''
+
+ def testAbstractPureVirtualMethodAvailability(self):
+ '''Test if Abstract class pure virtual method was properly wrapped.'''
+ self.assertTrue('pureVirtual' in dir(Abstract))
+
+ def testAbstractInstanciation(self):
+ '''Test if instanciation of an abstract class raises the correct exception.'''
+ self.assertRaises(NotImplementedError, Abstract)
+
+ def testUnimplementedPureVirtualMethodCall(self):
+ '''Test if calling a pure virtual method raises the correct exception.'''
+ i = Incomplete()
+ self.assertRaises(NotImplementedError, i.pureVirtual)
+
+ def testPureVirtualReturningVoidPtrReturnValue(self):
+ '''Test if a pure virtual method returning void ptr can be properly reimplemented'''
+ # Note that the semantics of reimplementing the pure virtual method in
+ # Python and calling it from C++ is undefined until it's decided how to
+ # cast the Python data types to void pointers
+ c = Concrete()
+ self.assertEqual(c.pureVirtualReturningVoidPtr(),42)
+
+ def testReimplementedVirtualMethodCall(self):
+ '''Test if instanciation of an abstract class raises the correct exception.'''
+ i = Concrete()
+ self.assertRaises(NotImplementedError, i.callPureVirtual)
+
+ def testReimplementedVirtualMethodCall(self):
+ '''Test if a Python override of a virtual method is correctly called from C++.'''
+ c = Concrete()
+ c.callUnpureVirtual()
+ self.assertTrue(c.unpure_virtual_called)
+
+ def testImplementedPureVirtualMethodCall(self):
+ '''Test if a Python override of a pure virtual method is correctly called from C++.'''
+ c = Concrete()
+ c.callPureVirtual()
+ self.assertTrue(c.pure_virtual_called)
+
+ def testEnumParameterOnVirtualMethodCall(self):
+ '''testEnumParameterOnVirtualMethodCall'''
+ c = Concrete()
+ c.callVirtualGettingEnum(Abstract.Short)
+ self.assertTrue(c.virtual_getting_enum)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/addedfunction_test.py b/sources/shiboken2/tests/samplebinding/addedfunction_test.py
new file mode 100644
index 000000000..1620a5114
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/addedfunction_test.py
@@ -0,0 +1,62 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for added functions.'''
+
+import unittest
+from sample import SampleNamespace, ObjectType, Point
+
+class TestAddedFunctionsWithSimilarTypes(unittest.TestCase):
+ '''Adds new signatures very similar to already existing ones.'''
+
+ def testValueTypeReferenceAndValue(self):
+ '''In C++ we have "function(const ValueType&, double)",
+ in Python we add "function(ValueType)".'''
+ point = Point(10, 20)
+ multiplier = 4.0
+ control = (point.x() + point.y()) * multiplier
+ self.assertEqual(SampleNamespace.passReferenceToValueType(point, multiplier), control)
+ control = point.x() + point.y()
+ self.assertEqual(SampleNamespace.passReferenceToValueType(point), control)
+
+ def testObjectTypeReferenceAndPointer(self):
+ '''In C++ we have "function(const ObjectType&, int)",
+ in Python we add "function(ValueType)".'''
+ obj = ObjectType()
+ obj.setObjectName('sbrubbles')
+ multiplier = 3.0
+ control = len(obj.objectName()) * multiplier
+ self.assertEqual(SampleNamespace.passReferenceToObjectType(obj, multiplier), control)
+ control = len(obj.objectName())
+ self.assertEqual(SampleNamespace.passReferenceToObjectType(obj), control)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/addedfunction_with_container_args_test.py b/sources/shiboken2/tests/samplebinding/addedfunction_with_container_args_test.py
new file mode 100644
index 000000000..da2406698
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/addedfunction_with_container_args_test.py
@@ -0,0 +1,51 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for added functions with nested and multi-argument container types.'''
+
+import unittest
+from sample import sum2d, sumproduct
+
+class TestAddedFunctionsWithContainerArgs(unittest.TestCase):
+ '''Tests added functions with nested and multi-argument container types.'''
+
+ def testNestedContainerType(self):
+ '''Test added function with single-argument containers.'''
+ values = [[1,2],[3,4,5],[6]]
+ self.assertEqual(sum2d(values), 21)
+
+ def testMultiArgContainerType(self):
+ '''Test added function with a two-argument container.'''
+ values = [(1,2),(3,4),(5,6)]
+ self.assertEqual(sumproduct(values), 44)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/argumentmodifications_test.py b/sources/shiboken2/tests/samplebinding/argumentmodifications_test.py
new file mode 100644
index 000000000..90db99f91
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/argumentmodifications_test.py
@@ -0,0 +1,111 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for method arguments modifications performed as described on typesystem.'''
+
+import sys
+import unittest
+
+from sample import Modifications, Point
+
+class ArgumentModificationsTest(unittest.TestCase):
+ '''Test cases for method arguments modifications performed as described on typesystem.'''
+
+ def setUp(self):
+ self.mods = Modifications()
+
+ def tearDown(self):
+ del self.mods
+
+ def testArgRemoval0(self):
+ '''Tests argument removal modifications on Modifications.argRemoval0.'''
+ # void [-> PyObject*] argRemoval0(int, bool, int = 123 [removed, new val = 321], int = 456)
+ # code-injection: returns tuple with received parameters plus removed ones
+ a0, a1, a2 = 1, True, 2
+ self.assertEqual(self.mods.argRemoval0(a0, a1), (a0, a1, 321, 456))
+ self.assertEqual(self.mods.argRemoval0(a0, a1, a2), (a0, a1, 321, a2))
+ # the other wasn't modified
+ # void argRemoval0(int, bool, int, bool)
+ self.assertEqual(self.mods.argRemoval0(0, False, 0, False), None)
+
+ def testArgRemoval1(self):
+ '''Tests argument removal modifications on Modifications.argRemoval1.'''
+ # void [-> PyObject*] argRemoval1(int, bool, Point = Point(1, 2) [removed], Point = Point(3, 4) [removed], int = 333)
+ # code-injection: returns tuple with received parameters plus removed ones
+ a0, a1, a2 = 1, True, 2
+ self.assertEqual(self.mods.argRemoval1(a0, a1), (a0, a1, Point(1, 2), Point(3, 4), 333))
+ self.assertEqual(self.mods.argRemoval1(a0, a1, a2), (a0, a1, Point(1, 2), Point(3, 4), a2))
+ # the other wasn't modified
+ # void argRemoval1(int, bool, int, bool)
+ self.assertEqual(self.mods.argRemoval1(0, False, 0, False), None)
+
+ def testArgRemoval2(self):
+ '''Tests argument removal modifications on Modifications.argRemoval2.'''
+ # void [-> PyObject*] argRemoval2(int, bool, Point = Point(1, 2) [removed], Point = Point(3, 4) [removed], int = 333)
+ # code-injection: returns tuple with received parameters plus removed ones
+ a0, a1, a2 = 1, True, 2
+ self.assertEqual(self.mods.argRemoval2(a0, a1), (a0, a1, Point(1, 2), Point(3, 4), 333))
+ self.assertEqual(self.mods.argRemoval2(a0, a1, a2), (a0, a1, Point(1, 2), Point(3, 4), a2))
+
+ def testArgRemoval3(self):
+ '''Tests argument removal modifications on Modifications.argRemoval3.'''
+ # void [-> PyObject*] argRemoval3(int, Point = Point(1, 2) [removed], bool = true, Point = Point(3, 4) [removed], int = 333)
+ # code-injection: returns tuple with received parameters plus removed ones
+ a0, a1, a2 = 1, True, 2
+ self.assertEqual(self.mods.argRemoval3(a0), (a0, Point(1, 2), True, Point(3, 4), 333))
+ self.assertEqual(self.mods.argRemoval3(a0, a1), (a0, Point(1, 2), a1, Point(3, 4), 333))
+ self.assertEqual(self.mods.argRemoval3(a0, a1, a2), (a0, Point(1, 2), a1, Point(3, 4), a2))
+
+ def testArgRemoval4(self):
+ '''Tests argument removal modifications on Modifications.argRemoval4.'''
+ # void [-> PyObject*] argRemoval4(int, Point [removed, new val = Point(6, 9)], bool, Point = Point(3, 4) [removed], int = 333)
+ # code-injection: returns tuple with received parameters plus removed ones
+ a0, a1, a2 = 1, True, 2
+ self.assertRaises(TypeError, self.mods.argRemoval4, a0)
+ self.assertEqual(self.mods.argRemoval4(a0, a1), (a0, Point(6, 9), a1, Point(3, 4), 333))
+ self.assertEqual(self.mods.argRemoval4(a0, a1, a2), (a0, Point(6, 9), a1, Point(3, 4), a2))
+
+ def testArgRemoval5(self):
+ '''Tests argument removal modifications on Modifications.argRemoval5.'''
+ # void [-> PyObject*] argRemoval5(int [removed, new val = 100], bool,
+ # Point = Point(1, 2) [removed],
+ # Point = Point(3, 4) [removed], int = 333)
+ # code-injection: returns tuple with received parameters plus removed ones
+ a0, a1, a2 = True, 2, True
+ self.assertEqual(self.mods.argRemoval5(a0), (100, a0, Point(1, 2), Point(3, 4), 333))
+ self.assertEqual(self.mods.argRemoval5(a0, a1), (100, a0, Point(1, 2), Point(3, 4), a1))
+ # void [-> PyObject*] argRemoval5(int [removed, new val = 200], bool, int, bool)
+ # code-injection: returns tuple with received parameters plus removed ones
+ self.assertEqual(self.mods.argRemoval5(a0, a1, a2), (200, a0, a1, a2))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/bug_554_test.py b/sources/shiboken2/tests/samplebinding/bug_554_test.py
new file mode 100644
index 000000000..0bcce92cf
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/bug_554_test.py
@@ -0,0 +1,45 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit test for bug#554'''
+
+from sample import *
+
+class Bug554:
+ def crash(self):
+ class Crasher(ObjectType):
+ pass
+
+if __name__ == '__main__':
+ bug = Bug554()
+ bug.crash()
+
+
diff --git a/sources/shiboken2/tests/samplebinding/bug_704_test.py b/sources/shiboken2/tests/samplebinding/bug_704_test.py
new file mode 100644
index 000000000..6b393f3b1
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/bug_704_test.py
@@ -0,0 +1,68 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from py3kcompat import IS_PY3K
+
+from sample import ObjectType
+
+
+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.'''
+
+ 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__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/bytearray_bufferprotocol.cpp b/sources/shiboken2/tests/samplebinding/bytearray_bufferprotocol.cpp
new file mode 100644
index 000000000..39fb8d353
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/bytearray_bufferprotocol.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#if PY_VERSION_HEX < 0x03000000
+// ByteArray buffer protocol functions
+// See: http://www.python.org/dev/peps/pep-3118/
+extern "C" {
+static Py_ssize_t SbkByteArray_segcountproc(PyObject* self, Py_ssize_t* lenp)
+{
+ if (lenp)
+ *lenp = self->ob_type->tp_as_sequence->sq_length(self);
+ return 1;
+}
+static Py_ssize_t SbkByteArray_readbufferproc(PyObject* self, Py_ssize_t segment, void** ptrptr)
+{
+ if (segment || !Shiboken::Object::isValid(self))
+ return -1;
+
+ ByteArray* cppSelf = %CONVERTTOCPP[ByteArray*](self);
+ *ptrptr = reinterpret_cast<void*>(const_cast<char*>(cppSelf->data()));
+ return cppSelf->size();
+}
+PyBufferProcs SbkByteArrayBufferProc = {
+ /*bf_getreadbuffer*/ &SbkByteArray_readbufferproc,
+ /*bf_getwritebuffer*/ (writebufferproc)&SbkByteArray_readbufferproc,
+ /*bf_getsegcount*/ &SbkByteArray_segcountproc,
+ /*bf_getcharbuffer*/ (charbufferproc)&SbkByteArray_readbufferproc
+};
+}
+#endif
diff --git a/sources/shiboken2/tests/samplebinding/bytearray_test.py b/sources/shiboken2/tests/samplebinding/bytearray_test.py
new file mode 100644
index 000000000..0e8039469
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/bytearray_test.py
@@ -0,0 +1,151 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from os.path import isdir
+from sample import ByteArray
+from py3kcompat import b
+
+
+class ByteArrayBufferProtocolTest(unittest.TestCase):
+ '''Tests ByteArray implementation of Python buffer protocol.'''
+
+ def testByteArrayBufferProtocol(self):
+ # Tests ByteArray implementation of Python buffer protocol using the os.path.isdir
+ # function which an unicode object or other object implementing the Python buffer protocol.
+ isdir(str(ByteArray('/tmp')))
+
+
+class ByteArrayConcatenationOperatorTest(unittest.TestCase):
+ '''Test cases for ByteArray concatenation with '+' operator.'''
+
+ def testConcatByteArrayAndPythonString(self):
+ # Test concatenation of a ByteArray with a Python string, in this order.
+ ba = ByteArray('foo')
+ result = ba + '\x00bar'
+ self.assertEqual(type(result), ByteArray)
+ self.assertEqual(result, 'foo\x00bar')
+
+ def testConcatPythonStringAndByteArray(self):
+ # Test concatenation of a Python string with a ByteArray, in this order.
+ concat_python_string_add_qbytearray_worked = True
+ ba = ByteArray('foo')
+ result = 'bar\x00' + ba
+ self.assertEqual(type(result), ByteArray)
+ self.assertEqual(result, 'bar\x00foo')
+
+
+class ByteArrayOperatorEqual(unittest.TestCase):
+ '''TestCase for operator ByteArray == ByteArray.'''
+
+ def testDefault(self):
+ # ByteArray() == ByteArray()
+ obj1 = ByteArray()
+ obj2 = ByteArray()
+ self.assertEqual(obj1, obj2)
+
+ def testSimple(self):
+ # ByteArray(some_string) == ByteArray(some_string)
+ string = 'egg snakes'
+ self.assertEqual(ByteArray(string), ByteArray(string))
+
+ def testPyString(self):
+ # ByteArray(string) == string
+ string = 'my test string'
+ self.assertEqual(ByteArray(string), string)
+
+ def testQString(self):
+ # ByteArray(string) == string
+ string = 'another test string'
+ self.assertEqual(ByteArray(string), string)
+
+
+class ByteArrayOperatorAt(unittest.TestCase):
+ '''TestCase for operator ByteArray[]'''
+
+ def testInRange(self):
+ # ByteArray[x] where x is a valid index.
+ string = 'abcdefgh'
+ obj = ByteArray(string)
+ for i in range(len(string)):
+ self.assertEqual(obj[i], b(string[i]))
+
+ 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]))
+
+ def testOutOfRange(self):
+ # ByteArray[x] where x is out of index.
+ string = '1234567'
+ obj = ByteArray(string)
+ self.assertRaises(IndexError, lambda :obj[len(string)])
+
+ def testNullStrings(self):
+ ba = ByteArray('\x00')
+ self.assertEqual(ba.at(0), '\x00')
+ self.assertEqual(ba[0], b('\x00'))
+
+
+class ByteArrayOperatorLen(unittest.TestCase):
+ '''Test case for __len__ operator of ByteArray'''
+
+ def testBasic(self):
+ '''ByteArray __len__'''
+ self.assertEqual(len(ByteArray()), 0)
+ self.assertEqual(len(ByteArray('')), 0)
+ self.assertEqual(len(ByteArray(' ')), 1)
+ self.assertEqual(len(ByteArray('yabadaba')), 8)
+
+
+class ByteArrayAndPythonStr(unittest.TestCase):
+ '''Test case for __str__ operator of ByteArray'''
+
+ def testStrOperator(self):
+ '''ByteArray __str__'''
+ self.assertEqual(ByteArray().__str__(), '')
+ self.assertEqual(ByteArray('').__str__(), '')
+ self.assertEqual(ByteArray('aaa').__str__(), 'aaa')
+
+ def testPythonStrAndNull(self):
+ s1 = b('123\000321')
+ ba = ByteArray(s1)
+ s2 = ba.data()
+ self.assertEqual(s1, s2)
+ self.assertEqual(type(s1), type(s2))
+ self.assertEqual(s1, ba)
+ self.assertNotEqual(type(s1), type(ba))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/child_return_test.py b/sources/shiboken2/tests/samplebinding/child_return_test.py
new file mode 100644
index 000000000..30859dc5a
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/child_return_test.py
@@ -0,0 +1,58 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''The BlackBox class has cases of ownership transference between C++ and Python.'''
+
+import sys
+import unittest
+
+from sample import *
+
+class ReturnOfChildTest(unittest.TestCase):
+ '''The BlackBox class has cases of ownership transference between C++ and Python.'''
+
+ def testKillParentKeepingChild(self):
+ '''Ownership transference from Python to C++ and back again.'''
+ o1 = ObjectType.createWithChild()
+ child = o1.children()[0]
+ del o1
+ self.assertRaises(RuntimeError, child.objectName)
+
+ def testKillParentKeepingChild2(self):
+ '''Ownership transference from Python to C++ and back again.'''
+ o1 = ObjectType.createWithChild()
+ child = o1.findChild("child")
+ del o1
+ self.assertRaises(RuntimeError, child.objectName)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/class_fields_test.py b/sources/shiboken2/tests/samplebinding/class_fields_test.py
new file mode 100644
index 000000000..0a2491cf2
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/class_fields_test.py
@@ -0,0 +1,168 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Simple test case for accessing the exposed C++ class fields.'''
+
+from sys import getrefcount
+import unittest
+
+from sample import Derived, Point, ObjectType
+
+class TestAccessingCppFields(unittest.TestCase):
+ '''Simple test case for accessing the exposed C++ class fields.'''
+
+ def testAccessingPrimitiveTypeField(self):
+ '''Reads and writes a primitive type (in this case an 'int') field.'''
+ d = Derived()
+ self.assertEqual(type(d.primitiveField), int)
+
+ # attribution
+ old_value = d.primitiveField
+ new_value = 2255
+ d.primitiveField = new_value
+ self.assertEqual(d.primitiveField, new_value)
+ self.assertNotEqual(d.primitiveField, old_value)
+
+ # attribution with a convertible type
+ value = 1.2
+ d.primitiveField = value
+ self.assertEqual(d.primitiveField, int(value))
+
+ # attribution with invalid type
+ self.assertRaises(TypeError, lambda : setattr(d, 'primitiveField', None))
+
+ def testAccessingUsersPrimitiveTypeField(self):
+ '''Reads and writes an user's primitive type (in this case an 'Complex') field.'''
+ d = Derived()
+ self.assertEqual(type(d.userPrimitiveField), complex)
+
+ # attribution
+ old_value = d.userPrimitiveField
+ new_value = complex(1.1, 2.2)
+ d.userPrimitiveField = new_value
+ self.assertEqual(d.userPrimitiveField, new_value)
+ self.assertNotEqual(d.userPrimitiveField, old_value)
+
+ # attribution with invalid type
+ self.assertRaises(TypeError, lambda : setattr(d, 'userPrimitiveField', None))
+
+ def testAccessingValueTypeField(self):
+ '''Reads and writes a value type (in this case a 'Point') field.'''
+ d = Derived()
+ self.assertEqual(type(d.valueTypeField), Point)
+
+ # attribution
+ old_value = d.valueTypeField
+ new_value = Point(-10, 537)
+ d.valueTypeField = new_value
+ self.assertEqual(d.valueTypeField, new_value)
+
+ #object modify
+ d.valueTypeField.setX(10)
+ d.valueTypeField.setY(20)
+ self.assertEqual(d.valueTypeField.x(), 10)
+ self.assertEqual(d.valueTypeField.y(), 20)
+
+ # attribution with invalid type
+ self.assertRaises(TypeError, lambda : setattr(d, 'valueTypeField', 123))
+
+ def testAccessingObjectTypeField(self):
+ '''Reads and writes a object type (in this case an 'ObjectType') field.'''
+ d = Derived()
+
+ # attribution
+ old_value = d.objectTypeField
+ new_value = ObjectType()
+ d.objectTypeField = new_value
+ self.assertEqual(d.objectTypeField, new_value)
+ self.assertNotEqual(d.objectTypeField, old_value)
+
+ # attribution with a convertible type
+ value = None
+ d.objectTypeField = value
+ self.assertEqual(d.objectTypeField, value)
+
+ # attribution with invalid type
+ self.assertRaises(TypeError, lambda : setattr(d, 'objectTypeField', 123))
+
+ def testRefCountingAccessingObjectTypeField(self):
+ '''Accessing a object type field should respect the reference counting rules.'''
+ d = Derived()
+
+ # attributing object to instance's field should increase its reference count
+ o1 = ObjectType()
+ refcount1 = getrefcount(o1)
+ d.objectTypeField = o1
+ self.assertEqual(d.objectTypeField, o1)
+ self.assertEqual(getrefcount(d.objectTypeField), refcount1 + 1)
+
+ # attributing a new object to instance's field should decrease the previous object's reference count
+ o2 = ObjectType()
+ refcount2 = getrefcount(o2)
+ d.objectTypeField = o2
+ self.assertEqual(d.objectTypeField, o2)
+ self.assertEqual(getrefcount(o1), refcount1)
+ self.assertEqual(getrefcount(d.objectTypeField), refcount2 + 1)
+
+ def testRefCountingOfReferredObjectAfterDeletingReferrer(self):
+ '''Deleting the object referring to other object should decrease the reference count of the referee.'''
+ d = Derived()
+ o = ObjectType()
+ refcount = getrefcount(o)
+ d.objectTypeField = o
+ self.assertEqual(getrefcount(o), refcount + 1)
+ del d
+ self.assertEqual(getrefcount(o), refcount)
+
+ def testStaticField(self):
+ self.assertEqual(Derived.staticPrimitiveField, 0)
+
+ def testAccessingUnsignedIntBitField(self):
+ d = Derived()
+
+ # attribution
+ old_value = d.bitField
+ new_value = 1
+ d.bitField= new_value
+ self.assertEqual(d.bitField, new_value)
+ self.assertNotEqual(d.bitField, old_value)
+
+ # attribution with a convertible type
+ value = 1.2
+ d.bitField = value
+ self.assertEqual(d.bitField, int(value))
+
+ # attribution with invalid type
+ self.assertRaises(TypeError, lambda : setattr(d, 'bitField', None))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/collector_test.py b/sources/shiboken2/tests/samplebinding/collector_test.py
new file mode 100644
index 000000000..cbd6326e6
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/collector_test.py
@@ -0,0 +1,81 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for Collector class' shift operators.'''
+
+import sys
+import unittest
+
+from sample import Collector, IntWrapper, ObjectType
+
+
+class CollectorTest(unittest.TestCase):
+ '''Test cases for Collector class' shift operators.'''
+
+ def testLShiftOperatorSingleUse(self):
+ '''Test case for using the Collector.__lshift__ operator just one time.'''
+ collector = Collector()
+ collector << 13
+ self.assertEqual(collector.size(), 1)
+ self.assertEqual(collector.items(), [13])
+
+ def testLShiftOperatorMultipleUses(self):
+ '''Test case for using the Collector.__lshift__ operator many times in the same line.'''
+ collector = Collector()
+ collector << 2 << 3 << 5 << 7 << 11
+ self.assertEqual(collector.size(), 5)
+ self.assertEqual(collector.items(), [2, 3, 5, 7, 11])
+
+class CollectorExternalOperator(unittest.TestCase):
+ '''Test cases for external operators of Collector'''
+
+ def testLShiftExternal(self):
+ '''Collector external operator'''
+ collector = Collector()
+ collector << IntWrapper(5)
+ self.assertEqual(collector.size(), 1)
+ self.assertEqual(collector.items(), [5])
+
+
+class CollectorObjectType(unittest.TestCase):
+ '''Test cases for Collector ObjectType'''
+
+ def testBasic(self):
+ '''Collector << ObjectType # greedy collector'''
+ collector = Collector()
+ obj = ObjectType()
+ collector << obj
+ self.assertEqual(collector.items()[0], obj.identifier())
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/complex_test.py b/sources/shiboken2/tests/samplebinding/complex_test.py
new file mode 100644
index 000000000..3a14f4d15
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/complex_test.py
@@ -0,0 +1,84 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for Complex class'''
+
+import sys
+import unittest
+
+import sample
+from sample import Point
+
+class ComplexTest(unittest.TestCase):
+ '''Test case for conversions between C++ Complex class to Python complex class'''
+
+ def testFunctionReturningComplexObject(self):
+ '''Test function returning a C++ Complex object.'''
+ cpx = sample.transmutePointIntoComplex(Point(5.0, 2.3))
+ self.assertEqual(cpx, complex(5.0, 2.3))
+
+ def testFunctionReceivingComplexObjectAsArgument(self):
+ '''Test function returning a C++ Complex object.'''
+ pt = sample.transmuteComplexIntoPoint(complex(1.2, 3.4))
+ # these assertions intentionally avoids to test the == operator,
+ # it should have its own test cases.
+ self.assertEqual(pt.x(), 1.2)
+ self.assertEqual(pt.y(), 3.4)
+
+ def testComplexList(self):
+ '''Test list of C++ Complex objects conversion to a list of Python complex objects.'''
+ # the global function gimmeComplexList() is expected to return a list
+ # containing the following Complex values: [0j, 1.1+2.2j, 1.3+2.4j]
+ cpxlist = sample.gimmeComplexList()
+ self.assertEqual(cpxlist, [complex(), complex(1.1, 2.2), complex(1.3, 2.4)])
+
+ def testSumComplexPair(self):
+ '''Test sum of a tuple containing two complex objects.'''
+ cpx1 = complex(1.2, 3.4)
+ cpx2 = complex(5.6, 7.8)
+ self.assertEqual(sample.sumComplexPair((cpx1, cpx2)), cpx1 + cpx2)
+
+ def testUsingTuples(self):
+ cpx1, cpx2 = (1.2, 3.4), (5.6, 7.8)
+ self.assertEqual(sample.sumComplexPair((cpx1, cpx2)), sample.sumComplexPair((complex(*cpx1), complex(*cpx2))))
+ cpx1, cpx2 = (1, 3), (5, 7)
+ self.assertEqual(sample.sumComplexPair((cpx1, cpx2)), sample.sumComplexPair((complex(*cpx1), complex(*cpx2))))
+ cpx1, cpx2 = (1.2, 3), (5.6, 7)
+ self.assertEqual(sample.sumComplexPair((cpx1, cpx2)), sample.sumComplexPair((complex(*cpx1), complex(*cpx2))))
+ cpx1, cpx2 = (1, 2, 3), (4, 5, 7)
+ self.assertRaises(TypeError, sample.sumComplexPair, (cpx1, cpx2))
+ cpx1, cpx2 = ('1', '2'), ('4', '5')
+ self.assertRaises(TypeError, sample.sumComplexPair, (cpx1, cpx2))
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/conversion_operator_test.py b/sources/shiboken2/tests/samplebinding/conversion_operator_test.py
new file mode 100644
index 000000000..01ac102e8
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/conversion_operator_test.py
@@ -0,0 +1,55 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for implicit conversion generated by conversion operator.'''
+
+import unittest
+
+from sample import Time, StrList
+
+class ConversionOperatorTest(unittest.TestCase):
+ '''Test cases for implicit conversion generated by conversion operator.'''
+
+ def testConversionOperator(self):
+ '''Time defined an conversion operator for Str, so passing a Time object to a method expecting a Str should work.'''
+ t = Time(1, 2, 3)
+ t_str = t.toString()
+ sl = StrList()
+
+ # StrList.append expects a Str object.
+ sl.append(t)
+
+ self.assertEqual(len(sl), 1)
+ self.assertEqual(sl[0], t_str)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/copy_test.py b/sources/shiboken2/tests/samplebinding/copy_test.py
new file mode 100644
index 000000000..09c8e4cbc
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/copy_test.py
@@ -0,0 +1,86 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for deep copy of objects'''
+
+import copy
+import unittest
+
+try:
+ import cPickle as pickle
+except ImportError:
+ import pickle
+
+
+from sample import Point
+
+
+class SimpleCopy(unittest.TestCase):
+ '''Simple copy of objects'''
+
+ def testCopy(self):
+ point = Point(0.1, 2.4)
+ new_point = copy.copy(point)
+
+ self.assertTrue(point is not new_point)
+ self.assertEqual(point, new_point)
+
+
+class DeepCopy(unittest.TestCase):
+ '''Deep copy with shiboken objects'''
+
+ def testDeepCopy(self):
+ '''Deep copy of value types'''
+ point = Point(3.1, 4.2)
+ new_point = copy.deepcopy([point])[0]
+
+ self.assertTrue(point is not new_point)
+ self.assertEqual(point, new_point)
+
+
+class PicklingTest(unittest.TestCase):
+ '''Support pickling'''
+
+ def testSimple(self):
+ '''Simple pickling and unpickling'''
+
+ point = Point(10.2, 43.5)
+
+ data = pickle.dumps(point)
+ new_point = pickle.loads(data)
+
+ self.assertEqual(point, new_point)
+ self.assertTrue(point is not new_point)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/ctorconvrule_test.py b/sources/shiboken2/tests/samplebinding/ctorconvrule_test.py
new file mode 100644
index 000000000..d1ebdc9d3
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ctorconvrule_test.py
@@ -0,0 +1,49 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for proper generation of constructor altered by conversion-rule tag.'''
+
+import unittest
+
+from sample import CtorConvRule
+
+class TestCtorConvRule(unittest.TestCase):
+ '''Simple test case for CtorConvRule'''
+
+ def testCtorConvRule(self):
+ '''Test CtorConvRule argument modification through conversion-rule tag.'''
+ value = 123
+ obj = CtorConvRule(value)
+ self.assertEqual(obj.value(), value + 1)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/cyclic_test.py b/sources/shiboken2/tests/samplebinding/cyclic_test.py
new file mode 100644
index 000000000..e92b3605f
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/cyclic_test.py
@@ -0,0 +1,109 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sample import ObjectType
+from sample import ObjectView
+from sample import ObjectModel
+
+
+
+class ObjTest(unittest.TestCase):
+
+ def test_cyclic_dependency_withParent(self):
+ """Create 2 objects with a cyclic dependency, so that they can
+ only be removed by the garbage collector, and then invoke the
+ garbage collector in a different thread.
+ """
+ import gc
+
+ class CyclicChildObject(ObjectType):
+ def __init__(self, parent):
+ super(CyclicChildObject, self).__init__(parent)
+ self._parent = parent
+
+ class CyclicObject(ObjectType):
+ def __init__(self):
+ super(CyclicObject, self).__init__()
+ CyclicChildObject(self)
+
+ # turn off automatic garbage collection, to be able to trigger it
+ # at the 'right' time
+ gc.disable()
+ alive = lambda :sum(isinstance(o, CyclicObject) for o in gc.get_objects() )
+
+ #
+ # first proof that the wizard is only destructed by the garbage
+ # collector
+ #
+ cycle = CyclicObject()
+ self.assertTrue(alive())
+ del cycle
+ self.assertTrue(alive())
+ gc.collect()
+ self.assertFalse(alive())
+
+ def test_cyclic_dependency_withKeepRef(self):
+ """Create 2 objects with a cyclic dependency, so that they can
+ only be removed by the garbage collector, and then invoke the
+ garbage collector in a different thread.
+ """
+ import gc
+
+ class CyclicChildObject(ObjectView):
+ def __init__(self, model):
+ super(CyclicChildObject, self).__init__(None)
+ self.setModel(model)
+
+ class CyclicObject(ObjectModel):
+ def __init__(self):
+ super(CyclicObject, self).__init__()
+ self._view = CyclicChildObject(self)
+
+ # turn off automatic garbage collection, to be able to trigger it
+ # at the 'right' time
+ gc.disable()
+ alive = lambda :sum(isinstance(o, CyclicObject) for o in gc.get_objects() )
+
+ #
+ # first proof that the wizard is only destructed by the garbage
+ # collector
+ #
+ cycle = CyclicObject()
+ self.assertTrue(alive())
+ del cycle
+ self.assertTrue(alive())
+ gc.collect()
+ self.assertFalse(alive())
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/date_test.py b/sources/shiboken2/tests/samplebinding/date_test.py
new file mode 100644
index 000000000..800774a57
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/date_test.py
@@ -0,0 +1,58 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for python conversions types '''
+
+import sys
+import unittest
+from datetime import date
+
+from sample import SbkDate
+
+class DateConversionTest(unittest.TestCase):
+
+ def testConstructorWithDateObject(self):
+ pyDate = date(2010, 12, 12)
+ cDate = SbkDate(pyDate)
+ self.assertTrue(cDate.day(), pyDate.day)
+ self.assertTrue(cDate.month(), pyDate.month)
+ self.assertTrue(cDate.year(), pyDate.year)
+
+ def testToPythonFunction(self):
+ cDate = SbkDate(2010, 12, 12)
+ pyDate = cDate.toPython()
+ self.assertTrue(cDate.day(), pyDate.day)
+ self.assertTrue(cDate.month(), pyDate.month)
+ self.assertTrue(cDate.year(), pyDate.year)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/decisor_test.py b/sources/shiboken2/tests/samplebinding/decisor_test.py
new file mode 100644
index 000000000..33f41b9ff
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/decisor_test.py
@@ -0,0 +1,65 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for the method overload decisor.'''
+
+import unittest
+
+from sample import SampleNamespace, Point, ObjectType, ObjectModel
+
+class DecisorTest(unittest.TestCase):
+ '''Test cases for the method overload decisor.'''
+
+ def testCallWithInvalidParametersSideA(self):
+ '''Call a method missing with the last argument missing.
+ This can trigger the bug #262, which means using an argument
+ not provided by the user.'''
+ pt = Point()
+ self.assertRaises(TypeError, SampleNamespace.forceDecisorSideA, pt)
+
+ def testCallWithInvalidParametersSideB(self):
+ '''Same as the previous test, but with an integer as first argument,
+ just to complicate things for the overload method decisor.'''
+ pt = Point()
+ self.assertRaises(TypeError, SampleNamespace.forceDecisorSideB, 1, pt)
+
+ def testDecideCallWithInheritance(self):
+ '''Call methods overloads that receive parent and inheritor classes' instances.'''
+ objecttype = ObjectType()
+ objectmodel = ObjectModel()
+ self.assertEqual(ObjectModel.receivesObjectTypeFamily(objecttype), ObjectModel.ObjectTypeCalled)
+ self.assertNotEqual(ObjectModel.receivesObjectTypeFamily(objecttype), ObjectModel.ObjectModelCalled)
+ self.assertEqual(ObjectModel.receivesObjectTypeFamily(objectmodel), ObjectModel.ObjectModelCalled)
+ self.assertNotEqual(ObjectModel.receivesObjectTypeFamily(objectmodel), ObjectModel.ObjectTypeCalled)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/delete_test.py b/sources/shiboken2/tests/samplebinding/delete_test.py
new file mode 100644
index 000000000..bc20ea234
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/delete_test.py
@@ -0,0 +1,47 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sample
+import shiboken2 as shiboken
+
+class DeleteTest(unittest.TestCase):
+ def testNonCppWrapperClassDelete(self):
+ """Would segfault when shiboken.delete called on obj not created from
+ Python """
+ obj = sample.ObjectType()
+ child = obj.createChild(None)
+ shiboken.delete(child)
+ assert not shiboken.isValid(child)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/deprecated_test.py b/sources/shiboken2/tests/samplebinding/deprecated_test.py
new file mode 100644
index 000000000..6c850cd10
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/deprecated_test.py
@@ -0,0 +1,44 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import warnings
+import unittest
+
+from sample import ObjectType
+
+class TestDeprecatedCall(unittest.TestCase):
+ def testCallWithError(self):
+ o = ObjectType()
+ warnings.simplefilter('error')
+ self.assertRaises(DeprecationWarning, o.deprecatedFunction)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/derived_test.py b/sources/shiboken2/tests/samplebinding/derived_test.py
new file mode 100644
index 000000000..b19835fef
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/derived_test.py
@@ -0,0 +1,153 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for Derived class'''
+
+import sys
+import unittest
+
+import sample
+from sample import Abstract, Derived, OverloadedFuncEnum
+
+class Deviant(Derived):
+ def __init__(self):
+ Derived.__init__(self)
+ self.pure_virtual_called = False
+ self.unpure_virtual_called = False
+
+ def pureVirtual(self):
+ self.pure_virtual_called = True
+
+ def unpureVirtual(self):
+ self.unpure_virtual_called = True
+
+ def className(self):
+ return 'Deviant'
+
+class DerivedTest(unittest.TestCase):
+ '''Test case for Derived class'''
+
+ def testParentClassMethodsAvailability(self):
+ '''Test if Derived class really inherits its methods from parent.'''
+ inherited_methods = set(['callPureVirtual', 'callUnpureVirtual',
+ 'id_', 'pureVirtual', 'unpureVirtual'])
+ self.assertTrue(inherited_methods.issubset(dir(Derived)))
+
+ def testOverloadedMethodCall(self):
+ '''Test if the correct overloaded method is being called.'''
+ derived = Derived()
+
+ result = derived.overloaded(1, 2)
+ self.assertEqual(type(result), OverloadedFuncEnum)
+ self.assertEqual(result, sample.OverloadedFunc_ii)
+
+ result = derived.overloaded(3)
+ self.assertEqual(type(result), OverloadedFuncEnum)
+ self.assertEqual(result, sample.OverloadedFunc_ii)
+
+ result = derived.overloaded(4.4)
+ self.assertEqual(type(result), OverloadedFuncEnum)
+ self.assertEqual(result, sample.OverloadedFunc_d)
+
+ def testOtherOverloadedMethodCall(self):
+ '''Another test to check overloaded method calling, just to double check.'''
+ derived = Derived()
+
+ result = derived.otherOverloaded(1, 2, True, 3.3)
+ self.assertEqual(type(result), Derived.OtherOverloadedFuncEnum)
+ self.assertEqual(result, sample.Derived.OtherOverloadedFunc_iibd)
+
+ result = derived.otherOverloaded(1, 2.2)
+ self.assertEqual(type(result), Derived.OtherOverloadedFuncEnum)
+ self.assertEqual(result, Derived.OtherOverloadedFunc_id)
+
+ def testOverloadedMethodCallWithDifferentNumericTypes(self):
+ '''Test if the correct overloaded method accepts a different numeric type as argument.'''
+ derived = Derived()
+ result = derived.overloaded(1.1, 2.2)
+ self.assertEqual(type(result), OverloadedFuncEnum)
+ self.assertEqual(result, sample.OverloadedFunc_ii)
+
+ def testOverloadedMethodCallWithWrongNumberOfArguments(self):
+ '''Test if a call to an overloaded method with the wrong number of arguments raises an exception.'''
+ derived = Derived()
+ self.assertRaises(TypeError, derived.otherOverloaded, 1, 2, True)
+
+ def testReimplementedPureVirtualMethodCall(self):
+ '''Test if a Python override of a implemented pure virtual method is correctly called from C++.'''
+ d = Deviant()
+ d.callPureVirtual()
+ self.assertTrue(d.pure_virtual_called)
+
+ def testReimplementedVirtualMethodCall(self):
+ '''Test if a Python override of a reimplemented virtual method is correctly called from C++.'''
+ d = Deviant()
+ d.callUnpureVirtual()
+ self.assertTrue(d.unpure_virtual_called)
+
+ def testVirtualMethodCallString(self):
+ '''Test virtual method call returning string.'''
+ d = Derived()
+ self.assertEqual(d.className(), 'Derived')
+ self.assertEqual(d.getClassName(), 'Derived')
+
+ def testReimplementedVirtualMethodCallReturningString(self):
+ '''Test if a Python override of a reimplemented virtual method is correctly called from C++.'''
+ d = Deviant()
+ self.assertEqual(d.className(), 'Deviant')
+ self.assertEqual(d.getClassName(), 'Deviant')
+
+ def testSingleArgument(self):
+ '''Test singleArgument call.'''
+ d = Derived()
+ self.assertTrue(d.singleArgument(False))
+ self.assertTrue(not d.singleArgument(True))
+
+ def testMethodCallWithDefaultValue(self):
+ '''Test method call with default value.'''
+ d = Derived()
+ self.assertEqual(d.defaultValue(3), 3.1)
+ self.assertEqual(d.defaultValue(), 0.1)
+
+ def testCallToMethodWithAbstractArgument(self):
+ '''Call to method that expects an Abstract argument.'''
+ objId = 123
+ d = Derived(objId)
+ self.assertEqual(Abstract.getObjectId(d), objId)
+
+ def testObjectCreationWithParentType(self):
+ '''Derived class creates an instance of itself in C++ and returns it as a pointer to its ancestor Abstract.'''
+ obj = Derived.createObject()
+ self.assertEqual(type(obj), Derived)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/duck_punching_test.py b/sources/shiboken2/tests/samplebinding/duck_punching_test.py
new file mode 100644
index 000000000..fd60a96af
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/duck_punching_test.py
@@ -0,0 +1,176 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for virtual methods.'''
+
+import types
+import unittest
+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))
+
+class Duck(VirtualMethods):
+ def __init__(self):
+ VirtualMethods.__init__(self)
+
+class Monkey(SimpleFile):
+ def __init__(self, filename):
+ SimpleFile.__init__(self, filename)
+
+class DuckPunchingTest(unittest.TestCase):
+ '''Test case for duck punching (aka "monkey patching").'''
+
+ def setUp(self):
+ self.multiplier = 2.0
+ self.duck_method_called = False
+ self.call_counter = 0
+
+ def testMonkeyPatchOnVirtualMethod(self):
+ '''Injects new 'virtualMethod0' on a VirtualMethods instance and makes C++ call it.'''
+ vm = VirtualMethods()
+ pt, val, cpx, b = Point(1.1, 2.2), 4, complex(3.3, 4.4), True
+
+ result1 = vm.virtualMethod0(pt, val, cpx, b)
+ result2 = vm.callVirtualMethod0(pt, val, cpx, b)
+ self.assertEqual(result1, result2)
+ self.assertEqual(result1, VirtualMethods.virtualMethod0(vm, pt, val, cpx, b))
+
+ def myVirtualMethod0(obj, pt, val, cpx, b):
+ self.duck_method_called = True
+ return VirtualMethods.virtualMethod0(obj, pt, val, cpx, b) * self.multiplier
+ vm.virtualMethod0 = MethodTypeCompat(myVirtualMethod0, vm)
+
+ result1 = vm.callVirtualMethod0(pt, val, cpx, b)
+ self.assertTrue(self.duck_method_called)
+
+ result2 = vm.virtualMethod0(pt, val, cpx, b)
+ self.assertEqual(result1, result2)
+ self.assertEqual(result1, VirtualMethods.virtualMethod0(vm, pt, val, cpx, b) * self.multiplier)
+
+ # This is done to decrease the refcount of the vm object
+ # allowing the object wrapper to be deleted before the
+ # BindingManager. This is useful when compiling Shiboken
+ # for debug, since the BindingManager destructor has an
+ # assert that checks if the wrapper mapper is empty.
+ vm.virtualMethod0 = None
+
+ def testMonkeyPatchOnVirtualMethodWithInheritance(self):
+ '''Injects new 'virtualMethod0' on an object that inherits from VirtualMethods and makes C++ call it.'''
+ duck = Duck()
+ pt, val, cpx, b = Point(1.1, 2.2), 4, complex(3.3, 4.4), True
+
+ result1 = duck.virtualMethod0(pt, val, cpx, b)
+ result2 = duck.callVirtualMethod0(pt, val, cpx, b)
+ self.assertEqual(result1, result2)
+ self.assertEqual(result1, VirtualMethods.virtualMethod0(duck, pt, val, cpx, b))
+
+ def myVirtualMethod0(obj, pt, val, cpx, b):
+ self.duck_method_called = True
+ return VirtualMethods.virtualMethod0(obj, pt, val, cpx, b) * self.multiplier
+ duck.virtualMethod0 = MethodTypeCompat(myVirtualMethod0, duck)
+
+ result1 = duck.callVirtualMethod0(pt, val, cpx, b)
+ self.assertTrue(self.duck_method_called)
+
+ result2 = duck.virtualMethod0(pt, val, cpx, b)
+ self.assertEqual(result1, result2)
+ self.assertEqual(result1, VirtualMethods.virtualMethod0(duck, pt, val, cpx, b) * self.multiplier)
+
+ duck.virtualMethod0 = None
+
+ def testMonkeyPatchOnMethodWithStaticAndNonStaticOverloads(self):
+ '''Injects new 'exists' on a SimpleFile instance and makes C++ call it.'''
+ simplefile = SimpleFile('foobar')
+
+ # Static 'exists'
+ simplefile.exists('sbrubbles')
+ self.assertFalse(self.duck_method_called)
+ # Non-static 'exists'
+ simplefile.exists()
+ self.assertFalse(self.duck_method_called)
+
+ def myExists(obj):
+ self.duck_method_called = True
+ return False
+ simplefile.exists = MethodTypeCompat(myExists, simplefile)
+
+ # Static 'exists' was overridden by the monkey patch, which accepts 0 arguments
+ self.assertRaises(TypeError, simplefile.exists, 'sbrubbles')
+ # Monkey patched exists
+ simplefile.exists()
+ self.assertTrue(self.duck_method_called)
+
+ simplefile.exists = None
+
+ def testMonkeyPatchOnMethodWithStaticAndNonStaticOverloadsWithInheritance(self):
+ '''Injects new 'exists' on an object that inherits from SimpleFile and makes C++ call it.'''
+ monkey = Monkey('foobar')
+
+ # Static 'exists'
+ monkey.exists('sbrubbles')
+ self.assertFalse(self.duck_method_called)
+ # Non-static 'exists'
+ monkey.exists()
+ self.assertFalse(self.duck_method_called)
+
+ def myExists(obj):
+ self.duck_method_called = True
+ return False
+ monkey.exists = MethodTypeCompat(myExists, monkey)
+
+ # Static 'exists' was overridden by the monkey patch, which accepts 0 arguments
+ self.assertRaises(TypeError, monkey.exists, 'sbrubbles')
+ # Monkey patched exists
+ monkey.exists()
+ self.assertTrue(self.duck_method_called)
+
+ monkey.exists = None
+
+ def testForInfiniteRecursion(self):
+ def myVirtualMethod0(obj, pt, val, cpx, b):
+ self.call_counter += 1
+ return VirtualMethods.virtualMethod0(obj, pt, val, cpx, b)
+ vm = VirtualMethods()
+ vm.virtualMethod0 = MethodTypeCompat(myVirtualMethod0, vm)
+ pt, val, cpx, b = Point(1.1, 2.2), 4, complex(3.3, 4.4), True
+ vm.virtualMethod0(pt, val, cpx, b)
+ self.assertEqual(self.call_counter, 1)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/echo_test.py b/sources/shiboken2/tests/samplebinding/echo_test.py
new file mode 100644
index 000000000..1b0b6a2cc
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/echo_test.py
@@ -0,0 +1,52 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for <add-function> with const char* as argument'''
+
+import unittest
+
+from sample import Echo
+
+class TestEcho(unittest.TestCase):
+ '''Simple test case for Echo.echo'''
+
+ def testEcho(self):
+ '''Test function added with const char * as arg'''
+ x = 'Foobar'
+ y = Echo().echo(x)
+ self.assertEqual(x, y)
+
+ def testCallOperator(self):
+ e = Echo()
+ self.assertEqual(e("Hello", 3), "Hello3");
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/enum_test.py b/sources/shiboken2/tests/samplebinding/enum_test.py
new file mode 100644
index 000000000..6468d3cc4
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/enum_test.py
@@ -0,0 +1,168 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for Python representation of C++ enums.'''
+
+import os
+import sys
+import unittest
+
+import sample
+from sample import SampleNamespace, ObjectType, Event
+from py3kcompat import IS_PY3K, b
+
+def createTempFile():
+ if sys.version_info >= (2, 6):
+ import tempfile
+ return tempfile.SpooledTemporaryFile(mode='rw')
+ else:
+ return os.tmpfile()
+
+class EnumTest(unittest.TestCase):
+ '''Test case for Python representation of C++ enums.'''
+
+ def testEnumRepr(self):
+ enum = SampleNamespace.Option(1)
+ self.assertEqual(eval(repr(enum)), enum)
+
+ enum = SampleNamespace.Option(999)
+ self.assertEqual(eval(repr(enum)), enum)
+
+ def testHashability(self):
+ self.assertEqual(hash(SampleNamespace.TwoIn), hash(SampleNamespace.TwoOut))
+ self.assertNotEqual(hash(SampleNamespace.TwoIn), hash(SampleNamespace.OneIn))
+
+ def testEnumValuesInsideEnum(self):
+ '''Enum values should be accessible inside the enum as well as outside.'''
+ for value_name in SampleNamespace.Option.values:
+ enum_item1 = getattr(SampleNamespace.Option, value_name)
+ enum_item2 = getattr(SampleNamespace, value_name)
+ self.assertEqual(enum_item1, enum_item2)
+
+ def testPassingIntegerOnEnumArgument(self):
+ '''Tries to use an integer in place of an enum argument.'''
+ self.assertRaises(TypeError, SampleNamespace.getNumber, 1)
+
+ def testBuildingEnumFromIntegerValue(self):
+ '''Tries to build the proper enum using an integer.'''
+ SampleNamespace.getNumber(SampleNamespace.Option(1))
+
+ def testBuildingEnumWithDefaultValue(self):
+ '''Enum constructor with default value'''
+ enum = SampleNamespace.Option()
+ self.assertEqual(enum, SampleNamespace.None_)
+
+ def testEnumConversionToAndFromPython(self):
+ '''Conversion of enum objects from Python to C++ back again.'''
+ enumout = SampleNamespace.enumInEnumOut(SampleNamespace.TwoIn)
+ self.assertTrue(enumout, SampleNamespace.TwoOut)
+ self.assertEqual(repr(enumout), repr(SampleNamespace.TwoOut))
+
+ def testEnumConstructorWithTooManyParameters(self):
+ '''Calling the constructor of non-extensible enum with the wrong number of parameters.'''
+ self.assertRaises(TypeError, SampleNamespace.InValue, 13, 14)
+
+ def testEnumConstructorWithNonNumberParameter(self):
+ '''Calling the constructor of non-extensible enum with a string.'''
+ self.assertRaises(TypeError, SampleNamespace.InValue, '1')
+
+ def testEnumItemAsDefaultValueToIntArgument(self):
+ '''Calls function with an enum item as default value to an int argument.'''
+ self.assertEqual(SampleNamespace.enumItemAsDefaultValueToIntArgument(), SampleNamespace.ZeroIn)
+ self.assertEqual(SampleNamespace.enumItemAsDefaultValueToIntArgument(SampleNamespace.ZeroOut), SampleNamespace.ZeroOut)
+ self.assertEqual(SampleNamespace.enumItemAsDefaultValueToIntArgument(123), 123)
+
+ def testAnonymousGlobalEnums(self):
+ '''Checks availability of anonymous global enum items.'''
+ self.assertEqual(sample.AnonymousGlobalEnum_Value0, 0)
+ self.assertEqual(sample.AnonymousGlobalEnum_Value1, 1)
+
+ def testAnonymousClassEnums(self):
+ '''Checks availability of anonymous class enum items.'''
+ self.assertEqual(SampleNamespace.AnonymousClassEnum_Value0, 0)
+ self.assertEqual(SampleNamespace.AnonymousClassEnum_Value1, 1)
+
+ 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__
+ tmpfile.seek(0)
+ text = tmpfile.read().strip()
+ tmpfile.close()
+ self.assertEqual(text, str(Event.ANY_EVENT))
+ self.assertEqual(text, repr(Event.ANY_EVENT))
+
+ def testEnumArgumentWithDefaultValue(self):
+ '''Option enumArgumentWithDefaultValue(Option opt = UnixTime);'''
+ self.assertEqual(SampleNamespace.enumArgumentWithDefaultValue(), SampleNamespace.UnixTime)
+ self.assertEqual(SampleNamespace.enumArgumentWithDefaultValue(SampleNamespace.RandomNumber), SampleNamespace.RandomNumber)
+
+
+class MyEvent(Event):
+ def __init__(self):
+ Event.__init__(self, Event.EventType(999))
+
+class OutOfBoundsTest(unittest.TestCase):
+ def testValue(self):
+ e = MyEvent()
+ self.assertEqual(repr(e.eventType()), 'sample.Event.EventType(999)')
+
+ def testNoneName(self):
+ e = MyEvent()
+ t = e.eventType()
+ self.assertEqual(t.name, None)
+
+class EnumOverloadTest(unittest.TestCase):
+ '''Test case for overloads involving enums'''
+
+ def testWithInt(self):
+ '''Overload with Enums and ints with default value'''
+ o = ObjectType()
+
+ self.assertEqual(o.callWithEnum('', Event.ANY_EVENT, 9), 81)
+ self.assertEqual(o.callWithEnum('', 9), 9)
+
+class EnumOperators(unittest.TestCase):
+ '''Test case for operations on enums'''
+
+ def testInequalitySameObject(self):
+ self.assertFalse(Event.ANY_EVENT != Event.ANY_EVENT)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py b/sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py
new file mode 100644
index 000000000..820e21f7c
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py
@@ -0,0 +1,53 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+import sample
+
+class TestEnumFromRemovedNamespace(unittest.TestCase):
+ def testEnumPromotedToGlobal(self):
+ sample.RemovedNamespace1_Enum
+ sample.RemovedNamespace1_Enum_Value0
+ sample.RemovedNamespace1_AnonymousEnum_Value0
+ sample.RemovedNamespace2_Enum
+ sample.RemovedNamespace2_Enum_Value0
+
+ def testEnumPromotedToUpperNamespace(self):
+ sample.UnremovedNamespace
+ sample.UnremovedNamespace.RemovedNamespace3_Enum
+ sample.UnremovedNamespace.RemovedNamespace3_Enum_Value0
+ sample.UnremovedNamespace.RemovedNamespace3_AnonymousEnum_Value0
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/event_loop_call_virtual_test.py b/sources/shiboken2/tests/samplebinding/event_loop_call_virtual_test.py
new file mode 100644
index 000000000..d8ed028c4
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/event_loop_call_virtual_test.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Simple event loop dispatcher test.'''
+
+import time
+import unittest
+from random import random
+
+from sample import ObjectType, Event
+
+
+class NoOverride(ObjectType):
+
+ pass
+
+
+class Override(ObjectType):
+
+ def __init__(self):
+ ObjectType.__init__(self)
+ self.called = False
+
+ def event(self, event):
+ self.called = True
+ return True
+
+
+class TestEventLoop(unittest.TestCase):
+
+ def testEventLoop(self):
+ '''Calling virtuals in a event loop'''
+ objs = [ObjectType(), NoOverride(), Override()]
+
+ evaluated = ObjectType.processEvent(objs,
+ Event(Event.BASIC_EVENT))
+
+ self.assertEqual(evaluated, 3)
+ self.assertTrue(objs[2].called)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/event_loop_thread_test.py b/sources/shiboken2/tests/samplebinding/event_loop_thread_test.py
new file mode 100644
index 000000000..8211ecd15
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/event_loop_thread_test.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import time
+import threading
+import unittest
+from random import random
+
+from sample import ObjectType, Event
+
+
+class Producer(ObjectType):
+
+ def __init__(self):
+ ObjectType.__init__(self)
+ self.data = None
+ self.read = False
+
+ def event(self, event):
+ self.data = random()
+
+ while not self.read:
+ time.sleep(0.01)
+
+ return True
+
+
+class Collector(threading.Thread):
+
+ def __init__(self, objects):
+ threading.Thread.__init__(self)
+ self.max_runs = len(objects)
+ self.objects = objects
+ self.data = []
+
+ def run(self):
+ i = 0
+ while i < self.max_runs:
+ if self.objects[i].data is not None:
+ self.data.append(self.objects[i].data)
+ self.objects[i].read = True
+ i += 1
+ time.sleep(0.01)
+
+
+class TestEventLoopWithThread(unittest.TestCase):
+ '''Communication between a python thread and an simple
+ event loop in C++'''
+
+ def testBasic(self):
+ '''Allowing threads and calling virtuals from C++'''
+ number = 10
+ objs = [Producer() for x in range(number)]
+ thread = Collector(objs)
+
+ thread.start()
+
+ evaluated = ObjectType.processEvent(objs,
+ Event(Event.BASIC_EVENT))
+
+ thread.join()
+
+ producer_data = [x.data for x in objs]
+ self.assertEqual(evaluated, number)
+ self.assertEqual(producer_data, thread.data)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/filter_test.py b/sources/shiboken2/tests/samplebinding/filter_test.py
new file mode 100644
index 000000000..eb84a932c
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/filter_test.py
@@ -0,0 +1,45 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from sample import Data, Intersection, Union
+
+class TestFilters(unittest.TestCase):
+
+ def testAnd(self):
+
+ f1 = Data(Data.Name, "joe")
+ f2 = Union()
+
+ inter = f1 & f2
+
+ self.assertEqual(type(inter), Intersection)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/global.h b/sources/shiboken2/tests/samplebinding/global.h
new file mode 100644
index 000000000..d273de961
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/global.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "abstract.h"
+#include "blackbox.h"
+#include "bytearray.h"
+#include "bucket.h"
+#include "collector.h"
+#include "complex.h"
+#include "ctorconvrule.h"
+#include "cvlist.h"
+#include "sbkdate.h"
+#include "derived.h"
+#include "echo.h"
+#include "functions.h"
+#include "implicitconv.h"
+#include "overloadsort.h"
+#include "handle.h"
+#include "injectcode.h"
+#include "list.h"
+#include "listuser.h"
+#include "mapuser.h"
+#include "modelindex.h"
+#include "modifications.h"
+#include "modified_constructor.h"
+#include "multiple_derived.h"
+#include "noimplicitconversion.h"
+#include "nondefaultctor.h"
+#include "objectmodel.h"
+#include "objecttype.h"
+#include "objecttypebyvalue.h"
+#include "objecttypeholder.h"
+#include "objecttypelayout.h"
+#include "objecttypeoperators.h"
+#include "objectview.h"
+#include "oddbool.h"
+#include "onlycopy.h"
+#include "overload.h"
+#include "pairuser.h"
+#include "pen.h"
+#include "photon.h"
+#include "point.h"
+#include "pointf.h"
+#include "pointerholder.h"
+#include "polygon.h"
+#include "privatector.h"
+#include "privatedtor.h"
+#include "protected.h"
+#include "rect.h"
+#include "reference.h"
+#include "removednamespaces.h"
+#include "sample.h"
+#include "samplenamespace.h"
+#include "simplefile.h"
+#include "size.h"
+#include "str.h"
+#include "strlist.h"
+#include "sometime.h"
+#include "templateptr.h"
+#include "transform.h"
+#include "virtualmethods.h"
+#include "voidholder.h"
+#include "valueandvirtual.h"
+#include "expression.h"
+#include "filter.h"
diff --git a/sources/shiboken2/tests/samplebinding/handleholder_test.py b/sources/shiboken2/tests/samplebinding/handleholder_test.py
new file mode 100644
index 000000000..6d945e499
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/handleholder_test.py
@@ -0,0 +1,57 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+''' Test case for a class that holds a unknown handle object.
+ Test case for BUG #1105.
+'''
+
+import unittest
+
+from sample import HandleHolder
+
+class HandleHolderTest(unittest.TestCase):
+ def testCreation(self):
+ holder = HandleHolder(HandleHolder.createHandle())
+ holder2 = HandleHolder(HandleHolder.createHandle())
+ self.assertEqual(holder.compare(holder2), False)
+
+ def testTransfer(self):
+ holder = HandleHolder()
+ holder2 = HandleHolder(holder.handle())
+ self.assertTrue(holder.compare(holder2))
+
+ def testUseDefinedType(self):
+ holder = HandleHolder(8)
+ holder2 = HandleHolder(holder.handle2())
+ self.assertTrue(holder.compare2(holder2))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/hashabletype_test.py b/sources/shiboken2/tests/samplebinding/hashabletype_test.py
new file mode 100644
index 000000000..069824ca7
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/hashabletype_test.py
@@ -0,0 +1,54 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for __hash__'''
+
+import unittest
+
+from sample import *
+
+class HashableTest(unittest.TestCase):
+
+ def testStrHash(self):
+ h = {}
+ s = Str("Hi")
+ h[s] = 2
+ self.assertTrue(h.get(s), 2)
+
+ def testObjectTypeHash(self):
+ h = {}
+ o = ObjectType()
+ h[o] = 2
+ self.assertTrue(h.get(o), 2)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/ignorederefop_test.py b/sources/shiboken2/tests/samplebinding/ignorederefop_test.py
new file mode 100644
index 000000000..dc3fe8b13
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ignorederefop_test.py
@@ -0,0 +1,38 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sample import *
+
+class TestLackOfDereferenceOperators (unittest.TestCase):
+ def testIf(self):
+ r = Reference()
+ self.assertFalse(hasattr(r, "__mul__"))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/implicitconv_numerical_test.py b/sources/shiboken2/tests/samplebinding/implicitconv_numerical_test.py
new file mode 100644
index 000000000..3fe66e30c
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/implicitconv_numerical_test.py
@@ -0,0 +1,151 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for inplicit converting C++ numeric types.'''
+
+import unittest
+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).
+cIntMin = -2147483648
+cIntMax = 2147483647
+cLongMin = cIntMin
+cLongMax = cIntMax
+maxRepresentableInt = sys.maxsize if IS_PY3K else sys.maxint
+is64bitArchitecture = maxRepresentableInt > 2**32
+if is64bitArchitecture and sys.platform != 'win32':
+ cLongMin = -9223372036854775808
+ cLongMax = 9223372036854775807
+
+class NumericTester(unittest.TestCase):
+ '''Helper class for numeric comparison testing'''
+
+ def check_value(self, source, expected, callback, desired_type=None):
+ result = callback(source)
+ self.assertEqual(result, expected)
+
+ if desired_type:
+ self.assertEqual(type(result), desired_type)
+
+
+class FloatImplicitConvert(NumericTester):
+ '''Test case for implicit converting C++ numeric types.'''
+
+ def testFloatAsInt(self):
+ '''Float as Int'''
+ self.check_value(3.14, 3, sample.acceptInt, int)
+ self.assertRaises(OverflowError, sample.acceptInt, cIntMax + 400)
+
+ def testFloatAsLong(self):
+ '''Float as Long'''
+ #C++ longs are python ints for us
+ self.check_value(3.14, 3, sample.acceptLong, int)
+ self.assertRaises(OverflowError, sample.acceptLong, cLongMax + 400)
+
+ def testFloatAsUInt(self):
+ '''Float as unsigned Int'''
+ self.check_value(3.14, 3, sample.acceptUInt, long)
+ 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.assertRaises(OverflowError, sample.acceptULong, -3.14)
+
+ def testFloatAsDouble(self):
+ '''Float as double'''
+ self.check_value(3.14, 3.14, sample.acceptDouble, float)
+
+
+class IntImplicitConvert(NumericTester):
+ '''Test case for implicit converting C++ numeric types.'''
+
+ def testIntAsInt(self):
+ '''Int as Int'''
+ self.check_value(3, 3, sample.acceptInt, int)
+
+ def testIntAsLong(self):
+ '''Int as Long'''
+ self.check_value(3, 3, sample.acceptLong, int)
+
+ # cLongMax goes here as CPython implements int as a C long
+ self.check_value(cLongMax, cLongMax, sample.acceptLong, int)
+ self.check_value(cLongMin, cLongMin, sample.acceptLong, int)
+
+ def testIntAsUInt(self):
+ '''Int as unsigned Int'''
+ self.check_value(3, 3, sample.acceptUInt, long)
+ self.assertRaises(OverflowError, sample.acceptUInt, -3)
+
+ def testIntAsULong(self):
+ '''Int as unsigned Long'''
+ self.check_value(3, 3, sample.acceptULong, long)
+ self.assertRaises(OverflowError, sample.acceptULong, -3)
+
+ def testFloatAsDouble(self):
+ '''Float as double'''
+ self.check_value(3.14, 3.14, sample.acceptDouble, float)
+
+
+class LongImplicitConvert(NumericTester):
+ '''Test case for implicit converting C++ numeric types.'''
+
+ def testLongAsInt(self):
+ '''Long as Int'''
+ self.check_value(l(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.assertRaises(OverflowError, sample.acceptLong, cLongMax + 20)
+
+ def testLongAsUInt(self):
+ '''Long as unsigned Int'''
+ self.check_value(l(260), 260, sample.acceptUInt, long)
+ 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))
+
+ def testLongAsDouble(self):
+ '''Float as double'''
+ self.check_value(l(42), 42, sample.acceptDouble, float)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/implicitconv_test.py b/sources/shiboken2/tests/samplebinding/implicitconv_test.py
new file mode 100644
index 000000000..a94151d80
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/implicitconv_test.py
@@ -0,0 +1,66 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for implicit conversions'''
+
+import unittest
+
+from sample import ImplicitConv, ObjectType
+
+class ImplicitConvTest(unittest.TestCase):
+ '''Test case for implicit conversions'''
+
+ def testImplicitConversions(self):
+ '''Test if overloaded function call decisor takes implicit conversions into account.'''
+ ic = ImplicitConv.implicitConvCommon(ImplicitConv())
+ self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorNone)
+
+ ic = ImplicitConv.implicitConvCommon(3)
+ self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorOne)
+ self.assertEqual(ic.objId(), 3)
+
+ ic = ImplicitConv.implicitConvCommon(ImplicitConv.CtorThree)
+ self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorThree)
+
+ obj = ObjectType()
+ ic = ImplicitConv.implicitConvCommon(obj)
+ self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorObjectTypeReference)
+
+ ic = ImplicitConv.implicitConvCommon(42.42)
+ self.assertEqual(ic.value(), 42.42)
+
+ ic = ImplicitConv(None)
+ self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorPrimitiveType)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/inheritanceandscope_test.py b/sources/shiboken2/tests/samplebinding/inheritanceandscope_test.py
new file mode 100755
index 000000000..a8ede0548
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/inheritanceandscope_test.py
@@ -0,0 +1,48 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for finding scope in cases involving inheritance.'''
+
+import unittest
+
+from sample import SampleNamespace
+
+class ScopeAndInheritanceTest(unittest.TestCase):
+ '''Test cases for finding scope in cases involving inheritance.'''
+
+ def testMethodCorrectlyWrapper(self):
+ '''A method returning a type declared in the scope of the method's
+ class parent must be found and the method correctly exported.'''
+ meth = getattr(SampleNamespace.DerivedFromNamespace, 'methodReturningTypeFromParentScope')
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/injectcode_test.py b/sources/shiboken2/tests/samplebinding/injectcode_test.py
new file mode 100644
index 000000000..99847f891
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/injectcode_test.py
@@ -0,0 +1,132 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for std::list container conversions'''
+
+import unittest
+from sample import InjectCode
+
+class MyInjectCode(InjectCode):
+ def __init__(self):
+ InjectCode.__init__(self)
+ self.multiplier = 2
+
+ def arrayMethod(self, values):
+ return self.multiplier * sum(values)
+
+class InjectCodeTest(unittest.TestCase):
+
+ def testTypeNativeBeginning_TypeTargetBeginning(self):
+ ic = InjectCode()
+ self.assertEqual(str(ic), "Hi! I'm the inject code dummy class.")
+
+ def testFunctionTargetBeginning_FunctionTargetEnd(self):
+ ic = InjectCode()
+ ret = ic.simpleMethod1(2, 1)
+ self.assertEqual(ret, "4end")
+ ret = ic.simpleMethod1(4, 2)
+ self.assertEqual(ret, "7end")
+
+ def testFunctionTargetBeginning(self):
+ ic = InjectCode()
+ ret = ic.simpleMethod2()
+ self.assertEqual(ret, "_end")
+
+ def testArgsModification(self):
+ ic = InjectCode()
+ ret = ic.overloadedMethod(["1", "2", "3", "4"])
+ self.assertEqual(ret, "1234")
+ ret = ic.overloadedMethod(2, 0.5)
+ self.assertEqual(ret, "2.5")
+ ret = ic.overloadedMethod(6, True)
+ self.assertEqual(ret, "6true")
+
+ def testArgsModification2(self):
+ ic = InjectCode()
+ ret = ic.simpleMethod3(["1", "2", "3", "4"])
+ self.assertEqual(ret, "1234")
+
+ def testArgumentRemovalAndArgumentTypeModification(self):
+ '''A method has its first argument removed and the second modified.'''
+ ic = InjectCode()
+ values = (1, 2, 3, 4, 5)
+ result = ic.arrayMethod(values)
+ self.assertEqual(result, sum(values))
+
+ def testCallVirtualMethodWithArgumentRemovalAndArgumentTypeModification(self):
+ '''A virtual method has its first argument removed and the second modified.'''
+ ic = InjectCode()
+ values = (1, 2, 3, 4, 5)
+ result = ic.callArrayMethod(values)
+ self.assertEqual(result, sum(values))
+
+ def testCallReimplementedVirtualMethodWithArgumentRemovalAndArgumentTypeModification(self):
+ '''Calls a reimplemented virtual method that had its first argument removed and the second modified.'''
+ ic = MyInjectCode()
+ values = (1, 2, 3, 4, 5)
+ result = ic.callArrayMethod(values)
+ self.assertEqual(result, ic.multiplier * sum(values))
+
+ def testUsageOfTypeSystemCheckVariableOnPrimitiveType(self):
+ '''When the sequence item is convertible to an integer -1 is returned, or -2 if its not convertible.'''
+ ic = InjectCode()
+ values = (1, 2, 3, 4, '5', 6.7)
+ result = ic.arrayMethod(values)
+
+ fixedValues = [v for v in values if isinstance(v, int)]\
+ + [-1 for v in values if isinstance(v, float)]\
+ + [-2 for v in values if not isinstance(v, int) and not isinstance(v, float)]
+ self.assertEqual(result, sum(fixedValues))
+
+
+class IntArrayTest(unittest.TestCase):
+ '''Test case for converting python sequence to int array'''
+
+ def testBasic(self):
+ '''Shiboken::sequenceToIntArray - basic case'''
+ args = [1, 2, 3, 4]
+ ic = InjectCode()
+ self.assertEqual(sum(args) + len(args), ic.sumArrayAndLength(args))
+
+ def testEmpty(self):
+ '''Shiboken::sequenceToIntArray - empty sequence'''
+ args = []
+ ic = InjectCode()
+ self.assertEqual(sum(args) + len(args), ic.sumArrayAndLength(args))
+
+ def testWithZero(self):
+ '''Shiboken::sequenceToIntArray - count only up to zero'''
+ args = [1, 2, 0, 3]
+ ic = InjectCode()
+ self.assertEqual(sum([1, 2]) + len([1, 2]), ic.sumArrayAndLength(args))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/innerclass_test.py b/sources/shiboken2/tests/samplebinding/innerclass_test.py
new file mode 100644
index 000000000..0df636857
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/innerclass_test.py
@@ -0,0 +1,42 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from sample import Derived
+
+class TestInnerClass(unittest.TestCase):
+ def testInstaciate(self):
+ d = Derived.SomeInnerClass()
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/intlist_test.py b/sources/shiboken2/tests/samplebinding/intlist_test.py
new file mode 100644
index 000000000..6d21ef053
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/intlist_test.py
@@ -0,0 +1,98 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from sample import IntList
+
+class IntListTest(unittest.TestCase):
+
+ def testAutoFunctionsToBaseList(self):
+ lst = IntList()
+ self.assertEqual(len(lst), 0)
+ lst.append(10)
+ self.assertEqual(lst[0], 10)
+ lst.append(20)
+ self.assertEqual(lst[1], 20)
+ lst.append(30)
+ self.assertEqual(lst[2], 30)
+ lst[1] = 25
+ self.assertEqual(lst[0], 10)
+ self.assertEqual(lst[1], 25)
+ self.assertEqual(lst[2], 30)
+ self.assertEqual(len(lst), 3)
+
+ def testIntListCtor_NoParams(self):
+ '''IntList constructor receives no parameter.'''
+ il = IntList()
+ self.assertEqual(len(il), 0)
+ self.assertEqual(il.constructorUsed(), IntList.NoParamsCtor)
+
+ def testIntListCtor_int(self):
+ '''IntList constructor receives an integer.'''
+ value = 123
+ il = IntList(value)
+ self.assertEqual(len(il), 1)
+ self.assertEqual(il[0], value)
+ self.assertEqual(il.constructorUsed(), IntList.IntCtor)
+
+ def testIntListCtor_IntList(self):
+ '''IntList constructor receives an IntList object.'''
+ il1 = IntList(123)
+ il2 = IntList(il1)
+ self.assertEqual(len(il1), len(il2))
+ for i in range(len(il1)):
+ self.assertEqual(il1[i], il2[i])
+ self.assertEqual(il2.constructorUsed(), IntList.CopyCtor)
+
+ def testIntListCtor_ListOfInts(self):
+ '''IntList constructor receives an integer list.'''
+ ints = [123, 456]
+ il = IntList(ints)
+ self.assertEqual(len(il), len(ints))
+ for i in range(len(il)):
+ self.assertEqual(il[i], ints[i])
+ self.assertEqual(il.constructorUsed(), IntList.ListOfIntCtor)
+
+ def testIntListAttributeTypeCheck(self):
+ '''Attribute values to IntList.'''
+ il = IntList([0, 1, 2])
+ self.assertEqual(len(il), 3)
+ il[0] = 123
+ self.assertEqual(len(il), 3)
+ self.assertEqual(il[0], 123)
+ il[1] = 432.1
+ self.assertEqual(len(il), 3)
+ self.assertEqual(il[1], int(432.1))
+ self.assertRaises(TypeError, il.__setitem__, 2, '78')
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/invalid_virtual_return_test.py b/sources/shiboken2/tests/samplebinding/invalid_virtual_return_test.py
new file mode 100644
index 000000000..f160f1e07
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/invalid_virtual_return_test.py
@@ -0,0 +1,65 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for returning invalid types in a virtual function'''
+
+import unittest
+from sample import ObjectModel, ObjectType, ObjectView
+
+import warnings
+
+
+class MyObject(ObjectType):
+ pass
+
+
+class ListModelWrong(ObjectModel):
+
+ def __init__(self, parent=None):
+ ObjectModel.__init__(self, parent)
+ self.obj = 0
+
+ def data(self):
+ warnings.simplefilter('error')
+ # Shouldn't segfault. Must set TypeError
+ return self.obj
+
+
+class ModelWrongReturnTest(unittest.TestCase):
+
+ def testWrongTypeReturn(self):
+ model = ListModelWrong()
+ view = ObjectView(model)
+ self.assertRaises(RuntimeWarning, view.getRawModelData) # calls model.data()
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/keep_reference_test.py b/sources/shiboken2/tests/samplebinding/keep_reference_test.py
new file mode 100644
index 000000000..a8f63f6df
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/keep_reference_test.py
@@ -0,0 +1,81 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for objects that keep references to other object without owning them (e.g. model/view relationships).'''
+
+import unittest
+from sys import getrefcount
+
+from sample import ObjectModel, ObjectView
+
+class TestKeepReference(unittest.TestCase):
+ '''Test case for objects that keep references to other object without owning them (e.g. model/view relationships).'''
+
+ def testReferenceCounting(self):
+ '''Tests reference count of model-like object referred by view-like objects.'''
+ model1 = ObjectModel()
+ refcount1 = getrefcount(model1)
+ view1 = ObjectView()
+ view1.setModel(model1)
+ self.assertEqual(getrefcount(view1.model()), refcount1 + 1)
+
+ view2 = ObjectView()
+ view2.setModel(model1)
+ self.assertEqual(getrefcount(view2.model()), refcount1 + 2)
+
+ model2 = ObjectModel()
+ view2.setModel(model2)
+ self.assertEqual(getrefcount(view1.model()), refcount1 + 1)
+
+ def testReferenceCountingWhenDeletingReferrer(self):
+ '''Tests reference count of model-like object referred by deceased view-like object.'''
+ model = ObjectModel()
+ refcount1 = getrefcount(model)
+ view = ObjectView()
+ view.setModel(model)
+ self.assertEqual(getrefcount(view.model()), refcount1 + 1)
+
+ del view
+ self.assertEqual(getrefcount(model), refcount1)
+
+ def testReferreedObjectSurvivalAfterContextEnd(self):
+ '''Model-like object assigned to a view-like object must survive after get out of context.'''
+ def createModelAndSetToView(view):
+ model = ObjectModel()
+ model.setObjectName('created model')
+ view.setModel(model)
+ view = ObjectView()
+ createModelAndSetToView(view)
+ model = view.model()
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/list_test.py b/sources/shiboken2/tests/samplebinding/list_test.py
new file mode 100644
index 000000000..22cb4c04b
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/list_test.py
@@ -0,0 +1,121 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for std::list container conversions'''
+
+import unittest
+
+from sample import ListUser, Point, PointF
+
+class ExtendedListUser(ListUser):
+ def __init__(self):
+ ListUser.__init__(self)
+ self.create_list_called = False
+
+ def createList(self):
+ self.create_list_called = True
+ return [2, 3, 5, 7, 13]
+
+class ListConversionTest(unittest.TestCase):
+ '''Test case for std::list container conversions'''
+
+ def testReimplementedVirtualMethodCall(self):
+ '''Test if a Python override of a virtual method is correctly called from C++.'''
+ lu = ExtendedListUser()
+ lst = lu.callCreateList()
+ self.assertTrue(lu.create_list_called)
+ self.assertEqual(type(lst), list)
+ for item in lst:
+ self.assertEqual(type(item), int)
+
+ def testPrimitiveConversionInsideContainer(self):
+ '''Test primitive type conversion inside conversible std::list container.'''
+ cpx0 = complex(1.2, 3.4)
+ cpx1 = complex(5.6, 7.8)
+ lst = ListUser.createComplexList(cpx0, cpx1)
+ self.assertEqual(type(lst), list)
+ for item in lst:
+ self.assertEqual(type(item), complex)
+ self.assertEqual(lst, [cpx0, cpx1])
+
+ def testSumListIntegers(self):
+ '''Test method that sums a list of integer values.'''
+ lu = ListUser()
+ lst = [3, 5, 7]
+ result = lu.sumList(lst)
+ self.assertEqual(result, sum(lst))
+
+ def testSumListFloats(self):
+ '''Test method that sums a list of float values.'''
+ lu = ListUser()
+ lst = [3.3, 4.4, 5.5]
+ result = lu.sumList(lst)
+ self.assertEqual(result, sum(lst))
+
+ def testConversionInBothDirections(self):
+ '''Test converting a list from Python to C++ and back again.'''
+ lu = ListUser()
+ lst = [3, 5, 7]
+ lu.setList(lst)
+ result = lu.getList()
+ self.assertEqual(result, lst)
+
+ def testConversionInBothDirectionsWithSimilarContainer(self):
+ '''Test converting a tuple, instead of the expected list, from Python to C++ and back again.'''
+ lu = ListUser()
+ lst = (3, 5, 7)
+ lu.setList(lst)
+ result = lu.getList()
+ self.assertNotEqual(result, lst)
+ self.assertEqual(result, list(lst))
+
+ def testConversionOfListOfObjectsPassedAsArgument(self):
+ '''Calls method with a Python list of wrapped objects to be converted to a C++ list.'''
+ mult = 3
+ pts0 = (Point(1.0, 2.0), Point(3.3, 4.4), Point(5, 6))
+ pts1 = (Point(1.0, 2.0), Point(3.3, 4.4), Point(5, 6))
+ ListUser.multiplyPointList(pts1, mult)
+ for pt0, pt1 in zip(pts0, pts1):
+ self.assertEqual(pt0.x() * mult, pt1.x())
+ self.assertEqual(pt0.y() * mult, pt1.y())
+
+ def testConversionOfInvalidLists(self):
+ mult = 3
+ pts = (Point(1.0, 2.0), 3, Point(5, 6))
+ self.assertRaises(TypeError, ListUser.multiplyPointList, pts, mult)
+
+ def testOverloadMethodReceivingRelatedContainerTypes(self):
+ self.assertEqual(ListUser.ListOfPointF, ListUser.listOfPoints([PointF()]))
+ self.assertEqual(ListUser.ListOfPoint, ListUser.listOfPoints([Point()]))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/lock_test.py b/sources/shiboken2/tests/samplebinding/lock_test.py
new file mode 100644
index 000000000..35bf5149d
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/lock_test.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Simple test with a blocking C++ method that should allow python
+ threads to run.'''
+
+import unittest
+import threading
+
+from sample import Bucket
+
+
+class Unlocker(threading.Thread):
+
+ def __init__(self, bucket):
+ threading.Thread.__init__(self)
+ self.bucket = bucket
+
+ def run(self):
+ while not self.bucket.locked():
+ pass
+
+ self.bucket.unlock()
+
+
+class MyBucket(Bucket):
+
+ def __init__(self):
+ Bucket.__init__(self)
+
+ def virtualBlockerMethod(self):
+ self.lock()
+ return True
+
+
+class TestLockUnlock(unittest.TestCase):
+
+ def testBasic(self):
+ '''Locking in C++ and releasing in a python thread'''
+ bucket = Bucket()
+ unlocker = Unlocker(bucket)
+
+ unlocker.start()
+ bucket.lock()
+ unlocker.join()
+
+ def testVirtualBlocker(self):
+ '''Same as the basic case but blocker method is a C++ virtual called from C++.'''
+ bucket = Bucket()
+ unlocker = Unlocker(bucket)
+
+ unlocker.start()
+ result = bucket.callVirtualBlockerMethodButYouDontKnowThis()
+ unlocker.join()
+ self.assertTrue(result)
+
+ def testReimplementedVirtualBlocker(self):
+ '''Same as the basic case but blocker method is a C++ virtual reimplemented in Python and called from C++.'''
+ mybucket = MyBucket()
+ unlocker = Unlocker(mybucket)
+
+ unlocker.start()
+ result = mybucket.callVirtualBlockerMethodButYouDontKnowThis()
+ unlocker.join()
+ self.assertTrue(result)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/map_test.py b/sources/shiboken2/tests/samplebinding/map_test.py
new file mode 100644
index 000000000..18cefd857
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/map_test.py
@@ -0,0 +1,80 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for std::map container conversions'''
+
+import unittest
+
+from sample import MapUser
+
+class ExtendedMapUser(MapUser):
+ def __init__(self):
+ MapUser.__init__(self)
+ self.create_map_called = False
+
+ def createMap(self):
+ self.create_map_called = True
+ return {'two' : (complex(2.2, 2.2), 2),
+ 'three' : (complex(3.3, 3.3), 3),
+ 'five' : (complex(5.5, 5.5), 5),
+ 'seven' : (complex(7.7, 7.7), 7)}
+
+class MapConversionTest(unittest.TestCase):
+ '''Test case for std::map container conversions'''
+
+ def testReimplementedVirtualMethodCall(self):
+ '''Test if a Python override of a virtual method is correctly called from C++.'''
+ mu = ExtendedMapUser()
+ map_ = mu.callCreateMap()
+ self.assertTrue(mu.create_map_called)
+ self.assertEqual(type(map_), dict)
+ for key, value in map_.items():
+ self.assertEqual(type(key), str)
+ self.assertEqual(type(value[0]), complex)
+ self.assertEqual(type(value[1]), int)
+
+ def testConversionInBothDirections(self):
+ '''Test converting a map from Python to C++ and back again.'''
+ mu = MapUser()
+ map_ = {'odds' : [2, 4, 6], 'evens' : [3, 5, 7], 'primes' : [3, 4, 6]}
+ mu.setMap(map_)
+ result = mu.getMap()
+ self.assertEqual(result, map_)
+
+ def testConversionMapIntKeyValueTypeValue(self):
+ '''C++ signature: MapUser::passMapIntValueType(const std::map<int, const ByteArray>&)'''
+ mu = MapUser()
+ map_ = {0 : 'string'}
+ result = mu.passMapIntValueType(map_)
+ self.assertEqual(map_, result)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/metaclass_test.py b/sources/shiboken2/tests/samplebinding/metaclass_test.py
new file mode 100644
index 000000000..972a2f17d
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/metaclass_test.py
@@ -0,0 +1,61 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from sample import *
+import unittest
+
+class MetaA(type):
+ pass
+
+class A(object):
+ __metaclass__ = MetaA
+
+MetaB = type(Point)
+B = Point
+
+class MetaC(MetaA, MetaB):
+ pass
+class C(A, B):
+ __metaclass__ = MetaC
+
+class D(C):
+ pass
+
+class TestMetaClass(unittest.TestCase):
+ def testIt(self):
+ w1 = C() # works
+ w1.setX(1)
+ w1.setY(2)
+
+ w2 = D() # should work!
+ w2.setX(3)
+ w2.setY(4)
+
+ w3 = w1 + w2
+ self.assertEqual(w3.x(), 4)
+ self.assertEqual(w3.y(), 6)
diff --git a/sources/shiboken2/tests/samplebinding/mi_virtual_methods_test.py b/sources/shiboken2/tests/samplebinding/mi_virtual_methods_test.py
new file mode 100644
index 000000000..0905dead9
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/mi_virtual_methods_test.py
@@ -0,0 +1,88 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for virtual methods in multiple inheritance scenarios'''
+
+import unittest
+
+from sample import VirtualMethods, ObjectType, Event
+
+
+class ImplementsNone(ObjectType, VirtualMethods):
+ '''Implements no virtual methods'''
+
+ def __init__(self):
+ ObjectType.__init__(self)
+ VirtualMethods.__init__(self)
+
+
+class ImplementsBoth(ObjectType, VirtualMethods):
+ '''Implements ObjectType.event and VirtualMethods.sum1'''
+
+ def __init__(self):
+ ObjectType.__init__(self)
+ VirtualMethods.__init__(self)
+ self.event_processed = False
+
+ def event(self, event):
+ self.event_processed = True
+ return True
+
+ def sum1(self, arg0, arg1, arg2):
+ return (arg0 + arg1 + arg2) * 2
+
+
+class CppVirtualTest(unittest.TestCase):
+ '''Virtual method defined in c++ called from C++'''
+
+ def testCpp(self):
+ '''C++ calling C++ virtual method in multiple inheritance scenario'''
+ obj = ImplementsNone()
+ self.assertTrue(ObjectType.processEvent([obj], Event(Event.BASIC_EVENT)))
+ self.assertRaises(AttributeError, getattr, obj, 'event_processed')
+
+ self.assertEqual(obj.callSum0(1, 2, 3), 6)
+
+
+class PyVirtualTest(unittest.TestCase):
+ '''Virtual method reimplemented in python called from C++'''
+
+ def testEvent(self):
+ '''C++ calling Python reimplementation of virtual in multiple inheritance'''
+ obj = ImplementsBoth()
+ self.assertTrue(ObjectType.processEvent([obj], Event(Event.BASIC_EVENT)))
+ self.assertTrue(obj.event_processed)
+
+ self.assertEqual(obj.callSum1(1, 2, 3), 12)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/mixed_mi_test.py b/sources/shiboken2/tests/samplebinding/mixed_mi_test.py
new file mode 100644
index 000000000..b6268cf2c
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/mixed_mi_test.py
@@ -0,0 +1,76 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for multiple inheritance in mixed Python/C++ scenarios'''
+
+import unittest
+
+from sample import ObjectType
+
+
+class Base(object):
+ '''Base Python class'''
+
+ def __init__(self):
+ self.name = ''
+
+ def pythonName(self):
+ return self.name
+
+ def setPythonName(self, name):
+ self.name = name
+
+
+class Child(Base, ObjectType):
+ '''Dummy class with mixed parents'''
+
+ def __init__(self):
+ Base.__init__(self)
+ ObjectType.__init__(self)
+
+
+class MixedInheritanceTest(unittest.TestCase):
+
+ def testMixed(self):
+ '''Mixed Python/C++ multiple inheritance'''
+ obj = Child()
+
+ obj.setObjectName('aaa')
+ self.assertEqual(obj.objectName(), 'aaa')
+
+ obj.setPythonName('python')
+ self.assertEqual(obj.pythonName(), 'python')
+
+
+if __name__ == '__main__':
+ unittest.main()
+
+
diff --git a/sources/shiboken2/tests/samplebinding/modelindex_test.py b/sources/shiboken2/tests/samplebinding/modelindex_test.py
new file mode 100644
index 000000000..5dd7d3bc7
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/modelindex_test.py
@@ -0,0 +1,53 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from sample import ModelIndex, ReferentModelIndex, PersistentModelIndex
+
+class TestCastOperator(unittest.TestCase):
+
+ def testCastOperatorReturningValue(self):
+ index = PersistentModelIndex()
+ index.setValue(123)
+ self.assertEqual(index.value(), 123)
+ self.assertEqual(index.value(), ModelIndex.getValue(index))
+
+ def testCastOperatorReturningReference(self):
+ index = ReferentModelIndex()
+ index.setValue(123)
+ self.assertEqual(index.value(), 123)
+ self.assertEqual(index.value(), ModelIndex.getValue(index))
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/modelview_test.py b/sources/shiboken2/tests/samplebinding/modelview_test.py
new file mode 100644
index 000000000..081de303d
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/modelview_test.py
@@ -0,0 +1,78 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for objects that keep references to other object without owning them (e.g. model/view relationships).'''
+
+import unittest
+from sample import ObjectModel, ObjectType, ObjectView
+
+
+object_name = 'test object'
+
+class MyObject(ObjectType):
+ pass
+
+class ListModelKeepsReference(ObjectModel):
+ def __init__(self, parent=None):
+ ObjectModel.__init__(self, parent)
+ self.obj = MyObject()
+ self.obj.setObjectName(object_name)
+
+ def data(self):
+ return self.obj
+
+class ListModelDoesntKeepsReference(ObjectModel):
+ def data(self):
+ obj = MyObject()
+ obj.setObjectName(object_name)
+ return obj
+
+
+class ModelViewTest(unittest.TestCase):
+
+ def testListModelDoesntKeepsReference(self):
+ model = ListModelDoesntKeepsReference()
+ view = ObjectView(model)
+ obj = view.getRawModelData()
+ self.assertEqual(type(obj), MyObject)
+ self.assertEqual(obj.objectName(), object_name)
+
+ def testListModelKeepsReference(self):
+ model = ListModelKeepsReference()
+ view = ObjectView(model)
+ obj = view.getRawModelData()
+ self.assertEqual(type(obj), MyObject)
+ self.assertEqual(obj.objectName(), object_name)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/modifications_test.py b/sources/shiboken2/tests/samplebinding/modifications_test.py
new file mode 100644
index 000000000..44748dc8c
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/modifications_test.py
@@ -0,0 +1,224 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for method modifications performed as described on type system. '''
+
+import unittest
+
+from sample import Modifications, Point, ByteArray
+
+class ExtModifications(Modifications):
+ def __init__(self):
+ Modifications.__init__(self)
+ self.multiplier = 3.0
+ self.increment = 10.0
+
+ def name(self):
+ return 'ExtModifications'
+
+ def differenceOfPointCoordinates(self, point):
+ ok, res = Modifications.differenceOfPointCoordinates(self, point)
+ return ok, res * self.multiplier + self.increment
+
+
+class ModificationsTest(unittest.TestCase):
+ '''Test cases for method modifications performed as described on type system. '''
+
+ def setUp(self):
+ self.mods = Modifications()
+
+ def tearDown(self):
+ del self.mods
+
+ def testClassMembersAvailability(self):
+ '''Test if Modified class really have the expected members.'''
+ expected_members = set(['OverloadedModFunc', 'OverloadedNone',
+ 'Overloaded_ibiP', 'Overloaded_ibib',
+ 'Overloaded_ibid', 'Overloaded_ibii',
+ 'calculateArea', 'doublePlus', 'increment',
+ 'multiplyPointCoordsPlusValue', 'name',
+ 'pointToPair', 'overloaded', 'power',
+ 'timesTen'])
+ self.assertTrue(expected_members.issubset(dir(Modifications)))
+
+ def testRenamedMethodAvailability(self):
+ '''Test if Modification class really have renamed the 'className' virtual method to 'name'.'''
+ self.assertTrue('className' not in dir(Modifications))
+ self.assertTrue('name' in dir(Modifications))
+
+ def testReimplementationOfRenamedVirtualMethod(self):
+ '''Test if class inheriting from Modification class have the reimplementation of renamed virtual method called.'''
+ em = ExtModifications()
+ self.assertEqual(self.mods.name(), 'Modifications')
+ self.assertEqual(em.name(), 'ExtModifications')
+
+ def testRegularMethodRenaming(self):
+ '''Test if Modifications::cppMultiply was correctly renamed to calculateArea.'''
+ self.assertTrue('cppMultiply' not in dir(Modifications))
+ self.assertTrue('calculateArea' in dir(Modifications))
+ self.assertEqual(self.mods.calculateArea(3, 6), 3 * 6)
+
+ def testRegularMethodRemoval(self):
+ '''Test if 'Modifications::exclusiveCppStuff' was removed from Python bindings.'''
+ self.assertTrue('exclusiveCppStuff' not in dir(Modifications))
+
+ def testArgumentRemoval(self):
+ '''Test if second argument of Modifications::doublePlus(int, int) was removed.'''
+ self.assertRaises(TypeError, self.mods.doublePlus, 3, 7)
+ self.assertEqual(self.mods.doublePlus(7), 14)
+
+ def testDefaultValueRemoval(self):
+ '''Test if default value was removed from first argument of Modifications::increment(int).'''
+ self.assertRaises(TypeError, self.mods.increment)
+ self.assertEqual(self.mods.increment(7), 8)
+
+ def testDefaultValueReplacement(self):
+ '''Test if default values for both arguments of Modifications::power(int, int) were modified.'''
+ # original default values: int power(int base = 1, int exponent = 0);
+ self.assertNotEqual(self.mods.power(4), 1)
+ # modified default values: int power(int base = 2, int exponent = 1);
+ self.assertEqual(self.mods.power(), 2)
+ self.assertEqual(self.mods.power(3), 3)
+ self.assertEqual(self.mods.power(5, 3), 5**3)
+
+ def testSetNewDefaultValue(self):
+ '''Test if default value was correctly set to 10 for first argument of Modifications::timesTen(int).'''
+ self.assertEqual(self.mods.timesTen(7), 70)
+ self.assertEqual(self.mods.timesTen(), 100)
+
+ def testArgumentRemovalAndReturnTypeModificationWithTypesystemTemplates1(self):
+ '''Test modifications to method signature and return value using type system templates (case 1).'''
+ result, ok = self.mods.pointToPair(Point(2, 5))
+ self.assertEqual(type(ok), bool)
+ self.assertEqual(type(result), tuple)
+ self.assertEqual(len(result), 2)
+ self.assertEqual(type(result[0]), float)
+ self.assertEqual(type(result[1]), float)
+ self.assertEqual(result[0], 2.0)
+ self.assertEqual(result[1], 5.0)
+
+ def testArgumentRemovalAndReturnTypeModificationWithTypesystemTemplates2(self):
+ '''Test modifications to method signature and return value using type system templates (case 2).'''
+ result, ok = self.mods.multiplyPointCoordsPlusValue(Point(2, 5), 4.1)
+ self.assertEqual(type(ok), bool)
+ self.assertEqual(type(result), float)
+ self.assertEqual(result, 14.1)
+
+ def testOverloadedMethodModifications(self):
+ '''Tests modifications to an overloaded method'''
+ # overloaded(int, bool[removed], int, double)
+ self.assertEqual(self.mods.overloaded(1, 2, 3.1), Modifications.Overloaded_ibid)
+ # overloaded(int, bool, int[removed,default=321], int)
+ self.assertEqual(self.mods.overloaded(1, True, 2), Modifications.Overloaded_ibii)
+ # the others weren't modified
+ self.assertEqual(self.mods.overloaded(1, True, 2, False), Modifications.Overloaded_ibib)
+ self.assertEqual(self.mods.overloaded(1, False, 2, Point(3, 4)), Modifications.Overloaded_ibiP)
+ self.assertRaises(TypeError, self.mods.overloaded, 1, True, Point(2, 3), Point(4, 5))
+ self.assertEqual(self.mods.over(1, True, Point(2, 3), Point(4, 5)), Modifications.Overloaded_ibPP)
+
+ def testPointArrayModification(self):
+ points = (Point(1, 1), Point(2, 2))
+ summedPoint = Point(1, 1) + Point(2, 2)
+ self.assertEqual(self.mods.sumPointArray(points), summedPoint)
+
+ def testTypeSystemVariableReplacementInFunctionModification(self):
+ ba = ByteArray('12345')
+ self.assertEqual(self.mods.getSize(ba), len(ba))
+ self.assertEqual(self.mods.getSize(ba, 20), 20)
+
+ def testNoNulPointerTag(self):
+ point = Point(12, 34)
+ self.assertEqual(self.mods.sumPointCoordinates(point), 12 + 34)
+ self.assertRaises(TypeError, self.mods.sumPointCoordinates, None)
+
+ def testNonConversionRuleForArgumentWithDefaultValue(self):
+ status, obj = self.mods.nonConversionRuleForArgumentWithDefaultValue()
+ self.assertTrue(status)
+ self.assertEqual(obj, self.mods.getObject())
+ self.assertEqual(obj.objectName(), 'MyObject')
+
+ def testInjectCodeWithConversionVariableForUserPrimitive(self):
+ self.assertTrue(Modifications.invertBoolean(False))
+ self.assertFalse(Modifications.invertBoolean(True))
+
+ def testConversionRuleForReturnType(self):
+ x, y = 11, 2
+ diff = float(abs(x - y))
+ point = Point(x, y)
+
+ ok, res = self.mods.differenceOfPointCoordinates(point)
+ self.assertTrue(isinstance(ok, bool))
+ self.assertTrue(isinstance(res, float))
+ self.assertEqual(res, diff)
+
+ ok, res = self.mods.callDifferenceOfPointCoordinates(point)
+ self.assertTrue(isinstance(ok, bool))
+ self.assertTrue(isinstance(res, float))
+ self.assertEqual(res, diff)
+
+ ok, res = self.mods.differenceOfPointCoordinates(None)
+ self.assertTrue(isinstance(ok, bool))
+ self.assertTrue(isinstance(res, float))
+ self.assertEqual(res, 0.0)
+
+ ok, res = self.mods.callDifferenceOfPointCoordinates(None)
+ self.assertTrue(isinstance(ok, bool))
+ self.assertTrue(isinstance(res, float))
+ self.assertEqual(res, 0.0)
+
+ def testConversionRuleForReturnTypeOnExtendedClass(self):
+ x, y = 11, 2
+ diff = float(abs(x - y))
+ point = Point(x, y)
+ em = ExtModifications()
+
+ ok, res = em.differenceOfPointCoordinates(point)
+ self.assertTrue(isinstance(ok, bool))
+ self.assertTrue(isinstance(res, float))
+ self.assertEqual(res, diff * em.multiplier + em.increment)
+
+ ok, res = em.callDifferenceOfPointCoordinates(point)
+ self.assertTrue(isinstance(ok, bool))
+ self.assertTrue(isinstance(res, float))
+ self.assertEqual(res, diff * em.multiplier + em.increment)
+
+ ok, res = em.differenceOfPointCoordinates(None)
+ self.assertTrue(isinstance(ok, bool))
+ self.assertTrue(isinstance(res, float))
+ self.assertEqual(res, em.increment)
+
+ ok, res = em.callDifferenceOfPointCoordinates(None)
+ self.assertTrue(isinstance(ok, bool))
+ self.assertTrue(isinstance(res, float))
+ self.assertEqual(res, em.increment)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/modified_constructor_test.py b/sources/shiboken2/tests/samplebinding/modified_constructor_test.py
new file mode 100644
index 000000000..859f89452
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/modified_constructor_test.py
@@ -0,0 +1,49 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests cases for ConstructorWithModifiedArgument class.'''
+
+import sys
+import unittest
+
+from sample import *
+
+
+class ConstructorWithModifiedArgumentTest(unittest.TestCase):
+ '''Test cases for ConstructorWithModifiedArgument class.'''
+
+ def testConstructorWithModifiedArgument(self):
+ sampleClass = ModifiedConstructor("10")
+ self.assertTrue(sampleClass.retrieveValue(), 10)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/modifiedvirtualmethods_test.py b/sources/shiboken2/tests/samplebinding/modifiedvirtualmethods_test.py
new file mode 100644
index 000000000..3121a9cc2
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/modifiedvirtualmethods_test.py
@@ -0,0 +1,248 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for modified virtual methods.'''
+
+import unittest
+
+from sample import VirtualMethods, Str
+
+class ExtendedVirtualMethods(VirtualMethods):
+ def __init__(self):
+ VirtualMethods.__init__(self)
+ self.name_called = False
+ self.sum0_called = False
+ self.sum1_called = False
+ self.sum2_called = False
+ self.sum3_called = False
+ self.sum4_called = False
+ self.sumThree_called = False
+ self.callMe_called = 0
+ self.multiplier = 12345
+
+ def sum0(self, a0, a1, a2):
+ self.sum0_called = True
+ return VirtualMethods.sumThree(self, a0, a1, a2) * self.multiplier
+
+ def sumThree(self, a0, a1, a2):
+ self.sumThree_called = True
+ return VirtualMethods.sumThree(self, a0, a1, a2) * self.multiplier
+
+ def sum1(self, a0, a1, a2):
+ self.sum1_called = True
+ return VirtualMethods.sum1(self, a0, a1, a2) * self.multiplier
+
+ def sum2(self, a0, a1):
+ self.sum2_called = True
+ return VirtualMethods.sum2(self, a0, a1) * self.multiplier
+
+ def sum3(self, a0, a1):
+ self.sum3_called = True
+ return VirtualMethods.sum3(self, a0, a1) * self.multiplier
+
+ def sum4(self, a0, a1):
+ self.sum4_called = True
+ return VirtualMethods.sum4(self, a0, a1) * self.multiplier
+
+ def name(self):
+ self.name_called = True
+ return Str('ExtendedVirtualMethods')
+
+ def callMe(self):
+ self.callMe_called += 1
+
+ def getMargins(self):
+ return tuple([m*2 for m in VirtualMethods.getMargins(self)])
+
+
+class VirtualMethodsTest(unittest.TestCase):
+ '''Test case for modified virtual methods.'''
+
+ def setUp(self):
+ self.vm = VirtualMethods()
+ self.evm = ExtendedVirtualMethods()
+
+ def tearDown(self):
+ del self.vm
+ del self.evm
+
+ def testModifiedVirtualMethod0(self):
+ '''Renamed virtual method.'''
+ a0, a1, a2 = 2, 3, 5
+ result0 = self.vm.callSum0(a0, a1, a2)
+ result1 = self.vm.sumThree(a0, a1, a2)
+ self.assertEqual(result0, a0 + a1 + a2)
+ self.assertEqual(result0, result1)
+ self.assertRaises(AttributeError, getattr, self.vm, 'sum0')
+
+ def testReimplementedModifiedVirtualMethod0(self):
+ '''Override of a renamed virtual method.'''
+ a0, a1, a2 = 2, 3, 5
+ result0 = self.vm.callSum0(a0, a1, a2)
+ result1 = self.vm.sumThree(a0, a1, a2)
+ result2 = self.evm.callSum0(a0, a1, a2)
+ self.assertEqual(result0, result1)
+ self.assertEqual(result0 * self.evm.multiplier, result2)
+ self.assertTrue(self.evm.sumThree_called)
+ self.assertFalse(self.evm.sum0_called)
+
+ def testModifiedVirtualMethod1(self):
+ '''Virtual method with three arguments and the last one
+ changed to have the default value set to 1000.'''
+ a0, a1, a2 = 2, 3, 5
+ result0 = self.vm.sum1(a0, a1)
+ self.assertEqual(result0, a0 + a1 + 1000)
+ result1 = self.vm.sum1(a0, a1, a2)
+ result2 = self.vm.callSum1(a0, a1, a2)
+ self.assertEqual(result1, result2)
+
+ def testReimplementedModifiedVirtualMethod1(self):
+ '''Override of the virtual method with three arguments and
+ the last one changed to have the default value set to 1000.'''
+ a0, a1 = 2, 3
+ result0 = self.vm.sum1(a0, a1)
+ result1 = self.evm.callSum1(a0, a1, 1000)
+ self.assertEqual(result0 * self.evm.multiplier, result1)
+ self.assertTrue(self.evm.sum1_called)
+
+ def testModifiedVirtualMethod2(self):
+ '''Virtual method originally with three arguments, the last
+ one was removed and the default value set to 2000.'''
+ a0, a1 = 1, 2
+ result0 = self.vm.sum2(a0, a1)
+ self.assertEqual(result0, a0 + a1 + 2000)
+ result1 = self.vm.sum2(a0, a1)
+ result2 = self.vm.callSum2(a0, a1, 2000)
+ self.assertEqual(result1, result2)
+ self.assertRaises(TypeError, self.vm.sum2, 1, 2, 3)
+
+ def testReimplementedModifiedVirtualMethod2(self):
+ '''Override of the virtual method originally with three arguments,
+ the last one was removed and the default value set to 2000.'''
+ a0, a1 = 1, 2
+ ignored = 54321
+ result0 = self.vm.sum2(a0, a1)
+ result1 = self.evm.callSum2(a0, a1, ignored)
+ self.assertEqual(result0 * self.evm.multiplier, result1)
+ self.assertTrue(self.evm.sum2_called)
+
+ def testModifiedVirtualMethod3(self):
+ '''Virtual method originally with three arguments have the second
+ one removed and replaced by custom code that replaces it by the sum
+ of the first and the last arguments.'''
+ a0, a1 = 1, 2
+ result0 = self.vm.sum3(a0, a1)
+ self.assertEqual(result0, a0 + (a0 + a1) + a1)
+ result1 = self.vm.callSum3(a0, 10, a1)
+ self.assertNotEqual(result0, result1)
+ result2 = self.vm.callSum3(a0, a0 + a1, a1)
+ self.assertEqual(result0, result2)
+ self.assertRaises(TypeError, self.vm.sum3, 1, 2, 3)
+
+ def testReimplementedModifiedVirtualMethod3(self):
+ '''Override of the virtual method originally with three arguments
+ have the second one removed and replaced by custom code that
+ replaces it by the sum of the first and the last arguments.'''
+ a0, a1 = 1, 2
+ ignored = 54321
+ result0 = self.vm.sum3(a0, a1)
+ result1 = self.evm.callSum3(a0, ignored, a1)
+ self.assertEqual(result0 * self.evm.multiplier, result1)
+ self.assertTrue(self.evm.sum3_called)
+
+ def testModifiedVirtualMethod4(self):
+ '''Virtual method originally with three arguments, the
+ last one was removed and the default value set to 3000.'''
+ a0, a1 = 1, 2
+ default_value = 3000
+ result0 = self.vm.sum4(a0, a1)
+ self.assertEqual(result0, a0 + default_value + a1)
+ removed_arg_value = 100
+ result1 = self.vm.callSum4(a0, removed_arg_value, a1)
+ self.assertEqual(result1, a0 + removed_arg_value + a1)
+ self.assertRaises(TypeError, self.vm.sum4, 1, 2, 3)
+
+ def testReimplementedModifiedVirtualMethod4(self):
+ '''Override of the virtual method originally with three arguments,
+ the last one was removed and the default value set to 3000.
+ The method was modified with code injection on the binding override
+ (the one that receives calls from C++ with the original signature
+ and forwards it to Python overrides) that subtracts the value of the
+ second argument (removed in Python) from the value of the first
+ before sending them to Python.'''
+ a0, a1 = 1, 2
+ removed_arg_value = 2011
+ default_value = 3000
+ result = self.evm.callSum4(a0, removed_arg_value, a1)
+ self.assertEqual(result, (a0 - removed_arg_value + a1 + default_value) * self.evm.multiplier)
+ self.assertTrue(self.evm.sum4_called)
+
+ def testOverridenMethodResultModification(self):
+ '''Injected code modifies the result of a call to a virtual
+ method overridden in Python.'''
+ orig_name = self.vm.callName()
+ self.assertEqual(orig_name, 'VirtualMethods')
+ name = self.evm.callName()
+ self.assertEqual(name, 'PimpedExtendedVirtualMethods')
+ self.assertEqual(name, Str('PimpedExtendedVirtualMethods'))
+ self.assertTrue(self.evm.name_called)
+
+ def testInjectCodeCallsPythonVirtualMethodOverride(self):
+ '''When injected code calls the Python override by itself
+ no code for the method call should be generated.'''
+ self.evm.callCallMe()
+ self.assertEqual(self.evm.callMe_called, 1)
+
+ def testAllArgumentsRemoved(self):
+ values = (10, 20, 30, 40)
+ self.vm.setMargins(*values)
+ self.assertEqual(self.vm.getMargins(), values)
+
+ def testAllArgumentsRemovedCallVirtual(self):
+ values = (10, 20, 30, 40)
+ self.vm.setMargins(*values)
+ self.assertEqual(self.vm.callGetMargins(), values)
+
+ def testExtendedAllArgumentsRemoved(self):
+ values = (10, 20, 30, 40)
+ self.evm.setMargins(*values)
+ double = tuple([m*2 for m in values])
+ self.assertEqual(self.evm.getMargins(), double)
+
+ def testExtendedAllArgumentsRemovedCallVirtual(self):
+ values = (10, 20, 30, 40)
+ self.evm.setMargins(*values)
+ double = tuple([m*2 for m in values])
+ self.assertEqual(self.evm.callGetMargins(), double)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/multi_cpp_inheritance_test.py b/sources/shiboken2/tests/samplebinding/multi_cpp_inheritance_test.py
new file mode 100644
index 000000000..6546c3ac6
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/multi_cpp_inheritance_test.py
@@ -0,0 +1,105 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for multiple inheritance'''
+
+import sys
+import unittest
+
+from sample import *
+
+class SimpleUseCase(ObjectType, Str):
+ def __init__(self, name):
+ ObjectType.__init__(self)
+ Str.__init__(self, name)
+
+class SimpleUseCaseReverse(Str, ObjectType):
+ def __init__(self, name):
+ ObjectType.__init__(self)
+ Str.__init__(self, name)
+
+class SimpleUseCase2(SimpleUseCase):
+ def __init__(self, name):
+ SimpleUseCase.__init__(self, name)
+
+class ComplexUseCase(SimpleUseCase2, Point):
+ def __init__(self, name):
+ SimpleUseCase2.__init__(self, name)
+ Point.__init__(self)
+
+class ComplexUseCaseReverse(Point, SimpleUseCase2):
+ def __init__(self, name):
+ SimpleUseCase2.__init__(self, name)
+ Point.__init__(self)
+
+class MultipleCppDerivedTest(unittest.TestCase):
+ def testInstanciation(self):
+ s = SimpleUseCase("Hi")
+ self.assertEqual(s, "Hi")
+ s.setObjectName(s)
+ self.assertEqual(s.objectName(), "Hi")
+
+ def testInstanciation2(self):
+ s = SimpleUseCase2("Hi")
+ self.assertEqual(s, "Hi")
+ s.setObjectName(s)
+ self.assertEqual(s.objectName(), "Hi")
+
+ def testComplexInstanciation(self):
+ c = ComplexUseCase("Hi")
+ self.assertEqual(c, "Hi")
+ c.setObjectName(c)
+ self.assertEqual(c.objectName(), "Hi")
+ c.setX(2);
+ self.assertEqual(c.x(), 2)
+
+class MultipleCppDerivedReverseTest(unittest.TestCase):
+ def testInstanciation(self):
+ s = SimpleUseCaseReverse("Hi")
+ self.assertEqual(s, "Hi")
+ s.setObjectName(s)
+ self.assertEqual(s.objectName(), "Hi")
+
+ def testInstanciation2(self):
+ s = SimpleUseCase2("Hi")
+ self.assertEqual(s, "Hi")
+ s.setObjectName(s)
+ self.assertEqual(s.objectName(), "Hi")
+
+ def testComplexInstanciation(self):
+ c = ComplexUseCaseReverse("Hi")
+ c.setObjectName(c)
+ self.assertEqual(c.objectName(), "Hi")
+ c.setX(2);
+ self.assertEqual(c, Point(2, 0))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/multiple_derived_test.py b/sources/shiboken2/tests/samplebinding/multiple_derived_test.py
new file mode 100644
index 000000000..e84cc76fd
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/multiple_derived_test.py
@@ -0,0 +1,221 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for multiple inheritance'''
+
+import sys
+import unittest
+
+from sample import Base1, Base2, Base3, Base4, Base5, Base6
+from sample import MDerived1, MDerived2, MDerived3, MDerived4, MDerived5, SonOfMDerived1
+
+class ExtMDerived1(MDerived1):
+ def __init__(self):
+ MDerived1.__init__(self)
+ self.multiplier = 20
+ self.base2Method_called = False
+ def base2Method(self):
+ return Base2.base2Method(self) * self.multiplier
+
+class MultipleDerivedTest(unittest.TestCase):
+ '''Test cases for multiple inheritance'''
+
+ def testIsInstance(self):
+ '''MDerived1 is instance of its parents Base1 and Base2.'''
+ a = MDerived1()
+ self.assertTrue(isinstance(a, MDerived1))
+ self.assertTrue(isinstance(a, Base1))
+ self.assertTrue(isinstance(a, Base2))
+
+ def testIsSubclass(self):
+ '''MDerived1 is subclass of its parents Base1 and Base2.'''
+ self.assertTrue(issubclass(MDerived1, Base1))
+ self.assertTrue(issubclass(MDerived1, Base2))
+
+ def testCallToFunctionWithBase1ArgumentThatCastsBackToMDerived1(self):
+ '''MDerived1 is passed as an Base1 argument to a method that returns it casted back to MDerived1.'''
+ a = MDerived1()
+ b = MDerived1.transformFromBase1(a)
+ self.assertEqual(a, b)
+
+ def testCallToFunctionWithBase2ArgumentThatCastsBackToMDerived1(self):
+ '''MDerived1 is passed as an Base2 argument to a method that returns it casted back to MDerived1.'''
+ a = MDerived1()
+ b = MDerived1.transformFromBase2(a)
+ self.assertEqual(a, b)
+
+ def testPythonClassIsInstance(self):
+ '''Python defined class ExtMDerived1 is instance of its parents MDerived1, Base1 and Base2.'''
+ a = ExtMDerived1()
+ self.assertTrue(isinstance(a, ExtMDerived1))
+ self.assertTrue(isinstance(a, MDerived1))
+ self.assertTrue(isinstance(a, Base1))
+ self.assertTrue(isinstance(a, Base2))
+
+ def testPythonClassIsSubclass(self):
+ '''Python defined class ExtMDerived1 is subclass of its parents MDerived1, Base1 and Base2.'''
+ self.assertTrue(issubclass(ExtMDerived1, MDerived1))
+ self.assertTrue(issubclass(ExtMDerived1, Base1))
+ self.assertTrue(issubclass(ExtMDerived1, Base2))
+
+ def testCastFromMDerived1ToBases(self):
+ '''MDerived1 is casted by C++ to its parents and the binding must return the MDerived1 wrapper.'''
+ a = MDerived1()
+ refcnt = sys.getrefcount(a)
+ b1 = a.castToBase1()
+ b2 = a.castToBase2()
+ self.assertTrue(isinstance(b1, MDerived1))
+ self.assertTrue(isinstance(b2, MDerived1))
+ self.assertEqual(a, b1)
+ self.assertEqual(a, b2)
+ self.assertEqual(sys.getrefcount(a), refcnt + 2)
+
+ def testCastFromExtMDerived1ToMDerived1Bases(self):
+ '''Python defined class ExtMDerived1 is casted by C++ to MDerived1 parents and the binding must return the correct ExtMDerived1 instance.'''
+ a = ExtMDerived1()
+ refcnt = sys.getrefcount(a)
+ b1 = a.castToBase1()
+ self.assertTrue(isinstance(b1, MDerived1))
+ self.assertTrue(isinstance(b1, ExtMDerived1))
+ b2 = a.castToBase2()
+ self.assertTrue(isinstance(b2, MDerived1))
+ self.assertTrue(isinstance(b2, ExtMDerived1))
+ self.assertEqual(a, b1)
+ self.assertEqual(a, b2)
+ self.assertEqual(sys.getrefcount(a), refcnt + 2)
+
+ def testCastFromSonOfMDerived1ToBases(self):
+ '''SonOfMDerived1 is casted by C++ to its parents and the binding must return the SonOfMDerived1 wrapper.'''
+ a = SonOfMDerived1()
+ refcnt = sys.getrefcount(a)
+ md1 = a.castToMDerived1()
+ b1 = a.castToBase1()
+ b2 = a.castToBase2()
+ self.assertTrue(isinstance(md1, SonOfMDerived1))
+ self.assertTrue(isinstance(b2, SonOfMDerived1))
+ self.assertTrue(isinstance(b2, SonOfMDerived1))
+ self.assertEqual(a, md1)
+ self.assertEqual(a, b1)
+ self.assertEqual(a, b2)
+ self.assertEqual(sys.getrefcount(a), refcnt + 3)
+
+ def testReimplementedBase2VirtualMethodOnClassInheritingFromMDerived1(self):
+ a = ExtMDerived1()
+ value = a.base2Method()
+ self.assertTrue(value, Base2.base2Method(a) * a.multiplier)
+
+ def testCastFromMDerived2ToBases(self):
+ '''MDerived2 is casted by C++ to its parents and the binding must return the MDerived2 wrapper.'''
+ a = MDerived2()
+ refcnt = sys.getrefcount(a)
+ b3 = a.castToBase3()
+ b4 = a.castToBase4()
+ b5 = a.castToBase5()
+ b6 = a.castToBase6()
+ self.assertTrue(isinstance(b3, MDerived2))
+ self.assertTrue(isinstance(b4, MDerived2))
+ self.assertTrue(isinstance(b5, MDerived2))
+ self.assertTrue(isinstance(b6, MDerived2))
+ self.assertEqual(a, b3)
+ self.assertEqual(a, b4)
+ self.assertEqual(a, b5)
+ self.assertEqual(a, b6)
+ self.assertEqual(sys.getrefcount(a), refcnt + 4)
+
+ def testCastFromMDerived3ToBases(self):
+ '''MDerived3 is casted by C++ to its parents and the binding must return the MDerived3 wrapper.'''
+ a = MDerived3()
+ refcnt = sys.getrefcount(a)
+ md1 = a.castToMDerived1()
+ md2 = a.castToMDerived2()
+ b1 = a.castToBase1()
+ b2 = a.castToBase2()
+ b3 = a.castToBase3()
+ b4 = a.castToBase4()
+ b5 = a.castToBase5()
+ b6 = a.castToBase6()
+ self.assertTrue(isinstance(md1, MDerived3))
+ self.assertTrue(isinstance(md2, MDerived3))
+ self.assertTrue(isinstance(b1, MDerived3))
+ self.assertTrue(isinstance(b2, MDerived3))
+ self.assertTrue(isinstance(b3, MDerived3))
+ self.assertTrue(isinstance(b4, MDerived3))
+ self.assertTrue(isinstance(b5, MDerived3))
+ self.assertTrue(isinstance(b6, MDerived3))
+ self.assertEqual(a, md1)
+ self.assertEqual(a, md2)
+ self.assertEqual(a, b1)
+ self.assertEqual(a, b2)
+ self.assertEqual(a, b3)
+ self.assertEqual(a, b4)
+ self.assertEqual(a, b5)
+ self.assertEqual(a, b6)
+ self.assertEqual(sys.getrefcount(a), refcnt + 8)
+
+ def testCastFromMDerived4ToBases(self):
+ '''MDerived4 is casted by C++ to its parents and the binding must return the MDerived4 wrapper.'''
+ a = MDerived4()
+ refcnt = sys.getrefcount(a)
+ b3 = a.castToBase3()
+ b4 = a.castToBase4()
+ self.assertTrue(isinstance(b3, MDerived4))
+ self.assertTrue(isinstance(b4, MDerived4))
+ self.assertEqual(a, b3)
+ self.assertEqual(a, b4)
+ self.assertEqual(sys.getrefcount(a), refcnt + 2)
+
+ def testCastFromMDerived5ToBases(self):
+ '''MDerived5 is casted by C++ to its parents and the binding must return the MDerived5 wrapper.'''
+ a = MDerived5()
+ refcnt = sys.getrefcount(a)
+ b3 = a.castToBase3()
+ b4 = a.castToBase4()
+ self.assertTrue(isinstance(b3, MDerived5))
+ self.assertTrue(isinstance(b4, MDerived5))
+ self.assertEqual(a, b3)
+ self.assertEqual(a, b4)
+ self.assertEqual(sys.getrefcount(a), refcnt + 2)
+
+ def testCastFromMDerived3ToBase3(self):
+ '''MDerived3 is casted by C++ to Base3 grandparent using both the inherited and reimplement castToBase3 methods.'''
+ a = MDerived3()
+ refcnt = sys.getrefcount(a)
+ b3_reimplemented = a.castToBase3()
+ b3_inherited = MDerived2.castToBase3(a)
+ self.assertTrue(isinstance(b3_reimplemented, MDerived3))
+ self.assertTrue(isinstance(b3_inherited, MDerived3))
+ self.assertEqual(a, b3_reimplemented)
+ self.assertEqual(a, b3_inherited)
+ self.assertEqual(sys.getrefcount(a), refcnt + 2)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/namespace_test.py b/sources/shiboken2/tests/samplebinding/namespace_test.py
new file mode 100644
index 000000000..653b9081b
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/namespace_test.py
@@ -0,0 +1,69 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for std::map container conversions'''
+
+import unittest
+from sample import *
+from py3kcompat import IS_PY3K
+
+if IS_PY3K:
+ TYPE_STR = "class"
+else:
+ TYPE_STR = "type"
+
+class TestEnumUnderNamespace(unittest.TestCase):
+ def testInvisibleNamespace(self):
+ o1 = EnumOnNamespace.Option1
+ self.assertEqual(o1, 1)
+
+class TestClassesUnderNamespace(unittest.TestCase):
+ def testIt(self):
+ c1 = SampleNamespace.SomeClass()
+ e1 = SampleNamespace.SomeClass.ProtectedEnum()
+ c2 = SampleNamespace.SomeClass.SomeInnerClass()
+ e2 = SampleNamespace.SomeClass.SomeInnerClass.ProtectedEnum()
+ c3 = SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough()
+ e3 = SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum()
+
+ def testFunctionAddedOnNamespace(self):
+ res = SampleNamespace.ImInsideANamespace(2, 2)
+ self.assertEqual(res, 4)
+
+ def testTpNames(self):
+ self.assertEqual(str(SampleNamespace.SomeClass), "<%s 'sample.SampleNamespace.SomeClass'>"%TYPE_STR)
+ self.assertEqual(str(SampleNamespace.SomeClass.ProtectedEnum), "<%s 'sample.SampleNamespace.SomeClass.ProtectedEnum'>"%TYPE_STR)
+ self.assertEqual(str(SampleNamespace.SomeClass.SomeInnerClass.ProtectedEnum), "<%s 'sample.SampleNamespace.SomeClass.SomeInnerClass.ProtectedEnum'>"%TYPE_STR)
+ self.assertEqual(str(SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough), "<%s 'sample.SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough'>"%TYPE_STR)
+ self.assertEqual(str(SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum), "<%s 'sample.SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum'>"%TYPE_STR)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/newdivision_test.py b/sources/shiboken2/tests/samplebinding/newdivision_test.py
new file mode 100644
index 000000000..d1a2eda75
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/newdivision_test.py
@@ -0,0 +1,42 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from __future__ import division
+from sample import *
+import unittest
+
+class TestNewDivision(unittest.TestCase):
+
+ def testIt(self):
+ p = Point(4, 4)
+ p2 = p/2
+ self.assertEqual(p2, Point(2, 2))
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/nondefaultctor_test.py b/sources/shiboken2/tests/samplebinding/nondefaultctor_test.py
new file mode 100644
index 000000000..e38dc9455
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/nondefaultctor_test.py
@@ -0,0 +1,71 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for ...'''
+
+import sys
+import unittest
+
+from sample import NonDefaultCtor
+
+class DerivedNonDefaultCtor (NonDefaultCtor):
+ def returnMyselfVirtual(self):
+ return NonDefaultCtor(self.value()+1)
+
+class AnotherDerivedNonDefaultCtor (NonDefaultCtor):
+ def __init__(self, some_string):
+ pass
+
+class NonDefaultCtorTest(unittest.TestCase):
+
+ def testNonDefaultCtor(self):
+ c = NonDefaultCtor(2)
+ # these functions returns NonDefaultCtor by value, so a PyObjecy is created every time
+ self.assertNotEqual(c.returnMyself(), c)
+ self.assertEqual(c.returnMyself().value(), 2)
+ self.assertNotEqual(c.returnMyself(3), c)
+ self.assertEqual(c.returnMyself(3).value(), 2)
+ self.assertNotEqual(c.returnMyself(4, c), c)
+ self.assertEqual(c.returnMyself(4, c).value(), 2)
+
+ def testVirtuals(self):
+ c = DerivedNonDefaultCtor(3)
+ # these functions returns NonDefaultCtor by value, so a PyObjecy is created every time
+ self.assertNotEqual(c.returnMyselfVirtual(), c)
+ self.assertEqual(c.returnMyselfVirtual().value(), 4)
+ self.assertEqual(c.callReturnMyselfVirtual().value(), 4)
+
+ def testCtorOverload(self):
+ c = AnotherDerivedNonDefaultCtor("testing")
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/nonzero_test.py b/sources/shiboken2/tests/samplebinding/nonzero_test.py
new file mode 100644
index 000000000..7020d30a8
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/nonzero_test.py
@@ -0,0 +1,43 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sample import *
+
+class TestNonZeroOperator(unittest.TestCase):
+ def testIt(self):
+ c = Color()
+ self.assertFalse(c)
+ c = Color(2)
+ self.assertTrue(c)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/numericaltypedef_test.py b/sources/shiboken2/tests/samplebinding/numericaltypedef_test.py
new file mode 100644
index 000000000..774b7f1d1
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/numericaltypedef_test.py
@@ -0,0 +1,56 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from sample import SizeF
+
+class NumericalTypedefTest(unittest.TestCase):
+
+ def testNumericalTypedefExact(self):
+ width, height = (1.1, 2.2)
+ size = SizeF(width, height)
+ self.assertEqual(size.width(), width)
+ self.assertEqual(size.height(), height)
+
+ def testNumericalTypedefConvertible(self):
+ width, height = (1, 2)
+ size = SizeF(width, height)
+ self.assertEqual(size.width(), float(width))
+ self.assertEqual(size.height(), float(height))
+
+ def testNumericalTypedefOfUnsignedShort(self):
+ self.assertEqual(SizeF.passTypedefOfUnsignedShort(123), 123)
+ self.assertEqual(SizeF.passTypedefOfUnsignedShort(321), 321)
+ self.assertNotEqual(SizeF.passTypedefOfUnsignedShort(123), 0)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/numpy_test.py b/sources/shiboken2/tests/samplebinding/numpy_test.py
new file mode 100644
index 000000000..65861e864
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/numpy_test.py
@@ -0,0 +1,58 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import sys
+
+try:
+ from distutils import sysconfig
+ if bool(sysconfig.get_config_var('Py_DEBUG')):
+ sys.exit(0)
+ import numpy
+except:
+ sys.exit(0)
+
+import unittest
+from sample import PointF
+
+class TestNumpyTypes(unittest.TestCase):
+
+ def testNumpyConverted(self):
+ x, y = (0.1, 0.2)
+ p = PointF(float(numpy.float32(x)), float(numpy.float32(y)))
+ self.assertAlmostEqual(p.x(), x)
+ self.assertAlmostEqual(p.y(), y)
+
+ def testNumpyAsIs(self):
+ x, y = (0.1, 0.2)
+ p = PointF(numpy.float32(x), numpy.float32(y))
+ self.assertAlmostEqual(p.x(), x)
+ self.assertAlmostEqual(p.y(), y)
+
+if __name__ == "__main__":
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/objecttype_test.py b/sources/shiboken2/tests/samplebinding/objecttype_test.py
new file mode 100644
index 000000000..1a06e7e08
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/objecttype_test.py
@@ -0,0 +1,122 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests ObjectType class of object-type with privates copy constructor and = operator.'''
+
+import unittest
+import sys
+
+from sample import ObjectType, Str
+import shiboken2 as shiboken
+
+
+class ObjectTypeTest(unittest.TestCase):
+ '''Test cases ObjectType class of object-type with privates copy constructor and = operator.'''
+
+ def testObjectTypeSetObjectNameWithStrVariable(self):
+ '''ObjectType.setObjectName with Str variable as argument.'''
+ s = Str('object name')
+ o = ObjectType()
+ o.setObjectName(s)
+ self.assertEqual(str(o.objectName()), str(s))
+
+ def testObjectTypeSetObjectNameWithStrInstantiation(self):
+ '''ObjectType.setObjectName with Str instantiation as argument.'''
+ s = 'object name'
+ o = ObjectType()
+ o.setObjectName(Str(s))
+ self.assertEqual(str(o.objectName()), s)
+
+ def testObjectTypeSetObjectNameWithPythonString(self):
+ '''ObjectType.setObjectName with Python string as argument.'''
+ o = ObjectType()
+ o.setObjectName('object name')
+ self.assertEqual(str(o.objectName()), 'object name')
+
+ def testNullOverload(self):
+ o = ObjectType()
+ o.setObject(None)
+ self.assertEqual(o.callId(), 0)
+ o.setNullObject(None)
+ self.assertEqual(o.callId(), 1)
+
+ def testParentFromCpp(self):
+ o = ObjectType()
+ self.assertEqual(sys.getrefcount(o), 2)
+ o.getCppParent().setObjectName('parent')
+ self.assertEqual(sys.getrefcount(o), 3)
+ o.getCppParent().setObjectName('parent')
+ self.assertEqual(sys.getrefcount(o), 3)
+ o.getCppParent().setObjectName('parent')
+ self.assertEqual(sys.getrefcount(o), 3)
+ o.getCppParent().setObjectName('parent')
+ self.assertEqual(sys.getrefcount(o), 3)
+ o.getCppParent().setObjectName('parent')
+ self.assertEqual(sys.getrefcount(o), 3)
+ o.destroyCppParent()
+ self.assertEqual(sys.getrefcount(o), 2)
+
+ def testNextInFocusChainCycle(self):
+ parent = ObjectType()
+ child = ObjectType(parent)
+ next_focus = child.nextInFocusChain()
+
+ shiboken.invalidate(parent)
+
+ def testNextInFocusChainCycleList(self):
+ '''As above but in for a list of objects'''
+ parents = []
+ children = []
+ focus_chains = []
+ for i in range(10):
+ parent = ObjectType()
+ child = ObjectType(parent)
+ next_focus = child.nextInFocusChain()
+ parents.append(parent)
+ children.append(child)
+ focus_chains.append(next_focus)
+
+ shiboken.invalidate(parents)
+
+ def testClassDecref(self):
+ # Bug was that class PyTypeObject wasn't decrefed when instance died
+ before = sys.getrefcount(ObjectType)
+
+ for i in range(1000):
+ obj = ObjectType()
+ shiboken.delete(obj)
+
+ after = sys.getrefcount(ObjectType)
+
+ self.assertLess(abs(before - after), 5)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/objecttype_with_named_args_test.py b/sources/shiboken2/tests/samplebinding/objecttype_with_named_args_test.py
new file mode 100755
index 000000000..533b5a5d1
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/objecttype_with_named_args_test.py
@@ -0,0 +1,72 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from sample import ObjectType
+
+class NamedArgsTest(unittest.TestCase):
+
+ def testOneArgument(self):
+ p = ObjectType()
+ o = ObjectType(parent=p)
+ self.assertEqual(o.parent(), p)
+
+ def testMoreArguments(self):
+ o = ObjectType()
+
+ o.setObjectSplittedName("", prefix="pys", suffix="ide")
+ self.assertEqual(o.objectName(), "pyside")
+
+ o.setObjectSplittedName("", suffix="ide", prefix="pys")
+ self.assertEqual(o.objectName(), "pyside")
+
+ o.setObjectNameWithSize(name="pyside", size=6)
+ self.assertEqual(o.objectName(), "pyside")
+
+ o.setObjectNameWithSize(size=6, name="pyside")
+ self.assertEqual(o.objectName(), "pyside")
+
+
+ def testUseDefaultValues(self):
+ o = ObjectType()
+
+ o.setObjectNameWithSize(size=3)
+ self.assertEqual(o.objectName(), "<un") # use name='unknown' default argument
+
+ o.setObjectSplittedName("")
+ self.assertEqual(o.objectName(), "<unknown>") # user prefix='<unk' and suffix='nown>'
+
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/objecttypebyvalue_test.py b/sources/shiboken2/tests/samplebinding/objecttypebyvalue_test.py
new file mode 100644
index 000000000..a9938b8af
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/objecttypebyvalue_test.py
@@ -0,0 +1,42 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from sample import *
+import unittest
+
+class ObjectTypeByValueTest (unittest.TestCase):
+ def testIt(self):
+ factory = ObjectTypeByValue()
+ obj = factory.returnSomeKindOfMe()
+ # This should crash!
+ obj.prop.protectedValueTypeProperty.setX(1.0)
+ # just to make sure it will segfault
+ obj.prop.protectedValueTypeProperty.setY(2.0)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/objecttypelayout_test.py b/sources/shiboken2/tests/samplebinding/objecttypelayout_test.py
new file mode 100644
index 000000000..4d0e8cab7
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/objecttypelayout_test.py
@@ -0,0 +1,302 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests cases for ObjectTypeLayout class.'''
+
+import sys
+import unittest
+
+from sample import *
+
+
+class ObjectTypeLayoutTest(unittest.TestCase):
+ '''Test cases for ObjectTypeLayout class.'''
+
+ def testOwnershipOverride(self):
+ l = ObjectTypeLayout()
+
+ o1 = ObjectType(l)
+ o1.setObjectName('o1')
+
+ self.assertEqual(sys.getrefcount(o1), 3)
+ l.takeChild('o1')
+ self.assertEqual(sys.getrefcount(o1), 2)
+
+
+ def testSetNullLayout(self):
+ '''ObjectType.setLayout(0).'''
+ o2 = ObjectType()
+ o2.setLayout(None)
+
+ def testSetNullLayoutToObjectTypeCreatedInCpp(self):
+ '''ObjectType.setLayout(0) to object created in C++.'''
+ o1 = ObjectType.create()
+ o1.setLayout(None)
+
+ def testObjectTypeLayout(self):
+ '''ObjectType.setLayout.'''
+ p1 = ObjectType()
+ c1 = ObjectType()
+ c2 = ObjectType()
+ c3 = ObjectType()
+ layout = ObjectTypeLayout()
+ layout.addObject(c1)
+ layout.addObject(c2)
+ layout.addObject(c3)
+ self.assertEqual(c1.parent(), None)
+ self.assertEqual(c2.parent(), None)
+ self.assertEqual(c3.parent(), None)
+
+ p1.setLayout(layout)
+ del p1 # This must kill c1, c2 and c3
+
+ self.assertRaises(RuntimeError, c1.objectName)
+ self.assertRaises(RuntimeError, c2.objectName)
+ self.assertRaises(RuntimeError, c3.objectName)
+ self.assertRaises(RuntimeError, layout.objectName)
+
+ def testObjectTypeLayoutWithObjectsCreatedInCpp(self):
+ '''ObjectType.setLayout with objects created in C++.'''
+ p1 = ObjectType.create()
+ c1 = ObjectType.create()
+ c2 = ObjectType.create()
+ c3 = ObjectType.create()
+ layout = ObjectTypeLayout()
+ layout.addObject(c1)
+ layout.addObject(c2)
+ layout.addObject(c3)
+ self.assertEqual(c1.parent(), None)
+ self.assertEqual(c2.parent(), None)
+ self.assertEqual(c3.parent(), None)
+
+ p1.setLayout(layout)
+ del p1 # This must kill c1, c2 and c3
+
+ self.assertRaises(RuntimeError, c1.objectName)
+ self.assertRaises(RuntimeError, c2.objectName)
+ self.assertRaises(RuntimeError, c3.objectName)
+ self.assertRaises(RuntimeError, layout.objectName)
+
+ def testObjectTypeLayoutTransference(self):
+ '''Transfer a layout from one ObjectType to another, so that all the items in the layout get reparented.'''
+ p1 = ObjectType()
+ p2 = ObjectType()
+ c1 = ObjectType()
+ c2 = ObjectType()
+
+ layout = ObjectTypeLayout()
+ layout.addObject(c1)
+ layout.addObject(c2)
+
+ p1.setLayout(layout)
+
+ self.assertEqual(len(p2.children()), 0)
+ self.assertEqual(c1.parent(), p1)
+ self.assertEqual(c2.parent(), p1)
+ self.assertEqual(set(p1.children()), set([c1, c2, layout]))
+
+ p2.setLayout(layout)
+
+ self.assertEqual(len(p1.children()), 0)
+ self.assertEqual(c1.parent(), p2)
+ self.assertEqual(c2.parent(), p2)
+ self.assertEqual(set(p2.children()), set([c1, c2, layout]))
+
+ def testObjectTypeLayoutInsideAnotherLayout(self):
+ '''Adds one ObjectTypeLayout to another and sets the parent to an ObjectType.'''
+ p1 = ObjectType()
+
+ l1 = ObjectTypeLayout()
+ c1 = ObjectType()
+ l1.addObject(c1)
+ c2 = ObjectType()
+ l1.addObject(c2)
+
+ l2 = ObjectTypeLayout()
+ c3 = ObjectType()
+ l2.addObject(c3)
+ c4 = ObjectType()
+ l2.addObject(c4)
+
+ l1.addObject(l2)
+
+ p1.setLayout(l1)
+
+ self.assertEqual(c1.parent(), p1)
+ self.assertEqual(c2.parent(), p1)
+ self.assertEqual(c3.parent(), p1)
+ self.assertEqual(c4.parent(), p1)
+ self.assertEqual(l1.parent(), p1)
+ self.assertEqual(l2.parent(), l1)
+
+ del p1
+
+ self.assertRaises(RuntimeError, c1.objectName)
+ self.assertRaises(RuntimeError, c2.objectName)
+ self.assertRaises(RuntimeError, c3.objectName)
+ self.assertRaises(RuntimeError, c4.objectName)
+ self.assertRaises(RuntimeError, l1.objectName)
+ self.assertRaises(RuntimeError, l2.objectName)
+
+ def testObjectTypeLayoutInsideAnotherLayoutAndEveryoneCreatedInCpp(self):
+ '''Adds one ObjectTypeLayout to another and sets the parent to an ObjectType. All the objects are created in C++.'''
+ p1 = ObjectType.create()
+
+ l1 = ObjectTypeLayout.create()
+ c1 = ObjectType.create()
+ l1.addObject(c1)
+ c2 = ObjectType.create()
+ l1.addObject(c2)
+
+ l2 = ObjectTypeLayout.create()
+ c3 = ObjectType.create()
+ l2.addObject(c3)
+ c4 = ObjectType.create()
+ l2.addObject(c4)
+
+ l1.addObject(l2)
+
+ p1.setLayout(l1)
+
+ self.assertEqual(c1.parent(), p1)
+ self.assertEqual(c2.parent(), p1)
+ self.assertEqual(c3.parent(), p1)
+ self.assertEqual(c4.parent(), p1)
+ self.assertEqual(l1.parent(), p1)
+ self.assertEqual(l2.parent(), l1)
+
+ del p1
+
+ self.assertRaises(RuntimeError, c1.objectName)
+ self.assertRaises(RuntimeError, c2.objectName)
+ self.assertRaises(RuntimeError, c3.objectName)
+ self.assertRaises(RuntimeError, c4.objectName)
+ self.assertRaises(RuntimeError, l1.objectName)
+ self.assertRaises(RuntimeError, l2.objectName)
+
+ def testTransferNestedLayoutsBetweenObjects(self):
+ '''Adds one ObjectTypeLayout to another, sets the parent to an ObjectType and then transfer it to another object.'''
+ p1 = ObjectType()
+ p2 = ObjectType()
+
+ l1 = ObjectTypeLayout()
+ c1 = ObjectType()
+ l1.addObject(c1)
+ c2 = ObjectType()
+ l1.addObject(c2)
+
+ l2 = ObjectTypeLayout()
+ c3 = ObjectType()
+ l2.addObject(c3)
+ c4 = ObjectType()
+ l2.addObject(c4)
+
+ l1.addObject(l2)
+
+ p1.setLayout(l1)
+
+ self.assertEqual(c1.parent(), p1)
+ self.assertEqual(c2.parent(), p1)
+ self.assertEqual(c3.parent(), p1)
+ self.assertEqual(c4.parent(), p1)
+ self.assertEqual(l1.parent(), p1)
+ self.assertEqual(l2.parent(), l1)
+
+ p2.setLayout(l1)
+ del p1
+
+ self.assertEqual(c1.parent(), p2)
+ self.assertEqual(c2.parent(), p2)
+ self.assertEqual(c3.parent(), p2)
+ self.assertEqual(c4.parent(), p2)
+ self.assertEqual(l1.parent(), p2)
+ self.assertEqual(l2.parent(), l1)
+
+ del p2
+
+ self.assertRaises(RuntimeError, c1.objectName)
+ self.assertRaises(RuntimeError, c2.objectName)
+ self.assertRaises(RuntimeError, c3.objectName)
+ self.assertRaises(RuntimeError, c4.objectName)
+ self.assertRaises(RuntimeError, l1.objectName)
+ self.assertRaises(RuntimeError, l2.objectName)
+
+ def testTransferNestedLayoutsBetweenObjectsAndEveryoneCreatedInCpp(self):
+ '''Adds one ObjectTypeLayout to another, sets the parent to an ObjectType and then transfer it to another object.
+ All the objects are created in C++.'''
+ p1 = ObjectType.create()
+ p2 = ObjectType.create()
+
+ l1 = ObjectTypeLayout.create()
+ c1 = ObjectType.create()
+ l1.addObject(c1)
+ c2 = ObjectType.create()
+ l1.addObject(c2)
+
+ l2 = ObjectTypeLayout.create()
+ c3 = ObjectType.create()
+ l2.addObject(c3)
+ c4 = ObjectType.create()
+ l2.addObject(c4)
+
+ l1.addObject(l2)
+
+ p1.setLayout(l1)
+
+ self.assertEqual(c1.parent(), p1)
+ self.assertEqual(c2.parent(), p1)
+ self.assertEqual(c3.parent(), p1)
+ self.assertEqual(c4.parent(), p1)
+ self.assertEqual(l1.parent(), p1)
+ self.assertEqual(l2.parent(), l1)
+
+ p2.setLayout(l1)
+ del p1
+
+ self.assertEqual(c1.parent(), p2)
+ self.assertEqual(c2.parent(), p2)
+ self.assertEqual(c3.parent(), p2)
+ self.assertEqual(c4.parent(), p2)
+ self.assertEqual(l1.parent(), p2)
+ self.assertEqual(l2.parent(), l1)
+
+ del p2
+
+ self.assertRaises(RuntimeError, c1.objectName)
+ self.assertRaises(RuntimeError, c2.objectName)
+ self.assertRaises(RuntimeError, c3.objectName)
+ self.assertRaises(RuntimeError, c4.objectName)
+ self.assertRaises(RuntimeError, l1.objectName)
+ self.assertRaises(RuntimeError, l2.objectName)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/objecttypeoperators_test.py b/sources/shiboken2/tests/samplebinding/objecttypeoperators_test.py
new file mode 100644
index 000000000..a8bcf1aa0
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/objecttypeoperators_test.py
@@ -0,0 +1,60 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sample import *
+
+class ObjectTypeOperatorsTest(unittest.TestCase):
+
+ def testIt(self):
+ a = ObjectTypeOperators("a")
+ b = ObjectTypeOperators("b")
+ self.assertFalse(a == b)
+ self.assertEqual(a, a < b)
+
+ # this should change a.key() and return nothing.
+ self.assertEqual(None, a > b)
+ self.assertEqual(a.key(), "aoperator>")
+
+ def testPointerOpeators(self):
+ a = ObjectTypeOperators("a")
+ b = ObjectTypeOperators("b")
+ self.assertEqual(a + "bc", "abc")
+ self.assertEqual("bc" + a, "bca")
+ self.assertEqual("a", a)
+ self.assertEqual(a, "a")
+
+ def testOperatorInjection(self):
+ a = ObjectTypeOperators("a")
+ self.assertNotEqual(a, "b")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/objecttypereferenceasvirtualmethodargument_test.py b/sources/shiboken2/tests/samplebinding/objecttypereferenceasvirtualmethodargument_test.py
new file mode 100644
index 000000000..3f09df200
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/objecttypereferenceasvirtualmethodargument_test.py
@@ -0,0 +1,49 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sample import ObjectTypeHolder
+
+class TestObjectTypeReferenceAsVirtualMethodArgument(unittest.TestCase):
+
+ def testBasic(self):
+ holder = ObjectTypeHolder('TheObjectFromC++')
+ self.assertEqual(holder.callPassObjectTypeAsReference(), 'TheObjectFromC++')
+
+ def testExtended(self):
+ class Holder(ObjectTypeHolder):
+ def passObjectTypeAsReference(self, objectType):
+ return objectType.objectName().prepend(('ThisIs'))
+ holder = Holder('TheObjectFromC++')
+ self.assertEqual(holder.callPassObjectTypeAsReference(), 'ThisIsTheObjectFromC++')
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/oddbool_test.py b/sources/shiboken2/tests/samplebinding/oddbool_test.py
new file mode 100644
index 000000000..3424d9dc0
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/oddbool_test.py
@@ -0,0 +1,78 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for OddBool user's primitive type conversion.'''
+
+import unittest
+
+from sample import OddBoolUser
+
+class DerivedOddBoolUser (OddBoolUser):
+ def returnMyselfVirtual(self):
+ return OddBoolUser()
+ pass
+
+class OddBoolTest(unittest.TestCase):
+
+ def testOddBoolUser(self):
+ obuTrue = OddBoolUser()
+ obuFalse = OddBoolUser()
+ obuTrue.setOddBool(True)
+ self.assertEqual(obuFalse.oddBool(), False)
+ self.assertEqual(obuTrue.oddBool(), True)
+ self.assertEqual(obuTrue.callInvertedOddBool(), False)
+
+ self.assertEqual(obuTrue.oddBool() == True, True)
+ self.assertEqual(False == obuFalse.oddBool(), True)
+ self.assertEqual(obuTrue.oddBool() == obuFalse.oddBool(), False)
+
+ self.assertEqual(obuFalse.oddBool() != True, True)
+ self.assertEqual(True != obuFalse.oddBool(), True)
+ self.assertEqual(obuTrue.oddBool() != obuFalse.oddBool(), True)
+
+ def testVirtuals(self):
+ dobu = DerivedOddBoolUser()
+ self.assertEqual(dobu.invertedOddBool(), True)
+
+ def testImplicitConversionWithUsersPrimitiveType(self):
+ obu = OddBoolUser(True)
+ self.assertTrue(obu.oddBool())
+ obu = OddBoolUser(False)
+ self.assertFalse(obu.oddBool())
+ cpx = complex(1.0, 0.0)
+ obu = OddBoolUser(cpx)
+ self.assertTrue(obu.oddBool())
+ cpx = complex(0.0, 0.0)
+ obu = OddBoolUser(cpx)
+ self.assertFalse(obu.oddBool())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/oldstyleclass_as_number_test.py b/sources/shiboken2/tests/samplebinding/oldstyleclass_as_number_test.py
new file mode 100644
index 000000000..a4f52e1fe
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/oldstyleclass_as_number_test.py
@@ -0,0 +1,82 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+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/onlycopyclass_test.py b/sources/shiboken2/tests/samplebinding/onlycopyclass_test.py
new file mode 100644
index 000000000..647d2cdd7
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/onlycopyclass_test.py
@@ -0,0 +1,57 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sample import OnlyCopy, FriendOfOnlyCopy
+
+class ClassWithOnlyCopyCtorTest(unittest.TestCase):
+ def testGetOne(self):
+ obj = FriendOfOnlyCopy.createOnlyCopy(123)
+ self.assertEqual(type(obj), OnlyCopy)
+ self.assertEqual(obj.value(), 123)
+
+ def testGetMany(self):
+ objs = FriendOfOnlyCopy.createListOfOnlyCopy(3)
+ self.assertEqual(type(objs), list)
+ self.assertEqual(len(objs), 3)
+ for value, obj in enumerate(objs):
+ self.assertEqual(obj.value(), value)
+
+ def testPassAsValue(self):
+ obj = FriendOfOnlyCopy.createOnlyCopy(123)
+ self.assertEqual(obj.value(), OnlyCopy.getValue(obj))
+
+ def testPassAsReference(self):
+ obj = FriendOfOnlyCopy.createOnlyCopy(123)
+ self.assertEqual(obj.value(), OnlyCopy.getValueFromReference(obj))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/overflow_test.py b/sources/shiboken2/tests/samplebinding/overflow_test.py
new file mode 100644
index 000000000..8a0fff45d
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/overflow_test.py
@@ -0,0 +1,87 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for overflowing C++ numeric types.'''
+
+import sys
+import unittest
+
+from sample import *
+from py3kcompat import IS_PY3K, long
+
+class OverflowTest(unittest.TestCase):
+ '''Test case for overflowing C++ numeric types.'''
+
+ def testUnsignedInt(self):
+ '''C++ function receives an unsigned int argument and raise OverflowError if the value is negative.'''
+ val = 100
+ self.assertEqual(doubleUnsignedInt(val), 2 * val)
+ val *= -1
+ self.assertRaises(OverflowError, doubleUnsignedInt, val)
+
+ def testLongLong(self):
+ '''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)
+ self.assertEqual(doubleLongLong(val), 2 * val)
+ val = (2 << 64) + 1
+ self.assertRaises(OverflowError, doubleLongLong, val)
+
+ def testUnsignedLongLong(self):
+ '''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)
+ self.assertEqual(doubleUnsignedLongLong(val), 2 * val)
+ val = -100
+ self.assertRaises(OverflowError, doubleUnsignedLongLong, val)
+ val = long(-200)
+ self.assertRaises(OverflowError, doubleUnsignedLongLong, val)
+
+ def testOverflow(self):
+ '''Calls function with unsigned int parameter using an overflowing value.'''
+ self.assertRaises(OverflowError, doubleUnsignedInt, 42415335332353253)
+ doubleUnsignedInt(0xdeadbeef)
+
+ def testShortOverflow(self):
+ '''Calls function with short parameter using an overflowing value.'''
+ doubleShort(-3)
+ self.assertRaises(OverflowError, doubleShort, 0xFFFF*-1)
+ self.assertRaises(OverflowError, doubleShort, 0xFFFF + 1)
+
+ def testOverflowOnCtor(self):
+ '''Calls object ctor with int parameter using overflowing values.'''
+ self.assertRaises(OverflowError, Point, 42415335332353253, 42415335332353253)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/overload_sorting_test.py b/sources/shiboken2/tests/samplebinding/overload_sorting_test.py
new file mode 100644
index 000000000..30e1ad955
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/overload_sorting_test.py
@@ -0,0 +1,92 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for overload sorting'''
+
+import unittest
+
+from sample import *
+
+class Dummy(object):
+ pass
+
+class SimpleOverloadSorting(unittest.TestCase):
+
+ def setUp(self):
+ self.obj = SortedOverload()
+
+ def testIntDouble(self):
+ '''Overloads with int and double'''
+ self.assertEqual(self.obj.overload(3), "int")
+ self.assertEqual(self.obj.overload(3.14), "double")
+
+ def testImplicitConvert(self):
+ '''Overloads with implicit convertible types'''
+ self.assertEqual(self.obj.overload(ImplicitTarget()), "ImplicitTarget")
+ self.assertEqual(self.obj.overload(ImplicitBase()), "ImplicitBase")
+
+ def testContainer(self):
+ '''Overloads with containers arguments'''
+ self.assertEqual(self.obj.overload([ImplicitBase()]), "list(ImplicitBase)")
+
+ def testPyObject(self):
+ '''Overloads with PyObject args'''
+ self.assertEqual(self.obj.overload(Dummy()), "PyObject")
+
+ def testImplicitOnly(self):
+ '''Passing an implicit convertible object to an overload'''
+ self.assertTrue(self.obj.implicit_overload(ImplicitTarget()))
+
+ def testPyObjectSort(self):
+ self.assertEqual(self.obj.pyObjOverload(1, 2), "int,int")
+ self.assertEqual(self.obj.pyObjOverload(object(), 2), "PyObject,int")
+
+
+class DeepOverloadSorting(unittest.TestCase):
+
+ def setUp(self):
+ self.obj = SortedOverload()
+
+ def testPyObject(self):
+ '''Deep Overload - (int, PyObject *)'''
+ self.assertEqual(self.obj.overloadDeep(1, Dummy()), "PyObject")
+
+ def testImplicit(self):
+ '''Deep Overload - (int, ImplicitBase *)'''
+ self.assertEqual(self.obj.overloadDeep(1, ImplicitBase()), "ImplicitBase")
+
+class EnumOverIntSorting(unittest.TestCase):
+ def testEnumOverInt(self):
+ ic = ImplicitConv(ImplicitConv.CtorTwo)
+ self.assertEqual(ic.ctorEnum(), ImplicitConv.CtorTwo)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/overload_test.py b/sources/shiboken2/tests/samplebinding/overload_test.py
new file mode 100644
index 000000000..efcd3bed8
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/overload_test.py
@@ -0,0 +1,209 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for Overload class'''
+
+import unittest
+from sample import Echo, Overload, Point, PointF, Polygon, Rect, RectF, Size, Str
+
+
+def raisesWithErrorMessage(func, arguments, errorType, errorMsg):
+ '''NOTE: Using 'try' because assertRaisesRegexp is not available
+ to check the error message.'''
+ try:
+ func(*arguments)
+ return False
+ except Exception as err:
+ if type(err) != TypeError:
+ return False
+ if not errorMsg in str(err):
+ return False
+ return True
+
+
+class OverloadTest(unittest.TestCase):
+ '''Test case for Overload class'''
+
+ def testOverloadMethod0(self):
+ '''Check overloaded method call for signature "overloaded()".'''
+ overload = Overload()
+ self.assertEqual(overload.overloaded(), Overload.Function0)
+
+ def testOverloadMethod1(self):
+ '''Check overloaded method call for signature "overloaded(Size*)".'''
+ overload = Overload()
+ size = Size()
+ self.assertEqual(overload.overloaded(size), Overload.Function1)
+
+ def testOverloadMethod2(self):
+ '''Check overloaded method call for signature "overloaded(Point*, ParamEnum)".'''
+ overload = Overload()
+ point = Point()
+ self.assertEqual(overload.overloaded(point, Overload.Param1), Overload.Function2)
+
+ def testOverloadMethod3(self):
+ '''Check overloaded method call for signature "overloaded(const Point&)".'''
+ overload = Overload()
+ point = Point()
+ self.assertEqual(overload.overloaded(point), Overload.Function3)
+
+ def testDifferentReturnTypes(self):
+ '''Check method calls for overloads with different return types.'''
+ overload = Overload()
+ self.assertEqual(overload.differentReturnTypes(), None)
+ self.assertEqual(overload.differentReturnTypes(Overload.Param1), None)
+ self.assertEqual(overload.differentReturnTypes(Overload.Param0, 13), 13)
+
+ def testIntOverloads(self):
+ overload = Overload()
+ self.assertEqual(overload.intOverloads(2, 3), 2)
+ self.assertEqual(overload.intOverloads(2, 4.5), 3)
+ self.assertEqual(overload.intOverloads(Point(0, 0), 3), 1)
+
+ def testIntDoubleOverloads(self):
+ overload = Overload()
+ self.assertEqual(overload.intDoubleOverloads(1, 2), Overload.Function0)
+ self.assertEqual(overload.intDoubleOverloads(1, 2.0), Overload.Function0)
+ self.assertEqual(overload.intDoubleOverloads(1.0, 2), Overload.Function1)
+ self.assertEqual(overload.intDoubleOverloads(1.0, 2.0), Overload.Function1)
+
+ def testWrapperIntIntOverloads(self):
+ overload = Overload()
+ self.assertEqual(overload.wrapperIntIntOverloads(Point(), 1, 2), Overload.Function0)
+ self.assertEqual(overload.wrapperIntIntOverloads(Polygon(), 1, 2), Overload.Function1)
+
+ def testDrawTextPointAndStr(self):
+ overload = Overload()
+ self.assertEqual(overload.drawText(Point(), Str()), Overload.Function0)
+ self.assertEqual(overload.drawText(Point(), ''), Overload.Function0)
+ self.assertEqual(overload.drawText(PointF(), Str()), Overload.Function1)
+ self.assertEqual(overload.drawText(PointF(), ''), Overload.Function1)
+
+ def testDrawTextRectIntStr(self):
+ overload = Overload()
+ self.assertEqual(overload.drawText(Rect(), 1, Str()), Overload.Function2)
+ self.assertEqual(overload.drawText(Rect(), 1, ''), Overload.Function2)
+ self.assertEqual(overload.drawText(RectF(), 1, Str()), Overload.Function3)
+ self.assertEqual(overload.drawText(RectF(), 1, ''), Overload.Function3)
+
+ def testDrawTextRectFStrEcho(self):
+ overload = Overload()
+ self.assertEqual(overload.drawText(RectF(), Str()), Overload.Function4)
+ self.assertEqual(overload.drawText(RectF(), ''), Overload.Function4)
+ self.assertEqual(overload.drawText(RectF(), Str(), Echo()), Overload.Function4)
+ self.assertEqual(overload.drawText(RectF(), '', Echo()), Overload.Function4)
+ self.assertEqual(overload.drawText(Rect(), Str()), Overload.Function4)
+ self.assertEqual(overload.drawText(Rect(), ''), Overload.Function4)
+ self.assertEqual(overload.drawText(Rect(), Str(), Echo()), Overload.Function4)
+ self.assertEqual(overload.drawText(Rect(), '', Echo()), Overload.Function4)
+
+ def testDrawTextIntIntStr(self):
+ overload = Overload()
+ self.assertEqual(overload.drawText(1, 2, Str()), Overload.Function5)
+ self.assertEqual(overload.drawText(1, 2, ''), Overload.Function5)
+
+ def testDrawTextIntIntIntIntStr(self):
+ overload = Overload()
+ self.assertEqual(overload.drawText(1, 2, 3, 4, 5, Str()), Overload.Function6)
+ self.assertEqual(overload.drawText(1, 2, 3, 4, 5, ''), Overload.Function6)
+
+ def testDrawText2IntIntIntIntStr(self):
+ overload = Overload()
+ self.assertEqual(overload.drawText2(1, 2, 3, 4, 5, Str()), Overload.Function6)
+ self.assertEqual(overload.drawText2(1, 2, 3, 4, 5, ''), Overload.Function6)
+ self.assertEqual(overload.drawText2(1, 2, 3, 4, 5), Overload.Function6)
+ self.assertEqual(overload.drawText2(1, 2, 3, 4), Overload.Function6)
+ self.assertEqual(overload.drawText2(1, 2, 3), Overload.Function6)
+
+ def testDrawText3(self):
+ overload = Overload()
+ self.assertEqual(overload.drawText3(Str(), Str(), Str()), Overload.Function0)
+ self.assertEqual(overload.drawText3('', '', ''), Overload.Function0)
+ self.assertEqual(overload.drawText3(1, 2, 3, 4, 5), Overload.Function1)
+ self.assertEqual(overload.drawText3(1, 2, 3, 4, 5), Overload.Function1)
+
+ def testDrawText3Exception(self):
+ overload = Overload()
+ args = (Str(), Str(), Str(), 4, 5)
+ result = raisesWithErrorMessage(overload.drawText3, args,
+ TypeError, 'called with wrong argument types:')
+ self.assertTrue(result)
+
+ def testDrawText4(self):
+ overload = Overload()
+ self.assertEqual(overload.drawText4(1, 2, 3), Overload.Function0)
+ self.assertEqual(overload.drawText4(1, 2, 3, 4, 5), Overload.Function1)
+
+ def testAcceptSequence(self):
+ # Overload.acceptSequence()
+ overload = Overload()
+ self.assertEqual(overload.acceptSequence(), Overload.Function0)
+
+ def testAcceptSequenceIntInt(self):
+ # Overload.acceptSequence(int,int)
+ overload = Overload()
+ self.assertEqual(overload.acceptSequence(1, 2), Overload.Function1)
+
+ def testAcceptSequenceStrParamEnum(self):
+ # Overload.acceptSequence(Str,Overload::ParamEnum)
+ overload = Overload()
+ self.assertEqual(overload.acceptSequence(''), Overload.Function2)
+ self.assertEqual(overload.acceptSequence('', Overload.Param0), Overload.Function2)
+ self.assertEqual(overload.acceptSequence(Str('')), Overload.Function2)
+ self.assertEqual(overload.acceptSequence(Str(''), Overload.Param0), Overload.Function2)
+
+ def testAcceptSequenceSize(self):
+ # Overload.acceptSequence(Size)
+ overload = Overload()
+ self.assertEqual(overload.acceptSequence(Size()), Overload.Function3)
+
+ def testAcceptSequenceStringList(self):
+ # Overload.acceptSequence(const char**)
+ overload = Overload()
+ strings = ['line 1', 'line 2']
+ self.assertEqual(overload.acceptSequence(strings), Overload.Function4)
+ args = (['line 1', 2], )
+ result = raisesWithErrorMessage(overload.acceptSequence, args,
+ TypeError, 'The argument must be a sequence of strings.')
+ self.assertTrue(result)
+
+ def testAcceptSequencePyObject(self):
+ # Overload.acceptSequence(void*)
+ overload = Overload()
+ class Foo(object):
+ pass
+ foo = Foo()
+ self.assertEqual(overload.acceptSequence(foo), Overload.Function5)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/overloadwithdefault_test.py b/sources/shiboken2/tests/samplebinding/overloadwithdefault_test.py
new file mode 100644
index 000000000..9f243a573
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/overloadwithdefault_test.py
@@ -0,0 +1,64 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from sample import Overload, Str
+from py3kcompat import b
+
+class OverloadTest(unittest.TestCase):
+
+ def testNoArgument(self):
+ overload = Overload()
+ self.assertEqual(overload.strBufferOverloads(), Overload.Function2)
+
+ def testStrArgument(self):
+ overload = Overload()
+ self.assertEqual(overload.strBufferOverloads(Str('')), Overload.Function0)
+ self.assertEqual(overload.strBufferOverloads(Str(''), ''), Overload.Function0)
+ self.assertEqual(overload.strBufferOverloads(Str(''), '', False), Overload.Function0)
+
+ def testStringArgumentAsStr(self):
+ overload = Overload()
+ self.assertEqual(overload.strBufferOverloads('', ''), Overload.Function0)
+ self.assertEqual(overload.strBufferOverloads('', '', False), Overload.Function0)
+
+ def testStringArgumentAsBuffer(self):
+ overload = Overload()
+ self.assertEqual(overload.strBufferOverloads(b'', 0), Overload.Function1)
+
+ def testBufferArgument(self):
+ overload = Overload()
+ self.assertEqual(overload.strBufferOverloads(b(''), 0), Overload.Function1)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/ownership_argument_invalidation_test.py b/sources/shiboken2/tests/samplebinding/ownership_argument_invalidation_test.py
new file mode 100644
index 000000000..5c6f31395
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ownership_argument_invalidation_test.py
@@ -0,0 +1,62 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Wrapper validity tests for arguments.'''
+
+import sys
+import unittest
+
+from sample import Polygon, Point
+
+class WrapperValidityOfArgumentsTest(unittest.TestCase):
+ '''Wrapper validity tests for arguments.'''
+
+ def testInvalidArgumentToMethod(self):
+ '''Call to method using invalidated Python wrapper as argument should raise RuntimeError.'''
+ poly = Polygon()
+ Polygon.stealOwnershipFromPython(poly)
+ self.assertRaises(RuntimeError, Polygon.doublePolygonScale, poly)
+
+ def testInvalidArgumentToConstructor(self):
+ '''Call to constructor using invalidated Python wrapper as argument should raise RuntimeError.'''
+ pt = Point(1, 2)
+ Polygon.stealOwnershipFromPython(pt)
+ self.assertRaises(RuntimeError, Polygon, pt)
+
+ def testInvalidArgumentWithImplicitConversion(self):
+ '''Call to method using invalidated Python wrapper to be implicitly converted should raise RuntimeError.'''
+ pt = Point(1, 2)
+ Polygon.stealOwnershipFromPython(pt)
+ self.assertRaises(RuntimeError, Polygon.doublePolygonScale, pt)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/ownership_delete_child_in_cpp_test.py b/sources/shiboken2/tests/samplebinding/ownership_delete_child_in_cpp_test.py
new file mode 100644
index 000000000..829cabd81
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ownership_delete_child_in_cpp_test.py
@@ -0,0 +1,54 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests for destroy a child object in C++'''
+
+import unittest
+
+from sample import ObjectType
+
+
+class DeleteChildInCpp(unittest.TestCase):
+ '''Test case for destroying a child in c++'''
+
+ def testDeleteChild(self):
+ '''Delete child in C++ should invalidate child - using C++ wrapper'''
+ parent = ObjectType()
+ parent.setObjectName('parent')
+ child = ObjectType(parent)
+ child.setObjectName('child')
+
+ parent.killChild('child')
+ self.assertRaises(RuntimeError, child.objectName)
+ self.assertEqual(parent.objectName(), 'parent')
+
+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
new file mode 100644
index 000000000..32312af7f
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ownership_delete_child_in_python_test.py
@@ -0,0 +1,60 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests for deleting a child object in python'''
+
+import unittest
+import random
+import string
+
+from sample import ObjectType
+from py3kcompat import IS_PY3K
+
+if IS_PY3K:
+ string.letters = string.ascii_letters
+
+
+class DeleteChildInPython(unittest.TestCase):
+ '''Test case for deleting (unref) a child in python'''
+
+ def testDeleteChild(self):
+ '''Delete child in python should not invalidate child'''
+ parent = ObjectType()
+ child = ObjectType(parent)
+ name = ''.join(random.sample(string.letters, 5))
+ child.setObjectName(name)
+
+ del child
+ new_child = parent.children()[0]
+ self.assertEqual(new_child.objectName(), name)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/ownership_delete_parent_test.py b/sources/shiboken2/tests/samplebinding/ownership_delete_parent_test.py
new file mode 100644
index 000000000..1c135a4aa
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ownership_delete_parent_test.py
@@ -0,0 +1,82 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests for destroying the parent'''
+
+import sys
+import unittest
+
+from sample import ObjectType
+
+
+class DeleteParentTest(unittest.TestCase):
+ '''Test case for deleting a parent object'''
+
+ def testParentDestructor(self):
+ '''Delete parent object should invalidate child'''
+ parent = ObjectType()
+ child = ObjectType()
+ child.setParent(parent)
+
+ refcount_before = sys.getrefcount(child)
+
+ del parent
+ self.assertRaises(RuntimeError, child.objectName)
+ self.assertEqual(sys.getrefcount(child), refcount_before-1)
+
+ def testParentDestructorMultipleChildren(self):
+ '''Delete parent object should invalidate all children'''
+ parent = ObjectType()
+ children = [ObjectType() for _ in range(10)]
+
+ for child in children:
+ child.setParent(parent)
+
+ del parent
+ for i, child in enumerate(children):
+ self.assertRaises(RuntimeError, child.objectName)
+ self.assertEqual(sys.getrefcount(child), 4)
+
+ def testRecursiveParentDelete(self):
+ '''Delete parent should invalidate grandchildren'''
+ parent = ObjectType()
+ child = ObjectType(parent)
+ grandchild = ObjectType(child)
+
+ del parent
+ self.assertRaises(RuntimeError, child.objectName)
+ self.assertEqual(sys.getrefcount(child), 2)
+ self.assertRaises(RuntimeError, grandchild.objectName)
+ self.assertEqual(sys.getrefcount(grandchild), 2)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/ownership_invalidate_after_use_test.py b/sources/shiboken2/tests/samplebinding/ownership_invalidate_after_use_test.py
new file mode 100644
index 000000000..8b3e84738
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ownership_invalidate_after_use_test.py
@@ -0,0 +1,110 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Ownership tests for cases of invalidation of Python wrapper after use.'''
+
+import sys
+import unittest
+
+from sample import ObjectType, ObjectTypeDerived, Event
+
+
+class ExtObjectType(ObjectType):
+ def __init__(self):
+ ObjectType.__init__(self)
+ self.type_of_last_event = None
+ self.last_event = None
+ def event(self, event):
+ self.last_event = event
+ self.type_of_last_event = event.eventType()
+ return True
+
+class MyObjectType (ObjectType):
+ def __init__(self):
+ super(MyObjectType, self).__init__()
+ self.fail = False
+
+ def event(self, ev):
+ self.callInvalidateEvent(ev)
+ try:
+ ev.eventType()
+ except:
+ self.fail = True
+ raise
+ return True
+
+ def invalidateEvent(self, ev):
+ pass
+
+class ExtObjectTypeDerived(ObjectTypeDerived):
+ def __init__(self):
+ ObjectTypeDerived.__init__(self)
+ self.type_of_last_event = None
+ self.last_event = None
+ def event(self, event):
+ self.last_event = event
+ self.type_of_last_event = event.eventType()
+ return True
+
+class OwnershipInvalidateAfterUseTest(unittest.TestCase):
+ '''Ownership tests for cases of invalidation of Python wrapper after use.'''
+
+ def testInvalidateAfterUse(self):
+ '''In ObjectType.event(Event*) the wrapper object created for Event must me marked as invalid after the method is called.'''
+ eot = ExtObjectType()
+ eot.causeEvent(Event.SOME_EVENT)
+ self.assertEqual(eot.type_of_last_event, Event.SOME_EVENT)
+ self.assertRaises(RuntimeError, eot.last_event.eventType)
+
+ def testObjectInvalidatedAfterUseAsParameter(self):
+ '''Tries to use wrapper invalidated after use as a parameter to another method.'''
+ eot = ExtObjectType()
+ ot = ObjectType()
+ eot.causeEvent(Event.ANY_EVENT)
+ self.assertEqual(eot.type_of_last_event, Event.ANY_EVENT)
+ self.assertRaises(RuntimeError, ot.event, eot.last_event)
+
+ def testit(self):
+ obj = MyObjectType()
+ obj.causeEvent(Event.BASIC_EVENT)
+ self.assertFalse(obj.fail)
+
+ def testInvalidateAfterUseInDerived(self):
+ '''Invalidate was failing in a derived C++ class that also inherited
+ other base classes'''
+ eot = ExtObjectTypeDerived()
+ eot.causeEvent(Event.SOME_EVENT)
+ self.assertEqual(eot.type_of_last_event, Event.SOME_EVENT)
+ self.assertRaises(RuntimeError, eot.last_event.eventType)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/ownership_invalidate_child_test.py b/sources/shiboken2/tests/samplebinding/ownership_invalidate_child_test.py
new file mode 100644
index 000000000..e92fa39f5
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ownership_invalidate_child_test.py
@@ -0,0 +1,69 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests for invalidating a C++ created child that was already on the care of a parent.'''
+
+import unittest
+
+from sample import ObjectType, BlackBox
+
+
+class InvalidateChildTest(unittest.TestCase):
+ '''Tests for invalidating a C++ created child that was already on the care of a parent.'''
+
+ def testInvalidateChild(self):
+ '''Invalidating method call should remove child from the care of a parent if it has one.'''
+ parent = ObjectType()
+ child1 = ObjectType(parent)
+ child1.setObjectName('child1')
+ child2 = ObjectType.create()
+ child2.setParent(parent)
+ child2.setObjectName('child2')
+
+ self.assertEqual(parent.children(), [child1, child2])
+
+ bbox = BlackBox()
+
+ # This method steals ownership from Python to C++.
+ bbox.keepObjectType(child1)
+ self.assertEqual(parent.children(), [child2])
+
+ bbox.keepObjectType(child2)
+ self.assertEqual(parent.children(), [])
+
+ del parent
+
+ self.assertEqual(child1.objectName(), 'child1')
+ self.assertRaises(RuntimeError, child2.objectName)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/ownership_invalidate_nonpolymorphic_test.py b/sources/shiboken2/tests/samplebinding/ownership_invalidate_nonpolymorphic_test.py
new file mode 100644
index 000000000..69527974c
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ownership_invalidate_nonpolymorphic_test.py
@@ -0,0 +1,53 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''The BlackBox class has cases of ownership transference between Python and C++.'''
+
+import sys
+import unittest
+
+from sample import Point, BlackBox
+
+class OwnershipInvalidateNonPolymorphicTest(unittest.TestCase):
+ '''The BlackBox class has cases of ownership transference between Python and C++.'''
+
+ def testOwnershipTransference(self):
+ '''Ownership transference from Python to C++ and back again.'''
+ p1 = Point(10, 20)
+ bb = BlackBox()
+ p1_ticket = bb.keepPoint(p1)
+ self.assertRaises(RuntimeError, p1.x)
+ p1_ret = bb.retrievePoint(p1_ticket)
+ self.assertEqual(p1_ret, Point(10, 20))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/ownership_invalidate_parent_test.py b/sources/shiboken2/tests/samplebinding/ownership_invalidate_parent_test.py
new file mode 100644
index 000000000..848c982ce
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ownership_invalidate_parent_test.py
@@ -0,0 +1,68 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests for invalidating a parent of other objects.'''
+
+import unittest
+
+from sample import ObjectType, BlackBox
+
+
+class InvalidateParentTest(unittest.TestCase):
+ '''Tests for invalidating a parent of other objects.'''
+
+ def testInvalidateParent(self):
+ '''Invalidate parent should invalidate children'''
+ parent = ObjectType.create()
+ child1 = ObjectType(parent)
+ child1.setObjectName("child1")
+ child2 = ObjectType.create()
+ child2.setObjectName("child2")
+ child2.setParent(parent)
+ grandchild1 = ObjectType(child1)
+ grandchild1.setObjectName("grandchild1")
+ grandchild2 = ObjectType.create()
+ grandchild2.setObjectName("grandchild2")
+ grandchild2.setParent(child2)
+ bbox = BlackBox()
+
+ bbox.keepObjectType(parent) # Should invalidate the parent
+
+ self.assertRaises(RuntimeError, parent.objectName)
+ # some children still valid they are wrapper classes
+ self.assertEqual(child1.objectName(), "child1")
+ self.assertRaises(RuntimeError, child2.objectName)
+ self.assertEqual(grandchild1.objectName(), "grandchild1")
+ self.assertRaises(RuntimeError, grandchild2.objectName)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/ownership_reparenting_test.py b/sources/shiboken2/tests/samplebinding/ownership_reparenting_test.py
new file mode 100644
index 000000000..20e6aca03
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ownership_reparenting_test.py
@@ -0,0 +1,130 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests for object reparenting.'''
+
+import unittest
+import sys
+
+from sample import ObjectType
+
+class ExtObjectType(ObjectType):
+ def __init__(self):
+ ObjectType.__init__(self)
+
+
+class ReparentingTest(unittest.TestCase):
+ '''Tests for object reparenting.'''
+
+ def testReparentedObjectTypeIdentity(self):
+ '''Reparent children from one parent to another.'''
+ object_list = []
+ old_parent = ObjectType()
+ new_parent = ObjectType()
+ for i in range(3):
+ obj = ObjectType()
+ object_list.append(obj)
+ obj.setParent(old_parent)
+ for obj in object_list:
+ obj.setParent(new_parent)
+ for child in new_parent.children():
+ self.assertTrue(child in object_list)
+
+ def testReparentWithTheSameParent(self):
+ '''Set the same parent twice to check if the ref continue the same'''
+ obj = ObjectType()
+ parent = ObjectType()
+ self.assertEqual(sys.getrefcount(obj), 2)
+ obj.setParent(parent)
+ self.assertEqual(sys.getrefcount(obj), 3)
+ obj.setParent(parent)
+ self.assertEqual(sys.getrefcount(obj), 3)
+
+ def testReparentedExtObjectType(self):
+ '''Reparent children from one extended parent to another.'''
+ object_list = []
+ old_parent = ExtObjectType()
+ new_parent = ExtObjectType()
+ for i in range(3):
+ obj = ExtObjectType()
+ object_list.append(obj)
+ obj.setParent(old_parent)
+ for obj in object_list:
+ obj.setParent(new_parent)
+ for orig, child in zip(object_list, new_parent.children()):
+ self.assertEqual(type(orig), type(child))
+
+ def testReparentedObjectTypeIdentityWithParentsCreatedInCpp(self):
+ '''Reparent children from one parent to another, both created in C++.'''
+ object_list = []
+ old_parent = ObjectType.create()
+ new_parent = ObjectType.create()
+ for i in range(3):
+ obj = ObjectType()
+ object_list.append(obj)
+ obj.setParent(old_parent)
+ for obj in object_list:
+ obj.setParent(new_parent)
+ for child in new_parent.children():
+ self.assertTrue(child in object_list)
+
+ def testReparentedObjectTypeIdentityWithChildrenCreatedInCpp(self):
+ '''Reparent children created in C++ from one parent to another.'''
+ object_list = []
+ old_parent = ObjectType()
+ new_parent = ObjectType()
+ for i in range(3):
+ obj = ObjectType.create()
+ object_list.append(obj)
+ obj.setParent(old_parent)
+ for obj in object_list:
+ obj.setParent(new_parent)
+ for child in new_parent.children():
+ self.assertTrue(child in object_list)
+
+ def testReparentedObjectTypeIdentityWithParentsAndChildrenCreatedInCpp(self):
+ '''Reparent children from one parent to another. Parents and children are created in C++.'''
+ object_list = []
+ old_parent = ObjectType.create()
+ new_parent = ObjectType.create()
+ for i in range(3):
+ obj = ObjectType.create()
+ object_list.append(obj)
+ obj.setParent(old_parent)
+ for obj in object_list:
+ obj.setParent(new_parent)
+ for child in new_parent.children():
+ self.assertTrue(child in object_list)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/ownership_transference_test.py b/sources/shiboken2/tests/samplebinding/ownership_transference_test.py
new file mode 100644
index 000000000..0df2a09ba
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/ownership_transference_test.py
@@ -0,0 +1,85 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''The BlackBox class has cases of ownership transference between C++ and Python.'''
+
+import sys
+import unittest
+
+from sample import ObjectType, BlackBox
+
+class BlackBoxTest(unittest.TestCase):
+ '''The BlackBox class has cases of ownership transference between C++ and Python.'''
+
+ def testOwnershipTransference(self):
+ '''Ownership transference from Python to C++ and back again.'''
+ o1 = ObjectType()
+ o1.setObjectName('object1')
+ o1_refcnt = sys.getrefcount(o1)
+ o2 = ObjectType()
+ o2.setObjectName('object2')
+ o2_refcnt = sys.getrefcount(o2)
+ bb = BlackBox()
+ o1_ticket = bb.keepObjectType(o1)
+ o2_ticket = bb.keepObjectType(o2)
+ self.assertEqual(set(bb.objects()), set([o1, o2]))
+ self.assertEqual(str(o1.objectName()), 'object1')
+ self.assertEqual(str(o2.objectName()), 'object2')
+ self.assertEqual(sys.getrefcount(o1), o1_refcnt + 1) # PySide give +1 ref to object with c++ ownership
+ self.assertEqual(sys.getrefcount(o2), o2_refcnt + 1)
+ o2 = bb.retrieveObjectType(o2_ticket)
+ self.assertEqual(sys.getrefcount(o2), o2_refcnt)
+ del bb
+ self.assertRaises(RuntimeError, o1.objectName)
+ self.assertEqual(str(o2.objectName()), 'object2')
+ self.assertEqual(sys.getrefcount(o2), o2_refcnt)
+
+ def testBlackBoxReleasingUnknownObjectType(self):
+ '''Asks BlackBox to release an unknown ObjectType.'''
+ o1 = ObjectType()
+ o2 = ObjectType()
+ bb = BlackBox()
+ o1_ticket = bb.keepObjectType(o1)
+ o3 = bb.retrieveObjectType(-5)
+ self.assertEqual(o3, None)
+
+ def testOwnershipTransferenceCppCreated(self):
+ '''Ownership transference using a C++ created object.'''
+ o1 = ObjectType.create()
+ o1.setObjectName('object1')
+ o1_refcnt = sys.getrefcount(o1)
+ bb = BlackBox()
+ o1_ticket = bb.keepObjectType(o1)
+ self.assertRaises(RuntimeError, o1.objectName)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/pair_test.py b/sources/shiboken2/tests/samplebinding/pair_test.py
new file mode 100644
index 000000000..4786213c5
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/pair_test.py
@@ -0,0 +1,105 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for std::pair container conversions'''
+
+import sys
+import unittest
+
+from sample import PairUser
+
+class ExtendedPairUser(PairUser):
+ def __init__(self):
+ PairUser.__init__(self)
+ self.create_pair_called = False
+
+ def createPair(self):
+ self.create_pair_called = True
+ return (7, 13)
+
+class PairConversionTest(unittest.TestCase):
+ '''Test case for std::pair container conversions'''
+
+ def testReimplementedVirtualMethodCall(self):
+ '''Test if a Python override of a virtual method is correctly called from C++.'''
+ pu = ExtendedPairUser()
+ pair = pu.callCreatePair()
+ self.assertTrue(pu.create_pair_called)
+ self.assertEqual(type(pair), tuple)
+ self.assertEqual(type(pair[0]), int)
+ self.assertEqual(type(pair[1]), int)
+ self.assertEqual(pair, (7, 13))
+
+ def testPrimitiveConversionInsideContainer(self):
+ '''Test primitive type conversion inside conversible std::pair container.'''
+ cpx0 = complex(1.2, 3.4)
+ cpx1 = complex(5.6, 7.8)
+ cp = PairUser.createComplexPair(cpx0, cpx1)
+ self.assertEqual(type(cp), tuple)
+ self.assertEqual(type(cp[0]), complex)
+ self.assertEqual(type(cp[1]), complex)
+ self.assertEqual(cp, (cpx0, cpx1))
+
+ def testSumPair(self):
+ '''Test method that sums the items of a pair using values of the types expected by C++ (int and double)'''
+ pu = PairUser()
+ pair = (3, 7.13)
+ result = pu.sumPair(pair)
+ self.assertEqual(result, sum(pair))
+
+ def testSumPairDifferentTypes(self):
+ '''Test method that sums the items of a pair using values of types different from the ones expected by C++ (int and double)'''
+ pu = PairUser()
+ pair = (3.3, 7)
+ result = pu.sumPair(pair)
+ self.assertNotEqual(result, sum(pair))
+ self.assertEqual(result, int(pair[0]) + pair[1])
+
+ def testConversionInBothDirections(self):
+ '''Test converting a pair from Python to C++ and the other way around.'''
+ pu = PairUser()
+ pair = (3, 5)
+ pu.setPair(pair)
+ result = pu.getPair()
+ self.assertEqual(result, pair)
+
+ def testConversionInBothDirectionsWithSimilarContainer(self):
+ '''Test converting a list, instead of the expected tuple, from Python to C++ and the other way around.'''
+ pu = PairUser()
+ pair = [3, 5]
+ pu.setPair(pair)
+ result = pu.getPair()
+ self.assertNotEqual(result, pair)
+ self.assertEqual(result, tuple(pair))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/pen_test.py b/sources/shiboken2/tests/samplebinding/pen_test.py
new file mode 100644
index 000000000..54c96b9c8
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/pen_test.py
@@ -0,0 +1,63 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for <add-function> with const char* as argument'''
+
+import unittest
+
+from sample import Color, Pen, SampleNamespace
+
+class TestPen(unittest.TestCase):
+ '''Simple test case for Pen.'''
+
+ def testPenWithEmptyConstructor(self):
+ pen = Pen()
+ self.assertEqual(pen.ctorType(), Pen.EmptyCtor)
+
+ def testPenWithEnumConstructor(self):
+ pen = Pen(SampleNamespace.RandomNumber)
+ self.assertEqual(pen.ctorType(), Pen.EnumCtor)
+
+ def testPenWithColorConstructor(self):
+ pen = Pen(Color())
+ self.assertEqual(pen.ctorType(), Pen.ColorCtor)
+
+ def testPenWithCopyConstructor(self):
+ pen = Pen(Pen())
+ self.assertEqual(pen.ctorType(), Pen.CopyCtor)
+
+ def testPenWithIntConvertedToColor(self):
+ pen = Pen(1)
+ self.assertEqual(pen.ctorType(), Pen.ColorCtor)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/point_test.py b/sources/shiboken2/tests/samplebinding/point_test.py
new file mode 100644
index 000000000..6f84ac999
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/point_test.py
@@ -0,0 +1,109 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for Point class'''
+
+import sys
+import unittest
+
+from sample import Point
+from py3kcompat import unicode
+
+class PointTest(unittest.TestCase):
+ '''Test case for Point class, including operator overloads.'''
+
+ def testConstructor(self):
+ '''Test Point class constructor.'''
+ pt = Point(5.0, 2.3)
+ self.assertEqual(pt.x(), 5.0)
+ self.assertEqual(pt.y(), 2.3)
+
+ def testPlusOperator(self):
+ '''Test Point class + operator.'''
+ pt1 = Point(5.0, 2.3)
+ pt2 = Point(0.5, 3.2)
+ self.assertEqual(pt1 + pt2, Point(5.0 + 0.5, 2.3 + 3.2))
+
+ def testEqualOperator(self):
+ '''Test Point class == operator.'''
+ pt1 = Point(5.0, 2.3)
+ pt2 = Point(5.0, 2.3)
+ pt3 = Point(0.5, 3.2)
+ self.assertTrue(pt1 == pt1)
+ self.assertTrue(pt1 == pt2)
+ self.assertFalse(pt1 == pt3)
+ self.assertFalse(pt1 == object())
+
+ def testNotEqualOperator(self):
+ '''Test Point class != operator.'''
+ pt1 = Point(5.0, 2.3)
+ pt2 = Point(5.0, 2.3)
+ self.assertRaises(NotImplementedError, pt1.__ne__, pt2)
+
+ def testReturnNewCopy(self):
+ '''Point returns a copy of itself.'''
+ pt1 = Point(1.1, 2.3)
+ pt2 = pt1.copy()
+ self.assertEqual(pt1, pt2)
+ pt2 += pt1
+ self.assertFalse(pt1 == pt2)
+
+ def testReturnConstPointer(self):
+ '''Point returns a const pointer for itself.'''
+ pt1 = Point(5.0, 2.3)
+ refcount1 = sys.getrefcount(pt1)
+ pt2 = pt1.getSelf()
+ self.assertEqual(pt1, pt2)
+ self.assertEqual(sys.getrefcount(pt1), refcount1 + 1)
+ self.assertEqual(sys.getrefcount(pt1), sys.getrefcount(pt2))
+
+ def testUintOverflow(self):
+ pt1 = Point(0.0, 0.0)
+ self.assertRaises(OverflowError, pt1.setXAsUint, 840835495615213080)
+ self.assertEqual(pt1.x(), 0.0)
+
+ def testAddedOperator(self):
+ p = Point(0.0, 0.0)
+ r = p - unicode('Hi')
+ self.assertEqual(r, unicode('Hi'))
+
+ # now the reverse op.
+ r = unicode('Hi') - p
+ self.assertEqual(r, unicode('Hi'))
+
+ def testModifiedMethod(self):
+ pt1 = Point(0.0, 0.0)
+ pt2 = Point(10.0, 10.0)
+ expected = Point((pt1.x() + pt2.x()) / 2.0, (pt1.y() + pt2.y()) / 2.0)
+ self.assertEqual(pt1.midpoint(pt2), expected)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/pointerholder_test.py b/sources/shiboken2/tests/samplebinding/pointerholder_test.py
new file mode 100644
index 000000000..32ef99d5c
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/pointerholder_test.py
@@ -0,0 +1,59 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for a class that holds an arbitraty pointer and is modified to hold an PyObject.'''
+
+import sys
+import unittest
+
+from sample import PointerHolder
+
+class TestPointerHolder(unittest.TestCase):
+ '''Test cases for a class that holds an arbitraty pointer and is modified to hold an PyObject.'''
+
+ def testStoringAndRetrievingPointer(self):
+ ph = PointerHolder('Hello')
+ self.assertEqual(ph.pointer(), 'Hello')
+ a = (1, 2, 3)
+ ph = PointerHolder(a)
+ self.assertEqual(ph.pointer(), a)
+
+ def testReferenceCounting(self):
+ '''Test reference counting when retrieving data with PointerHolder.pointer().'''
+ a = (1, 2, 3)
+ refcnt = sys.getrefcount(a)
+ ph = PointerHolder(a)
+ ptr = ph.pointer()
+ self.assertEqual(sys.getrefcount(a), refcnt + 1)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/pointf_test.py b/sources/shiboken2/tests/samplebinding/pointf_test.py
new file mode 100644
index 000000000..9318dca24
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/pointf_test.py
@@ -0,0 +1,69 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for PointF class'''
+
+import unittest
+
+from sample import PointF
+
+class PointFTest(unittest.TestCase):
+ '''Test case for PointF class, including operator overloads.'''
+
+ def testConstructor(self):
+ '''Test PointF class constructor.'''
+ pt = PointF(5.0, 2.3)
+ self.assertEqual(pt.x(), 5.0)
+ self.assertEqual(pt.y(), 2.3)
+
+ def testPlusOperator(self):
+ '''Test PointF class + operator.'''
+ pt1 = PointF(5.0, 2.3)
+ pt2 = PointF(0.5, 3.2)
+ self.assertEqual(pt1 + pt2, PointF(5.0 + 0.5, 2.3 + 3.2))
+
+ def testEqualOperator(self):
+ '''Test PointF class == operator.'''
+ pt1 = PointF(5.0, 2.3)
+ pt2 = PointF(5.0, 2.3)
+ pt3 = PointF(0.5, 3.2)
+ self.assertTrue(pt1 == pt1)
+ self.assertTrue(pt1 == pt2)
+ self.assertFalse(pt1 == pt3)
+
+ def testModifiedMethod(self):
+ pt1 = PointF(0.0, 0.0)
+ pt2 = PointF(10.0, 10.0)
+ expected = PointF((pt1.x() + pt2.x()) / 2.0, (pt1.y() + pt2.y()) / 2.0)
+ self.assertEqual(pt1.midpoint(pt2), expected)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/primitivereferenceargument_test.py b/sources/shiboken2/tests/samplebinding/primitivereferenceargument_test.py
new file mode 100644
index 000000000..e973c0d78
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/primitivereferenceargument_test.py
@@ -0,0 +1,49 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sample
+
+class PrimitiveReferenceArgumentTest(unittest.TestCase):
+
+ def testIntReferenceArgument(self):
+ '''C++ signature: int acceptIntReference(int&)'''
+ self.assertEqual(sample.acceptIntReference(123), 123)
+
+ def testOddBoolReferenceArgument(self):
+ '''C++ signature: OddBool acceptOddBoolReference(OddBool&)'''
+ self.assertEqual(sample.acceptOddBoolReference(True), True)
+ self.assertEqual(sample.acceptOddBoolReference(False), False)
+ self.assertNotEqual(sample.acceptOddBoolReference(True), False)
+ self.assertNotEqual(sample.acceptOddBoolReference(False), True)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/privatector_test.py b/sources/shiboken2/tests/samplebinding/privatector_test.py
new file mode 100644
index 000000000..471f735cb
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/privatector_test.py
@@ -0,0 +1,84 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for a class with only a private constructor.'''
+
+import gc
+import sys
+import unittest
+
+from sample import PrivateCtor
+
+
+class PrivateCtorTest(unittest.TestCase):
+ '''Test case for PrivateCtor class'''
+
+ def testPrivateCtorInstanciation(self):
+ '''Test if instanciation of class with a private constructor raises an exception.'''
+ self.assertRaises(TypeError, PrivateCtor)
+
+ def testPrivateCtorInheritance(self):
+ '''Test if inheriting from PrivateCtor raises an exception.'''
+ def inherit():
+ class Foo(PrivateCtor):
+ pass
+ self.assertRaises(TypeError, inherit)
+
+ def testPrivateCtorInstanceMethod(self):
+ '''Test if PrivateCtor.instance() method return the proper singleton.'''
+ pd1 = PrivateCtor.instance()
+ calls = pd1.instanceCalls()
+ self.assertEqual(type(pd1), PrivateCtor)
+ pd2 = PrivateCtor.instance()
+ self.assertEqual(pd2, pd1)
+ self.assertEqual(pd2.instanceCalls(), calls + 1)
+
+ def testPrivateCtorRefCounting(self):
+ '''Test refcounting of the singleton returned by PrivateCtor.instance().'''
+ pd1 = PrivateCtor.instance()
+ calls = pd1.instanceCalls()
+ refcnt = sys.getrefcount(pd1)
+ pd2 = PrivateCtor.instance()
+ self.assertEqual(pd2.instanceCalls(), calls + 1)
+ self.assertEqual(sys.getrefcount(pd2), sys.getrefcount(pd1))
+ self.assertEqual(sys.getrefcount(pd2), refcnt + 1)
+ del pd1
+ self.assertEqual(sys.getrefcount(pd2), refcnt)
+ del pd2
+ gc.collect()
+ pd3 = PrivateCtor.instance()
+ self.assertEqual(type(pd3), PrivateCtor)
+ self.assertEqual(pd3.instanceCalls(), calls + 2)
+ self.assertEqual(sys.getrefcount(pd3), refcnt)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/privatedtor_test.py b/sources/shiboken2/tests/samplebinding/privatedtor_test.py
new file mode 100644
index 000000000..3048a9848
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/privatedtor_test.py
@@ -0,0 +1,99 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for a class with a private destructor.'''
+
+import gc
+import sys
+import unittest
+
+import shiboken2 as shiboken
+from sample import PrivateDtor
+
+
+class PrivateDtorTest(unittest.TestCase):
+ '''Test case for PrivateDtor class'''
+
+ def testPrivateDtorInstanciation(self):
+ '''Test if instanciation of class with a private destructor raises an exception.'''
+ self.assertRaises(TypeError, PrivateDtor)
+
+ def testPrivateDtorInheritance(self):
+ '''Test if inheriting from PrivateDtor raises an exception.'''
+ def inherit():
+ class Foo(PrivateDtor):
+ pass
+ self.assertRaises(TypeError, inherit)
+
+ def testPrivateDtorInstanceMethod(self):
+ '''Test if PrivateDtor.instance() method return the proper singleton.'''
+ pd1 = PrivateDtor.instance()
+ calls = pd1.instanceCalls()
+ self.assertEqual(type(pd1), PrivateDtor)
+ pd2 = PrivateDtor.instance()
+ self.assertEqual(pd2, pd1)
+ self.assertEqual(pd2.instanceCalls(), calls + 1)
+
+ def testPrivateDtorRefCounting(self):
+ '''Test refcounting of the singleton returned by PrivateDtor.instance().'''
+ pd1 = PrivateDtor.instance()
+ calls = pd1.instanceCalls()
+ refcnt = sys.getrefcount(pd1)
+ pd2 = PrivateDtor.instance()
+ self.assertEqual(pd2.instanceCalls(), calls + 1)
+ self.assertEqual(sys.getrefcount(pd2), sys.getrefcount(pd1))
+ self.assertEqual(sys.getrefcount(pd2), refcnt + 1)
+ del pd1
+ self.assertEqual(sys.getrefcount(pd2), refcnt)
+ del pd2
+ gc.collect()
+ pd3 = PrivateDtor.instance()
+ self.assertEqual(type(pd3), PrivateDtor)
+ self.assertEqual(pd3.instanceCalls(), calls + 2)
+ self.assertEqual(sys.getrefcount(pd3), refcnt)
+
+ def testClassDecref(self):
+ # Bug was that class PyTypeObject wasn't decrefed when instance
+ # was invalidated
+
+ before = sys.getrefcount(PrivateDtor)
+
+ for i in range(1000):
+ obj = PrivateDtor.instance()
+ shiboken.invalidate(obj)
+
+ after = sys.getrefcount(PrivateDtor)
+
+ self.assertLess(abs(before - after), 5)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/protected_test.py b/sources/shiboken2/tests/samplebinding/protected_test.py
new file mode 100644
index 000000000..9201a63cf
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/protected_test.py
@@ -0,0 +1,357 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for protected methods.'''
+
+import unittest
+
+from sample import cacheSize
+from sample import ProtectedNonPolymorphic, ProtectedVirtualDestructor
+from sample import ProtectedPolymorphic, ProtectedPolymorphicDaughter, ProtectedPolymorphicGrandDaughter
+from sample import createProtectedProperty, ProtectedProperty, ProtectedEnumClass
+from sample import PrivateDtor
+from sample import Event, ObjectType, Point
+
+class ExtendedProtectedPolymorphic(ProtectedPolymorphic):
+ def __init__(self, name):
+ ProtectedPolymorphic.__init__(self, name)
+ self.protectedName_called = False
+ def protectedName(self):
+ self.protectedName_called = True
+ self._name = 'Extended' + ProtectedPolymorphic.protectedName(self)
+ return self._name
+
+class ExtendedProtectedPolymorphicDaughter(ProtectedPolymorphicDaughter):
+ def __init__(self, name):
+ self.protectedName_called = False
+ ProtectedPolymorphicDaughter.__init__(self, name)
+ def protectedName(self):
+ self.protectedName_called = True
+ self._name = 'ExtendedDaughter' + ProtectedPolymorphicDaughter.protectedName(self)
+ return self._name
+
+class ExtendedProtectedPolymorphicGrandDaughter(ProtectedPolymorphicGrandDaughter):
+ def __init__(self, name):
+ self.protectedName_called = False
+ ProtectedPolymorphicGrandDaughter.__init__(self, name)
+ def protectedName(self):
+ self.protectedName_called = True
+ self._name = 'ExtendedGrandDaughter' + ProtectedPolymorphicGrandDaughter.protectedName(self)
+ return self._name
+
+class ExtendedProtectedVirtualDestructor(ProtectedVirtualDestructor):
+ def __init__(self):
+ ProtectedVirtualDestructor.__init__(self)
+
+class ProtectedNonPolymorphicTest(unittest.TestCase):
+ '''Test cases for protected method in a class without virtual methods.'''
+
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
+ def testProtectedCall(self):
+ '''Calls a non-virtual protected method.'''
+ p = ProtectedNonPolymorphic('NonPoly')
+ self.assertEqual(p.publicName(), p.protectedName())
+ a0, a1 = 1, 2
+ self.assertEqual(p.protectedSum(a0, a1), a0 + a1)
+
+ def testProtectedCallWithInstanceCreatedOnCpp(self):
+ '''Calls a non-virtual protected method on an instance created in C++.'''
+ p = ProtectedNonPolymorphic.create()
+ self.assertEqual(p.publicName(), p.protectedName())
+ a0, a1 = 1, 2
+ self.assertEqual(p.protectedSum(a0, a1), a0 + a1)
+
+ def testModifiedProtectedCall(self):
+ '''Calls a non-virtual protected method modified with code injection.'''
+ p = ProtectedNonPolymorphic('NonPoly')
+ self.assertEqual(p.dataTypeName(), 'integer')
+ self.assertEqual(p.dataTypeName(1), 'integer')
+ self.assertEqual(p.dataTypeName(Point(1, 2)), 'pointer')
+
+class ProtectedPolymorphicTest(unittest.TestCase):
+ '''Test cases for protected method in a class with virtual methods.'''
+
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
+ def testProtectedCall(self):
+ '''Calls a virtual protected method.'''
+ p = ProtectedNonPolymorphic('Poly')
+ self.assertEqual(p.publicName(), p.protectedName())
+ a0, a1 = 1, 2
+ self.assertEqual(p.protectedSum(a0, a1), a0 + a1)
+
+ def testProtectedCallWithInstanceCreatedOnCpp(self):
+ '''Calls a virtual protected method on an instance created in C++.'''
+ p = ProtectedPolymorphic.create()
+ self.assertEqual(p.publicName(), p.protectedName())
+ self.assertEqual(p.callProtectedName(), p.protectedName())
+
+ def testReimplementedProtectedCall(self):
+ '''Calls a reimplemented virtual protected method.'''
+ original_name = 'Poly'
+ p = ExtendedProtectedPolymorphic(original_name)
+ name = p.callProtectedName()
+ self.assertTrue(p.protectedName_called)
+ self.assertEqual(p.protectedName(), name)
+ self.assertEqual(ProtectedPolymorphic.protectedName(p), original_name)
+class ProtectedPolymorphicDaugherTest(unittest.TestCase):
+ '''Test cases for protected method in a class inheriting for a class with virtual methods.'''
+
+ def testProtectedCallWithInstanceCreatedOnCpp(self):
+ '''Calls a virtual protected method from parent class on an instance created in C++.'''
+ p = ProtectedPolymorphicDaughter.create()
+ self.assertEqual(p.publicName(), p.protectedName())
+ self.assertEqual(p.callProtectedName(), p.protectedName())
+
+ def testReimplementedProtectedCall(self):
+ '''Calls a reimplemented virtual protected method from parent class.'''
+ original_name = 'Poly'
+ p = ExtendedProtectedPolymorphicDaughter(original_name)
+ name = p.callProtectedName()
+ self.assertTrue(p.protectedName_called)
+ self.assertEqual(p.protectedName(), name)
+ self.assertEqual(ProtectedPolymorphicDaughter.protectedName(p), original_name)
+
+
+class ProtectedPolymorphicGrandDaugherTest(unittest.TestCase):
+ '''Test cases for protected method in a class inheriting for a class that inherits from
+ another with protected virtual methods.'''
+
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
+ def testProtectedCallWithInstanceCreatedOnCpp(self):
+ '''Calls a virtual protected method from parent class on an instance created in C++.'''
+ p = ProtectedPolymorphicGrandDaughter.create()
+ self.assertEqual(p.publicName(), p.protectedName())
+ self.assertEqual(p.callProtectedName(), p.protectedName())
+
+ def testReimplementedProtectedCall(self):
+ '''Calls a reimplemented virtual protected method from parent class.'''
+ original_name = 'Poly'
+ p = ExtendedProtectedPolymorphicGrandDaughter(original_name)
+ name = p.callProtectedName()
+ self.assertTrue(p.protectedName_called)
+ self.assertEqual(p.protectedName(), name)
+ self.assertEqual(ProtectedPolymorphicGrandDaughter.protectedName(p), original_name)
+
+class ProtectedVirtualDtorTest(unittest.TestCase):
+ '''Test cases for protected virtual destructor.'''
+
+ def setUp(self):
+ ProtectedVirtualDestructor.resetDtorCounter()
+
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
+ def testVirtualProtectedDtor(self):
+ '''Original protected virtual destructor is being called.'''
+ dtor_called = ProtectedVirtualDestructor.dtorCalled()
+ for i in range(1, 10):
+ pvd = ProtectedVirtualDestructor()
+ del pvd
+ self.assertEqual(ProtectedVirtualDestructor.dtorCalled(), dtor_called + i)
+
+ def testVirtualProtectedDtorOnCppCreatedObject(self):
+ '''Original protected virtual destructor is being called for a C++ created object.'''
+ dtor_called = ProtectedVirtualDestructor.dtorCalled()
+ for i in range(1, 10):
+ pvd = ProtectedVirtualDestructor.create()
+ del pvd
+ self.assertEqual(ProtectedVirtualDestructor.dtorCalled(), dtor_called + i)
+
+ def testProtectedDtorOnDerivedClass(self):
+ '''Original protected virtual destructor is being called for a derived class.'''
+ dtor_called = ExtendedProtectedVirtualDestructor.dtorCalled()
+ for i in range(1, 10):
+ pvd = ExtendedProtectedVirtualDestructor()
+ del pvd
+ self.assertEqual(ExtendedProtectedVirtualDestructor.dtorCalled(), dtor_called + i)
+
+
+class ExtendedProtectedEnumClass(ProtectedEnumClass):
+ def __init__(self):
+ ProtectedEnumClass.__init__(self)
+ def protectedEnumMethod(self, value):
+ if value == ProtectedEnumClass.ProtectedItem0:
+ return ProtectedEnumClass.ProtectedItem1
+ return ProtectedEnumClass.ProtectedItem0
+ def publicEnumMethod(self, value):
+ if value == ProtectedEnumClass.PublicItem0:
+ return ProtectedEnumClass.PublicItem1
+ return ProtectedEnumClass.PublicItem0
+
+class ProtectedEnumTest(unittest.TestCase):
+ '''Test cases for protected enum.'''
+
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
+ def testProtectedMethodWithProtectedEnumArgument(self):
+ '''Calls protected method with protected enum argument.'''
+ obj = ProtectedEnumClass()
+
+ self.assertEqual(type(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedEnum)
+
+ self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem0)
+ self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem1)
+
+ self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem0)
+ self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem1)
+
+ def testProtectedMethodWithPublicEnumArgument(self):
+ '''Calls protected method with public enum argument.'''
+ obj = ProtectedEnumClass()
+
+ self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem0), ProtectedEnumClass.PublicItem0)
+ self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem1)
+
+ self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem0), ProtectedEnumClass.PublicItem0)
+ self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem1)
+
+ def testOverriddenProtectedMethodWithProtectedEnumArgument(self):
+ '''Calls overridden protected method with protected enum argument.'''
+ obj = ExtendedProtectedEnumClass()
+
+ self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem1)
+ self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem0)
+
+ self.assertEqual(ProtectedEnumClass.protectedEnumMethod(obj, ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem0)
+ self.assertEqual(ProtectedEnumClass.protectedEnumMethod(obj, ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem1)
+
+ self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem1)
+ self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem0)
+
+ def testOverriddenProtectedMethodWithPublicEnumArgument(self):
+ '''Calls overridden protected method with public enum argument.'''
+ obj = ExtendedProtectedEnumClass()
+
+ self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem0), ProtectedEnumClass.PublicItem1)
+ self.assertEqual(obj.publicEnumMethod(ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem0)
+
+ self.assertEqual(ProtectedEnumClass.publicEnumMethod(obj, ProtectedEnumClass.PublicItem0), ProtectedEnumClass.PublicItem0)
+ self.assertEqual(ProtectedEnumClass.publicEnumMethod(obj, ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem1)
+
+ self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem0), ProtectedEnumClass.PublicItem1)
+ self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem0)
+
+
+class ProtectedPropertyTest(unittest.TestCase):
+ '''Test cases for a class with a protected property (or field in C++).'''
+
+ def setUp(self):
+ self.obj = ProtectedProperty()
+
+ def tearDown(self):
+ del self.obj
+ self.assertEqual(cacheSize(), 0)
+
+ def testProtectedProperty(self):
+ '''Writes and reads a protected integer property.'''
+ self.obj.protectedProperty = 3
+ self.assertEqual(self.obj.protectedProperty, 3)
+
+ def testProtectedContainerProperty(self):
+ '''Writes and reads a protected list of integers property.'''
+ lst = [1, 2, 3, 4]
+ self.obj.protectedContainerProperty = lst
+ self.assertEqual(self.obj.protectedContainerProperty, lst)
+
+ def testProtectedEnumProperty(self):
+ '''Writes and reads a protected enum property.'''
+ self.obj.protectedEnumProperty = Event.SOME_EVENT
+ self.assertEqual(self.obj.protectedEnumProperty, Event.SOME_EVENT)
+
+ def testProtectedValueTypeProperty(self):
+ '''Writes and reads a protected value type property.'''
+ point = Point(12, 34)
+ self.obj.protectedValueTypeProperty = point
+ self.assertEqual(self.obj.protectedValueTypeProperty, point)
+ self.assertFalse(self.obj.protectedValueTypeProperty is point)
+ pointProperty = self.obj.protectedValueTypeProperty
+ self.assertTrue(self.obj.protectedValueTypeProperty is pointProperty)
+
+ def testProtectedValueTypePropertyWrapperRegistration(self):
+ '''Access colocated protected value type property.'''
+ cache_size = cacheSize()
+ point = Point(12, 34)
+ obj = createProtectedProperty()
+ obj.protectedValueTypeProperty
+ self.assertEqual(obj.protectedValueTypeProperty.copy(),
+ obj.protectedValueTypeProperty)
+ obj.protectedValueTypeProperty = point
+ self.assertEqual(obj.protectedValueTypeProperty, point)
+ self.assertFalse(obj.protectedValueTypeProperty is point)
+ pointProperty = obj.protectedValueTypeProperty
+ self.assertTrue(obj.protectedValueTypeProperty is pointProperty)
+ del obj, point, pointProperty
+ self.assertEqual(cacheSize(), cache_size)
+
+ def testProtectedValueTypePointerProperty(self):
+ '''Writes and reads a protected value type pointer property.'''
+ pt1 = Point(12, 34)
+ pt2 = Point(12, 34)
+ self.obj.protectedValueTypePointerProperty = pt1
+ self.assertEqual(self.obj.protectedValueTypePointerProperty, pt1)
+ self.assertEqual(self.obj.protectedValueTypePointerProperty, pt2)
+ self.assertTrue(self.obj.protectedValueTypePointerProperty is pt1)
+ self.assertFalse(self.obj.protectedValueTypePointerProperty is pt2)
+
+ def testProtectedObjectTypeProperty(self):
+ '''Writes and reads a protected object type property.'''
+ obj = ObjectType()
+ self.obj.protectedObjectTypeProperty = obj
+ self.assertEqual(self.obj.protectedObjectTypeProperty, obj)
+
+
+class PrivateDtorProtectedMethodTest(unittest.TestCase):
+ '''Test cases for classes with private destructors and protected methods.'''
+
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
+ def testProtectedMethod(self):
+ '''Calls protected method of a class with a private destructor.'''
+ obj = PrivateDtor.instance()
+
+ self.assertEqual(type(obj), PrivateDtor)
+ self.assertEqual(obj.instanceCalls(), 1)
+ self.assertEqual(obj.instanceCalls(), obj.protectedInstanceCalls())
+ obj = PrivateDtor.instance()
+ self.assertEqual(obj.instanceCalls(), 2)
+ self.assertEqual(obj.instanceCalls(), obj.protectedInstanceCalls())
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/pstrlist_test.py b/sources/shiboken2/tests/samplebinding/pstrlist_test.py
new file mode 100644
index 000000000..47e89bacb
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/pstrlist_test.py
@@ -0,0 +1,50 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+import sample
+
+class PStrListTest(unittest.TestCase):
+
+ def testPStrList(self):
+ a = 'str0'
+ b = 'str1'
+ lst = sample.createPStrList(a, b)
+ self.assertEqual(lst, [a, b])
+
+ def testListOfPStr(self):
+ a = 'str0'
+ b = 'str1'
+ lst = sample.createListOfPStr(a, b)
+ self.assertEqual(lst, [a, b])
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/pystr_test.py b/sources/shiboken2/tests/samplebinding/pystr_test.py
new file mode 100644
index 000000000..9056e96b7
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/pystr_test.py
@@ -0,0 +1,49 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for definition of __str__ method.'''
+
+import sys
+import unittest
+
+from sample import Point
+
+class PyStrTest(unittest.TestCase):
+ '''Test case for definition of __str__ method.'''
+
+ def testPyStr(self):
+ '''Test case for defined __str__ method.'''
+ pt = Point(5, 2)
+ self.assertEqual(str(pt), 'Point(5.0, 2.0)')
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/python_thread_test.py b/sources/shiboken2/tests/samplebinding/python_thread_test.py
new file mode 100644
index 000000000..dcd59ee1f
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/python_thread_test.py
@@ -0,0 +1,116 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+#!/usr/bin/env python
+
+'''Tests for using Shiboken-based bindings with python threads'''
+
+import unittest
+import threading
+import sample
+import time
+
+import logging
+
+#logging.basicConfig(level=logging.DEBUG)
+
+from random import random
+
+class Producer(threading.Thread):
+ '''Producer thread'''
+
+ def __init__(self, bucket, max_runs, *args):
+ #Constructor. Receives the bucket
+ super(Producer, self).__init__(*args)
+ self.runs = 0
+ self.bucket = bucket
+ self.max_runs = max_runs
+ self.production_list = []
+
+ def run(self):
+ while self.runs < self.max_runs:
+ value = int(random()*10) % 10
+ self.bucket.push(value)
+ self.production_list.append(value)
+ logging.debug('PRODUCER - pushed %d' % value)
+ self.runs += 1
+ #self.msleep(5)
+ time.sleep(0.01)
+
+
+class Consumer(threading.Thread):
+ '''Consumer thread'''
+ def __init__(self, bucket, max_runs, *args):
+ #Constructor. Receives the bucket
+ super(Consumer, self).__init__(*args)
+ self.runs = 0
+ self.bucket = bucket
+ self.max_runs = max_runs
+ self.consumption_list = []
+
+ def run(self):
+ while self.runs < self.max_runs:
+ if not self.bucket.empty():
+ value = self.bucket.pop()
+ self.consumption_list.append(value)
+ logging.debug('CONSUMER - got %d' % value)
+ self.runs += 1
+ else:
+ logging.debug('CONSUMER - empty bucket')
+ time.sleep(0.01)
+
+class ProducerConsumer(unittest.TestCase):
+ '''Basic test case for producer-consumer QThread'''
+
+ def finishCb(self):
+ #Quits the application
+ self.app.exit(0)
+
+ def testProdCon(self):
+ #QThread producer-consumer example
+ bucket = sample.Bucket()
+ prod = Producer(bucket, 10)
+ cons = Consumer(bucket, 10)
+
+ prod.start()
+ cons.start()
+
+ #QObject.connect(prod, SIGNAL('finished()'), self.finishCb)
+ #QObject.connect(cons, SIGNAL('finished()'), self.finishCb)
+
+ prod.join()
+ cons.join()
+
+ self.assertEqual(prod.production_list, cons.consumption_list)
+
+
+
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/receive_null_cstring_test.py b/sources/shiboken2/tests/samplebinding/receive_null_cstring_test.py
new file mode 100644
index 000000000..12cc67142
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/receive_null_cstring_test.py
@@ -0,0 +1,54 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for a function that could receive a NULL pointer in a '[const] char*' parameter.'''
+
+import unittest
+
+from sample import countCharacters
+
+class ReceiveNullCStringTest(unittest.TestCase):
+ '''Test case for a function that could receive a NULL pointer in a '[const] char*' parameter.'''
+
+ def testBasic(self):
+ '''The test function should be working for the basic cases.'''
+ a = ''
+ b = 'abc'
+ self.assertEqual(countCharacters(a), len(a))
+ self.assertEqual(countCharacters(b), len(b))
+
+ def testReceiveNull(self):
+ '''The test function returns '-1' when receives a None value instead of a string.'''
+ self.assertEqual(countCharacters(None), -1)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/reference_test.py b/sources/shiboken2/tests/samplebinding/reference_test.py
new file mode 100644
index 000000000..aaf809451
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/reference_test.py
@@ -0,0 +1,122 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for methods that receive references to objects.'''
+
+import sys
+import unittest
+
+from sample import *
+
+class ExtendedReference(Reference):
+ def __init__(self):
+ Reference.__init__(self)
+ self.uses_reference_virtual_called = False
+ self.uses_const_reference_virtual_called = False
+ self.reference_inc = 1
+ self.const_reference_inc = 2
+ self.multiplier = 333
+
+ def usesReferenceVirtual(self, ref, inc):
+ self.uses_reference_virtual_called = True
+ return ref.objId() + inc + self.reference_inc
+
+ def usesConstReferenceVirtual(self, ref, inc):
+ self.uses_const_reference_virtual_called = True
+ return ref.objId() + inc + self.const_reference_inc
+
+ def alterReferenceIdVirtual(self, ref):
+ ref.setObjId(ref.objId() * self.multiplier)
+
+
+class ReferenceTest(unittest.TestCase):
+ '''Test case for methods that receive references to objects.'''
+
+ def testMethodThatReceivesReference(self):
+ '''Test a method that receives a reference to an object as argument.'''
+ objId = 123
+ r = Reference(objId)
+ self.assertEqual(Reference.usesReference(r), objId)
+
+ def testCantSegFaultWhenReceiveNone(self):
+ '''do not segfault when receiving None as argument.'''
+ s = Str()
+ self.assertTrue(None == s)
+
+ def testMethodThatReceivesConstReference(self):
+ '''Test a method that receives a const reference to an object as argument.'''
+ objId = 123
+ r = Reference(objId)
+ self.assertEqual(Reference.usesConstReference(r), objId)
+
+ def testModificationOfReference(self):
+ '''Tests if the identity of a reference argument is preserved when passing it to be altered in C++.'''
+ objId = 123
+ r1 = Reference(objId)
+ r1.alterReferenceIdVirtual(r1)
+ self.assertEqual(r1.objId(), objId * Reference.multiplier())
+
+ def testModificationOfReferenceCallingAVirtualIndirectly(self):
+ '''Tests if the identity of a reference argument is preserved when passing it to be altered in C++ through a method that calls a virtual method.'''
+ objId = 123
+ r1 = Reference(objId)
+ r1.callAlterReferenceIdVirtual(r1)
+ self.assertEqual(r1.objId(), objId * Reference.multiplier())
+
+ def testModificationOfReferenceCallingAReimplementedVirtualIndirectly(self):
+ '''Test if a Python override of a virtual method with a reference parameter called from C++ alters the argument properly.'''
+ objId = 123
+ r = Reference(objId)
+ er = ExtendedReference()
+ result = er.callAlterReferenceIdVirtual(r)
+ self.assertEqual(r.objId(), objId * er.multiplier)
+
+ def testReimplementedVirtualMethodCallWithReferenceParameter(self):
+ '''Test if a Python override of a virtual method with a reference parameter is correctly called from C++.'''
+ inc = 9
+ objId = 123
+ r = Reference(objId)
+ er = ExtendedReference()
+ result = er.callUsesReferenceVirtual(r, inc)
+ self.assertEqual(result, objId + inc + er.reference_inc)
+
+ def testReimplementedVirtualMethodCallWithConstReferenceParameter(self):
+ '''Test if a Python override of a virtual method with a const reference parameter is correctly called from C++.'''
+ inc = 9
+ objId = 123
+ r = Reference(objId)
+ er = ExtendedReference()
+ result = er.callUsesConstReferenceVirtual(r, inc)
+ self.assertEqual(result, objId + inc + er.const_reference_inc)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/referencetopointer_test.py b/sources/shiboken2/tests/samplebinding/referencetopointer_test.py
new file mode 100644
index 000000000..8d85032a0
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/referencetopointer_test.py
@@ -0,0 +1,97 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for a reference to pointer argument type.'''
+
+import unittest
+
+from sample import VirtualMethods, Str
+
+class ExtendedVirtualMethods(VirtualMethods):
+ def __init__(self):
+ VirtualMethods.__init__(self)
+ self.prefix = 'Ext'
+
+ def createStr(self, text):
+ ext_text = text
+ if text is not None:
+ ext_text = self.prefix + text
+ return VirtualMethods.createStr(self, ext_text)
+
+
+class ReferenceToPointerTest(unittest.TestCase):
+ '''Test cases for a reference to pointer argument type.'''
+
+ def testSimpleCallWithNone(self):
+ '''Simple call to createStr method with a None argument.'''
+ obj = VirtualMethods()
+ ok, string = obj.createStr(None)
+ self.assertFalse(ok)
+ self.assertEqual(string, None)
+
+ def testSimpleCallWithString(self):
+ '''Simple call to createStr method with a Python string argument.'''
+ obj = VirtualMethods()
+ ok, string = obj.createStr('foo')
+ self.assertTrue(ok)
+ self.assertEqual(string, Str('foo'))
+
+ def testCallNonReimplementedMethodWithNone(self):
+ '''Calls createStr method from C++ with a None argument.'''
+ obj = VirtualMethods()
+ ok, string = obj.callCreateStr(None)
+ self.assertFalse(ok)
+ self.assertEqual(string, None)
+
+ def testCallNonReimplementedMethodWithString(self):
+ '''Calls createStr method from C++ with a Python string argument.'''
+ obj = VirtualMethods()
+ ok, string = obj.callCreateStr('foo')
+ self.assertTrue(ok)
+ self.assertEqual(string, Str('foo'))
+
+ def testCallReimplementedMethodWithNone(self):
+ '''Calls reimplemented createStr method from C++ with a None argument.'''
+ obj = ExtendedVirtualMethods()
+ ok, string = obj.callCreateStr(None)
+ self.assertFalse(ok)
+ self.assertEqual(string, None)
+
+ def testCallReimplementedMethodWithString(self):
+ '''Calls reimplemented createStr method from C++ with a Python string argument.'''
+ obj = ExtendedVirtualMethods()
+ ok, string = obj.callCreateStr('foo')
+ self.assertTrue(ok)
+ self.assertEqual(string, Str(obj.prefix + 'foo'))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/return_null_test.py b/sources/shiboken2/tests/samplebinding/return_null_test.py
new file mode 100644
index 000000000..377624482
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/return_null_test.py
@@ -0,0 +1,59 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for functions that could return a NULL pointer.'''
+
+import sys
+import unittest
+
+from sample import returnNullPrimitivePointer, returnNullValueTypePointer, returnNullObjectTypePointer
+
+class ReturnNullTest(unittest.TestCase):
+ '''Test case for functions that could return a NULL pointer.'''
+
+ def testReturnNull(self):
+ '''Function returns a NULL pointer to a primitive type.'''
+ o = returnNullPrimitivePointer()
+ self.assertEqual(o, None)
+
+ def testReturnNullObjectType(self):
+ '''Function returns a NULL pointer to an object-type.'''
+ o = returnNullObjectTypePointer()
+ self.assertEqual(o, None)
+
+ def testReturnNullValueType(self):
+ '''Function returns a NULL pointer to a value-type.'''
+ o = returnNullValueTypePointer()
+ self.assertEqual(o, None)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/richcompare_test.py b/sources/shiboken2/tests/samplebinding/richcompare_test.py
new file mode 100644
index 000000000..8c5eea694
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/richcompare_test.py
@@ -0,0 +1,46 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from sample import *
+
+class TestRichCompare(unittest.TestCase):
+
+ def testIt(self):
+ a = Expression(2)
+ b = Expression(3)
+ c = a + b
+ d = a + c < b + a
+ self.assertEqual(d.toString(), "((2+(2+3))<(3+2))")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/sample-binding.txt.in b/sources/shiboken2/tests/samplebinding/sample-binding.txt.in
new file mode 100644
index 000000000..317f76f09
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/sample-binding.txt.in
@@ -0,0 +1,15 @@
+[generator-project]
+
+generator-set = shiboken
+
+header-file = @CMAKE_CURRENT_SOURCE_DIR@/global.h
+typesystem-file = @sample_TYPESYSTEM@
+
+output-directory = @CMAKE_CURRENT_BINARY_DIR@
+
+include-path = @libsample_SOURCE_DIR@
+
+typesystem-path = @CMAKE_CURRENT_SOURCE_DIR@
+
+enable-parent-ctor-heuristic
+use-isnull-as-nb_nonzero
diff --git a/sources/shiboken2/tests/samplebinding/sample_test.py b/sources/shiboken2/tests/samplebinding/sample_test.py
new file mode 100644
index 000000000..65d1d2871
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/sample_test.py
@@ -0,0 +1,78 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for libsample bindings module'''
+
+import unittest
+
+import sample
+
+class ModuleTest(unittest.TestCase):
+ '''Test case for module and global functions'''
+
+ def testModuleMembers(self):
+ '''Test availability of classes, global functions and other members on binding'''
+ expected_members = set(['Abstract', 'Derived', 'Point',
+ 'ListUser', 'PairUser', 'MapUser',
+ 'gimmeComplexList', 'gimmeDouble', 'gimmeInt',
+ 'makeCString', 'multiplyPair', 'returnCString',
+ 'SampleNamespace', 'transmuteComplexIntoPoint',
+ 'transmutePointIntoComplex', 'sumComplexPair',
+ 'FirstThing', 'SecondThing', 'ThirdThing',
+ 'GlobalEnum', 'NoThing'])
+ self.assertTrue(expected_members.issubset(dir(sample)))
+
+ def testAbstractPrintFormatEnum(self):
+ '''Test availability of PrintFormat enum from Abstract class'''
+ enum_members = set(['PrintFormat', 'Short', 'Verbose',
+ 'OnlyId', 'ClassNameAndId'])
+ self.assertTrue(enum_members.issubset(dir(sample.Abstract)))
+
+ def testSampleNamespaceOptionEnum(self):
+ '''Test availability of Option enum from SampleNamespace namespace'''
+ enum_members = set(['Option', 'None_', 'RandomNumber', 'UnixTime'])
+ self.assertTrue(enum_members.issubset(dir(sample.SampleNamespace)))
+
+ def testAddedFunctionAtModuleLevel(self):
+ '''Calls function added to module from type system description.'''
+ str1 = 'Foo'
+ self.assertEqual(sample.multiplyString(str1, 3), str1 * 3)
+ self.assertEqual(sample.multiplyString(str1, 0), str1 * 0)
+
+ def testAddedFunctionWithVarargs(self):
+ '''Calls function that receives varargs added to module from type system description.'''
+ self.assertEqual(sample.countVarargs(1), 0)
+ self.assertEqual(sample.countVarargs(1, 2), 1)
+ self.assertEqual(sample.countVarargs(1, 2, 3, 'a', 'b', 4, (5, 6)), 6)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/simplefile_glue.cpp b/sources/shiboken2/tests/samplebinding/simplefile_glue.cpp
new file mode 100644
index 000000000..a7f05eb99
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/simplefile_glue.cpp
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+if (!%CPPSELF.%FUNCTION_NAME()) {
+ PyObject* error_msg = PyBytes_FromFormat(
+ "Could not open file: \"%s\"", %CPPSELF->filename());
+ PyErr_SetObject(PyExc_IOError, error_msg);
+ return 0;
+}
diff --git a/sources/shiboken2/tests/samplebinding/simplefile_test.py b/sources/shiboken2/tests/samplebinding/simplefile_test.py
new file mode 100644
index 000000000..c2a1afe59
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/simplefile_test.py
@@ -0,0 +1,81 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for SimpleFile class'''
+
+import os
+import unittest
+
+from sample import SimpleFile
+
+class SimpleFileTest(unittest.TestCase):
+ '''Test cases for SimpleFile class.'''
+
+ def setUp(self):
+ filename = 'simplefile%d.txt' % os.getpid()
+ self.existing_filename = os.path.join(os.path.curdir, filename)
+ self.delete_file = False
+ if not os.path.exists(self.existing_filename):
+ f = open(self.existing_filename, 'w')
+ for line in range(10):
+ f.write('sbrubbles\n')
+ f.close()
+ self.delete_file = True
+
+ self.non_existing_filename = os.path.join(os.path.curdir, 'inexistingfile.txt')
+ i = 0
+ while os.path.exists(self.non_existing_filename):
+ i += 1
+ filename = 'inexistingfile-%d.txt' % i
+ self.non_existing_filename = os.path.join(os.path.curdir, filename)
+
+ def tearDown(self):
+ if self.delete_file:
+ os.remove(self.existing_filename)
+
+ def testExistingFile(self):
+ '''Test SimpleFile class with existing file.'''
+ f = SimpleFile(self.existing_filename)
+ self.assertEqual(f.filename(), self.existing_filename)
+ f.open()
+ self.assertNotEqual(f.size(), 0)
+ f.close()
+
+ def testNonExistingFile(self):
+ '''Test SimpleFile class with non-existing file.'''
+ f = SimpleFile(self.non_existing_filename)
+ self.assertEqual(f.filename(), self.non_existing_filename)
+ self.assertRaises(IOError, f.open)
+ self.assertEqual(f.size(), 0)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/size_test.py b/sources/shiboken2/tests/samplebinding/size_test.py
new file mode 100644
index 000000000..502539689
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/size_test.py
@@ -0,0 +1,119 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for operator overloads on Size class'''
+
+import unittest
+
+from sample import Size
+
+class PointTest(unittest.TestCase):
+ '''Test case for Size class, including operator overloads.'''
+
+ def testConstructor(self):
+ '''Test Size class constructor.'''
+ width, height = (5.0, 2.3)
+ size = Size(width, height)
+ self.assertEqual(size.width(), width)
+ self.assertEqual(size.height(), height)
+ self.assertEqual(size.calculateArea(), width * height)
+
+ def testCopyConstructor(self):
+ '''Test Size class copy constructor.'''
+ width, height = (5.0, 2.3)
+ s1 = Size(width, height)
+ s2 = Size(s1)
+ self.assertFalse(s1 is s2)
+ self.assertEqual(s1, s2)
+
+ def testPlusOperator(self):
+ '''Test Size class + operator.'''
+ s1 = Size(5.0, 2.3)
+ s2 = Size(0.5, 3.2)
+ self.assertEqual(s1 + s2, Size(5.0 + 0.5, 2.3 + 3.2))
+
+ def testEqualOperator(self):
+ '''Test Size class == operator.'''
+ s1 = Size(5.0, 2.3)
+ s2 = Size(5.0, 2.3)
+ s3 = Size(0.5, 3.2)
+ self.assertTrue(s1 == s1)
+ self.assertTrue(s1 == s2)
+ self.assertFalse(s1 == s3)
+
+ def testNotEqualOperator(self):
+ '''Test Size class != operator.'''
+ s1 = Size(5.0, 2.3)
+ s2 = Size(5.0, 2.3)
+ s3 = Size(0.5, 3.2)
+ self.assertFalse(s1 != s1)
+ self.assertFalse(s1 != s2)
+ self.assertTrue(s1 != s3)
+
+ def testMinorEqualOperator(self):
+ '''Test Size class <= operator.'''
+ s1 = Size(5.0, 2.3)
+ s2 = Size(5.0, 2.3)
+ s3 = Size(0.5, 3.2)
+ self.assertTrue(s1 <= s1)
+ self.assertTrue(s1 <= s2)
+ self.assertTrue(s3 <= s1)
+ self.assertFalse(s1 <= s3)
+
+ def testMinorOperator(self):
+ '''Test Size class < operator.'''
+ s1 = Size(5.0, 2.3)
+ s2 = Size(0.5, 3.2)
+ self.assertFalse(s1 < s1)
+ self.assertFalse(s1 < s2)
+ self.assertTrue(s2 < s1)
+
+ def testMajorEqualOperator(self):
+ '''Test Size class >= operator.'''
+ s1 = Size(5.0, 2.3)
+ s2 = Size(5.0, 2.3)
+ s3 = Size(0.5, 3.2)
+ self.assertTrue(s1 >= s1)
+ self.assertTrue(s1 >= s2)
+ self.assertTrue(s1 >= s3)
+ self.assertFalse(s3 >= s1)
+
+ def testMajorOperator(self):
+ '''Test Size class > operator.'''
+ s1 = Size(5.0, 2.3)
+ s2 = Size(0.5, 3.2)
+ self.assertFalse(s1 > s1)
+ self.assertTrue(s1 > s2)
+ self.assertFalse(s2 > s1)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/static_nonstatic_methods_test.py b/sources/shiboken2/tests/samplebinding/static_nonstatic_methods_test.py
new file mode 100644
index 000000000..6451c4440
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/static_nonstatic_methods_test.py
@@ -0,0 +1,109 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for overloads involving static and non-static versions of a method.'''
+
+import os
+import unittest
+
+from sample import SimpleFile
+
+class SimpleFile2 (SimpleFile):
+ def exists(self):
+ return "Mooo"
+
+class SimpleFile3 (SimpleFile):
+ pass
+
+class SimpleFile4 (SimpleFile):
+ exists = 5
+
+class StaticNonStaticMethodsTest(unittest.TestCase):
+ '''Test cases for overloads involving static and non-static versions of a method.'''
+
+ def setUp(self):
+ filename = 'simplefile%d.txt' % os.getpid()
+ self.existing_filename = os.path.join(os.path.curdir, filename)
+ self.delete_file = False
+ if not os.path.exists(self.existing_filename):
+ f = open(self.existing_filename, 'w')
+ for line in range(10):
+ f.write('sbrubbles\n')
+ f.close()
+ self.delete_file = True
+
+ self.non_existing_filename = os.path.join(os.path.curdir, 'inexistingfile.txt')
+ i = 0
+ while os.path.exists(self.non_existing_filename):
+ i += 1
+ filename = 'inexistingfile-%d.txt' % i
+ self.non_existing_filename = os.path.join(os.path.curdir, filename)
+
+ def tearDown(self):
+ if self.delete_file:
+ os.remove(self.existing_filename)
+
+ def testCallingStaticMethodWithClass(self):
+ '''Call static method using class.'''
+ self.assertTrue(SimpleFile.exists(self.existing_filename))
+ self.assertFalse(SimpleFile.exists(self.non_existing_filename))
+
+ def testCallingStaticMethodWithInstance(self):
+ '''Call static method using instance of class.'''
+ f = SimpleFile(self.non_existing_filename)
+ self.assertTrue(f.exists(self.existing_filename))
+ self.assertFalse(f.exists(self.non_existing_filename))
+
+ def testCallingInstanceMethod(self):
+ '''Call instance method.'''
+ f1 = SimpleFile(self.non_existing_filename)
+ self.assertFalse(f1.exists())
+ f2 = SimpleFile(self.existing_filename)
+ self.assertTrue(f2.exists())
+
+ def testOverridingStaticNonStaticMethod(self):
+ f = SimpleFile2(self.existing_filename)
+ self.assertEqual(f.exists(), "Mooo")
+
+ f = SimpleFile3(self.existing_filename)
+ self.assertTrue(f.exists())
+
+ f = SimpleFile4(self.existing_filename)
+ self.assertEqual(f.exists, 5)
+
+ def testDuckPunchingStaticNonStaticMethod(self):
+ f = SimpleFile(self.existing_filename)
+ f.exists = lambda : "Meee"
+ self.assertEqual(f.exists(), "Meee")
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/str_test.py b/sources/shiboken2/tests/samplebinding/str_test.py
new file mode 100644
index 000000000..dca7e1f44
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/str_test.py
@@ -0,0 +1,115 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for a method that receives a reference to class that is implicitly convertible from a Python native type.'''
+
+import unittest
+
+from sample import Str
+
+class StrTest(unittest.TestCase):
+ '''Test cases for thr Str class.'''
+
+ def test__str__Method(self):
+ '''Test if the binding correcly implements the Python __str__ method.'''
+ s1 = 'original string'
+ s2 = Str(s1)
+ self.assertEqual(s1, s2)
+ self.assertEqual(s1, str(s2))
+
+ def testPassExactClassAsReferenceToArgument(self):
+ '''Test passing the expected class as an argument to a method that expects a reference.'''
+ s1 = Str('This is %VAR!').arg(Str('Sparta'))
+ self.assertEqual(str(s1), 'This is Sparta!')
+
+ def testPassPythonTypeImplictlyConvertibleToAClassUsedAsReference(self):
+ '''Test passing a Python class implicitly convertible to a wrapped class that is expected to be passed as reference.'''
+ s1 = Str('This is %VAR!').arg('Athens')
+ self.assertEqual(str(s1), 'This is Athens!')
+
+ def testSequenceOperators(self):
+ s1 = Str("abcdef")
+ self.assertEqual(len(s1), 6);
+ self.assertEqual(len(Str()), 0);
+
+ # getitem
+ self.assertEqual(s1[0], "a");
+ self.assertEqual(s1[1], "b");
+ self.assertEqual(s1[2], "c");
+ self.assertEqual(s1[3], "d");
+ self.assertEqual(s1[4], "e");
+ self.assertEqual(s1[5], "f");
+ self.assertEqual(s1[-1], "f");
+ self.assertEqual(s1[-2], "e");
+
+ self.assertRaises(TypeError, s1.__getitem__, 6)
+
+ # setitem
+ s1[0] = 'A'
+ s1[1] = 'B'
+ self.assertEqual(s1[0], 'A');
+ self.assertEqual(s1[1], 'B');
+ self.assertRaises(TypeError, s1.__setitem__(6, 67))
+
+ def testReverseOperator(self):
+ s1 = Str("hello")
+ n1 = 2
+ self.assertEqual(s1+2, "hello2")
+ self.assertEqual(2+s1, "2hello")
+
+ def testToIntError(self):
+ self.assertEqual(Str('Z').toInt(), (0, False))
+
+ def testToIntWithDecimal(self):
+ decimal = Str('37')
+ val, ok = decimal.toInt()
+ self.assertEqual(type(val), int)
+ self.assertEqual(type(ok), bool)
+ self.assertEqual(val, int(str(decimal)))
+
+ def testToIntWithOctal(self):
+ octal = Str('52')
+ val, ok = octal.toInt(8)
+ self.assertEqual(type(val), int)
+ self.assertEqual(type(ok), bool)
+ self.assertEqual(val, int(str(octal), 8))
+
+ def testToIntWithHexadecimal(self):
+ hexa = Str('2A')
+ val, ok = hexa.toInt(16)
+ self.assertEqual(type(val), int)
+ self.assertEqual(type(ok), bool)
+ self.assertEqual(val, int(str(hexa), 16))
+ self.assertEqual(hexa.toInt(), (0, False))
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/strlist_test.py b/sources/shiboken2/tests/samplebinding/strlist_test.py
new file mode 100644
index 000000000..341fcfa32
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/strlist_test.py
@@ -0,0 +1,112 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for StrList class that inherits from std::list<Str>.'''
+
+import unittest
+
+from sample import Str, StrList
+
+class StrListTest(unittest.TestCase):
+ '''Test cases for StrList class that inherits from std::list<Str>.'''
+
+ def testStrListCtor_NoParams(self):
+ '''StrList constructor receives no parameter.'''
+ sl = StrList()
+ self.assertEqual(len(sl), 0)
+ self.assertEqual(sl.constructorUsed(), StrList.NoParamsCtor)
+
+ def testStrListCtor_Str(self):
+ '''StrList constructor receives a Str object.'''
+ s = Str('Foo')
+ sl = StrList(s)
+ self.assertEqual(len(sl), 1)
+ self.assertEqual(sl[0], s)
+ self.assertEqual(sl.constructorUsed(), StrList.StrCtor)
+
+ def testStrListCtor_PythonString(self):
+ '''StrList constructor receives a Python string.'''
+ s = 'Foo'
+ sl = StrList(s)
+ self.assertEqual(len(sl), 1)
+ self.assertEqual(sl[0], s)
+ self.assertEqual(sl.constructorUsed(), StrList.StrCtor)
+
+ def testStrListCtor_StrList(self):
+ '''StrList constructor receives a StrList object.'''
+ sl1 = StrList(Str('Foo'))
+ sl2 = StrList(sl1)
+ #self.assertEqual(len(sl1), len(sl2))
+ #self.assertEqual(sl1, sl2)
+ self.assertEqual(sl2.constructorUsed(), StrList.CopyCtor)
+
+ def testStrListCtor_ListOfStrs(self):
+ '''StrList constructor receives a Python list of Str objects.'''
+ strs = [Str('Foo'), Str('Bar')]
+ sl = StrList(strs)
+ self.assertEqual(len(sl), len(strs))
+ self.assertEqual(sl, strs)
+ self.assertEqual(sl.constructorUsed(), StrList.ListOfStrCtor)
+
+ def testStrListCtor_MixedListOfStrsAndPythonStrings(self):
+ '''StrList constructor receives a Python list of mixed Str objects and Python strings.'''
+ strs = [Str('Foo'), 'Bar']
+ sl = StrList(strs)
+ self.assertEqual(len(sl), len(strs))
+ self.assertEqual(sl, strs)
+ self.assertEqual(sl.constructorUsed(), StrList.ListOfStrCtor)
+
+ def testCompareStrListWithTupleOfStrs(self):
+ '''Compares StrList with a Python tuple of Str objects.'''
+ sl = StrList()
+ sl.append(Str('Foo'))
+ sl.append(Str('Bar'))
+ self.assertEqual(len(sl), 2)
+ self.assertEqual(sl, (Str('Foo'), Str('Bar')))
+
+ def testCompareStrListWithTupleOfPythonStrings(self):
+ '''Compares StrList with a Python tuple of Python strings.'''
+ sl = StrList()
+ sl.append(Str('Foo'))
+ sl.append(Str('Bar'))
+ self.assertEqual(len(sl), 2)
+ self.assertEqual(sl, ('Foo', 'Bar'))
+
+ def testCompareStrListWithTupleOfStrAndPythonString(self):
+ '''Compares StrList with a Python tuple of mixed Str objects and Python strings.'''
+ sl = StrList()
+ sl.append(Str('Foo'))
+ sl.append(Str('Bar'))
+ self.assertEqual(len(sl), 2)
+ self.assertEqual(sl, (Str('Foo'), 'Bar'))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/templateinheritingclass_test.py b/sources/shiboken2/tests/samplebinding/templateinheritingclass_test.py
new file mode 100644
index 000000000..7acb6a597
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/templateinheritingclass_test.py
@@ -0,0 +1,80 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sample import Photon
+
+'''This tests classes that inherit from template classes,
+simulating a situation found in Qt's phonon module.'''
+
+class TemplateInheritingClassTest(unittest.TestCase):
+ def testClassBasics(self):
+ self.assertEqual(Photon.ValueIdentity.classType(), Photon.IdentityType)
+ self.assertEqual(Photon.ValueDuplicator.classType(), Photon.DuplicatorType)
+
+ def testInstanceBasics(self):
+ value = 123
+ samer = Photon.ValueIdentity(value)
+ self.assertEqual(samer.multiplicator(), 1)
+ doubler = Photon.ValueDuplicator(value)
+ self.assertEqual(doubler.multiplicator(), 2)
+ self.assertEqual(samer.value(), doubler.value())
+ self.assertEqual(samer.calculate() * 2, doubler.calculate())
+
+ def testPassToFunctionAsPointer(self):
+ obj = Photon.ValueDuplicator(123)
+ self.assertEqual(Photon.callCalculateForValueDuplicatorPointer(obj), obj.calculate())
+
+ def testPassToFunctionAsReference(self):
+ obj = Photon.ValueDuplicator(321)
+ self.assertEqual(Photon.callCalculateForValueDuplicatorReference(obj), obj.calculate())
+
+ def testPassToMethodAsValue(self):
+ value1, value2 = 123, 321
+ one = Photon.ValueIdentity(value1)
+ other = Photon.ValueIdentity(value2)
+ self.assertEqual(one.sumValueUsingPointer(other), value1 + value2)
+
+ def testPassToMethodAsReference(self):
+ value1, value2 = 123, 321
+ one = Photon.ValueDuplicator(value1)
+ other = Photon.ValueDuplicator(value2)
+ self.assertEqual(one.sumValueUsingReference(other), value1 + value2)
+
+ def testPassPointerThrough(self):
+ obj1 = Photon.ValueIdentity(123)
+ self.assertEqual(obj1, obj1.passPointerThrough(obj1))
+ obj2 = Photon.ValueDuplicator(321)
+ self.assertEqual(obj2, obj2.passPointerThrough(obj2))
+ self.assertRaises(TypeError, obj1.passPointerThrough, obj2)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/time_test.py b/sources/shiboken2/tests/samplebinding/time_test.py
new file mode 100644
index 000000000..db8818fd3
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/time_test.py
@@ -0,0 +1,139 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for constructor and method signature decisor on Time class.'''
+
+import sys
+import unittest
+import datetime
+
+from sample import Time, ImplicitConv, ObjectType
+
+class TimeTest(unittest.TestCase):
+ '''Test cases for constructor and method signature decisor on Time class.
+ The constructor and one method have these signatures: CTORMETHOD() and
+ CTORMETHOD(int h, int m, int s = 0, int ms = 0); there another method
+ with a more complex signature METH(int, int, ImplicitConv=DEFVALUE, ObjectType=0),
+ to produce an even worse scenario.
+ '''
+
+ def testConstructorWithoutParamers(self):
+ '''Constructor without parameters: Time()'''
+ time = Time()
+ self.assertTrue(time.isNull())
+
+ def testConstructorWithAllParamers(self):
+ '''Constructor with all parameters: Time(int h, int m, int s = 0, int ms = 0)'''
+ time = Time(1, 2, 3, 4)
+ self.assertTrue(time.toString(), '01:02:03.004')
+
+ def testConstructorWithThreeParamers(self):
+ '''Constructor with 3 parameters: Time(int h, int m, int s = 0, int ms = 0)'''
+ time = Time(1, 2, 3)
+ self.assertTrue(time.toString(), '01:02:03.000')
+
+ def testConstructorWithTwoParamers(self):
+ '''Constructor with 2 parameters: Time(int h, int m, int s = 0, int ms = 0)'''
+ time = Time(1, 2)
+ self.assertTrue(time.toString(), '01:02:00.000')
+
+ def testSimpleMethodWithoutParamers(self):
+ '''Constructor without parameters: Time.setTime()'''
+ time = Time(1, 2, 3, 4)
+ time.setTime()
+ self.assertTrue(time.isNull())
+
+ def testSimpleMethodWithAllParamers(self):
+ '''Simple method with all parameters: Time.setTime(int h, int m, int s = 0, int ms = 0)'''
+ time = Time()
+ time.setTime(1, 2, 3, 4)
+ self.assertTrue(time.toString(), '01:02:03.004')
+
+ def testSimpleMethodWithThreeParamers(self):
+ '''Simple method with 3 parameters: Time.setTime(int h, int m, int s = 0, int ms = 0)'''
+ time = Time()
+ time.setTime(1, 2, 3)
+ self.assertTrue(time.toString(), '01:02:03.000')
+
+ def testSimpleMethodWithTwoParamers(self):
+ '''Simple method with 2 parameters: Time.setTime(int h, int m, int s = 0, int ms = 0)'''
+ time = Time()
+ time.setTime(1, 2)
+ self.assertTrue(time.toString(), '01:02:00.000')
+
+ def testMethodWithoutParamers(self):
+ '''Method without parameters: Time.somethingCompletelyDifferent()'''
+ time = Time()
+ result = time.somethingCompletelyDifferent()
+ self.assertEqual(result, Time.ZeroArgs)
+
+ def testMethodWithAllParamers(self):
+ '''Method with all parameters:
+ Time.somethingCompletelyDifferent(
+ int h, int m, ImplicitConv ic = ImplicitConv::CtorThree, ObjectType* type = 0
+ );
+ '''
+ time = Time()
+ obj = ObjectType()
+ result = time.somethingCompletelyDifferent(1, 2, ImplicitConv(2), obj)
+ self.assertEqual(result, Time.FourArgs)
+
+ def testMethodWithThreeParamers(self):
+ '''Method with 3 parameters: Time.somethingCompletelyDifferent(...)'''
+ time = Time()
+ result = time.somethingCompletelyDifferent(1, 2, ImplicitConv(ImplicitConv.CtorOne))
+ self.assertEqual(result, Time.ThreeArgs)
+
+ def testMethodWithTwoParamers(self):
+ '''Method with 2 parameters: Time.somethingCompletelyDifferent(...)'''
+ time = Time()
+ result = time.somethingCompletelyDifferent(1, 2)
+ self.assertEqual(result, Time.TwoArgs)
+
+ def testMethodWithThreeParamersAndImplicitConversion(self):
+ '''Method with 3 parameters, the last one triggers an implicit conversion.'''
+ time = Time()
+ result = time.somethingCompletelyDifferent(1, 2, ImplicitConv.CtorOne)
+ self.assertEqual(result, Time.ThreeArgs)
+
+ def testCompareWithPythonTime(self):
+ time = Time(12, 32, 5)
+ py = datetime.time(12, 32, 5)
+ self.assertEqual(time, py)
+
+ def testNotEqual(self):
+ time = Time(12, 32, 6)
+ py = datetime.time(12, 32, 5)
+ self.assertNotEqual(time, py)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/transform_test.py b/sources/shiboken2/tests/samplebinding/transform_test.py
new file mode 100644
index 000000000..f490945b8
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/transform_test.py
@@ -0,0 +1,56 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for argument modification with more than nine arguments.'''
+
+import unittest
+
+from sample import Point, applyHomogeneousTransform
+
+class TransformTest(unittest.TestCase):
+ '''Test cases for modifying a function with > 9 arguments.'''
+
+ def testTransform_ValidMatrix(self):
+ '''Transform applies successfully.'''
+ p = Point(3, 4)
+ r = applyHomogeneousTransform(p, 0, 1, 0, -1, 0, 0, 0, 0, 1)
+ self.assertTrue(type(r) is Point)
+ self.assertEqual(r.x(), 4)
+ self.assertEqual(r.y(), -3)
+
+ def testTransform_InvalidMatrix(self):
+ '''Transform does not apply successfully.'''
+ p = Point(3, 4)
+ r = applyHomogeneousTransform(p, 1, 0, 0, 0, 1, 0, 0, 0, 0)
+ self.assertTrue(r is None)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/typeconverters_test.py b/sources/shiboken2/tests/samplebinding/typeconverters_test.py
new file mode 100644
index 000000000..b3b469c56
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/typeconverters_test.py
@@ -0,0 +1,189 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests various usages of the type converters.'''
+
+import unittest
+import sample
+
+class GetPythonTypeByNameTest(unittest.TestCase):
+
+ '''Uses an added function with inject code that uses the libshiboken
+ function "Shiboken::Conversions::getPythonTypeObject(typeName)".'''
+
+ def testGetObjectType(self):
+ pyType1 = sample.getPythonType('ObjectType')
+ self.assertEqual(pyType1, sample.ObjectType)
+ pyType2 = sample.getPythonType('ObjectType*')
+ self.assertEqual(pyType2, sample.ObjectType)
+ self.assertEqual(pyType1, pyType2)
+
+ def testGetValueType(self):
+ pyType1 = sample.getPythonType('Point')
+ self.assertEqual(pyType1, sample.Point)
+ pyType2 = sample.getPythonType('Point*')
+ self.assertEqual(pyType2, sample.Point)
+ self.assertEqual(pyType1, pyType2)
+
+ def testGetUsersPrimitiveType(self):
+ pyType = sample.getPythonType('OddBool')
+ self.assertEqual(pyType, bool)
+
+ def testGetUsersPrimitiveTypeWithoutTargetLangApiName(self):
+ '''If the primitive type attribute "target-lang-api-name" is not set
+ there'll be no Python type associated with the C++ type.'''
+ pyType = sample.getPythonType('PStr')
+ self.assertEqual(pyType, None)
+
+ def testPrimitiveTypeAndTypedef(self):
+ pyType = sample.getPythonType('double')
+ self.assertEqual(pyType, float)
+ pyTypedef = sample.getPythonType('real')
+ self.assertEqual(pyType, pyTypedef)
+
+ def testPairContainerType(self):
+ pyType = sample.getPythonType('std::pair<Complex,int>')
+ self.assertEqual(pyType, list)
+
+ def testListContainerType(self):
+ pyType = sample.getPythonType('std::list<int>')
+ self.assertEqual(pyType, list)
+
+ def testMapContainerType(self):
+ pyType = sample.getPythonType('std::map<std::string,int>')
+ self.assertEqual(pyType, dict)
+
+ def testGlobalEnumType(self):
+ pyType = sample.getPythonType('GlobalEnum')
+ self.assertEqual(pyType, sample.GlobalEnum)
+
+ def testScopedEnumType(self):
+ pyType = sample.getPythonType('Abstract::Type')
+ self.assertEqual(pyType, sample.Abstract.Type)
+
+
+class CheckValueAndObjectTypeByNameTest(unittest.TestCase):
+
+ '''Uses an added function with inject code that uses the libshiboken
+ functions that check if a type is Object or Value, based on its converter.'''
+
+ def testErrors(self):
+ '''not existent type'''
+ self.assertRaises(ValueError, sample.cppTypeIsValueType, 'NotExistentType')
+ self.assertRaises(ValueError, sample.cppTypeIsObjectType, 'NotExistentType')
+
+ def testObjectType1(self):
+ self.assertTrue(sample.cppTypeIsObjectType('ObjectType'))
+ self.assertFalse(sample.cppTypeIsValueType('ObjectType'))
+
+ def testObjectType2(self):
+ self.assertTrue(sample.cppTypeIsObjectType('ObjectType*'))
+ self.assertFalse(sample.cppTypeIsValueType('ObjectType*'))
+
+ def testValueType1(self):
+ self.assertTrue(sample.cppTypeIsValueType('Point'))
+ self.assertFalse(sample.cppTypeIsObjectType('Point'))
+
+ def testValueType2(self):
+ self.assertTrue(sample.cppTypeIsValueType('Point*'))
+ self.assertFalse(sample.cppTypeIsObjectType('Point*'))
+
+ def testUsersPrimitiveType(self):
+ self.assertFalse(sample.cppTypeIsValueType('Complex'))
+ self.assertFalse(sample.cppTypeIsObjectType('Complex'))
+
+ def testContainerType(self):
+ self.assertFalse(sample.cppTypeIsValueType('std::list<int>'))
+ self.assertFalse(sample.cppTypeIsObjectType('std::list<int>'))
+
+
+class SpecificConverterTest(unittest.TestCase):
+
+ '''Uses an added function with inject code that uses the libshiboken
+ adapter class "Shiboken::Conversions::SpecificConverter".'''
+
+ def testNotExistentType(self):
+ conversion = sample.getConversionTypeString('NotExistentType')
+ self.assertEqual(conversion, 'Invalid conversion')
+
+ def testObjectType(self):
+ conversion = sample.getConversionTypeString('ObjectType')
+ self.assertEqual(conversion, 'Pointer conversion')
+ conversion = sample.getConversionTypeString('ObjectType*')
+ self.assertEqual(conversion, 'Pointer conversion')
+ conversion = sample.getConversionTypeString('ObjectType&')
+ self.assertEqual(conversion, 'Reference conversion')
+
+ def testValueType(self):
+ conversion = sample.getConversionTypeString('Point')
+ self.assertEqual(conversion, 'Copy conversion')
+ conversion = sample.getConversionTypeString('Point*')
+ self.assertEqual(conversion, 'Pointer conversion')
+ conversion = sample.getConversionTypeString('Point&')
+ self.assertEqual(conversion, 'Reference conversion')
+
+
+class StringBasedConversionTest(unittest.TestCase):
+
+ def testValueType(self):
+ pts = (sample.Point(1, 1), sample.Point(2, 2), sample.Point(3, 3))
+ result = sample.convertValueTypeToCppAndThenToPython(pts[0], pts[1], pts[2])
+ for orig, new in zip(pts, result):
+ self.assertEqual(orig, new)
+ self.assertFalse(pts[0] is result[0])
+ self.assertTrue(pts[1] is result[1])
+ self.assertTrue(pts[2] is result[2])
+
+ def testObjectType(self):
+ objs = (sample.ObjectType(), sample.ObjectType())
+ objs[0].setObjectName('obj0')
+ objs[1].setObjectName('obj1')
+ result = sample.convertObjectTypeToCppAndThenToPython(objs[0], objs[1])
+ for orig, new in zip(objs, result):
+ self.assertEqual(orig, new)
+ self.assertEqual(orig.objectName(), new.objectName())
+ self.assertTrue(orig is new)
+
+ def testContainerType(self):
+ lst = range(4)
+ result = sample.convertListOfIntegersToCppAndThenToPython(lst)
+ self.assertTrue(len(result), 1)
+ self.assertTrue(lst, result[0])
+
+ def testCppPrimitiveType(self):
+ integers = (12, 34)
+ result = sample.convertIntegersToCppAndThenToPython(integers[0], integers[1])
+ for orig, new in zip(integers, result):
+ self.assertEqual(orig, new)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/typedealloc_test.py b/sources/shiboken2/tests/samplebinding/typedealloc_test.py
new file mode 100644
index 000000000..b0fe763e0
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/typedealloc_test.py
@@ -0,0 +1,75 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test deallocation of type extended in Python.'''
+
+import gc
+import weakref
+import unittest
+
+from sample import Point
+
+
+class TypeDeallocTest(unittest.TestCase):
+
+ def setUp(self):
+ self.called = False
+
+ def tearDown(self):
+ del self.called
+
+ def callback(self, *args):
+ self.called = True
+
+ def testScopeEnd(self):
+ ref = None
+ def scope():
+ class Ext(Point):
+ pass
+ o = Ext()
+ global ref
+ ref = weakref.ref(Ext, self.callback)
+ scope()
+ gc.collect()
+ self.assertTrue(self.called)
+
+ def testDeleteType(self):
+ class Ext(Point):
+ pass
+ ref = weakref.ref(Ext, self.callback)
+ del Ext
+ gc.collect()
+ self.assertTrue(self.called)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/typedtordoublefree_test.py b/sources/shiboken2/tests/samplebinding/typedtordoublefree_test.py
new file mode 100644
index 000000000..1106c8761
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/typedtordoublefree_test.py
@@ -0,0 +1,54 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sample import ObjectType
+
+class TestTypeDestructorDoubleFree(unittest.TestCase):
+ def testTypeDestructorDoubleFree(self):
+ '''Causes the type destructors of two derived classes to be called.'''
+ def scope():
+ class ExtObj1(ObjectType):
+ def __init__(self):
+ ObjectType.__init__(self)
+ obj = ExtObj1()
+ child = ObjectType(parent=obj)
+ self.assertEqual(obj.takeChild(child), child)
+ class ExtObj2(ObjectType):
+ def __init__(self):
+ ObjectType.__init__(self)
+ obj = ExtObj2()
+ child = ObjectType(parent=obj)
+ self.assertEqual(obj.takeChild(child), child)
+ scope()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
new file mode 100644
index 000000000..089f835fc
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
@@ -0,0 +1,2426 @@
+<?xml version="1.0"?>
+<typesystem package="sample">
+ <suppress-warning text="Duplicate type entry: 'sample'" />
+ <suppress-warning text="Duplicate type entry: 'SampleNamespace'" />
+
+ <custom-type name="str"/>
+ <custom-type name="PyBytes"/>
+ <custom-type name="PyDate"/>
+ <custom-type name="PyObject"/>
+ <custom-type name="PyUnicode"/>
+
+ <primitive-type name="bool"/>
+ <primitive-type name="double"/>
+ <primitive-type name="real"/>
+ <primitive-type name="int"/>
+ <primitive-type name="short"/>
+ <primitive-type name="unsigned short"/>
+ <primitive-type name="ushort"/>
+ <primitive-type name="unsigned int" />
+ <primitive-type name="signed int" />
+ <primitive-type name="char"/>
+ <primitive-type name="unsigned char"/>
+ <primitive-type name="long"/>
+ <primitive-type name="unsigned long"/>
+ <primitive-type name="long long"/>
+ <primitive-type name="unsigned long long"/>
+ <primitive-type name="std::string"/>
+ <primitive-type name="ObjectType::Identifier"/>
+
+ <primitive-type name="Foo::HANDLE" target-lang-api-name="PyLong"/>
+
+ <primitive-type name="std::size_t" target-lang-api-name="PyLong">
+ <conversion-rule>
+ <native-to-target>
+ return PyLong_FromSize_t(%in);
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyLong">
+ %out = %OUTTYPE(PyLong_AsSsize_t(%in));
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <inject-code class="native" position="beginning">
+ static bool Check2TupleOfNumbers(PyObject* pyIn) {
+ if (!PySequence_Check(pyIn) || !(PySequence_Size(pyIn) == 2))
+ return false;
+ Shiboken::AutoDecRef pyReal(PySequence_GetItem(pyIn, 0));
+ if (!SbkNumber_Check(pyReal))
+ return false;
+ Shiboken::AutoDecRef pyImag(PySequence_GetItem(pyIn, 1));
+ if (!SbkNumber_Check(pyImag))
+ return false;
+ return true;
+ }
+ </inject-code>
+ <primitive-type name="Complex" target-lang-api-name="PyComplex">
+ <include file-name="complex.h" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ return PyComplex_FromDoubles(%in.real(), %in.imag());
+ </native-to-target>
+ <target-to-native>
+ <!-- The 'check' attribute can be derived from the 'type' attribute,
+ it is defined here to test the CHECKTYPE type system variable. -->
+ <add-conversion type="PyComplex" check="%CHECKTYPE[Complex](%in)">
+ double real = PyComplex_RealAsDouble(%in);
+ double imag = PyComplex_ImagAsDouble(%in);
+ %out = %OUTTYPE(real, imag);
+ </add-conversion>
+ <add-conversion type="PySequence" check="Check2TupleOfNumbers(%in)">
+ Shiboken::AutoDecRef pyReal(PySequence_GetItem(%in, 0));
+ Shiboken::AutoDecRef pyImag(PySequence_GetItem(%in, 1));
+ double real = %CONVERTTOCPP[double](pyReal);
+ double imag = %CONVERTTOCPP[double](pyImag);
+ %out = %OUTTYPE(real, imag);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <primitive-type name="Null">
+ <include file-name="null.h" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ SBK_UNUSED(%in);
+ Py_RETURN_NONE;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyObject" check="%in == 0 || %in == Py_None">
+ %out = %OUTTYPE(%in == 0);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <primitive-type name="HANDLE" target-lang-api-name="PyComplex">
+ <include file-name="handle.h" location="local"/>
+ <conversion-rule>
+ <native-to-target>
+ if (!%in)
+ Py_RETURN_NONE;
+ #ifdef IS_PY3K
+ return PyCapsule_New(%in, 0, 0);
+ #else
+ return PyCObject_FromVoidPtr(%in, 0);
+ #endif
+ </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
+ %out = (%OUTTYPE)ptr;
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <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>
+
+ <primitive-type name="PrimitiveStructPtr">
+ <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
+ </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
+ %out = *((%OUTTYPE*)ptr);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <primitive-type name="OddBool" target-lang-api-name="PyBool" default-constructor="OddBool(false)">
+ <include file-name="oddbool.h" location="global"/>
+ <include file-name="complex.h" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ return PyBool_FromLong(%in.value());
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyBool">
+ // Tests CONVERTTOCPP macro with C++ primitive type.
+ bool b = %CONVERTTOCPP[bool](%in);
+ %out = %OUTTYPE(b);
+ </add-conversion>
+ <add-conversion type="PyComplex">
+ // Tests CONVERTTOCPP macro with user's primitive type.
+ Complex cpx = %CONVERTTOCPP[Complex](%in);
+ %out = %OUTTYPE(cpx.real() != 0.0 || cpx.imag() != 0.0);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <primitive-type name="PStr">
+ <include file-name="str.h" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ return Shiboken::String::fromCString(%in.cstring(), %in.size());
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyUnicode" check="Shiboken::String::check(%in)">
+ const char* str = %CONVERTTOCPP[const char*](%in);
+ %out = %OUTTYPE(str);
+ </add-conversion>
+ <add-conversion type="Py_None">
+ %out = %OUTTYPE();
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <function signature="changePStr(PStr*, const char*)">
+ <!--
+ Comment out these modifications and the Shiboken generator
+ will issue a fatal error, because it can't handle a pointer
+ to a primitive type (PStr*) without help from the binding
+ developer.
+ -->
+ <modify-function signature="changePStr(PStr*, const char*)">
+ <modify-argument index="1">
+ <replace-type modified-type="PStr"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ %FUNCTION_NAME(&amp;%1, %2);
+ %PYARG_0 = %CONVERTTOPYTHON[PStr](%1);
+ </inject-code>
+ </modify-function>
+ </function>
+
+ <function signature="duplicatePStr(PStr*)">
+ <modify-function signature="duplicatePStr(PStr*)">
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject"/>
+ </modify-argument>
+ <modify-argument index="1">
+ <replace-type modified-type="PStr"/>
+ <remove-default-expression/>
+ <replace-default-expression with="PStr()"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ %FUNCTION_NAME(&amp;%1);
+ %PYARG_0 = %CONVERTTOPYTHON[PStr](%1);
+ </inject-code>
+ </modify-function>
+ </function>
+
+ <primitive-type name="PStrList">
+ <include file-name="strlist.h" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ PyObject* %out = PyList_New((int) %in.size());
+ PStrList::const_iterator it = %in.begin();
+ for (int idx = 0; it != %in.end(); ++it, ++idx) {
+ PStr cppItem(*it);
+ PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[PStr](cppItem));
+ }
+ return %out;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PySequence">
+ %OUTTYPE&amp; list = %out;
+ Shiboken::AutoDecRef seq(PySequence_Fast(%in, 0));
+ for (int i = 0; i &lt; PySequence_Fast_GET_SIZE(seq.object()); i++) {
+ PyObject* pyItem = PySequence_Fast_GET_ITEM(seq.object(), i);
+ PStr cppItem = %CONVERTTOCPP[PStr](pyItem);
+ list.push_back(cppItem);
+ }
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <add-function signature="createPStrList(PStr, PStr)" return-type="PyObject">
+ <inject-code class="target">
+ PStrList %0;
+ %0.push_back(%1);
+ %0.push_back(%2);
+ %PYARG_0 = %CONVERTTOPYTHON[PStrList](%0);
+ </inject-code>
+ </add-function>
+ <add-function signature="createListOfPStr(PStr, PStr)" return-type="PyObject">
+ <inject-code class="target">
+ std::list&lt;PStr&gt; %0;
+ %0.push_back(%1);
+ %0.push_back(%2);
+ %PYARG_0 = %CONVERTTOPYTHON[std::list&lt;PStr&gt;](%0);
+ </inject-code>
+ </add-function>
+
+ <add-function signature="getPythonType(const char*)" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = (PyObject*) Shiboken::Conversions::getPythonTypeObject(%1);
+ if (!%PYARG_0)
+ %PYARG_0 = Py_None;
+ Py_INCREF(%PYARG_0);
+ </inject-code>
+ </add-function>
+
+ <template name="cpp_type_is_object_or_value_type">
+ SbkConverter* converter = Shiboken::Conversions::getConverter(%1);
+ if (converter) {
+ if (Shiboken::Conversions::pythonTypeIs$TYPEType(converter))
+ %PYARG_0 = Py_True;
+ else
+ %PYARG_0 = Py_False;
+ Py_INCREF(%PYARG_0);
+ } else {
+ PyErr_Format(PyExc_ValueError, "Type '%s' has no converter associated to it", %1);
+ }
+ </template>
+ <add-function signature="cppTypeIsObjectType(const char*)" return-type="bool">
+ <inject-code class="target" position="beginning">
+ <insert-template name="cpp_type_is_object_or_value_type">
+ <replace from="$TYPE" to="Object" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+ <add-function signature="cppTypeIsValueType(const char*)" return-type="bool">
+ <inject-code class="target" position="beginning">
+ <insert-template name="cpp_type_is_object_or_value_type">
+ <replace from="$TYPE" to="Value" />
+ </insert-template>
+ </inject-code>
+ </add-function>
+
+ <add-function signature="getConversionTypeString(const char*)" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ Shiboken::Conversions::SpecificConverter converter(%1);
+ const char* %0 = 0;
+ switch (converter.conversionType()) {
+ case Shiboken::Conversions::SpecificConverter::CopyConversion:
+ %0 = "Copy conversion";
+ break;
+ case Shiboken::Conversions::SpecificConverter::PointerConversion:
+ %0 = "Pointer conversion";
+ break;
+ case Shiboken::Conversions::SpecificConverter::ReferenceConversion:
+ %0 = "Reference conversion";
+ break;
+ default:
+ %0 = "Invalid conversion";
+ }
+ %PYARG_0 = %CONVERTTOPYTHON[const char*](%0);
+ </inject-code>
+ </add-function>
+
+ <inject-code class="native" position="beginning">
+ static PyObject* __convertCppValuesToPython(const char** typeName, void** values, int size)
+ {
+ PyObject* result = PyTuple_New(size);
+ for (int i = 0; i &lt; size; ++i) {
+ Shiboken::Conversions::SpecificConverter converter(typeName[i]);
+ PyTuple_SET_ITEM(result, i, converter.toPython(values[i]));
+ }
+ return result;
+ }
+ </inject-code>
+ <add-function signature="convertValueTypeToCppAndThenToPython(Point,Point*,Point&amp;)" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ const char* typeNames[] = { "Point", "Point*", "Point&amp;" };
+ void* values[] = { &amp;%1, &amp;%2, &amp;(%3) };
+ %PYARG_0 = __convertCppValuesToPython(typeNames, values, 3);
+ </inject-code>
+ </add-function>
+ <add-function signature="convertObjectTypeToCppAndThenToPython(ObjectType*,ObjectType&amp;)" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ const char* typeNames[] = { "ObjectType*", "ObjectType&amp;" };
+ void* values[] = { &amp;%1, &amp;(%2) };
+ %PYARG_0 = __convertCppValuesToPython(typeNames, values, 2);
+ </inject-code>
+ </add-function>
+ <add-function signature="convertListOfIntegersToCppAndThenToPython(std::list&lt;int&gt;)" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ const char* typeNames[] = { "std::list&lt;int&gt;" };
+ void* values[] = { &amp;%1 };
+ %PYARG_0 = __convertCppValuesToPython(typeNames, values, 1);
+ </inject-code>
+ </add-function>
+ <add-function signature="convertIntegersToCppAndThenToPython(int,int)" return-type="PyObject">
+ <inject-code class="target" position="beginning">
+ const char* typeNames[] = { "int", "int" };
+ void* values[] = { &amp;%1, &amp;%2 };
+ %PYARG_0 = __convertCppValuesToPython(typeNames, values, 2);
+ </inject-code>
+ </add-function>
+
+ <container-type name="std::pair" type="pair">
+ <include file-name="utility" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ PyObject* %out = PyTuple_New(2);
+ PyTuple_SET_ITEM(%out, 0, %CONVERTTOPYTHON[%INTYPE_0](%in.first));
+ PyTuple_SET_ITEM(%out, 1, %CONVERTTOPYTHON[%INTYPE_1](%in.second));
+ return %out;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PySequence">
+ %out.first = %CONVERTTOCPP[%OUTTYPE_0](PySequence_Fast_GET_ITEM(%in, 0));
+ %out.second = %CONVERTTOCPP[%OUTTYPE_1](PySequence_Fast_GET_ITEM(%in, 1));
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+ <template name="cpplist_to_pylist_convertion">
+ PyObject* %out = PyList_New((int) %in.size());
+ %INTYPE::const_iterator it = %in.begin();
+ for (int idx = 0; it != %in.end(); ++it, ++idx) {
+ %INTYPE_0 cppItem(*it);
+ PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem));
+ }
+ return %out;
+ </template>
+ <template name="pyseq_to_cpplist_convertion">
+ Shiboken::AutoDecRef seq(PySequence_Fast(%in, 0));
+ for (int i = 0; i &lt; PySequence_Fast_GET_SIZE(seq.object()); i++) {
+ PyObject* pyItem = PySequence_Fast_GET_ITEM(seq.object(), i);
+ %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem);
+ %out.push_back(cppItem);
+ }
+ </template>
+ <container-type name="std::list" type="list">
+ <include file-name="list" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ <insert-template name="cpplist_to_pylist_convertion"/>
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PySequence">
+ <insert-template name="pyseq_to_cpplist_convertion"/>
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+ <container-type name="List" type="list">
+ <include file-name="list" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ <insert-template name="cpplist_to_pylist_convertion"/>
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PySequence">
+ <insert-template name="pyseq_to_cpplist_convertion"/>
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+ <container-type name="std::map" type="map">
+ <include file-name="map" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ PyObject* %out = PyDict_New();
+ %INTYPE::const_iterator it = %in.begin();
+ for (; it != %in.end(); ++it) {
+ %INTYPE_0 key = it->first;
+ %INTYPE_1 value = it->second;
+ PyDict_SetItem(%out,
+ %CONVERTTOPYTHON[%INTYPE_0](key),
+ %CONVERTTOPYTHON[%INTYPE_1](value));
+ }
+ return %out;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyDict">
+ PyObject* key;
+ PyObject* value;
+ Py_ssize_t pos = 0;
+ while (PyDict_Next(%in, &amp;pos, &amp;key, &amp;value)) {
+ %OUTTYPE_0 cppKey = %CONVERTTOCPP[%OUTTYPE_0](key);
+ %OUTTYPE_1 cppValue = %CONVERTTOCPP[%OUTTYPE_1](value);
+ %out.insert(%OUTTYPE::value_type(cppKey, cppValue));
+ }
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+
+ <add-function signature="cacheSize()" return-type="int">
+ <inject-code class="target">
+ %RETURN_TYPE %0 = Shiboken::BindingManager::instance().getAllPyObjects().size();
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+
+ <namespace-type name="sample">
+ <value-type name="sample" />
+ </namespace-type>
+
+ <function signature="sumComplexPair(std::pair&lt;Complex, Complex>)" />
+ <function signature="gimmeComplexList()" />
+ <function signature="transmuteComplexIntoPoint(const Complex&amp;)" />
+ <function signature="transmutePointIntoComplex(const Point&amp;)" />
+ <function signature="sumComplexPair(std::pair&lt;Complex, Complex>)" />
+ <function signature="doubleUnsignedInt(unsigned int)" />
+ <function signature="doubleLongLong(long long)" />
+ <function signature="doubleUnsignedLongLong(unsigned long long)" />
+ <function signature="doubleShort(short)" />
+ <function signature="returnNullPrimitivePointer()" />
+ <function signature="returnNullValueTypePointer()" />
+ <function signature="returnNullObjectTypePointer()" />
+ <function signature="acceptInt(int)" />
+ <function signature="acceptUInt(unsigned int)" />
+ <function signature="acceptLong(long)" />
+ <function signature="acceptULong(unsigned long)" />
+ <function signature="acceptDouble(double)" />
+ <function signature="acceptIntReference(int&amp;)" />
+ <function signature="acceptOddBoolReference(OddBool&amp;)" />
+ <function signature="countCharacters(const char*)" />
+ <function signature="gimmeInt()" />
+ <function signature="gimmeDouble()" />
+ <function signature="makeCString()" />
+ <function signature="multiplyPair(std::pair&lt;double, double>)" />
+ <function signature="returnCString()" />
+ <function signature="overloadedFunc(double)" />
+ <function signature="overloadedFunc(int)" />
+
+ <value-type name="ClassWithFunctionPointer">
+ <suppress-warning text="skipping function 'ClassWithFunctionPointer::callFunctionPointer', unmatched parameter type 'void (*)(void*)'" />
+ </value-type>
+
+ <enum-type name="OverloadedFuncEnum"/>
+ <!-- BUG:
+ renaming the ICOverloadedFuncEnum to the same name
+ of a global enum causes the generator to confuse the
+ two types.
+ -->
+ <enum-type name="GlobalEnum"/>
+ <enum-type name="GlobalOverloadFuncEnum"/>
+
+ <enum-type identified-by-value="AnonymousGlobalEnum_Value0"/>
+
+ <namespace-type name="Invisible" generate="no">
+ <enum-type name="EnumOnNamespace" />
+ </namespace-type>
+
+ <namespace-type name="SampleNamespace">
+ <enum-type name="Option"/>
+ <enum-type name="InValue"/>
+ <enum-type name="OutValue"/>
+ <enum-type identified-by-value="AnonymousClassEnum_Value1"/>
+
+ <object-type name="DerivedFromNamespace">
+ <enum-type name="SampleNamespace"/>
+ </object-type>
+ <value-type name="SomeClass">
+ <value-type name="SomeInnerClass">
+ <object-type name="OkThisIsRecursiveEnough">
+ <enum-type name="NiceEnum" />
+ </object-type>
+ <enum-type name="ProtectedEnum"/>
+ </value-type>
+ <value-type name="SomeOtherInnerClass"/>
+ <enum-type name="ProtectedEnum"/>
+ </value-type>
+
+ <modify-function signature="doSomethingWithArray(const unsigned char*, unsigned int, const char*)">
+ <modify-argument index="1">
+ <replace-type modified-type="const char*"/>
+ <conversion-rule class="native">
+ const unsigned char* %out = reinterpret_cast&lt;const unsigned char*>(Shiboken::String::toCString(%PYARG_1));
+ </conversion-rule>
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument/>
+ <conversion-rule class="native">
+ unsigned int %out = static_cast&lt;unsigned int>(Shiboken::String::len(%PYARG_1));
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ <add-function signature="ImInsideANamespace(int, int)" return-type="int">
+ <inject-code class="target">
+ %RETURN_TYPE %0 = %1 + %2;
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ <add-function signature="passReferenceToValueType(Point&amp;)" return-type="double">
+ <inject-code>
+ %RETURN_TYPE %0 = %1.x() + %1.y();
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+
+ <!-- Do change the argument from pointer to reference to comply with the C++ overload
+ of this function. The generator must be able to deal with this for Object Types. -->
+ <add-function signature="passReferenceToObjectType(ObjectType*)" return-type="int">
+ <inject-code>
+ // The dot in "%1." must be replaced with a "->" by the generator.
+ %RETURN_TYPE %0 = %1.objectName().size();
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ </namespace-type>
+
+ <namespace-type name="RemovedNamespace1" generate='no'>
+ <enum-type name="RemovedNamespace1_Enum" />
+ <namespace-type name="RemovedNamespace2" generate='no'>
+ <enum-type name="RemovedNamespace2_Enum" />
+ </namespace-type>
+ <enum-type identified-by-value="RemovedNamespace1_AnonymousEnum_Value0" />
+ </namespace-type>
+
+ <namespace-type name="UnremovedNamespace">
+ <namespace-type name="RemovedNamespace3" generate='no'>
+ <enum-type name="RemovedNamespace3_Enum" />
+ <enum-type identified-by-value="RemovedNamespace3_AnonymousEnum_Value0" />
+ </namespace-type>
+ </namespace-type>
+
+ <namespace-type name="Photon">
+ <enum-type name="ClassType"/>
+ <value-type name="Base"/>
+ <value-type name="TemplateBase" generate="no"/>
+ <value-type name="ValueIdentity"/>
+ <value-type name="ValueDuplicator"/>
+ </namespace-type>
+
+ <value-type name="CVValueType"/>
+ <value-type name="CVListUser"/>
+
+ <value-type name="IntList">
+ <enum-type name="CtorEnum"/>
+ </value-type>
+ <value-type name="PointValueList">
+ <enum-type name="CtorEnum"/>
+ </value-type>
+ <value-type name="ObjectTypePtrList">
+ <enum-type name="CtorEnum"/>
+ </value-type>
+
+ <object-type name="Abstract">
+ <enum-type name="Type"/>
+ <enum-type name="PrintFormat"/>
+ <modify-function signature="id()" rename="id_"/>
+ <modify-function signature="hideFunction(HideType*)" remove="all"/>
+ </object-type>
+
+ <object-type name="Derived" polymorphic-id-expression="%1->type() == Derived::TpDerived">
+ <enum-type name="OtherOverloadedFuncEnum"/>
+ <value-type name="SomeInnerClass" />
+ </object-type>
+
+ <object-type name="ModifiedConstructor">
+ <modify-function signature="ModifiedConstructor(int)">
+ <modify-argument index="1">
+ <replace-type modified-type="str"/>
+ </modify-argument>
+ <inject-code class='target' position='beginning'>
+ const char* tmpArg = %CONVERTTOCPP[const char*](%PYARG_1);
+ %0 = new %FUNCTION_NAME(atoi(tmpArg));
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+ <object-type name="ObjectType" hash-function="objectTypeHash">
+ <modify-function signature="deprecatedFunction()" deprecated="yes" />
+ <!-- rename function to avoid Python signature conflit -->
+ <modify-function signature="setObject(const Null&amp;)" rename="setNullObject" />
+
+ <modify-function signature="getCppParent()">
+ <modify-argument index="this">
+ <parent index="return" action="add" />
+ </modify-argument>
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="event(Event*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="invalidateEvent(Event*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
+ <modify-function signature="create()">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="createWithChild()">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setParent(ObjectType*)">
+ <modify-argument index="this">
+ <parent index="1" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <inject-code class="native" position="beginning">
+ static void reparent_layout_items(PyObject* parent, PyObject* layout)
+ {
+ // CHECKTYPE and ISCONVERTIBLE are used here for test purposes, don't change them.
+ if (!%CHECKTYPE[ObjectTypeLayout*](layout) &amp;&amp; !%ISCONVERTIBLE[ObjectTypeLayout*](layout))
+ return;
+ // %CHECKTYPE[ObjectTypeLayout*](layout)
+ // %ISCONVERTIBLE[ObjectTypeLayout*](layout)
+ ObjectTypeLayout* var;
+ var = %CONVERTTOCPP[ObjectTypeLayout*](layout);
+ // TODO-CONVERTER: erase this
+ /*
+ ObjectTypeLayout* var2 = %CONVERTTOCPP[ObjectTypeLayout*](layout);
+ */
+ const ObjectTypeList&amp; objChildren = var->objects();
+ ObjectTypeList::const_iterator it = objChildren.begin();
+ for (; it != objChildren.end(); ++it) {
+ if ((*it)->isLayoutType()) {
+ ObjectTypeLayout* l = reinterpret_cast&lt;ObjectTypeLayout*>(*it);
+ reparent_layout_items(parent, %CONVERTTOPYTHON[ObjectTypeLayout*](l));
+ Shiboken::Object::setParent(layout, %CONVERTTOPYTHON[ObjectTypeLayout*](l));
+ } else {
+ Shiboken::Object::setParent(parent, %CONVERTTOPYTHON[ObjectType*](*it));
+ }
+ }
+ }
+ </inject-code>
+ <modify-function signature="setLayout(ObjectTypeLayout*)">
+ <modify-argument index="1">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ if (%PYARG_1 != Py_None)
+ reparent_layout_items(%PYSELF, %PYARG_1);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="takeChild(ObjectType*)">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="takeChild(const Str&amp;)">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ <parent index="this" action="remove"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="findChild(const Str&amp;)">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="children()const">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="createChild(ObjectType*)">
+ <modify-argument index="return">
+ <define-ownership owner="c++" />
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="nextInFocusChain()">
+ <modify-argument index="return">
+ <parent index="this" action="add"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="OtherBase" />
+ <object-type name="ObjectTypeDerived" />
+
+ <object-type name="ObjectTypeLayout">
+ <modify-function signature="create()">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <object-type name="ObjectView">
+ <modify-function signature="ObjectView(ObjectModel*, ObjectType*)">
+ <modify-argument index="1">
+ <reference-count action="set" variable-name="setModel(ObjectModel*)1"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="setModel(ObjectModel*)">
+ <modify-argument index="1">
+ <reference-count action="set"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <value-type name="ObjectTypeHolder"/>
+ <value-type name="OnlyCopy"/>
+ <value-type name="FriendOfOnlyCopy"/>
+
+ <object-type name="ObjectModel">
+ <enum-type name="MethodCalled" />
+ <modify-function signature="data() const">
+ <modify-argument index="return">
+ <define-ownership class="native" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+ <value-type name="Event">
+ <enum-type name="EventType"/>
+ </value-type>
+
+ <value-type name="BlackBox">
+ <modify-function signature="keepObjectType(ObjectType*)">
+ <modify-argument index="1">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="retrieveObjectType(int)">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="keepPoint(Point*)">
+ <modify-argument index="1">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="retrievePoint(int)">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+
+ <value-type name="ProtectedNonPolymorphic">
+ <modify-function signature="create()">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="modifiedProtectedSum(int, int)">
+ <inject-code class="target" position="beginning">
+ %RETURN_TYPE %0 = %CPPSELF.%TYPE::%FUNCTION_NAME(%1, %2) * 10;
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="dataTypeName(void*) const" remove="all"/>
+ <modify-function signature="dataTypeName(int) const">
+ <modify-argument index="1">
+ <replace-default-expression with="0"/>
+ </modify-argument>
+ </modify-function>
+ <add-function signature="dataTypeName(PyObject*)const" return-type="const char*">
+ <inject-code class="target" position="beginning">
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%PYARG_1);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ <value-type name="ProtectedPolymorphic">
+ <modify-function signature="create()">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+
+ <value-type name="ProtectedPolymorphicDaughter">
+ <modify-function signature="create()">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+
+ <value-type name="ProtectedPolymorphicGrandDaughter">
+ <modify-function signature="create()">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+
+ <object-type name="ProtectedVirtualDestructor">
+ <modify-function signature="create()">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+
+
+ <object-type name="ProtectedEnumClass">
+ <enum-type name="ProtectedEnum" />
+ <enum-type name="PublicEnum" />
+ </object-type>
+
+ <value-type name="ProtectedProperty" />
+
+ <function signature="createProtectedProperty()" />
+
+ <template name="boolptr_at_end_fix_beginning">
+ bool __ok__;
+ %RETURN_TYPE %0 = %CPPSELF.%TYPE::%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;__ok__);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </template>
+
+ <template name="boolptr_at_start_fix_beginning">
+ bool __ok__;
+ %RETURN_TYPE %0 = %CPPSELF.%TYPE::%FUNCTION_NAME(&amp;__ok__, %ARGUMENT_NAMES);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </template>
+
+ <template name="boolptr_at_start_and_one_arg_fix_beginning">
+ bool __ok__;
+ %RETURN_TYPE %0 = %CPPSELF.%TYPE::%FUNCTION_NAME(&amp;__ok__, %2);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </template>
+
+ <template name="boolptr_fix_end">
+ PyObject* _tuple_ = PyTuple_New(2);
+ PyTuple_SET_ITEM(_tuple_, 0, %PYARG_0);
+ PyObject* _item_ = %CONVERTTOPYTHON[bool](__ok__);
+ PyTuple_SET_ITEM(_tuple_, 1, _item_);
+ %PYARG_0 = _tuple_;
+ </template>
+
+ <template name="return_4_arguments_as_tuple">
+ %PYARG_0 = PyTuple_New(4);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%ARG1_TYPE](%1));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG2_TYPE](%2));
+ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[%ARG3_TYPE](%3));
+ PyTuple_SET_ITEM(%PYARG_0, 3, %CONVERTTOPYTHON[%ARG4_TYPE](%4));
+ </template>
+
+ <template name="return_5_arguments_as_tuple">
+ %PYARG_0 = PyTuple_New(5);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%ARG1_TYPE](%1));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG2_TYPE](%2));
+ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[%ARG3_TYPE](%3));
+ PyTuple_SET_ITEM(%PYARG_0, 3, %CONVERTTOPYTHON[%ARG4_TYPE](%4));
+ PyTuple_SET_ITEM(%PYARG_0, 4, %CONVERTTOPYTHON[%ARG5_TYPE](%5));
+ </template>
+
+ <template name="return_none">
+ %PYARG_0 = Py_None;
+ Py_INCREF(Py_None);
+ </template>
+
+ <object-type name="Modifications">
+ <enum-type name="OverloadedModFunc"/>
+
+ <modify-function signature="overloaded(int, bool, int, double)">
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ %RETURN_TYPE %0 = %CPPSELF.%TYPE::%FUNCTION_NAME(%1, true, %3, %4);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="overloaded(int, bool, int, int)">
+ <modify-argument index="3">
+ <remove-argument/>
+ <replace-default-expression with="321"/>
+ </modify-argument>
+ <!--
+ <modify-argument index="4">
+ <remove-default-expression/>
+ </modify-argument>
+ -->
+ </modify-function>
+
+ <modify-function signature="argRemoval0(int, bool, int, int)">
+ <modify-argument index="3">
+ <remove-argument/>
+ <replace-default-expression with="321"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_4_arguments_as_tuple"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="argRemoval1(int, bool, Point, Point, int)">
+ <modify-argument index="3">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="4">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_5_arguments_as_tuple"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="argRemoval1(int, bool, int, bool)">
+ <inject-code class="target" position="end">
+ <insert-template name="return_none"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="argRemoval2(int, bool, Point, Point, int)">
+ <modify-argument index="3">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="4">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_5_arguments_as_tuple"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="argRemoval3(int, Point, bool, Point, int)">
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="4">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_5_arguments_as_tuple"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="argRemoval4(int, Point, bool, Point, int)">
+ <modify-argument index="2">
+ <remove-argument/>
+ <replace-default-expression with="Point(6, 9)"/>
+ </modify-argument>
+ <modify-argument index="4">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_5_arguments_as_tuple"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="argRemoval5(int, bool, Point, Point, int)">
+ <modify-argument index="1">
+ <remove-argument/>
+ <replace-default-expression with="100"/>
+ </modify-argument>
+ <modify-argument index="3">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="4">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_5_arguments_as_tuple"/>
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="argRemoval5(int, bool, int, bool)">
+ <modify-argument index="1">
+ <remove-argument/>
+ <replace-default-expression with="200"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ <insert-template name="return_4_arguments_as_tuple"/>
+ </inject-code>
+ </modify-function>
+
+ <!--
+ this alteration will trigger an interesting
+ compile time error on the binding
+ -->
+ <!--
+ <modify-function signature="overloaded(int, bool, Point, Point)">
+ <modify-argument index="3">
+ <remove-argument/>
+ </modify-argument>
+ </modify-function>
+ -->
+
+ <!--
+ renaming this signature should remove it from the other
+ overloaded methods decision tree
+ -->
+ <modify-function signature="overloaded(int, bool, Point, Point)" rename="over"/>
+
+ <!--
+ 'ok' must be removed and the return value will be changed
+ to a tuple (PyObject*) containing the expected result plus
+ the 'ok' value as a Python boolean
+ -->
+ <modify-function signature="pointToPair(Point, bool*)">
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="boolptr_at_end_fix_beginning"/>
+ </inject-code>
+ <inject-code class="target" position="end">
+ <insert-template name="boolptr_fix_end"/>
+ </inject-code>
+ </modify-function>
+
+ <!-- same as 'pointToPair' except that this time 'ok' is the first argument -->
+ <modify-function signature="multiplyPointCoordsPlusValue(bool*, Point, double)">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="boolptr_at_start_fix_beginning"/>
+ </inject-code>
+ <inject-code class="target" position="end">
+ <insert-template name="boolptr_fix_end"/>
+ </inject-code>
+ </modify-function>
+
+ <!-- completely remove 'plus' from the Python side -->
+ <modify-function signature="doublePlus(int, int)">
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ </modify-function>
+
+ <!-- the default value for both arguments must be changed in Python -->
+ <modify-function signature="power(int, int)">
+ <modify-argument index="1">
+ <replace-default-expression with="2"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <replace-default-expression with="1"/>
+ </modify-argument>
+ </modify-function>
+
+ <!-- in Python set argument default value to 10 -->
+ <modify-function signature="timesTen(int)">
+ <modify-argument index="1">
+ <replace-default-expression with="10"/>
+ </modify-argument>
+ </modify-function>
+
+ <!-- in Python remove the argument default value -->
+ <modify-function signature="increment(int)">
+ <modify-argument index="1">
+ <remove-default-expression/>
+ </modify-argument>
+ </modify-function>
+
+ <!-- don't export this method to Python -->
+ <modify-function signature="exclusiveCppStuff()" remove="all"/>
+
+ <!-- change the name of this regular method -->
+ <modify-function signature="cppMultiply(int, int)" rename="calculateArea"/>
+
+ <!-- change the name of this virtual method -->
+ <modify-function signature="className()" rename="name"/>
+
+ <modify-function signature="sumPointArray(int, const Point*)">
+ <modify-argument index="1">
+ <remove-argument/>
+ <conversion-rule class="native">
+ int %out = PySequence_Size(%PYARG_1);
+ </conversion-rule>
+ </modify-argument>
+ <modify-argument index="2">
+ <replace-type modified-type="PySequence" />
+ <conversion-rule class="native">
+ Shiboken::AutoArrayPointer&lt;Point&gt; %out(%1);
+ for (int i = 0; i &lt; %1; ++i)
+ %out[i] = %CONVERTTOCPP[Point](PySequence_Fast_GET_ITEM(%PYARG_1, i));
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="getSize(const void*,int)">
+ <modify-argument index="1">
+ <replace-type modified-type="ByteArray&amp;"/>
+ </modify-argument>
+ <modify-argument index="2">
+ <replace-default-expression with="-1"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int size = (%2 &lt; 0) ? %1.size() : %2;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME((const void*) %1.data(), size);
+ %END_ALLOW_THREADS
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="sumPointCoordinates(const Point*)">
+ <modify-argument index="1">
+ <no-null-pointer/>
+ </modify-argument>
+ </modify-function>
+ <template name="differenceOfPointCoordinates_arg2">
+ bool _status;
+ bool* %2 = &amp;_status;
+ </template>
+ <template name="differenceOfPointCoordinates_returnTarget">
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[bool](*%2));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%RETURN_TYPE](%0));
+ </template>
+ <modify-function signature="differenceOfPointCoordinates(const Point*, bool*)">
+ <modify-argument index="2">
+ <remove-argument/>
+ <conversion-rule class="native">
+ <insert-template name="differenceOfPointCoordinates_arg2"/>
+ </conversion-rule>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PySequence"/>
+ <conversion-rule class="native">
+ Shiboken::AutoDecRef _py_ok_(PySequence_GetItem(%PYARG_0, 0));
+ Shiboken::AutoDecRef _py_ret_(PySequence_GetItem(%PYARG_0, 1));
+ *%2 = %CONVERTTOCPP[bool](_py_ok_);
+ %RETURN_TYPE %out = %CONVERTTOCPP[%RETURN_TYPE](_py_ret_);
+ </conversion-rule>
+ <conversion-rule class="target">
+ <insert-template name="differenceOfPointCoordinates_returnTarget"/>
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="callDifferenceOfPointCoordinates(const Point*, bool*)">
+ <modify-argument index="2">
+ <remove-argument/>
+ <conversion-rule class="native">
+ <insert-template name="differenceOfPointCoordinates_arg2"/>
+ </conversion-rule>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PySequence"/>
+ <conversion-rule class="target">
+ <insert-template name="differenceOfPointCoordinates_returnTarget"/>
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="nonConversionRuleForArgumentWithDefaultValue(ObjectType**)">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="(status, object)"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ ObjectType* tmpObject = 0;
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(&amp;tmpObject);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[ObjectType*](tmpObject));
+ </inject-code>
+ </modify-function>
+ <modify-function signature="passOddBool(OddBool)" rename="invertBoolean">
+ <inject-code class="target" position="beginning">
+ %RETURN_TYPE %0 = !%CPPSELF.%FUNCTION_NAME(%1);
+ %PYARG_0 = %CONVERTTOPYTHON[OddBool](%0);
+ </inject-code>
+ </modify-function>
+ </object-type>
+
+ <object-type name="AbstractModifications">
+ <!--
+ completely removing the pure virtual method from this
+ class will generate an #error directive.
+ -->
+ <!--
+ <modify-function signature="pointlessPureVirtualMethod()" remove="all"/>
+ -->
+ </object-type>
+
+ <value-type name="Reference">
+ <modify-function signature="returnMyFirstArg(Reference&amp;)">
+ <modify-argument index="return">
+ <replace-default-expression with="%1"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="returnMySecondArg(int, Reference&amp;)">
+ <modify-argument index="return">
+ <replace-default-expression with="%2"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+ <object-type name="ObjTypeReference">
+ <modify-function signature="returnMyFirstArg(ObjTypeReference&amp;)">
+ <modify-argument index="return">
+ <replace-default-expression with="%1"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="returnMySecondArg(int, ObjTypeReference&amp;)">
+ <modify-argument index="return">
+ <replace-default-expression with="%2"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="justAPureVirtualFunc(ObjTypeReference&amp;)">
+ <modify-argument index="return">
+ <replace-default-expression with="%1"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
+ <value-type name="ImplicitConv">
+ <enum-type name="CtorEnum"/>
+ <enum-type name="ICOverloadedFuncEnum"/>
+ </value-type>
+
+ <value-type name="VirtualMethods">
+ <modify-function signature="sum0(int, int, int)" rename="sumThree"/>
+ <modify-function signature="sum1(int, int, int)">
+ <modify-argument index="3">
+ <replace-default-expression with="1000"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="sum2(int, int, int)">
+ <modify-argument index="3">
+ <remove-argument/>
+ <replace-default-expression with="2000"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="sum3(int, int, int)">
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ %RETURN_TYPE %0 = %CPPSELF.%TYPE::%FUNCTION_NAME(%1, %1+%3, %3);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="sum4(int, int, int)">
+ <modify-argument index="2">
+ <remove-argument/>
+ <replace-default-expression with="3000"/>
+ </modify-argument>
+ <inject-code class="native" position="beginning">
+ PyObject* new_arg0 = PyInt_FromLong(PyInt_AS_LONG(%PYARG_1) - %2);
+ Py_DECREF(%PYARG_1);
+ %PYARG_1 = new_arg0;
+ </inject-code>
+ </modify-function>
+ <modify-function signature="name()">
+ <inject-code class="native" position="end">
+ %0.prepend(Str("Pimped"));
+ </inject-code>
+ </modify-function>
+ <modify-function signature="callMe()">
+ <inject-code class="native" position="end">
+ PyObject_Call(%PYTHON_METHOD_OVERRIDE, %PYTHON_ARGUMENTS, NULL);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="createStr(const char*, Str*&amp;)">
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PySequence"/>
+ <conversion-rule class="native">
+ Shiboken::AutoDecRef _py_ok_(PySequence_GetItem(%PYARG_0, 0));
+ Shiboken::AutoDecRef _py_ret_(PySequence_GetItem(%PYARG_0, 1));
+ %RETURN_TYPE %out = %CONVERTTOCPP[%RETURN_TYPE](_py_ok_);
+ %2 = %CONVERTTOCPP[Str*](_py_ret_);
+ </conversion-rule>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ Str* _str_arg_ = 0;
+ %RETURN_TYPE %0 = %CPPSELF.%TYPE::%FUNCTION_NAME(%1, _str_arg_);
+ </inject-code>
+ <inject-code class="target" position="end">
+ %PYARG_0 = PyTuple_New(2);
+ PyObject* _item_ = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ PyTuple_SET_ITEM(%PYARG_0, 0, _item_);
+ _item_ = %CONVERTTOPYTHON[Str*](_str_arg_);
+ PyTuple_SET_ITEM(%PYARG_0, 1, _item_);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="callCreateStr(const char*, Str*&amp;)">
+ <modify-argument index="2">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PySequence"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ Str* _str_arg_ = 0;
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1, _str_arg_);
+ </inject-code>
+ <inject-code class="target" position="end">
+ %PYARG_0 = PyTuple_New(2);
+ PyObject* _item_ = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ PyTuple_SET_ITEM(%PYARG_0, 0, _item_);
+ _item_ = %CONVERTTOPYTHON[Str*](_str_arg_);
+ PyTuple_SET_ITEM(%PYARG_0, 1, _item_);
+ </inject-code>
+ </modify-function>
+ <template name="fix_int*,int*,int*,int*">
+ int a0, a1, a2, a3;
+ %BEGIN_ALLOW_THREADS
+ %CPPSELF->::%TYPE::%FUNCTION_NAME(&amp;a0, &amp;a1, &amp;a2, &amp;a3);
+ %END_ALLOW_THREADS
+ %PYARG_0 = PyTuple_New(4);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](a0));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](a1));
+ PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[int](a2));
+ PyTuple_SET_ITEM(%PYARG_0, 3, %CONVERTTOPYTHON[int](a3));
+ </template>
+ <template name="fix_native_return_int*,int*,int*,int*">
+ PyObject* _obj = %PYARG_0.object();
+ if (!PySequence_Check(_obj)
+ || PySequence_Fast_GET_SIZE(_obj) != 4
+ || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 0))
+ || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 1))
+ || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 2))
+ || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 3))) {
+ PyErr_SetString(PyExc_TypeError, "Sequence of 4 numbers expected");
+ } else {
+ *%1 = %CONVERTTOCPP[int](PySequence_Fast_GET_ITEM(_obj, 0));
+ *%2 = %CONVERTTOCPP[int](PySequence_Fast_GET_ITEM(_obj, 1));
+ *%3 = %CONVERTTOCPP[int](PySequence_Fast_GET_ITEM(_obj, 2));
+ *%4 = %CONVERTTOCPP[int](PySequence_Fast_GET_ITEM(_obj, 3));
+ }
+ </template>
+ <modify-function signature="getMargins(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/>
+ <remove-default-expression/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_int*,int*,int*,int*"/>
+ </inject-code>
+ <inject-code class="native" position="end">
+ <insert-template name="fix_native_return_int*,int*,int*,int*"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="callGetMargins(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/>
+ <remove-default-expression/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="fix_int*,int*,int*,int*"/>
+ </inject-code>
+ </modify-function>
+ <modify-function signature="recursionOnModifiedVirtual(Str)const">
+ <inject-code class="target" position="beginning">
+ %BEGIN_ALLOW_THREADS
+ // It's important for test purposes to use a constructor with parenthesis as argument.
+ %RETURN_TYPE %0 = %RETURN_TYPE(%CPPSELF.%FUNCTION_NAME(Str(%1)));
+ %END_ALLOW_THREADS
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </modify-function>
+ </value-type>
+ <value-type name="VirtualDaughter" />
+
+ <value-type name="VirtualDtor">
+ <modify-function signature="create()">
+ <modify-argument index="return">
+ <define-ownership owner="target"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+
+ <value-type name="PointerHolder">
+ <modify-function signature="PointerHolder(void*)" remove="all"/>
+ <add-function signature="PointerHolder(PyObject*)">
+ <inject-code class="target" position="beginning">
+ %0 = new %TYPE(%PYARG_1);
+ </inject-code>
+ </add-function>
+ <modify-function signature="pointer() const">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = reinterpret_cast&lt;PyObject*>(%CPPSELF.%FUNCTION_NAME());
+ if (!%PYARG_0)
+ %PYARG_0 = Py_None;
+ Py_INCREF(%PYARG_0);
+ </inject-code>
+ </modify-function>
+ </value-type>
+
+ <function signature="applyHomogeneousTransform(Point,double,double,double,double,double,double,double,double,double,bool*)">
+ <!--
+ Tests handling of the '%#' substitution for # > 9.
+ -->
+ <modify-function signature="applyHomogeneousTransform(Point,double,double,double,double,double,double,double,double,double,bool*)">
+ <modify-argument index="11">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ bool ok_;
+ %RETURN_TYPE retval_ =
+ %FUNCTION_NAME(%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, &amp;ok_);
+ if (!ok_)
+ %PYARG_0 = Py_None;
+ else
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](retval_);
+ </inject-code>
+ </modify-function>
+ </function>
+
+ <!-- Tests add-function for nested template types -->
+ <add-function signature="sum2d(std::list&lt;std::list&lt;int&gt; &gt;)" return-type="int">
+ <inject-code class="target" position="beginning">
+ typedef std::list&lt;int&gt; Inner;
+ typedef std::list&lt;Inner&gt; Outer;
+
+ int result = 0;
+
+ Outer::const_iterator oiter, oend = %1.end();
+ for (oiter = %1.begin(); oiter != oend; ++oiter) {
+ const Inner&amp; inner = *oiter;
+ Inner::const_iterator iiter, iend = inner.end();
+ for (iiter = inner.begin(); iiter != iend; ++iiter)
+ result += *iiter;
+ }
+
+ %PYARG_0 = %CONVERTTOPYTHON[int](result);
+ </inject-code>
+ </add-function>
+
+ <!-- Tests add-function for nested template types -->
+ <add-function signature="sumproduct(std::list&lt;std::pair&lt;int, int&gt; &gt;)" return-type="int">
+ <inject-code class="target" position="beginning">
+ typedef std::pair&lt;int, int&gt; Pair;
+ typedef std::list&lt;Pair&gt; List;
+
+ int result = 0;
+
+ List::const_iterator iter, end = %1.end();
+ for (iter = %1.begin(); iter != end; ++iter)
+ result += iter->first * iter->second;
+
+ %PYARG_0 = %CONVERTTOPYTHON[int](result);
+ </inject-code>
+ </add-function>
+
+
+ <value-type name="InjectCode">
+ <!--
+ Various tests for inject codes.
+ Note: Some uses of inject code here are used just for testing purposes, consider using the add-function tag.
+ -->
+
+ <modify-function signature="sumArrayAndLength(int *) const">
+ <modify-argument index="1">
+ <replace-type modified-type="PyObject"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int* array = NULL;
+ bool errorOccurred = false;
+
+ if (PySequence_Check(%PYARG_1)) {
+ if((array = Shiboken::sequenceToIntArray(%PYARG_1, true)) == NULL &amp;&amp; PyErr_Occurred()) {
+ PyErr_SetString(PyExc_TypeError, "Should be a sequence of ints");
+ errorOccurred = true;
+ }
+ } else {
+ PyErr_SetString(PyExc_TypeError, "Should be a sequence of ints");
+ errorOccurred = true;
+ }
+
+ if (!errorOccurred) {
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(array);
+ if (array)
+ delete[] array;
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ }
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="arrayMethod(int, int*) const">
+ <modify-argument index="1">
+ <remove-argument/>
+ <conversion-rule class="native">
+ int %out = PySequence_Size(%PYARG_1);
+ </conversion-rule>
+ </modify-argument>
+ <modify-argument index="2">
+ <replace-type modified-type="PySequence"/>
+ <conversion-rule class="native">
+ int numItems = PySequence_Size(%PYARG_1);
+ Shiboken::AutoArrayPointer&lt;int&gt; %out(numItems);
+ for (int i = 0; i &lt; numItems; ++i) {
+ if (%CHECKTYPE[int](PySequence_Fast_GET_ITEM(%PYARG_1, i)))
+ %out[i] = %CONVERTTOCPP[int](PySequence_Fast_GET_ITEM(%PYARG_1, i));
+ else if (%ISCONVERTIBLE[int](PySequence_Fast_GET_ITEM(%PYARG_1, i)))
+ %out[i] = -1;
+ else
+ %out[i] = -2;
+ }
+ </conversion-rule>
+ <conversion-rule class="target">
+ PyObject* %out = PyList_New(count);
+ for (int i = 0; i &lt; count; ++i)
+ PyList_SET_ITEM(%out, i, %CONVERTTOPYTHON[int](%in[i]));
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+
+ <modify-function signature="callArrayMethod(int, int*) const">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="2">
+ <replace-type modified-type="PySequence"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int numItems = PySequence_Size(%PYARG_1);
+ int *cppItems = new int[numItems];
+ for (int i = 0; i &lt; numItems; i++)
+ cppItems[i] = %CONVERTTOCPP[int](PySequence_GetItem(%PYARG_1, i));
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(numItems, cppItems);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ delete[] cppItems;
+ </inject-code>
+ </modify-function>
+
+ <!--
+ Inject the tp_str method using this alternative way
+ Tested in InjectCodeTest.testTypeNativeBeginning_TypeTargetBeginning:
+ -->
+ <inject-code class="native" position="beginning">
+ PyObject* InjectCode_tpstr(PyObject*) { return Shiboken::String::fromCString("Hi! I'm the inject code dummy class."); }
+ </inject-code>
+ <!--
+ Register our tp_str class using another inject code
+ Tested in InjectCodeTest.testTypeNativeBeginning_TypeTargetBeginning:
+ -->
+ <inject-code class="target" position="beginning">
+ %PYTHONTYPEOBJECT.tp_str = InjectCode_tpstr;
+ </inject-code>
+
+ <!-- Tested in InjectCodeTest.testFunctionTargetBeginning_FunctionTargetEnd -->
+ <modify-function signature="simpleMethod1(int, int)">
+ <inject-code class="target" position="beginning">
+ %1 += 1;
+ </inject-code>
+ <inject-code class="target" position="end">
+ PyObject* tmp = Shiboken::String::fromCString("end");
+ Shiboken::String::concat(&amp;%PYARG_0, tmp);
+ Py_DECREF(tmp);
+ </inject-code>
+ </modify-function>
+
+ <!-- Tested in InjectCodeTest.testFunctionTargetBeginning -->
+ <modify-function signature="simpleMethod2()">
+ <inject-code class="target" position="end">
+ PyObject* tmp = Shiboken::String::fromCString("end");
+ Shiboken::String::concat(&amp;%PYARG_0, tmp);
+ Py_DECREF(tmp);
+ </inject-code>
+ </modify-function>
+
+ <!-- Tested in InjectCodeTest.testArgsModification -->
+ <modify-function signature="overloadedMethod(int, char**)">
+ <modify-argument index="1">
+ <replace-type modified-type="PySequence" />
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int argc;
+ char** argv;
+ if (!Shiboken::sequenceToArgcArgv(%PYARG_1, &amp;argc, &amp;argv)) {
+ PyErr_SetString(PyExc_TypeError, "error");
+ return 0;
+ }
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(argc, argv);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ for (int i = 0; i &lt; argc; ++i)
+ free(argv[i]);
+ delete[] argv;
+ </inject-code>
+ </modify-function>
+
+ <!-- Tested in InjectCodeTest.testArgsModification2 -->
+ <modify-function signature="simpleMethod3(int, char**)">
+ <modify-argument index="1">
+ <replace-type modified-type="PySequence" />
+ </modify-argument>
+ <modify-argument index="2">
+ <remove-argument />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ int argc;
+ char** argv;
+ if (!Shiboken::sequenceToArgcArgv(%PYARG_1, &amp;argc, &amp;argv)) {
+ PyErr_SetString(PyExc_TypeError, "error");
+ return 0;
+ }
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(argc, argv);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ for (int i = 0; i &lt; argc; ++i)
+ free(argv[i]);
+ delete[] argv;
+ </inject-code>
+ </modify-function>
+ </value-type>
+
+ <value-type name="ImplicitBase"/>
+ <value-type name="SortedOverload">
+ <add-function signature="overload(PyObject *)" return-type="const char *">
+ <inject-code class="target" position="beginning">
+ return Shiboken::String::fromCString("PyObject");
+ </inject-code>
+ </add-function>
+
+ <add-function signature="overloadDeep(int, PyObject *)" return-type="const char *">
+ <inject-code class="target" position="beginning">
+ return Shiboken::String::fromCString("PyObject");
+ </inject-code>
+ </add-function>
+ <modify-function signature="pyObjOverload(unsigned char*, int)">
+ <modify-argument index="1">
+ <replace-type modified-type="PyObject" />
+ <conversion-rule class="native">
+ unsigned char* %out = 0;
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+ <value-type name="ImplicitTarget"/>
+
+ <value-type name="Point">
+ <add-function signature="__str__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ int x1 = (int) %CPPSELF.x();
+ int x2 = ((int) (%CPPSELF.x() * 100)) - (x1 * 100);
+ int y1 = (int) %CPPSELF.y();
+ int y2 = ((int) (%CPPSELF.y() * 100)) - (y1 * 100);
+ %PYARG_0 = Shiboken::String::fromFormat("Point(%d.%d, %d.%d)", x1, x2, y1, y2);
+ </inject-code>
+ </add-function>
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ int x1 = (int) %CPPSELF.x();
+ int x2 = ((int) (%CPPSELF.x() * 10)) - (x1 * 10);
+ int y1 = (int) %CPPSELF.y();
+ int y2 = ((int) (%CPPSELF.y() * 10)) - (y1 * 10);
+ %PYARG_0 = Shiboken::String::fromFormat("&lt;Point object at %p: (%d.%d, %d.%d)&gt;", %CPPSELF, x1, x2, y1, y2);
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ PyObject* type = PyObject_Type(%PYSELF);
+ PyObject* args = NULL;
+
+ args = Py_BuildValue("(dd)", %CPPSELF.x(), %CPPSELF.y());
+
+ %PYARG_0 = Py_BuildValue("(OO)", type, args);
+ </inject-code>
+ </add-function>
+
+ <modify-function signature="midpoint(const Point&amp;, Point*)const">
+ <modify-argument index="2">
+ <remove-argument />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="Point" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ Point _midpoint;
+ // The test consists in *NOT* using the ARGUMENT_NAMES type system variable.
+ %CPPSELF.%FUNCTION_NAME(%1, &amp;_midpoint);
+ %PYARG_0 = %CONVERTTOPYTHON[Point](_midpoint);
+ </inject-code>
+ </modify-function>
+
+ <template name="return_self">
+ %PYARG_0 = %PYARG_1;
+ Py_INCREF(%PYARG_1);
+ </template>
+ <add-function signature="operator-(PyUnicode)">
+ <inject-code>
+ <insert-template name="return_self" />
+ </inject-code>
+ </add-function>
+ <!-- A reverse operator -->
+ <add-function signature="operator-(PyUnicode, Point)">
+ <inject-code>
+ <insert-template name="return_self" />
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ <value-type name="PointF">
+ <add-function signature="__str__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ int x1 = (int) %CPPSELF.x();
+ int x2 = ((int) (%CPPSELF.x() * 100)) - (x1 * 100);
+ int y1 = (int) %CPPSELF.y();
+ int y2 = ((int) (%CPPSELF.y() * 100)) - (y1 * 100);
+ %PYARG_0 = Shiboken::String::fromFormat("PointF(%d.%d, %d.%d)", x1, x2, y1, y2);
+ </inject-code>
+ </add-function>
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ int x1 = (int) %CPPSELF.x();
+ int x2 = ((int) (%CPPSELF.x() * 10)) - (x1 * 10);
+ int y1 = (int) %CPPSELF.y();
+ int y2 = ((int) (%CPPSELF.y() * 10)) - (y1 * 10);
+ %PYARG_0 = Shiboken::String::fromFormat("&lt;PointF object at %p: (%d.%d, %d.%d)&gt;", %CPPSELF, x1, x2, y1, y2);
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__reduce__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ PyObject *type = PyObject_Type(%PYSELF);
+ PyObject *args = NULL;
+
+ args = Py_BuildValue("(dd)", %CPPSELF.x(), %CPPSELF.y());
+
+ %PYARG_0 = Py_BuildValue("(OO)", type, args);
+ </inject-code>
+ </add-function>
+
+ <modify-function signature="midpoint(const PointF&amp;, PointF*)const">
+ <modify-argument index="2">
+ <remove-argument />
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PointF" />
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ PointF _midpoint;
+ // The test consists in using the ARGUMENT_NAMES type system variable.
+ %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;_midpoint);
+ %PYARG_0 = %CONVERTTOPYTHON[PointF](_midpoint);
+ </inject-code>
+ </modify-function>
+ </value-type>
+
+ <value-type name="Rect" />
+ <value-type name="RectF" />
+
+ <value-type name="Polygon">
+ <modify-function signature="stealOwnershipFromPython(Point*)">
+ <modify-argument index="1">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="stealOwnershipFromPython(Polygon*)">
+ <modify-argument index="1">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+
+ <value-type name="Time">
+ <extra-includes>
+ <include file-name="datetime.h" location="global"/>
+ </extra-includes>
+ <enum-type name="NumArgs"/>
+ <add-function signature="operator!=(const PyObject*)" return-type="PyObject">
+ <inject-code>
+ if (!PyDateTimeAPI)
+ PyDateTime_IMPORT;
+ if (PyTime_Check(%1)) {
+ int pyH = PyDateTime_TIME_GET_HOUR(%1);
+ int pyM = PyDateTime_TIME_GET_MINUTE(%1);
+ int pyS = PyDateTime_TIME_GET_SECOND(%1);
+ if ((pyH == %CPPSELF.hour()) &amp;&amp;
+ (pyM == %CPPSELF.minute()) &amp;&amp;
+ (pyS == %CPPSELF.second()))
+ %PYARG_0 = Py_False;
+ else
+ %PYARG_0 = Py_True;
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="operator==(const PyObject*)" return-type="PyObject">
+ <inject-code>
+ if (!PyDateTimeAPI)
+ PyDateTime_IMPORT;
+ if (PyTime_Check(%1)) {
+ int pyH = PyDateTime_TIME_GET_HOUR(%1);
+ int pyM = PyDateTime_TIME_GET_MINUTE(%1);
+ int pyS = PyDateTime_TIME_GET_SECOND(%1);
+ if ((pyH == %CPPSELF.hour()) &amp;&amp;
+ (pyM == %CPPSELF.minute()) &amp;&amp;
+ (pyS == %CPPSELF.second()))
+ %PYARG_0 = Py_True;
+ else
+ %PYARG_0 = Py_False;
+ }
+ </inject-code>
+ </add-function>
+
+ </value-type>
+ <value-type name="Size">
+ <add-function signature="Size(const char*)">
+ <inject-code class="target" position="beginning">
+ %0 = new %TYPE();
+ </inject-code>
+ <inject-code class="target" position="end">
+ Shiboken::AutoDecRef result(PyObject_CallMethod(%PYSELF, const_cast&lt;char*>("setHeight"), const_cast&lt;char*>("i"), 2));
+ </inject-code>
+ </add-function>
+ </value-type>
+ <value-type name="SizeF"/>
+ <value-type name="MapUser"/>
+ <value-type name="PairUser"/>
+ <value-type name="ListUser">
+ <enum-type name="ListOfSomething"/>
+ </value-type>
+ <value-type name="NoImplicitConversion" />
+ <value-type name="NonDefaultCtor" />
+ <value-type name="OddBoolUser" />
+ <object-type name="Overload">
+ <enum-type name="FunctionEnum"/>
+ <enum-type name="ParamEnum"/>
+ <modify-function signature="intOverloads(int, int, double)">
+ <modify-argument index="2">
+ <remove-argument />
+ </modify-argument>
+ <inject-code class="target">
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1, 2, %3);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </modify-function>
+ <modify-function signature="singleOverload(Point*)">
+ <modify-argument index="1">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="acceptSequence(const char**)">
+ <modify-argument index="1">
+ <replace-type modified-type="PySequence" />
+ <conversion-rule class="native">
+ {
+ Shiboken::AutoDecRef strList(PySequence_Fast(%PYARG_1, "The argument must be a sequence."));
+ int lineCount = PySequence_Fast_GET_SIZE(strList.object());
+ for (int line = 0; line &lt; lineCount; ++line) {
+ if (!Shiboken::String::check(PySequence_Fast_GET_ITEM(strList.object(), line))) {
+ PyErr_SetString(PyExc_TypeError, "The argument must be a sequence of strings.");
+ break;
+ }
+ }
+ }
+ const char** %out = 0;
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="acceptSequence(void*)">
+ <modify-argument index="1">
+ <replace-type modified-type="PyObject" />
+ <conversion-rule class="native">
+ void* %out = 0;
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+
+ <template name="buffer_argument">
+ unsigned char* %out = (unsigned char*) Shiboken::Buffer::getPointer(%PYARG_1);
+ </template>
+
+ <modify-function signature="strBufferOverloads(unsigned char*,int)">
+ <modify-argument index="1">
+ <replace-type modified-type="PyBuffer"/>
+ <conversion-rule class="native">
+ <insert-template name="buffer_argument" />
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ <!--
+ This added function simulates the solution given to PySide's QImage
+ constructor problem, as seen in PySide/bbba1cc4, and described in
+ bug #489 [http://bugs.pyside.org/show_bug.cgi?id=489].
+ This is not the best solution, just one that works. The proper way
+ to handle it would be to fix the overload decisor.
+ -->
+ <add-function signature="strBufferOverloads(Str&amp;,int)" return-type="Overload::FunctionEnum">
+ <inject-code class="target" position="beginning">
+ <insert-template name="buffer_argument">
+ <replace from="%out" to="argOut" />
+ </insert-template>
+ %BEGIN_ALLOW_THREADS
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(argOut, %2);
+ %END_ALLOW_THREADS
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ </object-type>
+ <object-type name="Overload2" />
+
+ <object-type name="Collector" stream="yes"/>
+
+ <value-type name="IntWrapper" />
+
+ <value-type name="Str" hash-function="strHash">
+ <add-function signature="__str__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = Shiboken::String::fromCString(%CPPSELF.cstring());
+ </inject-code>
+ </add-function>
+ <add-function signature="__len__" >
+ <inject-code class="target" position="end">
+ return %CPPSELF.size();
+ </inject-code>
+ </add-function>
+ <add-function signature="__getitem__" >
+ <inject-code class="target" position="beginning">
+ if (_i &lt; 0 || _i >= %CPPSELF.size()) {
+ PyErr_BadArgument();
+ return 0;
+ } else {
+ char res[2];
+ res[0] = %CPPSELF.get_char(_i);
+ res[1] = 0;
+ return Shiboken::String::fromCString(res);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="__setitem__" >
+ <inject-code class="target" position="beginning">
+ PyObject* args = Py_BuildValue("(iO)", _i, _value);
+ PyObject* result = Sbk_StrFunc_set_char(self, args);
+ Py_DECREF(args);
+ int ok = result == Py_True;
+ if (result) {
+ Py_DECREF(result);
+ }
+ return !ok ? -1 : 0;
+ </inject-code>
+ </add-function>
+ <modify-function signature="toInt(bool*, int)const">
+ <modify-argument index="1">
+ <remove-argument/>
+ </modify-argument>
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ <insert-template name="boolptr_at_start_and_one_arg_fix_beginning"/>
+ </inject-code>
+ <inject-code class="target" position="end">
+ <insert-template name="boolptr_fix_end"/>
+ </inject-code>
+ </modify-function>
+ </value-type>
+
+ <value-type name="ByteArray" hash-function="ByteArray::hash">
+ <conversion-rule>
+ <target-to-native>
+ <add-conversion type="Py_None">
+ %out = %OUTTYPE();
+ </add-conversion>
+ <add-conversion type="PyObject" check="Shiboken::String::check(%in) || PyBytes_Check(%in)">
+ Py_ssize_t len;
+ const char* str = Shiboken::String::toCString(%in, &amp;len);
+ %out = %OUTTYPE(str, len);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+
+ <modify-function signature="ByteArray(const char*,int)" remove="all" />
+ <modify-function signature="ByteArray(const char*)" remove="all" >
+ <!-- Keep \x00 bytes passed in Python strings. -->
+ <modify-argument index="1">
+ <replace-type modified-type="PyBytes"/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ PyObject* data = 0;
+ if (PyUnicode_CheckExact(%PYARG_1)) {
+ data = PyUnicode_AsASCIIString(%PYARG_1);
+ } else {
+ data = %PYARG_1;
+ Py_INCREF(data);
+ }
+
+ %0 = new %TYPE(PyBytes_AsString(data), PyBytes_GET_SIZE(data));
+ Py_DECREF(data);
+ </inject-code>
+ </modify-function>
+
+ <!-- buffer protocol -->
+ <inject-code class="native" position="beginning" file="bytearray_bufferprotocol.cpp" />
+ <inject-code class="target" position="end">
+ #if PY_VERSION_HEX &lt; 0x03000000
+ Shiboken::SbkType&lt;ByteArray&gt;()->tp_as_buffer = &amp;SbkByteArrayBufferProc;
+ Shiboken::SbkType&lt;ByteArray&gt;()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER;
+ #endif
+ </inject-code>
+
+ <modify-function signature="data() const">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = PyBytes_FromStringAndSize(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.size());
+ </inject-code>
+ </modify-function>
+
+ <modify-function signature="hash(const ByteArray&amp;)" remove="all" />
+ <!-- Functions removed to proper deal with strings containing zeroes -->
+ <modify-function signature="append(const char*)" remove="all" />
+ <modify-function signature="append(const char*,int)" remove="all" />
+ <modify-function signature="operator==(const char*,ByteArray)" remove="all" />
+ <modify-function signature="operator==(ByteArray,const char*)" remove="all" />
+ <modify-function signature="operator!=(const char*,ByteArray)" remove="all" />
+ <modify-function signature="operator!=(ByteArray,const char*)" remove="all" />
+ <modify-function signature="operator+(ByteArray,const char*)" remove="all" />
+ <modify-function signature="operator+(const char*,ByteArray)" remove="all" />
+ <modify-function signature="operator+=(const char*)" remove="all" />
+ <modify-function signature="operator[](int)const" remove="all"/>
+
+ <add-function signature="operator+(PyUnicode)" return-type="ByteArray">
+ <inject-code>
+ Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1));
+ if (!data.isNull()) {
+ ByteArray ba(*%CPPSELF);
+ ba.append(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object()));
+ %PYARG_0 = %CONVERTTOPYTHON[ByteArray](ba);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+(PyUnicode,ByteArray)" return-type="ByteArray">
+ <inject-code>
+ Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1));
+ if (!data.isNull()) {
+ ByteArray ba(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object()));
+ ba.append(*%CPPSELF);
+ %PYARG_0 = %CONVERTTOPYTHON[ByteArray](ba);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+(PyBytes,ByteArray)">
+ <inject-code>
+ ByteArray ba(PyBytes_AsString(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1));
+ ba = ba + *%CPPSELF;
+ %PYARG_0 = %CONVERTTOPYTHON[ByteArray](ba);
+ </inject-code>
+ </add-function>
+ <add-function signature="operator+(PyBytes)">
+ <inject-code>
+ ByteArray ba(PyBytes_AsString(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1));
+ ba.append(*%CPPSELF);
+ %PYARG_0 = %CONVERTTOPYTHON[ByteArray](ba);
+ </inject-code>
+ </add-function>
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ ByteArray b(((PyObject*)%PYSELF)->ob_type->tp_name);
+ PyObject* aux = Shiboken::String::fromStringAndSize(%CPPSELF.data(), %CPPSELF.size());
+ if (PyUnicode_CheckExact(aux)) {
+ PyObject* tmp = PyUnicode_AsASCIIString(aux);
+ Py_DECREF(aux);
+ aux = tmp;
+ }
+ b += "('";
+ b += ByteArray(PyBytes_AS_STRING(aux), PyBytes_GET_SIZE(aux));
+ b += "')";
+ %PYARG_0 = Shiboken::String::fromStringAndSize(b.data(), b.size());
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__str__" return-type="str">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = Shiboken::String::fromStringAndSize(%CPPSELF.data(), %CPPSELF.size());
+ </inject-code>
+ </add-function>
+
+ <add-function signature="__len__">
+ <inject-code class="target" position="beginning">
+ return %CPPSELF.size();
+ </inject-code>
+ </add-function>
+ <add-function signature="__getitem__">
+ <inject-code class="target" position="beginning">
+ if (_i &lt; 0 || _i >= %CPPSELF.size()) {
+ PyErr_SetString(PyExc_IndexError, "index out of bounds");
+ return 0;
+ } else {
+ char res[2];
+ res[0] = %CPPSELF.at(_i);
+ res[1] = 0;
+ return PyBytes_FromStringAndSize(res, 1);
+ }
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ <value-type name="StrList">
+ <enum-type name="CtorEnum"/>
+ <add-function signature="__len__" >
+ <inject-code class="target" position="end">
+ return %CPPSELF.size();
+ </inject-code>
+ </add-function>
+ <add-function signature="__getitem__" >
+ <inject-code class="target" position="beginning">
+ if (_i &lt; 0 || _i >= static_cast&lt;Py_ssize_t>(%CPPSELF.size())) {
+ PyErr_BadArgument();
+ return 0;
+ } else {
+ %TYPE::const_iterator it = %CPPSELF.begin();
+ for (Py_ssize_t i = 1; i &lt;= _i; i++)
+ ++it;
+ return %CONVERTTOPYTHON[Str](*it);
+ }
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ <value-type name="SimpleFile">
+ <modify-function signature="open()">
+ <modify-argument index="return">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="end" file="simplefile_glue.cpp"/>
+ </modify-function>
+ </value-type>
+
+ <value-type name="VoidHolder">
+ <modify-function signature="gimmeMeSomeVoidPointer()">
+ <modify-argument index="return">
+ <replace-type modified-type="PyObject*"/>
+ </modify-argument>
+ <inject-code class="target" position="end">
+ %RETURN_TYPE %0 = %TYPE::%FUNCTION_NAME();
+ %PYARG_0 = Shiboken::Object::newObject(&amp;SbkObject_Type, %0, false, false);
+ </inject-code>
+ </modify-function>
+ </value-type>
+
+ <object-type name="PrivateCtor" />
+ <object-type name="PrivateDtor" />
+
+ <object-type name="Base1"/>
+ <object-type name="Base2"/>
+ <object-type name="Base3"/>
+ <object-type name="Base4"/>
+ <object-type name="Base5"/>
+ <object-type name="Base6"/>
+ <object-type name="MDerived1"/>
+ <object-type name="MDerived2"/>
+ <object-type name="MDerived3"/>
+ <object-type name="MDerived4"/>
+ <object-type name="MDerived5"/>
+ <object-type name="SonOfMDerived1"/>
+
+ <object-type name="Bucket">
+ <modify-function signature="lock()" allow-thread="yes" />
+ <modify-function signature="virtualBlockerMethod()" allow-thread="yes"/>
+ <modify-function signature="callVirtualBlockerMethodButYouDontKnowThis()" allow-thread="yes"/>
+ </object-type>
+
+ <value-type name="Echo">
+ <add-function signature="echo(const char *)" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = Shiboken::String::fromCString(%1);
+ </inject-code>
+ </add-function>
+ <add-function signature="operator>(int)">
+ <inject-code>
+ // This should test if code injections works inside rich comparison operators
+ Py_INCREF(Py_True);
+ %PYARG_0 = Py_True;
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ <value-type name="Color" />
+ <value-type name="Pen">
+ <enum-type identified-by-value="EnumCtor"/>
+ </value-type>
+
+ <value-type name="CtorConvRule">
+ <modify-function signature="CtorConvRule(long)">
+ <modify-argument index="1">
+ <!--<replace-type modified-type="long"/>-->
+ <conversion-rule class="native">
+ // Does nothing really, just test the code generation
+ // of constructors whose arguments where
+ long %out = PyInt_AS_LONG(%PYARG_1) + 1;
+ </conversion-rule>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+
+ <add-function signature="multiplyString(str, unsigned int)" return-type="const char*">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = Shiboken::String::fromCString("");
+ for (unsigned int i = 0; i &lt; %2; ++i)
+ Shiboken::String::concat(&amp;%PYARG_0, %PYARG_1);
+ </inject-code>
+ </add-function>
+
+ <add-function signature="countVarargs(int, ...)" return-type="int">
+ <inject-code class="target" position="beginning">
+ %RETURN_TYPE %0 = PyTuple_GET_SIZE(%PYARG_2);
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+
+ <value-type name="SbkDate">
+ <extra-includes>
+ <include file-name="datetime.h" location="global"/>
+ </extra-includes>
+ <inject-code class="native" position="beginning">
+ static bool PyDate_ImportAndCheck(PyObject* pyIn) {
+ if (!PyDateTimeAPI)
+ PyDateTime_IMPORT;
+ return PyDate_Check(pyIn);
+ }
+ </inject-code>
+ <conversion-rule>
+ <target-to-native>
+ <add-conversion type="PyDate" check="PyDate_ImportAndCheck(%in)">
+ int day = PyDateTime_GET_DAY(%in);
+ int month = PyDateTime_GET_MONTH(%in);
+ int year = PyDateTime_GET_YEAR(%in);
+ %out = %OUTTYPE(day, month, year);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ <add-function signature="toPython()" return-type="PyDate">
+ <inject-code class="target">
+ if (!PyDateTimeAPI)
+ PyDateTime_IMPORT;
+ %PYARG_0 = PyDate_FromDate(%CPPSELF.day(), %CPPSELF.month(), %CPPSELF.year());
+ </inject-code>
+ </add-function>
+ </value-type>
+
+ <object-type name="HandleHolder" />
+ <value-type name="PrimitiveStructPointerHolder" />
+
+ <object-type name="ObjectTypeOperators">
+ <add-function signature="operator!=(std::string)" return-type="bool">
+ <inject-code class="target">
+ %RETURN_TYPE %0 = %CPPSELF.key() != %1;
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ </object-type>
+
+ <value-type name="Filter" />
+ <value-type name="Data">
+ <enum-type name="Field" />
+ <add-function signature="operator&amp;(const Union&amp;)" return-type="Intersection">
+ <inject-code class="target">
+ %RETURN_TYPE %0 = *%CPPSELF &amp; %1;
+ return %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ </value-type>
+ <value-type name="Union">
+ <add-function signature="operator&amp;(const Data&amp;)" return-type="Intersection">
+ <inject-code class="target">
+ %RETURN_TYPE %0 = *%CPPSELF &amp; %1;
+ return %CONVERTTOPYTHON[%RETURN_TYPE](%0);
+ </inject-code>
+ </add-function>
+ </value-type>
+ <value-type name="Intersection" />
+
+ <!-- type used in abstract method -->
+ <object-type name="HideType" generate="no" />
+
+ <value-type name="Expression" />
+
+ <value-type name="ModelIndex" />
+ <value-type name="ReferentModelIndex">
+ <modify-function signature="operator const ModelIndex&amp;()const">
+ <modify-argument index="return">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </value-type>
+ <value-type name="PersistentModelIndex" />
+
+ <!-- test rejections using full signatures; this method is a template and
+ cannot be wrapped, but is otherwise recognized by shiboken and will
+ result in a compile error if the rejection is not matched -->
+ <rejection class="Photon::Base" function-name="isType()"/>
+
+ <value-type name="ValueAndVirtual" />
+
+ <object-type name="ObjectTypeByValue" />
+
+ <object-type name="TemplatePtr">
+ <modify-function signature="dummy(std::list&lt;std::pair&lt;BlackBox *, BlackBox *&gt; &gt; &amp;)" rename="dummy_method" />
+ </object-type>
+
+ <suppress-warning text="horribly broken type '__off64_t'" />
+ <suppress-warning text="enum '__codecvt_result' does not have a type entry or is not an enum" />
+ <suppress-warning text="Pure virtual method &quot;Abstract::hideFunction(HideType*)&quot; must be implement but was completely removed on typesystem." />
+ <suppress-warning text="hiding of function 'takeChild' in class 'ObjectType'" />
+ <suppress-warning text="Shadowing: MDerived2::castToBase3() and MDerived3::castToBase3()" />
+ <suppress-warning text="hiding of function 'takeChild' in class 'Bucket'" />
+ <suppress-warning text="visibility of function 'publicMethod' modified in class 'MDerived1'" />
+ <suppress-warning text="hiding of function 'doNothingInPublic3' in class 'Overload2'" />
+ <suppress-warning text="hiding of function 'takeChild' in class 'ObjectModel'" />
+ <suppress-warning text="hiding of function 'takeChild' in class 'ObjectView'" />
+ <suppress-warning text="visibility of function 'publicMethod' modified in class 'MDerived3'" />
+ <suppress-warning text="skipping function 'InjectCode::toStr', unmatched parameter type 'T const&amp;'" />
+
+ <!-- Do not fix this warning, the generator should be able to handle this situation for Object Types. -->
+ <suppress-warning text="Argument in position 1 of added function 'SampleNamespace::passReferenceToObjectType(ObjectType * arg__1)', has a type that is not a reference, while the argument in the corresponding position in C++ function 'SampleNamespace::passReferenceToObjectType(const ObjectType &amp; obj, int multiplier)' is a reference." />
+
+</typesystem>
diff --git a/sources/shiboken2/tests/samplebinding/unsafe_parent_test.py b/sources/shiboken2/tests/samplebinding/unsafe_parent_test.py
new file mode 100644
index 000000000..18da16458
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/unsafe_parent_test.py
@@ -0,0 +1,54 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for ...'''
+
+import sys
+import unittest
+
+from sample import ObjectType
+
+class DerivedObjectType(ObjectType):
+ def isPython(self):
+ return True
+
+ def createChild(self, parent):
+ return DerivedObjectType(parent)
+
+class ParentTest(unittest.TestCase):
+
+ def testUunsafeParent(self):
+ o = DerivedObjectType()
+ o.callVirtualCreateChild()
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/useraddedctor_test.py b/sources/shiboken2/tests/samplebinding/useraddedctor_test.py
new file mode 100644
index 000000000..ea9d1f878
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/useraddedctor_test.py
@@ -0,0 +1,45 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for user added constructors'''
+
+import unittest
+from sample import *
+
+class PointTest(unittest.TestCase):
+ def testUsingSelfOnCtor(self):
+ # This is a user added ctor and no errors should happen!
+ s = Size("oi")
+ self.assertEqual(s.height(), 2)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/virtualdtor_test.py b/sources/shiboken2/tests/samplebinding/virtualdtor_test.py
new file mode 100644
index 000000000..46f29179c
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/virtualdtor_test.py
@@ -0,0 +1,76 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for virtual destructor.'''
+
+import sys
+import unittest
+
+from sample import VirtualDtor
+
+class ExtendedVirtualDtor(VirtualDtor):
+ def __init__(self):
+ VirtualDtor.__init__(self)
+
+class VirtualDtorTest(unittest.TestCase):
+ '''Test case for virtual destructor.'''
+
+ def setUp(self):
+ VirtualDtor.resetDtorCounter()
+
+ def testVirtualDtor(self):
+ '''Original virtual destructor is being called.'''
+ dtor_called = VirtualDtor.dtorCalled()
+ for i in range(1, 10):
+ vd = VirtualDtor()
+ del vd
+ self.assertEqual(VirtualDtor.dtorCalled(), dtor_called + i)
+
+ def testVirtualDtorOnCppCreatedObject(self):
+ '''Original virtual destructor is being called for a C++ created object.'''
+ dtor_called = VirtualDtor.dtorCalled()
+ for i in range(1, 10):
+ vd = VirtualDtor.create()
+ del vd
+ self.assertEqual(VirtualDtor.dtorCalled(), dtor_called + i)
+
+ def testDtorOnDerivedClass(self):
+ '''Original virtual destructor is being called for a derived class.'''
+ dtor_called = ExtendedVirtualDtor.dtorCalled()
+ for i in range(1, 10):
+ evd = ExtendedVirtualDtor()
+ del evd
+ self.assertEqual(ExtendedVirtualDtor.dtorCalled(), dtor_called + i)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/virtualmethods_test.py b/sources/shiboken2/tests/samplebinding/virtualmethods_test.py
new file mode 100644
index 000000000..8a361c9f9
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/virtualmethods_test.py
@@ -0,0 +1,138 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for virtual methods.'''
+
+import sys
+import unittest
+
+from sample import *
+
+import warnings
+
+class ExtendedVirtualMethods(VirtualMethods):
+ def __init__(self):
+ VirtualMethods.__init__(self)
+ self.virtual_method0_called = False
+
+ def virtualMethod0(self, pt, val, cpx, b):
+ self.virtual_method0_called = True
+ return VirtualMethods.virtualMethod0(self, pt, val, cpx, b) * -1.0
+
+ def strListToStdList(self, arg):
+ warnings.simplefilter('error')
+ # returning wrong type for test purposes.
+ return True
+
+ def recursionOnModifiedVirtual(self, arg):
+ # check if recursion is caused by injected code that calls C++.
+ return VirtualMethods.recursionOnModifiedVirtual(self, arg) + 10
+
+class ExtendedVirtualDaughter(VirtualDaughter):
+ def __init__(self, name):
+ VirtualDaughter.__init__(self, name)
+ self.grand_daughter_name_called = False
+
+ def name(self):
+ self.grand_daughter_name_called = True
+ return VirtualDaughter.name(self).prepend('Extended')
+
+class ExtendedExtendedVirtualDaughter(ExtendedVirtualDaughter):
+ def __init__(self, name):
+ ExtendedVirtualDaughter.__init__(self, name)
+ self.grand_grand_daughter_name_called = False
+
+ def name(self):
+ self.grand_grand_daughter_name_called = True
+ return ExtendedVirtualDaughter.name(self).prepend('Extended')
+
+class VirtualMethodsTest(unittest.TestCase):
+ '''Test case for virtual methods'''
+
+ def setUp(self):
+ self.prefix_from_codeinjection = Str('Pimped')
+
+ def tearDown(self):
+ del self.prefix_from_codeinjection
+
+ def testReimplementedVirtualMethod0(self):
+ '''Test Python override of a virtual method with various different parameters is correctly called from C++.'''
+ vm = VirtualMethods()
+ evm = ExtendedVirtualMethods()
+ pt = Point(1.1, 2.2)
+ val = 4
+ cpx = complex(3.3, 4.4)
+ b = True
+ result0 = vm.callVirtualMethod0(pt, val, cpx, b)
+ result1 = evm.callVirtualMethod0(pt, val, cpx, b)
+ self.assertEqual(result0 * -1.0, result1)
+
+ def testRecursionOnModifiedVirtual(self):
+ evm = ExtendedVirtualMethods()
+ self.assertEqual(evm.recursionOnModifiedVirtual(''), 10)
+ self.assertEqual(evm.callRecursionOnModifiedVirtual(''), 10)
+
+ def testReimplementedVirtualMethodInheritedFromGrandParent(self):
+ '''Test Python override of a virtual method inherited from a grand parent.'''
+ original_name = 'Foo'
+ evd = ExtendedVirtualDaughter(original_name)
+
+ self.assertEqual(VirtualDaughter.name(evd), original_name)
+ self.assertEqual(VirtualMethods.name(evd), original_name)
+ self.assertFalse(evd.grand_daughter_name_called)
+
+ name = evd.callName()
+ self.assertTrue(evd.grand_daughter_name_called)
+ self.assertEqual(evd.name().prepend(self.prefix_from_codeinjection), name)
+
+ def testReimplementedVirtualMethodInheritedFromGrandGrandParent(self):
+ '''Test Python override of a virtual method inherited from a grand grand parent.'''
+ original_name = 'Foo'
+ eevd = ExtendedExtendedVirtualDaughter(original_name)
+
+ self.assertEqual(VirtualDaughter.name(eevd), original_name)
+ self.assertEqual(VirtualMethods.name(eevd), original_name)
+ self.assertFalse(eevd.grand_daughter_name_called)
+ self.assertFalse(eevd.grand_grand_daughter_name_called)
+
+ name = eevd.callName()
+ self.assertTrue(eevd.grand_daughter_name_called)
+ self.assertTrue(eevd.grand_grand_daughter_name_called)
+ self.assertEqual(eevd.name().prepend(self.prefix_from_codeinjection), name)
+
+class PrettyErrorMessageTest(unittest.TestCase):
+ def testIt(self):
+ obj = ExtendedVirtualMethods()
+ self.assertRaises(RuntimeWarning, obj.callStrListToStdList, StrList())
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/visibilitychange_test.py b/sources/shiboken2/tests/samplebinding/visibilitychange_test.py
new file mode 100644
index 000000000..b89036a94
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/visibilitychange_test.py
@@ -0,0 +1,47 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from sample import *
+
+class VisibilityChangeTest(unittest.TestCase):
+
+ def testVisibilityChange(self):
+ b1 = Base1()
+ b1.publicMethod() # ok...
+ d1 = MDerived1()
+ self.assertRaises(TypeError, d1.publicMethod);
+
+if __name__ == '__main__':
+ unittest.main()
+
+
diff --git a/sources/shiboken2/tests/samplebinding/voidholder_test.py b/sources/shiboken2/tests/samplebinding/voidholder_test.py
new file mode 100644
index 000000000..cb5cab6e5
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/voidholder_test.py
@@ -0,0 +1,69 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for a class that holds a void pointer.'''
+
+import unittest
+
+from sample import VoidHolder, Point
+
+class VoidHolderTest(unittest.TestCase):
+ '''Test case for void pointer manipulation.'''
+
+ def testGetVoidPointerFromCppAndPutsOnVoidHolder(self):
+ '''Passes a void pointer created in C++ and to kept by VoidHolder.'''
+ voidptr = VoidHolder.gimmeMeSomeVoidPointer()
+ voidholder = VoidHolder(voidptr)
+ self.assertEqual(voidptr, voidholder.voidPointer())
+
+ def testPutRandomObjectInsideVoidHolder(self):
+ '''Passes a C++ pointer for an object created in Python to be kept by VoidHolder.'''
+ obj = Point(1, 2)
+ voidholder = VoidHolder(obj)
+ self.assertEqual(obj, voidholder.voidPointer())
+
+ def testGetNoneObjectFromVoidHolder(self):
+ '''A VoidHolder created without parameters returns a NULL pointer
+ that should be converted to a Python None.'''
+ voidholder = VoidHolder()
+ self.assertEqual(voidholder.voidPointer(), None)
+
+ def testPutPythonObjectInsideVoidHolder(self):
+ '''Passes a native Python object to be kept by VoidHolder.'''
+ obj = 'Foo'
+ voidholder = VoidHolder(obj)
+ self.assertEqual(obj, voidholder.voidPointer())
+
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/weakref_test.py b/sources/shiboken2/tests/samplebinding/weakref_test.py
new file mode 100644
index 000000000..77be7ec9f
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/weakref_test.py
@@ -0,0 +1,65 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test weakref support'''
+
+import weakref
+import unittest
+
+from sample import ObjectType, PrivateDtor
+
+
+class WeakrefBasicTest(unittest.TestCase):
+ '''Simple test case of using a weakref'''
+
+ def setUp(self):
+ self.called = False
+
+ def cb(self, *args):
+ self.called = True
+
+ def testBasic(self):
+ '''ObjectType weakref'''
+ obj = ObjectType()
+ ref = weakref.ref(obj, self.cb)
+ del obj
+ self.assertTrue(self.called)
+
+ def testPrivateDtor(self):
+ '''PrivateDtor weakref'''
+ obj = PrivateDtor.instance()
+ ref = weakref.ref(obj, self.cb)
+ del obj
+ self.assertTrue(self.called)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/writableclassdict_test.py b/sources/shiboken2/tests/samplebinding/writableclassdict_test.py
new file mode 100644
index 000000000..828ac686a
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/writableclassdict_test.py
@@ -0,0 +1,52 @@
+#!/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 PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from sample import Point
+
+class ExtPoint(Point): pass
+
+class TestWritableClassDict(unittest.TestCase):
+ def testSetattrOnClass(self):
+ setattr(Point, 'foo', 123)
+ self.assertEqual(Point.foo, 123)
+ pt = Point()
+ self.assertEqual(pt.foo, 123)
+
+ def testSetattrOnInheritingClass(self):
+ setattr(Point, 'bar', 321)
+ self.assertEqual(Point.bar, 321)
+ self.assertEqual(ExtPoint.bar, 321)
+ pt = ExtPoint()
+ self.assertEqual(pt.bar, 321)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/shibokenmodule/module_test.py b/sources/shiboken2/tests/shibokenmodule/module_test.py
new file mode 100644
index 000000000..bc2931251
--- /dev/null
+++ b/sources/shiboken2/tests/shibokenmodule/module_test.py
@@ -0,0 +1,116 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import shiboken2 as shiboken
+import unittest
+from sample import *
+
+class MultipleInherited (ObjectType, Point):
+ def __init__(self):
+ ObjectType.__init__(self)
+ Point.__init__(self)
+
+class TestShiboken(unittest.TestCase):
+ def testIsValid(self):
+ self.assertTrue(shiboken.isValid(object()))
+ self.assertTrue(shiboken.isValid(None))
+
+ bb = BlackBox()
+ item = ObjectType()
+ ticket = bb.keepObjectType(item)
+ bb.disposeObjectType(ticket)
+ self.assertFalse(shiboken.isValid(item))
+
+ def testWrapInstance(self):
+ addr = ObjectType.createObjectType()
+ obj = shiboken.wrapInstance(addr, ObjectType)
+ self.assertFalse(shiboken.createdByPython(obj))
+ obj.setObjectName("obj")
+ self.assertEqual(obj.objectName(), "obj")
+ self.assertEqual(addr, obj.identifier())
+ self.assertFalse(shiboken.createdByPython(obj))
+
+ # avoid mem leak =]
+ bb = BlackBox()
+ self.assertTrue(shiboken.createdByPython(bb))
+ bb.disposeObjectType(bb.keepObjectType(obj))
+
+ def testIsOwnedByPython(self):
+ obj = ObjectType()
+ self.assertTrue(shiboken.ownedByPython(obj))
+ p = ObjectType()
+ obj.setParent(p)
+ self.assertFalse(shiboken.ownedByPython(obj))
+
+ def testDump(self):
+ """Just check if dump doesn't crash on certain use cases"""
+ p = ObjectType()
+ obj = ObjectType(p)
+ obj2 = ObjectType(obj)
+ obj3 = ObjectType(obj)
+ self.assertEqual(shiboken.dump(None), "Ordinary Python type.")
+ shiboken.dump(obj)
+
+ model = ObjectModel(p)
+ v = ObjectView(model, p)
+ shiboken.dump(v)
+
+ m = MultipleInherited()
+ shiboken.dump(m)
+ self.assertEqual(len(shiboken.getCppPointer(m)), 2)
+
+ # Don't crash even after deleting an object
+ shiboken.invalidate(obj)
+ shiboken.dump(obj) # deleted
+ shiboken.dump(p) # child deleted
+ shiboken.dump(obj2) # parent deleted
+
+ def testDelete(self):
+ obj = ObjectType()
+ child = ObjectType(obj)
+ self.assertTrue(shiboken.isValid(obj))
+ self.assertTrue(shiboken.isValid(child))
+ # Note: this test doesn't assure that the object dtor was really called
+ shiboken.delete(obj)
+ self.assertFalse(shiboken.isValid(obj))
+ self.assertFalse(shiboken.isValid(child))
+
+ def testVersionAttr(self):
+ self.assertEqual(type(shiboken.__version__), str)
+ self.assertTrue(len(shiboken.__version__) >= 5)
+ self.assertEqual(type(shiboken.__version_info__), tuple)
+ self.assertEqual(len(shiboken.__version_info__), 5)
+
+ def testAllWrappers(self):
+ obj = ObjectType()
+ self.assertTrue(obj in shiboken.getAllValidWrappers())
+ shiboken.delete(obj)
+ self.assertFalse(obj in shiboken.getAllValidWrappers())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/smartbinding/CMakeLists.txt b/sources/shiboken2/tests/smartbinding/CMakeLists.txt
new file mode 100644
index 000000000..e9c52d447
--- /dev/null
+++ b/sources/shiboken2/tests/smartbinding/CMakeLists.txt
@@ -0,0 +1,39 @@
+project(smart)
+
+set(smart_TYPESYSTEM
+${CMAKE_CURRENT_SOURCE_DIR}/typesystem_smart.xml
+)
+
+set(smart_SRC
+${CMAKE_CURRENT_BINARY_DIR}/smart/smart_module_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/smart/obj_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/smart/integer_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/smart/sharedptr_obj_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/smart/sharedptr_integer_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/smart/registry_wrapper.cpp
+)
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/smart-binding.txt.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/smart-binding.txt" @ONLY)
+
+add_custom_command(OUTPUT ${smart_SRC}
+COMMAND shiboken2 --project-file=${CMAKE_CURRENT_BINARY_DIR}/smart-binding.txt ${GENERATOR_EXTRA_FLAGS}
+DEPENDS ${smart_TYPESYSTEM} ${CMAKE_CURRENT_SOURCE_DIR}/global.h shiboken2
+WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+COMMENT "Running generator for 'smart' test binding..."
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}
+ ${SBK_PYTHON_INCLUDE_DIR}
+ ${libsmart_SOURCE_DIR}
+ ${libshiboken_SOURCE_DIR})
+add_library(smart MODULE ${smart_SRC})
+set_property(TARGET smart PROPERTY PREFIX "")
+if(WIN32)
+ set_property(TARGET smart PROPERTY SUFFIX ".pyd")
+endif()
+target_link_libraries(smart
+ libsmart
+ ${SBK_PYTHON_LIBRARIES}
+ libshiboken)
diff --git a/sources/shiboken2/tests/smartbinding/global.h b/sources/shiboken2/tests/smartbinding/global.h
new file mode 100644
index 000000000..a72cd21a5
--- /dev/null
+++ b/sources/shiboken2/tests/smartbinding/global.h
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "smart.h"
diff --git a/sources/shiboken2/tests/smartbinding/smart-binding.txt.in b/sources/shiboken2/tests/smartbinding/smart-binding.txt.in
new file mode 100644
index 000000000..699f0bfe6
--- /dev/null
+++ b/sources/shiboken2/tests/smartbinding/smart-binding.txt.in
@@ -0,0 +1,15 @@
+[generator-project]
+
+generator-set = shiboken
+
+header-file = @CMAKE_CURRENT_SOURCE_DIR@/global.h
+typesystem-file = @smart_TYPESYSTEM@
+
+output-directory = @CMAKE_CURRENT_BINARY_DIR@
+
+include-path = @libsmart_SOURCE_DIR@
+
+typesystem-path = @CMAKE_CURRENT_SOURCE_DIR@
+
+enable-parent-ctor-heuristic
+use-isnull-as-nb_nonzero
diff --git a/sources/shiboken2/tests/smartbinding/smart_pointer_test.py b/sources/shiboken2/tests/smartbinding/smart_pointer_test.py
new file mode 100644
index 000000000..c8eb1b2c5
--- /dev/null
+++ b/sources/shiboken2/tests/smartbinding/smart_pointer_test.py
@@ -0,0 +1,147 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from copy import copy
+from smart import Obj, Registry, Integer
+
+def objCount():
+ return Registry.getInstance().countObjects()
+
+def integerCount():
+ return Registry.getInstance().countIntegers()
+
+class SmartPointerTests(unittest.TestCase):
+ def testObjSmartPointer(self):
+ # Uncomment to see more debug info about creation of objects and ref counts.
+ # Registry.getInstance().setShouldPrint(True)
+
+ # Create Obj.
+ o = Obj()
+ self.assertEqual(objCount(), 1)
+
+ # Create a shared pointer to an Obj together with an Obj.
+ ptrToObj = o.giveSharedPtrToObj()
+ self.assertEqual(objCount(), 2)
+
+ # Delete the old Obj.
+ o = None
+ self.assertEqual(objCount(), 1)
+
+ # Get a wrapper to the Obj inside of the shared pointer, object count should not change.
+ obj = ptrToObj.data()
+ self.assertEqual(objCount(), 1)
+ obj.m_integer = 50
+ self.assertEqual(obj.m_integer, 50)
+
+ # Set and get a member value via shared pointer (like operator->).
+ ptrToObj.m_integer = 100
+ self.assertEqual(ptrToObj.m_integer, 100)
+
+ # Get inner PyObject via shared pointer (like operator->) and set value in it.
+ ptrToObj.m_internalInteger.m_int = 200
+ self.assertEqual(ptrToObj.m_internalInteger.m_int, 200)
+
+ # Pass smart pointer as argument to a method, return value is the value of m_integer of
+ # passed Obj inside the smart pointer.
+ result = ptrToObj.takeSharedPtrToObj(ptrToObj)
+ self.assertEqual(result, 100)
+
+ # Pass an Integer as an argument that returns itself.
+ result = ptrToObj.takeInteger(ptrToObj.m_internalInteger)
+ self.assertEqual(integerCount(), 2)
+ result = None
+ self.assertEqual(integerCount(), 1)
+
+ # Make a copy of the shared pointer, object count should not change.
+ ptrToObj2 = copy(ptrToObj)
+ self.assertEqual(objCount(), 1)
+
+ # Delete the first shared pointer, object count should not change because the second
+ # one still has a reference.
+ del ptrToObj
+ self.assertEqual(objCount(), 1)
+
+ # Delete the second smart pointer, object should be deleted.
+ del ptrToObj2
+ self.assertEqual(objCount(), 0)
+ self.assertEqual(integerCount(), 0)
+
+ def testIntegerSmartPointer(self):
+ # Uncomment to see more debug info about creation of objects and ref counts.
+ # Registry.getInstance().setShouldPrint(True)
+
+ # Create Obj.
+ o = Obj()
+ self.assertEqual(objCount(), 1)
+
+ # Create a shared pointer to an Integer together with an Integer.
+ ptrToInteger = o.giveSharedPtrToInteger()
+ self.assertEqual(objCount(), 1)
+ self.assertEqual(integerCount(), 2)
+
+ # Get a wrapper to the Integer inside of the shared pointer, integer count should not
+ # change.
+ integer = ptrToInteger.data()
+ self.assertEqual(integerCount(), 2)
+ integer.m_int = 50
+ self.assertEqual(integer.m_int, 50)
+
+ # Set and get a member value via shared pointer (like operator->).
+ ptrToInteger.m_int = 100
+ self.assertEqual(ptrToInteger.m_int, 100)
+
+ # Pass smart pointer as argument to a method, return value is the value of m_int of
+ # passed Integer inside the smart pointer.
+ result = o.takeSharedPtrToInteger(ptrToInteger)
+ self.assertEqual(result, 100)
+
+ # Make a copy of the shared pointer, integer count should not change.
+ ptrToInteger2 = copy(ptrToInteger)
+ self.assertEqual(integerCount(), 2)
+
+ # Delete the first shared pointer, integer count should not change because the second
+ # one still has a reference.
+ del ptrToInteger
+ self.assertEqual(integerCount(), 2)
+
+ # Delete the second smart pointer, integer should be deleted.
+ del ptrToInteger2
+ self.assertEqual(objCount(), 1)
+ self.assertEqual(integerCount(), 1)
+
+ # Delete the original object which was used to create the integer.
+ del o
+ self.assertEqual(objCount(), 0)
+ self.assertEqual(integerCount(), 0)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken2/tests/smartbinding/typesystem_smart.xml b/sources/shiboken2/tests/smartbinding/typesystem_smart.xml
new file mode 100644
index 000000000..a2654730d
--- /dev/null
+++ b/sources/shiboken2/tests/smartbinding/typesystem_smart.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<typesystem package="smart">
+ <primitive-type name="int" />
+ <primitive-type name="char" />
+ <primitive-type name="float" />
+ <primitive-type name="bool" />
+
+ <!-- Used in tests to check what C++ objects are allocated. -->
+ <object-type name="Registry" />
+
+ <!-- Current limitation: shared pointer python objects can only be instantiated from API usage,
+ like when they are returned as a result of a method, or passed as arguments. It is not
+ possible to explicitly instantiate a new shared pointer in python e.g. o = SharedPtr_Foo()
+ won't work.
+ -->
+ <smart-pointer-type name="SharedPtr" type="shared" getter="data" ref-count-method="useCount" />
+
+ <object-type name="Obj" />
+ <value-type name="Integer" />
+
+ <!-- Just used to silence the warnings that shiboken doens't know what to do with this type -->
+ <custom-type name="RefData" />
+</typesystem>
diff --git a/sources/shiboken2/tests/sphinxtabletest.cpp b/sources/shiboken2/tests/sphinxtabletest.cpp
new file mode 100644
index 000000000..6a8ac7703
--- /dev/null
+++ b/sources/shiboken2/tests/sphinxtabletest.cpp
@@ -0,0 +1,332 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sphinxtabletest.h"
+#include "qtdocgenerator.h"
+#include <QtTest/QTest>
+#include <QDebug>
+
+QString SphinxTableTest::transformXml(const char* xml)
+{
+ return QtXmlToSphinx(m_generator, xml).result();
+}
+
+void SphinxTableTest::setUp()
+{
+ m_generator = new QtDocGenerator;
+}
+
+void SphinxTableTest::tearDown()
+{
+ delete m_generator;
+}
+
+void SphinxTableTest::testEmptyString()
+{
+ const char* xml = "";
+ QCOMPARE(transformXml(xml), QString());
+}
+
+void SphinxTableTest::testSimpleTable()
+{
+ const char* xml = "\
+<table>\
+ <header>\
+ <item>\
+ <para>Header 1</para>\
+ </item>\
+ <item>\
+ <para>Header 2</para>\
+ </item>\
+ </header>\
+ <row>\
+ <item>\
+ <para>1 1</para>\
+ </item>\
+ <item>\
+ <para>1 2</para>\
+ </item>\
+ </row>\
+ <row>\
+ <item>\
+ <para>2 1</para>\
+ </item>\
+ <item>\
+ <para>2 2</para>\
+ </item>\
+ </row>\
+</table>";
+ QCOMPARE(transformXml(xml), QString("\
+ +--------+--------+\n\
+ |Header 1|Header 2|\n\
+ +--------+--------+\n\
+ |1 1 |1 2 |\n\
+ +--------+--------+\n\
+ |2 1 |2 2 |\n\
+ +--------+--------+\n\
+\n"));
+}
+
+void SphinxTableTest::testColSpan()
+{
+ const char* xml = "\
+<table>\
+ <header>\
+ <item>\
+ <para>Header 1</para>\
+ </item>\
+ <item>\
+ <para>Header 2</para>\
+ </item>\
+ </header>\
+ <row>\
+ <item colspan=\"2\">\
+ <para>I'm a big text!</para>\
+ </item>\
+ </row>\
+ <row>\
+ <item>\
+ <para>2 1</para>\
+ </item>\
+ <item>\
+ <para>2 2</para>\
+ </item>\
+ </row>\
+</table>";
+ QCOMPARE(transformXml(xml), QString("\
+ +---------------+--------+\n\
+ |Header 1 |Header 2|\n\
+ +---------------+--------+\n\
+ |I'm a big text! |\n\
+ +---------------+--------+\n\
+ |2 1 |2 2 |\n\
+ +---------------+--------+\n\
+\n"));
+}
+
+
+void SphinxTableTest::testRowSpan()
+{
+ const char* xml = "\
+<table>\
+ <header>\
+ <item>\
+ <para>Header 1</para>\
+ </item>\
+ <item>\
+ <para>Header 2</para>\
+ </item>\
+ </header>\
+ <row>\
+ <item rowspan=\"2\">\
+ <para>1.1</para>\
+ </item>\
+ <item>\
+ <para>1.2</para>\
+ </item>\
+ </row>\
+ <row>\
+ <item>\
+ <para>2 2</para>\
+ </item>\
+ </row>\
+</table>";
+ QCOMPARE(transformXml(xml), QString("\
+ +--------+--------+\n\
+ |Header 1|Header 2|\n\
+ +--------+--------+\n\
+ |1.1 |1.2 |\n\
+ + +--------+\n\
+ | |2 2 |\n\
+ +--------+--------+\n\
+\n"));
+}
+
+
+void SphinxTableTest::testComplexTable()
+{
+ const char* xml = "\
+<table>\
+ <header>\
+ <item>\
+ <para>Header 1</para>\
+ </item>\
+ <item>\
+ <para>Header 2</para>\
+ </item>\
+ <item>\
+ <para>Header 3</para>\
+ </item>\
+ </header>\
+ <row>\
+ <item rowspan=\"2\">\
+ <para>1.1</para>\
+ </item>\
+ <item colspan=\"2\">\
+ <para>1.2</para>\
+ </item>\
+ </row>\
+ <row>\
+ <item>\
+ <para>2 2</para>\
+ </item>\
+ <item>\
+ <para>2 3</para>\
+ </item>\
+ </row>\
+</table>";
+ QCOMPARE(transformXml(xml), QString("\
+ +--------+--------+--------+\n\
+ |Header 1|Header 2|Header 3|\n\
+ +--------+--------+--------+\n\
+ |1.1 |1.2 |\n\
+ + +--------+--------+\n\
+ | |2 2 |2 3 |\n\
+ +--------+--------+--------+\n\
+\n"));
+}
+
+void SphinxTableTest::testRowSpan2()
+{
+ const char* xml = "\
+<table>\
+ <header>\
+ <item><para>h1</para></item>\
+ <item><para>h2</para></item>\
+ <item><para>h3</para></item>\
+ <item><para>h4</para></item>\
+ </header>\
+ <row>\
+ <item rowspan=\"6\"><para>A</para></item>\
+ <item rowspan=\"6\"><para>B</para></item>\
+ <item><para>C</para></item>\
+ <item><para>D</para></item>\
+ </row>\
+ <row>\
+ <item><para>E</para></item>\
+ <item><para>F</para></item>\
+ </row>\
+ <row>\
+ <item><para>E</para></item>\
+ <item><para>F</para></item>\
+ </row>\
+ <row>\
+ <item><para>E</para></item>\
+ <item><para>F</para></item>\
+ </row>\
+ <row>\
+ <item><para>E</para></item>\
+ <item><para>F</para></item>\
+ </row>\
+ <row>\
+ <item><para>E</para></item>\
+ <item><para>F</para></item>\
+ </row>\
+</table>";
+ QCOMPARE(transformXml(xml), QString("\
+ +--+--+--+--+\n\
+ |h1|h2|h3|h4|\n\
+ +--+--+--+--+\n\
+ |A |B |C |D |\n\
+ + + +--+--+\n\
+ | | |E |F |\n\
+ + + +--+--+\n\
+ | | |E |F |\n\
+ + + +--+--+\n\
+ | | |E |F |\n\
+ + + +--+--+\n\
+ | | |E |F |\n\
+ + + +--+--+\n\
+ | | |E |F |\n\
+ +--+--+--+--+\n\
+\n"));
+}
+
+void SphinxTableTest::testBrokenTable()
+{
+ const char* xml = "\
+<table>\
+ <header>\
+ <item>\
+ <para>Header 1</para>\
+ </item>\
+ <item>\
+ <para>Header 2</para>\
+ </item>\
+ </header>\
+ <row>\
+ <item>\
+ <para>1.1</para>\
+ </item>\
+ <item>\
+ <para>1.2</para>\
+ </item>\
+ </row>\
+ <row>\
+ <item colspan=\"2\">\
+ <para>2 2</para>\
+ </item>\
+ <item>\
+ <para>2 3</para>\
+ </item>\
+ <item>\
+ <para>2 4</para>\
+ </item>\
+ <item>\
+ <para>2 5</para>\
+ </item>\
+ </row>\
+ <row>\
+ <item>\
+ <para>3 1</para>\
+ </item>\
+ <item>\
+ <para>3 2</para>\
+ </item>\
+ <item>\
+ <para>3 3</para>\
+ </item>\
+ </row>\
+</table>";
+ QCOMPARE(transformXml(xml), QString("\
+ +--------+------------+\n\
+ |Header 1|Header 2 |\n\
+ +--------+------------+\n\
+ |1.1 |1.2 |\n\
+ +--------+------------+\n\
+ |2 2 2 3 2 4 2 5|\n\
+ +--------+------------+\n\
+ |3 1 |3 2 3 3 |\n\
+ +--------+------------+\n\
+\n"));
+}
+
+
+QTEST_APPLESS_MAIN( SphinxTableTest )
+
+#include "sphinxtabletest.moc"
diff --git a/sources/shiboken2/tests/sphinxtabletest.h b/sources/shiboken2/tests/sphinxtabletest.h
new file mode 100644
index 000000000..4779b75cd
--- /dev/null
+++ b/sources/shiboken2/tests/sphinxtabletest.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SPHINXTABLETEST_H
+#define SPHINXTABLETEST_H
+
+#include <QObject>
+
+class QtDocGenerator;
+class SphinxTableTest : public QObject {
+ Q_OBJECT
+
+private slots:
+ void setUp();
+ void tearDown();
+ void testEmptyString();
+ void testSimpleTable();
+ void testRowSpan();
+ void testColSpan();
+ void testComplexTable();
+ void testRowSpan2();
+ void testBrokenTable();
+private:
+ QtDocGenerator* m_generator;
+
+ QString transformXml(const char* xml);
+};
+
+#endif
diff --git a/sources/shiboken2/tests/test_generator/CMakeLists.txt b/sources/shiboken2/tests/test_generator/CMakeLists.txt
new file mode 100644
index 000000000..5f5099897
--- /dev/null
+++ b/sources/shiboken2/tests/test_generator/CMakeLists.txt
@@ -0,0 +1,68 @@
+project(test_generator)
+
+set(dummy_generator_SRC dummygenerator.cpp)
+add_library(dummy_generator SHARED ${dummy_generator_SRC})
+target_link_libraries(dummy_generator ${APIEXTRACTOR_LIBRARY} ${QT_QTCORE_LIBRARY} genrunner)
+set_property(TARGET dummy_generator PROPERTY PREFIX "")
+
+add_executable(dummygenerator main.cpp)
+set(DUMMYGENERATOR_EXECUTABLE dummygenerator${generator_SUFFIX})
+set_target_properties(dummygenerator PROPERTIES OUTPUT_NAME ${DUMMYGENERATOR_EXECUTABLE})
+target_link_libraries(dummygenerator ${Qt5Core_LIBRARIES})
+
+configure_file(dummygentestconfig.h.in "${CMAKE_CURRENT_BINARY_DIR}/dummygentestconfig.h" @ONLY)
+
+get_filename_component(APIEXTRACTOR_LIBRARY_DIRS ${APIEXTRACTOR_LIBRARY} PATH)
+if(WIN32)
+ set(PATH_SEP ";")
+ find_program(APIEXTRACTOR_BINARY apiextractor.dll HINTS ${APIEXTRACTOR_LIBRARY_DIRS})
+ get_filename_component(APIEXTRACTOR_BINARY_DIR ${APIEXTRACTOR_BINARY} PATH)
+ set(APIEXTRACTOR_LIBRARY_DIRS "${APIEXTRACTOR_LIBRARY_DIRS}${PATH_SEP}${APIEXTRACTOR_BINARY_DIR}")
+else()
+ set(PATH_SEP ":")
+endif()
+
+set(ENV_PATH "${generatorrunner_BINARY_DIR}${PATH_SEP}${CMAKE_CURRENT_BINARY_DIR}${PATH_SEP}$ENV{PATH}${PATH_SEP}${APIEXTRACTOR_LIBRARY_DIRS}")
+set(ENV_QT_PLUGIN_PATH "${CMAKE_CURRENT_BINARY_DIR}${PATH_SEP}$ENV{QT_PLUGIN_PATH}")
+if(WIN32)
+ string(REPLACE "\\;" ";" ENV_PATH "${ENV_PATH}")
+ string(REPLACE ";" "\\;" ENV_PATH "${ENV_PATH}")
+ string(REPLACE "\\;" ";" ENV_QT_PLUGIN_PATH "${ENV_QT_PLUGIN_PATH}")
+ string(REPLACE ";" "\\;" ENV_QT_PLUGIN_PATH "${ENV_QT_PLUGIN_PATH}")
+endif()
+
+macro(m_add_test testname)
+ if(CMAKE_VERSION VERSION_LESS 2.8)
+ add_test(${testname} ${CMAKE_COMMAND} -DTEST=${testname}
+ -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}
+ -DENV_PATH=${ENV_PATH} -DENV_QT_PLUGIN_PATH=${ENV_QT_PLUGIN_PATH}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/run_test.cmake)
+ else()
+ add_test(${testname} ${testname})
+ set_property(TEST ${testname} PROPERTY ENVIRONMENT "PATH=${ENV_PATH}" "QT_PLUGIN_PATH=${ENV_QT_PLUGIN_PATH}")
+ endif()
+endmacro()
+
+macro(declare_test testname)
+ qt4_automoc("${testname}.cpp")
+ add_executable(${testname} "${testname}.cpp")
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+ target_link_libraries(${testname}
+ ${QT_QTTEST_LIBRARY}
+ ${QT_QTCORE_LIBRARY}
+ ${Qt5Test_LIBRARIES}
+ ${Qt5Core_LIBRARIES}
+ )
+ m_add_test(${testname})
+endmacro(declare_test testname)
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/test_global.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/test_global.h" COPYONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/test_typesystem.xml"
+ "${CMAKE_CURRENT_BINARY_DIR}/test_typesystem.xml" COPYONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/dummygentest-project.txt.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/dummygentest-project.txt" @ONLY)
+declare_test(dummygentest)
+
+add_dependencies(dummygenerator generatorrunner)
+
diff --git a/sources/shiboken2/tests/test_generator/dummygenerator.cpp b/sources/shiboken2/tests/test_generator/dummygenerator.cpp
new file mode 100644
index 000000000..51d2b33da
--- /dev/null
+++ b/sources/shiboken2/tests/test_generator/dummygenerator.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <iostream>
+#include "dummygenerator.h"
+
+EXPORT_GENERATOR_PLUGIN(new DummyGenerator)
+
+using namespace std;
+
+QString
+DummyGenerator::fileNameForClass(const AbstractMetaClass* metaClass) const
+{
+ return QString("%1_generated.txt").arg(metaClass->name().toLower());
+}
+
+void
+DummyGenerator::generateClass(QTextStream& s, const AbstractMetaClass* metaClass)
+{
+ s << "// Generated code for class: " << qPrintable(metaClass->name()) << endl;
+}
+
+bool
+DummyGenerator::doSetup(const QMap<QString, QString>& args)
+{
+ if (args.contains("dump-arguments") && !args["dump-arguments"].isEmpty()) {
+ QFile logFile(args["dump-arguments"]);
+ logFile.open(QIODevice::WriteOnly | QIODevice::Text);
+ QTextStream out(&logFile);
+ foreach (const QString& key, args.keys()) {
+ if (key == "arg-1")
+ out << "header-file";
+ else if (key == "arg-2")
+ out << "typesystem-file";
+ else
+ out << key;
+ if (!args[key].isEmpty())
+ out << " = " << args[key];
+ out << endl;
+ }
+ }
+ return true;
+}
+
diff --git a/sources/shiboken2/tests/test_generator/dummygenerator.h b/sources/shiboken2/tests/test_generator/dummygenerator.h
new file mode 100644
index 000000000..5ab95a925
--- /dev/null
+++ b/sources/shiboken2/tests/test_generator/dummygenerator.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef DUMMYGENERATOR_H
+#define DUMMYGENERATOR_H
+
+#include "generator.h"
+
+class GENRUNNER_API DummyGenerator : public Generator
+{
+public:
+ DummyGenerator() {}
+ ~DummyGenerator() {}
+ bool doSetup(const QMap<QString, QString>& args);
+ const char* name() const { return "DummyGenerator"; }
+
+protected:
+ void writeFunctionArguments(QTextStream&, const AbstractMetaFunction*, Options) const {}
+ void writeArgumentNames(QTextStream&, const AbstractMetaFunction*, Options) const {}
+ QString fileNameForClass(const AbstractMetaClass* metaClass) const;
+ void generateClass(QTextStream& s, const AbstractMetaClass* metaClass);
+ void finishGeneration() {}
+};
+
+#endif // DUMMYGENERATOR_H
diff --git a/sources/shiboken2/tests/test_generator/dummygentest-project.txt.in b/sources/shiboken2/tests/test_generator/dummygentest-project.txt.in
new file mode 100644
index 000000000..0a076d8bd
--- /dev/null
+++ b/sources/shiboken2/tests/test_generator/dummygentest-project.txt.in
@@ -0,0 +1,20 @@
+[generator-project]
+
+generator-set = dummy
+header-file = @CMAKE_CURRENT_BINARY_DIR@/test_global.h
+typesystem-file = @CMAKE_CURRENT_BINARY_DIR@/test_typesystem.xml
+output-directory = /tmp/output
+
+dump-arguments = @CMAKE_CURRENT_BINARY_DIR@/dummygen-args.log
+
+include-path = /include/path/location1
+include-path = /include/path/location2
+
+typesystem-path = /typesystem/path/location1
+typesystem-path = /typesystem/path/location2
+
+api-version = 1.2.3
+debug = sparse
+
+no-suppress-warnings
+
diff --git a/sources/shiboken2/tests/test_generator/dummygentest.cpp b/sources/shiboken2/tests/test_generator/dummygentest.cpp
new file mode 100644
index 000000000..ae028e2c8
--- /dev/null
+++ b/sources/shiboken2/tests/test_generator/dummygentest.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "dummygentest.h"
+#include "dummygenerator.h"
+#include "dummygentestconfig.h"
+#include <QTemporaryFile>
+#include <QtTest/QTest>
+#include <QProcess>
+
+#define GENERATED_CONTENTS "// Generated code for class: Dummy"
+
+void DummyGenTest::initTestCase()
+{
+ int argc = 0;
+ char* argv[] = {NULL};
+ QCoreApplication app(argc, argv);
+ workDir = QDir::currentPath();
+
+ headerFilePath = workDir + "/test_global.h";
+ typesystemFilePath = workDir + "/test_typesystem.xml";
+ projectFilePath = workDir + "/dummygentest-project.txt";
+ generatedFilePath = QString("%1/dummy/dummy_generated.txt").arg(QDir::tempPath());
+}
+
+void DummyGenTest::testCallGenRunnerWithFullPathToDummyGenModule()
+{
+ QStringList args;
+ args.append("--generator-set=" DUMMYGENERATOR_BINARY_DIR "/dummy_generator" MODULE_EXTENSION);
+ args.append(QString("--output-directory=%1").arg(QDir::tempPath()));
+ args.append(headerFilePath);
+ args.append(typesystemFilePath);
+ int result = QProcess::execute("generatorrunner", args);
+ QCOMPARE(result, 0);
+
+ QFile generatedFile(generatedFilePath);
+ generatedFile.open(QIODevice::ReadOnly);
+ QCOMPARE(generatedFile.readAll().trimmed(), QByteArray(GENERATED_CONTENTS).trimmed());
+ generatedFile.close();
+
+ QVERIFY(generatedFile.remove());
+}
+
+void DummyGenTest::testCallGenRunnerWithNameOfDummyGenModule()
+{
+ QStringList args;
+ args.append("--generator-set=dummy");
+ args.append(QString("--output-directory=%1").arg(QDir::tempPath()));
+ args.append(headerFilePath);
+ args.append(typesystemFilePath);
+ int result = QProcess::execute("generatorrunner", args);
+ QCOMPARE(result, 0);
+
+ QFile generatedFile(generatedFilePath);
+ generatedFile.open(QIODevice::ReadOnly);
+ QCOMPARE(generatedFile.readAll().trimmed(), QByteArray(GENERATED_CONTENTS).trimmed());
+ generatedFile.close();
+
+ QVERIFY(generatedFile.remove());
+}
+
+void DummyGenTest::testCallDummyGeneratorExecutable()
+{
+ QStringList args;
+ args.append(QString("--output-directory=%1").arg(QDir::tempPath()));
+ args.append(headerFilePath);
+ args.append(typesystemFilePath);
+ int result = QProcess::execute(DUMMYGENERATOR_BINARY, args);
+ QCOMPARE(result, 0);
+
+ QFile generatedFile(generatedFilePath);
+ generatedFile.open(QIODevice::ReadOnly);
+ QCOMPARE(generatedFile.readAll().trimmed(), QByteArray(GENERATED_CONTENTS).trimmed());
+ generatedFile.close();
+
+ QVERIFY(generatedFile.remove());
+}
+
+void DummyGenTest::testProjectFileArgumentsReading()
+{
+ QStringList args(QString("--project-file=%1/dummygentest-project.txt").arg(workDir));
+ int result = QProcess::execute("generatorrunner", args);
+ QCOMPARE(result, 0);
+
+ QFile logFile(workDir + "/dummygen-args.log");
+ logFile.open(QIODevice::ReadOnly);
+ QStringList logContents;
+ while (!logFile.atEnd())
+ logContents << logFile.readLine().trimmed();
+ logContents.sort();
+ QCOMPARE(logContents[0], QString("api-version = 1.2.3"));
+ QCOMPARE(logContents[1], QString("debug = sparse"));
+ QVERIFY(logContents[2].startsWith("dump-arguments = "));
+ QVERIFY(logContents[2].endsWith("dummygen-args.log"));
+ QCOMPARE(logContents[3], QString("generator-set = dummy"));
+ QVERIFY(logContents[4].startsWith("header-file = "));
+ QVERIFY(logContents[4].endsWith("test_global.h"));
+ QCOMPARE(logContents[5],
+ QDir::toNativeSeparators(QString("include-paths = /include/path/location1%1/include/path/location2").arg(PATH_SPLITTER)));
+ QCOMPARE(logContents[6], QString("no-suppress-warnings"));
+ QCOMPARE(logContents[7], QString("output-directory = /tmp/output"));
+ QVERIFY(logContents[8].startsWith("project-file = "));
+ QVERIFY(logContents[8].endsWith("dummygentest-project.txt"));
+ QVERIFY(logContents[9].startsWith("typesystem-file = "));
+ QVERIFY(logContents[9].endsWith("test_typesystem.xml"));
+ QCOMPARE(logContents[10],
+ QDir::toNativeSeparators(QString("typesystem-paths = /typesystem/path/location1%1/typesystem/path/location2").arg(PATH_SPLITTER)));
+}
+
+QTEST_APPLESS_MAIN(DummyGenTest)
+
+#include "dummygentest.moc"
+
diff --git a/sources/shiboken2/tests/test_generator/dummygentest.h b/sources/shiboken2/tests/test_generator/dummygentest.h
new file mode 100644
index 000000000..be8ca42af
--- /dev/null
+++ b/sources/shiboken2/tests/test_generator/dummygentest.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DUMMYGENTABLETEST_H
+#define DUMMYGENTABLETEST_H
+
+#include <QObject>
+
+class DummyGenerator;
+
+class DummyGenTest : public QObject
+{
+ Q_OBJECT
+
+private:
+ QString workDir;
+ QString headerFilePath;
+ QString typesystemFilePath;
+ QString generatedFilePath;
+ QString projectFilePath;
+
+private slots:
+ void initTestCase();
+ void testCallGenRunnerWithFullPathToDummyGenModule();
+ void testCallGenRunnerWithNameOfDummyGenModule();
+ void testCallDummyGeneratorExecutable();
+ void testProjectFileArgumentsReading();
+};
+
+#endif
+
diff --git a/sources/shiboken2/tests/test_generator/dummygentestconfig.h.in b/sources/shiboken2/tests/test_generator/dummygentestconfig.h.in
new file mode 100644
index 000000000..9da17dcd3
--- /dev/null
+++ b/sources/shiboken2/tests/test_generator/dummygentestconfig.h.in
@@ -0,0 +1,15 @@
+#ifndef DUMMYGENTESTCONFIG_H
+#define DUMMYGENTESTCONFIG_H
+
+#define MODULE_EXTENSION "@CMAKE_SHARED_LIBRARY_SUFFIX@"
+#define DUMMYGENERATOR_BINARY "@DUMMYGENERATOR_EXECUTABLE@"
+#define DUMMYGENERATOR_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@"
+
+#ifdef _WINDOWS
+ #define PATH_SPLITTER ";"
+#else
+ #define PATH_SPLITTER ":"
+#endif
+
+#endif // DUMMYGENTESTCONFIG_H
+
diff --git a/sources/shiboken2/tests/test_generator/main.cpp b/sources/shiboken2/tests/test_generator/main.cpp
new file mode 100644
index 000000000..5c46ea006
--- /dev/null
+++ b/sources/shiboken2/tests/test_generator/main.cpp
@@ -0,0 +1,39 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of PySide2.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore>
+
+int main(int argc, char *argv[])
+{
+ QStringList args;
+ args.append("--generator-set=dummy");
+ for (int i = 1; i < argc; i++)
+ args.append(argv[i]);
+ return QProcess::execute("generatorrunner", args);
+}
+
diff --git a/sources/shiboken2/tests/test_generator/run_test.cmake b/sources/shiboken2/tests/test_generator/run_test.cmake
new file mode 100644
index 000000000..34a821d80
--- /dev/null
+++ b/sources/shiboken2/tests/test_generator/run_test.cmake
@@ -0,0 +1,11 @@
+# The tests are run through this script due to a limitation
+# on versions of CMake lesser than 2.8, that prevent setting
+# environment variables for tests from working.
+
+set(ENV{PATH} "${ENV_PATH}")
+set(ENV{QT_PLUGIN_PATH} "${ENV_QT_PLUGIN_PATH}")
+execute_process(COMMAND ${TEST} WORKING_DIRECTORY "${WORKDIR}" RESULT_VARIABLE OK)
+
+if(NOT OK EQUAL 0)
+ message(SEND_ERROR "${TEST} failed!")
+endif()
diff --git a/sources/shiboken2/tests/test_generator/test_global.h b/sources/shiboken2/tests/test_generator/test_global.h
new file mode 100644
index 000000000..6a95200cf
--- /dev/null
+++ b/sources/shiboken2/tests/test_generator/test_global.h
@@ -0,0 +1 @@
+struct Dummy {};
diff --git a/sources/shiboken2/tests/test_generator/test_typesystem.xml b/sources/shiboken2/tests/test_generator/test_typesystem.xml
new file mode 100644
index 000000000..c19a4e95e
--- /dev/null
+++ b/sources/shiboken2/tests/test_generator/test_typesystem.xml
@@ -0,0 +1,3 @@
+<typesystem package='dummy'>
+ <value-type name='Dummy'/>
+</typesystem>