
// 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 <pysideqobject.h>
#include <pysidesignal.h>
#include <pysideproperty.h>
#include <signalmanager.h>
#include <pysidemetafunction.h>
#include <pysideqenum.h>
#include <pysideutils.h>
#include <feature_select.h>
QT_WARNING_DISABLE_DEPRECATED


// module include
#include "akonadicalendar_python.h"

// main header
#include "akonadi_calendarclipboard_wrapper.h"

// Wrappers providing overrides
#include "akonadi_todopurger_wrapper.h"

// Argument includes
#include <QString>
#include <qobject.h>
#include <qobjectdefs.h>

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

using namespace Akonadi;

extern "C" {
static PyTypeObject *Sbk_Akonadi_CalendarClipboard_TypeF(void)
{
    return SbkAkonadiCalendarTypeStructs[SBK_Akonadi_CalendarClipboard_IDX].type;
}
} // extern "C"

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

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

void CalendarClipboardWrapper::childEvent(::QChildEvent * event)
{
    static const char *funcName = "childEvent";
    static PyObject *nameCache[2] = {};
    Shiboken::GilState gil(false);
    Shiboken::AutoDecRef pyOverride(Sbk_GetPyOverride(this, Sbk_Akonadi_CalendarClipboard_TypeF(), gil, funcName, m_PyMethodCache[0], nameCache));
    if (pyOverride.isNull()) {
        return this->::QObject::childEvent(event);
    }
    TodoPurgerWrapper::sbk_o_childEvent("CalendarClipboard", funcName, gil, pyOverride, event);
}

void CalendarClipboardWrapper::connectNotify(const ::QMetaMethod & signal)
{
    static const char *funcName = "connectNotify";
    static PyObject *nameCache[2] = {};
    Shiboken::GilState gil(false);
    Shiboken::AutoDecRef pyOverride(Sbk_GetPyOverride(this, Sbk_Akonadi_CalendarClipboard_TypeF(), gil, funcName, m_PyMethodCache[1], nameCache));
    if (pyOverride.isNull()) {
        return this->::QObject::connectNotify(signal);
    }
    TodoPurgerWrapper::sbk_o_connectNotify("CalendarClipboard", funcName, gil, pyOverride, signal);
}

void CalendarClipboardWrapper::customEvent(::QEvent * event)
{
    static const char *funcName = "customEvent";
    static PyObject *nameCache[2] = {};
    Shiboken::GilState gil(false);
    Shiboken::AutoDecRef pyOverride(Sbk_GetPyOverride(this, Sbk_Akonadi_CalendarClipboard_TypeF(), gil, funcName, m_PyMethodCache[2], nameCache));
    if (pyOverride.isNull()) {
        return this->::QObject::customEvent(event);
    }
    TodoPurgerWrapper::sbk_o_customEvent("CalendarClipboard", funcName, gil, pyOverride, event);
}

void CalendarClipboardWrapper::disconnectNotify(const ::QMetaMethod & signal)
{
    static const char *funcName = "disconnectNotify";
    static PyObject *nameCache[2] = {};
    Shiboken::GilState gil(false);
    Shiboken::AutoDecRef pyOverride(Sbk_GetPyOverride(this, Sbk_Akonadi_CalendarClipboard_TypeF(), gil, funcName, m_PyMethodCache[3], nameCache));
    if (pyOverride.isNull()) {
        return this->::QObject::disconnectNotify(signal);
    }
    TodoPurgerWrapper::sbk_o_connectNotify("CalendarClipboard", funcName, gil, pyOverride, signal);
}

bool CalendarClipboardWrapper::event(::QEvent * event)
{
    static const char *funcName = "event";
    static PyObject *nameCache[2] = {};
    Shiboken::GilState gil(false);
    Shiboken::AutoDecRef pyOverride(Sbk_GetPyOverride(this, Sbk_Akonadi_CalendarClipboard_TypeF(), gil, funcName, m_PyMethodCache[4], nameCache));
    if (pyOverride.isNull()) {
        return this->::QObject::event(event);
    }
    return TodoPurgerWrapper::sbk_o_event("CalendarClipboard", funcName, gil, pyOverride, event);
}

