aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetalang.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
index 80ec20b46..9c54cc0d4 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
@@ -319,8 +319,11 @@ AbstractMetaType::TypeUsagePattern AbstractMetaType::determineUsagePattern() con
if (m_typeEntry->isPrimitive() && (actualIndirections() == 0 || passByConstRef()))
return PrimitivePattern;
- if (m_typeEntry->isVoid())
- return NativePointerPattern;
+ if (m_typeEntry->isVoid()) {
+ return m_arrayElementCount < 0 && m_referenceType == NoReference
+ && m_indirections.isEmpty() && m_constant == 0 && m_volatile == 0
+ ? VoidPattern : NativePointerPattern;
+ }
if (m_typeEntry->isVarargs())
return VarargsPattern;
@@ -410,6 +413,16 @@ bool AbstractMetaType::compare(const AbstractMetaType &rhs, ComparisonFlags flag
return true;
}
+AbstractMetaType *AbstractMetaType::createVoid()
+{
+ static const TypeEntry *voidTypeEntry = TypeDatabase::instance()->findType(QLatin1String("void"));
+ Q_ASSERT(voidTypeEntry);
+ auto *metaType = new AbstractMetaType;
+ metaType->setTypeEntry(voidTypeEntry);
+ metaType->decideUsagePattern();
+ return metaType;
+}
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const AbstractMetaType *at)
{
@@ -642,8 +655,7 @@ AbstractMetaFunction *AbstractMetaFunction::copy() const
cpy->setImplementingClass(implementingClass());
cpy->setFunctionType(functionType());
cpy->setDeclaringClass(declaringClass());
- if (type())
- cpy->setType(type()->copy());
+ cpy->setType(type()->copy());
cpy->setConstant(isConstant());
cpy->setExceptionSpecification(m_exceptionSpecification);
cpy->setAllowThreadModification(m_allowThreadModification);
@@ -653,8 +665,7 @@ AbstractMetaFunction *AbstractMetaFunction::copy() const
for (AbstractMetaArgument *arg : m_arguments)
cpy->addArgument(arg->copy());
- Q_ASSERT((!type() && !cpy->type())
- || (type()->instantiations() == cpy->type()->instantiations()));
+ Q_ASSERT(type()->instantiations() == cpy->type()->instantiations());
return cpy;
}
@@ -663,7 +674,7 @@ bool AbstractMetaFunction::usesRValueReferences() const
{
if (m_functionType == MoveConstructorFunction || m_functionType == MoveAssignmentOperatorFunction)
return true;
- if (m_type && m_type->referenceType() == RValueReference)
+ if (m_type->referenceType() == RValueReference)
return true;
for (const AbstractMetaArgument *a : m_arguments) {
if (a->type()->referenceType() == RValueReference)
@@ -828,8 +839,7 @@ bool AbstractMetaFunction::isDeprecated() const
bool AbstractMetaFunction::autoDetectAllowThread() const
{
// Disallow for simple getter functions.
- const bool maybeGetter = m_constant != 0 && m_type != nullptr
- && m_arguments.isEmpty();
+ const bool maybeGetter = m_constant != 0 && !isVoid() && m_arguments.isEmpty();
return !maybeGetter;
}
@@ -1929,6 +1939,7 @@ bool AbstractMetaClass::hasPrivateCopyConstructor() const
void AbstractMetaClass::addDefaultConstructor()
{
auto *f = new AbstractMetaFunction;
+ f->setType(AbstractMetaType::createVoid());
f->setOriginalName(name());
f->setName(name());
f->setOwnerClass(this);
@@ -1947,6 +1958,7 @@ void AbstractMetaClass::addDefaultConstructor()
void AbstractMetaClass::addDefaultCopyConstructor(bool isPrivate)
{
auto f = new AbstractMetaFunction;
+ f->setType(AbstractMetaType::createVoid());
f->setOriginalName(name());
f->setName(name());
f->setOwnerClass(this);