LLNL / shroud

Shroud: generate Fortran and Python wrappers for C and C++ libraries
BSD 3-Clause "New" or "Revised" License
90 stars 7 forks source link

adding header files to wrapNAME.cpp #235

Closed wojdyr closed 3 years ago

wojdyr commented 3 years ago

With this config:

library: abc
namespace: abc
#cxx_header: a.hpp

declarations:

- decl: class A
  cxx_header: a.hpp
  declarations:
  - decl: A()

- decl: class B
  cxx_header: b.hpp
  declarations:
  - decl: B()

wrapA.cpp has #include "a.hpp" and wrapB.cpp has #include "b.hpp". wrapabc.cpp which uses both abc::A and abc::B in ABC_SHROUD_memory_destructor doesn't have these includes. I could specify global cxx_header, but can I add more than one header there? Ideally, these headers would be included automatically.

ltaylor16 commented 3 years ago

I've started a branch to fix this.

ltaylor16 commented 3 years ago

I merged changes into the develop branch which fixes the problem. I took the opportunity to move the memory destructor routine into the utility file. It seemed to make more sense in there. I also found a commit comment from a couple of years ago that suggested the change, so I've been thinking about it for a while. This may requires changes to any Makefile used to compile the wrapper since the utility file may not of been created before.

ltaylor16 commented 3 years ago

To answer the question in your original comment: cxx_header is a blank delimited list of filenames so you can include multiple names. They should be included in the generated source in the same order as listed in case there are any dependencies.

wojdyr commented 3 years ago

Thanks for these changes. Yes, I realized that I can put multiple filenames after opening this issue.

BTW regarding Fortran previous work, there is also h2m-AutoFortran tool (I haven't tried it, though).