aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/shiboken2
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-06-27 15:30:24 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-07-16 11:18:32 +0000
commit269f835a8d21d6ad79e20de675ebb2132255367d (patch)
tree40ad75a74bb167b3c43d87f2868ba4209c34ee3b /sources/shiboken2/generator/shiboken2
parentce8547b044ac635f2b1f6e7ecd3d100714241b04 (diff)
shiboken: Refactor command line arguments handling
In main, replace the class ArgsHandler by plain QMap handling. Remove the args parameter of Generator::doSetup() and add a new virtual handleOption(key, value) to the generators instead. Add missing initialization. Change-Id: I9bc844172a81244f729d87a3d4262545e6433904 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/generator/shiboken2')
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp26
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.h15
2 files changed, 26 insertions, 15 deletions
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index 0965a373a..1d3f52ba4 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -2431,6 +2431,23 @@ Generator::OptionDescriptions ShibokenGenerator::options() const
"the value of boolean casts"));
}
+bool ShibokenGenerator::handleOption(const QString &key, const QString & /* value */)
+{
+ if (key == QLatin1String(PARENT_CTOR_HEURISTIC))
+ return (m_useCtorHeuristic = true);
+ if (key == QLatin1String(ENABLE_PYSIDE_EXTENSIONS))
+ return (m_usePySideExtensions = true);
+ if (key == QLatin1String(RETURN_VALUE_HEURISTIC))
+ return (m_userReturnValueHeuristic = true);
+ if (key == QLatin1String(DISABLE_VERBOSE_ERROR_MESSAGES))
+ return (m_verboseErrorMessagesDisabled = true);
+ if (key == QLatin1String(USE_ISNULL_AS_NB_NONZERO))
+ return (m_useIsNullAsNbNonZero = true);
+ if (key == QLatin1String(AVOID_PROTECTED_HACK))
+ return (m_avoidProtectedHack = true);
+ return false;
+}
+
static void getCode(QStringList& code, const CodeSnipList& codeSnips)
{
for (const CodeSnip &snip : qAsConst(codeSnips))
@@ -2456,15 +2473,8 @@ static void getCode(QStringList& code, const TypeEntry* type)
code.append(toNative->conversion());
}
-bool ShibokenGenerator::doSetup(const QMap<QString, QString>& args)
+bool ShibokenGenerator::doSetup()
{
- m_useCtorHeuristic = args.contains(QLatin1String(PARENT_CTOR_HEURISTIC));
- m_usePySideExtensions = args.contains(QLatin1String(ENABLE_PYSIDE_EXTENSIONS));
- m_userReturnValueHeuristic = args.contains(QLatin1String(RETURN_VALUE_HEURISTIC));
- m_verboseErrorMessagesDisabled = args.contains(QLatin1String(DISABLE_VERBOSE_ERROR_MESSAGES));
- m_useIsNullAsNbNonZero = args.contains(QLatin1String(USE_ISNULL_AS_NB_NONZERO));
- m_avoidProtectedHack = args.contains(QLatin1String(AVOID_PROTECTED_HACK));
-
TypeDatabase* td = TypeDatabase::instance();
QStringList snips;
const PrimitiveTypeEntryList &primitiveTypeList = primitiveTypes();
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
index cb1bdd11f..d06803e82 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
@@ -414,6 +414,7 @@ public:
QString getModuleHeaderFileName(const QString& moduleName = QString()) const;
OptionDescriptions options() const override;
+ bool handleOption(const QString &key, const QString &value) override;
/// Returns true if the user enabled the so called "parent constructor heuristic".
bool useCtorHeuristic() const;
@@ -462,7 +463,7 @@ public:
*/
static QString getDefaultValue(const AbstractMetaFunction* func, const AbstractMetaArgument* arg);
protected:
- bool doSetup(const QMap<QString, QString>& args);
+ bool doSetup() override;
void collectContainerTypesFromConverterMacros(const QString& code, bool toPythonMacro);
// verify whether the class is copyable
bool isCopyable(const AbstractMetaClass* metaClass);
@@ -517,12 +518,12 @@ protected:
static QString msgCouldNotFindMinimalConstructor(const QString &where, const QString &type);
private:
- bool m_useCtorHeuristic;
- bool m_userReturnValueHeuristic;
- bool m_usePySideExtensions;
- bool m_verboseErrorMessagesDisabled;
- bool m_useIsNullAsNbNonZero;
- bool m_avoidProtectedHack;
+ bool m_useCtorHeuristic = false;
+ bool m_userReturnValueHeuristic = false;
+ bool m_usePySideExtensions = false;
+ bool m_verboseErrorMessagesDisabled = false;
+ bool m_useIsNullAsNbNonZero = false;
+ bool m_avoidProtectedHack = false;
typedef QHash<QString, AbstractMetaType*> AbstractMetaTypeCache;
AbstractMetaTypeCache m_metaTypeFromStringCache;