swig-fortran / swig

This fork of SWIG creates Fortran wrapper code from C++ headers.
http://www.swig.org
Other
42 stars 11 forks source link

Replace `NATIVE` typemap with more standard SWIG behavior #78

Closed sethrj closed 5 years ago

sethrj commented 6 years ago

Instead of adding NATIVE typemap definitions, choose to handle vectors/arrays/strings as described in the typemaps/std_vector documentation:

The aim of all that follows would be to integrate std::vector with as much as possible, namely, to allow the user to pass and be returned tuples or lists. const declarations are used to guess the intent of the function being exported; therefore, the following rationale is applied:

  • f(std::vector), f(const std::vector&): the parameter being read-only, either a sequence or a previously wrapped std::vector can be passed.
  • f(std::vector&), f(std::vector*): the parameter may be modified; therefore, only a wrapped std::vector can be passed.
  • std::vector f(), const std::vector& f(): the vector is returned by copy; therefore, a sequence of T:s is returned which is most easily used in other functions
  • std::vector& f(), std::vector* f(): the vector is returned by reference; therefore, a wrapped std::vector is returned
  • const std::vector f(), f(const std::vector): for consistency, they expect and return a plain vector pointer.
sethrj commented 5 years ago

Fixed in 80c0e00512ee7912465d03eca3fbdf8e30e8671f