aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-06-08 14:28:53 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-10 10:52:01 +0000
commit2705ee2f7eea52e2651bbb657a8171a724f56091 (patch)
treef251b5b93418b3cef2d5612bedaba3730397cace
parent4bd8838afec0494881c9f5bc490b8124cef0f004 (diff)
Use replaced types in functions signatures
This is a preparation step for PYSIDE-1499, but in effect it is solving a lot of old problems where signatures hat to guess what was changed, and failed. Task-number: PYSIDE-1588 Change-Id: Ib20f78e8f79e8928b5ec16b733f22fd85c3a1155 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com> (cherry picked from commit 99148a428f937476e5e740f16999bb2eb44a3c3f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp21
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py6
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py4
3 files changed, 25 insertions, 6 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 2e9ea8d0b..91caa51ba 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -5057,15 +5057,28 @@ void CppGenerator::writeSignatureInfo(TextStream &s, const AbstractMetaFunctionC
// Toplevel functions like `PySide6.QtCore.QEnum` are always self-less.
if (!(f->isStatic()) && f->ownerClass())
args << QLatin1String("self");
- for (const AbstractMetaArgument &arg : f->arguments())
- args.append(signatureParameter(arg));
+ const auto &arguments = f->arguments();
+ for (qsizetype i = 0, size = arguments.size(); i < size; ++i) {
+ QString t = f->typeReplaced(i + 1);
+ if (t.isEmpty()) {
+ t = signatureParameter(arguments.at(i));
+ } else {
+ t.prepend(u':');
+ t.prepend(arguments.at(i).name());
+ }
+ args.append(t);
+ }
// mark the multiple signatures as such, to make it easier to generate different code
if (multiple)
s << idx-- << ':';
s << funcName << '(' << args.join(QLatin1Char(',')) << ')';
- if (!f->isVoid())
- s << "->" << f->type().pythonSignature();
+ if (!f->isVoid()) {
+ QString t = f->typeReplaced(0);
+ if (t.isEmpty())
+ t = f->type().pythonSignature();
+ s << "->" << t;
+ }
s << '\n';
}
}
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
index 8cb5d4775..af78ed309 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
@@ -235,6 +235,7 @@ type_map.update({
"nullptr": None,
"PyCallable": typing.Callable,
"PyObject": object,
+ "PyObject*": object,
"PyArrayObject": ArrayLikeVariable, # numpy
"PySequence": typing.Iterable, # important for numpy
"PyTypeObject": type,
@@ -458,8 +459,10 @@ def init_PySide6_QtCore():
"size_t": int,
"NULL": None, # 5.6, MSVC
"nullptr": None, # 5.9
+ "PyBuffer": bytes,
"PyByteArray": bytearray,
"PyBytes": bytes,
+ "PyTuple": typing.Tuple,
"QDeadlineTimer(QDeadlineTimer.Forever)": Instance("PySide6.QtCore.QDeadlineTimer"),
"PySide6.QtCore.QUrl.ComponentFormattingOptions":
PySide6.QtCore.QUrl.ComponentFormattingOption, # mismatch option/enum, why???
@@ -606,8 +609,7 @@ def init_PySide6_QtOpenGL():
def init_PySide6_QtQml():
type_map.update({
- "QJSValueList()": [],
- "QVariantHash()": typing.Dict[str, Variant], # from 5.9
+ "VolatileBool": PySide6.QtQml.VolatileBool,
})
return locals()
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
index 8133c1e63..047ce6c4b 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
@@ -389,6 +389,10 @@ def calculate_props(line):
_defaults.append(default)
defaults = tuple(_defaults)
returntype = parsed.returntype
+ if isinstance(returntype, str) and returntype.startswith("("):
+ # PYSIDE-1588: Simplify the handling of returned tuples for now.
+ # Later we might create named tuples, instead.
+ returntype = "Tuple"
# PYSIDE-1383: We need to handle `None` explicitly.
annotations["return"] = (_resolve_type(returntype, line, 0, handle_retvar)
if returntype is not None else None)