diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-01-30 13:25:17 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-01-31 07:12:14 +0000 |
commit | d2ea4919081b5b61aa77029fb47e2cdf8e94adca (patch) | |
tree | 7dc16c12be158eb73ab2da1b59b64ea987eedcec /sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | |
parent | 53a794cb20d00f1b84e601440c32d22e4397d27b (diff) |
shiboken: Add option to skip deprecated functions
Pass the "deprecated" annotation from Clang into the meta language and
reject functions based on it when the the command line option
--skip-deprecated is set.
By default, have Python output a deprecation warning when a deprecated
function is called (which is visible when passing -Wd).
Task-number: PYSIDE-487
Change-Id: Ic28d82963fde11f258b2559b562d3f24017fe98d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index 7498d3a18..14f6806fe 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -112,7 +112,8 @@ static QStringList parseTemplateType(const QString& name) { } AbstractMetaBuilderPrivate::AbstractMetaBuilderPrivate() : m_currentClass(0), - m_logDirectory(QLatin1String(".") + QDir::separator()) + m_logDirectory(QLatin1String(".") + QDir::separator()), + m_skipDeprecated(false) { } @@ -1937,7 +1938,17 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio if (functionItem->isFriend()) return 0; + const bool deprecated = functionItem->isDeprecated(); + if (deprecated && m_skipDeprecated) { + m_rejectedFunctions.insert(originalQualifiedSignatureWithReturn + QLatin1String(" is deprecated."), + AbstractMetaBuilder::GenerationDisabled); + return nullptr; + } + AbstractMetaFunction *metaFunction = new AbstractMetaFunction; + if (deprecated) + *metaFunction += AbstractMetaAttributes::Deprecated; + // Additional check for assignment/move assignment down below metaFunction->setFunctionType(functionTypeFromCodeModel(functionItem->functionType())); metaFunction->setConstant(functionItem->isConstant()); @@ -3075,6 +3086,10 @@ static void writeRejectLogFile(const QString &name, s << "Incompatible API"; break; + case AbstractMetaBuilder::Deprecated: + s << "Deprecated"; + break; + default: s << "unknown reason"; break; @@ -3241,6 +3256,11 @@ void AbstractMetaBuilder::setGlobalHeader(const QString& globalHeader) d->m_globalHeader = QFileInfo(globalHeader); } +void AbstractMetaBuilder::setSkipDeprecated(bool value) +{ + d->m_skipDeprecated = value; +} + void AbstractMetaBuilderPrivate::setInclude(TypeEntry *te, const QString &fileName) const { QFileInfo info(fileName); |