aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside2/CMakeLists.txt5
-rw-r--r--sources/pyside2/cmake/Macros/PySideModules.cmake7
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp23
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp9
4 files changed, 43 insertions, 1 deletions
diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt
index d517d0ad7..1215e2598 100644
--- a/sources/pyside2/CMakeLists.txt
+++ b/sources/pyside2/CMakeLists.txt
@@ -104,6 +104,11 @@ if(CMAKE_HOST_APPLE)
endif()
endif()
+# Force usage of the C++11 standard, without a silent fallback
+# to C++98 if the compiler does not support C++11.
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
# Qt5: QT_INCLUDE_DIR does no longer exist.
# On Windows, macOS, and Linux it can be computed from Qt5Core_INCLUDE_DIRS, which contains
# a list of include directories. We take the first one.
diff --git a/sources/pyside2/cmake/Macros/PySideModules.cmake b/sources/pyside2/cmake/Macros/PySideModules.cmake
index 85ad6129e..b5bb725fe 100644
--- a/sources/pyside2/cmake/Macros/PySideModules.cmake
+++ b/sources/pyside2/cmake/Macros/PySideModules.cmake
@@ -160,10 +160,17 @@ macro(check_qt_class module class optional_source_files dropped_entries)
"${NAMESPACE_USE}\n"
"int main() { sizeof(${class}); }\n"
)
+
+ # Force usage of the C++11 standard. CMAKE_CXX_STANDARD does not work with try_compile
+ # but the issue has a fix in CMake 3.9. Thus we use a terrible workaround, we pass the C++
+ # standard flag the way CheckCXXSourceCompiles.cmake does it.
+ set(CUSTOM_CPP_STANDARD ${CMAKE_CXX11_EXTENSION_COMPILE_OPTION})
+
try_compile(Q_WORKS ${CMAKE_BINARY_DIR}
${SRC_FILE}
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES=${QT_INCLUDE_DIR};${Qt5${_module_no_qt_prefix}_INCLUDE_DIRS}"
+ "-DCOMPILE_DEFINITIONS:STRING=${CUSTOM_CPP_STANDARD}"
OUTPUT_VARIABLE OUTPUT)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCheckQtClassTest.log ${OUTPUT})
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index 5739643f2..5b606e063 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -2519,7 +2519,28 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const TypeInfo &_typ
return 0;
}
- if (typeInfo.arrays.size() > 0) {
+ // 2. Handle arrays.
+ // 2.1 Handle char arrays with unspecified size (aka "const char[]") as "const char*" with
+ // NativePointerPattern usage.
+ bool oneDimensionalArrayOfUnspecifiedSize =
+ typeInfo.arrays.size() == 1
+ && typeInfo.arrays[0].isEmpty();
+
+ bool isConstCharStarCase =
+ oneDimensionalArrayOfUnspecifiedSize
+ && typeInfo.qualified_name.size() == 1
+ && typeInfo.qualified_name[0] == QStringLiteral("char")
+ && typeInfo.indirections == 0
+ && typeInfo.is_constant == 1
+ && typeInfo.is_busted == 0
+ && typeInfo.referenceType == NoReference
+ && typeInfo.template_instantiations.size() == 0;
+
+ if (isConstCharStarCase)
+ typeInfo.indirections += typeInfo.arrays.size();
+
+ // 2.2 Handle regular arrays.
+ if (typeInfo.arrays.size() > 0 && !isConstCharStarCase) {
TypeInfo newInfo;
//newInfo.setArguments(typei.arguments());
newInfo.setIndirections(typei.indirections());
diff --git a/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp
index 408c51461..7c9d20ede 100644
--- a/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testarrayargument.cpp
@@ -71,8 +71,11 @@ void TestArrayArgument::testArraySignature()
void mi1(int arg[5]);\n\
void mi1c(const int arg[5]);\n\
void mi1cu(const int arg[]);\n\
+ void mc1cu(const char arg[]);\n\
+ void mc1cup(const char *arg[]);\n\
void muc2(unsigned char *arg[2][3]);\n\
void mc2c(const char *arg[5][6]);\n\
+ void mc2cu(const char arg[][2]);\n\
};\n";
const char xmlCode[] = "\
<typesystem package='Foo'>\n\
@@ -91,10 +94,16 @@ void TestArrayArgument::testArraySignature()
QLatin1String("mi1c(const int[5])"));
QCOMPARE(functionMinimalSignature(classA, QLatin1String("mi1cu")),
QLatin1String("mi1cu(const int[])"));
+ QCOMPARE(functionMinimalSignature(classA, QLatin1String("mc1cu")),
+ QLatin1String("mc1cu(const char*)"));
+ QCOMPARE(functionMinimalSignature(classA, QLatin1String("mc1cup")),
+ QLatin1String("mc1cup(const char*[])"));
QCOMPARE(functionMinimalSignature(classA, QLatin1String("muc2")),
QLatin1String("muc2(unsigned char*[2][3])"));
QCOMPARE(functionMinimalSignature(classA, QLatin1String("mc2c")),
QLatin1String("mc2c(const char*[5][6])"));
+ QCOMPARE(functionMinimalSignature(classA, QLatin1String("mc2cu")),
+ QLatin1String("mc2cu(const char[][2])"));
}
void TestArrayArgument::testArrayArgumentWithSizeDefinedByEnumValue()