aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp14
-rw-r--r--sources/shiboken2/ApiExtractor/parser/enumvalue.h1
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.h6
3 files changed, 19 insertions, 2 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index 251d674a9..c8ff41d91 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -960,6 +960,15 @@ AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(const EnumModelItem &
metaEnum->setOriginalAttributes(metaEnum->attributes());
// Register all enum values on Type database
+ QString prefix;
+ if (enclosing) {
+ prefix += enclosing->typeEntry()->qualifiedCppName();
+ prefix += colonColon();
+ }
+ if (enumItem->enumKind() == EnumClass) {
+ prefix += enumItem->name();
+ prefix += colonColon();
+ }
const EnumeratorList &enumerators = enumItem->enumerators();
for (const EnumeratorModelItem &e : enumerators) {
QString name;
@@ -967,11 +976,12 @@ AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(const EnumModelItem &
name += enclosing->name();
name += colonColon();
}
- name += e->name();
EnumValueTypeEntry *enumValue =
- new EnumValueTypeEntry(name, e->stringValue(),
+ new EnumValueTypeEntry(prefix + e->name(), e->stringValue(),
enumTypeEntry, enumTypeEntry->version());
TypeDatabase::instance()->addType(enumValue);
+ if (e->value().isNullValue())
+ enumTypeEntry->setNullValue(enumValue);
}
return metaEnum;
diff --git a/sources/shiboken2/ApiExtractor/parser/enumvalue.h b/sources/shiboken2/ApiExtractor/parser/enumvalue.h
index 4905e89ba..ea30c39bb 100644
--- a/sources/shiboken2/ApiExtractor/parser/enumvalue.h
+++ b/sources/shiboken2/ApiExtractor/parser/enumvalue.h
@@ -49,6 +49,7 @@ public:
Type type() { return m_type; }
qint64 value() const { return m_value; }
quint64 unsignedValue() const { return m_unsignedValue; }
+ bool isNullValue() const { return m_type == Signed ? m_value == 0 : m_unsignedValue == 0u; }
void setValue(qint64 v);
void setUnsignedValue(quint64 v);
diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h
index 26f94e3ee..d892cb3a5 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.h
+++ b/sources/shiboken2/ApiExtractor/typesystem.h
@@ -1067,6 +1067,8 @@ private:
PrimitiveTypeEntry* m_referencedTypeEntry = nullptr;
};
+class EnumValueTypeEntry;
+
class EnumTypeEntry : public TypeEntry
{
public:
@@ -1088,6 +1090,9 @@ public:
m_qualifier = q;
}
+ const EnumValueTypeEntry *nullValue() const { return m_nullValue; }
+ void setNullValue(const EnumValueTypeEntry *n) { m_nullValue = n; }
+
void setFlags(FlagsTypeEntry *flags)
{
m_flags = flags;
@@ -1121,6 +1126,7 @@ private:
QString m_packageName;
QString m_qualifier;
QString m_targetLangName;
+ const EnumValueTypeEntry *m_nullValue = nullptr;
QStringList m_rejectedEnums;