Hi Neal. I suppose you read my posts on boost.python mailing list.
If not you suggest you to read them.
Any way, I implemented the missing functionality. In your case
struct A {};
struct B {
A& a;
};
py++ will create next code:
#include "boost/python.hpp"
#include "1.h"
namespace bp =3D boost::python;
struct B_wrapper : B, bp::wrapper< B > {
static ::A & get_a( B& inst ) {
return inst.a;
}
static void set_a( B& inst, ::A & new_value ){
inst.a =3D new_value;
}
};
BOOST_PYTHON_MODULE(pyplusplus){
if( true ){
typedef bp::class_< B_wrapper, boost::noncopyable > B_exposer_t;
B_exposer_t B_exposer =3D B_exposer_t( "B", bp::no_init );
bp::scope B_scope( B_exposer );
B_exposer.def( "get_a"
, (::A & (*)( ::B ))(&B_wrapper::get_a)
, bp::return_value_policy<
bp::copy_non_const_reference, bp::default_call_policies >() );
B_exposer.def( "set_a"
, (void (*)( ::B,::A & ))(&B_wrapper::set_a)
, bp::default_call_policies() );
}
bp::class_< A >( "A" );
}
You can change call policies for every function using getter_call_policies
and setter_call_policies of variable_t class.
It would be nice if you can try new functionality and report problems and/o=
r
suggestions. I did some testing, but not a full one.
Thanks
--=20
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|