aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/generator/shiboken/cppgenerator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-09-10 14:58:54 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-09-11 07:57:17 +0200
commitacaa0e5ce430d87eea1d76620e3b9e3584a55f86 (patch)
treecce83caa766e7d69de3be3bee5990b2b3e79baea /sources/shiboken6/generator/shiboken/cppgenerator.cpp
parenta4a23da2df6af79f03f0d10bd10a18b3cb437396 (diff)
shiboken6: Refactor handling of values with copy constructor only
ShibokenGenerato::valueTypeWithCopyConstructorOnly() is frequently called when writing argument conversions. Instead of repeatedly searching for classes and looping its functions, determine the value once in AbstractMetaBuilder and set it as a boolean flag on class and type entry. Move the functions from ShibokenGenerator to AbstractMetaType. Task-number: PYSIDE-1605 Change-Id: If6701ff87b8dd23039f1d35daa6c9291acd0aa87 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/generator/shiboken/cppgenerator.cpp')
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index a0fe11cc7..1cda61c93 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -2492,7 +2492,7 @@ void CppGenerator::writeTypeCheck(TextStream &s,
bool numberType = numericTypes.count() == 1 || ShibokenGenerator::isPyInt(argType);
QString customType = (overloadData->hasArgumentTypeReplace() ? overloadData->argumentTypeReplaced() : QString());
bool rejectNull =
- shouldRejectNullPointerArgument(api(), overloadData->referenceFunction(), overloadData->argPos());
+ shouldRejectNullPointerArgument(overloadData->referenceFunction(), overloadData->argPos());
writeTypeCheck(s, argType, argumentName, numberType, customType, rejectNull);
}
@@ -2610,7 +2610,7 @@ void CppGenerator::writePythonToCppTypeConversion(TextStream &s,
const bool isPrimitive = typeEntry->isPrimitive();
const bool isEnum = typeEntry->isEnum();
const bool isFlags = typeEntry->isFlags();
- bool treatAsPointer = valueTypeWithCopyConstructorOnlyPassed(api(), type);
+ const bool treatAsPointer = type.valueTypeWithCopyConstructorOnlyPassed();
bool isPointerOrObjectType = (type.isObjectType() || type.isPointer())
&& !type.isUserPrimitive() && !type.isExtendedCppPrimitive()
&& !isEnum && !isFlags;
@@ -3328,7 +3328,7 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s, const Abst
for (int i = 0; i < containerType.instantiations().count(); ++i) {
const AbstractMetaType &type = containerType.instantiations().at(i);
QString typeName = getFullTypeName(type);
- if (valueTypeWithCopyConstructorOnlyPassed(api(), type)) {
+ if (type.valueTypeWithCopyConstructorOnlyPassed()) {
for (int pos = 0; ; ) {
const QRegularExpressionMatch match = convertToCppRegEx().match(code, pos);
if (!match.hasMatch())
@@ -3597,7 +3597,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
userArgs.append(arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX));
} else {
const int idx = arg.argumentIndex() - removedArgs;
- const bool deRef = valueTypeWithCopyConstructorOnlyPassed(api(), arg.type())
+ const bool deRef = arg.type().valueTypeWithCopyConstructorOnlyPassed()
|| arg.type().isObjectTypeUsedAsValueType()
|| arg.type().shouldDereferencePointer();
QString argName;