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/generator | |
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/generator')
-rw-r--r-- | sources/shiboken2/generator/main.cpp | 8 | ||||
-rw-r--r-- | sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp index 362191fd0..c5bcb766d 100644 --- a/sources/shiboken2/generator/main.cpp +++ b/sources/shiboken2/generator/main.cpp @@ -57,6 +57,7 @@ static inline QString typesystemPathOption() { return QStringLiteral("typesystem static inline QString helpOption() { return QStringLiteral("help"); } static inline QString diffOption() { return QStringLiteral("diff"); } static inline QString dryrunOption() { return QStringLiteral("dry-run"); } +static inline QString skipDeprecatedOption() { return QStringLiteral("skip-deprecated"); } static const char helpHint[] = "Note: use --help or -h for more information.\n"; @@ -310,6 +311,8 @@ void printUsage() QLatin1String("System include paths used by the C++ parser")) << qMakePair(QLatin1String("generator-set=<\"generator module\">"), QLatin1String("generator-set to be used. e.g. qtdoc")) + << qMakePair(skipDeprecatedOption(), + QLatin1String("Skip deprecated functions")) << qMakePair(diffOption(), QLatin1String("Print a diff of wrapper files")) << qMakePair(dryrunOption(), @@ -475,6 +478,11 @@ int main(int argc, char *argv[]) // Create and set-up API Extractor ApiExtractor extractor; extractor.setLogDirectory(outputDirectory); + ait = args.find(skipDeprecatedOption()); + if (ait != args.end()) { + extractor.setSkipDeprecated(true); + args.erase(ait); + } ait = args.find(QLatin1String("silent")); if (ait != args.end()) { diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 9cfc95fd1..a61095e15 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -2656,6 +2656,12 @@ void CppGenerator::writeFunctionCalls(QTextStream &s, const OverloadData &overlo { Indentation indent(INDENT); writeSingleFunctionCall(s, overloadData, func, context); + if (func->attributes().testFlag(AbstractMetaAttributes::Deprecated)) { + s << INDENT << "PyErr_WarnEx(PyExc_DeprecationWarning, \""; + if (auto cls = context.metaClass()) + s << cls->name() << '.'; + s << func->signature() << " is deprecated\", 1);\n"; + } s << INDENT << "break;" << endl; } s << INDENT << '}' << endl; |