« Return to Thread: Function Overloading (double and double[])

Function Overloading (double and double[])

by Gerald Schweighofer :: Rate this Message:

| View in Thread


Hi,

it seems that overloading with a double and a double array is not supported ?
e.g.:

void test(double erg[2]);
void test(double e);

If i call "test([1,2])" from python , I got the following error message:

> NotImplementedError                       Traceback (most recent call last)
> ..\<ipython console> in <module>()
> NotImplementedError: Wrong number or type of arguments for  
> overloaded function 'test'.
>  Possible C/C++ prototypes are:
>    test(double [2])
>    test(double)

If I comment out the function "void test(double e)" it works!

Should this be supported or is it a bug ?


--------------------------------------------------
Here is my test.i file:

%module test
%include typemaps.i

%{
static int convert_darray(PyObject *input, double *ptr, int size) {
   int i;
   if (!PySequence_Check(input)) {
       PyErr_SetString(PyExc_TypeError,"Expecting a sequence");
       return 0;
   }
   if (PyObject_Length(input) != size) {
       PyErr_SetString(PyExc_ValueError,"Sequence size mismatch");
       return 0;
   }
   for (i =0; i < size; i++) {
       PyObject *o = PySequence_GetItem(input,i);
       if (!PyFloat_Check(o)) {
          Py_XDECREF(o);
          PyErr_SetString(PyExc_ValueError,"Expecting a sequence of floats");
          return 0;
       }
       ptr[i] = PyFloat_AsDouble(o);
       Py_DECREF(o);
   }
   return 1;
}
%}

%typemap(in) double [ANY](double temp[$1_dim0]) {
    if (!convert_darray($input,temp,$1_dim0)) {
       return NULL;
    }
    $1 = &temp[0];
}

%{
void test(double erg[2]){ erg[0]+=1.0; }
void test(double e){ printf("%f",e); }
}


void test(double erg[2]);
void test(double e);


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

 « Return to Thread: Function Overloading (double and double[])