|
AW: typemaps for python lists (double,int) as function arguments: msg#00184programming.swig
Hi Luigi, thank you. Of course you're right. While testing I have stripped my example code more and more resulting in a function calc that does actually nothing. In reality I am using the (double*, int size) solution right now. And I was just reading the chapter of the doc you referred to :-) In "real" reality my funcitons look like: calc(double*, int size, double*, int size, double*, int size) with the first two lists going in and the last storing the result. For other functions the number of in and out list changes and some additional parameters are passed in. So would you suggest writing a single typemap for each function, maybe using the parameter names explicitly? Or is there a smarter solution. For the outgoing list I guess I have to use an (argout) typemap that will create Pythonlist for me. The only way I found for doing this is PyList_New and a PyList_Append loop. Isn't that awfully slow? marcus > -----Ursprüngliche Nachricht----- > Von: Luigi Ballabio [mailto:luigi.ballabio@xxxxxxxxxxxxx] > Gesendet: Freitag, 31. Januar 2003 11:57 > An: Marcus Stojek; swig@xxxxxxxxxxxxxxx > Betreff: Re: [Swig] 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> |
|---|---|---|
| Previous by Date: | [Newbie]:swig wrappers for bootstrapped classes: 00184, David Beazley |
|---|---|
| Next by Date: | Re: swig and perl580 and sun solaris compiler 5.3: 00184, Good Times |
| Previous by Thread: | Re: typemaps for python lists (double,int) as function argumentsi: 00184, Luigi Ballabio |
| Next by Thread: | Re: AW: typemaps for python lists (double,int) as function arguments: 00184, Luigi Ballabio |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |