|
Boost Users : |
From: Peter Piehler (ppiehler_at_[hidden])
Date: 2004-07-04 05:31:41
Hello,
I use call<void>(pyFunc,arg1,..) to call a python
function with standard double, int etc.
What must I do to call a function with a c++ object as
argument?
psydocode:
class MyAnimal
{
/*...*/
std::string __strName;
public:
MyAnimal() : __strName("Tux") {}
/*...*/
std::string getName()
{ return __strName;}
void setName(const std::string &strName)
{ __strName = strName; }
};
int main()
{
/*...*/
MyAnimal* pTux = new Animal;
/*do something with pTux*/
/*use a python function with pTux*/
call<void>(pyFunc1, ?pTux? );
/*change attributes pTux in pyFunc2*/
dog = call<MyAnimal>(pyFunc2, ?pTux?);
/*if it possible to call by reference?*/
call<void>(pyFunc3, ?pTux?);
pTux->getName();// return Cat
}
python module:
def py_func1(a):
print a.getName()
def py_func2(a):
a.setName('Dog')
return a
def py_funnc3(a):
a.setName('Cat')
___________________________________________________________
Gesendet von Yahoo! Mail - Jetzt mit 100MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net