]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/my_typemaps.i
wxPython 2.0b9, second phase (gtk)
[wxWidgets.git] / utils / wxPython / src / my_typemaps.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: my_typemaps.i
3 // Purpose: Special typemaps specifically for wxPython.
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7/3/97
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13
14 //---------------------------------------------------------------------------
15 // Tell SWIG to wrap all the wrappers with Python's thread macros
16
17 %except(python) {
18 wxPy_BEGIN_ALLOW_THREADS;
19 $function
20 wxPy_END_ALLOW_THREADS;
21 }
22
23 //----------------------------------------------------------------------
24 // Here are some to map (int LCOUNT, int* LIST), etc. from a python list
25
26 %{
27
28 extern byte* byte_LIST_helper(PyObject* source);
29 extern int* int_LIST_helper(PyObject* source);
30 extern long* long_LIST_helper(PyObject* source);
31 extern char** string_LIST_helper(PyObject* source);
32 extern wxPoint* wxPoint_LIST_helper(PyObject* source);
33 extern wxBitmap** wxBitmap_LIST_helper(PyObject* source);
34 extern wxString* wxString_LIST_helper(PyObject* source);
35 extern wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
36
37 %}
38
39 //----------------------------------------------------------------------
40
41 %typemap(python,build) int LCOUNT {
42 if (_in_LIST) {
43 $target = PyList_Size(_in_LIST);
44 }
45 else {
46 $target = 0;
47 }
48 }
49
50
51
52 %typemap(python,in) byte* LIST {
53 $target = byte_LIST_helper($source);
54 if ($target == NULL) {
55 return NULL;
56 }
57 }
58 %typemap(python,freearg) byte* LIST {
59 delete [] $source;
60 }
61
62
63 %typemap(python,in) int* LIST {
64 $target = int_LIST_helper($source);
65 if ($target == NULL) {
66 return NULL;
67 }
68 }
69 %typemap(python,freearg) int* LIST {
70 delete [] $source;
71 }
72
73
74 %typemap(python,in) long* LIST {
75 $target = long_LIST_helper($source);
76 if ($target == NULL) {
77 return NULL;
78 }
79 }
80 %typemap(python,freearg) long* LIST {
81 delete [] $source;
82 }
83
84
85 %typemap(python,in) unsigned long* LIST {
86 $target = (unsigned long*)long_LIST_helper($source);
87 if ($target == NULL) {
88 return NULL;
89 }
90 }
91 %typemap(python,freearg) unsigned long* LIST {
92 delete [] $source;
93 }
94
95
96
97 %typemap(python,in) wxDash* LIST = unsigned long* LIST;
98 %typemap(python,freearg) wxDash* LIST = unsigned long* LIST;
99
100
101 %typemap(python,in) char** LIST {
102 $target = string_LIST_helper($source);
103 if ($target == NULL) {
104 return NULL;
105 }
106 }
107 %typemap(python,freearg) char** LIST {
108 delete [] $source;
109 }
110
111
112
113 %typemap(python,in) wxPoint* LIST {
114 $target = wxPoint_LIST_helper($source);
115 if ($target == NULL) {
116 return NULL;
117 }
118 }
119 %typemap(python,freearg) wxPoint* LIST {
120 delete [] $source;
121 }
122
123 %typemap(python,in) wxBitmap** LIST {
124 $target = wxBitmap_LIST_helper($source);
125 if ($target == NULL) {
126 return NULL;
127 }
128 }
129 %typemap(python,freearg) wxBitmap** LIST {
130 delete [] $source;
131 }
132
133 %typemap(python,in) wxString* LIST {
134 $target = wxString_LIST_helper($source);
135 if ($target == NULL) {
136 return NULL;
137 }
138 }
139 %typemap(python,freearg) wxString* LIST {
140 delete [] $source;
141 }
142
143 %typemap(python,in) wxAcceleratorEntry* LIST {
144 $target = wxAcceleratorEntry_LIST_helper($source);
145 if ($target == NULL) {
146 return NULL;
147 }
148 }
149 %typemap(python,freearg) wxAcceleratorEntry* LIST {
150 delete [] $source;
151 }
152
153
154 //---------------------------------------------------------------------------
155
156 %{
157 static char* wxStringErrorMsg = "string type is required for parameter";
158 %}
159
160 %typemap(python, in) wxString& {
161 if (!PyString_Check($source)) {
162 PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
163 return NULL;
164 }
165 $target = new wxString(PyString_AsString($source), PyString_Size($source));
166 }
167 %typemap(python, freearg) wxString& {
168 if ($target)
169 delete $source;
170 }
171
172
173
174 %typemap(python, out) wxString {
175 $target = PyString_FromString(WXSTRINGCAST *($source));
176 }
177 %typemap(python, ret) wxString {
178 delete $source;
179 }
180
181
182 %typemap(python, out) wxString* {
183 $target = PyString_FromString(WXSTRINGCAST (*$source));
184 }
185
186
187 // --------------------------------------------------------------------
188 //---------------------------------------------------------------------------
189
190
191
192 // --------------------------------------------------------------------
193 // Map T_OUTPUTs for floats to return ints.
194
195
196 %typemap(python,ignore) float *T_OUTPUT_TOINT(float temp),
197 double *T_OUTPUT_TOINT(double temp)
198 {
199 $target = &temp;
200 }
201
202
203 %typemap(python,argout) float *T_OUTPUT_TOINT,
204 double *T_OUTPUT_TOINT
205 {
206 PyObject *o;
207 o = PyInt_FromLong((long) (*$source));
208 $target = t_output_helper($target, o);
209 }
210
211 //---------------------------------------------------------------------------
212 /////////////////////////////////////////////////////////////////////////////
213 //
214 // $Log$
215 // Revision 1.5 1999/04/30 03:29:19 RD
216 // wxPython 2.0b9, first phase (win32)
217 // Added gobs of stuff, see wxPython/README.txt for details
218 //
219 // Revision 1.4.4.2 1999/03/28 06:35:01 RD
220 //
221 // wxPython 2.0b8
222 // Python thread support
223 // various minor additions
224 // various minor fixes
225 //
226 // Revision 1.4.4.1 1999/03/16 06:04:03 RD
227 //
228 // wxPython 2.0b7
229 //
230 // Revision 1.4 1998/11/25 08:45:27 RD
231 //
232 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
233 // Added events for wxGrid
234 // Other various fixes and additions
235 //
236 // Revision 1.3 1998/11/15 23:03:47 RD
237 // Removing some ifdef's for wxGTK
238 //
239 // Revision 1.2 1998/08/14 23:36:39 RD
240 // Beginings of wxGTK compatibility
241 //
242 // Revision 1.1 1998/08/09 08:25:52 RD
243 // Initial version
244 //
245 //
246