diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-10-22 08:59:03 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-10-27 10:01:34 +0000 |
commit | 8b88410f9f9589235738bb26739d40af4447cc05 (patch) | |
tree | 19276bec219bf2a3c728fdced77b8fb3a45063fc /sources/shiboken2/ApiExtractor/abstractmetalang.h | |
parent | 49bd2b28d4a666107d4d124b9a5cc9fbe88d8fe8 (diff) |
shiboken2: AbstractMetaArgument: use QSharedData[Pointer]
Similar to AbstractMetaType, AbstractMetaArgument was previously
kept as a raw pointer. The data were copied numerous times by
AbstractMetaArgument::copy() when adding the inherited functions to a
AbstractMetaClass.
Similar to what was done for AbstractMetaType in
6cad0686101b252cfdbd1a6768a2b02c39aa1d8a, change the type to be based
on QSharedData[Pointer]. It can then be passed around and treated like
a C++ value type, with Qt sharing the data when possible behind the
scenes.
* Remove inheritance from AbstractMetaVariable by moving
the fields over.
* Remove the unused field m_originalName.
Change-Id: Ic9e476ca71e163de131fbecc267d0a4e336cb0b9
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetalang.h')
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetalang.h | 73 |
1 files changed, 7 insertions, 66 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h index 66331bbd9..9c52182ef 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.h +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h @@ -30,6 +30,7 @@ #define ABSTRACTMETALANG_H #include "abstractmetalang_typedefs.h" +#include "abstractmetaargument.h" #include "abstractmetatype.h" #include "documentation.h" #include "sourcelocation.h" @@ -306,66 +307,6 @@ private: QDebug operator<<(QDebug d, const AbstractMetaVariable *av); #endif -class AbstractMetaArgument : public AbstractMetaVariable -{ -public: - AbstractMetaArgument(); - - QString defaultValueExpression() const - { - return m_expression; - } - void setDefaultValueExpression(const QString &expr) - { - m_expression = expr; - } - - QString originalDefaultValueExpression() const - { - return m_originalExpression; - } - void setOriginalDefaultValueExpression(const QString &expr) - { - m_originalExpression = expr; - } - - bool hasDefaultValueExpression() const - { return !m_expression.isEmpty(); } - bool hasOriginalDefaultValueExpression() const - { return !m_originalExpression.isEmpty(); } - bool hasUnmodifiedDefaultValueExpression() const - { return !m_originalExpression.isEmpty() && m_originalExpression == m_expression; } - bool hasModifiedDefaultValueExpression() const - { return !m_expression.isEmpty() && m_originalExpression != m_expression; } - - QString toString() const - { - return type().name() + QLatin1Char(' ') + AbstractMetaVariable::name() + - (m_expression.isEmpty() ? QString() : QLatin1String(" = ") + m_expression); - } - - int argumentIndex() const - { - return m_argumentIndex; - } - void setArgumentIndex(int argIndex) - { - m_argumentIndex = argIndex; - } - - AbstractMetaArgument *copy() const; - -protected: - void assignMetaArgument(const AbstractMetaArgument &other); - -private: - QString m_expression; - QString m_originalExpression; - int m_argumentIndex = 0; - - friend class AbstractMetaClass; -}; - class EnclosingClassMixin { public: const AbstractMetaClass *enclosingClass() const { return m_enclosingClass; } @@ -376,10 +317,6 @@ private: const AbstractMetaClass *m_enclosingClass = nullptr; }; -#ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug d, const AbstractMetaArgument *aa); -#endif - class AbstractMetaField : public AbstractMetaVariable, public AbstractMetaAttributes, public EnclosingClassMixin { public: @@ -591,7 +528,11 @@ public: m_implementingClass = cls; } - AbstractMetaArgumentList arguments() const + const AbstractMetaArgumentList &arguments() const + { + return m_arguments; + } + AbstractMetaArgumentList &arguments() { return m_arguments; } @@ -599,7 +540,7 @@ public: { m_arguments = arguments; } - void addArgument(AbstractMetaArgument *argument) + void addArgument(const AbstractMetaArgument &argument) { m_arguments << argument; } |