aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/PySide2')
-rw-r--r--sources/pyside2/PySide2/QtCharts/typesystem_charts.xml3
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_common.xml6
-rw-r--r--sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml11
-rw-r--r--sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml.in1
-rw-r--r--sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml1
-rw-r--r--sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp19
-rw-r--r--sources/pyside2/PySide2/glue/qtcore.cpp48
-rw-r--r--sources/pyside2/PySide2/glue/qtmultimedia.cpp7
-rw-r--r--sources/pyside2/PySide2/support/generate_pyi.py76
9 files changed, 125 insertions, 47 deletions
diff --git a/sources/pyside2/PySide2/QtCharts/typesystem_charts.xml b/sources/pyside2/PySide2/QtCharts/typesystem_charts.xml
index b8550ef2c..a14177586 100644
--- a/sources/pyside2/PySide2/QtCharts/typesystem_charts.xml
+++ b/sources/pyside2/PySide2/QtCharts/typesystem_charts.xml
@@ -41,6 +41,9 @@
-->
<typesystem package="PySide2.QtCharts">
<load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no"/>
+ <!-- PYSIDE-1101 Removing inherited method to avoid argument conflict
+ on the QChart::scroll overload -->
+ <rejection class="QGraphicsItem" function-name="scroll"/>
<namespace-type name="QtCharts">
<object-type name="QAbstractAxis" since="5.7">
<enum-type name="AxisType"/>
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
index 9ffc7d376..92a4f41c4 100644
--- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
+++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
@@ -2544,12 +2544,6 @@
<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"/>
diff --git a/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml
index f7ac67857..3667b2c55 100644
--- a/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml
+++ b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml
@@ -82,10 +82,19 @@
<object-type name="QAbstractVideoSurface">
<enum-type name="Error"/>
</object-type>
- <object-type name="QAbstractVideoFilter"/>
+ <object-type name="QAbstractVideoFilter">
+ <modify-function signature="createFilterRunnable()">
+ <modify-argument index="return">
+ <define-ownership class="native" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
<value-type name="QVideoFrame">
<enum-type name="FieldType"/>
<enum-type name="PixelFormat"/>
+ <modify-function signature="bits()">
+ <inject-code file="../glue/qtmultimedia.cpp" snippet="qvideoframe-bits"/>
+ </modify-function>
<modify-function signature="bits(int)" remove="all"/>
<modify-function signature="bits(int)const" remove="all"/>
</value-type>
diff --git a/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml.in b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml.in
index 7949b2daa..ff078d19a 100644
--- a/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml.in
+++ b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml.in
@@ -40,7 +40,6 @@
****************************************************************************/
-->
<typesystem package="PySide2.QtPrintSupport">
- <load-typesystem name="QtGui/typesystem_gui.xml" generate="no"/>
<load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no"/>
<load-typesystem name="QtPrintSupport/typesystem_printsupport_common.xml" generate="yes"/>
</typesystem>
diff --git a/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml
index c11a6e046..487103875 100644
--- a/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml
+++ b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml
@@ -40,6 +40,7 @@
****************************************************************************/
-->
<typesystem package="PySide2.QtPrintSupport">
+ <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no"/>
<object-type name="QPageSetupDialog">
<modify-function signature="exec()" rename="exec_" allow-thread="yes"/>
diff --git a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp
index 2386620ca..6427e5198 100644
--- a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp
+++ b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp
@@ -41,6 +41,7 @@
// shiboken
#include <shiboken.h>
+#include <signature.h>
// pyside
#include <pyside.h>
@@ -215,13 +216,13 @@ static int propListTpInit(PyObject *self, PyObject *args, PyObject *kwds)
&data->at,
&data->clear,
&data->count)) {
- return 0;
+ return -1;
}
PySide::Property::setMetaCallHandler(pySelf, &propListMetaCall);
PySide::Property::setTypeName(pySelf, "QQmlListProperty<QObject>");
PySide::Property::setUserData(pySelf, data);
- return 1;
+ return 0;
}
void propListTpFree(void *self)
@@ -469,12 +470,22 @@ PyTypeObject *QtQml_VolatileBoolTypeF(void)
return type;
}
+static const char *PropertyList_SignatureStrings[] = {
+ "PySide2.QtQml.ListProperty(type:type,append:typing.Callable,"
+ "at:typing.Callable=None,clear:typing.Callable=None,count:typing.Callable=None)",
+ nullptr}; // Sentinel
+
+static const char *VolatileBool_SignatureStrings[] = {
+ "PySide2.QtQml.VolatileBool.get()->bool",
+ "PySide2.QtQml.VolatileBool.set(a:object)",
+ nullptr}; // Sentinel
+
void PySide::initQmlSupport(PyObject *module)
{
ElementFactory<PYSIDE_MAX_QML_TYPES - 1>::init();
// Export QmlListProperty type
- if (PyType_Ready(PropertyListTypeF()) < 0) {
+ if (SbkSpecial_Type_Ready(module, PropertyListTypeF(), PropertyList_SignatureStrings) < 0) {
PyErr_Print();
qWarning() << "Error initializing PropertyList type.";
return;
@@ -484,7 +495,7 @@ void PySide::initQmlSupport(PyObject *module)
PyModule_AddObject(module, PepType_GetNameStr(PropertyListTypeF()),
reinterpret_cast<PyObject *>(PropertyListTypeF()));
- if (PyType_Ready(QtQml_VolatileBoolTypeF()) < 0) {
+ if (SbkSpecial_Type_Ready(module, QtQml_VolatileBoolTypeF(), VolatileBool_SignatureStrings) < 0) {
PyErr_Print();
qWarning() << "Error initializing VolatileBool type.";
return;
diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp
index 3e1bab97b..a218e433f 100644
--- a/sources/pyside2/PySide2/glue/qtcore.cpp
+++ b/sources/pyside2/PySide2/glue/qtcore.cpp
@@ -57,24 +57,39 @@ bool py2kStrCheck(PyObject *obj)
// @snippet pystring-check
// @snippet qsettings-value
-QVariant out = %CPPSELF.value(%1, %2);
+// If we enter the kwds, means that we have a defaultValue or
+// at least a type.
+// This avoids that we are passing '0' as defaultValue.
+// defaultValue can also be passed as positional argument,
+// not only as keyword.
+QVariant out;
+if (kwds || numArgs > 1)
+ out = %CPPSELF.value(%1, %2);
+else
+ out = %CPPSELF.value(%1);
+
PyTypeObject *typeObj = reinterpret_cast<PyTypeObject*>(%PYARG_3);
if (typeObj) {
if (typeObj == &PyList_Type) {
- QByteArrayList valuesList = out.toByteArray().split(',');
- const int valuesSize = valuesList.size();
- if (valuesSize > 0) {
- PyObject *list = PyList_New(valuesSize);
- for (int i = 0; i < valuesSize; i++) {
- PyObject *item = PyUnicode_FromString(valuesList[i].data());
- PyList_SET_ITEM(list, i, item);
- Py_DECREF(item);
- }
- %PYARG_0 = list;
+ QByteArray out_ba = out.toByteArray();
+ if (!out_ba.isEmpty()) {
+ QByteArrayList valuesList = out_ba.split(',');
+ const int valuesSize = valuesList.size();
+ if (valuesSize > 0) {
+ PyObject *list = PyList_New(valuesSize);
+ for (int i = 0; i < valuesSize; i++) {
+ PyObject *item = PyUnicode_FromString(valuesList[i].data());
+ PyList_SET_ITEM(list, i, item);
+ Py_DECREF(item);
+ }
+ %PYARG_0 = list;
+ } else {
+ %PYARG_0 = %CONVERTTOPYTHON[QVariant](out);
+ }
} else {
- %PYARG_0 = %CONVERTTOPYTHON[QVariant](out);
+ %PYARG_0 = PyList_New(0);
}
} else if (typeObj == &PyBytes_Type) {
QByteArray asByteArray = out.toByteArray();
@@ -94,11 +109,13 @@ if (typeObj) {
} else if (typeObj == &PyFloat_Type) {
float asFloat = out.toFloat();
%PYARG_0 = PyFloat_FromDouble(asFloat);
+ } else if (typeObj == &PyBool_Type) {
+ %PYARG_0 = out.toBool() ? Py_True : Py_False;
}
// TODO: PyDict_Type and PyTuple_Type
}
else {
- if (out == 0)
+ if (!out.isValid())
%PYARG_0 = Py_None;
else
%PYARG_0 = %CONVERTTOPYTHON[QVariant](out);
@@ -1289,7 +1306,7 @@ Shiboken::AutoDecRef emptyTuple(PyTuple_New(0));
PyObject *pyTimer = reinterpret_cast<PyTypeObject *>(Shiboken::SbkType<QTimer>())->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0);
reinterpret_cast<PyTypeObject *>(Shiboken::SbkType<QTimer>())->tp_init(pyTimer, emptyTuple, 0);
-QTimer * timer = %CONVERTTOCPP[QTimer *](pyTimer);
+auto timer = %CONVERTTOCPP[QTimer *](pyTimer);
//XXX /|\ omitting this space crashes shiboken!
Shiboken::AutoDecRef result(
PyObject_CallMethod(pyTimer,
@@ -1484,8 +1501,7 @@ if (PySide::SignalManager::registerMetaMethod(%1, signalName.mid(1).toLatin1().d
if (!PyObject_TypeCheck(%1, PySideSignalInstanceTypeF()))
goto Sbk_%TYPEFunc_%FUNCTION_NAME_TypeError;
PySideSignalInstance *signalInstance = reinterpret_cast<PySideSignalInstance *>(%1);
-QObject * sender = %CONVERTTOCPP[QObject *](PySide::Signal::getObject(signalInstance));
-//XXX /|\ omitting this space crashes shiboken!
+auto sender = %CONVERTTOCPP[QObject *](PySide::Signal::getObject(signalInstance));
QSignalTransition *%0 = %CPPSELF->%FUNCTION_NAME(sender, PySide::Signal::getSignature(signalInstance),%2);
%PYARG_0 = %CONVERTTOPYTHON[QSignalTransition *](%0);
// @snippet qstate-addtransition-2
diff --git a/sources/pyside2/PySide2/glue/qtmultimedia.cpp b/sources/pyside2/PySide2/glue/qtmultimedia.cpp
index 5a3f3a5e7..cbe1367cb 100644
--- a/sources/pyside2/PySide2/glue/qtmultimedia.cpp
+++ b/sources/pyside2/PySide2/glue/qtmultimedia.cpp
@@ -44,3 +44,10 @@ QObject * upcastedArg = %CONVERTTOCPP[QObject *](%PYARG_1);
%CPPSELF.%FUNCTION_NAME(reinterpret_cast< %ARG1_TYPE >(upcastedArg));
%END_ALLOW_THREADS
// @snippet upcast
+
+// @snippet qvideoframe-bits
+%BEGIN_ALLOW_THREADS
+%RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME();
+%END_ALLOW_THREADS
+%PYARG_0 = Shiboken::Buffer::newObject(%0, %CPPSELF.bytesPerLine() * %CPPSELF.height(), Shiboken::Buffer::ReadWrite);
+// @snippet qvideoframe-bits
diff --git a/sources/pyside2/PySide2/support/generate_pyi.py b/sources/pyside2/PySide2/support/generate_pyi.py
index c732227f4..d5bbe5d7c 100644
--- a/sources/pyside2/PySide2/support/generate_pyi.py
+++ b/sources/pyside2/PySide2/support/generate_pyi.py
@@ -100,6 +100,38 @@ class Formatter(Writer):
The separation in formatter and enumerator is done to keep the
unrelated tasks of enumeration and formatting apart.
"""
+ def __init__(self, *args):
+ Writer.__init__(self, *args)
+ # patching __repr__ to disable the __repr__ of typing.TypeVar:
+ """
+ def __repr__(self):
+ if self.__covariant__:
+ prefix = '+'
+ elif self.__contravariant__:
+ prefix = '-'
+ else:
+ prefix = '~'
+ return prefix + self.__name__
+ """
+ def _typevar__repr__(self):
+ return "typing." + self.__name__
+ typing.TypeVar.__repr__ = _typevar__repr__
+
+ # Adding a pattern to substitute "Union[T, NoneType]" by "Optional[T]"
+ # I tried hard to replace typing.Optional by a simple override, but
+ # this became _way_ too much.
+ # See also the comment in layout.py .
+ brace_pat = build_brace_pattern(3)
+ pattern = (r"\b Union \s* \[ \s* {brace_pat} \s*, \s* NoneType \s* \]"
+ .format(**locals()))
+ replace = r"Optional[\1]"
+ optional_searcher = re.compile(pattern, flags=re.VERBOSE)
+ def optional_replacer(source):
+ return optional_searcher.sub(replace, str(source))
+ self.optional_replacer = optional_replacer
+ # self.level is maintained by enum_sig.py
+ # self.after_enum() is a one-shot set by enum_sig.py .
+
@contextmanager
def module(self, mod_name):
self.mod_name = mod_name
@@ -121,27 +153,22 @@ class Formatter(Writer):
@contextmanager
def klass(self, class_name, class_str):
- self.class_name = class_name
- spaces = ""
+ spaces = indent * self.level
while "." in class_name:
- spaces += indent
class_name = class_name.split(".", 1)[-1]
class_str = class_str.split(".", 1)[-1]
self.print()
- if not spaces:
+ if self.level == 0:
self.print()
here = self.outfile.tell()
self.print("{spaces}class {class_str}:".format(**locals()))
- self.print()
pos = self.outfile.tell()
- self.spaces = spaces
yield
if pos == self.outfile.tell():
# we have not written any function
self.outfile.seek(here)
self.outfile.truncate()
- # Note: we cannot use class_str when we have no body.
- self.print("{spaces}class {class_name}: ...".format(**locals()))
+ self.print("{spaces}class {class_str}: ...".format(**locals()))
if "<" in class_name:
# This is happening in QtQuick for some reason:
## class QSharedPointer<QQuickItemGrabResult >:
@@ -150,24 +177,34 @@ class Formatter(Writer):
self.outfile.truncate()
@contextmanager
- def function(self, func_name, signature):
+ def function(self, func_name, signature, modifier=None):
+ if self.after_enum() or func_name == "__init__":
+ self.print()
key = func_name
- spaces = indent + self.spaces if self.class_name else ""
+ spaces = indent * self.level
if type(signature) == type([]):
for sig in signature:
self.print('{spaces}@typing.overload'.format(**locals()))
- self._function(func_name, sig, spaces)
+ self._function(func_name, sig, modifier, spaces)
else:
- self._function(func_name, signature, spaces)
+ self._function(func_name, signature, modifier, spaces)
+ if func_name == "__init__":
+ self.print()
yield key
- def _function(self, func_name, signature, spaces):
- # this would be nicer to get somehow together with the signature
- is_meth = re.match(r"\((\w*)", str(signature)).group(1) == "self"
- if self.class_name and not is_meth:
- self.print('{spaces}@staticmethod'.format(**locals()))
+ def _function(self, func_name, signature, modifier, spaces):
+ if modifier:
+ self.print('{spaces}@{modifier}'.format(**locals()))
+ signature = self.optional_replacer(signature)
self.print('{spaces}def {func_name}{signature}: ...'.format(**locals()))
+ @contextmanager
+ def enum(self, class_name, enum_name, value):
+ spaces = indent * self.level
+ hexval = hex(value)
+ self.print("{spaces}{enum_name:25}: {class_name} = ... # {hexval}".format(**locals()))
+ yield
+
def get_license_text():
with io.open(sourcepath) as f:
@@ -247,10 +284,11 @@ def generate_all_pyi(outpath, options):
os.environ["PYTHONPATH"] = pypath
# now we can import
- global PySide2, inspect, HintingEnumerator
+ global PySide2, inspect, typing, HintingEnumerator, build_brace_pattern
import PySide2
- from PySide2.support.signature import inspect
+ from PySide2.support.signature import inspect, typing
from PySide2.support.signature.lib.enum_sig import HintingEnumerator
+ from PySide2.support.signature.lib.tool import build_brace_pattern
# propagate USE_PEP563 to the mapping module.
# Perhaps this can be automated?