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

#include "sipAPIgoldencheetah.h"

#line 59 "goldencheetah.sip"
#include "Bindings.h"
#line 12 "./sipgoldencheetahPythonDataSeries.cpp"

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


extern "C" {static int slot_PythonDataSeries___setitem__(PyObject *,PyObject *);}
static int slot_PythonDataSeries___setitem__(PyObject *sipSelf,PyObject *sipArgs)
{
     ::PythonDataSeries *sipCpp = reinterpret_cast< ::PythonDataSeries *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_PythonDataSeries));

    if (!sipCpp)
        return -1;

    PyObject *sipParseErr = NULL;

    {
        long a0;
        double a1;

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

#line 104 "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) {
                sipCpp->data[a0] = a1;
                RideFile *rideFile = sipCpp->rideFile;
                if (rideFile) {
                    RideFile::SeriesType seriesType = static_cast<RideFile::SeriesType>(sipCpp->seriesType);
                    rideFile->command->setPointValue(a0, seriesType, a1);
                    if (!rideFile->isDataPresent(seriesType)) rideFile->command->setDataPresent(seriesType, true);
                }
            } else {
                PyErr_SetString(PyExc_IndexError, "Index out of range");
                sipError = sipErrorFail;
            }
        }
#line 56 "./sipgoldencheetahPythonDataSeries.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_PythonDataSeries, sipName___setitem__, NULL);

    return -1;
}


extern "C" {static PyObject *slot_PythonDataSeries___getitem__(PyObject *,PyObject *);}
static PyObject *slot_PythonDataSeries___getitem__(PyObject *sipSelf,PyObject *sipArg)
{
     ::PythonDataSeries *sipCpp = reinterpret_cast< ::PythonDataSeries *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_PythonDataSeries));

    if (!sipCpp)
        return 0;

    PyObject *sipParseErr = NULL;

    {
        long a0;

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

#line 94 "goldencheetah.sip"
        if (a0 < 0) a0 += sipCpp->count;
        if (a0 >= 0 && a0 < sipCpp->count) {
            sipRes = sipCpp->data[a0];
        } else {
            PyErr_SetString(PyExc_IndexError, "Index out of range");
            sipError = sipErrorFail;
        }
#line 103 "./sipgoldencheetahPythonDataSeries.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_PythonDataSeries, sipName___getitem__, NULL);

    return 0;
}


extern "C" {static SIP_SSIZE_T slot_PythonDataSeries___len__(PyObject *);}
static SIP_SSIZE_T slot_PythonDataSeries___len__(PyObject *sipSelf)
{
     ::PythonDataSeries *sipCpp = reinterpret_cast< ::PythonDataSeries *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_PythonDataSeries));

    if (!sipCpp)
        return 0;


    {
        {
            SIP_SSIZE_T sipRes = 0;

#line 90 "goldencheetah.sip"
        sipRes = sipCpp->count;
#line 139 "./sipgoldencheetahPythonDataSeries.cpp"

            return sipRes;
        }
    }

    return 0;
}


extern "C" {static PyObject *slot_PythonDataSeries___str__(PyObject *);}
static PyObject *slot_PythonDataSeries___str__(PyObject *sipSelf)
{
     ::PythonDataSeries *sipCpp = reinterpret_cast< ::PythonDataSeries *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_PythonDataSeries));

    if (!sipCpp)
        return 0;


    {
        {
             ::QString*sipRes = 0;

#line 86 "goldencheetah.sip"
        sipRes = new QString(sipCpp->name);
#line 164 "./sipgoldencheetahPythonDataSeries.cpp"

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

    return 0;
}


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


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

#line 63 "goldencheetah.sip"
    sipBuffer->obj = sipSelf;
    sipBuffer->buf = (void*)sipCpp->data;
    sipBuffer->len = sipCpp->count * sizeof(double);
    sipBuffer->readonly = 0;
    sipBuffer->itemsize = sizeof(double);
    sipBuffer->format = (char*)"d";  // double
    sipBuffer->ndim = 1;
    sipBuffer->shape = &sipCpp->count;  // 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 204 "./sipgoldencheetahPythonDataSeries.cpp"

    return sipRes;
}
#endif


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


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


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


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


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


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

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

            return sipCpp;
        }
    }

    {
        const  ::PythonDataSeries* a0;

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

            return sipCpp;
        }
    }

    return NULL;
}


/* Define this type's Python slots. */
static sipPySlotDef slots_PythonDataSeries[] = {
    {(void *)slot_PythonDataSeries___setitem__, setitem_slot},
    {(void *)slot_PythonDataSeries___getitem__, getitem_slot},
    {(void *)slot_PythonDataSeries___len__, len_slot},
    {(void *)slot_PythonDataSeries___str__, str_slot},
    {0, (sipPySlotType)0}
};


sipClassTypeDef sipTypeDef_goldencheetah_PythonDataSeries = {
    {
        -1,
        0,
        0,
        SIP_TYPE_CLASS,
        sipNameNr_PythonDataSeries,
        {0},
        0
    },
    {
        sipNameNr_PythonDataSeries,
        {0, 0, 1},
        0, 0,
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    },
    0,
    -1,
    -1,
    0,
    slots_PythonDataSeries,
    init_type_PythonDataSeries,
    0,
    0,
#if PY_MAJOR_VERSION >= 3
    getbuffer_PythonDataSeries,
    releasebuffer_PythonDataSeries,
#else
    0,
    0,
    0,
    0,
#endif
    dealloc_PythonDataSeries,
    assign_PythonDataSeries,
    array_PythonDataSeries,
    copy_PythonDataSeries,
    release_PythonDataSeries,
    0,
    0,
    0,
    0,
    0,
    0,
    0
};
