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