1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Special typemaps specifically for wxPython.
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
14 //---------------------------------------------------------------------------
15 // Tell SWIG to wrap all the wrappers with Python's thread macros
18 wxPy_BEGIN_ALLOW_THREADS;
20 wxPy_END_ALLOW_THREADS;
23 //----------------------------------------------------------------------
24 // LCOUNT and choices go together. They allow a single Python list to be
25 // converted to an integer count and an array count items long.
27 %typemap(python,build) int LCOUNT {
29 $target = PyList_Size(_in_choices);
38 %typemap(python,in) byte* choices {
39 $target = byte_LIST_helper($source);
40 if ($target == NULL) {
44 %typemap(python,freearg) byte* choices {
49 %typemap(python,in) int* choices {
50 $target = int_LIST_helper($source);
51 if ($target == NULL) {
55 %typemap(python,freearg) int* choices {
60 %typemap(python,in) long* choices {
61 $target = long_LIST_helper($source);
62 if ($target == NULL) {
66 %typemap(python,freearg) long* choices {
71 %typemap(python,in) unsigned long* choices {
72 $target = (unsigned long*)long_LIST_helper($source);
73 if ($target == NULL) {
77 %typemap(python,freearg) unsigned long* choices {
83 %typemap(python,in) wxDash* choices = unsigned long* choices;
84 %typemap(python,freearg) wxDash* choices = unsigned long* choices;
86 %typemap(python,in) wxDash* choices = byte* choices;
87 %typemap(python,freearg) wxDash* choices = byte* choices;
91 %typemap(python,in) char** choices {
92 $target = string_LIST_helper($source);
93 if ($target == NULL) {
97 %typemap(python,freearg) char** choices {
102 %typemap(python,in) wxBitmap** choices {
103 $target = wxBitmap_LIST_helper($source);
104 if ($target == NULL) {
108 %typemap(python,freearg) wxBitmap** choices {
112 %typemap(python,in) wxString* choices {
113 $target = wxString_LIST_helper($source);
114 if ($target == NULL) {
118 %typemap(python,freearg) wxString* choices {
122 %typemap(python,in) wxAcceleratorEntry* choices {
123 $target = wxAcceleratorEntry_LIST_helper($source);
124 if ($target == NULL) {
128 %typemap(python,freearg) wxAcceleratorEntry* choices {
136 %typemap(python,build) int PCOUNT {
138 $target = PyList_Size(_in_points);
145 %typemap(python,in) wxPoint* points {
146 $target = wxPoint_LIST_helper($source);
147 if ($target == NULL) {
151 %typemap(python,freearg) wxPoint* points {
157 //---------------------------------------------------------------------------
160 static char* wxStringErrorMsg = "string type is required for parameter";
163 %typemap(python, in) wxString& {
164 if (!PyString_Check($source)) {
165 PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
168 $target = new wxString(PyString_AsString($source), PyString_Size($source));
170 %typemap(python, freearg) wxString& {
177 %typemap(python, out) wxString {
178 $target = PyString_FromStringAndSize($source->c_str(), $source->Len());
180 %typemap(python, ret) wxString {
185 %typemap(python, out) wxString* {
186 $target = PyString_FromStringAndSize($source->c_str(), $source->Len());
193 //---------------------------------------------------------------------------
194 // Typemaps to convert Python sequence objects (2-tuples, etc.) to
195 // wxSize, wxPoint, wxRealPoint, and wxRect.
197 %typemap(python,in) wxSize& (wxSize temp) {
199 if (! wxSize_helper($source, &$target))
203 %typemap(python,in) wxPoint& (wxPoint temp) {
205 if (! wxPoint_helper($source, &$target))
209 %typemap(python,in) wxRealPoint& (wxRealPoint temp) {
211 if (! wxRealPoint_helper($source, &$target))
215 %typemap(python,in) wxRect& (wxRect temp) {
217 if (! wxRect_helper($source, &$target))
222 //---------------------------------------------------------------------------
223 // Map T_OUTPUTs for floats to return ints.
226 %typemap(python,ignore) float *T_OUTPUT_TOINT(float temp),
227 double *T_OUTPUT_TOINT(double temp)
233 %typemap(python,argout) float *T_OUTPUT_TOINT,
234 double *T_OUTPUT_TOINT
237 o = PyInt_FromLong((long) (*$source));
238 $target = t_output_helper($target, o);
241 //---------------------------------------------------------------------------
242 //---------------------------------------------------------------------------