diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-30 18:39:25 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-12-07 12:31:15 +0000 |
commit | ed87e710dd14bc9612dcfdba2e09143201768556 (patch) | |
tree | 0c7dd4b49e4a891c57d514fca39642abfaad91f6 /sources/shiboken6/ApiExtractor/abstractmetafunction.cpp | |
parent | eb16797b9a54970dbc0c461ebeddda57b060af22 (diff) |
shiboken6: Add support for a snake case typesystem attribute
Add a snake case attribute to type system, complex type entry,
function type entry as well as to function and field modifications.
Add a function definitionNames() to AbstractMetaFunction/Field
returning the names under which the function/field will be registered.
Change the code writing the registration accordingly.
Fixes: PYSIDE-1441
Change-Id: I178390bb80fa25aad9f8a56e99e4cc70064178eb
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/abstractmetafunction.cpp')
-rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetafunction.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp index e2d0fb9dc..9594cfdb6 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include "abstractmetafunction.h" +#include "abstractmetabuilder.h" #include "abstractmetalang.h" #include "abstractmetalang_helpers.h" #include "abstractmetatype.h" @@ -144,6 +145,11 @@ void AbstractMetaFunction::setOriginalName(const QString &name) d->m_originalName = name; } +QStringList AbstractMetaFunction::definitionNames() const +{ + return AbstractMetaBuilder::definitionNames(d->m_name, snakeCase()); +} + const Documentation &AbstractMetaFunction::documentation() const { return d->m_doc; @@ -1132,6 +1138,46 @@ int AbstractMetaFunction::overloadNumber() const return d->overloadNumber(this); } +TypeSystem::SnakeCase AbstractMetaFunction::snakeCase() const +{ + if (isUserAdded()) + return TypeSystem::SnakeCase::Disabled; + // Renamed? + if (!d->m_originalName.isEmpty() && d->m_originalName != d->m_name) + return TypeSystem::SnakeCase::Disabled; + switch (d->m_functionType) { + case AbstractMetaFunction::NormalFunction: + case AbstractMetaFunction::SignalFunction: + case AbstractMetaFunction::EmptyFunction: + case AbstractMetaFunction::SlotFunction: + case AbstractMetaFunction::GlobalScopeFunction: + if (isOperatorOverload()) + return TypeSystem::SnakeCase::Disabled; + break; + default: + return TypeSystem::SnakeCase::Disabled; + } + + for (const auto &mod : modifications()) { + if (mod.snakeCase() != TypeSystem::SnakeCase::Unspecified) + return mod.snakeCase(); + } + + if (d->m_typeEntry) { // Global function + const auto snakeCase = d->m_typeEntry->snakeCase(); + return snakeCase != TypeSystem::SnakeCase::Unspecified + ? snakeCase : d->m_typeEntry->typeSystemTypeEntry()->snakeCase(); + } + + if (d->m_class) { + auto typeEntry = d->m_class->typeEntry(); + const auto snakeCase = typeEntry->snakeCase(); + return snakeCase != TypeSystem::SnakeCase::Unspecified + ? snakeCase : typeEntry->typeSystemTypeEntry()->snakeCase(); + } + return TypeSystem::SnakeCase::Disabled; +} + // Query functions for generators bool AbstractMetaFunction::injectedCodeUsesPySelf() const { |