[C++-sig] pyplusplus: Feature requests

Roman Yakovenko roman.yakovenko at gmail.com
Mon Feb 27 07:48:58 CET 2006

On 2/26/06, Matthias Baas <baas at ira.uka.de> wrote:
> - When keywords are disabled on a constructor any optional argument is
> turned into a non-optional argument. Pyste uses the optional<> construct
> to set optional values. It would be great if pyplusplus would do that as
> well, so that optional values are still optional even when keywords are
> not specified. So for example, if there's a constructor that takes 3
> doubles from which two are optional, Pyste generates:
>    .def(init< double, optional< double, double > >())
> I haven't checked, but maybe this scheme even works with keyword
> arguments...? (which would solve the registration order problem for
> constructors)
> - Copy constructors don't get wrapped
> - Index operators don't get wrapped
> - Friend functions that implement operators for a class don't get
> wrapped (for example, if you have a 3D vector class and you implement
> the scalar multiplication with a float you need such a friend function
> if you also want to support the expression float*vec and not only
> vec*float).
> By the way, here I don't understand why I actually can multiply my
> vectors with an integer (even from both sides), but not with a float
> from the right side. The following are all the defs in my vector that
> deal with multiplication:
>    MVector_exposer.def( bp::self * bp::self );
>    MVector_exposer.def( bp::self * bp::other< double >() );
>    MVector_exposer.def( bp::self * bp::other< MMatrix >() );
> So why can I multiply my vector with an integer? (the C++ class does
> allow that but the stuff isn't wrapped) And if I try to multiply a float
> from the left side I get:
> TypeError: can't multiply sequence by non-int
> ?!?
> - When using a cache the order of enum values changes in the generated
> source files from call to call. This leads to new compilations that
> wouldn't be necessary.
> - Are there any plans on adding some support for creating wrapper
> methods in cases where they are absolutely necessary? Suppose you have a
> method void getSize(int& width, int& height) that returns the resolution
> of an image. pyplusplus currently wraps that method happily without
> issuing a warning, but I'm not even able to call that function from
> Python, let alone will it ever do what it's supposed to do. I don't
> expect pyplusplus to deal with such cases in a fully automated manner
> (as to date, reading the user's mind is still out of scope of such tools
> ;) but it could help the user resolve these things. A minimal aid would
> simply be to report such methods that might not work in Python so that
> the user knows he has to do something about it. Maybe for some cases we
> could provide some automatic wrapper generation once the user has
> specified which arguments are actually output values and shouldn't be
> part of the argument list in Python.

pyplusplus has functionality I needed. The functionality you are
talking about is needed.
I will added, but it will take some time.

Can you create relevant test cases and send them to me? I will add the
code that fixes it.

Also, I do plan to create automatic wrapper for non virtual functions
like getSize(int& width, int& height)


> - Matthias -

Roman Yakovenko
C++ Python language binding

More information about the Cplusplus-sig mailing list