[C++-sig] [Py++] Nested enum as default arg

Roman Yakovenko roman.yakovenko at gmail.com
Wed Sep 6 21:31:32 CEST 2006


On 9/6/06, Kirill Lapshin <kir at lapshin.net> wrote:
> Oh, I see. But that would only work for enums, wouldn't it? I would
> prefer some more generic solution. In fact I've already encountered
> another similar problem. This time it is more along the lines of:
>
> struct Foo
> {
>      explicit Foo( const shared_ptr<Foo>& foo = shared_ptr<Foo>() );
> };
>
>
> > You are not the first one who has this problem. Another work around is:
> > using boost::python;
> > class_< Foo > foo( "Foo", no_init );
> > scope foo_scope( foo );
> > enum_< ... >...;
> > foo_scope.def( init< ... >( ... ) );
>
> That makes a lot of sense, but that requires modification of Py++,
> doesn't it? Or is there a way to customize code generation to do it the
> way you've cited?
>
> Seems to me if Py++ would always opt for code like that, it would
> already solve quite a few dependency problems.
>
> I would be more then happy to implement this. Could you point me in
> right direction, please?

Yes of course:

code_creators\class_declaration.py - class_t._generate_constructor
It should not be too difficult to change the code.

Next document will help you to understand design\architecture of Py++
http://language-binding.net/pyplusplus/documentation/architecture.html


-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list