]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/my_typemaps.i
Moved wxPy_ConvertList function from oglhelpers to helpers
[wxWidgets.git] / utils / wxPython / src / my_typemaps.i
CommitLineData
7bf85405
RD
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
cf694132
RD
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
7bf85405
RD
23//----------------------------------------------------------------------
24// Here are some to map (int LCOUNT, int* LIST), etc. from a python list
25
26%{
27
d559219f
RD
28HELPEREXPORT byte* byte_LIST_helper(PyObject* source);
29HELPEREXPORT int* int_LIST_helper(PyObject* source);
30HELPEREXPORT long* long_LIST_helper(PyObject* source);
31HELPEREXPORT char** string_LIST_helper(PyObject* source);
32HELPEREXPORT wxPoint* wxPoint_LIST_helper(PyObject* source);
33HELPEREXPORT wxBitmap** wxBitmap_LIST_helper(PyObject* source);
34HELPEREXPORT wxString* wxString_LIST_helper(PyObject* source);
35HELPEREXPORT wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
7bf85405
RD
36
37%}
38
39//----------------------------------------------------------------------
40
41%typemap(python,build) int LCOUNT {
cf694132
RD
42 if (_in_LIST) {
43 $target = PyList_Size(_in_LIST);
44 }
45 else {
46 $target = 0;
47 }
7bf85405
RD
48}
49
50
51
b639c3c5
RD
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
7bf85405
RD
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%{
157static 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 }
cf694132 165 $target = new wxString(PyString_AsString($source), PyString_Size($source));
7bf85405
RD
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$
d559219f
RD
215// Revision 1.6 1999/09/10 06:05:32 RD
216// Lots more support for event-less callbacks
217// Exported some symbols for the other modules to use
218// etc.
219//
cf694132 220// Revision 1.5 1999/04/30 03:29:19 RD
d559219f 221//
cf694132
RD
222// wxPython 2.0b9, first phase (win32)
223// Added gobs of stuff, see wxPython/README.txt for details
224//
225// Revision 1.4.4.2 1999/03/28 06:35:01 RD
226//
227// wxPython 2.0b8
228// Python thread support
229// various minor additions
230// various minor fixes
231//
232// Revision 1.4.4.1 1999/03/16 06:04:03 RD
233//
234// wxPython 2.0b7
235//
b639c3c5 236// Revision 1.4 1998/11/25 08:45:27 RD
cf694132 237//
b639c3c5
RD
238// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
239// Added events for wxGrid
240// Other various fixes and additions
241//
faf3cb35
RD
242// Revision 1.3 1998/11/15 23:03:47 RD
243// Removing some ifdef's for wxGTK
244//
853b255a
RD
245// Revision 1.2 1998/08/14 23:36:39 RD
246// Beginings of wxGTK compatibility
247//
7bf85405
RD
248// Revision 1.1 1998/08/09 08:25:52 RD
249// Initial version
250//
251//
252