diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-12-04 11:32:11 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-12-05 20:24:16 +0000 |
commit | a983ea88d1fa4263f2bbc3eb46241d9fd5965fed (patch) | |
tree | f09bd37cd04e9e5b92b32d3fa715a163aa740042 /sources/shiboken2/ApiExtractor | |
parent | e4b83104be7de56ca4a6959f84624c546ea8cd38 (diff) |
shiboken: Unify constructors of the MetaLang* classes
Use member initialization where possible. Move constructors/destructors
of classes in hierarchies out of line (fixing Clang warnings about
classes having no virtual out of line methods).
Change-Id: I511e7261a077db259e6c305cb1dcb08c1ee4810f
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetalang.cpp | 76 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetalang.h | 142 |
2 files changed, 110 insertions, 108 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index c011c9b08..6f57527f7 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -59,6 +59,13 @@ QDebug operator<<(QDebug d, const AbstractMetaAttributes *aa) * AbstractMetaVariable */ +AbstractMetaVariable::AbstractMetaVariable() = default; + +AbstractMetaVariable::~AbstractMetaVariable() +{ + delete m_type; +} + AbstractMetaVariable::AbstractMetaVariable(const AbstractMetaVariable &other) { m_originalName = other.m_originalName; @@ -86,20 +93,21 @@ QDebug operator<<(QDebug d, const AbstractMetaVariable *av) #endif // !QT_NO_DEBUG_STREAM /******************************************************************************* + * AbstractMetaAttributes + */ + +AbstractMetaAttributes::AbstractMetaAttributes() = default; +AbstractMetaAttributes::~AbstractMetaAttributes() = default; + +/******************************************************************************* * AbstractMetaType */ -AbstractMetaType::AbstractMetaType() - :m_typeEntry(0), - m_arrayElementCount(-1), - m_arrayElementType(0), - m_originalTemplateType(0), - m_pattern(InvalidPattern), +AbstractMetaType::AbstractMetaType() : m_constant(false), m_cppInstantiation(true), m_indirections(0), - m_reserved(0), - m_referenceType(NoReference) + m_reserved(0) { } @@ -325,6 +333,9 @@ QDebug operator<<(QDebug d, const AbstractMetaType *at) /******************************************************************************* * AbstractMetaArgument */ + +AbstractMetaArgument::AbstractMetaArgument() = default; + AbstractMetaArgument *AbstractMetaArgument::copy() const { return new AbstractMetaArgument(*this); @@ -349,6 +360,17 @@ QDebug operator<<(QDebug d, const AbstractMetaArgument *aa) /******************************************************************************* * AbstractMetaFunction */ + +AbstractMetaFunction::AbstractMetaFunction() + : m_constant(false), + m_reverse(false), + m_userAdded(false), + m_explicit(false), + m_pointerOperator(false), + m_isCallOperator(false) +{ +} + AbstractMetaFunction::~AbstractMetaFunction() { qDeleteAll(m_arguments); @@ -1285,6 +1307,26 @@ QDebug operator<<(QDebug d, const AbstractMetaFunction *af) /******************************************************************************* * AbstractMetaClass */ + +AbstractMetaClass::AbstractMetaClass() + : m_hasVirtuals(false), + m_isPolymorphic(false), + m_hasNonpublic(false), + m_hasVirtualSlots(false), + m_hasNonPrivateConstructor(false), + m_functionsFixed(false), + m_hasPrivateDestructor(false), + m_hasProtectedDestructor(false), + m_hasVirtualDestructor(false), + m_forceShellClass(false), + m_hasHashFunction(false), + m_hasEqualsOperator(false), + m_hasCloneOperator(false), + m_isTypeDef(false), + m_hasToStringCapability(false) +{ +} + AbstractMetaClass::~AbstractMetaClass() { qDeleteAll(m_functions); @@ -1807,9 +1849,7 @@ static bool functions_contains(const AbstractMetaFunctionList &l, const Abstract return false; } -AbstractMetaField::AbstractMetaField() : m_getter(0), m_setter(0), m_class(0) -{ -} +AbstractMetaField::AbstractMetaField() = default; AbstractMetaField::~AbstractMetaField() { @@ -2797,6 +2837,20 @@ QDebug operator<<(QDebug d, const AbstractMetaClass *ac) } #endif // !QT_NO_DEBUG_STREAM +/******************************************************************************* +* AbstractMetaEnum +*/ + +AbstractMetaEnum::AbstractMetaEnum() : + m_hasQenumsDeclaration(false) +{ +} + +AbstractMetaEnum::~AbstractMetaEnum() +{ + qDeleteAll(m_enumValues); +} + QString AbstractMetaEnum::name() const { return m_typeEntry->targetLangName(); diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h index 6bf71c0b6..d30e70c4a 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.h +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h @@ -71,8 +71,7 @@ public: Target }; - Documentation() - : m_format(Documentation::Native) {} + Documentation() {} Documentation(const QString& value, Format fmt = Documentation::Native) : m_data(value), m_format(fmt) {} @@ -94,7 +93,7 @@ public: private: QString m_data; - Format m_format; + Format m_format = Documentation::Native; }; @@ -102,7 +101,8 @@ class AbstractMetaAttributes { Q_GADGET public: - AbstractMetaAttributes() : m_attributes(0), m_originalAttributes(0) {}; + AbstractMetaAttributes(); + virtual ~AbstractMetaAttributes(); enum Attribute { None = 0x00000000, @@ -604,26 +604,26 @@ private: TypeUsagePattern determineUsagePattern() const; QString formatSignature(bool minimal) const; - const TypeEntry *m_typeEntry; + const TypeEntry *m_typeEntry = nullptr; AbstractMetaTypeList m_instantiations; QString m_package; mutable QString m_name; mutable QString m_cachedCppSignature; QString m_originalTypeDescription; - int m_arrayElementCount; - const AbstractMetaType *m_arrayElementType; - const AbstractMetaType *m_originalTemplateType; + int m_arrayElementCount = -1; + const AbstractMetaType *m_arrayElementType = nullptr; + const AbstractMetaType *m_originalTemplateType = nullptr; - TypeUsagePattern m_pattern; + TypeUsagePattern m_pattern = InvalidPattern; uint m_constant : 1; uint m_cppInstantiation : 1; int m_indirections : 4; uint m_reserved : 26; // unused - ReferenceType m_referenceType; + ReferenceType m_referenceType = NoReference; AbstractMetaTypeList m_children; - Q_DISABLE_COPY(AbstractMetaType); + Q_DISABLE_COPY(AbstractMetaType) }; #ifndef QT_NO_DEBUG_STREAM @@ -633,13 +633,10 @@ QDebug operator<<(QDebug d, const AbstractMetaType *at); class AbstractMetaVariable { public: - AbstractMetaVariable() : m_type(0), m_hasName(false) {} + AbstractMetaVariable(); AbstractMetaVariable(const AbstractMetaVariable &other); - virtual ~AbstractMetaVariable() - { - delete m_type; - } + virtual ~AbstractMetaVariable(); AbstractMetaType *type() const { @@ -690,8 +687,8 @@ public: private: QString m_originalName; QString m_name; - AbstractMetaType *m_type; - bool m_hasName; + AbstractMetaType *m_type = nullptr; + bool m_hasName = false; Documentation m_doc; }; @@ -703,7 +700,7 @@ QDebug operator<<(QDebug d, const AbstractMetaVariable *av); class AbstractMetaArgument : public AbstractMetaVariable { public: - AbstractMetaArgument() : m_argumentIndex(0) {}; + AbstractMetaArgument(); QString defaultValueExpression() const { @@ -742,7 +739,7 @@ public: private: QString m_expression; QString m_originalExpression; - int m_argumentIndex; + int m_argumentIndex = 0; friend class AbstractMetaClass; }; @@ -779,9 +776,9 @@ public: AbstractMetaField *copy() const; private: - mutable AbstractMetaFunction *m_getter; - mutable AbstractMetaFunction *m_setter; - const AbstractMetaClass *m_class; + mutable AbstractMetaFunction *m_getter = nullptr; + mutable AbstractMetaFunction *m_setter = nullptr; + const AbstractMetaClass *m_class = nullptr; }; #ifndef QT_NO_DEBUG_STREAM @@ -825,23 +822,7 @@ public: Q_DECLARE_FLAGS(CompareResult, CompareResultFlag) Q_FLAG(CompareResultFlag) - AbstractMetaFunction() - : m_typeEntry(0), - m_functionType(NormalFunction), - m_type(0), - m_class(0), - m_implementingClass(0), - m_declaringClass(0), - m_propertySpec(0), - m_constant(false), - m_reverse(false), - m_userAdded(false), - m_explicit(false), - m_pointerOperator(false), - m_isCallOperator(false) - { - } - + AbstractMetaFunction(); ~AbstractMetaFunction(); QString name() const @@ -1188,13 +1169,13 @@ private: mutable QString m_cachedSignature; mutable QString m_cachedModifiedName; - FunctionTypeEntry* m_typeEntry; - FunctionType m_functionType; - AbstractMetaType *m_type; - const AbstractMetaClass *m_class; - const AbstractMetaClass *m_implementingClass; - const AbstractMetaClass *m_declaringClass; - QPropertySpec *m_propertySpec; + FunctionTypeEntry* m_typeEntry = nullptr; + FunctionType m_functionType = NormalFunction; + AbstractMetaType *m_type = nullptr; + const AbstractMetaClass *m_class = nullptr; + const AbstractMetaClass *m_implementingClass = nullptr; + const AbstractMetaClass *m_declaringClass = nullptr; + QPropertySpec *m_propertySpec = nullptr; AbstractMetaArgumentList m_arguments; uint m_constant : 1; uint m_reverse : 1; @@ -1213,10 +1194,7 @@ QDebug operator<<(QDebug d, const AbstractMetaFunction *af); class AbstractMetaEnumValue { public: - AbstractMetaEnumValue() - : m_valueSet(false), m_value(0) - { - } + AbstractMetaEnumValue() {} int value() const { @@ -1268,8 +1246,8 @@ private: QString m_name; QString m_stringValue; - bool m_valueSet; - int m_value; + bool m_valueSet = false; + int m_value = 0; Documentation m_doc; }; @@ -1277,11 +1255,8 @@ private: class AbstractMetaEnum : public AbstractMetaAttributes { public: - AbstractMetaEnum() : m_typeEntry(0), m_class(0), m_hasQenumsDeclaration(false) {} - ~AbstractMetaEnum() - { - qDeleteAll(m_enumValues); - } + AbstractMetaEnum(); + ~AbstractMetaEnum(); AbstractMetaEnumValueList values() const { @@ -1339,8 +1314,8 @@ public: private: AbstractMetaEnumValueList m_enumValues; - EnumTypeEntry *m_typeEntry; - AbstractMetaClass *m_class; + EnumTypeEntry *m_typeEntry = nullptr; + AbstractMetaClass *m_class = nullptr; uint m_hasQenumsDeclaration : 1; }; @@ -1406,32 +1381,8 @@ public: int access = Public; }; - AbstractMetaClass() - : m_hasVirtuals(false), - m_isPolymorphic(false), - m_hasNonpublic(false), - m_hasVirtualSlots(false), - m_hasNonPrivateConstructor(false), - m_functionsFixed(false), - m_hasPrivateDestructor(false), - m_hasProtectedDestructor(false), - m_hasVirtualDestructor(false), - m_forceShellClass(false), - m_hasHashFunction(false), - m_hasEqualsOperator(false), - m_hasCloneOperator(false), - m_isTypeDef(false), - m_hasToStringCapability(false), - m_enclosingClass(0), - m_baseClass(0), - m_templateBaseClass(0), - m_extractedInterface(0), - m_typeEntry(0), - m_stream(false) - { - } - - virtual ~AbstractMetaClass(); + AbstractMetaClass(); + ~AbstractMetaClass(); AbstractMetaClass *extractInterface(); void fixFunctions(); @@ -1846,14 +1797,14 @@ private: uint m_isTypeDef : 1; uint m_hasToStringCapability : 1; - const AbstractMetaClass *m_enclosingClass; - AbstractMetaClass *m_baseClass; - const AbstractMetaClass *m_templateBaseClass; + const AbstractMetaClass *m_enclosingClass = nullptr; + AbstractMetaClass *m_baseClass = nullptr; + const AbstractMetaClass *m_templateBaseClass = nullptr; AbstractMetaFunctionList m_functions; AbstractMetaFieldList m_fields; AbstractMetaEnumList m_enums; AbstractMetaClassList m_interfaces; - AbstractMetaClass *m_extractedInterface; + AbstractMetaClass *m_extractedInterface = nullptr; QVector<QPropertySpec *> m_propertySpecs; AbstractMetaClassList m_innerClasses; @@ -1861,10 +1812,10 @@ private: QStringList m_baseClassNames; QVector<TypeEntry *> m_templateArgs; - ComplexTypeEntry *m_typeEntry; + ComplexTypeEntry *m_typeEntry = nullptr; // FunctionModelItem m_qDebugStreamFunction; - bool m_stream; + bool m_stream = false; }; Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaClass::FunctionQueryOptions) @@ -1873,10 +1824,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaClass::OperatorQueryOptions) class QPropertySpec { public: - QPropertySpec(const TypeEntry *type) - : m_type(type), - m_index(-1) - {} + explicit QPropertySpec(const TypeEntry *type) : m_type(type) {} const TypeEntry *type() const { @@ -1950,7 +1898,7 @@ private: QString m_designable; QString m_reset; const TypeEntry *m_type; - int m_index; + int m_index = -1; }; inline AbstractMetaFunctionList AbstractMetaClass::cppSignalFunctions() const |