Skip to content
11 changes: 9 additions & 2 deletions python_orocos_kdl/PyKDL/kinfam.sip
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,15 @@ public:

unsigned int getNrOfJoints()const;
unsigned int getNrOfSegments()const;

const Segment& getSegment(unsigned int nr)const /Factory/;

const Segment* getSegment(unsigned int nr)const /Factory/;
%MethodCode
if (a0 < 0 || a0 >= (unsigned int)sipCpp->getNrOfSegments()) {
PyErr_SetString(PyExc_IndexError, "Chain index out of range");
return 0;
}
sipRes = &(sipCpp->getSegment(a0));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I am not sure if this is valid in SIP. The /Factory/ annotation indicates that the returned pointer is owned by Python, but actually the returned pointer must not be deleted independently. I wonder whether that annotation was actually correct even for the original version of the method.

Why did you change the return type from const Segment& to const Segment*?

Could anybody who is more proficient with SIP could jump in (@smits)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not mean to change the return type, that must have slipped in while I was testing, good catch.

%End

};

Expand Down