Re: Array return argument with typemaps

William S Fulton <[email protected]>
Newsgroups gmane.comp.programming.swig
Message-ID <CANGqftDkPYu2oK9kUYGafdOecY7ShX_t4nAXH3-oP8Q4nYXsXw@mail.gmail.com>
On Thu, 4 Jun 2020 at 18:02, Alberto Luaces <[email protected]>
wrote:

> Hello,
>
> I am wrapping a function that receives a pointer to class, double
> parameter and writes the computation to an array:
>
> extern "C" void interp5C(spline *stat, double G, double *f);
>
> The input arguments are working well.  The "stat" object holds the size
> of the system and thus the size that "f" should have.
>
>
This is a complex API because the type information is split over more than
one C type and there is an unrelated parameter (double G) splitting the two
associated C types. If your api insted contained related types next to each
other like this:

extern "C" void interp5C(spline *stat, double *f, double G);

Then you could write multi-argument typemaps for (spline *stat, double *f)
with access to both parameters in the one typemap.


> and this works, but I am not entirely convinced with this, because I am
> accessing "arg1" directly to refer to "stat", which I think it is not
> very clean.
>
> Correct.

Your marshalling seems complex too with a Matrix class and dim_vector class
which I don't follow. I'd be tempted to write a simple C/C++ function
wrapper with all this code in instead.

William

_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.