]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_streams.i
Add flags parameter to wx.Process.Kill and wx.Kill
[wxWidgets.git] / wxPython / src / _streams.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _streams.i
3 // Purpose: SWIG typemaps and wrappers for wxInputStream
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 25-Sept-2000
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
18 %{
19 #include "wx/wxPython/pyistream.h"
20 %}
21
22 //---------------------------------------------------------------------------
23 %newgroup
24
25
26 // typemaps for wxInputStream
27 %typemap(in) wxInputStream* (wxPyInputStream* temp, bool created) {
28 if (wxPyConvertSwigPtr($input, (void **)&temp, wxT("wxPyInputStream"))) {
29 $1 = temp->m_wxis;
30 created = false;
31 } else {
32 PyErr_Clear(); // clear the failure of the wxPyConvert above
33 $1 = wxPyCBInputStream_create($input, false);
34 if ($1 == NULL) {
35 PyErr_SetString(PyExc_TypeError, "Expected wxInputStream or Python file-like object.");
36 SWIG_fail;
37 }
38 created = true;
39 }
40 }
41 %typemap(freearg) wxInputStream* {
42 if (created$argnum)
43 delete $1;
44 }
45
46
47 %typemap(in) wxInputStream& = wxInputStream*;
48 %typemap(freearg) wxInputStream& = wxInputStream*;
49
50
51 %typemap(out) wxInputStream* {
52 wxPyInputStream * _ptr = NULL;
53
54 if ($1) {
55 _ptr = new wxPyInputStream($1);
56 }
57 $result = wxPyConstructObject(_ptr, wxT("wxPyInputStream"), $owner);
58 }
59
60
61 //---------------------------------------------------------------------------
62
63 enum wxSeekMode
64 {
65 wxFromStart,
66 wxFromCurrent,
67 wxFromEnd
68 };
69
70
71 %name(InputStream) class wxPyInputStream {
72 public:
73 %extend {
74 wxPyInputStream(PyObject* p) {
75 wxInputStream* wxis = wxPyCBInputStream::create(p);
76 if (wxis)
77 return new wxPyInputStream(wxis);
78 else
79 return NULL;
80 }
81 }
82 ~wxPyInputStream();
83
84 void close();
85 void flush();
86 bool eof();
87 PyObject* read(int size=-1);
88 PyObject* readline(int size=-1);
89 PyObject* readlines(int sizehint=-1);
90 void seek(int offset, int whence=0);
91 int tell();
92
93 /*
94 bool isatty();
95 int fileno();
96 void truncate(int size=-1);
97 void write(wxString data);
98 void writelines(wxStringPtrList);
99 */
100
101 char Peek();
102 char GetC();
103 size_t LastRead();
104 bool CanRead();
105 bool Eof();
106 bool Ungetch(char c);
107
108 long SeekI(long pos, wxSeekMode mode = wxFromStart);
109 long TellI();
110 };
111
112
113
114 // TODO: make a more fully implemented file interface...
115 class wxOutputStream {
116 public:
117 /*
118 void close();
119 void flush();
120 wxString* read(int size=-1);
121 wxString* readline(int size=-1);
122 wxStringPtrList* readlines(int sizehint=-1);
123 void seek(int offset, int whence=0);
124 int tell();
125 bool isatty();
126 int fileno();
127 void truncate(int size=-1);
128 void write(wxString data);
129 void writelines(wxStringPtrList);
130 */
131
132 %extend {
133 void write(PyObject* obj) {
134 // We use only strings for the streams, not unicode
135 PyObject* str = PyObject_Str(obj);
136 if (! str) {
137 PyErr_SetString(PyExc_TypeError, "Unable to convert to string");
138 return;
139 }
140 self->Write(PyString_AS_STRING(str),
141 PyString_GET_SIZE(str));
142 Py_DECREF(str);
143 }
144 }
145 };
146
147
148 //---------------------------------------------------------------------------
149 %init %{
150 wxPyPtrTypeMap_Add("wxInputStream", "wxPyInputStream");
151 %}
152 //---------------------------------------------------------------------------