]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/my_typemaps.i
Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
[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 // Here are some to map (int LCOUNT, int* LIST), etc. from a python list
16
17 %{
18
19 extern byte* byte_LIST_helper(PyObject* source);
20 extern int* int_LIST_helper(PyObject* source);
21 extern long* long_LIST_helper(PyObject* source);
22 extern char** string_LIST_helper(PyObject* source);
23 extern wxPoint* wxPoint_LIST_helper(PyObject* source);
24 extern wxBitmap** wxBitmap_LIST_helper(PyObject* source);
25 extern wxString* wxString_LIST_helper(PyObject* source);
26 extern wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
27
28 %}
29
30 //----------------------------------------------------------------------
31
32 %typemap(python,build) int LCOUNT {
33 $target = PyList_Size(_in_LIST);
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
83 %typemap(python,in) wxDash* LIST = unsigned long* LIST;
84 %typemap(python,freearg) wxDash* LIST = unsigned long* LIST;
85
86
87 %typemap(python,in) char** LIST {
88 $target = string_LIST_helper($source);
89 if ($target == NULL) {
90 return NULL;
91 }
92 }
93 %typemap(python,freearg) char** LIST {
94 delete [] $source;
95 }
96
97
98
99 %typemap(python,in) wxPoint* LIST {
100 $target = wxPoint_LIST_helper($source);
101 if ($target == NULL) {
102 return NULL;
103 }
104 }
105 %typemap(python,freearg) wxPoint* LIST {
106 delete [] $source;
107 }
108
109 %typemap(python,in) wxBitmap** LIST {
110 $target = wxBitmap_LIST_helper($source);
111 if ($target == NULL) {
112 return NULL;
113 }
114 }
115 %typemap(python,freearg) wxBitmap** LIST {
116 delete [] $source;
117 }
118
119 %typemap(python,in) wxString* LIST {
120 $target = wxString_LIST_helper($source);
121 if ($target == NULL) {
122 return NULL;
123 }
124 }
125 %typemap(python,freearg) wxString* LIST {
126 delete [] $source;
127 }
128
129 %typemap(python,in) wxAcceleratorEntry* LIST {
130 $target = wxAcceleratorEntry_LIST_helper($source);
131 if ($target == NULL) {
132 return NULL;
133 }
134 }
135 %typemap(python,freearg) wxAcceleratorEntry* LIST {
136 delete [] $source;
137 }
138
139
140 //---------------------------------------------------------------------------
141
142 %{
143 static char* wxStringErrorMsg = "string type is required for parameter";
144 %}
145
146 %typemap(python, in) wxString& {
147 if (!PyString_Check($source)) {
148 PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
149 return NULL;
150 }
151 $target = new wxString(PyString_AsString($source));
152 }
153 %typemap(python, freearg) wxString& {
154 if ($target)
155 delete $source;
156 }
157
158
159
160 %typemap(python, out) wxString {
161 $target = PyString_FromString(WXSTRINGCAST *($source));
162 }
163 %typemap(python, ret) wxString {
164 delete $source;
165 }
166
167
168 %typemap(python, out) wxString* {
169 $target = PyString_FromString(WXSTRINGCAST (*$source));
170 }
171
172
173 // --------------------------------------------------------------------
174 //---------------------------------------------------------------------------
175
176
177
178 // --------------------------------------------------------------------
179 // Map T_OUTPUTs for floats to return ints.
180
181
182 %typemap(python,ignore) float *T_OUTPUT_TOINT(float temp),
183 double *T_OUTPUT_TOINT(double temp)
184 {
185 $target = &temp;
186 }
187
188
189 %typemap(python,argout) float *T_OUTPUT_TOINT,
190 double *T_OUTPUT_TOINT
191 {
192 PyObject *o;
193 o = PyInt_FromLong((long) (*$source));
194 $target = t_output_helper($target, o);
195 }
196
197 //---------------------------------------------------------------------------
198 /////////////////////////////////////////////////////////////////////////////
199 //
200 // $Log$
201 // Revision 1.4 1998/11/25 08:45:27 RD
202 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
203 // Added events for wxGrid
204 // Other various fixes and additions
205 //
206 // Revision 1.3 1998/11/15 23:03:47 RD
207 // Removing some ifdef's for wxGTK
208 //
209 // Revision 1.2 1998/08/14 23:36:39 RD
210 // Beginings of wxGTK compatibility
211 //
212 // Revision 1.1 1998/08/09 08:25:52 RD
213 // Initial version
214 //
215 //
216