[C++-sig] Generation of wrapper for arguments of type T*&

Roman Yakovenko roman.yakovenko at gmail.com
Tue Apr 18 07:11:38 CEST 2006


On 4/18/06, Haridev, Meghana <mharidev at qualcomm.com> wrote:
> Thanks Roman.
>
> Can I make pyplusplus just insert the "manual wrappers" code in the
> generated file? Is there a simple example which illustrates a way in which
> we can just write/insert pieces of code to the generated file?

It is possible, but it still does not have good user interface.
Anyway, please take a look on pyplusplus/file_writers package.
It contains single_file.py and multiple_files.py modules. You can derive from
them and implement custom algorithm for dumping code to files.

> Or do I have to create a different file where I put the code for the "manual
> wrappers" and then make pylusplus include that file in the generated file?

You can do that.

mb = module_builder_t(...)
mb.build_code_creator( module_name="hw" )

my_include =  code_creators.include_t( header=header_file )
mb.code_creator.adopt_include( my_include )

The price you pay is compilation time. This file will be included in
every generated cpp
file.

>
> >    after this you can add
>
> >    .def( "for", &foo )
> >   code to the class, using add_code method
> >   #I assume that you already has module_builder_t class instance
> >   mb = module_builder_t( ... )
> >   #Get declaration of Class_Z class
> >   Class_Z = mb.class_( name="Class_Z" )
> >  #get declaration of function "foo", If "foo" function is overloaded, then
> >  #you can specify additional criteria: argument types
> >   foo = Class_Z.member_function( name="foo" )
> >   foo.exclude()
> >   Class_Z.add_code( 'def( "foo", &foo )' )

> This works for me....but how can I make pyplusplus insert this manual code
> to the generated code? :-)

Yesterday, I did not have access to source code, so the answer was incomplete.
Now I do have.

Class_Z.add_wrapper_code( "your code here" ).

That's all.

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



More information about the Cplusplus-sig mailing list