/*
 * Interface wrapper code.
 *
 * Generated by SIP 4.19.8
 */

#include "sipAPIgoldencheetah.h"

#line 244 "goldencheetah.sip"
#include "Bindings.h"
#line 12 "./sipgoldencheetahPythonXDataSeries.cpp"

#line 28 "goldencheetah.sip"
#include <qstring.h>
#line 16 "./sipgoldencheetahPythonXDataSeries.cpp"


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

    {
        double a0;
         ::PythonXDataSeries *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "Bd", &sipSelf, sipType_PythonXDataSeries, &sipCpp, &a0))
        {
            sipErrorState sipError = sipErrorNone;

#line 306 "goldencheetah.sip"
        if (sipCpp->readOnly) {
            PyErr_SetString(PyExc_AttributeError, "Object is read-only");
            sipError = sipErrorFail;
        } else {
            if (!sipCpp->add(a0)) {
                PyErr_SetString(PyExc_RuntimeError, "XData series does not exist");
            }
        }
#line 41 "./sipgoldencheetahPythonXDataSeries.cpp"

            if (sipError == sipErrorFail)
                return 0;

            if (sipError == sipErrorNone)
            {
            Py_INCREF(Py_None);
            return Py_None;
            }

            sipAddException(sipError, &sipParseErr);
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_PythonXDataSeries, sipName_append, NULL);

    return NULL;
}


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

    {
        long a0;
         ::PythonXDataSeries *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "Bl", &sipSelf, sipType_PythonXDataSeries, &sipCpp, &a0))
        {
            sipErrorState sipError = sipErrorNone;

#line 317 "goldencheetah.sip"
        if (sipCpp->readOnly) {
            PyErr_SetString(PyExc_AttributeError, "Object is read-only");
            sipError = sipErrorFail;
        } else {
            if (!sipCpp->remove(a0)) {
                PyErr_SetString(PyExc_RuntimeError, "XData series does not exist");
            }
        }
#line 85 "./sipgoldencheetahPythonXDataSeries.cpp"

            if (sipError == sipErrorFail)
                return 0;

            if (sipError == sipErrorNone)
            {
            Py_INCREF(Py_None);
            return Py_None;
            }

            sipAddException(sipError, &sipParseErr);
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_PythonXDataSeries, sipName_remove, NULL);

    return NULL;
}


extern "C" {static int slot_PythonXDataSeries___setitem__(PyObject *,PyObject *);}
static int slot_PythonXDataSeries___setitem__(PyObject *sipSelf,PyObject *sipArgs)
{
     ::PythonXDataSeries *sipCpp = reinterpret_cast< ::PythonXDataSeries *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_PythonXDataSeries));

    if (!sipCpp)
        return -1;

    PyObject *sipParseErr = NULL;

    {
        long a0;
        double a1;

        if (sipParseArgs(&sipParseErr, sipArgs, "ld", &a0, &a1))
        {
            sipErrorState sipError = sipErrorNone;

#line 289 "goldencheetah.sip"
        if (sipCpp->readOnly) {
            PyErr_SetString(PyExc_AttributeError, "Object is read-only");
            sipError = sipErrorFail;
        } else {
            if (a0 < 0) a0 += sipCpp->count();
            if (a0 >= 0 && a0 < sipCpp->count()) {
                if (!sipCpp->set(a0, a1)) {
                    PyErr_SetString(PyExc_RuntimeError, "XData series does not exist");
                }
            } else {
                PyErr_SetString(PyExc_IndexError, "Index out of range");
                sipError = sipErrorFail;
            }
        }
#line 140 "./sipgoldencheetahPythonXDataSeries.cpp"

            if (sipError == sipErrorFail)
                return -1;

            if (sipError == sipErrorNone)
            {
            return 0;
            }

            sipAddException(sipError, &sipParseErr);
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_PythonXDataSeries, sipName___setitem__, NULL);

    return -1;
}


