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

// Argument includes
#include <recurrence.h>

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

using namespace KCalendarCore;

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

// Native ---------------------------------------------------------

void RecurrenceObserverWrapper::resetPyMethodCache()
{
    std::fill(m_PyMethodCache.begin(), m_PyMethodCache.end(), nullptr);
}

RecurrenceObserverWrapper::RecurrenceObserverWrapper()
{
}

void RecurrenceObserverWrapper::recurrenceUpdated(::KCalendarCore::Recurrence * r)
{
    static const char *funcName = "recurrenceUpdated";
    static PyObject *nameCache[2] = {};
    Shiboken::GilState gil(false);
    Shiboken::AutoDecRef pyOverride(Sbk_GetPyOverride(this, Sbk_KCalendarCore_Recurrence_RecurrenceObserver_TypeF(), gil, funcName, m_PyMethodCache[0], nameCache));
    if (pyOverride.isNull()) {
        gil.acquire();
        Shiboken::Errors::setPureVirtualMethodError("RecurrenceObserver.recurrenceUpdated");
        return;
    }
    sbk_o_recurrenceUpdated("RecurrenceObserver", funcName, gil, pyOverride, r);
}

void RecurrenceObserverWrapper::sbk_o_recurrenceUpdated([[maybe_unused]] const char *ownerClassName, [[maybe_unused]] const char *funcName, [[maybe_unused]] Shiboken::GilState &gil, [[maybe_unused]] const Shiboken::AutoDecRef &pyOverride, [[maybe_unused]] ::KCalendarCore::Recurrence * r)
{
#if !defined(PYPY_VERSION) && (!defined(Py_LIMITED_API) || Py_LIMITED_API >= 0x030C0000)
    PyObject *pyArgArray[1] = {
        Shiboken::Conversions::pointerToPython(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_Recurrence_IDX]), r)
    };
#else
    Shiboken::AutoDecRef pyArgs(Py_BuildValue("(N)",
        Shiboken::Conversions::pointerToPython(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_Recurrence_IDX]), r)
    ));
#endif

#if !defined(PYPY_VERSION) && (!defined(Py_LIMITED_API) || Py_LIMITED_API >= 0x030C0000)
    Shiboken::AutoDecRef pyResult(PyObject_Vectorcall(pyOverride, pyArgArray, 1, nullptr));
    Py_DECREF(pyArgArray[0]);
#else
    Shiboken::AutoDecRef pyResult(PyObject_Call(pyOverride, pyArgs, nullptr));
#endif
    if (pyResult.isNull()) {
        // An error happened in python code!
        Shiboken::Errors::storePythonOverrideErrorOrPrint(ownerClassName, funcName);
        return;
    }
}

RecurrenceObserverWrapper::~RecurrenceObserverWrapper()
{
    auto *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(this, Sbk_KCalendarCore_Recurrence_RecurrenceObserver_TypeF());
    Shiboken::Object::destroy(wrapper, this);
}

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

extern "C" {
static int
Sbk_KCalendarCore_Recurrence_RecurrenceObserver_Init(PyObject *self, [[maybe_unused]] PyObject *args, [[maybe_unused]] PyObject *kwds)
{
    auto *sbkSelf = reinterpret_cast<SbkObject *>(self);
    PyTypeObject *type = self->ob_type;
    PyTypeObject *myType = Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_Recurrence_RecurrenceObserver_IDX]);
    if (type == myType) {
        Shiboken::Errors::setInstantiateAbstractClass("KCalendarCore::Recurrence::RecurrenceObserver");
        return -1;
    }

    PySide::Feature::Select(self);
    if (Shiboken::Object::isUserType(self) && !Shiboken::ObjectType::canCallConstructor(self->ob_type, Shiboken::SbkType< ::KCalendarCore::Recurrence::RecurrenceObserver >()))
        return -1;

    RecurrenceObserverWrapper *cptr{};
    Shiboken::PythonContextMarker pcm;


    // PyMI support
    Shiboken::callInheritedInit(self, args, kwds, SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_Recurrence_RecurrenceObserver_IDX]);
    if (Shiboken::Errors::occurred() != nullptr)
        return -1;

    // Call function/method
    {

        // RecurrenceObserver::RecurrenceObserver()
        cptr = new RecurrenceObserverWrapper();
    }

    if (Shiboken::Errors::occurred() != nullptr || !Shiboken::Object::setCppPointer(sbkSelf, Shiboken::SbkType< KCalendarCore::Recurrence::RecurrenceObserver >(), cptr)) {
        delete cptr;
        return -1;
    }
    Shiboken::Object::setValidCpp(sbkSelf, true);
    Shiboken::Object::setHasCppWrapper(sbkSelf, true);
    Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);


    return 1;
}

