~ubuntu-branches/ubuntu/intrepid/plplot/intrepid

« back to all changes in this revision

Viewing changes to bindings/python/plplotcmodule.i

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2006-11-04 10:19:34 UTC
  • mfrom: (2.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061104101934-mlirvdg4gpwi6i5q
Tags: 5.6.1-10
* Orphaning the package
* debian/control: Changed the maintainer to the Debian QA Group

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
You should have received a copy of the GNU Library General Public License
20
20
along with the file PLplot; if not, write to the Free Software
21
 
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
22
22
*/
23
23
 
24
24
/* 
25
25
A SWIG interface to PLplot for Python. This wrapper is different from
26
 
the one supplied in plmodule.c in that:
 
26
the one supplied in plmodule.c (now stored in the "old" subdirectory of
 
27
the top-level build tree for reference purposes) in that:
27
28
 
28
29
   1) it strictly provides the C-API with the usual change of not
29
30
      requiring lengths for arrays,
57
58
#define  PyArray_PLFLT PyArray_FLOAT
58
59
#endif
59
60
 
60
 
#define  PyArray_PLINT PyArray_INT
 
61
#define  PyArray_PLINT PyArray_LONG
61
62
/* python-1.5 compatibility mode? */
62
63
#define PySequence_Fast_GET_ITEM PySequence_GetItem
63
64
#define PySequence_Size PySequence_Length
69
70
typedef float PLFLT;
70
71
#endif
71
72
 
72
 
typedef int PLINT;
 
73
typedef long PLINT;
 
74
typedef unsigned int PLUNICODE;
 
75
typedef PLINT PLBOOL;
73
76
 
74
77
/* We have to get import_array called in our extension before we can use Numeric */
75
78
%init %{
103
106
**********************************************************************************/
104
107
 
105
108
/* With preceding count */
106
 
%typemap(in) (PLINT n, PLINT* Array) (PyArrayObject* tmp) {
 
109
%typemap(in) (PLINT n, PLINT *Array) (PyArrayObject* tmp) {
107
110
  tmp = (PyArrayObject *)PyArray_ContiguousFromObject($input, PyArray_PLINT, 1, 1);
108
111
  if(tmp == NULL) return NULL;
109
112
  $1 = Alen = tmp->dimensions[0];
110
113
  $2 = (PLINT*)tmp->data;
111
114
}
112
 
%typemap(freearg) (PLINT n, PLINT* Array) {Py_DECREF(tmp$argnum);}
 
115
%typemap(freearg) (PLINT n, PLINT *Array) {Py_DECREF(tmp$argnum);}
 
116
 
 
117
/* Trailing count and check consistency with previous */
 
118
%typemap(in) (PLINT *ArrayCk, PLINT n) (PyArrayObject* tmp) {
 
119
  tmp = (PyArrayObject *)PyArray_ContiguousFromObject($input, PyArray_PLINT, 1, 1);
 
120
  if(tmp == NULL) return NULL;
 
121
  if(tmp->dimensions[0] != Alen) {
 
122
    PyErr_SetString(PyExc_ValueError, "Vectors must be same length.");
 
123
    return NULL;
 
124
  }
 
125
  $2 = tmp->dimensions[0];
 
126
  $1 = (PLINT*)tmp->data;
 
127
}
 
128
%typemap(freearg) (PLINT *ArrayCk, PLINT n) {Py_DECREF(tmp$argnum); }
113
129
 
114
130
/* No count but check consistency with previous */
115
 
%typemap(in) PLINT* ArrayCk (PyArrayObject* tmp) {
 
131
%typemap(in) PLINT *ArrayCk (PyArrayObject* tmp) {
116
132
  tmp = (PyArrayObject *)PyArray_ContiguousFromObject($input, PyArray_PLINT, 1, 1);
117
133
  if(tmp == NULL) return NULL;
118
134
  if(tmp->dimensions[0] != Alen) {
121
137
  }
122
138
  $1 = (PLINT*)tmp->data;
123
139
}
124
 
%typemap(freearg) PLINT* ArrayCk { Py_DECREF(tmp$argnum);}
 
140
%typemap(freearg) PLINT *ArrayCk { Py_DECREF(tmp$argnum);}
125
141
 
126
142
/* Weird case to allow argument to be one shorter than others */
127
 
%typemap(in) PLINT* ArrayCkMinus1 (PyArrayObject* tmp) {
 
143
%typemap(in) PLINT *ArrayCkMinus1 (PyArrayObject* tmp) {
128
144
  tmp = (PyArrayObject *)PyArray_ContiguousFromObject($input, PyArray_PLINT, 1, 1);
129
145
  if(tmp == NULL) return NULL;
130
146
  if(tmp->dimensions[0] < Alen-1) {
133
149
  }
134
150
  $1 = (PLINT*)tmp->data;
135
151
}
136
 
%typemap(freearg) PLINT* ArrayCkMinus1 { Py_DECREF(tmp$argnum);}
 
152
%typemap(freearg) PLINT *ArrayCkMinus1 { Py_DECREF(tmp$argnum);}
137
153
 
138
154
/* No length but remember size to check others */
139
155
%typemap(in) PLINT *Array (PyArrayObject* tmp) {
142
158
  Alen = tmp->dimensions[0];
143
159
  $1 = (PLINT*)tmp->data;
144
160
}
145
 
%typemap(freearg) (PLINT* Array) {Py_DECREF(tmp$argnum);}
146
 
 
147
 
/* Trailing count */
148
 
%typemap(in) (PLINT *ArrayCk, PLINT n) (PyArrayObject* tmp) {
149
 
  tmp = (PyArrayObject *)PyArray_ContiguousFromObject($input, PyArray_PLINT, 1, 1);
150
 
  if(tmp == NULL) return NULL;
151
 
  if(tmp->dimensions[0] != Alen) {
152
 
    PyErr_SetString(PyExc_ValueError, "Vectors must be same length.");
153
 
    return NULL;
154
 
  }
155
 
  $2 = tmp->dimensions[0];
156
 
  $1 = (PLINT*)tmp->data;
157
 
}
158
 
%typemap(freearg) (PLINT* ArrayCk, int n) {Py_DECREF(tmp$argnum); }
 
161
%typemap(freearg) (PLINT *Array) {Py_DECREF(tmp$argnum);}
159
162
 
160
163
/******************************************************************************
161
164
                                 PLFLT Arrays 
185
188
#endif
186
189
 
187
190
/* with preceding count */
188
 
%typemap(in) (PLINT n, PLFLT* Array) (PyArrayObject* tmp) {
 
191
%typemap(in) (PLINT n, PLFLT *Array) (PyArrayObject* tmp) {
189
192
  tmp = (PyArrayObject *)myArray_ContiguousFromObject($input, PyArray_PLFLT, 1, 1);
190
193
  if(tmp == NULL) return NULL;
191
194
  $1 = Alen = tmp->dimensions[0];
192
195
  $2 = (PLFLT*)tmp->data;
193
196
}
194
 
%typemap(freearg) (PLINT n, PLFLT* Array) { Py_DECREF(tmp$argnum);}
 
197
%typemap(freearg) (PLINT n, PLFLT *Array) { Py_DECREF(tmp$argnum);}
195
198
 
196
 
/* check consistency with previous */
197
 
%typemap(in) (PLFLT* ArrayCk, PLINT n) (PyArrayObject* tmp) {
 
199
/* trailing count and check consistency with previous */
 
200
%typemap(in) (PLFLT *ArrayCk, PLINT n) (PyArrayObject* tmp) {
198
201
  tmp = (PyArrayObject *)myArray_ContiguousFromObject($input, PyArray_PLFLT, 1, 1);
199
202
  if(tmp == NULL) return NULL;
200
203
  if(tmp->dimensions[0] != Alen) {
204
207
  $1 = (PLFLT*)tmp->data;
205
208
  $2 = tmp->dimensions[0];
206
209
}
207
 
%typemap(freearg) (PLFLT* ArrayCk, PLINT n) { Py_DECREF(tmp$argnum);}
 
210
%typemap(freearg) (PLFLT *ArrayCk, PLINT n) { Py_DECREF(tmp$argnum);}
208
211
 
209
 
/* check consistency with previous */
210
 
%typemap(in) PLFLT* ArrayCk (PyArrayObject* tmp) {
 
212
/* no count, but check consistency with previous */
 
213
%typemap(in) PLFLT *ArrayCk (PyArrayObject* tmp) {
211
214
  tmp = (PyArrayObject *)myArray_ContiguousFromObject($input, PyArray_PLFLT, 1, 1);
212
215
  if(tmp == NULL) return NULL;
213
216
  if(tmp->dimensions[0] != Alen) {
216
219
  }
217
220
  $1 = (PLFLT*)tmp->data;
218
221
}
219
 
%typemap(freearg) PLFLT* ArrayCk { Py_DECREF(tmp$argnum);}
 
222
%typemap(freearg) PLFLT *ArrayCk { Py_DECREF(tmp$argnum);}
220
223
 
221
224
/* check consistency with X dimension of previous */
222
 
%typemap(in) PLFLT* ArrayCkX (PyArrayObject* tmp) {
 
225
%typemap(in) PLFLT *ArrayCkX (PyArrayObject* tmp) {
223
226
  tmp = (PyArrayObject *)myArray_ContiguousFromObject($input, PyArray_PLFLT, 1, 1);
224
227
  if(tmp == NULL) return NULL;
225
228
  if(tmp->dimensions[0] != Xlen) {
228
231
  }
229
232
  $1 = (PLFLT*)tmp->data;
230
233
}
231
 
%typemap(freearg) PLFLT* ArrayCkX { Py_DECREF(tmp$argnum);}
 
234
%typemap(freearg) PLFLT *ArrayCkX { Py_DECREF(tmp$argnum);}
232
235
 
233
236
/* check consistency with Y dimension of previous */
234
 
%typemap(in) PLFLT* ArrayCkY (PyArrayObject* tmp) {
 
237
%typemap(in) PLFLT *ArrayCkY (PyArrayObject* tmp) {
235
238
  tmp = (PyArrayObject *)myArray_ContiguousFromObject($input, PyArray_PLFLT, 1, 1);
236
239
  if(tmp == NULL) return NULL;
237
240
  if(tmp->dimensions[0] != Ylen) {
240
243
  }
241
244
  $1 = (PLFLT*)tmp->data;
242
245
}
243
 
%typemap(freearg) PLFLT* ArrayCkY { Py_DECREF(tmp$argnum);}
 
246
%typemap(freearg) PLFLT *ArrayCkY { Py_DECREF(tmp$argnum);}
244
247
 
245
248
/* set X length for later consistency checking */
246
249
%typemap(in) PLFLT *ArrayX (PyArrayObject* tmp) {
249
252
  Xlen = tmp->dimensions[0];
250
253
  $1 = (PLFLT*)tmp->data;
251
254
}
252
 
%typemap(freearg) PLFLT* ArrayX {Py_DECREF(tmp$argnum);}
 
255
%typemap(freearg) PLFLT *ArrayX {Py_DECREF(tmp$argnum);}
253
256
 
254
257
/* set Y length for later consistency checking */
255
258
%typemap(in) PLFLT *ArrayY (PyArrayObject* tmp) {
258
261
  Ylen = tmp->dimensions[0];
259
262
  $1 = (PLFLT*)tmp->data;
260
263
}
261
 
%typemap(freearg) (PLFLT* ArrayY) {Py_DECREF(tmp$argnum);}
 
264
%typemap(freearg) (PLFLT *ArrayY) {Py_DECREF(tmp$argnum);}
262
265
 
263
266
/* with trailing count */
264
267
%typemap(in) (PLFLT *Array, PLINT n) (PyArrayObject* tmp) {
267
270
  $2 = tmp->dimensions[0];
268
271
  $1 = (PLFLT*)tmp->data;
269
272
}
270
 
%typemap(freearg) (PLFLT* Array, PLINT n) {Py_DECREF(tmp$argnum); }
 
273
%typemap(freearg) (PLFLT *Array, PLINT n) {Py_DECREF(tmp$argnum); }
271
274
 
272
275
/* with no count */
273
 
%typemap(in) PLFLT* Array (PyArrayObject* tmp) {
 
276
%typemap(in) PLFLT *Array (PyArrayObject* tmp) {
274
277
  tmp = (PyArrayObject *)myArray_ContiguousFromObject($input, PyArray_PLFLT, 1, 1);
275
278
  if(tmp == NULL) return NULL;
276
279
  Alen = tmp->dimensions[0];
277
280
  $1 = (PLFLT*)tmp->data;
278
281
}
279
 
%typemap(freearg) PLFLT* Array { Py_DECREF(tmp$argnum);}
 
282
%typemap(freearg) PLFLT *Array { Py_DECREF(tmp$argnum);}
280
283
 
281
284
/* 2D array with trailing dimensions, check consistency with previous */
282
285
%typemap(in) (PLFLT **MatrixCk, PLINT nx, PLINT ny) (PyArrayObject* tmp) {
822
825
/* End of all code associated with special call-back functions.*/
823
826
 
824
827
/* Process options list using current options info. */
825
 
%typemap(in) (PLINT *p_argc, char **argv) (PLINT tmp) {
 
828
%typemap(in) (int *p_argc, char **argv) (int tmp) {
826
829
  int i;
827
830
  if (!PyList_Check($input)) {
828
831
    PyErr_SetString(PyExc_ValueError, "Expecting a list");
843
846
  $2[i] = 0;
844
847
}
845
848
 
846
 
%typemap(freearg) (PLINT *p_argc, char **argv) {
 
849
%typemap(freearg) (int *p_argc, char **argv) {
847
850
   if ($2) free($2);
848
851
}
849
852