
// Workaround to access protected functions
#ifndef protected
#  define protected public
#endif

// default includes
#include <shiboken.h>
#include <sbkpep.h>
#include <sbkpepbuffer.h>

#define PYSIDE6_COMOPT_COMPRESS 1

#ifndef QT_NO_VERSION_TAGGING
#  define QT_NO_VERSION_TAGGING
#endif
#include <QtCore/QDebug>
#include <pysideqenum.h>
#include <pysideutils.h>
#include <feature_select.h>
QT_WARNING_DISABLE_DEPRECATED


// module include
#include "kguiaddons_python.h"

// main header
#include "kiconutils_wrapper.h"

// Argument includes
#include <QHash>
#include <QString>
#include <QStringList>
#include <qicon.h>
#include <qnamespace.h>

#include <cctype>
#include <cstring>
#include <iterator>
#include <type_traits>
#include <typeinfo>


// Target ---------------------------------------------------------

extern "C" {
static int Sbk_KIconUtils_Init(PyObject *, PyObject *, PyObject *)
{
    Shiboken::Errors::setInstantiateNamespace("KIconUtils");
    return -1;
}

static PyObject *Sbk_KIconUtilsFunc_addOverlay([[maybe_unused]] PyObject *self, PyObject *args)
{
    PyObject *pyResult{};
    Shiboken::AutoDecRef errInfo{};
    Shiboken::PythonContextMarker pcm;
    int overloadId = -1;
    [[maybe_unused]] Shiboken::Conversions::PythonToCppConversion pythonToCpp[3];
    const Py_ssize_t numArgs = PyTuple_Size(args);
    SBK_UNUSED(numArgs)
    PyObject *pyArgs[] = {nullptr, nullptr, nullptr};

    // invalid argument lengths

    if (PyArg_UnpackTuple(args, "addOverlay", 3, 3, &(pyArgs[0]), &(pyArgs[1]), &(pyArgs[2])) == 0)
        return {};


    // Overloaded function decisor
    // 0: static KIconUtils::addOverlay(const QIcon&,const QIcon&,Qt::Corner)->QIcon
    if (numArgs == 3
        && (pythonToCpp[0] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkPySide6_QtGuiTypeStructs[SBK_QIcon_IDX]), (pyArgs[0])))
        && (pythonToCpp[1] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkPySide6_QtGuiTypeStructs[SBK_QIcon_IDX]), (pyArgs[1])))
        && (pythonToCpp[2] = Shiboken::Conversions::pythonToCppConversion(Shiboken::Enum::getConverter(reinterpret_cast<SbkEnumType *>(Shiboken::Module::get(SbkPySide6_QtCoreTypeStructs[SBK_Qt_Corner_IDX]))), (pyArgs[2])))) {
        overloadId = 0; // static KIconUtils::addOverlay(const QIcon&,const QIcon&,Qt::Corner)->QIcon
    }

    // Function signature not found.
    if (overloadId == -1)
        return Shiboken::returnWrongArguments(args, "addOverlay", SbkKGuiAddonsTypeStructs[SBK_KGuiAddonsKIconUtils_IDX]);

    // Call function/method
    {
        if (!Shiboken::Object::isValid(pyArgs[0]))
            return {};
        ::QIcon cppArg0_local;
        ::QIcon *cppArg0 = &cppArg0_local;
        if (pythonToCpp[0].isValue())
            pythonToCpp[0](pyArgs[0], &cppArg0_local);
        else
            pythonToCpp[0](pyArgs[0], &cppArg0);

        if (!Shiboken::Object::isValid(pyArgs[1]))
            return {};
        ::QIcon cppArg1_local;
        ::QIcon *cppArg1 = &cppArg1_local;
        if (pythonToCpp[1].isValue())
            pythonToCpp[1](pyArgs[1], &cppArg1_local);
        else
            pythonToCpp[1](pyArgs[1], &cppArg1);

        ::Qt::Corner cppArg2{Qt::TopLeftCorner};
        pythonToCpp[2](pyArgs[2], &cppArg2);

        if (Shiboken::Errors::occurred() == nullptr) {
            // static KIconUtils::addOverlay(const QIcon&,const QIcon&,Qt::Corner)->QIcon
            QIcon cppResult = ::KIconUtils::addOverlay(*cppArg0, *cppArg1, cppArg2);
            pyResult = Shiboken::Conversions::copyToPython(Shiboken::Module::get(SbkPySide6_QtGuiTypeStructs[SBK_QIcon_IDX]), &cppResult);
        }
    }

    return Sbk_ReturnFromPython_Result(pyResult);
}

