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

#include "sipAPI_core.h"

        

        #include <wx/gdicmn.h>
        
        class wxPointList_iterator {
        public:
            wxPointList_iterator(wxPointList::compatibility_iterator start)
                : m_node(start) {}

            wxPoint* __next__() {
                wxPoint* obj = NULL;
                if (m_node) {
                    obj = (wxPoint*) m_node->GetData();
                    m_node = m_node->GetNext();
                }
                else {
                    PyErr_SetString(PyExc_StopIteration, "");
                }
                return (wxPoint*)obj;
            }
        private:
            wxPointList::compatibility_iterator m_node;
        };


PyDoc_STRVAR(doc_wxPointList_index, "index(self, obj: Point) -> int");

extern "C" {static PyObject *meth_wxPointList_index(PyObject *, PyObject *, PyObject *);}
static PyObject *meth_wxPointList_index(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = SIP_NULLPTR;

    {
         ::wxPoint* obj;
        int objState = 0;
         ::wxPointList *sipCpp;

        static const char *sipKwdList[] = {
            sipName_obj,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BJ0", &sipSelf, sipType_wxPointList, &sipCpp, sipType_wxPoint, &obj, &objState))
        {
            int sipRes = 0;
            sipErrorState sipError = sipErrorNone;

        int idx = sipCpp->IndexOf((wxPoint*)obj);
        if (idx == wxNOT_FOUND) {
            sipError = sipErrorFail;
            wxPyErr_SetString(PyExc_ValueError,
                              "sequence.index(x): x not in sequence");
        }
        sipRes = idx;
            sipReleaseType(obj,sipType_wxPoint,objState);

            if (sipError == sipErrorFail)
                return 0;

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

            sipAddException(sipError, &sipParseErr);
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_PointList, sipName_index, doc_wxPointList_index);

    return SIP_NULLPTR;
}


extern "C" {static PyObject *slot_wxPointList___iter__(PyObject *);}
static PyObject *slot_wxPointList___iter__(PyObject *sipSelf)
{
     ::wxPointList *sipCpp = reinterpret_cast< ::wxPointList *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_wxPointList));

    if (!sipCpp)
        return SIP_NULLPTR;


    {
        {
             ::wxPointList_iterator*sipRes = 0;

        sipRes =  new wxPointList_iterator(sipCpp->GetFirst());

            return sipConvertFromNewType(sipRes,sipType_wxPointList_iterator,SIP_NULLPTR);
        }
    }

    return 0;
}


extern "C" {static int slot_wxPointList___contains__(PyObject *,PyObject *);}
static int slot_wxPointList___contains__(PyObject *sipSelf,PyObject *sipArg)
{
     ::wxPointList *sipCpp = reinterpret_cast< ::wxPointList *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_wxPointList));

    if (!sipCpp)
        return -1;

    PyObject *sipParseErr = SIP_NULLPTR;

    {
        const  ::wxPoint* obj;
        int objState = 0;

        if (sipParseArgs(&sipParseErr, sipArg, "1J0", sipType_wxPoint, &obj, &objState))
        {
            int sipRes = 0;

        wxPointList::compatibility_iterator node;
        node = sipCpp->Find((wxPoint*)obj);
        sipRes = node != NULL;
            sipReleaseType(const_cast< ::wxPoint *>(obj),sipType_wxPoint,objState);

            return sipRes;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_PointList, sipName___contains__, SIP_NULLPTR);

    return -1;
}


extern "C" {static PyObject *slot_wxPointList___getitem__(PyObject *,PyObject *);}
static PyObject *slot_wxPointList___getitem__(PyObject *sipSelf,PyObject *sipArg)
{
     ::wxPointList *sipCpp = reinterpret_cast< ::wxPointList *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_wxPointList));

    if (!sipCpp)
        return SIP_NULLPTR;

    PyObject *sipParseErr = SIP_NULLPTR;

    {
        long index;

        if (sipParseArgs(&sipParseErr, sipArg, "1l", &index))
        {
             ::wxPoint*sipRes = 0;
            sipErrorState sipError = sipErrorNone;

        if (0 > index)
            index += sipCpp->size();

        if (index < sipCpp->size() && (0 <= index)) {
            wxPointList::compatibility_iterator node = sipCpp->Item(index);
            if (node)
                sipRes = (wxPoint*)node->GetData();
        }
        else {
            wxPyErr_SetString(PyExc_IndexError, "sequence index out of range");
            sipError = sipErrorFail;
        }

            if (sipError == sipErrorFail)
                return 0;

            if (sipError == sipErrorNone)
            {
            return sipConvertFromType(sipRes,sipType_wxPoint,SIP_NULLPTR);
            }

            sipAddException(sipError, &sipParseErr);
        }
    }

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

    return SIP_NULLPTR;
}


extern "C" {static SIP_SSIZE_T slot_wxPointList___len__(PyObject *);}
static SIP_SSIZE_T slot_wxPointList___len__(PyObject *sipSelf)
{
     ::wxPointList *sipCpp = reinterpret_cast< ::wxPointList *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_wxPointList));

    if (!sipCpp)
        return 0;


    {
        {
            SIP_SSIZE_T sipRes = 0;

        sipRes = sipCpp->size();

            return sipRes;
        }
    }

    return 0;
}


