By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,341 Members | 1,395 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,341 IT Pros & Developers. It's quick & easy.

create a c++ wrapper for python class?

P: n/a
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

--
Mark Harrison
Pixar Animation Studios
May 10 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Mark Harrison schrieb:
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
May 11 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.