aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-09-10 09:38:36 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-09-12 08:18:25 +0200
commit78c0e308194408ab9943c0ba71d28cfb483ac394 (patch)
tree554d6c1c96fd2440277b1322fd3faee78b67a8e3 /sources/shiboken2/ApiExtractor
parentaeacefcdccdc3a0cb5e9f405fb3af3276a987c08 (diff)
shiboken: Introduce flags for AbstractMetaBuilder*::translateType*
This is a preparation for further extensions. Change-Id: I5279f351f7964f17ee3ca92386c10d3b90b5d8c8 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp29
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.h11
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h6
3 files changed, 30 insertions, 16 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index 9c930dcdc..85e4e3778 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -1915,7 +1915,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
AbstractMetaType *type = nullptr;
if (!returnType.isVoid()) {
- type = translateType(returnType, currentClass, true, &errorMessage);
+ type = translateType(returnType, currentClass, {}, &errorMessage);
if (!type) {
const QString reason = msgUnmatchedReturnType(functionItem, errorMessage);
qCWarning(lcShiboken, "%s",
@@ -1951,7 +1951,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
return nullptr;
}
- AbstractMetaType *metaType = translateType(arg->type(), currentClass, true, &errorMessage);
+ AbstractMetaType *metaType = translateType(arg->type(), currentClass, {}, &errorMessage);
if (!metaType) {
// If an invalid argument has a default value, simply remove it
if (arg->defaultValue()) {
@@ -2155,22 +2155,27 @@ static const TypeEntry* findTypeEntryUsingContext(const AbstractMetaClass* metaC
AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const TypeInfo &_typei,
AbstractMetaClass *currentClass,
- bool resolveType,
+ TranslateTypeFlags flags,
QString *errorMessage)
{
- return translateTypeStatic(_typei, currentClass, this, resolveType, errorMessage);
+ return translateTypeStatic(_typei, currentClass, this, flags, errorMessage);
}
AbstractMetaType *AbstractMetaBuilderPrivate::translateTypeStatic(const TypeInfo &_typei,
AbstractMetaClass *currentClass,
AbstractMetaBuilderPrivate *d,
- bool resolveType,
+ TranslateTypeFlags flags,
QString *errorMessageIn)
{
// 1. Test the type info without resolving typedefs in case this is present in the
// type system
+ const bool resolveType = !flags.testFlag(AbstractMetaBuilder::DontResolveType);
if (resolveType) {
- if (AbstractMetaType *resolved = translateTypeStatic(_typei, currentClass, d, false, errorMessageIn))
+ AbstractMetaType *resolved =
+ translateTypeStatic(_typei, currentClass, d,
+ flags | AbstractMetaBuilder::DontResolveType,
+ errorMessageIn);
+ if (resolved)
return resolved;
}
@@ -2229,7 +2234,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateTypeStatic(const TypeInfo
newInfo.setReferenceType(typeInfo.referenceType());
newInfo.setVolatile(typeInfo.isVolatile());
- AbstractMetaType *elementType = translateTypeStatic(newInfo, currentClass, d, true, &errorMessage);
+ AbstractMetaType *elementType = translateTypeStatic(newInfo, currentClass, d, flags, &errorMessage);
if (!elementType) {
if (errorMessageIn) {
errorMessage.prepend(QLatin1String("Unable to translate array element: "));
@@ -2340,7 +2345,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateTypeStatic(const TypeInfo
const auto &templateArguments = typeInfo.instantiations();
for (int t = 0, size = templateArguments.size(); t < size; ++t) {
const TypeInfo &ti = templateArguments.at(t);
- AbstractMetaType *targType = translateTypeStatic(ti, currentClass, d, true, &errorMessage);
+ AbstractMetaType *targType = translateTypeStatic(ti, currentClass, d, flags, &errorMessage);
if (!targType) {
if (errorMessageIn)
*errorMessageIn = msgCannotTranslateTemplateArgument(t, ti, errorMessage);
@@ -2362,17 +2367,17 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateTypeStatic(const TypeInfo
AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei,
AbstractMetaClass *currentClass,
- bool resolveType,
+ TranslateTypeFlags flags,
QString *errorMessage)
{
return AbstractMetaBuilderPrivate::translateTypeStatic(_typei, currentClass,
- nullptr, resolveType,
+ nullptr, flags,
errorMessage);
}
AbstractMetaType *AbstractMetaBuilder::translateType(const QString &t,
AbstractMetaClass *currentClass,
- bool resolveType,
+ TranslateTypeFlags flags,
QString *errorMessageIn)
{
QString errorMessage;
@@ -2385,7 +2390,7 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const QString &t,
qCWarning(lcShiboken, "%s", qPrintable(errorMessage));
return nullptr;
}
- return translateType(typeInfo, currentClass, resolveType, errorMessageIn);
+ return translateType(typeInfo, currentClass, flags, errorMessageIn);
}
qint64 AbstractMetaBuilderPrivate::findOutValueFromString(const QString &stringValue, bool &ok)
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder.h
index 1789ca2aa..93b9d9fd2 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.h
@@ -90,13 +90,18 @@ public:
void setSkipDeprecated(bool value);
+ enum TranslateTypeFlag {
+ DontResolveType = 0x1
+ };
+ Q_DECLARE_FLAGS(TranslateTypeFlags, TranslateTypeFlag);
+
static AbstractMetaType *translateType(const TypeInfo &_typei,
AbstractMetaClass *currentClass = nullptr,
- bool resolveType = true,
+ TranslateTypeFlags flags = {},
QString *errorMessage = nullptr);
static AbstractMetaType *translateType(const QString &t,
AbstractMetaClass *currentClass = nullptr,
- bool resolveType = true,
+ TranslateTypeFlags flags = {},
QString *errorMessage = nullptr);
@@ -109,6 +114,8 @@ private:
AbstractMetaBuilderPrivate *d;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaBuilder::TranslateTypeFlags);
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const AbstractMetaBuilder &ab);
#endif
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
index fec2eddb9..adf4d836b 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
@@ -43,6 +43,8 @@ class TypeDatabase;
class AbstractMetaBuilderPrivate
{
public:
+ using TranslateTypeFlags = AbstractMetaBuilder::TranslateTypeFlags;
+
Q_DISABLE_COPY(AbstractMetaBuilderPrivate)
AbstractMetaBuilderPrivate();
@@ -135,12 +137,12 @@ public:
AbstractMetaType *translateType(const AddedFunction::TypeInfo &typeInfo);
AbstractMetaType *translateType(const TypeInfo &type,
AbstractMetaClass *currentClass,
- bool resolveType = true,
+ TranslateTypeFlags flags = {},
QString *errorMessage = nullptr);
static AbstractMetaType *translateTypeStatic(const TypeInfo &type,
AbstractMetaClass *current,
AbstractMetaBuilderPrivate *d = nullptr,
- bool resolveType = true,
+ TranslateTypeFlags flags = {},
QString *errorMessageIn = nullptr);
qint64 findOutValueFromString(const QString &stringValue, bool &ok);