diff options
| author | Christian Tismer <tismer@stackless.com> | 2018-10-14 11:13:40 +0200 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2018-11-15 10:24:23 +0000 |
| commit | 2533dab013455bf94da2d4766e54abaf4d735e1e (patch) | |
| tree | 506f169c2f3a44fed3bfe623c1f626d40836a379 /sources/pyside2/PySide2/support/signature/mapping.py | |
| parent | 93b54f123771c5b7da9880e9a2f372562893707f (diff) | |
Signature: Implement Nested Classes and Functions for Shiboken
This patch again contains a complete overhaul of the signature
module. The code was re-implemented to properly support nested
classes. Also, the code was reduced by AutoDecRef and by
adopting a concise C++ style.
Note.. We will add a shiboken signature test and complete
mapping.py after the split into three projects is done. The split
changes a lot and is needed right now!
Signatures were quite complete for PySide, but the support for Shiboken
was under-developed.
Since we are planning to generally enhance error messages by using
the Signature module, we should be able to rely on them to always
produce a signature. Therefore, a general overhaul was needed
to resolve all cornes cases for Python 2 and 3.
Nested classes are supported, as well as plain module functions.
The usage of the typing module might improve over time, but the
Signature implementation is now considered complete.
The loader will respect now the path settings which might not be
the package dir but the build dir. This is more consistens with COIN
testing.
Task-number: PYSIDE-795
Change-Id: I246449d4df895dadf2bcb4d997eaa13d78463d9b
Reviewed-by: Simo Fält <simo.falt@qt.io>
Diffstat (limited to 'sources/pyside2/PySide2/support/signature/mapping.py')
| -rw-r--r-- | sources/pyside2/PySide2/support/signature/mapping.py | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/sources/pyside2/PySide2/support/signature/mapping.py b/sources/pyside2/PySide2/support/signature/mapping.py index 6b7d1ad01..23ba6a7f1 100644 --- a/sources/pyside2/PySide2/support/signature/mapping.py +++ b/sources/pyside2/PySide2/support/signature/mapping.py @@ -56,6 +56,11 @@ import sys import struct import PySide2 try: + import sample +except ImportError: + pass + +try: from . import typing except ImportError: import typing @@ -64,10 +69,12 @@ ellipsis = "..." Char = typing.Union[str, int] # how do I model the limitation to 1 char? StringList = typing.List[str] IntList = typing.List[int] +IntMatrix = typing.List[IntList] Variant = typing.Any ModelIndexList = typing.List[int] QImageCleanupFunction = typing.Callable -FloatMatrix = typing.List[typing.List[float]] +FloatList = typing.List[float] +FloatMatrix = typing.List[FloatList] # Pair could be more specific, but we loose the info in the generator. Pair = typing.Tuple[typing.Any, typing.Any] MultiMap = typing.DefaultDict[str, typing.List[str]] @@ -132,7 +139,7 @@ class Instance(_NotCalled): class Reloader(object): def __init__(self): self.sys_module_count = 0 - self.uninitialized = PySide2.__all__[:] + self.uninitialized = PySide2.__all__[:] + ["sample"] def update(self): if self.sys_module_count == len(sys.modules): @@ -140,7 +147,7 @@ class Reloader(object): self.sys_module_count = len(sys.modules) g = globals() for mod_name in self.uninitialized[:]: - if "PySide2." + mod_name in sys.modules: + if "PySide2." + mod_name in sys.modules or mod_name == "sample": self.uninitialized.remove(mod_name) proc_name = "init_" + mod_name if proc_name in g: @@ -289,6 +296,7 @@ def init_QtCore(): "PySide2.QtCore.QAbstractItemModel.CheckIndexOptions.NoOption"), # 5.11 "QVariantMap": dict, "PySide2.QtCore.QCborStreamReader.StringResult": typing.AnyStr, + "PySide2.QtCore.double": float, }) try: type_map.update({ @@ -299,6 +307,7 @@ def init_QtCore(): pass return locals() + def init_QtGui(): import PySide2.QtGui type_map.update({ @@ -328,6 +337,7 @@ def init_QtGui(): }) return locals() + def init_QtWidgets(): import PySide2.QtWidgets from PySide2.QtWidgets import QWidget, QMessageBox, QStyleOption, QStyleHintReturn, QStyleOptionComplex @@ -364,6 +374,7 @@ def init_QtWidgets(): }) return locals() + def init_QtSql(): import PySide2.QtSql from PySide2.QtSql import QSqlDatabase @@ -373,6 +384,7 @@ def init_QtSql(): }) return locals() + def init_QtNetwork(): import PySide2.QtNetwork type_map.update({ @@ -383,6 +395,7 @@ def init_QtNetwork(): }) return locals() + def init_QtXmlPatterns(): import PySide2.QtXmlPatterns from PySide2.QtXmlPatterns import QXmlName @@ -392,6 +405,7 @@ def init_QtXmlPatterns(): }) return locals() + def init_QtMultimedia(): import PySide2.QtMultimedia import PySide2.QtMultimediaWidgets @@ -401,6 +415,7 @@ def init_QtMultimedia(): }) return locals() + def init_QtOpenGL(): import PySide2.QtOpenGL type_map.update({ @@ -417,6 +432,7 @@ def init_QtOpenGL(): }) return locals() + def init_QtQml(): import PySide2.QtQml type_map.update({ @@ -429,6 +445,7 @@ def init_QtQml(): }) return locals() + def init_QtQuick(): import PySide2.QtQuick type_map.update({ @@ -440,6 +457,7 @@ def init_QtQuick(): }) return locals() + def init_QtScript(): import PySide2.QtScript type_map.update({ @@ -447,6 +465,7 @@ def init_QtScript(): }) return locals() + def init_QtTest(): import PySide2.QtTest type_map.update({ @@ -471,6 +490,23 @@ def init_QtWinExtras(): }) return locals() +def init_sample(): + type_map.update({ + "sample.int": int, + "Complex": complex, + "sample.OddBool": bool, + "sample.bool": bool, + "sample.PStr": str, + "double[]": FloatList, + "OddBool": bool, + "PStr": str, + "sample.char": Char, + "double[][]": FloatMatrix, + "int[]": IntList, + "int[][]": IntMatrix, + }) + return locals() + # Here was testbinding, actually the source of all evil. # end of file |
