I am attempting to create python bindings for some C++ code using swig. I seem have run into a problem trying to create python properties from some accessor functions I have for
From http://www.swig.org/Doc2.0/SWIGDocumentation.html#SWIG_adding_member_functions:
A little known feature of the %extend directive is that it can also be used to add synthesized attributes or to modify the behavior of existing data attributes. For example, suppose you wanted to make magnitude a read-only attribute of Vector instead of a method.
So in your example the following should work:
%extend Player {
Entity entity;
}
%{
Entity* Player_entity_get(Player* p) {
return p->get_entity();
}
void Player_entityProp_set(Player* p, Entity* e) {
p->set_entity(e);
}
%}