aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-07-11 11:19:42 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-07-13 17:19:35 +0200
commitf1796628ec2d81c656876876148b2bf5db47c472 (patch)
treef86b528c1783a51bcdda244fe08aae3f9d9987dd /sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
parent035a2991c9468bdaad961da11053cf4176791819 (diff)
shiboken: Improve handling of pointer types for CONVERTTOCPP in injected code
Code snippets like: QByteArray *cppSelf = %CONVERTTOCPP[QByteArray *](obj); cause an assert in shiboken since the '*' is captured into the target of the assignment and is not considered part of the type. Make the error message a bit clearer and add documentation. Fixes: PYSIDE-1037 Change-Id: Ie8da2f57ba91325ea677e1a00852e91726c0e09b Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/generator/shiboken2/shibokengenerator.cpp')
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index 8e27777d6..e41c91716 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -149,6 +149,8 @@ ShibokenGenerator::ShibokenGenerator()
const char CHECKTYPE_REGEX[] = R"(%CHECKTYPE\[([^\[]*)\]\()";
const char ISCONVERTIBLE_REGEX[] = R"(%ISCONVERTIBLE\[([^\[]*)\]\()";
const char CONVERTTOPYTHON_REGEX[] = R"(%CONVERTTOPYTHON\[([^\[]*)\]\()";
+ // Capture a '*' leading the variable name into the target
+ // so that "*valuePtr = %CONVERTTOCPP..." works as expected.
const char CONVERTTOCPP_REGEX[] =
R"((\*?%?[a-zA-Z_][\w\.]*(?:\[[^\[^<^>]+\])*)(?:\s+)=(?:\s+)%CONVERTTOCPP\[([^\[]*)\]\()";
m_typeSystemConvRegEx[TypeSystemCheckFunction] = QRegularExpression(QLatin1String(CHECKTYPE_REGEX));
@@ -2044,10 +2046,9 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa
varType = miniNormalizer(varType);
QString varName = list.at(1).trimmed();
if (!varType.isEmpty()) {
- if (varType != conversionType->cppSignature()) {
- qFatal("Types of receiver variable ('%s') and %%CONVERTTOCPP type system variable ('%s') differ.",
- qPrintable(varType), qPrintable(conversionType->cppSignature()));
- }
+ const QString conversionSignature = conversionType->cppSignature();
+ if (varType != conversionSignature)
+ qFatal("%s", qPrintable(msgConversionTypesDiffer(varType, conversionSignature)));
c << getFullTypeName(conversionType) << ' ' << varName;
writeMinimalConstructorExpression(c, conversionType);
c << ';' << endl;