bool CalendarClipboardWrapper::eventFilter(::QObject * watched, ::QEvent * event)
{
    static const char *funcName = "eventFilter";
    static PyObject *nameCache[2] = {};
    Shiboken::GilState gil(false);
    Shiboken::AutoDecRef pyOverride(Sbk_GetPyOverride(this, Sbk_Akonadi_CalendarClipboard_TypeF(), gil, funcName, m_PyMethodCache[5], nameCache));
    if (pyOverride.isNull()) {
        return this->::QObject::eventFilter(watched, event);
    }
    return TodoPurgerWrapper::sbk_o_eventFilter("CalendarClipboard", funcName, gil, pyOverride, watched, event);
}

void CalendarClipboardWrapper::timerEvent(::QTimerEvent * event)
{
    static const char *funcName = "timerEvent";
    static PyObject *nameCache[2] = {};
    Shiboken::GilState gil(false);
    Shiboken::AutoDecRef pyOverride(Sbk_GetPyOverride(this, Sbk_Akonadi_CalendarClipboard_TypeF(), gil, funcName, m_PyMethodCache[6], nameCache));
    if (pyOverride.isNull()) {
        return this->::QObject::timerEvent(event);
    }
    TodoPurgerWrapper::sbk_o_timerEvent("CalendarClipboard", funcName, gil, pyOverride, event);
}

const QMetaObject *CalendarClipboardWrapper::metaObject() const
{
    if (QObject::d_ptr->metaObject != nullptr)
        return QObject::d_ptr->dynamicMetaObject();
    SbkObject *pySelf = Shiboken::BindingManager::instance().retrieveWrapper(this);
    if (pySelf == nullptr)
        return Akonadi::CalendarClipboard::metaObject();
    return PySide::SignalManager::retrieveMetaObject(reinterpret_cast<PyObject *>(pySelf));
}

int CalendarClipboardWrapper::qt_metacall(QMetaObject::Call call, int id, void **args)
{
    int result = Akonadi::CalendarClipboard::qt_metacall(call, id, args);
    return result < 0 ? result : PySide::SignalManager::qt_metacall(this, call, id, args);
}

void *CalendarClipboardWrapper::qt_metacast(const char *_clname)
{
    if (_clname == nullptr)
        return {};
    if (SbkObject *pySelf = Shiboken::BindingManager::instance().retrieveWrapper(this)) {
        auto *obSelf = reinterpret_cast<PyObject *>(pySelf);
        if (PySide::inherits(Py_TYPE(obSelf), _clname))
            return static_cast<void *>(const_cast< CalendarClipboardWrapper *>(this));
    }
    return Akonadi::CalendarClipboard::qt_metacast(_clname);
}

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

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

extern "C" {
static int Sbk_Akonadi_CalendarClipboard_Init(PyObject *, PyObject *, PyObject *)
{
    Shiboken::Errors::setInstantiateNonConstructible("CalendarClipboard");
    return -1;
}

static PyObject *Sbk_Akonadi_CalendarClipboardFunc_pasteAvailable(PyObject *self)
{
    if (!Shiboken::Object::isValid(self))
        return {};
    [[maybe_unused]] auto *cppSelf = reinterpret_cast< ::Akonadi::CalendarClipboard *>(Shiboken::Conversions::cppPointer(Shiboken::Module::get(SbkAkonadiCalendarTypeStructs[SBK_Akonadi_CalendarClipboard_IDX]), reinterpret_cast<SbkObject *>(self)));
    PyObject *pyResult{};
    Shiboken::PythonContextMarker pcm;

    // Call function/method
    {

        // CalendarClipboard::pasteAvailable()const->bool
        bool cppResult = const_cast<const ::Akonadi::CalendarClipboard *>(cppSelf)->pasteAvailable();
        pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<bool>(), &cppResult);
    }

    return Sbk_ReturnFromPython_Result(pyResult);
}


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

