aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
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/abstractmetalang.cpp
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/abstractmetalang.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp33
1 files changed, 23 insertions, 10 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;
}