aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-10-06 10:58:53 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-10-07 14:25:02 +0200
commit1db8fe5d80496be390e19d31ca9c8b87ed7579a4 (patch)
treeb262889f0e771a228887760dfc1431f4ca60dcce /sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp
parentba6179ceba84e925748068b83624c1921cfbf6d7 (diff)
shiboken6/Clang parser: Replace #ifdefery for compiler/platform by variables
Introduce enumerations for compiler and platform. Add variables, initialize them by #ifdefs and use accessor functions instead of versions. This lays the groundwork for cross-compiling. Task-number: PYSIDE-802 Pick-to: 6.2 Change-Id: I988bb9e963f6205a6433d3e48c05b7a8823f8398 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp
index 6f5a4d47f..5ea4af308 100644
--- a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp
+++ b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp
@@ -830,24 +830,30 @@ bool BuilderPrivate::visitHeader(const QString &fileName) const
|| baseName == u"stddef.h") { // size_t
return true;
}
-#ifdef Q_OS_LINUX
- if (fileName == u"/usr/include/stdlib.h"
- || baseName == u"types.h"
- || baseName == u"stdint-intn.h" // int32_t
- || baseName == u"stdint-uintn.h") { // uint32_t
- return true;
- }
-#endif // Q_OS_LINUX
-#ifdef Q_OS_MACOS
- // Parse the following system headers to get the correct typdefs for types like
- // int32_t, which are used in the macOS implementation of OpenGL framework.
- if (baseName == u"gltypes.h"
- || fileName.startsWith(u"/usr/include/_types")
- || fileName.startsWith(u"/usr/include/_types")
- || fileName.startsWith(u"/usr/include/sys/_types")) {
- return true;
+
+ switch (clang::platform()) {
+ case Platform::Unix:
+ if (fileName == u"/usr/include/stdlib.h"
+ || baseName == u"types.h"
+ || baseName == u"stdint-intn.h" // int32_t
+ || baseName == u"stdint-uintn.h") { // uint32_t
+ return true;
+ }
+ break;
+ case Platform::macOS:
+ // Parse the following system headers to get the correct typdefs for types like
+ // int32_t, which are used in the macOS implementation of OpenGL framework.
+ if (baseName == u"gltypes.h"
+ || fileName.startsWith(u"/usr/include/_types")
+ || fileName.startsWith(u"/usr/include/_types")
+ || fileName.startsWith(u"/usr/include/sys/_types")) {
+ return true;
+ }
+ break;
+ default:
+ break;
}
-#endif // Q_OS_MACOS
+
for (const auto &systemInclude : m_systemIncludes) {
if (systemInclude == baseName)
return true;