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

#include "sipAPI_core.h"




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


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


extern "C" {static void *copy_wxCharBuffer(const void *, SIP_SSIZE_T);}
static void *copy_wxCharBuffer(const void *sipSrc, SIP_SSIZE_T sipSrcIdx)
{
    return new  ::wxCharBuffer(reinterpret_cast<const  ::wxCharBuffer *>(sipSrc)[sipSrcIdx]);
}


/* Call the mapped type's destructor. */
extern "C" {static void release_wxCharBuffer(void *, int);}
static void release_wxCharBuffer(void *ptr, int)
{
    Py_BEGIN_ALLOW_THREADS
    delete reinterpret_cast< ::wxCharBuffer *>(ptr);
    Py_END_ALLOW_THREADS
}



extern "C" {static int convertTo_wxCharBuffer(PyObject *, void **, int *, PyObject *);}
static int convertTo_wxCharBuffer(PyObject *sipPy,void **sipCppPtrV,int *sipIsErr,PyObject *sipTransferObj)
{
     ::wxCharBuffer **sipCppPtr = reinterpret_cast< ::wxCharBuffer **>(sipCppPtrV);

        // Code to test a PyObject for compatibility
        if (!sipIsErr) {
            if (PyBytes_Check(sipPy))
                return TRUE;
            return FALSE;
        }

        // Code to create a new wxCharBuffer from the PyObject
        char* bbuf;
        Py_ssize_t blen;
        PyBytes_AsStringAndSize(sipPy, &bbuf, &blen);
        wxCharBuffer* cbuf = new wxCharBuffer(blen);
        memcpy(cbuf->data(), bbuf, blen);
        *sipCppPtr = cbuf;
        return sipGetState(sipTransferObj);
}


extern "C" {static PyObject *convertFrom_wxCharBuffer(void *, PyObject *);}
static PyObject *convertFrom_wxCharBuffer(void *sipCppV, PyObject *)
{
    ::wxCharBuffer *sipCpp = reinterpret_cast< ::wxCharBuffer *>(sipCppV);

        return PyBytes_FromStringAndSize(sipCpp->data(), sipCpp->length());
}


sipMappedTypeDef sipTypeDef__core_wxCharBuffer = {
    {
        -1,
        SIP_NULLPTR,
        0,
        SIP_TYPE_MAPPED,
        sipNameNr_wxCharBuffer,     /* wxCharBuffer */
        {0},
        0
    },
    {
        -1,
        {0, 0, 1},
        0, 0,
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    assign_wxCharBuffer,
    array_wxCharBuffer,
    copy_wxCharBuffer,
    release_wxCharBuffer,
    convertTo_wxCharBuffer,
    convertFrom_wxCharBuffer
};
