aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/parser/codemodel.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-03-19 17:24:00 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-04-19 12:51:14 +0000
commitfb7386c18c15ca83aebe8f973c1b018d016baaa9 (patch)
tree91f0c2988af2e4133a2fdc702fccce69a623b9bf /sources/shiboken2/ApiExtractor/parser/codemodel.h
parenta89690409972501741c846ac8ad4a499f2982809 (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.h')
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.h b/sources/shiboken2/ApiExtractor/parser/codemodel.h
index b300cf249..ed0eedf7d 100644
--- a/sources/shiboken2/ApiExtractor/parser/codemodel.h
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel.h
@@ -33,6 +33,7 @@
#include "codemodel_fwd.h"
#include "codemodel_enums.h"
+#include "enumvalue.h"
#include <QtCore/QHash>
#include <QtCore/QSet>
@@ -633,6 +634,8 @@ public:
explicit _EnumModelItem(CodeModel *model, const QString &name, int kind = __node_kind)
: _CodeModelItem(model, name, kind) {}
+ explicit _EnumModelItem(CodeModel *model, int kind = __node_kind)
+ : _CodeModelItem(model, kind) {}
~_EnumModelItem();
CodeModel::AccessPolicy accessPolicy() const;
@@ -648,10 +651,14 @@ public:
void formatDebug(QDebug &d) const override;
#endif
+ bool isSigned() const;
+ void setSigned(bool s);
+
private:
CodeModel::AccessPolicy m_accessPolicy = CodeModel::Public;
EnumeratorList m_enumerators;
EnumKind m_enumKind = CEnum;
+ bool m_signed = true;
};
class _EnumeratorModelItem: public _CodeModelItem
@@ -665,15 +672,19 @@ public:
: _CodeModelItem(model, name, kind) {}
~_EnumeratorModelItem();
- QString value() const;
- void setValue(const QString &value);
+ QString stringValue() const;
+ void setStringValue(const QString &stringValue);
+
+ EnumValue value() const { return m_value; }
+ void setValue(EnumValue v) { m_value = v; }
#ifndef QT_NO_DEBUG_STREAM
void formatDebug(QDebug &d) const override;
#endif
private:
- QString m_value;
+ QString m_stringValue;
+ EnumValue m_value;
};
class _TemplateParameterModelItem: public _CodeModelItem