logo       

Re: typemaps for python lists (double,int) as function arguments: msg#00182

programming.swig

Subject: Re: typemaps for python lists (double,int) as function arguments

At 12:15 PM 1/31/03 +0000, Marcus Stojek wrote:
Now what do I have to do, if I want to pass an array
of variable lenght to a function?

int calc( double *){
....}

Marcus,
I'm puzzled. Before even taking SWIG into the picture, how would the C function know the length of the array you're passing? Is it some kind of global variable, does the array use some kind of terminator, or (more likely) is the function actually declared as
int calc( double*, int size ) ?
In the first case, you can simply use the global variable; in the second case, you'll have to use PyList_Size and build the array, including the terminator; in the third case (which I do hope is the one you're using) you can write a typemap for both arguments at once (see http://www.swig.org/Doc1.3/Typemaps.html#n40 for details).

Hope this helps,
Luigi


_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise