diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-03-19 17:24:00 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-04-19 12:51:14 +0000 |
commit | fb7386c18c15ca83aebe8f973c1b018d016baaa9 (patch) | |
tree | 91f0c2988af2e4133a2fdc702fccce69a623b9bf /sources/shiboken2/ApiExtractor/parser/codemodel.cpp | |
parent | a89690409972501741c846ac8ad4a499f2982809 (diff) |
shiboken: Use enum values from Clang
Remove a lot of ugly value parsing code in favor of
clang_getEnumConstantDeclValue() and
clang_getEnumConstantDeclUnsignedValue() depending on the
type.
Introduce a class EnumValue containing a union of qint64 and quint64 values
to represent signed/unsigned values correctly and use that in the code model
and meta language classes.
Change-Id: If2efb7cfd560237907678b8f6fdfb0bc689c0c93
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/parser/codemodel.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/parser/codemodel.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp index fbfeaadf7..1262f5901 100644 --- a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp +++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp @@ -1014,6 +1014,16 @@ void _EnumModelItem::addEnumerator(EnumeratorModelItem item) m_enumerators.append(item); } +bool _EnumModelItem::isSigned() const +{ + return m_signed; +} + +void _EnumModelItem::setSigned(bool s) +{ + m_signed = s; +} + #ifndef QT_NO_DEBUG_STREAM void _EnumModelItem::formatDebug(QDebug &d) const { @@ -1028,6 +1038,8 @@ void _EnumModelItem::formatDebug(QDebug &d) const d << " (class)"; break; } + if (!m_signed) + d << " (unsigned)"; formatModelItemList(d, ", enumerators=", m_enumerators); } #endif // !QT_NO_DEBUG_STREAM @@ -1037,22 +1049,21 @@ _EnumeratorModelItem::~_EnumeratorModelItem() { } -QString _EnumeratorModelItem::value() const +QString _EnumeratorModelItem::stringValue() const { - return m_value; + return m_stringValue; } -void _EnumeratorModelItem::setValue(const QString &value) +void _EnumeratorModelItem::setStringValue(const QString &value) { - m_value = value; + m_stringValue = value; } #ifndef QT_NO_DEBUG_STREAM void _EnumeratorModelItem::formatDebug(QDebug &d) const { _CodeModelItem::formatDebug(d); - if (!m_value.isEmpty()) - d << ", value=\"" << m_value << '"'; + d << ", value=" << m_value << ", stringValue=\"" << m_stringValue << '"'; } #endif // !QT_NO_DEBUG_STREAM |