Skip to content

Commit 156763a

Browse files
authored
Communicate through swig that PathPointSet::insert takes ownership (opensim-org#3276)
* Communicate through swig that PathPointSet::insert takes ownership of the passed in pointer * Update java_simulation.i Beef up the comment explaining the change * Update CHANGELOG.md Update changelog
1 parent 498e95f commit 156763a

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Bindings/Java/swig/java_simulation.i

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ using namespace SimTK;
3131

3232
%rename OpenSim::PathPointSet::clone unused_clone;
3333

34+
// replace insert with a variant that takes ownership of passed in AbstractPathPoint.
35+
// in java the method 'insert' ends in super class so we can call it internally
36+
// and that hides the super class method
37+
%typemap(javacode) OpenSim::PathPointSet %{
38+
public boolean insert(int aIndex, AbstractPathPoint aObject) {
39+
aObject.markAdopted();
40+
return super.insert(aIndex, aObject);
41+
}
42+
%}
43+
3444
%extend OpenSim::Body {
3545
void getInertia(Array<double>& rInertia) {
3646
SimTK::Mat33 inertia= self->getInertia().toMat33();

Bindings/Python/swig/python_simulation.i

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ MODEL_ADOPT_HELPER(Controller);
9292
args[1]._markAdopted()
9393
%}
9494

95+
// PathPointSet takes ownership of passed in object
96+
%pythonappend OpenSim::PathPointSet::insert %{
97+
aObject._markAdopted()
98+
%}
9599
// Typemaps
96100
// ========
97101
// None.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ v4.4.1
1010
======
1111

1212
- Made `Component::getSocketNames` a `const` member method (previously: non-const)
13+
- Modifed the swig interface files to make OpenSim::PathPointSet adopt new PathPoints inserted into it. (Issue #3276)
1314

1415
v4.4
1516
====

0 commit comments

Comments
 (0)