/*
 * Interface wrapper code.
 *
 * Generated by SIP 6.6.2
 *
 * Copyright (c) 2022 Riverbank Computing Limited <info@riverbankcomputing.com>
 * 
 * This file is part of PyQtWebEngine.
 * 
 * This file may be used under the terms of the GNU General Public License
 * version 3.0 as published by the Free Software Foundation and appearing in
 * the file LICENSE included in the packaging of this file.  Please review the
 * following information to ensure the GNU General Public License version 3.0
 * requirements will be met: http://www.gnu.org/copyleft/gpl.html.
 * 
 * If you do not wish to use this file under the terms of the GPL version 3.0
 * then you may purchase a commercial license.  For more information contact
 * info@riverbankcomputing.com.
 * 
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#include "sipAPIQtWebEngineCore.h"

#line 27 "/usr/lib/python3.10/site-packages/PyQt5/bindings/QtCore/qpycore_qmap.sip"
#include <qmap.h>
#line 29 "/build/pyqt5-webengine/src/PyQtWebEngine-5.15.6/build/QtWebEngineCore/sipQtWebEngineCoreQMap0100QByteArray0100QByteArray.cpp"

#line 30 "/usr/lib/python3.10/site-packages/PyQt5/bindings/QtCore/qbytearray.sip"
#include <qbytearray.h>
#line 33 "/build/pyqt5-webengine/src/PyQtWebEngine-5.15.6/build/QtWebEngineCore/sipQtWebEngineCoreQMap0100QByteArray0100QByteArray.cpp"


extern "C" {static void assign_QMap_0100QByteArray_0100QByteArray(void *, Py_ssize_t, void *);}
static void assign_QMap_0100QByteArray_0100QByteArray(void *sipDst, Py_ssize_t sipDstIdx, void *sipSrc)
{
    reinterpret_cast<QMap< ::QByteArray, ::QByteArray> *>(sipDst)[sipDstIdx] = *reinterpret_cast<QMap< ::QByteArray, ::QByteArray> *>(sipSrc);
}


extern "C" {static void *array_QMap_0100QByteArray_0100QByteArray(Py_ssize_t);}
static void *array_QMap_0100QByteArray_0100QByteArray(Py_ssize_t sipNrElem)
{
    return new QMap< ::QByteArray, ::QByteArray>[sipNrElem];
}


extern "C" {static void *copy_QMap_0100QByteArray_0100QByteArray(const void *, Py_ssize_t);}
static void *copy_QMap_0100QByteArray_0100QByteArray(const void *sipSrc, Py_ssize_t sipSrcIdx)
{
    return new QMap< ::QByteArray, ::QByteArray>(reinterpret_cast<const QMap< ::QByteArray, ::QByteArray> *>(sipSrc)[sipSrcIdx]);
}


/* Call the mapped type's destructor. */
extern "C" {static void release_QMap_0100QByteArray_0100QByteArray(void *, int);}
static void release_QMap_0100QByteArray_0100QByteArray(void *sipCppV, int)
{
    QMap< ::QByteArray, ::QByteArray> *sipCpp = reinterpret_cast<QMap< ::QByteArray, ::QByteArray> *>(sipCppV);
    delete sipCpp;
}



