]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/my_typemaps.i
Beginings of wxGTK compatibility
[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 int* int_LIST_helper(PyObject* source);
20 extern long* long_LIST_helper(PyObject* source);
21 extern char** string_LIST_helper(PyObject* source);
22 extern wxPoint* wxPoint_LIST_helper(PyObject* source);
23 extern wxBitmap** wxBitmap_LIST_helper(PyObject* source);
24 extern wxString* wxString_LIST_helper(PyObject* source);
25 #ifdef __WXMSW__
26 extern wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
27 #endif
28
29 %}
30
31 //----------------------------------------------------------------------
32
33 %typemap(python,build) int LCOUNT {
34 $target = PyList_Size(_in_LIST);
35 }
36
37
38
39 %typemap(python,in) int* LIST {
40 $target = int_LIST_helper($source);
41 if ($target == NULL) {
42 return NULL;
43 }
44 }
45 %typemap(python,freearg) int* LIST {
46 delete [] $source;
47 }
48
49
50 %typemap(python,in) long* LIST {
51 $target = long_LIST_helper($source);
52 if ($target == NULL) {
53 return NULL;
54 }
55 }
56 %typemap(python,freearg) long* LIST {
57 delete [] $source;
58 }
59
60
61 %typemap(python,in) unsigned long* LIST {
62 $target = (unsigned long*)long_LIST_helper($source);
63 if ($target == NULL) {
64 return NULL;
65 }
66 }
67 %typemap(python,freearg) unsigned long* LIST {
68 delete [] $source;
69 }
70
71
72
73 %typemap(python,in) wxDash* LIST = unsigned long* LIST;
74 %typemap(python,freearg) wxDash* LIST = unsigned long* LIST;
75
76
77 %typemap(python,in) char** LIST {
78 $target = string_LIST_helper($source);
79 if ($target == NULL) {
80 return NULL;
81 }
82 }
83 %typemap(python,freearg) char** LIST {
84 delete [] $source;
85 }
86
87
88
89 %typemap(python,in) wxPoint* LIST {
90 $target = wxPoint_LIST_helper($source);
91 if ($target == NULL) {
92 return NULL;
93 }
94 }
95 %typemap(python,freearg) wxPoint* LIST {
96 delete [] $source;
97 }
98
99 %typemap(python,in) wxBitmap** LIST {
100 $target = wxBitmap_LIST_helper($source);
101 if ($target == NULL) {
102 return NULL;
103 }
104 }
105 %typemap(python,freearg) wxBitmap** LIST {
106 delete [] $source;
107 }
108
109 %typemap(python,in) wxString* LIST {
110 $target = wxString_LIST_helper($source);
111 if ($target == NULL) {
112 return NULL;
113 }
114 }
115 %typemap(python,freearg) wxString* LIST {
116 delete [] $source;
117 }
118
119 %typemap(python,in) wxAcceleratorEntry* LIST {
120 $target = wxAcceleratorEntry_LIST_helper($source);
121 if ($target == NULL) {
122 return NULL;
123 }
124 }
125 %typemap(python,freearg) wxAcceleratorEntry* LIST {
126 delete [] $source;
127 }
128
129
130 //---------------------------------------------------------------------------
131
132 %{
133 static char* wxStringErrorMsg = "string type is required for parameter";
134 %}
135
136 %typemap(python, in) wxString& {
137 if (!PyString_Check($source)) {
138 PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
139 return NULL;
140 }
141 $target = new wxString(PyString_AsString($source));
142 }
143 %typemap(python, freearg) wxString& {
144 if ($target)
145 delete $source;
146 }
147
148
149
150 %typemap(python, out) wxString {
151 $target = PyString_FromString(WXSTRINGCAST *($source));
152 }
153 %typemap(python, ret) wxString {
154 delete $source;
155 }
156
157
158 %typemap(python, out) wxString* {
159 $target = PyString_FromString(WXSTRINGCAST (*$source));
160 }
161
162
163 // --------------------------------------------------------------------
164 //---------------------------------------------------------------------------
165
166
167
168 // --------------------------------------------------------------------
169 // Map T_OUTPUTs for floats to return ints.
170
171
172 %typemap(python,ignore) float *T_OUTPUT_TOINT(float temp),
173 double *T_OUTPUT_TOINT(double temp)
174 {
175 $target = &temp;
176 }
177
178
179 %typemap(python,argout) float *T_OUTPUT_TOINT,
180 double *T_OUTPUT_TOINT
181 {
182 PyObject *o;
183 o = PyInt_FromLong((long) (*$source));
184 $target = t_output_helper($target, o);
185 }
186
187 //---------------------------------------------------------------------------
188 /////////////////////////////////////////////////////////////////////////////
189 //
190 // $Log$
191 // Revision 1.2 1998/08/14 23:36:39 RD
192 // Beginings of wxGTK compatibility
193 //
194 // Revision 1.1 1998/08/09 08:25:52 RD
195 // Initial version
196 //
197 //
198