[C++-sig] Default arguments in pyplusplus

Roman Yakovenko roman.yakovenko at gmail.com
Mon Jun 19 07:17:48 CEST 2006

On 6/19/06, Niall Douglas <s_sourceforge at nedprod.com> wrote:
> On 18 Jun 2006 at 20:41, Roman Yakovenko wrote:
> > > Needless to say, the TnFOX python bindings won't work without default
> > > arguments working :(
> >
> > I agree with you, may be you have some where in the code use_keywords = False?
> That's precisely the case. I am talking about default parameters not
> working when use_keywords is False. Sorry, I thought I mentioned that
> earlier in a previous bug report.
> I think surely you will need to use
> BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS() for when keywords are not
> enabled?

As I already said: this macro has limitations. It can not be used in
general case.

> > > I did try adding this on my own, but it's complex. I'm afraid the
> > > class hierarchy in pyplusplus is fairly complex, complex enough that
> > > without a debugger it's hard to modify. So I'll have to leave it to
> > > you Roman!
> >
> > Please provide test case and I will try to fix ASAP.
> I think that I have use_keywords as False is enough?

Yes this is enough.

> Try your unit
> test with use_keywords as False, if that still works I will modify
> one of your unit tests to show the behaviour.

Why don't you resolve the issue with enums. I see few ways to go:

To find places where enum used as default arguments and enum still not exported
>From here you have 2 solutions: to remove default arguments or to change default
arguments to have integer type with value of enum. This should work.

Another solution is to move enum to from class to FX namespace. In
this case it will be
exported earlier.

There is third approach:
Every function has "overloads" property. You can find all member
functions, that are
overloaded. Then you can exclude them. After this, generate code that
uses the macro
in one file ( may be it is a time to implement interface that will
allow to edit generated cpp
file ). And finally you can add the code to the class using add_code.

What do you think?

Roman Yakovenko
C++ Python language binding

More information about the Cplusplus-sig mailing list