Fix this test for the case when Test::Pod is not installed.
[Math-GSL.git] / typemap_examples.i
blob0e3f2a734d36082a7f0e3c16c2eb178d65dec519
1 // we need the following typemap for arrays of doubles in Perl
3 %typemap(in) float value[ANY] {
4 int i;
5 if (!PySequence_Check($input)) {
6 PyErr_SetString(PyExc_ValueError,"Expected a sequence");
7 return NULL;
9 if (PySequence_Length($input) != $1_dim0) {
10 PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected $1_dim0 elements");
11 return NULL;
13 $1 = (float *) malloc($1_dim0*sizeof(float));
14 for (i = 0; i < $1_dim0; i++) {
15 PyObject *o = PySequence_GetItem($input,i);
16 if (PyNumber_Check(o)) {
17 $1[i] = (float) PyFloat_AsDouble(o);
18 } else {
19 PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
20 free($1);
21 return NULL;
25 %typemap(freearg) float value[ANY] {
26 if ($1) free($1);