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

// main header
#include "kcalendarcore_occurrenceiterator_wrapper.h"

// Argument includes
#include <calendar.h>
#include <qdatetime.h>

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

using namespace KCalendarCore;

extern "C" {
static PyTypeObject *Sbk_KCalendarCore_OccurrenceIterator_TypeF(void)
{
    return SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX].type;
}
} // extern "C"


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

extern "C" {
static int
Sbk_KCalendarCore_OccurrenceIterator_Init(PyObject *self, PyObject *args, [[maybe_unused]] PyObject *kwds)
{
    auto *sbkSelf = reinterpret_cast<SbkObject *>(self);
    PySide::Feature::Select(self);
    if (Shiboken::Object::isUserType(self) && !Shiboken::ObjectType::canCallConstructor(self->ob_type, Shiboken::SbkType< ::KCalendarCore::OccurrenceIterator >()))
        return -1;

    ::KCalendarCore::OccurrenceIterator *cptr{};
    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
    errInfo.reset(Shiboken::checkInvalidArgumentCount(numArgs, 1, 3));
    if (!errInfo.isNull())
        return Shiboken::returnWrongArguments_MinusOne(args, "__init__", errInfo, SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX]);

    if (PyArg_ParseTuple(args, "|OOO:OccurrenceIterator", &(pyArgs[0]), &(pyArgs[1]), &(pyArgs[2])) == 0)
        return -1;


    // Overloaded function decisor
    // 0: OccurrenceIterator::OccurrenceIterator(const KCalendarCore::Calendar&,const QDateTime&=,const QDateTime&=)
    if (numArgs >= 1
        && (pythonToCpp[0] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_Calendar_IDX]), (pyArgs[0])))) {
        if (numArgs == 1) {
            overloadId = 0; // OccurrenceIterator(KCalendarCore::Calendar,QDateTime,QDateTime)
        } else if (numArgs >= 2
            && (pythonToCpp[1] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkPySide6_QtCoreTypeStructs[SBK_QDateTime_IDX]), (pyArgs[1])))) {
            if (numArgs == 2) {
                overloadId = 0; // OccurrenceIterator(KCalendarCore::Calendar,QDateTime,QDateTime)
            } else if (numArgs >= 3
                && (pythonToCpp[2] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkPySide6_QtCoreTypeStructs[SBK_QDateTime_IDX]), (pyArgs[2])))) {
                overloadId = 0; // OccurrenceIterator::OccurrenceIterator(const KCalendarCore::Calendar&,const QDateTime&=,const QDateTime&=)
            }
        }
    }

    // Function signature not found.
    if (overloadId == -1)
        return Shiboken::returnWrongArguments_MinusOne(args, "__init__", SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX]);

    // Resolve keyword arguments
    {
        if (kwds != nullptr && PyDict_Size(kwds) > 0) {
            static const Shiboken::ArgumentNameIndexMapping mapping[2] = {{"start", 1}, {"end", 2}};
            if (!Shiboken::parseKeywordArguments(kwds, mapping, 2, errInfo, pyArgs)
                || (pyArgs[1] != nullptr && !((pythonToCpp[1] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkPySide6_QtCoreTypeStructs[SBK_QDateTime_IDX]), (pyArgs[1])))))
                || (pyArgs[2] != nullptr && !((pythonToCpp[2] = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkPySide6_QtCoreTypeStructs[SBK_QDateTime_IDX]), (pyArgs[2])))))) {
                Py_XINCREF(errInfo.object());
                return Shiboken::returnWrongArguments_MinusOne(args, "__init__", errInfo, SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX]);
            }
        }
    }

    // PyMI support
    Shiboken::callInheritedInit(self, args, errInfo.isNull() ? kwds : errInfo.object(), SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX]);
    if (Shiboken::Errors::occurred() != nullptr)
        return -1;

    // Call function/method
    {
        if (!Shiboken::Object::isValid(pyArgs[0]))
            return -1;
        ::KCalendarCore::Calendar *cppArg0;
        pythonToCpp[0](pyArgs[0], &cppArg0);
        if (!Shiboken::Object::isValid(pyArgs[1]))
            return -1;
        ::QDateTime cppArg1_local = QDateTime();
        ::QDateTime *cppArg1 = &cppArg1_local;
        if (pythonToCpp[1]) {
            if (pythonToCpp[1].isValue())
                pythonToCpp[1](pyArgs[1], &cppArg1_local);
            else
                pythonToCpp[1](pyArgs[1], &cppArg1);
            }
        if (!Shiboken::Object::isValid(pyArgs[2]))
            return -1;
        ::QDateTime cppArg2_local = QDateTime();
        ::QDateTime *cppArg2 = &cppArg2_local;
        if (pythonToCpp[2]) {
            if (pythonToCpp[2].isValue())
                pythonToCpp[2](pyArgs[2], &cppArg2_local);
            else
                pythonToCpp[2](pyArgs[2], &cppArg2);
            }

        if (Shiboken::Errors::occurred() == nullptr) {
            // OccurrenceIterator::OccurrenceIterator(const KCalendarCore::Calendar&,const QDateTime&=,const QDateTime&=)
            cptr = new ::KCalendarCore::OccurrenceIterator(*cppArg0, *cppArg1, *cppArg2);
        }
    }

    if (Shiboken::Errors::occurred() != nullptr || !Shiboken::Object::setCppPointer(sbkSelf, Shiboken::SbkType< ::KCalendarCore::OccurrenceIterator >(), cptr)) {
        delete cptr;
        return -1;
    }
    if (cptr == nullptr)
        return Shiboken::returnWrongArguments_MinusOne(args, "__init__", SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX]);

    Shiboken::Object::setValidCpp(sbkSelf, true);
    Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);


    return 1;
}

