/*
 * Interface wrapper code.
 *
 * Generated by SIP 4.19.24
 *
 *     Copyright: (c) 2020 by Total Control Software
 *     License:   wxWindows License
 */

#include "sipAPI_adv.h"

        #include <wx/sound.h>

        #include <wx/object.h>
        #include <wx/object.h>
        #include <wx/object.h>
    bool _wxSound_CreateFromData(wxSound* self, wxPyBuffer* data)
    {
        return self->Create((size_t)data->m_len, data->m_ptr);
    }
    int _wxSound___nonzero__(wxSound* self)
    {
        return self->IsOk();
    }
    int _wxSound___bool__(wxSound* self)
    {
        return self->IsOk();
    }


class sipwxSound : public  ::wxSound
{
public:
    sipwxSound();
    sipwxSound(const  ::wxString&);
    ~sipwxSound();

public:
    sipSimpleWrapper *sipPySelf;

private:
    sipwxSound(const sipwxSound &);
    sipwxSound &operator = (const sipwxSound &);
};

sipwxSound::sipwxSound():  ::wxSound(), sipPySelf(SIP_NULLPTR)
{
}

sipwxSound::sipwxSound(const  ::wxString& fileName):  ::wxSound(fileName), sipPySelf(SIP_NULLPTR)
{
}

sipwxSound::~sipwxSound()
{
    sipInstanceDestroyedEx(&sipPySelf);
}


PyDoc_STRVAR(doc_wxSound_Play, "Play(flags=SOUND_ASYNC) -> bool\n"
"\n"
"Plays the sound file.");

extern "C" {static PyObject *meth_wxSound_Play(PyObject *, PyObject *, PyObject *);}
static PyObject *meth_wxSound_Play(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = SIP_NULLPTR;

    {
        uint flags = wxSOUND_ASYNC;
        const  ::wxSound *sipCpp;

        static const char *sipKwdList[] = {
            sipName_flags,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "B|u", &sipSelf, sipType_wxSound, &sipCpp, &flags))
        {
            bool sipRes;

        if (!wxPyCheckForApp()) return NULL;

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipRes = sipCpp->Play(flags);
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
                return 0;

            return PyBool_FromLong(sipRes);
        }
    }

    sipNoMethod(sipParseErr, sipName_Sound, sipName_Play, SIP_NULLPTR);

    return SIP_NULLPTR;
}


PyDoc_STRVAR(doc_wxSound_PlaySound, "PlaySound(filename, flags=SOUND_ASYNC) -> bool\n"
"\n"
"Plays the sound file.");

extern "C" {static PyObject *meth_wxSound_PlaySound(PyObject *, PyObject *, PyObject *);}
static PyObject *meth_wxSound_PlaySound(PyObject *, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = SIP_NULLPTR;

    {
        const  ::wxString* filename;
        int filenameState = 0;
        uint flags = wxSOUND_ASYNC;

        static const char *sipKwdList[] = {
            sipName_filename,
            sipName_flags,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "J1|u", sipType_wxString,&filename, &filenameState, &flags))
        {
            bool sipRes;

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipRes =  ::wxSound::Play(*filename,flags);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast< ::wxString *>(filename),sipType_wxString,filenameState);

            if (PyErr_Occurred())
                return 0;

            return PyBool_FromLong(sipRes);
        }
    }

    sipNoMethod(sipParseErr, sipName_Sound, sipName_PlaySound, SIP_NULLPTR);

    return SIP_NULLPTR;
}


PyDoc_STRVAR(doc_wxSound_Create, "Create(fileName) -> bool\n"
"\n"
"Constructs a wave object from a file or resource.");

extern "C" {static PyObject *meth_wxSound_Create(PyObject *, PyObject *, PyObject *);}
static PyObject *meth_wxSound_Create(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = SIP_NULLPTR;

    {
        const  ::wxString* fileName;
        int fileNameState = 0;
         ::wxSound *sipCpp;

        static const char *sipKwdList[] = {
            sipName_fileName,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BJ1", &sipSelf, sipType_wxSound, &sipCpp, sipType_wxString,&fileName, &fileNameState))
        {
            bool sipRes;

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipRes = sipCpp->Create(*fileName);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast< ::wxString *>(fileName),sipType_wxString,fileNameState);

            if (PyErr_Occurred())
                return 0;

            return PyBool_FromLong(sipRes);
        }
    }

    sipNoMethod(sipParseErr, sipName_Sound, sipName_Create, SIP_NULLPTR);

    return SIP_NULLPTR;
}


PyDoc_STRVAR(doc_wxSound_IsOk, "IsOk() -> bool\n"
"\n"
"Returns true if the object contains a successfully loaded file or\n"
"resource, false otherwise.");

