Embedding Python support

Asked by Gregor Burger

Hi,

I would like to use pybindgen for a project where I want to extend c++ defined classes in
python and use them in c++.

generating the bindings works very well, but i can't figure out how to extract the extended
c++ class from a PyObject. I know I can do this by using PyArg_ParseTuple but i need the
Py[ClassName] structure for that. I need to do this because I'm instantiating the objects
from c++.

Is there a way to extract C++ object from an PyObject that pybindgen provides or is it possible
to split the generated sources into header and implementation that I can include and use.

thanks in advance and pybindgen is cool! ;-)

Question information

Language:
English Edit question
Status:
Solved
For:
PyBindGen Edit question
Assignee:
No assignee Edit question
Solved by:
Gustavo Carneiro
Solved:
Last query:
Last reply:
Revision history for this message
Best Gustavo Carneiro (gjc) said :
#1

Splitting the generated sources into header and implementation is possible. NS-3 has this, for instance:
http://code.nsnam.org/ns-3-dev/file/2e293c541a03/bindings/python/ns3modulegen.py (search for "ns3module.h")

Extracting the C++ object from a PyObject is then a matter of casting to a PyXxx structure generated by PBG and then accessing the obj member inside it.

Revision history for this message
Gregor Burger (burger-gregor) said :
#2

Thanks Gustavo Carneiro, that solved my question.