
// 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 "akonadicore_python.h"

// main header
#include "akonadi_wrapper.h"

// inner classes
#include "akonadi_trashsettings_wrapper.h"
#include "akonadi_tagfetchscope_wrapper.h"
#include "akonadi_tagcache_wrapper.h"
#include "akonadi_session_wrapper.h"
#include "akonadi_servermanager_wrapper.h"
#include "akonadi_searchquery_wrapper.h"
#include "akonadi_searchterm_wrapper.h"
#include "akonadi_partfetcher_wrapper.h"
#include "akonadi_notificationsubscriber_wrapper.h"
#include "akonadi_mimetypechecker_wrapper.h"
#include "akonadi_itemmonitor_wrapper.h"
#include "akonadi_itemfetchscope_wrapper.h"
#include "akonadi_gidextractorinterface_wrapper.h"
#include "akonadi_differencesalgorithminterface_wrapper.h"
#include "akonadi_control_wrapper.h"
#include "akonadi_collectionutils_wrapper.h"
#include "akonadi_collectionstatistics_wrapper.h"
#include "akonadi_monitor_wrapper.h"
#include "akonadi_changerecorder_wrapper.h"
#include "akonadi_changenotification_wrapper.h"
#include "akonadi_cachepolicy_wrapper.h"
#include "akonadi_attributefactory_wrapper.h"
#include "akonadi_agentmanager_wrapper.h"
#include "akonadi_agentinstance_wrapper.h"
#include "akonadi_agentconfigurationbase_wrapper.h"
#include "akonadi_accountactivitiesabstract_wrapper.h"
#include "akonadi_abstractdifferencesreporter_wrapper.h"
#include "akonadi_trashfilterproxymodel_wrapper.h"
#include "akonadi_tagmodel_wrapper.h"
#include "akonadi_statisticsproxymodel_wrapper.h"
#include "akonadi_selectionproxymodel_wrapper.h"
#include "akonadi_recursivecollectionfilterproxymodel_wrapper.h"
#include "akonadi_favoritecollectionsmodel_wrapper.h"
#include "akonadi_entityrightsfiltermodel_wrapper.h"
#include "akonadi_entityorderproxymodel_wrapper.h"
#include "akonadi_entitymimetypefiltermodel_wrapper.h"
#include "akonadi_agenttypemodel_wrapper.h"
#include "akonadi_agentinstancemodel_wrapper.h"
#include "akonadi_agentinstancefilterproxymodel_wrapper.h"
#include "akonadi_agentfilterproxymodel_wrapper.h"
#include "akonadi_specialcollectionsdiscoveryjob_wrapper.h"
#include "akonadi_specialcollections_wrapper.h"
#include "akonadi_resourcesynchronizationjob_wrapper.h"
#include "akonadi_recursiveitemfetchjob_wrapper.h"
#include "akonadi_collectionattributessynchronizationjob_wrapper.h"
#include "akonadi_agentinstancecreatejob_wrapper.h"
#include "akonadi_agenttype_wrapper.h"
#include "akonadi_entitytreemodel_wrapper.h"
#include "akonadi_item_wrapper.h"
#include "akonadi_tag_wrapper.h"
#include "akonadi_job_wrapper.h"
#include "akonadi_itemsync_wrapper.h"
#include "akonadi_collectionpathresolver_wrapper.h"
#include "akonadi_trashrestorejob_wrapper.h"
#include "akonadi_trashjob_wrapper.h"
#include "akonadi_transactionjob_wrapper.h"
#include "akonadi_tagmodifyjob_wrapper.h"
#include "akonadi_tagfetchjob_wrapper.h"
#include "akonadi_tagdeletejob_wrapper.h"
#include "akonadi_tagcreatejob_wrapper.h"
#include "akonadi_transactionsequence_wrapper.h"
#include "akonadi_specialcollectionsrequestjob_wrapper.h"
#include "akonadi_searchcreatejob_wrapper.h"
#include "akonadi_itemsearchjob_wrapper.h"
#include "akonadi_itemmovejob_wrapper.h"
#include "akonadi_itemmodifyjob_wrapper.h"
#include "akonadi_itemfetchjob_wrapper.h"
#include "akonadi_itemdeletejob_wrapper.h"
#include "akonadi_itemcreatejob_wrapper.h"
#include "akonadi_itemcopyjob_wrapper.h"
#include "akonadi_collectionstatisticsjob_wrapper.h"
#include "akonadi_collectionmovejob_wrapper.h"
#include "akonadi_collectionmodifyjob_wrapper.h"
#include "akonadi_collectionfetchjob_wrapper.h"
#include "akonadi_collectiondeletejob_wrapper.h"
#include "akonadi_collectioncreatejob_wrapper.h"
#include "akonadi_collectioncopyjob_wrapper.h"
#include "akonadi_exception_wrapper.h"
#include "akonadi_collectionfetchscope_wrapper.h"
#include "akonadi_collection_wrapper.h"
#include "akonadi_attribute_wrapper.h"
#include "akonadi_tagattribute_wrapper.h"
#include "akonadi_specialcollectionattribute_wrapper.h"
#include "akonadi_persistentsearchattribute_wrapper.h"
#include "akonadi_indexpolicyattribute_wrapper.h"
#include "akonadi_favoritecollectionattribute_wrapper.h"
#include "akonadi_entityhiddenattribute_wrapper.h"
#include "akonadi_entitydisplayattribute_wrapper.h"
#include "akonadi_entitydeletedattribute_wrapper.h"
#include "akonadi_entityannotationsattribute_wrapper.h"
#include "akonadi_collectionquotaattribute_wrapper.h"
#include "akonadi_collectionidentificationattribute_wrapper.h"
#include "akonadi_collectioncolorattribute_wrapper.h"
#include "akonadi_collectionannotationsattribute_wrapper.h"
#include "akonadi_collectionfilterproxymodel_wrapper.h"

