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

#include "sipAPI_core.h"




extern "C" {static void assign_wxMemoryBuffer(void *, Py_ssize_t, void *);}
static void assign_wxMemoryBuffer(void *sipDst, Py_ssize_t sipDstIdx, void *sipSrc)
{
    reinterpret_cast<::wxMemoryBuffer *>(sipDst)[sipDstIdx] = *reinterpret_cast<::wxMemoryBuffer *>(sipSrc);
}


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


extern "C" {static void *copy_wxMemoryBuffer(const void *, Py_ssize_t);}
static void *copy_wxMemoryBuffer(const void *sipSrc, Py_ssize_t sipSrcIdx)
{
    return new ::wxMemoryBuffer(reinterpret_cast<const ::wxMemoryBuffer *>(sipSrc)[sipSrcIdx]);
}


/* Call the mapped type's destructor. */
extern "C" {static void release_wxMemoryBuffer(void *, int);}
static void release_wxMemoryBuffer(void *sipCppV, int)
{
    ::wxMemoryBuffer *sipCpp = reinterpret_cast<::wxMemoryBuffer *>(sipCppV);
    Py_BEGIN_ALLOW_THREADS
    delete sipCpp;
    Py_END_ALLOW_THREADS
}



extern "C" {static int convertTo_wxMemoryBuffer(PyObject *, void **, int *, PyObject *);}
static int convertTo_wxMemoryBuffer(PyObject *sipPy, void **sipCppPtrV, int *sipIsErr, PyObject *sipTransferObj)
{
    ::wxMemoryBuffer **sipCppPtr = reinterpret_cast<::wxMemoryBuffer **>(sipCppPtrV);
        // Code to test a PyObject for compatibility
        if (!sipIsErr) {
            if (PyObject_CheckBuffer(sipPy))
                return TRUE;
            return FALSE;
        }

        // Code to create a new wxMemoryBuffer from the PyObject
        wxPyBuffer pybuf;
        pybuf.create(sipPy);
        wxMemoryBuffer* buf = new wxMemoryBuffer(pybuf.m_len);
        buf->AppendData(pybuf.m_ptr, pybuf.m_len);
        *sipCppPtr = buf;
        return sipGetState(sipTransferObj);
}


extern "C" {static PyObject *convertFrom_wxMemoryBuffer(void *, PyObject *);}
static PyObject *convertFrom_wxMemoryBuffer(void *sipCppV, PyObject *)
{
    ::wxMemoryBuffer *sipCpp = reinterpret_cast<::wxMemoryBuffer *>(sipCppV);
        return wxPyMakeBuffer(sipCpp->GetData(), sipCpp->GetDataLen());
}


sipMappedTypeDef sipTypeDef__core_wxMemoryBuffer = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_MAPPED,
        sipNameNr_wxMemoryBuffer,
        SIP_NULLPTR,
        SIP_NULLPTR,
    },
    {
        -1,
        {0, 0, 1},
        0, SIP_NULLPTR,
        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}
    },
    assign_wxMemoryBuffer,
    array_wxMemoryBuffer,
    copy_wxMemoryBuffer,
    release_wxMemoryBuffer,
    convertTo_wxMemoryBuffer,
    convertFrom_wxMemoryBuffer
};
