/*
 * Interface wrapper code.
 *
 * Generated by SIP 4.19.3
 */

#include "sipAPIKGuiAddons.h"

#include <qhash.h>

#include <qnamespace.h>
#include <qicon.h>


extern "C" {static void assign_QHash_0100Qt_Corner_0100QIcon(void *, SIP_SSIZE_T, const void *);}
static void assign_QHash_0100Qt_Corner_0100QIcon(void *sipDst, SIP_SSIZE_T sipDstIdx, const void *sipSrc)
{
    reinterpret_cast<QHash< ::Qt::Corner, ::QIcon> *>(sipDst)[sipDstIdx] = *reinterpret_cast<const QHash< ::Qt::Corner, ::QIcon> *>(sipSrc);
}


extern "C" {static void *array_QHash_0100Qt_Corner_0100QIcon(SIP_SSIZE_T);}
static void *array_QHash_0100Qt_Corner_0100QIcon(SIP_SSIZE_T sipNrElem)
{
    return new QHash< ::Qt::Corner, ::QIcon>[sipNrElem];
}


extern "C" {static void *copy_QHash_0100Qt_Corner_0100QIcon(const void *, SIP_SSIZE_T);}
static void *copy_QHash_0100Qt_Corner_0100QIcon(const void *sipSrc, SIP_SSIZE_T sipSrcIdx)
{
    return new QHash< ::Qt::Corner, ::QIcon>(reinterpret_cast<const QHash< ::Qt::Corner, ::QIcon> *>(sipSrc)[sipSrcIdx]);
}


/* Call the mapped type's destructor. */
extern "C" {static void release_QHash_0100Qt_Corner_0100QIcon(void *, int);}
static void release_QHash_0100Qt_Corner_0100QIcon(void *ptr, int)
{
    delete reinterpret_cast<QHash< ::Qt::Corner, ::QIcon> *>(ptr);
}



extern "C" {static int convertTo_QHash_0100Qt_Corner_0100QIcon(PyObject *, void **, int *, PyObject *);}
static int convertTo_QHash_0100Qt_Corner_0100QIcon(PyObject *sipPy,void **sipCppPtrV,int *sipIsErr,PyObject *sipTransferObj)
{
    QHash< ::Qt::Corner, ::QIcon> **sipCppPtr = reinterpret_cast<QHash< ::Qt::Corner, ::QIcon> **>(sipCppPtrV);

    if (!sipIsErr)
        return PyDict_Check(sipPy);

    QHash<Qt::Corner, QIcon> *qh = new QHash<Qt::Corner, QIcon>;

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

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

            delete qh;

            return 0;
        }

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

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

            sipReleaseType(k, sipType_Qt_Corner, kstate);
            delete qh;

            return 0;
        }

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

        sipReleaseType(v, sipType_QIcon, vstate);
        sipReleaseType(k, sipType_Qt_Corner, kstate);
    }
 
    *sipCppPtr = qh;
 
    return sipGetState(sipTransferObj);
}


extern "C" {static PyObject *convertFrom_QHash_0100Qt_Corner_0100QIcon(void *, PyObject *);}
static PyObject *convertFrom_QHash_0100Qt_Corner_0100QIcon(void *sipCppV, PyObject *sipTransferObj)
{
   QHash< ::Qt::Corner, ::QIcon> *sipCpp = reinterpret_cast<QHash< ::Qt::Corner, ::QIcon> *>(sipCppV);

    PyObject *d = PyDict_New();

    if (!d)
        return 0;

    QHash<Qt::Corner, QIcon>::const_iterator it = sipCpp->constBegin();
    QHash<Qt::Corner, QIcon>::const_iterator end = sipCpp->constEnd();

    while (it != end)
    {
        Qt::Corner *k = new Qt::Corner(it.key());
        PyObject *kobj = sipConvertFromNewType(k, sipType_Qt_Corner,
                sipTransferObj);

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

            return 0;
        }

        QIcon *v = new QIcon(it.value());
        PyObject *vobj = sipConvertFromNewType(v, sipType_QIcon,
                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;
}


sipMappedTypeDef sipTypeDef_KGuiAddons_QHash_0100Qt_Corner_0100QIcon = {
    {
        -1,
        0,
        0,
        SIP_TYPE_MAPPED,
        sipNameNr_92,     /* QHash<Qt::Corner,QIcon> */
        {0},
        0
    },
    {
        -1,
        {0, 0, 1},
        0, 0,
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    assign_QHash_0100Qt_Corner_0100QIcon,
    array_QHash_0100Qt_Corner_0100QIcon,
    copy_QHash_0100Qt_Corner_0100QIcon,
    release_QHash_0100Qt_Corner_0100QIcon,
    convertTo_QHash_0100Qt_Corner_0100QIcon,
    convertFrom_QHash_0100Qt_Corner_0100QIcon
};
