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

// Argument includes
#include <attribute.h>
#include <attributefactory.h>
#include <qbytearray.h>

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

using namespace Akonadi;

extern "C" {
static PyTypeObject *Sbk_Akonadi_AttributeFactory_TypeF(void)
{
    return SbkAkonadiCoreTypeStructs[SBK_Akonadi_AttributeFactory_IDX].type;
}
} // extern "C"


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

extern "C" {
static int
Sbk_Akonadi_AttributeFactory_Init(PyObject *self, [[maybe_unused]] 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< ::Akonadi::AttributeFactory >()))
        return -1;

    ::Akonadi::AttributeFactory *cptr{};
    Shiboken::PythonContextMarker pcm;


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

    // Call function/method
    {

        // AttributeFactory::AttributeFactory()
        cptr = new ::Akonadi::AttributeFactory();
    }

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


    return 1;
}

static PyObject *Sbk_Akonadi_AttributeFactoryFunc_createAttribute([[maybe_unused]] PyObject *self, PyObject *pyArg)
{
    PyObject *pyResult{};
    Shiboken::AutoDecRef errInfo{};
    Shiboken::PythonContextMarker pcm;
    int overloadId = -1;
    [[maybe_unused]] Shiboken::Conversions::PythonToCppConversion pythonToCpp;

    // Overloaded function decisor
    // 0: static AttributeFactory::createAttribute(const QByteArray&)->Akonadi::Attribute*
    if ((pythonToCpp = Shiboken::Conversions::pythonToCppReferenceConversion(Shiboken::Module::get(SbkPySide6_QtCoreTypeStructs[SBK_QByteArray_IDX]), (pyArg)))) {
        overloadId = 0; // static AttributeFactory::createAttribute(const QByteArray&)->Akonadi::Attribute*
    }

    // Function signature not found.
    if (overloadId == -1)
        return Shiboken::returnWrongArguments(pyArg, "createAttribute", SbkAkonadiCoreTypeStructs[SBK_Akonadi_AttributeFactory_IDX]);

    // Call function/method
    {
        if (!Shiboken::Object::isValid(pyArg))
            return {};
        ::QByteArray cppArg0_local;
        ::QByteArray *cppArg0 = &cppArg0_local;
        if (pythonToCpp.isValue())
            pythonToCpp(pyArg, &cppArg0_local);
        else
            pythonToCpp(pyArg, &cppArg0);


        if (Shiboken::Errors::occurred() == nullptr) {
            // static AttributeFactory::createAttribute(const QByteArray&)->Akonadi::Attribute*
            Akonadi::Attribute * cppResult = ::Akonadi::AttributeFactory::createAttribute(*cppArg0);
            pyResult = Shiboken::Conversions::pointerToPython(Shiboken::Module::get(SbkAkonadiCoreTypeStructs[SBK_Akonadi_Attribute_IDX]), cppResult);
        }
    }

    return Sbk_ReturnFromPython_Result(pyResult);
}


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

static PyMethodDef Sbk_Akonadi_AttributeFactory_methods[] = {
    {"createAttribute", reinterpret_cast<PyCFunction>(Sbk_Akonadi_AttributeFactoryFunc_createAttribute), METH_O|METH_STATIC, nullptr},
    {nullptr, nullptr, 0, nullptr} // Sentinel
};

} // extern "C"

static int Sbk_Akonadi_AttributeFactory_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_AttributeFactory_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_AttributeFactory_slots[] = {
    {Py_tp_base,        nullptr}, // inserted by introduceWrapperType
    {Py_tp_dealloc,     reinterpret_cast<void *>(&SbkDeallocWrapper)},
    {Py_tp_traverse,    reinterpret_cast<void *>(Sbk_Akonadi_AttributeFactory_traverse)},
    {Py_tp_clear,       reinterpret_cast<void *>(Sbk_Akonadi_AttributeFactory_clear)},
    {Py_tp_methods,     reinterpret_cast<void *>(Sbk_Akonadi_AttributeFactory_methods)},
    {Py_tp_init,        reinterpret_cast<void *>(Sbk_Akonadi_AttributeFactory_Init)},
    {Py_tp_new,         reinterpret_cast<void *>(SbkObject_tp_new)},
    {0, nullptr}
};
static PyType_Spec Sbk_Akonadi_AttributeFactory_spec = {
    "1:AkonadiCore.Akonadi.AttributeFactory",
    sizeof(SbkObject),
    0,
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
    Sbk_Akonadi_AttributeFactory_slots
};

} //extern "C"

