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 LIST 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_LIST);
38 %typemap(python,in) byte* LIST {
39 $target = byte_LIST_helper($source);
40 if ($target == NULL) {
44 %typemap(python,freearg) byte* LIST {
49 %typemap(python,in) int* LIST {
50 $target = int_LIST_helper($source);
51 if ($target == NULL) {
55 %typemap(python,freearg) int* LIST {
60 %typemap(python,in) long* LIST {
61 $target = long_LIST_helper($source);
62 if ($target == NULL) {
66 %typemap(python,freearg) long* LIST {
71 %typemap(python,in) unsigned long* LIST {
72 $target = (unsigned long*)long_LIST_helper($source);
73 if ($target == NULL) {
77 %typemap(python,freearg) unsigned long* LIST {
83 %typemap(python,in) wxDash* LIST = unsigned long* LIST;
84 %typemap(python,freearg) wxDash* LIST = unsigned long* LIST;
87 %typemap(python,in) char** LIST {
88 $target = string_LIST_helper($source);
89 if ($target == NULL) {
93 %typemap(python,freearg) char** LIST {
99 %typemap(python,in) wxPoint* LIST {
100 $target = wxPoint_LIST_helper($source);
101 if ($target == NULL) {
105 %typemap(python,freearg) wxPoint* LIST {
109 %typemap(python,in) wxBitmap** LIST {
110 $target = wxBitmap_LIST_helper($source);
111 if ($target == NULL) {
115 %typemap(python,freearg) wxBitmap** LIST {
119 %typemap(python,in) wxString* LIST {
120 $target = wxString_LIST_helper($source);
121 if ($target == NULL) {
125 %typemap(python,freearg) wxString* LIST {
129 %typemap(python,in) wxAcceleratorEntry* LIST {
130 $target = wxAcceleratorEntry_LIST_helper($source);
131 if ($target == NULL) {
135 %typemap(python,freearg) wxAcceleratorEntry* LIST {
140 //---------------------------------------------------------------------------
143 static char* wxStringErrorMsg = "string type is required for parameter";
146 %typemap(python, in) wxString& {
147 if (!PyString_Check($source)) {
148 PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
151 $target = new wxString(PyString_AsString($source), PyString_Size($source));
153 %typemap(python, freearg) wxString& {
160 %typemap(python, out) wxString {
161 $target = PyString_FromString(WXSTRINGCAST *($source));
163 %typemap(python, ret) wxString {
168 %typemap(python, out) wxString* {
169 $target = PyString_FromString(WXSTRINGCAST (*$source));
176 //---------------------------------------------------------------------------
177 // Typemaps to convert Python sequence objects (2-tuples, etc.) to
178 // wxSize, wxPoint, wxRealPoint, and wxRect.
180 %typemap(python,in) wxSize& (wxSize temp) {
182 if (! wxSize_helper($source, &$target))
186 %typemap(python,in) wxPoint& (wxPoint temp) {
188 if (! wxPoint_helper($source, &$target))
192 %typemap(python,in) wxRealPoint& (wxRealPoint temp) {
194 if (! wxRealPoint_helper($source, &$target))
198 %typemap(python,in) wxRect& (wxRect temp) {
200 if (! wxRect_helper($source, &$target))
205 //---------------------------------------------------------------------------
206 // Map T_OUTPUTs for floats to return ints.
209 %typemap(python,ignore) float *T_OUTPUT_TOINT(float temp),
210 double *T_OUTPUT_TOINT(double temp)
216 %typemap(python,argout) float *T_OUTPUT_TOINT,
217 double *T_OUTPUT_TOINT
220 o = PyInt_FromLong((long) (*$source));
221 $target = t_output_helper($target, o);
224 //---------------------------------------------------------------------------
225 //---------------------------------------------------------------------------