aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/typesystem.h
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/ApiExtractor/typesystem.h')
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.h585
1 files changed, 184 insertions, 401 deletions
diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h
index a8ee0ced4..c8a1c88fa 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.h
+++ b/sources/shiboken2/ApiExtractor/typesystem.h
@@ -35,9 +35,11 @@
#include <QtCore/QHash>
#include <QtCore/qobjectdefs.h>
+#include <QtCore/QRegularExpression>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QMap>
+#include <QtCore/QVector>
//Used to identify the conversion rule to avoid break API
#define TARGET_CONVERSION_RULE_FLAG "0"
@@ -47,6 +49,7 @@ class Indentor;
class AbstractMetaType;
QT_BEGIN_NAMESPACE
+class QDebug;
class QTextStream;
QT_END_NAMESPACE
@@ -59,7 +62,6 @@ class TemplateInstance;
struct ReferenceCount
{
- ReferenceCount() {}
enum Action { // 0x01 - 0xff
Invalid = 0x00,
Add = 0x01,
@@ -73,8 +75,8 @@ struct ReferenceCount
Padding = 0xffffffff
};
- Action action;
QString varName;
+ Action action = Invalid;
};
struct ArgumentOwner
@@ -90,27 +92,23 @@ struct ArgumentOwner
ReturnIndex = 0,
FirstArgumentIndex = 1
};
- ArgumentOwner() : action(ArgumentOwner::Invalid), index(ArgumentOwner::InvalidIndex) {}
- Action action;
- int index;
+ Action action = Invalid;
+ int index = InvalidIndex;
};
class CodeSnipFragment
{
-private:
- QString m_code;
- TemplateInstance *m_instance;
-
public:
- CodeSnipFragment(const QString &code)
- : m_code(code),
- m_instance(0) {}
-
- CodeSnipFragment(TemplateInstance *instance)
- : m_instance(instance) {}
+ CodeSnipFragment() = default;
+ explicit CodeSnipFragment(const QString &code) : m_code(code) {}
+ explicit CodeSnipFragment(TemplateInstance *instance) : m_instance(instance) {}
QString code() const;
+
+private:
+ QString m_code;
+ TemplateInstance *m_instance = nullptr;
};
class CodeSnipAbstract
@@ -126,13 +124,13 @@ public:
codeList.append(CodeSnipFragment(ti));
}
- QList<CodeSnipFragment> codeList;
+ QVector<CodeSnipFragment> codeList;
};
class CustomFunction : public CodeSnipAbstract
{
public:
- CustomFunction(const QString &n = QString()) : name(n) { }
+ explicit CustomFunction(const QString &n = QString()) : name(n) {}
QString name;
QString paramName;
@@ -141,31 +139,21 @@ public:
class TemplateEntry : public CodeSnipAbstract
{
public:
- TemplateEntry(const QString &name, double vr)
- : m_name(name), m_version(vr)
- {
- };
+ explicit TemplateEntry(const QString &name) : m_name(name) {}
QString name() const
{
return m_name;
- };
-
- double version() const
- {
- return m_version;
}
private:
QString m_name;
- double m_version;
};
class TemplateInstance
{
public:
- TemplateInstance(const QString &name, double vr)
- : m_name(name), m_version(vr) {}
+ explicit TemplateInstance(const QString &name) : m_name(name) {}
void addReplaceRule(const QString &name, const QString &value)
{
@@ -179,14 +167,8 @@ public:
return m_name;
}
- double version() const
- {
- return m_version;
- }
-
private:
const QString m_name;
- double m_version;
QHash<QString, QString> replaceRules;
};
@@ -194,32 +176,26 @@ private:
class CodeSnip : public CodeSnipAbstract
{
public:
- CodeSnip(double vr) : language(TypeSystem::TargetLangCode), version(vr) { }
- CodeSnip(double vr, TypeSystem::Language lang) : language(lang), version(vr) { }
+ CodeSnip() = default;
+ explicit CodeSnip(TypeSystem::Language lang) : language(lang) {}
- TypeSystem::Language language;
- TypeSystem::CodeSnipPosition position;
+ TypeSystem::Language language = TypeSystem::TargetLangCode;
+ TypeSystem::CodeSnipPosition position = TypeSystem::CodeSnipPositionAny;
ArgumentMap argumentMap;
- double version;
};
struct ArgumentModification
{
- ArgumentModification(int idx, double vr)
- : removedDefaultExpression(false), removed(false),
- noNullPointers(false), index(idx), version(vr) {}
+ ArgumentModification() : removedDefaultExpression(false), removed(false),
+ noNullPointers(false), array(false) {}
+ explicit ArgumentModification(int idx) : index(idx), removedDefaultExpression(false), removed(false),
+ noNullPointers(false), array(false) {}
// Should the default expression be removed?
- uint removedDefaultExpression : 1;
- uint removed : 1;
- uint noNullPointers : 1;
- uint resetAfterUse : 1;
- // The index of this argument
- int index;
// Reference count flags for this argument
- QList<ReferenceCount> referenceCounts;
+ QVector<ReferenceCount> referenceCounts;
// The text given for the new type of the argument
QString modified_type;
@@ -244,11 +220,17 @@ struct ArgumentModification
//QObject parent(owner) of this argument
ArgumentOwner owner;
- //Api version
- double version;
-
//New name
QString renamed_to;
+
+ // The index of this argument
+ int index = -1;
+
+ uint removedDefaultExpression : 1;
+ uint removed : 1;
+ uint noNullPointers : 1;
+ uint resetAfterUse : 1;
+ uint array : 1; // consider "int*" to be "int[]"
};
struct Modification
@@ -274,8 +256,6 @@ struct Modification
VirtualSlot = 0x10000 | NonFinal
};
- Modification() : modifiers(0), removal(TypeSystem::NoLanguage) { }
-
bool isAccessModifier() const
{
return modifiers & AccessModifierMask;
@@ -337,15 +317,13 @@ struct Modification
return removal != TypeSystem::NoLanguage;
}
- uint modifiers;
QString renamedToName;
- TypeSystem::Language removal;
+ uint modifiers = 0;
+ TypeSystem::Language removal = TypeSystem::NoLanguage;
};
struct FunctionModification: public Modification
{
- FunctionModification(double vr) : m_thread(false), m_allowThread(false), m_version(vr) {}
-
bool isCodeInjection() const
{
return modifiers & CodeInjection;
@@ -366,31 +344,29 @@ struct FunctionModification: public Modification
{
m_allowThread = allow;
}
- double version() const
+
+ bool matches(const QString &functionSignature) const
{
- return m_version;
+ return m_signature.isEmpty()
+ ? m_signaturePattern.match(functionSignature).hasMatch()
+ : m_signature == functionSignature;
}
- bool operator!=(const FunctionModification& other) const;
- bool operator==(const FunctionModification& other) const;
-
+ bool setSignature(const QString &s, QString *errorMessage = nullptr);
+ QString signature() const { return m_signature.isEmpty() ? m_signaturePattern.pattern() : m_signature; }
QString toString() const;
- QString signature;
QString association;
CodeSnipList snips;
- QList<ArgumentModification> argument_mods;
+ QVector<ArgumentModification> argument_mods;
private:
- FunctionModification() {}
-
- bool m_thread;
- bool m_allowThread;
- double m_version;
-
-
+ QString m_signature;
+ QRegularExpression m_signaturePattern;
+ bool m_thread = false;
+ bool m_allowThread = false;
};
struct FieldModification: public Modification
@@ -428,18 +404,19 @@ struct AddedFunction
* AbstractMetaType and AbstractMetaArgument for the AbstractMetaFunctions.
*/
struct TypeInfo {
- TypeInfo() : isConstant(false), indirections(0), isReference(false) {}
+ TypeInfo() = default;
static TypeInfo fromSignature(const QString& signature);
QString name;
- bool isConstant;
- int indirections;
- bool isReference;
QString defaultValue;
+ int indirections = 0;
+ bool isConstant = false;
+ bool isReference = false;
};
/// Creates a new AddedFunction with a signature and a return type.
- AddedFunction(QString signature, QString returnType, double vr);
+ explicit AddedFunction(QString signature, QString returnType, double vr);
+ AddedFunction() = default;
/// Returns the function name.
QString name() const
@@ -466,7 +443,7 @@ struct AddedFunction
}
/// Returns a list of argument type infos.
- QList<TypeInfo> arguments() const
+ QVector<TypeInfo> arguments() const
{
return m_arguments;
}
@@ -495,12 +472,12 @@ struct AddedFunction
}
private:
QString m_name;
- Access m_access;
- QList<TypeInfo> m_arguments;
+ QVector<TypeInfo> m_arguments;
TypeInfo m_returnType;
- bool m_isConst;
- bool m_isStatic;
- double m_version;
+ double m_version = 0;
+ Access m_access = Protected;
+ bool m_isConst = false;
+ bool m_isStatic = false;
};
#ifndef QT_NO_DEBUG_STREAM
@@ -508,28 +485,17 @@ QDebug operator<<(QDebug d, const AddedFunction::TypeInfo &ti);
QDebug operator<<(QDebug d, const AddedFunction &af);
#endif
-struct ExpensePolicy
-{
- ExpensePolicy() : limit(-1) {}
- int limit;
- QString cost;
- bool isValid() const
- {
- return limit >= 0;
- }
-};
-
class InterfaceTypeEntry;
class ObjectTypeEntry;
class DocModification
{
public:
- DocModification(const QString& xpath, const QString& signature, double vr)
- : format(TypeSystem::NativeCode), m_mode(TypeSystem::DocModificationXPathReplace),
- m_xpath(xpath), m_signature(signature), m_version(vr) {}
- DocModification(TypeSystem::DocModificationMode mode, const QString& signature, double vr)
- : m_mode(mode), m_signature(signature), m_version(vr) {}
+ DocModification() = default;
+ explicit DocModification(const QString& xpath, const QString& signature) :
+ m_xpath(xpath), m_signature(signature) {}
+ explicit DocModification(TypeSystem::DocModificationMode mode, const QString& signature) :
+ m_signature(signature), m_mode(mode) {}
void setCode(const QString& code) { m_code = code; }
void setCode(const QStringRef& code) { m_code = code.toString(); }
@@ -550,25 +516,23 @@ public:
{
return m_mode;
}
- double version() const
- {
- return m_version;
- }
- TypeSystem::Language format;
+ TypeSystem::Language format() const { return m_format; }
+ void setFormat(TypeSystem::Language f) { m_format = f; }
private:
- TypeSystem::DocModificationMode m_mode;
QString m_code;
QString m_xpath;
QString m_signature;
- double m_version;
+ TypeSystem::DocModificationMode m_mode = TypeSystem::DocModificationXPathReplace;
+ TypeSystem::Language m_format = TypeSystem::NativeCode;
};
class CustomConversion;
class TypeEntry
{
+ Q_DISABLE_COPY(TypeEntry)
Q_GADGET
public:
enum Type {
@@ -609,15 +573,7 @@ public:
};
Q_ENUM(CodeGeneration)
- TypeEntry(const QString &name, Type t, double vr)
- : m_name(name),
- m_type(t),
- m_codeGeneration(GenerateAll),
- m_preferredConversion(true),
- m_stream(false),
- m_version(vr)
- {
- };
+ explicit TypeEntry(const QString &name, Type t, double vr);
virtual ~TypeEntry();
@@ -882,7 +838,13 @@ public:
}
void setInclude(const Include &inc)
{
- m_include = inc;
+ // This is a workaround for preventing double inclusion of the QSharedPointer implementation
+ // header, which does not use header guards. In the previous parser this was not a problem
+ // because the Q_QDOC define was set, and the implementation header was never included.
+ if (inc.name() == QLatin1String("qsharedpointer_impl.h"))
+ m_include = Include(inc.type(), QLatin1String("qsharedpointer.h"));
+ else
+ m_include = inc;
}
// Replace conversionRule arg to CodeSnip in future version
@@ -930,48 +892,42 @@ public:
private:
QString m_name;
Type m_type;
- uint m_codeGeneration;
+ uint m_codeGeneration = GenerateAll;
CustomFunction m_customConstructor;
CustomFunction m_customDestructor;
- bool m_preferredConversion;
+ bool m_preferredConversion = true;
CodeSnipList m_codeSnips;
DocModificationList m_docModifications;
IncludeList m_extraIncludes;
Include m_include;
QHash<QString, bool> m_includesUsed;
QString m_conversionRule;
- bool m_stream;
+ bool m_stream = false;
double m_version;
};
class TypeSystemTypeEntry : public TypeEntry
{
public:
- TypeSystemTypeEntry(const QString &name, double vr)
- : TypeEntry(name, TypeSystemType, vr)
- {
- };
+ explicit TypeSystemTypeEntry(const QString &name, double vr);
};
class VoidTypeEntry : public TypeEntry
{
public:
- VoidTypeEntry() : TypeEntry(QLatin1String("void"), VoidType, 0) { }
+ VoidTypeEntry();
};
class VarargsTypeEntry : public TypeEntry
{
public:
- VarargsTypeEntry() : TypeEntry(QLatin1String("..."), VarargsType, 0) { }
+ VarargsTypeEntry();
};
class TemplateArgumentEntry : public TypeEntry
{
public:
- TemplateArgumentEntry(const QString &name, double vr)
- : TypeEntry(name, TemplateArgumentType, vr), m_ordinal(0)
- {
- }
+ explicit TemplateArgumentEntry(const QString &name, double vr);
int ordinal() const
{
@@ -983,17 +939,13 @@ public:
}
private:
- int m_ordinal;
+ int m_ordinal = 0;
};
class ArrayTypeEntry : public TypeEntry
{
public:
- ArrayTypeEntry(const TypeEntry *nested_type, double vr)
- : TypeEntry(QLatin1String("Array"), ArrayType, vr), m_nestedType(nested_type)
- {
- Q_ASSERT(m_nestedType);
- }
+ explicit ArrayTypeEntry(const TypeEntry *nested_type, double vr);
void setNestedTypeEntry(TypeEntry *nested)
{
@@ -1004,17 +956,8 @@ public:
return m_nestedType;
}
- QString targetLangName() const
- {
- return m_nestedType->targetLangName() + QLatin1String("[]");
- }
- QString targetLangApiName() const
- {
- if (m_nestedType->isPrimitive())
- return m_nestedType->targetLangApiName() + QLatin1String("Array");
- else
- return QLatin1String("jobjectArray");
- }
+ QString targetLangName() const override;
+ QString targetLangApiName() const override;
private:
const TypeEntry *m_nestedType;
@@ -1024,27 +967,15 @@ private:
class PrimitiveTypeEntry : public TypeEntry
{
public:
- PrimitiveTypeEntry(const QString &name, double vr)
- : TypeEntry(name, PrimitiveType, vr),
- m_preferredConversion(true),
- m_preferredTargetLangType(true),
- m_referencedTypeEntry(0)
- {
- }
+ explicit PrimitiveTypeEntry(const QString &name, double vr);
- QString targetLangName() const
- {
- return m_targetLangName;
- }
+ QString targetLangName() const override;
void setTargetLangName(const QString &targetLangName)
{
m_targetLangName = targetLangName;
}
- QString targetLangApiName() const
- {
- return m_targetLangApiName;
- }
+ QString targetLangApiName() const override;
void setTargetLangApiName(const QString &targetLangApiName)
{
m_targetLangApiName = targetLangApiName;
@@ -1088,37 +1019,32 @@ public:
*/
PrimitiveTypeEntry* basicReferencedTypeEntry() const;
- virtual bool preferredConversion() const
- {
- return m_preferredConversion;
- }
- virtual void setPreferredConversion(bool b)
- {
- m_preferredConversion = b;
- }
+ bool preferredConversion() const override;
+ void setPreferredConversion(bool b) override;
- virtual bool preferredTargetLangType() const
+ bool preferredTargetLangType() const
{
return m_preferredTargetLangType;
}
- virtual void setPreferredTargetLangType(bool b)
+ void setPreferredTargetLangType(bool b)
{
m_preferredTargetLangType = b;
}
void setTargetLangPackage(const QString& package);
- QString targetLangPackage() const;
+ QString targetLangPackage() const override;
private:
QString m_targetLangName;
QString m_targetLangApiName;
QString m_defaultConstructor;
uint m_preferredConversion : 1;
uint m_preferredTargetLangType : 1;
- PrimitiveTypeEntry* m_referencedTypeEntry;
+ PrimitiveTypeEntry* m_referencedTypeEntry = nullptr;
};
struct EnumValueRedirection
{
+ EnumValueRedirection() {}
EnumValueRedirection(const QString &rej, const QString &us)
: rejected(rej),
used(us)
@@ -1131,48 +1057,16 @@ struct EnumValueRedirection
class EnumTypeEntry : public TypeEntry
{
public:
- EnumTypeEntry(const QString &nspace, const QString &enumName, double vr)
- : TypeEntry(nspace.isEmpty() ? enumName : nspace + QLatin1String("::") + enumName,
- EnumType, vr),
- m_qualifier(nspace),
- m_targetLangName(enumName),
- m_flags(0),
- m_extensible(false),
- m_forceInteger(false),
- m_anonymous(false)
- {
- }
+ explicit EnumTypeEntry(const QString &nspace, const QString &enumName, double vr);
- QString targetLangPackage() const
- {
- return m_packageName;
- }
- void setTargetLangPackage(const QString &package)
- {
- m_packageName = package;
- }
+ QString targetLangPackage() const override;
+ void setTargetLangPackage(const QString &package);
- QString targetLangName() const
- {
- return m_targetLangName;
- }
+ QString targetLangName() const override;
QString targetLangQualifier() const;
- QString qualifiedTargetLangName() const
- {
- QString qualifiedName;
- QString pkg = targetLangPackage();
- QString qualifier = targetLangQualifier();
-
- if (!pkg.isEmpty())
- qualifiedName += pkg + QLatin1Char('.');
- if (!qualifier.isEmpty())
- qualifiedName += qualifier + QLatin1Char('.');
- qualifiedName += targetLangName();
-
- return qualifiedName;
- }
+ QString qualifiedTargetLangName() const override;
- QString targetLangApiName() const;
+ QString targetLangApiName() const override;
QString qualifier() const
{
@@ -1183,10 +1077,7 @@ public:
m_qualifier = q;
}
- virtual bool preferredConversion() const
- {
- return false;
- }
+ bool preferredConversion() const override;
bool isBoundsChecked() const
{
@@ -1272,22 +1163,19 @@ private:
QString m_upperBound;
QStringList m_rejectedEnums;
- QList<EnumValueRedirection> m_enumRedirections;
+ QVector<EnumValueRedirection> m_enumRedirections;
- FlagsTypeEntry *m_flags;
+ FlagsTypeEntry *m_flags = nullptr;
- bool m_extensible;
- bool m_forceInteger;
- bool m_anonymous;
+ bool m_extensible = false;
+ bool m_forceInteger = false;
+ bool m_anonymous = false;
};
class EnumValueTypeEntry : public TypeEntry
{
public:
- EnumValueTypeEntry(const QString& name, const QString& value, const EnumTypeEntry* enclosingEnum, double vr)
- : TypeEntry(name, TypeEntry::EnumValue, vr), m_value(value), m_enclosingEnum(enclosingEnum)
- {
- }
+ explicit EnumValueTypeEntry(const QString& name, const QString& value, const EnumTypeEntry* enclosingEnum, double vr);
QString value() const { return m_value; }
const EnumTypeEntry* enclosingEnum() const { return m_enclosingEnum; }
@@ -1299,20 +1187,12 @@ private:
class FlagsTypeEntry : public TypeEntry
{
public:
- FlagsTypeEntry(const QString &name, double vr) : TypeEntry(name, FlagsType, vr), m_enum(0)
- {
- }
+ explicit FlagsTypeEntry(const QString &name, double vr);
- QString qualifiedTargetLangName() const;
- QString targetLangName() const
- {
- return m_targetLangName;
- }
- QString targetLangApiName() const;
- virtual bool preferredConversion() const
- {
- return false;
- }
+ QString qualifiedTargetLangName() const override;
+ QString targetLangName() const override;
+ QString targetLangApiName() const override;
+ bool preferredConversion() const override;
QString originalName() const
{
@@ -1346,15 +1226,12 @@ public:
m_enum = e;
}
- QString targetLangPackage() const
- {
- return m_enum->targetLangPackage();
- }
+ QString targetLangPackage() const override;
private:
QString m_originalName;
QString m_targetLangName;
- EnumTypeEntry *m_enum;
+ EnumTypeEntry *m_enum = nullptr;
};
@@ -1374,52 +1251,18 @@ public:
Unknown
};
- ComplexTypeEntry(const QString &name, Type t, double vr)
- : TypeEntry(QString(name).replace(QLatin1String(".*::"), QString()), t, vr),
- m_qualifiedCppName(name),
- m_qobject(false),
- m_polymorphicBase(false),
- m_genericClass(false),
- m_typeFlags(0),
- m_copyableFlag(Unknown),
- m_baseContainerType(0)
- {
- }
-
- bool isComplex() const
- {
- return true;
- }
-
- ComplexTypeEntry *copy() const
- {
- ComplexTypeEntry *centry = new ComplexTypeEntry(name(), type(), version());
- centry->setInclude(include());
- centry->setExtraIncludes(extraIncludes());
- centry->setAddedFunctions(addedFunctions());
- centry->setFunctionModifications(functionModifications());
- centry->setFieldModifications(fieldModifications());
- centry->setQObject(isQObject());
- centry->setDefaultSuperclass(defaultSuperclass());
- centry->setCodeSnips(codeSnips());
- centry->setTargetLangPackage(targetLangPackage());
- centry->setBaseContainerType(baseContainerType());
- centry->setDefaultConstructor(defaultConstructor());
+ explicit ComplexTypeEntry(const QString &name, Type t, double vr);
- return centry;
- }
+ bool isComplex() const override;
void setLookupName(const QString &name)
{
m_lookupName = name;
}
- virtual QString lookupName() const
- {
- return m_lookupName.isEmpty() ? targetLangName() : m_lookupName;
- }
+ QString lookupName() const override;
- QString targetLangApiName() const;
+ QString targetLangApiName() const override;
void setTypeFlags(TypeFlags flags)
{
@@ -1468,10 +1311,7 @@ public:
return m_fieldMods;
}
- QString targetLangPackage() const
- {
- return m_package;
- }
+ QString targetLangPackage() const override;
void setTargetLangPackage(const QString &package)
{
m_package = package;
@@ -1495,7 +1335,7 @@ public:
m_defaultSuperclass = sc;
}
- virtual QString qualifiedCppName() const
+ QString qualifiedCppName() const override
{
return m_qualifiedCppName;
}
@@ -1528,16 +1368,6 @@ public:
return m_heldTypeValue;
}
-
- void setExpensePolicy(const ExpensePolicy &policy)
- {
- m_expensePolicy = policy;
- }
- const ExpensePolicy &expensePolicy() const
- {
- return m_expensePolicy;
- }
-
QString targetType() const
{
return m_targetType;
@@ -1547,12 +1377,7 @@ public:
m_targetType = code;
}
- QString targetLangName() const
- {
- return m_targetLangName.isEmpty()
- ? TypeEntry::targetLangName()
- : m_targetLangName;
- }
+ QString targetLangName() const override;
void setTargetLangName(const QString &name)
{
m_targetLangName = name;
@@ -1616,12 +1441,11 @@ private:
QString m_heldTypeValue;
QString m_lookupName;
QString m_targetType;
- ExpensePolicy m_expensePolicy;
TypeFlags m_typeFlags;
- CopyableFlag m_copyableFlag;
+ CopyableFlag m_copyableFlag = Unknown;
QString m_hashFunction;
- const ComplexTypeEntry* m_baseContainerType;
+ const ComplexTypeEntry* m_baseContainerType = nullptr;
};
class ContainerTypeEntry : public ComplexTypeEntry
@@ -1645,11 +1469,7 @@ public:
};
Q_ENUM(Type)
- ContainerTypeEntry(const QString &name, Type type, double vr)
- : ComplexTypeEntry(name, ContainerType, vr), m_type(type)
- {
- setCodeGeneration(GenerateForSubclass);
- }
+ explicit ContainerTypeEntry(const QString &name, Type type, double vr);
Type type() const
{
@@ -1657,9 +1477,9 @@ public:
}
QString typeName() const;
- QString targetLangName() const;
- QString targetLangPackage() const;
- QString qualifiedCppName() const;
+ QString targetLangName() const override;
+ QString targetLangPackage() const override;
+ QString qualifiedCppName() const override;
static Type containerTypeFromString(QString typeName)
{
@@ -1688,17 +1508,11 @@ private:
class SmartPointerTypeEntry : public ComplexTypeEntry
{
public:
- SmartPointerTypeEntry(const QString &name,
- const QString &getterName,
- const QString &smartPointerType,
- const QString &refCountMethodName,
- double vr)
- : ComplexTypeEntry(name, SmartPointerType, vr),
- m_getterName(getterName),
- m_smartPointerType(smartPointerType),
- m_refCountMethodName(refCountMethodName)
- {
- }
+ explicit SmartPointerTypeEntry(const QString &name,
+ const QString &getterName,
+ const QString &smartPointerType,
+ const QString &refCountMethodName,
+ double vr);
QString getter() const
{
@@ -1719,91 +1533,65 @@ private:
class NamespaceTypeEntry : public ComplexTypeEntry
{
public:
- NamespaceTypeEntry(const QString &name, double vr) : ComplexTypeEntry(name, NamespaceType, vr) { }
+ explicit NamespaceTypeEntry(const QString &name, double vr);
};
class ValueTypeEntry : public ComplexTypeEntry
{
public:
- ValueTypeEntry(const QString &name, double vr) : ComplexTypeEntry(name, BasicValueType, vr) { }
+ explicit ValueTypeEntry(const QString &name, double vr);
- bool isValue() const
- {
- return true;
- }
+ bool isValue() const override;
- virtual bool isNativeIdBased() const
- {
- return true;
- }
+ bool isNativeIdBased() const override;
protected:
- ValueTypeEntry(const QString &name, Type t, double vr) : ComplexTypeEntry(name, t, vr) { }
+ explicit ValueTypeEntry(const QString &name, Type t, double vr);
};
class StringTypeEntry : public ValueTypeEntry
{
public:
- StringTypeEntry(const QString &name, double vr)
- : ValueTypeEntry(name, StringType, vr)
- {
- setCodeGeneration(GenerateNothing);
- }
+ explicit StringTypeEntry(const QString &name, double vr);
- QString targetLangApiName() const;
- QString targetLangName() const;
- QString targetLangPackage() const;
+ QString targetLangApiName() const override;
+ QString targetLangName() const override;
+ QString targetLangPackage() const override;
- virtual bool isNativeIdBased() const
- {
- return false;
- }
+ bool isNativeIdBased() const override;
};
class CharTypeEntry : public ValueTypeEntry
{
public:
- CharTypeEntry(const QString &name, double vr) : ValueTypeEntry(name, CharType, vr)
- {
- setCodeGeneration(GenerateNothing);
- }
+ explicit CharTypeEntry(const QString &name, double vr);
- QString targetLangApiName() const;
- QString targetLangName() const;
- QString targetLangPackage() const
- {
- return QString();
- }
+ QString targetLangApiName() const override;
+ QString targetLangName() const override;
+ QString targetLangPackage() const override;
- virtual bool isNativeIdBased() const
- {
- return false;
- }
+ bool isNativeIdBased() const override;
};
class VariantTypeEntry: public ValueTypeEntry
{
public:
- VariantTypeEntry(const QString &name, double vr) : ValueTypeEntry(name, VariantType, vr) { }
+ explicit VariantTypeEntry(const QString &name, double vr);
- QString targetLangApiName() const;
- QString targetLangName() const;
- QString targetLangPackage() const;
+ QString targetLangApiName() const override;
+ QString targetLangName() const override;
+ QString targetLangPackage() const override;
- virtual bool isNativeIdBased() const
- {
- return false;
- }
+ bool isNativeIdBased() const override;
};
class InterfaceTypeEntry : public ComplexTypeEntry
{
public:
- InterfaceTypeEntry(const QString &name, double vr)
- : ComplexTypeEntry(name, InterfaceType, vr) {}
+ explicit InterfaceTypeEntry(const QString &name, double vr);
static QString interfaceName(const QString &name)
{
@@ -1819,15 +1607,8 @@ public:
m_origin = origin;
}
- virtual bool isNativeIdBased() const
- {
- return true;
- }
- virtual QString qualifiedCppName() const
- {
- const int len = ComplexTypeEntry::qualifiedCppName().length() - interfaceName(QString()).length();
- return ComplexTypeEntry::qualifiedCppName().left(len);
- }
+ bool isNativeIdBased() const override;
+ QString qualifiedCppName() const override;
private:
ObjectTypeEntry *m_origin;
@@ -1837,11 +1618,7 @@ private:
class FunctionTypeEntry : public TypeEntry
{
public:
- FunctionTypeEntry(const QString& name, const QString& signature, double vr)
- : TypeEntry(name, FunctionType, vr)
- {
- addSignature(signature);
- }
+ explicit FunctionTypeEntry(const QString& name, const QString& signature, double vr);
void addSignature(const QString& signature)
{
m_signatures << signature;
@@ -1863,35 +1640,41 @@ private:
class ObjectTypeEntry : public ComplexTypeEntry
{
public:
- ObjectTypeEntry(const QString &name, double vr)
- : ComplexTypeEntry(name, ObjectType, vr), m_interface(0) {}
+ explicit ObjectTypeEntry(const QString &name, double vr);
- InterfaceTypeEntry *designatedInterface() const
- {
- return m_interface;
- }
+ InterfaceTypeEntry *designatedInterface() const override;
void setDesignatedInterface(InterfaceTypeEntry *entry)
{
m_interface = entry;
}
- virtual bool isNativeIdBased() const
- {
- return true;
- }
+ bool isNativeIdBased() const override;
private:
- InterfaceTypeEntry *m_interface;
+ InterfaceTypeEntry *m_interface = nullptr;
};
struct TypeRejection
{
- QString class_name;
- QString function_name;
- QString field_name;
- QString enum_name;
+ enum MatchType
+ {
+ ExcludeClass, // Match className only
+ Function, // Match className and function name
+ Field, // Match className and field name
+ Enum, // Match className and enum name
+ ArgumentType, // Match className and argument type
+ ReturnType // Match className and return type
+ };
+
+ QRegularExpression className;
+ QRegularExpression pattern;
+ MatchType matchType;
};
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const TypeRejection &r);
+#endif
+
QString fixCppTypeName(const QString &name);
class CustomConversion
@@ -1932,7 +1715,7 @@ public:
bool replaceOriginalTargetToNativeConversions() const;
void setReplaceOriginalTargetToNativeConversions(bool replaceOriginalTargetToNativeConversions);
- typedef QList<TargetToNativeConversion*> TargetToNativeConversions;
+ typedef QVector<TargetToNativeConversion*> TargetToNativeConversions;
bool hasTargetToNativeConversions() const;
TargetToNativeConversions& targetToNativeConversions();
const TargetToNativeConversions& targetToNativeConversions() const;