// Argument includes
#include <agenttype.h>
#include <collection.h>
#include <item.h>
#include <tag.h>

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


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

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

static PyObject *Sbk_AkonadiFunc_qHash([[maybe_unused]] PyObject *self, PyObject *args, [[maybe_unused]] PyObject *kwds)
{
    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
    errInfo.reset(Shiboken::checkInvalidArgumentCount(numArgs, 1, 2));
    if (!errInfo.isNull())
        return Shiboken::returnWrongArguments(args, "qHash", errInfo, SbkAkonadiCoreTypeStructs[SBK_AkonadiCoreAkonadi_IDX]);

    if (PyArg_ParseTuple(args, "|OO:qHash", &(pyArgs[0]), &(pyArgs[1])) == 0)
        return {};


    // Overloaded function decisor
    // 0: static Akonadi::qHash(const Akonadi::AgentType&,size_t=)->size_t
    // 1: static Akonadi::qHash(const Akonadi::Collection&,size_t=)->size_t
    // 2: static Akonadi::qHash(const Akonadi::Item&,size_t=)->size_t
    // 3: static Akonadi::qHash(const Akonadi::Tag&,size_t=)->size_t
    if (numArgs >= 1
        && (pythonToCpp[0] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkAkonadiCoreTypeStructs[SBK_Akonadi_Tag_IDX]), (pyArgs[0])))) {
        if (numArgs == 1) {
            overloadId = 3; // qHash(Akonadi::Tag,size_t)
        } else if (numArgs >= 2
            && (pythonToCpp[1] = Shiboken::Conversions::pythonToCppConversion(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), (pyArgs[1])))) {
            overloadId = 3; // static Akonadi::qHash(const Akonadi::Tag&,size_t=)->size_t
        }
    } else if (numArgs >= 1
        && (pythonToCpp[0] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkAkonadiCoreTypeStructs[SBK_Akonadi_Item_IDX]), (pyArgs[0])))) {
        if (numArgs == 1) {
            overloadId = 2; // qHash(Akonadi::Item,size_t)
        } else if (numArgs >= 2
            && (pythonToCpp[1] = Shiboken::Conversions::pythonToCppConversion(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), (pyArgs[1])))) {
            overloadId = 2; // static Akonadi::qHash(const Akonadi::Item&,size_t=)->size_t
        }
    } else if (numArgs >= 1
        && (pythonToCpp[0] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkAkonadiCoreTypeStructs[SBK_Akonadi_Collection_IDX]), (pyArgs[0])))) {
        if (numArgs == 1) {
            overloadId = 1; // qHash(Akonadi::Collection,size_t)
        } else if (numArgs >= 2
            && (pythonToCpp[1] = Shiboken::Conversions::pythonToCppConversion(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), (pyArgs[1])))) {
            overloadId = 1; // static Akonadi::qHash(const Akonadi::Collection&,size_t=)->size_t
        }
    } else if (numArgs >= 1
        && (pythonToCpp[0] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkAkonadiCoreTypeStructs[SBK_Akonadi_AgentType_IDX]), (pyArgs[0])))) {
        if (numArgs == 1) {
            overloadId = 0; // qHash(Akonadi::AgentType,size_t)
        } else if (numArgs >= 2
            && (pythonToCpp[1] = Shiboken::Conversions::pythonToCppConversion(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), (pyArgs[1])))) {
            overloadId = 0; // static Akonadi::qHash(const Akonadi::AgentType&,size_t=)->size_t
        }
    }

    // Function signature not found.
    if (overloadId == -1)
        return Shiboken::returnWrongArguments(args, "qHash", SbkAkonadiCoreTypeStructs[SBK_AkonadiCoreAkonadi_IDX]);

    // Call function/method
    switch (overloadId) {
        case 0: // qHash(const Akonadi::AgentType &type, size_t seed)
        {
            if (kwds != nullptr && PyDict_Size(kwds) > 0) {
                static const Shiboken::ArgumentNameIndexMapping mapping[1] = {{"seed", 1}};
                if (!Shiboken::parseKeywordArguments(kwds, mapping, 1, errInfo, pyArgs)
                    || (pyArgs[1] != nullptr && !((pythonToCpp[1] = Shiboken::Conversions::pythonToCppConversion(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), (pyArgs[1])))))) {
                    Py_XINCREF(errInfo.object());
                    return Shiboken::returnWrongArguments(args, "qHash", errInfo, SbkAkonadiCoreTypeStructs[SBK_AkonadiCoreAkonadi_IDX]);
                }
            }
            if (!Shiboken::Object::isValid(pyArgs[0]))
                return {};
            ::Akonadi::AgentType cppArg0_local;
            ::Akonadi::AgentType *cppArg0 = &cppArg0_local;
            if (pythonToCpp[0].isValue())
                pythonToCpp[0](pyArgs[0], &cppArg0_local);
            else
                pythonToCpp[0](pyArgs[0], &cppArg0);

            size_t cppArg1 = 0;
            if (pythonToCpp[1])
                pythonToCpp[1](pyArgs[1], &cppArg1);

            if (Shiboken::Errors::occurred() == nullptr) {
                // static Akonadi::qHash(const Akonadi::AgentType&,size_t=)->size_t
                size_t cppResult = ::Akonadi::qHash(*cppArg0, cppArg1);
                pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), &cppResult);
            }
            break;
        }
        case 1: // qHash(const Akonadi::Collection &collection, size_t seed)
        {
            if (kwds != nullptr && PyDict_Size(kwds) > 0) {
                static const Shiboken::ArgumentNameIndexMapping mapping[1] = {{"seed", 1}};
                if (!Shiboken::parseKeywordArguments(kwds, mapping, 1, errInfo, pyArgs)
                    || (pyArgs[1] != nullptr && !((pythonToCpp[1] = Shiboken::Conversions::pythonToCppConversion(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), (pyArgs[1])))))) {
                    Py_XINCREF(errInfo.object());
                    return Shiboken::returnWrongArguments(args, "qHash", errInfo, SbkAkonadiCoreTypeStructs[SBK_AkonadiCoreAkonadi_IDX]);
                }
            }
            if (!Shiboken::Object::isValid(pyArgs[0]))
                return {};
            ::Akonadi::Collection cppArg0_local;
            ::Akonadi::Collection *cppArg0 = &cppArg0_local;
            if (pythonToCpp[0].isValue())
                pythonToCpp[0](pyArgs[0], &cppArg0_local);
            else
                pythonToCpp[0](pyArgs[0], &cppArg0);

            size_t cppArg1 = 0;
            if (pythonToCpp[1])
                pythonToCpp[1](pyArgs[1], &cppArg1);

            if (Shiboken::Errors::occurred() == nullptr) {
                // static Akonadi::qHash(const Akonadi::Collection&,size_t=)->size_t
                size_t cppResult = ::Akonadi::qHash(*cppArg0, cppArg1);
                pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), &cppResult);
            }
            break;
        }
        case 2: // qHash(const Akonadi::Item &item, size_t seed)
        {
            if (kwds != nullptr && PyDict_Size(kwds) > 0) {
                static const Shiboken::ArgumentNameIndexMapping mapping[1] = {{"seed", 1}};
                if (!Shiboken::parseKeywordArguments(kwds, mapping, 1, errInfo, pyArgs)
                    || (pyArgs[1] != nullptr && !((pythonToCpp[1] = Shiboken::Conversions::pythonToCppConversion(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), (pyArgs[1])))))) {
                    Py_XINCREF(errInfo.object());
                    return Shiboken::returnWrongArguments(args, "qHash", errInfo, SbkAkonadiCoreTypeStructs[SBK_AkonadiCoreAkonadi_IDX]);
                }
            }
            if (!Shiboken::Object::isValid(pyArgs[0]))
                return {};
            ::Akonadi::Item cppArg0_local;
            ::Akonadi::Item *cppArg0 = &cppArg0_local;
            if (pythonToCpp[0].isValue())
                pythonToCpp[0](pyArgs[0], &cppArg0_local);
            else
                pythonToCpp[0](pyArgs[0], &cppArg0);

            size_t cppArg1 = 0;
            if (pythonToCpp[1])
                pythonToCpp[1](pyArgs[1], &cppArg1);

            if (Shiboken::Errors::occurred() == nullptr) {
                // static Akonadi::qHash(const Akonadi::Item&,size_t=)->size_t
                size_t cppResult = ::Akonadi::qHash(*cppArg0, cppArg1);
                pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), &cppResult);
            }
            break;
        }
        case 3: // qHash(const Akonadi::Tag &arg__1, size_t sed)
        {
            if (kwds != nullptr && PyDict_Size(kwds) > 0) {
                static const Shiboken::ArgumentNameIndexMapping mapping[1] = {{"sed", 1}};
                if (!Shiboken::parseKeywordArguments(kwds, mapping, 1, errInfo, pyArgs)
                    || (pyArgs[1] != nullptr && !((pythonToCpp[1] = Shiboken::Conversions::pythonToCppConversion(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), (pyArgs[1])))))) {
                    Py_XINCREF(errInfo.object());
                    return Shiboken::returnWrongArguments(args, "qHash", errInfo, SbkAkonadiCoreTypeStructs[SBK_AkonadiCoreAkonadi_IDX]);
                }
            }
            if (!Shiboken::Object::isValid(pyArgs[0]))
                return {};
            ::Akonadi::Tag cppArg0_local;
            ::Akonadi::Tag *cppArg0 = &cppArg0_local;
            if (pythonToCpp[0].isValue())
                pythonToCpp[0](pyArgs[0], &cppArg0_local);
            else
                pythonToCpp[0](pyArgs[0], &cppArg0);

            size_t cppArg1 = 0;
            if (pythonToCpp[1])
                pythonToCpp[1](pyArgs[1], &cppArg1);

            if (Shiboken::Errors::occurred() == nullptr) {
                // static Akonadi::qHash(const Akonadi::Tag&,size_t=)->size_t
                size_t cppResult = ::Akonadi::qHash(*cppArg0, cppArg1);
                pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<size_t>(), &cppResult);
            }
            break;
        }
    }

    return Sbk_ReturnFromPython_Result(pyResult);
}


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

