Skip to content

Commit db1c911

Browse files
committed
Fix SWIGPOLICY for downstream modules
1 parent e8928d4 commit db1c911

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

Source/Modules/fortran.cxx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,24 @@ int FORTRAN::classDeclaration(Node *n) {
22912291
}
22922292
}
22932293

2294+
// Define policy
2295+
if (CPlusPlus) {
2296+
if (SwigType *name = Getattr(n, "name")) {
2297+
String *policystr = Swig_string_mangle(name);
2298+
Insert(policystr, 0, "SWIGPOLICY_");
2299+
Setattr(n, "fortran:policy", policystr);
2300+
2301+
// Define policies for the class
2302+
const char *policy = "swig::ASSIGNMENT_DEFAULT";
2303+
if (Getattr(n, "feature:smartptr")) {
2304+
policy = "swig::ASSIGNMENT_SMARTPTR";
2305+
} else if (!GetFlag(n, "allocate:default_destructor")) {
2306+
policy = "swig::ASSIGNMENT_NODESTRUCT";
2307+
}
2308+
Printv(f_policies, "#define ", policystr, " ", policy, "\n", NULL);
2309+
}
2310+
}
2311+
22942312
return Language::classDeclaration(n);
22952313
}
22962314

@@ -2346,25 +2364,6 @@ int FORTRAN::classHandler(Node *n) {
23462364
}
23472365
Printv(f_class, ", public :: ", fsymname, "\n", NULL);
23482366

2349-
// Define policy
2350-
if (CPlusPlus)
2351-
{
2352-
SwigType *name = Getattr(n, "name");
2353-
ASSERT_OR_PRINT_NODE(name, n);
2354-
String *policystr = Swig_string_mangle(name);
2355-
Insert(policystr, 0, "SWIGPOLICY_");
2356-
Setattr(n, "fortran:policy", policystr);
2357-
2358-
// Define policies for the class
2359-
const char *policy = "swig::ASSIGNMENT_DEFAULT";
2360-
if (Getattr(n, "feature:smartptr")) {
2361-
policy = "swig::ASSIGNMENT_SMARTPTR";
2362-
} else if (!GetFlag(n, "allocate:default_destructor")) {
2363-
policy = "swig::ASSIGNMENT_NODESTRUCT";
2364-
}
2365-
Printv(f_policies, "#define ", policystr, " ", policy, "\n", NULL);
2366-
}
2367-
23682367
if (!bindc) {
23692368
if (!base_fsymname) {
23702369
// Insert the class data if this doesn't inherit from anything

0 commit comments

Comments
 (0)