aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/generator/shiboken/cppgenerator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-09-17 12:54:10 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-09-24 13:52:35 +0200
commit97b4305474fd25a68b95b815cca6e413fcc80884 (patch)
tree7cf8259bac7367a3c4fed2b98ffc331680d37757 /sources/shiboken6/generator/shiboken/cppgenerator.cpp
parent56c24b5d1aa507c62bdf3af917519e6c7cf7718c (diff)
shiboken6: TypeEntry: Use a pointer to the target lang API type entry
Replace the string m_targetLangApiName by a pointer to the type entry; allowing to retrieve the check function. Similarly, in TargetToNativeConversion::sourceTypeCheck(), use the existing type entry to retrieve the check function, allowing for removing some heuristics. Task-number: PYSIDE-1660 Change-Id: Ieeda43f804b4e129d3cc0984e36bd0c0d546fd86 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/generator/shiboken/cppgenerator.cpp')
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 8e1a2c934..0b9ad6636 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -1576,7 +1576,7 @@ return result;)";
const AbstractMetaType sourceType = conv->arguments().constFirst().type();
typeCheck = cpythonCheckFunction(sourceType);
bool isUserPrimitiveWithoutTargetLangName = sourceType.isUserPrimitive()
- && sourceType.typeEntry()->targetLangApiName() == sourceType.typeEntry()->name();
+ && !sourceType.typeEntry()->hasTargetLangApiType();
if (!sourceType.isWrapperType()
&& !isUserPrimitiveWithoutTargetLangName
&& !sourceType.typeEntry()->isEnum()
@@ -3266,15 +3266,6 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s,
typeCheck = QLatin1String("Shiboken::isShibokenEnum(%in)");
else if (pyTypeName == QLatin1String("SbkObject"))
typeCheck = QLatin1String("Shiboken::Object::checkType(%in)");
- else if (pyTypeName == cPyTypeObjectT())
- typeCheck = QLatin1String("PyType_Check(%in)");
- else if (pyTypeName == cPyObjectT())
- typeCheck = QLatin1String("PyObject_TypeCheck(%in, &PyBaseObject_Type)");
- // PYSIDE-795: We abuse PySequence for iterables
- else if (pyTypeName == cPySequenceT())
- typeCheck = QLatin1String("Shiboken::String::checkIterable(%in)");
- else if (pyTypeName.startsWith(QLatin1String("Py")))
- typeCheck = pyTypeName + QLatin1String("_Check(%in)");
}
if (typeCheck.isEmpty()) {
if (!toNative->sourceType() || toNative->sourceType()->isPrimitive()) {
@@ -4040,8 +4031,8 @@ void CppGenerator::writePrimitiveConverterInitialization(TextStream &s,
QString converter = converterObject(type);
s << "// Register converter for type '" << type->qualifiedTargetLangName() << "'.\n"
<< converter << " = Shiboken::Conversions::createConverter(";
- if (type->targetLangApiName() == type->name())
- s << '0';
+ if (!type->hasTargetLangApiType())
+ s << "nullptr";
else if (type->targetLangApiName() == cPyObjectT())
s << "&PyBaseObject_Type";
else