diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-09-29 16:07:50 +0200 |
---|---|---|
committer | Adrian Herrmann <adrian.herrmann@qt.io> | 2022-10-07 15:33:55 +0200 |
commit | 06e1d55919b3baf24f5f3522267de5f1b80c215f (patch) | |
tree | 7c5098ee7e76fb9b21a1eb5b2c5080779771b414 | |
parent | 5aabf453a72a59119380296cbf7631fb0d93f9fd (diff) |
shiboken2/macOS: Fix C++ 11 integer types (int32_t, ...) not being recognized
The system type headers were not parsed when Xcode was installed
under /Applications/Xcode.app/Contents/Developer/...,
causing the typedefs not to be seen and int32_t being
handled as unknown primitive types. The array modifications
for the OpenGL functions were then not generated correctly.
Fix by using std::strstr() for checking.
Change-Id: Ia4344599807a9fcc3d4de5bbe850575faace4b3e
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit 92943cbb530edb4fd8b7292b3b0ea964d7a6fdde)
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r-- | sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp index 1f3a89fc9..02d39caa8 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp @@ -777,18 +777,22 @@ static bool cStringStartsWith(const char *str, const QByteArray &prefix) return std::strncmp(prefix.constData(), str, int(prefix.size())) == 0; } +#ifdef Q_OS_UNIX +static bool cStringContains(const char *str, const char *prefix) +{ + return std::strstr(str, prefix) != nullptr; +} +#endif + bool BuilderPrivate::visitHeader(const char *cFileName) const { // Resolve OpenGL typedefs although the header is considered a system header. const char *baseName = cBaseName(cFileName); if (cCompareFileName(baseName, "gl.h")) return true; -#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) - if (cStringStartsWith(cFileName, "/usr/include/stdint.h")) - return true; -#endif #ifdef Q_OS_LINUX - if (cStringStartsWith(cFileName, "/usr/include/stdlib.h") + if (cStringStartsWith(cFileName, "/usr/include/stdint.h") + || cStringStartsWith(cFileName, "/usr/include/stdlib.h") || cStringStartsWith(cFileName, "/usr/include/sys/types.h")) { return true; } @@ -797,9 +801,9 @@ bool BuilderPrivate::visitHeader(const char *cFileName) const // 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 (cCompareFileName(baseName, "gltypes.h") - || cStringStartsWith(cFileName, "/usr/include/_types") - || cStringStartsWith(cFileName, "/usr/include/_types") - || cStringStartsWith(cFileName, "/usr/include/sys/_types")) { + || cStringContains(cFileName, "/usr/include/stdint.h") + || cStringContains(cFileName, "/usr/include/_types") + || cStringContains(cFileName, "/usr/include/sys/_types")) { return true; } #endif // Q_OS_MACOS |