extern "C" {static PyObject *slot_PythonXDataSeries___getitem__(PyObject *,PyObject *);}
static PyObject *slot_PythonXDataSeries___getitem__(PyObject *sipSelf,PyObject *sipArg)
{
     ::PythonXDataSeries *sipCpp = reinterpret_cast< ::PythonXDataSeries *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_PythonXDataSeries));

    if (!sipCpp)
        return 0;

    PyObject *sipParseErr = NULL;

    {
        long a0;

        if (sipParseArgs(&sipParseErr, sipArg, "1l", &a0))
        {
            double sipRes = 0;
            sipErrorState sipError = sipErrorNone;

#line 279 "goldencheetah.sip"
        if (a0 < 0) a0 += sipCpp->count();
        if (a0 >= 0 && a0 < sipCpp->count()) {
            sipRes = sipCpp->get(a0);
        } else {
            PyErr_SetString(PyExc_IndexError, "Index out of range");
            sipError = sipErrorFail;
        }
#line 187 "./sipgoldencheetahPythonXDataSeries.cpp"

            if (sipError == sipErrorFail)
                return 0;

            if (sipError == sipErrorNone)
            {
            return PyFloat_FromDouble(sipRes);
            }

            sipAddException(sipError, &sipParseErr);
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_PythonXDataSeries, sipName___getitem__, NULL);

    return 0;
}


extern "C" {static SIP_SSIZE_T slot_PythonXDataSeries___len__(PyObject *);}
static SIP_SSIZE_T slot_PythonXDataSeries___len__(PyObject *sipSelf)
{
     ::PythonXDataSeries *sipCpp = reinterpret_cast< ::PythonXDataSeries *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_PythonXDataSeries));

    if (!sipCpp)
        return 0;


    {
        {
            SIP_SSIZE_T sipRes = 0;

#line 275 "goldencheetah.sip"
        sipRes = sipCpp->count();
#line 223 "./sipgoldencheetahPythonXDataSeries.cpp"

            return sipRes;
        }
    }

    return 0;
}


extern "C" {static PyObject *slot_PythonXDataSeries___str__(PyObject *);}
static PyObject *slot_PythonXDataSeries___str__(PyObject *sipSelf)
{
     ::PythonXDataSeries *sipCpp = reinterpret_cast< ::PythonXDataSeries *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_PythonXDataSeries));

    if (!sipCpp)
        return 0;


    {
        {
             ::QString*sipRes = 0;

#line 271 "goldencheetah.sip"
        sipRes = new QString(sipCpp->name());
#line 248 "./sipgoldencheetahPythonXDataSeries.cpp"

            return sipConvertFromNewType(sipRes,sipType_QString,NULL);
        }
    }

    return 0;
}


/* Call the instance's destructor. */
extern "C" {static void release_PythonXDataSeries(void *, int);}
static void release_PythonXDataSeries(void *sipCppV, int)
{
    delete reinterpret_cast< ::PythonXDataSeries *>(sipCppV);
}


#if PY_MAJOR_VERSION >= 3
extern "C" {static int getbuffer_PythonXDataSeries(PyObject *, void *, Py_buffer *, int);}
static int getbuffer_PythonXDataSeries(PyObject *sipSelf, void *sipCppV, Py_buffer *sipBuffer, int )
{
     ::PythonXDataSeries *sipCpp = reinterpret_cast< ::PythonXDataSeries *>(sipCppV);
    int sipRes;

#line 248 "goldencheetah.sip"
    sipBuffer->obj = sipSelf;
    sipBuffer->buf = sipCpp->rawDataPtr();
    sipBuffer->len = sipCpp->count() * sizeof(double);
    sipBuffer->readonly = 0;
    sipBuffer->itemsize = sizeof(double);
    sipBuffer->format = (char*)"d";  // double
    sipBuffer->ndim = 1;
    sipBuffer->shape = sipCpp->shape.data();  // length-1 sequence of dimensions
    sipBuffer->strides = &sipBuffer->itemsize;  // for the simple case we can do this
    sipBuffer->suboffsets = NULL;
    sipBuffer->internal = NULL;

    Py_INCREF(sipSelf);  // need to increase the reference count
    sipRes = 0;
#line 288 "./sipgoldencheetahPythonXDataSeries.cpp"

    return sipRes;
}
#endif