/* Call the instance's destructor. */
extern "C" {static void release_wxPointList(void *, int);}
static void release_wxPointList(void *sipCppV, int)
{
    Py_BEGIN_ALLOW_THREADS

    delete reinterpret_cast< ::wxPointList *>(sipCppV);

    Py_END_ALLOW_THREADS
}


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


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


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


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


extern "C" {static void *init_type_wxPointList(sipSimpleWrapper *, PyObject *, PyObject *, PyObject **, PyObject **, PyObject **);}
static void *init_type_wxPointList(sipSimpleWrapper *, PyObject *sipArgs, PyObject *sipKwds, PyObject **sipUnused, PyObject **, PyObject **sipParseErr)
{
     ::wxPointList *sipCpp = SIP_NULLPTR;

    {
        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, SIP_NULLPTR, sipUnused, ""))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp = new  ::wxPointList();
            Py_END_ALLOW_THREADS

            return sipCpp;
        }
    }

    {
        const  ::wxPointList* a0;
        int a0State = 0;

        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, SIP_NULLPTR, sipUnused, "J1", sipType_wxPointList, &a0, &a0State))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp = new  ::wxPointList(*a0);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast< ::wxPointList *>(a0),sipType_wxPointList,a0State);

            return sipCpp;
        }
    }

    return SIP_NULLPTR;
}


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

    // Code to test a PyObject for compatibility
    if (!sipIsErr) {
        int success = TRUE;
        // is it already a wxPointList?
        if (sipCanConvertToType(sipPy, sipType_wxPointList, SIP_NO_CONVERTORS))
            return success;
        // otherwise ensure that it is a sequence
        if (! PySequence_Check(sipPy))
            success = FALSE;
        // ensure it is not a string or unicode object (they are sequences too)
        else if (PyBytes_Check(sipPy) || PyUnicode_Check(sipPy))
            success = FALSE;
        // ensure each item can be converted to wxPoint
        else {
            Py_ssize_t i, len = PySequence_Length(sipPy);
            for (i=0; i<len; i++) {
                PyObject* item = PySequence_ITEM(sipPy, i);
                if (!sipCanConvertToType(item, sipType_wxPoint, SIP_NOT_NONE)) {
                    Py_DECREF(item);
                    success = FALSE;
                    break;
                }
                Py_DECREF(item);
            }
        }
        if (!success)
            PyErr_SetString(PyExc_TypeError, "Sequence of wxPoint compatible objects expected.");
        return success;
    }

    // Is it already a wxPointList? Return the exiting instance if so
    if (sipCanConvertToType(sipPy, sipType_wxPointList, SIP_NO_CONVERTORS)) {
        *sipCppPtr = reinterpret_cast<wxPointList*>(
                     sipConvertToType(sipPy, sipType_wxPointList, NULL,
                                      SIP_NO_CONVERTORS, 0, sipIsErr));
        return 0;
    }

    // Create a new wxPointList and convert compatible PyObjects from the sequence
    wxPointList *list = new wxPointList;
    list->DeleteContents(true); // tell the list to take ownership of the items
    Py_ssize_t i, len = PySequence_Length(sipPy);
    for (i=0; i<len; i++) {
        int state;
        PyObject* pyItem = PySequence_ITEM(sipPy, i);
        wxPoint* cItem = reinterpret_cast<wxPoint*>(
                             sipConvertToType(pyItem, sipType_wxPoint,
                             NULL, 0, &state, sipIsErr));
        if (!state)  // a temporary was not created for us, make one now
            cItem = new wxPoint(*cItem);
        list->Append(cItem);
        Py_DECREF(pyItem);
    }
    *sipCppPtr = list;
    return SIP_TEMPORARY;
}


/* Define this type's Python slots. */
static sipPySlotDef slots_wxPointList[] = {
    {(void *)slot_wxPointList___iter__, iter_slot},
    {(void *)slot_wxPointList___contains__, contains_slot},
    {(void *)slot_wxPointList___getitem__, getitem_slot},
    {(void *)slot_wxPointList___len__, len_slot},
    {0, (sipPySlotType)0}
};


static PyMethodDef methods_wxPointList[] = {
    {SIP_MLNAME_CAST(sipName_index), SIP_MLMETH_CAST(meth_wxPointList_index), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxPointList_index)}
};

PyDoc_STRVAR(doc_wxPointList, "\1PointList()\n"
"PointList(PointList)");


sipClassTypeDef sipTypeDef__core_wxPointList = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_CLASS,
        sipNameNr_wxPointList,
        {SIP_NULLPTR},
        SIP_NULLPTR
    },
    {
        sipNameNr_PointList,
        {0, 0, 1},
        1, methods_wxPointList,
        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},
    },
    doc_wxPointList,
    -1,
    -1,
    SIP_NULLPTR,
    slots_wxPointList,
    init_type_wxPointList,
    SIP_NULLPTR,
    SIP_NULLPTR,
#if PY_MAJOR_VERSION >= 3
    SIP_NULLPTR,
    SIP_NULLPTR,
#else
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
#endif
    dealloc_wxPointList,
    assign_wxPointList,
    array_wxPointList,
    copy_wxPointList,
    release_wxPointList,
    SIP_NULLPTR,
    convertTo_wxPointList,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR
};
