|
| 1 | +diff --git a/build_scripts/main.py b/build_scripts/main.py |
| 2 | +index cf56850df..0e1a0fa4b 100644 |
| 3 | +--- a/build_scripts/main.py |
| 4 | ++++ b/build_scripts/main.py |
| 5 | +@@ -544,6 +544,9 @@ class PysideBuild(_build): |
| 6 | + py_include_dir = os.path.join(py_prefix, "include") |
| 7 | + else: |
| 8 | + py_include_dir = os.path.join(py_prefix, "include/python{}".format(py_version)) |
| 9 | ++ if not os.path.isdir(py_include_dir): |
| 10 | ++ py_include_dir = os.path.join(py_prefix, "include/python{}m".format(py_version)) |
| 11 | ++ |
| 12 | + dbg_postfix = "" |
| 13 | + if build_type == "Debug": |
| 14 | + dbg_postfix = "_d" |
| 15 | +diff --git a/sources/pyside2/libpyside/CMakeLists.txt b/sources/pyside2/libpyside/CMakeLists.txt |
| 16 | +index 7493a453a..f67196815 100644 |
| 17 | +--- a/sources/pyside2/libpyside/CMakeLists.txt |
| 18 | ++++ b/sources/pyside2/libpyside/CMakeLists.txt |
| 19 | +@@ -1,13 +1,5 @@ |
| 20 | + project(libpyside) |
| 21 | + |
| 22 | +-if(${Qt5Qml_FOUND}) |
| 23 | +- if(NOT "${Qt5Qml_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQml/") |
| 24 | +- string(REPLACE "/QtCore" "/QtQml" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}") |
| 25 | +- list(APPEND Qt5Qml_PRIVATE_INCLUDE_DIRS ${replaceme}) |
| 26 | +- list(REMOVE_DUPLICATES Qt5Qml_PRIVATE_INCLUDE_DIRS) |
| 27 | +- endif() |
| 28 | +-endif() |
| 29 | +- |
| 30 | + if(${Qt5Quick_FOUND}) |
| 31 | + if(NOT "${Qt5Quick_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQuick/") |
| 32 | + string(REPLACE "/QtCore" "/QtQuick" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}") |
| 33 | +@@ -17,26 +9,11 @@ if(${Qt5Quick_FOUND}) |
| 34 | + endif() |
| 35 | + endif() |
| 36 | + |
| 37 | ++# Disable QML support |
| 38 | ++set(QML_SUPPORT 0) |
| 39 | + set(QML_PRIVATE_API_SUPPORT 0) |
| 40 | +-if(Qt5Qml_FOUND) |
| 41 | +- # Used for registering custom QQuickItem classes defined in Python code. |
| 42 | +- set(QML_SUPPORT 1) |
| 43 | +- set(QML_INCLUDES ${Qt5Qml_INCLUDE_DIRS}) |
| 44 | +- set(QML_LIBRARIES ${Qt5Qml_LIBRARIES}) |
| 45 | +- |
| 46 | +- if(Qt5Qml_PRIVATE_INCLUDE_DIRS) |
| 47 | +- # Used for transforming QML exceptions into Python exceptions. |
| 48 | +- set(QML_PRIVATE_API_SUPPORT 1) |
| 49 | +- set(QML_INCLUDES ${QML_INCLUDES} ${Qt5Qml_PRIVATE_INCLUDE_DIRS}) |
| 50 | +- else() |
| 51 | +- message(WARNING "QML private API include files could not be found, support for catching QML exceptions inside Python code will not work.") |
| 52 | +- endif() |
| 53 | +-else() |
| 54 | +- set(QML_SUPPORT 0) |
| 55 | +- set(QML_PRIVATE_API_SUPPORT 0) |
| 56 | +- set(QML_INCLUDES "") |
| 57 | +- set(QML_LIBRARIES "") |
| 58 | +-endif() |
| 59 | ++set(QML_INCLUDES "") |
| 60 | ++set(QML_LIBRARIES "") |
| 61 | + |
| 62 | + qt5_wrap_cpp(DESTROYLISTENER_MOC "destroylistener.h") |
| 63 | + |
| 64 | +diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp |
| 65 | +index e2b8708ce..0541c7d91 100644 |
| 66 | +--- a/sources/pyside2/libpyside/pyside.cpp |
| 67 | ++++ b/sources/pyside2/libpyside/pyside.cpp |
| 68 | +@@ -423,7 +423,7 @@ static const char invalidatePropertyName[] = "_PySideInvalidatePtr"; |
| 69 | + // class by walking up the meta objects. |
| 70 | + static const char *typeName(QObject *cppSelf) |
| 71 | + { |
| 72 | +- const char *typeName = typeid(*cppSelf).name(); |
| 73 | ++ const char *typeName = getTypeId(*cppSelf).name(); |
| 74 | + if (!Shiboken::Conversions::getConverter(typeName)) { |
| 75 | + for (auto metaObject = cppSelf->metaObject(); metaObject; metaObject = metaObject->superClass()) { |
| 76 | + const char *name = metaObject->className(); |
| 77 | +@@ -459,7 +459,6 @@ PyObject *getWrapperForQObject(QObject *cppSelf, SbkObjectType *sbk_type) |
| 78 | + } |
| 79 | + |
| 80 | + pyOut = Shiboken::Object::newObject(sbk_type, cppSelf, false, false, typeName(cppSelf)); |
| 81 | +- |
| 82 | + return pyOut; |
| 83 | + } |
| 84 | + |
| 85 | +diff --git a/sources/pyside2/libpyside/pyside.h b/sources/pyside2/libpyside/pyside.h |
| 86 | +index ae400e1fe..b7412594b 100644 |
| 87 | +--- a/sources/pyside2/libpyside/pyside.h |
| 88 | ++++ b/sources/pyside2/libpyside/pyside.h |
| 89 | +@@ -50,12 +50,57 @@ |
| 90 | + |
| 91 | + #include <QtCore/QMetaType> |
| 92 | + #include <QtCore/QHash> |
| 93 | ++#include <QtCore/QMetaObject> |
| 94 | ++#include <QtCore/QObject> |
| 95 | ++ |
| 96 | ++#include <type_traits> |
| 97 | ++#include <typeinfo> |
| 98 | + |
| 99 | + struct SbkObjectType; |
| 100 | + |
| 101 | + namespace PySide |
| 102 | + { |
| 103 | + |
| 104 | ++// Analog for std::type_info with the name field, to allow getTypeId to be used in lieu of typeid |
| 105 | ++class TypeInfo |
| 106 | ++{ |
| 107 | ++private: |
| 108 | ++ const char* m_name = nullptr; |
| 109 | ++ |
| 110 | ++public: |
| 111 | ++ explicit TypeInfo(const char* name) : m_name(name) {} |
| 112 | ++ const char* name() const { return m_name; } |
| 113 | ++}; |
| 114 | ++ |
| 115 | ++// getTypeId returns an interface similar to the std::type_info returned by typeid, but will attempt to use |
| 116 | ++// Qt's meta-object system for QObject subclasses instead - this allows Shiboken to interop with libraries that |
| 117 | ++// are built without RTTI |
| 118 | ++template <class T> |
| 119 | ++const TypeInfo getTypeId(typename std::enable_if<std::is_base_of<QObject, T>::value>::type* = 0) |
| 120 | ++{ |
| 121 | ++ const char* typeName = T::staticMetaObject.className(); |
| 122 | ++ return TypeInfo(typeName); |
| 123 | ++} |
| 124 | ++ |
| 125 | ++template <class T> |
| 126 | ++const TypeInfo getTypeId(typename std::enable_if<!std::is_base_of<QObject, T>::value>::type* = 0) |
| 127 | ++{ |
| 128 | ++ return TypeInfo(typeid(T).name()); |
| 129 | ++} |
| 130 | ++ |
| 131 | ++template <class T> |
| 132 | ++const TypeInfo getTypeId(const T& t, typename std::enable_if<std::is_base_of<QObject, T>::value>::type* = 0) |
| 133 | ++{ |
| 134 | ++ const char* typeName = t.metaObject() ? t.metaObject()->className() : T::staticMetaObject.className(); |
| 135 | ++ return TypeInfo(typeName); |
| 136 | ++} |
| 137 | ++ |
| 138 | ++template <class T> |
| 139 | ++const TypeInfo getTypeId(const T& t, typename std::enable_if<!std::is_base_of<QObject, T>::value>::type* = 0) |
| 140 | ++{ |
| 141 | ++ return TypeInfo(typeid(t).name()); |
| 142 | ++} |
| 143 | ++ |
| 144 | + PYSIDE_API void init(PyObject *module); |
| 145 | + |
| 146 | + /** |
| 147 | +diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt |
| 148 | +index c1349cae6..5e6071bb7 100644 |
| 149 | +--- a/sources/shiboken2/CMakeLists.txt |
| 150 | ++++ b/sources/shiboken2/CMakeLists.txt |
| 151 | +@@ -76,7 +76,7 @@ if (NOT PYTHON_EXTENSION_SUFFIX) |
| 152 | + get_python_extension_suffix() |
| 153 | + endif() |
| 154 | + |
| 155 | +-option(FORCE_LIMITED_API "Enable the limited API." "yes") |
| 156 | ++option(FORCE_LIMITED_API "Enable the limited API." ON) |
| 157 | + set(PYTHON_LIMITED_API 0) |
| 158 | + |
| 159 | + shiboken_check_if_limited_api() |
| 160 | +diff --git a/sources/shiboken2/data/shiboken_helpers.cmake b/sources/shiboken2/data/shiboken_helpers.cmake |
| 161 | +index 6bd75d0ea..316b52f05 100644 |
| 162 | +--- a/sources/shiboken2/data/shiboken_helpers.cmake |
| 163 | ++++ b/sources/shiboken2/data/shiboken_helpers.cmake |
| 164 | +@@ -298,7 +298,7 @@ macro(shiboken_check_if_limited_api) |
| 165 | + OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES |
| 166 | + OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 167 | + |
| 168 | +- if(FORCE_LIMITED_API STREQUAL "yes") |
| 169 | ++ if(FORCE_LIMITED_API) |
| 170 | + if (${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER 4) |
| 171 | + # GREATER_EQUAL is available only from cmake 3.7 on. We mean python 3.5 . |
| 172 | + set(PYTHON_LIMITED_API 1) |
| 173 | +diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp |
| 174 | +index 64467e3d1..e729c49ea 100644 |
| 175 | +--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp |
| 176 | ++++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp |
| 177 | +@@ -58,7 +58,11 @@ static const char typeNameFunc[] = R"CPP( |
| 178 | + template <class T> |
| 179 | + static const char *typeNameOf(const T &t) |
| 180 | + { |
| 181 | ++#ifdef PYSIDE_H |
| 182 | ++ const char *typeName = PySide::getTypeId<T>(t).name(); |
| 183 | ++#else |
| 184 | + const char *typeName = typeid(t).name(); |
| 185 | ++#endif //PYSIDE_H |
| 186 | + auto size = std::strlen(typeName); |
| 187 | + #if defined(Q_CC_MSVC) // MSVC: "class QPaintDevice * __ptr64" |
| 188 | + if (auto lastStar = strchr(typeName, '*')) { |
| 189 | +@@ -1522,18 +1526,31 @@ void CppGenerator::writeConverterRegister(QTextStream &s, const AbstractMetaClas |
| 190 | + cppSignature.removeFirst(); |
| 191 | + } |
| 192 | + |
| 193 | +- s << INDENT << "Shiboken::Conversions::registerConverterName(converter, typeid(::"; |
| 194 | ++ if (usePySideExtensions() && metaClass->isQObject()) { |
| 195 | ++ s << INDENT << "Shiboken::Conversions::registerConverterName(converter, PySide::getTypeId<::"; |
| 196 | ++ } else { |
| 197 | ++ s << INDENT << "Shiboken::Conversions::registerConverterName(converter, typeid(::"; |
| 198 | ++ } |
| 199 | + QString qualifiedCppNameInvocation; |
| 200 | + if (!classContext.forSmartPointer()) |
| 201 | + qualifiedCppNameInvocation = metaClass->qualifiedCppName(); |
| 202 | + else |
| 203 | + qualifiedCppNameInvocation = classContext.preciseType()->cppSignature(); |
| 204 | + |
| 205 | +- s << qualifiedCppNameInvocation << ").name());\n"; |
| 206 | ++ if (usePySideExtensions() && metaClass->isQObject()) { |
| 207 | ++ s << qualifiedCppNameInvocation << ">().name());\n"; |
| 208 | ++ } else { |
| 209 | ++ s << qualifiedCppNameInvocation << ").name());\n"; |
| 210 | ++ } |
| 211 | + |
| 212 | + if (shouldGenerateCppWrapper(metaClass)) { |
| 213 | +- s << INDENT << "Shiboken::Conversions::registerConverterName(converter, typeid(::"; |
| 214 | +- s << wrapperName(metaClass) << ").name());\n"; |
| 215 | ++ if (usePySideExtensions() && metaClass->isQObject()) { |
| 216 | ++ s << INDENT << "Shiboken::Conversions::registerConverterName(converter, PySide::getTypeId<::"; |
| 217 | ++ s << wrapperName(metaClass) << ">().name());\n"; |
| 218 | ++ } else { |
| 219 | ++ s << INDENT << "Shiboken::Conversions::registerConverterName(converter, typeid(::"; |
| 220 | ++ s << wrapperName(metaClass) << ").name());\n"; |
| 221 | ++ } |
| 222 | + } |
| 223 | + |
| 224 | + s << endl; |
0 commit comments