#if PY_MAJOR_VERSION >= 3
extern "C" {static void releasebuffer_PythonXDataSeries(PyObject *, void *, Py_buffer *);}
static void releasebuffer_PythonXDataSeries(PyObject *, void *, Py_buffer *)
{
#line 265 "goldencheetah.sip"
    // we do not require any special release function
#line 301 "./sipgoldencheetahPythonXDataSeries.cpp"
}
#endif


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


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


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


extern "C" {static void dealloc_PythonXDataSeries(sipSimpleWrapper *);}
static void dealloc_PythonXDataSeries(sipSimpleWrapper *sipSelf)
{
    if (sipIsOwnedByPython(sipSelf))
    {
        release_PythonXDataSeries(sipGetAddress(sipSelf), 0);
    }
}


extern "C" {static void *init_type_PythonXDataSeries(sipSimpleWrapper *, PyObject *, PyObject *, PyObject **, PyObject **, PyObject **);}
static void *init_type_PythonXDataSeries(sipSimpleWrapper *, PyObject *sipArgs, PyObject *sipKwds, PyObject **sipUnused, PyObject **, PyObject **sipParseErr)
{
     ::PythonXDataSeries *sipCpp = 0;

    {
        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, NULL, sipUnused, ""))
        {
            sipCpp = new  ::PythonXDataSeries();

            return sipCpp;
        }
    }

    {
        const  ::PythonXDataSeries* a0;

        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, NULL, sipUnused, "J9", sipType_PythonXDataSeries, &a0))
        {
            sipCpp = new  ::PythonXDataSeries(*a0);

            return sipCpp;
        }
    }

    return NULL;
}


/* Define this type's Python slots. */
static sipPySlotDef slots_PythonXDataSeries[] = {
    {(void *)slot_PythonXDataSeries___setitem__, setitem_slot},
    {(void *)slot_PythonXDataSeries___getitem__, getitem_slot},
    {(void *)slot_PythonXDataSeries___len__, len_slot},
    {(void *)slot_PythonXDataSeries___str__, str_slot},
    {0, (sipPySlotType)0}
};


static PyMethodDef methods_PythonXDataSeries[] = {
    {SIP_MLNAME_CAST(sipName_append), meth_PythonXDataSeries_append, METH_VARARGS, NULL},
    {SIP_MLNAME_CAST(sipName_remove), meth_PythonXDataSeries_remove, METH_VARARGS, NULL}
};


sipClassTypeDef sipTypeDef_goldencheetah_PythonXDataSeries = {
    {
        -1,
        0,
        0,
        SIP_TYPE_CLASS,
        sipNameNr_PythonXDataSeries,
        {0},
        0
    },
    {
        sipNameNr_PythonXDataSeries,
        {0, 0, 1},
        2, methods_PythonXDataSeries,
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    },
    0,
    -1,
    -1,
    0,
    slots_PythonXDataSeries,
    init_type_PythonXDataSeries,
    0,
    0,
#if PY_MAJOR_VERSION >= 3
    getbuffer_PythonXDataSeries,
    releasebuffer_PythonXDataSeries,
#else
    0,
    0,
    0,
    0,
#endif
    dealloc_PythonXDataSeries,
    assign_PythonXDataSeries,
    array_PythonXDataSeries,
    copy_PythonXDataSeries,
    release_PythonXDataSeries,
    0,
    0,
    0,
    0,
    0,
    0,
    0
};
