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         #include <wx/stream.h>
13 
14         #include <wx/stream.h>
15         //--------------------------------------------------------------------------
16 
wxPyGetMethod(PyObject * py,char * name)17         static PyObject* wxPyGetMethod(PyObject* py, char* name)
18         {
19             if (!PyObject_HasAttrString(py, name))
20                 return NULL;
21             PyObject* o = PyObject_GetAttrString(py, name);
22             if (!PyMethod_Check(o) && !PyCFunction_Check(o)) {
23                 Py_DECREF(o);
24                 return NULL;
25             }
26             return o;
27         }
28 
29         #define wxPyBlock_t_default PyGILState_UNLOCKED
30 
31 
32         // This class can wrap a Python file-like object and allow it to be used
33         // as a wxInputStream.
34         class wxPyOutputStream : public wxOutputStream
35         {
36         public:
37 
38             // Make sure there is at least a write method
Check(PyObject * fileObj)39             static bool Check(PyObject* fileObj)
40             {
41                 PyObject* method = wxPyGetMethod(fileObj, "write");
42                 bool rval = method != NULL;
43                 Py_XDECREF(method);
44                 return rval;
45             }
46 
wxPyOutputStream(PyObject * fileObj,bool block=true)47             wxPyOutputStream(PyObject* fileObj, bool block=true)
48             {
49                 m_block = block;
50                 wxPyThreadBlocker blocker(m_block);
51 
52                 m_write = wxPyGetMethod(fileObj, "write");
53                 m_seek = wxPyGetMethod(fileObj, "seek");
54                 m_tell = wxPyGetMethod(fileObj, "tell");
55             }
56 
~wxPyOutputStream()57             virtual ~wxPyOutputStream()
58             {
59                 wxPyThreadBlocker blocker(m_block);
60                 Py_XDECREF(m_write);
61                 Py_XDECREF(m_seek);
62                 Py_XDECREF(m_tell);
63             }
64 
wxPyOutputStream(const wxPyOutputStream & other)65             wxPyOutputStream(const wxPyOutputStream& other)
66             {
67                 wxPyThreadBlocker blocker;
68                 m_write  = other.m_write;
69                 m_seek  = other.m_seek;
70                 m_tell  = other.m_tell;
71                 m_block = other.m_block;
72                 Py_INCREF(m_write);
73                 Py_INCREF(m_seek);
74                 Py_INCREF(m_tell);
75             }
76 
77         protected:
78 
79             // implement base class virtuals
80 
GetLength() const81             wxFileOffset GetLength() const
82             {
83                 wxPyOutputStream* self = (wxPyOutputStream*)this; // cast off const
84                 if (m_seek && m_tell) {
85                     wxFileOffset temp = self->OnSysTell();
86                     wxFileOffset ret = self->OnSysSeek(0, wxFromEnd);
87                     self->OnSysSeek(temp, wxFromStart);
88                     return ret;
89                 }
90                 else
91                     return wxInvalidOffset;
92             }
93 
OnSysRead(void * buffer,size_t bufsize)94             size_t OnSysRead(void *buffer, size_t bufsize)
95             {
96                 m_lasterror = wxSTREAM_READ_ERROR;
97                 return 0;
98             }
99 
OnSysWrite(const void * buffer,size_t bufsize)100             size_t OnSysWrite(const void *buffer, size_t bufsize)
101             {
102                 if (bufsize == 0)
103                     return 0;
104 
105                 wxPyThreadBlocker blocker;
106                 PyObject* arglist = PyTuple_New(1);
107                 PyTuple_SET_ITEM(arglist, 0, PyBytes_FromStringAndSize((char*)buffer, bufsize));
108 
109                 PyObject* result = PyEval_CallObject(m_write, arglist);
110                 Py_DECREF(arglist);
111 
112                 if (result != NULL)
113                     Py_DECREF(result);
114                 else
115                     m_lasterror = wxSTREAM_WRITE_ERROR;
116                 return bufsize;
117             }
118 
OnSysSeek(wxFileOffset off,wxSeekMode mode)119             wxFileOffset OnSysSeek(wxFileOffset off, wxSeekMode mode)
120             {
121                 wxPyThreadBlocker blocker;
122                 PyObject* arglist = PyTuple_New(2);
123 
124                 if (sizeof(wxFileOffset) > sizeof(long))
125                     // wxFileOffset is a 64-bit value...
126                     PyTuple_SET_ITEM(arglist, 0, PyLong_FromLongLong(off));
127                 else
128                     PyTuple_SET_ITEM(arglist, 0, wxPyInt_FromLong(off));
129 
130                 PyTuple_SET_ITEM(arglist, 1, wxPyInt_FromLong(mode));
131 
132 
133                 PyObject* result = PyEval_CallObject(m_seek, arglist);
134                 Py_DECREF(arglist);
135                 Py_XDECREF(result);
136                 return OnSysTell();
137             }
138 
OnSysTell() const139             wxFileOffset OnSysTell() const
140             {
141                 wxPyThreadBlocker blocker;
142                 PyObject* arglist = Py_BuildValue("()");
143                 PyObject* result = PyEval_CallObject(m_tell, arglist);
144                 Py_DECREF(arglist);
145                 wxFileOffset o = 0;
146                 if (result != NULL) {
147                     if (PyLong_Check(result))
148                         o = PyLong_AsLongLong(result);
149                     else
150                         o = wxPyInt_AsLong(result);
151                     Py_DECREF(result);
152                 };
153                 return o;
154             }
155 
IsSeekable() const156             bool IsSeekable() const
157             {
158                 return (m_seek != NULL);
159             }
160 
161         private:
162             PyObject* m_write;
163             PyObject* m_seek;
164             PyObject* m_tell;
165             bool      m_block;
166         };
167 
168         //--------------------------------------------------------------------------
_wxOutputStream_seek(wxOutputStream * self,wxFileOffset offset,int whence)169     void _wxOutputStream_seek(wxOutputStream* self, wxFileOffset offset, int whence)
170     {
171         self->SeekO(offset, (wxSeekMode)whence);
172     }
_wxOutputStream_tell(wxOutputStream * self)173     wxFileOffset _wxOutputStream_tell(wxOutputStream* self)
174     {
175         return self->TellO();
176     }
_wxOutputStream_close(wxOutputStream * self)177     void _wxOutputStream_close(wxOutputStream* self)
178     {
179         self->Close();
180     }
_wxOutputStream_flush(wxOutputStream * self)181     void _wxOutputStream_flush(wxOutputStream* self)
182     {
183         self->Sync();
184     }
_wxOutputStream_eof(wxOutputStream * self)185     bool _wxOutputStream_eof(wxOutputStream* self)
186     {
187         return false; //self->Eof();
188     }
_wxOutputStream_write(wxOutputStream * self,PyObject * data)189     PyObject* _wxOutputStream_write(wxOutputStream* self, PyObject* data)
190     {
191         // We use only bytes objects (strings in 2.7) for the streams, never unicode
192         wxPyThreadBlocker blocker;
193         if (!PyBytes_Check(data)) {
194             PyErr_SetString(PyExc_TypeError, "Bytes object expected");
195             return NULL;
196         }
197         self->Write(PyBytes_AS_STRING(data), PyBytes_GET_SIZE(data));
198         RETURN_NONE();
199     }
200 
201 
202 PyDoc_STRVAR(doc_wxOutputStream_Close, "Close() -> bool\n"
203 "\n"
204 "Closes the stream, returning false if an error occurs.");
205 
206 extern "C" {static PyObject *meth_wxOutputStream_Close(PyObject *, PyObject *);}
meth_wxOutputStream_Close(PyObject * sipSelf,PyObject * sipArgs)207 static PyObject *meth_wxOutputStream_Close(PyObject *sipSelf, PyObject *sipArgs)
208 {
209     PyObject *sipParseErr = SIP_NULLPTR;
210 
211     {
212          ::wxOutputStream *sipCpp;
213 
214         if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxOutputStream, &sipCpp))
215         {
216             bool sipRes;
217 
218             PyErr_Clear();
219 
220             Py_BEGIN_ALLOW_THREADS
221             sipRes = sipCpp->Close();
222             Py_END_ALLOW_THREADS
223 
224             if (PyErr_Occurred())
225                 return 0;
226 
227             return PyBool_FromLong(sipRes);
228         }
229     }
230 
231     /* Raise an exception if the arguments couldn't be parsed. */
232     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_Close, SIP_NULLPTR);
233 
234     return SIP_NULLPTR;
235 }
236 
237 
238 PyDoc_STRVAR(doc_wxOutputStream_LastWrite, "LastWrite() -> size_t\n"
239 "\n"
240 "Returns the number of bytes written during the last Write().");
241 
242 extern "C" {static PyObject *meth_wxOutputStream_LastWrite(PyObject *, PyObject *);}
meth_wxOutputStream_LastWrite(PyObject * sipSelf,PyObject * sipArgs)243 static PyObject *meth_wxOutputStream_LastWrite(PyObject *sipSelf, PyObject *sipArgs)
244 {
245     PyObject *sipParseErr = SIP_NULLPTR;
246 
247     {
248         const  ::wxOutputStream *sipCpp;
249 
250         if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxOutputStream, &sipCpp))
251         {
252             size_t sipRes;
253 
254             PyErr_Clear();
255 
256             Py_BEGIN_ALLOW_THREADS
257             sipRes = sipCpp->LastWrite();
258             Py_END_ALLOW_THREADS
259 
260             if (PyErr_Occurred())
261                 return 0;
262 
263             return PyLong_FromUnsignedLong(sipRes);
264         }
265     }
266 
267     /* Raise an exception if the arguments couldn't be parsed. */
268     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_LastWrite, SIP_NULLPTR);
269 
270     return SIP_NULLPTR;
271 }
272 
273 
274 PyDoc_STRVAR(doc_wxOutputStream_PutC, "PutC(c)\n"
275 "\n"
276 "Puts the specified character in the output queue and increments the\n"
277 "stream position.");
278 
279 extern "C" {static PyObject *meth_wxOutputStream_PutC(PyObject *, PyObject *, PyObject *);}
meth_wxOutputStream_PutC(PyObject * sipSelf,PyObject * sipArgs,PyObject * sipKwds)280 static PyObject *meth_wxOutputStream_PutC(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
281 {
282     PyObject *sipParseErr = SIP_NULLPTR;
283 
284     {
285         char c;
286          ::wxOutputStream *sipCpp;
287 
288         static const char *sipKwdList[] = {
289             sipName_c,
290         };
291 
292         if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "Bc", &sipSelf, sipType_wxOutputStream, &sipCpp, &c))
293         {
294             PyErr_Clear();
295 
296             Py_BEGIN_ALLOW_THREADS
297             sipCpp->PutC(c);
298             Py_END_ALLOW_THREADS
299 
300             if (PyErr_Occurred())
301                 return 0;
302 
303             Py_INCREF(Py_None);
304             return Py_None;
305         }
306     }
307 
308     /* Raise an exception if the arguments couldn't be parsed. */
309     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_PutC, SIP_NULLPTR);
310 
311     return SIP_NULLPTR;
312 }
313 
314 
315 PyDoc_STRVAR(doc_wxOutputStream_SeekO, "SeekO(pos, mode=FromStart) -> FileOffset\n"
316 "\n"
317 "Changes the stream current position.");
318 
319 extern "C" {static PyObject *meth_wxOutputStream_SeekO(PyObject *, PyObject *, PyObject *);}
meth_wxOutputStream_SeekO(PyObject * sipSelf,PyObject * sipArgs,PyObject * sipKwds)320 static PyObject *meth_wxOutputStream_SeekO(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
321 {
322     PyObject *sipParseErr = SIP_NULLPTR;
323 
324     {
325          ::wxFileOffset pos;
326          ::wxSeekMode mode = wxFromStart;
327          ::wxOutputStream *sipCpp;
328 
329         static const char *sipKwdList[] = {
330             sipName_pos,
331             sipName_mode,
332         };
333 
334         if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "Bn|E", &sipSelf, sipType_wxOutputStream, &sipCpp, &pos, sipType_wxSeekMode, &mode))
335         {
336              ::wxFileOffset sipRes;
337 
338             PyErr_Clear();
339 
340             Py_BEGIN_ALLOW_THREADS
341             sipRes = sipCpp->SeekO(pos,mode);
342             Py_END_ALLOW_THREADS
343 
344             if (PyErr_Occurred())
345                 return 0;
346 
347             return PyLong_FromLongLong(sipRes);
348         }
349     }
350 
351     /* Raise an exception if the arguments couldn't be parsed. */
352     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_SeekO, SIP_NULLPTR);
353 
354     return SIP_NULLPTR;
355 }
356 
357 
358 PyDoc_STRVAR(doc_wxOutputStream_TellO, "TellO() -> FileOffset\n"
359 "\n"
360 "Returns the current stream position.");
361 
362 extern "C" {static PyObject *meth_wxOutputStream_TellO(PyObject *, PyObject *);}
meth_wxOutputStream_TellO(PyObject * sipSelf,PyObject * sipArgs)363 static PyObject *meth_wxOutputStream_TellO(PyObject *sipSelf, PyObject *sipArgs)
364 {
365     PyObject *sipParseErr = SIP_NULLPTR;
366 
367     {
368         const  ::wxOutputStream *sipCpp;
369 
370         if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxOutputStream, &sipCpp))
371         {
372              ::wxFileOffset sipRes;
373 
374             PyErr_Clear();
375 
376             Py_BEGIN_ALLOW_THREADS
377             sipRes = sipCpp->TellO();
378             Py_END_ALLOW_THREADS
379 
380             if (PyErr_Occurred())
381                 return 0;
382 
383             return PyLong_FromLongLong(sipRes);
384         }
385     }
386 
387     /* Raise an exception if the arguments couldn't be parsed. */
388     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_TellO, SIP_NULLPTR);
389 
390     return SIP_NULLPTR;
391 }
392 
393 
394 PyDoc_STRVAR(doc_wxOutputStream_Write, "Write(buffer, size) -> OutputStream\n"
395 "Write(stream_in) -> OutputStream\n"
396 "\n"
397 "Writes up to the specified amount of bytes using the data of buffer.\n"
398 "");
399 
400 extern "C" {static PyObject *meth_wxOutputStream_Write(PyObject *, PyObject *, PyObject *);}
meth_wxOutputStream_Write(PyObject * sipSelf,PyObject * sipArgs,PyObject * sipKwds)401 static PyObject *meth_wxOutputStream_Write(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
402 {
403     PyObject *sipParseErr = SIP_NULLPTR;
404 
405     {
406         const void* buffer;
407         size_t size;
408          ::wxOutputStream *sipCpp;
409 
410         static const char *sipKwdList[] = {
411             sipName_buffer,
412             sipName_size,
413         };
414 
415         if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "Bv=", &sipSelf, sipType_wxOutputStream, &sipCpp, &buffer, &size))
416         {
417              ::wxOutputStream*sipRes;
418 
419             PyErr_Clear();
420 
421             Py_BEGIN_ALLOW_THREADS
422             sipRes = &sipCpp->Write(buffer,size);
423             Py_END_ALLOW_THREADS
424 
425             if (PyErr_Occurred())
426                 return 0;
427 
428             return sipConvertFromType(sipRes,sipType_wxOutputStream,SIP_NULLPTR);
429         }
430     }
431 
432     {
433          ::wxInputStream* stream_in;
434         int stream_inState = 0;
435          ::wxOutputStream *sipCpp;
436 
437         static const char *sipKwdList[] = {
438             sipName_stream_in,
439         };
440 
441         if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BJ1", &sipSelf, sipType_wxOutputStream, &sipCpp, sipType_wxInputStream, &stream_in, &stream_inState))
442         {
443              ::wxOutputStream*sipRes;
444 
445             PyErr_Clear();
446 
447             Py_BEGIN_ALLOW_THREADS
448             sipRes = &sipCpp->Write(*stream_in);
449             Py_END_ALLOW_THREADS
450             sipReleaseType(stream_in,sipType_wxInputStream,stream_inState);
451 
452             if (PyErr_Occurred())
453                 return 0;
454 
455             return sipConvertFromType(sipRes,sipType_wxOutputStream,SIP_NULLPTR);
456         }
457     }
458 
459     /* Raise an exception if the arguments couldn't be parsed. */
460     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_Write, SIP_NULLPTR);
461 
462     return SIP_NULLPTR;
463 }
464 
465 
466 PyDoc_STRVAR(doc_wxOutputStream_WriteAll, "WriteAll(buffer, size) -> bool\n"
467 "\n"
468 "Writes exactly the specified number of bytes from the buffer.");
469 
470 extern "C" {static PyObject *meth_wxOutputStream_WriteAll(PyObject *, PyObject *, PyObject *);}
meth_wxOutputStream_WriteAll(PyObject * sipSelf,PyObject * sipArgs,PyObject * sipKwds)471 static PyObject *meth_wxOutputStream_WriteAll(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
472 {
473     PyObject *sipParseErr = SIP_NULLPTR;
474 
475     {
476         const void* buffer;
477         size_t size;
478          ::wxOutputStream *sipCpp;
479 
480         static const char *sipKwdList[] = {
481             sipName_buffer,
482             sipName_size,
483         };
484 
485         if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "Bv=", &sipSelf, sipType_wxOutputStream, &sipCpp, &buffer, &size))
486         {
487             bool sipRes;
488 
489             PyErr_Clear();
490 
491             Py_BEGIN_ALLOW_THREADS
492             sipRes = sipCpp->WriteAll(buffer,size);
493             Py_END_ALLOW_THREADS
494 
495             if (PyErr_Occurred())
496                 return 0;
497 
498             return PyBool_FromLong(sipRes);
499         }
500     }
501 
502     /* Raise an exception if the arguments couldn't be parsed. */
503     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_WriteAll, SIP_NULLPTR);
504 
505     return SIP_NULLPTR;
506 }
507 
508 
509 PyDoc_STRVAR(doc_wxOutputStream_seek, "seek(offset, whence=0)");
510 
511 extern "C" {static PyObject *meth_wxOutputStream_seek(PyObject *, PyObject *, PyObject *);}
meth_wxOutputStream_seek(PyObject * sipSelf,PyObject * sipArgs,PyObject * sipKwds)512 static PyObject *meth_wxOutputStream_seek(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
513 {
514     PyObject *sipParseErr = SIP_NULLPTR;
515 
516     {
517          ::wxFileOffset offset;
518         int whence = 0;
519          ::wxOutputStream *sipCpp;
520 
521         static const char *sipKwdList[] = {
522             sipName_offset,
523             sipName_whence,
524         };
525 
526         if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "Bn|i", &sipSelf, sipType_wxOutputStream, &sipCpp, &offset, &whence))
527         {
528             int sipIsErr = 0;
529 
530         PyErr_Clear();
531         Py_BEGIN_ALLOW_THREADS
532         _wxOutputStream_seek(sipCpp, offset, whence);
533         Py_END_ALLOW_THREADS
534         if (PyErr_Occurred()) sipIsErr = 1;
535 
536             if (sipIsErr)
537                 return 0;
538 
539             Py_INCREF(Py_None);
540             return Py_None;
541         }
542     }
543 
544     /* Raise an exception if the arguments couldn't be parsed. */
545     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_seek, SIP_NULLPTR);
546 
547     return SIP_NULLPTR;
548 }
549 
550 
551 PyDoc_STRVAR(doc_wxOutputStream_tell, "tell() -> FileOffset");
552 
553 extern "C" {static PyObject *meth_wxOutputStream_tell(PyObject *, PyObject *);}
meth_wxOutputStream_tell(PyObject * sipSelf,PyObject * sipArgs)554 static PyObject *meth_wxOutputStream_tell(PyObject *sipSelf, PyObject *sipArgs)
555 {
556     PyObject *sipParseErr = SIP_NULLPTR;
557 
558     {
559          ::wxOutputStream *sipCpp;
560 
561         if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxOutputStream, &sipCpp))
562         {
563              ::wxFileOffset sipRes = 0;
564             int sipIsErr = 0;
565 
566         PyErr_Clear();
567         Py_BEGIN_ALLOW_THREADS
568         sipRes = _wxOutputStream_tell(sipCpp);
569         Py_END_ALLOW_THREADS
570         if (PyErr_Occurred()) sipIsErr = 1;
571 
572             if (sipIsErr)
573                 return 0;
574 
575             return PyLong_FromLongLong(sipRes);
576         }
577     }
578 
579     /* Raise an exception if the arguments couldn't be parsed. */
580     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_tell, SIP_NULLPTR);
581 
582     return SIP_NULLPTR;
583 }
584 
585 
586 PyDoc_STRVAR(doc_wxOutputStream_close, "close()");
587 
588 extern "C" {static PyObject *meth_wxOutputStream_close(PyObject *, PyObject *);}
meth_wxOutputStream_close(PyObject * sipSelf,PyObject * sipArgs)589 static PyObject *meth_wxOutputStream_close(PyObject *sipSelf, PyObject *sipArgs)
590 {
591     PyObject *sipParseErr = SIP_NULLPTR;
592 
593     {
594          ::wxOutputStream *sipCpp;
595 
596         if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxOutputStream, &sipCpp))
597         {
598             int sipIsErr = 0;
599 
600         PyErr_Clear();
601         Py_BEGIN_ALLOW_THREADS
602         _wxOutputStream_close(sipCpp);
603         Py_END_ALLOW_THREADS
604         if (PyErr_Occurred()) sipIsErr = 1;
605 
606             if (sipIsErr)
607                 return 0;
608 
609             Py_INCREF(Py_None);
610             return Py_None;
611         }
612     }
613 
614     /* Raise an exception if the arguments couldn't be parsed. */
615     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_close, SIP_NULLPTR);
616 
617     return SIP_NULLPTR;
618 }
619 
620 
621 PyDoc_STRVAR(doc_wxOutputStream_flush, "flush()");
622 
623 extern "C" {static PyObject *meth_wxOutputStream_flush(PyObject *, PyObject *);}
meth_wxOutputStream_flush(PyObject * sipSelf,PyObject * sipArgs)624 static PyObject *meth_wxOutputStream_flush(PyObject *sipSelf, PyObject *sipArgs)
625 {
626     PyObject *sipParseErr = SIP_NULLPTR;
627 
628     {
629          ::wxOutputStream *sipCpp;
630 
631         if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxOutputStream, &sipCpp))
632         {
633             int sipIsErr = 0;
634 
635         PyErr_Clear();
636         Py_BEGIN_ALLOW_THREADS
637         _wxOutputStream_flush(sipCpp);
638         Py_END_ALLOW_THREADS
639         if (PyErr_Occurred()) sipIsErr = 1;
640 
641             if (sipIsErr)
642                 return 0;
643 
644             Py_INCREF(Py_None);
645             return Py_None;
646         }
647     }
648 
649     /* Raise an exception if the arguments couldn't be parsed. */
650     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_flush, SIP_NULLPTR);
651 
652     return SIP_NULLPTR;
653 }
654 
655 
656 PyDoc_STRVAR(doc_wxOutputStream_eof, "eof() -> bool");
657 
658 extern "C" {static PyObject *meth_wxOutputStream_eof(PyObject *, PyObject *);}
meth_wxOutputStream_eof(PyObject * sipSelf,PyObject * sipArgs)659 static PyObject *meth_wxOutputStream_eof(PyObject *sipSelf, PyObject *sipArgs)
660 {
661     PyObject *sipParseErr = SIP_NULLPTR;
662 
663     {
664          ::wxOutputStream *sipCpp;
665 
666         if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxOutputStream, &sipCpp))
667         {
668             bool sipRes = 0;
669             int sipIsErr = 0;
670 
671         PyErr_Clear();
672         Py_BEGIN_ALLOW_THREADS
673         sipRes = _wxOutputStream_eof(sipCpp);
674         Py_END_ALLOW_THREADS
675         if (PyErr_Occurred()) sipIsErr = 1;
676 
677             if (sipIsErr)
678                 return 0;
679 
680             return PyBool_FromLong(sipRes);
681         }
682     }
683 
684     /* Raise an exception if the arguments couldn't be parsed. */
685     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_eof, SIP_NULLPTR);
686 
687     return SIP_NULLPTR;
688 }
689 
690 
691 PyDoc_STRVAR(doc_wxOutputStream_write, "write(data) -> PyObject");
692 
693 extern "C" {static PyObject *meth_wxOutputStream_write(PyObject *, PyObject *, PyObject *);}
meth_wxOutputStream_write(PyObject * sipSelf,PyObject * sipArgs,PyObject * sipKwds)694 static PyObject *meth_wxOutputStream_write(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
695 {
696     PyObject *sipParseErr = SIP_NULLPTR;
697 
698     {
699         PyObject * data;
700          ::wxOutputStream *sipCpp;
701 
702         static const char *sipKwdList[] = {
703             sipName_data,
704         };
705 
706         if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BP0", &sipSelf, sipType_wxOutputStream, &sipCpp, &data))
707         {
708             PyObject * sipRes = SIP_NULLPTR;
709             int sipIsErr = 0;
710 
711         PyErr_Clear();
712         Py_BEGIN_ALLOW_THREADS
713         sipRes = _wxOutputStream_write(sipCpp, data);
714         Py_END_ALLOW_THREADS
715         if (PyErr_Occurred()) sipIsErr = 1;
716 
717             if (sipIsErr)
718                 return 0;
719 
720             return sipRes;
721         }
722     }
723 
724     /* Raise an exception if the arguments couldn't be parsed. */
725     sipNoMethod(sipParseErr, sipName_OutputStream, sipName_write, SIP_NULLPTR);
726 
727     return SIP_NULLPTR;
728 }
729 
730 
731 /* Cast a pointer to a type somewhere in its inheritance hierarchy. */
732 extern "C" {static void *cast_wxOutputStream(void *, const sipTypeDef *);}
cast_wxOutputStream(void * sipCppV,const sipTypeDef * targetType)733 static void *cast_wxOutputStream(void *sipCppV, const sipTypeDef *targetType)
734 {
735      ::wxOutputStream *sipCpp = reinterpret_cast< ::wxOutputStream *>(sipCppV);
736 
737     if (targetType == sipType_wxStreamBase)
738         return static_cast< ::wxStreamBase *>(sipCpp);
739 
740     return sipCppV;
741 }
742 
743 
744 /* Call the instance's destructor. */
745 extern "C" {static void release_wxOutputStream(void *, int);}
release_wxOutputStream(void * sipCppV,int)746 static void release_wxOutputStream(void *sipCppV, int)
747 {
748     Py_BEGIN_ALLOW_THREADS
749 
750     delete reinterpret_cast< ::wxOutputStream *>(sipCppV);
751 
752     Py_END_ALLOW_THREADS
753 }
754 
755 
756 extern "C" {static void dealloc_wxOutputStream(sipSimpleWrapper *);}
dealloc_wxOutputStream(sipSimpleWrapper * sipSelf)757 static void dealloc_wxOutputStream(sipSimpleWrapper *sipSelf)
758 {
759     if (sipIsOwnedByPython(sipSelf))
760     {
761         release_wxOutputStream(sipGetAddress(sipSelf), 0);
762     }
763 }
764 
765 
766 extern "C" {static int convertTo_wxOutputStream(PyObject *, void **, int *, PyObject *);}
convertTo_wxOutputStream(PyObject * sipPy,void ** sipCppPtrV,int * sipIsErr,PyObject * sipTransferObj)767 static int convertTo_wxOutputStream(PyObject *sipPy,void **sipCppPtrV,int *sipIsErr,PyObject *sipTransferObj)
768 {
769      ::wxOutputStream **sipCppPtr = reinterpret_cast< ::wxOutputStream **>(sipCppPtrV);
770 
771         // is it just a typecheck?
772         if (!sipIsErr) {
773             if (wxPyOutputStream::Check(sipPy))
774                 return 1;
775             return 0;
776         }
777         // otherwise do the conversion
778         *sipCppPtr = new wxPyOutputStream(sipPy);
779         return sipGetState(sipTransferObj);
780 }
781 
782 
783 /* Define this type's super-types. */
784 static sipEncodedTypeDef supers_wxOutputStream[] = {{498, 255, 1}};
785 
786 
787 static PyMethodDef methods_wxOutputStream[] = {
788     {SIP_MLNAME_CAST(sipName_Close), meth_wxOutputStream_Close, METH_VARARGS, SIP_MLDOC_CAST(doc_wxOutputStream_Close)},
789     {SIP_MLNAME_CAST(sipName_LastWrite), meth_wxOutputStream_LastWrite, METH_VARARGS, SIP_MLDOC_CAST(doc_wxOutputStream_LastWrite)},
790     {SIP_MLNAME_CAST(sipName_PutC), SIP_MLMETH_CAST(meth_wxOutputStream_PutC), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxOutputStream_PutC)},
791     {SIP_MLNAME_CAST(sipName_SeekO), SIP_MLMETH_CAST(meth_wxOutputStream_SeekO), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxOutputStream_SeekO)},
792     {SIP_MLNAME_CAST(sipName_TellO), meth_wxOutputStream_TellO, METH_VARARGS, SIP_MLDOC_CAST(doc_wxOutputStream_TellO)},
793     {SIP_MLNAME_CAST(sipName_Write), SIP_MLMETH_CAST(meth_wxOutputStream_Write), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxOutputStream_Write)},
794     {SIP_MLNAME_CAST(sipName_WriteAll), SIP_MLMETH_CAST(meth_wxOutputStream_WriteAll), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxOutputStream_WriteAll)},
795     {SIP_MLNAME_CAST(sipName_close), meth_wxOutputStream_close, METH_VARARGS, SIP_MLDOC_CAST(doc_wxOutputStream_close)},
796     {SIP_MLNAME_CAST(sipName_eof), meth_wxOutputStream_eof, METH_VARARGS, SIP_MLDOC_CAST(doc_wxOutputStream_eof)},
797     {SIP_MLNAME_CAST(sipName_flush), meth_wxOutputStream_flush, METH_VARARGS, SIP_MLDOC_CAST(doc_wxOutputStream_flush)},
798     {SIP_MLNAME_CAST(sipName_seek), SIP_MLMETH_CAST(meth_wxOutputStream_seek), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxOutputStream_seek)},
799     {SIP_MLNAME_CAST(sipName_tell), meth_wxOutputStream_tell, METH_VARARGS, SIP_MLDOC_CAST(doc_wxOutputStream_tell)},
800     {SIP_MLNAME_CAST(sipName_write), SIP_MLMETH_CAST(meth_wxOutputStream_write), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxOutputStream_write)}
801 };
802 
803 PyDoc_STRVAR(doc_wxOutputStream, "OutputStream()\n"
804 "\n"
805 "wxOutputStream is an abstract base class which may not be used\n"
806 "directly.");
807 
808 
809 sipClassTypeDef sipTypeDef__core_wxOutputStream = {
810     {
811         -1,
812         SIP_NULLPTR,
813         SIP_NULLPTR,
814         SIP_TYPE_ABSTRACT|SIP_TYPE_CLASS,
815         sipNameNr_wxOutputStream,
816         {SIP_NULLPTR},
817         SIP_NULLPTR
818     },
819     {
820         sipNameNr_OutputStream,
821         {0, 0, 1},
822         13, methods_wxOutputStream,
823         0, SIP_NULLPTR,
824         0, SIP_NULLPTR,
825         {SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR},
826     },
827     doc_wxOutputStream,
828     -1,
829     -1,
830     supers_wxOutputStream,
831     SIP_NULLPTR,
832     SIP_NULLPTR,
833     SIP_NULLPTR,
834     SIP_NULLPTR,
835 #if PY_MAJOR_VERSION >= 3
836     SIP_NULLPTR,
837     SIP_NULLPTR,
838 #else
839     SIP_NULLPTR,
840     SIP_NULLPTR,
841     SIP_NULLPTR,
842     SIP_NULLPTR,
843 #endif
844     dealloc_wxOutputStream,
845     SIP_NULLPTR,
846     SIP_NULLPTR,
847     SIP_NULLPTR,
848     release_wxOutputStream,
849     cast_wxOutputStream,
850     convertTo_wxOutputStream,
851     SIP_NULLPTR,
852     SIP_NULLPTR,
853     SIP_NULLPTR,
854     SIP_NULLPTR,
855     SIP_NULLPTR
856 };
857