static PyObject *Sbk_KIconUtilsFunc_addOverlays([[maybe_unused]] PyObject *self, PyObject *args)
{
    PyObject *pyResult{};
    Shiboken::AutoDecRef errInfo{};
    Shiboken::PythonContextMarker pcm;
    int overloadId = -1;
    [[maybe_unused]] Shiboken::Conversions::PythonToCppConversion pythonToCpp[2];
    const Py_ssize_t numArgs = PyTuple_Size(args);
    SBK_UNUSED(numArgs)
    PyObject *pyArgs[] = {nullptr, nullptr};

    // invalid argument lengths

    if (PyArg_UnpackTuple(args, "addOverlays", 2, 2, &(pyArgs[0]), &(pyArgs[1])) == 0)
        return {};


    // Overloaded function decisor
    // 0: static KIconUtils::addOverlays(const QIcon&,const QHash<Qt::Corner,QIcon>&)->QIcon
    // 1: static KIconUtils::addOverlays(const QIcon&,const QStringList&)->QIcon
    // 2: static KIconUtils::addOverlays(const QString&,const QStringList&)->QIcon
    if (numArgs == 2
        && (pythonToCpp[0] = Shiboken::Conversions::pythonToCppConversion(SbkPySide6_QtCoreTypeConverters[SBK_QString_IDX], (pyArgs[0])))
        && (pythonToCpp[1] = Shiboken::Conversions::pythonToCppConversion(SbkPySide6_QtCoreTypeConverters[SBK_QStringList_IDX], (pyArgs[1])))) {
        overloadId = 2; // static KIconUtils::addOverlays(const QString&,const QStringList&)->QIcon
    } else if (numArgs >= 1
        && (pythonToCpp[0] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkPySide6_QtGuiTypeStructs[SBK_QIcon_IDX]), (pyArgs[0])))) {
        if (numArgs == 2
            && (pythonToCpp[1] = Shiboken::Conversions::pythonToCppConversion(SbkPySide6_QtCoreTypeConverters[SBK_QStringList_IDX], (pyArgs[1])))) {
            overloadId = 1; // static KIconUtils::addOverlays(const QIcon&,const QStringList&)->QIcon
        } else if (numArgs == 2
            && (pythonToCpp[1] = Shiboken::Conversions::pythonToCppConversion(SbkKGuiAddonsTypeConverters[SBK_KGuiAddons_QHash_Qt_Corner_QIcon_IDX], (pyArgs[1])))) {
            overloadId = 0; // static KIconUtils::addOverlays(const QIcon&,const QHash<Qt::Corner,QIcon>&)->QIcon
        }
    }

    // Function signature not found.
    if (overloadId == -1)
        return Shiboken::returnWrongArguments(args, "addOverlays", SbkKGuiAddonsTypeStructs[SBK_KGuiAddonsKIconUtils_IDX]);

    // Call function/method
    switch (overloadId) {
        case 0: // addOverlays(const QIcon &icon, const QHash<Qt::Corner,QIcon> &overlays)
        {
            if (!Shiboken::Object::isValid(pyArgs[0]))
                return {};
            ::QIcon cppArg0_local;
            ::QIcon *cppArg0 = &cppArg0_local;
            if (pythonToCpp[0].isValue())
                pythonToCpp[0](pyArgs[0], &cppArg0_local);
            else
                pythonToCpp[0](pyArgs[0], &cppArg0);

            ::QHash<Qt::Corner,QIcon> cppArg1;
            pythonToCpp[1](pyArgs[1], &cppArg1);

            if (Shiboken::Errors::occurred() == nullptr) {
                // static KIconUtils::addOverlays(const QIcon&,const QHash<Qt::Corner,QIcon>&)->QIcon
                QIcon cppResult = ::KIconUtils::addOverlays(*cppArg0, cppArg1);
                pyResult = Shiboken::Conversions::copyToPython(Shiboken::Module::get(SbkPySide6_QtGuiTypeStructs[SBK_QIcon_IDX]), &cppResult);
            }
            break;
        }
        case 1: // addOverlays(const QIcon &icon, const QStringList &overlays)
        {
            if (!Shiboken::Object::isValid(pyArgs[0]))
                return {};
            ::QIcon cppArg0_local;
            ::QIcon *cppArg0 = &cppArg0_local;
            if (pythonToCpp[0].isValue())
                pythonToCpp[0](pyArgs[0], &cppArg0_local);
            else
                pythonToCpp[0](pyArgs[0], &cppArg0);

            ::QStringList cppArg1;
            pythonToCpp[1](pyArgs[1], &cppArg1);

            if (Shiboken::Errors::occurred() == nullptr) {
                // static KIconUtils::addOverlays(const QIcon&,const QStringList&)->QIcon
                QIcon cppResult = ::KIconUtils::addOverlays(*cppArg0, cppArg1);
                pyResult = Shiboken::Conversions::copyToPython(Shiboken::Module::get(SbkPySide6_QtGuiTypeStructs[SBK_QIcon_IDX]), &cppResult);
            }
            break;
        }
        case 2: // addOverlays(const QString &iconName, const QStringList &overlays)
        {
            ::QString cppArg0;
            pythonToCpp[0](pyArgs[0], &cppArg0);
            ::QStringList cppArg1;
            pythonToCpp[1](pyArgs[1], &cppArg1);

            if (Shiboken::Errors::occurred() == nullptr) {
                // static KIconUtils::addOverlays(const QString&,const QStringList&)->QIcon
                QIcon cppResult = ::KIconUtils::addOverlays(cppArg0, cppArg1);
                pyResult = Shiboken::Conversions::copyToPython(Shiboken::Module::get(SbkPySide6_QtGuiTypeStructs[SBK_QIcon_IDX]), &cppResult);
            }
            break;
        }
    }

    return Sbk_ReturnFromPython_Result(pyResult);
}


