Skip to content

Commit

Permalink
Fix bindc class wrapping
Browse files Browse the repository at this point in the history
This is due to a change in d387ea2 that processes `feature:nodefault` before the Language sees it.
A betetr solution is to override the behavior in the constructor and destructor handlers.
  • Loading branch information
sethrj committed Aug 18, 2023
1 parent 0df3460 commit 78a5192
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Source/Modules/fortran.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2310,10 +2310,6 @@ int FORTRAN::classDeclaration(Node *n) {
if (!fsymname)
return SWIG_NOWRAP;
}
if (GetFlag(n, "feature:fortran:bindc")) {
// Prevent default constructors, destructors, etc.
SetFlag(n, "feature:nodefault");
}

// Build symbol table here, even if class is being imported
Symtab *fsymtab = NewHash();
Expand Down Expand Up @@ -2491,6 +2487,11 @@ int FORTRAN::classHandler(Node *n) {
* \brief Extra stuff for constructors.
*/
int FORTRAN::constructorHandler(Node *n) {
if (this->is_bindc_struct()) {
// Don't generate destructor for %fortranbindc structs
return SWIG_NOWRAP;
}

// Set fortran symname of this function to the class symname
Setattr(n, "fortran:name", Getattr(this->getCurrentClass(), "fortran:name"));

Expand All @@ -2510,6 +2511,11 @@ int FORTRAN::constructorHandler(Node *n) {
* \brief Handle extra destructor stuff.
*/
int FORTRAN::destructorHandler(Node *n) {
if (this->is_bindc_struct()) {
// Don't generate destructor for %fortranbindc structs
return SWIG_NOWRAP;
}

// Make the destructor a member function called 'release'
Setattr(n, "fortran:name", "release");
SetFlag(n, "fortran:ismember");
Expand Down

0 comments on commit 78a5192

Please sign in to comment.