static const char *Sbk_Akonadi_CalendarClipboard_EnumFlagInfo[] = {
    "Mode:IntEnum",
    nullptr // Sentinel
};

static PyMethodDef Sbk_Akonadi_CalendarClipboard_methods[] = {
    {"pasteAvailable", reinterpret_cast<PyCFunction>(Sbk_Akonadi_CalendarClipboardFunc_pasteAvailable), METH_NOARGS, nullptr},
    {nullptr, nullptr, 0, nullptr} // Sentinel
};

static int Sbk_Akonadi_CalendarClipboard_setattro(PyObject *self, PyObject *name, PyObject *value)
{
    PySide::Feature::Select(self);
    if (value != nullptr && PyCallable_Check(value) != 0) {
        auto plain_inst = reinterpret_cast< ::Akonadi::CalendarClipboard *>(Shiboken::Conversions::cppPointer(Shiboken::Module::get(SbkAkonadiCalendarTypeStructs[SBK_Akonadi_CalendarClipboard_IDX]), reinterpret_cast<SbkObject *>(self)));
        auto *inst = dynamic_cast<CalendarClipboardWrapper *>(plain_inst);
        if (inst != nullptr)
            inst->resetPyMethodCache();
    }
    Shiboken::AutoDecRef pp(reinterpret_cast<PyObject *>(PySide::Property::getObject(self, name)));
    if (!pp.isNull())
        return PySide::Property::setValue(reinterpret_cast<PySideProperty *>(pp.object()), self, value);
    return PyObject_GenericSetAttr(self, name, value);
}

} // extern "C"