extern "C" {static PyObject *meth_wxSound_IsOk(PyObject *, PyObject *);}
static PyObject *meth_wxSound_IsOk(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = SIP_NULLPTR;

    {
        const  ::wxSound *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxSound, &sipCpp))
        {
            bool sipRes;

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipRes = sipCpp->IsOk();
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
                return 0;

            return PyBool_FromLong(sipRes);
        }
    }

    sipNoMethod(sipParseErr, sipName_Sound, sipName_IsOk, SIP_NULLPTR);

    return SIP_NULLPTR;
}


PyDoc_STRVAR(doc_wxSound_Stop, "Stop()\n"
"\n"
"If a sound is played, this function stops it.");

extern "C" {static PyObject *meth_wxSound_Stop(PyObject *, PyObject *);}
static PyObject *meth_wxSound_Stop(PyObject *, PyObject *sipArgs)
{
    PyObject *sipParseErr = SIP_NULLPTR;

    {
        if (sipParseArgs(&sipParseErr, sipArgs, ""))
        {

        if (!wxPyCheckForApp()) return NULL;
            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
             ::wxSound::Stop();
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
                return 0;

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    sipNoMethod(sipParseErr, sipName_Sound, sipName_Stop, SIP_NULLPTR);

    return SIP_NULLPTR;
}


PyDoc_STRVAR(doc_wxSound_CreateFromData, "CreateFromData(data) -> bool\n"
"\n"
"Create a sound object from data in a memory buffer in WAV format.");

extern "C" {static PyObject *meth_wxSound_CreateFromData(PyObject *, PyObject *, PyObject *);}
static PyObject *meth_wxSound_CreateFromData(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = SIP_NULLPTR;

    {
         ::wxPyBuffer* data;
        int dataState = 0;
         ::wxSound *sipCpp;

        static const char *sipKwdList[] = {
            sipName_data,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BJ0", &sipSelf, sipType_wxSound, &sipCpp, sipType_wxPyBuffer,&data, &dataState))
        {
            bool sipRes = 0;
            int sipIsErr = 0;

        PyErr_Clear();
        Py_BEGIN_ALLOW_THREADS
        sipRes = _wxSound_CreateFromData(sipCpp, data);
        Py_END_ALLOW_THREADS
        if (PyErr_Occurred()) sipIsErr = 1;
            sipReleaseType(data,sipType_wxPyBuffer,dataState);

            if (sipIsErr)
                return 0;

            return PyBool_FromLong(sipRes);
        }
    }

    sipNoMethod(sipParseErr, sipName_Sound, sipName_CreateFromData, SIP_NULLPTR);

    return SIP_NULLPTR;
}


extern "C" {static int slot_wxSound___bool__(PyObject *);}
static int slot_wxSound___bool__(PyObject *sipSelf)
{
     ::wxSound *sipCpp = reinterpret_cast< ::wxSound *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_wxSound));

    if (!sipCpp)
        return -1;


    {
        {
            int sipRes = 0;
            int sipIsErr = 0;

        PyErr_Clear();
        Py_BEGIN_ALLOW_THREADS
        sipRes = _wxSound___bool__(sipCpp);
        Py_END_ALLOW_THREADS
        if (PyErr_Occurred()) sipIsErr = 1;

            if (sipIsErr)
                return -1;

            return sipRes;
        }
    }

    return 0;
}


extern "C" {static int slot_wxSound___nonzero__(PyObject *);}
static int slot_wxSound___nonzero__(PyObject *sipSelf)
{
     ::wxSound *sipCpp = reinterpret_cast< ::wxSound *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_wxSound));

    if (!sipCpp)
        return -1;


    {
        {
            int sipRes = 0;
            int sipIsErr = 0;

        PyErr_Clear();
        Py_BEGIN_ALLOW_THREADS
        sipRes = _wxSound___nonzero__(sipCpp);
        Py_END_ALLOW_THREADS
        if (PyErr_Occurred()) sipIsErr = 1;

            if (sipIsErr)
                return -1;

            return sipRes;
        }
    }

    return 0;
}


/* Cast a pointer to a type somewhere in its inheritance hierarchy. */
extern "C" {static void *cast_wxSound(void *, const sipTypeDef *);}
static void *cast_wxSound(void *sipCppV, const sipTypeDef *targetType)
{
     ::wxSound *sipCpp = reinterpret_cast< ::wxSound *>(sipCppV);

    if (targetType == sipType_wxObject)
        return static_cast< ::wxObject *>(sipCpp);

    return sipCppV;
}


/* Call the instance's destructor. */
extern "C" {static void release_wxSound(void *, int);}
static void release_wxSound(void *sipCppV, int sipState)
{
    Py_BEGIN_ALLOW_THREADS

    if (sipState & SIP_DERIVED_CLASS)
        delete reinterpret_cast<sipwxSound *>(sipCppV);
    else
        delete reinterpret_cast< ::wxSound *>(sipCppV);

    Py_END_ALLOW_THREADS
}


