Hi!
I've been using the boost::python library for some time with few problems but now I got stuck.
Fortunately I isolated the problem.
In the class Domain below I defined a property called solver which returns a shared_ptr<Solver>
instance:
namespace bp=boost::python;
class Solver
{
public:
bool _b;
void func() { _b = true; }
};
typedef shared_ptr<Solver> Solver_ptr;
class Domain
{
public:
Solver_ptr solver;
void set_solver(Solver_ptr s) { solver = s; }
};
typedef shared_ptr<Domain> Domain_ptr;
BOOST_PYTHON_MODULE(test) {
bp::class_<Solver, Solver_ptr>("Solver").def("func", &Solver::func);bp::class_<Domain, Domain_ptr>("Domain").def("set_solver" , &Domain::set_solver).add_property("solver" , &Domain::solver);
}
from test import *
d = Domain()
s = Solver()
d.set_solver(s) # is it ok to do that?
d.solver.func() # this line does not work
Traceback (most recent call last):File "test_test.py", line 5, in <module>d.solver.func()Boost.Python.ArgumentError: Python argument types inSolver.func(Solver)did not match C++ signature:func(Solver {lvalue})