aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside2/PySide2/QtQuick/typesystem_quick.xml15
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp36
-rw-r--r--sources/shiboken2/ApiExtractor/messages.cpp6
-rw-r--r--sources/shiboken2/ApiExtractor/messages.h2
-rw-r--r--sources/shiboken2/ApiExtractor/typedatabase.cpp1
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.cpp112
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.h67
-rw-r--r--sources/shiboken2/ApiExtractor/typesystemparser.cpp48
-rw-r--r--sources/shiboken2/ApiExtractor/typesystemparser.h4
9 files changed, 154 insertions, 137 deletions
diff --git a/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml b/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml
index 7a18dac54..223eff773 100644
--- a/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml
+++ b/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml
@@ -55,8 +55,9 @@
<object-type name="QQuickAsyncImageProvider" since="5.6"/>
- <object-type name="QQuickFramebufferObject"/>
- <object-type name="QQuickFramebufferObject::Renderer"/>
+ <object-type name="QQuickFramebufferObject">
+ <object-type name="Renderer"/>
+ </object-type>
<object-type name="QQuickTextureFactory"/>
<object-type name="QQuickImageProvider"/>
@@ -122,12 +123,12 @@
<enum-type name="AttributeType" since="5.8"/>
<enum-type name="DrawingMode" since="5.8"/>
<enum-type name="Type" since="5.8"/>
+ <value-type name="Attribute"/>
+ <value-type name="AttributeSet"/>
+ <value-type name="ColoredPoint2D"/>
+ <value-type name="Point2D"/>
+ <value-type name="TexturedPoint2D"/>
</object-type>
- <value-type name="QSGGeometry::Attribute"/>
- <value-type name="QSGGeometry::AttributeSet"/>
- <value-type name="QSGGeometry::ColoredPoint2D"/>
- <value-type name="QSGGeometry::Point2D"/>
- <value-type name="QSGGeometry::TexturedPoint2D"/>
<object-type name="QSGGeometryNode"/>
<!-- QSGMaterialShader doesn't compile because of const char * char * types not being recognized
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);
}
diff --git a/sources/shiboken2/ApiExtractor/messages.cpp b/sources/shiboken2/ApiExtractor/messages.cpp
index b60e1f73b..546e9c4ed 100644
--- a/sources/shiboken2/ApiExtractor/messages.cpp
+++ b/sources/shiboken2/ApiExtractor/messages.cpp
@@ -480,6 +480,12 @@ QString msgNoRootTypeSystemEntry()
return QLatin1String("Type system entry appears out of order, there does not seem to be a root type system element.");
}
+QString msgIncorrectlyNestedName(const QString &name)
+{
+ return QLatin1String("Nesting types by specifying '::' is no longer supported (")
+ + name + QLatin1String(").");
+}
+
// qtdocgenerator.cpp
QString msgTagWarning(const QXmlStreamReader &reader, const QString &context,
diff --git a/sources/shiboken2/ApiExtractor/messages.h b/sources/shiboken2/ApiExtractor/messages.h
index 5bbd7ba58..2b7b75ba0 100644
--- a/sources/shiboken2/ApiExtractor/messages.h
+++ b/sources/shiboken2/ApiExtractor/messages.h
@@ -133,6 +133,8 @@ QString msgInvalidRegularExpression(const QString &pattern, const QString &why);
QString msgNoRootTypeSystemEntry();
+QString msgIncorrectlyNestedName(const QString &name);
+
QString msgCyclicDependency(const QString &funcName, const QString &graphName,
const QVector<const AbstractMetaFunction *> &involvedConversions);
diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp
index 4f8887bd2..de51f6586 100644
--- a/sources/shiboken2/ApiExtractor/typedatabase.cpp
+++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp
@@ -841,7 +841,6 @@ void EnumTypeEntry::formatDebug(QDebug &d) const
{
TypeEntry::formatDebug(d);
FORMAT_NONEMPTY_STRING("package", m_packageName)
- FORMAT_NONEMPTY_STRING("qualifier", m_qualifier)
FORMAT_NONEMPTY_STRING("targetLangName", m_targetLangName)
if (m_flags)
d << ", flags=(" << m_flags << ')';
diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp
index a5572354f..f70871598 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken2/ApiExtractor/typesystem.cpp
@@ -43,9 +43,9 @@ static QString strings_jobject = QLatin1String("jobject");
static inline QString callOperator() { return QStringLiteral("operator()"); }
-PrimitiveTypeEntry::PrimitiveTypeEntry(const QString &name, const QVersionNumber &vr,
+PrimitiveTypeEntry::PrimitiveTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(name, PrimitiveType, vr, parent),
+ TypeEntry(entryName, PrimitiveType, vr, parent),
m_preferredTargetLangType(true)
{
}
@@ -194,8 +194,12 @@ ContainerTypeEntry::ContainerTypeEntry(const ContainerTypeEntry &) = default;
QString EnumTypeEntry::targetLangQualifier() const
{
- TypeEntry *te = TypeDatabase::instance()->findType(m_qualifier);
- return te ? te->targetLangName() : m_qualifier;
+ const QString q = qualifier();
+ if (!q.isEmpty()) {
+ if (auto te = TypeDatabase::instance()->findType(q))
+ return te->targetLangName();
+ }
+ return q;
}
QString EnumTypeEntry::qualifiedTargetLangName() const
@@ -213,6 +217,13 @@ QString EnumTypeEntry::qualifiedTargetLangName() const
return qualifiedName;
}
+QString EnumTypeEntry::qualifier() const
+{
+ auto parentEntry = parent();
+ return parentEntry && parentEntry->type() != TypeEntry::TypeSystemType ?
+ parentEntry->name() : QString();
+}
+
QString EnumTypeEntry::targetLangApiName() const
{
return QLatin1String("jint");
@@ -617,11 +628,17 @@ AddedFunction::TypeInfo AddedFunction::TypeInfo::fromSignature(const QString& si
return parseType(signature);
}
-ComplexTypeEntry::ComplexTypeEntry(const QString &name, TypeEntry::Type t,
+static QString buildName(const QString &entryName, const TypeEntry *parent)
+{
+ return parent == nullptr || parent->type() == TypeEntry::TypeSystemType
+ ? entryName : parent->name() + QLatin1String("::") + entryName;
+}
+
+ComplexTypeEntry::ComplexTypeEntry(const QString &entryName, TypeEntry::Type t,
const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(name, t, vr, parent),
- m_qualifiedCppName(name),
+ TypeEntry(entryName, t, vr, parent),
+ m_qualifiedCppName(buildName(entryName, parent)),
m_polymorphicBase(false),
m_genericClass(false),
m_deleteInMainThread(false)
@@ -719,10 +736,11 @@ bool TypeEntry::isCppPrimitive() const
return typeName.contains(QLatin1Char(' ')) || primitiveCppTypes().contains(typeName);
}
-TypeEntry::TypeEntry(const QString &name, TypeEntry::Type t, const QVersionNumber &vr,
+TypeEntry::TypeEntry(const QString &entryName, TypeEntry::Type t, const QVersionNumber &vr,
const TypeEntry *parent) :
m_parent(parent),
- m_name(name),
+ m_name(buildName(entryName, parent)),
+ m_entryName(entryName),
m_version(vr),
m_type(t)
{
@@ -765,6 +783,7 @@ TypeEntry *TypeEntry::clone() const
// Take over parameters relevant for typedefs
void TypeEntry::useAsTypedef(const TypeEntry *source)
{
+ m_entryName = source->m_entryName;
m_name = source->m_name;
m_targetLangPackage = source->m_targetLangPackage;
m_codeGeneration = source->m_codeGeneration;
@@ -773,9 +792,9 @@ void TypeEntry::useAsTypedef(const TypeEntry *source)
TypeEntry::TypeEntry(const TypeEntry &) = default;
-TypeSystemTypeEntry::TypeSystemTypeEntry(const QString &name, const QVersionNumber &vr,
+TypeSystemTypeEntry::TypeSystemTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(name, TypeSystemType, vr, parent)
+ TypeEntry(entryName, TypeSystemType, vr, parent)
{
}
@@ -810,9 +829,9 @@ TypeEntry *VarargsTypeEntry::clone() const
VarargsTypeEntry::VarargsTypeEntry(const VarargsTypeEntry &) = default;
-TemplateArgumentEntry::TemplateArgumentEntry(const QString &name, const QVersionNumber &vr,
+TemplateArgumentEntry::TemplateArgumentEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(name, TemplateArgumentType, vr, parent)
+ TypeEntry(entryName, TemplateArgumentType, vr, parent)
{
}
@@ -850,13 +869,11 @@ TypeEntry *ArrayTypeEntry::clone() const
ArrayTypeEntry::ArrayTypeEntry(const ArrayTypeEntry &) = default;
-EnumTypeEntry::EnumTypeEntry(const QString &nspace, const QString &enumName,
+EnumTypeEntry::EnumTypeEntry(const QString &entryName,
const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(nspace.isEmpty() ? enumName : nspace + QLatin1String("::") + enumName,
- EnumType, vr, parent),
- m_qualifier(nspace),
- m_targetLangName(enumName)
+ TypeEntry(entryName, EnumType, vr, parent),
+ m_targetLangName(entryName)
{
}
@@ -867,8 +884,10 @@ QString EnumTypeEntry::targetLangName() const
EnumValueTypeEntry::EnumValueTypeEntry(const QString &name, const QString &value,
const EnumTypeEntry *enclosingEnum,
- const QVersionNumber &vr, const TypeEntry *parent) :
- TypeEntry(name, TypeEntry::EnumValue, vr, parent),
+ bool isScopedEnum,
+ const QVersionNumber &vr) :
+ TypeEntry(name, TypeEntry::EnumValue, vr,
+ isScopedEnum ? enclosingEnum : enclosingEnum->parent()),
m_value(value),
m_enclosingEnum(enclosingEnum)
{
@@ -881,17 +900,30 @@ TypeEntry *EnumValueTypeEntry::clone() const
EnumValueTypeEntry::EnumValueTypeEntry(const EnumValueTypeEntry &) = default;
-FlagsTypeEntry::FlagsTypeEntry(const QString &name, const QVersionNumber &vr,
+FlagsTypeEntry::FlagsTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(name, FlagsType, vr, parent)
+ TypeEntry(entryName, FlagsType, vr, parent)
{
}
+ConstantValueTypeEntry::ConstantValueTypeEntry(const QString& name,
+ const TypeEntry *parent) :
+ TypeEntry(name, ConstantValueType, QVersionNumber(0, 0), parent)
+{
+}
+
+TypeEntry *ConstantValueTypeEntry::clone() const
+{
+ return new ConstantValueTypeEntry(*this);
+}
+
+ConstantValueTypeEntry::ConstantValueTypeEntry(const ConstantValueTypeEntry &) = default;
+
/* A typedef entry allows for specifying template specializations in the
* typesystem XML file. */
-TypedefEntry::TypedefEntry(const QString &name, const QString &sourceType,
+TypedefEntry::TypedefEntry(const QString &entryName, const QString &sourceType,
const QVersionNumber &vr, const TypeEntry *parent) :
- ComplexTypeEntry(name, TypedefType, vr, parent),
+ ComplexTypeEntry(entryName, TypedefType, vr, parent),
m_sourceType(sourceType)
{
}
@@ -903,21 +935,21 @@ TypeEntry *TypedefEntry::clone() const
TypedefEntry::TypedefEntry(const TypedefEntry &) = default;
-ContainerTypeEntry::ContainerTypeEntry(const QString &name, Type type,
+ContainerTypeEntry::ContainerTypeEntry(const QString &entryName, Type type,
const QVersionNumber &vr,
const TypeEntry *parent) :
- ComplexTypeEntry(name, ContainerType, vr, parent),
+ ComplexTypeEntry(entryName, ContainerType, vr, parent),
m_type(type)
{
setCodeGeneration(GenerateForSubclass);
}
-SmartPointerTypeEntry::SmartPointerTypeEntry(const QString &name,
+SmartPointerTypeEntry::SmartPointerTypeEntry(const QString &entryName,
const QString &getterName,
const QString &smartPointerType,
const QString &refCountMethodName,
const QVersionNumber &vr, const TypeEntry *parent) :
- ComplexTypeEntry(name, SmartPointerType, vr, parent),
+ ComplexTypeEntry(entryName, SmartPointerType, vr, parent),
m_getterName(getterName),
m_smartPointerType(smartPointerType),
m_refCountMethodName(refCountMethodName)
@@ -931,9 +963,9 @@ TypeEntry *SmartPointerTypeEntry::clone() const
SmartPointerTypeEntry::SmartPointerTypeEntry(const SmartPointerTypeEntry &) = default;
-NamespaceTypeEntry::NamespaceTypeEntry(const QString &name, const QVersionNumber &vr,
+NamespaceTypeEntry::NamespaceTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
- ComplexTypeEntry(name, NamespaceType, vr, parent)
+ ComplexTypeEntry(entryName, NamespaceType, vr, parent)
{
}
@@ -957,9 +989,9 @@ bool NamespaceTypeEntry::matchesFile(const QString &needle) const
return m_filePattern.match(needle).hasMatch();
}
-ValueTypeEntry::ValueTypeEntry(const QString &name, const QVersionNumber &vr,
+ValueTypeEntry::ValueTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
- ComplexTypeEntry(name, BasicValueType, vr, parent)
+ ComplexTypeEntry(entryName, BasicValueType, vr, parent)
{
}
@@ -980,9 +1012,9 @@ TypeEntry *ValueTypeEntry::clone() const
ValueTypeEntry::ValueTypeEntry(const ValueTypeEntry &) = default;
-ValueTypeEntry::ValueTypeEntry(const QString &name, Type t, const QVersionNumber &vr,
+ValueTypeEntry::ValueTypeEntry(const QString &entryName, Type t, const QVersionNumber &vr,
const TypeEntry *parent) :
- ComplexTypeEntry(name, t, vr, parent)
+ ComplexTypeEntry(entryName, t, vr, parent)
{
}
@@ -1120,9 +1152,9 @@ void CustomConversion::TargetToNativeConversion::setConversion(const QString& co
m_d->conversion = conversion;
}
-InterfaceTypeEntry::InterfaceTypeEntry(const QString &name, const QVersionNumber &vr,
+InterfaceTypeEntry::InterfaceTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
- ComplexTypeEntry(name, InterfaceType, vr, parent)
+ ComplexTypeEntry(entryName, InterfaceType, vr, parent)
{
}
@@ -1144,10 +1176,10 @@ TypeEntry *InterfaceTypeEntry::clone() const
InterfaceTypeEntry::InterfaceTypeEntry(const InterfaceTypeEntry &) = default;
-FunctionTypeEntry::FunctionTypeEntry(const QString &name, const QString &signature,
+FunctionTypeEntry::FunctionTypeEntry(const QString &entryName, const QString &signature,
const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(name, FunctionType, vr, parent)
+ TypeEntry(entryName, FunctionType, vr, parent)
{
addSignature(signature);
}
@@ -1159,9 +1191,9 @@ TypeEntry *FunctionTypeEntry::clone() const
FunctionTypeEntry::FunctionTypeEntry(const FunctionTypeEntry &) = default;
-ObjectTypeEntry::ObjectTypeEntry(const QString &name, const QVersionNumber &vr,
+ObjectTypeEntry::ObjectTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent)
- : ComplexTypeEntry(name, ObjectType, vr, parent)
+ : ComplexTypeEntry(entryName, ObjectType, vr, parent)
{
}
diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h
index 6d7a9d450..67e2420a1 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.h
+++ b/sources/shiboken2/ApiExtractor/typesystem.h
@@ -560,6 +560,7 @@ public:
FlagsType,
EnumType,
EnumValue,
+ ConstantValueType,
TemplateArgumentType,
ThreadType,
BasicValueType,
@@ -592,7 +593,7 @@ public:
};
Q_ENUM(CodeGeneration)
- explicit TypeEntry(const QString &name, Type t, const QVersionNumber &vr,
+ explicit TypeEntry(const QString &entryName, Type t, const QVersionNumber &vr,
const TypeEntry *parent);
virtual ~TypeEntry();
@@ -706,10 +707,9 @@ public:
}
// The type's name in C++, fully qualified
- QString name() const
- {
- return m_name;
- }
+ QString name() const { return m_name; }
+ // Name as specified in XML
+ QString entryName() const { return m_entryName; }
uint codeGeneration() const
{
@@ -907,7 +907,8 @@ protected:
private:
const TypeEntry *m_parent;
- QString m_name;
+ QString m_name; // fully qualified
+ QString m_entryName;
QString m_targetLangPackage;
CustomFunction m_customConstructor;
CustomFunction m_customDestructor;
@@ -928,7 +929,7 @@ private:
class TypeSystemTypeEntry : public TypeEntry
{
public:
- explicit TypeSystemTypeEntry(const QString &name, const QVersionNumber &vr,
+ explicit TypeSystemTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent);
TypeEntry *clone() const override;
@@ -962,7 +963,7 @@ protected:
class TemplateArgumentEntry : public TypeEntry
{
public:
- explicit TemplateArgumentEntry(const QString &name, const QVersionNumber &vr,
+ explicit TemplateArgumentEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent);
int ordinal() const
@@ -1014,7 +1015,7 @@ private:
class PrimitiveTypeEntry : public TypeEntry
{
public:
- explicit PrimitiveTypeEntry(const QString &name, const QVersionNumber &vr,
+ explicit PrimitiveTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent);
QString targetLangName() const override;
@@ -1094,7 +1095,7 @@ class EnumValueTypeEntry;
class EnumTypeEntry : public TypeEntry
{
public:
- explicit EnumTypeEntry(const QString &nspace, const QString &enumName,
+ explicit EnumTypeEntry(const QString &entryName,
const QVersionNumber &vr,
const TypeEntry *parent);
@@ -1104,14 +1105,7 @@ public:
QString targetLangApiName() const override;
- QString qualifier() const
- {
- return m_qualifier;
- }
- void setQualifier(const QString &q)
- {
- m_qualifier = q;
- }
+ QString qualifier() const;
const EnumValueTypeEntry *nullValue() const { return m_nullValue; }
void setNullValue(const EnumValueTypeEntry *n) { m_nullValue = n; }
@@ -1147,7 +1141,6 @@ protected:
private:
QString m_packageName;
- QString m_qualifier;
QString m_targetLangName;
const EnumValueTypeEntry *m_nullValue = nullptr;
@@ -1164,8 +1157,7 @@ class EnumValueTypeEntry : public TypeEntry
public:
explicit EnumValueTypeEntry(const QString& name, const QString& value,
const EnumTypeEntry* enclosingEnum,
- const QVersionNumber &vr,
- const TypeEntry *parent);
+ bool isScopedEnum, const QVersionNumber &vr);
QString value() const { return m_value; }
const EnumTypeEntry* enclosingEnum() const { return m_enclosingEnum; }
@@ -1183,7 +1175,7 @@ private:
class FlagsTypeEntry : public TypeEntry
{
public:
- explicit FlagsTypeEntry(const QString &name, const QVersionNumber &vr,
+ explicit FlagsTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent);
QString qualifiedTargetLangName() const override;
@@ -1228,6 +1220,19 @@ private:
EnumTypeEntry *m_enum = nullptr;
};
+// For primitive values, typically to provide a dummy type for
+// example the '2' in non-type template 'Array<2>'.
+class ConstantValueTypeEntry : public TypeEntry
+{
+public:
+ explicit ConstantValueTypeEntry(const QString& name,
+ const TypeEntry *parent);
+
+ TypeEntry *clone() const override;
+
+protected:
+ ConstantValueTypeEntry(const ConstantValueTypeEntry &);
+};
class ComplexTypeEntry : public TypeEntry
{
@@ -1243,7 +1248,7 @@ public:
Unknown
};
- explicit ComplexTypeEntry(const QString &name, Type t, const QVersionNumber &vr,
+ explicit ComplexTypeEntry(const QString &entryName, Type t, const QVersionNumber &vr,
const TypeEntry *parent);
bool isComplex() const override;
@@ -1443,7 +1448,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(ComplexTypeEntry::TypeFlags)
class TypedefEntry : public ComplexTypeEntry
{
public:
- explicit TypedefEntry(const QString &name,
+ explicit TypedefEntry(const QString &entryName,
const QString &sourceType,
const QVersionNumber &vr,
const TypeEntry *parent);
@@ -1492,7 +1497,7 @@ public:
};
Q_ENUM(Type)
- explicit ContainerTypeEntry(const QString &name, Type type, const QVersionNumber &vr,
+ explicit ContainerTypeEntry(const QString &entryName, Type type, const QVersionNumber &vr,
const TypeEntry *parent);
Type type() const
@@ -1519,7 +1524,7 @@ private:
class SmartPointerTypeEntry : public ComplexTypeEntry
{
public:
- explicit SmartPointerTypeEntry(const QString &name,
+ explicit SmartPointerTypeEntry(const QString &entryName,
const QString &getterName,
const QString &smartPointerType,
const QString &refCountMethodName,
@@ -1550,7 +1555,7 @@ private:
class NamespaceTypeEntry : public ComplexTypeEntry
{
public:
- explicit NamespaceTypeEntry(const QString &name, const QVersionNumber &vr,
+ explicit NamespaceTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent);
TypeEntry *clone() const override;
@@ -1581,7 +1586,7 @@ private:
class ValueTypeEntry : public ComplexTypeEntry
{
public:
- explicit ValueTypeEntry(const QString &name, const QVersionNumber &vr,
+ explicit ValueTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent);
bool isValue() const override;
@@ -1591,7 +1596,7 @@ public:
TypeEntry *clone() const override;
protected:
- explicit ValueTypeEntry(const QString &name, Type t, const QVersionNumber &vr,
+ explicit ValueTypeEntry(const QString &entryName, Type t, const QVersionNumber &vr,
const TypeEntry *parent);
ValueTypeEntry(const ValueTypeEntry &);
};
@@ -1599,7 +1604,7 @@ protected:
class InterfaceTypeEntry : public ComplexTypeEntry
{
public:
- explicit InterfaceTypeEntry(const QString &name, const QVersionNumber &vr,
+ explicit InterfaceTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent);
static QString interfaceName(const QString &name)
@@ -1662,7 +1667,7 @@ private:
class ObjectTypeEntry : public ComplexTypeEntry
{
public:
- explicit ObjectTypeEntry(const QString &name, const QVersionNumber &vr,
+ explicit ObjectTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent);
InterfaceTypeEntry *designatedInterface() const override;
diff --git a/sources/shiboken2/ApiExtractor/typesystemparser.cpp b/sources/shiboken2/ApiExtractor/typesystemparser.cpp
index 6ecdf1dc9..6d9e409a4 100644
--- a/sources/shiboken2/ApiExtractor/typesystemparser.cpp
+++ b/sources/shiboken2/ApiExtractor/typesystemparser.cpp
@@ -1064,34 +1064,34 @@ void TypeSystemParser::applyCommonAttributes(TypeEntry *type, QXmlStreamAttribut
FlagsTypeEntry *
TypeSystemParser::parseFlagsEntry(const QXmlStreamReader &,
- EnumTypeEntry *enumEntry,
- const QString &name, QString flagName,
+ EnumTypeEntry *enumEntry, QString flagName,
const QVersionNumber &since,
QXmlStreamAttributes *attributes)
{
if (!checkRootElement())
return nullptr;
- auto ftype = new FlagsTypeEntry(QLatin1String("QFlags<") + name + QLatin1Char('>'),
+ auto ftype = new FlagsTypeEntry(QLatin1String("QFlags<") + enumEntry->name() + QLatin1Char('>'),
since,
currentParentTypeEntry()->typeSystemTypeEntry());
ftype->setOriginator(enumEntry);
ftype->setTargetLangPackage(enumEntry->targetLangPackage());
- // Try to get the guess the qualified flag name
- const int lastSepPos = name.lastIndexOf(colonColon());
- if (lastSepPos >= 0 && !flagName.contains(colonColon()))
- flagName.prepend(name.left(lastSepPos + 2));
+ // Try toenumEntry get the guess the qualified flag name
+ if (!flagName.contains(colonColon())) {
+ auto eq = enumEntry->qualifier();
+ if (!eq.isEmpty())
+ flagName.prepend(eq + colonColon());
+ }
ftype->setOriginalName(flagName);
applyCommonAttributes(ftype, attributes);
- QString n = ftype->originalName();
- QStringList lst = n.split(colonColon());
+ QStringList lst = flagName.split(colonColon());
const QString &targetLangQualifier = enumEntry->targetLangQualifier();
if (QStringList(lst.mid(0, lst.size() - 1)).join(colonColon()) != targetLangQualifier) {
qCWarning(lcShiboken).noquote().nospace()
- << QStringLiteral("enum %1 and flags %2 differ in qualifiers")
- .arg(targetLangQualifier, lst.constFirst());
+ << QStringLiteral("enum %1 and flags %2 (%3) differ in qualifiers")
+ .arg(targetLangQualifier, lst.constFirst(), flagName);
}
ftype->setFlagsName(lst.constLast());
@@ -1223,19 +1223,12 @@ ContainerTypeEntry *
EnumTypeEntry *
TypeSystemParser::parseEnumTypeEntry(const QXmlStreamReader &reader,
- const QString &fullName, const QVersionNumber &since,
+ const QString &name, const QVersionNumber &since,
QXmlStreamAttributes *attributes)
{
if (!checkRootElement())
return nullptr;
- QString scope;
- QString name = fullName;
- const int sep = fullName.lastIndexOf(colonColon());
- if (sep != -1) {
- scope = fullName.left(sep);
- name = fullName.right(fullName.size() - sep - 2);
- }
- auto *entry = new EnumTypeEntry(scope, name, since, currentParentTypeEntry());
+ auto *entry = new EnumTypeEntry(name, since, currentParentTypeEntry());
applyCommonAttributes(entry, attributes);
entry->setTargetLangPackage(m_defaultPackage);
@@ -1263,7 +1256,7 @@ EnumTypeEntry *
if (!flagNames.isEmpty()) {
const QStringList &flagNameList = flagNames.split(QLatin1Char(','));
for (const QString &flagName : flagNameList)
- parseFlagsEntry(reader, entry, fullName, flagName.trimmed(), since, attributes);
+ parseFlagsEntry(reader, entry, flagName.trimmed(), since, attributes);
}
return entry;
}
@@ -2668,6 +2661,12 @@ bool TypeSystemParser::startElement(const QXmlStreamReader &reader)
return false;
}
}
+ // Allow for primitive and/or std:: types only, else require proper nesting.
+ if (element->type != StackElement::PrimitiveTypeEntry && name.contains(QLatin1Char(':'))
+ && !name.contains(QLatin1String("std::"))) {
+ m_error = msgIncorrectlyNestedName(name);
+ return false;
+ }
if (m_database->hasDroppedTypeEntries()) {
QString identifier = getNamePrefix(element) + QLatin1Char('.');
@@ -2715,13 +2714,6 @@ bool TypeSystemParser::startElement(const QXmlStreamReader &reader)
}
}
- // Fix type entry name using nesting information.
- if (element->type & StackElement::TypeEntryMask
- && element->parent && element->parent->type != StackElement::Root) {
- name = element->parent->entry->name() + colonColon() + name;
- }
-
-
if (name.isEmpty()) {
m_error = QLatin1String("no 'name' attribute specified");
return false;
diff --git a/sources/shiboken2/ApiExtractor/typesystemparser.h b/sources/shiboken2/ApiExtractor/typesystemparser.h
index afe68a689..d3ea54fc6 100644
--- a/sources/shiboken2/ApiExtractor/typesystemparser.h
+++ b/sources/shiboken2/ApiExtractor/typesystemparser.h
@@ -176,8 +176,8 @@ private:
const QVersionNumber &since, QXmlStreamAttributes *);
FlagsTypeEntry *
parseFlagsEntry(const QXmlStreamReader &, EnumTypeEntry *enumEntry,
- const QString &name, QString flagName,
- const QVersionNumber &since, QXmlStreamAttributes *);
+ QString flagName, const QVersionNumber &since,
+ QXmlStreamAttributes *);
NamespaceTypeEntry *
parseNamespaceTypeEntry(const QXmlStreamReader &,