← Back to team overview

yade-users team mailing list archive

[Question #236389]: How to pass a python callback function tom C++

 

New question #236389 on Yade:
https://answers.launchpad.net/yade/+question/236389

I want to pass a python callback function through a python::object to my C++ class. But I get errors due to serialization problems. I need to get the return value of this callback function.
Has someone already done this?

void
MyClass::pyHandleCustomCtorArgs(python::tuple& t, python::dict& d)
{
  if (python::len(t) != 1)
    throw invalid_argument("Exactly 1 argument must be given.");
  prob_func = python::extract<python::object*>(t[0])();
}

Is it correct to use the python::object to pass a python function? And how can I avoid the serialization problems?

Thanks for any help

Cheers Reza

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.