Modify a C++ instance from the embed python interpreter

W

Wezzy

Hi, is there a tool that automatically expose an object to python? i
have an instance of a C++ (or ObjC) object and i want to pass it to the
embed interpreter that runs inside my program.
Python code have to call c++ method and register some callback.

I know that swig helps when python creates c++ instance but i've the
instance and i want to use it with python.

Thanks
 
D

Diez B. Roggisch

Wezzy said:
Hi, is there a tool that automatically expose an object to python? i
have an instance of a C++ (or ObjC) object and i want to pass it to the
embed interpreter that runs inside my program.
Python code have to call c++ method and register some callback.

I know that swig helps when python creates c++ instance but i've the
instance and i want to use it with python.

That is the same case, wrt SWIG - the objects methods get accessed by
functions like

int Object_foo(Object *s) {
return s->foo();
}


So passing a exiting object reference to such a function will work. You
might also consider using SIP, it appears to me to be much more OO.

Diez
 
W

Wezzy

Diez B. Roggisch said:
That is the same case, wrt SWIG - the objects methods get accessed by
functions like

int Object_foo(Object *s) {
return s->foo();
}

Can you post few line of code ?
So passing a exiting object reference to such a function will work. You
might also consider using SIP, it appears to me to be much more OO.

Diez

well i'll look to SIP but i prefer to use swig because it can interface
C++ with other language such as ruby
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top