Original Post
hi, i would like to embed a scripting language in my (planned) c++ apps. i've found boost.python now, and it seems to be what i need. nevertheless, i'm still unsure whether i can do the follwoing with boost.python: (note that the python-related part is just pseudo-code :> ) Where the python code sets a to 5 directly (something like foobar.a=5), calls printHelloPython(), sets the someNumber instance inside foobar to 1330 and then calls foobar.add(2). I'd expect an output of "hello python" and the returned result from main to be 1337. so, can i manipulate the c++ instance from within a python script? if i can't, is there a scripting language that i can embed in my application that is able to do the job?
class someNumber
{
public:
float x;
someNumber() : x(0) {}
};
class myClass
{
public:
int a;
someNumber* number;
myClass() : a(0) {number=new someNumber();}
~myClass(){delete number;}
void add(const int x) {a+=x;}
};
void printHelloPython()
{
std::cout<<"hello python";
}
int main()
{
myClass foobar();
revealFunctionToPython(&printHelloPython);
revealClassToPython("someNumber");
revealClassToPython("myClass");
revealInstanceToPython(&foobar);
runThatPythonScrip();
return foobar.a+foobar.number.x;
}