create a c++ wrapper for python class?

M

Mark Harrison

Right now I'm using Boost Python to wrap some C++ code so
that applications from both languages can use it.

This is great, but I'm rapidly coming to the conclusion that
a lot of this work is better coded in Python. There's nothing
particularly CPU-bound, and the comprehensive Python library is a
big help.

So, I'm looking for a C++ wrapper generator, so that I can
write a class in Python, and then have a .h and .cpp generated
that will give me a corresponding C++ class.

Of course, the usual restrictions apply: no dynamically
added methods, accessing all instance data via getters
and setters, etc.

It seems a first cut of this is pretty straightforward,
using introspection to get the required methods. Something
needs to be done to specify the C++ types of the parameters.

Is there any work being done in this area?

Many TIA,
Mark
 
D

Diez B. Roggisch

Mark said:
Right now I'm using Boost Python to wrap some C++ code so
that applications from both languages can use it.

This is great, but I'm rapidly coming to the conclusion that
a lot of this work is better coded in Python. There's nothing
particularly CPU-bound, and the comprehensive Python library is a
big help.

So, I'm looking for a C++ wrapper generator, so that I can
write a class in Python, and then have a .h and .cpp generated
that will give me a corresponding C++ class.

Of course, the usual restrictions apply: no dynamically
added methods, accessing all instance data via getters
and setters, etc.

It seems a first cut of this is pretty straightforward,
using introspection to get the required methods. Something
needs to be done to specify the C++ types of the parameters.

Is there any work being done in this area?

No - and I doubt there is much to do about that. C++ needs so many
static information to form a proper class, you'd end up duplicating the
whole declarational efforts in some awkward addition or complementary
annotation to python's syntax that it just isn't feasible. There is
shedskin, avery interesting project, but then this sufers from being a
subset of python and AFAIK no seamless interoperability between python
and C++.

I don't know about boost - but I know my way around SIP a little bit.
So what I would do is to declare whatever you need in C++ in a class
with all virtual methods. SIP then should be able to let you subclass
that class in python, and pass back instances of your python classes to
your C++-core/library/whatever.

Diez
 

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,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top