[C++-sig] Protected destructor compile error

Roman Yakovenko roman.yakovenko at gmail.com
Sat Jun 24 20:43:26 CEST 2006


On 6/24/06, Allen Bierbaum <abierbaum at gmail.com> wrote:
> On 6/23/06, Roman Yakovenko <roman.yakovenko at gmail.com> wrote:
> > On 6/23/06, Allen Bierbaum <abierbaum at gmail.com> wrote:
> > > I could always just try to make some smart wrapper code with
> > > pyplusplus that automatically detects this case and creates a thin
> > > wrapper for me.  (any ideas here Roman?)
> >
> > Actually yes. You have 2 ways to go:
> > 1. Contribute to pyplusplus:
> >     1. Add code to pyplusplus.decl_wrappers.calldef_t.has_wrapper.
> > This code should
> >         "understand", that function takes an argument const reference to
> >         non-destructable object.
> >     2. Add code that generates wrapper code to
> > code_creators/calldef.py relevant
> >         classes.
> >     This is not should be very difficult. If you need more
> > information, please ask on
> >     pyplusplus mailing list.
>
> Sounds interesting but I don't know that code nearly as well as you.  :)

I will guide you :-).

> > 2. Easy and quick.
> >     Build custom small code generator, that will generate function
> > wrapper, for every
> >     function, that takes as argument "const Viewport&". After this, exclude all
> >     original functions and replace them with new functions. This
> > should work and it
> >     should take less then an hour to implement it.
>
> This one sounds more approachable to me right now.  The question I
> have though is how to add the function wrapper code to the generated
> code.  Is this something I can do to the class decl wrapper?  What
> method do I use to add it?  (if you provide pseudo code I can fill in
> all the details and debug it)

struct X{
    void do_smth( const Viewport& );
};

wrapper_code_example = """
static void do_smth( X& x, Viewport& v){
    x.do_smth( v );
};
"""

mb = module_builder_t( ... )
for cls in mb.classes():
    for f in cls.member_functions( function=contains const Viewport& as arg )
        f.exclude()
        #Next code you will have to replace with something that
actually deals with f
        cls.add_wrapper_code ( wrapper_code_example )
        cls.add_code( 'def( "do_smth", &X_wrapper::do_smth )' )

cls.wrapper_alias will give you the name of the generated class wrapper name

code_creators/calldef.py - calldef_wrapper_t.args_declaration will help you
to get idea how to generate function wrapper code

There is another approach. In this approach you don't generate code,  but modify
code creators tree. I can explain you if you are interested.

> Thanks for the quick reply.

My pleasure.



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



More information about the Cplusplus-sig mailing list