Reputation: 165
I have this following code in my Swig file (.i) :
%extend vgSofa::handler::VertexShape
{
vgd::Shp< vgSofa::handler::VertexShape > createVSWithNode( sofa::simulation::Node * root )
{
vgd::Shp< vgSofa::handler::VertexShape > result( new vgSofa::handler::VertexShape() );
return result->init(root) ? result : vgd::Shp< vgSofa::handler::VertexShape >();
}
vgd::Shp< vgSofa::handler::VertexShape > createVSWithBsicHandler( vgd::Shp<vgSofa::handler::BasicHandler> h )
{
return vgSofa_handler_VertexShape_createVSWithNode( $self, h->getRoot() );
}
};
in .cpp file created, swig adds another parameter in my methods :
SWIGINTERN vgd::Shp< vgSofa::handler::VertexShape > vgSofa_handler_VertexShape_createVSWithBsicHandler(vgSofa::handler::VertexShape *self,vgd::Shp< vgSofa::handler::BasicHandler > h)
{...}
How do I prevent the addition of this additional parameter to VertexShape?
Upvotes: 1
Views: 938
Reputation: 6757
That is a normal behavior. SWIG's %extend
directive generates stand-alone functions in the generated code. If you use $self
in the body, that function is provided with an argument (named "self") that is a pointer to an instance of the C++ class.
As a side note: C++ does the same thing under the hood. The this
pointer is implicitly passed as first argument to all non-static member functions.
Upvotes: 1