diff options
Diffstat (limited to 'sources/pyside2')
-rw-r--r-- | sources/pyside2/PySide2/QtCore/typesystem_core_common.xml | 4 | ||||
-rw-r--r-- | sources/pyside2/PySide2/QtScript/qscript_value_iterator_glue.cpp | 3 | ||||
-rw-r--r-- | sources/pyside2/PySide2/QtScript/typesystem_script.xml | 4 | ||||
-rw-r--r-- | sources/pyside2/libpyside/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sources/pyside2/libpyside/globalreceiver.cpp | 1 | ||||
-rw-r--r-- | sources/pyside2/libpyside/globalreceiverv2.cpp | 1 | ||||
-rw-r--r-- | sources/pyside2/libpyside/pyside.cpp | 5 | ||||
-rw-r--r-- | sources/pyside2/libpyside/pysideconversions.h | 275 | ||||
-rw-r--r-- | sources/pyside2/libpyside/signalmanager.cpp.in | 28 |
9 files changed, 11 insertions, 311 deletions
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml index 41a20a617..951d943ee 100644 --- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml @@ -313,7 +313,6 @@ </primitive-type> <primitive-type name="QVariant" target-lang-api-name="PyObject"> - <include file-name="typeresolver.h" location="global"/> <conversion-rule> <native-to-target> if (!%in.isValid()) @@ -756,7 +755,8 @@ <container-type name="QHash" type="hash"> <include file-name="QHash" location="global"/> - <include file-name="pysideconversions.h" location="global"/> + <!-- Include to make enum flags work. --> + <include file-name="pysideqflags.h" location="global"/> <conversion-rule> <native-to-target> <insert-template name="cppmap_to_pymap_conversion"/> diff --git a/sources/pyside2/PySide2/QtScript/qscript_value_iterator_glue.cpp b/sources/pyside2/PySide2/QtScript/qscript_value_iterator_glue.cpp new file mode 100644 index 000000000..fd9cd84a3 --- /dev/null +++ b/sources/pyside2/PySide2/QtScript/qscript_value_iterator_glue.cpp @@ -0,0 +1,3 @@ +%PYARG_0 = Shiboken::Object::newObject( + reinterpret_cast<SbkObjectType*>(Shiboken::SbkType< ::QScriptValueIterator >()), + new QScriptValueIterator(*%CPPSELF), true, true); diff --git a/sources/pyside2/PySide2/QtScript/typesystem_script.xml b/sources/pyside2/PySide2/QtScript/typesystem_script.xml index 9dbd107a1..46ee824c1 100644 --- a/sources/pyside2/PySide2/QtScript/typesystem_script.xml +++ b/sources/pyside2/PySide2/QtScript/typesystem_script.xml @@ -106,9 +106,7 @@ </inject-code> </add-function> <add-function signature="__iter__()" return-type="PyObject*"> - <inject-code> - %PYARG_0 = Shiboken::createWrapper(new QScriptValueIterator(*%CPPSELF), true, true); - </inject-code> + <inject-code file="qscript_value_iterator_glue.cpp" /> </add-function> </value-type> <object-type name="QScriptValueIterator"> diff --git a/sources/pyside2/libpyside/CMakeLists.txt b/sources/pyside2/libpyside/CMakeLists.txt index 05e383307..1cddebc07 100644 --- a/sources/pyside2/libpyside/CMakeLists.txt +++ b/sources/pyside2/libpyside/CMakeLists.txt @@ -120,7 +120,6 @@ set(libpyside_HEADERS dynamicqmetaobject.h globalreceiver.h pysideclassinfo.h - pysideconversions.h pysidemacros.h signalmanager.h pyside.h diff --git a/sources/pyside2/libpyside/globalreceiver.cpp b/sources/pyside2/libpyside/globalreceiver.cpp index e183e09ba..5e0aa0d66 100644 --- a/sources/pyside2/libpyside/globalreceiver.cpp +++ b/sources/pyside2/libpyside/globalreceiver.cpp @@ -49,7 +49,6 @@ #include <sbkconverter.h> #include <gilstate.h> -#include "typeresolver.h" #include "signalmanager.h" #define RECEIVER_DESTROYED_SLOT_NAME "__receiverDestroyed__(QObject*)" diff --git a/sources/pyside2/libpyside/globalreceiverv2.cpp b/sources/pyside2/libpyside/globalreceiverv2.cpp index a79d43c20..9e9bccbaf 100644 --- a/sources/pyside2/libpyside/globalreceiverv2.cpp +++ b/sources/pyside2/libpyside/globalreceiverv2.cpp @@ -48,7 +48,6 @@ #include <autodecref.h> #include <gilstate.h> -#include "typeresolver.h" #include "signalmanager.h" #define RECEIVER_DESTROYED_SLOT_NAME "__receiverDestroyed__(QObject*)" diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp index d4e867c61..17366ce6e 100644 --- a/sources/pyside2/libpyside/pyside.cpp +++ b/sources/pyside2/libpyside/pyside.cpp @@ -50,14 +50,15 @@ #include "dynamicqmetaobject.h" #include "destroylistener.h" +#include <autodecref.h> #include <qapp_macro.h> #include <basewrapper.h> -#include <conversions.h> #include <sbkconverter.h> +#include <sbkstring.h> #include <gilstate.h> -#include <typeresolver.h> #include <bindingmanager.h> #include <algorithm> +#include <typeinfo> #include <cstring> #include <cctype> #include <QStack> diff --git a/sources/pyside2/libpyside/pysideconversions.h b/sources/pyside2/libpyside/pysideconversions.h deleted file mode 100644 index ed8002fae..000000000 --- a/sources/pyside2/libpyside/pysideconversions.h +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of PySide2. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PYSIDECONVERSIONS_H -#define PYSIDECONVERSIONS_H - -#include <sbkpython.h> -#include <QFlag> -#include <conversions.h> -#include <pysideqflags.h> - -template <typename QtDict> -struct QtDictConverter -{ - static inline bool checkType(PyObject* pyObj) - { - return isConvertible(pyObj); - } - - static inline bool isConvertible(PyObject* pyObj) - { - if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<QtDict>())) - return true; - - if ((Shiboken::SbkType<QtDict>() && Shiboken::Object::checkType(pyObj)) || !PyDict_Check(pyObj)) - return false; - - PyObject* key; - PyObject* value; - Py_ssize_t pos = 0; - - while (PyDict_Next(pyObj, &pos, &key, &value)) { - if (!Shiboken::Converter<typename QtDict::key_type>::isConvertible(key) - && !Shiboken::Converter<typename QtDict::mapped_type>::isConvertible(value)) { - return false; - } - } - return true; - } - - static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<QtDict*>(cppObj)); } - static inline PyObject* toPython(const QtDict& cppobj) - { - PyObject* result = PyDict_New(); - typename QtDict::const_iterator it = cppobj.begin(); - - for (; it != cppobj.end(); ++it) { - Shiboken::AutoDecRef keyObj(Shiboken::Converter<typename QtDict::key_type>::toPython(it.key())); - Shiboken::AutoDecRef valueObj(Shiboken::Converter<typename QtDict::mapped_type>::toPython(it.value())); - PyDict_SetItem(result, keyObj, valueObj); - } - - return result; - } - static inline QtDict toCpp(PyObject* pyobj) - { - if (PyObject_TypeCheck(pyobj, Shiboken::SbkType<QtDict>())) - return *reinterpret_cast<QtDict *>(Shiboken::Object::cppPointer(reinterpret_cast<SbkObject *>(pyobj), Shiboken::SbkType<QtDict>())); - - QtDict result; - - PyObject* key; - PyObject* value; - Py_ssize_t pos = 0; - - while (PyDict_Next(pyobj, &pos, &key, &value)) - result[Shiboken::Converter<typename QtDict::key_type>::toCpp(key)] = Shiboken::Converter<typename QtDict::mapped_type>::toCpp(value); - return result; - } -}; - -template <typename MultiMap> -struct QtMultiMapConverter -{ - static inline bool checkType(PyObject* pyObj) - { - return isConvertible(pyObj); - } - - static inline bool isConvertible(PyObject* pyObj) - { - if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<MultiMap>())) - return true; - - if ((Shiboken::SbkType<MultiMap>() && Shiboken::Object::checkType(pyObj)) || !PyDict_Check(pyObj)) - return false; - - PyObject* key; - PyObject* value; - Py_ssize_t pos = 0; - - while (PyDict_Next(pyObj, &pos, &key, &value)) { - if (!Shiboken::Converter<typename MultiMap::key_type>::isConvertible(key)) { - if (PySequence_Check(value)) { - for (int i = 0, max = PySequence_Length(value); i < max; ++i) { - Shiboken::AutoDecRef item(PySequence_GetItem(value, i)); - if (!Shiboken::Converter<typename MultiMap::mapped_type>::isConvertible(value)) - return false; - } - } else if (!Shiboken::Converter<typename MultiMap::mapped_type>::isConvertible(value)) { - return false; - } - } - } - return true; - } - - static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<MultiMap*>(cppObj)); } - static inline PyObject* toPython(const MultiMap& cppObj) - { - PyObject* result = PyDict_New(); - typename MultiMap::const_iterator it = cppObj.begin(); - - for (; it != cppObj.end(); ++it) { - Shiboken::AutoDecRef key(Shiboken::Converter<typename MultiMap::key_type>::toPython(it.key())); - Shiboken::AutoDecRef value(Shiboken::Converter<typename MultiMap::mapped_type>::toPython(it.value())); - - PyObject* values = PyDict_GetItem(result, key); - bool decRefValues = !values; - if (!values) - values = PyList_New(0); - PyList_Append(values, value); - PyDict_SetItem(result, key, values); - if (decRefValues) { - Py_DECREF(values); - } - } - - return result; - } - - static inline MultiMap toCpp(PyObject* pyObj) - { - if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<MultiMap>())) - return *reinterpret_cast<MultiMap *>(Shiboken::Object::cppPointer(reinterpret_cast<SbkObject *>(pyObj), Shiboken::SbkType<MultiMap>())); - - MultiMap result; - - PyObject* key; - PyObject* value; - Py_ssize_t pos = 0; - - while (PyDict_Next(pyObj, &pos, &key, &value)) - result[Shiboken::Converter<typename MultiMap::key_type>::toCpp(key)] = Shiboken::Converter<typename MultiMap::mapped_type>::toCpp(value); - return result; - } -}; - -template <typename T> -struct QSequenceConverter -{ - static inline bool checkType(PyObject* pyObj) - { - return isConvertible(pyObj); - } - - static inline bool isConvertible(PyObject* pyObj) - { - if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<T>())) - return true; - if ((Shiboken::SbkType<T>() && Shiboken::Object::checkType(pyObj)) || !PySequence_Check(pyObj)) - return false; - for (int i = 0, max = PySequence_Length(pyObj); i < max; ++i) { - Shiboken::AutoDecRef item(PySequence_GetItem(pyObj, i)); - if (!Shiboken::Converter<typename T::value_type>::isConvertible(item)) - return false; - } - return true; - } - static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<T*>(cppObj)); } - static PyObject* toPython(const T& cppobj) - { - PyObject* result = PyList_New((int) cppobj.size()); - typename T::const_iterator it = cppobj.begin(); - for (int idx = 0; it != cppobj.end(); ++it, ++idx) { - typename T::value_type vh(*it); - PyList_SET_ITEM(result, idx, Shiboken::Converter<typename T::value_type>::toPython(vh)); - } - return result; - } - static T toCpp(PyObject* pyobj) - { - if (PyObject_TypeCheck(pyobj, Shiboken::SbkType<T>())) - return *reinterpret_cast<T *>(Shiboken::Object::cppPointer(reinterpret_cast<SbkObject *>(pyobj), Shiboken::SbkType<T>())); - - Shiboken::AutoDecRef fastSequence(PySequence_Fast(pyobj, "Invalid sequence object")); - T result; - for (int i = 0; i < PySequence_Size(pyobj); i++) { - PyObject* pyItem = PySequence_Fast_GET_ITEM(fastSequence.object(), i); - result << Shiboken::Converter<typename T::value_type>::toCpp(pyItem); - } - return result; - } -}; - - -template <typename T> -struct QFlagsConverter -{ - static inline bool checkType(PyObject* pyObj) - { - return PyObject_TypeCheck(pyObj, Shiboken::SbkType<T>()); - } - - static inline bool isConvertible(PyObject* pyObj) - { - return PyObject_TypeCheck(pyObj, Shiboken::SbkType<T>()) - || PyObject_TypeCheck(pyObj, Shiboken::SbkType<typename T::enum_type>()); - } - - static inline PyObject* toPython(void* cppObj) - { - return toPython(*reinterpret_cast<T*>(cppObj)); - } - - static inline PyObject* toPython(const T& cppObj) - { - return reinterpret_cast<PyObject*>(PySide::QFlags::newObject(cppObj, Shiboken::SbkType<T>())); - } - - static inline T toCpp(PyObject* pyObj) - { - /* this was long. Needed int in Qt5 */ - int val = 0; - if (Shiboken::Enum::check(pyObj)) { - val = Shiboken::Enum::getValue(pyObj); - } else if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<T>())) { - val = PySide::QFlags::getValue(reinterpret_cast<PySideQFlagsObject*>(pyObj)); - } else if (PyNumber_Check(pyObj)) { - Shiboken::AutoDecRef pyLong(PyNumber_Long(pyObj)); - val = PyLong_AsLong(pyLong.object()); - } else { - PyErr_BadArgument(); - } - return T(QFlag(val)); - } -}; - -#endif diff --git a/sources/pyside2/libpyside/signalmanager.cpp.in b/sources/pyside2/libpyside/signalmanager.cpp.in index 473057cbc..8ede09610 100644 --- a/sources/pyside2/libpyside/signalmanager.cpp.in +++ b/sources/pyside2/libpyside/signalmanager.cpp.in @@ -55,10 +55,10 @@ #include <QDebug> #include <limits> #include <algorithm> -#include <typeresolver.h> #include <basewrapper.h> +#include <bindingmanager.h> #include <sbkconverter.h> -#include <conversions.h> +#include <sbkstring.h> // These private headers are needed to throw JavaScript exceptions #if @QML_PRIVATE_API_SUPPORT@ @@ -214,30 +214,6 @@ QDataStream &operator>>(QDataStream& in, PyObjectWrapper& myObj) }; -namespace Shiboken { - -template<> -struct Converter<PySide::PyObjectWrapper> -{ - static PySide::PyObjectWrapper toCpp(PyObject* obj) - { - return PySide::PyObjectWrapper(obj); - } - - static PyObject* toPython(void* obj) - { - return toPython(*reinterpret_cast<PySide::PyObjectWrapper*>(obj)); - } - - static PyObject* toPython(const PySide::PyObjectWrapper& obj) - { - Py_INCREF((PyObject*)obj); - return obj; - } -}; - -}; - using namespace PySide; struct SignalManager::SignalManagerPrivate |