1 /*
2  * Interface wrapper code.
3  *
4  * Generated by SIP 4.19.16
5  *
6  *     Copyright: (c) 2018 by Total Control Software
7  *     License:   wxWindows License
8  */
9 
10 #include "sipAPI_core.h"
11 
12 
13 
14         #include <wx/gdicmn.h>
15 
16         class wxPointList_iterator {
17         public:
wxPointList_iterator(wxPointList::compatibility_iterator start)18             wxPointList_iterator(wxPointList::compatibility_iterator start)
19                 : m_node(start) {}
20 
__next__()21             wxPoint* __next__() {
22                 wxPoint* obj = NULL;
23                 if (m_node) {
24                     obj = (wxPoint*) m_node->GetData();
25                     m_node = m_node->GetNext();
26                 }
27                 else {
28                     PyErr_SetString(PyExc_StopIteration, "");
29                 }
30                 return (wxPoint*)obj;
31             }
32         private:
33             wxPointList::compatibility_iterator m_node;
34         };
35 
36 
37 PyDoc_STRVAR(doc_wxPointList_index, "index(self, obj: Point) -> int");
38 
39 extern "C" {static PyObject *meth_wxPointList_index(PyObject *, PyObject *, PyObject *);}
meth_wxPointList_index(PyObject * sipSelf,PyObject * sipArgs,PyObject * sipKwds)40 static PyObject *meth_wxPointList_index(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
41 {
42     PyObject *sipParseErr = SIP_NULLPTR;
43 
44     {
45          ::wxPoint* obj;
46         int objState = 0;
47          ::wxPointList *sipCpp;
48 
49         static const char *sipKwdList[] = {
50             sipName_obj,
51         };
52 
53         if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BJ0", &sipSelf, sipType_wxPointList, &sipCpp, sipType_wxPoint, &obj, &objState))
54         {
55             int sipRes = 0;
56             sipErrorState sipError = sipErrorNone;
57 
58         int idx = sipCpp->IndexOf((wxPoint*)obj);
59         if (idx == wxNOT_FOUND) {
60             sipError = sipErrorFail;
61             wxPyErr_SetString(PyExc_ValueError,
62                               "sequence.index(x): x not in sequence");
63         }
64         sipRes = idx;
65             sipReleaseType(obj,sipType_wxPoint,objState);
66 
67             if (sipError == sipErrorFail)
68                 return 0;
69 
70             if (sipError == sipErrorNone)
71             {
72             return SIPLong_FromLong(sipRes);
73             }
74 
75             sipAddException(sipError, &sipParseErr);
76         }
77     }
78 
79     /* Raise an exception if the arguments couldn't be parsed. */
80     sipNoMethod(sipParseErr, sipName_PointList, sipName_index, doc_wxPointList_index);
81 
82     return SIP_NULLPTR;
83 }
84 
85 
86 extern "C" {static PyObject *slot_wxPointList___iter__(PyObject *);}
slot_wxPointList___iter__(PyObject * sipSelf)87 static PyObject *slot_wxPointList___iter__(PyObject *sipSelf)
88 {
89      ::wxPointList *sipCpp = reinterpret_cast< ::wxPointList *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_wxPointList));
90 
91     if (!sipCpp)
92         return SIP_NULLPTR;
93 
94 
95     {
96         {
97              ::wxPointList_iterator*sipRes = 0;
98 
99         sipRes =  new wxPointList_iterator(sipCpp->GetFirst());
100 
101             return sipConvertFromNewType(sipRes,sipType_wxPointList_iterator,SIP_NULLPTR);
102         }
103     }
104 
105     return 0;
106 }
107 
108 
109 extern "C" {static int slot_wxPointList___contains__(PyObject *,PyObject *);}
slot_wxPointList___contains__(PyObject * sipSelf,PyObject * sipArg)110 static int slot_wxPointList___contains__(PyObject *sipSelf,PyObject *sipArg)
111 {
112      ::wxPointList *sipCpp = reinterpret_cast< ::wxPointList *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_wxPointList));
113 
114     if (!sipCpp)
115         return -1;
116 
117     PyObject *sipParseErr = SIP_NULLPTR;
118 
119     {
120         const  ::wxPoint* obj;
121         int objState = 0;
122 
123         if (sipParseArgs(&sipParseErr, sipArg, "1J0", sipType_wxPoint, &obj, &objState))
124         {
125             int sipRes = 0;
126 
127         wxPointList::compatibility_iterator node;
128         node = sipCpp->Find((wxPoint*)obj);
129         sipRes = node != NULL;
130             sipReleaseType(const_cast< ::wxPoint *>(obj),sipType_wxPoint,objState);
131 
132             return sipRes;
133         }
134     }
135 
136     /* Raise an exception if the arguments couldn't be parsed. */
137     sipNoMethod(sipParseErr, sipName_PointList, sipName___contains__, SIP_NULLPTR);
138 
139     return -1;
140 }
141 
142 
143 extern "C" {static PyObject *slot_wxPointList___getitem__(PyObject *,PyObject *);}
slot_wxPointList___getitem__(PyObject * sipSelf,PyObject * sipArg)144 static PyObject *slot_wxPointList___getitem__(PyObject *sipSelf,PyObject *sipArg)
145 {
146      ::wxPointList *sipCpp = reinterpret_cast< ::wxPointList *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_wxPointList));
147 
148     if (!sipCpp)
149         return SIP_NULLPTR;
150 
151     PyObject *sipParseErr = SIP_NULLPTR;
152 
153     {
154         long index;
155 
156         if (sipParseArgs(&sipParseErr, sipArg, "1l", &index))
157         {
158              ::wxPoint*sipRes = 0;
159             sipErrorState sipError = sipErrorNone;
160 
161         if (0 > index)
162             index += sipCpp->size();
163 
164         if (index < sipCpp->size() && (0 <= index)) {
165             wxPointList::compatibility_iterator node = sipCpp->Item(index);
166             if (node)
167                 sipRes = (wxPoint*)node->GetData();
168         }
169         else {
170             wxPyErr_SetString(PyExc_IndexError, "sequence index out of range");
171             sipError = sipErrorFail;
172         }
173 
174             if (sipError == sipErrorFail)
175                 return 0;
176 
177             if (sipError == sipErrorNone)
178             {
179             return sipConvertFromType(sipRes,sipType_wxPoint,SIP_NULLPTR);
180             }
181 
182             sipAddException(sipError, &sipParseErr);
183         }
184     }
185 
186     /* Raise an exception if the arguments couldn't be parsed. */
187     sipNoMethod(sipParseErr, sipName_PointList, sipName___getitem__, SIP_NULLPTR);
188 
189     return SIP_NULLPTR;
190 }
191 
192 
193 extern "C" {static SIP_SSIZE_T slot_wxPointList___len__(PyObject *);}
slot_wxPointList___len__(PyObject * sipSelf)194 static SIP_SSIZE_T slot_wxPointList___len__(PyObject *sipSelf)
195 {
196      ::wxPointList *sipCpp = reinterpret_cast< ::wxPointList *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_wxPointList));
197 
198     if (!sipCpp)
199         return 0;
200 
201 
202     {
203         {
204             SIP_SSIZE_T sipRes = 0;
205 
206         sipRes = sipCpp->size();
207 
208             return sipRes;
209         }
210     }
211 
212     return 0;
213 }
214 
215 
216 /* Call the instance's destructor. */
217 extern "C" {static void release_wxPointList(void *, int);}
release_wxPointList(void * sipCppV,int)218 static void release_wxPointList(void *sipCppV, int)
219 {
220     Py_BEGIN_ALLOW_THREADS
221 
222     delete reinterpret_cast< ::wxPointList *>(sipCppV);
223 
224     Py_END_ALLOW_THREADS
225 }
226 
227 
228 extern "C" {static void assign_wxPointList(void *, SIP_SSIZE_T, void *);}
assign_wxPointList(void * sipDst,SIP_SSIZE_T sipDstIdx,void * sipSrc)229 static void assign_wxPointList(void *sipDst, SIP_SSIZE_T sipDstIdx, void *sipSrc)
230 {
231     reinterpret_cast< ::wxPointList *>(sipDst)[sipDstIdx] = *reinterpret_cast< ::wxPointList *>(sipSrc);
232 }
233 
234 
235 extern "C" {static void *array_wxPointList(SIP_SSIZE_T);}
array_wxPointList(SIP_SSIZE_T sipNrElem)236 static void *array_wxPointList(SIP_SSIZE_T sipNrElem)
237 {
238     return new  ::wxPointList[sipNrElem];
239 }
240 
241 
242 extern "C" {static void *copy_wxPointList(const void *, SIP_SSIZE_T);}
copy_wxPointList(const void * sipSrc,SIP_SSIZE_T sipSrcIdx)243 static void *copy_wxPointList(const void *sipSrc, SIP_SSIZE_T sipSrcIdx)
244 {
245     return new  ::wxPointList(reinterpret_cast<const  ::wxPointList *>(sipSrc)[sipSrcIdx]);
246 }
247 
248 
249 extern "C" {static void dealloc_wxPointList(sipSimpleWrapper *);}
dealloc_wxPointList(sipSimpleWrapper * sipSelf)250 static void dealloc_wxPointList(sipSimpleWrapper *sipSelf)
251 {
252     if (sipIsOwnedByPython(sipSelf))
253     {
254         release_wxPointList(sipGetAddress(sipSelf), 0);
255     }
256 }
257 
258 
259 extern "C" {static void *init_type_wxPointList(sipSimpleWrapper *, PyObject *, PyObject *, PyObject **, PyObject **, PyObject **);}
init_type_wxPointList(sipSimpleWrapper *,PyObject * sipArgs,PyObject * sipKwds,PyObject ** sipUnused,PyObject **,PyObject ** sipParseErr)260 static void *init_type_wxPointList(sipSimpleWrapper *, PyObject *sipArgs, PyObject *sipKwds, PyObject **sipUnused, PyObject **, PyObject **sipParseErr)
261 {
262      ::wxPointList *sipCpp = SIP_NULLPTR;
263 
264     {
265         if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, SIP_NULLPTR, sipUnused, ""))
266         {
267             Py_BEGIN_ALLOW_THREADS
268             sipCpp = new  ::wxPointList();
269             Py_END_ALLOW_THREADS
270 
271             return sipCpp;
272         }
273     }
274 
275     {
276         const  ::wxPointList* a0;
277         int a0State = 0;
278 
279         if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, SIP_NULLPTR, sipUnused, "J1", sipType_wxPointList, &a0, &a0State))
280         {
281             Py_BEGIN_ALLOW_THREADS
282             sipCpp = new  ::wxPointList(*a0);
283             Py_END_ALLOW_THREADS
284             sipReleaseType(const_cast< ::wxPointList *>(a0),sipType_wxPointList,a0State);
285 
286             return sipCpp;
287         }
288     }
289 
290     return SIP_NULLPTR;
291 }
292 
293 
294 extern "C" {static int convertTo_wxPointList(PyObject *, void **, int *, PyObject *);}
convertTo_wxPointList(PyObject * sipPy,void ** sipCppPtrV,int * sipIsErr,PyObject *)295 static int convertTo_wxPointList(PyObject *sipPy,void **sipCppPtrV,int *sipIsErr,PyObject *)
296 {
297      ::wxPointList **sipCppPtr = reinterpret_cast< ::wxPointList **>(sipCppPtrV);
298 
299     // Code to test a PyObject for compatibility
300     if (!sipIsErr) {
301         int success = TRUE;
302         // is it already a wxPointList?
303         if (sipCanConvertToType(sipPy, sipType_wxPointList, SIP_NO_CONVERTORS))
304             return success;
305         // otherwise ensure that it is a sequence
306         if (! PySequence_Check(sipPy))
307             success = FALSE;
308         // ensure it is not a string or unicode object (they are sequences too)
309         else if (PyBytes_Check(sipPy) || PyUnicode_Check(sipPy))
310             success = FALSE;
311         // ensure each item can be converted to wxPoint
312         else {
313             Py_ssize_t i, len = PySequence_Length(sipPy);
314             for (i=0; i<len; i++) {
315                 PyObject* item = PySequence_ITEM(sipPy, i);
316                 if (!sipCanConvertToType(item, sipType_wxPoint, SIP_NOT_NONE)) {
317                     Py_DECREF(item);
318                     success = FALSE;
319                     break;
320                 }
321                 Py_DECREF(item);
322             }
323         }
324         if (!success)
325             PyErr_SetString(PyExc_TypeError, "Sequence of wxPoint compatible objects expected.");
326         return success;
327     }
328 
329     // Is it already a wxPointList? Return the exiting instance if so
330     if (sipCanConvertToType(sipPy, sipType_wxPointList, SIP_NO_CONVERTORS)) {
331         *sipCppPtr = reinterpret_cast<wxPointList*>(
332                      sipConvertToType(sipPy, sipType_wxPointList, NULL,
333                                       SIP_NO_CONVERTORS, 0, sipIsErr));
334         return 0;
335     }
336 
337     // Create a new wxPointList and convert compatible PyObjects from the sequence
338     wxPointList *list = new wxPointList;
339     list->DeleteContents(true); // tell the list to take ownership of the items
340     Py_ssize_t i, len = PySequence_Length(sipPy);
341     for (i=0; i<len; i++) {
342         int state;
343         PyObject* pyItem = PySequence_ITEM(sipPy, i);
344         wxPoint* cItem = reinterpret_cast<wxPoint*>(
345                              sipConvertToType(pyItem, sipType_wxPoint,
346                              NULL, 0, &state, sipIsErr));
347         if (!state)  // a temporary was not created for us, make one now
348             cItem = new wxPoint(*cItem);
349         list->Append(cItem);
350         Py_DECREF(pyItem);
351     }
352     *sipCppPtr = list;
353     return SIP_TEMPORARY;
354 }
355 
356 
357 /* Define this type's Python slots. */
358 static sipPySlotDef slots_wxPointList[] = {
359     {(void *)slot_wxPointList___iter__, iter_slot},
360     {(void *)slot_wxPointList___contains__, contains_slot},
361     {(void *)slot_wxPointList___getitem__, getitem_slot},
362     {(void *)slot_wxPointList___len__, len_slot},
363     {0, (sipPySlotType)0}
364 };
365 
366 
367 static PyMethodDef methods_wxPointList[] = {
368     {SIP_MLNAME_CAST(sipName_index), SIP_MLMETH_CAST(meth_wxPointList_index), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxPointList_index)}
369 };
370 
371 PyDoc_STRVAR(doc_wxPointList, "\1PointList()\n"
372 "PointList(PointList)");
373 
374 
375 sipClassTypeDef sipTypeDef__core_wxPointList = {
376     {
377         -1,
378         SIP_NULLPTR,
379         SIP_NULLPTR,
380         SIP_TYPE_CLASS,
381         sipNameNr_wxPointList,
382         {SIP_NULLPTR},
383         SIP_NULLPTR
384     },
385     {
386         sipNameNr_PointList,
387         {0, 0, 1},
388         1, methods_wxPointList,
389         0, SIP_NULLPTR,
390         0, SIP_NULLPTR,
391         {SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR},
392     },
393     doc_wxPointList,
394     -1,
395     -1,
396     SIP_NULLPTR,
397     slots_wxPointList,
398     init_type_wxPointList,
399     SIP_NULLPTR,
400     SIP_NULLPTR,
401 #if PY_MAJOR_VERSION >= 3
402     SIP_NULLPTR,
403     SIP_NULLPTR,
404 #else
405     SIP_NULLPTR,
406     SIP_NULLPTR,
407     SIP_NULLPTR,
408     SIP_NULLPTR,
409 #endif
410     dealloc_wxPointList,
411     assign_wxPointList,
412     array_wxPointList,
413     copy_wxPointList,
414     release_wxPointList,
415     SIP_NULLPTR,
416     convertTo_wxPointList,
417     SIP_NULLPTR,
418     SIP_NULLPTR,
419     SIP_NULLPTR,
420     SIP_NULLPTR,
421     SIP_NULLPTR
422 };
423