jameskermode / f90wrap

F90 to Python interface generator with derived type support
GNU Lesser General Public License v3.0
246 stars 83 forks source link

Support for allocatable polymorphic class objects #235

Open krystophny opened 6 days ago

krystophny commented 6 days ago

This is a continuation of #227 required for #41. The idea is to wrap class instances into a type to keep pointer logic and avoid automatic deallocation, in order to keep remaining changes minimal:

type :: myclass_wrapper_t
    class(myclass_impl_t), allocatable :: obj
end type myclass_wrapper_t

Developing on https://github.com/itpplasma/f90wrap/tree/issue235_allocatable_classes

krystophny commented 5 days ago

The automatically generated constructor in add_missing_constructors has to be modified to also allocate the nested object in the wrapper in addition to the pointer. This is currently done in write_init_lines where it doesn't belong.

krystophny commented 5 days ago

Currently, the parse tree is transversed twice in order to check if a type is used as a class afterwards. The clean way would be to annotate the type node by a is_used_as_class attribute.