aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/PySide2')
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_common.xml75
-rw-r--r--sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml11
-rw-r--r--sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml12
-rw-r--r--sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml27
-rw-r--r--sources/pyside2/PySide2/glue/qtcore.cpp47
-rw-r--r--sources/pyside2/PySide2/templates/gui_common.xml21
-rw-r--r--sources/pyside2/PySide2/templates/webkitwidgets_common.xml18
-rw-r--r--sources/pyside2/PySide2/templates/widgets_common.xml37
8 files changed, 143 insertions, 105 deletions
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
index 25f5c3e65..c70049d8e 100644
--- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
+++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
@@ -670,30 +670,7 @@
<inject-code class="target" position="end" file="../glue/qtcore.cpp" snippet="qt-version"/>
<!-- WARNING: There is an issue when adding this code to an external file -->
- <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.reset(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>
-
+ <inject-code class="target" position="end" file="../glue/qtcore.cpp" snippet="qt-module-shutdown"/>
<add-function signature="__moduleShutdown()">
<inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="moduleshutdown"/>
</add-function>
@@ -2224,56 +2201,24 @@
</inject-code>
</modify-function>
<modify-function signature="readData(char*,qint64)">
- <!-- placing this injected code in the snippet files breaks the
- propagation of this method to the QAbstractSocket and QLocalSocket
- classes -->
- <inject-code class="target">
- QByteArray ba(1 + int(%2), char(0));
- %CPPSELF.%FUNCTION_NAME(ba.data(), int(%2));
- %PYARG_0 = Shiboken::String::fromCString(ba.constData());
- </inject-code>
+ <inject-code class="target" file="../glue/qtcore.cpp" snippet="qiodevice-readData"/>
<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>
+ <inject-code class="native" position="end" file="../glue/qtcore.cpp" snippet="return-readData"/>
</modify-function>
<modify-function signature="readLineData(char*,qint64)">
- <!-- placing this injected code in the snippet files breaks the
- propagation of this method to the QAbstractSocket and QLocalSocket
- classes -->
- <inject-code class="target">
- QByteArray ba(1 + int(%2), char(0));
- %CPPSELF.%FUNCTION_NAME(ba.data(), int(%2));
- %PYARG_0 = Shiboken::String::fromCString(ba.constData());
- </inject-code>
+ <inject-code class="target" file="../glue/qtcore.cpp" snippet="qiodevice-readData"/>
<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>
+ <inject-code class="native" position="end" file="../glue/qtcore.cpp" snippet="return-readData"/>
</modify-function>
</object-type>
<object-type name="QCryptographicHash">
@@ -2768,13 +2713,7 @@
<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>
+ <inject-code class="target" position="end" file="../glue/qtcore.cpp" snippet="return-qstring-ref"/>
</modify-function>
<modify-function signature="flush()" allow-thread="yes"/>
@@ -2804,7 +2743,7 @@
</modify-function>
<modify-function signature="globalInstance()" >
- <inject-code position="end" file="../glue/qtcore.cpp" snippet="releaseownership"/>
+ <inject-code class="target" position="end" file="../glue/qtcore.cpp" snippet="releaseownership"/>
</modify-function>
</object-type>
<value-type name="QXmlStreamAttribute"/>
diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
index d7bdf0412..16bce9d30 100644
--- a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
+++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
@@ -412,17 +412,16 @@
<modify-argument index="1">
<replace-type modified-type="PyBuffer"/>
<conversion-rule class="target">
- PyObject *%out = Shiboken::Buffer::newObject(%in, size);
+ <insert-template name="const_char_pybuffer"/>
</conversion-rule>
<conversion-rule class="native">
- Py_ssize_t bufferLen;
- char *%out = reinterpret_cast&lt;char*&gt;(Shiboken::Buffer::getPointer(%PYARG_1, &amp;bufferLen));
+ <insert-template name="pybuffer_const_char"/>
</conversion-rule>
</modify-argument>
<modify-argument index="2">
<remove-argument/>
<conversion-rule class="native">
- uint %out = bufferLen;
+ <insert-template name="uint_remove"/>
</conversion-rule>
</modify-argument>
</modify-function>
@@ -584,13 +583,13 @@
<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));
+ <insert-template name="pybytes_const_uchar"/>
</conversion-rule>
</modify-argument>
<modify-argument index="2">
<remove-argument/>
<conversion-rule class="native">
- uint %out = static_cast&lt;uint>(PyBytes_Size(%PYARG_1));
+ <insert-template name="pybytes_uint"/>
</conversion-rule>
</modify-argument>
</modify-function>
diff --git a/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml b/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml
index 27a4835e2..dfabff81d 100644
--- a/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml
+++ b/sources/pyside2/PySide2/QtWebKitWidgets/typesystem_webkitwidgets.xml
@@ -185,22 +185,16 @@
<modify-argument index="4">
<remove-argument />
<conversion-rule class="native">
- QString _local;
- QString* %4 = &amp;_local;
+ <insert-template name="qstring_remove"/>
</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);
+ <insert-template name="pysequence_qstring"/>
</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));
+ <insert-template name="qstring_pytuple"/>
</conversion-rule>
</modify-argument>
</modify-function>
diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
index 13cc6f7cf..dba6c268d 100644
--- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
+++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
@@ -1479,46 +1479,29 @@
<modify-argument index="2">
<remove-argument/>
<conversion-rule class="native">
- int %out = PySequence_Size(%PYARG_1);
+ <insert-template name="pysequencesize_int"/>
</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));
- }
+ <insert-template name="qgraphicsitem_pysequence"/>
</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();
+ <insert-template name="qgraphicsitem_pyobject"/>
</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();
+ <insert-template name="qstyleoptiongraphicsitem_pyobject"/>
</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));
- }
+ <insert-template name="pysequence_qstyleoptiongraphicsitem"/>
</conversion-rule>
</modify-argument>
</modify-function>
diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp
index 47895bdda..4c77e9e87 100644
--- a/sources/pyside2/PySide2/glue/qtcore.cpp
+++ b/sources/pyside2/PySide2/glue/qtcore.cpp
@@ -1493,6 +1493,53 @@ QT_END_NAMESPACE
%PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](_cpp_result);
// @snippet stream-read-method
+// @snippet return-qstring-ref
+QString &res = *%0;
+%PYARG_0 = %CONVERTTOPYTHON[QString](res);
+// @snippet return-qstring-ref
+
+// @snippet return-readData
+%RETURN_TYPE %0 = 0;
+if (PyBytes_Check(%PYARG_0)) {
+ %0 = PyBytes_GET_SIZE((PyObject*)%PYARG_0);
+ memcpy(%1, PyBytes_AS_STRING((PyObject*)%PYARG_0), %0);
+} else if (Shiboken::String::check(%PYARG_0)) {
+ %0 = Shiboken::String::len((PyObject*)%PYARG_0);
+ memcpy(%1, Shiboken::String::toCString((PyObject*)%PYARG_0), %0);
+}
+// @snippet return-readData
+
+// @snippet qiodevice-readData
+QByteArray ba(1 + int(%2), char(0));
+%CPPSELF.%FUNCTION_NAME(ba.data(), int(%2));
+%PYARG_0 = Shiboken::String::fromCString(ba.constData());
+// @snippet qiodevice-readData
+
+// @snippet qt-module-shutdown
+{ // Avoid name clash
+ Shiboken::AutoDecRef regFunc((PyObject*)NULL);
+ Shiboken::AutoDecRef atexit(Shiboken::Module::import("atexit"));
+ if (atexit.isNull()) {
+ qWarning("Module atexit not found for registering __moduleShutdown");
+ PyErr_Clear();
+ }else{
+ regFunc.reset(PyObject_GetAttrString(atexit, "register"));
+ if (regFunc.isNull()) {
+ qWarning("Function atexit.register not found for registering __moduleShutdown");
+ PyErr_Clear();
+ }
+ }
+ if (!atexit.isNull() && !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());
+ }
+}
+// @snippet qt-module-shutdown
+
+
/*********************************************************************
* CONVERSIONS
********************************************************************/
diff --git a/sources/pyside2/PySide2/templates/gui_common.xml b/sources/pyside2/PySide2/templates/gui_common.xml
index 227d0a460..d25d50014 100644
--- a/sources/pyside2/PySide2/templates/gui_common.xml
+++ b/sources/pyside2/PySide2/templates/gui_common.xml
@@ -287,5 +287,26 @@
%PYARG_0 = %CONVERTTOPYTHON[%CPPSELF_TYPE](_tmp);
</template>
+ <template name="const_char_pybuffer">
+ PyObject *%out = Shiboken::Buffer::newObject(%in, size);
+ </template>
+
+ <template name="pybuffer_const_char">
+ Py_ssize_t bufferLen;
+ char *%out = reinterpret_cast&lt;char*&gt;(Shiboken::Buffer::getPointer(%PYARG_1, &amp;bufferLen));
+ </template>
+
+ <template name="uint_remove">
+ uint %out = bufferLen;
+ </template>
+
+ <template name="pybytes_const_uchar">
+ const uchar *%out = reinterpret_cast&lt;const uchar*>(PyBytes_AS_STRING(%PYARG_1));
+ </template>
+
+ <template name="pybytes_uint">
+ uint %out = static_cast&lt;uint>(PyBytes_Size(%PYARG_1));
+ </template>
+
</typesystem>
diff --git a/sources/pyside2/PySide2/templates/webkitwidgets_common.xml b/sources/pyside2/PySide2/templates/webkitwidgets_common.xml
index fa70c8de7..43e560c5f 100644
--- a/sources/pyside2/PySide2/templates/webkitwidgets_common.xml
+++ b/sources/pyside2/PySide2/templates/webkitwidgets_common.xml
@@ -52,4 +52,22 @@
}
</template>
+ <template name="qstring_remove">
+ QString _local;
+ QString* %4 = &amp;_local;
+ </template>
+
+ <template name="pysequence_qstring">
+ 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);
+ </template>
+
+ <template name="qstring_pytuple">
+ %PYARG_0 = PyTuple_New(2);
+ PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0));
+ PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QString](*%4));
+ </template>
+
</typesystem>
diff --git a/sources/pyside2/PySide2/templates/widgets_common.xml b/sources/pyside2/PySide2/templates/widgets_common.xml
index b68739533..e63785bb2 100644
--- a/sources/pyside2/PySide2/templates/widgets_common.xml
+++ b/sources/pyside2/PySide2/templates/widgets_common.xml
@@ -51,4 +51,41 @@
Shiboken::Object::setParent(%PYSELF, $PYARG);
</template>
+ <template name="qgraphicsitem_pysequence">
+ 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));
+ }
+ </template>
+
+ <template name="qgraphicsitem_pyobject">
+ 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();
+ </template>
+
+ <template name="qstyleoptiongraphicsitem_pyobject">
+ 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();
+ </template>
+
+ <template name="pysequence_qstyleoptiongraphicsitem">
+ 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));
+ }
+ </template>
+
+ <template name="pysequencesize_int">
+ int %out = PySequence_Size(%PYARG_1);
+ </template>
+
</typesystem>