f90wrap icon indicating copy to clipboard operation
f90wrap copied to clipboard

object-bound procedures...

Open perrette opened this issue 9 years ago • 7 comments

...do not seem to be supported. I mean here:

module mod1_api
  implicit none

  type typ1
    integer :: n = 2
  contains
    procedure :: inc
  end type

contains

  subroutine inc(self) 
    class(typ1), intent(inout) :: self
    t%n = t%n + 1
  end subroutine

end module

e.g. of use in fortran:

program  prog
  use mod1_api
  type(typ1) :: t
  call t%inc()
  print*, t%n
end program

Note it is a secondary issue (there seem to be more advantages not using this feature than otherwise in fortran...), so it would be only justified to work on that if this would require only minor work (e.g. in the wrapper, replace back class with type, remove the contains part of the type and use information provided by procedure :: inc or procedure :: inc => typ1_inc to add methods to the corresponding python class...)

This would be quite handy on the python side though.

perrette avatar Dec 11 '15 20:12 perrette

An option to f90wrap to create classes automatically from type and functions / methods having the type as first argument could also be a handy feature. What do you think? I will have a look into it at some point...

perrette avatar Dec 18 '15 17:12 perrette

The second request, to create classes from functions which "look like" methods is already supported. See the --move-methods command line argument to f90wrap. Wrappers for functions/subroutines with a derived type instance as first argument are moved into the Python class defining the type.

jameskermode avatar Dec 21 '15 14:12 jameskermode

Excellent, thanks !

perrette avatar Dec 25 '15 19:12 perrette

Hi! Is there support scheduled for the first request here, i.e. allow class(object) declaration instead of type(object)?

leonfoks avatar May 31 '16 18:05 leonfoks

As far as I know no-one is working on this, but pull requests would be welcome!

jameskermode avatar Jun 12 '16 17:06 jameskermode

Has there been any development on this front? Being able to move type bound procedures into the python class would be very useful!

akshaysubr avatar Apr 29 '17 20:04 akshaysubr

Are there any new developments in this direction?

enricofacca avatar Jul 03 '20 15:07 enricofacca