[C++-sig] Pyplusplus templates and roadmap

Roman Yakovenko roman.yakovenko at gmail.com
Mon Feb 13 08:36:45 CET 2006

On 2/12/06, Allen Bierbaum <abierbaum at gmail.com> wrote:
> It is very useful and very powerful.  But right now that is a two
> edged sword.  It is so powerful that it is difficult to understand how
> to do simple things.  I agree with the other posters that there should
> probably be a "simple" interface available to do simple things.  I
> think it would be possible to create an interface layer that looks
> similar to the Pyste API and that would allow users to specify only
> the basic details of what they want done and then have it handled
> behind the scenes.
> I need to think about it quite a bit more, but right now I am thinking
> of something like:
> ---------------------------------
> py_module = create_module(['header1.h","header2.h"], working_dir,
> include_paths, symbols, undef_symbols, gccxml_path)
> class1 = py_module.Class("Class1")
> class2 = py_module.Class("Class2")
> func1 = py_module.Func("func1")
> class1.removeMethod("hidden_method")
> class1.setCallPolicy("method1", return_by_value)
> for name in class2.methodNames():
>    if should_be_hidden(name):
>       class2.removeMethod(name)
> py_module.write_file('bindings.cpp')
> py_module.write_multiple_files('.')
> -----------------------------------
> The key ideas of this interface are:
> - Use helper classes to wrap access/finding methods and classes in decls
> - Create helper methods to accomplish common goals
> - Hide decls and filtering inside wrapper classes so users don't need
> to understand all the details of what is happening
> - Allow access to all details if requested (so we don't lose the power
> of pyplusplus)
> I believe that an interface like this could be expanded upon in the
> future to provide a great deal of power while still providing a usable
> interface with the simplicity of a domain specific language.  If while
> wrapping my current project I find an interface like this to be
> helpful I may give a shot at creating this type of wrapper.

I understand. In general you and other users don't want to speak in
"code creators"
language. This is too low level, right. You prefer to speak in
language that is close to you
or your goals:

     [don't] expose this class\function
     rename class\function

It has nothing to to with simple interface files, but rather with
domain specific language.
Now I've got it. Thank you very much. I will try to create some
document, that will
explain what I think should be done, based on your ideas. I am sorry I
did not get it earlier.

> >
> > > - I think the tutorial should also expose a class.  The first thing I
> > > tried to do after reading the tutorial was to expose a class and it
> > > did not work.  (I think I need to use either filters or recursive to
> > > make it work but I haven't figured that out yet).
> >
> > There are so many ways to expose class. If you try to expose class, please
> > use pyplusplus GUI. It has new functionality - generate pyplusplus code.
> > Should be very helpful to you.
> This didn't work.  I extended the tutorial code (see attached) and
> then used the GUI to generate the generator.  It still only exports
> the free function.

I think, I know what the problem is. First of all you find a bug.
Now what it is:

file_configuration = parser.file_configuration_t(

to_be_exported = declarations.filtering.by_location(
                                 , [file_configuration.data] )

You run ui.py from /home/allenb/temp/test_pypp directory and header
file text box you
wrote hello_world.hpp, right?

All declaration locations has full path on them. So when you asked to
filter declarations,
pyplusplus generated code that as input to by_location function transferred
"hello_world.hpp". And this is was the bug. It has been fixed in CVS.

> Agreed.  If I may ask what comment format standard are you going to
> use?  I have had very limited success extracting "good" comments from
> python code in the past and I am interested to learn how other people
> are solving this problem.

I am going manually to write documentation that will explain main concepts
of pyplusplus, tutorials and few examples and what ever needed for
better understanding
of pyplusplus. In my opinion user should refer to generated
documentation only in
case he wants to find\understand some specific property of the class or pre\post
condition of function.

I don't like this idea, but it seems that I don't have a lot of choices.
( There are always some constraints, right? )

> Thanks,
> Allen

Thank you very much.

Roman Yakovenko
C++ Python language binding

More information about the Cplusplus-sig mailing list