static PyObject *Sbk_KCalendarCore_OccurrenceIteratorFunc_hasNext(PyObject *self)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    [[maybe_unused]] auto *cppSelf = reinterpret_cast< ::KCalendarCore::OccurrenceIterator *>(Shiboken::Conversions::cppPointer(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX]), reinterpret_cast<SbkObject *>(self)));
    PyObject *pyResult{};
    Shiboken::PythonContextMarker pcm;

    // Call function/method
    {

        // OccurrenceIterator::hasNext()const->bool
        bool cppResult = const_cast<const ::KCalendarCore::OccurrenceIterator *>(cppSelf)->hasNext();
        pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<bool>(), &cppResult);
    }

    return Sbk_ReturnFromPython_Result(pyResult);
}

static PyObject *Sbk_KCalendarCore_OccurrenceIteratorFunc_next(PyObject *self)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    [[maybe_unused]] auto *cppSelf = reinterpret_cast< ::KCalendarCore::OccurrenceIterator *>(Shiboken::Conversions::cppPointer(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX]), reinterpret_cast<SbkObject *>(self)));
    Shiboken::PythonContextMarker pcm;

    // Call function/method
    {

        // OccurrenceIterator::next()
        cppSelf->next();
    }

     return Sbk_ReturnFromPython_None();
}

static PyObject *Sbk_KCalendarCore_OccurrenceIteratorFunc_occurrenceEndDate(PyObject *self)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    [[maybe_unused]] auto *cppSelf = reinterpret_cast< ::KCalendarCore::OccurrenceIterator *>(Shiboken::Conversions::cppPointer(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX]), reinterpret_cast<SbkObject *>(self)));
    PyObject *pyResult{};
    Shiboken::PythonContextMarker pcm;

    // Call function/method
    {

        // OccurrenceIterator::occurrenceEndDate()const->QDateTime
        QDateTime cppResult = const_cast<const ::KCalendarCore::OccurrenceIterator *>(cppSelf)->occurrenceEndDate();
        pyResult = Shiboken::Conversions::copyToPython(Shiboken::Module::get(SbkPySide6_QtCoreTypeStructs[SBK_QDateTime_IDX]), &cppResult);
    }

    return Sbk_ReturnFromPython_Result(pyResult);
}