extern "C" {static void *array_wxSound(Py_ssize_t);}
static void *array_wxSound(Py_ssize_t sipNrElem)
{
    return new  ::wxSound[sipNrElem];
}


extern "C" {static void dealloc_wxSound(sipSimpleWrapper *);}
static void dealloc_wxSound(sipSimpleWrapper *sipSelf)
{
    if (sipIsDerivedClass(sipSelf))
        reinterpret_cast<sipwxSound *>(sipGetAddress(sipSelf))->sipPySelf = SIP_NULLPTR;

    if (sipIsOwnedByPython(sipSelf))
    {
        release_wxSound(sipGetAddress(sipSelf), sipIsDerivedClass(sipSelf));
    }
}


extern "C" {static void *init_type_wxSound(sipSimpleWrapper *, PyObject *, PyObject *, PyObject **, PyObject **, PyObject **);}
static void *init_type_wxSound(sipSimpleWrapper *sipSelf, PyObject *sipArgs, PyObject *sipKwds, PyObject **sipUnused, PyObject **, PyObject **sipParseErr)
{
    sipwxSound *sipCpp = SIP_NULLPTR;

    {
        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, SIP_NULLPTR, sipUnused, ""))
        {

        if (!wxPyCheckForApp()) return NULL;

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipCpp = new sipwxSound();
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
            {
                delete sipCpp;
                return SIP_NULLPTR;
            }

            sipCpp->sipPySelf = sipSelf;

            return sipCpp;
        }
    }

    {
        const  ::wxString* fileName;
        int fileNameState = 0;

        static const char *sipKwdList[] = {
            sipName_fileName,
        };

        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, sipKwdList, sipUnused, "J1", sipType_wxString,&fileName, &fileNameState))
        {

        if (!wxPyCheckForApp()) return NULL;

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipCpp = new sipwxSound(*fileName);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast< ::wxString *>(fileName),sipType_wxString,fileNameState);

            if (PyErr_Occurred())
            {
                delete sipCpp;
                return SIP_NULLPTR;
            }

            sipCpp->sipPySelf = sipSelf;

            return sipCpp;
        }
    }

    return SIP_NULLPTR;
}


/* Define this type's super-types. */
static sipEncodedTypeDef supers_wxSound[] = {{39, 0, 1}};


/* Define this type's Python slots. */
static sipPySlotDef slots_wxSound[] = {
    {(void *)slot_wxSound___bool__, bool_slot},
    {(void *)slot_wxSound___nonzero__, bool_slot},
    {0, (sipPySlotType)0}
};


static PyMethodDef methods_wxSound[] = {
    {SIP_MLNAME_CAST(sipName_Create), SIP_MLMETH_CAST(meth_wxSound_Create), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxSound_Create)},
    {SIP_MLNAME_CAST(sipName_CreateFromData), SIP_MLMETH_CAST(meth_wxSound_CreateFromData), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxSound_CreateFromData)},
    {SIP_MLNAME_CAST(sipName_IsOk), meth_wxSound_IsOk, METH_VARARGS, SIP_MLDOC_CAST(doc_wxSound_IsOk)},
    {SIP_MLNAME_CAST(sipName_Play), SIP_MLMETH_CAST(meth_wxSound_Play), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxSound_Play)},
    {SIP_MLNAME_CAST(sipName_PlaySound), SIP_MLMETH_CAST(meth_wxSound_PlaySound), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxSound_PlaySound)},
    {SIP_MLNAME_CAST(sipName_Stop), meth_wxSound_Stop, METH_VARARGS, SIP_MLDOC_CAST(doc_wxSound_Stop)}
};

PyDoc_STRVAR(doc_wxSound, "Sound()\n"
"Sound(fileName)\n"
"\n"
"This class represents a short sound (loaded from Windows WAV file),\n"
"that can be stored in memory and played.");


sipClassTypeDef sipTypeDef__adv_wxSound = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_SCC|SIP_TYPE_CLASS,
        sipNameNr_wxSound,
        {SIP_NULLPTR},
        SIP_NULLPTR
    },
    {
        sipNameNr_Sound,
        {0, 0, 1},
        6, methods_wxSound,
        0, SIP_NULLPTR,
        0, SIP_NULLPTR,
        {SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR},
    },
    doc_wxSound,
    -1,
    -1,
    supers_wxSound,
    slots_wxSound,
    init_type_wxSound,
    SIP_NULLPTR,
    SIP_NULLPTR,
#if PY_MAJOR_VERSION >= 3
    SIP_NULLPTR,
    SIP_NULLPTR,
#else
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
#endif
    dealloc_wxSound,
    SIP_NULLPTR,
    array_wxSound,
    SIP_NULLPTR,
    release_wxSound,
    cast_wxSound,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR
};