static PyMethodDef Sbk_Akonadi_methods[] = {
    {"qHash", reinterpret_cast<PyCFunction>(Sbk_AkonadiFunc_qHash), METH_VARARGS|METH_KEYWORDS|METH_STATIC, nullptr},
    {nullptr, nullptr, 0, nullptr} // Sentinel
};

} // extern "C"

static int Sbk_Akonadi_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_Akonadi_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_Akonadi_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_Akonadi_traverse)},
    {Py_tp_clear,       reinterpret_cast<void *>(Sbk_Akonadi_clear)},
    {Py_tp_methods,     reinterpret_cast<void *>(Sbk_Akonadi_methods)},
    {Py_tp_init,        reinterpret_cast<void *>(Sbk_Akonadi_Init)},
    {Py_tp_new,         reinterpret_cast<void *>(SbkDummyNew /* PYSIDE-595: Prevent replacement of "0" with base->tp_new. */)},
    {0, nullptr}
};
static PyType_Spec Sbk_Akonadi_spec = {
    "1:AkonadiCore.Akonadi",
    sizeof(SbkObject),
    0,
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
    Sbk_Akonadi_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 *AkonadiCoreAkonadi_SignatureStrings[] = {
    "3:AkonadiCore.Akonadi.qHash(type:AkonadiCore.Akonadi.AgentType,seed:size_t=0)->size_t",
    "2:AkonadiCore.Akonadi.qHash(collection:AkonadiCore.Akonadi.Collection,seed:size_t=0)->size_t",
    "1:AkonadiCore.Akonadi.qHash(item:AkonadiCore.Akonadi.Item,seed:size_t=0)->size_t",
    "0:AkonadiCore.Akonadi.qHash(arg__1:AkonadiCore.Akonadi.Tag,sed:size_t=0)->size_t",
    nullptr}; // Sentinel
#else
static constexpr size_t AkonadiCoreAkonadi_SignatureByteSize = 118;
static constexpr uint8_t AkonadiCoreAkonadi_SignatureBytes[118] = {
    0x78, 0xda, 0x33, 0xb6, 0x72, 0xcc, 0xce, 0xcf, 0x4b, 0x4c, 0xc9, 0x74, 0xce, 0x2f, 0x4a, 0xd5,
    0x83, 0xb2, 0xf5, 0x0a, 0x3d, 0x12, 0x8b, 0x33, 0x34, 0x4a, 0x2a, 0x0b, 0x52, 0xb1, 0x4a, 0x3b,
    0xa6, 0xa7, 0xe6, 0x95, 0x84, 0x00, 0x65, 0x75, 0x8a, 0x53, 0x53, 0x53, 0xac, 0x8a, 0x33, 0xab,
    0x52, 0xe3, 0x4b, 0x6c, 0x0d, 0x34, 0x75, 0xed, 0x20, 0x4c, 0x2e, 0x23, 0x3c, 0xa6, 0x26, 0xe7,
    0xe7, 0xe4, 0xa4, 0x26, 0x97, 0x64, 0xe6, 0xe7, 0x61, 0x55, 0xe4, 0x0c, 0x97, 0xc6, 0x65, 0xb8,
    0x21, 0x1e, 0xc3, 0x33, 0x4b, 0x52, 0x73, 0xb1, 0x4a, 0x7b, 0x02, 0x25, 0x70, 0x19, 0x68, 0x80,
    0xc7, 0xc0, 0xc4, 0xa2, 0xf4, 0xf8, 0x78, 0xec, 0x36, 0x86, 0x24, 0xa6, 0x03, 0x4d, 0xc4, 0x66,
    0x20, 0x00, 0x1c, 0x3c, 0x7a, 0x04
};
#endif

PyTypeObject *init_AkonadiCoreAkonadi(PyObject *module)
{
    auto &typeStruct = SbkAkonadiCoreTypeStructs[SBK_AkonadiCoreAkonadi_IDX];
    if (typeStruct.type != nullptr)
        return typeStruct.type;

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

    PyTypeObject *pyType = Shiboken::ObjectType::introduceWrapperType(
        module,
        "Akonadi",
        "Akonadi",
        &Sbk_Akonadi_spec,
        nullptr,
        Sbk_Akonadi_Type_bases.object(),
        0);
#if PYSIDE6_COMOPT_COMPRESS == 0
    InitSignatureStrings(pyType, AkonadiCoreAkonadi_SignatureStrings);
#else
    InitSignatureBytes(pyType, AkonadiCoreAkonadi_SignatureBytes, AkonadiCoreAkonadi_SignatureByteSize);
#endif
    SbkObjectType_SetPropertyStrings(pyType, Sbk_Akonadi_PropertyStrings);
    typeStruct.type = pyType;



    return pyType;
}
