@@ -2832,16 +2832,15 @@ int FORTRAN::enumDeclaration(Node *n) {
2832
2832
* treated as global const variables.
2833
2833
*/
2834
2834
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
-
2841
2835
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
2843
2843
Append (d_enum_public, fsymname);
2844
- // Print the enum to the list
2845
2844
Printv (f_fdecl, " enumerator :: " , fsymname, NULL );
2846
2845
if (String *value = Getattr (n, " enumvalue" )) {
2847
2846
Printv (f_fdecl, " = " , value, NULL );
@@ -2882,6 +2881,15 @@ int FORTRAN::constantWrapper(Node *n) {
2882
2881
value = Getattr (n, " value" );
2883
2882
}
2884
2883
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
+
2885
2893
if (is_native_constant) {
2886
2894
if (!value) {
2887
2895
Swig_error (input_file,
0 commit comments