static PyObject *Sbk_KCalendarCore_OccurrenceIteratorFunc_occurrenceStartDate(PyObject *self)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    [[maybe_unused]] auto *cppSelf = reinterpret_cast< ::KCalendarCore::OccurrenceIterator *>(Shiboken::Conversions::cppPointer(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX]), reinterpret_cast<SbkObject *>(self)));
    PyObject *pyResult{};
    Shiboken::PythonContextMarker pcm;

    // Call function/method
    {

        // OccurrenceIterator::occurrenceStartDate()const->QDateTime
        QDateTime cppResult = const_cast<const ::KCalendarCore::OccurrenceIterator *>(cppSelf)->occurrenceStartDate();
        pyResult = Shiboken::Conversions::copyToPython(Shiboken::Module::get(SbkPySide6_QtCoreTypeStructs[SBK_QDateTime_IDX]), &cppResult);
    }

    return Sbk_ReturnFromPython_Result(pyResult);
}

static PyObject *Sbk_KCalendarCore_OccurrenceIteratorFunc_recurrenceId(PyObject *self)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    [[maybe_unused]] auto *cppSelf = reinterpret_cast< ::KCalendarCore::OccurrenceIterator *>(Shiboken::Conversions::cppPointer(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX]), reinterpret_cast<SbkObject *>(self)));
    PyObject *pyResult{};
    Shiboken::PythonContextMarker pcm;

    // Call function/method
    {

        // OccurrenceIterator::recurrenceId()const->QDateTime
        QDateTime cppResult = const_cast<const ::KCalendarCore::OccurrenceIterator *>(cppSelf)->recurrenceId();
        pyResult = Shiboken::Conversions::copyToPython(Shiboken::Module::get(SbkPySide6_QtCoreTypeStructs[SBK_QDateTime_IDX]), &cppResult);
    }

    return Sbk_ReturnFromPython_Result(pyResult);
}


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

static PyMethodDef Sbk_KCalendarCore_OccurrenceIterator_methods[] = {
    {"hasNext", reinterpret_cast<PyCFunction>(Sbk_KCalendarCore_OccurrenceIteratorFunc_hasNext), METH_NOARGS, nullptr},
    {"next", reinterpret_cast<PyCFunction>(Sbk_KCalendarCore_OccurrenceIteratorFunc_next), METH_NOARGS, nullptr},
    {"occurrenceEndDate", reinterpret_cast<PyCFunction>(Sbk_KCalendarCore_OccurrenceIteratorFunc_occurrenceEndDate), METH_NOARGS, nullptr},
    {"occurrenceStartDate", reinterpret_cast<PyCFunction>(Sbk_KCalendarCore_OccurrenceIteratorFunc_occurrenceStartDate), METH_NOARGS, nullptr},
    {"recurrenceId", reinterpret_cast<PyCFunction>(Sbk_KCalendarCore_OccurrenceIteratorFunc_recurrenceId), METH_NOARGS, nullptr},
    {nullptr, nullptr, 0, nullptr} // Sentinel
};

} // extern "C"

static int Sbk_KCalendarCore_OccurrenceIterator_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_KCalendarCore_OccurrenceIterator_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_KCalendarCore_OccurrenceIterator_slots[] = {
    {Py_tp_base,        nullptr}, // inserted by introduceWrapperType
    {Py_tp_dealloc,     reinterpret_cast<void *>(&SbkDeallocWrapper)},
    {Py_tp_traverse,    reinterpret_cast<void *>(Sbk_KCalendarCore_OccurrenceIterator_traverse)},
    {Py_tp_clear,       reinterpret_cast<void *>(Sbk_KCalendarCore_OccurrenceIterator_clear)},
    {Py_tp_methods,     reinterpret_cast<void *>(Sbk_KCalendarCore_OccurrenceIterator_methods)},
    {Py_tp_init,        reinterpret_cast<void *>(Sbk_KCalendarCore_OccurrenceIterator_Init)},
    {Py_tp_new,         reinterpret_cast<void *>(SbkObject_tp_new)},
    {0, nullptr}
};
static PyType_Spec Sbk_KCalendarCore_OccurrenceIterator_spec = {
    "1:KCalendarCore.KCalendarCore.OccurrenceIterator",
    sizeof(SbkObject),
    0,
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
    Sbk_KCalendarCore_OccurrenceIterator_slots
};

} //extern "C"