extern "C" {static int convertTo_QMap_0100QByteArray_0100QByteArray(PyObject *, void **, int *, PyObject *);}
static int convertTo_QMap_0100QByteArray_0100QByteArray(PyObject *sipPy, void **sipCppPtrV, int *sipIsErr, PyObject *sipTransferObj)
{
    QMap< ::QByteArray, ::QByteArray> **sipCppPtr = reinterpret_cast<QMap< ::QByteArray, ::QByteArray> **>(sipCppPtrV);

#line 85 "/usr/lib/python3.10/site-packages/PyQt5/bindings/QtCore/qpycore_qmap.sip"
    if (!sipIsErr)
        return PyDict_Check(sipPy);

    QMap<QByteArray, QByteArray> *qm = new QMap<QByteArray, QByteArray>;

    Py_ssize_t pos = 0;
    PyObject *kobj, *vobj;
 
    while (PyDict_Next(sipPy, &pos, &kobj, &vobj))
    {
        int kstate;
        QByteArray *k = reinterpret_cast<QByteArray *>(
                sipForceConvertToType(kobj, sipType_QByteArray, sipTransferObj,
                        SIP_NOT_NONE, &kstate, sipIsErr));

        if (*sipIsErr)
        {
            PyErr_Format(PyExc_TypeError,
                    "a dict key has type '%s' but 'QByteArray' is expected",
                    sipPyTypeName(Py_TYPE(kobj)));

            delete qm;

            return 0;
        }

        int vstate;
        QByteArray *v = reinterpret_cast<QByteArray *>(
                sipForceConvertToType(vobj, sipType_QByteArray, sipTransferObj,
                        SIP_NOT_NONE, &vstate, sipIsErr));

        if (*sipIsErr)
        {
            PyErr_Format(PyExc_TypeError,
                    "a dict value has type '%s' but 'QByteArray' is expected",
                    sipPyTypeName(Py_TYPE(vobj)));

            sipReleaseType(k, sipType_QByteArray, kstate);
            delete qm;

            return 0;
        }

        qm->insert(*k, *v);

        sipReleaseType(v, sipType_QByteArray, vstate);
        sipReleaseType(k, sipType_QByteArray, kstate);
    }
 
    *sipCppPtr = qm;
 
    return sipGetState(sipTransferObj);
#line 125 "/build/pyqt5-webengine/src/PyQtWebEngine-5.15.6/build/QtWebEngineCore/sipQtWebEngineCoreQMap0100QByteArray0100QByteArray.cpp"
}


extern "C" {static PyObject *convertFrom_QMap_0100QByteArray_0100QByteArray(void *, PyObject *);}
static PyObject *convertFrom_QMap_0100QByteArray_0100QByteArray(void *sipCppV, PyObject *sipTransferObj)
{
   QMap< ::QByteArray, ::QByteArray> *sipCpp = reinterpret_cast<QMap< ::QByteArray, ::QByteArray> *>(sipCppV);

#line 31 "/usr/lib/python3.10/site-packages/PyQt5/bindings/QtCore/qpycore_qmap.sip"
    PyObject *d = PyDict_New();

    if (!d)
        return 0;

    QMap<QByteArray, QByteArray>::const_iterator it = sipCpp->constBegin();
    QMap<QByteArray, QByteArray>::const_iterator end = sipCpp->constEnd();

    while (it != end)
    {
        QByteArray *k = new QByteArray(it.key());
        PyObject *kobj = sipConvertFromNewType(k, sipType_QByteArray,
                sipTransferObj);

        if (!kobj)
        {
            delete k;
            Py_DECREF(d);

            return 0;
        }

        QByteArray *v = new QByteArray(it.value());
        PyObject *vobj = sipConvertFromNewType(v, sipType_QByteArray,
                sipTransferObj);

        if (!vobj)
        {
            delete v;
            Py_DECREF(kobj);
            Py_DECREF(d);

            return 0;
        }

        int rc = PyDict_SetItem(d, kobj, vobj);

        Py_DECREF(vobj);
        Py_DECREF(kobj);

        if (rc < 0)
        {
            Py_DECREF(d);

            return 0;
        }

        ++it;
    }

    return d;
#line 186 "/build/pyqt5-webengine/src/PyQtWebEngine-5.15.6/build/QtWebEngineCore/sipQtWebEngineCoreQMap0100QByteArray0100QByteArray.cpp"
}


sipMappedTypeDef sipTypeDef_QtWebEngineCore_QMap_0100QByteArray_0100QByteArray = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_MAPPED,
        sipNameNr_451,
        SIP_NULLPTR,
        SIP_NULLPTR
    },
    {
        -1,
        {0, 0, 1},
        0, 0,
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    assign_QMap_0100QByteArray_0100QByteArray,
    array_QMap_0100QByteArray_0100QByteArray,
    copy_QMap_0100QByteArray_0100QByteArray,
    release_QMap_0100QByteArray_0100QByteArray,
    convertTo_QMap_0100QByteArray_0100QByteArray,
    convertFrom_QMap_0100QByteArray_0100QByteArray
};
