From 78a51929c30324dbc31b64d17ef4524496a0473d Mon Sep 17 00:00:00 2001 From: Seth R Johnson Date: Fri, 18 Aug 2023 14:39:55 -0400 Subject: [PATCH] Fix bindc class wrapping This is due to a change in d387ea21d6b51463429dd7ddbdb5c64298252a6a that processes `feature:nodefault` before the Language sees it. A betetr solution is to override the behavior in the constructor and destructor handlers. --- Source/Modules/fortran.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/Modules/fortran.cxx b/Source/Modules/fortran.cxx index 7cd4099c3cb..80921e06f2b 100644 --- a/Source/Modules/fortran.cxx +++ b/Source/Modules/fortran.cxx @@ -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(); @@ -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")); @@ -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");