static PyObject *Sbk_KCalendarCore_Recurrence_RecurrenceObserverFunc_recurrenceUpdated(PyObject *self, PyObject *pyArg)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    [[maybe_unused]] auto *cppSelf = reinterpret_cast< ::KCalendarCore::Recurrence::RecurrenceObserver *>(Shiboken::Conversions::cppPointer(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_Recurrence_RecurrenceObserver_IDX]), reinterpret_cast<SbkObject *>(self)));
    Shiboken::AutoDecRef errInfo{};
    Shiboken::PythonContextMarker pcm;
    int overloadId = -1;
    [[maybe_unused]] Shiboken::Conversions::PythonToCppConversion pythonToCpp;

    // Overloaded function decisor
    // 0: RecurrenceObserver::recurrenceUpdated(KCalendarCore::Recurrence*)
    if ((pythonToCpp = Shiboken::Conversions::pythonToCppPointerConversion(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_Recurrence_IDX]), (pyArg)))) {
        overloadId = 0; // RecurrenceObserver::recurrenceUpdated(KCalendarCore::Recurrence*)
    }

    // Function signature not found.
    if (overloadId == -1)
        return Shiboken::returnWrongArguments(pyArg, "recurrenceUpdated", SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_Recurrence_RecurrenceObserver_IDX]);

    // Call function/method
    {
        if (!Shiboken::Object::isValid(pyArg))
            return {};
        ::KCalendarCore::Recurrence *cppArg0;
        pythonToCpp(pyArg, &cppArg0);

        if (Shiboken::Errors::occurred() == nullptr) {
            // RecurrenceObserver::recurrenceUpdated(KCalendarCore::Recurrence*)
            if (Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(self))) {
                Shiboken::Errors::setPureVirtualMethodError("RecurrenceObserver.recurrenceUpdated");
                return {};
            }
            cppSelf->recurrenceUpdated(cppArg0);
        }
    }

     return Sbk_ReturnFromPython_None();
}


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

static PyMethodDef Sbk_KCalendarCore_Recurrence_RecurrenceObserver_methods[] = {
    {"recurrenceUpdated", reinterpret_cast<PyCFunction>(Sbk_KCalendarCore_Recurrence_RecurrenceObserverFunc_recurrenceUpdated), METH_O, nullptr},
    {nullptr, nullptr, 0, nullptr} // Sentinel
};

static int Sbk_KCalendarCore_Recurrence_RecurrenceObserver_setattro(PyObject *self, PyObject *name, PyObject *value)
{
    PySide::Feature::Select(self);
    if (value != nullptr && PyCallable_Check(value) != 0) {
        auto plain_inst = reinterpret_cast< ::KCalendarCore::Recurrence::RecurrenceObserver *>(Shiboken::Conversions::cppPointer(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_Recurrence_RecurrenceObserver_IDX]), reinterpret_cast<SbkObject *>(self)));
        auto *inst = dynamic_cast<RecurrenceObserverWrapper *>(plain_inst);
        if (inst != nullptr)
            inst->resetPyMethodCache();
    }
    return PyObject_GenericSetAttr(self, name, value);
}

} // extern "C"

static int Sbk_KCalendarCore_Recurrence_RecurrenceObserver_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_Recurrence_RecurrenceObserver_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_Recurrence_RecurrenceObserver_slots[] = {
    {Py_tp_base,        nullptr}, // inserted by introduceWrapperType
    {Py_tp_dealloc,     reinterpret_cast<void *>(&SbkDeallocWrapper)},
    {Py_tp_setattro,    reinterpret_cast<void *>(Sbk_KCalendarCore_Recurrence_RecurrenceObserver_setattro)},
    {Py_tp_traverse,    reinterpret_cast<void *>(Sbk_KCalendarCore_Recurrence_RecurrenceObserver_traverse)},
    {Py_tp_clear,       reinterpret_cast<void *>(Sbk_KCalendarCore_Recurrence_RecurrenceObserver_clear)},
    {Py_tp_methods,     reinterpret_cast<void *>(Sbk_KCalendarCore_Recurrence_RecurrenceObserver_methods)},
    {Py_tp_init,        reinterpret_cast<void *>(Sbk_KCalendarCore_Recurrence_RecurrenceObserver_Init)},
    {Py_tp_new,         reinterpret_cast<void *>(SbkObject_tp_new)},
    {0, nullptr}
};
static PyType_Spec Sbk_KCalendarCore_Recurrence_RecurrenceObserver_spec = {
    "1:KCalendarCore.KCalendarCore.Recurrence.RecurrenceObserver",
    sizeof(SbkObject),
    0,
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
    Sbk_KCalendarCore_Recurrence_RecurrenceObserver_slots
};

} //extern "C"

