]>
Commit | Line | Data |
---|---|---|
c368d904 RD |
1 | /* |
2 | * FILE : src/gtk/streams.cpp | |
3 | * | |
4 | * This file was automatically generated by : | |
5 | * Simplified Wrapper and Interface Generator (SWIG) | |
2cd2fac8 | 6 | * Version 1.1 (Build 883) |
c368d904 RD |
7 | * |
8 | * Portions Copyright (c) 1995-1998 | |
9 | * The University of Utah and The Regents of the University of California. | |
10 | * Permission is granted to distribute this file in any manner provided | |
11 | * this notice remains intact. | |
12 | * | |
13 | * Do not make changes to this file--changes will be lost! | |
14 | * | |
15 | */ | |
16 | ||
17 | ||
18 | #define SWIGCODE | |
19 | /* Implementation : PYTHON */ | |
20 | ||
21 | #define SWIGPYTHON | |
22 | #include <string.h> | |
23 | #include <stdlib.h> | |
24 | /* Definitions for Windows/Unix exporting */ | |
25 | #if defined(__WIN32__) | |
26 | # if defined(_MSC_VER) | |
27 | # define SWIGEXPORT(a) __declspec(dllexport) a | |
28 | # else | |
29 | # if defined(__BORLANDC__) | |
9c4165ad | 30 | # define SWIGEXPORT(a) a _export |
c368d904 | 31 | # else |
9c4165ad | 32 | # define SWIGEXPORT(a) a |
c368d904 RD |
33 | # endif |
34 | # endif | |
35 | #else | |
9c4165ad | 36 | # define SWIGEXPORT(a) a |
c368d904 RD |
37 | #endif |
38 | ||
c368d904 RD |
39 | #ifdef __cplusplus |
40 | extern "C" { | |
41 | #endif | |
9c4165ad | 42 | #include "Python.h" |
c368d904 RD |
43 | extern void SWIG_MakePtr(char *, void *, char *); |
44 | extern void SWIG_RegisterMapping(char *, char *, void *(*)(void *)); | |
45 | extern char *SWIG_GetPtr(char *, void **, char *); | |
46 | extern char *SWIG_GetPtrObj(PyObject *, void **, char *); | |
47 | extern void SWIG_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *)); | |
48 | extern PyObject *SWIG_newvarlink(void); | |
49 | #ifdef __cplusplus | |
50 | } | |
51 | #endif | |
52 | #define SWIG_init initstreamsc | |
53 | ||
54 | #define SWIG_name "streamsc" | |
55 | ||
56 | #include "helpers.h" | |
57 | #include <wx/stream.h> | |
58 | #include <wx/list.h> | |
59 | ||
60 | static PyObject* l_output_helper(PyObject* target, PyObject* o) { | |
61 | PyObject* o2; | |
2cd2fac8 | 62 | if (!target) { |
c368d904 | 63 | target = o; |
2cd2fac8 | 64 | } else if (target == Py_None) { |
c368d904 RD |
65 | Py_DECREF(Py_None); |
66 | target = o; | |
2cd2fac8 | 67 | } else { |
c368d904 RD |
68 | if (!PyList_Check(target)) { |
69 | o2 = target; | |
70 | target = PyList_New(0); | |
71 | PyList_Append(target, o2); | |
72 | Py_XDECREF(o2); | |
73 | } | |
74 | PyList_Append(target,o); | |
75 | Py_XDECREF(o); | |
76 | } | |
77 | return target; | |
78 | } | |
79 | ||
80 | static PyObject* t_output_helper(PyObject* target, PyObject* o) { | |
81 | PyObject* o2; | |
82 | PyObject* o3; | |
83 | ||
2cd2fac8 | 84 | if (!target) { |
c368d904 | 85 | target = o; |
2cd2fac8 | 86 | } else if (target == Py_None) { |
c368d904 RD |
87 | Py_DECREF(Py_None); |
88 | target = o; | |
2cd2fac8 | 89 | } else { |
c368d904 RD |
90 | if (!PyTuple_Check(target)) { |
91 | o2 = target; | |
92 | target = PyTuple_New(1); | |
93 | PyTuple_SetItem(target, 0, o2); | |
94 | } | |
2cd2fac8 RD |
95 | o3 = PyTuple_New(1); |
96 | PyTuple_SetItem(o3, 0, o); | |
c368d904 RD |
97 | |
98 | o2 = target; | |
2cd2fac8 RD |
99 | target = PySequence_Concat(o2, o3); |
100 | Py_DECREF(o2); | |
c368d904 RD |
101 | Py_DECREF(o3); |
102 | } | |
103 | return target; | |
104 | } | |
105 | ||
106 | static char* wxStringErrorMsg = "string type is required for parameter"; | |
107 | // C++ | |
108 | // definitions of wxStringPtrList and wxPyInputStream | |
109 | #include <wx/listimpl.cpp> | |
110 | WX_DEFINE_LIST(wxStringPtrList); | |
111 | ||
112 | ||
113 | void wxPyInputStream::close() { | |
114 | /* do nothing */ | |
115 | } | |
116 | ||
117 | void wxPyInputStream::flush() { | |
118 | /*do nothing*/ | |
119 | } | |
120 | ||
121 | bool wxPyInputStream::eof() { | |
122 | if (wxi) | |
123 | return wxi->Eof(); | |
124 | else | |
125 | return TRUE; | |
126 | } | |
127 | ||
128 | wxPyInputStream::~wxPyInputStream() { | |
129 | /*do nothing*/ | |
130 | } | |
131 | ||
132 | wxString* wxPyInputStream::read(int size) { | |
133 | wxString* s = NULL; | |
134 | const int BUFSIZE = 1024; | |
135 | ||
136 | // check if we have a real wxInputStream to work with | |
137 | if (!wxi) { | |
138 | PyErr_SetString(PyExc_IOError,"no valid C-wxInputStream below"); | |
139 | return NULL; | |
140 | } | |
141 | ||
142 | if (size < 0) { | |
143 | // init buffers | |
144 | char * buf = new char[BUFSIZE]; | |
145 | if (!buf) { | |
146 | PyErr_NoMemory(); | |
147 | return NULL; | |
148 | } | |
149 | ||
150 | s = new wxString(); | |
151 | if (!s) { | |
152 | delete buf; | |
153 | PyErr_NoMemory(); | |
154 | return NULL; | |
155 | } | |
156 | ||
157 | // read until EOF | |
158 | wxPy_BEGIN_ALLOW_THREADS; | |
159 | while (! wxi->Eof()) { | |
160 | wxi->Read(buf, BUFSIZE); | |
161 | //*s += wxString(buf, wxi->LastRead()); | |
162 | s->Append(buf, wxi->LastRead()); | |
163 | } | |
164 | delete buf; | |
165 | wxPy_END_ALLOW_THREADS; | |
166 | ||
167 | // error check | |
168 | if (wxi->LastError() == wxSTREAM_READ_ERROR) { | |
169 | delete s; | |
170 | PyErr_SetString(PyExc_IOError,"IOError in wxInputStream"); | |
171 | return NULL; | |
172 | } | |
173 | ||
174 | } else { // Read only size number of characters | |
175 | s = new wxString; | |
176 | if (!s) { | |
177 | PyErr_NoMemory(); | |
178 | return NULL; | |
179 | } | |
180 | ||
181 | // read size bytes | |
182 | wxPy_BEGIN_ALLOW_THREADS; | |
183 | wxi->Read(s->GetWriteBuf(size+1), size); | |
184 | s->UngetWriteBuf(wxi->LastRead()); | |
185 | wxPy_END_ALLOW_THREADS; | |
186 | ||
187 | // error check | |
188 | if (wxi->LastError() == wxSTREAM_READ_ERROR) { | |
189 | delete s; | |
190 | PyErr_SetString(PyExc_IOError,"IOError in wxInputStream"); | |
191 | return NULL; | |
192 | } | |
193 | } | |
194 | return s; | |
195 | } | |
196 | ||
197 | ||
198 | wxString* wxPyInputStream::readline (int size) { | |
199 | // check if we have a real wxInputStream to work with | |
200 | if (!wxi) { | |
201 | PyErr_SetString(PyExc_IOError,"no valid C-wxInputStream below"); | |
202 | return NULL; | |
203 | } | |
204 | ||
205 | // init buffer | |
206 | int i; | |
207 | char ch; | |
208 | wxString* s = new wxString; | |
209 | if (!s) { | |
210 | PyErr_NoMemory(); | |
211 | return NULL; | |
212 | } | |
213 | ||
214 | // read until \n or byte limit reached | |
215 | wxPy_BEGIN_ALLOW_THREADS; | |
216 | for (i=ch=0; (ch != '\n') && (!wxi->Eof()) && ((size < 0) || (i < size)); i++) { | |
217 | *s += ch = wxi->GetC(); | |
218 | } | |
219 | wxPy_END_ALLOW_THREADS; | |
220 | ||
221 | // errorcheck | |
222 | if (wxi->LastError() == wxSTREAM_READ_ERROR) { | |
223 | delete s; | |
224 | PyErr_SetString(PyExc_IOError,"IOError in wxInputStream"); | |
225 | return NULL; | |
226 | } | |
227 | return s; | |
228 | } | |
229 | ||
230 | ||
231 | wxStringPtrList* wxPyInputStream::readlines (int sizehint) { | |
232 | // check if we have a real wxInputStream to work with | |
233 | if (!wxi) { | |
234 | PyErr_SetString(PyExc_IOError,"no valid C-wxInputStream below"); | |
235 | return NULL; | |
236 | } | |
237 | ||
238 | // init list | |
239 | wxStringPtrList* l = new wxStringPtrList(); | |
240 | if (!l) { | |
241 | PyErr_NoMemory(); | |
242 | return NULL; | |
243 | } | |
244 | ||
245 | // read sizehint bytes or until EOF | |
246 | wxPy_BEGIN_ALLOW_THREADS; | |
247 | int i; | |
248 | for (i=0; (!wxi->Eof()) && ((sizehint < 0) || (i < sizehint));) { | |
249 | wxString* s = readline(); | |
250 | if (s == NULL) { | |
251 | l->DeleteContents(TRUE); | |
252 | l->Clear(); | |
253 | return NULL; | |
254 | } | |
255 | l->Append(s); | |
256 | i = i + s->Length(); | |
257 | } | |
258 | wxPy_END_ALLOW_THREADS; | |
259 | ||
260 | // error check | |
261 | if (wxi->LastError() == wxSTREAM_READ_ERROR) { | |
262 | l->DeleteContents(TRUE); | |
263 | l->Clear(); | |
264 | PyErr_SetString(PyExc_IOError,"IOError in wxInputStream"); | |
265 | return NULL; | |
266 | } | |
267 | return l; | |
268 | } | |
269 | ||
270 | ||
271 | void wxPyInputStream::seek(int offset, int whence) { | |
272 | if (wxi) | |
273 | wxi->SeekI(offset, wxSeekMode(whence)); | |
274 | } | |
275 | ||
276 | int wxPyInputStream::tell(){ | |
277 | if (wxi) | |
278 | return wxi->TellI(); | |
279 | } | |
280 | ||
281 | ||
282 | ||
283 | // wxInputStream which operates on a Python file-like object | |
284 | class wxPyCBInputStream : public wxInputStream { | |
285 | protected: | |
286 | PyObject* read; | |
287 | PyObject* seek; | |
288 | PyObject* tell; | |
289 | PyObject* py; | |
290 | ||
291 | virtual size_t OnSysRead(void *buffer, size_t bufsize) { | |
292 | if (bufsize == 0) | |
293 | return 0; | |
294 | ||
295 | bool doSave = wxPyRestoreThread(); | |
296 | PyObject* arglist = Py_BuildValue("(i)", bufsize); | |
297 | PyObject* result = PyEval_CallObject(read, arglist); | |
298 | Py_DECREF(arglist); | |
299 | ||
300 | size_t o = 0; | |
301 | if ((result != NULL) && PyString_Check(result)) { | |
302 | o = PyString_Size(result); | |
303 | if (o == 0) | |
304 | m_lasterror = wxSTREAM_EOF; | |
305 | if (o > bufsize) | |
306 | o = bufsize; | |
307 | strncpy((char*)buffer, PyString_AsString(result), o); | |
308 | Py_DECREF(result); | |
309 | ||
310 | } | |
311 | else | |
312 | m_lasterror = wxSTREAM_READ_ERROR; | |
313 | wxPySaveThread(doSave); | |
314 | m_lastcount = o; | |
315 | return o; | |
316 | } | |
317 | ||
318 | virtual size_t OnSysWrite(const void *buffer, size_t bufsize){ | |
319 | m_lasterror = wxSTREAM_WRITE_ERROR; | |
320 | return 0; | |
321 | } | |
322 | ||
323 | virtual off_t OnSysSeek(off_t off, wxSeekMode mode){ | |
324 | bool doSave = wxPyRestoreThread(); | |
325 | PyObject*arglist = Py_BuildValue("(ii)", off, mode); | |
326 | PyObject*result = PyEval_CallObject(seek, arglist); | |
327 | Py_DECREF(arglist); | |
328 | Py_XDECREF(result); | |
329 | wxPySaveThread(doSave); | |
330 | return OnSysTell(); | |
331 | } | |
332 | ||
333 | virtual off_t OnSysTell() const{ | |
334 | bool doSave = wxPyRestoreThread(); | |
335 | PyObject* arglist = Py_BuildValue("()"); | |
336 | PyObject* result = PyEval_CallObject(tell, arglist); | |
337 | Py_DECREF(arglist); | |
338 | off_t o = 0; | |
339 | if (result != NULL) { | |
340 | o = PyInt_AsLong(result); | |
341 | Py_DECREF(result); | |
342 | }; | |
343 | wxPySaveThread(doSave); | |
344 | return o; | |
345 | } | |
346 | ||
347 | wxPyCBInputStream(PyObject *p, PyObject *r, PyObject *s, PyObject *t) | |
348 | : py(p), read(r), seek(s), tell(t) | |
349 | {} | |
350 | ||
351 | public: | |
352 | ~wxPyCBInputStream() { | |
353 | bool doSave = wxPyRestoreThread(); | |
354 | Py_XDECREF(py); | |
355 | Py_XDECREF(read); | |
356 | Py_XDECREF(seek); | |
357 | Py_XDECREF(tell); | |
358 | wxPySaveThread(doSave); | |
359 | } | |
360 | ||
361 | virtual size_t GetSize() { | |
362 | if (seek && tell) { | |
363 | off_t temp = OnSysTell(); | |
364 | off_t ret = OnSysSeek(0, wxFromEnd); | |
365 | OnSysSeek(temp, wxFromStart); | |
366 | return ret; | |
367 | } | |
368 | else | |
369 | return 0; | |
370 | } | |
371 | ||
372 | static wxPyCBInputStream* create(PyObject *py) { | |
373 | PyObject* read; | |
374 | PyObject* seek; | |
375 | PyObject* tell; | |
376 | ||
377 | if (!PyInstance_Check(py) && !PyFile_Check(py)) { | |
378 | PyErr_SetString(PyExc_TypeError, "Not a file-like object"); | |
379 | Py_XDECREF(py); | |
380 | return NULL; | |
381 | } | |
382 | read = getMethod(py, "read"); | |
383 | seek = getMethod(py, "seek"); | |
384 | tell = getMethod(py, "tell"); | |
385 | ||
386 | if (!read) { | |
387 | PyErr_SetString(PyExc_TypeError, "Not a file-like object"); | |
388 | Py_XDECREF(py); | |
389 | Py_XDECREF(read); | |
390 | Py_XDECREF(seek); | |
391 | Py_XDECREF(tell); | |
392 | return NULL; | |
393 | } | |
394 | return new wxPyCBInputStream(py, read, seek, tell); | |
395 | } | |
396 | ||
397 | static PyObject* getMethod(PyObject* py, char* name) { | |
398 | if (!PyObject_HasAttrString(py, name)) | |
399 | return NULL; | |
400 | PyObject* o = PyObject_GetAttrString(py, name); | |
2cd2fac8 RD |
401 | if (!PyMethod_Check(o) && !PyCFunction_Check(o)) { |
402 | Py_DECREF(o); | |
c368d904 | 403 | return NULL; |
2cd2fac8 | 404 | } |
c368d904 RD |
405 | return o; |
406 | } | |
407 | ||
408 | protected: | |
409 | ||
410 | }; | |
411 | ||
412 | #ifdef __cplusplus | |
413 | extern "C" { | |
414 | #endif | |
415 | static wxPyInputStream *new_wxPyInputStream(PyObject *p) { | |
416 | wxInputStream* wxi = wxPyCBInputStream::create(p); | |
417 | if (wxi) | |
418 | return new wxPyInputStream(wxi); | |
419 | else | |
420 | return NULL; | |
421 | } | |
422 | ||
423 | static PyObject *_wrap_new_wxInputStream(PyObject *self, PyObject *args, PyObject *kwargs) { | |
424 | PyObject * _resultobj; | |
425 | wxPyInputStream * _result; | |
426 | PyObject * _arg0; | |
427 | PyObject * _obj0 = 0; | |
428 | char *_kwnames[] = { "p", NULL }; | |
429 | ||
430 | self = self; | |
431 | if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:new_wxInputStream",_kwnames,&_obj0)) | |
432 | return NULL; | |
433 | { | |
434 | _arg0 = _obj0; | |
435 | } | |
436 | { | |
437 | _result = (wxPyInputStream *)new_wxPyInputStream(_arg0); | |
438 | ||
439 | }{ | |
440 | char _ptemp[128]; | |
441 | if (_result) { | |
442 | SWIG_MakePtr(_ptemp, (char *) _result,"_wxPyInputStream_p"); | |
443 | _resultobj = Py_BuildValue("s",_ptemp); | |
444 | } | |
445 | else | |
446 | _resultobj=0; | |
447 | } | |
448 | return _resultobj; | |
449 | } | |
450 | ||
451 | #define wxInputStream_close(_swigobj) (_swigobj->close()) | |
452 | static PyObject *_wrap_wxInputStream_close(PyObject *self, PyObject *args, PyObject *kwargs) { | |
453 | PyObject * _resultobj; | |
454 | wxPyInputStream * _arg0; | |
455 | PyObject * _argo0 = 0; | |
456 | char *_kwnames[] = { "self", NULL }; | |
457 | ||
458 | self = self; | |
459 | if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxInputStream_close",_kwnames,&_argo0)) | |
460 | return NULL; | |
461 | if (_argo0) { | |
462 | if (_argo0 == Py_None) { _arg0 = NULL; } | |
463 | else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyInputStream_p")) { | |
464 | PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxInputStream_close. Expected _wxPyInputStream_p."); | |
465 | return NULL; | |
466 | } | |
467 | } | |
468 | { | |
469 | wxInputStream_close(_arg0); | |
470 | ||
471 | } Py_INCREF(Py_None); | |
472 | _resultobj = Py_None; | |
473 | return _resultobj; | |
474 | } | |
475 | ||
476 | #define wxInputStream_flush(_swigobj) (_swigobj->flush()) | |
477 | static PyObject *_wrap_wxInputStream_flush(PyObject *self, PyObject *args, PyObject *kwargs) { | |
478 | PyObject * _resultobj; | |
479 | wxPyInputStream * _arg0; | |
480 | PyObject * _argo0 = 0; | |
481 | char *_kwnames[] = { "self", NULL }; | |
482 | ||
483 | self = self; | |
484 | if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxInputStream_flush",_kwnames,&_argo0)) | |
485 | return NULL; | |
486 | if (_argo0) { | |
487 | if (_argo0 == Py_None) { _arg0 = NULL; } | |
488 | else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyInputStream_p")) { | |
489 | PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxInputStream_flush. Expected _wxPyInputStream_p."); | |
490 | return NULL; | |
491 | } | |
492 | } | |
493 | { | |
494 | wxInputStream_flush(_arg0); | |
495 | ||
496 | } Py_INCREF(Py_None); | |
497 | _resultobj = Py_None; | |
498 | return _resultobj; | |
499 | } | |
500 | ||
501 | #define wxInputStream_eof(_swigobj) (_swigobj->eof()) | |
502 | static PyObject *_wrap_wxInputStream_eof(PyObject *self, PyObject *args, PyObject *kwargs) { | |
503 | PyObject * _resultobj; | |
504 | bool _result; | |
505 | wxPyInputStream * _arg0; | |
506 | PyObject * _argo0 = 0; | |
507 | char *_kwnames[] = { "self", NULL }; | |
508 | ||
509 | self = self; | |
510 | if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxInputStream_eof",_kwnames,&_argo0)) | |
511 | return NULL; | |
512 | if (_argo0) { | |
513 | if (_argo0 == Py_None) { _arg0 = NULL; } | |
514 | else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyInputStream_p")) { | |
515 | PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxInputStream_eof. Expected _wxPyInputStream_p."); | |
516 | return NULL; | |
517 | } | |
518 | } | |
519 | { | |
520 | _result = (bool )wxInputStream_eof(_arg0); | |
521 | ||
522 | } _resultobj = Py_BuildValue("i",_result); | |
523 | return _resultobj; | |
524 | } | |
525 | ||
526 | #define wxInputStream_read(_swigobj,_swigarg0) (_swigobj->read(_swigarg0)) | |
527 | static PyObject *_wrap_wxInputStream_read(PyObject *self, PyObject *args, PyObject *kwargs) { | |
528 | PyObject * _resultobj; | |
529 | wxString * _result; | |
530 | wxPyInputStream * _arg0; | |
531 | int _arg1 = (int ) -1; | |
532 | PyObject * _argo0 = 0; | |
533 | char *_kwnames[] = { "self","size", NULL }; | |
534 | ||
535 | self = self; | |
536 | if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O|i:wxInputStream_read",_kwnames,&_argo0,&_arg1)) | |
537 | return NULL; | |
538 | if (_argo0) { | |
539 | if (_argo0 == Py_None) { _arg0 = NULL; } | |
540 | else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyInputStream_p")) { | |
541 | PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxInputStream_read. Expected _wxPyInputStream_p."); | |
542 | return NULL; | |
543 | } | |
544 | } | |
545 | { | |
546 | _result = (wxString *)wxInputStream_read(_arg0,_arg1); | |
547 | ||
548 | }{ | |
549 | if (_result) { | |
550 | _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len()); | |
551 | delete _result; | |
552 | } | |
553 | else | |
554 | _resultobj=0; | |
555 | } | |
556 | return _resultobj; | |
557 | } | |
558 | ||
559 | #define wxInputStream_readline(_swigobj,_swigarg0) (_swigobj->readline(_swigarg0)) | |
560 | static PyObject *_wrap_wxInputStream_readline(PyObject *self, PyObject *args, PyObject *kwargs) { | |
561 | PyObject * _resultobj; | |
562 | wxString * _result; | |
563 | wxPyInputStream * _arg0; | |
564 | int _arg1 = (int ) -1; | |
565 | PyObject * _argo0 = 0; | |
566 | char *_kwnames[] = { "self","size", NULL }; | |
567 | ||
568 | self = self; | |
569 | if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O|i:wxInputStream_readline",_kwnames,&_argo0,&_arg1)) | |
570 | return NULL; | |
571 | if (_argo0) { | |
572 | if (_argo0 == Py_None) { _arg0 = NULL; } | |
573 | else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyInputStream_p")) { | |
574 | PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxInputStream_readline. Expected _wxPyInputStream_p."); | |
575 | return NULL; | |
576 | } | |
577 | } | |
578 | { | |
579 | _result = (wxString *)wxInputStream_readline(_arg0,_arg1); | |
580 | ||
581 | }{ | |
582 | if (_result) { | |
583 | _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len()); | |
584 | delete _result; | |
585 | } | |
586 | else | |
587 | _resultobj=0; | |
588 | } | |
589 | return _resultobj; | |
590 | } | |
591 | ||
592 | #define wxInputStream_readlines(_swigobj,_swigarg0) (_swigobj->readlines(_swigarg0)) | |
593 | static PyObject *_wrap_wxInputStream_readlines(PyObject *self, PyObject *args, PyObject *kwargs) { | |
594 | PyObject * _resultobj; | |
595 | wxStringPtrList * _result; | |
596 | wxPyInputStream * _arg0; | |
597 | int _arg1 = (int ) -1; | |
598 | PyObject * _argo0 = 0; | |
599 | char *_kwnames[] = { "self","sizehint", NULL }; | |
600 | ||
601 | self = self; | |
602 | if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O|i:wxInputStream_readlines",_kwnames,&_argo0,&_arg1)) | |
603 | return NULL; | |
604 | if (_argo0) { | |
605 | if (_argo0 == Py_None) { _arg0 = NULL; } | |
606 | else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyInputStream_p")) { | |
607 | PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxInputStream_readlines. Expected _wxPyInputStream_p."); | |
608 | return NULL; | |
609 | } | |
610 | } | |
611 | { | |
612 | _result = (wxStringPtrList *)wxInputStream_readlines(_arg0,_arg1); | |
613 | ||
614 | }{ | |
615 | if (_result) { | |
616 | _resultobj = PyList_New(_result->GetCount()); | |
617 | wxStringPtrList::Node *node = _result->GetFirst(); | |
618 | for (int i=0; node; i++) { | |
619 | wxString *s = node->GetData(); | |
620 | PyList_SetItem(_resultobj, i, PyString_FromStringAndSize(s->c_str(), s->Len())); | |
621 | node = node->GetNext(); | |
622 | delete s; | |
623 | } | |
624 | delete _result; | |
625 | } | |
626 | else | |
627 | _resultobj=0; | |
628 | } | |
629 | return _resultobj; | |
630 | } | |
631 | ||
632 | #define wxInputStream_seek(_swigobj,_swigarg0,_swigarg1) (_swigobj->seek(_swigarg0,_swigarg1)) | |
633 | static PyObject *_wrap_wxInputStream_seek(PyObject *self, PyObject *args, PyObject *kwargs) { | |
634 | PyObject * _resultobj; | |
635 | wxPyInputStream * _arg0; | |
636 | int _arg1; | |
637 | int _arg2 = (int ) 0; | |
638 | PyObject * _argo0 = 0; | |
639 | char *_kwnames[] = { "self","offset","whence", NULL }; | |
640 | ||
641 | self = self; | |
642 | if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi|i:wxInputStream_seek",_kwnames,&_argo0,&_arg1,&_arg2)) | |
643 | return NULL; | |
644 | if (_argo0) { | |
645 | if (_argo0 == Py_None) { _arg0 = NULL; } | |
646 | else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyInputStream_p")) { | |
647 | PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxInputStream_seek. Expected _wxPyInputStream_p."); | |
648 | return NULL; | |
649 | } | |
650 | } | |
651 | { | |
652 | wxInputStream_seek(_arg0,_arg1,_arg2); | |
653 | ||
654 | } Py_INCREF(Py_None); | |
655 | _resultobj = Py_None; | |
656 | return _resultobj; | |
657 | } | |
658 | ||
659 | #define wxInputStream_tell(_swigobj) (_swigobj->tell()) | |
660 | static PyObject *_wrap_wxInputStream_tell(PyObject *self, PyObject *args, PyObject *kwargs) { | |
661 | PyObject * _resultobj; | |
662 | int _result; | |
663 | wxPyInputStream * _arg0; | |
664 | PyObject * _argo0 = 0; | |
665 | char *_kwnames[] = { "self", NULL }; | |
666 | ||
667 | self = self; | |
668 | if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxInputStream_tell",_kwnames,&_argo0)) | |
669 | return NULL; | |
670 | if (_argo0) { | |
671 | if (_argo0 == Py_None) { _arg0 = NULL; } | |
672 | else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyInputStream_p")) { | |
673 | PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxInputStream_tell. Expected _wxPyInputStream_p."); | |
674 | return NULL; | |
675 | } | |
676 | } | |
677 | { | |
678 | _result = (int )wxInputStream_tell(_arg0); | |
679 | ||
680 | } _resultobj = Py_BuildValue("i",_result); | |
681 | return _resultobj; | |
682 | } | |
683 | ||
684 | static void wxOutputStream_write(wxOutputStream *self,const wxString & str) { | |
685 | self->Write(str.c_str(), str.Length()); | |
686 | } | |
687 | static PyObject *_wrap_wxOutputStream_write(PyObject *self, PyObject *args, PyObject *kwargs) { | |
688 | PyObject * _resultobj; | |
689 | wxOutputStream * _arg0; | |
690 | wxString * _arg1; | |
691 | PyObject * _argo0 = 0; | |
692 | PyObject * _obj1 = 0; | |
693 | char *_kwnames[] = { "self","str", NULL }; | |
694 | ||
695 | self = self; | |
696 | if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxOutputStream_write",_kwnames,&_argo0,&_obj1)) | |
697 | return NULL; | |
698 | if (_argo0) { | |
699 | if (_argo0 == Py_None) { _arg0 = NULL; } | |
700 | else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxOutputStream_p")) { | |
701 | PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxOutputStream_write. Expected _wxOutputStream_p."); | |
702 | return NULL; | |
703 | } | |
704 | } | |
705 | { | |
2cd2fac8 RD |
706 | #if PYTHON_API_VERSION >= 1009 |
707 | char* tmpPtr; int tmpSize; | |
708 | if (!PyString_Check(_obj1) && !PyUnicode_Check(_obj1)) { | |
709 | PyErr_SetString(PyExc_TypeError, "String or Unicode type required"); | |
710 | return NULL; | |
711 | } | |
712 | if (PyString_AsStringAndSize(_obj1, &tmpPtr, &tmpSize) == -1) | |
713 | return NULL; | |
714 | _arg1 = new wxString(tmpPtr, tmpSize); | |
715 | #else | |
c368d904 RD |
716 | if (!PyString_Check(_obj1)) { |
717 | PyErr_SetString(PyExc_TypeError, wxStringErrorMsg); | |
718 | return NULL; | |
719 | } | |
2cd2fac8 RD |
720 | _arg1 = new wxString(PyString_AS_STRING(_obj1), PyString_GET_SIZE(_obj1)); |
721 | #endif | |
c368d904 RD |
722 | } |
723 | { | |
724 | wxOutputStream_write(_arg0,*_arg1); | |
725 | ||
726 | } Py_INCREF(Py_None); | |
727 | _resultobj = Py_None; | |
728 | { | |
729 | if (_obj1) | |
730 | delete _arg1; | |
731 | } | |
732 | return _resultobj; | |
733 | } | |
734 | ||
735 | static PyMethodDef streamscMethods[] = { | |
736 | { "wxOutputStream_write", (PyCFunction) _wrap_wxOutputStream_write, METH_VARARGS | METH_KEYWORDS }, | |
737 | { "wxInputStream_tell", (PyCFunction) _wrap_wxInputStream_tell, METH_VARARGS | METH_KEYWORDS }, | |
738 | { "wxInputStream_seek", (PyCFunction) _wrap_wxInputStream_seek, METH_VARARGS | METH_KEYWORDS }, | |
739 | { "wxInputStream_readlines", (PyCFunction) _wrap_wxInputStream_readlines, METH_VARARGS | METH_KEYWORDS }, | |
740 | { "wxInputStream_readline", (PyCFunction) _wrap_wxInputStream_readline, METH_VARARGS | METH_KEYWORDS }, | |
741 | { "wxInputStream_read", (PyCFunction) _wrap_wxInputStream_read, METH_VARARGS | METH_KEYWORDS }, | |
742 | { "wxInputStream_eof", (PyCFunction) _wrap_wxInputStream_eof, METH_VARARGS | METH_KEYWORDS }, | |
743 | { "wxInputStream_flush", (PyCFunction) _wrap_wxInputStream_flush, METH_VARARGS | METH_KEYWORDS }, | |
744 | { "wxInputStream_close", (PyCFunction) _wrap_wxInputStream_close, METH_VARARGS | METH_KEYWORDS }, | |
745 | { "new_wxInputStream", (PyCFunction) _wrap_new_wxInputStream, METH_VARARGS | METH_KEYWORDS }, | |
746 | { NULL, NULL } | |
747 | }; | |
748 | #ifdef __cplusplus | |
749 | } | |
750 | #endif | |
751 | /* | |
752 | * This table is used by the pointer type-checker | |
753 | */ | |
754 | static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { | |
755 | { "_signed_long","_long",0}, | |
756 | { "_wxPrintQuality","_wxCoord",0}, | |
757 | { "_wxPrintQuality","_int",0}, | |
758 | { "_wxPrintQuality","_signed_int",0}, | |
759 | { "_wxPrintQuality","_unsigned_int",0}, | |
760 | { "_wxPrintQuality","_wxWindowID",0}, | |
761 | { "_wxPrintQuality","_uint",0}, | |
762 | { "_wxPrintQuality","_EBool",0}, | |
763 | { "_wxPrintQuality","_size_t",0}, | |
764 | { "_wxPrintQuality","_time_t",0}, | |
765 | { "_byte","_unsigned_char",0}, | |
766 | { "_long","_unsigned_long",0}, | |
767 | { "_long","_signed_long",0}, | |
768 | { "_size_t","_wxCoord",0}, | |
769 | { "_size_t","_wxPrintQuality",0}, | |
770 | { "_size_t","_time_t",0}, | |
771 | { "_size_t","_unsigned_int",0}, | |
772 | { "_size_t","_int",0}, | |
773 | { "_size_t","_wxWindowID",0}, | |
774 | { "_size_t","_uint",0}, | |
775 | { "_uint","_wxCoord",0}, | |
776 | { "_uint","_wxPrintQuality",0}, | |
777 | { "_uint","_time_t",0}, | |
778 | { "_uint","_size_t",0}, | |
779 | { "_uint","_unsigned_int",0}, | |
780 | { "_uint","_int",0}, | |
781 | { "_uint","_wxWindowID",0}, | |
782 | { "_wxChar","_char",0}, | |
783 | { "_char","_wxChar",0}, | |
784 | { "_EBool","_wxCoord",0}, | |
785 | { "_EBool","_wxPrintQuality",0}, | |
786 | { "_EBool","_signed_int",0}, | |
787 | { "_EBool","_int",0}, | |
788 | { "_EBool","_wxWindowID",0}, | |
789 | { "_unsigned_long","_long",0}, | |
790 | { "_wxPyInputStream","_class_wxPyInputStream",0}, | |
791 | { "_class_wxOutputStream","_wxOutputStream",0}, | |
792 | { "_signed_int","_wxCoord",0}, | |
793 | { "_signed_int","_wxPrintQuality",0}, | |
794 | { "_signed_int","_EBool",0}, | |
795 | { "_signed_int","_wxWindowID",0}, | |
796 | { "_signed_int","_int",0}, | |
797 | { "_WXTYPE","_short",0}, | |
798 | { "_WXTYPE","_signed_short",0}, | |
799 | { "_WXTYPE","_unsigned_short",0}, | |
800 | { "_unsigned_short","_WXTYPE",0}, | |
801 | { "_unsigned_short","_short",0}, | |
802 | { "_class_wxPyInputStream","_wxPyInputStream",0}, | |
803 | { "_signed_short","_WXTYPE",0}, | |
804 | { "_signed_short","_short",0}, | |
805 | { "_unsigned_char","_byte",0}, | |
806 | { "_unsigned_int","_wxCoord",0}, | |
807 | { "_unsigned_int","_wxPrintQuality",0}, | |
808 | { "_unsigned_int","_time_t",0}, | |
809 | { "_unsigned_int","_size_t",0}, | |
810 | { "_unsigned_int","_uint",0}, | |
811 | { "_unsigned_int","_wxWindowID",0}, | |
812 | { "_unsigned_int","_int",0}, | |
813 | { "_short","_WXTYPE",0}, | |
814 | { "_short","_unsigned_short",0}, | |
815 | { "_short","_signed_short",0}, | |
816 | { "_wxWindowID","_wxCoord",0}, | |
817 | { "_wxWindowID","_wxPrintQuality",0}, | |
818 | { "_wxWindowID","_time_t",0}, | |
819 | { "_wxWindowID","_size_t",0}, | |
820 | { "_wxWindowID","_EBool",0}, | |
821 | { "_wxWindowID","_uint",0}, | |
822 | { "_wxWindowID","_int",0}, | |
823 | { "_wxWindowID","_signed_int",0}, | |
824 | { "_wxWindowID","_unsigned_int",0}, | |
825 | { "_int","_wxCoord",0}, | |
826 | { "_int","_wxPrintQuality",0}, | |
827 | { "_int","_time_t",0}, | |
828 | { "_int","_size_t",0}, | |
829 | { "_int","_EBool",0}, | |
830 | { "_int","_uint",0}, | |
831 | { "_int","_wxWindowID",0}, | |
832 | { "_int","_unsigned_int",0}, | |
833 | { "_int","_signed_int",0}, | |
834 | { "_time_t","_wxCoord",0}, | |
835 | { "_time_t","_wxPrintQuality",0}, | |
836 | { "_time_t","_unsigned_int",0}, | |
837 | { "_time_t","_int",0}, | |
838 | { "_time_t","_wxWindowID",0}, | |
839 | { "_time_t","_uint",0}, | |
840 | { "_time_t","_size_t",0}, | |
841 | { "_wxCoord","_int",0}, | |
842 | { "_wxCoord","_signed_int",0}, | |
843 | { "_wxCoord","_unsigned_int",0}, | |
844 | { "_wxCoord","_wxWindowID",0}, | |
845 | { "_wxCoord","_uint",0}, | |
846 | { "_wxCoord","_EBool",0}, | |
847 | { "_wxCoord","_size_t",0}, | |
848 | { "_wxCoord","_time_t",0}, | |
849 | { "_wxCoord","_wxPrintQuality",0}, | |
850 | { "_wxOutputStream","_class_wxOutputStream",0}, | |
851 | {0,0,0}}; | |
852 | ||
853 | static PyObject *SWIG_globals; | |
854 | #ifdef __cplusplus | |
855 | extern "C" | |
856 | #endif | |
857 | SWIGEXPORT(void) initstreamsc() { | |
858 | PyObject *m, *d; | |
859 | SWIG_globals = SWIG_newvarlink(); | |
860 | m = Py_InitModule("streamsc", streamscMethods); | |
861 | d = PyModule_GetDict(m); | |
862 | { | |
863 | int i; | |
864 | for (i = 0; _swig_mapping[i].n1; i++) | |
865 | SWIG_RegisterMapping(_swig_mapping[i].n1,_swig_mapping[i].n2,_swig_mapping[i].pcnv); | |
866 | } | |
867 | } |