static int Sbk_Akonadi_CalendarClipboard_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_CalendarClipboard_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_CalendarClipboard_slots[] = {
    {Py_tp_base,        nullptr}, // inserted by introduceWrapperType
    {Py_tp_dealloc,     reinterpret_cast<void *>(&SbkDeallocWrapper)},
    {Py_tp_setattro,    reinterpret_cast<void *>(Sbk_Akonadi_CalendarClipboard_setattro)},
    {Py_tp_traverse,    reinterpret_cast<void *>(Sbk_Akonadi_CalendarClipboard_traverse)},
    {Py_tp_clear,       reinterpret_cast<void *>(Sbk_Akonadi_CalendarClipboard_clear)},
    {Py_tp_methods,     reinterpret_cast<void *>(Sbk_Akonadi_CalendarClipboard_methods)},
    {Py_tp_init,        reinterpret_cast<void *>(Sbk_Akonadi_CalendarClipboard_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_CalendarClipboard_spec = {
    "1:AkonadiCalendar.Akonadi.CalendarClipboard",
    sizeof(SbkObject),
    0,
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
    Sbk_Akonadi_CalendarClipboard_slots
};

} //extern "C"

static void *Sbk_Akonadi_CalendarClipboard_typeDiscovery([[maybe_unused]] void *cptr, [[maybe_unused]] PyTypeObject *instanceType)
{
    if (instanceType == Shiboken::SbkType< ::QObject >())
        return dynamic_cast< ::Akonadi::CalendarClipboard *>(reinterpret_cast< ::QObject *>(cptr));
    return {};
}


// Type conversion functions.

// Python to C++ enum conversion.
static void Enum_PythonToCpp_Akonadi_CalendarClipboard_Mode(PyObject *pyIn, void *cppOut)
{
    const auto value = static_cast<::Akonadi::CalendarClipboard::Mode>(Shiboken::Enum::getValue(pyIn));
    *reinterpret_cast<::Akonadi::CalendarClipboard::Mode *>(cppOut) = value;

}
static PythonToCppFunc is_Enum_PythonToCpp_Akonadi_CalendarClipboard_Mode_Convertible(PyObject *pyIn)
{
    if (PyObject_TypeCheck(pyIn, Shiboken::Module::get(SbkAkonadiCalendarTypeStructs[SBK_Akonadi_CalendarClipboard_Mode_IDX])))
        return Enum_PythonToCpp_Akonadi_CalendarClipboard_Mode;
    return {};
}

static PyObject *Akonadi_CalendarClipboard_Mode_CppToPython_Enum(PyTypeObject *pyType, const void *cppIn)
{
    using IntType = std::underlying_type_t<::Akonadi::CalendarClipboard::Mode>;
    const auto castCppIn = IntType(*reinterpret_cast<const ::Akonadi::CalendarClipboard::Mode *>(cppIn));
    return Shiboken::Enum::newItem(pyType, castCppIn);

}

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

// C++ to Python pointer conversion - tries to find the Python wrapper for the C++ object (keeps object identity).
static PyObject *CalendarClipboard_PTR_CppToPython_CalendarClipboard(const void *cppIn)
{
    return PySide::getWrapperForQObject(reinterpret_cast<::Akonadi::CalendarClipboard *>(const_cast<void *>(cppIn)), Sbk_Akonadi_CalendarClipboard_TypeF());

}

// The signatures string for the functions.
// Multiple signatures have their index "n:" in front.
#if PYSIDE6_COMOPT_COMPRESS == 0
static const char *Akonadi_CalendarClipboard_SignatureStrings[] = {
    "AkonadiCalendar.Akonadi.CalendarClipboard.pasteAvailable(self)->bool",
    nullptr}; // Sentinel
#else
static constexpr size_t Akonadi_CalendarClipboard_SignatureByteSize = 66;
static constexpr uint8_t Akonadi_CalendarClipboard_SignatureBytes[66] = {
    0x78, 0xda, 0x73, 0xcc, 0xce, 0xcf, 0x4b, 0x4c, 0xc9, 0x74, 0x4e, 0xcc, 0x49, 0xcd, 0x4b, 0x49,
    0x2c, 0xd2, 0x73, 0x84, 0xf0, 0xf5, 0x60, 0x02, 0xce, 0x39, 0x99, 0x05, 0x49, 0xf9, 0x89, 0x45,
    0x29, 0x7a, 0x05, 0x89, 0xc5, 0x25, 0xa9, 0x8e, 0x65, 0x89, 0x99, 0x39, 0x89, 0x49, 0x39, 0xa9,
    0x1a, 0xc5, 0xa9, 0x39, 0x69, 0x9a, 0xba, 0x76, 0x49, 0xf9, 0xf9, 0x39, 0x5c, 0x00, 0x8c, 0x7a,
    0x19, 0x77
};
#endif

PyTypeObject *init_Akonadi_CalendarClipboard(PyObject *enclosingClass)
{
    auto &typeStruct = SbkAkonadiCalendarTypeStructs[SBK_Akonadi_CalendarClipboard_IDX];
    if (typeStruct.type != nullptr)
        return typeStruct.type;

    auto *base1 = reinterpret_cast<PyObject *>(Shiboken::Module::get(SbkPySide6_QtCoreTypeStructs[SBK_QObject_IDX]));
    Shiboken::AutoDecRef Sbk_Akonadi_CalendarClipboard_Type_bases(PyTuple_Pack(1, base1));

    PyTypeObject *pyType = Shiboken::ObjectType::introduceWrapperType(
        enclosingClass,
        "CalendarClipboard",
        "Akonadi::CalendarClipboard*",
        &Sbk_Akonadi_CalendarClipboard_spec,
        &Shiboken::callCppDestructor< Akonadi::CalendarClipboard >,
        Sbk_Akonadi_CalendarClipboard_Type_bases.object(),
        Shiboken::ObjectType::WrapperFlags::InnerClass);
#if PYSIDE6_COMOPT_COMPRESS == 0
    InitSignatureStrings(pyType, Akonadi_CalendarClipboard_SignatureStrings);
#else
    InitSignatureBytes(pyType, Akonadi_CalendarClipboard_SignatureBytes, Akonadi_CalendarClipboard_SignatureByteSize);
#endif
    SbkObjectType_SetPropertyStrings(pyType, Sbk_Akonadi_CalendarClipboard_PropertyStrings);
    typeStruct.type = pyType;

    // Register Converter
    SbkConverter *converter = Shiboken::Conversions::createConverter(pyType,
        CalendarClipboard_PythonToCpp_CalendarClipboard_PTR,
        is_CalendarClipboard_PythonToCpp_CalendarClipboard_PTR_Convertible,
        CalendarClipboard_PTR_CppToPython_CalendarClipboard);

    Shiboken::Conversions::registerConverterName(converter, "Akonadi::CalendarClipboard");
    Shiboken::Conversions::registerConverterName(converter, "Akonadi::CalendarClipboard*");
    Shiboken::Conversions::registerConverterName(converter, "Akonadi::CalendarClipboard&");
    Shiboken::Conversions::registerConverterAlias(converter, "CalendarClipboard");
    Shiboken::Conversions::registerConverterAlias(converter, "CalendarClipboard*");
    Shiboken::Conversions::registerConverterAlias(converter, "CalendarClipboard&");
    Shiboken::Conversions::registerConverterName(converter, typeid(::Akonadi::CalendarClipboard).name());
    Shiboken::Conversions::registerConverterName(converter, typeid(CalendarClipboardWrapper).name());

    Shiboken::ObjectType::setTypeDiscoveryFunctionV2(pyType, &Sbk_Akonadi_CalendarClipboard_typeDiscovery);

    // Pass the ..._EnumFlagInfo to the class.
    SbkObjectType_SetEnumFlagInfo(pyType, Sbk_Akonadi_CalendarClipboard_EnumFlagInfo);

    // Initialization of enums.
    Shiboken::AutoDecRef tpDict{};
    [[maybe_unused]] PyTypeObject *EType{};

    // Initialization of enum 'Mode'.
    const char *Mode_Initializer[] = {
        "SingleMode",
        "RecursiveMode",
        "AskMode",
        nullptr};
    // "uint8_t" used instead of "unsigned int"
    constexpr uint8_t Mode_InitializerValues[] = {
        uint8_t(Akonadi::CalendarClipboard::Mode::SingleMode),    //  0x00  0
        uint8_t(Akonadi::CalendarClipboard::Mode::RecursiveMode), //  0x01  1
        uint8_t(Akonadi::CalendarClipboard::Mode::AskMode)        //  0x02  2
        };
    EType = Shiboken::Enum::createPythonEnum(pyType,
        "1:AkonadiCalendar.Akonadi.CalendarClipboard.Mode",
        Mode_Initializer, Mode_InitializerValues);
    SbkAkonadiCalendarTypeStructs[SBK_Akonadi_CalendarClipboard_Mode_IDX].type = EType;
    // Register converter for enum 'Akonadi::CalendarClipboard::Mode'.
    {
        SbkConverter *converter = Shiboken::Conversions::createConverter(EType,
            Akonadi_CalendarClipboard_Mode_CppToPython_Enum);
        Shiboken::Conversions::addPythonToCppValueConversion(converter,
            Enum_PythonToCpp_Akonadi_CalendarClipboard_Mode,
            is_Enum_PythonToCpp_Akonadi_CalendarClipboard_Mode_Convertible);
        Shiboken::Conversions::registerConverterName(converter, "Akonadi::CalendarClipboard::Mode");
        Shiboken::Conversions::registerConverterAlias(converter, "CalendarClipboard::Mode");
        Shiboken::Conversions::registerConverterAlias(converter, "Mode");
        Shiboken::Enum::setTypeConverter(EType, converter, nullptr);
    }
    // End of 'Mode' enum.

    PySide::Signal::registerSignals(pyType, &::Akonadi::CalendarClipboard::staticMetaObject);
    qRegisterMetaType< ::Akonadi::CalendarClipboard::Mode >("CalendarClipboard::Mode");
    qRegisterMetaType< ::Akonadi::CalendarClipboard::Mode >("Akonadi::CalendarClipboard::Mode");
    Shiboken::ObjectType::setSubTypeInitHook(pyType, &PySide::initQObjectSubType);
    PySide::initDynamicMetaObject(pyType, &::Akonadi::CalendarClipboard::staticMetaObject, sizeof(CalendarClipboardWrapper));

    return pyType;
}
