From 62c21af778b7bff6c86e7f89ef03a87efa6c51cb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Oct 2020 08:53:29 +0200 Subject: Move the annotations for parsing Qt-based headers to shiboken2 It is one of the lesser known things that any project generating bindings for Qt-based code needs to include pyside2_global.h in order for signals, slots and properties to be recognized, since the annotation macro definitions are in this file. Move the definitions over to shiboken2 to remove the need to include it. [ChangeLog][shiboken2] Projects generating bindings for Qt-based code no longer need to include pyside2_global.h. Change-Id: I531bb7444561ccfc352f3be09ecdf854f9f7dd3d Reviewed-by: Qt CI Bot Reviewed-by: Cristian Maureira-Fredes --- sources/shiboken2/generator/main.cpp | 5 ++++- sources/shiboken2/generator/shiboken2/shibokengenerator.h | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'sources/shiboken2/generator') diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp index 3c9d13b48..8d819c763 100644 --- a/sources/shiboken2/generator/main.cpp +++ b/sources/shiboken2/generator/main.cpp @@ -612,7 +612,10 @@ int main(int argc, char *argv[]) extractor.setCppFileNames(cppFileNames); extractor.setTypeSystem(typeSystemFileName); - if (!extractor.run()) { + auto shibokenGenerator = dynamic_cast(generators.constFirst().data()); + const bool usePySideExtensions = shibokenGenerator && shibokenGenerator->usePySideExtensions(); + + if (!extractor.run(usePySideExtensions)) { errorPrint(QLatin1String("Error running ApiExtractor.")); return EXIT_FAILURE; } diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h index 33da01a3a..6d36026cd 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h @@ -90,6 +90,9 @@ public: /// Returns a list of all ancestor classes for the given class. AbstractMetaClassList getAllAncestors(const AbstractMetaClass *metaClass) const; + /// Returns true if the user enabled PySide extensions. + bool usePySideExtensions() const; + protected: bool doSetup() override; @@ -377,8 +380,6 @@ protected: bool useCtorHeuristic() const; /// Returns true if the user enabled the so called "return value heuristic". bool useReturnValueHeuristic() const; - /// Returns true if the user enabled PySide extensions. - bool usePySideExtensions() const; /// Returns true if the generator should use the result of isNull()const to compute boolean casts. bool useIsNullAsNbNonZero() const; /// Returns true if the generated code should use the "#define protected public" hack. -- cgit v1.2.3