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

// Argument includes
#include <recurrencerule.h>

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

using namespace KCalendarCore;

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

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

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

RuleObserverWrapper::RuleObserverWrapper()
{
}

void RuleObserverWrapper::recurrenceChanged(::KCalendarCore::RecurrenceRule * arg__1)
{
    static const char *funcName = "recurrenceChanged";
    static PyObject *nameCache[2] = {};
    Shiboken::GilState gil(false);
    Shiboken::AutoDecRef pyOverride(Sbk_GetPyOverride(this, Sbk_KCalendarCore_RecurrenceRule_RuleObserver_TypeF(), gil, funcName, m_PyMethodCache[0], nameCache));
    if (pyOverride.isNull()) {
        gil.acquire();
        Shiboken::Errors::setPureVirtualMethodError("RuleObserver.recurrenceChanged");
        return;
    }
    sbk_o_recurrenceChanged("RuleObserver", funcName, gil, pyOverride, arg__1);
}

void RuleObserverWrapper::sbk_o_recurrenceChanged([[maybe_unused]] const char *ownerClassName, [[maybe_unused]] const char *funcName, [[maybe_unused]] Shiboken::GilState &gil, [[maybe_unused]] const Shiboken::AutoDecRef &pyOverride, [[maybe_unused]] ::KCalendarCore::RecurrenceRule * arg__1)
{
#if !defined(PYPY_VERSION) && (!defined(Py_LIMITED_API) || Py_LIMITED_API >= 0x030C0000)
    PyObject *pyArgArray[1] = {
        Shiboken::Conversions::pointerToPython(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_RecurrenceRule_IDX]), arg__1)
    };
#else
    Shiboken::AutoDecRef pyArgs(Py_BuildValue("(N)",
        Shiboken::Conversions::pointerToPython(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_RecurrenceRule_IDX]), arg__1)
    ));
#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;
    }
}

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

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

extern "C" {
static int
Sbk_KCalendarCore_RecurrenceRule_RuleObserver_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_RecurrenceRule_RuleObserver_IDX]);
    if (type == myType) {
        Shiboken::Errors::setInstantiateAbstractClass("KCalendarCore::RecurrenceRule::RuleObserver");
        return -1;
    }

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

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


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

    // Call function/method
    {

        // RuleObserver::RuleObserver()
        cptr = new RuleObserverWrapper();
    }

    if (Shiboken::Errors::occurred() != nullptr || !Shiboken::Object::setCppPointer(sbkSelf, Shiboken::SbkType< KCalendarCore::RecurrenceRule::RuleObserver >(), 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_RecurrenceRule_RuleObserverFunc_recurrenceChanged(PyObject *self, PyObject *pyArg)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    [[maybe_unused]] auto *cppSelf = reinterpret_cast< ::KCalendarCore::RecurrenceRule::RuleObserver *>(Shiboken::Conversions::cppPointer(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_RecurrenceRule_RuleObserver_IDX]), reinterpret_cast<SbkObject *>(self)));
    Shiboken::AutoDecRef errInfo{};
    Shiboken::PythonContextMarker pcm;
    int overloadId = -1;
    [[maybe_unused]] Shiboken::Conversions::PythonToCppConversion pythonToCpp;

    // Overloaded function decisor
    // 0: RuleObserver::recurrenceChanged(KCalendarCore::RecurrenceRule*)
    if ((pythonToCpp = Shiboken::Conversions::pythonToCppPointerConversion(Shiboken::Module::get(SbkKCalendarCoreTypeStructs[SBK_KCalendarCore_RecurrenceRule_IDX]), (pyArg)))) {
        overloadId = 0; // RuleObserver::recurrenceChanged(KCalendarCore::RecurrenceRule*)
    }

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

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

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

     return Sbk_ReturnFromPython_None();
}


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

static PyMethodDef Sbk_KCalendarCore_RecurrenceRule_RuleObserver_methods[] = {
    {"recurrenceChanged", reinterpret_cast<PyCFunction>(Sbk_KCalendarCore_RecurrenceRule_RuleObserverFunc_recurrenceChanged), METH_O, nullptr},
    {nullptr, nullptr, 0, nullptr} // Sentinel
};

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

} // extern "C"

