Skip to content

Commit c348df5

Browse files
author
Sam Hatchett
committed
fixes memory management, strips pseudoscope prefix from enums
1 parent cad6123 commit c348df5

5 files changed

Lines changed: 23 additions & 17 deletions

File tree

owa-epanet/scripts/clean.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ _skbuild \
99
_cmake_test_compile \
1010
dist \
1111
packages/epanet.egg-info \
12-
test/*
12+
test/Pipf*
1313

1414
touch test/Pipfile
15-

owa-epanet/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name = "owa-epanet",
9-
version = "1.0.2",
9+
version = "1.0.3",
1010
author = "Sam Hatchett",
1111
author_email = "samhatchett@gmail.com",
1212
description = "a thin wrapper for epanet hydraulic toolkit",

owa-epanet/test/test-lib.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from epanet import toolkit
2+
3+
for i in range(1,4):
4+
p = toolkit.createproject()
5+
toolkit.deleteproject(p)
6+
7+
p = toolkit.createproject()
8+
del p

owa-epanet/wrapper/toolkit.i

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
%{
77
#include <epanet2_2.h>
88
%}
9-
%include <epanet2_enums.h>
109

11-
/* strip the pseudo-scope from function declarations */
10+
/* strip the pseudo-scope from function declarations and enums*/
1211
%rename("%(strip:[EN_])s") "";
1312

1413
%typemap(in,numinputs=0) EN_Project* (EN_Project temp) {
@@ -25,16 +24,6 @@
2524
Py_INCREF($result);
2625
}
2726

28-
%delobject deleteproject;
29-
30-
struct Project {};
31-
%extend Project {
32-
~Project() {
33-
EN_deleteproject($self);
34-
}
35-
};
36-
%ignore Project;
37-
3827
%apply int *OUTPUT {
3928
int *count,
4029
int *version,
@@ -105,6 +94,14 @@ struct Project {};
10594
int *inout_index
10695
}
10796

97+
%nodefault Project;
98+
struct Project {};
99+
%extend Project {
100+
~Project() {
101+
EN_deleteproject($self);
102+
}
103+
};
104+
ignore Project;
108105

109106
/* INSERTS CUSTOM EXCEPTION HANDLING IN WRAPPER */
110107
%exception
@@ -120,6 +117,8 @@ struct Project {};
120117
}
121118

122119
%feature("autodoc", "2");
120+
%newobject EN_createproject;
121+
%delobject EN_deleteproject;
122+
%include <epanet2_enums.h>
123123
%include <epanet2_2.h>
124-
125124
%exception;

0 commit comments

Comments
 (0)