/*
 * Interface wrapper code.
 *
 * Generated by SIP 6.16.1
 *
 * Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
 * 
 * This file is part of PyQt6.
 * 
 * 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 "sipAPIQtCore.h"

#line 26 "/build/pyqt6/src/pyqt6-6.11.0/sip/QtCore/qpycore_std_pair.sip"
#include <utility>
#line 29 "/build/pyqt6/src/pyqt6-6.11.0/build/QtCore/sipQtCorestdpair0100QVariant0100QVariant.cpp"

#line 26 "/build/pyqt6/src/pyqt6-6.11.0/sip/QtCore/qvariant.sip"
#include <qvariant.h>
#line 33 "/build/pyqt6/src/pyqt6-6.11.0/build/QtCore/sipQtCorestdpair0100QVariant0100QVariant.cpp"


extern "C" {static void assign_std_pair_0100QVariant_0100QVariant(void *, Py_ssize_t, void *);}
static void assign_std_pair_0100QVariant_0100QVariant(void *sipDst, Py_ssize_t sipDstIdx, void *sipSrc)
{
    reinterpret_cast<std::pair< ::QVariant, ::QVariant> *>(sipDst)[sipDstIdx] = *reinterpret_cast<std::pair< ::QVariant, ::QVariant> *>(sipSrc);
}


extern "C" {static void *array_std_pair_0100QVariant_0100QVariant(Py_ssize_t);}
static void *array_std_pair_0100QVariant_0100QVariant(Py_ssize_t sipNrElem)
{
    return new std::pair< ::QVariant, ::QVariant>[sipNrElem];
}


extern "C" {static void *copy_std_pair_0100QVariant_0100QVariant(const void *, Py_ssize_t);}
static void *copy_std_pair_0100QVariant_0100QVariant(const void *sipSrc, Py_ssize_t sipSrcIdx)
{
    return new std::pair< ::QVariant, ::QVariant>(reinterpret_cast<const std::pair< ::QVariant, ::QVariant> *>(sipSrc)[sipSrcIdx]);
}


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



extern "C" {static int convertTo_std_pair_0100QVariant_0100QVariant(PyObject *, void **, int *, PyObject *, void **);}
static int convertTo_std_pair_0100QVariant_0100QVariant(PyObject *sipPy, void **sipCppPtrV, int *sipIsErr, PyObject *sipTransferObj, void **)
{
    std::pair< ::QVariant, ::QVariant> **sipCppPtr = reinterpret_cast<std::pair< ::QVariant, ::QVariant> **>(sipCppPtrV);

#line 47 "/build/pyqt6/src/pyqt6-6.11.0/sip/QtCore/qpycore_std_pair.sip"
    if (!sipIsErr)
        return (PySequence_Check(sipPy) && !PyUnicode_Check(sipPy));

    Py_ssize_t len = PySequence_Size(sipPy);

    if (len != 2)
    {
        // A negative length should only be an internal error so let the
        // original exception stand.
        if (len >= 0)
            PyErr_Format(PyExc_TypeError,
                    "sequence has %zd elements but 2 elements are expected",
                    len);

        *sipIsErr = 1;

        return 0;
    }

    PyObject *firstobj = PySequence_GetItem(sipPy, 0);

    if (!firstobj)
    {
        *sipIsErr = 1;

        return 0;
    }

    int firststate;
    QVariant *first = reinterpret_cast<QVariant *>(
            sipForceConvertToType(firstobj, sipType_QVariant, sipTransferObj,
                    SIP_NOT_NONE, &firststate, sipIsErr));
 
    if (*sipIsErr)
    {
        PyErr_Format(PyExc_TypeError,
                "the first element has type '%s' but 'QVariant' is expected",
                sipPyTypeName(Py_TYPE(firstobj)));

        return 0;
    }

    PyObject *secondobj = PySequence_GetItem(sipPy, 1);

    if (!secondobj)
    {
        sipReleaseType(first, sipType_QVariant, firststate);
        Py_DECREF(firstobj);
        *sipIsErr = 1;

        return 0;
    }

    int secondstate;
    QVariant *second = reinterpret_cast<QVariant *>(
            sipForceConvertToType(secondobj, sipType_QVariant, sipTransferObj,
                    SIP_NOT_NONE, &secondstate, sipIsErr));
 
    if (*sipIsErr)
    {
        PyErr_Format(PyExc_TypeError,
                "the second element has type '%s' but 'QVariant' is expected",
                sipPyTypeName(Py_TYPE(secondobj)));

        Py_DECREF(secondobj);
        sipReleaseType(first, sipType_QVariant, firststate);
        Py_DECREF(firstobj);
        *sipIsErr = 1;

        return 0;
    }

    *sipCppPtr = new std::pair<QVariant, QVariant>(*first, *second);

    sipReleaseType(second, sipType_QVariant, secondstate);
    Py_DECREF(secondobj);
    sipReleaseType(first, sipType_QVariant, firststate);
    Py_DECREF(firstobj);
 
    return sipGetState(sipTransferObj);
#line 153 "/build/pyqt6/src/pyqt6-6.11.0/build/QtCore/sipQtCorestdpair0100QVariant0100QVariant.cpp"
}


extern "C" {static PyObject *convertFrom_std_pair_0100QVariant_0100QVariant(void *, PyObject *);}
static PyObject *convertFrom_std_pair_0100QVariant_0100QVariant(void *sipCppV, PyObject *sipTransferObj)
{
    std::pair< ::QVariant, ::QVariant> *sipCpp = reinterpret_cast<std::pair< ::QVariant, ::QVariant> *>(sipCppV);

#line 30 "/build/pyqt6/src/pyqt6-6.11.0/sip/QtCore/qpycore_std_pair.sip"
    QVariant *first = new QVariant(sipCpp->first);
    QVariant *second = new QVariant(sipCpp->second);
    PyObject *t = sipBuildResult(NULL, "(NN)", first, sipType_QVariant,
            sipTransferObj, second, sipType_QVariant, sipTransferObj);

    if (!t)
    {
        delete first;
        delete second;

        return 0;
    }

    return t;
#line 177 "/build/pyqt6/src/pyqt6-6.11.0/build/QtCore/sipQtCorestdpair0100QVariant0100QVariant.cpp"
}


sipMappedTypeDef sipTypeDef_QtCore_std_pair_0100QVariant_0100QVariant = {
    {
        SIP_NULLPTR,
        SIP_TYPE_MAPPED,
        sipNameNr_5217,
        SIP_NULLPTR,
        SIP_NULLPTR,
    },
    {
        -1,
        {0, 0, 1},
        0, SIP_NULLPTR,
        0, SIP_NULLPTR,
        {SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR}
    },
    assign_std_pair_0100QVariant_0100QVariant,
    array_std_pair_0100QVariant_0100QVariant,
    copy_std_pair_0100QVariant_0100QVariant,
    release_std_pair_0100QVariant_0100QVariant,
    convertTo_std_pair_0100QVariant_0100QVariant,
    convertFrom_std_pair_0100QVariant_0100QVariant
};
