aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp11
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h2
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp12
-rw-r--r--sources/shiboken2/ApiExtractor/typedatabase.cpp10
-rw-r--r--sources/shiboken2/ApiExtractor/typedatabase.h3
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.cpp98
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.h54
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem_p.h5
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp18
9 files changed, 116 insertions, 97 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index 37b82e99f..1afc7d135 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -1053,7 +1053,7 @@ AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(EnumModelItem enumIte
QString nspace;
if (names.size() > 1)
nspace = QStringList(names.mid(0, names.size() - 1)).join(colonColon());
- typeEntry = new EnumTypeEntry(nspace, enumName, 0);
+ typeEntry = new EnumTypeEntry(nspace, enumName, QVersionNumber(0, 0));
TypeDatabase::instance()->addType(typeEntry);
} else if (!enumItem->isAnonymous()) {
typeEntry = TypeDatabase::instance()->findType(qualifiedName);
@@ -1937,7 +1937,7 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu
metaFunction->setUserAdded(true);
AbstractMetaAttributes::Attribute isStatic = addedFunc.isStatic() ? AbstractMetaFunction::Static : AbstractMetaFunction::None;
metaFunction->setAttributes(metaFunction->attributes() | AbstractMetaAttributes::FinalInTargetLang | isStatic);
- metaFunction->setType(translateType(addedFunc.version(), addedFunc.returnType()));
+ metaFunction->setType(translateType(addedFunc.returnType()));
QVector<AddedFunction::TypeInfo> args = addedFunc.arguments();
@@ -1946,7 +1946,7 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu
for (int i = 0; i < args.count(); ++i) {
AddedFunction::TypeInfo& typeInfo = args[i];
AbstractMetaArgument *metaArg = new AbstractMetaArgument;
- AbstractMetaType* type = translateType(addedFunc.version(), typeInfo);
+ AbstractMetaType *type = translateType(typeInfo);
decideUsagePattern(type);
metaArg->setType(type);
metaArg->setArgumentIndex(i);
@@ -2404,8 +2404,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(FunctionModel
return metaFunction;
}
-AbstractMetaType *AbstractMetaBuilderPrivate::translateType(double vr,
- const AddedFunction::TypeInfo &typeInfo)
+AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const AddedFunction::TypeInfo &typeInfo)
{
Q_ASSERT(!typeInfo.name.isEmpty());
TypeDatabase* typeDb = TypeDatabase::instance();
@@ -2462,7 +2461,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(double vr,
metaType->setConstant(typeInfo.isConstant);
if (isTemplate) {
for (const QString& templateArg : qAsConst(templateArgs)) {
- AbstractMetaType* metaArgType = translateType(vr, AddedFunction::TypeInfo::fromSignature(templateArg));
+ AbstractMetaType *metaArgType = translateType(AddedFunction::TypeInfo::fromSignature(templateArg));
metaType->addInstantiation(metaArgType);
}
metaType->setTypeUsagePattern(AbstractMetaType::ContainerPattern);
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
index 9e15541f6..7a2565914 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
@@ -124,7 +124,7 @@ public:
QString fixDefaultValue(ArgumentModelItem item, AbstractMetaType *type,
AbstractMetaFunction *fnc, AbstractMetaClass *,
int argumentIndex);
- AbstractMetaType* translateType(double vr, const AddedFunction::TypeInfo &typeInfo);
+ AbstractMetaType *translateType(const AddedFunction::TypeInfo &typeInfo);
AbstractMetaType *translateType(const TypeInfo &type, bool *ok,
bool resolveType = true,
bool resolveScope = true);
diff --git a/sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp b/sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp
index bcc5238bc..9ad846a52 100644
--- a/sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testaddfunction.cpp
@@ -36,7 +36,7 @@ void TestAddFunction::testParsingFuncNameAndConstness()
{
// generic test...
const char sig1[] = "func(type1, const type2, const type3* const)";
- AddedFunction f1(QLatin1String(sig1), QLatin1String("void"), 0);
+ AddedFunction f1(QLatin1String(sig1), QLatin1String("void"));
QCOMPARE(f1.name(), QLatin1String("func"));
QCOMPARE(f1.arguments().count(), 3);
AddedFunction::TypeInfo retval = f1.returnType();
@@ -47,7 +47,7 @@ void TestAddFunction::testParsingFuncNameAndConstness()
// test with a ugly template as argument and other ugly stuff
const char sig2[] = " _fu__nc_ ( type1, const type2, const Abc<int& , C<char*> * > * *, const type3* const ) const ";
- AddedFunction f2(QLatin1String(sig2), QLatin1String("const Abc<int& , C<char*> * > * *"), 0);
+ AddedFunction f2(QLatin1String(sig2), QLatin1String("const Abc<int& , C<char*> * > * *"));
QCOMPARE(f2.name(), QLatin1String("_fu__nc_"));
QVector< AddedFunction::TypeInfo > args = f2.arguments();
QCOMPARE(args.count(), 4);
@@ -64,7 +64,7 @@ void TestAddFunction::testParsingFuncNameAndConstness()
// function with no args.
const char sig3[] = "func()";
- AddedFunction f3(QLatin1String(sig3), QLatin1String("void"), 0);
+ AddedFunction f3(QLatin1String(sig3), QLatin1String("void"));
QCOMPARE(f3.name(), QLatin1String("func"));
QCOMPARE(f3.arguments().count(), 0);
}
@@ -181,7 +181,7 @@ void TestAddFunction::testAddFunctionCodeSnippets()
void TestAddFunction::testAddFunctionWithoutParenteses()
{
const char sig1[] = "func";
- AddedFunction f1(QLatin1String(sig1), QLatin1String("void"), 0);
+ AddedFunction f1(QLatin1String(sig1), QLatin1String("void"));
QCOMPARE(f1.name(), QLatin1String("func"));
QCOMPARE(f1.arguments().count(), 0);
@@ -211,7 +211,7 @@ void TestAddFunction::testAddFunctionWithoutParenteses()
void TestAddFunction::testAddFunctionWithDefaultArgs()
{
const char sig1[] = "func";
- AddedFunction f1(QLatin1String(sig1), QLatin1String("void"), 0);
+ AddedFunction f1(QLatin1String(sig1), QLatin1String("void"));
QCOMPARE(f1.name(), QLatin1String("func"));
QCOMPARE(f1.arguments().count(), 0);
@@ -276,7 +276,7 @@ void TestAddFunction::testAddFunctionAtModuleLevel()
void TestAddFunction::testAddFunctionWithVarargs()
{
const char sig1[] = "func(int,char,...)";
- AddedFunction f1( QLatin1String(sig1), QLatin1String("void"), 0);
+ AddedFunction f1( QLatin1String(sig1), QLatin1String("void"));
QCOMPARE(f1.name(), QLatin1String("func"));
QCOMPARE(f1.arguments().count(), 3);
diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp
index 76953a51e..e94d952a3 100644
--- a/sources/shiboken2/ApiExtractor/typedatabase.cpp
+++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp
@@ -672,15 +672,9 @@ bool TypeDatabase::setApiVersion(const QString& packageWildcardPattern, const QS
return true;
}
-bool TypeDatabase::checkApiVersion(const QString& package, const QString& version) const
+bool TypeDatabase::checkApiVersion(const QString &package,
+ const QVersionNumber &versionNumber) const
{
- const QVersionNumber versionNumber = QVersionNumber::fromString(version);
- if (versionNumber.isNull()) {
- qCWarning(lcShiboken).noquote().nospace()
- << "checkApiVersion: Invalid version \"" << version << "\" specified for package "
- << package << '.';
- return false;
- }
const ApiVersions &versions = *apiVersions();
for (int i = 0, size = versions.size(); i < size; ++i) {
if (versions.at(i).first.match(package).hasMatch())
diff --git a/sources/shiboken2/ApiExtractor/typedatabase.h b/sources/shiboken2/ApiExtractor/typedatabase.h
index dfddfc300..30d261d35 100644
--- a/sources/shiboken2/ApiExtractor/typedatabase.h
+++ b/sources/shiboken2/ApiExtractor/typedatabase.h
@@ -39,6 +39,7 @@
#include <QtCore/QStringList>
QT_FORWARD_DECLARE_CLASS(QIODevice)
+QT_FORWARD_DECLARE_CLASS(QVersionNumber)
class ComplexTypeEntry;
class ContainerTypeEntry;
@@ -148,7 +149,7 @@ public:
bool setApiVersion(const QString& package, const QString& version);
- bool checkApiVersion(const QString& package, const QString &version) const;
+ bool checkApiVersion(const QString &package, const QVersionNumber &version) const;
bool hasDroppedTypeEntries() const { return !m_dropTypeEntries.isEmpty(); }
diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp
index 69dccbb86..600536aba 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken2/ApiExtractor/typesystem.cpp
@@ -215,6 +215,17 @@ static QString msgReaderError(const QXmlStreamReader &reader)
return msgReaderError(reader, reader.errorString());
}
+static QString msgInvalidVersion(const QStringRef &version, const QString &package = QString())
+{
+ QString result;
+ QTextStream str(&result);
+ str << "Invalid version \"" << version << '"';
+ if (!package.isEmpty())
+ str << "\" specified for package " << package;
+ str << '.';
+ return result;
+}
+
bool Handler::parse(QXmlStreamReader &reader)
{
m_error.clear();
@@ -605,7 +616,8 @@ static QString checkSignatureError(const QString& signature, const QString& tag)
}
void Handler::addFlags(const QString &name, QString flagName,
- const QHash<QString, QString> &attributes, double since)
+ const QHash<QString, QString> &attributes,
+ const QVersionNumber &since)
{
FlagsTypeEntry *ftype = new FlagsTypeEntry(QLatin1String("QFlags<") + name + QLatin1Char('>'), since);
ftype->setOriginator(m_currentEnum);
@@ -640,7 +652,7 @@ void Handler::addFlags(const QString &name, QString flagName,
bool Handler::handleSmartPointerEntry(StackElement *element,
QHash<QString, QString> &attributes,
const QString &name,
- double since)
+ const QVersionNumber &since)
{
QString smartPointerType = attributes[QLatin1String("type")];
if (smartPointerType.isEmpty()) {
@@ -692,9 +704,19 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts
return true;
}
- if (!m_defaultPackage.isEmpty() && atts.hasAttribute(sinceAttribute())) {
+ QVersionNumber since(0, 0);
+ const QStringRef sinceSpec = atts.value(sinceAttribute());
+ if (!sinceSpec.isNull()) {
+ since = QVersionNumber::fromString(sinceSpec.toString());
+ if (since.isNull()) {
+ m_error = msgInvalidVersion(sinceSpec, m_defaultPackage);
+ return false;
+ }
+ }
+
+ if (!m_defaultPackage.isEmpty() && since > QVersionNumber(0, 0)) {
TypeDatabase* td = TypeDatabase::instance();
- if (!td->checkApiVersion(m_defaultPackage, atts.value(sinceAttribute()).toString())) {
+ if (!td->checkApiVersion(m_defaultPackage, since)) {
++m_ignoreDepth;
return true;
}
@@ -734,7 +756,7 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts
QHash<QString, QString> attributes;
attributes.insert(nameAttribute(), QString());
attributes.insert(QLatin1String("revision"), QLatin1String("0"));
- attributes.insert(sinceAttribute(), QLatin1String("0"));
+ attributes.insert(sinceAttribute(), QString()); // dummy for matching allowed attributes
switch (element->type) {
case StackElement::PrimitiveTypeEntry:
@@ -798,7 +820,6 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts
fetchAttributeValues(tagName, atts, &attributes);
QString name = attributes[nameAttribute()];
- double since = attributes[sinceAttribute()].toDouble();
if (m_database->hasDroppedTypeEntries()) {
QString identifier = getNamePrefix(element) + QLatin1Char('.');
@@ -1097,7 +1118,7 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts
QHash<QString, QString> attributes;
attributes.insert(QLatin1String("mode"), QLatin1String("replace"));
attributes.insert(QLatin1String("format"), QLatin1String("native"));
- attributes.insert(sinceAttribute(), QLatin1String("0"));
+ attributes.insert(sinceAttribute(), QString()); // dummy for matching allowed attributes
fetchAttributeValues(tagName, atts, &attributes);
@@ -1144,7 +1165,7 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts
// check the XML tag attributes
QHash<QString, QString> attributes;
attributes.insert(xPathAttribute(), QString());
- attributes.insert(sinceAttribute(), QLatin1String("0"));
+ attributes.insert(sinceAttribute(), QString()); // dummy for matching allowed attributes
fetchAttributeValues(tagName, atts, &attributes);
const int validParent = StackElement::TypeEntryMask
@@ -1179,7 +1200,7 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts
element->entry = topElement.entry;
QHash<QString, QString> attributes;
- attributes.insert(sinceAttribute(), QLatin1String("0"));
+ attributes.insert(sinceAttribute(), QString()); // dummy for matching allowed attributes
switch (element->type) {
case StackElement::Root:
attributes.insert(QLatin1String("package"), QString());
@@ -1309,11 +1330,8 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts
{ };
};
- double since = 0;
- if (attributes.count() > 0) {
+ if (!attributes.isEmpty())
fetchAttributeValues(tagName, atts, &attributes);
- since = attributes[sinceAttribute()].toDouble();
- }
switch (element->type) {
case StackElement::Root:
@@ -1718,7 +1736,7 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts
return false;
}
- AddedFunction func(signature, attributes[QLatin1String("return-type")], since);
+ AddedFunction func(signature, attributes[QLatin1String("return-type")]);
func.setStatic(attributes[QLatin1String("static")] == yesAttributeValue());
if (!signature.contains(QLatin1Char('(')))
signature += QLatin1String("()");
@@ -2082,7 +2100,7 @@ bool Handler::startElement(const QStringRef &n, const QXmlStreamAttributes &atts
return true;
}
-PrimitiveTypeEntry::PrimitiveTypeEntry(const QString &name, double vr) :
+PrimitiveTypeEntry::PrimitiveTypeEntry(const QString &name, const QVersionNumber &vr) :
TypeEntry(name, PrimitiveType, vr),
m_preferredConversion(true),
m_preferredTargetLangType(true)
@@ -2471,8 +2489,7 @@ static AddedFunction::TypeInfo parseType(const QString& signature, int startPos
return result;
}
-AddedFunction::AddedFunction(QString signature, QString returnType, double vr) :
- m_version(vr),
+AddedFunction::AddedFunction(QString signature, const QString &returnType) :
m_access(Public)
{
Q_ASSERT(!returnType.isEmpty());
@@ -2540,7 +2557,8 @@ AddedFunction::TypeInfo AddedFunction::TypeInfo::fromSignature(const QString& si
return parseType(signature);
}
-ComplexTypeEntry::ComplexTypeEntry(const QString &name, TypeEntry::Type t, double vr) :
+ComplexTypeEntry::ComplexTypeEntry(const QString &name, TypeEntry::Type t,
+ const QVersionNumber &vr) :
TypeEntry(QString(name).replace(QLatin1String(".*::"), QString()), t, vr),
m_qualifiedCppName(name),
m_qobject(false),
@@ -2581,7 +2599,7 @@ bool StringTypeEntry::isNativeIdBased() const
return false;
}
-CharTypeEntry::CharTypeEntry(const QString &name, double vr) :
+CharTypeEntry::CharTypeEntry(const QString &name, const QVersionNumber &vr) :
ValueTypeEntry(name, CharType, vr)
{
setCodeGeneration(GenerateNothing);
@@ -2606,7 +2624,7 @@ bool CharTypeEntry::isNativeIdBased() const
return false;
}
-VariantTypeEntry::VariantTypeEntry(const QString &name, double vr) :
+VariantTypeEntry::VariantTypeEntry(const QString &name, const QVersionNumber &vr) :
ValueTypeEntry(name, VariantType, vr)
{
}
@@ -2695,7 +2713,7 @@ bool TypeEntry::isCppPrimitive() const
typedef QHash<const TypeEntry*, CustomConversion*> TypeEntryCustomConversionMap;
Q_GLOBAL_STATIC(TypeEntryCustomConversionMap, typeEntryCustomConversionMap);
-TypeEntry::TypeEntry(const QString &name, TypeEntry::Type t, double vr) :
+TypeEntry::TypeEntry(const QString &name, TypeEntry::Type t, const QVersionNumber &vr) :
m_name(name),
m_type(t),
m_version(vr)
@@ -2729,27 +2747,27 @@ CustomConversion* TypeEntry::customConversion() const
return 0;
}
-TypeSystemTypeEntry::TypeSystemTypeEntry(const QString &name, double vr) :
+TypeSystemTypeEntry::TypeSystemTypeEntry(const QString &name, const QVersionNumber &vr) :
TypeEntry(name, TypeSystemType, vr)
{
}
VoidTypeEntry::VoidTypeEntry() :
- TypeEntry(QLatin1String("void"), VoidType, 0)
+ TypeEntry(QLatin1String("void"), VoidType, QVersionNumber(0, 0))
{
}
VarargsTypeEntry::VarargsTypeEntry() :
- TypeEntry(QLatin1String("..."), VarargsType, 0)
+ TypeEntry(QLatin1String("..."), VarargsType, QVersionNumber(0, 0))
{
}
-TemplateArgumentEntry::TemplateArgumentEntry(const QString &name, double vr) :
+TemplateArgumentEntry::TemplateArgumentEntry(const QString &name, const QVersionNumber &vr) :
TypeEntry(name, TemplateArgumentType, vr)
{
}
-ArrayTypeEntry::ArrayTypeEntry(const TypeEntry *nested_type, double vr) :
+ArrayTypeEntry::ArrayTypeEntry(const TypeEntry *nested_type, const QVersionNumber &vr) :
TypeEntry(QLatin1String("Array"), ArrayType, vr),
m_nestedType(nested_type)
{
@@ -2769,7 +2787,8 @@ QString ArrayTypeEntry::targetLangApiName() const
return QLatin1String("jobjectArray");
}
-EnumTypeEntry::EnumTypeEntry(const QString &nspace, const QString &enumName, double vr) :
+EnumTypeEntry::EnumTypeEntry(const QString &nspace, const QString &enumName,
+ const QVersionNumber &vr) :
TypeEntry(nspace.isEmpty() ? enumName : nspace + QLatin1String("::") + enumName,
EnumType, vr),
m_qualifier(nspace),
@@ -2792,19 +2811,22 @@ QString EnumTypeEntry::targetLangName() const
return m_targetLangName;
}
-EnumValueTypeEntry::EnumValueTypeEntry(const QString& name, const QString& value, const EnumTypeEntry* enclosingEnum, double vr) :
+EnumValueTypeEntry::EnumValueTypeEntry(const QString &name, const QString &value,
+ const EnumTypeEntry *enclosingEnum,
+ const QVersionNumber &vr) :
TypeEntry(name, TypeEntry::EnumValue, vr),
m_value(value),
m_enclosingEnum(enclosingEnum)
{
}
-FlagsTypeEntry::FlagsTypeEntry(const QString &name, double vr) :
+FlagsTypeEntry::FlagsTypeEntry(const QString &name, const QVersionNumber &vr) :
TypeEntry(name, FlagsType, vr)
{
}
-ContainerTypeEntry::ContainerTypeEntry(const QString &name, Type type, double vr) :
+ContainerTypeEntry::ContainerTypeEntry(const QString &name, Type type,
+ const QVersionNumber &vr) :
ComplexTypeEntry(name, ContainerType, vr),
m_type(type)
{
@@ -2815,7 +2837,7 @@ SmartPointerTypeEntry::SmartPointerTypeEntry(const QString &name,
const QString &getterName,
const QString &smartPointerType,
const QString &refCountMethodName,
- double vr) :
+ const QVersionNumber &vr) :
ComplexTypeEntry(name, SmartPointerType, vr),
m_getterName(getterName),
m_smartPointerType(smartPointerType),
@@ -2823,12 +2845,12 @@ SmartPointerTypeEntry::SmartPointerTypeEntry(const QString &name,
{
}
-NamespaceTypeEntry::NamespaceTypeEntry(const QString &name, double vr) :
+NamespaceTypeEntry::NamespaceTypeEntry(const QString &name, const QVersionNumber &vr) :
ComplexTypeEntry(name, NamespaceType, vr)
{
}
-ValueTypeEntry::ValueTypeEntry(const QString &name, double vr) :
+ValueTypeEntry::ValueTypeEntry(const QString &name, const QVersionNumber &vr) :
ComplexTypeEntry(name, BasicValueType, vr)
{
}
@@ -2843,12 +2865,12 @@ bool ValueTypeEntry::isNativeIdBased() const
return true;
}
-ValueTypeEntry::ValueTypeEntry(const QString &name, Type t, double vr) :
+ValueTypeEntry::ValueTypeEntry(const QString &name, Type t, const QVersionNumber &vr) :
ComplexTypeEntry(name, t, vr)
{
}
-StringTypeEntry::StringTypeEntry(const QString &name, double vr) :
+StringTypeEntry::StringTypeEntry(const QString &name, const QVersionNumber &vr) :
ValueTypeEntry(name, StringType, vr)
{
setCodeGeneration(GenerateNothing);
@@ -3007,7 +3029,7 @@ void CustomConversion::TargetToNativeConversion::setConversion(const QString& co
m_d->conversion = conversion;
}
-InterfaceTypeEntry::InterfaceTypeEntry(const QString &name, double vr) :
+InterfaceTypeEntry::InterfaceTypeEntry(const QString &name, const QVersionNumber &vr) :
ComplexTypeEntry(name, InterfaceType, vr)
{
}
@@ -3024,13 +3046,13 @@ QString InterfaceTypeEntry::qualifiedCppName() const
}
FunctionTypeEntry::FunctionTypeEntry(const QString &name, const QString &signature,
- double vr) :
+ const QVersionNumber &vr) :
TypeEntry(name, FunctionType, vr)
{
addSignature(signature);
}
-ObjectTypeEntry::ObjectTypeEntry(const QString &name, double vr)
+ObjectTypeEntry::ObjectTypeEntry(const QString &name, const QVersionNumber &vr)
: ComplexTypeEntry(name, ObjectType, vr)
{
}
diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h
index 62d348f69..2f534c93d 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.h
+++ b/sources/shiboken2/ApiExtractor/typesystem.h
@@ -40,6 +40,7 @@
#include <QtCore/QStringList>
#include <QtCore/QMap>
#include <QtCore/QVector>
+#include <QtCore/QVersionNumber>
//Used to identify the conversion rule to avoid break API
#define TARGET_CONVERSION_RULE_FLAG "0"
@@ -415,7 +416,7 @@ struct AddedFunction
};
/// Creates a new AddedFunction with a signature and a return type.
- explicit AddedFunction(QString signature, QString returnType, double vr);
+ explicit AddedFunction(QString signature, const QString &returnType);
AddedFunction() = default;
/// Returns the function name.
@@ -466,15 +467,10 @@ struct AddedFunction
return m_isStatic;
}
- double version() const
- {
- return m_version;
- }
private:
QString m_name;
QVector<TypeInfo> m_arguments;
TypeInfo m_returnType;
- double m_version = 0;
Access m_access = Protected;
bool m_isConst = false;
bool m_isStatic = false;
@@ -573,7 +569,7 @@ public:
};
Q_ENUM(CodeGeneration)
- explicit TypeEntry(const QString &name, Type t, double vr);
+ explicit TypeEntry(const QString &name, Type t, const QVersionNumber &vr);
virtual ~TypeEntry();
@@ -867,7 +863,7 @@ public:
return !m_conversionRule.isEmpty();
}
- double version() const
+ QVersionNumber version() const
{
return m_version;
}
@@ -903,13 +899,13 @@ private:
QHash<QString, bool> m_includesUsed;
QString m_conversionRule;
bool m_stream = false;
- double m_version;
+ QVersionNumber m_version;
};
class TypeSystemTypeEntry : public TypeEntry
{
public:
- explicit TypeSystemTypeEntry(const QString &name, double vr);
+ explicit TypeSystemTypeEntry(const QString &name, const QVersionNumber &vr);
};
class VoidTypeEntry : public TypeEntry
@@ -927,7 +923,7 @@ public:
class TemplateArgumentEntry : public TypeEntry
{
public:
- explicit TemplateArgumentEntry(const QString &name, double vr);
+ explicit TemplateArgumentEntry(const QString &name, const QVersionNumber &vr);
int ordinal() const
{
@@ -945,7 +941,7 @@ private:
class ArrayTypeEntry : public TypeEntry
{
public:
- explicit ArrayTypeEntry(const TypeEntry *nested_type, double vr);
+ explicit ArrayTypeEntry(const TypeEntry *nested_type, const QVersionNumber &vr);
void setNestedTypeEntry(TypeEntry *nested)
{
@@ -967,7 +963,7 @@ private:
class PrimitiveTypeEntry : public TypeEntry
{
public:
- explicit PrimitiveTypeEntry(const QString &name, double vr);
+ explicit PrimitiveTypeEntry(const QString &name, const QVersionNumber &vr);
QString targetLangName() const override;
void setTargetLangName(const QString &targetLangName)
@@ -1051,7 +1047,8 @@ public:
EnumClass // C++ 11 : enum class Foo { value1, value2 }
};
- explicit EnumTypeEntry(const QString &nspace, const QString &enumName, double vr);
+ explicit EnumTypeEntry(const QString &nspace, const QString &enumName,
+ const QVersionNumber &vr);
QString targetLangPackage() const override;
void setTargetLangPackage(const QString &package);
@@ -1164,7 +1161,7 @@ private:
class EnumValueTypeEntry : public TypeEntry
{
public:
- explicit EnumValueTypeEntry(const QString& name, const QString& value, const EnumTypeEntry* enclosingEnum, double vr);
+ explicit EnumValueTypeEntry(const QString& name, const QString& value, const EnumTypeEntry* enclosingEnum, const QVersionNumber &vr);
QString value() const { return m_value; }
const EnumTypeEntry* enclosingEnum() const { return m_enclosingEnum; }
@@ -1176,7 +1173,7 @@ private:
class FlagsTypeEntry : public TypeEntry
{
public:
- explicit FlagsTypeEntry(const QString &name, double vr);
+ explicit FlagsTypeEntry(const QString &name, const QVersionNumber &vr);
QString qualifiedTargetLangName() const override;
QString targetLangName() const override;
@@ -1240,7 +1237,7 @@ public:
Unknown
};
- explicit ComplexTypeEntry(const QString &name, Type t, double vr);
+ explicit ComplexTypeEntry(const QString &name, Type t, const QVersionNumber &vr);
bool isComplex() const override;
@@ -1458,7 +1455,7 @@ public:
};
Q_ENUM(Type)
- explicit ContainerTypeEntry(const QString &name, Type type, double vr);
+ explicit ContainerTypeEntry(const QString &name, Type type, const QVersionNumber &vr);
Type type() const
{
@@ -1501,7 +1498,7 @@ public:
const QString &getterName,
const QString &smartPointerType,
const QString &refCountMethodName,
- double vr);
+ const QVersionNumber &vr);
QString getter() const
{
@@ -1522,28 +1519,28 @@ private:
class NamespaceTypeEntry : public ComplexTypeEntry
{
public:
- explicit NamespaceTypeEntry(const QString &name, double vr);
+ explicit NamespaceTypeEntry(const QString &name, const QVersionNumber &vr);
};
class ValueTypeEntry : public ComplexTypeEntry
{
public:
- explicit ValueTypeEntry(const QString &name, double vr);
+ explicit ValueTypeEntry(const QString &name, const QVersionNumber &vr);
bool isValue() const override;
bool isNativeIdBased() const override;
protected:
- explicit ValueTypeEntry(const QString &name, Type t, double vr);
+ explicit ValueTypeEntry(const QString &name, Type t, const QVersionNumber &vr);
};
class StringTypeEntry : public ValueTypeEntry
{
public:
- explicit StringTypeEntry(const QString &name, double vr);
+ explicit StringTypeEntry(const QString &name, const QVersionNumber &vr);
QString targetLangApiName() const override;
QString targetLangName() const override;
@@ -1555,7 +1552,7 @@ public:
class CharTypeEntry : public ValueTypeEntry
{
public:
- explicit CharTypeEntry(const QString &name, double vr);
+ explicit CharTypeEntry(const QString &name, const QVersionNumber &vr);
QString targetLangApiName() const override;
QString targetLangName() const override;
@@ -1567,7 +1564,7 @@ public:
class VariantTypeEntry: public ValueTypeEntry
{
public:
- explicit VariantTypeEntry(const QString &name, double vr);
+ explicit VariantTypeEntry(const QString &name, const QVersionNumber &vr);
QString targetLangApiName() const override;
QString targetLangName() const override;
@@ -1580,7 +1577,7 @@ public:
class InterfaceTypeEntry : public ComplexTypeEntry
{
public:
- explicit InterfaceTypeEntry(const QString &name, double vr);
+ explicit InterfaceTypeEntry(const QString &name, const QVersionNumber &vr);
static QString interfaceName(const QString &name)
{
@@ -1607,7 +1604,8 @@ private:
class FunctionTypeEntry : public TypeEntry
{
public:
- explicit FunctionTypeEntry(const QString& name, const QString& signature, double vr);
+ explicit FunctionTypeEntry(const QString& name, const QString& signature,
+ const QVersionNumber &vr);
void addSignature(const QString& signature)
{
m_signatures << signature;
@@ -1629,7 +1627,7 @@ private:
class ObjectTypeEntry : public ComplexTypeEntry
{
public:
- explicit ObjectTypeEntry(const QString &name, double vr);
+ explicit ObjectTypeEntry(const QString &name, const QVersionNumber &vr);
InterfaceTypeEntry *designatedInterface() const override;
void setDesignatedInterface(InterfaceTypeEntry *entry)
diff --git a/sources/shiboken2/ApiExtractor/typesystem_p.h b/sources/shiboken2/ApiExtractor/typesystem_p.h
index d3485726e..d4707acb7 100644
--- a/sources/shiboken2/ApiExtractor/typesystem_p.h
+++ b/sources/shiboken2/ApiExtractor/typesystem_p.h
@@ -145,7 +145,7 @@ private:
bool handleSmartPointerEntry(StackElement *element,
QHash<QString, QString> &attributes,
const QString &name,
- double since);
+ const QVersionNumber &since);
bool endElement(const QStringRef& localName);
template <class String> // QString/QStringRef
bool characters(const String &ch);
@@ -154,7 +154,8 @@ private:
bool importFileElement(const QXmlStreamAttributes &atts);
void addFlags(const QString &name, QString flagName,
- const QHash<QString, QString> &attributes, double since);
+ const QHash<QString, QString> &attributes,
+ const QVersionNumber &since);
TypeDatabase* m_database;
StackElement* m_current;
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index 7cce97ae1..0465fdf09 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -157,6 +157,14 @@ static QTextStream &ensureEndl(QTextStream &s)
return s;
}
+static void formatSince(QTextStream &s, const char *what, const TypeEntry *te)
+{
+ if (te && te->version() > QVersionNumber(0, 0)) {
+ s << ".. note:: This " << what << " was introduced in Qt "
+ << te->version().toString() << '.' << endl;
+ }
+}
+
static QString msgTagWarning(const QXmlStreamReader &reader, const QString &context,
const QString &tag, const QString &message)
{
@@ -1368,8 +1376,7 @@ void QtDocGenerator::generateClass(QTextStream &s, GeneratorContext &classContex
writeInheritedByList(s, metaClass, classes());
- if (metaClass->typeEntry() && (metaClass->typeEntry()->version() != 0))
- s << ".. note:: This class was introduced in Qt " << metaClass->typeEntry()->version() << endl;
+ formatSince(s, "class", metaClass->typeEntry());
writeFunctionList(s, metaClass);
@@ -1490,9 +1497,7 @@ void QtDocGenerator::writeEnums(QTextStream& s, const AbstractMetaClass* cppClas
for (AbstractMetaEnum *en : enums) {
s << section_title << getClassTargetFullName(cppClass) << '.' << en->name() << endl << endl;
writeFormattedText(s, en->documentation(), cppClass);
-
- if (en->typeEntry() && (en->typeEntry()->version() != 0))
- s << ".. note:: This enum was introduced or modified in Qt " << en->typeEntry()->version() << endl;
+ formatSince(s, "enum", en->typeEntry());
}
}
@@ -1807,8 +1812,7 @@ void QtDocGenerator::writeFunction(QTextStream& s, bool writeDoc, const Abstract
writeFunctionSignature(s, cppClass, func);
s << endl;
- if (func->typeEntry() && (func->typeEntry()->version() != 0))
- s << ".. note:: This method was introduced in Qt " << func->typeEntry()->version() << endl;
+ formatSince(s, "method", func->typeEntry());
if (writeDoc) {
s << endl;