diff options
-rw-r--r-- | sources/pyside6/doc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sources/shiboken6/generator/generator.cpp | 18 | ||||
-rw-r--r-- | sources/shiboken6/generator/generator.h | 3 | ||||
-rw-r--r-- | sources/shiboken6/generator/main.cpp | 3 | ||||
-rw-r--r-- | sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp | 8 | ||||
-rw-r--r-- | sources/shiboken6/generator/shiboken/shibokengenerator.cpp | 21 | ||||
-rw-r--r-- | sources/shiboken6/generator/shiboken/shibokengenerator.h | 4 |
7 files changed, 34 insertions, 24 deletions
diff --git a/sources/pyside6/doc/CMakeLists.txt b/sources/pyside6/doc/CMakeLists.txt index f900b96eb..b36c1828f 100644 --- a/sources/pyside6/doc/CMakeLists.txt +++ b/sources/pyside6/doc/CMakeLists.txt @@ -184,6 +184,7 @@ configure_file("conf.py.in" "rst/conf.py" @ONLY) add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/rst/PySide6/QtCore/index.rst" COMMAND Shiboken6::shiboken6 --generator-set=qtdoc ${docHeader} + --enable-pyside-extensions --include-paths="${QT_INCLUDE_DIR}${PATH_SEP}${pyside6_SOURCE_DIR}${PATH_SEP}${TS_ROOT}" --api-version=${SUPPORTED_QT_VERSION} --typesystem-paths="${QDOC_TYPESYSTEM_PATH}" diff --git a/sources/shiboken6/generator/generator.cpp b/sources/shiboken6/generator/generator.cpp index 6a0183403..f40aa6c94 100644 --- a/sources/shiboken6/generator/generator.cpp +++ b/sources/shiboken6/generator/generator.cpp @@ -47,6 +47,8 @@ #include <QDebug> #include <typedatabase.h> +static const char ENABLE_PYSIDE_EXTENSIONS[] = "enable-pyside-extensions"; + /** * DefaultValue is used for storing default values of types for which code is * generated in different contexts: @@ -178,6 +180,7 @@ struct Generator::GeneratorPrivate AbstractMetaTypeList instantiatedSmartPointers; AbstractMetaClassCList m_invisibleTopNamespaces; bool m_hasPrivateClasses = false; + bool m_usePySideExtensions = false; }; Generator::Generator() : m_d(new GeneratorPrivate) @@ -350,11 +353,17 @@ AbstractMetaTypeList Generator::instantiatedSmartPointers() const Generator::OptionDescriptions Generator::options() const { - return OptionDescriptions(); + return { + {QLatin1String(ENABLE_PYSIDE_EXTENSIONS), + u"Enable PySide extensions, such as support for signal/slots,\n" + "use this if you are creating a binding for a Qt-based library."_qs} + }; } -bool Generator::handleOption(const QString & /* key */, const QString & /* value */) +bool Generator::handleOption(const QString & key, const QString & /* value */) { + if (key == QLatin1String(ENABLE_PYSIDE_EXTENSIONS)) + return ( m_d->m_usePySideExtensions = true); return false; } @@ -506,6 +515,11 @@ bool Generator::hasPrivateClasses() const return m_d->m_hasPrivateClasses; } +bool Generator::usePySideExtensions() const +{ + return m_d->m_usePySideExtensions; +} + QString Generator::getFullTypeName(const TypeEntry *type) { QString result = type->qualifiedCppName(); diff --git a/sources/shiboken6/generator/generator.h b/sources/shiboken6/generator/generator.h index 115a59a13..59d1b9822 100644 --- a/sources/shiboken6/generator/generator.h +++ b/sources/shiboken6/generator/generator.h @@ -237,6 +237,9 @@ public: bool hasPrivateClasses() const; + /// Returns true if the user enabled PySide extensions (command line option) + bool usePySideExtensions() const; + /** * Retrieves the name of the currently processed module. * While package name is a complete package idetification, e.g. 'PySide.QtCore', diff --git a/sources/shiboken6/generator/main.cpp b/sources/shiboken6/generator/main.cpp index 315e963c4..934e31307 100644 --- a/sources/shiboken6/generator/main.cpp +++ b/sources/shiboken6/generator/main.cpp @@ -689,8 +689,7 @@ int shibokenMain(int argc, char *argv[]) extractor.setCppFileNames(cppFileNames); extractor.setTypeSystem(typeSystemFileName); - auto shibokenGenerator = dynamic_cast<const ShibokenGenerator *>(generators.constFirst().data()); - const bool usePySideExtensions = shibokenGenerator && shibokenGenerator->usePySideExtensions(); + const bool usePySideExtensions = generators.constFirst().data()->usePySideExtensions(); const std::optional<ApiExtractorResult> apiOpt = extractor.run(usePySideExtensions); diff --git a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp index 8c768a57d..75b3cc2f1 100644 --- a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp @@ -999,7 +999,8 @@ bool QtDocGenerator::doSetup() Generator::OptionDescriptions QtDocGenerator::options() const { - return { + auto result = Generator::options(); + result.append({ {QLatin1String("doc-parser=<parser>"), QLatin1String("The documentation parser used to interpret the documentation\n" "input files (qdoc|doxygen)")}, @@ -1014,11 +1015,14 @@ Generator::OptionDescriptions QtDocGenerator::options() const {additionalDocumentationOption() + QLatin1String("=<file>"), QLatin1String("List of additional XML files to be converted to .rst files\n" "(for example, tutorials).")} - }; + }); + return result; } bool QtDocGenerator::handleOption(const QString &key, const QString &value) { + if (Generator::handleOption(key, value)) + return true; if (key == QLatin1String("library-source-dir")) { m_parameters.libSourceDir = value; return true; diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp index 99e90c1ef..07c41b1c5 100644 --- a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp +++ b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp @@ -56,7 +56,6 @@ static const char AVOID_PROTECTED_HACK[] = "avoid-protected-hack"; static const char PARENT_CTOR_HEURISTIC[] = "enable-parent-ctor-heuristic"; static const char RETURN_VALUE_HEURISTIC[] = "enable-return-value-heuristic"; -static const char ENABLE_PYSIDE_EXTENSIONS[] = "enable-pyside-extensions"; static const char DISABLE_VERBOSE_ERROR_MESSAGES[] = "disable-verbose-error-messages"; static const char USE_ISNULL_AS_NB_NONZERO[] = "use-isnull-as-nb_nonzero"; static const char USE_OPERATOR_BOOL_AS_NB_NONZERO[] = "use-operator-bool-as-nb_nonzero"; @@ -2366,7 +2365,8 @@ void ShibokenGenerator::getInheritedOverloads(const AbstractMetaClass *scope, Generator::OptionDescriptions ShibokenGenerator::options() const { - return { + auto result = Generator::options(); + result.append({ {QLatin1String(AVOID_PROTECTED_HACK), QLatin1String("Avoid the use of the '#define protected public' hack.")}, {QLatin1String(DISABLE_VERBOSE_ERROR_MESSAGES), @@ -2374,9 +2374,6 @@ Generator::OptionDescriptions ShibokenGenerator::options() const "but safe few kB on the generated bindings.")}, {QLatin1String(PARENT_CTOR_HEURISTIC), QLatin1String("Enable heuristics to detect parent relationship on constructors.")}, - {QLatin1String(ENABLE_PYSIDE_EXTENSIONS), - QLatin1String("Enable PySide extensions, such as support for signal/slots,\n" - "use this if you are creating a binding for a Qt-based library.")}, {QLatin1String(RETURN_VALUE_HEURISTIC), QLatin1String("Enable heuristics to detect parent relationship on return values\n" "(USE WITH CAUTION!)")}, @@ -2388,15 +2385,16 @@ Generator::OptionDescriptions ShibokenGenerator::options() const "the value of boolean casts")}, {QLatin1String(WRAPPER_DIAGNOSTICS), QLatin1String("Generate diagnostic code around wrappers")} - }; + }); + return result; } -bool ShibokenGenerator::handleOption(const QString &key, const QString & /* value */) +bool ShibokenGenerator::handleOption(const QString &key, const QString &value) { + if (Generator::handleOption(key, value)) + return true; 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)) @@ -2502,11 +2500,6 @@ bool ShibokenGenerator::useReturnValueHeuristic() const return m_userReturnValueHeuristic; } -bool ShibokenGenerator::usePySideExtensions() const -{ - return m_usePySideExtensions; -} - bool ShibokenGenerator::useIsNullAsNbNonZero() const { return m_useIsNullAsNbNonZero; diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.h b/sources/shiboken6/generator/shiboken/shibokengenerator.h index 454083768..35374b843 100644 --- a/sources/shiboken6/generator/shiboken/shibokengenerator.h +++ b/sources/shiboken6/generator/shiboken/shibokengenerator.h @@ -90,9 +90,6 @@ public: const char *name() const override { return "Shiboken"; } - /// Returns true if the user enabled PySide extensions. - bool usePySideExtensions() const; - static QString minimalConstructorExpression(const ApiExtractorResult &api, const AbstractMetaType &type); static QString minimalConstructorExpression(const ApiExtractorResult &api, @@ -474,7 +471,6 @@ private: bool m_useCtorHeuristic = false; bool m_userReturnValueHeuristic = false; - bool m_usePySideExtensions = false; bool m_verboseErrorMessagesDisabled = false; bool m_useIsNullAsNbNonZero = false; bool m_useOperatorBoolAsNbNonZero = false; |