// Type conversion functions.

// Python to C++ pointer conversion - returns the C++ object of the Python wrapper (keeps object identity).
static void OccurrenceIterator_PythonToCpp_OccurrenceIterator_PTR(PyObject *pyIn, void *cppOut)
{
    Shiboken::Conversions::pythonToCppPointer(Sbk_KCalendarCore_OccurrenceIterator_TypeF(), pyIn, cppOut);
}
static PythonToCppFunc is_OccurrenceIterator_PythonToCpp_OccurrenceIterator_PTR_Convertible(PyObject *pyIn)
{
    if (pyIn == Py_None)
        return Shiboken::Conversions::nonePythonToCppNullPtr;
    if (PyObject_TypeCheck(pyIn, Sbk_KCalendarCore_OccurrenceIterator_TypeF()))
        return OccurrenceIterator_PythonToCpp_OccurrenceIterator_PTR;
    return {};
}

// C++ to Python pointer conversion - tries to find the Python wrapper for the C++ object (keeps object identity).
static PyObject *OccurrenceIterator_PTR_CppToPython_OccurrenceIterator(const void *cppIn)
{
    auto *pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper(cppIn, Sbk_KCalendarCore_OccurrenceIterator_TypeF()));
    if (pyOut) {
        Py_INCREF(pyOut);
        return pyOut;
    }
    return Shiboken::Object::newObjectWithHeuristics(Sbk_KCalendarCore_OccurrenceIterator_TypeF(), const_cast<void *>(cppIn), false);

}

// The signatures string for the functions.
// Multiple signatures have their index "n:" in front.
#if PYSIDE6_COMOPT_COMPRESS == 0
static const char *KCalendarCore_OccurrenceIterator_SignatureStrings[] = {
    "KCalendarCore.KCalendarCore.OccurrenceIterator(self,calendar:KCalendarCore.KCalendarCore.Calendar,start:PySide6.QtCore.QDateTime=QDateTime(),end:PySide6.QtCore.QDateTime=QDateTime())",
    "KCalendarCore.KCalendarCore.OccurrenceIterator.hasNext(self)->bool",
    "KCalendarCore.KCalendarCore.OccurrenceIterator.next(self)",
    "KCalendarCore.KCalendarCore.OccurrenceIterator.occurrenceEndDate(self)->PySide6.QtCore.QDateTime",
    "KCalendarCore.KCalendarCore.OccurrenceIterator.occurrenceStartDate(self)->PySide6.QtCore.QDateTime",
    "KCalendarCore.KCalendarCore.OccurrenceIterator.recurrenceId(self)->PySide6.QtCore.QDateTime",
    nullptr}; // Sentinel
