diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-14 11:48:10 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-27 06:16:46 +0000 |
commit | 2412e332a9984891aa481176141d403183ac3b11 (patch) | |
tree | 5646f4a929a3585131eb09009f404834a55c6cd2 /sources/shiboken2/ApiExtractor/abstractmetalang.cpp | |
parent | 0f8b1cf2daae6fcc0a922a9e2514f12374eeee31 (diff) |
Add exception handling
Add XML elements specifying an exception handling mode to type system,
complex type entries (classes) and function modifications.
From the mode and the exception specification as detected
by Clang, deduce whether to generate try/catch code.
Task-number: PYSIDE-62
Change-Id: Ib76adc21cefd81bf9f82f819a3c151056c33a3b7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetalang.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetalang.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index 878d7fb9e..35e12f780 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -407,7 +407,8 @@ AbstractMetaFunction::AbstractMetaFunction() m_userAdded(false), m_explicit(false), m_pointerOperator(false), - m_isCallOperator(false) + m_isCallOperator(false), + m_generateExceptionHandling(false) { } @@ -526,6 +527,7 @@ AbstractMetaFunction *AbstractMetaFunction::copy() const cpy->setType(type()->copy()); cpy->setConstant(isConstant()); cpy->setExceptionSpecification(m_exceptionSpecification); + cpy->setGenerateExceptionHandling(m_generateExceptionHandling); for (AbstractMetaArgument *arg : m_arguments) cpy->addArgument(arg->copy()); @@ -1153,6 +1155,8 @@ void AbstractMetaFunction::formatDebugVerbose(QDebug &d) const d << " throw(...)"; break; } + if (m_generateExceptionHandling) + d << "[generate-exception-handling]"; d << '('; for (int i = 0, count = m_arguments.size(); i < count; ++i) { if (i) @@ -1899,6 +1903,11 @@ bool AbstractMetaClass::hasFunction(const AbstractMetaFunction *f) const return functions_contains(m_functions, f); } +bool AbstractMetaClass::generateExceptionHandling() const +{ + return queryFirstFunction(m_functions, AbstractMetaClass::Visible + | AbstractMetaClass::GenerateExceptionHandling) != nullptr; +} /* Goes through the list of functions and returns a list of all functions matching all of the criteria in \a query. */ @@ -1968,6 +1977,9 @@ bool AbstractMetaClass::queryFunction(const AbstractMetaFunction *f, FunctionQue if ((query & OperatorOverloads) && !f->isOperatorOverload()) return false; + if ((query & GenerateExceptionHandling) && !f->generateExceptionHandling()) + return false; + return true; } |