diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-17 14:43:43 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-18 09:59:00 +0000 |
commit | 9bbbf390f8e8e88457763f2201cfe98f94bf1520 (patch) | |
tree | f87f8efb0c696366d685ceb87c65e1f5895b4ff2 /sources/shiboken2/ApiExtractor/abstractmetalang.cpp | |
parent | 853b637b02b07d502ddb5e84bcf60f6a8a58cf29 (diff) |
shiboken: Simplify code looking for copy constructors
Replace various loops operating on lists by a convenience
function
AbstractMetaFunction *AbstractMetaClass::copyConstructor() const
Change-Id: If38b954ae01856a84835a17a7e4d3e981b5aac9b
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetalang.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetalang.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index 22c119c94..6316cfc43 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -1829,24 +1829,19 @@ bool AbstractMetaClass::hasConstructors() const return !queryFunctions(Constructors).isEmpty(); } -bool AbstractMetaClass::hasCopyConstructor() const +const AbstractMetaFunction *AbstractMetaClass::copyConstructor() const { - const AbstractMetaFunctionList &ctors = queryFunctions(Constructors); - for (const AbstractMetaFunction* ctor : ctors) { - if (ctor->functionType() == AbstractMetaFunction::CopyConstructorFunction) - return true; + for (const AbstractMetaFunction *f : m_functions) { + if (f->functionType() == AbstractMetaFunction::CopyConstructorFunction) + return f; } - return false; + return nullptr; } bool AbstractMetaClass::hasPrivateCopyConstructor() const { - const AbstractMetaFunctionList &ctors = queryFunctions(Constructors); - for (const AbstractMetaFunction *ctor : ctors) { - if (ctor->functionType() == AbstractMetaFunction::CopyConstructorFunction && ctor->isPrivate()) - return true; - } - return false; + const AbstractMetaFunction *copyCt = copyConstructor(); + return copyCt && copyCt->isPrivate(); } void AbstractMetaClass::addDefaultConstructor() |