#else
static constexpr size_t KCalendarCore_OccurrenceIterator_SignatureByteSize = 155;
static constexpr uint8_t KCalendarCore_OccurrenceIterator_SignatureBytes[155] = {
    0x78, 0xda, 0xf3, 0x76, 0x4e, 0xcc, 0x49, 0xcd, 0x4b, 0x49, 0x2c, 0x72, 0xce, 0x2f, 0x4a, 0xd5,
    0xf3, 0x46, 0xe1, 0xf9, 0x27, 0x27, 0x97, 0x16, 0x15, 0xa5, 0xe6, 0x25, 0xa7, 0x7a, 0x96, 0xa4,
    0x16, 0x25, 0x96, 0xe4, 0x17, 0x69, 0x14, 0xa7, 0xe6, 0xa4, 0xe9, 0x24, 0x43, 0x15, 0x59, 0x79,
    0xe3, 0xd1, 0x0c, 0xe3, 0xe8, 0x14, 0x97, 0x24, 0x16, 0x95, 0x58, 0x05, 0x54, 0x06, 0x67, 0xa6,
    0xa4, 0x9a, 0xe9, 0x05, 0x96, 0x80, 0x65, 0x03, 0x5d, 0x12, 0x4b, 0x52, 0x43, 0x32, 0x73, 0x53,
    0x6d, 0xe1, 0x2c, 0x0d, 0x4d, 0x1d, 0xa0, 0x06, 0xa2, 0x14, 0x6a, 0x72, 0x79, 0x93, 0xe4, 0x6c,
    0xbd, 0x8c, 0xc4, 0x62, 0xbf, 0xd4, 0x8a, 0x12, 0xb0, 0xf3, 0x35, 0x75, 0xed, 0x92, 0xf2, 0xf3,
    0x73, 0x48, 0x35, 0x22, 0x0f, 0xae, 0x9f, 0x54, 0x9d, 0xf9, 0x70, 0x21, 0xd7, 0xbc, 0x14, 0x90,
    0x27, 0x60, 0xce, 0xc0, 0xe5, 0x55, 0xf2, 0x2d, 0x08, 0x06, 0x85, 0x35, 0x2d, 0xac, 0x28, 0x4a,
    0x85, 0x0b, 0xa5, 0x10, 0x34, 0x1b, 0x00, 0x82, 0x5d, 0xd9, 0x3e
};
#endif

PyTypeObject *init_KCalendarCore_OccurrenceIterator(PyObject *enclosingClass)
{
    auto &typeStruct = SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_OccurrenceIterator_IDX];
    if (typeStruct.type != nullptr)
        return typeStruct.type;

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

    PyTypeObject *pyType = Shiboken::ObjectType::introduceWrapperType(
        enclosingClass,
        "OccurrenceIterator",
        "KCalendarCore::OccurrenceIterator*",
        &Sbk_KCalendarCore_OccurrenceIterator_spec,
        &Shiboken::callCppDestructor< ::KCalendarCore::OccurrenceIterator >,
        Sbk_KCalendarCore_OccurrenceIterator_Type_bases.object(),
        Shiboken::ObjectType::WrapperFlags::InnerClass);
#if PYSIDE6_COMOPT_COMPRESS == 0
    InitSignatureStrings(pyType, KCalendarCore_OccurrenceIterator_SignatureStrings);
#else
    InitSignatureBytes(pyType, KCalendarCore_OccurrenceIterator_SignatureBytes, KCalendarCore_OccurrenceIterator_SignatureByteSize);
#endif
    SbkObjectType_SetPropertyStrings(pyType, Sbk_KCalendarCore_OccurrenceIterator_PropertyStrings);
    typeStruct.type = pyType;

    // Register Converter
    SbkConverter *converter = Shiboken::Conversions::createConverter(pyType,
        OccurrenceIterator_PythonToCpp_OccurrenceIterator_PTR,
        is_OccurrenceIterator_PythonToCpp_OccurrenceIterator_PTR_Convertible,
        OccurrenceIterator_PTR_CppToPython_OccurrenceIterator);

    Shiboken::Conversions::registerConverterName(converter, "KCalendarCore::OccurrenceIterator");
    Shiboken::Conversions::registerConverterName(converter, "KCalendarCore::OccurrenceIterator*");
    Shiboken::Conversions::registerConverterName(converter, "KCalendarCore::OccurrenceIterator&");
    Shiboken::Conversions::registerConverterAlias(converter, "OccurrenceIterator");
    Shiboken::Conversions::registerConverterAlias(converter, "OccurrenceIterator*");
    Shiboken::Conversions::registerConverterAlias(converter, "OccurrenceIterator&");
    Shiboken::Conversions::registerConverterName(converter, typeid(::KCalendarCore::OccurrenceIterator).name());

    qRegisterMetaType< ::KCalendarCore::OccurrenceIterator *>();

    return pyType;
}
