/*
 * Interface wrapper code.
 *
 * Generated by SIP 6.15.3
 *
 * 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 "sipAPIQtStateMachine.h"

#line 140 "/build/pyqt6/src/pyqt6-6.11.0/sip/QtCore/qpycore_qset.sip"
#include <qset.h>
#line 29 "/build/pyqt6/src/pyqt6-6.11.0/build/QtStateMachine/sipQtStateMachineQSet0101QAbstractState.cpp"

#line 26 "/build/pyqt6/src/pyqt6-6.11.0/sip/QtStateMachine/qabstractstate.sip"
#include <qabstractstate.h>
#line 33 "/build/pyqt6/src/pyqt6-6.11.0/build/QtStateMachine/sipQtStateMachineQSet0101QAbstractState.cpp"


extern "C" {static void assign_QSet_0101QAbstractState(void *, Py_ssize_t, void *);}
static void assign_QSet_0101QAbstractState(void *sipDst, Py_ssize_t sipDstIdx, void *sipSrc)
{
    reinterpret_cast<QSet< ::QAbstractState*> *>(sipDst)[sipDstIdx] = *reinterpret_cast<QSet< ::QAbstractState*> *>(sipSrc);
}


extern "C" {static void *array_QSet_0101QAbstractState(Py_ssize_t);}
static void *array_QSet_0101QAbstractState(Py_ssize_t sipNrElem)
{
    return new QSet< ::QAbstractState*>[sipNrElem];
}


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


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



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

#line 178 "/build/pyqt6/src/pyqt6-6.11.0/sip/QtCore/qpycore_qset.sip"
    PyObject *iter = PyObject_GetIter(sipPy);

    if (!sipIsErr)
    {
        PyErr_Clear();
        Py_XDECREF(iter);

        return (iter && !PyUnicode_Check(sipPy));
    }

    if (!iter)
    {
        *sipIsErr = 1;

        return 0;
    }

    QSet<QAbstractState *> *qs = new QSet<QAbstractState *>;
 
    for (Py_ssize_t i = 0; ; ++i)
    {
        PyErr_Clear();
        PyObject *itm = PyIter_Next(iter);

        if (!itm)
        {
            if (PyErr_Occurred())
            {
                delete qs;
                Py_DECREF(iter);
                *sipIsErr = 1;

                return 0;
            }

            break;
        }

        QAbstractState *t = reinterpret_cast<QAbstractState *>(
                sipForceConvertToType(itm, sipType_QAbstractState, sipTransferObj, 0,
                        0, sipIsErr));

        if (*sipIsErr)
        {
            PyErr_Format(PyExc_TypeError,
                    "index %zd has type '%s' but 'QAbstractState' is expected", i,
                    sipPyTypeName(Py_TYPE(itm)));

            Py_DECREF(itm);
            delete qs;
            Py_DECREF(iter);

            return 0;
        }

        qs->insert(t);

        Py_DECREF(itm);
    }
 
    Py_DECREF(iter);

    *sipCppPtr = qs;
 
    return sipGetState(sipTransferObj);
#line 138 "/build/pyqt6/src/pyqt6-6.11.0/build/QtStateMachine/sipQtStateMachineQSet0101QAbstractState.cpp"
}


extern "C" {static PyObject *convertFrom_QSet_0101QAbstractState(void *, PyObject *);}
static PyObject *convertFrom_QSet_0101QAbstractState(void *sipCppV, PyObject *sipTransferObj)
{
    QSet< ::QAbstractState*> *sipCpp = reinterpret_cast<QSet< ::QAbstractState*> *>(sipCppV);

#line 144 "/build/pyqt6/src/pyqt6-6.11.0/sip/QtCore/qpycore_qset.sip"
    int gc_enabled = sipEnableGC(0);
    PyObject *s = PySet_New(0);

    if (s)
    {
        QSet<QAbstractState *>::const_iterator it = sipCpp->constBegin();
        QSet<QAbstractState *>::const_iterator end = sipCpp->constEnd();

        while (it != end)
        {
            // The explicit (void *) cast allows QAbstractState to be const.
            PyObject *tobj = sipConvertFromType((void *)*it, sipType_QAbstractState,
                    sipTransferObj);

            if (!tobj)
            {
                Py_DECREF(s);
                s = 0;

                break;
            }

            PySet_Add(s, tobj);

            ++it;
        }
    }

    sipEnableGC(gc_enabled);

    return s;
#line 179 "/build/pyqt6/src/pyqt6-6.11.0/build/QtStateMachine/sipQtStateMachineQSet0101QAbstractState.cpp"
}


sipMappedTypeDef sipTypeDef_QtStateMachine_QSet_0101QAbstractState = {
    {
        SIP_NULLPTR,
        SIP_TYPE_MAPPED,
        sipNameNr_449,
        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_QSet_0101QAbstractState,
    array_QSet_0101QAbstractState,
    copy_QSet_0101QAbstractState,
    release_QSet_0101QAbstractState,
    convertTo_QSet_0101QAbstractState,
    convertFrom_QSet_0101QAbstractState
};
