diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-05-15 17:11:57 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-05-16 09:36:08 +0000 |
commit | a66352996264d7dfbbe68df179421a8e0ef3637a (patch) | |
tree | 1e33d85992e42fe68caed5be2df60365ddac650c /sources/shiboken2/ApiExtractor | |
parent | 15273fe0fe52569013dd4811bf9ed770ce7fb287 (diff) |
Fix wrongly generated code for enums passed by const-ref
First encountered in:
QtScxmlEvent::setEventType(const EventType &);
The metatype was wrongly detected as NativePointerPattern
in AbstractMetaType::determineUsagePattern().
Introduce a helper for detecting plain const-ref and use
that consistently.
Change-Id: I6b105bc99ae63e4737c5d628e79f23b7acbcca3d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetalang.cpp | 14 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetalang.h | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index ba33f78d9..7cba99839 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -189,6 +189,11 @@ AbstractMetaTypeCList AbstractMetaType::nestedArrayTypes() const return result; } +bool AbstractMetaType::isConstRef() const +{ + return isConstant() && m_referenceType == LValueReference && indirections() == 0; +} + QString AbstractMetaType::cppSignature() const { if (m_cachedCppSignature.isEmpty()) @@ -201,10 +206,8 @@ AbstractMetaType::TypeUsagePattern AbstractMetaType::determineUsagePattern() con if (m_typeEntry->isTemplateArgument() || m_referenceType == RValueReference) return InvalidPattern; - if (m_typeEntry->isPrimitive() && (!actualIndirections() - || (isConstant() && m_referenceType == LValueReference && !indirections()))) { + if (m_typeEntry->isPrimitive() && (actualIndirections() == 0 || isConstRef())) return PrimitivePattern; - } if (m_typeEntry->isVoid()) return NativePointerPattern; @@ -212,7 +215,7 @@ AbstractMetaType::TypeUsagePattern AbstractMetaType::determineUsagePattern() con if (m_typeEntry->isVarargs()) return VarargsPattern; - if (m_typeEntry->isEnum() && actualIndirections() == 0) + if (m_typeEntry->isEnum() && (actualIndirections() == 0 || isConstRef())) return EnumPattern; if (m_typeEntry->isObject()) { @@ -228,8 +231,7 @@ AbstractMetaType::TypeUsagePattern AbstractMetaType::determineUsagePattern() con if (m_typeEntry->isSmartPointer() && indirections() == 0) return SmartPointerPattern; - if (m_typeEntry->isFlags() && indirections() == 0 - && (isConstant() == (m_referenceType == LValueReference))) + if (m_typeEntry->isFlags() && (actualIndirections() == 0 || isConstRef())) return FlagsPattern; if (m_typeEntry->isArray()) diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h index c31c5a386..cfc8b7246 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.h +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h @@ -434,6 +434,8 @@ public: m_constant = constant; } + bool isConstRef() const; + ReferenceType referenceType() const { return m_referenceType; } void setReferenceType(ReferenceType ref) { m_referenceType = ref; } |