Skip to content

Commit c85c40b

Browse files
authored
Merge pull request #96 from aerispaha/swig4.3-error-code-fix
applying swmm toolkit fix for compatibility with SWIG>=4.3
2 parents f71869a + bce11ca commit c85c40b

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

owa-epanet/wrapper/toolkit.i

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,39 @@
2424
}
2525

2626
/* TYPEMAP FOR IGNORING INT ERROR CODE RETURN VALUE */
27+
/*
28+
This is the same logic applied in swmm toolkit to handle a breaking change
29+
introduced in the version 4.3 of SWIG. Credit: karosc
30+
31+
See https://github.com/karosc/swmm-python/commit/1ef854ac469c1e2df29f9bb1ed718361df79cc95
32+
*/
33+
%header %{
34+
SWIGINTERN PyObject*
35+
Custom_SWIG_Python_AppendOutput(PyObject* result, PyObject* obj, int is_void) {
36+
if (!result) {
37+
result = obj;
38+
} else if (result == Py_None) {
39+
SWIG_Py_DECREF(result);
40+
result = obj;
41+
} else {
42+
if (!PyList_Check(result)) {
43+
PyObject *o2 = result;
44+
result = PyList_New(1);
45+
if (result) {
46+
PyList_SET_ITEM(result, 0, o2);
47+
} else {
48+
SWIG_Py_DECREF(obj);
49+
return o2;
50+
}
51+
}
52+
PyList_Append(result,obj);
53+
SWIG_Py_DECREF(obj);
54+
}
55+
return result;
56+
}
57+
#define SWIG_Python_AppendOutput Custom_SWIG_Python_AppendOutput
58+
%}
59+
2760
%typemap(out) int {
2861
$result = Py_None;
2962
Py_INCREF($result);

0 commit comments

Comments
 (0)