Skip to content

Commit 61f8527

Browse files
committed
Fix interplay between constant handlers and getters
1 parent 4b989fa commit 61f8527

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

Source/Modules/fortran.cxx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,16 +2832,15 @@ int FORTRAN::enumDeclaration(Node *n) {
28322832
* treated as global const variables.
28332833
*/
28342834
int FORTRAN::constantWrapper(Node *n) {
2835-
// Get or create a unique fortran identifier
2836-
String *fsymname = this->get_fsymname(n);
2837-
if (!fsymname) {
2838-
return SWIG_ERROR;
2839-
}
2840-
28412835
if (d_enum_public) {
2842-
// We're wrapping a native enumerator: add to the list of enums being built
2836+
// We're wrapping a native enumerator.
2837+
String *fsymname = this->get_fsymname(n);
2838+
if (!fsymname) {
2839+
return SWIG_ERROR;
2840+
}
2841+
2842+
// Add to list of public enums
28432843
Append(d_enum_public, fsymname);
2844-
// Print the enum to the list
28452844
Printv(f_fdecl, " enumerator :: ", fsymname, NULL);
28462845
if (String *value = Getattr(n, "enumvalue")) {
28472846
Printv(f_fdecl, " = ", value, NULL);
@@ -2882,6 +2881,15 @@ int FORTRAN::constantWrapper(Node *n) {
28822881
value = Getattr(n, "value");
28832882
}
28842883

2884+
// Get or create a unique fortran identifier *after* we've confirmed it's
2885+
// going to be wrapped as a constant. Otherwise "getter" functions sent to
2886+
// globalvariableHandler above will be renamed so that they lose the `get_`
2887+
// prefix.
2888+
String *fsymname = this->get_fsymname(n);
2889+
if (!fsymname) {
2890+
return SWIG_ERROR;
2891+
}
2892+
28852893
if (is_native_constant) {
28862894
if (!value) {
28872895
Swig_error(input_file,

0 commit comments

Comments
 (0)