dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #21100
Re: std::vector SWIG typemaps
On Saturday January 29 2011 14:00:50 Garth N. Wells wrote:
> On 29/01/11 21:59, Johan Hake wrote:
> > On Saturday January 29 2011 12:14:36 Garth N. Wells wrote:
> >> Do we still have std::vector<uint> SWIG typemaps, or were they removed?
> >
> > I am cleaning up some of the standalone typemaps we have now, putting
> > them into a macro. However we need to have a convention for how these
> > are passed.
> >
> > For now:
> > std::vector<PRIMITIVE>& values
> >
> > will generate an argout typemap, and
> >
> > const std::vector<PRIMITIVE>& values
> >
> > will generate an in typemap.
> >
> > Both of them need to be instantiated calling the macro at the end of
> > std_vector_typemaps.i. They all map a NumPy array to/from a std::vector.
> >
> > I see that the color_type vector is not a const reference and the typemap
> > will not kick in. Is the rationale for this that it is small, (only size
> > 3).
>
> Yes.
>
> > Maybee
> > this should be mapped to a tuple instead in Python?
>
> Yes, a tuple is appropriate. It tried it quickly, but it didn't work.
I just added a typemap macro for any std::vectors that is passed by value. Now
any sequence of scalars can be passed. The typemap is enabled for the previous
arguments (value_shape, values (Constant)) and for the color_type
(untested...)
Johan
> Garth
>
> > We have a similare logic
> > logic for the pass by value typemap for Expression(std::vector<uint>
> > value_shape), which here maps to a list (not a tuple...).
> >
> > It makes sense to add a typemap macro for pass by value std::vectors,
> > that maps to an iterable in Python.
> >
> > Johan
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help : https://help.launchpad.net/ListHelp
References