]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/my_typemaps.i
Fixed wxWindowCreateEvent and wxWindowDestroyEvent to set m_eventType
[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 // LCOUNT and LIST go together. They allow a single Python list to be
25 // converted to an integer count and an array count items long.
26
27 %typemap(python,build) int LCOUNT {
28 if (_in_LIST) {
29 $target = PyList_Size(_in_LIST);
30 }
31 else {
32 $target = 0;
33 }
34 }
35
36
37
38 %typemap(python,in) byte* LIST {
39 $target = byte_LIST_helper($source);
40 if ($target == NULL) {
41 return NULL;
42 }
43 }
44 %typemap(python,freearg) byte* LIST {
45 delete [] $source;
46 }
47
48
49 %typemap(python,in) int* LIST {
50 $target = int_LIST_helper($source);
51 if ($target == NULL) {
52 return NULL;
53 }
54 }
55 %typemap(python,freearg) int* LIST {
56 delete [] $source;
57 }
58
59
60 %typemap(python,in) long* LIST {
61 $target = long_LIST_helper($source);
62 if ($target == NULL) {
63 return NULL;
64 }
65 }
66 %typemap(python,freearg) long* LIST {
67 delete [] $source;
68 }
69
70
71 %typemap(python,in) unsigned long* LIST {
72 $target = (unsigned long*)long_LIST_helper($source);
73 if ($target == NULL) {
74 return NULL;
75 }
76 }
77 %typemap(python,freearg) unsigned long* LIST {
78 delete [] $source;
79 }
80
81
82 #ifdef __WXMSW__
83 %typemap(python,in) wxDash* LIST = unsigned long* LIST;
84 %typemap(python,freearg) wxDash* LIST = unsigned long* LIST;
85 #else
86 %typemap(python,in) wxDash* LIST = byte* LIST;
87 %typemap(python,freearg) wxDash* LIST = byte* LIST;
88 #endif
89
90
91 %typemap(python,in) char** LIST {
92 $target = string_LIST_helper($source);
93 if ($target == NULL) {
94 return NULL;
95 }
96 }
97 %typemap(python,freearg) char** LIST {
98 delete [] $source;
99 }
100
101
102
103 %typemap(python,in) wxPoint* LIST {
104 $target = wxPoint_LIST_helper($source);
105 if ($target == NULL) {
106 return NULL;
107 }
108 }
109 %typemap(python,freearg) wxPoint* LIST {
110 delete [] $source;
111 }
112
113 %typemap(python,in) wxBitmap** LIST {
114 $target = wxBitmap_LIST_helper($source);
115 if ($target == NULL) {
116 return NULL;
117 }
118 }
119 %typemap(python,freearg) wxBitmap** LIST {
120 delete [] $source;
121 }
122
123 %typemap(python,in) wxString* LIST {
124 $target = wxString_LIST_helper($source);
125 if ($target == NULL) {
126 return NULL;
127 }
128 }
129 %typemap(python,freearg) wxString* LIST {
130 delete [] $source;
131 }
132
133 %typemap(python,in) wxAcceleratorEntry* LIST {
134 $target = wxAcceleratorEntry_LIST_helper($source);
135 if ($target == NULL) {
136 return NULL;
137 }
138 }
139 %typemap(python,freearg) wxAcceleratorEntry* LIST {
140 delete [] $source;
141 }
142
143
144 //---------------------------------------------------------------------------
145
146 %{
147 static char* wxStringErrorMsg = "string type is required for parameter";
148 %}
149
150 %typemap(python, in) wxString& {
151 if (!PyString_Check($source)) {
152 PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
153 return NULL;
154 }
155 $target = new wxString(PyString_AsString($source), PyString_Size($source));
156 }
157 %typemap(python, freearg) wxString& {
158 if ($target)
159 delete $source;
160 }
161
162
163
164 %typemap(python, out) wxString {
165 $target = PyString_FromString(WXSTRINGCAST *($source));
166 }
167 %typemap(python, ret) wxString {
168 delete $source;
169 }
170
171
172 %typemap(python, out) wxString* {
173 $target = PyString_FromString(WXSTRINGCAST (*$source));
174 }
175
176
177
178
179
180 //---------------------------------------------------------------------------
181 // Typemaps to convert Python sequence objects (2-tuples, etc.) to
182 // wxSize, wxPoint, wxRealPoint, and wxRect.
183
184 %typemap(python,in) wxSize& (wxSize temp) {
185 $target = &temp;
186 if (! wxSize_helper($source, &$target))
187 return NULL;
188 }
189
190 %typemap(python,in) wxPoint& (wxPoint temp) {
191 $target = &temp;
192 if (! wxPoint_helper($source, &$target))
193 return NULL;
194 }
195
196 %typemap(python,in) wxRealPoint& (wxRealPoint temp) {
197 $target = &temp;
198 if (! wxRealPoint_helper($source, &$target))
199 return NULL;
200 }
201
202 %typemap(python,in) wxRect& (wxRect temp) {
203 $target = &temp;
204 if (! wxRect_helper($source, &$target))
205 return NULL;
206 }
207
208
209 //---------------------------------------------------------------------------
210 // Map T_OUTPUTs for floats to return ints.
211
212
213 %typemap(python,ignore) float *T_OUTPUT_TOINT(float temp),
214 double *T_OUTPUT_TOINT(double temp)
215 {
216 $target = &temp;
217 }
218
219
220 %typemap(python,argout) float *T_OUTPUT_TOINT,
221 double *T_OUTPUT_TOINT
222 {
223 PyObject *o;
224 o = PyInt_FromLong((long) (*$source));
225 $target = t_output_helper($target, o);
226 }
227
228 //---------------------------------------------------------------------------
229 //---------------------------------------------------------------------------
230