// Type conversion functions.

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

// C++ to Python pointer conversion - tries to find the Python wrapper for the C++ object (keeps object identity).
static PyObject *AttributeFactory_PTR_CppToPython_AttributeFactory(const void *cppIn)
{
    auto *pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper(cppIn, Sbk_Akonadi_AttributeFactory_TypeF()));
    if (pyOut) {
        Py_INCREF(pyOut);
        return pyOut;
    }
    return Shiboken::Object::newObjectWithHeuristics(Sbk_Akonadi_AttributeFactory_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 *Akonadi_AttributeFactory_SignatureStrings[] = {
    "AkonadiCore.Akonadi.AttributeFactory(self)",
    "AkonadiCore.Akonadi.AttributeFactory.createAttribute(type:typing.Union[PySide6.QtCore.QByteArray, char*])->AkonadiCore.Akonadi.Attribute",
    nullptr}; // Sentinel
#else
static constexpr size_t Akonadi_AttributeFactory_SignatureByteSize = 112;
static constexpr uint8_t Akonadi_AttributeFactory_SignatureBytes[112] = {
    0x78, 0xda, 0x73, 0xcc, 0xce, 0xcf, 0x4b, 0x4c, 0xc9, 0x74, 0xce, 0x2f, 0x4a, 0xd5, 0x73, 0x84,
    0xb0, 0xf5, 0x1c, 0x4b, 0x4a, 0x8a, 0x32, 0x93, 0x4a, 0x4b, 0x52, 0xdd, 0x12, 0x93, 0x4b, 0xf2,
    0x8b, 0x2a, 0x35, 0x8a, 0x53, 0x73, 0xd2, 0x34, 0xb9, 0x1c, 0x89, 0x50, 0xaa, 0x97, 0x5c, 0x94,
    0x9a, 0x58, 0x92, 0x0a, 0x17, 0xd6, 0x28, 0xa9, 0x2c, 0x48, 0xb5, 0x02, 0x12, 0x99, 0x79, 0xe9,
    0x7a, 0xa1, 0x79, 0x99, 0xf9, 0x79, 0xd1, 0x01, 0x95, 0xc1, 0x99, 0x29, 0xa9, 0x66, 0x7a, 0x81,
    0x25, 0x60, 0x93, 0x02, 0x9d, 0x2a, 0x81, 0xea, 0x8b, 0x8a, 0x12, 0x2b, 0x75, 0x14, 0x92, 0x33,
    0x12, 0x8b, 0xb4, 0x62, 0x35, 0x75, 0xed, 0xf0, 0x5a, 0xc5, 0x05, 0x00, 0xd4, 0x31, 0x42, 0x93
};
#endif

PyTypeObject *init_Akonadi_AttributeFactory(PyObject *enclosingClass)
{
    auto &typeStruct = SbkAkonadiCoreTypeStructs[SBK_Akonadi_AttributeFactory_IDX];
    if (typeStruct.type != nullptr)
        return typeStruct.type;

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

    PyTypeObject *pyType = Shiboken::ObjectType::introduceWrapperType(
        enclosingClass,
        "AttributeFactory",
        "Akonadi::AttributeFactory*",
        &Sbk_Akonadi_AttributeFactory_spec,
        &Shiboken::callCppDestructor< ::Akonadi::AttributeFactory >,
        Sbk_Akonadi_AttributeFactory_Type_bases.object(),
        Shiboken::ObjectType::WrapperFlags::InnerClass);
#if PYSIDE6_COMOPT_COMPRESS == 0
    InitSignatureStrings(pyType, Akonadi_AttributeFactory_SignatureStrings);
#else
    InitSignatureBytes(pyType, Akonadi_AttributeFactory_SignatureBytes, Akonadi_AttributeFactory_SignatureByteSize);
#endif
    SbkObjectType_SetPropertyStrings(pyType, Sbk_Akonadi_AttributeFactory_PropertyStrings);
    typeStruct.type = pyType;

    // Register Converter
    SbkConverter *converter = Shiboken::Conversions::createConverter(pyType,
        AttributeFactory_PythonToCpp_AttributeFactory_PTR,
        is_AttributeFactory_PythonToCpp_AttributeFactory_PTR_Convertible,
        AttributeFactory_PTR_CppToPython_AttributeFactory);

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

    qRegisterMetaType< ::Akonadi::AttributeFactory *>();

    return pyType;
}
