+
+
+
+wxPoint2D* wxPoint2D_LIST_helper(PyObject* source, size_t *count)
+{
+ size_t idx;
+ wxPoint2D* temp;
+ PyObject *o, *o1, *o2;
+ bool isFast = PyList_Check(source) || PyTuple_Check(source);
+
+ if (!PySequence_Check(source)) {
+ goto error0;
+ }
+
+ // The length of the sequence is returned in count.
+ *count = PySequence_Length(source);
+ if (*count < 0) {
+ goto error0;
+ }
+
+ temp = new wxPoint2D[*count];
+ if (!temp) {
+ PyErr_SetString(PyExc_MemoryError, "Unable to allocate temporary array");
+ return NULL;
+ }
+ for (idx=0; idx<*count; idx++) {
+ // Get an item: try fast way first.
+ if (isFast) {
+ o = PySequence_Fast_GET_ITEM(source, idx);
+ }
+ else {
+ o = PySequence_GetItem(source, idx);
+ if (o == NULL) {
+ goto error1;
+ }
+ }
+
+ // Convert o to wxPoint.
+ if ((PyTuple_Check(o) && PyTuple_GET_SIZE(o) == 2) ||
+ (PyList_Check(o) && PyList_GET_SIZE(o) == 2)) {
+ o1 = PySequence_Fast_GET_ITEM(o, 0);
+ o2 = PySequence_Fast_GET_ITEM(o, 1);
+ if (!wxPoint2DFromObjects(o1, o2, &temp[idx])) {
+ goto error2;
+ }
+ }
+ else if (wxPySwigInstance_Check(o)) {
+ wxPoint2D* pt;
+ if (! wxPyConvertSwigPtr(o, (void **)&pt, wxT("wxPoint2D"))) {
+ goto error2;
+ }
+ temp[idx] = *pt;
+ }
+ else if (PySequence_Check(o) && PySequence_Length(o) == 2) {
+ o1 = PySequence_GetItem(o, 0);
+ o2 = PySequence_GetItem(o, 1);
+ if (!wxPoint2DFromObjects(o1, o2, &temp[idx])) {
+ goto error3;
+ }
+ Py_DECREF(o1);
+ Py_DECREF(o2);
+ }
+ else {
+ goto error2;
+ }
+ // Clean up.
+ if (!isFast)
+ Py_DECREF(o);
+ }
+ return temp;
+
+error3:
+ Py_DECREF(o1);
+ Py_DECREF(o2);
+error2:
+ if (!isFast)
+ Py_DECREF(o);
+error1:
+ delete [] temp;
+error0:
+ PyErr_SetString(PyExc_TypeError, "Expected a sequence of length-2 sequences or wxPoint2Ds.");
+ return NULL;
+}
+
+//---------------------------------------------------------------------------