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

#include "sipAPI_core.h"




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


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


extern "C" {static void *copy_wxMemoryBuffer(const void *, SIP_SSIZE_T);}
static void *copy_wxMemoryBuffer(const void *sipSrc, SIP_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 *ptr, int)
{
    Py_BEGIN_ALLOW_THREADS
    delete reinterpret_cast< ::wxMemoryBuffer *>(ptr);
    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,
        0,
        SIP_TYPE_MAPPED,
        sipNameNr_wxMemoryBuffer,     /* wxMemoryBuffer */
        {0},
        0
    },
    {
        -1,
        {0, 0, 1},
        0, 0,
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    assign_wxMemoryBuffer,
    array_wxMemoryBuffer,
    copy_wxMemoryBuffer,
    release_wxMemoryBuffer,
    convertTo_wxMemoryBuffer,
    convertFrom_wxMemoryBuffer
};