static const char *Sbk_KIconUtils_PropertyStrings[] = {
    nullptr // Sentinel
};

static PyMethodDef Sbk_KIconUtils_methods[] = {
    {"addOverlay", reinterpret_cast<PyCFunction>(Sbk_KIconUtilsFunc_addOverlay), METH_VARARGS|METH_STATIC, nullptr},
    {"addOverlays", reinterpret_cast<PyCFunction>(Sbk_KIconUtilsFunc_addOverlays), METH_VARARGS|METH_STATIC, nullptr},
    {nullptr, nullptr, 0, nullptr} // Sentinel
};

} // extern "C"

static int Sbk_KIconUtils_traverse(PyObject *self, visitproc visit, void *arg)
{
    auto traverseProc = reinterpret_cast<traverseproc>(PyType_GetSlot(SbkObject_TypeF(), Py_tp_traverse));
    ;
    return traverseProc(self, visit, arg);
}
static int Sbk_KIconUtils_clear(PyObject *self)
{
    auto clearProc = reinterpret_cast<inquiry>(PyType_GetSlot(SbkObject_TypeF(), Py_tp_clear));
    ;
    return clearProc(self);
}

// Class Definition -----------------------------------------------
extern "C" {

static PyType_Slot Sbk_KIconUtils_slots[] = {
    {Py_tp_base,        nullptr}, // inserted by introduceWrapperType
    {Py_tp_dealloc,     reinterpret_cast<void *>(Sbk_object_dealloc /* PYSIDE-832: Prevent replacement of "0" with subtype_dealloc. */)},
    {Py_tp_traverse,    reinterpret_cast<void *>(Sbk_KIconUtils_traverse)},
    {Py_tp_clear,       reinterpret_cast<void *>(Sbk_KIconUtils_clear)},
    {Py_tp_methods,     reinterpret_cast<void *>(Sbk_KIconUtils_methods)},
    {Py_tp_init,        reinterpret_cast<void *>(Sbk_KIconUtils_Init)},
    {Py_tp_new,         reinterpret_cast<void *>(SbkDummyNew /* PYSIDE-595: Prevent replacement of "0" with base->tp_new. */)},
    {0, nullptr}
};
static PyType_Spec Sbk_KIconUtils_spec = {
    "1:KGuiAddons.KIconUtils",
    sizeof(SbkObject),
    0,
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
    Sbk_KIconUtils_slots
};

} //extern "C"

// Type conversion functions.

// The signatures string for the functions.
// Multiple signatures have their index "n:" in front.
#if PYSIDE6_COMOPT_COMPRESS == 0
static const char *KGuiAddonsKIconUtils_SignatureStrings[] = {
    "KGuiAddons.KIconUtils.addOverlay(icon:typing.Union[PySide6.QtGui.QIcon, PySide6.QtGui.QPixmap],overlay:typing.Union[PySide6.QtGui.QIcon, PySide6.QtGui.QPixmap],position:PySide6.QtCore.Qt.Corner)->PySide6.QtGui.QIcon",
    "2:KGuiAddons.KIconUtils.addOverlays(icon:typing.Union[PySide6.QtGui.QIcon, PySide6.QtGui.QPixmap],overlays:QHash[PySide6.QtCore.Qt.Corner, PySide6.QtGui.QIcon])->PySide6.QtGui.QIcon",
    "1:KGuiAddons.KIconUtils.addOverlays(icon:typing.Union[PySide6.QtGui.QIcon, PySide6.QtGui.QPixmap],overlays:QStringList)->PySide6.QtGui.QIcon",
    "0:KGuiAddons.KIconUtils.addOverlays(iconName:QString,overlays:QStringList)->PySide6.QtGui.QIcon",
    nullptr}; // Sentinel