// Type conversion functions.

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

// C++ to Python pointer conversion - tries to find the Python wrapper for the C++ object (keeps object identity).
static PyObject *RecurrenceObserver_PTR_CppToPython_RecurrenceObserver(const void *cppIn)
{
    auto *pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper(cppIn, Sbk_KCalendarCore_Recurrence_RecurrenceObserver_TypeF()));
    if (pyOut) {
        Py_INCREF(pyOut);
        return pyOut;
    }
    auto *tCppIn = reinterpret_cast<const ::KCalendarCore::Recurrence::RecurrenceObserver *>(cppIn);
    const char *typeName = typeid(*tCppIn).name();
    return Shiboken::Object::newObjectForPointer(Sbk_KCalendarCore_Recurrence_RecurrenceObserver_TypeF(), const_cast<void *>(cppIn), false, typeName);

}

// The signatures string for the functions.
// Multiple signatures have their index "n:" in front.
#if PYSIDE6_COMOPT_COMPRESS == 0
static const char *KCalendarCore_Recurrence_RecurrenceObserver_SignatureStrings[] = {
    "KCalendarCore.KCalendarCore.Recurrence.RecurrenceObserver(self)",
    "KCalendarCore.KCalendarCore.Recurrence.RecurrenceObserver.recurrenceUpdated(self,r:KCalendarCore.KCalendarCore.Recurrence)",
    nullptr}; // Sentinel
#else
static constexpr size_t KCalendarCore_Recurrence_RecurrenceObserver_SignatureByteSize = 74;
static constexpr uint8_t KCalendarCore_Recurrence_RecurrenceObserver_SignatureBytes[74] = {
    0x78, 0xda, 0xf3, 0x76, 0x4e, 0xcc, 0x49, 0xcd, 0x4b, 0x49, 0x2c, 0x72, 0xce, 0x2f, 0x4a, 0xd5,
    0xf3, 0x46, 0xe1, 0x05, 0xa5, 0x26, 0x97, 0x16, 0x15, 0xa5, 0xe6, 0x25, 0x23, 0x33, 0xfd, 0x93,
    0x8a, 0x53, 0x8b, 0xca, 0x52, 0x8b, 0x34, 0x8a, 0x53, 0x73, 0xd2, 0x34, 0xb9, 0xbc, 0xc9, 0xd5,
    0xaf, 0x57, 0x04, 0x17, 0x0a, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x4d, 0x01, 0x9b, 0xa8, 0x53, 0x64,
    0x45, 0x9c, 0x91, 0x9a, 0x5c, 0x00, 0xbe, 0x74, 0x45, 0xe0
};
#endif

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

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

    PyTypeObject *pyType = Shiboken::ObjectType::introduceWrapperType(
        enclosingClass,
        "RecurrenceObserver",
        "KCalendarCore::Recurrence::RecurrenceObserver*",
        &Sbk_KCalendarCore_Recurrence_RecurrenceObserver_spec,
        &Shiboken::callCppDestructor< KCalendarCore::Recurrence::RecurrenceObserver >,
        Sbk_KCalendarCore_Recurrence_RecurrenceObserver_Type_bases.object(),
        Shiboken::ObjectType::WrapperFlags::InnerClass);
#if PYSIDE6_COMOPT_COMPRESS == 0
    InitSignatureStrings(pyType, KCalendarCore_Recurrence_RecurrenceObserver_SignatureStrings);
#else
    InitSignatureBytes(pyType, KCalendarCore_Recurrence_RecurrenceObserver_SignatureBytes, KCalendarCore_Recurrence_RecurrenceObserver_SignatureByteSize);
#endif
    SbkObjectType_SetPropertyStrings(pyType, Sbk_KCalendarCore_Recurrence_RecurrenceObserver_PropertyStrings);
    typeStruct.type = pyType;

    // Register Converter
    SbkConverter *converter = Shiboken::Conversions::createConverter(pyType,
        RecurrenceObserver_PythonToCpp_RecurrenceObserver_PTR,
        is_RecurrenceObserver_PythonToCpp_RecurrenceObserver_PTR_Convertible,
        RecurrenceObserver_PTR_CppToPython_RecurrenceObserver);

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

    qRegisterMetaType< ::KCalendarCore::Recurrence::RecurrenceObserver *>();

    return pyType;
}
