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;
86 %typemap(python,in) wxDash* LIST = byte* LIST;
87 %typemap(python,freearg) wxDash* LIST = byte* LIST;
91 %typemap(python,in) char** LIST {
92 $target = string_LIST_helper($source);
93 if ($target == NULL) {
97 %typemap(python,freearg) char** LIST {
103 %typemap(python,in) wxPoint* LIST {
104 $target = wxPoint_LIST_helper($source);
105 if ($target == NULL) {
109 %typemap(python,freearg) wxPoint* LIST {
113 %typemap(python,in) wxBitmap** LIST {
114 $target = wxBitmap_LIST_helper($source);
115 if ($target == NULL) {
119 %typemap(python,freearg) wxBitmap** LIST {
123 %typemap(python,in) wxString* LIST {
124 $target = wxString_LIST_helper($source);
125 if ($target == NULL) {
129 %typemap(python,freearg) wxString* LIST {
133 %typemap(python,in) wxAcceleratorEntry* LIST {
134 $target = wxAcceleratorEntry_LIST_helper($source);
135 if ($target == NULL) {
139 %typemap(python,freearg) wxAcceleratorEntry* LIST {
144 //---------------------------------------------------------------------------
147 static char* wxStringErrorMsg = "string type is required for parameter";
150 %typemap(python, in) wxString& {
151 if (!PyString_Check($source)) {
152 PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
155 $target = new wxString(PyString_AsString($source), PyString_Size($source));
157 %typemap(python, freearg) wxString& {
164 %typemap(python, out) wxString {
165 $target = PyString_FromString(WXSTRINGCAST *($source));
167 %typemap(python, ret) wxString {
172 %typemap(python, out) wxString* {
173 $target = PyString_FromString(WXSTRINGCAST (*$source));
180 //---------------------------------------------------------------------------
181 // Typemaps to convert Python sequence objects (2-tuples, etc.) to
182 // wxSize, wxPoint, wxRealPoint, and wxRect.
184 %typemap(python,in) wxSize& (wxSize temp) {
186 if (! wxSize_helper($source, &$target))
190 %typemap(python,in) wxPoint& (wxPoint temp) {
192 if (! wxPoint_helper($source, &$target))
196 %typemap(python,in) wxRealPoint& (wxRealPoint temp) {
198 if (! wxRealPoint_helper($source, &$target))
202 %typemap(python,in) wxRect& (wxRect temp) {
204 if (! wxRect_helper($source, &$target))
209 //---------------------------------------------------------------------------
210 // Map T_OUTPUTs for floats to return ints.
213 %typemap(python,ignore) float *T_OUTPUT_TOINT(float temp),
214 double *T_OUTPUT_TOINT(double temp)
220 %typemap(python,argout) float *T_OUTPUT_TOINT,
221 double *T_OUTPUT_TOINT
224 o = PyInt_FromLong((long) (*$source));
225 $target = t_output_helper($target, o);
228 //---------------------------------------------------------------------------
229 //---------------------------------------------------------------------------