#else
static constexpr size_t KGuiAddonsKIconUtils_SignatureByteSize = 174;
static constexpr uint8_t KGuiAddonsKIconUtils_SignatureBytes[174] = {
    0x78, 0xda, 0xf3, 0x76, 0x2f, 0xcd, 0x74, 0x4c, 0x49, 0xc9, 0xcf, 0x2b, 0xd6, 0xf3, 0xf6, 0x4c,
    0xce, 0xcf, 0x0b, 0x2d, 0xc9, 0xcc, 0x29, 0xd6, 0x4b, 0x4c, 0x49, 0xf1, 0x2f, 0x4b, 0x2d, 0xca,
    0x49, 0xac, 0xd4, 0xc8, 0x04, 0x0a, 0x5a, 0x95, 0x54, 0x16, 0x64, 0xe6, 0xa5, 0xeb, 0x85, 0xe6,
    0x65, 0xe6, 0xe7, 0x45, 0x07, 0x54, 0x06, 0x67, 0xa6, 0xa4, 0x9a, 0xe9, 0x05, 0x96, 0x00, 0xf5,
    0xea, 0x05, 0x82, 0x74, 0xe9, 0x28, 0xa0, 0x09, 0x06, 0x64, 0x56, 0xe4, 0x26, 0x16, 0xc4, 0xea,
    0xe4, 0x43, 0x4c, 0x21, 0xdf, 0x80, 0x82, 0xfc, 0xe2, 0xcc, 0x12, 0xa0, 0x26, 0x2b, 0x84, 0xbc,
    0x73, 0x7e, 0x51, 0x2a, 0x90, 0xd2, 0x03, 0xd2, 0x79, 0xa9, 0x45, 0x9a, 0xba, 0x76, 0x58, 0xcc,
    0xe3, 0x32, 0xb2, 0xf2, 0x26, 0xe0, 0xb3, 0x62, 0xea, 0x78, 0xad, 0xd8, 0x2a, 0xd0, 0x23, 0xb1,
    0x38, 0x23, 0x1a, 0x97, 0xfb, 0x30, 0xf4, 0x83, 0x0c, 0x8d, 0xc5, 0xe1, 0x6a, 0x43, 0x3a, 0xba,
    0x3a, 0xb8, 0xa4, 0x08, 0x68, 0x84, 0x4f, 0x66, 0x71, 0x09, 0x0e, 0xc7, 0x18, 0x10, 0xe9, 0x18,
    0xbf, 0xc4, 0xdc, 0x54, 0x98, 0x71, 0xa4, 0x98, 0x0f, 0x00, 0x54, 0xd9, 0xe2, 0xa9
};
#endif

PyTypeObject *init_KGuiAddonsKIconUtils(PyObject *module)
{
    auto &typeStruct = SbkKGuiAddonsTypeStructs[SBK_KGuiAddonsKIconUtils_IDX];
    if (typeStruct.type != nullptr)
        return typeStruct.type;

    auto *base1 = SbkObject_TypeF();
    Shiboken::AutoDecRef Sbk_KIconUtils_Type_bases(PyTuple_Pack(1, base1));

    PyTypeObject *pyType = Shiboken::ObjectType::introduceWrapperType(
        module,
        "KIconUtils",
        "KIconUtils",
        &Sbk_KIconUtils_spec,
        nullptr,
        Sbk_KIconUtils_Type_bases.object(),
        0);
#if PYSIDE6_COMOPT_COMPRESS == 0
    InitSignatureStrings(pyType, KGuiAddonsKIconUtils_SignatureStrings);
#else
    InitSignatureBytes(pyType, KGuiAddonsKIconUtils_SignatureBytes, KGuiAddonsKIconUtils_SignatureByteSize);
#endif
    SbkObjectType_SetPropertyStrings(pyType, Sbk_KIconUtils_PropertyStrings);
    typeStruct.type = pyType;



    return pyType;
}
