aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-12-04 13:39:40 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-12-06 12:48:22 +0000
commit58720761d8b3c22d65d2bee1d064ce55cee62b0f (patch)
tree9a4f178cc951b060110629aa4035e49c8f0674fb /sources/shiboken2/ApiExtractor
parenta983ea88d1fa4263f2bbc3eb46241d9fd5965fed (diff)
shiboken: Refactor copying of the MetaLang* classes
Disable copying of the base classes AbstractMetaAttributes and AbstractMetaVariable and refactor the copy() functions of the derived classes in terms of protected assign*() functions. Change-Id: I6cbe1cfa02207230e914ad41dddba46c866cb689 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp33
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.h13
2 files changed, 35 insertions, 11 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
index 6f57527f7..f442da5ec 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
@@ -66,7 +66,7 @@ AbstractMetaVariable::~AbstractMetaVariable()
delete m_type;
}
-AbstractMetaVariable::AbstractMetaVariable(const AbstractMetaVariable &other)
+void AbstractMetaVariable::assignMetaVariable(const AbstractMetaVariable &other)
{
m_originalName = other.m_originalName;
m_name = other.m_name;
@@ -99,6 +99,13 @@ QDebug operator<<(QDebug d, const AbstractMetaVariable *av)
AbstractMetaAttributes::AbstractMetaAttributes() = default;
AbstractMetaAttributes::~AbstractMetaAttributes() = default;
+void AbstractMetaAttributes::assignMetaAttributes(const AbstractMetaAttributes &other)
+{
+ m_attributes = other.m_attributes;
+ m_originalAttributes = other.m_originalAttributes;
+ m_doc = other.m_doc;
+}
+
/*******************************************************************************
* AbstractMetaType
*/
@@ -336,9 +343,19 @@ QDebug operator<<(QDebug d, const AbstractMetaType *at)
AbstractMetaArgument::AbstractMetaArgument() = default;
+void AbstractMetaArgument::assignMetaArgument(const AbstractMetaArgument &other)
+{
+ assignMetaVariable(other);
+ m_expression = other.m_expression;
+ m_originalExpression = other.m_originalExpression;
+ m_argumentIndex = other.m_argumentIndex;
+}
+
AbstractMetaArgument *AbstractMetaArgument::copy() const
{
- return new AbstractMetaArgument(*this);
+ AbstractMetaArgument *copy = new AbstractMetaArgument;
+ copy->assignMetaArgument(*this);
+ return copy;
}
#ifndef QT_NO_DEBUG_STREAM
@@ -532,17 +549,16 @@ AbstractMetaFunction::CompareResult AbstractMetaFunction::compareTo(const Abstra
AbstractMetaFunction *AbstractMetaFunction::copy() const
{
AbstractMetaFunction *cpy = new AbstractMetaFunction;
+ cpy->assignMetaAttributes(*this);
cpy->setName(name());
cpy->setOriginalName(originalName());
cpy->setOwnerClass(ownerClass());
cpy->setImplementingClass(implementingClass());
cpy->setFunctionType(functionType());
- cpy->setAttributes(attributes());
cpy->setDeclaringClass(declaringClass());
if (type())
cpy->setType(type()->copy());
cpy->setConstant(isConstant());
- cpy->setOriginalAttributes(originalAttributes());
for (AbstractMetaArgument *arg : m_arguments)
cpy->addArgument(arg->copy());
@@ -1860,12 +1876,9 @@ AbstractMetaField::~AbstractMetaField()
AbstractMetaField *AbstractMetaField::copy() const
{
AbstractMetaField *returned = new AbstractMetaField;
- returned->setEnclosingClass(0);
- returned->setAttributes(attributes());
- returned->setName(name());
- returned->setType(type()->copy());
- returned->setOriginalAttributes(originalAttributes());
-
+ returned->assignMetaVariable(*this);
+ returned->assignMetaAttributes(*this);
+ returned->setEnclosingClass(nullptr);
return returned;
}
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h
index d30e70c4a..31d9fa53e 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h
@@ -99,6 +99,7 @@ private:
class AbstractMetaAttributes
{
+ Q_DISABLE_COPY(AbstractMetaAttributes)
Q_GADGET
public:
AbstractMetaAttributes();
@@ -281,6 +282,9 @@ public:
return m_doc;
}
+protected:
+ void assignMetaAttributes(const AbstractMetaAttributes &other);
+
private:
Attributes m_attributes;
Attributes m_originalAttributes;
@@ -632,9 +636,9 @@ QDebug operator<<(QDebug d, const AbstractMetaType *at);
class AbstractMetaVariable
{
+ Q_DISABLE_COPY(AbstractMetaVariable)
public:
AbstractMetaVariable();
- AbstractMetaVariable(const AbstractMetaVariable &other);
virtual ~AbstractMetaVariable();
@@ -684,6 +688,9 @@ public:
return m_doc;
}
+protected:
+ void assignMetaVariable(const AbstractMetaVariable &other);
+
private:
QString m_originalName;
QString m_name;
@@ -736,6 +743,10 @@ public:
}
AbstractMetaArgument *copy() const;
+
+protected:
+ void assignMetaArgument(const AbstractMetaArgument &other);
+
private:
QString m_expression;
QString m_originalExpression;