aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-10-25 15:39:57 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-11-25 16:15:06 +0100
commit0ced05f77b88c68c8e2a1c71161cb19b9c890f59 (patch)
tree572383fc27b857a4a77d6b8a68b28108b9d346ac /sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
parent60795a6fc7460b9c5b115270541ef573ba15cde9 (diff)
shiboken: Store the unqualified entry name in TypeEntry
With the previous change adding a parent pointer, this is working towards building the target lang name by walking up the hierarchy, prepending the names, making it possible to exclude namespaces. Pass the unqualified name from the XML parser and build the qualified name in the TypeEntry constructor. For this to work, a new ConstantValueTypeEntry is added replacing the abuse of EnumValueTypeEntry for nontype-template parameters. As a side effect, it is no longer possible to nest types by qualifying with "::" in XML: <object-type name="Class"/> <enum-type name="Class::Enum"/> This needs to be fixed in the type system files. [ChangeLog][shiboken] As a result of a code cleanup, it is no longer possible to nest types by by qualifying with "::" in the type system files. The elements need to be properly nested. Task-number: PYSIDE-990 Task-number: PYSIDE-1074 Change-Id: I8a2f93c40d59167b0ba205ef3ff3b325d242c3d3 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp36
1 files changed, 8 insertions, 28 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index 12dafb47d..32c8e437d 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -838,13 +838,8 @@ AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(const EnumModelItem &
TypeEntry *typeEntry = nullptr;
const TypeEntry *enclosingTypeEntry = enclosing ? enclosing->typeEntry() : nullptr;
if (enumItem->accessPolicy() == CodeModel::Private) {
- QStringList names = enumItem->qualifiedName();
- const QString &enumName = names.constLast();
- QString nspace;
- if (names.size() > 1)
- nspace = QStringList(names.mid(0, names.size() - 1)).join(colonColon());
- typeEntry = new EnumTypeEntry(nspace, enumName, QVersionNumber(0, 0),
- enclosingTypeEntry);
+ typeEntry = new EnumTypeEntry(enumItem->qualifiedName().constLast(),
+ QVersionNumber(0, 0), enclosingTypeEntry);
TypeDatabase::instance()->addType(typeEntry);
} else if (enumItem->enumKind() != AnonymousEnum) {
typeEntry = TypeDatabase::instance()->findType(qualifiedName);
@@ -947,26 +942,13 @@ 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 bool isScopedEnum = enumItem->enumKind() == EnumClass;
const EnumeratorList &enumerators = enumItem->enumerators();
for (const EnumeratorModelItem &e : enumerators) {
- QString name;
- if (enclosing) {
- name += enclosing->name();
- name += colonColon();
- }
- EnumValueTypeEntry *enumValue =
- new EnumValueTypeEntry(prefix + e->name(), e->stringValue(),
- enumTypeEntry, enumTypeEntry->version(),
- enumTypeEntry->parent());
+ auto enumValue =
+ new EnumValueTypeEntry(e->name(), e->stringValue(),
+ enumTypeEntry, isScopedEnum,
+ enumTypeEntry->version());
TypeDatabase::instance()->addType(enumValue);
if (e->value().isNullValue())
enumTypeEntry->setNullValue(enumValue);
@@ -2681,9 +2663,7 @@ bool AbstractMetaBuilderPrivate::inheritTemplate(AbstractMetaClass *subclass,
if (isNumber) {
t = typeDb->findType(typeName);
if (!t) {
- t = new EnumValueTypeEntry(typeName, typeName, nullptr,
- QVersionNumber(0, 0),
- subclass->typeEntry()->parent());
+ t = new ConstantValueTypeEntry(typeName, subclass->typeEntry()->typeSystemTypeEntry());
t->setCodeGeneration(0);
typeDb->addType(t);
}