]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/streams.i
Typo fix for GetSizer.
[wxWidgets.git] / wxPython / src / streams.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: streams.i
3 // Purpose: SWIG definitions of the wxFileSystem family of classes
4 //
5 // Author: Joerg Baumann
6 //
7 // Created: 25-Sept-2000
8 // RCS-ID: $Id$
9 // Copyright: (c) 2000 by Joerg Baumann
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module streams
14
15 %{
16 #include "helpers.h"
17 #include <wx/stream.h>
18 #include <wx/list.h>
19 %}
20
21 //----------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 // Import some definitions of other classes, etc.
27 %import _defs.i
28
29 %pragma(python) code = "import wx"
30 %pragma(python) code = "import string"
31
32 //----------------------------------------------------------------------
33 // typemaps for wxInputStream
34
35
36 %typemap(python,in) wxInputStream * (wxPyInputStream* temp, bool created) {
37 if (SWIG_GetPtrObj($source, (void **) &temp, "_wxPyInputStream_p") == 0) {
38 $target = temp->m_wxis;
39 created = FALSE;
40 } else {
41 $target = wxPyCBInputStream::create($source, FALSE);
42 if ($target == NULL) {
43 PyErr_SetString(PyExc_TypeError,"Expected _wxInputStream_p or Python file-like object.");
44 return NULL;
45 }
46 created = TRUE;
47 }
48 }
49
50 %typemap(python, freearg) wxInputStream * {
51 if (created)
52 delete $source;
53 }
54
55
56 // typemaps for wxInputStream
57 %typemap(python,out) wxInputStream* {
58 wxPyInputStream * _ptr = NULL;
59
60 if ($source) {
61 _ptr = new wxPyInputStream($source);
62 }
63 $target = wxPyConstructObject(_ptr, "wxInputStream", TRUE);
64 }
65
66 //----------------------------------------------------------------------
67
68
69 // wxStringPtrList* to python list of strings typemap
70 %typemap(python, out) wxStringPtrList* {
71 if ($source) {
72 $target = PyList_New($source->GetCount());
73 wxStringPtrList::Node *node = $source->GetFirst();
74 for (int i=0; node; i++) {
75 wxString *s = node->GetData();
76 PyList_SetItem($target, i, PyString_FromStringAndSize(s->c_str(), s->Len()));
77 node = node->GetNext();
78 delete s;
79 }
80 delete $source;
81 }
82 else
83 $target=0;
84 }
85
86
87
88
89 %name(wxInputStream) class wxPyInputStream {
90 public:
91 %addmethods {
92 wxPyInputStream(PyObject* p) {
93 wxInputStream* wxis = wxPyCBInputStream::create(p);
94 if (wxis)
95 return new wxPyInputStream(wxis);
96 else
97 return NULL;
98 }
99 }
100 void close();
101 void flush();
102 bool eof();
103 wxString* read(int size=-1);
104 wxString* readline(int size=-1);
105 wxStringPtrList* readlines(int sizehint=-1);
106 void seek(int offset, int whence=0);
107 int tell();
108
109 /*
110 bool isatty();
111 int fileno();
112 void truncate(int size=-1);
113 void write(wxString data);
114 void writelines(wxStringPtrList);
115 */
116 }
117
118
119
120 // TODO: make a more fully implemented file interface...
121 class wxOutputStream {
122 public:
123 /*
124 void close();
125 void flush();
126 wxString* read(int size=-1);
127 wxString* readline(int size=-1);
128 wxStringPtrList* readlines(int sizehint=-1);
129 void seek(int offset, int whence=0);
130 int tell();
131 bool isatty();
132 int fileno();
133 void truncate(int size=-1);
134 void write(wxString data);
135 void writelines(wxStringPtrList);
136 */
137
138 %addmethods {
139 void write(const wxString& str) {
140 self->Write(str.c_str(), str.Length());
141 }
142 }
143 };
144
145
146 // restore except and typemaps
147 %typemap(python,out) wxStringPtrList*;
148 %typemap(python,out) wxPyInputStream*;
149
150
151 //----------------------------------------------------------------------
152
153 %init %{
154 wxPyPtrTypeMap_Add("wxInputStream", "wxPyInputStream");
155 %}
156
157 //----------------------------------------------------------------------