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

// main header
#include "kpassword_wrapper.h"

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


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

extern "C" {
static int Sbk_KPassword_Init(PyObject *, PyObject *, PyObject *)
{
    Shiboken::Errors::setInstantiateNamespace("KPassword");
    return -1;
}


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

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

static PyMethodDef Sbk_KPassword_methods[] = {
    {nullptr, nullptr, 0, nullptr} // Sentinel
};

} // extern "C"

static int Sbk_KPassword_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_KPassword_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_KPassword_slots[] = {
    {Py_tp_base,        nullptr}, // inserted by introduceWrapperType
    {Py_tp_dealloc,     reinterpret_cast<void *>(Sbk_object_dealloc /* PYSIDE-832: Prevent replacement of "0" with subtype_dealloc. */)},
    {Py_tp_traverse,    reinterpret_cast<void *>(Sbk_KPassword_traverse)},
    {Py_tp_clear,       reinterpret_cast<void *>(Sbk_KPassword_clear)},
    {Py_tp_methods,     reinterpret_cast<void *>(Sbk_KPassword_methods)},
    {Py_tp_init,        reinterpret_cast<void *>(Sbk_KPassword_Init)},
    {Py_tp_new,         reinterpret_cast<void *>(SbkDummyNew /* PYSIDE-595: Prevent replacement of "0" with base->tp_new. */)},
    {0, nullptr}
};
static PyType_Spec Sbk_KPassword_spec = {
    "1:KWidgetsAddons.KPassword",
    sizeof(SbkObject),
    0,
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC,
    Sbk_KPassword_slots
};

} //extern "C"

// Type conversion functions.

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

}
static PythonToCppFunc is_Enum_PythonToCpp_KPassword_RevealMode_Convertible(PyObject *pyIn)
{
    if (PyObject_TypeCheck(pyIn, Shiboken::Module::get(SbkKWidgetsAddonsTypeStructs[SBK_KPassword_RevealMode_IDX])))
        return Enum_PythonToCpp_KPassword_RevealMode;
    return {};
}

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

}

// The signatures string for the functions.
// Multiple signatures have their index "n:" in front.
#if PYSIDE6_COMOPT_COMPRESS == 0
static const char *KWidgetsAddonsKPassword_SignatureStrings[] = {
    nullptr}; // Sentinel
#else
static constexpr size_t KWidgetsAddonsKPassword_SignatureByteSize = 0;
static constexpr uint8_t KWidgetsAddonsKPassword_SignatureBytes[1] = {
    0x00
};
#endif

PyTypeObject *init_KWidgetsAddonsKPassword(PyObject *module)
{
    auto &typeStruct = SbkKWidgetsAddonsTypeStructs[SBK_KWidgetsAddonsKPassword_IDX];
    if (typeStruct.type != nullptr)
        return typeStruct.type;

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

    PyTypeObject *pyType = Shiboken::ObjectType::introduceWrapperType(
        module,
        "KPassword",
        "KPassword",
        &Sbk_KPassword_spec,
        nullptr,
        Sbk_KPassword_Type_bases.object(),
        0);
#if PYSIDE6_COMOPT_COMPRESS == 0
    InitSignatureStrings(pyType, KWidgetsAddonsKPassword_SignatureStrings);
#else
    InitSignatureBytes(pyType, KWidgetsAddonsKPassword_SignatureBytes, KWidgetsAddonsKPassword_SignatureByteSize);
#endif
    SbkObjectType_SetPropertyStrings(pyType, Sbk_KPassword_PropertyStrings);
    typeStruct.type = pyType;


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

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

    // Initialization of enum 'RevealMode'.
    const char *RevealMode_Initializer[] = {
        "OnlyNew",
        "Never",
        "Always",
        nullptr};
    // "int8_t" used instead of "int"
    constexpr int8_t RevealMode_InitializerValues[] = {
        int8_t(KPassword::RevealMode::OnlyNew), //  0x00  0
        int8_t(KPassword::RevealMode::Never),   //  0x01  1
        int8_t(KPassword::RevealMode::Always)   //  0x02  2
        };
    EType = Shiboken::Enum::createPythonEnum(pyType,
        "1:KWidgetsAddons.KPassword.RevealMode",
        RevealMode_Initializer, RevealMode_InitializerValues);
    SbkKWidgetsAddonsTypeStructs[SBK_KPassword_RevealMode_IDX].type = EType;
    // Register converter for enum 'KPassword::RevealMode'.
    {
        SbkConverter *converter = Shiboken::Conversions::createConverter(EType,
            KPassword_RevealMode_CppToPython_Enum);
        Shiboken::Conversions::addPythonToCppValueConversion(converter,
            Enum_PythonToCpp_KPassword_RevealMode,
            is_Enum_PythonToCpp_KPassword_RevealMode_Convertible);
        Shiboken::Conversions::registerConverterName(converter, "KPassword::RevealMode");
        Shiboken::Conversions::registerConverterAlias(converter, "RevealMode");
        Shiboken::Enum::setTypeConverter(EType, converter, nullptr);
    }
    // End of 'RevealMode' enum.

    qRegisterMetaType< ::KPassword::RevealMode >("KPassword::RevealMode");

    return pyType;
}
