aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-04-17 08:52:51 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-04-17 12:12:37 +0200
commitd790ceeda49122fbe6cd6b66f1595355f915db4f (patch)
treea09579f95a05c1c7025930c4aeec4257bba5116a /sources
parent4bbbf01abbae1509f9d2ee46ffaf20840abd278e (diff)
shiboken: Refactor setting of debug level
Remove ApiExtractor::setDebugLevel(), which was just redirecting to ReportHandler. Move functionality to set from a command line argument to ReportHandler and add proper checks. Task-number: PYSIDE-1265 Change-Id: I3b8ad1f40283079d88f8eaffda192a7b1f607649 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken2/ApiExtractor/apiextractor.cpp5
-rw-r--r--sources/shiboken2/ApiExtractor/apiextractor.h2
-rw-r--r--sources/shiboken2/ApiExtractor/reporthandler.cpp14
-rw-r--r--sources/shiboken2/ApiExtractor/reporthandler.h1
-rw-r--r--sources/shiboken2/generator/main.cpp12
5 files changed, 20 insertions, 14 deletions
diff --git a/sources/shiboken2/ApiExtractor/apiextractor.cpp b/sources/shiboken2/ApiExtractor/apiextractor.cpp
index 6d29ed1e0..250fb7afd 100644
--- a/sources/shiboken2/ApiExtractor/apiextractor.cpp
+++ b/sources/shiboken2/ApiExtractor/apiextractor.cpp
@@ -92,11 +92,6 @@ void ApiExtractor::setTypeSystem(const QString& typeSystemFileName)
m_typeSystemFileName = typeSystemFileName;
}
-void ApiExtractor::setDebugLevel(ReportHandler::DebugLevel debugLevel)
-{
- ReportHandler::setDebugLevel(debugLevel);
-}
-
void ApiExtractor::setSkipDeprecated(bool value)
{
m_skipDeprecated = value;
diff --git a/sources/shiboken2/ApiExtractor/apiextractor.h b/sources/shiboken2/ApiExtractor/apiextractor.h
index c8f50f2a5..84319e64f 100644
--- a/sources/shiboken2/ApiExtractor/apiextractor.h
+++ b/sources/shiboken2/ApiExtractor/apiextractor.h
@@ -29,7 +29,6 @@
#ifndef APIEXTRACTOR_H
#define APIEXTRACTOR_H
-#include "reporthandler.h"
#include "dependency.h"
#include "abstractmetalang_typedefs.h"
#include "apiextractormacros.h"
@@ -67,7 +66,6 @@ public:
QString typeSystem() const { return m_typeSystemFileName; }
void setCppFileName(const QString& cppFileName);
QString cppFileName() const { return m_cppFileName; }
- void setDebugLevel(ReportHandler::DebugLevel debugLevel);
void setSkipDeprecated(bool value);
void setSuppressWarnings(bool value);
void setSilent(bool value);
diff --git a/sources/shiboken2/ApiExtractor/reporthandler.cpp b/sources/shiboken2/ApiExtractor/reporthandler.cpp
index 139256aaa..a489f7548 100644
--- a/sources/shiboken2/ApiExtractor/reporthandler.cpp
+++ b/sources/shiboken2/ApiExtractor/reporthandler.cpp
@@ -81,6 +81,20 @@ void ReportHandler::setDebugLevel(ReportHandler::DebugLevel level)
m_debugLevel = level;
}
+bool ReportHandler::setDebugLevelFromArg(const QString &level)
+{
+ bool result = true;
+ if (level == QLatin1String("sparse"))
+ ReportHandler::setDebugLevel(ReportHandler::SparseDebug);
+ else if (level == QLatin1String("medium"))
+ ReportHandler::setDebugLevel(ReportHandler::MediumDebug);
+ else if (level == QLatin1String("full"))
+ ReportHandler::setDebugLevel(ReportHandler::FullDebug);
+ else
+ result = false;
+ return result;
+}
+
int ReportHandler::suppressedCount()
{
return m_suppressedCount;
diff --git a/sources/shiboken2/ApiExtractor/reporthandler.h b/sources/shiboken2/ApiExtractor/reporthandler.h
index c649f9bdc..21f0e8933 100644
--- a/sources/shiboken2/ApiExtractor/reporthandler.h
+++ b/sources/shiboken2/ApiExtractor/reporthandler.h
@@ -45,6 +45,7 @@ public:
static DebugLevel debugLevel();
static void setDebugLevel(DebugLevel level);
+ static bool setDebugLevelFromArg(const QString &);
static int warningCount();
diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp
index e4d86f489..7c9845886 100644
--- a/sources/shiboken2/generator/main.cpp
+++ b/sources/shiboken2/generator/main.cpp
@@ -33,6 +33,7 @@
#include <iostream>
#include <apiextractor.h>
#include <fileout.h>
+#include <reporthandler.h>
#include <typedatabase.h>
#include <messages.h>
#include "generator.h"
@@ -487,14 +488,11 @@ int main(int argc, char *argv[])
} else {
ait = args.find(QLatin1String("debug-level"));
if (ait != args.end()) {
- const QString level = ait.value();
+ if (!ReportHandler::setDebugLevelFromArg(ait.value())) {
+ errorPrint(QLatin1String("Invalid debug level: ") + ait.value());
+ return EXIT_FAILURE;
+ }
args.erase(ait);
- if (level == QLatin1String("sparse"))
- extractor.setDebugLevel(ReportHandler::SparseDebug);
- else if (level == QLatin1String("medium"))
- extractor.setDebugLevel(ReportHandler::MediumDebug);
- else if (level == QLatin1String("full"))
- extractor.setDebugLevel(ReportHandler::FullDebug);
}
}
ait = args.find(QLatin1String("no-suppress-warnings"));