static int Sbk_KCalendarCore_RecurrenceRule_RuleObserver_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_RecurrenceRule_RuleObserver_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_RecurrenceRule_RuleObserver_slots[] = {
    {Py_tp_base,        nullptr}, // inserted by introduceWrapperType
    {Py_tp_dealloc,     reinterpret_cast<void *>(&SbkDeallocWrapper)},
    {Py_tp_setattro,    reinterpret_cast<void *>(Sbk_KCalendarCore_RecurrenceRule_RuleObserver_setattro)},
    {Py_tp_traverse,    reinterpret_cast<void *>(Sbk_KCalendarCore_RecurrenceRule_RuleObserver_traverse)},
    {Py_tp_clear,       reinterpret_cast<void *>(Sbk_KCalendarCore_RecurrenceRule_RuleObserver_clear)},
    {Py_tp_methods,     reinterpret_cast<void *>(Sbk_KCalendarCore_RecurrenceRule_RuleObserver_methods)},
    {Py_tp_init,        reinterpret_cast<void *>(Sbk_KCalendarCore_RecurrenceRule_RuleObserver_Init)},
    {Py_tp_new,         reinterpret_cast<void *>(SbkObject_tp_new)},
    {0, nullptr}
};
static PyType_Spec Sbk_KCalendarCore_RecurrenceRule_RuleObserver_spec = {
    "1:KCalendarCore.KCalendarCore.RecurrenceRule.RuleObserver",
    sizeof(SbkObject),
    0,
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
    Sbk_KCalendarCore_RecurrenceRule_RuleObserver_slots
};

} //extern "C"

// Type conversion functions.

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

// C++ to Python pointer conversion - tries to find the Python wrapper for the C++ object (keeps object identity).
static PyObject *RuleObserver_PTR_CppToPython_RuleObserver(const void *cppIn)
{
    auto *pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper(cppIn, Sbk_KCalendarCore_RecurrenceRule_RuleObserver_TypeF()));
    if (pyOut) {
        Py_INCREF(pyOut);
        return pyOut;
    }
    auto *tCppIn = reinterpret_cast<const ::KCalendarCore::RecurrenceRule::RuleObserver *>(cppIn);
    const char *typeName = typeid(*tCppIn).name();
    return Shiboken::Object::newObjectForPointer(Sbk_KCalendarCore_RecurrenceRule_RuleObserver_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_RecurrenceRule_RuleObserver_SignatureStrings[] = {
    "KCalendarCore.KCalendarCore.RecurrenceRule.RuleObserver(self)",
    "KCalendarCore.KCalendarCore.RecurrenceRule.RuleObserver.recurrenceChanged(self,arg__1:KCalendarCore.KCalendarCore.RecurrenceRule)",
    nullptr}; // Sentinel
#else
static constexpr size_t KCalendarCore_RecurrenceRule_RuleObserver_SignatureByteSize = 85;
static constexpr uint8_t KCalendarCore_RecurrenceRule_RuleObserver_SignatureBytes[85] = {
    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, 0xa7, 0x06, 0x95, 0xe6,
    0x00, 0xb9, 0x40, 0xc2, 0x3f, 0xa9, 0x38, 0xb5, 0xa8, 0x2c, 0xb5, 0x48, 0xa3, 0x38, 0x35, 0x27,
    0x4d, 0x93, 0xcb, 0x9b, 0x3c, 0xdd, 0x7a, 0x45, 0x70, 0x39, 0xe7, 0x8c, 0xc4, 0xbc, 0xf4, 0xd4,
    0x14, 0xb0, 0x79, 0x3a, 0x89, 0x45, 0xe9, 0xf1, 0xf1, 0x86, 0x56, 0xc4, 0x9b, 0xaa, 0xc9, 0x05,
    0x00, 0xfe, 0x9e, 0x47, 0x56
};
#endif

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

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

    PyTypeObject *pyType = Shiboken::ObjectType::introduceWrapperType(
        enclosingClass,
        "RuleObserver",
        "KCalendarCore::RecurrenceRule::RuleObserver*",
        &Sbk_KCalendarCore_RecurrenceRule_RuleObserver_spec,
        &Shiboken::callCppDestructor< KCalendarCore::RecurrenceRule::RuleObserver >,
        Sbk_KCalendarCore_RecurrenceRule_RuleObserver_Type_bases.object(),
        Shiboken::ObjectType::WrapperFlags::InnerClass);
#if PYSIDE6_COMOPT_COMPRESS == 0
    InitSignatureStrings(pyType, KCalendarCore_RecurrenceRule_RuleObserver_SignatureStrings);
#else
    InitSignatureBytes(pyType, KCalendarCore_RecurrenceRule_RuleObserver_SignatureBytes, KCalendarCore_RecurrenceRule_RuleObserver_SignatureByteSize);
#endif
    SbkObjectType_SetPropertyStrings(pyType, Sbk_KCalendarCore_RecurrenceRule_RuleObserver_PropertyStrings);
    typeStruct.type = pyType;

    // Register Converter
    SbkConverter *converter = Shiboken::Conversions::createConverter(pyType,
        RuleObserver_PythonToCpp_RuleObserver_PTR,
        is_RuleObserver_PythonToCpp_RuleObserver_PTR_Convertible,
        RuleObserver_PTR_CppToPython_RuleObserver);

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

    qRegisterMetaType< ::KCalendarCore::RecurrenceRule::RuleObserver *>();

    return pyType;
}
