aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-02-28 10:42:30 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-02-28 15:48:07 +0000
commit0aa52375886138693caf395238fcd3baf3489dec (patch)
treefc24d91372e071e41db65831f919b505cb898083 /sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
parente9c89837f91bf608371a7e39903ecd4038f769c1 (diff)
shiboken: Fix exception handling when specified in base class
Class-level exception specifications on a base class were not working so far. This requires a larger refactoring, since the base classes are not yet known at the point where class functions were traversed (AbstractMetaBuilder::setupInheritance() is called at a later stage). To fix this, store the actual type system modification in the AbstractMetaFunction and move the logic determining whether to generate exception handling into AbstractMetaFunction::generateExceptionHandling(). In this function, recurse down the base classes if the function does not have a modification set. This is a preparation for giving the allow-thread attribute, which can currently only be used at a function level, a similar handling. Task-number: PYSIDE-62 Change-Id: I28597559511d330cf860c6f6e21ffea229bfab3e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp39
1 files changed, 2 insertions, 37 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index 15700e91e..41ae5d7f1 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -1871,40 +1871,12 @@ bool AbstractMetaBuilderPrivate::setArrayArgumentType(AbstractMetaFunction *func
return true;
}
-static bool generateExceptionHandling(const AbstractMetaFunction *func,
- ExceptionSpecification spec,
- TypeSystem::ExceptionHandling handling)
-{
- switch (func->functionType()) {
- case AbstractMetaFunction::CopyConstructorFunction:
- case AbstractMetaFunction::MoveConstructorFunction:
- case AbstractMetaFunction::AssignmentOperatorFunction:
- case AbstractMetaFunction::MoveAssignmentOperatorFunction:
- case AbstractMetaFunction::DestructorFunction:
- return false;
- default:
- break;
- }
- switch (handling) {
- case TypeSystem::ExceptionHandling::On:
- return true;
- case TypeSystem::ExceptionHandling::AutoDefaultToOn:
- return spec != ExceptionSpecification::NoExcept;
- case TypeSystem::ExceptionHandling::AutoDefaultToOff:
- return spec == ExceptionSpecification::Throws;
- default:
- break;
- }
- return false;
-}
-
AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const FunctionModelItem &functionItem)
{
if (functionItem->isDeleted() || !functionItem->templateParameters().isEmpty())
return nullptr;
QString functionName = functionItem->name();
QString className;
- TypeSystem::ExceptionHandling exceptionHandling = TypeSystem::ExceptionHandling::Unspecified;
if (m_currentClass) {
// Clang: Skip qt_metacast(), qt_metacall(), expanded from Q_OBJECT
// and overridden metaObject(), QGADGET helpers
@@ -1913,7 +1885,6 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
return nullptr;
}
className = m_currentClass->typeEntry()->qualifiedCppName();
- exceptionHandling = m_currentClass->typeEntry()->exceptionHandling();
if (functionName == QLatin1String("metaObject") && className != QLatin1String("QObject"))
return nullptr;
}
@@ -2085,16 +2056,10 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
const FunctionModificationList functionMods = metaFunction->modifications(m_currentClass);
for (const FunctionModification &mod : functionMods) {
- if (mod.exceptionHandling() != TypeSystem::ExceptionHandling::Unspecified) {
- exceptionHandling = mod.exceptionHandling();
- break;
- }
+ if (mod.exceptionHandling() != TypeSystem::ExceptionHandling::Unspecified)
+ metaFunction->setExceptionHandlingModification(mod.exceptionHandling());
}
- metaFunction->setGenerateExceptionHandling(generateExceptionHandling(metaFunction,
- functionItem->exceptionSpecification(),
- exceptionHandling));
-
// Find the correct default values
for (int i = 0, size = metaArguments.size(); i < size; ++i) {
const ArgumentModelItem &arg = arguments.at(i);