From 39236c01ae6c9bc99ee3a02d8294679e12d9b734 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 22 May 2017 16:44:51 +0200 Subject: move everying into sources/pyside2 in preparation for a subtree merge. this should not be necessary to do in a separate commit, but git is a tad stupid about following history correctly without it. --- sources/pyside2/PySide2/QtCore/CMakeLists.txt | 185 + .../QtCore/glue/qbytearray_bufferprotocol.cpp | 73 + .../PySide2/QtCore/glue/qcoreapplication_init.cpp | 63 + .../PySide2/QtCore/glue/qeasingcurve_glue.cpp | 159 + .../PySide2/QtCore/glue/qeasingcurve_glue.h | 66 + .../PySide2/QtCore/glue/qobject_connect.cpp | 228 ++ .../PySide2/QtCore/glue/qobject_findchild.cpp | 78 + .../pyside2/PySide2/QtCore/typesystem_core.xml.in | 45 + .../PySide2/QtCore/typesystem_core_common.xml | 4225 ++++++++++++++++++++ .../pyside2/PySide2/QtCore/typesystem_core_mac.xml | 57 + .../pyside2/PySide2/QtCore/typesystem_core_win.xml | 90 + .../pyside2/PySide2/QtCore/typesystem_core_x11.xml | 61 + 12 files changed, 5330 insertions(+) create mode 100644 sources/pyside2/PySide2/QtCore/CMakeLists.txt create mode 100644 sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp create mode 100644 sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp create mode 100644 sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp create mode 100644 sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h create mode 100644 sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp create mode 100644 sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp create mode 100644 sources/pyside2/PySide2/QtCore/typesystem_core.xml.in create mode 100644 sources/pyside2/PySide2/QtCore/typesystem_core_common.xml create mode 100644 sources/pyside2/PySide2/QtCore/typesystem_core_mac.xml create mode 100644 sources/pyside2/PySide2/QtCore/typesystem_core_win.xml create mode 100644 sources/pyside2/PySide2/QtCore/typesystem_core_x11.xml (limited to 'sources/pyside2/PySide2/QtCore') diff --git a/sources/pyside2/PySide2/QtCore/CMakeLists.txt b/sources/pyside2/PySide2/QtCore/CMakeLists.txt new file mode 100644 index 000000000..4e833f584 --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/CMakeLists.txt @@ -0,0 +1,185 @@ +project(QtCore) + +set(QtCore_gluecode "${QtCore_SOURCE_DIR}/glue/qeasingcurve_glue.cpp") + +if(ENABLE_WIN) + set(SPECIFIC_OS_FILES + ${QtCore_GEN_DIR}/qwineventnotifier_wrapper.cpp + ) +else() + set(SPECIFIC_OS_FILES "") +endif() + +# TODO: Fix cycling dependency when generating QDataStream operator<< for QUuid +set (QtCore_SRC_FIXED_ME ${QtCore_GEN_DIR}/quuid_wrapper.cpp) + +set(QtCore_SRC +${QtCore_GEN_DIR}/qabstractanimation_wrapper.cpp +${QtCore_GEN_DIR}/qabstracteventdispatcher_timerinfo_wrapper.cpp +${QtCore_GEN_DIR}/qabstracteventdispatcher_wrapper.cpp +${QtCore_GEN_DIR}/qabstractitemmodel_wrapper.cpp +${QtCore_GEN_DIR}/qabstractlistmodel_wrapper.cpp +${QtCore_GEN_DIR}/qabstractproxymodel_wrapper.cpp +${QtCore_GEN_DIR}/qabstractstate_wrapper.cpp +${QtCore_GEN_DIR}/qabstracttablemodel_wrapper.cpp +${QtCore_GEN_DIR}/qabstracttransition_wrapper.cpp +${QtCore_GEN_DIR}/qanimationgroup_wrapper.cpp +${QtCore_GEN_DIR}/qbasicmutex_wrapper.cpp +${QtCore_GEN_DIR}/qbasictimer_wrapper.cpp +${QtCore_GEN_DIR}/qbitarray_wrapper.cpp +${QtCore_GEN_DIR}/qbuffer_wrapper.cpp +${QtCore_GEN_DIR}/qbytearray_wrapper.cpp +${QtCore_GEN_DIR}/qbytearraymatcher_wrapper.cpp +${QtCore_GEN_DIR}/qchildevent_wrapper.cpp +${QtCore_GEN_DIR}/qcollator_wrapper.cpp +${QtCore_GEN_DIR}/qcollatorsortkey_wrapper.cpp +${QtCore_GEN_DIR}/qcommandlineoption_wrapper.cpp +${QtCore_GEN_DIR}/qcommandlineparser_wrapper.cpp +${QtCore_GEN_DIR}/qcoreapplication_wrapper.cpp +${QtCore_GEN_DIR}/qcryptographichash_wrapper.cpp +${QtCore_GEN_DIR}/qdatastream_wrapper.cpp +${QtCore_GEN_DIR}/qdate_wrapper.cpp +${QtCore_GEN_DIR}/qdatetime_wrapper.cpp +${QtCore_GEN_DIR}/qdir_wrapper.cpp +${QtCore_GEN_DIR}/qdiriterator_wrapper.cpp +${QtCore_GEN_DIR}/qdynamicpropertychangeevent_wrapper.cpp +${QtCore_GEN_DIR}/qeasingcurve_wrapper.cpp +${QtCore_GEN_DIR}/qelapsedtimer_wrapper.cpp +${QtCore_GEN_DIR}/qevent_wrapper.cpp +${QtCore_GEN_DIR}/qeventloop_wrapper.cpp +${QtCore_GEN_DIR}/qeventtransition_wrapper.cpp +${QtCore_GEN_DIR}/qfactoryinterface_wrapper.cpp +${QtCore_GEN_DIR}/qfile_wrapper.cpp +${QtCore_GEN_DIR}/qfileselector_wrapper.cpp +${QtCore_GEN_DIR}/qfiledevice_wrapper.cpp +${QtCore_GEN_DIR}/qfileinfo_wrapper.cpp +${QtCore_GEN_DIR}/qfilesystemwatcher_wrapper.cpp +${QtCore_GEN_DIR}/qfinalstate_wrapper.cpp +${QtCore_GEN_DIR}/qgenericargument_wrapper.cpp +${QtCore_GEN_DIR}/qgenericreturnargument_wrapper.cpp +${QtCore_GEN_DIR}/qhistorystate_wrapper.cpp +${QtCore_GEN_DIR}/qiodevice_wrapper.cpp +${QtCore_GEN_DIR}/qjsonarray_wrapper.cpp +${QtCore_GEN_DIR}/qjsondocument_wrapper.cpp +${QtCore_GEN_DIR}/qjsonparseerror_wrapper.cpp +${QtCore_GEN_DIR}/qjsonvalue_wrapper.cpp +${QtCore_GEN_DIR}/qitemselection_wrapper.cpp +${QtCore_GEN_DIR}/qitemselectionmodel_wrapper.cpp +${QtCore_GEN_DIR}/qitemselectionrange_wrapper.cpp +${QtCore_GEN_DIR}/qlibraryinfo_wrapper.cpp +${QtCore_GEN_DIR}/qline_wrapper.cpp +${QtCore_GEN_DIR}/qlinef_wrapper.cpp +${QtCore_GEN_DIR}/qlocale_wrapper.cpp +${QtCore_GEN_DIR}/qmargins_wrapper.cpp +${QtCore_GEN_DIR}/qmarginsf_wrapper.cpp +${QtCore_GEN_DIR}/qmessagelogcontext_wrapper.cpp +${QtCore_GEN_DIR}/qmetaclassinfo_wrapper.cpp +${QtCore_GEN_DIR}/qmetaenum_wrapper.cpp +${QtCore_GEN_DIR}/qmetamethod_wrapper.cpp +${QtCore_GEN_DIR}/qmetaobject_connection_wrapper.cpp +${QtCore_GEN_DIR}/qmetaobject_wrapper.cpp +${QtCore_GEN_DIR}/qmetaproperty_wrapper.cpp +${QtCore_GEN_DIR}/qmimedata_wrapper.cpp +${QtCore_GEN_DIR}/qmimedatabase_wrapper.cpp +${QtCore_GEN_DIR}/qmimetype_wrapper.cpp +${QtCore_GEN_DIR}/qmodelindex_wrapper.cpp +${QtCore_GEN_DIR}/qmutex_wrapper.cpp +${QtCore_GEN_DIR}/qmutexlocker_wrapper.cpp +${QtCore_GEN_DIR}/qobject_wrapper.cpp +${QtCore_GEN_DIR}/qparallelanimationgroup_wrapper.cpp +${QtCore_GEN_DIR}/qpauseanimation_wrapper.cpp +${QtCore_GEN_DIR}/qpersistentmodelindex_wrapper.cpp +${QtCore_GEN_DIR}/qpluginloader_wrapper.cpp +${QtCore_GEN_DIR}/qpoint_wrapper.cpp +${QtCore_GEN_DIR}/qpointf_wrapper.cpp +${QtCore_GEN_DIR}/qprocess_wrapper.cpp +${QtCore_GEN_DIR}/qprocessenvironment_wrapper.cpp +${QtCore_GEN_DIR}/qpropertyanimation_wrapper.cpp +${QtCore_GEN_DIR}/qreadlocker_wrapper.cpp +${QtCore_GEN_DIR}/qreadwritelock_wrapper.cpp +${QtCore_GEN_DIR}/qrect_wrapper.cpp +${QtCore_GEN_DIR}/qrectf_wrapper.cpp +${QtCore_GEN_DIR}/qregexp_wrapper.cpp +${QtCore_GEN_DIR}/qresource_wrapper.cpp +${QtCore_GEN_DIR}/qrunnable_wrapper.cpp +${QtCore_GEN_DIR}/qsavefile_wrapper.cpp +${QtCore_GEN_DIR}/qsemaphore_wrapper.cpp +${QtCore_GEN_DIR}/qsequentialanimationgroup_wrapper.cpp +${QtCore_GEN_DIR}/qsettings_wrapper.cpp +${QtCore_GEN_DIR}/qsignalmapper_wrapper.cpp +${QtCore_GEN_DIR}/qsignaltransition_wrapper.cpp +${QtCore_GEN_DIR}/qsize_wrapper.cpp +${QtCore_GEN_DIR}/qsizef_wrapper.cpp +${QtCore_GEN_DIR}/qsocketnotifier_wrapper.cpp +${QtCore_GEN_DIR}/qsortfilterproxymodel_wrapper.cpp +${QtCore_GEN_DIR}/qstate_wrapper.cpp +${QtCore_GEN_DIR}/qstandardpaths_wrapper.cpp +${QtCore_GEN_DIR}/qstatemachine_signalevent_wrapper.cpp +${QtCore_GEN_DIR}/qstatemachine_wrappedevent_wrapper.cpp +${QtCore_GEN_DIR}/qstatemachine_wrapper.cpp +${QtCore_GEN_DIR}/qstorageinfo_wrapper.cpp +${QtCore_GEN_DIR}/qsysinfo_wrapper.cpp +${QtCore_GEN_DIR}/qsystemsemaphore_wrapper.cpp +${QtCore_GEN_DIR}/qt_wrapper.cpp +${QtCore_GEN_DIR}/qtemporarydir_wrapper.cpp +${QtCore_GEN_DIR}/qtemporaryfile_wrapper.cpp +${QtCore_GEN_DIR}/qtextboundaryfinder_wrapper.cpp +${QtCore_GEN_DIR}/qtextcodec_converterstate_wrapper.cpp +${QtCore_GEN_DIR}/qtextcodec_wrapper.cpp +${QtCore_GEN_DIR}/qtextdecoder_wrapper.cpp +${QtCore_GEN_DIR}/qtextencoder_wrapper.cpp +${QtCore_GEN_DIR}/qtextstream_wrapper.cpp +${QtCore_GEN_DIR}/qtextstreammanipulator_wrapper.cpp +${QtCore_GEN_DIR}/qthread_wrapper.cpp +${QtCore_GEN_DIR}/qthreadpool_wrapper.cpp +${QtCore_GEN_DIR}/qtime_wrapper.cpp +${QtCore_GEN_DIR}/qtimeline_wrapper.cpp +${QtCore_GEN_DIR}/qtimer_wrapper.cpp +${QtCore_GEN_DIR}/qtimerevent_wrapper.cpp +${QtCore_GEN_DIR}/qtranslator_wrapper.cpp +${QtCore_GEN_DIR}/qurl_wrapper.cpp +${QtCore_GEN_DIR}/qvariantanimation_wrapper.cpp +${QtCore_GEN_DIR}/qwaitcondition_wrapper.cpp +${QtCore_GEN_DIR}/qwritelocker_wrapper.cpp +${QtCore_GEN_DIR}/qxmlstreamattribute_wrapper.cpp +${QtCore_GEN_DIR}/qxmlstreamattributes_wrapper.cpp +${QtCore_GEN_DIR}/qxmlstreamentitydeclaration_wrapper.cpp +${QtCore_GEN_DIR}/qxmlstreamentityresolver_wrapper.cpp +${QtCore_GEN_DIR}/qxmlstreamnamespacedeclaration_wrapper.cpp +${QtCore_GEN_DIR}/qxmlstreamnotationdeclaration_wrapper.cpp +${QtCore_GEN_DIR}/qxmlstreamreader_wrapper.cpp +${QtCore_GEN_DIR}/qxmlstreamwriter_wrapper.cpp + + +${SPECIFIC_OS_FILES} +# module is always needed +${QtCore_GEN_DIR}/qtcore_module_wrapper.cpp +) + +configure_file("${QtCore_SOURCE_DIR}/typesystem_core.xml.in" + "${QtCore_BINARY_DIR}/typesystem_core.xml" @ONLY) + +make_path(QtCore_typesystem_path ${QtCore_SOURCE_DIR}) + + +set(QtCore_include_dirs ${QtCore_SOURCE_DIR} + ${QtCore_BINARY_DIR} + ${Qt5Core_INCLUDE_DIRS} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ) +set(QtCore_libraries pyside2 + ${SHIBOKEN_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${Qt5Core_LIBRARIES} + ) +create_pyside_module(QtCore + QtCore_include_dirs + QtCore_libraries + "" + QtCore_typesystem_path + QtCore_SRC + QtCore_gluecode + ${QtCore_BINARY_DIR}/typesystem_core.xml) + diff --git a/sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp b/sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp new file mode 100644 index 000000000..593b4bfba --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#if PY_VERSION_HEX < 0x03000000 + +// QByteArray buffer protocol functions +// see: http://www.python.org/dev/peps/pep-3118/ + +extern "C" { + +static Py_ssize_t SbkQByteArray_segcountproc(PyObject* self, Py_ssize_t* lenp) +{ + if (lenp) + *lenp = self->ob_type->tp_as_sequence->sq_length(self); + return 1; +} + +static Py_ssize_t SbkQByteArray_readbufferproc(PyObject* self, Py_ssize_t segment, void** ptrptr) +{ + if (segment || !Shiboken::Object::isValid(self)) + return -1; + + QByteArray* cppSelf = %CONVERTTOCPP[QByteArray*](self); + *ptrptr = reinterpret_cast(cppSelf->data()); + return cppSelf->size(); +} + +PyBufferProcs SbkQByteArrayBufferProc = { + /*bf_getreadbuffer*/ &SbkQByteArray_readbufferproc, + /*bf_getwritebuffer*/ (writebufferproc) &SbkQByteArray_readbufferproc, + /*bf_getsegcount*/ &SbkQByteArray_segcountproc, + /*bf_getcharbuffer*/ (charbufferproc) &SbkQByteArray_readbufferproc +}; + +} + +#endif diff --git a/sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp b/sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp new file mode 100644 index 000000000..20e9c4464 --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +// Global variables used to store argc and argv values +static int QCoreApplicationArgCount; +static char** QCoreApplicationArgValues; + +void QCoreApplication_constructor(PyObject* self, PyObject* args, QCoreApplicationWrapper** cptr) +{ + if (QCoreApplication::instance()) { + PyErr_SetString(PyExc_RuntimeError, "A QCoreApplication instance already exists."); + return; + } + + int numArgs = PyTuple_GET_SIZE(args); + if (numArgs != 1 + || !Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QCoreApplicationArgCount, &QCoreApplicationArgValues, "PySideApp")) { + PyErr_BadArgument(); + return; + } + + *cptr = new QCoreApplicationWrapper(QCoreApplicationArgCount, QCoreApplicationArgValues); + + Shiboken::Object::releaseOwnership(reinterpret_cast(self)); + PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); + Py_INCREF(self); +} diff --git a/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp new file mode 100644 index 000000000..6955b1149 --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "glue/qeasingcurve_glue.h" + +#define __ECF_ATT_NAME__ "__ecf__" +#define MAX_CUSTOM_FUNCTIONS 10 + +static void deleteData(void* data); + +struct CustomFunctionsData +{ + static CustomFunctionsData m_list[MAX_CUSTOM_FUNCTIONS]; + + PySideEasingCurveFunctor* m_obj; + QEasingCurve::EasingFunction m_func; +}; + +CustomFunctionsData CustomFunctionsData::m_list[MAX_CUSTOM_FUNCTIONS]; + +template +struct CustomFunctions +{ + static void init() + { + CustomFunctionsData data; + data.m_obj = 0; + data.m_func = &CustomFunctions::callback; + CustomFunctionsData::m_list[N] = data; + + CustomFunctions::init(); + } + + static qreal callback(qreal v) + { + return (*CustomFunctionsData::m_list[N].m_obj)(v); + } +}; + +template<> +struct CustomFunctions<0> +{ + static void init() + { + CustomFunctionsData data; + data.m_obj = 0; + data.m_func = &CustomFunctions<0>::callback; + CustomFunctionsData::m_list[0] = data; + } + + static qreal callback(qreal v) + { + return (*CustomFunctionsData::m_list[0].m_obj)(v); + } +}; + +void deleteData(void* data) +{ + delete (PySideEasingCurveFunctor*)(data); +} + +void PySideEasingCurveFunctor::init() +{ + CustomFunctions::init(); +} + +QEasingCurve::EasingFunction PySideEasingCurveFunctor::createCustomFuntion(PyObject* parent, PyObject* pyFunc) +{ + for(int i=0; i < MAX_CUSTOM_FUNCTIONS; i++) { + CustomFunctionsData& data = CustomFunctionsData::m_list[i]; + if (data.m_obj == 0) { + data.m_obj = new PySideEasingCurveFunctor(i, parent, pyFunc); + return data.m_func; + } + } + //PyErr_Format(PyExc_RuntimeError, "PySide only supports %d custom functions simultaneously.", MAX_CUSTOM_FUNCTIONS); + return 0; +} + +PySideEasingCurveFunctor::~PySideEasingCurveFunctor() +{ + + CustomFunctionsData::m_list[m_index].m_obj = 0; + PyObject_SetAttrString(m_parent, __ECF_ATT_NAME__, Py_None); +} + +qreal PySideEasingCurveFunctor::operator()(qreal progress) +{ + Shiboken::GilState state; + PyObject* args = Py_BuildValue("(f)", progress); + PyObject* result = PyObject_CallObject(m_func, args); + qreal cppResult = 0.0; + if (result) { + Shiboken::Conversions::pythonToCppCopy(Shiboken::Conversions::PrimitiveTypeConverter(), result, &cppResult); + Py_DECREF(result); + } + Py_DECREF(args); + return cppResult; +} + +PyObject* PySideEasingCurveFunctor::callable() +{ + Py_INCREF(m_func); + return m_func; +} + +PyObject* PySideEasingCurveFunctor::callable(PyObject* parent) +{ + return PyObject_GetAttrString(parent, __ECF_ATT_NAME__); +} + +PySideEasingCurveFunctor::PySideEasingCurveFunctor(int index, PyObject* parent, PyObject* pyFunc) + : m_parent(parent), m_func(pyFunc), m_index(index) +{ + PyObject_SetAttrString(m_parent, __ECF_ATT_NAME__, m_func); + PySide::WeakRef::create(m_parent, deleteData, this); +} + diff --git a/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h new file mode 100644 index 000000000..39acac5d5 --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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 __QEASINGCURVE_GLUE__ +#define __QEASINGCURVE_GLUE__ + +#include +#include + +class PySideEasingCurveFunctor +{ + public: + static void init(); + static QEasingCurve::EasingFunction createCustomFuntion(PyObject* parent, PyObject* pyFunc); + + qreal operator()(qreal progress); + + PyObject* callable(); //Return New reference + static PyObject* callable(PyObject* parent); //Return New reference + + ~PySideEasingCurveFunctor(); + private: + PyObject* m_parent; + PyObject* m_func; + int m_index; + + PySideEasingCurveFunctor(int index, PyObject* parent, PyObject *pyFunc); +}; + +#endif diff --git a/sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp b/sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp new file mode 100644 index 000000000..5690112ca --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +static bool isDecorator(PyObject* method, PyObject* self) +{ + Shiboken::AutoDecRef methodName(PyObject_GetAttrString(method, "__name__")); + if (!PyObject_HasAttr(self, methodName)) + return true; + Shiboken::AutoDecRef otherMethod(PyObject_GetAttr(self, methodName)); + return reinterpret_cast(otherMethod.object())->im_func != \ + reinterpret_cast(method)->im_func; +} + +static bool getReceiver(QObject *source, const char* signal, PyObject* callback, QObject** receiver, PyObject** self, QByteArray* callbackSig) +{ + bool forceGlobalReceiver = false; + if (PyMethod_Check(callback)) { + *self = PyMethod_GET_SELF(callback); + if (%CHECKTYPE[QObject*](*self)) + *receiver = %CONVERTTOCPP[QObject*](*self); + forceGlobalReceiver = isDecorator(callback, *self); + } else if (PyCFunction_Check(callback)) { + *self = PyCFunction_GET_SELF(callback); + if (*self && %CHECKTYPE[QObject*](*self)) + *receiver = %CONVERTTOCPP[QObject*](*self); + } else if (PyCallable_Check(callback)) { + // Ok, just a callable object + *receiver = 0; + *self = 0; + } + + bool usingGlobalReceiver = !*receiver || forceGlobalReceiver; + + // Check if this callback is a overwrite of a non-virtual Qt slot. + if (!usingGlobalReceiver && receiver && self) { + *callbackSig = PySide::Signal::getCallbackSignature(signal, *receiver, callback, usingGlobalReceiver).toLatin1(); + const QMetaObject* metaObject = (*receiver)->metaObject(); + int slotIndex = metaObject->indexOfSlot(callbackSig->constData()); + if (slotIndex != -1 && slotIndex < metaObject->methodOffset() && PyMethod_Check(callback)) + usingGlobalReceiver = true; + } + + if (usingGlobalReceiver) { + PySide::SignalManager& signalManager = PySide::SignalManager::instance(); + *receiver = signalManager.globalReceiver(source, callback); + *callbackSig = PySide::Signal::getCallbackSignature(signal, *receiver, callback, usingGlobalReceiver).toLatin1(); + } + + return usingGlobalReceiver; +} + +static bool qobjectConnect(QObject* source, const char* signal, QObject* receiver, const char* slot, Qt::ConnectionType type) +{ + if (!signal || !slot) + return false; + + if (!PySide::Signal::checkQtSignal(signal)) + return false; + signal++; + + if (!PySide::SignalManager::registerMetaMethod(source, signal, QMetaMethod::Signal)) + return false; + + bool isSignal = PySide::Signal::isQtSignal(slot); + slot++; + PySide::SignalManager::registerMetaMethod(receiver, slot, isSignal ? QMetaMethod::Signal : QMetaMethod::Slot); + bool connection; + Py_BEGIN_ALLOW_THREADS + connection = QObject::connect(source, signal - 1, receiver, slot - 1, type); + Py_END_ALLOW_THREADS + return connection; +} + +static bool qobjectConnect(QObject* source, QMetaMethod signal, QObject* receiver, QMetaMethod slot, Qt::ConnectionType type) +{ + return qobjectConnect(source, signal.methodSignature(), receiver, slot.methodSignature(), type); +} + +static bool qobjectConnectCallback(QObject* source, const char* signal, PyObject* callback, Qt::ConnectionType type) +{ + if (!signal || !PySide::Signal::checkQtSignal(signal)) + return false; + signal++; + + int signalIndex = PySide::SignalManager::registerMetaMethodGetIndex(source, signal, QMetaMethod::Signal); + if (signalIndex == -1) + return false; + + PySide::SignalManager& signalManager = PySide::SignalManager::instance(); + + // Extract receiver from callback + QObject* receiver = 0; + PyObject* self = 0; + QByteArray callbackSig; + bool usingGlobalReceiver = getReceiver(source, signal, callback, &receiver, &self, &callbackSig); + if (receiver == 0 && self == 0) + return false; + + const QMetaObject* metaObject = receiver->metaObject(); + const char* slot = callbackSig.constData(); + int slotIndex = metaObject->indexOfSlot(slot); + QMetaMethod signalMethod = metaObject->method(signalIndex); + + if (slotIndex == -1) { + if (!usingGlobalReceiver && self && !Shiboken::Object::hasCppWrapper((SbkObject*)self)) { + qWarning() << "You can't add dynamic slots on an object originated from C++."; + if (usingGlobalReceiver) + signalManager.releaseGlobalReceiver(source, receiver); + + return false; + } + + if (usingGlobalReceiver) + slotIndex = signalManager.globalReceiverSlotIndex(receiver, slot); + else + slotIndex = PySide::SignalManager::registerMetaMethodGetIndex(receiver, slot, QMetaMethod::Slot); + + if (slotIndex == -1) { + if (usingGlobalReceiver) + signalManager.releaseGlobalReceiver(source, receiver); + + return false; + } + } + bool connection; + Py_BEGIN_ALLOW_THREADS + connection = QMetaObject::connect(source, signalIndex, receiver, slotIndex, type); + Py_END_ALLOW_THREADS + if (connection) { + if (usingGlobalReceiver) + signalManager.notifyGlobalReceiver(receiver); + #ifndef AVOID_PROTECTED_HACK + source->connectNotify(signalMethod); //Qt5: QMetaMethod instead of char* + #else + // Need to cast to QObjectWrapper* and call the public version of + // connectNotify when avoiding the protected hack. + reinterpret_cast(source)->connectNotify(signalMethod); //Qt5: QMetaMethod instead of char* + #endif + + return connection; + } + + if (usingGlobalReceiver) + signalManager.releaseGlobalReceiver(source, receiver); + + return false; +} + + +static bool qobjectDisconnectCallback(QObject* source, const char* signal, PyObject* callback) +{ + if (!PySide::Signal::checkQtSignal(signal)) + return false; + + PySide::SignalManager& signalManager = PySide::SignalManager::instance(); + + // Extract receiver from callback + QObject* receiver = 0; + PyObject* self = 0; + QByteArray callbackSig; + QMetaMethod slotMethod; + bool usingGlobalReceiver = getReceiver(NULL, signal, callback, &receiver, &self, &callbackSig); + if (receiver == 0 && self == 0) + return false; + + const QMetaObject* metaObject = receiver->metaObject(); + int signalIndex = source->metaObject()->indexOfSignal(++signal); + int slotIndex = -1; + + slotIndex = metaObject->indexOfSlot(callbackSig); + slotMethod = metaObject->method(slotIndex); + + bool disconnected; + Py_BEGIN_ALLOW_THREADS + disconnected = QMetaObject::disconnectOne(source, signalIndex, receiver, slotIndex); + Py_END_ALLOW_THREADS + + if (disconnected) { + if (usingGlobalReceiver) + signalManager.releaseGlobalReceiver(source, receiver); + + #ifndef AVOID_PROTECTED_HACK + source->disconnectNotify(slotMethod); //Qt5: QMetaMethod instead of char* + #else + // Need to cast to QObjectWrapper* and call the public version of + // connectNotify when avoiding the protected hack. + reinterpret_cast(source)->disconnectNotify(slotMethod); //Qt5: QMetaMethod instead of char* + #endif + return true; + } + return false; +} diff --git a/sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp b/sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp new file mode 100644 index 000000000..5aa75566e --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +static QObject* _findChildHelper(const QObject* parent, const QString& name, PyTypeObject* desiredType) +{ + foreach(QObject* child, parent->children()) { + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child)); + if (PyType_IsSubtype(pyChild->ob_type, desiredType) + && (name.isNull() || name == child->objectName())) { + return child; + } + } + + QObject* obj; + foreach(QObject* child, parent->children()) { + obj = _findChildHelper(child, name, desiredType); + if (obj) + return obj; + } + return 0; +} + +static inline bool _findChildrenComparator(const QObject*& child, const QRegExp& name) +{ + return name.indexIn(child->objectName()) != -1; +} + +static inline bool _findChildrenComparator(const QObject*& child, const QString& name) +{ + return name.isNull() || name == child->objectName(); +} + +template +static void _findChildrenHelper(const QObject* parent, const T& name, PyTypeObject* desiredType, PyObject* result) +{ + foreach(const QObject* child, parent->children()) { + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child)); + if (PyType_IsSubtype(pyChild->ob_type, desiredType) && _findChildrenComparator(child, name)) + PyList_Append(result, pyChild); + _findChildrenHelper(child, name, desiredType, result); + } +} diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core.xml.in b/sources/pyside2/PySide2/QtCore/typesystem_core.xml.in new file mode 100644 index 000000000..4ccf6423f --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/typesystem_core.xml.in @@ -0,0 +1,45 @@ + + + + + + diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml new file mode 100644 index 000000000..e81eb7e21 --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml @@ -0,0 +1,4225 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // qFatal doesn't have a stream version, so we do a + // qWarning call followed by a qFatal() call using a + // literal. + qWarning() << %1; + qFatal("[A qFatal() call was made from Python code]"); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + return PyBool_FromLong((bool)%in); + + + + %out = %OUTTYPE(%in == Py_True); + + + + + + + + + + return PyLong_FromLong(%in); + + + + %out = %OUTTYPE(PyLong_AsLong(%in)); + + + + + + + + return PyLong_FromUnsignedLong(%in); + + + + %out = %OUTTYPE(PyLong_AsUnsignedLong(%in)); + + + + + + + + return PyLong_FromLong(%in); + + + + %out = %OUTTYPE(PyLong_AsLong(%in)); + + + + + + + bool py2kStrCheck(PyObject* obj) + { + #ifdef IS_PY3K + return false; + #else + return PyString_Check(obj); + #endif + } + + + + + + + const int N = %in.length(); + wchar_t* str = new wchar_t[N]; + %in.toWCharArray(str); + PyObject* %out = PyUnicode_FromWideChar(str, N); + delete[] str; + return %out; + + + + Py_UNICODE* unicode = PyUnicode_AS_UNICODE(%in); + #if defined(Py_UNICODE_WIDE) + // cast as Py_UNICODE can be a different type + %out = QString::fromUcs4((const uint*)unicode); + #else + %out = QString::fromUtf16((const ushort*)unicode, PyUnicode_GET_SIZE(%in)); + #endif + + + #ifndef IS_PY3K + const char* str = %CONVERTTOCPP[const char*](%in); + %out = %OUTTYPE(str); + #endif + + + %out = %OUTTYPE(); + + + + + + + + + const int N = %in.toString().length(); + wchar_t* str = new wchar_t[N]; + %in.toString().toWCharArray(str); + PyObject* %out = PyUnicode_FromWideChar(str, N); + delete[] str; + return %out; + + + + + + + wchar_t c = (wchar_t)%in.unicode(); + return PyUnicode_FromWideChar(&c, 1); + + + + char c = %CONVERTTOCPP[char](%in); + %out = %OUTTYPE(c); + + + int i = %CONVERTTOCPP[int](%in); + %out = %OUTTYPE(i); + + + %out = %OUTTYPE(); + + + + + + + + + + if (!%in.isValid()) + Py_RETURN_NONE; + + if (qstrcmp(%in.typeName(), "QVariantList") == 0) { + QList<QVariant> var = %in.value<QVariantList>(); + return %CONVERTTOPYTHON[QList<QVariant>](var); + } + + if (qstrcmp(%in.typeName(), "QStringList") == 0) { + QStringList var = %in.value<QStringList>(); + return %CONVERTTOPYTHON[QList<QString>](var); + } + + if (qstrcmp(%in.typeName(), "QVariantMap") == 0) { + QMap<QString, QVariant> var = %in.value<QVariantMap>(); + return %CONVERTTOPYTHON[QMap<QString, QVariant>](var); + } + + Shiboken::Conversions::SpecificConverter converter(cppInRef.typeName()); + if (converter) { + void* ptr = cppInRef.data(); + return converter.toPython(ptr); + } + PyErr_Format(PyExc_RuntimeError, "Can't find converter for '%s'.", %in.typeName()); + return 0; + + + + %out = %OUTTYPE(%in == Py_True); + + + %out = %OUTTYPE(); + + + QString in = %CONVERTTOCPP[QString](%in); + %out = %OUTTYPE(in); + + + QByteArray in = %CONVERTTOCPP[QByteArray](%in); + %out = %OUTTYPE(in); + + + double in = %CONVERTTOCPP[double](%in); + %out = %OUTTYPE(in); + + + int in = %CONVERTTOCPP[int](%in); + %out = %OUTTYPE(in); + + + qlonglong in = %CONVERTTOCPP[qlonglong](%in); + %out = %OUTTYPE(in); + + + int in = %CONVERTTOCPP[int](%in); + %out = %OUTTYPE(in); + + + // a class supported by QVariant? + int typeCode; + const char* typeName = QVariant_resolveMetaType(%in->ob_type, &typeCode); + if (!typeCode || !typeName) + return; + QVariant var(typeCode, (void*)0); + Shiboken::Conversions::SpecificConverter converter(typeName); + converter.toCpp(pyIn, var.data()); + %out = var; + + + QVariant ret = QVariant_convertToVariantMap(%in); + %out = ret.isValid() ? ret : QVariant::fromValue<PySide::PyObjectWrapper>(%in); + + + %out = QVariant_convertToVariantList(%in); + + + // Is a shiboken type not known by Qt + %out = QVariant::fromValue<PySide::PyObjectWrapper>(%in); + + + + + + static const char* QVariant_resolveMetaType(PyTypeObject* type, int* typeId) + { + if (PyObject_TypeCheck(type, &SbkObjectType_Type)) { + SbkObjectType* sbkType = (SbkObjectType*)type; + const char* typeName = Shiboken::ObjectType::getOriginalName(sbkType); + if (!typeName) + return 0; + bool valueType = '*' != typeName[qstrlen(typeName) - 1]; + // Do not convert user type of value + if (valueType && Shiboken::ObjectType::isUserType(type)) + return 0; + int obTypeId = QMetaType::type(typeName); + if (obTypeId) { + *typeId = obTypeId; + return typeName; + } + // Do not resolve types to value type + if (valueType) + return 0; + // Find in base types. First check tp_bases, and only after check tp_base, because + // tp_base does not always point to the first base class, but rather to the first + // that has added any python fields or slots to its object layout. + // See https://mail.python.org/pipermail/python-list/2009-January/520733.html + if (type->tp_bases) { + for(int i = 0; i < PyTuple_GET_SIZE(type->tp_bases); ++i) { + const char* derivedName = QVariant_resolveMetaType((PyTypeObject*)PyTuple_GET_ITEM(type->tp_bases, i), typeId); + if (derivedName) + return derivedName; + } + } + else if (type->tp_base) { + return QVariant_resolveMetaType(type->tp_base, typeId); + } + } + *typeId = 0; + return 0; + } + static QVariant QVariant_convertToValueList(PyObject* list) + { + if (PySequence_Size(list) < 1) + return QVariant(); + Shiboken::AutoDecRef element(PySequence_GetItem(list, 0)); + int typeId; + const char* typeName = QVariant_resolveMetaType(element.cast<PyTypeObject*>(), &typeId); + if (typeName) { + QByteArray listTypeName("QList<"); + listTypeName += typeName; + listTypeName += '>'; + typeId = QMetaType::type(listTypeName); + if (typeId > 0) { + Shiboken::Conversions::SpecificConverter converter(listTypeName); + if (converter) { + QVariant var(typeId, (void*)0); + converter.toCpp(list, &var); + return var; + } + qWarning() << "Type converter for :" << listTypeName << "not registered."; + } + } + return QVariant(); + } + static bool QVariant_isStringList(PyObject *list) + { + bool allString = true; + Shiboken::AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList")); + Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object()); + for(int i = 0; i < size; ++i) { + PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i); + if (!%CHECKTYPE[QString](item)) { + allString = false; + break; + } + } + return allString; + } + static QVariant QVariant_convertToVariantMap(PyObject* map) + { + Py_ssize_t pos = 0; + Shiboken::AutoDecRef keys(PyDict_Keys(map)); + if (!QVariant_isStringList(keys)) + return QVariant(); + PyObject* key; + PyObject* value; + QMap<QString,QVariant> ret; + while (PyDict_Next(map, &pos, &key, &value)) { + QString cppKey = %CONVERTTOCPP[QString](key); + QVariant cppValue = %CONVERTTOCPP[QVariant](value); + ret.insert(cppKey, cppValue); + } + return QVariant(ret); + } + static QVariant QVariant_convertToVariantList(PyObject* list) + { + if (QVariant_isStringList(list)) { + QList<QString > lst = %CONVERTTOCPP[QList<QString>](list); + return QVariant(QStringList(lst)); + } + QVariant valueList = QVariant_convertToValueList(list); + if (valueList.isValid()) + return valueList; + QList<QVariant> lst; + Shiboken::AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList")); + Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object()); + for (int i = 0; i < size; ++i) { + PyObject* pyItem = PySequence_Fast_GET_ITEM(fast.object(), i); + QVariant item = %CONVERTTOCPP[QVariant](pyItem); + lst.append(item); + } + return QVariant(lst); + } + + + + + + const char* typeName = QVariant::typeToName(%in); + PyObject* %out; + PyTypeObject* pyType = 0; + if (typeName) + pyType = Shiboken::Conversions::getPythonTypeObject(typeName); + %out = pyType ? ((PyObject*)pyType) : Py_None; + Py_INCREF(%out); + return %out; + + + + %out = QVariant::Invalid; + + + const char* typeName; + if (Shiboken::String::checkType((PyTypeObject*)%in)) + typeName = "QString"; + else if (%in == (PyObject*)&PyFloat_Type) + typeName = "double"; // float is a UserType in QVariant. + else if (%in == (PyObject*)&PyLong_Type) + typeName = "int"; // long is a UserType in QVariant. + else if (%in->ob_type == &SbkObjectType_Type) + typeName = Shiboken::ObjectType::getOriginalName((SbkObjectType*)%in); + else + typeName = ((PyTypeObject*)%in)->tp_name; + %out = QVariant::nameToType(typeName); + + + %out = QVariant::nameToType(Shiboken::String::toCString(%in)); + + + %out = QVariant::nameToType("QVariantMap"); + + + const char* typeName; + if (QVariantType_isStringList(%in)) + typeName = "QStringList"; + else + typeName = "QVariantList"; + %out = QVariant::nameToType(typeName); + + + + + + + + Shiboken::Conversions::registerConverterName(SbkPySide2_QtCoreTypeConverters[SBK_QTCORE_QMAP_QSTRING_QVARIANT_IDX], "QVariantMap"); + + + + static bool QVariantType_isStringList(PyObject* list) + { + bool allString = true; + Shiboken::AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList")); + Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object()); + for(int i=0; i < size; i++) { + PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i); + if (!%CHECKTYPE[QString](item)) { + allString = false; + break; + } + } + return allString; + } + static bool QVariantType_checkAllStringKeys(PyObject* dict) + { + Shiboken::AutoDecRef keys(PyDict_Keys(dict)); + return QVariantType_isStringList(keys); + } + + + + + + + + + + + + + + + + + + + + + + + + // The QVariantMap returned by QJsonObject seems to cause a segfault, so + // using QJsonObject.toVariantMap() won't work. + // Wrapping it in a QJsonValue first allows it to work + QJsonValue val(%in); + QVariant ret = val.toVariant(); + + return %CONVERTTOPYTHON[QVariant](ret); + + + + QVariant dict = QVariant_convertToVariantMap(%in); + QJsonValue val = QJsonValue::fromVariant(dict); + + %out = val.toObject(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PyObject* %out = PyTuple_New(2); + PyTuple_SET_ITEM(%out, 0, %CONVERTTOPYTHON[%INTYPE_0](%in.first)); + PyTuple_SET_ITEM(%out, 1, %CONVERTTOPYTHON[%INTYPE_1](%in.second)); + return %out; + + + + %out.first = %CONVERTTOCPP[%OUTTYPE_0](PySequence_Fast_GET_ITEM(%in, 0)); + %out.second = %CONVERTTOCPP[%OUTTYPE_1](PySequence_Fast_GET_ITEM(%in, 1)); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + double _abs = qAbs(%1); + %PYARG_0 = %CONVERTTOPYTHON[double](_abs); + + + + + namespace PySide { + static QStack<PyObject*> globalPostRoutineFunctions; + void globalPostRoutineCallback() + { + Shiboken::GilState state; + foreach(PyObject* callback, globalPostRoutineFunctions) { + Shiboken::AutoDecRef result(PyObject_CallObject(callback, NULL)); + Py_DECREF(callback); + } + globalPostRoutineFunctions.clear(); + } + void addPostRoutine(PyObject* callback) + { + if (PyCallable_Check(callback)) { + globalPostRoutineFunctions << callback; + Py_INCREF(callback); + } else { + PyErr_SetString(PyExc_TypeError, "qAddPostRoutine: The argument must be a callable object."); + } + } + } // namespace + + + + PySide::addPostRoutine(%1); + + + + qAddPostRoutine(PySide::globalPostRoutineCallback); + + + + QList<QByteArray> version = QByteArray(qVersion()).split('.'); + PyObject* pyQtVersion = PyTuple_New(3); + for (int i = 0; i < 3; ++i) + PyTuple_SET_ITEM(pyQtVersion, i, PyInt_FromLong(version[i].toInt())); + PyModule_AddObject(module, "__version_info__", pyQtVersion); + PyModule_AddStringConstant(module, "__version__", qVersion()); + + + + { // Avoid name clash + Shiboken::AutoDecRef regFunc((PyObject*)NULL); + Shiboken::AutoDecRef atexit(Shiboken::Module::import("atexit")); + if (atexit.isNull()) { + qWarning() << "Module atexit not found for registering __moduleShutdown"; + PyErr_Clear(); + }else{ + regFunc = PyObject_GetAttrString(atexit, "register"); + if (regFunc.isNull()) { + qWarning() << "Function atexit.register not found for registering __moduleShutdown"; + PyErr_Clear(); + } + } + if (!atexit.isNull() && !regFunc.isNull()){ + PyObject* shutDownFunc = PyObject_GetAttrString(module, "__moduleShutdown"); + Shiboken::AutoDecRef args(PyTuple_New(1)); + PyTuple_SET_ITEM(args, 0, shutDownFunc); + Shiboken::AutoDecRef retval(PyObject_Call(regFunc, args, 0)); + Q_ASSERT(!retval.isNull()); + } + } + + + + + PySide::runCleanupFunctions(); + + + + + + Shiboken::Conversions::registerConverterName(SbkPySide2_QtCoreTypeConverters[SBK_QSTRING_IDX], "unicode"); + Shiboken::Conversions::registerConverterName(SbkPySide2_QtCoreTypeConverters[SBK_QSTRING_IDX], "str"); + Shiboken::Conversions::registerConverterName(SbkPySide2_QtCoreTypeConverters[SBK_QTCORE_QLIST_QVARIANT_IDX], "QVariantList"); + + PySide::init(module); + Py_AtExit(QtCoreModuleExit); + + + #include <pyside.h> + + + + // Define a global variable to handle qInstallMessageHandler callback + static PyObject* qtmsghandler = 0; + + static void msgHandlerCallback(QtMsgType type, const QMessageLogContext & ctx, const QString &msg) + { + Shiboken::GilState state; + Shiboken::AutoDecRef arglist(PyTuple_New(3)); + PyTuple_SET_ITEM(arglist, 0, %CONVERTTOPYTHON[QtMsgType](type)); + PyTuple_SET_ITEM(arglist, 1, %CONVERTTOPYTHON[QMessageLogContext &](ctx)); + QByteArray array = msg.toLatin1().data(); + char *data = array.data(); + PyTuple_SET_ITEM(arglist, 2, %CONVERTTOPYTHON[char *](data)); + Shiboken::AutoDecRef ret(PyObject_CallObject(qtmsghandler, arglist)); + } + static void QtCoreModuleExit() + { + PySide::SignalManager::instance().clear(); + } + + + + if (%PYARG_1 == Py_None) { + qInstallMessageHandler(0); + %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None; + qtmsghandler = 0; + } else if (!PyCallable_Check(%PYARG_1)) { + PyErr_SetString(PyExc_TypeError, "parameter must be callable"); + } else { + %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None; + Py_INCREF(%PYARG_1); + qtmsghandler = %PYARG_1; + qInstallMessageHandler(msgHandlerCallback); + } + + if (%PYARG_0 == Py_None) + Py_INCREF(%PYARG_0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + namespace PySide { + template<> inline uint hash(const QLine& v) { + return qHash(qMakePair(qMakePair(v.x1(), v.y1()), qMakePair(v.x2(), v.y2()))); + } + }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QPointF p; + %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &p); + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QPointF](p)); + + + + + + + Returns a read only buffer object pointing to the segment of data that this resource represents. If the resource is compressed the data returns is compressed and qUncompress() must be used to access the data. If the resource is a directory None is returned. + + + + + + const void* d = %CPPSELF.%FUNCTION_NAME(); + if (d) { + %PYARG_0 = Shiboken::Buffer::newObject(d, %CPPSELF.size()); + } else { + Py_INCREF(Py_None); + %PYARG_0 = Py_None; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %out = %OUTTYPE(); + + + int day = PyDateTime_GET_DAY(%in); + int month = PyDateTime_GET_MONTH(%in); + int year = PyDateTime_GET_YEAR(%in); + %out = %OUTTYPE(year, month, day); + + + + + + + + + + + + + + + + + + + + + + + + + + + if (!PyDateTimeAPI) PySideDateTime_IMPORT; + %PYARG_0 = PyDate_FromDate(%CPPSELF.year(), %CPPSELF.month(), %CPPSELF.day()); + + + + + + + + + + + + + + + + + int year, month, day; + %BEGIN_ALLOW_THREADS + %CPPSELF.%FUNCTION_NAME(&year, &month, &day); + %END_ALLOW_THREADS + %PYARG_0 = PyTuple_New(3); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](year)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](month)); + PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[int](day)); + + + + + + + + + + + int yearNumber; + %BEGIN_ALLOW_THREADS + int week = %CPPSELF.%FUNCTION_NAME(&yearNumber); + %END_ALLOW_THREADS + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](week)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](yearNumber)); + + + + + + + + + + + + + %out = %OUTTYPE(); + + + int day = PyDateTime_GET_DAY(%in); + int month = PyDateTime_GET_MONTH(%in); + int year = PyDateTime_GET_YEAR(%in); + int hour = PyDateTime_DATE_GET_HOUR(%in); + int min = PyDateTime_DATE_GET_MINUTE(%in); + int sec = PyDateTime_DATE_GET_SECOND(%in); + int usec = PyDateTime_DATE_GET_MICROSECOND(%in); + %out = %OUTTYPE(QDate(year, month, day), QTime(hour, min, sec, usec/1000)); + + + + + + + + + + + + + QDate date(%1, %2, %3); + QTime time(%4, %5, %6, %7); + %0 = new %TYPE(date, time, Qt::TimeSpec(%8)); + + + + + QDate date(%1, %2, %3); + QTime time(%4, %5, %6); + %0 = new %TYPE(date, time); + + + + + + + + + + + + + + + + + + + + + QDate date = %CPPSELF.date(); + QTime time = %CPPSELF.time(); + if (!PyDateTimeAPI) PySideDateTime_IMPORT; + %PYARG_0 = PyDateTime_FromDateAndTime(date.year(), date.month(), date.day(), time.hour(), time.minute(), time.second(), time.msec()*1000); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + namespace PySide { + template<> inline uint hash(const QPoint& v) { + return qHash(qMakePair(v.x(), v.y())); + } + }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + namespace PySide { + template<> inline uint hash(const QRect& v) { + return qHash(qMakePair(qMakePair(v.x(), v.y()), qMakePair(v.width(), v.height()))); + } + }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + namespace PySide { + template<> inline uint hash(const QSize& v) { + return qHash(qMakePair(v.width(), v.height())); + } + }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %out = %OUTTYPE(); + + + int hour = PyDateTime_TIME_GET_HOUR(%in); + int min = PyDateTime_TIME_GET_MINUTE(%in); + int sec = PyDateTime_TIME_GET_SECOND(%in); + int usec = PyDateTime_TIME_GET_MICROSECOND(%in); + %out = %OUTTYPE(hour, min, sec, usec/1000); + + + + + + + + + + + + + + + + + + + + + + + + + + + if (!PyDateTimeAPI) PySideDateTime_IMPORT; + %PYARG_0 = PyTime_FromTime(%CPPSELF.hour(), %CPPSELF.minute(), %CPPSELF.second(), %CPPSELF.msec()*1000); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + return %CPPSELF.size(); + + + + + if (_i < 0 || _i >= %CPPSELF.size()) { + PyErr_SetString(PyExc_IndexError, "index out of bounds"); + return 0; + } + bool ret = %CPPSELF.at(_i); + return %CONVERTTOPYTHON[bool](ret); + + + + + PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value); + PyObject* result = Sbk_QBitArrayFunc_setBit(self, args); + Py_DECREF(args); + Py_XDECREF(result); + return !result ? -1 : 0; + + + + + + + + + + + + + + + + + + + + + + + %CPPSELF.unlock(); + + + + + + + + + + + + + + %CPPSELF.unlock(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1, %2, %PYARG_3); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + Creates a model index for the given row and column with the internal pointer ptr. + When using a QSortFilterProxyModel, its indexes have their own internal pointer. It is not advisable to access this internal pointer outside of the model. Use the data() function instead. + This function provides a consistent interface that model subclasses must use to create model indexes. + + .. warning:: Because of some Qt/Python itegration rules, the ptr argument do not get the reference incremented during the QModelIndex life time. So it is necessary to keep the object used on ptr argument alive during the whole process. Do not destroy the object if you are not sure about that. + + + + qRegisterMetaType<QVector<int> >("QVector<int>"); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // %FUNCTION_NAME() - disable generation of function call. + bool %0 = qobjectConnect(%1, %2, %CPPSELF, %3, %4); + %PYARG_0 = %CONVERTTOPYTHON[bool](%0); + + + + + + + + + // %FUNCTION_NAME() - disable generation of function call. + bool %0 = qobjectConnect(%1, %2, %3, %4, %5); + %PYARG_0 = %CONVERTTOPYTHON[bool](%0); + + + + + + + + // %FUNCTION_NAME() - disable generation of function call. + bool %0 = qobjectConnect(%1, %2, %3, %4, %5); + %PYARG_0 = %CONVERTTOPYTHON[bool](%0); + + + + + + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectConnectCallback(%1, %2, %PYARG_3, %4); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectConnectCallback(%CPPSELF, %1, %PYARG_2, %3); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectConnect(%CPPSELF, %1, %2, %3, %4); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + %RETURN_TYPE %0 = PySide::SignalManager::instance().emitSignal(%CPPSELF, %1, %PYARG_2); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectDisconnectCallback(%CPPSELF, %1, %2); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectDisconnectCallback(%1, %2, %3); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + QObject* child = _findChildHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1); + %PYARG_0 = %CONVERTTOPYTHON[QObject*](child); + + + + + + + + + + + %PYARG_0 = PyList_New(0); + _findChildrenHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1, %PYARG_0); + + + + + + + + + + + %PYARG_0 = PyList_New(0); + _findChildrenHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1, %PYARG_0); + + + + + + + + + + + + + + + + QString result; + if (QCoreApplication::instance()) { + PyObject *klass = PyObject_GetAttrString(%PYSELF, "__class__"); + PyObject *cname = PyObject_GetAttrString(klass, "__name__"); + result = QString(QCoreApplication::instance()->translate(Shiboken::String::toCString(cname), + /* %1, %2, QCoreApplication::CodecForTr, %3)); */ + %1, %2, %3)); + + Py_DECREF(klass); + Py_DECREF(cname); + } else { + result = QString(QString::fromLatin1(%1)); + } + %PYARG_0 = %CONVERTTOPYTHON[QString](result); + + + + + + // Avoid return +1 because SignalManager connect to "destroyed()" signal to control object timelife + int ret = %CPPSELF.%FUNCTION_NAME(%1); + if (ret > 0 && ((strcmp(%1, SIGNAL(destroyed())) == 0) || (strcmp(%1, SIGNAL(destroyed(QObject*))) == 0))) + ret -= PySide::SignalManager::instance().countConnectionsWith(%CPPSELF); + + %PYARG_0 = %CONVERTTOPYTHON[int](ret); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <para>URLs can be represented in two forms: encoded or unencoded. The unencoded representation is suitable for showing to users, but the encoded representation is typically what you would send to a web server. For example, the unencoded URL "http://bühler.example.com" would be sent to the server as "http://xn--bhler-kva.example.com/List%20of%20applicants.xml".</para> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Replaces every occurrence of the regular expression in *sourceString* with *after*. + Returns a new Python string with the modified contents. For example: + + :: + + s = "Banana" + re = QRegExp("a[mn]") + s = re.replace(s, "ox") + # s == "Boxoxa" + + + For regular expressions containing capturing parentheses, occurrences of \1, \2, ..., in *after* + are replaced with rx.cap(1), cap(2), ... + + :: + + t = "A <i>bon mot</i>." + re = QRegExp("<i>([^<]*)</i>") + t = re.replace(t, "\\emph{\\1}") + # t == "A \\emph{bon mot}." + + + + %1.replace(*%CPPSELF, %2); + %PYARG_0 = %CONVERTTOPYTHON[QString](%1); + + + + + + + + + + + + + + + + + + + + + + + %out = %OUTTYPE(); + + + %out = %OUTTYPE(Shiboken::String::toCString(%in), Shiboken::String::len(%in)); + + + #ifdef IS_PY3K + %out = %OUTTYPE(PyBytes_AS_STRING(%in), PyBytes_GET_SIZE(%in)); + #endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Shiboken::AutoDecRef str(PyUnicode_AsASCIIString(%PYARG_1)); + if (!str.isNull()) { + QByteArray b(PyBytes_AS_STRING(str.object()), PyBytes_GET_SIZE (str.object())); + b.prepend(*%CPPSELF); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](b); + } + + + + + Shiboken::AutoDecRef str(PyUnicode_AsASCIIString(%PYARG_1)); + if (!str.isNull()) { + QByteArray b(PyBytes_AS_STRING(str.object()), PyBytes_GET_SIZE(str.object())); + b.append(*%CPPSELF); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](b); + } + + + + + QByteArray ba = QByteArray(PyBytes_AS_STRING(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1)) + *%CPPSELF; + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + + + + + + + QByteArray b(((PyObject*)%PYSELF)->ob_type->tp_name); + PyObject* aux = Shiboken::String::fromStringAndSize(%CPPSELF.constData(), %CPPSELF.size()); + if (PyUnicode_CheckExact(aux)) { + PyObject* tmp = PyUnicode_AsASCIIString(aux); + Py_DECREF(aux); + aux = tmp; + } + b += "('"; + b += QByteArray(PyBytes_AS_STRING(aux), PyBytes_GET_SIZE(aux)); + b += "')"; + %PYARG_0 = Shiboken::String::fromStringAndSize(b.constData(), b.size()); + + + + + + + + + + + + + + + if (PyBytes_Check(%PYARG_1)) { + %0 = new QByteArray(PyBytes_AsString(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1)); + } else if (PyUnicode_CheckExact(%PYARG_1)) { + Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1)); + %0 = new QByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object())); + } else if (Shiboken::String::check(%PYARG_1)) { + %0 = new QByteArray(Shiboken::String::toCString(%PYARG_1), Shiboken::String::len(%PYARG_1)); + } + + + + + + #if PY_VERSION_HEX < 0x03000000 + Shiboken::SbkType<QByteArray>()->tp_as_buffer = &SbkQByteArrayBufferProc; + Shiboken::SbkType<QByteArray>()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER; + #endif + + + + + %PYARG_0 = PyBytes_FromStringAndSize(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.size()); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(PyBytes_AsString(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1)); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + + + + + + + + + + + + + %PYARG_0 = Shiboken::String::fromStringAndSize(%CPPSELF.constData(), %CPPSELF.size()); + + + + + return %CPPSELF.count(); + + + + + if (_i < 0 || _i >= %CPPSELF.size()) { + PyErr_SetString(PyExc_IndexError, "index out of bounds"); + return 0; + } else { + char res[2]; + res[0] = %CPPSELF.at(_i); + res[1] = 0; + return PyBytes_FromStringAndSize(res, 1); + } + + + + + %CPPSELF.remove(_i, 1); + PyObject* args = Py_BuildValue("(nO)", _i, _value); + PyObject* result = Sbk_QByteArrayFunc_insert(self, args); + Py_DECREF(args); + Py_XDECREF(result); + return !result ? -1 : 0; + + + + + Py_ssize_t max = %CPPSELF.count(); + _i1 = qBound(Py_ssize_t(0), _i1, max); + _i2 = qBound(Py_ssize_t(0), _i2, max); + QByteArray ba; + if (_i1 < _i2) + ba = %CPPSELF.mid(_i1, _i2 - _i1); + return %CONVERTTOPYTHON[QByteArray](ba); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uchar* ptr = (uchar*) Shiboken::Buffer::getPointer(%PYARG_1); + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(ptr); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(%1, %2, %3), %2, Shiboken::Buffer::ReadWrite); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QByteArray ba; + ba.resize(%2); + %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + + + + + + + + %RETURN_TYPE %out = 0; + if (PyBytes_Check(%PYARG_0)) { + %out = PyBytes_GET_SIZE((PyObject*)%PYARG_0); + memcpy(%1, PyBytes_AS_STRING((PyObject*)%PYARG_0), %out); + } else if (Shiboken::String::check(%PYARG_0)) { + %out = Shiboken::String::len((PyObject*)%PYARG_0); + memcpy(%1, Shiboken::String::toCString((PyObject*)%PYARG_0), %out); + } + + + + + + QByteArray ba; + ba.resize(%2); + %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + + + + + + + + %RETURN_TYPE %out; + if (!PyBytes_Check(%PYARG_0)) { + %out = -1; + } else { + %out = PyBytes_GET_SIZE((PyObject*)%PYARG_0); + memcpy(%1, PyBytes_AS_STRING((PyObject*)%PYARG_0), %out); + } + + + + + + + + + + + + %CPPSELF.%FUNCTION_NAME(Shiboken::String::toCString(%PYARG_1), Shiboken::String::len(%PYARG_1)); + + + + + + + + + + + + + + + + + + + + + + %CPPSELF.unlock(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Shiboken::AutoDecRef fileNo(PyObject_GetAttrString(%PYARG_1, "fileno")); + if (!fileNo.isNull()) { + Shiboken::AutoDecRef fileNoValue(PyObject_CallObject(fileNo, 0)); + if (%CHECKTYPE[int](fileNoValue)) { + int cppFileNoValue = %CONVERTTOCPP[int](fileNoValue); + /* Qt4 version: + * %0 = new %TYPE(cppFileNoValue, %2, %3); + * Qt5 has qintptr instead. + * XXX check if this means a pointer or just the pointer size cast (what I implemented) + */ + qintptr socket = (qintptr)cppFileNoValue; + %0 = new %TYPE(socket, %2, %3); + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Py_ssize_t size; + uchar* ptr = (uchar*) Shiboken::Buffer::getPointer(%PYARG_1, &size); + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(const_cast<const uchar*>(ptr), size); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + + + + + + + + + + + + // %FUNCTION_NAME() - disable generation of c++ function call + (void) %2; // remove warning about unused variable + Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); + PyObject* pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); + Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); + + QTimer* timer = %CONVERTTOCPP[QTimer*](pyTimer); + Shiboken::AutoDecRef result( + PyObject_CallMethod(pyTimer, + const_cast<char*>("connect"), + const_cast<char*>("OsOs"), + pyTimer, + SIGNAL(timeout()), + %PYARG_2, + %3) + ); + Shiboken::Object::releaseOwnership((SbkObject*)pyTimer); + Py_XDECREF(pyTimer); + timer->setSingleShot(true); + timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); + timer->start(%1); + + + + + // %FUNCTION_NAME() - disable generation of c++ function call + Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); + PyObject *pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); + Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); + QTimer* timer = %CONVERTTOCPP[QTimer*](pyTimer); + timer->setSingleShot(true); + + if (PyObject_TypeCheck(%2, &PySideSignalInstanceType)) { + PySideSignalInstance* signalInstance = reinterpret_cast<PySideSignalInstance*>(%2); + Shiboken::AutoDecRef signalSignature(Shiboken::String::fromFormat("2%s", PySide::Signal::getSignature(signalInstance))); + Shiboken::AutoDecRef result( + PyObject_CallMethod(pyTimer, + const_cast<char*>("connect"), + const_cast<char*>("OsOO"), + pyTimer, + SIGNAL(timeout()), + PySide::Signal::getObject(signalInstance), + signalSignature.object()) + ); + } else { + Shiboken::AutoDecRef result( + PyObject_CallMethod(pyTimer, + const_cast<char*>("connect"), + const_cast<char*>("OsO"), + pyTimer, + SIGNAL(timeout()), + %PYARG_2) + ); + } + + timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()), Qt::DirectConnection); + Shiboken::Object::releaseOwnership((SbkObject*)pyTimer); + Py_XDECREF(pyTimer); + timer->start(%1); + + + + + + + + + + + + + + + + + + + + + + + + + + + qint64 pid; + %RETURN_TYPE retval = %TYPE::%FUNCTION_NAME(%1, %2, %3, &pid); + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[qint64](pid)); + + + + + + + long result; + #ifdef WIN32 + _PROCESS_INFORMATION* procInfo = %CPPSELF.%FUNCTION_NAME(); + result = procInfo ? procInfo->dwProcessId : 0; + #else + result = %CPPSELF.%FUNCTION_NAME(); + #endif + %PYARG_0 = %CONVERTTOPYTHON[long](result); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +.. class:: QCoreApplication(args) + + Constructs a Qt kernel application. Kernel applications are applications + without a graphical user interface. These type of applications are used + at the console or as server processes. + + The *args* argument is processed by the application, and made available + in a more convenient form by the :meth:`~QCoreApplication.arguments()` + method. + + + + QCoreApplication_constructor(%PYSELF, args, &%0); + + + + + + + + + + + QCoreApplication* app = QCoreApplication::instance(); + PyObject* pyApp = Py_None; + if (app) { + pyApp = reinterpret_cast<PyObject*>(Shiboken::BindingManager::instance().retrieveWrapper(app)); + if (!pyApp) + pyApp = %CONVERTTOPYTHON[QCoreApplication*](app); // this will keep app live after python exit (extra ref) + } + %PYARG_0 = pyApp; + Py_XINCREF(%PYARG_0); + + + + + + + + + + + + + + + + + + + + long *%out = new long; + %out = 0; + + + + + + %RETURN_TYPE %out = false; + if (PySequence_Check(%PYARG_0) && (PySequence_Size(%PYARG_0) == 2)) { + Shiboken::AutoDecRef pyResult(PySequence_GetItem(%PYARG_0, 0)); + %out = %CONVERTTOCPP[bool](pyResult); + } + + + + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[long](*result_out)); + delete result_out; + + + + + + + + + + + + + + + + + + + + + + .. warning:: QSettings.value can return different types (QVariant types) depending on the platform it's running on, so the safest way to use it is always casting the result to the desired type, e.g.: int(settings.value("myKey")) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QByteArray data; + data.resize(%2); + int result = %CPPSELF.%FUNCTION_NAME(data.data(), data.size()); + if (result == -1) { + Py_INCREF(Py_None); + %PYARG_0 = Py_None; + } else { + %PYARG_0 = PyBytes_FromStringAndSize(data.data(), result); + } + + + + + + + + int r = %CPPSELF.%FUNCTION_NAME(%1, Shiboken::String::len(%PYARG_1)); + %PYARG_0 = %CONVERTTOPYTHON[int](r); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QString& res = *%0; + %PYARG_0 = %CONVERTTOPYTHON[QString](res); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Shiboken::Object::releaseOwnership(%PYARG_0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for(int counter = 0; counter < %CPPSELF.animationCount(); ++counter ) { + QAbstractAnimation* animation = %CPPSELF.animationAt(counter); + PyObject* obj = %CONVERTTOPYTHON[QAbstractAnimation*](animation); + Shiboken::Object::setParent(NULL, obj); + Py_DECREF(obj); + } + %CPPSELF.clear(); + + + + + + + + + + + + + + PySideEasingCurveFunctor::init(); + + + + + QEasingCurve::EasingFunction func = PySideEasingCurveFunctor::createCustomFuntion(%PYSELF, %PYARG_1); + if (func) + %CPPSELF.%FUNCTION_NAME(func); + + + + + //%FUNCTION_NAME() + %PYARG_0 = PySideEasingCurveFunctor::callable(%PYSELF); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <code>machine = QStateMachine() + +s1 = new QState() +s11 = new QState(s1) +s12 = new QState(s1) + +s1h = QHistoryState(s1) +s1h.setDefaultState(s11) + +machine.addState(s1) + +s2 = QState() +machine.addState(s2) + +button = QPushButton() +# Clicking the button will cause the state machine to enter the child state +# that s1 was in the last time s1 was exited, or the history state's default +# state if s1 has never been entered. +s1.addTransition(button.clicked, s1h)</code> + + + + + + + + + + + + + + + + + + + + + + + if (PyObject_TypeCheck(%1, &PySideSignalInstanceType)) { + PyObject* dataSource = PySide::Signal::getObject((PySideSignalInstance*) %PYARG_1); + Shiboken::AutoDecRef obType(PyObject_Type(dataSource)); + QObject* sender = %CONVERTTOCPP[QObject*](dataSource); + if (sender) { + const char* dataSignature = PySide::Signal::getSignature((PySideSignalInstance*) %PYARG_1); + QByteArray signature(dataSignature); // Append SIGNAL flag (2) + %0 = new QSignalTransitionWrapper(sender, "2" + signature, %2); + } + } + + + + + + + + + + + + + + + + + + + QString signalName(%2); + if (PySide::SignalManager::registerMetaMethod(%1, signalName.mid(1).toLatin1().data(), QMetaMethod::Signal)) { + QSignalTransition* %0 = %CPPSELF->addTransition(%1, %2, %3); + %PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%0); + } else { + Py_INCREF(Py_None); + %PYARG_0 = Py_None; + } + + + + + + + + + + + + + + + // Obviously the label used by the following goto is a very awkward solution, + // since it refers to a name very tied to the generator implementation. + // Check bug #362 for more information on this + // http://bugs.openbossa.org/show_bug.cgi?id=362 + if (!PyObject_TypeCheck(%1, &PySideSignalInstanceType)) + goto Sbk_%TYPEFunc_%FUNCTION_NAME_TypeError; + PySideSignalInstance* signalInstance = reinterpret_cast<PySideSignalInstance*>(%1); + QObject* sender = %CONVERTTOCPP[QObject*](PySide::Signal::getObject(signalInstance)); + QSignalTransition* %0 = %CPPSELF->%FUNCTION_NAME(sender, PySide::Signal::getSignature(signalInstance), %2); + %PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %PYARG_0 = PySet_New(0); + foreach(QAbstractState* abs_state, %CPPSELF.configuration()) { + Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractState*](abs_state)); + Shiboken::Object::setParent(self, obj); + PySet_Add(%PYARG_0, obj); + } + + + + + + + + %PYARG_0 = PyList_New(0); + foreach(QAbstractAnimation* abs_anim, %CPPSELF.defaultAnimations()) { + Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractAnimation*](abs_anim)); + Shiboken::Object::setParent(self, obj); + PyList_Append(%PYARG_0, obj); + } + + + + + + + + + + + %PYARG_0 = Shiboken::String::fromFormat("2%s", QMetaObject::normalizedSignature(%1).constData()); + + + + + + %PYARG_0 = Shiboken::String::fromFormat("1%s", QMetaObject::normalizedSignature(%1).constData()); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + extern bool + qRegisterResourceData(int, + const unsigned char *, + const unsigned char *, + const unsigned char *); + + extern bool + qUnregisterResourceData(int, + const unsigned char *, + const unsigned char *, + const unsigned char *); + + + + %RETURN_TYPE %0 = %FUNCTION_NAME(%1, (uchar*)PyBytes_AS_STRING(%PYARG_2), + (uchar*)PyBytes_AS_STRING(%PYARG_3), + (uchar*)PyBytes_AS_STRING(%PYARG_4)); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + %RETURN_TYPE %0 = %FUNCTION_NAME(%1, (uchar*)PyBytes_AS_STRING(%PYARG_2), + (uchar*)PyBytes_AS_STRING(%PYARG_3), + (uchar*)PyBytes_AS_STRING(%PYARG_4)); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_mac.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_mac.xml new file mode 100644 index 000000000..be4832c01 --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_mac.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_win.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_win.xml new file mode 100644 index 000000000..c9c9f73c5 --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_win.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + #ifdef IS_PY3K + return PyCapsule_New(%in, 0, 0); + #else + return PyCObject_FromVoidPtr(%in, 0); + #endif + + + + %out = 0; + + + #ifdef IS_PY3K + %out = (%OUTTYPE)PyCapsule_GetPointer(%in, 0); + #else + %out = (%OUTTYPE)PyCObject_AsVoidPtr(%in); + #endif + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_x11.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_x11.xml new file mode 100644 index 000000000..801c52b0f --- /dev/null +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_x11.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3